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

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

Issue 96653002: Minor refactoring in FormatBlockCommand::formatRange. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/FormatBlockCommand.cpp
diff --git a/Source/core/editing/FormatBlockCommand.cpp b/Source/core/editing/FormatBlockCommand.cpp
index 8ea2e4d608d120a29ac09e5430c26c0792bf0e99..8f49839357156e8969474632819bea2dc1f3ebc0 100644
--- a/Source/core/editing/FormatBlockCommand.cpp
+++ b/Source/core/editing/FormatBlockCommand.cpp
@@ -60,16 +60,17 @@ void FormatBlockCommand::formatSelection(const VisiblePosition& startOfSelection
void FormatBlockCommand::formatRange(const Position& start, const Position& end, const Position& endOfSelection, RefPtr<Element>& blockNode)
{
- Node* nodeToSplitTo = enclosingBlockToSplitTreeTo(start.deprecatedNode());
- RefPtr<Node> outerBlock = (start.deprecatedNode() == nodeToSplitTo) ? start.deprecatedNode() : splitTreeToNode(start.deprecatedNode(), nodeToSplitTo);
- RefPtr<Node> nodeAfterInsertionPosition = outerBlock;
-
- RefPtr<Range> range = Range::create(document(), start, endOfSelection);
Element* refNode = enclosingBlockFlowElement(end);
Element* root = editableRootForPosition(start);
// Root is null for elements with contenteditable=false.
if (!root || !refNode)
return;
+
+ Node* nodeToSplitTo = enclosingBlockToSplitTreeTo(start.deprecatedNode());
+ RefPtr<Node> outerBlock = (start.deprecatedNode() == nodeToSplitTo) ? start.deprecatedNode() : splitTreeToNode(start.deprecatedNode(), nodeToSplitTo);
+ RefPtr<Node> nodeAfterInsertionPosition = outerBlock;
+ RefPtr<Range> range = Range::create(document(), start, endOfSelection);
+
if (isElementForFormatBlock(refNode->tagQName()) && start == startOfBlock(start)
&& (end == endOfBlock(end) || isNodeVisiblyContainedWithin(refNode, range.get()))
&& refNode != root && !root->isDescendantOf(refNode)) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698