CSSCanvasValue can't be renamed, enforce this at compile-time.
authorkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jan 2012 13:00:39 +0000 (13:00 +0000)
committerkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jan 2012 13:00:39 +0000 (13:00 +0000)
<http://webkit.org/b/76352>

Reviewed by Antti Koivisto.

Have the CSSCanvasValue constructor take the name as an argument instead of
having a setName() that's only called from one place in CSSParser.

* css/CSSCanvasValue.h:
(WebCore::CSSCanvasValue::create):
(WebCore::CSSCanvasValue::CSSCanvasValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseCanvas):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@105056 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/CSSCanvasValue.h
Source/WebCore/css/CSSParser.cpp

index b69dff4..0f823d4 100644 (file)
@@ -1,3 +1,19 @@
+2012-01-15  Andreas Kling  <awesomekling@apple.com>
+
+        CSSCanvasValue can't be renamed, enforce this at compile-time.
+        <http://webkit.org/b/76352>
+
+        Reviewed by Antti Koivisto.
+
+        Have the CSSCanvasValue constructor take the name as an argument instead of
+        having a setName() that's only called from one place in CSSParser.
+
+        * css/CSSCanvasValue.h:
+        (WebCore::CSSCanvasValue::create):
+        (WebCore::CSSCanvasValue::CSSCanvasValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseCanvas):
+
 2012-01-16  Andreas Kling  <awesomekling@apple.com>
 
         CSSStyleSelector: Dodge parser when creating default LTR/RTL declarations.
index efad7e6..159e619 100644 (file)
@@ -35,7 +35,7 @@ class Document;
 
 class CSSCanvasValue : public CSSImageGeneratorValue {
 public:
-    static PassRefPtr<CSSCanvasValue> create() { return adoptRef(new CSSCanvasValue); }
+    static PassRefPtr<CSSCanvasValue> create(const String& name) { return adoptRef(new CSSCanvasValue(name)); }
     ~CSSCanvasValue();
 
     String customCssText() const;
@@ -47,12 +47,11 @@ public:
     bool isPending() const { return false; }
     void loadSubimages(CachedResourceLoader*) { }
 
-    void setName(const String& name) { m_name = name; }
-
 private:
-    CSSCanvasValue()
+    CSSCanvasValue(const String& name)
         : CSSImageGeneratorValue(CanvasClass)
         , m_canvasObserver(this)
+        , m_name(name)
         , m_element(0)
     {
     }
index f9f6d7e..432942d 100644 (file)
@@ -6444,19 +6444,17 @@ bool CSSParser::parseCrossfade(CSSParserValueList* valueList, RefPtr<CSSValue>&
 
 bool CSSParser::parseCanvas(CSSParserValueList* valueList, RefPtr<CSSValue>& canvas)
 {
-    RefPtr<CSSCanvasValue> result = CSSCanvasValue::create();
-
     // Walk the arguments.
     CSSParserValueList* args = valueList->current()->function->args.get();
     if (!args || args->size() != 1)
         return false;
 
     // The first argument is the canvas name.  It is an identifier.
-    CSSParserValue* a = args->current();
-    if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT)
+    CSSParserValue* value = args->current();
+    if (!value || value->unit != CSSPrimitiveValue::CSS_IDENT)
         return false;
-    result->setName(a->string);
-    canvas = result;
+
+    canvas = CSSCanvasValue::create(value->string);
     return true;
 }