Bug 135995 - Web Inspector: Inspect Element doesn't always highlight the correct element when inspector is closed before inspecting
Summary: Web Inspector: Inspect Element doesn't always highlight the correct element w...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Jonathan Wells
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-08-15 15:21 PDT by Jonathan Wells
Modified: 2014-08-15 17:57 PDT (History)
5 users (show)

See Also:


Attachments
[PATCH] Attempted fix. (2.51 KB, patch)
2014-08-15 15:37 PDT, Jonathan Wells
joepeck: review+
joepeck: commit-queue-
Details | Formatted Diff | Diff
[PATCH] Attempted fix, review feedback. (2.45 KB, patch)
2014-08-15 17:17 PDT, Jonathan Wells
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wells 2014-08-15 15:21:18 PDT
In pages with heavy use of frames, a frame might trigger restore of a selected element after the inspected element has been highlighted.

<rdar://problem/17971908>
Comment 1 Jonathan Wells 2014-08-15 15:37:52 PDT
Created attachment 236682 [details]
[PATCH] Attempted fix.
Comment 2 Joseph Pecoraro 2014-08-15 17:07:53 PDT
Comment on attachment 236682 [details]
[PATCH] Attempted fix.

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

> Source/WebInspectorUI/ChangeLog:11
> +        Change so if an element is inspected, restoreSelectedNodeIsAllowed is set to false
> +        and kept in that state until the main resource changes or is refreshed. This way an
> +        attempt by a frame on a page to restore a node will not change the highlighted
> +        element unexpectedly.

There is a lot of ambiguity in this ChangeLog comment!

How about something like: (emphasis mine and can be removed)

    Change so if an element is inspected *via the Inspect Element context menu*, selected node restoration is disallowed
    until the main resource *in the main frame* changes. This way an attempt by a *sub-frame* will not change the
    highlighted element in the Main Frame's DOM tree unexpectedly.

> Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js:272
> +    _mainResourceDidChange: function(event) {
> +        if (event.target.isMainFrame())
> +            this._restoreSelectedNodeIsAllowed = true;
> +    },

Style: Opening brace should be on its own line
Style: This function should be down at the bottom of this file in the Private section.
Comment 3 Joseph Pecoraro 2014-08-15 17:08:35 PDT
> until the main resource *in the main frame* changes

Can just be until a page navigation / reload.
Comment 4 Jonathan Wells 2014-08-15 17:17:00 PDT
Created attachment 236695 [details]
[PATCH] Attempted fix, review feedback.
Comment 5 WebKit Commit Bot 2014-08-15 17:56:57 PDT
Comment on attachment 236695 [details]
[PATCH] Attempted fix, review feedback.

Clearing flags on attachment: 236695

Committed r172662: <http://trac.webkit.org/changeset/172662>
Comment 6 WebKit Commit Bot 2014-08-15 17:57:00 PDT
All reviewed patches have been landed.  Closing bug.