Bug 148010 - Web Inspector: NavigationBar.updateLayoutSoon should use requestAnimationFrame
Summary: Web Inspector: NavigationBar.updateLayoutSoon should use requestAnimationFrame
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: Matt Baker
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-08-13 18:36 PDT by Matt Baker
Modified: 2015-08-14 21:35 PDT (History)
8 users (show)

See Also:


Attachments
[Patch] Proposed Fix (2.65 KB, patch)
2015-08-14 18:16 PDT, Matt Baker
no flags Details | Formatted Diff | Diff
[Patch] Proposed Fix (2.39 KB, patch)
2015-08-14 19:54 PDT, Matt Baker
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Baker 2015-08-13 18:36:07 PDT
* SUMMARY
NavigationBar.updateLayoutSoon should use requestAnimationFrame. Currently it just uses a simple setTimeout(..., 0).
Comment 1 Radar WebKit Bug Importer 2015-08-13 18:36:19 PDT
<rdar://problem/22281006>
Comment 2 Matt Baker 2015-08-14 18:16:36 PDT
Created attachment 259062 [details]
[Patch] Proposed Fix
Comment 3 Devin Rousso 2015-08-14 18:54:20 PDT
Comment on attachment 259062 [details]
[Patch] Proposed Fix

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

> Source/WebInspectorUI/UserInterface/Views/NavigationBar.js:59
> +        this._updateLayoutIdentifier = 0;

To me, _updateLayoutIdentifier is a bit ambiguous as to what it represents.  _updateLayoutTimeout was clear that it represented a timeout, so maybe use something like _updateLayoutAnimationFrameIdentifier?
Comment 4 Matt Baker 2015-08-14 19:35:46 PDT
(In reply to comment #3)
> Comment on attachment 259062 [details]
> [Patch] Proposed Fix
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=259062&action=review
> 
> > Source/WebInspectorUI/UserInterface/Views/NavigationBar.js:59
> > +        this._updateLayoutIdentifier = 0;
> 
> To me, _updateLayoutIdentifier is a bit ambiguous as to what it represents. 
> _updateLayoutTimeout was clear that it represented a timeout, so maybe use
> something like _updateLayoutAnimationFrameIdentifier?

It's consistent with our other request id variable names. However, we should create an abstraction to encapsulate the boilerplate layout code in Inspector view classes. This would would also address the ambiguity issue.
Comment 5 BJ Burg 2015-08-14 19:36:05 PDT
Comment on attachment 259062 [details]
[Patch] Proposed Fix

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

r=me

>> Source/WebInspectorUI/UserInterface/Views/NavigationBar.js:59
>> +        this._updateLayoutIdentifier = 0;
> 
> To me, _updateLayoutIdentifier is a bit ambiguous as to what it represents.  _updateLayoutTimeout was clear that it represented a timeout, so maybe use something like _updateLayoutAnimationFrameIdentifier?

The existing name, or _scheduledUpdateIdentifier, would be consistent with existing code.

> Source/WebInspectorUI/UserInterface/Views/NavigationBar.js:60
> +        this._needsLayout = false;

Not necessary.

> Source/WebInspectorUI/UserInterface/Views/NavigationBar.js:148
> +            this._updateLayoutIdentifier = 0;

I would assign back to undefined, since the intention is less ambiguous.
Comment 6 Matt Baker 2015-08-14 19:44:40 PDT
(In reply to comment #5)
> Comment on attachment 259062 [details]
> [Patch] Proposed Fix
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=259062&action=review
> 
> r=me
> 
> >> Source/WebInspectorUI/UserInterface/Views/NavigationBar.js:59
> >> +        this._updateLayoutIdentifier = 0;
> > 
> > To me, _updateLayoutIdentifier is a bit ambiguous as to what it represents.  _updateLayoutTimeout was clear that it represented a timeout, so maybe use something like _updateLayoutAnimationFrameIdentifier?
> 
> The existing name, or _scheduledUpdateIdentifier, would be consistent with
> existing code.
> 
> > Source/WebInspectorUI/UserInterface/Views/NavigationBar.js:60
> > +        this._needsLayout = false;
> 
> Not necessary.
> 
> > Source/WebInspectorUI/UserInterface/Views/NavigationBar.js:148
> > +            this._updateLayoutIdentifier = 0;
> 
> I would assign back to undefined, since the intention is less ambiguous.

Zero seems more appropriate, since requestAnimationFrame returns a non-zero value. It looks like we use undefined more than zero currently, and delete this._*Identifier the majority of the time. I'm fine with either, although I prefer zero.
Comment 7 Matt Baker 2015-08-14 19:54:44 PDT
Created attachment 259075 [details]
[Patch] Proposed Fix
Comment 8 WebKit Commit Bot 2015-08-14 20:47:29 PDT
Comment on attachment 259075 [details]
[Patch] Proposed Fix

Clearing flags on attachment: 259075

Committed r188506: <http://trac.webkit.org/changeset/188506>
Comment 9 WebKit Commit Bot 2015-08-14 20:47:34 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 BJ Burg 2015-08-14 21:35:04 PDT
(In reply to comment #6)
>
> > > Source/WebInspectorUI/UserInterface/Views/NavigationBar.js:148
> > > +            this._updateLayoutIdentifier = 0;
> > 
> > I would assign back to undefined, since the intention is less ambiguous.
> 
> Zero seems more appropriate, since requestAnimationFrame returns a non-zero
> value. It looks like we use undefined more than zero currently, and delete
> this._*Identifier the majority of the time. I'm fine with either, although I
> prefer zero.

What I meant was that `= undefined` is a generic replacement for delete, whereas `= 0` only makes sense in some context. So if I read the former, I need to think less about what is being done.