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

Unified Diff: third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp

Issue 2170823002: Make ApplyStyleCommand::applyBlockStyle() to use connected position only (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-07-21T17:08:56 Created 4 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 | « third_party/WebKit/LayoutTests/editing/execCommand/apply_style/justify_right_ul_br_crash.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp
index 10da9d445850691fd872d476701ec2b53b0d96ce..bb27619f6cfabdc65e08a4f8128d5ea7e43f5c99 100644
--- a/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp
@@ -275,6 +275,7 @@ void ApplyStyleCommand::applyBlockStyle(EditingStyle *style, EditingState* editi
VisiblePosition nextParagraphStart(nextPositionOf(endOfParagraph(paragraphStart)));
VisiblePosition beyondEnd(nextPositionOf(endOfParagraph(visibleEnd)));
while (paragraphStart.isNotNull() && paragraphStart.deepEquivalent() != beyondEnd.deepEquivalent()) {
+ DCHECK(!paragraphStart.isOrphan()) << paragraphStart;
StyleChange styleChange(style, paragraphStart.deepEquivalent());
if (styleChange.cssStyle().length() || m_removeOnly) {
Element* block = enclosingBlock(paragraphStart.deepEquivalent().anchorNode());
@@ -283,21 +284,30 @@ void ApplyStyleCommand::applyBlockStyle(EditingStyle *style, EditingState* editi
HTMLElement* newBlock = moveParagraphContentsToNewBlockIfNecessary(paragraphStartToMove, editingState);
if (editingState->isAborted())
return;
- if (newBlock)
+ if (newBlock) {
block = newBlock;
+ if (paragraphStart.isOrphan())
+ paragraphStart = createVisiblePosition(Position::firstPositionInNode(newBlock));
+ }
+ DCHECK(!paragraphStart.isOrphan()) << paragraphStart;
}
if (block && block->isHTMLElement()) {
removeCSSStyle(style, toHTMLElement(block), editingState);
if (editingState->isAborted())
return;
- if (!m_removeOnly)
+ DCHECK(!paragraphStart.isOrphan()) << paragraphStart;
+ if (!m_removeOnly) {
addBlockStyle(styleChange, toHTMLElement(block));
+ DCHECK(!paragraphStart.isOrphan()) << paragraphStart;
+ }
}
+ DCHECK(!paragraphStart.isOrphan()) << paragraphStart;
if (nextParagraphStart.isOrphan())
nextParagraphStart = nextPositionOf(endOfParagraph(paragraphStart));
}
+ DCHECK(!nextParagraphStart.isOrphan()) << nextParagraphStart;
paragraphStart = nextParagraphStart;
nextParagraphStart = nextPositionOf(endOfParagraph(paragraphStart));
}
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/execCommand/apply_style/justify_right_ul_br_crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698