Diff
Modified: trunk/Source/WebCore/ChangeLog (174066 => 174067)
--- trunk/Source/WebCore/ChangeLog 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/ChangeLog 2014-09-29 17:16:32 UTC (rev 174067)
@@ -1,5 +1,58 @@
2014-09-29 Christophe Dumez <cdu...@apple.com>
+ Remove remaining uses of NODE_TYPE_CASTS() from html/
+ https://bugs.webkit.org/show_bug.cgi?id=137172
+
+ Reviewed by Darin Adler.
+
+ Remove remaining uses of NODE_TYPE_CASTS() from html/ and use the new
+ SPECIALIZE_TYPE_TRAITS_*() macro instead so that is<>() / downcast<>()
+ works for those types.
+
+ No new tests, no behavior change.
+
+ * css/SelectorCheckerTestFunctions.h:
+ (WebCore::matchesLangPseudoClass):
+ (WebCore::matchesFutureCuePseudoClass):
+ (WebCore::matchesPastCuePseudoClass):
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::canShareStyleWithElement):
+ The new casting function found a bad cast from a StyledElement to VTTElement.
+ Those two types are unrelated as VTTElement inherits directly from Element.
+ Knowing that |element| in this method cannot be a VTTElement simplifies the
+ logic a bit.
+
+ * dom/NodeRenderingTraversal.cpp:
+ (WebCore::NodeRenderingTraversal::findFirstEnteringInsertionPoints):
+ (WebCore::NodeRenderingTraversal::findLastEnteringInsertionPoints):
+ (WebCore::NodeRenderingTraversal::traverseParent):
+ * html/HTMLLabelElement.cpp:
+ (WebCore::nodeAsSupportedLabelableElement):
+ * html/HTMLTextAreaElement.cpp:
+ (WebCore::HTMLTextAreaElement::innerTextElement):
+ * html/LabelableElement.h:
+ (WebCore::isLabelableElement):
+ * html/shadow/ContentDistributor.cpp:
+ (WebCore::ContentDistributor::ensureInsertionPointList):
+ * html/shadow/InsertionPoint.h:
+ (WebCore::isInsertionPoint):
+ (WebCore::isActiveInsertionPoint):
+ (WebCore::parentNodeForDistribution):
+ * html/shadow/TextControlInnerElements.h:
+ (WebCore::isTextControlInnerTextElement):
+ * html/track/VTTCue.cpp:
+ (WebCore::VTTCue::copyWebVTTNodeToDOMTree):
+ (WebCore::VTTCue::markFutureAndPastNodes):
+ * html/track/WebVTTElement.h:
+ (WebCore::isWebVTTElement):
+ * html/track/WebVTTParser.cpp:
+ (WebCore::WebVTTTreeBuilder::constructTreeFromToken):
+ * style/StyleResolveTree.cpp:
+ (WebCore::Style::attachRenderTree):
+ (WebCore::Style::detachChildren):
+
+2014-09-29 Christophe Dumez <cdu...@apple.com>
+
Make is<>() / downcast<>() work for HTMLDocument and its subclasses
https://bugs.webkit.org/show_bug.cgi?id=137169
Modified: trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h (174066 => 174067)
--- trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h 2014-09-29 17:16:32 UTC (rev 174067)
@@ -127,8 +127,8 @@
{
AtomicString value;
#if ENABLE(VIDEO_TRACK)
- if (element->isWebVTTElement())
- value = toWebVTTElement(element)->language();
+ if (is<WebVTTElement>(element))
+ value = downcast<WebVTTElement>(*element).language();
else
#endif
value = element->computeInheritedLanguage();
@@ -304,12 +304,12 @@
#if ENABLE(VIDEO_TRACK)
ALWAYS_INLINE bool matchesFutureCuePseudoClass(const Element* element)
{
- return (element->isWebVTTElement() && !toWebVTTElement(element)->isPastNode());
+ return is<WebVTTElement>(element) && !downcast<WebVTTElement>(*element).isPastNode();
}
ALWAYS_INLINE bool matchesPastCuePseudoClass(const Element* element)
{
- return (element->isWebVTTElement() && toWebVTTElement(element)->isPastNode());
+ return is<WebVTTElement>(element) && downcast<WebVTTElement>(*element).isPastNode();
}
#endif
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (174066 => 174067)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2014-09-29 17:16:32 UTC (rev 174067)
@@ -650,11 +650,8 @@
#if ENABLE(VIDEO_TRACK)
// Deny sharing styles between WebVTT and non-WebVTT nodes.
- if (element->isWebVTTElement() != state.element()->isWebVTTElement())
+ if (is<WebVTTElement>(state.element()))
return false;
-
- if (element->isWebVTTElement() && state.element()->isWebVTTElement() && toWebVTTElement(element)->isPastNode() != toWebVTTElement(state.element())->isPastNode())
- return false;
#endif
#if ENABLE(FULLSCREEN_API)
Modified: trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp (174066 => 174067)
--- trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp 2014-09-29 17:16:32 UTC (rev 174067)
@@ -72,8 +72,8 @@
ASSERT(node);
if (!isActiveInsertionPoint(node))
return const_cast<Node*>(node);
- const InsertionPoint* insertionPoint = toInsertionPoint(node);
- if (Node* found = findFirstFromDistributedNode(insertionPoint->firstDistributed(), insertionPoint))
+ const InsertionPoint& insertionPoint = downcast<InsertionPoint>(*node);
+ if (Node* found = findFirstFromDistributedNode(insertionPoint.firstDistributed(), &insertionPoint))
return found;
return findFirstSiblingEnteringInsertionPoints(node->firstChild());
}
@@ -101,8 +101,8 @@
ASSERT(node);
if (!isActiveInsertionPoint(node))
return const_cast<Node*>(node);
- const InsertionPoint* insertionPoint = toInsertionPoint(node);
- if (Node* found = findLastFromDistributedNode(insertionPoint->lastDistributed(), insertionPoint))
+ const InsertionPoint& insertionPoint = downcast<InsertionPoint>(*node);
+ if (Node* found = findLastFromDistributedNode(insertionPoint.lastDistributed(), &insertionPoint))
return found;
return findLastSiblingEnteringInsertionPoints(node->lastChild());
}
@@ -135,11 +135,11 @@
if (parent->isShadowRoot())
return shadowRootCrossing == CrossShadowRoot ? toShadowRoot(parent)->hostElement() : parent;
- if (parent->isInsertionPoint()) {
- const InsertionPoint* insertionPoint = toInsertionPoint(parent);
- if (insertionPoint->hasDistribution())
+ if (is<InsertionPoint>(parent)) {
+ const InsertionPoint& insertionPoint = downcast<InsertionPoint>(*parent);
+ if (insertionPoint.hasDistribution())
return nullptr;
- if (insertionPoint->isActive())
+ if (insertionPoint.isActive())
return traverseParent(parent, shadowRootCrossing);
}
return parent;
Modified: trunk/Source/WebCore/html/HTMLLabelElement.cpp (174066 => 174067)
--- trunk/Source/WebCore/html/HTMLLabelElement.cpp 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/html/HTMLLabelElement.cpp 2014-09-29 17:16:32 UTC (rev 174067)
@@ -38,9 +38,9 @@
static LabelableElement* nodeAsSupportedLabelableElement(Node* node)
{
- if (!node || !isLabelableElement(*node))
+ if (!node || !is<LabelableElement>(*node))
return nullptr;
- LabelableElement& element = toLabelableElement(*node);
+ LabelableElement& element = downcast<LabelableElement>(*node);
return element.supportLabels() ? &element : nullptr;
}
Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (174066 => 174067)
--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp 2014-09-29 17:16:32 UTC (rev 174067)
@@ -326,8 +326,7 @@
TextControlInnerTextElement* HTMLTextAreaElement::innerTextElement() const
{
- Node* node = userAgentShadowRoot()->firstChild();
- return toTextControlInnerTextElement(node);
+ return downcast<TextControlInnerTextElement>(userAgentShadowRoot()->firstChild());
}
void HTMLTextAreaElement::rendererWillBeDestroyed()
Modified: trunk/Source/WebCore/html/LabelableElement.h (174066 => 174067)
--- trunk/Source/WebCore/html/LabelableElement.h 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/html/LabelableElement.h 2014-09-29 17:16:32 UTC (rev 174067)
@@ -50,17 +50,11 @@
virtual bool isLabelable() const override final { return true; }
};
-void isLabelableElement(const LabelableElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isLabelableElement(const HTMLElement& element) { return element.isLabelable(); }
-inline bool isLabelableElement(const Node& node) { return is<HTMLElement>(node) && downcast<HTMLElement>(node).isLabelable(); }
+SPECIALIZE_TYPE_TRAITS_BEGIN(LabelableElement)
+ static bool isLabelableElement(const HTMLElement& element) { return element.isLabelable(); }
+ static bool isLabelableElement(const Node& node) { return is<HTMLElement>(node) && isLabelableElement(downcast<HTMLElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
-template <typename ArgType>
-struct NodeTypeCastTraits<const LabelableElement, ArgType> {
- static bool isType(ArgType& node) { return isLabelableElement(node); }
-};
-
-NODE_TYPE_CASTS(LabelableElement)
-
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/html/shadow/ContentDistributor.cpp (174066 => 174067)
--- trunk/Source/WebCore/html/shadow/ContentDistributor.cpp 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/html/shadow/ContentDistributor.cpp 2014-09-29 17:16:32 UTC (rev 174067)
@@ -56,10 +56,8 @@
m_insertionPointListIsValid = true;
ASSERT(m_insertionPointList.isEmpty());
- for (auto& element : descendantsOfType<Element>(*shadowRoot)) {
- if (element.isInsertionPoint())
- m_insertionPointList.append(toInsertionPoint(&element));
- }
+ for (auto& element : descendantsOfType<InsertionPoint>(*shadowRoot))
+ m_insertionPointList.append(&element);
return m_insertionPointList;
}
Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.h (174066 => 174067)
--- trunk/Source/WebCore/html/shadow/InsertionPoint.h 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.h 2014-09-29 17:16:32 UTC (rev 174067)
@@ -75,13 +75,13 @@
bool m_hasDistribution;
};
-inline bool isInsertionPoint(const Node& node) { return node.isInsertionPoint(); }
+SPECIALIZE_TYPE_TRAITS_BEGIN(InsertionPoint)
+ static bool isInsertionPoint(const Node& node) { return node.isInsertionPoint(); }
+SPECIALIZE_TYPE_TRAITS_END()
-NODE_TYPE_CASTS(InsertionPoint);
-
inline bool isActiveInsertionPoint(const Node* node)
{
- return node && node->isInsertionPoint() && toInsertionPoint(node)->isActive();
+ return node && is<InsertionPoint>(node) && downcast<InsertionPoint>(*node).isActive();
}
inline Node* parentNodeForDistribution(const Node* node)
@@ -89,12 +89,12 @@
ASSERT(node);
if (Node* parent = node->parentNode()) {
- if (parent->isInsertionPoint() && toInsertionPoint(parent)->shouldUseFallbackElements())
+ if (is<InsertionPoint>(parent) && downcast<InsertionPoint>(*parent).shouldUseFallbackElements())
return parent->parentNode();
return parent;
}
- return 0;
+ return nullptr;
}
inline Element* parentElementForDistribution(const Node* node)
Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.h (174066 => 174067)
--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.h 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.h 2014-09-29 17:16:32 UTC (rev 174067)
@@ -70,9 +70,10 @@
virtual bool isTextControlInnerTextElement() const override { return true; }
};
-inline bool isTextControlInnerTextElement(const HTMLElement& element) { return element.isTextControlInnerTextElement(); }
-inline bool isTextControlInnerTextElement(const Node& node) { return is<HTMLElement>(node) && isTextControlInnerTextElement(downcast<HTMLElement>(node)); }
-NODE_TYPE_CASTS(TextControlInnerTextElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(TextControlInnerTextElement)
+ static bool isTextControlInnerTextElement(const HTMLElement& element) { return element.isTextControlInnerTextElement(); }
+ static bool isTextControlInnerTextElement(const Node& node) { return is<HTMLElement>(node) && isTextControlInnerTextElement(downcast<HTMLElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
class SearchFieldResultsButtonElement final : public HTMLDivElement {
public:
Modified: trunk/Source/WebCore/html/track/VTTCue.cpp (174066 => 174067)
--- trunk/Source/WebCore/html/track/VTTCue.cpp 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/html/track/VTTCue.cpp 2014-09-29 17:16:32 UTC (rev 174067)
@@ -497,8 +497,8 @@
{
for (Node* node = webVTTNode->firstChild(); node; node = node->nextSibling()) {
RefPtr<Node> clonedNode;
- if (node->isWebVTTElement())
- clonedNode = toWebVTTElement(node)->createEquivalentHTMLElement(ownerDocument());
+ if (is<WebVTTElement>(node))
+ clonedNode = downcast<WebVTTElement>(*node).createEquivalentHTMLElement(ownerDocument());
else
clonedNode = node->cloneNode(false);
parent->appendChild(clonedNode, ASSERT_NO_EXCEPTION);
@@ -766,8 +766,8 @@
isPastNode = false;
}
- if (child->isWebVTTElement()) {
- toWebVTTElement(child)->setIsPastNode(isPastNode);
+ if (is<WebVTTElement>(child)) {
+ downcast<WebVTTElement>(*child).setIsPastNode(isPastNode);
// Make an elemenet id match a cue id for style matching purposes.
if (!id().isEmpty())
toElement(child)->setIdAttribute(id());
Modified: trunk/Source/WebCore/html/track/WebVTTElement.h (174066 => 174067)
--- trunk/Source/WebCore/html/track/WebVTTElement.h 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/html/track/WebVTTElement.h 2014-09-29 17:16:32 UTC (rev 174067)
@@ -80,9 +80,9 @@
AtomicString m_language;
};
-void isWebVTTElement(const WebVTTElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isWebVTTElement(const Node& node) { return node.isWebVTTElement(); }
-NODE_TYPE_CASTS(WebVTTElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebVTTElement)
+ static bool isWebVTTElement(const Node& node) { return node.isWebVTTElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
} // namespace WebCore
Modified: trunk/Source/WebCore/html/track/WebVTTParser.cpp (174066 => 174067)
--- trunk/Source/WebCore/html/track/WebVTTParser.cpp 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/html/track/WebVTTParser.cpp 2014-09-29 17:16:32 UTC (rev 174067)
@@ -561,7 +561,7 @@
if (nodeType == WebVTTNodeTypeNone)
break;
- WebVTTNodeType currentType = m_currentNode->isWebVTTElement() ? toWebVTTElement(m_currentNode.get())->webVTTNodeType() : WebVTTNodeTypeNone;
+ WebVTTNodeType currentType = is<WebVTTElement>(*m_currentNode) ? downcast<WebVTTElement>(*m_currentNode).webVTTNodeType() : WebVTTNodeTypeNone;
// <rt> is only allowed if the current node is <ruby>.
if (nodeType == WebVTTNodeTypeRubyText && currentType != WebVTTNodeTypeRuby)
break;
@@ -589,10 +589,10 @@
// The only non-VTTElement would be the DocumentFragment root. (Text
// nodes and PIs will never appear as m_currentNode.)
- if (!m_currentNode->isWebVTTElement())
+ if (!is<WebVTTElement>(*m_currentNode))
break;
- WebVTTNodeType currentType = toWebVTTElement(m_currentNode.get())->webVTTNodeType();
+ WebVTTNodeType currentType = downcast<WebVTTElement>(*m_currentNode).webVTTNodeType();
bool matchesCurrent = nodeType == currentType;
if (!matchesCurrent) {
// </ruby> auto-closes <rt>
Modified: trunk/Source/WebCore/style/StyleResolveTree.cpp (174066 => 174067)
--- trunk/Source/WebCore/style/StyleResolveTree.cpp 2014-09-29 17:05:50 UTC (rev 174066)
+++ trunk/Source/WebCore/style/StyleResolveTree.cpp 2014-09-29 17:16:32 UTC (rev 174067)
@@ -352,7 +352,7 @@
static void invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(Node& current)
{
- if (isInsertionPoint(current))
+ if (is<InsertionPoint>(current))
return;
// This function finds sibling text renderers where the results of textRendererIsNeeded may have changed as a result of
// the current node gaining or losing the renderer. This can only affect white space text nodes.
@@ -606,8 +606,8 @@
PostResolutionCallbackDisabler callbackDisabler(current.document());
WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
- if (isInsertionPoint(current)) {
- attachDistributedChildren(toInsertionPoint(current), inheritedStyle, renderTreePosition);
+ if (is<InsertionPoint>(current)) {
+ attachDistributedChildren(downcast<InsertionPoint>(current), inheritedStyle, renderTreePosition);
current.clearNeedsStyleRecalc();
current.clearChildNeedsStyleRecalc();
return;
@@ -662,8 +662,8 @@
static void detachChildren(ContainerNode& current, DetachType detachType)
{
- if (isInsertionPoint(current))
- detachDistributedChildren(toInsertionPoint(current));
+ if (is<InsertionPoint>(current))
+ detachDistributedChildren(downcast<InsertionPoint>(current));
for (Node* child = current.firstChild(); child; child = child->nextSibling()) {
if (child->isTextNode()) {
@@ -899,7 +899,7 @@
{
ASSERT(change != Detach);
- if (isInsertionPoint(current)) {
+ if (is<InsertionPoint>(current)) {
current.clearNeedsStyleRecalc();
current.clearChildNeedsStyleRecalc();
return;