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

Unified Diff: Source/core/editing/InsertParagraphSeparatorCommand.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 | « Source/core/editing/InsertListCommand.cpp ('k') | Source/core/editing/MarkupAccumulator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/InsertParagraphSeparatorCommand.cpp
diff --git a/Source/core/editing/InsertParagraphSeparatorCommand.cpp b/Source/core/editing/InsertParagraphSeparatorCommand.cpp
index 7f982205430f57b1261488288021694fffe2114a..417ab39e4d0bc9e65afc10d9d69080a69f7b4313 100644
--- a/Source/core/editing/InsertParagraphSeparatorCommand.cpp
+++ b/Source/core/editing/InsertParagraphSeparatorCommand.cpp
@@ -50,7 +50,7 @@ static Element* highestVisuallyEquivalentDivBelowRoot(Element* startBlock)
Element* curBlock = startBlock;
// We don't want to return a root node (if it happens to be a div, e.g., in a document fragment) because there are no
// siblings for us to append to.
- while (!curBlock->nextSibling() && curBlock->parentElement()->hasTagName(divTag) && curBlock->parentElement()->parentElement()) {
+ while (!curBlock->nextSibling() && isHTMLDivElement(*curBlock->parentElement()) && curBlock->parentElement()->parentElement()) {
if (curBlock->parentElement()->hasAttributes())
break;
curBlock = curBlock->parentElement();
@@ -170,10 +170,10 @@ void InsertParagraphSeparatorCommand::doApply()
if (!startBlock
|| !startBlock->nonShadowBoundaryParentNode()
|| isTableCell(startBlock.get())
- || startBlock->hasTagName(formTag)
+ || isHTMLFormElement(*startBlock)
// FIXME: If the node is hidden, we don't have a canonical position so we will do the wrong thing for tables and <hr>. https://bugs.webkit.org/show_bug.cgi?id=40342
|| (!canonicalPos.isNull() && isRenderedTable(canonicalPos.deprecatedNode()))
- || (!canonicalPos.isNull() && canonicalPos.deprecatedNode()->hasTagName(hrTag))) {
+ || (!canonicalPos.isNull() && isHTMLHRElement(*canonicalPos.deprecatedNode()))) {
applyCommandToComposite(InsertLineBreakCommand::create(document()));
return;
}
@@ -240,7 +240,7 @@ void InsertParagraphSeparatorCommand::doApply()
// Most of the time we want to stay at the nesting level of the startBlock (e.g., when nesting within lists). However,
// for div nodes, this can result in nested div tags that are hard to break out of.
Element* siblingNode = startBlock.get();
- if (blockToInsert->hasTagName(divTag))
+ if (isHTMLDivElement(*blockToInsert))
siblingNode = highestVisuallyEquivalentDivBelowRoot(startBlock.get());
insertNodeAfter(blockToInsert, siblingNode);
}
« no previous file with comments | « Source/core/editing/InsertListCommand.cpp ('k') | Source/core/editing/MarkupAccumulator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698