Diff
Modified: trunk/Source/WebCore/ChangeLog (174068 => 174069)
--- trunk/Source/WebCore/ChangeLog 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/ChangeLog 2014-09-29 17:35:28 UTC (rev 174069)
@@ -1,5 +1,86 @@
2014-09-29 Christophe Dumez <cdu...@apple.com>
+ Use the new is<>() / downcast<>() for ShadowRoot and StyledElement
+ https://bugs.webkit.org/show_bug.cgi?id=137199
+
+ Reviewed by Darin Adler.
+
+ Use the new is<>() / downcast<>() for ShadowRoot and StyledElement and
+ move towards getting rid of the NODE_TYPE_CASTS() macro.
+
+ No new tests, no behavior change.
+
+ * css/ElementRuleCollector.cpp:
+ (WebCore::ElementRuleCollector::matchAllRules):
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::State::initElement):
+ (WebCore::StyleResolver::State::initForStyleResolve):
+ (WebCore::StyleResolver::locateCousinList):
+ (WebCore::StyleResolver::findSiblingForStyleSharing):
+ * dom/Attr.cpp:
+ (WebCore::Attr::style):
+ * dom/Element.cpp:
+ (WebCore::Element::removeAttribute):
+ * dom/EventDispatcher.cpp:
+ (WebCore::EventRelatedNodeResolver::moveToParentOrShadowHost):
+ (WebCore::EventRelatedNodeResolver::findHostOfTreeScopeInTargetTreeScope):
+ (WebCore::eventTargetRespectingTargetRules):
+ (WebCore::EventPath::EventPath):
+ * dom/Node.cpp:
+ (WebCore::Node::containingShadowRoot):
+ (WebCore::Node::parentOrShadowHostElement):
+ (WebCore::Node::showNodePathForThis):
+ * dom/NodeRenderingTraversal.cpp:
+ (WebCore::NodeRenderingTraversal::traverseParent):
+ * dom/ShadowRoot.h:
+ (WebCore::isShadowRoot):
+ (WebCore::Node::shadowRoot):
+ (WebCore::Node::parentOrShadowHostNode):
+ * dom/StyledElement.h:
+ (WebCore::StyledElement::presentationAttributeStyle):
+ (WebCore::isStyledElement):
+ * dom/Text.cpp:
+ (WebCore::isSVGShadowText):
+ * dom/TreeScope.cpp:
+ (WebCore::TreeScope::focusedElement):
+ * dom/TreeScopeAdopter.cpp:
+ (WebCore::TreeScopeAdopter::moveNodeToNewDocument):
+ * editing/ApplyStyleCommand.cpp:
+ (WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock):
+ (WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode):
+ * editing/EditingStyle.cpp:
+ (WebCore::EditingStyle::wrappingStyleForSerialization):
+ * editing/Editor.cpp:
+ (WebCore::Editor::applyEditingStyleToElement):
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
+ * editing/cocoa/HTMLConverter.mm:
+ (HTMLConverterCaches::inlineStylePropertyForElement):
+ * editing/markup.cpp:
+ (WebCore::StyledMarkupAccumulator::appendElement):
+ * inspector/InspectorCSSAgent.cpp:
+ (WebCore::InspectorCSSAgent::buildObjectForAttributesStyle):
+ * inspector/InspectorOverlay.cpp:
+ (WebCore::buildObjectForElementInfo):
+ * page/DragController.cpp:
+ (WebCore::asFileInput):
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::handleMousePressEvent):
+ * page/FocusController.cpp:
+ (WebCore::FocusNavigationScope::owner):
+ * page/PageSerializer.cpp:
+ (WebCore::PageSerializer::serializeFrame):
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::resize):
+ * svg/SVGElement.cpp:
+ (WebCore::SVGElement::title):
+ * testing/Internals.cpp:
+ (WebCore::Internals::shadowRoot):
+ (WebCore::Internals::shadowRootType):
+ (WebCore::Internals::includerFor):
+
+2014-09-29 Christophe Dumez <cdu...@apple.com>
+
Use the new is<>() / downcast<>() for Text Nodes
https://bugs.webkit.org/show_bug.cgi?id=137188
Modified: trunk/Source/WebCore/css/ElementRuleCollector.cpp (174068 => 174069)
--- trunk/Source/WebCore/css/ElementRuleCollector.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/css/ElementRuleCollector.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -388,8 +388,8 @@
matchUserRules(false);
// Now check author rules, beginning first with presentational attributes mapped from HTML.
- if (m_element.isStyledElement()) {
- StyledElement& styledElement = toStyledElement(m_element);
+ if (is<StyledElement>(m_element)) {
+ StyledElement& styledElement = downcast<StyledElement>(m_element);
addElementStyleProperties(styledElement.presentationAttributeStyle());
// Now we check additional mapped declarations.
@@ -409,8 +409,8 @@
if (matchAuthorAndUserStyles)
matchAuthorRules(false);
- if (matchAuthorAndUserStyles && m_element.isStyledElement()) {
- StyledElement& styledElement = toStyledElement(m_element);
+ if (matchAuthorAndUserStyles && is<StyledElement>(m_element)) {
+ StyledElement& styledElement = downcast<StyledElement>(m_element);
// Now check our inline style attribute.
if (styledElement.inlineStyle()) {
// Inline style is immutable as long as there is no CSSOM wrapper.
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (174068 => 174069)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -385,11 +385,11 @@
m_cssToLengthConversionData = CSSToLengthConversionData(m_style.get(), m_rootElementStyle, m_element ? document().renderView() : nullptr);
}
-inline void StyleResolver::State::initElement(Element* e)
+inline void StyleResolver::State::initElement(Element* element)
{
- m_element = e;
- m_styledElement = e && e->isStyledElement() ? toStyledElement(e) : nullptr;
- m_elementLinkState = e ? e->document().visitedLinkState().determineLinkState(*e) : NotInsideLink;
+ m_element = element;
+ m_styledElement = element && is<StyledElement>(element) ? downcast<StyledElement>(element) : nullptr;
+ m_elementLinkState = element ? element->document().visitedLinkState().determineLinkState(*element) : NotInsideLink;
updateConversionData();
}
@@ -409,7 +409,7 @@
m_regionForStyling = regionForStyling;
if (e) {
- bool resetStyleInheritance = hasShadowRootParent(*e) && toShadowRoot(e->parentNode())->resetStyleInheritance();
+ bool resetStyleInheritance = hasShadowRootParent(*e) && downcast<ShadowRoot>(*e->parentNode()).resetStyleInheritance();
m_parentStyle = resetStyleInheritance ? nullptr : parentStyle;
} else
m_parentStyle = parentStyle;
@@ -445,9 +445,9 @@
{
if (visitedNodeCount >= cStyleSearchThreshold * cStyleSearchLevelThreshold)
return nullptr;
- if (!parent || !parent->isStyledElement())
+ if (!parent || !is<StyledElement>(parent))
return nullptr;
- StyledElement* styledParent = toStyledElement(parent);
+ StyledElement* styledParent = downcast<StyledElement>(parent);
if (styledParent->inlineStyle())
return nullptr;
if (is<SVGElement>(styledParent) && downcast<SVGElement>(*styledParent).animatedSMILStyleProperties())
@@ -664,14 +664,14 @@
inline StyledElement* StyleResolver::findSiblingForStyleSharing(Node* node, unsigned& count) const
{
for (; node; node = node->previousSibling()) {
- if (!node->isStyledElement())
+ if (!is<StyledElement>(node))
continue;
- if (canShareStyleWithElement(toStyledElement(node)))
+ if (canShareStyleWithElement(downcast<StyledElement>(node)))
break;
if (count++ == cStyleSearchThreshold)
- return 0;
+ return nullptr;
}
- return toStyledElement(node);
+ return downcast<StyledElement>(node);
}
RenderStyle* StyleResolver::locateSharedStyle()
Modified: trunk/Source/WebCore/dom/Attr.cpp (174068 => 174069)
--- trunk/Source/WebCore/dom/Attr.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/dom/Attr.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -188,10 +188,10 @@
CSSStyleDeclaration* Attr::style()
{
// This function only exists to support the Obj-C bindings.
- if (!m_element || !m_element->isStyledElement())
+ if (!m_element || !is<StyledElement>(m_element))
return nullptr;
m_style = MutableStyleProperties::create();
- toStyledElement(m_element)->collectStyleForPresentationAttribute(qualifiedName(), value(), *m_style);
+ downcast<StyledElement>(*m_element).collectStyleForPresentationAttribute(qualifiedName(), value(), *m_style);
return m_style->ensureCSSStyleDeclaration();
}
Modified: trunk/Source/WebCore/dom/Element.cpp (174068 => 174069)
--- trunk/Source/WebCore/dom/Element.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/dom/Element.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -1825,8 +1825,8 @@
AtomicString localName = shouldIgnoreAttributeCase(*this) ? name.lower() : name;
unsigned index = elementData()->findAttributeIndexByName(localName, false);
if (index == ElementData::attributeNotFound) {
- if (UNLIKELY(localName == styleAttr) && elementData()->styleAttributeIsDirty() && isStyledElement())
- toStyledElement(this)->removeAllInlineStyleProperties();
+ if (UNLIKELY(localName == styleAttr) && elementData()->styleAttributeIsDirty() && is<StyledElement>(*this))
+ downcast<StyledElement>(*this).removeAllInlineStyleProperties();
return false;
}
Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (174068 => 174069)
--- trunk/Source/WebCore/dom/EventDispatcher.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -143,8 +143,8 @@
return m_relatedNodeInCurrentTreeScope;
if (m_currentTreeScope) {
- ASSERT(m_currentTreeScope->rootNode().isShadowRoot());
- ASSERT(&newTarget == toShadowRoot(m_currentTreeScope->rootNode()).hostElement());
+ ASSERT(is<ShadowRoot>(m_currentTreeScope->rootNode()));
+ ASSERT(&newTarget == downcast<ShadowRoot>(m_currentTreeScope->rootNode()).hostElement());
ASSERT(m_currentTreeScope->parentTreeScope() == &newTreeScope);
}
@@ -184,8 +184,8 @@
ASSERT_WITH_SECURITY_IMPLICATION(&previousHost->treeScope() == &targetScope);
return previousHost;
}
- if (scope->rootNode().isShadowRoot())
- previousHost = toShadowRoot(scope->rootNode()).hostElement();
+ if (is<ShadowRoot>(scope->rootNode()))
+ previousHost = downcast<ShadowRoot>(scope->rootNode()).hostElement();
else
ASSERT_WITH_SECURITY_IMPLICATION(!scope->parentTreeScope());
}
@@ -217,7 +217,7 @@
// Spec: The event handling for the non-exposed tree works as if the referenced element had been textually included
// as a deeply cloned child of the 'use' element, except that events are dispatched to the SVGElementInstance objects
auto& rootNode = referenceNode.treeScope().rootNode();
- Element* shadowHostElement = rootNode.isShadowRoot() ? toShadowRoot(rootNode).hostElement() : nullptr;
+ Element* shadowHostElement = is<ShadowRoot>(rootNode) ? downcast<ShadowRoot>(rootNode).hostElement() : nullptr;
// At this time, SVG nodes are not supported in non-<use> shadow trees.
if (!shadowHostElement || !shadowHostElement->hasTagName(SVGNames::useTag))
return referenceNode;
@@ -447,12 +447,12 @@
m_path.append(std::make_unique<EventContext>(node, ¤tTarget, target));
if (!inDocument)
return;
- if (node->isShadowRoot())
+ if (is<ShadowRoot>(node))
break;
}
- if (!node || !shouldEventCrossShadowBoundary(event, *toShadowRoot(node), *target))
+ if (!node || !shouldEventCrossShadowBoundary(event, downcast<ShadowRoot>(*node), *target))
return;
- node = toShadowRoot(node)->hostElement();
+ node = downcast<ShadowRoot>(*node).hostElement();
}
}
Modified: trunk/Source/WebCore/dom/Node.cpp (174068 => 174069)
--- trunk/Source/WebCore/dom/Node.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/dom/Node.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -974,7 +974,7 @@
ShadowRoot* Node::containingShadowRoot() const
{
ContainerNode& root = treeScope().rootNode();
- return root.isShadowRoot() ? toShadowRoot(&root) : nullptr;
+ return is<ShadowRoot>(root) ? downcast<ShadowRoot>(&root) : nullptr;
}
Node* Node::nonBoundaryShadowTreeRootNode()
@@ -1002,13 +1002,13 @@
{
ContainerNode* parent = parentOrShadowHostNode();
if (!parent)
- return 0;
+ return nullptr;
- if (parent->isShadowRoot())
- return toShadowRoot(parent)->hostElement();
+ if (is<ShadowRoot>(parent))
+ return downcast<ShadowRoot>(parent)->hostElement();
if (!parent->isElementNode())
- return 0;
+ return nullptr;
return toElement(parent);
}
@@ -1572,9 +1572,9 @@
}
for (unsigned index = chain.size(); index > 0; --index) {
const Node* node = chain[index - 1];
- if (node->isShadowRoot()) {
+ if (is<ShadowRoot>(node)) {
int count = 0;
- for (const ShadowRoot* shadowRoot = toShadowRoot(node); shadowRoot && shadowRoot != node; shadowRoot = shadowRoot->shadowRoot())
+ for (const ShadowRoot* shadowRoot = downcast<ShadowRoot>(node); shadowRoot && shadowRoot != node; shadowRoot = shadowRoot->shadowRoot())
++count;
fprintf(stderr, "/#shadow-root[%d]", count);
continue;
Modified: trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp (174068 => 174069)
--- trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -121,7 +121,7 @@
static ContainerNode* traverseParent(const Node* node, ShadowRootCrossing shadowRootCrossing)
{
if (shadowRootCrossing == DontCrossShadowRoot && node->isShadowRoot())
- return 0;
+ return nullptr;
if (nodeCanBeDistributed(node)) {
if (InsertionPoint* insertionPoint = findInsertionPointOf(node))
@@ -132,8 +132,8 @@
if (!parent)
return nullptr;
- if (parent->isShadowRoot())
- return shadowRootCrossing == CrossShadowRoot ? toShadowRoot(parent)->hostElement() : parent;
+ if (is<ShadowRoot>(parent))
+ return shadowRootCrossing == CrossShadowRoot ? downcast<ShadowRoot>(parent)->hostElement() : parent;
if (is<InsertionPoint>(parent)) {
const InsertionPoint& insertionPoint = downcast<InsertionPoint>(*parent);
Modified: trunk/Source/WebCore/dom/ShadowRoot.h (174068 => 174069)
--- trunk/Source/WebCore/dom/ShadowRoot.h 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/dom/ShadowRoot.h 2014-09-29 17:35:28 UTC (rev 174069)
@@ -95,22 +95,22 @@
return treeScope().focusedElement();
}
-inline bool isShadowRoot(const Node& node) { return node.isShadowRoot(); }
+SPECIALIZE_TYPE_TRAITS_BEGIN(ShadowRoot)
+ static bool isShadowRoot(const Node& node) { return node.isShadowRoot(); }
+SPECIALIZE_TYPE_TRAITS_END()
-NODE_TYPE_CASTS(ShadowRoot)
-
inline ShadowRoot* Node::shadowRoot() const
{
if (!isElementNode())
- return 0;
+ return nullptr;
return toElement(this)->shadowRoot();
}
inline ContainerNode* Node::parentOrShadowHostNode() const
{
ASSERT(isMainThreadOrGCThread());
- if (isShadowRoot())
- return toShadowRoot(this)->hostElement();
+ if (is<ShadowRoot>(this))
+ return downcast<ShadowRoot>(*this).hostElement();
return parentNode();
}
Modified: trunk/Source/WebCore/dom/StyledElement.h (174068 => 174069)
--- trunk/Source/WebCore/dom/StyledElement.h 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/dom/StyledElement.h 2014-09-29 17:35:28 UTC (rev 174069)
@@ -100,16 +100,16 @@
inline const StyleProperties* StyledElement::presentationAttributeStyle()
{
if (!elementData())
- return 0;
+ return nullptr;
if (elementData()->presentationAttributeStyleIsDirty())
rebuildPresentationAttributeStyle();
return elementData()->presentationAttributeStyle();
}
-inline bool isStyledElement(const Node& node) { return node.isStyledElement(); }
+SPECIALIZE_TYPE_TRAITS_BEGIN(StyledElement)
+ static bool isStyledElement(const Node& node) { return node.isStyledElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
-NODE_TYPE_CASTS(StyledElement)
-
} //namespace
#endif
Modified: trunk/Source/WebCore/dom/Text.cpp (174068 => 174069)
--- trunk/Source/WebCore/dom/Text.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/dom/Text.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -178,7 +178,7 @@
static bool isSVGShadowText(Text* text)
{
Node* parentNode = text->parentNode();
- return parentNode->isShadowRoot() && toShadowRoot(parentNode)->hostElement()->hasTagName(SVGNames::trefTag);
+ return is<ShadowRoot>(parentNode) && downcast<ShadowRoot>(*parentNode).hostElement()->hasTagName(SVGNames::trefTag);
}
static bool isSVGText(Text* text)
Modified: trunk/Source/WebCore/dom/TreeScope.cpp (174068 => 174069)
--- trunk/Source/WebCore/dom/TreeScope.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/dom/TreeScope.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -311,7 +311,7 @@
return nullptr;
TreeScope* treeScope = &element->treeScope();
while (treeScope != this && treeScope != &document) {
- element = toShadowRoot(treeScope->rootNode()).hostElement();
+ element = downcast<ShadowRoot>(treeScope->rootNode()).hostElement();
treeScope = &element->treeScope();
}
if (this != treeScope)
Modified: trunk/Source/WebCore/dom/TreeScopeAdopter.cpp (174068 => 174069)
--- trunk/Source/WebCore/dom/TreeScopeAdopter.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/dom/TreeScopeAdopter.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -124,8 +124,8 @@
if (oldDocument)
oldDocument->moveNodeIteratorsToNewDocument(node, newDocument);
- if (node->isShadowRoot())
- toShadowRoot(node)->setDocumentScope(newDocument);
+ if (is<ShadowRoot>(node))
+ downcast<ShadowRoot>(*node).setDocumentScope(newDocument);
#ifndef NDEBUG
didMoveToNewDocumentWasCalled = false;
Modified: trunk/Source/WebCore/editing/ApplyStyleCommand.cpp (174068 => 174069)
--- trunk/Source/WebCore/editing/ApplyStyleCommand.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/editing/ApplyStyleCommand.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -502,14 +502,14 @@
if (!block)
return;
- Node* parent = 0;
- for (Node* n = node->parentNode(); n != block && n != unsplitAncestor; n = parent) {
- parent = n->parentNode();
- if (!n->isStyledElement())
+ Node* parent = nullptr;
+ for (Node* ancestor = node->parentNode(); ancestor != block && ancestor != unsplitAncestor; ancestor = parent) {
+ parent = ancestor->parentNode();
+ if (!is<StyledElement>(ancestor))
continue;
- StyledElement* element = toStyledElement(n);
- int unicodeBidi = toIdentifier(ComputedStyleExtractor(element).propertyValue(CSSPropertyUnicodeBidi));
+ StyledElement& element = downcast<StyledElement>(*ancestor);
+ int unicodeBidi = toIdentifier(ComputedStyleExtractor(&element).propertyValue(CSSPropertyUnicodeBidi));
if (!unicodeBidi || unicodeBidi == CSSValueNormal)
continue;
@@ -517,17 +517,17 @@
// and all matching style rules in order to determine how to best set the unicode-bidi property to 'normal'.
// For now, it assumes that if the 'dir' attribute is present, then removing it will suffice, and
// otherwise it sets the property in the inline style declaration.
- if (element->fastHasAttribute(dirAttr)) {
+ if (element.fastHasAttribute(dirAttr)) {
// FIXME: If this is a BDO element, we should probably just remove it if it has no
// other attributes, like we (should) do with B and I elements.
- removeNodeAttribute(element, dirAttr);
+ removeNodeAttribute(&element, dirAttr);
} else {
- RefPtr<MutableStyleProperties> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
+ RefPtr<MutableStyleProperties> inlineStyle = copyStyleOrCreateEmpty(element.inlineStyle());
inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal);
inlineStyle->removeProperty(CSSPropertyDirection);
- setNodeAttribute(element, styleAttr, inlineStyle->asText());
- if (isSpanWithoutAttributesOrUnstyledStyleSpan(element))
- removeNodePreservingChildren(element);
+ setNodeAttribute(&element, styleAttr, inlineStyle->asText());
+ if (isSpanWithoutAttributesOrUnstyledStyleSpan(&element))
+ removeNodePreservingChildren(&element);
}
}
}
@@ -1040,8 +1040,8 @@
getChildNodes(*current.get(), currentChildren);
RefPtr<StyledElement> styledElement;
- if (current->isStyledElement() && isStyledInlineElementToRemove(toElement(current.get()))) {
- styledElement = toStyledElement(current.get());
+ if (is<StyledElement>(*current) && isStyledInlineElementToRemove(toElement(current.get()))) {
+ styledElement = downcast<StyledElement>(current.get());
elementsToPushDown.append(*styledElement);
}
Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (174068 => 174069)
--- trunk/Source/WebCore/editing/EditingStyle.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -1036,8 +1036,8 @@
// When not annotating for interchange, we only preserve inline style declarations.
for (Node* node = context; node && !node->isDocumentNode(); node = node->parentNode()) {
- if (node->isStyledElement() && !isMailBlockquote(node)) {
- wrappingStyle->mergeInlineAndImplicitStyleOfElement(toStyledElement(node), EditingStyle::DoNotOverrideValues,
+ if (is<StyledElement>(node) && !isMailBlockquote(node)) {
+ wrappingStyle->mergeInlineAndImplicitStyleOfElement(downcast<StyledElement>(node), EditingStyle::DoNotOverrideValues,
EditingStyle::EditingPropertiesInEffect);
}
}
Modified: trunk/Source/WebCore/editing/Editor.cpp (174068 => 174069)
--- trunk/Source/WebCore/editing/Editor.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/editing/Editor.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -3107,12 +3107,12 @@
{
if (!element)
return;
- ASSERT(element->isStyledElement());
- if (!element->isStyledElement())
+ ASSERT(is<StyledElement>(element));
+ if (!is<StyledElement>(element))
return;
// Mutate using the CSSOM wrapper so we get the same event behavior as a script.
- CSSStyleDeclaration* style = toStyledElement(element)->style();
+ CSSStyleDeclaration* style = downcast<StyledElement>(*element).style();
style->setPropertyInternal(CSSPropertyWordWrap, "break-word", false, IGNORE_EXCEPTION);
style->setPropertyInternal(CSSPropertyWebkitNbspMode, "space", false, IGNORE_EXCEPTION);
style->setPropertyInternal(CSSPropertyWebkitLineBreak, "after-white-space", false, IGNORE_EXCEPTION);
Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (174068 => 174069)
--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -480,10 +480,10 @@
// FIXME: <rdar://problem/5371536> Style rules that match pasted content can change it's appearance
next = NodeTraversal::next(node.get());
- if (!node->isStyledElement())
+ if (!is<StyledElement>(*node))
continue;
- StyledElement* element = toStyledElement(node.get());
+ StyledElement* element = downcast<StyledElement>(node.get());
const StyleProperties* inlineStyle = element->inlineStyle();
RefPtr<EditingStyle> newInlineStyle = EditingStyle::create(inlineStyle);
@@ -495,7 +495,7 @@
if (newInlineStyle->conflictsWithImplicitStyleOfElement(&htmlElement)) {
// e.g. <b style="font-weight: normal;"> is converted to <span style="font-weight: normal;">
node = replaceElementWithSpanPreservingChildrenAndAttributes(&htmlElement);
- element = toStyledElement(node.get());
+ element = downcast<StyledElement>(node.get());
insertedNodes.didReplaceNode(&htmlElement, node.get());
} else if (newInlineStyle->extractConflictingImplicitStyleOfAttributes(&htmlElement, EditingStyle::PreserveWritingDirection, 0, attributes,
EditingStyle::DoNotExtractMatchingStyle)) {
Modified: trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm (174068 => 174069)
--- trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm 2014-09-29 17:35:28 UTC (rev 174069)
@@ -709,9 +709,9 @@
PassRefPtr<CSSValue> HTMLConverterCaches::inlineStylePropertyForElement(Element& element, CSSPropertyID propertyId)
{
- if (propertyId == CSSPropertyInvalid || !element.isStyledElement())
+ if (propertyId == CSSPropertyInvalid || !is<StyledElement>(element))
return nullptr;
- const StyleProperties* properties = toStyledElement(element).inlineStyle();
+ const StyleProperties* properties = downcast<StyledElement>(element).inlineStyle();
if (!properties)
return nullptr;
return properties->getPropertyCSSValue(propertyId);
Modified: trunk/Source/WebCore/editing/markup.cpp (174068 => 174069)
--- trunk/Source/WebCore/editing/markup.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/editing/markup.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -322,8 +322,8 @@
} else
newInlineStyle = EditingStyle::create();
- if (element.isStyledElement() && toStyledElement(element).inlineStyle())
- newInlineStyle->overrideWithStyle(toStyledElement(element).inlineStyle());
+ if (is<StyledElement>(element) && downcast<StyledElement>(element).inlineStyle())
+ newInlineStyle->overrideWithStyle(downcast<StyledElement>(element).inlineStyle());
if (shouldAnnotateOrForceInline) {
if (shouldAnnotate())
Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (174068 => 174069)
--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -1086,11 +1086,11 @@
PassRefPtr<Inspector::Protocol::CSS::CSSStyle> InspectorCSSAgent::buildObjectForAttributesStyle(Element* element)
{
- if (!element->isStyledElement())
+ if (!is<StyledElement>(element))
return nullptr;
// FIXME: Ugliness below.
- StyleProperties* attributeStyle = const_cast<StyleProperties*>(toStyledElement(element)->presentationAttributeStyle());
+ StyleProperties* attributeStyle = const_cast<StyleProperties*>(downcast<StyledElement>(element)->presentationAttributeStyle());
if (!attributeStyle)
return nullptr;
Modified: trunk/Source/WebCore/inspector/InspectorOverlay.cpp (174068 => 174069)
--- trunk/Source/WebCore/inspector/InspectorOverlay.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/inspector/InspectorOverlay.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -686,9 +686,9 @@
elementInfo->setString("tagName", isXHTML ? element->nodeName() : element->nodeName().lower());
elementInfo->setString("idValue", element->getIdAttribute());
HashSet<AtomicString> usedClassNames;
- if (element->hasClass() && element->isStyledElement()) {
+ if (element->hasClass() && is<StyledElement>(element)) {
StringBuilder classNames;
- const SpaceSplitString& classNamesString = toStyledElement(element)->classNames();
+ const SpaceSplitString& classNamesString = downcast<StyledElement>(*element).classNames();
size_t classNameCount = classNamesString.size();
for (size_t i = 0; i < classNameCount; ++i) {
const AtomicString& className = classNamesString[i];
Modified: trunk/Source/WebCore/page/DragController.cpp (174068 => 174069)
--- trunk/Source/WebCore/page/DragController.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/page/DragController.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -273,8 +273,8 @@
HTMLInputElement* inputElement = node->toInputElement();
// If this is a button inside of the a file input, move up to the file input.
- if (inputElement && inputElement->isTextButton() && inputElement->treeScope().rootNode().isShadowRoot())
- inputElement = toShadowRoot(inputElement->treeScope().rootNode()).hostElement()->toInputElement();
+ if (inputElement && inputElement->isTextButton() && is<ShadowRoot>(inputElement->treeScope().rootNode()))
+ inputElement = downcast<ShadowRoot>(inputElement->treeScope().rootNode()).hostElement()->toInputElement();
return inputElement && inputElement->isFileUpload() ? inputElement : 0;
}
Modified: trunk/Source/WebCore/page/EventHandler.cpp (174068 => 174069)
--- trunk/Source/WebCore/page/EventHandler.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -1760,7 +1760,7 @@
// If a mouse event handler changes the input element type to one that has a widget associated,
// we'd like to EventHandler::handleMousePressEvent to pass the event to the widget and thus the
// event target node can't still be the shadow node.
- if (mouseEvent.targetNode()->isShadowRoot() && is<HTMLInputElement>(toShadowRoot(mouseEvent.targetNode())->hostElement()))
+ if (is<ShadowRoot>(mouseEvent.targetNode()) && is<HTMLInputElement>(downcast<ShadowRoot>(*mouseEvent.targetNode()).hostElement()))
mouseEvent = m_frame.document()->prepareMouseEvent(HitTestRequest(), documentPoint, platformMouseEvent);
FrameView* view = m_frame.view();
Modified: trunk/Source/WebCore/page/FocusController.cpp (174068 => 174069)
--- trunk/Source/WebCore/page/FocusController.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/page/FocusController.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -82,11 +82,11 @@
Element* FocusNavigationScope::owner() const
{
ContainerNode* root = rootNode();
- if (root->isShadowRoot())
- return toShadowRoot(root)->hostElement();
+ if (is<ShadowRoot>(root))
+ return downcast<ShadowRoot>(*root).hostElement();
if (Frame* frame = root->document().frame())
return frame->ownerElement();
- return 0;
+ return nullptr;
}
FocusNavigationScope FocusNavigationScope::focusNavigationScopeOf(Node* node)
Modified: trunk/Source/WebCore/page/PageSerializer.cpp (174068 => 174069)
--- trunk/Source/WebCore/page/PageSerializer.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/page/PageSerializer.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -225,25 +225,25 @@
if (!node->isElementNode())
continue;
- Element* element = toElement(node);
+ Element& element = toElement(*node);
// We have to process in-line style as it might contain some resources (typically background images).
- if (element->isStyledElement())
- retrieveResourcesForProperties(toStyledElement(element)->inlineStyle(), document);
+ if (is<StyledElement>(element))
+ retrieveResourcesForProperties(downcast<StyledElement>(element).inlineStyle(), document);
if (is<HTMLImageElement>(element)) {
- HTMLImageElement& imageElement = downcast<HTMLImageElement>(*element);
+ HTMLImageElement& imageElement = downcast<HTMLImageElement>(element);
URL url = ""
CachedImage* cachedImage = imageElement.cachedImage();
addImageToResources(cachedImage, imageElement.renderer(), url);
} else if (is<HTMLLinkElement>(element)) {
- HTMLLinkElement& linkElement = downcast<HTMLLinkElement>(*element);
+ HTMLLinkElement& linkElement = downcast<HTMLLinkElement>(element);
if (CSSStyleSheet* sheet = linkElement.sheet()) {
URL url = ""
serializeCSSStyleSheet(sheet, url);
ASSERT(m_resourceURLs.contains(url));
}
} else if (is<HTMLStyleElement>(element)) {
- if (CSSStyleSheet* sheet = downcast<HTMLStyleElement>(*element).sheet())
+ if (CSSStyleSheet* sheet = downcast<HTMLStyleElement>(element).sheet())
serializeCSSStyleSheet(sheet, URL());
}
}
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (174068 => 174069)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -2569,7 +2569,7 @@
LayoutSize difference = (currentSize + newOffset - adjustedOldOffset).expandedTo(minimumSize) - currentSize;
- StyledElement* styledElement = toStyledElement(element);
+ StyledElement* styledElement = downcast<StyledElement>(element);
bool isBoxSizingBorder = renderer->style().boxSizing() == BORDER_BOX;
EResize resize = renderer->style().resize();
Modified: trunk/Source/WebCore/svg/SVGElement.cpp (174068 => 174069)
--- trunk/Source/WebCore/svg/SVGElement.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/svg/SVGElement.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -957,7 +957,7 @@
// Walk up the tree, to find out whether we're inside a <use> shadow tree, to find the right title.
if (isInShadowTree()) {
- Element* shadowHostElement = toShadowRoot(treeScope().rootNode()).hostElement();
+ Element* shadowHostElement = downcast<ShadowRoot>(treeScope().rootNode()).hostElement();
// At this time, SVG nodes are not allowed in non-<use> shadow trees, so any shadow root we do
// have should be a use. The assert and following test is here to catch future shadow DOM changes
// that do enable SVG in a shadow tree.
Modified: trunk/Source/WebCore/testing/Internals.cpp (174068 => 174069)
--- trunk/Source/WebCore/testing/Internals.cpp 2014-09-29 17:20:18 UTC (rev 174068)
+++ trunk/Source/WebCore/testing/Internals.cpp 2014-09-29 17:35:28 UTC (rev 174069)
@@ -574,19 +574,19 @@
{
if (!host) {
ec = INVALID_ACCESS_ERR;
- return 0;
+ return nullptr;
}
return host->shadowRoot();
}
String Internals::shadowRootType(const Node* root, ExceptionCode& ec) const
{
- if (!root || !root->isShadowRoot()) {
+ if (!root || !is<ShadowRoot>(root)) {
ec = INVALID_ACCESS_ERR;
return String();
}
- switch (toShadowRoot(root)->type()) {
+ switch (downcast<ShadowRoot>(*root).type()) {
case ShadowRoot::UserAgentShadowRoot:
return String("UserAgentShadowRoot");
default:
@@ -598,7 +598,7 @@
Element* Internals::includerFor(Node*, ExceptionCode& ec)
{
ec = INVALID_ACCESS_ERR;
- return 0;
+ return nullptr;
}
String Internals::shadowPseudoId(Element* element, ExceptionCode& ec)