diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/editing/FormatBlockCommand.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/core/editing/FormatBlockCommand.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/chromium/third_party/WebKit/Source/core/editing/FormatBlockCommand.cpp b/chromium/third_party/WebKit/Source/core/editing/FormatBlockCommand.cpp index 8ea2e4d608d..57b9634a83a 100644 --- a/chromium/third_party/WebKit/Source/core/editing/FormatBlockCommand.cpp +++ b/chromium/third_party/WebKit/Source/core/editing/FormatBlockCommand.cpp @@ -32,6 +32,7 @@ #include "core/editing/FormatBlockCommand.h" #include "core/editing/VisibleUnits.h" #include "core/editing/htmlediting.h" +#include "core/html/HTMLElement.h" namespace WebCore { @@ -60,16 +61,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)) { @@ -91,6 +93,10 @@ void FormatBlockCommand::formatRange(const Position& start, const Position& end, moveParagraphWithClones(start, end, blockNode.get(), outerBlock.get()); + // Copy the inline style of the original block element to the newly created block-style element. + if (outerBlock.get() != nodeAfterInsertionPosition.get() && toHTMLElement(nodeAfterInsertionPosition.get())->hasAttribute(styleAttr)) + blockNode->setAttribute(styleAttr, toHTMLElement(nodeAfterInsertionPosition.get())->getAttribute(styleAttr)); + if (wasEndOfParagraph && !isEndOfParagraph(lastParagraphInBlockNode) && !isStartOfParagraph(lastParagraphInBlockNode)) insertBlockPlaceholder(lastParagraphInBlockNode); } |