Index: third_party/WebKit/Source/core/editing/FrameSelection.cpp |
diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.cpp b/third_party/WebKit/Source/core/editing/FrameSelection.cpp |
index 87da464c3e58dd84af4fe4492893e167581a7fb0..a385cf2d1fc592340184784adb99904b8df00206 100644 |
--- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp |
+++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp |
@@ -945,10 +945,19 @@ void FrameSelection::selectFrameElementInParentIfFullySelected() { |
Position(ownerElementParent, ownerElementNodeIndex + 1), |
VP_UPSTREAM_IF_POSSIBLE); |
+ SelectionInDOMTree::Builder builder; |
Xiaocheng
2016/10/21 11:18:36
Let's use setBaseAndExtentDeprecated, since having
yosin_UTC9
2016/10/24 06:19:44
Done
|
+ if (beforeOwnerElement.isNotNull() && afterOwnerElement.isNotNull()) { |
+ builder.collapse(beforeOwnerElement.toPositionWithAffinity()) |
+ .extend(afterOwnerElement.deepEquivalent()); |
+ } else if (beforeOwnerElement.isNotNull()) { |
+ builder.collapse(beforeOwnerElement.toPositionWithAffinity()); |
+ } else if (afterOwnerElement.isNotNull()) { |
+ builder.collapse(afterOwnerElement.toPositionWithAffinity()); |
+ } |
+ |
// Focus on the parent frame, and then select from before this element to |
// after. |
- VisibleSelection newSelection = |
- createVisibleSelection(beforeOwnerElement, afterOwnerElement); |
+ VisibleSelection newSelection = createVisibleSelection(builder.build()); |
page->focusController().setFocusedFrame(parent); |
// setFocusedFrame can dispatch synchronous focus/blur events. The document |
// tree might be modified. |
@@ -1387,9 +1396,13 @@ bool FrameSelection::selectWordAroundPosition(const VisiblePosition& position) { |
String text = |
plainText(EphemeralRange(start.deepEquivalent(), end.deepEquivalent())); |
if (!text.isEmpty() && !isSeparator(text.characterStartingAt(0))) { |
- setSelection(createVisibleSelection(start, end), |
- CloseTyping | ClearTypingStyle, |
- CursorAlignOnScroll::IfNeeded, WordGranularity); |
+ setSelection( |
+ createVisibleSelection(SelectionInDOMTree::Builder() |
+ .collapse(start.toPositionWithAffinity()) |
+ .extend(end.deepEquivalent()) |
+ .build()), |
+ CloseTyping | ClearTypingStyle, CursorAlignOnScroll::IfNeeded, |
+ WordGranularity); |
return true; |
} |
} |
@@ -1431,8 +1444,17 @@ void FrameSelection::moveRangeSelectionExtent(const IntPoint& contentsPoint) { |
void FrameSelection::moveRangeSelection(const VisiblePosition& basePosition, |
const VisiblePosition& extentPosition, |
TextGranularity granularity) { |
- VisibleSelection newSelection = |
- createVisibleSelection(basePosition, extentPosition); |
+ SelectionInDOMTree::Builder builder; |
+ if (basePosition.isNotNull() && extentPosition.isNotNull()) { |
Xiaocheng
2016/10/21 11:18:36
Let's use setBaseAndExtentDeprecated, since having
yosin_UTC9
2016/10/24 06:19:44
Done
|
+ builder.collapse(basePosition.toPositionWithAffinity()) |
+ .extend(extentPosition.deepEquivalent()); |
+ } else if (basePosition.isNotNull()) { |
+ builder.collapse(basePosition.toPositionWithAffinity()); |
+ } else if (extentPosition.isNotNull()) { |
+ builder.collapse(extentPosition.toPositionWithAffinity()); |
+ } |
+ |
+ VisibleSelection newSelection = createVisibleSelection(builder.build()); |
newSelection.expandUsingGranularity(granularity); |
if (newSelection.isNone()) |