-
Notifications
You must be signed in to change notification settings - Fork 15k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: manually set spellchecker for sub frames #11238
Conversation
FrameSpellChecker spell_checker( | ||
spell_check_client_.get(), | ||
content::RenderFrame::FromWebFrame(web_frame_)); | ||
content::RenderFrame::ForEach(&spell_checker); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The steps look good but there might be a small timing issue here: in subsequent calls, the webframes' TextCheckClient will be dangling pointers inbetween the calls to
spell_check_client_.reset()
and
ForEach() ->render_frame->GetWebFrame()->SetTextCheckClient()
Seems like we'd want to keep the previous spell_check_client_ alive in temporary unique_ptr until after ForEach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Followup question, is it certain that the ForEach
will change all the frames that hold a pointer to the old spellchecker?
E.g. is it possible for GetRenderView()
, GetMainRenderFrame()
, or IsMainFrame()
to change so that subsequent calls to ForEach
might change a different set of frames than the last call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there might be a small timing issue here:
👍 , in that case would it be better to initialize SpellCheckClient
once per frame and just reset the states on subsequent calls ? I am not sure about the reason for current implementation. @zcbenz what do you think about this ?
is it certain that the ForEach will change all the frames that hold a pointer to the old spellchecker?
Yup, ForEach
is certain to iterate over all live frames in the process. The only reason for the main frame checks are to make sure that in sandbox mode frames with similar site instances in different windows only get assigned to the spellchecker their parent frame is assigned with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can keep the new pointer and then do a swap:
std::unique_ptr client(new SpellCheckClient());
ForEach()->Set(client.get());
spell_check_client_.swap(client);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, have addressed the changes requested. Thanks!
b0764b3
to
83d2917
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
The failing test is not related to this PR, I'm merging anyway. |
Since the spellchecker has been refactored for OOPIF to be frame based instead of view based https://bugs.chromium.org/p/chromium/issues/detail?id=638361 , we need to make sure that its enabled for the sub frames.
Fixes #11147