Skip to content
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

Merged
merged 1 commit into from
Dec 21, 2017
Merged

Conversation

deepak1556
Copy link
Member

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

@deepak1556 deepak1556 requested review from zcbenz and a team November 24, 2017 07:01
FrameSpellChecker spell_checker(
spell_check_client_.get(),
content::RenderFrame::FromWebFrame(web_frame_));
content::RenderFrame::ForEach(&spell_checker);
Copy link
Member

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

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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);

Copy link
Member Author

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!

Copy link
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@zcbenz
Copy link
Member

zcbenz commented Dec 21, 2017

The failing test is not related to this PR, I'm merging anyway.

@zcbenz zcbenz merged commit 65871cd into master Dec 21, 2017
@zcbenz zcbenz deleted the spellchecker_iframe_patch branch December 21, 2017 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants