Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/VisibleUnits.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp |
| index 251dd1fc6e4ca94b56807bbe0a6481345a4a0042..0e3e828398915b9164787faf28df66291cd16d61 100644 |
| --- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp |
| +++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp |
| @@ -1826,6 +1826,8 @@ PositionTemplate<Strategy> startOfParagraphAlgorithm( |
| CannotCrossEditingBoundary); |
| ContainerNode* const highestRoot = highestEditableRoot(position); |
| const bool startNodeIsEditable = hasEditableStyle(*startNode); |
| + const HTMLElement* body = startNode->document().body(); |
|
yosin_UTC9
2017/03/17 10:04:11
Could you move VisibleUnits.cpp change in another
|
| + const bool startNodeIsInBody = body && Strategy::contains(*body, *startNode); |
| Node* candidateNode = startNode; |
| PositionAnchorType candidateType = position.anchorType(); |
| @@ -1848,6 +1850,10 @@ PositionTemplate<Strategy> startOfParagraphAlgorithm( |
| break; |
| } |
| + if (startNodeIsInBody != |
|
yosin_UTC9
2017/03/17 10:04:11
There are three occurrences of this pattern. Is it
|
| + (body && Strategy::contains(*body, *previousNodeIterator))) |
| + break; |
| + |
| const LayoutItem layoutItem = |
| LayoutItem(previousNodeIterator->layoutObject()); |
| if (layoutItem.isNull()) { |
| @@ -1944,6 +1950,8 @@ static PositionTemplate<Strategy> endOfParagraphAlgorithm( |
| CannotCrossEditingBoundary); |
| ContainerNode* const highestRoot = highestEditableRoot(position); |
| const bool startNodeIsEditable = hasEditableStyle(*startNode); |
| + const HTMLElement* body = startNode->document().body(); |
| + const bool startNodeIsInBody = body && Strategy::contains(*body, *startNode); |
| Node* candidateNode = startNode; |
| PositionAnchorType candidateType = position.anchorType(); |
| @@ -1963,6 +1971,10 @@ static PositionTemplate<Strategy> endOfParagraphAlgorithm( |
| break; |
| } |
| + if (startNodeIsInBody != |
| + (body && Strategy::contains(*body, *nextNodeIterator))) |
| + break; |
| + |
| LayoutObject* const layoutObject = nextNodeIterator->layoutObject(); |
| if (!layoutObject) { |
| nextNodeIterator = Strategy::next(*nextNodeIterator, startBlock); |
| @@ -2928,6 +2940,8 @@ static PositionTemplate<Strategy> mostBackwardCaretPosition( |
| adjustPositionForBackwardIteration<Strategy>(position)); |
| PositionIteratorAlgorithm<Strategy> currentPos = lastVisible; |
| bool startEditable = hasEditableStyle(*startNode); |
| + const HTMLElement* body = startNode->document().body(); |
| + const bool startNodeIsInBody = body && Strategy::contains(*body, *startNode); |
| Node* lastNode = startNode; |
| bool boundaryCrossed = false; |
| for (; !currentPos.atStart(); currentPos.decrement()) { |
| @@ -2945,6 +2959,9 @@ static PositionTemplate<Strategy> mostBackwardCaretPosition( |
| lastNode = currentNode; |
| } |
| + if (startNodeIsInBody != (body && Strategy::contains(*body, *currentNode))) |
| + break; |
| + |
| // If we've moved to a position that is visually distinct, return the last |
| // saved position. There is code below that terminates early if we're |
| // *about* to move to a visually distinct position. |
| @@ -3123,7 +3140,8 @@ PositionTemplate<Strategy> mostForwardCaretPosition( |
| // stop before going above the body, up into the head |
| // return the last visible streamer position |
| - if (isHTMLBodyElement(*currentNode) && currentPos.atEndOfNode()) |
| + if (currentNode->document().body() == currentNode && |
| + currentPos.atEndOfNode()) |
| break; |
| // Do not move to a visually distinct position. |