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

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

Issue 2709983005: Selection API: Do not change focus by Selection functions. (Closed)
Patch Set: . Created 3 years, 10 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 e63d68bea411ac67e8396e9ed4b85b96bcd9ed8b..9749531655181942d4c7d075f03dbb7c97ea9f08 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
@@ -242,14 +242,17 @@ void FrameSelection::setSelection(const SelectionInDOMTree& passedSelection,
// Always clear the x position used for vertical arrow navigation.
// It will be restored by the vertical arrow navigation code if necessary.
m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation();
- // TODO(yosin): Can we move this to at end of this function?
- // This may dispatch a synchronous focus-related events.
- selectFrameElementInParentIfFullySelected();
- if (!isAvailable() || document() != currentDocument) {
- // editing/selection/selectallchildren-crash.html and
- // editing/selection/longpress-selection-in-iframe-removed-crash.html
- // reach here.
- return;
+
+ if (!(options & DoNotSetFocus)) {
+ // TODO(yosin): Can we move this to at end of this function? This may
+ // dispatch a synchronous focus-related events.
+ selectFrameElementInParentIfFullySelected();
+ if (!isAvailable() || document() != currentDocument) {
+ // editing/selection/selectallchildren-crash.html and
+ // editing/selection/longpress-selection-in-iframe-removed-crash.html
+ // reach here.
+ return;
+ }
}
EUserTriggered userTriggered = selectionOptionsToUserTriggered(options);
notifyLayoutObjectOfSelectionChange(userTriggered);
@@ -368,7 +371,9 @@ static DispatchEventResult dispatchSelectStart(
bool FrameSelection::modify(EAlteration alter,
SelectionDirection direction,
TextGranularity granularity,
- EUserTriggered userTriggered) {
+ EUserTriggered userTriggered,
+ SetSelectionOptions noFocusFlag) {
+ DCHECK(noFocusFlag == 0 || noFocusFlag == DoNotSetFocus);
SelectionModifier selectionModifier(
*frame(), computeVisibleSelectionInDOMTreeDeprecated(),
m_xPosForVerticalArrowNavigation);
@@ -393,7 +398,7 @@ bool FrameSelection::modify(EAlteration alter,
}
const SetSelectionOptions options =
- CloseTyping | ClearTypingStyle | userTriggered;
+ CloseTyping | ClearTypingStyle | userTriggered | noFocusFlag;
setSelection(selectionModifier.selection(), options);
if (granularity == LineGranularity || granularity == ParagraphGranularity)

Powered by Google App Engine
This is Rietveld 408576698