Commit a95539cf authored by danakj@chromium.org's avatar danakj@chromium.org

WebViewPlugin: Apply Prefs to WebSettings before creating WebLocalFrame

If we create a WebLocalFrame and then set blink's settings, the frame
gets an inconsistent view of the settings when they change out from
underneath it.

Concretely, this leads to us doing WebViewImpl::setRootGraphicsLayer(A)
with pinch virtual viewport disabled (the default in WebSettings), when
we attach the document to the tree, then we apply the prefs to enable
pinch virtual viewport, and later setRootGraphicsLayer(NULL) to detach
the document. This causes a crash because the viewport code expects
a matching attach before the detach.

With this CL, https://codereview.chromium.org/261143003 is able to pass
on the print preview and prerender browser tests.

R=bauerb@chromium.org
BUG=376531,361729

Review URL: https://codereview.chromium.org/296983017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272628 0039d316-1c4b-4281-b951-d872f2087c98
parent 304130fa
......@@ -41,13 +41,17 @@ using blink::WebURLResponse;
using blink::WebVector;
using blink::WebView;
WebViewPlugin::WebViewPlugin(WebViewPlugin::Delegate* delegate)
WebViewPlugin::WebViewPlugin(WebViewPlugin::Delegate* delegate,
const WebPreferences& preferences)
: delegate_(delegate),
container_(NULL),
web_view_(WebView::create(this)),
web_frame_(WebLocalFrame::create(this)),
finished_loading_(false),
focused_(false) {
// ApplyWebPreferences before making a WebLocalFrame so that the frame sees a
// consistent view of our preferences.
content::ApplyWebPreferences(preferences, web_view_);
web_frame_ = WebLocalFrame::create(this);
web_view_->setMainFrame(web_frame_);
}
......@@ -56,10 +60,8 @@ WebViewPlugin* WebViewPlugin::Create(WebViewPlugin::Delegate* delegate,
const WebPreferences& preferences,
const std::string& html_data,
const GURL& url) {
WebViewPlugin* plugin = new WebViewPlugin(delegate);
WebView* web_view = plugin->web_view();
content::ApplyWebPreferences(preferences, web_view);
web_view->mainFrame()->loadHTMLString(html_data, url);
WebViewPlugin* plugin = new WebViewPlugin(delegate, preferences);
plugin->web_view()->mainFrame()->loadHTMLString(html_data, url);
return plugin;
}
......
......@@ -47,8 +47,6 @@ class WebViewPlugin : public blink::WebPlugin,
virtual void PluginDestroyed() = 0;
};
explicit WebViewPlugin(Delegate* delegate);
// Convenience method to set up a new WebViewPlugin using |preferences|
// and displaying |html_data|. |url| should be a (fake) chrome:// URL; it is
// only used for navigation and never actually resolved.
......@@ -137,6 +135,7 @@ class WebViewPlugin : public blink::WebPlugin,
private:
friend class base::DeleteHelper<WebViewPlugin>;
WebViewPlugin(Delegate* delegate, const WebPreferences& preferences);
virtual ~WebViewPlugin();
// Manages its own lifetime.
......
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