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

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

Issue 2753193002: Editing: Indent command: Do not insert BLOCKQUOTE under the root HTML element. (Closed)
Patch Set: . Created 3 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
Index: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
index 012a9693251f32f8d429ad6c62433ff70c5ff4e7..85350e77fede3c4e050a3301601b01061a3ae195 100644
--- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
@@ -1952,6 +1952,43 @@ void CompositeEditCommand::setEndingVisibleSelection(
}
}
+void CompositeEditCommand::shrinkEndingSelectionToFitBody() {
yosin_UTC9 2017/03/17 10:04:11 I would like this function as local function and f
+ Position start = endingSelection().visibleStart().deepEquivalent();
+ Position end = endingSelection().visibleEnd().deepEquivalent();
+ if (start.isNull() || start.isOrphan() || end.isNull() || end.isOrphan())
+ return;
+ HTMLElement* body = start.document()->body();
+ if (!body)
+ return;
+ Position bodyStart(body, PositionAnchorType::BeforeChildren);
+ Position bodyEnd(body, PositionAnchorType::AfterChildren);
+ bool needsToShrink = false;
+
+ if (start < bodyStart) {
+ start = bodyStart;
+ needsToShrink = true;
+ }
+ if (end < bodyStart) {
+ end = bodyStart;
+ needsToShrink = true;
+ }
+ if (bodyEnd < start) {
+ start = bodyEnd;
+ needsToShrink = true;
+ }
+ if (bodyEnd < end) {
+ end = bodyEnd;
+ needsToShrink = true;
+ }
+ if (!needsToShrink)
+ return;
+ SelectionInDOMTree::Builder builder;
+ builder.collapse(start);
+ builder.extend(end);
+ builder.setIsDirectional(endingSelection().isDirectional());
+ setEndingSelection(builder.build());
+}
+
void CompositeEditCommand::setParent(CompositeEditCommand* parent) {
EditCommand::setParent(parent);
if (!parent)

Powered by Google App Engine
This is Rietveld 408576698