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

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

Issue 428533006: Use ContainerNode::hasChildren() instead of firstChild() in conditionals (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: build fix 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
Index: Source/core/editing/ReplaceSelectionCommand.cpp
diff --git a/Source/core/editing/ReplaceSelectionCommand.cpp b/Source/core/editing/ReplaceSelectionCommand.cpp
index 746703cbb292845d12811408f2d2c4243e528b5f..5d708b5a0a8dd877b06e09ad89a325238672ebd4 100644
--- a/Source/core/editing/ReplaceSelectionCommand.cpp
+++ b/Source/core/editing/ReplaceSelectionCommand.cpp
@@ -148,9 +148,7 @@ ReplacementFragment::ReplacementFragment(Document* document, DocumentFragment* f
{
if (!m_document)
return;
- if (!m_fragment)
- return;
- if (!m_fragment->firstChild())
+ if (!m_fragment || !m_fragment->hasChildren())
return;
RefPtrWillBeRawPtr<Element> editableRoot = selection.rootEditableElement();
@@ -192,7 +190,7 @@ ReplacementFragment::ReplacementFragment(Document* document, DocumentFragment* f
restoreAndRemoveTestRenderingNodesToFragment(holder.get());
m_fragment = createFragmentFromText(selection.toNormalizedRange().get(), evt->text());
- if (!m_fragment->firstChild())
+ if (!m_fragment->hasChildren())
return;
holder = insertFragmentForTestRendering(editableRoot.get());
@@ -204,7 +202,7 @@ ReplacementFragment::ReplacementFragment(Document* document, DocumentFragment* f
bool ReplacementFragment::isEmpty() const
{
- return (!m_fragment || !m_fragment->firstChild()) && !m_hasInterchangeNewlineAtStart && !m_hasInterchangeNewlineAtEnd;
+ return (!m_fragment || !m_fragment->hasChildren()) && !m_hasInterchangeNewlineAtStart && !m_hasInterchangeNewlineAtEnd;
}
Node *ReplacementFragment::firstChild() const
@@ -548,7 +546,7 @@ void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
// WebKit used to not add display: inline and float: none on copy.
// Keep this code around for backward compatibility
if (isLegacyAppleStyleSpan(element)) {
- if (!element->firstChild()) {
+ if (!element->hasChildren()) {
insertedNodes.willRemoveNodePreservingChildren(*element);
removeNodePreservingChildren(element);
continue;
@@ -669,7 +667,7 @@ void ReplaceSelectionCommand::moveNodeOutOfAncestor(PassRefPtrWillBeRawPtr<Node>
removeNode(node);
insertNodeBefore(node, nodeToSplitTo);
}
- if (!ancestor->firstChild())
+ if (!ancestor->hasChildren())
removeNode(ancestor.release());
}
@@ -802,7 +800,7 @@ void ReplaceSelectionCommand::handleStyleSpans(InsertedNodes& insertedNodes)
// with block styles by the editing engine used to style them. WebKit doesn't do this, but others might.
style->removeBlockProperties();
- if (style->isEmpty() || !wrappingStyleSpan->firstChild()) {
+ if (style->isEmpty() || !wrappingStyleSpan->hasChildren()) {
insertedNodes.willRemoveNodePreservingChildren(*wrappingStyleSpan);
removeNodePreservingChildren(wrappingStyleSpan);
} else {
« no previous file with comments | « Source/core/editing/InsertParagraphSeparatorCommand.cpp ('k') | Source/core/editing/SimplifyMarkupCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698