Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: third_party/WebKit/Source/core/editing/FrameSelection.cpp

Issue 2437873008: Get rid of flat tree version of createVisibleSelection() taking two VisiblePosition (Closed)
Patch Set: 2016-10-21T16:03:11 Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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())

Powered by Google App Engine
This is Rietveld 408576698