Title: [159187] trunk/Source/WebCore
Revision
159187
Author
[email protected]
Date
2013-11-13 03:51:23 -0800 (Wed, 13 Nov 2013)

Log Message

Refalize CSSCursorImageValue.
<https://webkit.org/b/124272>

Make CSSCursorImageValue constructor return a PassRef, and have it
take the image CSSValue as a PassRef (and store it internally in a
Ref<CSSValue>.)

Had to add a Ref version of compareCSSValuePtr() to make this work.

Reviewed by Antti Koivisto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (159186 => 159187)


--- trunk/Source/WebCore/ChangeLog	2013-11-13 11:46:51 UTC (rev 159186)
+++ trunk/Source/WebCore/ChangeLog	2013-11-13 11:51:23 UTC (rev 159187)
@@ -1,5 +1,18 @@
 2013-11-13  Andreas Kling  <[email protected]>
 
+        Refalize CSSCursorImageValue.
+        <https://webkit.org/b/124272>
+
+        Make CSSCursorImageValue constructor return a PassRef, and have it
+        take the image CSSValue as a PassRef (and store it internally in a
+        Ref<CSSValue>.)
+
+        Had to add a Ref version of compareCSSValuePtr() to make this work.
+
+        Reviewed by Antti Koivisto.
+
+2013-11-13  Andreas Kling  <[email protected]>
+
         RenderTableSection: Cell structures don't need allocation padding.
         <https://webkit.org/b/124263>
 

Modified: trunk/Source/WebCore/css/CSSCursorImageValue.cpp (159186 => 159187)


--- trunk/Source/WebCore/css/CSSCursorImageValue.cpp	2013-11-13 11:46:51 UTC (rev 159186)
+++ trunk/Source/WebCore/css/CSSCursorImageValue.cpp	2013-11-13 11:51:23 UTC (rev 159187)
@@ -58,9 +58,9 @@
 }
 #endif
 
-CSSCursorImageValue::CSSCursorImageValue(PassRefPtr<CSSValue> imageValue, bool hasHotSpot, const IntPoint& hotSpot)
+CSSCursorImageValue::CSSCursorImageValue(PassRef<CSSValue> imageValue, bool hasHotSpot, const IntPoint& hotSpot)
     : CSSValue(CursorImageClass)
-    , m_imageValue(imageValue)
+    , m_imageValue(std::move(imageValue))
     , m_hasHotSpot(hasHotSpot)
     , m_hotSpot(hotSpot)
     , m_accessedImage(false)
@@ -79,7 +79,7 @@
     for (; it != end; ++it) {
         SVGElement* referencedElement = *it;
         referencedElement->cursorImageValueRemoved();
-        if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(toCSSImageValue(m_imageValue.get())->url(), referencedElement->document()))
+        if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(toCSSImageValue(m_imageValue.get()).url(), referencedElement->document()))
             cursorElement->removeClient(referencedElement);
     }
 #endif
@@ -88,7 +88,7 @@
 String CSSCursorImageValue::customCSSText() const
 {
     StringBuilder result;
-    result.append(m_imageValue->cssText());
+    result.append(m_imageValue.get().cssText());
     if (m_hasHotSpot) {
         result.append(' ');
         result.appendNumber(m_hotSpot.x());
@@ -109,7 +109,7 @@
     if (!isSVGCursor())
         return false;
 
-    if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(toCSSImageValue(m_imageValue.get())->url(), element->document())) {
+    if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(toCSSImageValue(m_imageValue.get()).url(), element->document())) {
         // FIXME: This will override hot spot specified in CSS, which is probably incorrect.
         SVGLengthContext lengthContext(0);
         m_hasHotSpot = true;
@@ -136,8 +136,8 @@
 StyleImage* CSSCursorImageValue::cachedImage(CachedResourceLoader* loader)
 {
 #if ENABLE(CSS_IMAGE_SET)
-    if (m_imageValue->isImageSetValue())
-        return toCSSImageSetValue(m_imageValue.get())->cachedImageSet(loader);
+    if (m_imageValue.get().isImageSetValue())
+        return toCSSImageSetValue(m_imageValue.get()).cachedImageSet(loader);
 #endif
 
     if (!m_accessedImage) {
@@ -149,7 +149,7 @@
         // we create an alternate CSSImageValue to use.
         if (isSVGCursor() && loader && loader->document()) {
             // FIXME: This will fail if the <cursor> element is in a shadow DOM (bug 59827)
-            if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(toCSSImageValue(m_imageValue.get())->url(), *loader->document())) {
+            if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(toCSSImageValue(m_imageValue.get()).url(), *loader->document())) {
                 Ref<CSSImageValue> svgImageValue(CSSImageValue::create(cursorElement->href()));
                 StyleCachedImage* cachedImage = svgImageValue->cachedImage(loader);
                 m_image = cachedImage;
@@ -158,8 +158,8 @@
         }
 #endif
 
-        if (m_imageValue->isImageValue())
-            m_image = toCSSImageValue(m_imageValue.get())->cachedImage(loader);
+        if (m_imageValue.get().isImageValue())
+            m_image = toCSSImageValue(m_imageValue.get()).cachedImage(loader);
     }
 
     if (m_image && m_image->isCachedImage())
@@ -172,8 +172,8 @@
 {
 #if ENABLE(CSS_IMAGE_SET)
     // Need to delegate completely so that changes in device scale factor can be handled appropriately.
-    if (m_imageValue->isImageSetValue())
-        return toCSSImageSetValue(m_imageValue.get())->cachedOrPendingImageSet(document);
+    if (m_imageValue.get().isImageSetValue())
+        return toCSSImageSetValue(m_imageValue.get()).cachedOrPendingImageSet(document);
 #endif
 
     if (!m_image)
@@ -185,8 +185,8 @@
 #if ENABLE(SVG)
 bool CSSCursorImageValue::isSVGCursor() const
 {
-    if (m_imageValue->isImageValue()) {
-        URL kurl(ParsedURLString, toCSSImageValue(m_imageValue.get())->url());
+    if (m_imageValue.get().isImageValue()) {
+        URL kurl(ParsedURLString, toCSSImageValue(m_imageValue.get()).url());
         return kurl.hasFragmentIdentifier();
     }
     return false;
@@ -214,7 +214,7 @@
 bool CSSCursorImageValue::equals(const CSSCursorImageValue& other) const
 {
     return m_hasHotSpot ? other.m_hasHotSpot && m_hotSpot == other.m_hotSpot : !other.m_hasHotSpot
-        && compareCSSValuePtr(m_imageValue, other.m_imageValue);
+        && compareCSSValue(m_imageValue, other.m_imageValue);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/CSSCursorImageValue.h (159186 => 159187)


--- trunk/Source/WebCore/css/CSSCursorImageValue.h	2013-11-13 11:46:51 UTC (rev 159186)
+++ trunk/Source/WebCore/css/CSSCursorImageValue.h	2013-11-13 11:51:23 UTC (rev 159187)
@@ -33,9 +33,9 @@
 
 class CSSCursorImageValue : public CSSValue {
 public:
-    static PassRefPtr<CSSCursorImageValue> create(PassRefPtr<CSSValue> imageValue, bool hasHotSpot, const IntPoint& hotSpot)
+    static PassRef<CSSCursorImageValue> create(PassRef<CSSValue> imageValue, bool hasHotSpot, const IntPoint& hotSpot)
     {
-        return adoptRef(new CSSCursorImageValue(imageValue, hasHotSpot, hotSpot));
+        return adoptRef(*new CSSCursorImageValue(std::move(imageValue), hasHotSpot, hotSpot));
     }
 
     ~CSSCursorImageValue();
@@ -62,7 +62,7 @@
     bool equals(const CSSCursorImageValue&) const;
 
 private:
-    CSSCursorImageValue(PassRefPtr<CSSValue> imageValue, bool hasHotSpot, const IntPoint& hotSpot);
+    CSSCursorImageValue(PassRef<CSSValue> imageValue, bool hasHotSpot, const IntPoint& hotSpot);
 
 #if ENABLE(SVG)
     bool isSVGCursor() const;
@@ -70,7 +70,7 @@
     void clearCachedImage();
 #endif
 
-    RefPtr<CSSValue> m_imageValue;
+    Ref<CSSValue> m_imageValue;
 
     bool m_hasHotSpot;
     IntPoint m_hotSpot;

Modified: trunk/Source/WebCore/css/CSSImageValue.h (159186 => 159187)


--- trunk/Source/WebCore/css/CSSImageValue.h	2013-11-13 11:46:51 UTC (rev 159186)
+++ trunk/Source/WebCore/css/CSSImageValue.h	2013-11-13 11:51:23 UTC (rev 159187)
@@ -44,7 +44,7 @@
     // Returns a StyleCachedImage if the image is cached already, otherwise a StylePendingImage.
     StyleImage* cachedOrPendingImage();
 
-    const String& url() { return m_url; }
+    const String& url() const { return m_url; }
 
     String customCSSText() const;
 

Modified: trunk/Source/WebCore/css/CSSParser.cpp (159186 => 159187)


--- trunk/Source/WebCore/css/CSSParser.cpp	2013-11-13 11:46:51 UTC (rev 159186)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2013-11-13 11:51:23 UTC (rev 159187)
@@ -2101,7 +2101,7 @@
                 list = CSSValueList::createCommaSeparated();
 
             if (image)
-                list->append(CSSCursorImageValue::create(image, hasHotSpot, hotSpot));
+                list->append(CSSCursorImageValue::create(image.releaseNonNull(), hasHotSpot, hotSpot));
 
             if ((inStrictMode() && !value) || (value && !(value->unit == CSSParserValue::Operator && value->iValue == ',')))
                 return false;

Modified: trunk/Source/WebCore/css/CSSValue.h (159186 => 159187)


--- trunk/Source/WebCore/css/CSSValue.h	2013-11-13 11:46:51 UTC (rev 159186)
+++ trunk/Source/WebCore/css/CSSValue.h	2013-11-13 11:51:23 UTC (rev 159187)
@@ -272,6 +272,12 @@
     return first ? second && first->equals(*second) : !second;
 }
 
+template<typename CSSValueType>
+inline bool compareCSSValue(const Ref<CSSValueType>& first, const Ref<CSSValueType>& second)
+{
+    return first.get().equals(second.get());
+}
+
 #define CSS_VALUE_TYPE_CASTS(ToValueTypeName, predicate) \
     TYPE_CASTS_BASE(ToValueTypeName, CSSValue, value, value->predicate, value.predicate)
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to