Append overloading function for isFooElement
authorkangil.han@samsung.com <kangil.han@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Jul 2013 14:18:34 +0000 (14:18 +0000)
committerkangil.han@samsung.com <kangil.han@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Jul 2013 14:18:34 +0000 (14:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=118334

Reviewed by Antti Koivisto.

Node::hasTagName needs additional isElementNode() check when it is triggered.
So conversion from Element* to Node* in isFooElement should be avoided.
Therefore, to support both Node* and Element* as an argument of isFooElement,
this patch appends overloading inline function.

* css/CSSStyleSheet.cpp:
(WebCore::isAcceptableCSSStyleSheetParent):
* css/StyleScopeResolver.cpp:
(WebCore::StyleScopeResolver::scopeFor):
* dom/Node.cpp:
(WebCore::Node::numberOfScopedHTMLStyleChildren):
* html/HTMLAnchorElement.h:
(WebCore::isHTMLAnchorElement):
* html/HTMLAreaElement.h:
(WebCore::isHTMLAreaElement):
* html/HTMLAudioElement.h:
(WebCore::isHTMLAudioElement):
* html/HTMLFormElement.h:
(WebCore::isHTMLFormElement):
* html/HTMLImageElement.h:
(WebCore::isHTMLImageElement):
* html/HTMLInputElement.h:
(WebCore::isHTMLInputElement):
* html/HTMLLabelElement.h:
(WebCore::isHTMLLabelElement):
* html/HTMLOptGroupElement.h:
(WebCore::isHTMLOptGroupElement):
* html/HTMLOptionElement.h:
(WebCore::isHTMLOptionElement):
* html/HTMLStyleElement.h:
(WebCore::isHTMLStyleElement):
(WebCore::toHTMLStyleElement):
* html/HTMLTextAreaElement.h:
(WebCore::isHTMLTextAreaElement):

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSStyleSheet.cpp
Source/WebCore/css/StyleScopeResolver.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/html/HTMLAnchorElement.h
Source/WebCore/html/HTMLAreaElement.h
Source/WebCore/html/HTMLAudioElement.h
Source/WebCore/html/HTMLFormElement.h
Source/WebCore/html/HTMLImageElement.h
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/HTMLLabelElement.h
Source/WebCore/html/HTMLOptGroupElement.h
Source/WebCore/html/HTMLOptionElement.h
Source/WebCore/html/HTMLStyleElement.h
Source/WebCore/html/HTMLTextAreaElement.h

index cfe2759..c35a94a 100644 (file)
@@ -1,3 +1,45 @@
+2013-07-03  Kangil Han  <kangil.han@samsung.com>
+
+        Append overloading function for isFooElement
+        https://bugs.webkit.org/show_bug.cgi?id=118334
+
+        Reviewed by Antti Koivisto.
+
+        Node::hasTagName needs additional isElementNode() check when it is triggered.
+        So conversion from Element* to Node* in isFooElement should be avoided.
+        Therefore, to support both Node* and Element* as an argument of isFooElement,
+        this patch appends overloading inline function.
+
+        * css/CSSStyleSheet.cpp:
+        (WebCore::isAcceptableCSSStyleSheetParent):
+        * css/StyleScopeResolver.cpp:
+        (WebCore::StyleScopeResolver::scopeFor):
+        * dom/Node.cpp:
+        (WebCore::Node::numberOfScopedHTMLStyleChildren):
+        * html/HTMLAnchorElement.h:
+        (WebCore::isHTMLAnchorElement):
+        * html/HTMLAreaElement.h:
+        (WebCore::isHTMLAreaElement):
+        * html/HTMLAudioElement.h:
+        (WebCore::isHTMLAudioElement):
+        * html/HTMLFormElement.h:
+        (WebCore::isHTMLFormElement):
+        * html/HTMLImageElement.h:
+        (WebCore::isHTMLImageElement):
+        * html/HTMLInputElement.h:
+        (WebCore::isHTMLInputElement):
+        * html/HTMLLabelElement.h:
+        (WebCore::isHTMLLabelElement):
+        * html/HTMLOptGroupElement.h:
+        (WebCore::isHTMLOptGroupElement):
+        * html/HTMLOptionElement.h:
+        (WebCore::isHTMLOptionElement):
+        * html/HTMLStyleElement.h:
+        (WebCore::isHTMLStyleElement):
+        (WebCore::toHTMLStyleElement):
+        * html/HTMLTextAreaElement.h:
+        (WebCore::isHTMLTextAreaElement):
+
 2013-07-03  Balazs Kelemen  <b.kelemen@samsung.com>
 
         Gif: zero filling should use memset instead of setRGBA for every pixel
index 110ff8b..8811e37 100644 (file)
@@ -65,7 +65,7 @@ static bool isAcceptableCSSStyleSheetParent(Node* parentNode)
     return !parentNode
         || parentNode->isDocumentNode()
         || parentNode->hasTagName(HTMLNames::linkTag)
-        || (parentNode->isElementNode() && isHTMLStyleElement(toElement(parentNode)))
+        || isHTMLStyleElement(parentNode)
 #if ENABLE(SVG)
         || parentNode->hasTagName(SVGNames::styleTag)
 #endif
index 9038858..e322152 100644 (file)
@@ -60,10 +60,10 @@ const ContainerNode* StyleScopeResolver::scopeFor(const CSSStyleSheet* sheet)
     if (!document)
         return 0;
     Node* ownerNode = sheet->ownerNode();
-    if (!ownerNode || !ownerNode->isHTMLElement() || !isHTMLStyleElement(toElement(ownerNode)))
+    if (!ownerNode || !ownerNode->isHTMLElement() || !isHTMLStyleElement(ownerNode))
         return 0;
 
-    HTMLStyleElement* styleElement = toHTMLStyleElement(toElement(ownerNode));
+    HTMLStyleElement* styleElement = toHTMLStyleElement(ownerNode);
     if (!styleElement->scoped())
         return styleElement->isInShadowTree() ? styleElement->containingShadowRoot() : 0;
 
index b4f99dd..e444977 100644 (file)
@@ -2536,10 +2536,9 @@ void Node::unregisterScopedHTMLStyleChild()
 size_t Node::numberOfScopedHTMLStyleChildren() const
 {
     size_t count = 0;
-    for (Element* element = ElementTraversal::firstWithin(this); element; element = ElementTraversal::next(element, this)) {
+    for (Element* element = ElementTraversal::firstWithin(this); element; element = ElementTraversal::next(element, this))
         if (isHTMLStyleElement(element) && toHTMLStyleElement(element)->isRegisteredAsScoped())
             count++;
-    }
 
     return count;
 }
index 6fad409..e548a1a 100644 (file)
@@ -159,6 +159,11 @@ inline bool isHTMLAnchorElement(Node* node)
     return node->hasTagName(HTMLNames::aTag);
 }
 
+inline bool isHTMLAnchorElement(Element* element)
+{
+    return element->hasTagName(HTMLNames::aTag);
+}
+
 inline HTMLAnchorElement* toHTMLAnchorElement(Node* node)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLAnchorElement(node));
index a39ace8..aa7f74c 100644 (file)
@@ -80,6 +80,11 @@ inline bool isHTMLAreaElement(Node* node)
     return node->hasTagName(HTMLNames::areaTag);
 }
 
+inline bool isHTMLAreaElement(Element* element)
+{
+    return element->hasTagName(HTMLNames::areaTag);
+}
+
 inline HTMLAreaElement* toHTMLAreaElement(Node* node)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLAreaElement(node));
index 0dcdd69..07ca48d 100644 (file)
@@ -48,6 +48,11 @@ inline bool isHTMLAudioElement(Node* node)
     return node->hasTagName(HTMLNames::audioTag);
 }
 
+inline bool isHTMLAudioElement(Element* element)
+{
+    return element->hasTagName(HTMLNames::audioTag);
+}
+
 inline HTMLAudioElement* toHTMLAudioElement(Node* node)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLAudioElement(node));
index 9b5ea2d..0ffc5d1 100644 (file)
@@ -166,6 +166,11 @@ inline bool isHTMLFormElement(Node* node)
     return node->hasTagName(HTMLNames::formTag);
 }
 
+inline bool isHTMLFormElement(Element* element)
+{
+    return element->hasTagName(HTMLNames::formTag);
+}
+
 inline HTMLFormElement* toHTMLFormElement(Node* node)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLFormElement(node));
index 4ad71bb..826c274 100644 (file)
@@ -117,6 +117,11 @@ inline bool isHTMLImageElement(Node* node)
     return node->hasTagName(HTMLNames::imgTag);
 }
 
+inline bool isHTMLImageElement(Element* element)
+{
+    return element->hasTagName(HTMLNames::imgTag);
+}
+
 inline HTMLImageElement* toHTMLImageElement(Node* node)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLImageElement(node));
index 5672846..2271dd9 100644 (file)
@@ -444,6 +444,11 @@ inline bool isHTMLInputElement(Node* node)
     return node->hasTagName(HTMLNames::inputTag);
 }
 
+inline bool isHTMLInputElement(Element* element)
+{
+    return element->hasTagName(HTMLNames::inputTag);
+}
+
 inline HTMLInputElement* toHTMLInputElement(Node* node)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLInputElement(node));
index 844f4c6..22366d9 100644 (file)
@@ -60,6 +60,11 @@ inline bool isHTMLLabelElement(Node* node)
     return node->hasTagName(HTMLNames::labelTag);
 }
 
+inline bool isHTMLLabelElement(Element* element)
+{
+    return element->hasTagName(HTMLNames::labelTag);
+}
+
 inline HTMLLabelElement* toHTMLLabelElement(Node* node)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLLabelElement(node));
index 4ecdc25..cc62e90 100644 (file)
@@ -68,6 +68,11 @@ inline bool isHTMLOptGroupElement(Node* node)
     return node->hasTagName(HTMLNames::optgroupTag);
 }
 
+inline bool isHTMLOptGroupElement(Element* element)
+{
+    return element->hasTagName(HTMLNames::optgroupTag);
+}
+
 inline HTMLOptGroupElement* toHTMLOptGroupElement(Node* node)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLOptGroupElement(node));
index 3dbb882..47e4a91 100644 (file)
@@ -100,6 +100,11 @@ inline bool isHTMLOptionElement(Node* node)
     return node->hasTagName(HTMLNames::optionTag);
 }
 
+inline bool isHTMLOptionElement(Element* element)
+{
+    return element->hasTagName(HTMLNames::optionTag);
+}
+
 inline HTMLOptionElement* toHTMLOptionElement(Node* node)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLOptionElement(node));
index 16487d5..3f25401 100644 (file)
@@ -97,15 +97,20 @@ private:
     ScopedStyleRegistrationState m_scopedStyleRegistrationState;
 };
 
+inline bool isHTMLStyleElement(Node* node)
+{
+    return node->hasTagName(HTMLNames::styleTag);
+}
+
 inline bool isHTMLStyleElement(Element* element)
 {
     return element->hasTagName(HTMLNames::styleTag);
 }
 
-inline HTMLStyleElement* toHTMLStyleElement(Element* element)
+inline HTMLStyleElement* toHTMLStyleElement(Node* node)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(!element || isHTMLStyleElement(element));
-    return static_cast<HTMLStyleElement*>(element);
+    ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLStyleElement(node));
+    return static_cast<HTMLStyleElement*>(node);
 }
 
 } //namespace
index 02fb9f9..d9785c9 100644 (file)
@@ -132,6 +132,11 @@ inline bool isHTMLTextAreaElement(Node* node)
     return node->hasTagName(HTMLNames::textareaTag);
 }
 
+inline bool isHTMLTextAreaElement(Element* element)
+{
+    return element->hasTagName(HTMLNames::textareaTag);
+}
+
 inline HTMLTextAreaElement* toHTMLTextAreaElement(Node* node)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLTextAreaElement(node));