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

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

Issue 166573003: Port ParentNode API to ElementTraversal (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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/dom/ParentNode.h ('k') | Source/core/svg/SVGPatternElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/TypingCommand.cpp
diff --git a/Source/core/editing/TypingCommand.cpp b/Source/core/editing/TypingCommand.cpp
index 924d58a0116caa746e532107a6dc19f813eb2b6c..709bb88f8757841a0b4bf1c4ad2236c66d74cee8 100644
--- a/Source/core/editing/TypingCommand.cpp
+++ b/Source/core/editing/TypingCommand.cpp
@@ -29,6 +29,7 @@
#include "HTMLNames.h"
#include "core/dom/Document.h"
#include "core/dom/Element.h"
+#include "core/dom/ElementTraversal.h"
#include "core/editing/BreakBlockquoteCommand.h"
#include "core/editing/Editor.h"
#include "core/editing/FrameSelection.h"
@@ -381,10 +382,13 @@ bool TypingCommand::makeEditableRootEmpty()
if (!root || !root->firstChild())
return false;
- if (root->firstChild() == root->lastChild() && root->firstElementChild() && root->firstElementChild()->hasTagName(brTag)) {
- // If there is a single child and it could be a placeholder, leave it alone.
- if (root->renderer() && root->renderer()->isRenderBlockFlow())
- return false;
+ if (root->firstChild() == root->lastChild()) {
+ Element* firstElementChild = ElementTraversal::firstWithin(*root);
+ if (firstElementChild && firstElementChild->hasTagName(brTag)) {
+ // If there is a single child and it could be a placeholder, leave it alone.
+ if (root->renderer() && root->renderer()->isRenderBlockFlow())
+ return false;
+ }
}
while (Node* child = root->firstChild())
« no previous file with comments | « Source/core/dom/ParentNode.h ('k') | Source/core/svg/SVGPatternElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698