Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(900)

Unified Diff: Source/core/editing/ApplyStyleCommand.cpp

Issue 196683003: Use new is*Element() helper functions more in editing code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/editing/BreakBlockquoteCommand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/ApplyStyleCommand.cpp
diff --git a/Source/core/editing/ApplyStyleCommand.cpp b/Source/core/editing/ApplyStyleCommand.cpp
index 6136cff9efee86cf88f88cb41420deb31c7e0502..4d70f21375520a056f48469907908d6c5389632f 100644
--- a/Source/core/editing/ApplyStyleCommand.cpp
+++ b/Source/core/editing/ApplyStyleCommand.cpp
@@ -85,21 +85,21 @@ static bool hasNoAttributeOrOnlyStyleAttribute(const Element* element, ShouldSty
bool isStyleSpanOrSpanWithOnlyStyleAttribute(const Element* element)
{
- if (!element || !element->hasTagName(spanTag))
+ if (!isHTMLSpanElement(element))
return false;
return hasNoAttributeOrOnlyStyleAttribute(toHTMLElement(element), AllowNonEmptyStyleAttribute);
}
static inline bool isSpanWithoutAttributesOrUnstyledStyleSpan(const Node* node)
{
- if (!node || !node->isHTMLElement() || !node->hasTagName(spanTag))
+ if (!isHTMLSpanElement(node))
return false;
return hasNoAttributeOrOnlyStyleAttribute(toHTMLElement(node), StyleAttributeShouldBeEmpty);
}
bool isEmptyFontTag(const Element* element, ShouldStyleAttributeBeEmpty shouldStyleAttributeBeEmpty)
{
- if (!element || !element->hasTagName(fontTag))
+ if (!isHTMLFontElement(element))
return false;
return hasNoAttributeOrOnlyStyleAttribute(toHTMLElement(element), shouldStyleAttributeBeEmpty);
@@ -695,7 +695,7 @@ void ApplyStyleCommand::fixRangeAndApplyInlineStyle(EditingStyle* style, const P
// FIXME: Callers should perform this operation on a Range that includes the br
// if they want style applied to the empty line.
- if (start == end && start.deprecatedNode()->hasTagName(brTag))
+ if (start == end && isHTMLBRElement(*start.deprecatedNode()))
pastEndNode = NodeTraversal::next(*start.deprecatedNode());
// Start from the highest fully selected ancestor so that we can modify the fully selected node.
@@ -795,7 +795,7 @@ void ApplyStyleCommand::applyInlineStyleToNodeRange(EditingStyle* style, PassRef
Node* runEnd = node.get();
Node* sibling = node->nextSibling();
while (sibling && sibling != pastEndNode && !sibling->contains(pastEndNode.get())
- && (!isBlock(sibling) || sibling->hasTagName(brTag))
+ && (!isBlock(sibling) || isHTMLBRElement(*sibling))
&& !containsNonEditableRegion(*sibling)) {
runEnd = sibling;
sibling = runEnd->nextSibling();
@@ -998,7 +998,7 @@ void ApplyStyleCommand::applyInlineStyleToPushDown(Node* node, EditingStyle* sty
node->document().updateStyleIfNeeded();
- if (!style || style->isEmpty() || !node->renderer() || node->hasTagName(iframeTag))
+ if (!style || style->isEmpty() || !node->renderer() || isHTMLIFrameElement(*node))
return;
RefPtr<EditingStyle> newInlineStyle = style;
@@ -1304,7 +1304,7 @@ bool ApplyStyleCommand::mergeEndWithNextIfIdentical(const Position& start, const
endNode = end.deprecatedNode()->parentNode();
}
- if (!endNode->isElementNode() || endNode->hasTagName(brTag))
+ if (!endNode->isElementNode() || isHTMLBRElement(*endNode))
return false;
Node* nextSibling = endNode->nextSibling();
@@ -1420,12 +1420,12 @@ void ApplyStyleCommand::applyInlineStyleChange(PassRefPtr<Node> passedStart, Pas
HTMLElement* fontContainer = 0;
HTMLElement* styleContainer = 0;
for (Node* container = startNode.get(); container && startNode == endNode; container = container->firstChild()) {
- if (container->isHTMLElement() && container->hasTagName(fontTag))
+ if (isHTMLFontElement(*container))
fontContainer = toHTMLElement(container);
- bool styleContainerIsNotSpan = !styleContainer || !styleContainer->hasTagName(spanTag);
+ bool styleContainerIsNotSpan = !isHTMLSpanElement(styleContainer);
if (container->isHTMLElement()) {
HTMLElement* containerElement = toHTMLElement(container);
- if (containerElement->hasTagName(spanTag) || (styleContainerIsNotSpan && containerElement->hasChildren()))
+ if (isHTMLSpanElement(*containerElement) || (styleContainerIsNotSpan && containerElement->hasChildren()))
styleContainer = toHTMLElement(container);
}
if (!container->firstChild())
« no previous file with comments | « no previous file | Source/core/editing/BreakBlockquoteCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698