Chromium Code Reviews| Index: Source/core/editing/htmlediting.cpp |
| diff --git a/Source/core/editing/htmlediting.cpp b/Source/core/editing/htmlediting.cpp |
| index 8b5e040f7fb0d12d1e820f6ee2dadde554a62a8c..d2c9741331abbdf22058ba988e29376ee13605dc 100644 |
| --- a/Source/core/editing/htmlediting.cpp |
| +++ b/Source/core/editing/htmlediting.cpp |
| @@ -334,6 +334,23 @@ Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule) |
| return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosingNode) : 0; |
| } |
| +Element* enclosingBlockFlowElement(Node& node) |
| +{ |
| + if (node.isBlockFlowElement()) |
| + return &toElement(node); |
| + |
| + for (Node* n = node.parentNode(); n; n = n->parentNode()) { |
| + if (n->isBlockFlowElement() || isHTMLBodyElement(*n)) |
| + return toElement(n); |
| + } |
| + return 0; |
| +} |
| + |
| +bool inSameContainingBlockFlowElement(Node* a, Node* b) |
| +{ |
| + return a && b ? enclosingBlockFlowElement(*a) == enclosingBlockFlowElement(*b) : false; |
|
leviw_travelin_and_unemployed
2014/07/28 21:39:56
a && b && enclosingBlockFlowElement(*a) == enclosi
Inactive
2014/07/28 21:47:11
Done.
|
| +} |
| + |
| TextDirection directionOfEnclosingBlock(const Position& position) |
| { |
| Element* enclosingBlockElement = enclosingBlock(position.containerNode()); |
| @@ -933,7 +950,7 @@ Position leadingWhitespacePosition(const Position& position, EAffinity affinity, |
| return Position(); |
| Position prev = previousCharacterPosition(position, affinity); |
| - if (prev != position && prev.anchorNode()->inSameContainingBlockFlowElement(position.anchorNode()) && prev.anchorNode()->isTextNode()) { |
| + if (prev != position && inSameContainingBlockFlowElement(prev.anchorNode(), position.anchorNode()) && prev.anchorNode()->isTextNode()) { |
| String string = toText(prev.anchorNode())->data(); |
| UChar previousCharacter = string[prev.deprecatedEditingOffset()]; |
| bool isSpace = option == ConsiderNonCollapsibleWhitespace ? (isSpaceOrNewline(previousCharacter) || previousCharacter == noBreakSpace) : isCollapsibleWhitespace(previousCharacter); |