diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2017-04-27 11:23:55 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-11-11 13:13:43 +0100 |
commit | 8cc9dc7d6abb000e994f793a116807b0c3767a01 (patch) | |
tree | 91ffe70275891d1fa523db90c23a90a91c426d65 /chromium/third_party/blink/renderer/core | |
parent | 89ce1f44d7b13d7d69dfc6137a18e9f5b1853051 (diff) | |
download | qtwebengine-chromium-8cc9dc7d6abb000e994f793a116807b0c3767a01.tar.gz |
Update TextSelection for non-user initiated events
This makes Chromium Content API to be able to notify about text
selection changes triggered by non-user events (eg. JavaScript, IME,
autofill).
Based on:
https://codereview.chromium.org/2903833002
Corresponding Chromium bug report:
https://bugs.chromium.org/p/chromium/issues/detail?id=671986
Change-Id: I86a7f203d789853199469b301facd06fe5ba54bd
Task-number: QTBUG-53134
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'chromium/third_party/blink/renderer/core')
10 files changed, 27 insertions, 9 deletions
diff --git a/chromium/third_party/blink/renderer/core/exported/web_page_popup_impl.cc b/chromium/third_party/blink/renderer/core/exported/web_page_popup_impl.cc index bba1deca18b..979ff97d0ff 100644 --- a/chromium/third_party/blink/renderer/core/exported/web_page_popup_impl.cc +++ b/chromium/third_party/blink/renderer/core/exported/web_page_popup_impl.cc @@ -480,6 +480,10 @@ void WebPagePopupImpl::SetHandlingInputEvent(bool handling) { widget_base_->input_handler().set_handling_input_event(handling); } +bool WebPagePopupImpl::ImeCompositionReplacement() { + return widget_base_->input_handler().ime_composition_replacement(); +} + void WebPagePopupImpl::ProcessInputEventSynchronouslyForTesting( const WebCoalescedInputEvent& event, HandledEventCallback callback) { diff --git a/chromium/third_party/blink/renderer/core/exported/web_page_popup_impl.h b/chromium/third_party/blink/renderer/core/exported/web_page_popup_impl.h index 5958171205d..bfbc24502a7 100644 --- a/chromium/third_party/blink/renderer/core/exported/web_page_popup_impl.h +++ b/chromium/third_party/blink/renderer/core/exported/web_page_popup_impl.h @@ -169,6 +169,7 @@ class CORE_EXPORT WebPagePopupImpl final : public WebPagePopup, void SetCursor(const ui::Cursor& cursor) override; bool HandlingInputEvent() override; void SetHandlingInputEvent(bool handling) override; + bool ImeCompositionReplacement() override; void ProcessInputEventSynchronouslyForTesting(const WebCoalescedInputEvent&, HandledEventCallback) override; void UpdateTextInputState() override; diff --git a/chromium/third_party/blink/renderer/core/frame/local_frame.cc b/chromium/third_party/blink/renderer/core/frame/local_frame.cc index 1dd636810e0..075fbc3fdeb 100644 --- a/chromium/third_party/blink/renderer/core/frame/local_frame.cc +++ b/chromium/third_party/blink/renderer/core/frame/local_frame.cc @@ -1378,8 +1378,9 @@ String LocalFrame::SelectedTextForClipboard() const { void LocalFrame::TextSelectionChanged(const WTF::String& selection_text, uint32_t offset, - const gfx::Range& range) const { - GetLocalFrameHostRemote().TextSelectionChanged(selection_text, offset, range); + const gfx::Range& range, + bool user_initiated) const { + GetLocalFrameHostRemote().TextSelectionChanged(selection_text, offset, range, user_initiated); } PositionWithAffinity LocalFrame::PositionForPoint( diff --git a/chromium/third_party/blink/renderer/core/frame/local_frame.h b/chromium/third_party/blink/renderer/core/frame/local_frame.h index ee6dc15d3d8..8143abc7a91 100644 --- a/chromium/third_party/blink/renderer/core/frame/local_frame.h +++ b/chromium/third_party/blink/renderer/core/frame/local_frame.h @@ -366,7 +366,8 @@ class CORE_EXPORT LocalFrame final : public Frame, String SelectedTextForClipboard() const; void TextSelectionChanged(const WTF::String& selection_text, uint32_t offset, - const gfx::Range& range) const; + const gfx::Range& range, + bool user_initiated) const; PositionWithAffinityTemplate<EditingAlgorithm<NodeTraversal>> PositionForPoint(const PhysicalOffset& frame_point); diff --git a/chromium/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc b/chromium/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc index eeec156e231..d21d78971a5 100644 --- a/chromium/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc +++ b/chromium/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc @@ -2359,6 +2359,11 @@ void WebFrameWidgetImpl::SetHandlingInputEvent(bool handling) { widget_base_->input_handler().set_handling_input_event(handling); } +bool WebFrameWidgetImpl::ImeCompositionReplacement() +{ + return widget_base_->input_handler().ime_composition_replacement(); +} + void WebFrameWidgetImpl::ProcessInputEventSynchronouslyForTesting( const WebCoalescedInputEvent& event, HandledEventCallback callback) { @@ -3539,7 +3544,8 @@ void WebFrameWidgetImpl::Replace(const String& word) { // If the resulting selection is not actually a change in selection, we do not // need to explicitly notify about the selection change. focused_frame->Client()->SyncSelectionIfRequired( - blink::SyncCondition::kNotForced); + blink::SyncCondition::kNotForced, false /* is_empty_selection */, + true /* user_initiated */); } void WebFrameWidgetImpl::ReplaceMisspelling(const String& word) { diff --git a/chromium/third_party/blink/renderer/core/frame/web_frame_widget_impl.h b/chromium/third_party/blink/renderer/core/frame/web_frame_widget_impl.h index 7ccca2f7f12..8901a9ad2f3 100644 --- a/chromium/third_party/blink/renderer/core/frame/web_frame_widget_impl.h +++ b/chromium/third_party/blink/renderer/core/frame/web_frame_widget_impl.h @@ -345,6 +345,7 @@ class CORE_EXPORT WebFrameWidgetImpl void SetCursor(const ui::Cursor& cursor) override; bool HandlingInputEvent() override; void SetHandlingInputEvent(bool handling) override; + bool ImeCompositionReplacement() override; void ProcessInputEventSynchronouslyForTesting(const WebCoalescedInputEvent&, HandledEventCallback) override; WebInputEventResult DispatchBufferedTouchEvents() override; diff --git a/chromium/third_party/blink/renderer/core/frame/web_local_frame_impl.cc b/chromium/third_party/blink/renderer/core/frame/web_local_frame_impl.cc index 5fcd08c4b70..3d718e04a50 100644 --- a/chromium/third_party/blink/renderer/core/frame/web_local_frame_impl.cc +++ b/chromium/third_party/blink/renderer/core/frame/web_local_frame_impl.cc @@ -1373,8 +1373,9 @@ WebString WebLocalFrameImpl::SelectionAsMarkup() const { void WebLocalFrameImpl::TextSelectionChanged(const WebString& selection_text, uint32_t offset, - const gfx::Range& range) { - GetFrame()->TextSelectionChanged(selection_text, offset, range); + const gfx::Range& range, + bool user_initiated) { + GetFrame()->TextSelectionChanged(selection_text, offset, range, user_initiated); } bool WebLocalFrameImpl::SelectWordAroundCaret() { diff --git a/chromium/third_party/blink/renderer/core/frame/web_local_frame_impl.h b/chromium/third_party/blink/renderer/core/frame/web_local_frame_impl.h index f04fe0c3eba..ebd7f45cadf 100644 --- a/chromium/third_party/blink/renderer/core/frame/web_local_frame_impl.h +++ b/chromium/third_party/blink/renderer/core/frame/web_local_frame_impl.h @@ -217,7 +217,8 @@ class CORE_EXPORT WebLocalFrameImpl final WebString SelectionAsMarkup() const override; void TextSelectionChanged(const WebString& selection_text, uint32_t offset, - const gfx::Range& range) override; + const gfx::Range& range, + bool user_initiated) override; bool SelectWordAroundCaret() override; void SelectRange(const gfx::Point& base, const gfx::Point& extent) override; void SelectRange(const WebRange&, diff --git a/chromium/third_party/blink/renderer/core/testing/fake_local_frame_host.cc b/chromium/third_party/blink/renderer/core/testing/fake_local_frame_host.cc index 31f80c24aa3..ca8f889ee79 100644 --- a/chromium/third_party/blink/renderer/core/testing/fake_local_frame_host.cc +++ b/chromium/third_party/blink/renderer/core/testing/fake_local_frame_host.cc @@ -167,7 +167,8 @@ void FakeLocalFrameHost::FocusedElementChanged( void FakeLocalFrameHost::TextSelectionChanged(const WTF::String& text, uint32_t offset, - const gfx::Range& range) {} + const gfx::Range& range, + bool user_initiated) {} void FakeLocalFrameHost::ShowPopupMenu( mojo::PendingRemote<mojom::blink::PopupMenuClient> popup_client, const gfx::Rect& bounds, diff --git a/chromium/third_party/blink/renderer/core/testing/fake_local_frame_host.h b/chromium/third_party/blink/renderer/core/testing/fake_local_frame_host.h index 2ec80b20adc..f81921e1b7d 100644 --- a/chromium/third_party/blink/renderer/core/testing/fake_local_frame_host.h +++ b/chromium/third_party/blink/renderer/core/testing/fake_local_frame_host.h @@ -107,7 +107,8 @@ class FakeLocalFrameHost : public mojom::blink::LocalFrameHost { blink::mojom::FocusType focus_type) override; void TextSelectionChanged(const WTF::String& text, uint32_t offset, - const gfx::Range& range) override; + const gfx::Range& range, + bool user_initiated) override; void ShowPopupMenu( mojo::PendingRemote<mojom::blink::PopupMenuClient> popup_client, const gfx::Rect& bounds, |