Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp |
| index cfbeebd84a333bfa091068ee7b29239729958a04..529b2c578668b1eb5bd9bad994ed24c637a93c91 100644 |
| --- a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp |
| +++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp |
| @@ -794,6 +794,22 @@ static void removeHeadContents(ReplacementFragment& fragment) |
| } |
| } |
| +static bool followBlockElementStyle(const Node* node) |
| +{ |
| + if (!node->isHTMLElement()) |
| + return false; |
| + |
| + const HTMLElement& element = toHTMLElement(*node); |
| + return element.hasTagName(liTag) |
|
yosin_UTC9
2016/06/28 01:27:50
Is it better to check "display:block", "display:ta
joone
2016/06/28 08:41:43
Done.
|
| + || element.hasTagName(preTag) |
| + || element.hasTagName(tdTag) |
| + || element.hasTagName(h1Tag) |
| + || element.hasTagName(h2Tag) |
| + || element.hasTagName(h3Tag) |
| + || element.hasTagName(h4Tag) |
| + || element.hasTagName(h5Tag); |
|
yosin_UTC9
2016/06/28 01:27:50
Could you explain why do you omit H6?
https://deve
joone
2016/06/28 08:41:43
I just missed h6.
|
| +} |
| + |
| // Remove style spans before insertion if they are unnecessary. It's faster because we'll |
| // avoid doing a layout. |
| static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const Position& insertionPos) |
| @@ -807,10 +823,19 @@ static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const |
| if (isMailPasteAsQuotationHTMLBlockQuoteElement(topNode) || enclosingNodeOfType(firstPositionInOrBeforeNode(topNode), isMailHTMLBlockquoteElement, CanCrossEditingBoundary)) |
| return false; |
| - // Remove style spans to follow the styles of list item when |fragment| becomes a list item. |
| - // See bug http://crbug.com/335955. |
| + // Remove style spans to follow the styles of parent block element when |fragment| becomes a part of it. |
| + // See bugs http://crbug.com/226941 and http://crbug.com/335955. |
| HTMLSpanElement* wrappingStyleSpan = toHTMLSpanElement(topNode); |
| - if (isListItem(enclosingBlock(insertionPos.anchorNode()))) { |
| + const Node* node = insertionPos.anchorNode(); |
| + // |node| can be an inline element like <br> under <li> |
| + // e.g.) editing/execCommand/switch-list-type.html |
| + // editing/deleting/backspace-merge-into-block.html |
| + if (node->layoutObject() && node->layoutObject()->isInline()) { |
|
yosin_UTC9
2016/06/28 01:27:50
Let's use Node::computedStyle() rather than layout
joone
2016/06/28 08:41:43
Done.
|
| + if (!(node = enclosingBlock(insertionPos.anchorNode()))) |
| + return false; |
| + } |
| + |
| + if (followBlockElementStyle(node)) { |
| fragment.removeNodePreservingChildren(wrappingStyleSpan); |
| return true; |
| } |