| Index: third_party/WebKit/Source/core/editing/DOMSelection.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/DOMSelection.cpp b/third_party/WebKit/Source/core/editing/DOMSelection.cpp
|
| index b3c2e3b205ea2611a44d4dca631320125766c83d..36c41babfb7efba89ffe033a3e97a70efcc2e87a 100644
|
| --- a/third_party/WebKit/Source/core/editing/DOMSelection.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/DOMSelection.cpp
|
| @@ -43,10 +43,15 @@
|
| #include "core/frame/LocalFrame.h"
|
| #include "core/frame/UseCounter.h"
|
| #include "core/inspector/ConsoleMessage.h"
|
| +#include "platform/EventDispatchForbiddenScope.h"
|
| #include "wtf/text/WTFString.h"
|
|
|
| namespace blink {
|
|
|
| +const FrameSelection::SetSelectionOptions kSetSelectionOptions =
|
| + FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle |
|
| + FrameSelection::DoNotSetFocus;
|
| +
|
| static Node* selectionShadowAncestor(LocalFrame* frame) {
|
| Node* node = frame->selection()
|
| .computeVisibleSelectionInDOMTreeDeprecated()
|
| @@ -251,11 +256,13 @@ void DOMSelection::collapse(Node* node,
|
| return;
|
|
|
| // 6. Set the context object's range to newRange.
|
| + EventDispatchForbiddenScope noEvents;
|
| frame()->selection().setSelection(
|
| SelectionInDOMTree::Builder()
|
| .collapse(Position(node, offset))
|
| .setIsDirectional(frame()->selection().isDirectional())
|
| - .build());
|
| + .build(),
|
| + kSetSelectionOptions);
|
| cacheRangeIfSelectionOfDocument(newRange);
|
| }
|
|
|
| @@ -274,13 +281,14 @@ void DOMSelection::collapseToEnd(ExceptionState& exceptionState) {
|
|
|
| // Otherwise, it must create a new range, set both its start and end to the
|
| // end of the context object's range,
|
| + EventDispatchForbiddenScope noEvents;
|
| Range* newRange = getRangeAt(0, ASSERT_NO_EXCEPTION)->cloneRange();
|
| newRange->collapse(false);
|
|
|
| // and then set the context object's range to the newly-created range.
|
| SelectionInDOMTree::Builder builder;
|
| builder.collapse(newRange->endPosition());
|
| - frame()->selection().setSelection(builder.build());
|
| + frame()->selection().setSelection(builder.build(), kSetSelectionOptions);
|
| cacheRangeIfSelectionOfDocument(newRange);
|
| }
|
|
|
| @@ -299,13 +307,14 @@ void DOMSelection::collapseToStart(ExceptionState& exceptionState) {
|
|
|
| // Otherwise, it must create a new range, set both its start and end to the
|
| // start of the context object's range,
|
| + EventDispatchForbiddenScope noEvents;
|
| Range* newRange = getRangeAt(0, ASSERT_NO_EXCEPTION)->cloneRange();
|
| newRange->collapse(true);
|
|
|
| // and then set the context object's range to the newly-created range.
|
| SelectionInDOMTree::Builder builder;
|
| builder.collapse(newRange->startPosition());
|
| - frame()->selection().setSelection(builder.build());
|
| + frame()->selection().setSelection(builder.build(), kSetSelectionOptions);
|
| cacheRangeIfSelectionOfDocument(newRange);
|
| }
|
|
|
| @@ -355,13 +364,15 @@ void DOMSelection::setBaseAndExtent(Node* baseNode,
|
| // See "svg/text/textpath-reference-crash.html"
|
| frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
|
|
|
| + EventDispatchForbiddenScope noEvents;
|
| Position basePosition(baseNode, baseOffset);
|
| Position extentPosition(extentNode, extentOffset);
|
| frame()->selection().setSelection(
|
| SelectionInDOMTree::Builder()
|
| .setBaseAndExtentDeprecated(basePosition, extentPosition)
|
| .setIsDirectional(true)
|
| - .build());
|
| + .build(),
|
| + kSetSelectionOptions);
|
|
|
| Range* newRange = Range::create(baseNode->document());
|
| if (extentPosition.isNull()) {
|
| @@ -425,7 +436,10 @@ void DOMSelection::modify(const String& alterString,
|
| else
|
| return;
|
|
|
| - frame()->selection().modify(alter, direction, granularity);
|
| + EventDispatchForbiddenScope noEvents;
|
| + frame()->selection().modify(alter, direction, granularity,
|
| + EUserTriggered::NotUserTriggered,
|
| + FrameSelection::DoNotSetFocus);
|
| }
|
|
|
| // https://www.w3.org/TR/selection-api/#dom-selection-extend
|
| @@ -453,6 +467,7 @@ void DOMSelection::extend(Node* node,
|
| if (exceptionState.hadException())
|
| return;
|
|
|
| + EventDispatchForbiddenScope noEvents;
|
| // 3. Let oldAnchor and oldFocus be the context object's anchor and focus, and
|
| // let newFocus be the boundary point (node, offset).
|
| const Position& oldAnchor = anchorPosition();
|
| @@ -502,7 +517,8 @@ void DOMSelection::extend(Node* node,
|
| builder.collapse(newFocus);
|
| else
|
| builder.collapse(oldAnchor).extend(newFocus);
|
| - frame()->selection().setSelection(builder.setIsDirectional(true).build());
|
| + frame()->selection().setSelection(builder.setIsDirectional(true).build(),
|
| + kSetSelectionOptions);
|
| cacheRangeIfSelectionOfDocument(newRange);
|
| }
|
|
|
| @@ -602,7 +618,10 @@ void DOMSelection::addRange(Range* newRange) {
|
| }
|
|
|
| if (rangeCount() == 0) {
|
| - selection.setSelectedRange(EphemeralRange(newRange), VP_DEFAULT_AFFINITY);
|
| + EventDispatchForbiddenScope noEvents;
|
| + selection.setSelectedRange(EphemeralRange(newRange), VP_DEFAULT_AFFINITY,
|
| + SelectionDirectionalMode::NonDirectional,
|
| + kSetSelectionOptions);
|
| cacheRangeIfSelectionOfDocument(newRange);
|
| return;
|
| }
|
|
|