Title: [174039] trunk/Source/WebCore
Revision
174039
Author
[email protected]
Date
2014-09-27 22:21:30 -0700 (Sat, 27 Sep 2014)

Log Message

Use the new is<>() / downcast<>() for more Node subclasses
https://bugs.webkit.org/show_bug.cgi?id=137184

Reviewed by Ryosuke Niwa.

Use the new is<>() / downcast<>() for more Node subclasses:
CDATASection, CharacterData, Comment, DocumentType,
ProcessingInstruction, and PseudoElement.

No new tests, no behavior change.

* dom/CDATASection.h:
(WebCore::isCDATASection):
* dom/CharacterData.cpp:
(WebCore::CharacterData::setDataAndUpdate):
* dom/CharacterData.h:
(WebCore::isCharacterData):
* dom/Comment.h:
(WebCore::isComment):
* dom/DocumentStyleSheetCollection.cpp:
(WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets):
* dom/DocumentType.h:
(WebCore::isDocumentType):
* dom/EventDispatcher.cpp:
(WebCore::eventTargetRespectingTargetRules):
(WebCore::nodeOrHostIfPseudoElement):
* dom/Node.cpp:
(WebCore::markAncestorsWithChildNeedsStyleRecalc):
(WebCore::Node::pseudoAwarePreviousSibling):
(WebCore::Node::pseudoAwareNextSibling):
* dom/NodeTraversal.cpp:
(WebCore::NodeTraversal::previousIncludingPseudo):
(WebCore::NodeTraversal::nextIncludingPseudo):
(WebCore::NodeTraversal::nextIncludingPseudoSkippingChildren):
* dom/ProcessingInstruction.h:
(WebCore::isProcessingInstruction):
* dom/PseudoElement.h:
(WebCore::isPseudoElement):
* dom/Range.cpp:
(WebCore::lengthOfContentsInNode):
(WebCore::Range::processContentsBetweenOffsets):
(WebCore::Range::checkNodeWOffset):
* editing/Editor.cpp:
(WebCore::Editor::shouldInsertFragment):
* editing/MarkupAccumulator.cpp:
(WebCore::MarkupAccumulator::appendStartMarkup):
* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::_traverseNode):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::buildObjectForNode):
* inspector/InspectorLayerTreeAgent.cpp:
(WebCore::InspectorLayerTreeAgent::buildObjectForLayer):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::setInnerNode):
(WebCore::HitTestResult::setInnerNonSharedNode):
* rendering/RenderListItem.cpp:
(WebCore::enclosingList):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::generatingPseudoHostElement):
* xml/XPathFunctions.cpp:
(WebCore::XPath::expandedNameLocalPart):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (174038 => 174039)


--- trunk/Source/WebCore/ChangeLog	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/ChangeLog	2014-09-28 05:21:30 UTC (rev 174039)
@@ -1,5 +1,69 @@
 2014-09-27  Christophe Dumez  <[email protected]>
 
+        Use the new is<>() / downcast<>() for more Node subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137184
+
+        Reviewed by Ryosuke Niwa.
+
+        Use the new is<>() / downcast<>() for more Node subclasses:
+        CDATASection, CharacterData, Comment, DocumentType,
+        ProcessingInstruction, and PseudoElement.
+
+        No new tests, no behavior change.
+
+        * dom/CDATASection.h:
+        (WebCore::isCDATASection):
+        * dom/CharacterData.cpp:
+        (WebCore::CharacterData::setDataAndUpdate):
+        * dom/CharacterData.h:
+        (WebCore::isCharacterData):
+        * dom/Comment.h:
+        (WebCore::isComment):
+        * dom/DocumentStyleSheetCollection.cpp:
+        (WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets):
+        * dom/DocumentType.h:
+        (WebCore::isDocumentType):
+        * dom/EventDispatcher.cpp:
+        (WebCore::eventTargetRespectingTargetRules):
+        (WebCore::nodeOrHostIfPseudoElement):
+        * dom/Node.cpp:
+        (WebCore::markAncestorsWithChildNeedsStyleRecalc):
+        (WebCore::Node::pseudoAwarePreviousSibling):
+        (WebCore::Node::pseudoAwareNextSibling):
+        * dom/NodeTraversal.cpp:
+        (WebCore::NodeTraversal::previousIncludingPseudo):
+        (WebCore::NodeTraversal::nextIncludingPseudo):
+        (WebCore::NodeTraversal::nextIncludingPseudoSkippingChildren):
+        * dom/ProcessingInstruction.h:
+        (WebCore::isProcessingInstruction):
+        * dom/PseudoElement.h:
+        (WebCore::isPseudoElement):
+        * dom/Range.cpp:
+        (WebCore::lengthOfContentsInNode):
+        (WebCore::Range::processContentsBetweenOffsets):
+        (WebCore::Range::checkNodeWOffset):
+        * editing/Editor.cpp:
+        (WebCore::Editor::shouldInsertFragment):
+        * editing/MarkupAccumulator.cpp:
+        (WebCore::MarkupAccumulator::appendStartMarkup):
+        * editing/cocoa/HTMLConverter.mm:
+        (HTMLConverter::_traverseNode):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::buildObjectForNode):
+        * inspector/InspectorLayerTreeAgent.cpp:
+        (WebCore::InspectorLayerTreeAgent::buildObjectForLayer):
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::setInnerNode):
+        (WebCore::HitTestResult::setInnerNonSharedNode):
+        * rendering/RenderListItem.cpp:
+        (WebCore::enclosingList):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::generatingPseudoHostElement):
+        * xml/XPathFunctions.cpp:
+        (WebCore::XPath::expandedNameLocalPart):
+
+2014-09-27  Christophe Dumez  <[email protected]>
+
         Use the new is<>() / downcast<>() for Attr Nodes
         https://bugs.webkit.org/show_bug.cgi?id=137183
 

Modified: trunk/Source/WebCore/dom/CDATASection.h (174038 => 174039)


--- trunk/Source/WebCore/dom/CDATASection.h	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/dom/CDATASection.h	2014-09-28 05:21:30 UTC (rev 174039)
@@ -41,12 +41,10 @@
     virtual PassRefPtr<Text> virtualCreate(const String&) override;
 };
 
-inline bool isCDATASection(const Node& node) { return node.nodeType() == Node::CDATA_SECTION_NODE; }
-void isCDATASection(const CDATASection&); // Catch unnecessary runtime check of type known at compile time.
-void isCDATASection(const ContainerNode&); // Catch unnecessary runtime check of type known at compile time.
+SPECIALIZE_TYPE_TRAITS_BEGIN(CDATASection)
+    static bool isCDATASection(const Node& node) { return node.nodeType() == Node::CDATA_SECTION_NODE; }
+SPECIALIZE_TYPE_TRAITS_END()
 
-NODE_TYPE_CASTS(CDATASection)
-
 } // namespace WebCore
 
 #endif // CDATASection_h

Modified: trunk/Source/WebCore/dom/CharacterData.cpp (174038 => 174039)


--- trunk/Source/WebCore/dom/CharacterData.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/dom/CharacterData.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -198,8 +198,8 @@
     if (isTextNode())
         Style::updateTextRendererAfterContentChange(*toText(this), offsetOfReplacedData, oldLength);
 
-    if (nodeType() == PROCESSING_INSTRUCTION_NODE)
-        toProcessingInstruction(this)->checkStyleSheet();
+    if (is<ProcessingInstruction>(this))
+        downcast<ProcessingInstruction>(*this).checkStyleSheet();
 
     if (document().frame())
         document().frame()->selection().textWasReplaced(this, offsetOfReplacedData, oldLength, newLength);

Modified: trunk/Source/WebCore/dom/CharacterData.h (174038 => 174039)


--- trunk/Source/WebCore/dom/CharacterData.h	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/dom/CharacterData.h	2014-09-28 05:21:30 UTC (rev 174039)
@@ -76,12 +76,10 @@
     String m_data;
 };
 
-inline bool isCharacterData(const Node& node) { return node.isCharacterDataNode(); }
-void isCharacterData(const CharacterData&); // Catch unnecessary runtime check of type known at compile time.
-void isCharacterData(const ContainerNode&); // Catch unnecessary runtime check of type known at compile time.
+SPECIALIZE_TYPE_TRAITS_BEGIN(CharacterData)
+    static bool isCharacterData(const Node& node) { return node.isCharacterDataNode(); }
+SPECIALIZE_TYPE_TRAITS_END()
 
-NODE_TYPE_CASTS(CharacterData)
-
 } // namespace WebCore
 
 #endif // CharacterData_h

Modified: trunk/Source/WebCore/dom/Comment.h (174038 => 174039)


--- trunk/Source/WebCore/dom/Comment.h	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/dom/Comment.h	2014-09-28 05:21:30 UTC (rev 174039)
@@ -41,12 +41,10 @@
     virtual bool childTypeAllowed(NodeType) const override;
 };
 
-inline bool isComment(const Node& node) { return node.nodeType() == Node::COMMENT_NODE; }
-void isComment(const Comment&); // Catch unnecessary runtime check of type known at compile time.
-void isComment(const ContainerNode&); // Catch unnecessary runtime check of type known at compile time.
+SPECIALIZE_TYPE_TRAITS_BEGIN(Comment)
+    static bool isComment(const Node& node) { return node.nodeType() == Node::COMMENT_NODE; }
+SPECIALIZE_TYPE_TRAITS_END()
 
-NODE_TYPE_CASTS(Comment)
-
 } // namespace WebCore
 
 #endif // Comment_h

Modified: trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp (174038 => 174039)


--- trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -266,17 +266,17 @@
 
     for (auto& node : m_styleSheetCandidateNodes) {
         StyleSheet* sheet = nullptr;
-        if (node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE) {
+        if (is<ProcessingInstruction>(node)) {
             // Processing instruction (XML documents only).
             // We don't support linking to embedded CSS stylesheets, see <https://bugs.webkit.org/show_bug.cgi?id=49281> for discussion.
-            ProcessingInstruction* pi = toProcessingInstruction(node);
-            sheet = pi->sheet();
+            ProcessingInstruction& pi = downcast<ProcessingInstruction>(*node);
+            sheet = pi.sheet();
 #if ENABLE(XSLT)
             // Don't apply XSL transforms to already transformed documents -- <rdar://problem/4132806>
-            if (pi->isXSL() && !m_document.transformSourceDocument()) {
+            if (pi.isXSL() && !m_document.transformSourceDocument()) {
                 // Don't apply XSL transforms until loading is finished.
                 if (!m_document.parsing())
-                    m_document.applyXSLTransform(pi);
+                    m_document.applyXSLTransform(&pi);
                 return;
             }
 #endif

Modified: trunk/Source/WebCore/dom/DocumentType.h (174038 => 174039)


--- trunk/Source/WebCore/dom/DocumentType.h	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/dom/DocumentType.h	2014-09-28 05:21:30 UTC (rev 174039)
@@ -60,13 +60,10 @@
     String m_subset;
 };
 
-inline bool isDocumentType(const Node& node)
-{
-    return node.nodeType() == Node::DOCUMENT_TYPE_NODE;
-}
+SPECIALIZE_TYPE_TRAITS_BEGIN(DocumentType)
+    static bool isDocumentType(const Node& node) { return node.nodeType() == Node::DOCUMENT_TYPE_NODE; }
+SPECIALIZE_TYPE_TRAITS_END()
 
-NODE_TYPE_CASTS(DocumentType)
-
 } // namespace WebCore
 
 #endif

Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (174038 => 174039)


--- trunk/Source/WebCore/dom/EventDispatcher.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -205,8 +205,8 @@
 
 inline EventTarget& eventTargetRespectingTargetRules(Node& referenceNode)
 {
-    if (referenceNode.isPseudoElement()) {
-        EventTarget* hostElement = toPseudoElement(referenceNode).hostElement();
+    if (is<PseudoElement>(referenceNode)) {
+        EventTarget* hostElement = downcast<PseudoElement>(referenceNode).hostElement();
         ASSERT(hostElement);
         return *hostElement;
     }
@@ -418,7 +418,7 @@
 
 static Node* nodeOrHostIfPseudoElement(Node* node)
 {
-    return node->isPseudoElement() ? toPseudoElement(node)->hostElement() : node;
+    return is<PseudoElement>(node) ? downcast<PseudoElement>(*node).hostElement() : node;
 }
 
 EventPath::EventPath(Node& targetNode, Event& event)

Modified: trunk/Source/WebCore/dom/Node.cpp (174038 => 174039)


--- trunk/Source/WebCore/dom/Node.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/dom/Node.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -672,7 +672,7 @@
 
 static inline void markAncestorsWithChildNeedsStyleRecalc(Node& node)
 {
-    if (ContainerNode* ancestor = node.isPseudoElement() ? toPseudoElement(node).hostElement() : node.parentOrShadowHostNode()) {
+    if (ContainerNode* ancestor = is<PseudoElement>(node) ? downcast<PseudoElement>(node).hostElement() : node.parentOrShadowHostNode()) {
         ancestor->setDirectChildNeedsStyleRecalc();
 
         for (; ancestor && !ancestor->childNeedsStyleRecalc(); ancestor = ancestor->parentOrShadowHostNode())
@@ -872,7 +872,7 @@
 
 Node* Node::pseudoAwarePreviousSibling() const
 {
-    Element* parentOrHost = isPseudoElement() ? toPseudoElement(this)->hostElement() : parentElement();
+    Element* parentOrHost = is<PseudoElement>(this) ? downcast<PseudoElement>(*this).hostElement() : parentElement();
     if (parentOrHost && !previousSibling()) {
         if (isAfterPseudoElement() && parentOrHost->lastChild())
             return parentOrHost->lastChild();
@@ -884,7 +884,7 @@
 
 Node* Node::pseudoAwareNextSibling() const
 {
-    Element* parentOrHost = isPseudoElement() ? toPseudoElement(this)->hostElement() : parentElement();
+    Element* parentOrHost = is<PseudoElement>(this) ? downcast<PseudoElement>(*this).hostElement() : parentElement();
     if (parentOrHost && !nextSibling()) {
         if (isBeforePseudoElement() && parentOrHost->firstChild())
             return parentOrHost->firstChild();

Modified: trunk/Source/WebCore/dom/NodeTraversal.cpp (174038 => 174039)


--- trunk/Source/WebCore/dom/NodeTraversal.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/dom/NodeTraversal.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -35,13 +35,13 @@
 {
     Node* previous;
     if (current == stayWithin)
-        return 0;
+        return nullptr;
     if ((previous = current->pseudoAwarePreviousSibling())) {
         while (previous->pseudoAwareLastChild())
             previous = previous->pseudoAwareLastChild();
         return previous;
     }
-    return current->isPseudoElement() ? toPseudoElement(current)->hostElement() : current->parentNode();
+    return is<PseudoElement>(current) ? downcast<PseudoElement>(*current).hostElement() : current->parentNode();
 }
 
 Node* nextIncludingPseudo(const Node* current, const Node* stayWithin)
@@ -50,34 +50,34 @@
     if ((next = current->pseudoAwareFirstChild()))
         return next;
     if (current == stayWithin)
-        return 0;
+        return nullptr;
     if ((next = current->pseudoAwareNextSibling()))
         return next;
-    current = current->isPseudoElement() ? toPseudoElement(current)->hostElement() : current->parentNode();
+    current = is<PseudoElement>(current) ? downcast<PseudoElement>(*current).hostElement() : current->parentNode();
     for (; current; current = current->parentNode()) {
         if (current == stayWithin)
-            return 0;
+            return nullptr;
         if ((next = current->pseudoAwareNextSibling()))
             return next;
     }
-    return 0;
+    return nullptr;
 }
 
 Node* nextIncludingPseudoSkippingChildren(const Node* current, const Node* stayWithin)
 {
     Node* next;
     if (current == stayWithin)
-        return 0;
+        return nullptr;
     if ((next = current->pseudoAwareNextSibling()))
         return next;
-    current = current->isPseudoElement() ? toPseudoElement(current)->hostElement() : current->parentNode();
+    current = is<PseudoElement>(current) ? downcast<PseudoElement>(*current).hostElement() : current->parentNode();
     for (; current; current = current->parentNode()) {
         if (current == stayWithin)
-            return 0;
+            return nullptr;
         if ((next = current->pseudoAwareNextSibling()))
             return next;
     }
-    return 0;
+    return nullptr;
 }
 
 Node* nextAncestorSibling(const Node* current)

Modified: trunk/Source/WebCore/dom/ProcessingInstruction.h (174038 => 174039)


--- trunk/Source/WebCore/dom/ProcessingInstruction.h	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/dom/ProcessingInstruction.h	2014-09-28 05:21:30 UTC (rev 174039)
@@ -91,13 +91,10 @@
 #endif
 };
 
-inline bool isProcessingInstruction(const Node& node)
-{
-    return node.nodeType() == Node::PROCESSING_INSTRUCTION_NODE;
-}
+SPECIALIZE_TYPE_TRAITS_BEGIN(ProcessingInstruction)
+    static bool isProcessingInstruction(const Node& node) { return node.nodeType() == Node::PROCESSING_INSTRUCTION_NODE; }
+SPECIALIZE_TYPE_TRAITS_END()
 
-NODE_TYPE_CASTS(ProcessingInstruction)
-
 } //namespace
 
 #endif

Modified: trunk/Source/WebCore/dom/PseudoElement.h (174038 => 174039)


--- trunk/Source/WebCore/dom/PseudoElement.h	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/dom/PseudoElement.h	2014-09-28 05:21:30 UTC (rev 174039)
@@ -77,9 +77,9 @@
     return style && style->display() != NONE && (style->contentData() || style->hasFlowFrom());
 }
 
-void isPseudoElement(const PseudoElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isPseudoElement(const Node& node) { return node.isPseudoElement(); }
-NODE_TYPE_CASTS(PseudoElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(PseudoElement)
+    static bool isPseudoElement(const Node& node) { return node.isPseudoElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
 
 } // namespace
 

Modified: trunk/Source/WebCore/dom/Range.cpp (174038 => 174039)


--- trunk/Source/WebCore/dom/Range.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/dom/Range.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -660,9 +660,8 @@
     case Node::TEXT_NODE:
     case Node::CDATA_SECTION_NODE:
     case Node::COMMENT_NODE:
-        return toCharacterData(node)->length();
     case Node::PROCESSING_INSTRUCTION_NODE:
-        return toProcessingInstruction(node)->data().length();
+        return downcast<CharacterData>(*node).length();
     case Node::ELEMENT_NODE:
     case Node::ATTRIBUTE_NODE:
     case Node::ENTITY_REFERENCE_NODE:
@@ -809,7 +808,7 @@
                 result = c.release();
         }
         if (action == Extract || action == Delete)
-            toCharacterData(container)->deleteData(startOffset, endOffset - startOffset, ec);
+            downcast<CharacterData>(*container).deleteData(startOffset, endOffset - startOffset, ec);
         break;
     case Node::PROCESSING_INSTRUCTION_NODE:
         endOffset = std::min(endOffset, static_cast<ProcessingInstruction*>(container)->data().length());
@@ -824,10 +823,10 @@
                 result = c.release();
         }
         if (action == Extract || action == Delete) {
-            ProcessingInstruction* pi = toProcessingInstruction(container);
-            String data(pi->data());
+            ProcessingInstruction& pi = downcast<ProcessingInstruction>(*container);
+            String data(pi.data());
             data.remove(startOffset, endOffset - startOffset);
-            pi->setData(data, ec);
+            pi.setData(data, ec);
         }
         break;
     case Node::ELEMENT_NODE:
@@ -1152,17 +1151,14 @@
         case Node::ENTITY_NODE:
         case Node::NOTATION_NODE:
             ec = RangeException::INVALID_NODE_TYPE_ERR;
-            return 0;
+            return nullptr;
         case Node::CDATA_SECTION_NODE:
         case Node::COMMENT_NODE:
         case Node::TEXT_NODE:
-            if (static_cast<unsigned>(offset) > toCharacterData(n)->length())
-                ec = INDEX_SIZE_ERR;
-            return 0;
         case Node::PROCESSING_INSTRUCTION_NODE:
-            if (static_cast<unsigned>(offset) > toProcessingInstruction(n)->data().length())
+            if (static_cast<unsigned>(offset) > downcast<CharacterData>(*n).length())
                 ec = INDEX_SIZE_ERR;
-            return 0;
+            return nullptr;
         case Node::ATTRIBUTE_NODE:
         case Node::DOCUMENT_FRAGMENT_NODE:
         case Node::DOCUMENT_NODE:
@@ -1170,7 +1166,7 @@
         case Node::ENTITY_REFERENCE_NODE:
         case Node::XPATH_NAMESPACE_NODE: {
             if (!offset)
-                return 0;
+                return nullptr;
             Node* childBefore = n->traverseToChildAt(offset - 1);
             if (!childBefore)
                 ec = INDEX_SIZE_ERR;
@@ -1178,7 +1174,7 @@
         }
     }
     ASSERT_NOT_REACHED();
-    return 0;
+    return nullptr;
 }
 
 void Range::checkNodeBA(Node* n, ExceptionCode& ec) const

Modified: trunk/Source/WebCore/editing/Editor.cpp (174038 => 174039)


--- trunk/Source/WebCore/editing/Editor.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/editing/Editor.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -588,8 +588,8 @@
     
     if (fragment) {
         Node* child = fragment->firstChild();
-        if (child && fragment->lastChild() == child && child->isCharacterDataNode())
-            return client()->shouldInsertText(toCharacterData(child)->data(), replacingDOMRange.get(), givenAction);
+        if (child && fragment->lastChild() == child && is<CharacterData>(child))
+            return client()->shouldInsertText(downcast<CharacterData>(*child).data(), replacingDOMRange.get(), givenAction);
     }
 
     return client()->shouldInsertNode(fragment.get(), replacingDOMRange.get(), givenAction);

Modified: trunk/Source/WebCore/editing/MarkupAccumulator.cpp (174038 => 174039)


--- trunk/Source/WebCore/editing/MarkupAccumulator.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/editing/MarkupAccumulator.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -556,7 +556,7 @@
         appendText(result, toText(node));
         break;
     case Node::COMMENT_NODE:
-        appendComment(result, toComment(node).data());
+        appendComment(result, downcast<Comment>(node).data());
         break;
     case Node::DOCUMENT_NODE:
         appendXMLDeclaration(result, toDocument(node));
@@ -564,16 +564,16 @@
     case Node::DOCUMENT_FRAGMENT_NODE:
         break;
     case Node::DOCUMENT_TYPE_NODE:
-        appendDocumentType(result, toDocumentType(node));
+        appendDocumentType(result, downcast<DocumentType>(node));
         break;
     case Node::PROCESSING_INSTRUCTION_NODE:
-        appendProcessingInstruction(result, toProcessingInstruction(node).target(), toProcessingInstruction(node).data());
+        appendProcessingInstruction(result, downcast<ProcessingInstruction>(node).target(), downcast<ProcessingInstruction>(node).data());
         break;
     case Node::ELEMENT_NODE:
         appendElement(result, toElement(node), namespaces);
         break;
     case Node::CDATA_SECTION_NODE:
-        appendCDATASection(result, toCDATASection(node).data());
+        appendCDATASection(result, downcast<CDATASection>(node).data());
         break;
     case Node::ATTRIBUTE_NODE:
     case Node::ENTITY_NODE:

Modified: trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm (174038 => 174039)


--- trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm	2014-09-28 05:21:30 UTC (rev 174039)
@@ -2414,8 +2414,8 @@
                 _exitElement(element, depth, startIndex);
             }
         }
-    } else if (node.isCharacterDataNode())
-        _processText(toCharacterData(node));
+    } else if (is<CharacterData>(node))
+        _processText(downcast<CharacterData>(node));
 
     if (isEnd)
         _flags.reachedEnd = YES;

Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (174038 => 174039)


--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -1306,11 +1306,11 @@
         value->setDocumentURL(documentURLString(document));
         value->setBaseURL(documentBaseURLString(document));
         value->setXmlVersion(document->xmlVersion());
-    } else if (node->nodeType() == Node::DOCUMENT_TYPE_NODE) {
-        DocumentType* docType = toDocumentType(node);
-        value->setPublicId(docType->publicId());
-        value->setSystemId(docType->systemId());
-        value->setInternalSubset(docType->internalSubset());
+    } else if (is<DocumentType>(node)) {
+        DocumentType& docType = downcast<DocumentType>(*node);
+        value->setPublicId(docType.publicId());
+        value->setSystemId(docType.systemId());
+        value->setInternalSubset(docType.internalSubset());
     } else if (is<Attr>(node)) {
         Attr& attribute = downcast<Attr>(*node);
         value->setName(attribute.name());

Modified: trunk/Source/WebCore/inspector/InspectorLayerTreeAgent.cpp (174038 => 174039)


--- trunk/Source/WebCore/inspector/InspectorLayerTreeAgent.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/inspector/InspectorLayerTreeAgent.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -183,7 +183,7 @@
         if (isReflection)
             renderer = renderer->parent();
         layerObject->setIsGeneratedContent(true);
-        layerObject->setPseudoElementId(bindPseudoElement(toPseudoElement(renderer->node())));
+        layerObject->setPseudoElementId(bindPseudoElement(downcast<PseudoElement>(renderer->node())));
         if (renderer->isBeforeContent())
             layerObject->setPseudoElement("before");
         else if (renderer->isAfterContent())

Modified: trunk/Source/WebCore/rendering/HitTestResult.cpp (174038 => 174039)


--- trunk/Source/WebCore/rendering/HitTestResult.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/rendering/HitTestResult.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -129,18 +129,18 @@
     setInnerNonSharedNode(node);
 }
 
-void HitTestResult::setInnerNode(Node* n)
+void HitTestResult::setInnerNode(Node* node)
 {
-    if (n && n->isPseudoElement())
-        n = toPseudoElement(n)->hostElement();
-    m_innerNode = n;
+    if (node && is<PseudoElement>(node))
+        node = downcast<PseudoElement>(*node).hostElement();
+    m_innerNode = node;
 }
     
-void HitTestResult::setInnerNonSharedNode(Node* n)
+void HitTestResult::setInnerNonSharedNode(Node* node)
 {
-    if (n && n->isPseudoElement())
-        n = toPseudoElement(n)->hostElement();
-    m_innerNonSharedNode = n;
+    if (node && is<PseudoElement>(node))
+        node = downcast<PseudoElement>(*node).hostElement();
+    m_innerNonSharedNode = node;
 }
 
 void HitTestResult::setURLElement(Element* n) 

Modified: trunk/Source/WebCore/rendering/RenderListItem.cpp (174038 => 174039)


--- trunk/Source/WebCore/rendering/RenderListItem.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/rendering/RenderListItem.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -99,8 +99,8 @@
 static Element* enclosingList(const RenderListItem* listItem)
 {
     Element& listItemElement = listItem->element();
-    Element* firstNode = 0;
-    Element* parent = listItemElement.isPseudoElement() ? toPseudoElement(listItemElement).hostElement() : listItemElement.parentElement();
+    Element* firstNode = nullptr;
+    Element* parent = is<PseudoElement>(listItemElement) ? downcast<PseudoElement>(listItemElement).hostElement() : listItemElement.parentElement();
     // We use parentNode because the enclosing list could be a ShadowRoot that's not Element.
     for (; parent; parent = parent->parentElement()) {
         if (isList(parent))

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (174038 => 174039)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -2549,7 +2549,7 @@
 
 Node* RenderObject::generatingPseudoHostElement() const
 {
-    return toPseudoElement(node())->hostElement();
+    return downcast<PseudoElement>(*node()).hostElement();
 }
 
 void RenderObject::setNeedsBoundariesUpdate()

Modified: trunk/Source/WebCore/xml/XPathFunctions.cpp (174038 => 174039)


--- trunk/Source/WebCore/xml/XPathFunctions.cpp	2014-09-28 04:13:59 UTC (rev 174038)
+++ trunk/Source/WebCore/xml/XPathFunctions.cpp	2014-09-28 05:21:30 UTC (rev 174039)
@@ -362,8 +362,8 @@
 {
     // The local part of an XPath expanded-name matches DOM local name for most node types, except for namespace nodes and processing instruction nodes.
     ASSERT(node->nodeType() != Node::XPATH_NAMESPACE_NODE); // Not supported yet.
-    if (node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE)
-        return toProcessingInstruction(node)->target();
+    if (is<ProcessingInstruction>(node))
+        return downcast<ProcessingInstruction>(*node).target();
     return node->localName().string();
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to