Title: [220383] trunk/Source/WebCore
Revision
220383
Author
simon.fra...@apple.com
Date
2017-08-07 19:52:10 -0700 (Mon, 07 Aug 2017)

Log Message

RenderStyle:diff() was inadvertently doing deep compares of StyleRareNonInheritedData etc
https://bugs.webkit.org/show_bug.cgi?id=175304

Reviewed by Tim Horton.

r210758 changed DataRef::get() from returning a pointer to a reference. This caused all the places
in RenderStyle::diff() and related functions, where we intended to do a quick pointer comparison,
to doing deep compares via operator!=. This made the code slightly slower.

Fix by exposing ptr() on DataRef and using it wherever we wish to do pointer comparison.

* rendering/style/DataRef.h:
(WebCore::DataRef::ptr const):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::inheritedDataShared const):
(WebCore::RenderStyle::changeAffectsVisualOverflow const):
(WebCore::RenderStyle::changeRequiresLayout const):
(WebCore::RenderStyle::changeRequiresRecompositeLayer const):
(WebCore::RenderStyle::listStyleImage const): Expand the function onto multiple lines.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (220382 => 220383)


--- trunk/Source/WebCore/ChangeLog	2017-08-08 02:52:08 UTC (rev 220382)
+++ trunk/Source/WebCore/ChangeLog	2017-08-08 02:52:10 UTC (rev 220383)
@@ -1,5 +1,27 @@
 2017-08-07  Simon Fraser  <simon.fra...@apple.com>
 
+        RenderStyle:diff() was inadvertently doing deep compares of StyleRareNonInheritedData etc
+        https://bugs.webkit.org/show_bug.cgi?id=175304
+
+        Reviewed by Tim Horton.
+
+        r210758 changed DataRef::get() from returning a pointer to a reference. This caused all the places
+        in RenderStyle::diff() and related functions, where we intended to do a quick pointer comparison,
+        to doing deep compares via operator!=. This made the code slightly slower.
+
+        Fix by exposing ptr() on DataRef and using it wherever we wish to do pointer comparison.
+
+        * rendering/style/DataRef.h:
+        (WebCore::DataRef::ptr const):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::inheritedDataShared const):
+        (WebCore::RenderStyle::changeAffectsVisualOverflow const):
+        (WebCore::RenderStyle::changeRequiresLayout const):
+        (WebCore::RenderStyle::changeRequiresRecompositeLayer const):
+        (WebCore::RenderStyle::listStyleImage const): Expand the function onto multiple lines.
+
+2017-08-07  Simon Fraser  <simon.fra...@apple.com>
+
         Add a fast path for rotate() and rotateZ() transform parsing
         https://bugs.webkit.org/show_bug.cgi?id=175308
 

Modified: trunk/Source/WebCore/rendering/style/DataRef.h (220382 => 220383)


--- trunk/Source/WebCore/rendering/style/DataRef.h	2017-08-08 02:52:08 UTC (rev 220382)
+++ trunk/Source/WebCore/rendering/style/DataRef.h	2017-08-08 02:52:10 UTC (rev 220383)
@@ -55,6 +55,11 @@
         return m_data;
     }
 
+    const T* ptr() const
+    {
+        return m_data.ptr();
+    }
+
     const T& get() const
     {
         return m_data;

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (220382 => 220383)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2017-08-08 02:52:08 UTC (rev 220382)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2017-08-08 02:52:10 UTC (rev 220383)
@@ -452,9 +452,9 @@
 {
     // This is a fast check that only looks if the data structures are shared.
     return m_inheritedFlags == other->m_inheritedFlags
-        && m_inheritedData.get() == other->m_inheritedData.get()
-        && m_svgStyle.get() == other->m_svgStyle.get()
-        && m_rareInheritedData.get() == other->m_rareInheritedData.get();
+        && m_inheritedData.ptr() == other->m_inheritedData.ptr()
+        && m_svgStyle.ptr() == other->m_svgStyle.ptr()
+        && m_rareInheritedData.ptr() == other->m_rareInheritedData.ptr();
 }
 
 static bool positionChangeIsMovementOnly(const LengthBox& a, const LengthBox& b, const Length& width)
@@ -486,11 +486,11 @@
 
 inline bool RenderStyle::changeAffectsVisualOverflow(const RenderStyle& other) const
 {
-    if (m_rareNonInheritedData.get() != other.m_rareNonInheritedData.get()
+    if (m_rareNonInheritedData.ptr() != other.m_rareNonInheritedData.ptr()
         && !arePointingToEqualData(m_rareNonInheritedData->boxShadow, other.m_rareNonInheritedData->boxShadow))
         return true;
 
-    if (m_rareInheritedData.get() != other.m_rareInheritedData.get()
+    if (m_rareInheritedData.ptr() != other.m_rareInheritedData.ptr()
         && !arePointingToEqualData(m_rareInheritedData->textShadow, other.m_rareInheritedData->textShadow))
         return true;
 
@@ -536,7 +536,7 @@
     if (changeAffectsVisualOverflow(other))
         return true;
 
-    if (m_rareNonInheritedData.get() != other.m_rareNonInheritedData.get()) {
+    if (m_rareNonInheritedData.ptr() != other.m_rareNonInheritedData.ptr()) {
         if (m_rareNonInheritedData->appearance != other.m_rareNonInheritedData->appearance
             || m_rareNonInheritedData->marginBeforeCollapse != other.m_rareNonInheritedData->marginBeforeCollapse
             || m_rareNonInheritedData->marginAfterCollapse != other.m_rareNonInheritedData->marginAfterCollapse
@@ -597,7 +597,7 @@
         }
     }
 
-    if (m_rareInheritedData.get() != other.m_rareInheritedData.get()) {
+    if (m_rareInheritedData.ptr() != other.m_rareInheritedData.ptr()) {
         if (m_rareInheritedData->indent != other.m_rareInheritedData->indent
 #if ENABLE(CSS3_TEXT)
             || m_rareInheritedData->textAlignLast != other.m_rareInheritedData->textAlignLast
@@ -910,7 +910,7 @@
 
 bool RenderStyle::changeRequiresRecompositeLayer(const RenderStyle& other, unsigned&) const
 {
-    if (m_rareNonInheritedData.get() != other.m_rareNonInheritedData.get()) {
+    if (m_rareNonInheritedData.ptr() != other.m_rareNonInheritedData.ptr()) {
         if (m_rareNonInheritedData->transformStyle3D != other.m_rareNonInheritedData->transformStyle3D
             || m_rareNonInheritedData->backfaceVisibility != other.m_rareNonInheritedData->backfaceVisibility
             || m_rareNonInheritedData->perspective != other.m_rareNonInheritedData->perspective
@@ -1196,7 +1196,10 @@
     };
 }
 
-StyleImage* RenderStyle::listStyleImage() const { return m_rareInheritedData->listStyleImage.get(); }
+StyleImage* RenderStyle::listStyleImage() const
+{
+    return m_rareInheritedData->listStyleImage.get();
+}
 
 void RenderStyle::setListStyleImage(RefPtr<StyleImage>&& v)
 {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to