Title: [181898] trunk/Source/WebCore
Revision
181898
Author
[email protected]
Date
2015-03-24 12:13:06 -0700 (Tue, 24 Mar 2015)

Log Message

Improve the offsetWidth/Height layout optimization
https://bugs.webkit.org/show_bug.cgi?id=143008

Reviewed by Dean Jackson.

* dom/Document.cpp:
(WebCore::Document::updateLayoutIfDimensionsOutOfDate):
* dom/Document.h:
Change Element* to Element&. Clean up the dimension bits to use shifting. Remove both the inline and
the positioning restrictions on the optimization check.

* dom/Element.cpp:
(WebCore::Element::offsetWidth):
(WebCore::Element::offsetHeight):
Change to use Element& instead of Element*.

(WebCore::Element::clientWidth):
(WebCore::Element::clientHeight):
(WebCore::Element::scrollWidth):
(WebCore::Element::scrollHeight):
Turn on the optimization for clientWidth/Height and scrollWidth/Height.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (181897 => 181898)


--- trunk/Source/WebCore/ChangeLog	2015-03-24 17:25:31 UTC (rev 181897)
+++ trunk/Source/WebCore/ChangeLog	2015-03-24 19:13:06 UTC (rev 181898)
@@ -1,3 +1,27 @@
+2015-03-24  David Hyatt  <[email protected]>
+
+        Improve the offsetWidth/Height layout optimization
+        https://bugs.webkit.org/show_bug.cgi?id=143008
+
+        Reviewed by Dean Jackson.
+
+        * dom/Document.cpp:
+        (WebCore::Document::updateLayoutIfDimensionsOutOfDate):
+        * dom/Document.h:
+        Change Element* to Element&. Clean up the dimension bits to use shifting. Remove both the inline and
+        the positioning restrictions on the optimization check.
+
+        * dom/Element.cpp:
+        (WebCore::Element::offsetWidth):
+        (WebCore::Element::offsetHeight):
+        Change to use Element& instead of Element*.
+
+        (WebCore::Element::clientWidth):
+        (WebCore::Element::clientHeight):
+        (WebCore::Element::scrollWidth):
+        (WebCore::Element::scrollHeight):
+        Turn on the optimization for clientWidth/Height and scrollWidth/Height.
+
 2015-03-24  Yoav Weiss  <[email protected]>
 
         Stop image from displaying when src attribute is removed or emptied

Modified: trunk/Source/WebCore/dom/Document.cpp (181897 => 181898)


--- trunk/Source/WebCore/dom/Document.cpp	2015-03-24 17:25:31 UTC (rev 181897)
+++ trunk/Source/WebCore/dom/Document.cpp	2015-03-24 19:13:06 UTC (rev 181898)
@@ -1896,7 +1896,7 @@
     return ensureStyleResolver().styleForElement(element, element->parentNode() ? element->parentNode()->computedStyle() : nullptr);
 }
 
-bool Document::updateLayoutIfDimensionsOutOfDate(Element* element, DimensionsCheck dimensionsCheck)
+bool Document::updateLayoutIfDimensionsOutOfDate(Element& element, DimensionsCheck dimensionsCheck)
 {
     ASSERT(isMainThread());
     
@@ -1920,13 +1920,13 @@
     // layout.
     bool requireFullLayout = false;
     if (HTMLFrameOwnerElement* owner = ownerElement()) {
-        if (owner->document().updateLayoutIfDimensionsOutOfDate(owner))
+        if (owner->document().updateLayoutIfDimensionsOutOfDate(*owner))
             requireFullLayout = true;
     }
     
     updateStyleIfNeeded();
-    
-    RenderObject* renderer = element->renderer();
+
+    RenderObject* renderer = element.renderer();
     if (!renderer || renderer->needsLayout())
         requireFullLayout = true;
 
@@ -1940,7 +1940,7 @@
         RenderBox* currentBox = nullptr;
         
         // Check our containing block chain. If anything in the chain needs a layout, then require a full layout.
-        for (RenderObject* currRenderer = element->renderer(); currRenderer && !currRenderer->isRenderView(); currRenderer = currRenderer->container()) {
+        for (RenderObject* currRenderer = element.renderer(); currRenderer && !currRenderer->isRenderView(); currRenderer = currRenderer->container()) {
             
             // Require the entire container chain to be boxes.
             if (!is<RenderBox>(currRenderer)) {
@@ -1969,9 +1969,8 @@
                 }
             }
             
-            if (!currentBox->isRenderBlockFlow() || currentBox->isInline() || currentBox->isOutOfFlowPositioned() || currentBox->flowThreadContainingBlock() || currentBox->isWritingModeRoot()) {
-                // FIXME: For now require only block-level non-positioned
-                // block flows all the way back to the root. This limits the optimization
+            if (!currentBox->isRenderBlockFlow() || currentBox->flowThreadContainingBlock() || currentBox->isWritingModeRoot()) {
+                // FIXME: For now require only block flows all the way back to the root. This limits the optimization
                 // for now, and we'll expand it in future patches to apply to more and more scenarios.
                 // Disallow regions/columns from having the optimization.
                 // Give up if the writing mode changes at all in the containing block chain.

Modified: trunk/Source/WebCore/dom/Document.h (181897 => 181898)


--- trunk/Source/WebCore/dom/Document.h	2015-03-24 17:25:31 UTC (rev 181897)
+++ trunk/Source/WebCore/dom/Document.h	2015-03-24 19:13:06 UTC (rev 181898)
@@ -260,7 +260,7 @@
     LimitedQuirksMode = 1 << 2
 };
 
-enum DimensionsCheck { WidthDimensionsCheck = 0x1, HeightDimensionsCheck = 0x2, AllDimensionsCheck = 0x3 };
+enum DimensionsCheck { WidthDimensionsCheck = 1 << 0, HeightDimensionsCheck = 1 << 1, AllDimensionsCheck = 1 << 2 };
 
 class Document : public ContainerNode, public TreeScope, public ScriptExecutionContext, public FontSelectorClient {
 public:
@@ -569,7 +569,7 @@
     bool renderTreeBeingDestroyed() const { return m_renderTreeBeingDestroyed; }
     bool hasLivingRenderTree() const { return renderView() && !renderTreeBeingDestroyed(); }
     
-    bool updateLayoutIfDimensionsOutOfDate(Element*, DimensionsCheck = AllDimensionsCheck);
+    bool updateLayoutIfDimensionsOutOfDate(Element&, DimensionsCheck = AllDimensionsCheck);
     
     AXObjectCache* existingAXObjectCache() const;
     WEBCORE_EXPORT AXObjectCache* axObjectCache() const;

Modified: trunk/Source/WebCore/dom/Element.cpp (181897 => 181898)


--- trunk/Source/WebCore/dom/Element.cpp	2015-03-24 17:25:31 UTC (rev 181897)
+++ trunk/Source/WebCore/dom/Element.cpp	2015-03-24 19:13:06 UTC (rev 181898)
@@ -728,7 +728,7 @@
 
 double Element::offsetWidth()
 {
-    document().updateLayoutIfDimensionsOutOfDate(this, WidthDimensionsCheck);
+    document().updateLayoutIfDimensionsOutOfDate(*this, WidthDimensionsCheck);
     if (RenderBoxModelObject* renderer = renderBoxModelObject()) {
         LayoutUnit offsetWidth = subpixelMetricsEnabled(renderer->document()) ? renderer->offsetWidth() : LayoutUnit(renderer->pixelSnappedOffsetWidth());
         return convertToNonSubpixelValueIfNeeded(adjustLayoutUnitForAbsoluteZoom(offsetWidth, *renderer).toDouble(), renderer->document());
@@ -738,7 +738,7 @@
 
 double Element::offsetHeight()
 {
-    document().updateLayoutIfDimensionsOutOfDate(this, HeightDimensionsCheck);
+    document().updateLayoutIfDimensionsOutOfDate(*this, HeightDimensionsCheck);
     if (RenderBoxModelObject* renderer = renderBoxModelObject()) {
         LayoutUnit offsetHeight = subpixelMetricsEnabled(renderer->document()) ? renderer->offsetHeight() : LayoutUnit(renderer->pixelSnappedOffsetHeight());
         return convertToNonSubpixelValueIfNeeded(adjustLayoutUnitForAbsoluteZoom(offsetHeight, *renderer).toDouble(), renderer->document());
@@ -790,7 +790,7 @@
 
 double Element::clientWidth()
 {
-    document().updateLayoutIgnorePendingStylesheets();
+    document().updateLayoutIfDimensionsOutOfDate(*this, WidthDimensionsCheck);
 
     if (!document().hasLivingRenderTree())
         return 0;
@@ -811,8 +811,7 @@
 
 double Element::clientHeight()
 {
-    document().updateLayoutIgnorePendingStylesheets();
-
+    document().updateLayoutIfDimensionsOutOfDate(*this, HeightDimensionsCheck);
     if (!document().hasLivingRenderTree())
         return 0;
     RenderView& renderView = *document().renderView();
@@ -872,7 +871,7 @@
 
 int Element::scrollWidth()
 {
-    document().updateLayoutIgnorePendingStylesheets();
+    document().updateLayoutIfDimensionsOutOfDate(*this, WidthDimensionsCheck);
     if (RenderBox* rend = renderBox())
         return adjustForAbsoluteZoom(rend->scrollWidth(), *rend);
     return 0;
@@ -880,7 +879,7 @@
 
 int Element::scrollHeight()
 {
-    document().updateLayoutIgnorePendingStylesheets();
+    document().updateLayoutIfDimensionsOutOfDate(*this, HeightDimensionsCheck);
     if (RenderBox* rend = renderBox())
         return adjustForAbsoluteZoom(rend->scrollHeight(), *rend);
     return 0;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to