Title: [109702] trunk/Source/WebCore
Revision
109702
Author
[email protected]
Date
2012-03-04 20:09:39 -0800 (Sun, 04 Mar 2012)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (109701 => 109702)


--- trunk/Source/WebCore/ChangeLog	2012-03-05 04:02:12 UTC (rev 109701)
+++ trunk/Source/WebCore/ChangeLog	2012-03-05 04:09:39 UTC (rev 109702)
@@ -1,3 +1,30 @@
+2012-03-04  MORITA Hajime  <[email protected]>
+
+        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   <[email protected]>
 
         Handle CSSPropertyWebkitColumnBreakAfter, CSSPropertyWebkitColumnBreakBefore and CSSPropertyWebkitColumnBreakInside in CSSStyleApplyProperty.

Modified: trunk/Source/WebCore/dom/make_names.pl (109701 => 109702)


--- trunk/Source/WebCore/dom/make_names.pl	2012-03-05 04:02:12 UTC (rev 109701)
+++ trunk/Source/WebCore/dom/make_names.pl	2012-03-05 04:09:39 UTC (rev 109702)
@@ -1161,7 +1161,7 @@
     } 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
 ;
     }

Modified: trunk/Source/WebCore/html/HTMLElement.h (109701 => 109702)


--- trunk/Source/WebCore/html/HTMLElement.h	2012-03-05 04:02:12 UTC (rev 109701)
+++ trunk/Source/WebCore/html/HTMLElement.h	2012-03-05 04:09:39 UTC (rev 109702)
@@ -97,6 +97,10 @@
     PassRefPtr<MicroDataItemValue> itemValue() const;
 #endif
 
+#ifndef NDEBUG
+    virtual bool isHTMLUnknownElement() const { return false; }
+#endif
+
 protected:
     HTMLElement(const QualifiedName& tagName, Document*);
 

Modified: trunk/Source/WebCore/html/HTMLUnknownElement.h (109701 => 109702)


--- trunk/Source/WebCore/html/HTMLUnknownElement.h	2012-03-05 04:02:12 UTC (rev 109701)
+++ trunk/Source/WebCore/html/HTMLUnknownElement.h	2012-03-05 04:09:39 UTC (rev 109702)
@@ -41,6 +41,10 @@
         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 @@
     }
 };
 
+inline HTMLUnknownElement* toHTMLUnknownElement(HTMLElement* element)
+{
+    ASSERT(!element || element->isHTMLUnknownElement());
+    return static_cast<HTMLUnknownElement*>(element);
+}
+
 } // namespace
 
 #endif

Modified: trunk/Source/WebCore/mathml/MathMLElement.h (109701 => 109702)


--- trunk/Source/WebCore/mathml/MathMLElement.h	2012-03-05 04:02:12 UTC (rev 109701)
+++ trunk/Source/WebCore/mathml/MathMLElement.h	2012-03-05 04:09:39 UTC (rev 109702)
@@ -48,5 +48,11 @@
     
 }
 
+inline MathMLElement* toMathMLElement(Element* element)
+{
+    ASSERT(!element || element->isMathMLElement());
+    return static_cast<MathMLElement*>(element);
+}
+
 #endif // ENABLE(MATHML)
 #endif // MathMLElement_h

Modified: trunk/Source/WebCore/svg/SVGElement.h (109701 => 109702)


--- trunk/Source/WebCore/svg/SVGElement.h	2012-03-05 04:02:12 UTC (rev 109701)
+++ trunk/Source/WebCore/svg/SVGElement.h	2012-03-05 04:09:39 UTC (rev 109702)
@@ -148,7 +148,13 @@
     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
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to