Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.6.0, 5.7.0 Beta
-
None
-
54e108f1efbc695a8da2f3ce33a44cff2eae4a36 3deea958f1485b50940e7437c0a3b73ed29ee134
Description
Changing the selection of a QWebEnginePage using the javascript API i.e.
var range = document.createRange(); var node = document.getElementById("container"); range.selectNode(node); getSelection().addRange(range);
and afterwards calling QWebEnginePage::selectedText() will return an empty string. The selectedTextChanged signal is also not emitted.
This happens because RenderFrameImpl::didChangeSelection returns early, when the selection change is not caused by an input event, which suggests this is done on purpose.
Attaching call trace of the in process renderer just for informational purposes:
1 content::RenderFrameImpl::didChangeSelection(bool) render_frame_impl.cc 2980 0x10329b648 2 blink::EditorClientImpl::respondToChangedSelection(blink::LocalFrame *, blink::SelectionType) EditorClientImpl.cpp 52 0x102fe8250 3 blink::Editor::notifyComponentsOnChangedSelection(blink::VisibleSelection const&, unsigned int) Editor.cpp 541 0x104e465b8 4 blink::Editor::respondToChangedSelection(blink::VisibleSelection const&, unsigned int) Editor.cpp 1261 0x104e4a05b 5 blink::FrameSelection::setSelection(blink::VisibleSelection const&, unsigned int, blink::FrameSelection::CursorAlignOnScroll, blink::TextGranularity) FrameSelection.cpp 316 0x104e59e9f 6 blink::FrameSelection::setSelectedRange(blink::EphemeralRangeTemplate<blink::EditingStrategy> const&, blink::EAffinity, blink::FrameSelection::DirectoinalOption, unsigned int) FrameSelection.cpp 1482 0x104e6164a 7 blink::FrameSelection::setSelectedRange(blink::Range *, blink::EAffinity, blink::FrameSelection::DirectoinalOption, unsigned int) FrameSelection.cpp 1463 0x104e6146c 8 blink::DOMSelection::addRange(blink::Range *) DOMSelection.cpp 407 0x104e2b85d 9 blink::DOMSelectionV8Internal::addRangeMethod(v8::FunctionCallbackInfo<v8::Value> const&) V8Selection.cpp 244 0x1024c67fd 10 blink::DOMSelectionV8Internal::addRangeMethodCallback(v8::FunctionCallbackInfo<v8::Value> const&) V8Selection.cpp 250 0x1024c5bf4 11 v8::internal::FunctionCallbackArguments::Call(void ( *)(v8::FunctionCallbackInfo<v8::Value> const&)) arguments.cc 33 0x1071be78c 12 v8::internal::MaybeHandle<v8::internal::Object> v8::internal::HandleApiCallHelper<false>(v8::internal::Isolate *, v8::internal::(anonymous namespace)::BuiltinArguments<(v8::internal::BuiltinExtraArguments)1>&) builtins.cc 1092 0x1071f9145 13 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::(anonymous namespace)::BuiltinArguments<(v8::internal::BuiltinExtraArguments)1>, v8::internal::Isolate *) builtins.cc 1115 0x1071ff336 14 v8::internal::Builtin_HandleApiCall(int, v8::internal::Object * *, v8::internal::Isolate *) builtins.cc 1111 0x1071ff278 15 None 0x128b7909b7b 16 None 0x128b79395a3 17 None 0x128b7931abd 18 None 0x128b79160c2 19 v8::internal::Invoke(bool, v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object> *) execution.cc 128 0x10739bb52 20 v8::Script::Run(v8::Local<v8::Context>) api.cc 1671 0x10715a365 21 blink::V8ScriptRunner::runCompiledScript(v8::Isolate *, v8::Local<v8::Script>, blink::ExecutionContext *) V8ScriptRunner.cpp 391 0x1023da7ec 22 blink::ScriptController::executeScriptAndReturnValue(v8::Local<v8::Context>, blink::ScriptSourceCode const&, blink::AccessControlStatus, double *) ScriptController.cpp 190 0x102359252 23 blink::ScriptController::evaluateScriptInMainWorld(blink::ScriptSourceCode const&, blink::AccessControlStatus, blink::ScriptController::ExecuteScriptPolicy, double *) ScriptController.cpp 563 0x10235b1a4 24 blink::ScriptController::executeScriptInMainWorldAndReturnValue(blink::ScriptSourceCode const&) ScriptController.cpp 541 0x10235b439 25 blink::WebLocalFrameImpl::executeScriptAndReturnValue(blink::WebScriptSource const&) WebLocalFrameImpl.cpp 896 0x103067f5b 26 content::RenderFrameImpl::OnJavaScriptExecuteRequest(std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short>> const&, int, bool) render_frame_impl.cc 1401 0x10328a797 27 void base::DispatchToMethodImpl<content::RenderFrameImpl, void (content::RenderFrameImpl:: *)(std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short>> const&, int, bool), std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short>>, int, bool, 0ul, 1ul, 2ul>(content::RenderFrameImpl *, void (content::RenderFrameImpl:: *)(std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short>> const&, int, bool), base::Tuple<std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short>>, int, bool> const&, base::IndexSequence<0ul, 1ul, 2ul>) tuple.h 254 0x1032b7d8d 28 void base::DispatchToMethod<content::RenderFrameImpl, void (content::RenderFrameImpl:: *)(std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short>> const&, int, bool), std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short>>, int, bool>(content::RenderFrameImpl *, void (content::RenderFrameImpl:: *)(std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short>> const&, int, bool), base::Tuple<std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short>>, int, bool> const&) tuple.h 261 0x1032b7c95 29 bool FrameMsg_JavaScriptExecuteRequest::Dispatch<content::RenderFrameImpl, content::RenderFrameImpl, void, void (content::RenderFrameImpl:: *)(std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short>> const&, int, bool)>(IPC::Message const *, content::RenderFrameImpl *, content::RenderFrameImpl *, void *, void (content::RenderFrameImpl:: *)(std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short>> const&, int, bool)) frame_messages.h 514 0x1032a79da 30 content::RenderFrameImpl::OnMessageReceived(IPC::Message const&) render_frame_impl.cc 1032 0x103287f25 31 content::MessageRouter::RouteMessage(IPC::Message const&) message_router.cc 54 0x105db3bab 32 content::MessageRouter::OnMessageReceived(IPC::Message const&) message_router.cc 46 0x105db3b2e 33 content::ChildThreadImpl::OnMessageReceived(IPC::Message const&) child_thread_impl.cc 631 0x107bf64c0 34 IPC::ChannelProxy::Context::OnDispatchMessage(IPC::Message const&) ipc_channel_proxy.cc 298 0x1019985b2 35 base::internal::RunnableAdapter<void (IPC::ChannelProxy::Context:: *)(IPC::Message const&)>::Run(IPC::ChannelProxy::Context *, IPC::Message const&) bind_internal.h 176 0x10199dc31 36 base::internal::InvokeHelper<false, void, base::internal::RunnableAdapter<void (IPC::ChannelProxy::Context:: *)(IPC::Message const&)>, base::internal::TypeList<IPC::ChannelProxy::Context * const&, IPC::Message const&>>::MakeItSo(base::internal::RunnableAdapter<void (IPC::ChannelProxy::Context:: *)(IPC::Message const&)>, IPC::ChannelProxy::Context * const&, IPC::Message const&) bind_internal.h 293 0x10199db71 37 base::internal::Invoker<base::IndexSequence<0ul, 1ul>, base::internal::BindState<base::internal::RunnableAdapter<void (IPC::ChannelProxy::Context:: *)(IPC::Message const&)>, void (IPC::ChannelProxy::Context *, IPC::Message const&), base::internal::TypeList<IPC::ChannelProxy::Context *, IPC::Message>>, base::internal::TypeList<base::internal::UnwrapTraits<IPC::ChannelProxy::Context *>, base::internal::UnwrapTraits<IPC::Message>>, base::internal::InvokeHelper<false, void, base::internal::RunnableAdapter<void (IPC::ChannelProxy::Context:: *)(IPC::Message const&)>, base::internal::TypeList<IPC::ChannelProxy::Context * const&, IPC::Message const&>>, void ()>::Run(base::internal::BindStateBase *) bind_internal.h 343 0x10199db21 38 base::Callback<void ()>::Run() const callback.h 396 0x101a29dde 39 base::debug::TaskAnnotator::RunTask(const char *, const char *, base::PendingTask const&) task_annotator.cc 62 0x101be9ed2 40 scheduler::TaskQueueManager::ProcessTaskFromWorkQueue(unsigned long, bool, base::PendingTask *) task_queue_manager.cc 737 0x1053481eb 41 scheduler::TaskQueueManager::DoWork(bool) task_queue_manager.cc 691 0x1053469de 42 base::internal::RunnableAdapter<void (scheduler::TaskQueueManager:: *)(bool)>::Run(scheduler::TaskQueueManager *, bool const&) bind_internal.h 176 0x1053527c6 43 base::internal::InvokeHelper<true, void, base::internal::RunnableAdapter<void (scheduler::TaskQueueManager:: *)(bool)>, base::internal::TypeList<base::WeakPtr<scheduler::TaskQueueManager> const&, bool const&>>::MakeItSo(base::internal::RunnableAdapter<void (scheduler::TaskQueueManager:: *)(bool)>, base::WeakPtr<scheduler::TaskQueueManager> const&, bool const&) bind_internal.h 303 0x1053526a6 44 base::internal::Invoker<base::IndexSequence<0ul, 1ul>, base::internal::BindState<base::internal::RunnableAdapter<void (scheduler::TaskQueueManager:: *)(bool)>, void (scheduler::TaskQueueManager *, bool), base::internal::TypeList<base::WeakPtr<scheduler::TaskQueueManager>, bool>>, base::internal::TypeList<base::internal::UnwrapTraits<base::WeakPtr<scheduler::TaskQueueManager>>, base::internal::UnwrapTraits<bool>>, base::internal::InvokeHelper<true, void, base::internal::RunnableAdapter<void (scheduler::TaskQueueManager:: *)(bool)>, base::internal::TypeList<base::WeakPtr<scheduler::TaskQueueManager> const&, bool const&>>, void ()>::Run(base::internal::BindStateBase *) bind_internal.h 343 0x105352641 45 base::Callback<void ()>::Run() const callback.h 396 0x101a29dde 46 base::debug::TaskAnnotator::RunTask(const char *, const char *, base::PendingTask const&) task_annotator.cc 62 0x101be9ed2 47 base::MessageLoop::RunTask(base::PendingTask const&) message_loop.cc 472 0x101c6720f 48 base::MessageLoop::DeferOrRunPendingTask(base::PendingTask const&) message_loop.cc 482 0x101c67348 49 base::MessageLoop::DoWork() message_loop.cc 594 0x101c6792e 50 base::MessagePumpCFRunLoopBase::RunWork() message_pump_mac.mm 328 0x101bb3c2a 51 ___ZN4base24MessagePumpCFRunLoopBase13RunWorkSourceEPv_block_invoke message_pump_mac.mm 305 0x101bb3bbc 52 base::mac::CallWithEHFrame(void () block_pointer) call_with_eh_frame_asm.S 36 0x101c3eeda 53 base::MessagePumpCFRunLoopBase::RunWorkSource(void *) message_pump_mac.mm 304 0x101bb3257 54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ 0x7fff90f17881 55 __CFRunLoopDoSources0 0x7fff90ef6fbc 56 __CFRunLoopRun 0x7fff90ef64df 57 CFRunLoopRunSpecific 0x7fff90ef5ed8 58 base::MessagePumpCFRunLoop::DoRun(base::MessagePump::Delegate *) message_pump_mac.mm 552 0x101bb41ce 59 base::MessagePumpCFRunLoopBase::Run(base::MessagePump::Delegate *) message_pump_mac.mm 236 0x101bb394a 60 base::MessageLoop::RunHandler() message_loop.cc 438 0x101c66cea 61 base::RunLoop::Run() run_loop.cc 55 0x101cbfb74 62 base::MessageLoop::Run() message_loop.cc 287 0x101c66183 63 base::Thread::Run(base::MessageLoop *) thread.cc 198 0x101d56029 64 base::Thread::ThreadMain() thread.cc 248 0x101d56570 65 base::(anonymous namespace)::ThreadFunc(void *) platform_thread_posix.cc 76 0x101d3d2e6 66 _pthread_body 0x7fff9d08499d 67 _pthread_start 0x7fff9d08491a 68 thread_start 0x7fff9d082351
Also attached example.
Attachments
Issue Links
- relates to
-
QTBUG-60381 tst_QWebEngineView::imeComposition() fails
- Closed
-
QTBUG-54071 When doing a find after selecting some text then it will still think that the text is selected if you query for selectedText
- Closed
-
QTBUG-55766 Add back QInputMethodEvent support and tests to Widget API
- Closed
For Gerrit Dashboard: QTBUG-53134 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
192920,4 | Update TextSelection for non-user initiated events | 58-based | qt/qtwebengine-chromium | Status: MERGED | +2 | 0 |
192921,6 | Fix emitting selectionChanged signal for non-user text selection change | dev | qt/qtwebengine | Status: MERGED | +2 | 0 |
194066,5 | Fix selectedText() to return the value of what findText("") finds | 5.10 | qt/qtwebengine | Status: MERGED | +2 | 0 |
201419,2 | Update TextSelection for non-user initiated events | 60-based | qt/qtwebengine-chromium | Status: MERGED | +2 | 0 |
325276,9 | Update TextSelection for non-user initiated events | 87-based | qt/qtwebengine-chromium | Status: MERGED | +2 | 0 |