Bug 6571 - New Web (DOM) Inspector
Summary: New Web (DOM) Inspector
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P3 Enhancement
Assignee: Timothy Hatcher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-15 16:53 PST by Timothy Hatcher
Modified: 2006-01-15 18:42 PST (History)
0 users

See Also:


Attachments
Inspector Patch (first cut) (160.26 KB, patch)
2006-01-15 16:57 PST, Timothy Hatcher
darin: review+
Details | Formatted Diff | Diff
Images (First Cut) (32.88 KB, application/zip)
2006-01-15 17:01 PST, Timothy Hatcher
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Timothy Hatcher 2006-01-15 16:53:19 PST
Add a DOM inspector that lives in WebKit and is accessible from any WebView.

The inspector should allow the following:
 * View and walk the DOM tree.
 * View serialized HTML from a DOM sub-tree.
 * View CSS rules and computed style for elements.
 * View properties for nodes.
 * View metrics for nodes, including absolute position, parent relative position, padding, margin, etc.
 * Highlight nodes in the WebView.
 * Search for nodes.
Comment 1 Timothy Hatcher 2006-01-15 16:57:40 PST
Created attachment 5707 [details]
Inspector Patch (first cut)

This patch gets the Inspector working and living in WebKit. 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.
Comment 2 Timothy Hatcher 2006-01-15 17:01:59 PST
Created attachment 5708 [details]
Images (First Cut)

Images that go with the first cut patch.
Comment 3 Darin Adler 2006-01-15 17:37:13 PST
Comment on attachment 5707 [details]
Inspector Patch (first cut)

+  scrollIntoViewIfNeeded	DOMElement::ScrollIntoView     
DontDelete|Function 1

Bug on this line. Needs to say DOMElement::ScrollIntoViewIfNeeded.

+	 return rects;
+    } else if(!firstChild())
+	 return QValueList<IntRect>();

No need for else after return. Need space after if.

+    RenderObject *child = firstChild();
+    while (child) {

More elegant to write the above as a for loop.

+	 return IntRect(0,0,0,0);

Should use spaces after commas.

-@interface DOMElement (DOMElementExtensions)
-- (void)focus;
-- (void)blur;
-@end
-
Not good to move public API out of a public header DOMExtensions.h. Should put
the new stuff in a new category temporarily and leave the already-public stuff
public.

Are we going to make this localizable?

+	     return [_private->searchResults count];
+	 else if (!item)
+	     return 1;

No need for else after return.

+	     return [_private->searchResults objectAtIndex:index];
+	 else if (!item)
+	     return _private->rootNode;

Again.

+    DOMNode *currentNode = [node parentNode];
+    while (currentNode) {
+	 if ([self isSameNode:currentNode])
+	     return YES;
+	 currentNode = [currentNode parentNode];
+    }

Above looks like it should be a for loop.

Looks like a great start. At least that very first thing I mentioned should be
fixed before landing, but I'm going to be loose here and say review+. Lets get
that first cut in there!

r=me
Comment 4 Timothy Hatcher 2006-01-15 18:42:39 PST
Modified per the comments from Darin, Eric and Maciej. Committed in r12122.