Skip to content
Permalink
Browse files
WebCore:
        Reviewed by Darin.

        Support for the new DOM Inspector.

        * khtml/ecma/kjs_dom.cpp: exposes scrollIntoViewIfNeeded to JS
        * khtml/ecma/kjs_dom.h:
        * khtml/rendering/RenderText.cpp:
        (RenderText::lineBoxRects): returns text run rects
        * khtml/rendering/RenderText.h:
        * khtml/rendering/render_container.cpp:
        (RenderContainer::lineBoxRects): returns all child line box rects
        * khtml/rendering/render_container.h:
        * khtml/rendering/render_object.cpp:
        (RenderObject::lineBoxRects): returns an empty list
        * khtml/rendering/render_object.h:
        * khtml/xml/dom_elementimpl.cpp:
        (ElementImpl::scrollIntoViewIfNeeded): scrolls only if needed, bool decides to center to align to nearest edge
        * khtml/xml/dom_elementimpl.h: Ditto
        * kwq/DOM.mm:
        (-[DOMNode boundingBox]): returns the bounding box for a node
        (-[DOMNode lineBoxRects]): returns text runs for a node
        * kwq/DOMCore.h: added missing @protocol DOMEventListener and @Class DOMEvent
        * kwq/DOMExtensions.h: removes methods that haven't been API reviewed
        * kwq/DOMPrivate.h: new pending public API added for the Inspector

WebKit:

        Reviewed by Darin.

        New DOM Inspector that lives in WebKit and is accessible from any WebView.
        Accessible from a contextual menu when the WebKitEnableInspectElementContextMenuItem default is
        true or you have a development build. Browsing the tree, serialized HTML and CSS rules work.

        To always enable enter the following in the Terminal (change the bundle id to affect other WebKit apps):
        defaults write com.apple.Safari WebKitEnableInspectElementContextMenuItem -bool true

        http://bugzilla.opendarwin.org/show_bug.cgi?id=6571

        * English.lproj/Localizable.strings:
        * English.lproj/StringsNotToBeLocalized.txt: reorder of the entries
        * Misc.subproj/WebKitNSStringExtras.h:
        * Misc.subproj/WebKitNSStringExtras.m:
        (-[NSString _webkit_stringByCollapsingWhitespaceCharacters]): collapses consecutive whitespace into a single space
        * WebCoreSupport.subproj/WebFrameBridge.m:
        (-[WebFrameBridge pluginViewWithPackage:attributeNames:attributeValues:baseURL:]): cleanup
        (-[WebFrameBridge viewForPluginWithURL:attributeNames:attributeValues:MIMEType:]): call the new UI delegate method
        * WebInspector.subproj: Added.
        * WebInspector.subproj/WebInspector.h: Added.
        * WebInspector.subproj/WebInspector.m: Added.
        (+[WebInspector sharedWebInspector]):
        (-[WebInspector init]):
        (-[WebInspector initWithWebFrame:]):
        (-[WebInspector dealloc]):
        (-[WebInspector window]):
        (-[WebInspector windowDidLoad]):
        (-[WebInspector windowWillClose:]):
        (-[WebInspector showWindow:]):
        (-[WebInspector setWebFrame:]):
        (-[WebInspector webFrame]):
        (-[WebInspector setRootDOMNode:]):
        (-[WebInspector rootDOMNode]):
        (-[WebInspector setFocusedDOMNode:]):
        (-[WebInspector focusedDOMNode]):
        (-[WebInspector setSearchQuery:]):
        (-[WebInspector searchQuery]):
        (-[WebInspector searchResults]):
        (-[WebInspector showOptionsMenu]):
        (-[WebInspector selectNewRoot:]):
        (-[WebInspector resizeTopArea:]):
        (-[WebInspector treeViewScrollTo:]):
        (-[WebInspector treeViewOffsetTop]):
        (-[WebInspector treeViewScrollHeight]):
        (-[WebInspector traverseTreeBackward]):
        (-[WebInspector traverseTreeForward]):
        (-[WebInspector _toggleIgnoreWhitespace:]):
        (-[WebInspector _highlightNode:]):
        (-[WebInspector _nodeHighlightExpired:]):
        (-[WebInspector _focusRootNode:]):
        (-[WebInspector _revealAndSelectNodeInTree:]):
        (-[WebInspector _showSearchResults:]):
        (-[WebInspector _refreshSearch]):
        (-[WebInspector _update]):
        (-[WebInspector _updateRoot]):
        (-[WebInspector _updateTreeScrollbar]):
        (+[WebInspector isSelectorExcludedFromWebScript:]):
        (+[WebInspector webScriptNameForSelector:]):
        (+[WebInspector isKeyExcludedFromWebScript:]):
        (-[WebInspector handleEvent:]):
        (-[WebInspector webView:didFinishLoadForFrame:]):
        (-[WebInspector webView:plugInViewWithArguments:]):
        (-[WebInspector outlineView:numberOfChildrenOfItem:]):
        (-[WebInspector outlineView:isItemExpandable:]):
        (-[WebInspector outlineView🧒ofItem:]):
        (-[WebInspector outlineView:objectValueForTableColumn:byItem:]):
        (-[WebInspector outlineView:willDisplayOutlineCell:forTableColumn:item:]):
        (-[WebInspector outlineViewItemDidCollapse:]):
        (-[WebInspector outlineViewSelectionDidChange:]):
        (-[WebInspectorPrivate dealloc]):
        (-[DOMHTMLElement _addClassName:]): Helper method for the Inspector to append style classes
        (-[DOMHTMLElement _removeClassName:]): Helper method for the Inspector to remove style classes
        (-[DOMNode _contentPreview]):
        (-[DOMNode _isAncestorOfNode:]):
        (-[DOMNode _isDescendantOfNode:]):
        (-[DOMNode _isWhitespace]):
        (-[DOMNode _lengthOfChildNodesIgnoringWhitespace]):
        (-[DOMNode _childNodeAtIndexIgnoringWhitespace:]):
        (-[DOMNode _nextSiblingSkippingWhitespace]):
        (-[DOMNode _previousSiblingSkippingWhitespace]):
        (-[DOMNode _firstChildSkippingWhitespace]):
        (-[DOMNode _lastChildSkippingWhitespace]):
        (-[DOMNode _firstAncestorCommonWithNode:]):
        (-[DOMNode _traverseNextNodeStayingWithin:]):
        (-[DOMNode _traverseNextNodeSkippingWhitespaceStayingWithin:]):
        (-[DOMNode _traversePreviousNode]):
        (-[DOMNode _traversePreviousNodeSkippingWhitespace]):
        (-[DOMNode _nodeTypeName]):
        (-[DOMNode _shortDisplayName]):
        (-[DOMNode _displayName]):
        * WebInspector.subproj/WebInspectorInternal.h: Added.
        * WebInspector.subproj/WebInspectorOutlineView.h: Added.
        * WebInspector.subproj/WebInspectorOutlineView.m: Added.
        (-[WebInspectorOutlineView isOpaque]):
        (-[WebInspectorOutlineView _highlightColorForCell:]):
        (-[WebInspectorOutlineView _highlightRow:clipRect:]):
        (-[WebInspectorOutlineView drawBackgroundInClipRect:]):
        * WebInspector.subproj/WebInspectorPanel.h: Added.
        * WebInspector.subproj/WebInspectorPanel.m: Added.
        (-[WebInspectorPanel canBecomeKeyWindow]):
        (-[WebInspectorPanel canBecomeMainWindow]):
        (-[WebInspectorPanel moveWindow:]):
        (-[WebInspectorPanel resizeWindow:]):
        (-[WebInspectorPanel sendEvent:]):
        * WebInspector.subproj/WebNodeHighlight.h: Added.
        * WebInspector.subproj/WebNodeHighlight.m: Added.
        (-[WebNodeHighlight initWithBounds:andRects:forView:]):
        (-[WebNodeHighlight dealloc]):
        (-[WebNodeHighlight fractionComplete]):
        (-[WebNodeHighlight expire]):
        (-[WebNodeHighlight redraw:]):
        * WebInspector.subproj/WebNodeHighlightView.h: Added.
        * WebInspector.subproj/WebNodeHighlightView.m: Added.
        (-[WebNodeHighlightView roundedRect:withRadius:]):
        (-[WebNodeHighlightView initWithHighlight:andRects:forView:]):
        (-[WebNodeHighlightView dealloc]):
        (-[WebNodeHighlightView isOpaque]):
        (-[WebNodeHighlightView drawRect:]):
        * WebInspector.subproj/webInspector: Added.
        * WebInspector.subproj/webInspector/Images: Added.
        * WebInspector.subproj/webInspector/Images/close.png: Added.
        * WebInspector.subproj/webInspector/Images/closePressed.png: Added.
        * WebInspector.subproj/webInspector/Images/downTriangle.png: Added.
        * WebInspector.subproj/webInspector/Images/menu.png: Added.
        * WebInspector.subproj/webInspector/Images/menuPressed.png: Added.
        * WebInspector.subproj/webInspector/Images/popupFill.png: Added.
        * WebInspector.subproj/webInspector/Images/popupFillPressed.png: Added.
        * WebInspector.subproj/webInspector/Images/popupLeft.png: Added.
        * WebInspector.subproj/webInspector/Images/popupLeftPressed.png: Added.
        * WebInspector.subproj/webInspector/Images/popupRight.png: Added.
        * WebInspector.subproj/webInspector/Images/popupRightPressed.png: Added.
        * WebInspector.subproj/webInspector/Images/rightTriangle.png: Added.
        * WebInspector.subproj/webInspector/Images/scrollThumbBottom.png: Added.
        * WebInspector.subproj/webInspector/Images/scrollThumbMiddle.png: Added.
        * WebInspector.subproj/webInspector/Images/scrollThumbTop.png: Added.
        * WebInspector.subproj/webInspector/Images/scrollTrackBottom.png: Added.
        * WebInspector.subproj/webInspector/Images/scrollTrackMiddle.png: Added.
        * WebInspector.subproj/webInspector/Images/scrollTrackTop.png: Added.
        * WebInspector.subproj/webInspector/Images/squareButtonRight.png: Added.
        * WebInspector.subproj/webInspector/Images/squareButtonRightPressed.png: Added.
        * WebInspector.subproj/webInspector/Images/upTriangle.png: Added.
        * WebInspector.subproj/webInspector/inspector.css: Added.
        * WebInspector.subproj/webInspector/inspector.html: Added.
        * WebInspector.subproj/webInspector/inspector.js: Added.
        * WebKit.xcodeproj/project.pbxproj: Adds Web Inspector files
        * WebView.subproj/WebUIDelegatePrivate.h: new UI delegate method to supply a replacement view for plugins
        * WebView.subproj/WebView.m:
        (-[WebView _menuForElement:defaultItems:]): Add a new context menu item for inspecting
        (-[WebView _inspectElement:]): Context menu item target for inspecting



Canonical link: https://commits.webkit.org/10176@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@12122 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
xeenon committed Jan 16, 2006
1 parent f58bc02 commit 111d96a98b4814019c7d733cb400cd736e413952
Showing 59 changed files with 3,928 additions and 18 deletions.
@@ -1,3 +1,30 @@
2006-01-15 Timothy Hatcher <timothy@apple.com>

Reviewed by Darin.

Support for the new DOM Inspector.

* khtml/ecma/kjs_dom.cpp: exposes scrollIntoViewIfNeeded to JS
* khtml/ecma/kjs_dom.h:
* khtml/rendering/RenderText.cpp:
(RenderText::lineBoxRects): returns text run rects
* khtml/rendering/RenderText.h:
* khtml/rendering/render_container.cpp:
(RenderContainer::lineBoxRects): returns all child line box rects
* khtml/rendering/render_container.h:
* khtml/rendering/render_object.cpp:
(RenderObject::lineBoxRects): returns an empty list
* khtml/rendering/render_object.h:
* khtml/xml/dom_elementimpl.cpp:
(ElementImpl::scrollIntoViewIfNeeded): scrolls only if needed, bool decides to center to align to nearest edge
* khtml/xml/dom_elementimpl.h: Ditto
* kwq/DOM.mm:
(-[DOMNode boundingBox]): returns the bounding box for a node
(-[DOMNode lineBoxRects]): returns text runs for a node
* kwq/DOMCore.h: added missing @protocol DOMEventListener and @class DOMEvent
* kwq/DOMExtensions.h: removes methods that haven't been API reviewed
* kwq/DOMPrivate.h: new pending public API added for the Inspector

2006-01-15 Darin Adler <darin@apple.com>

Reviewed by Eric.
@@ -1110,6 +1110,7 @@ JSValue *DOMDocumentProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj
getElementsByTagNameNS DOMElement::GetElementsByTagNameNS DontDelete|Function 2
hasAttributeNS DOMElement::HasAttributeNS DontDelete|Function 2
scrollIntoView DOMElement::ScrollIntoView DontDelete|Function 1
scrollIntoViewIfNeeded DOMElement::ScrollIntoViewIfNeeded DontDelete|Function 1
focus DOMElement::ElementFocus DontDelete|Function 0
blur DOMElement::ElementBlur DontDelete|Function 0
@@ -1243,6 +1244,9 @@ JSValue *DOMElementProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj,
case DOMElement::ScrollIntoView:
element.scrollIntoView(args[0]->isUndefinedOrNull() || args[0]->toBoolean(exec));
return jsUndefined();
case DOMElement::ScrollIntoViewIfNeeded:
element.scrollIntoViewIfNeeded(args[0]->isUndefinedOrNull() || args[0]->toBoolean(exec));
return jsUndefined();
case DOMElement::ScrollByLines:
case DOMElement::ScrollByPages:
if (DocumentImpl* doc = element.getDocument()) {
@@ -77,7 +77,8 @@ namespace KJS {
OnMouseMove, OnMouseOut, OnMouseOver, OnMouseUp, OnMouseWheel, OnMove, OnReset,
OnResize, OnScroll, OnSearch, OnSelect, OnSubmit, OnUnload,
OffsetLeft, OffsetTop, OffsetWidth, OffsetHeight, OffsetParent,
ClientWidth, ClientHeight, ScrollLeft, ScrollTop, ScrollWidth, ScrollHeight, ScrollIntoView };
ClientWidth, ClientHeight, ScrollLeft, ScrollTop, ScrollWidth, ScrollHeight,
ScrollIntoView, ScrollIntoViewIfNeeded };

protected:
// Constructor for inherited classes; doesn't set up a prototype.
@@ -211,6 +211,15 @@ void RenderText::absoluteRects(QValueList<IntRect>& rects, int _tx, int _ty)
box->height()));
}

QValueList<IntRect> RenderText::lineBoxRects()
{
QValueList<IntRect> rects;
int x = 0, y = 0;
absolutePosition(x, y);
absoluteRects(rects, x, y);
return rects;
}

InlineTextBox* RenderText::findNextInlineTextBox(int offset, int &pos) const
{
// The text runs point to parts of the rendertext's str string
@@ -80,6 +80,7 @@ class RenderText : public RenderObject
HitTestAction hitTestAction) { assert(false); return false; }

virtual void absoluteRects(QValueList<IntRect>& rects, int _tx, int _ty);
virtual QValueList<IntRect> RenderText::lineBoxRects();

virtual VisiblePosition positionForCoordinates(int x, int y);

@@ -490,5 +490,30 @@ VisiblePosition RenderContainer::positionForCoordinates(int _x, int _y)

return VisiblePosition(element(), 0, DOWNSTREAM);
}


QValueList<IntRect> RenderContainer::lineBoxRects()
{
if (!firstChild() && (isInline() || isAnonymousBlock())) {
QValueList<IntRect> rects;
int x = 0, y = 0;
absolutePosition(x, y);
absoluteRects(rects, x, y);
return rects;
}

if (!firstChild())
return QValueList<IntRect>();

QValueList<IntRect> rects;
for (RenderObject *child = firstChild(); child; child = child->nextSibling()) {
if (child->isText() || child->isInline() || child->isAnonymousBlock()) {
int x = 0, y = 0;
child->absolutePosition(x, y);
child->absoluteRects(rects, x, y);
}
}

return rects;
}

#undef DEBUG_LAYOUT
@@ -63,6 +63,8 @@ class RenderContainer : public RenderBox
void updatePseudoChild(RenderStyle::PseudoId type, RenderObject* child);

virtual VisiblePosition positionForCoordinates(int x, int y);

virtual QValueList<IntRect> lineBoxRects();

protected:
void setFirstChild(RenderObject *first) { m_first = first; }
@@ -1271,6 +1271,11 @@ void RenderObject::paintBorder(QPainter *p, int _tx, int _ty, int w, int h, cons
p->restore(); // Undo the clip.
}

QValueList<IntRect> RenderObject::lineBoxRects()
{
return QValueList<IntRect>();
}

void RenderObject::absoluteRects(QValueList<IntRect>& rects, int _tx, int _ty)
{
// For blocks inside inlines, we go ahead and include margins so that we run right up to the
@@ -1293,7 +1298,10 @@ IntRect RenderObject::absoluteBoundingBoxRect()
absolutePosition(x, y);
QValueList<IntRect> rects;
absoluteRects(rects, x, y);


if (rects.isEmpty())
return IntRect(0, 0, 0, 0);

QValueList<IntRect>::ConstIterator it = rects.begin();
IntRect result = *it;
while (++it != rects.end()) {
@@ -671,6 +671,8 @@ class RenderObject : public CachedObjectClient
virtual int borderLeft() const { return style()->borderLeftWidth(); }
virtual int borderRight() const { return style()->borderRightWidth(); }

virtual QValueList<IntRect> lineBoxRects();

virtual void absoluteRects(QValueList<IntRect>& rects, int _tx, int _ty);
IntRect absoluteBoundingBoxRect();

@@ -361,6 +361,17 @@ void ElementImpl::scrollIntoView(bool alignToTop)
}
}

void ElementImpl::scrollIntoViewIfNeeded(bool centerIfNeeded)
{
IntRect bounds = this->getRect();
if (m_render) {
if (centerIfNeeded)
m_render->enclosingLayer()->scrollRectToVisible(bounds, RenderLayer::gAlignCenterIfNeeded, RenderLayer::gAlignCenterIfNeeded);
else
m_render->enclosingLayer()->scrollRectToVisible(bounds, RenderLayer::gAlignToEdgeIfNeeded, RenderLayer::gAlignToEdgeIfNeeded);
}
}

const AtomicString& ElementImpl::getAttributeNS(const DOMString &namespaceURI,
const DOMString &localName) const
{
@@ -194,7 +194,8 @@ class ElementImpl : public ContainerNodeImpl
void setAttributeNS(const DOMString &namespaceURI, const DOMString &qualifiedName, const DOMString &value, int &exception);

void scrollIntoView (bool alignToTop);

void scrollIntoViewIfNeeded(bool centerIfNeeded);

void removeAttribute(const DOMString &name, int &exception) { removeAttributeNS(DOMString(), name, exception); }
void removeAttributeNS(const DOMString &namespaceURI, const DOMString &localName, int &exception);

@@ -404,6 +404,29 @@ - (BOOL)dispatchEvent:(DOMEvent *)event
return result;
}

- (NSRect)boundingBox
{
khtml::RenderObject *renderer = [self _nodeImpl]->renderer();
if (renderer)
return renderer->absoluteBoundingBoxRect();
return NSZeroRect;
}

- (NSArray *)lineBoxRects
{
khtml::RenderObject *renderer = [self _nodeImpl]->renderer();
if (renderer) {
NSMutableArray *results = [[NSMutableArray alloc] init];
QValueList<IntRect> rects = renderer->lineBoxRects();
if (!rects.isEmpty()) {
for (QValueList<IntRect>::ConstIterator it = rects.begin(); it != rects.end(); ++it)
[results addObject:[NSValue valueWithRect:*it]];
}
return [results autorelease];
}
return nil;
}

@end

@implementation DOMNode (WebCoreInternal)
@@ -1436,6 +1459,16 @@ - (void)blur
[self _elementImpl]->blur();
}

- (void)scrollIntoView:(BOOL)alignTop
{
[self _elementImpl]->scrollIntoView(alignTop);
}

- (void)scrollIntoViewIfNeeded:(BOOL)centerIfNeeded
{
[self _elementImpl]->scrollIntoViewIfNeeded(centerIfNeeded);
}

@end

@implementation DOMElement (WebCoreInternal)
@@ -32,7 +32,9 @@
@class DOMElement;
@class DOMNamedNodeMap;
@class DOMNodeList;
@class DOMEvent;

@protocol DOMEventListener;
@protocol DOMEventTarget;

typedef struct DOMObjectInternal DOMObjectInternal;
@@ -32,11 +32,6 @@
- (DOMCSSStyleDeclaration *)createCSSStyleDeclaration;
@end

@interface DOMElement (DOMElementExtensions)
- (void)focus;
- (void)blur;
@end

@interface DOMHTMLElement (DOMHTMLElementExtensions)
- (NSString *)innerHTML;
- (void)setInnerHTML:(NSString *)innerHTML;
@@ -89,6 +89,28 @@
- (NSString *)getPropertyShorthand:(NSString *)propertyName;
- (BOOL)isPropertyImplicit:(NSString *)propertyName;
@end

@interface DOMNode (DOMNodePendingPublic)
- (BOOL)isSameNode:(DOMNode *) other;
- (BOOL)isEqualNode:(DOMNode *) other;

- (NSRect)boundingBox;
- (NSArray *)lineBoxRects;

- (NSString *)textContent;
- (void)setTextContent:(NSString *)text;

- (void)addEventListener:(NSString *)type :(id <DOMEventListener>)listener :(BOOL)useCapture;
- (void)removeEventListener:(NSString *)type :(id <DOMEventListener>)listener :(BOOL)useCapture;
- (BOOL)dispatchEvent:(DOMEvent *)event;
@end

@interface DOMElement (DOMElementExtensions)
- (void)focus;
- (void)blur;
- (void)scrollIntoView:(BOOL)alignTop;
- (void)scrollIntoViewIfNeeded:(BOOL)centerIfNeeded;
@end
// END

// Pending DOM3 APIs

0 comments on commit 111d96a

Please sign in to comment.