Bug 12054 - Ability to serialize an element subtree (into clipboard?) from the DOM inspector
Summary: Ability to serialize an element subtree (into clipboard?) from the DOM inspector
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 420+
Hardware: All All
: P2 Enhancement
Assignee: Timothy Hatcher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-31 20:03 PST by Eric Seidel (no email)
Modified: 2007-11-10 16:57 PST (History)
2 users (show)

See Also:


Attachments
Patch (4.73 KB, patch)
2007-11-09 23:54 PST, Timothy Hatcher
no flags Details | Formatted Diff | Diff
Patch (4.73 KB, patch)
2007-11-09 23:54 PST, Timothy Hatcher
mrowe: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2006-12-31 20:03:14 PST
Ability to serialize an element subtree (into clipboard?) from the DOM inspector

This would be very useful when debugging SVGs.  if a piece is not rendering (especially when it's rendered by javascript), the ability to just select that piece and serialize it to the clipboard would be very useful.  Then I can paste it into a new file and debug.
Comment 1 Timothy Hatcher 2007-11-09 23:54:32 PST
Created attachment 17165 [details]
Patch
Comment 2 Timothy Hatcher 2007-11-09 23:54:32 PST
Created attachment 17166 [details]
Patch
Comment 3 Mark Rowe (bdash) 2007-11-10 00:00:33 PST
Comment on attachment 17166 [details]
Patch

r=me with the comment clarification Alexey mentioned in #webkit.
Comment 4 Adam Roben (:aroben) 2007-11-10 00:03:21 PST
Comment on attachment 17166 [details]
Patch

+          and it's subtree is copied to the clipboard. If the node has no

Typo: it's -> its

+        var data = this.focusedDOMNode.outerHTML;
+        if (!data)
+            data = this.focusedDOMNode.nodeValue;

You should be able to use || for this.

+    if (this.currentFocusElement.handleCopyEvent)
+        event.preventDefault();
+    else if (this.currentFocusElement.id && this.currentFocusElement.id.length && WebInspector[this.currentFocusElement.id + "Copy"])
+        event.preventDefault();

I think this would be clearer with || instead of else if, though I suppose this way the code is more similar to documentCopy.

r=me
Comment 5 Timothy Hatcher 2007-11-10 00:06:36 PST
Landed in r27663. http://trac.webkit.org/projects/webkit/changeset/27663
Comment 6 Alexey Proskuryakov 2007-11-10 13:10:06 PST
I've been playing with this feature to see if it lets one copy text from password fields (it apparently doesn't), and noticed a quirk - copying via a context menu gives different results than copying via a keyboard shortcut. E.g. when copying an input element from the tree, I just get "input".
Comment 7 Timothy Hatcher 2007-11-10 13:14:50 PST
Right clicking selects the word under the mouse. And since there is a selection, we allow the normal copy path. I guess we should make this smarter somehow, but it will be tricky.
Comment 8 Timothy Hatcher 2007-11-10 16:57:23 PST
The word being selected on right-click is actually in the breadcrumb, not right under the mouse!