Add toHTMLTableSectionElement() functions, and use it
authorgyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Jan 2014 05:15:07 +0000 (05:15 +0000)
committergyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Jan 2014 05:15:07 +0000 (05:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126418

Reviewed by Anders Carlsson.

HTMLTableSectionElement covers tbody, tfoot, and thead tags. So, we can't
generate isHTMLTableSectionElement() by using template. This patch add
toHTMLTableSectionElement() manually in order to cleanup static_cast<>.

No new tests, no behavior change.

* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::tHead):
(WebCore::HTMLTableElement::tFoot):
(WebCore::HTMLTableElement::lastBody):
* html/HTMLTableRowElement.cpp:
(WebCore::HTMLTableRowElement::rowIndex):
* html/HTMLTableSectionElement.h:
* html/HTMLTagNames.in:

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

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLTableElement.cpp
Source/WebCore/html/HTMLTableRowElement.cpp
Source/WebCore/html/HTMLTableSectionElement.h

index 055fbb7..c0634bc 100644 (file)
@@ -1,3 +1,25 @@
+2014-01-06  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Add toHTMLTableSectionElement() functions, and use it
+        https://bugs.webkit.org/show_bug.cgi?id=126418
+
+        Reviewed by Anders Carlsson.
+
+        HTMLTableSectionElement covers tbody, tfoot, and thead tags. So, we can't
+        generate isHTMLTableSectionElement() by using template. This patch add
+        toHTMLTableSectionElement() manually in order to cleanup static_cast<>.
+
+        No new tests, no behavior change.
+
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::tHead):
+        (WebCore::HTMLTableElement::tFoot):
+        (WebCore::HTMLTableElement::lastBody):
+        * html/HTMLTableRowElement.cpp:
+        (WebCore::HTMLTableRowElement::rowIndex):
+        * html/HTMLTableSectionElement.h:
+        * html/HTMLTagNames.in:
+
 2014-01-06  Mark Rowe  <mrowe@apple.com>
 
         <https://webkit.org/b/126559> Be more correct in dealing with NSControlSize
index ba9a5f7..bf22d00 100644 (file)
@@ -86,7 +86,7 @@ HTMLTableSectionElement* HTMLTableElement::tHead() const
 {
     for (Node* child = firstChild(); child; child = child->nextSibling()) {
         if (child->hasTagName(theadTag))
-            return static_cast<HTMLTableSectionElement*>(child);
+            return toHTMLTableSectionElement(child);
     }
     return 0;
 }
@@ -107,7 +107,7 @@ HTMLTableSectionElement* HTMLTableElement::tFoot() const
 {
     for (Node* child = firstChild(); child; child = child->nextSibling()) {
         if (child->hasTagName(tfootTag))
-            return static_cast<HTMLTableSectionElement*>(child);
+            return toHTMLTableSectionElement(child);
     }
     return 0;
 }
@@ -178,7 +178,7 @@ HTMLTableSectionElement* HTMLTableElement::lastBody() const
 {
     for (Node* child = lastChild(); child; child = child->previousSibling()) {
         if (child->hasTagName(tbodyTag))
-            return static_cast<HTMLTableSectionElement*>(child);
+            return toHTMLTableSectionElement(child);
     }
     return 0;
 }
index 649ec2f..4c4d979 100644 (file)
@@ -81,7 +81,7 @@ int HTMLTableRowElement::rowIndex() const
     
     for (Node *node = table->firstChild(); node; node = node->nextSibling()) {
         if (node->hasTagName(tbodyTag)) {
-            HTMLTableSectionElement* section = static_cast<HTMLTableSectionElement*>(node);
+            HTMLTableSectionElement* section = toHTMLTableSectionElement(node);
             for (Node* row = section->firstChild(); row; row = row->nextSibling()) {
                 if (row == this)
                     return rIndex;
index d67125a..6a2522f 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef HTMLTableSectionElement_h
 #define HTMLTableSectionElement_h
 
+#include "HTMLNames.h"
 #include "HTMLTablePartElement.h"
 
 namespace WebCore {
@@ -59,6 +60,39 @@ private:
     virtual const StyleProperties* additionalPresentationAttributeStyle() OVERRIDE;
 };
 
+// FIXME: These manual isHTMLFoo and toHTMLFoo should be clean up by using toFoo generation template.
+inline bool isHTMLTableSectionElement(const Node& node)
+{
+    return node.hasTagName(HTMLNames::trTag) || node.hasTagName(HTMLNames::tfootTag) || node.hasTagName(HTMLNames::tbodyTag);
+}
+
+inline HTMLTableSectionElement* toHTMLTableSectionElement(Node* node)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLTableSectionElement(*node));
+    return static_cast<HTMLTableSectionElement*>(node);
+}
+
+inline const HTMLTableSectionElement* toHTMLTableSectionElement(const Node* node)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLTableSectionElement(*node));
+    return static_cast<const HTMLTableSectionElement*>(node);
+}
+
+inline HTMLTableSectionElement& toHTMLTableSectionElement(Node& node)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(isHTMLTableSectionElement(node));
+    return static_cast<HTMLTableSectionElement&>(node);
+}
+
+inline const HTMLTableSectionElement& toHTMLTableSectionElement(const Node& node)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(isHTMLTableSectionElement(node));
+    return static_cast<const HTMLTableSectionElement&>(node);
+}
+
+void toHTMLTableSectionElement(const HTMLTableSectionElement*);
+void toHTMLTableSectionElement(const HTMLTableSectionElement&);
+
 } //namespace
 
 #endif