WebKit needs toHTMLUnknownElement() and isUnknown() for sanity check.
authormorrita@google.com <morrita@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Mar 2012 04:09:39 +0000 (04:09 +0000)
committermorrita@google.com <morrita@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Mar 2012 04:09:39 +0000 (04:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=80229

Reviewed by Kent Tamura.

The code generator has naked static_cast<> which could be unsafe.
We can turn it into toHTMLUnknownElement() and the like.

No new tests. Just added a sanity check.

* dom/make_names.pl:
(printWrapperFactoryCppFile):
* html/HTMLElement.h:
(HTMLElement):
(WebCore::HTMLElement::isHTMLUnknownElement):
* html/HTMLUnknownElement.h:
(HTMLUnknownElement):
(WebCore::toHTMLUnknownElement):
(WebCore):
* mathml/MathMLElement.h:
(toMathMLElement):
* svg/SVGElement.h:
(WebCore::toSVGElement):
(WebCore):

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

Source/WebCore/ChangeLog
Source/WebCore/dom/make_names.pl
Source/WebCore/html/HTMLElement.h
Source/WebCore/html/HTMLUnknownElement.h
Source/WebCore/mathml/MathMLElement.h
Source/WebCore/svg/SVGElement.h

index f4e7703..c237b4f 100644 (file)
@@ -1,3 +1,30 @@
+2012-03-04  MORITA Hajime  <morrita@google.com>
+
+        WebKit needs toHTMLUnknownElement() and isUnknown() for sanity check.
+        https://bugs.webkit.org/show_bug.cgi?id=80229
+
+        Reviewed by Kent Tamura.
+
+        The code generator has naked static_cast<> which could be unsafe.
+        We can turn it into toHTMLUnknownElement() and the like.
+
+        No new tests. Just added a sanity check.
+
+        * dom/make_names.pl:
+        (printWrapperFactoryCppFile):
+        * html/HTMLElement.h:
+        (HTMLElement):
+        (WebCore::HTMLElement::isHTMLUnknownElement):
+        * html/HTMLUnknownElement.h:
+        (HTMLUnknownElement):
+        (WebCore::toHTMLUnknownElement):
+        (WebCore):
+        * mathml/MathMLElement.h:
+        (toMathMLElement):
+        * svg/SVGElement.h:
+        (WebCore::toSVGElement):
+        (WebCore):
+
 2012-03-04  Luke Macpherson   <macpherson@chromium.org>
 
         Handle CSSPropertyWebkitColumnBreakAfter, CSSPropertyWebkitColumnBreakBefore and CSSPropertyWebkitColumnBreakInside in CSSStyleApplyProperty.
index 5a516a8..8219b3a 100755 (executable)
@@ -1161,7 +1161,7 @@ END
     } elsif ($wrapperFactoryType eq "V8") {
         print F <<END
         return createWrapperFunction(element);
-    return V8$parameters{fallbackInterfaceName}::wrap(static_cast<$parameters{fallbackInterfaceName}*>(element), forceNewObject);
+    return V8$parameters{fallbackInterfaceName}::wrap(to$parameters{fallbackInterfaceName}(element), forceNewObject);
 END
 ;
     }
index 831a364..c8eeed0 100644 (file)
@@ -97,6 +97,10 @@ public:
     PassRefPtr<MicroDataItemValue> itemValue() const;
 #endif
 
+#ifndef NDEBUG
+    virtual bool isHTMLUnknownElement() const { return false; }
+#endif
+
 protected:
     HTMLElement(const QualifiedName& tagName, Document*);
 
index b1259c5..28ca837 100644 (file)
@@ -41,6 +41,10 @@ public:
         return adoptRef(new HTMLUnknownElement(tagName, document));
     }
 
+#ifndef NDEBUG
+    virtual bool isHTMLUnknownElement() const OVERRIDE { return true; }
+#endif
+
 private:
     HTMLUnknownElement(const QualifiedName& tagName, Document* document)
         : HTMLElement(tagName, document)
@@ -48,6 +52,12 @@ private:
     }
 };
 
+inline HTMLUnknownElement* toHTMLUnknownElement(HTMLElement* element)
+{
+    ASSERT(!element || element->isHTMLUnknownElement());
+    return static_cast<HTMLUnknownElement*>(element);
+}
+
 } // namespace
 
 #endif
index 11eb174..8780733 100644 (file)
@@ -48,5 +48,11 @@ private:
     
 }
 
+inline MathMLElement* toMathMLElement(Element* element)
+{
+    ASSERT(!element || element->isMathMLElement());
+    return static_cast<MathMLElement*>(element);
+}
+
 #endif // ENABLE(MATHML)
 #endif // MathMLElement_h
index f2aa241..87b9835 100644 (file)
@@ -148,6 +148,12 @@ struct SVGAttributeHashTranslator {
     static bool equal(QualifiedName a, QualifiedName b) { return a.matches(b); }
 };
 
+inline SVGElement* toSVGElement(Element* element)
+{
+    ASSERT(!element || element->isSVGElement());
+    return static_cast<SVGElement*>(element);
+}
+
 }
 
 #endif