Chromium Code Reviews| Index: components/spellcheck/renderer/spellcheck_provider.cc |
| diff --git a/components/spellcheck/renderer/spellcheck_provider.cc b/components/spellcheck/renderer/spellcheck_provider.cc |
| index 73d536ff33c83783387c1617bb26b11e7fb94da2..1cebca7e803c721bca115092da818bad16e8ba5e 100644 |
| --- a/components/spellcheck/renderer/spellcheck_provider.cc |
| +++ b/components/spellcheck/renderer/spellcheck_provider.cc |
| @@ -11,7 +11,6 @@ |
| #include "components/spellcheck/renderer/spellcheck_language.h" |
| #include "components/spellcheck/spellcheck_build_features.h" |
| #include "content/public/renderer/render_frame.h" |
| -#include "content/public/renderer/render_view.h" |
| #include "third_party/WebKit/public/platform/WebVector.h" |
| #include "third_party/WebKit/public/web/WebDocument.h" |
| #include "third_party/WebKit/public/web/WebElement.h" |
| @@ -19,7 +18,6 @@ |
| #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" |
| #include "third_party/WebKit/public/web/WebTextCheckingResult.h" |
| #include "third_party/WebKit/public/web/WebTextDecorationType.h" |
| -#include "third_party/WebKit/public/web/WebView.h" |
| using blink::WebElement; |
| using blink::WebLocalFrame; |
| @@ -34,14 +32,16 @@ static_assert(int(blink::WebTextDecorationTypeSpelling) == |
| static_assert(int(blink::WebTextDecorationTypeGrammar) == |
| int(SpellCheckResult::GRAMMAR), "mismatching enums"); |
| -SpellCheckProvider::SpellCheckProvider( |
| - content::RenderView* render_view, |
| - SpellCheck* spellcheck) |
| - : content::RenderViewObserver(render_view), |
| - content::RenderViewObserverTracker<SpellCheckProvider>(render_view), |
| +SpellCheckProvider::SpellCheckProvider(content::RenderFrame* render_frame, |
| + SpellCheck* spellcheck) |
| + : content::RenderFrameObserver(render_frame), |
| + content::RenderFrameObserverTracker<SpellCheckProvider>(render_frame), |
| spellcheck_(spellcheck) { |
| DCHECK(spellcheck_); |
| - if (render_view) { // NULL in unit tests. |
| + if (render_frame) { // NULL in unit tests. |
| + render_frame->GetWebFrame()->setTextCheckClient(this); |
| + // TODO(xiaochengh): It is possible that the LocalFrame has not been set up, |
| + // even though the WebLocalFrame must have been set up. Investigate why. |
| EnableSpellcheck(spellcheck_->IsSpellcheckEnabled()); |
|
Xiaocheng
2017/04/07 01:43:45
Crashes here, because EnableSpellcheck() visits bl
|
| } |
| } |
| @@ -98,7 +98,7 @@ bool SpellCheckProvider::OnMessageReceived(const IPC::Message& message) { |
| void SpellCheckProvider::FocusedNodeChanged(const blink::WebNode& unused) { |
| #if BUILDFLAG(USE_BROWSER_SPELLCHECKER) |
| - WebLocalFrame* frame = render_view()->GetWebView()->focusedFrame(); |
| + WebLocalFrame* frame = render_frame()->GetWebFrame(); |
| WebElement element = frame->document().isNull() ? WebElement() : |
| frame->document().focusedElement(); |
| bool enabled = !element.isNull() && element.isEditable(); |
| @@ -225,15 +225,7 @@ void SpellCheckProvider::OnRespondTextCheck( |
| #endif |
| void SpellCheckProvider::EnableSpellcheck(bool enable) { |
| - if (!render_view()->GetWebView()) |
| - return; |
| - |
| - WebLocalFrame* frame = render_view()->GetWebView()->focusedFrame(); |
| - // TODO(yabinh): The null check should be unnecessary. |
| - // See crbug.com/625068 |
| - if (!frame) |
| - return; |
| - |
| + WebLocalFrame* frame = render_frame()->GetWebFrame(); |
| frame->enableSpellChecking(enable); |
| if (!enable) |
| frame->removeSpellingMarkers(); |