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

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

Issue 405973004: Optimize / clean up hasTagName() call sites (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | « Source/core/editing/MarkupAccumulator.cpp ('k') | Source/core/html/HTMLTableElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/ReplaceSelectionCommand.cpp
diff --git a/Source/core/editing/ReplaceSelectionCommand.cpp b/Source/core/editing/ReplaceSelectionCommand.cpp
index 558d5d9c073c9921bc6a6bb63aa9839f5cf21f3d..47617e8e5b2e2f7247e1d3845c56f7ed7a6c8a28 100644
--- a/Source/core/editing/ReplaceSelectionCommand.cpp
+++ b/Source/core/editing/ReplaceSelectionCommand.cpp
@@ -437,15 +437,16 @@ static bool isMailPasteAsQuotationNode(const Node* node)
static bool isHeaderElement(const Node* a)
{
- if (!a)
+ if (!a || !a->isHTMLElement())
return false;
- return a->hasTagName(h1Tag)
- || a->hasTagName(h2Tag)
- || a->hasTagName(h3Tag)
- || a->hasTagName(h4Tag)
- || a->hasTagName(h5Tag)
- || a->hasTagName(h6Tag);
+ const HTMLElement& element = toHTMLElement(*a);
+ return element.hasTagName(h1Tag)
+ || element.hasTagName(h2Tag)
+ || element.hasTagName(h3Tag)
+ || element.hasTagName(h4Tag)
+ || element.hasTagName(h5Tag)
+ || element.hasTagName(h6Tag);
}
static bool haveSameTagName(Node* a, Node* b)
@@ -460,8 +461,8 @@ bool ReplaceSelectionCommand::shouldMerge(const VisiblePosition& source, const V
Node* sourceNode = source.deepEquivalent().deprecatedNode();
Node* destinationNode = destination.deepEquivalent().deprecatedNode();
- Node* sourceBlock = enclosingBlock(sourceNode);
- Node* destinationBlock = enclosingBlock(destinationNode);
+ Element* sourceBlock = enclosingBlock(sourceNode);
+ Element* destinationBlock = enclosingBlock(destinationNode);
return !enclosingNodeOfType(source.deepEquivalent(), &isMailPasteAsQuotationNode) &&
sourceBlock && (!sourceBlock->hasTagName(blockquoteTag) || isMailBlockquote(sourceBlock)) &&
enclosingListChild(sourceBlock) == enclosingListChild(destinationNode) &&
« no previous file with comments | « Source/core/editing/MarkupAccumulator.cpp ('k') | Source/core/html/HTMLTableElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698