Title: [222416] trunk/Source/WebInspectorUI
- Revision
- 222416
- Author
- [email protected]
- Date
- 2017-09-22 17:27:38 -0700 (Fri, 22 Sep 2017)
Log Message
Web Inspector: View should automatically layout when it becomes attached to the DOM
https://bugs.webkit.org/show_bug.cgi?id=177189
Reviewed by Devin Rousso.
This guarantees that a layout is always scheduled as soon as a view is
attached to the DOM. Now that nearly all views are created lazily, it
is safe to make this change even without having a visibility concept in
the View class that would prevent layouts for background views.
* UserInterface/Views/View.js:
(WI.View):
Remove `this._needsLayoutWhenAttachedToRoot` flag, which is now implicit.
This was set if a layout was requested before the view had been attached
to the DOM.
(WI.View.prototype.get element):
(WI.View.prototype.get layoutPending):
(WI.View.prototype.get parentView):
(WI.View.prototype.get subviews):
(WI.View.prototype.get isAttached):
(WI.View.prototype.insertSubviewBefore):
(WI.View.prototype.removeSubview):
(WI.View.prototype.removeAllSubviews):
(WI.View.prototype.attached):
(WI.View.prototype.detached):
Hooks for subclasses to define behavior added or removed from the DOM.
(WI.View.prototype._didMoveToParent):
(WI.View.prototype._didMoveToWindow):
(WI.View._scheduleLayoutForView):
(WI.View.prototype.didMoveToWindow): Deleted.
(WI.View.prototype.didMoveToParent): Deleted.
These were only used by View, and have been made private.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (222415 => 222416)
--- trunk/Source/WebInspectorUI/ChangeLog 2017-09-23 00:08:19 UTC (rev 222415)
+++ trunk/Source/WebInspectorUI/ChangeLog 2017-09-23 00:27:38 UTC (rev 222416)
@@ -1,3 +1,39 @@
+2017-09-22 Matt Baker <[email protected]>
+
+ Web Inspector: View should automatically layout when it becomes attached to the DOM
+ https://bugs.webkit.org/show_bug.cgi?id=177189
+
+ Reviewed by Devin Rousso.
+
+ This guarantees that a layout is always scheduled as soon as a view is
+ attached to the DOM. Now that nearly all views are created lazily, it
+ is safe to make this change even without having a visibility concept in
+ the View class that would prevent layouts for background views.
+
+ * UserInterface/Views/View.js:
+ (WI.View):
+ Remove `this._needsLayoutWhenAttachedToRoot` flag, which is now implicit.
+ This was set if a layout was requested before the view had been attached
+ to the DOM.
+
+ (WI.View.prototype.get element):
+ (WI.View.prototype.get layoutPending):
+ (WI.View.prototype.get parentView):
+ (WI.View.prototype.get subviews):
+ (WI.View.prototype.get isAttached):
+ (WI.View.prototype.insertSubviewBefore):
+ (WI.View.prototype.removeSubview):
+ (WI.View.prototype.removeAllSubviews):
+ (WI.View.prototype.attached):
+ (WI.View.prototype.detached):
+ Hooks for subclasses to define behavior added or removed from the DOM.
+ (WI.View.prototype._didMoveToParent):
+ (WI.View.prototype._didMoveToWindow):
+ (WI.View._scheduleLayoutForView):
+ (WI.View.prototype.didMoveToWindow): Deleted.
+ (WI.View.prototype.didMoveToParent): Deleted.
+ These were only used by View, and have been made private.
+
2017-09-22 Nikita Vasilyev <[email protected]>
Web Inspector: Styles Redesign: support toggling properties
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/View.js (222415 => 222416)
--- trunk/Source/WebInspectorUI/UserInterface/Views/View.js 2017-09-23 00:08:19 UTC (rev 222415)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/View.js 2017-09-23 00:27:38 UTC (rev 222416)
@@ -35,7 +35,6 @@
this._subviews = [];
this._dirty = false;
this._dirtyDescendantsCount = 0;
- this._needsLayoutWhenAttachedToRoot = false;
this._isAttachedToRoot = false;
this._layoutReason = null;
this._didInitialLayout = false;
@@ -53,26 +52,12 @@
// Public
- get element()
- {
- return this._element;
- }
+ get element() { return this._element; }
+ get layoutPending() { return this._dirty; }
+ get parentView() { return this._parentView; }
+ get subviews() { return this._subviews; }
+ get isAttached() { return this._isAttachedToRoot; }
- get layoutPending()
- {
- return this._dirty;
- }
-
- get parentView()
- {
- return this._parentView;
- }
-
- get subviews()
- {
- return this._subviews;
- }
-
isDescendantOf(view)
{
let parentView = this._parentView;
@@ -112,7 +97,7 @@
if (!view.element.parentNode)
this._element.insertBefore(view.element, referenceView ? referenceView.element : null);
- view.didMoveToParent(this);
+ view._didMoveToParent(this);
}
removeSubview(view)
@@ -129,13 +114,13 @@
this._subviews.splice(index, 1);
this._element.removeChild(view.element);
- view.didMoveToParent(null);
+ view._didMoveToParent(null);
}
removeAllSubviews()
{
for (let subview of this._subviews)
- subview.didMoveToParent(null);
+ subview._didMoveToParent(null);
this._subviews = [];
this._element.removeChildren();
@@ -185,38 +170,14 @@
get layoutReason() { return this._layoutReason; }
get didInitialLayout() { return this._didInitialLayout; }
- didMoveToWindow(isAttachedToRoot)
+ attached()
{
- this._isAttachedToRoot = isAttachedToRoot;
-
- if (this._isAttachedToRoot && this._needsLayoutWhenAttachedToRoot) {
- WI.View._scheduleLayoutForView(this);
- this._needsLayoutWhenAttachedToRoot = false;
- }
-
- for (let view of this._subviews)
- view.didMoveToWindow(isAttachedToRoot);
+ // Implemented by subclasses.
}
- didMoveToParent(parentView)
+ detached()
{
- this._parentView = parentView;
-
- let isAttachedToRoot = this.isDescendantOf(WI.View._rootView);
- this.didMoveToWindow(isAttachedToRoot);
-
- if (!this._parentView)
- return;
-
- let pendingLayoutsCount = this._dirtyDescendantsCount;
- if (this._dirty)
- pendingLayoutsCount++;
-
- let view = this._parentView;
- while (view) {
- view._dirtyDescendantsCount += pendingLayoutsCount;
- view = view.parentView;
- }
+ // Implemented by subclasses.
}
initialLayout()
@@ -245,6 +206,43 @@
// Private
+ _didMoveToParent(parentView)
+ {
+ this._parentView = parentView;
+
+ let isAttachedToRoot = this.isDescendantOf(WI.View._rootView);
+ this._didMoveToWindow(isAttachedToRoot);
+
+ if (!this._parentView)
+ return;
+
+ let pendingLayoutsCount = this._dirtyDescendantsCount;
+ if (this._dirty)
+ pendingLayoutsCount++;
+
+ let view = this._parentView;
+ while (view) {
+ view._dirtyDescendantsCount += pendingLayoutsCount;
+ view = view.parentView;
+ }
+ }
+
+ _didMoveToWindow(isAttachedToRoot)
+ {
+ if (this._isAttachedToRoot === isAttachedToRoot)
+ return;
+
+ this._isAttachedToRoot = isAttachedToRoot;
+ if (this._isAttachedToRoot) {
+ this.attached();
+ WI.View._scheduleLayoutForView(this);
+ } else
+ this.detached();
+
+ for (let view of this._subviews)
+ view._didMoveToWindow(isAttachedToRoot);
+ }
+
_layoutSubtree()
{
this._dirty = false;
@@ -309,12 +307,8 @@
parentView = parentView.parentView;
}
- if (!view._isAttachedToRoot) {
- // Don't schedule layout of the view unless it is a descendant of the root view.
- // When it moves to a rooted view tree, schedule an initial layout.
- view._needsLayoutWhenAttachedToRoot = true;
+ if (!view._isAttachedToRoot)
return;
- }
if (WI.View._scheduledLayoutUpdateIdentifier)
return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes