Title: [191017] trunk/Source
Revision
191017
Author
[email protected]
Date
2015-10-13 17:14:29 -0700 (Tue, 13 Oct 2015)

Log Message

Add helper funtion for checking pointer equivalency and use it
https://bugs.webkit.org/show_bug.cgi?id=150022

Reviewed by Darin Adler.
Source/WebCore:

A common pattern in WebCore code is to check for equivalency of two pointers,
either both null, or both non-null and with equal values. This was written in
several different ways in different places.

Add arePointingToEqualData() to standardize this pattern.

This obviates the need for StyleImage::imagesEquivalent(), counterDataEquivalent()
etc.

Also change some comparisons of DataRef<> which checked the pointer and then the
values to use DataRef<>::operator== which does the same thing. Comparisons of
m_grid and m_gridItem only checked pointer equality, so this is probably a bug fix there.

* page/animation/CSSPropertyAnimation.cpp: if ((!a && !b) || a == b) is redundant so fix,
and add checks for a and b RenderStyle* first.
(WebCore::PropertyWrapperGetter::equals):
(WebCore::StyleImagePropertyWrapper::equals):
(WebCore::PropertyWrapperShadow::equals):
(WebCore::PropertyWrapperMaybeInvalidColor::equals):
(WebCore::FillLayerPropertyWrapperGetter::equals):
(WebCore::FillLayerStyleImagePropertyWrapper::equals):
(WebCore::FillLayersPropertyWrapper::equals):
(WebCore::ShorthandPropertyWrapper::equals):
(WebCore::PropertyWrapperFlex::equals):
(WebCore::PropertyWrapperSVGPaint::equals):
* platform/network/ResourceRequestBase.cpp:
(WebCore::equalIgnoringHeaderFields):
* rendering/style/FillLayer.cpp:
(WebCore::FillLayer::operator==):
* rendering/style/NinePieceImage.cpp:
(WebCore::NinePieceImageData::operator==):
* rendering/style/RenderStyle.cpp: Some nullptr cleanup.
(WebCore::RenderStyle::getCachedPseudoStyle):
(WebCore::RenderStyle::addCachedPseudoStyle):
(WebCore::RenderStyle::changeAffectsVisualOverflow):
(WebCore::RenderStyle::changeRequiresLayout):
(WebCore::RenderStyle::changeRequiresLayerRepaint):
(WebCore::RenderStyle::setWillChange):
* rendering/style/SVGRenderStyleDefs.cpp:
(WebCore::StyleShadowSVGData::operator==):
* rendering/style/ShadowData.cpp:
(WebCore::ShadowData::operator==):
* rendering/style/StyleImage.h:
(WebCore::StyleImage::imagesEquivalent): Deleted.
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::operator==):
(WebCore::cursorDataEquivalent): Deleted.
(WebCore::quotesDataEquivalent): Deleted.
(WebCore::StyleRareInheritedData::shadowDataEquivalent): Deleted.
* rendering/style/StyleRareInheritedData.h:
* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::operator==):
(WebCore::StyleRareNonInheritedData::counterDataEquivalent): Deleted.
(WebCore::StyleRareNonInheritedData::shadowDataEquivalent): Deleted.
(WebCore::StyleRareNonInheritedData::willChangeDataEquivalent): Deleted.
(WebCore::StyleRareNonInheritedData::reflectionDataEquivalent): Deleted.
(WebCore::StyleRareNonInheritedData::animationDataEquivalent): Deleted.
(WebCore::StyleRareNonInheritedData::transitionDataEquivalent): Deleted.
* rendering/style/StyleRareNonInheritedData.h:

Source/WTF:

Add PointerComparison.h which contains the templated pointer comparison
function.

* WTF.xcodeproj/project.pbxproj:
* wtf/PointerComparison.h: Added.
(WTF::arePointingToEqualData):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (191016 => 191017)


--- trunk/Source/WTF/ChangeLog	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WTF/ChangeLog	2015-10-14 00:14:29 UTC (rev 191017)
@@ -1,3 +1,17 @@
+2015-10-13  Simon Fraser  <[email protected]>
+
+        Add helper funtion for checking pointer equivalency and use it
+        https://bugs.webkit.org/show_bug.cgi?id=150022
+
+        Reviewed by Darin Adler.
+        
+        Add PointerComparison.h which contains the templated pointer comparison
+        function.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/PointerComparison.h: Added.
+        (WTF::arePointingToEqualData):
+
 2015-10-12  Andreas Kling  <[email protected]>
 
         "A + B" with strings shouldn't copy if A or B is empty.

Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (191016 => 191017)


--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2015-10-14 00:14:29 UTC (rev 191017)
@@ -51,6 +51,7 @@
 		0FEB3DCF1BB5D684009D7AAD /* SharedTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FEB3DCE1BB5D684009D7AAD /* SharedTask.h */; };
 		0FEB3DD11BB7366B009D7AAD /* ParallelVectorIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FEB3DD01BB7366B009D7AAD /* ParallelVectorIterator.h */; };
 		0FED67B61B22D4D80066CE15 /* TinyPtrSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FED67B51B22D4D80066CE15 /* TinyPtrSet.h */; };
+		0FF860951BCCBD740045127F /* PointerComparison.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF860941BCCBD740045127F /* PointerComparison.h */; };
 		0FFF19DC1BB334EB00886D91 /* ParallelHelperPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FFF19DA1BB334EB00886D91 /* ParallelHelperPool.cpp */; };
 		0FFF19DD1BB334EB00886D91 /* ParallelHelperPool.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FFF19DB1BB334EB00886D91 /* ParallelHelperPool.h */; };
 		14022F4118F5C3FC007FF0EB /* libbmalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14022F4018F5C3FC007FF0EB /* libbmalloc.a */; };
@@ -344,6 +345,7 @@
 		0FEB3DCE1BB5D684009D7AAD /* SharedTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedTask.h; sourceTree = "<group>"; };
 		0FEB3DD01BB7366B009D7AAD /* ParallelVectorIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParallelVectorIterator.h; sourceTree = "<group>"; };
 		0FED67B51B22D4D80066CE15 /* TinyPtrSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TinyPtrSet.h; sourceTree = "<group>"; };
+		0FF860941BCCBD740045127F /* PointerComparison.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointerComparison.h; sourceTree = "<group>"; };
 		0FFF19DA1BB334EB00886D91 /* ParallelHelperPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParallelHelperPool.cpp; sourceTree = "<group>"; };
 		0FFF19DB1BB334EB00886D91 /* ParallelHelperPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParallelHelperPool.h; sourceTree = "<group>"; };
 		14022F4018F5C3FC007FF0EB /* libbmalloc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libbmalloc.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -837,6 +839,7 @@
 				0F824A651B7443A0002E345D /* ParkingLot.h */,
 				A8A472ED151A825B004123FF /* PassRefPtr.h */,
 				A876DBD7151816E500DADB95 /* Platform.h */,
+				0FF860941BCCBD740045127F /* PointerComparison.h */,
 				0F9D335D165DBA73005AD387 /* PrintStream.cpp */,
 				0F9D335E165DBA73005AD387 /* PrintStream.h */,
 				0FC4488216FE9FE100844BE9 /* ProcessID.h */,
@@ -1208,6 +1211,7 @@
 				A8A47420151A825B004123FF /* SentinelLinkedList.h in Headers */,
 				A8A47422151A825B004123FF /* SHA1.h in Headers */,
 				A8A47423151A825B004123FF /* SimpleStats.h in Headers */,
+				0FF860951BCCBD740045127F /* PointerComparison.h in Headers */,
 				A8A47424151A825B004123FF /* SinglyLinkedList.h in Headers */,
 				A748745317A0BDAE00FA04CB /* SixCharacterHash.h in Headers */,
 				A8A47426151A825B004123FF /* Spectrum.h in Headers */,

Added: trunk/Source/WTF/wtf/PointerComparison.h (0 => 191017)


--- trunk/Source/WTF/wtf/PointerComparison.h	                        (rev 0)
+++ trunk/Source/WTF/wtf/PointerComparison.h	2015-10-14 00:14:29 UTC (rev 191017)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WTF_PointerComparison_h
+#define WTF_PointerComparison_h
+
+namespace WTF {
+
+template<typename T> inline bool arePointingToEqualData(const T& a, const T& b)
+{ 
+    return a == b || (a && b && *a == *b);
+}
+
+} // namespace WTF
+
+using WTF::arePointingToEqualData;
+
+#endif // WTF_PointerComparison_h

Modified: trunk/Source/WebCore/ChangeLog (191016 => 191017)


--- trunk/Source/WebCore/ChangeLog	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WebCore/ChangeLog	2015-10-14 00:14:29 UTC (rev 191017)
@@ -1,3 +1,70 @@
+2015-10-13  Simon Fraser  <[email protected]>
+
+        Add helper funtion for checking pointer equivalency and use it
+        https://bugs.webkit.org/show_bug.cgi?id=150022
+
+        Reviewed by Darin Adler.
+
+        A common pattern in WebCore code is to check for equivalency of two pointers,
+        either both null, or both non-null and with equal values. This was written in
+        several different ways in different places.
+        
+        Add arePointingToEqualData() to standardize this pattern.
+
+        This obviates the need for StyleImage::imagesEquivalent(), counterDataEquivalent()
+        etc.
+        
+        Also change some comparisons of DataRef<> which checked the pointer and then the
+        values to use DataRef<>::operator== which does the same thing. Comparisons of
+        m_grid and m_gridItem only checked pointer equality, so this is probably a bug fix there.
+
+        * page/animation/CSSPropertyAnimation.cpp: if ((!a && !b) || a == b) is redundant so fix,
+        and add checks for a and b RenderStyle* first.
+        (WebCore::PropertyWrapperGetter::equals):
+        (WebCore::StyleImagePropertyWrapper::equals):
+        (WebCore::PropertyWrapperShadow::equals):
+        (WebCore::PropertyWrapperMaybeInvalidColor::equals):
+        (WebCore::FillLayerPropertyWrapperGetter::equals):
+        (WebCore::FillLayerStyleImagePropertyWrapper::equals):
+        (WebCore::FillLayersPropertyWrapper::equals):
+        (WebCore::ShorthandPropertyWrapper::equals):
+        (WebCore::PropertyWrapperFlex::equals):
+        (WebCore::PropertyWrapperSVGPaint::equals):
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::equalIgnoringHeaderFields):
+        * rendering/style/FillLayer.cpp:
+        (WebCore::FillLayer::operator==):
+        * rendering/style/NinePieceImage.cpp:
+        (WebCore::NinePieceImageData::operator==):
+        * rendering/style/RenderStyle.cpp: Some nullptr cleanup.
+        (WebCore::RenderStyle::getCachedPseudoStyle):
+        (WebCore::RenderStyle::addCachedPseudoStyle):
+        (WebCore::RenderStyle::changeAffectsVisualOverflow):
+        (WebCore::RenderStyle::changeRequiresLayout):
+        (WebCore::RenderStyle::changeRequiresLayerRepaint):
+        (WebCore::RenderStyle::setWillChange):
+        * rendering/style/SVGRenderStyleDefs.cpp:
+        (WebCore::StyleShadowSVGData::operator==):
+        * rendering/style/ShadowData.cpp:
+        (WebCore::ShadowData::operator==):
+        * rendering/style/StyleImage.h:
+        (WebCore::StyleImage::imagesEquivalent): Deleted.
+        * rendering/style/StyleRareInheritedData.cpp:
+        (WebCore::StyleRareInheritedData::operator==):
+        (WebCore::cursorDataEquivalent): Deleted.
+        (WebCore::quotesDataEquivalent): Deleted.
+        (WebCore::StyleRareInheritedData::shadowDataEquivalent): Deleted.
+        * rendering/style/StyleRareInheritedData.h:
+        * rendering/style/StyleRareNonInheritedData.cpp:
+        (WebCore::StyleRareNonInheritedData::operator==):
+        (WebCore::StyleRareNonInheritedData::counterDataEquivalent): Deleted.
+        (WebCore::StyleRareNonInheritedData::shadowDataEquivalent): Deleted.
+        (WebCore::StyleRareNonInheritedData::willChangeDataEquivalent): Deleted.
+        (WebCore::StyleRareNonInheritedData::reflectionDataEquivalent): Deleted.
+        (WebCore::StyleRareNonInheritedData::animationDataEquivalent): Deleted.
+        (WebCore::StyleRareNonInheritedData::transitionDataEquivalent): Deleted.
+        * rendering/style/StyleRareNonInheritedData.h:
+
 2015-10-13  Myles C. Maxfield  <[email protected]>
 
         Split TypesettingFeatures into kerning and ligatures bools

Modified: trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp (191016 => 191017)


--- trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp	2015-10-14 00:14:29 UTC (rev 191017)
@@ -54,6 +54,7 @@
 #include <memory>
 #include <wtf/MathExtras.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/PointerComparison.h>
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
@@ -400,9 +401,7 @@
 
     virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
     {
-        // If the style pointers are the same, don't bother doing the test.
-        // If either is null, return false. If both are null, return true.
-        if ((!a && !b) || a == b)
+        if (a == b)
             return true;
         if (!a || !b)
             return false;
@@ -536,8 +535,6 @@
 
     virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
     {
-       // If the style pointers are the same, don't bother doing the test.
-       // If either is null, return false. If both are null, return true.
        if (a == b)
            return true;
        if (!a || !b)
@@ -545,7 +542,7 @@
 
         StyleImage* imageA = (a->*m_getter)();
         StyleImage* imageB = (b->*m_getter)();
-        return StyleImage::imagesEquivalent(imageA, imageB);
+        return arePointingToEqualData(imageA, imageB);
     }
 };
 
@@ -674,6 +671,11 @@
 
     virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
     {
+        if (a == b)
+            return true;
+        if (!a || !b)
+            return false;
+
         const ShadowData* shadowA = (a->*m_getter)();
         const ShadowData* shadowB = (b->*m_getter)();
 
@@ -790,6 +792,11 @@
 
     virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
     {
+        if (a == b)
+            return true;
+        if (!a || !b)
+            return false;
+
         Color fromColor = (a->*m_getter)();
         Color toColor = (b->*m_getter)();
 
@@ -884,11 +891,9 @@
 
     virtual bool equals(const FillLayer* a, const FillLayer* b) const
     {
-       // If the style pointers are the same, don't bother doing the test.
-       // If either is null, return false. If both are null, return true.
-       if ((!a && !b) || a == b)
-           return true;
-       if (!a || !b)
+        if (a == b)
+            return true;
+        if (!a || !b)
             return false;
         return (a->*m_getter)() == (b->*m_getter)();
     }
@@ -945,8 +950,6 @@
 
     virtual bool equals(const FillLayer* a, const FillLayer* b) const
     {
-       // If the style pointers are the same, don't bother doing the test.
-       // If either is null, return false. If both are null, return true.
        if (a == b)
            return true;
        if (!a || !b)
@@ -954,7 +957,7 @@
 
         StyleImage* imageA = (a->*m_getter)();
         StyleImage* imageB = (b->*m_getter)();
-        return StyleImage::imagesEquivalent(imageA, imageB);
+        return arePointingToEqualData(imageA, imageB);
     }
 };
 
@@ -993,6 +996,11 @@
 
     virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
     {
+        if (a == b)
+            return true;
+        if (!a || !b)
+            return false;
+
         const FillLayer* fromLayer = (a->*m_layersGetter)();
         const FillLayer* toLayer = (b->*m_layersGetter)();
 
@@ -1041,6 +1049,11 @@
 
     virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
     {
+        if (a == b)
+            return true;
+        if (!a || !b)
+            return false;
+
         for (auto& wrapper : m_propertyWrappers) {
             if (!wrapper->equals(a, b))
                 return false;
@@ -1070,9 +1083,7 @@
 
     virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
     {
-        // If the style pointers are the same, don't bother doing the test.
-        // If either is null, return false. If both are null, return true.
-        if ((!a && !b) || a == b)
+        if (a == b)
             return true;
         if (!a || !b)
             return false;
@@ -1101,6 +1112,11 @@
 
     virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
     {
+        if (a == b)
+            return true;
+        if (!a || !b)
+            return false;
+
         if ((a->*m_paintTypeGetter)() != (b->*m_paintTypeGetter)())
             return false;
 

Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp (191016 => 191017)


--- trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp	2015-10-14 00:14:29 UTC (rev 191017)
@@ -28,6 +28,7 @@
 
 #include "HTTPHeaderNames.h"
 #include "ResourceRequest.h"
+#include <wtf/PointerComparison.h>
 
 namespace WebCore {
 
@@ -500,18 +501,7 @@
     if (a.requester() != b.requester())
         return false;
 
-    FormData* formDataA = a.httpBody();
-    FormData* formDataB = b.httpBody();
-    
-    if (!formDataA)
-        return !formDataB;
-    if (!formDataB)
-        return !formDataA;
-    
-    if (*formDataA != *formDataB)
-        return false;
-    
-    return true;
+    return arePointingToEqualData(a.httpBody(), b.httpBody());
 }
 
 bool ResourceRequestBase::compare(const ResourceRequest& a, const ResourceRequest& b)

Modified: trunk/Source/WebCore/rendering/style/FillLayer.cpp (191016 => 191017)


--- trunk/Source/WebCore/rendering/style/FillLayer.cpp	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WebCore/rendering/style/FillLayer.cpp	2015-10-14 00:14:29 UTC (rev 191017)
@@ -22,6 +22,8 @@
 #include "config.h"
 #include "FillLayer.h"
 
+#include <wtf/PointerComparison.h>
+
 namespace WebCore {
 
 struct SameSizeAsFillLayer {
@@ -152,7 +154,7 @@
 {
     // We do not check the "isSet" booleans for each property, since those are only used during initial construction
     // to propagate patterns into layers. All layer comparisons happen after values have all been filled in anyway.
-    return StyleImage::imagesEquivalent(m_image.get(), o.m_image.get()) && m_xPosition == o.m_xPosition && m_yPosition == o.m_yPosition
+    return arePointingToEqualData(m_image.get(), o.m_image.get()) && m_xPosition == o.m_xPosition && m_yPosition == o.m_yPosition
         && m_backgroundXOrigin == o.m_backgroundXOrigin && m_backgroundYOrigin == o.m_backgroundYOrigin
         && m_attachment == o.m_attachment && m_clip == o.m_clip && m_composite == o.m_composite
         && m_blendMode == o.m_blendMode && m_origin == o.m_origin && m_repeatX == o.m_repeatX

Modified: trunk/Source/WebCore/rendering/style/NinePieceImage.cpp (191016 => 191017)


--- trunk/Source/WebCore/rendering/style/NinePieceImage.cpp	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WebCore/rendering/style/NinePieceImage.cpp	2015-10-14 00:14:29 UTC (rev 191017)
@@ -28,6 +28,7 @@
 #include "LengthFunctions.h"
 #include "RenderStyle.h"
 #include <wtf/NeverDestroyed.h>
+#include <wtf/PointerComparison.h>
 
 namespace WebCore {
 
@@ -252,7 +253,7 @@
 
 bool NinePieceImageData::operator==(const NinePieceImageData& other) const
 {
-    return StyleImage::imagesEquivalent(image.get(), other.image.get())
+    return arePointingToEqualData(image, other.image)
         && imageSlices == other.imageSlices
         && fill == other.fill
         && borderSlices == other.borderSlices

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (191016 => 191017)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2015-10-14 00:14:29 UTC (rev 191017)
@@ -42,6 +42,7 @@
 #include "StyleSelfAlignmentData.h"
 #include "WillChangeData.h"
 #include <wtf/MathExtras.h>
+#include <wtf/PointerComparison.h>
 #include <wtf/StdLibExtras.h>
 #include <algorithm>
 
@@ -310,10 +311,10 @@
 RenderStyle* RenderStyle::getCachedPseudoStyle(PseudoId pid) const
 {
     if (!m_cachedPseudoStyles || !m_cachedPseudoStyles->size())
-        return 0;
+        return nullptr;
 
     if (styleType() != NOPSEUDO) 
-        return 0;
+        return nullptr;
 
     for (size_t i = 0; i < m_cachedPseudoStyles->size(); ++i) {
         RenderStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get();
@@ -321,13 +322,13 @@
             return pseudoStyle;
     }
 
-    return 0;
+    return nullptr;
 }
 
 RenderStyle* RenderStyle::addCachedPseudoStyle(PassRefPtr<RenderStyle> pseudo)
 {
     if (!pseudo)
-        return 0;
+        return nullptr;
 
     ASSERT(pseudo->styleType() > NOPSEUDO);
 
@@ -459,11 +460,11 @@
 inline bool RenderStyle::changeAffectsVisualOverflow(const RenderStyle& other) const
 {
     if (rareNonInheritedData.get() != other.rareNonInheritedData.get()
-        && !rareNonInheritedData->shadowDataEquivalent(*other.rareNonInheritedData.get()))
+        && !arePointingToEqualData(rareNonInheritedData->m_boxShadow, other.rareNonInheritedData->m_boxShadow))
         return true;
 
     if (rareInheritedData.get() != other.rareInheritedData.get()
-        && !rareInheritedData->shadowDataEquivalent(*other.rareInheritedData.get()))
+        && !arePointingToEqualData(rareInheritedData->textShadow, other.rareInheritedData->textShadow))
         return true;
 
     if (inherited_flags._text_decorations != other.inherited_flags._text_decorations
@@ -523,13 +524,12 @@
             return true;
 #endif
 
-        if (rareNonInheritedData->m_deprecatedFlexibleBox.get() != other.rareNonInheritedData->m_deprecatedFlexibleBox.get()
-            && *rareNonInheritedData->m_deprecatedFlexibleBox.get() != *other.rareNonInheritedData->m_deprecatedFlexibleBox.get())
+        if (rareNonInheritedData->m_deprecatedFlexibleBox != other.rareNonInheritedData->m_deprecatedFlexibleBox)
             return true;
 
-        if (rareNonInheritedData->m_flexibleBox.get() != other.rareNonInheritedData->m_flexibleBox.get()
-            && *rareNonInheritedData->m_flexibleBox.get() != *other.rareNonInheritedData->m_flexibleBox.get())
+        if (rareNonInheritedData->m_flexibleBox != other.rareNonInheritedData->m_flexibleBox)
             return true;
+
         if (rareNonInheritedData->m_order != other.rareNonInheritedData->m_order
             || rareNonInheritedData->m_alignContent != other.rareNonInheritedData->m_alignContent
             || rareNonInheritedData->m_alignItems != other.rareNonInheritedData->m_alignItems
@@ -539,11 +539,10 @@
             || rareNonInheritedData->m_justifySelf != other.rareNonInheritedData->m_justifySelf)
             return true;
 
-        if (!rareNonInheritedData->reflectionDataEquivalent(*other.rareNonInheritedData.get()))
+        if (!arePointingToEqualData(rareNonInheritedData->m_boxReflect, other.rareNonInheritedData->m_boxReflect))
             return true;
 
-        if (rareNonInheritedData->m_multiCol.get() != other.rareNonInheritedData->m_multiCol.get()
-            && *rareNonInheritedData->m_multiCol.get() != *other.rareNonInheritedData->m_multiCol.get())
+        if (rareNonInheritedData->m_multiCol != other.rareNonInheritedData->m_multiCol)
             return true;
 
         if (rareNonInheritedData->m_transform != other.rareNonInheritedData->m_transform) {
@@ -556,8 +555,8 @@
         }
 
 #if ENABLE(CSS_GRID_LAYOUT)
-        if (rareNonInheritedData->m_grid.get() != other.rareNonInheritedData->m_grid.get()
-            || rareNonInheritedData->m_gridItem.get() != other.rareNonInheritedData->m_gridItem.get())
+        if (rareNonInheritedData->m_grid != other.rareNonInheritedData->m_grid
+            || rareNonInheritedData->m_gridItem != other.rareNonInheritedData->m_gridItem)
             return true;
 #endif
 
@@ -567,7 +566,7 @@
             return true;
 #endif
 
-        if (!rareNonInheritedData->willChangeDataEquivalent(*other.rareNonInheritedData.get())) {
+        if (!arePointingToEqualData(rareNonInheritedData->m_willChange, other.rareNonInheritedData->m_willChange)) {
             changedContextSensitiveProperties |= ContextSensitivePropertyWillChange;
             // Don't return; keep looking for another change
         }
@@ -616,7 +615,7 @@
 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
             || rareInheritedData->useTouchOverflowScrolling != other.rareInheritedData->useTouchOverflowScrolling
 #endif
-            || rareInheritedData->listStyleImage != other.rareInheritedData->listStyleImage)
+            || rareInheritedData->listStyleImage != other.rareInheritedData->listStyleImage) // FIXME: needs arePointingToEqualData()?
             return true;
 
         if (textStrokeWidth() != other.textStrokeWidth())
@@ -700,9 +699,7 @@
         return true;
 
     // If the counter directives change, trigger a relayout to re-calculate counter values and rebuild the counter node tree.
-    const CounterDirectiveMap* mapA = rareNonInheritedData->m_counterDirectives.get();
-    const CounterDirectiveMap* mapB = other.rareNonInheritedData->m_counterDirectives.get();
-    if (!(mapA == mapB || (mapA && mapB && *mapA == *mapB)))
+    if (!arePointingToEqualData(rareNonInheritedData->m_counterDirectives, other.rareNonInheritedData->m_counterDirectives))
         return true;
 
     if ((visibility() == COLLAPSE) != (other.visibility() == COLLAPSE))
@@ -725,9 +722,7 @@
         return true;
 #endif
 
-    const QuotesData* quotesDataA = rareInheritedData->quotes.get();
-    const QuotesData* quotesDataB = other.rareInheritedData->quotes.get();
-    if (!(quotesDataA == quotesDataB || (quotesDataA && quotesDataB && *quotesDataA == *quotesDataB)))
+    if (!arePointingToEqualData(rareInheritedData->quotes, other.rareInheritedData->quotes))
         return true;
 
     if (position() != StaticPosition) {
@@ -784,8 +779,7 @@
         // Don't return; keep looking for another change.
     }
 
-    if (rareNonInheritedData->m_filter.get() != other.rareNonInheritedData->m_filter.get()
-        && *rareNonInheritedData->m_filter.get() != *other.rareNonInheritedData->m_filter.get()) {
+    if (rareNonInheritedData->m_filter != other.rareNonInheritedData->m_filter) {
         changedContextSensitiveProperties |= ContextSensitivePropertyFilter;
         // Don't return; keep looking for another change.
     }
@@ -946,8 +940,7 @@
 
 void RenderStyle::setWillChange(PassRefPtr<WillChangeData> willChangeData)
 {
-    if (rareNonInheritedData->m_willChange == willChangeData
-        || (rareNonInheritedData->m_willChange && willChangeData && *rareNonInheritedData->m_willChange == *willChangeData))
+    if (arePointingToEqualData(rareNonInheritedData->m_willChange.get(), willChangeData.get()))
         return;
 
     rareNonInheritedData.access()->m_willChange = WTF::move(willChangeData);

Modified: trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp (191016 => 191017)


--- trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp	2015-10-14 00:14:29 UTC (rev 191017)
@@ -31,6 +31,7 @@
 
 #include "RenderStyle.h"
 #include "SVGRenderStyle.h"
+#include <wtf/PointerComparison.h>
 
 namespace WebCore {
 
@@ -216,11 +217,7 @@
 
 bool StyleShadowSVGData::operator==(const StyleShadowSVGData& other) const
 {
-    if ((!shadow && other.shadow) || (shadow && !other.shadow))
-        return false;
-    if (shadow && other.shadow && (*shadow != *other.shadow))
-        return false;
-    return true;
+    return arePointingToEqualData(shadow, other.shadow);
 }
 
 StyleResourceData::StyleResourceData()

Modified: trunk/Source/WebCore/rendering/style/ShadowData.cpp (191016 => 191017)


--- trunk/Source/WebCore/rendering/style/ShadowData.cpp	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WebCore/rendering/style/ShadowData.cpp	2015-10-14 00:14:29 UTC (rev 191017)
@@ -23,6 +23,7 @@
 #include "ShadowData.h"
 
 #include "LayoutRect.h"
+#include <wtf/PointerComparison.h>
 
 namespace WebCore {
 
@@ -39,8 +40,7 @@
 
 bool ShadowData::operator==(const ShadowData& o) const
 {
-    if ((m_next && !o.m_next) || (!m_next && o.m_next)
-        || (m_next && o.m_next && *m_next != *o.m_next))
+    if (!arePointingToEqualData(m_next, o.m_next))
         return false;
     
     return m_location == o.m_location

Modified: trunk/Source/WebCore/rendering/style/StyleImage.h (191016 => 191017)


--- trunk/Source/WebCore/rendering/style/StyleImage.h	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WebCore/rendering/style/StyleImage.h	2015-10-14 00:14:29 UTC (rev 191017)
@@ -74,11 +74,6 @@
     ALWAYS_INLINE bool isGeneratedImage() const { return m_isGeneratedImage; }
     ALWAYS_INLINE bool isCachedImageSet() const { return m_isCachedImageSet; }
     
-    static bool imagesEquivalent(StyleImage* image1, StyleImage* image2)
-    {
-        return image1 == image2 || (image1 && image2 && *image1 == *image2);
-    }
-
 protected:
     StyleImage()
         : m_isCachedImage(false)

Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp (191016 => 191017)


--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp	2015-10-14 00:14:29 UTC (rev 191017)
@@ -30,6 +30,7 @@
 #include "ShadowData.h"
 #include "StyleCustomPropertyData.h"
 #include "StyleImage.h"
+#include <wtf/PointerComparison.h>
 
 namespace WebCore {
 
@@ -235,24 +236,6 @@
 {
 }
 
-static bool cursorDataEquivalent(const CursorList* c1, const CursorList* c2)
-{
-    if (c1 == c2)
-        return true;
-    if ((!c1 && c2) || (c1 && !c2))
-        return false;
-    return (*c1 == *c2);
-}
-
-static bool quotesDataEquivalent(const QuotesData* q1, const QuotesData* q2)
-{
-    if (q1 == q2)
-        return true;
-    if ((!q1 && q2) || (q1 && !q2))
-        return false;
-    return (*q1 == *q2);
-}
-
 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
 {
     return textStrokeColor == o.textStrokeColor
@@ -265,8 +248,8 @@
 #if ENABLE(TOUCH_EVENTS)
         && tapHighlightColor == o.tapHighlightColor
 #endif
-        && shadowDataEquivalent(o)
-        && cursorDataEquivalent(cursorData.get(), o.cursorData.get())
+        && arePointingToEqualData(textShadow, o.textShadow)
+        && arePointingToEqualData(cursorData, o.cursorData)
         && indent == o.indent
         && m_effectiveZoom == o.m_effectiveZoom
         && widows == o.widows
@@ -307,7 +290,7 @@
         && hyphenationString == o.hyphenationString
         && locale == o.locale
         && textEmphasisCustomMark == o.textEmphasisCustomMark
-        && quotesDataEquivalent(quotes.get(), o.quotes.get())
+        && arePointingToEqualData(quotes, o.quotes)
         && m_tabSize == o.m_tabSize
         && m_lineGrid == o.m_lineGrid
 #if ENABLE(CSS_IMAGE_ORIENTATION)
@@ -333,16 +316,7 @@
         && trailingWord == o.trailingWord
 #endif
         && m_customProperties == o.m_customProperties
-        && StyleImage::imagesEquivalent(listStyleImage.get(), o.listStyleImage.get());
+        && arePointingToEqualData(listStyleImage, o.listStyleImage);
 }
 
-bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
-{
-    if ((!textShadow && o.textShadow) || (textShadow && !o.textShadow))
-        return false;
-    if (textShadow && o.textShadow && (*textShadow != *o.textShadow))
-        return false;
-    return true;
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h (191016 => 191017)


--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h	2015-10-14 00:14:29 UTC (rev 191017)
@@ -58,7 +58,6 @@
     {
         return !(*this == o);
     }
-    bool shadowDataEquivalent(const StyleRareInheritedData&) const;
 
     RefPtr<StyleImage> listStyleImage;
 

Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp (191016 => 191017)


--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2015-10-14 00:14:29 UTC (rev 191017)
@@ -31,6 +31,8 @@
 #include "StyleImage.h"
 #include "StyleResolver.h"
 #include "StyleScrollSnapPoints.h"
+#include <wtf/PointerComparison.h>
+#include <wtf/RefPtr.h>
 
 namespace WebCore {
 
@@ -233,21 +235,21 @@
         && m_scrollSnapPoints == o.m_scrollSnapPoints
 #endif
         && contentDataEquivalent(o)
-        && counterDataEquivalent(o)
-        && shadowDataEquivalent(o)
-        && willChangeDataEquivalent(o)
-        && reflectionDataEquivalent(o)
-        && animationDataEquivalent(o)
-        && transitionDataEquivalent(o)
+        && arePointingToEqualData(m_counterDirectives, o.m_counterDirectives)
+        && arePointingToEqualData(m_boxShadow, o.m_boxShadow)
+        && arePointingToEqualData(m_willChange, o.m_willChange)
+        && arePointingToEqualData(m_boxReflect, o.m_boxReflect)
+        && arePointingToEqualData(m_animations, o.m_animations)
+        && arePointingToEqualData(m_transitions, o.m_transitions)
         && m_mask == o.m_mask
         && m_maskBoxImage == o.m_maskBoxImage
         && m_pageSize == o.m_pageSize
 #if ENABLE(CSS_SHAPES)
-        && shapeOutsideDataEquivalent(o)
+        && arePointingToEqualData(m_shapeOutside, o.m_shapeOutside)
         && m_shapeMargin == o.m_shapeMargin
         && m_shapeImageThreshold == o.m_shapeImageThreshold
 #endif
-        && clipPathOperationsEquivalent(o)
+        && arePointingToEqualData(m_clipPath, o.m_clipPath)
         && m_textDecorationColor == o.m_textDecorationColor
         && m_visitedLinkTextDecorationColor == o.m_visitedLinkTextDecorationColor
         && m_visitedLinkBackgroundColor == o.m_visitedLinkBackgroundColor
@@ -305,84 +307,6 @@
     return !a && !b;
 }
 
-bool StyleRareNonInheritedData::counterDataEquivalent(const StyleRareNonInheritedData& o) const
-{
-    if (m_counterDirectives.get() == o.m_counterDirectives.get())
-        return true;
-        
-    if (m_counterDirectives && o.m_counterDirectives && *m_counterDirectives == *o.m_counterDirectives)
-        return true;
-
-    return false;
-}
-
-bool StyleRareNonInheritedData::shadowDataEquivalent(const StyleRareNonInheritedData& o) const
-{
-    if ((!m_boxShadow && o.m_boxShadow) || (m_boxShadow && !o.m_boxShadow))
-        return false;
-    if (m_boxShadow && o.m_boxShadow && (*m_boxShadow != *o.m_boxShadow))
-        return false;
-    return true;
-}
-
-bool StyleRareNonInheritedData::willChangeDataEquivalent(const StyleRareNonInheritedData& o) const
-{
-    if (m_willChange != o.m_willChange) {
-        if (!m_willChange || !o.m_willChange)
-            return false;
-        return *m_willChange == *o.m_willChange;
-    }
-    return true;
-}
-
-bool StyleRareNonInheritedData::reflectionDataEquivalent(const StyleRareNonInheritedData& o) const
-{
-    if (m_boxReflect != o.m_boxReflect) {
-        if (!m_boxReflect || !o.m_boxReflect)
-            return false;
-        return *m_boxReflect == *o.m_boxReflect;
-    }
-    return true;
-}
-
-bool StyleRareNonInheritedData::animationDataEquivalent(const StyleRareNonInheritedData& o) const
-{
-    if ((!m_animations && o.m_animations) || (m_animations && !o.m_animations))
-        return false;
-    if (m_animations && o.m_animations && (*m_animations != *o.m_animations))
-        return false;
-    return true;
-}
-
-bool StyleRareNonInheritedData::transitionDataEquivalent(const StyleRareNonInheritedData& o) const
-{
-    if ((!m_transitions && o.m_transitions) || (m_transitions && !o.m_transitions))
-        return false;
-    if (m_transitions && o.m_transitions && (*m_transitions != *o.m_transitions))
-        return false;
-    return true;
-}
-
-bool StyleRareNonInheritedData::clipPathOperationsEquivalent(const StyleRareNonInheritedData& o) const
-{
-    if ((!m_clipPath && o.m_clipPath) || (m_clipPath && !o.m_clipPath))
-        return false;
-    if (m_clipPath && o.m_clipPath && (*m_clipPath != *o.m_clipPath))
-        return false;
-    return true;
-}
-
-#if ENABLE(CSS_SHAPES)
-bool StyleRareNonInheritedData::shapeOutsideDataEquivalent(const StyleRareNonInheritedData& o) const
-{
-    if ((!m_shapeOutside && o.m_shapeOutside) || (m_shapeOutside && !o.m_shapeOutside))
-        return false;
-    if (m_shapeOutside && o.m_shapeOutside && (*m_shapeOutside != *o.m_shapeOutside))
-        return false;
-    return true;
-}
-#endif
-
 bool StyleRareNonInheritedData::hasFilters() const
 {
     return m_filter.get() && !m_filter->m_operations.isEmpty();

Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h (191016 => 191017)


--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2015-10-14 00:12:18 UTC (rev 191016)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2015-10-14 00:14:29 UTC (rev 191017)
@@ -92,16 +92,7 @@
     bool operator!=(const StyleRareNonInheritedData& o) const { return !(*this == o); }
 
     bool contentDataEquivalent(const StyleRareNonInheritedData&) const;
-    bool counterDataEquivalent(const StyleRareNonInheritedData&) const;
-    bool shadowDataEquivalent(const StyleRareNonInheritedData&) const;
-    bool willChangeDataEquivalent(const StyleRareNonInheritedData&) const;
-    bool reflectionDataEquivalent(const StyleRareNonInheritedData&) const;
-    bool animationDataEquivalent(const StyleRareNonInheritedData&) const;
-    bool transitionDataEquivalent(const StyleRareNonInheritedData&) const;
-    bool clipPathOperationsEquivalent(const StyleRareNonInheritedData&) const;
-#if ENABLE(CSS_SHAPES)
-    bool shapeOutsideDataEquivalent(const StyleRareNonInheritedData&) const;
-#endif
+
     bool hasFilters() const;
 #if ENABLE(FILTERS_LEVEL_2)
     bool hasBackdropFilters() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to