Bug 44311 - Web Inspector: elements dom tree - word wrap toggle
Summary: Web Inspector: elements dom tree - word wrap toggle
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Alexander Pavlov (apavlov)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-19 16:55 PDT by Adam
Modified: 2011-03-10 04:43 PST (History)
8 users (show)

See Also:


Attachments
[IMAGE] Rooted at HTML (108.02 KB, image/png)
2010-08-19 17:04 PDT, Joseph Pecoraro
no flags Details
[IMAGE] Rooted at div#ten (84.58 KB, image/png)
2010-08-19 17:05 PDT, Joseph Pecoraro
no flags Details
[PATCH] Suggested solution (7.54 KB, patch)
2011-03-05 06:28 PST, Alexander Pavlov (apavlov)
pfeldman: review-
Details | Formatted Diff | Diff
[IMAGE] Screenshot of a non-word-wrapped DOM with a context menu displayed (18.31 KB, image/png)
2011-03-05 06:29 PST, Alexander Pavlov (apavlov)
no flags Details
[PATCH] Comments addressed, added revealing of the element's left boundary (if necessary) (7.15 KB, patch)
2011-03-09 04:51 PST, Alexander Pavlov (apavlov)
pfeldman: review-
Details | Formatted Diff | Diff
[PATCH] Comments addressed (8.22 KB, patch)
2011-03-09 06:04 PST, Alexander Pavlov (apavlov)
pfeldman: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam 2010-08-19 16:55:20 PDT
I'd really like to see a toggle switch for turning word-wrap on/off on the DOM tree.  Depending on how deep the tree is, you need a really wide monitor to see everything without it being very cramped.  It would be good if it was an option so be able to turn it off and add a scroll bar.  Otherwise on a deep tree with word-wrap, it's 80% white space and a tall line of text.

It is convenient for shallow trees, it could be annoying to have to keep scrolling half an inch back and forth.  So it should really be optional.
Comment 1 Joseph Pecoraro 2010-08-19 17:04:14 PDT
That may be nice. Note that you can re-root the tree at a given node.
Just double click the node in the breadcrumbs (bottom of the element's
panel). This should help some.
Comment 2 Joseph Pecoraro 2010-08-19 17:04:51 PDT
Created attachment 64912 [details]
[IMAGE] Rooted at HTML
Comment 3 Joseph Pecoraro 2010-08-19 17:05:09 PDT
Created attachment 64913 [details]
[IMAGE] Rooted at div#ten
Comment 4 Adam 2010-08-20 11:37:15 PDT
Sweet, didn't realize that double clicking did that.
Comment 5 Alexander Pavlov (apavlov) 2011-03-05 06:28:39 PST
Created attachment 84861 [details]
[PATCH] Suggested solution

A "Word Wrap" context menu check item will switch between the word-wrapped and non-word-wrapped modes of the DOM display.
Comment 6 Alexander Pavlov (apavlov) 2011-03-05 06:29:46 PST
Created attachment 84862 [details]
[IMAGE] Screenshot of a non-word-wrapped DOM with a context menu displayed
Comment 7 Pavel Feldman 2011-03-06 10:54:48 PST
Comment on attachment 84861 [details]
[PATCH] Suggested solution

View in context: https://bugs.webkit.org/attachment.cgi?id=84861&action=review

Did you check whether revealing element reveals it horizontally Ok?

> Source/WebCore/inspector/front-end/ElementsTreeOutline.js:196
> +        var x = Math.max(Math.min(root.totalOffsetLeft + root.offsetWidth, root.parentElement.totalOffsetLeft + root.parentElement.offsetWidth) - 20, 1);

Could you use wrap / nowrap conditions here and simplify the code? r- for this.
Comment 8 Alexander Pavlov (apavlov) 2011-03-06 11:23:54 PST
(In reply to comment #7)
> (From update of attachment 84861 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=84861&action=review
> 
> Did you check whether revealing element reveals it horizontally Ok?
Good point, I'm pretty sure it only scrolls to the necessary line.

> > Source/WebCore/inspector/front-end/ElementsTreeOutline.js:196
> > +        var x = Math.max(Math.min(root.totalOffsetLeft + root.offsetWidth, root.parentElement.totalOffsetLeft + root.parentElement.offsetWidth) - 20, 1);
> 
> Could you use wrap / nowrap conditions here and simplify the code? r- for this.
This is not about wrap/nowrap. This code constrains the x coordinate to the visible portion of the corresponding list item. I don't see a point in having two similar conditions instead of one -- it clutters the code (especially given that this code is wrap-agnostic at the moment).
Comment 9 Pavel Feldman 2011-03-06 11:29:00 PST
Comment on attachment 84861 [details]
[PATCH] Suggested solution

View in context: https://bugs.webkit.org/attachment.cgi?id=84861&action=review

>>> Source/WebCore/inspector/front-end/ElementsTreeOutline.js:196
>>> +        var x = Math.max(Math.min(root.totalOffsetLeft + root.offsetWidth, root.parentElement.totalOffsetLeft + root.parentElement.offsetWidth) - 20, 1);
>> 
>> Could you use wrap / nowrap conditions here and simplify the code? r- for this.
> 
> This is not about wrap/nowrap. This code constrains the x coordinate to the visible portion of the corresponding list item. I don't see a point in having two similar conditions instead of one -- it clutters the code (especially given that this code is wrap-agnostic at the moment).

Two things concern me:
1) Math.min(root.totalOffsetLeft + root.offsetWidth, root.parentElement.totalOffsetLeft + root.parentElement.offsetWidth)
    So you imply that container can be smaller that the child. Is this related to the scroll? If yes, why not to check explicitly
2) Math.max(, 1) implies we now hit negative numbers

Formula this big is 100 times worse that 5 lines of clean conditional code. It is hard to understand, it is hard to maintain, it is hard not to regress.
Comment 10 Alexander Pavlov (apavlov) 2011-03-09 04:51:49 PST
Created attachment 85161 [details]
[PATCH] Comments addressed, added revealing of the element's left boundary (if necessary)
Comment 11 Pavel Feldman 2011-03-09 05:07:14 PST
Comment on attachment 85161 [details]
[PATCH] Comments addressed, added revealing of the element's left boundary (if necessary)

View in context: https://bugs.webkit.org/attachment.cgi?id=85161&action=review

> Source/WebCore/inspector/front-end/ElementsTreeOutline.js:188
> +        var container = this.element.parentElement;

What is wrong with the native implementation? We should use platform capabilities where possible.

> Source/WebCore/inspector/front-end/ElementsTreeOutline.js:201
> +        // items extend nearly to the right edge of the outer <ol>. However,

You could do:
var scrollContainerElement = this.element.parentElement;
and then leave old code changed to using scrollContainerElement.
Comment 12 Alexander Pavlov (apavlov) 2011-03-09 06:04:38 PST
Created attachment 85168 [details]
[PATCH] Comments addressed
Comment 13 Alexander Pavlov (apavlov) 2011-03-10 04:43:08 PST
Committing to http://svn.webkit.org/repository/webkit/trunk ...
        M       Source/WebCore/ChangeLog
        M       Source/WebCore/English.lproj/localizedStrings.js
        M       Source/WebCore/inspector/front-end/ElementsPanel.js
        M       Source/WebCore/inspector/front-end/ElementsTreeOutline.js
        M       Source/WebCore/inspector/front-end/Settings.js
        M       Source/WebCore/inspector/front-end/inspector.css
Committed r80708