Index: third_party/WebKit/Source/core/editing/SelectionController.cpp |
diff --git a/third_party/WebKit/Source/core/editing/SelectionController.cpp b/third_party/WebKit/Source/core/editing/SelectionController.cpp |
index e26e1732d57ef92bb4111b2507ed4856c894f2d5..4f8b2ef6e8517b44d1ffc971859d5321d0880353 100644 |
--- a/third_party/WebKit/Source/core/editing/SelectionController.cpp |
+++ b/third_party/WebKit/Source/core/editing/SelectionController.cpp |
@@ -295,23 +295,32 @@ void SelectionController::selectClosestWordFromHitTestResult(const HitTestResult |
if (!innerNode || !innerNode->layoutObject()) |
return; |
- const VisiblePositionInFlatTree& pos = visiblePositionOfHitTestResult(result); |
+ // Special-case image local offset to always be zero, to avoid triggering |
+ // LayoutReplaced::positionFromPoint's advancement of the position at the |
+ // mid-point of the the image (which was intended for mouse-drag selection |
+ // and isn't desirable for long-press). |
+ HitTestResult adjustedHitTestResult = result; |
+ if (result.image()) { |
yosin_UTC9
2016/04/05 05:16:45
nit: we don't need to have "{}" here, since then-c
aelias_OOO_until_Jul13
2016/04/05 06:48:36
Done.
|
+ adjustedHitTestResult.setNodeAndPosition(result.innerNode(), LayoutPoint(0, 0)); |
+ } |
+ |
+ const VisiblePositionInFlatTree& pos = visiblePositionOfHitTestResult(adjustedHitTestResult); |
if (pos.isNotNull()) { |
newSelection = VisibleSelectionInFlatTree(pos); |
newSelection.expandUsingGranularity(WordGranularity); |
} |
-#if OS(ANDROID) |
- // If node doesn't have text except space, tab or line break, do not |
- // select that 'empty' area. |
- EphemeralRangeInFlatTree range = EphemeralRangeInFlatTree(newSelection.start(), newSelection.end()); |
- const String& str = plainText(range, TextIteratorDefaultBehavior); |
- if (str.isEmpty() || str.simplifyWhiteSpace().containsOnlyWhitespace()) |
- return; |
-#endif |
- |
- if (appendTrailingWhitespace == AppendTrailingWhitespace::ShouldAppend && newSelection.isRange()) |
- newSelection.appendTrailingWhitespace(); |
+ if (appendTrailingWhitespace == AppendTrailingWhitespace::DontAppend) { |
+ // If node doesn't have text except space, tab or line break, do not |
+ // select that 'empty' area. |
+ EphemeralRangeInFlatTree range = EphemeralRangeInFlatTree(newSelection.start(), newSelection.end()); |
yosin_UTC9
2016/04/05 05:16:45
nit: |const EphmeralRangeInFlatTree&| to avoid unn
aelias_OOO_until_Jul13
2016/04/05 06:48:36
Switched to parens-on-local-variable-constructor s
|
+ const String& str = plainText(range, TextIteratorEmitsObjectReplacementCharacter); |
+ if (str.simplifyWhiteSpace().isEmpty()) |
+ return; |
+ } else { |
yosin_UTC9
2016/04/05 05:16:45
To avoid nesting, we can write:
} else if (newSel
aelias_OOO_until_Jul13
2016/04/05 06:48:36
Switched this back to the former syntax anyway.
|
+ if (newSelection.isRange()) |
+ newSelection.appendTrailingWhitespace(); |
+ } |
updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelectionToRespectUserSelectAll(innerNode, newSelection), WordGranularity); |
} |
@@ -540,11 +549,7 @@ bool SelectionController::handleGestureLongPress(const PlatformGestureEvent& ges |
return false; |
Node* innerNode = hitTestResult.innerNode(); |
-#if OS(ANDROID) |
bool innerNodeIsSelectable = innerNode && (innerNode->isContentEditable() || innerNode->isTextNode() || innerNode->canStartSelection()); |
-#else |
- bool innerNodeIsSelectable = innerNode && (innerNode->isContentEditable() || innerNode->isTextNode()); |
-#endif |
if (!innerNodeIsSelectable) |
return false; |