mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Make WebView::close not crash and start to fix navigation in SkyShell
However WebView::close() no longer crashes. close() is never called in MojoShell since mojo can't shutdown yet. I tried closing the existing WebView and replacing it but somehow that caused it to only draw red. After a while of looking at this with abarth we decided to just load into the same WebView for now. Eventually we should do something smarter where we start the provisional load and only replace the webview once the new one is ready, but that's a later CL. R=abarth@chromium.org BUG= Review URL: https://codereview.chromium.org/952273003
This commit is contained in:
parent
29dad69899
commit
5a69a1edca
@ -34,9 +34,17 @@ void Animator::RequestFrame() {
|
||||
}
|
||||
}
|
||||
|
||||
void Animator::CancelFrameRequest() {
|
||||
engine_requested_frame_ = false;
|
||||
}
|
||||
|
||||
void Animator::BeginFrame() {
|
||||
DCHECK(frame_in_progress_);
|
||||
DCHECK(engine_requested_frame_);
|
||||
// There could be a request in the message loop at time of cancel.
|
||||
if (!engine_requested_frame_) {
|
||||
frame_in_progress_ = false;
|
||||
return;
|
||||
}
|
||||
engine_requested_frame_ = false;
|
||||
|
||||
engine_->BeginFrame(base::TimeTicks::Now());
|
||||
|
||||
@ -17,6 +17,7 @@ class Animator {
|
||||
~Animator();
|
||||
|
||||
void RequestFrame();
|
||||
void CancelFrameRequest();
|
||||
|
||||
private:
|
||||
void BeginFrame();
|
||||
|
||||
@ -119,13 +119,21 @@ void Engine::OnInputEvent(InputEventPtr event) {
|
||||
}
|
||||
|
||||
void Engine::LoadURL(const mojo::String& url) {
|
||||
web_view_ = blink::WebView::create(this);
|
||||
// Something bad happens if you try to call WebView::close and replace
|
||||
// the webview. So for now we just load into the existing one. :/
|
||||
if (!web_view_)
|
||||
web_view_ = blink::WebView::create(this);
|
||||
ConfigureSettings(web_view_->settings());
|
||||
web_view_->setMainFrame(blink::WebLocalFrame::create(this));
|
||||
UpdateWebViewSize();
|
||||
web_view_->mainFrame()->load(GURL(url));
|
||||
}
|
||||
|
||||
void Engine::frameDetached(blink::WebFrame* frame) {
|
||||
// |frame| is invalid after here.
|
||||
frame->close();
|
||||
}
|
||||
|
||||
void Engine::initializeLayerTreeView() {
|
||||
}
|
||||
|
||||
@ -133,5 +141,23 @@ void Engine::scheduleVisualUpdate() {
|
||||
animator_->RequestFrame();
|
||||
}
|
||||
|
||||
blink::ServiceProvider* Engine::services() {
|
||||
return this;
|
||||
}
|
||||
|
||||
mojo::NavigatorHost* Engine::NavigatorHost() {
|
||||
return this;
|
||||
}
|
||||
|
||||
void Engine::RequestNavigate(mojo::Target target,
|
||||
mojo::URLRequestPtr request) {
|
||||
// Ignoring target for now.
|
||||
base::MessageLoop::current()->PostTask(FROM_HERE,
|
||||
base::Bind(&Engine::LoadURL, GetWeakPtr(), request->url));
|
||||
}
|
||||
|
||||
void Engine::DidNavigateLocally(const mojo::String& url) {
|
||||
}
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
|
||||
@ -11,7 +11,9 @@
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "mojo/public/cpp/bindings/binding.h"
|
||||
#include "mojo/public/cpp/system/core.h"
|
||||
#include "mojo/services/navigation/public/interfaces/navigation.mojom.h"
|
||||
#include "skia/ext/refptr.h"
|
||||
#include "sky/engine/public/platform/ServiceProvider.h"
|
||||
#include "sky/engine/public/web/WebFrameClient.h"
|
||||
#include "sky/engine/public/web/WebViewClient.h"
|
||||
#include "sky/shell/gpu_delegate.h"
|
||||
@ -26,6 +28,8 @@ class Animator;
|
||||
|
||||
class Engine : public UIDelegate,
|
||||
public ViewportObserver,
|
||||
public blink::ServiceProvider,
|
||||
public mojo::NavigatorHost,
|
||||
public blink::WebFrameClient,
|
||||
public blink::WebViewClient {
|
||||
public:
|
||||
@ -56,9 +60,19 @@ class Engine : public UIDelegate,
|
||||
void LoadURL(const mojo::String& url) override;
|
||||
|
||||
// WebViewClient methods:
|
||||
void frameDetached(blink::WebFrame*) override;
|
||||
void initializeLayerTreeView() override;
|
||||
void scheduleVisualUpdate() override;
|
||||
blink::WebScreenInfo screenInfo() override;
|
||||
blink::ServiceProvider* services() override;
|
||||
|
||||
// Services methods:
|
||||
mojo::NavigatorHost* NavigatorHost() override;
|
||||
|
||||
// NavigatorHost methods:
|
||||
void RequestNavigate(mojo::Target target,
|
||||
mojo::URLRequestPtr request) override;
|
||||
void DidNavigateLocally(const mojo::String& url) override;
|
||||
|
||||
void UpdateWebViewSize();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user