Commit be0ec866 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Don't call SpellCheckHost::DisconnectSessionBridge if SpellCheckHost is not bound yet

It's a waste to call SpellCheckHost::DisconnectSessionBridge when
SpellCheckHost is not bound, as it initializes a SpellCheckHost and
then disables it immediately.

Therefore, this patch stops calling it when SpellCheckHost is not
bound yet. This gives a 12% performance improvement on test
blink_perf.css/FocusUpdate:

https://pinpoint-dot-chromeperf.appspot.com/job/15c3ea19740000

Bug: 814225
Change-Id: I0e00a7b31528db424f80cf89ec013751436ea88c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1500779
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#637901}
parent c80fa465
...@@ -146,14 +146,14 @@ void SpellCheckProvider::RequestTextChecking( ...@@ -146,14 +146,14 @@ void SpellCheckProvider::RequestTextChecking(
void SpellCheckProvider::FocusedNodeChanged(const blink::WebNode& unused) { void SpellCheckProvider::FocusedNodeChanged(const blink::WebNode& unused) {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
if (!spell_check_host_.is_bound())
return;
WebLocalFrame* frame = render_frame()->GetWebFrame(); WebLocalFrame* frame = render_frame()->GetWebFrame();
WebElement element = frame->GetDocument().IsNull() WebElement element = frame->GetDocument().IsNull()
? WebElement() ? WebElement()
: frame->GetDocument().FocusedElement(); : frame->GetDocument().FocusedElement();
bool enabled = !element.IsNull() && element.IsEditable(); bool enabled = !element.IsNull() && element.IsEditable();
// TODO(xiaochengh): Don't call GetSpellCheckHost() if SpellCheckHost is not
// bound yet. crbug.com/814225
if (!enabled) if (!enabled)
GetSpellCheckHost().DisconnectSessionBridge(); GetSpellCheckHost().DisconnectSessionBridge();
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment