Bug 30663 - Web Inspector: windowFocused and windowBlured Fail to Clear/Mark Inspector as "inactive"
Summary: Web Inspector: windowFocused and windowBlured Fail to Clear/Mark Inspector as...
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: Joseph Pecoraro
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-21 23:20 PDT by Joseph Pecoraro
Modified: 2009-10-22 14:09 PDT (History)
6 users (show)

See Also:


Attachments
[PATCH] Check document.defaultView (1.28 KB, patch)
2009-10-21 23:24 PDT, Joseph Pecoraro
pfeldman: review+
Details | Formatted Diff | Diff
[PATCH] Handle Focus/Blur of inner <iframe>s (2.44 KB, patch)
2009-10-22 13:35 PDT, Joseph Pecoraro
timothy: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2009-10-21 23:20:24 PDT
The style class "inactive" is not getting added to the body. It is used numerous times in the CSS.
Comment 1 Joseph Pecoraro 2009-10-21 23:24:21 PDT
Created attachment 41639 [details]
[PATCH] Check document.defaultView

The events are registered on a doc.defaultView:

  doc.defaultView.addEventListener("focus", this.windowFocused.bind(this), true);
  doc.defaultView.addEventListener("blur", this.windowBlured.bind(this), true);

The doc.defaultView is a DOMWindow. Old behavior always fails:

  if (event.target.nodeType === Node.DOCUMENT_NODE)

New behavior tests against the defaultView:

  if (event.target === document.defaultView)
Comment 2 Joseph Pecoraro 2009-10-21 23:38:14 PDT
NOTE TO SELF: the function should be renamed to "windowBlurred" to fix the typo.
Comment 3 Pavel Feldman 2009-10-22 07:41:14 PDT
Comment on attachment 41639 [details]
[PATCH] Check document.defaultView

Fix the Reviewed by :P.
Comment 4 Joseph Pecoraro 2009-10-22 08:29:31 PDT
Landed in http://trac.webkit.org/changeset/49939
r49939 = 4a2c682da0e4de665ca85ef024415a8bdaf830b0
Comment 5 Timothy Hatcher 2009-10-22 08:56:01 PDT
Comment on attachment 41639 [details]
[PATCH] Check document.defaultView

The WebInspector.windowFocused and WebInspector.windowBlured functions are registered on iframes too.

So this will break break for iframes. Try clicking in a Resource source frame, the Inspector should not become "inactive" then.

SourceFrame.js _loaded calls:

        WebInspector.addMainEventListeners(this.element.contentDocument);
Comment 6 Timothy Hatcher 2009-10-22 08:57:02 PDT
Maybe you were seeing it fire twice because you were testing with a source frame?
Comment 7 Joseph Pecoraro 2009-10-22 13:35:58 PDT
Created attachment 41680 [details]
[PATCH] Handle Focus/Blur of inner <iframe>s

Because focus/blur do not tell you _what_ they are focusing on there has to be a bit of co-dependence between the focus/blur:

- Blur runs first, if you're blurring any inner document, always add "inactive"
- Focus runs next, if you're focusing on any inner document, remove "inactive"

Changing useCapture to false no longer fires duplicate blur/focus events.  This was happening when clicking a toolbar (when they were in their :active state). Could be a bug in itself, and may require some investigation.
Comment 8 Joseph Pecoraro 2009-10-22 13:39:22 PDT
(In reply to comment #7)
> Changing useCapture to false no longer fires duplicate blur/focus events.

Oh, this also makes it so event.target is what we expect it to be (doc.defaultView a DOMWindow) so the following should never blow up with an undefined for document:

  event.target.document.nodeType
Comment 9 Joseph Pecoraro 2009-10-22 14:09:31 PDT
Landed Second Patch in http://trac.webkit.org/changeset/49956
r49956 = 3ba0b1d4a6414ecd8dc61d94fe35153b36c04eae