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

Reviewed by Andreas Kling.

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@161420 268f45cc-cd09-0410-ab3c-d52691b4dbfc

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

index 7fe89fc..d6f78fe 100644 (file)
@@ -1,3 +1,25 @@
+2014-01-07  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Add toHTMLTableSectionElement() functions, and use it
+        https://bugs.webkit.org/show_bug.cgi?id=126418
+
+        Reviewed by Andreas Kling.
+
+        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-07  László Langó  <llango.u-szeged@partner.samsung.com>
 
         Remove some extra includes from SVG.
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..d56172f 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef HTMLTableSectionElement_h
 #define HTMLTableSectionElement_h
 
+#include "HTMLNames.h"
 #include "HTMLTablePartElement.h"
 
 namespace WebCore {
@@ -59,6 +60,13 @@ private:
     virtual const StyleProperties* additionalPresentationAttributeStyle() OVERRIDE;
 };
 
+inline bool isHTMLTableSectionElement(const Node& node)
+{
+    return node.hasTagName(HTMLNames::theadTag) || node.hasTagName(HTMLNames::tfootTag) || node.hasTagName(HTMLNames::tbodyTag);
+}
+
+NODE_TYPE_CASTS(HTMLTableSectionElement)
+
 } //namespace
 
 #endif