diff options
author | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 18:09:19 +0000 |
---|---|---|
committer | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 18:09:19 +0000 |
commit | 261746fea395fb1587311bad6c185a4cde8335ec (patch) | |
tree | 19b195aed42d23ed988175081e75e96810ca6fbc /content/renderer/browser_plugin | |
parent | 03d9afc0b775748203170a27014a3ee3500aecc2 (diff) | |
download | chromium_src-261746fea395fb1587311bad6c185a4cde8335ec.zip chromium_src-261746fea395fb1587311bad6c185a4cde8335ec.tar.gz chromium_src-261746fea395fb1587311bad6c185a4cde8335ec.tar.bz2 |
<webview>: Expose transparency API
BUG=157628
Review URL: https://codereview.chromium.org/95693002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238428 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/browser_plugin')
-rw-r--r-- | content/renderer/browser_plugin/browser_plugin.cc | 41 | ||||
-rw-r--r-- | content/renderer/browser_plugin/browser_plugin.h | 12 | ||||
-rw-r--r-- | content/renderer/browser_plugin/browser_plugin_bindings.cc | 37 |
3 files changed, 63 insertions, 27 deletions
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc index 192f64c..178f96d 100644 --- a/content/renderer/browser_plugin/browser_plugin.cc +++ b/content/renderer/browser_plugin/browser_plugin.cc @@ -86,7 +86,6 @@ BrowserPlugin::BrowserPlugin( content_window_routing_id_(MSG_ROUTING_NONE), plugin_focused_(false), visible_(true), - opaque_(true), before_first_navigation_(true), mouse_locked_(false), browser_plugin_manager_(render_view->GetBrowserPluginManager()), @@ -182,6 +181,10 @@ std::string BrowserPlugin::GetNameAttribute() const { return GetDOMAttributeValue(browser_plugin::kAttributeName); } +bool BrowserPlugin::GetAllowTransparencyAttribute() const { + return HasDOMAttribute(browser_plugin::kAttributeAllowTransparency); +} + std::string BrowserPlugin::GetSrcAttribute() const { return GetDOMAttributeValue(browser_plugin::kAttributeSrc); } @@ -259,6 +262,21 @@ void BrowserPlugin::ParseNameAttribute() { GetNameAttribute())); } +void BrowserPlugin::ParseAllowTransparencyAttribute() { + if (!HasGuestInstanceID()) + return; + + bool opaque = !GetAllowTransparencyAttribute(); + + if (compositing_helper_) + compositing_helper_->SetContentsOpaque(opaque); + + browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetContentsOpaque( + render_view_routing_id_, + guest_instance_id_, + opaque)); +} + bool BrowserPlugin::ParseSrcAttribute(std::string* error_message) { if (!valid_partition_id_) { *error_message = browser_plugin::kErrorInvalidPartition; @@ -372,7 +390,7 @@ void BrowserPlugin::Attach(scoped_ptr<base::DictionaryValue> extra_params) { BrowserPluginHostMsg_Attach_Params attach_params; attach_params.focused = ShouldGuestBeFocused(); attach_params.visible = visible_; - attach_params.opaque = opaque_; + attach_params.opaque = !GetAllowTransparencyAttribute(); attach_params.name = GetNameAttribute(); attach_params.storage_partition_id = storage_partition_id_; attach_params.persist_storage = persist_storage_; @@ -393,23 +411,6 @@ void BrowserPlugin::DidCommitCompositorFrame() { compositing_helper_->DidCommitCompositorFrame(); } -void BrowserPlugin::SetContentsOpaque(bool opaque) { - if (opaque_ == opaque) - return; - - opaque_ = opaque; - if (!HasGuestInstanceID()) - return; - - if (compositing_helper_) - compositing_helper_->SetContentsOpaque(opaque_); - - browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetContentsOpaque( - render_view_routing_id_, - guest_instance_id_, - opaque_)); -} - void BrowserPlugin::OnAdvanceFocus(int guest_instance_id, bool reverse) { DCHECK(render_view_.get()); render_view_->GetWebView()->advanceFocus(reverse); @@ -922,7 +923,7 @@ void BrowserPlugin::EnableCompositing(bool enable) { } } compositing_helper_->EnableCompositing(enable); - compositing_helper_->SetContentsOpaque(opaque_); + compositing_helper_->SetContentsOpaque(!GetAllowTransparencyAttribute()); } void BrowserPlugin::destroy() { diff --git a/content/renderer/browser_plugin/browser_plugin.h b/content/renderer/browser_plugin/browser_plugin.h index f9c6fbb..afaca69 100644 --- a/content/renderer/browser_plugin/browser_plugin.h +++ b/content/renderer/browser_plugin/browser_plugin.h @@ -60,6 +60,11 @@ class CONTENT_EXPORT BrowserPlugin : std::string GetNameAttribute() const; // Parse the name attribute value. void ParseNameAttribute(); + // Get the allowtransparency attribute value. + bool GetAllowTransparencyAttribute() const; + // Parse the allowtransparency attribute and adjust transparency of + // BrowserPlugin accordingly. + void ParseAllowTransparencyAttribute(); // Get the src attribute value of the BrowserPlugin instance. std::string GetSrcAttribute() const; // Parse the src attribute value of the BrowserPlugin instance. @@ -135,10 +140,6 @@ class CONTENT_EXPORT BrowserPlugin : // sent, if needed. void DidCommitCompositorFrame(); - // Apply opacity settings on the composited layers in embedder and send a - // message to the guest renderer to enable or disable transparent background. - void SetContentsOpaque(bool opaque); - // Returns whether a message should be forwarded to BrowserPlugin. static bool ShouldForwardToBrowserPlugin(const IPC::Message& message); @@ -335,9 +336,6 @@ class CONTENT_EXPORT BrowserPlugin : // Tracks the visibility of the browser plugin regardless of the whole // embedder RenderView's visibility. bool visible_; - // Tracks the opacity of the compositing helper's layers and the guest - // renderer process. - bool opaque_; WebCursor cursor_; diff --git a/content/renderer/browser_plugin/browser_plugin_bindings.cc b/content/renderer/browser_plugin/browser_plugin_bindings.cc index ffeafcf..2e0ab77 100644 --- a/content/renderer/browser_plugin/browser_plugin_bindings.cc +++ b/content/renderer/browser_plugin/browser_plugin_bindings.cc @@ -312,6 +312,41 @@ class BrowserPluginPropertyBinding { DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBinding); }; +class BrowserPluginPropertyBindingAllowTransparency + : public BrowserPluginPropertyBinding { + public: + BrowserPluginPropertyBindingAllowTransparency() + : BrowserPluginPropertyBinding( + browser_plugin::kAttributeAllowTransparency) { + } + virtual bool GetProperty(BrowserPluginBindings* bindings, + NPVariant* result) OVERRIDE { + bool allow_transparency = + bindings->instance()->GetAllowTransparencyAttribute(); + BOOLEAN_TO_NPVARIANT(allow_transparency, *result); + return true; + } + virtual bool SetProperty(BrowserPluginBindings* bindings, + NPObject* np_obj, + const NPVariant* variant) OVERRIDE { + std::string value = StringFromNPVariant(*variant); + if (!bindings->instance()->HasDOMAttribute(name())) { + UpdateDOMAttribute(bindings, value); + bindings->instance()->ParseAllowTransparencyAttribute(); + } else { + UpdateDOMAttribute(bindings, value); + } + return true; + } + virtual void RemoveProperty(BrowserPluginBindings* bindings, + NPObject* np_obj) OVERRIDE { + bindings->instance()->RemoveDOMAttribute(name()); + bindings->instance()->ParseAllowTransparencyAttribute(); + } + private: + DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingAllowTransparency); +}; + class BrowserPluginPropertyBindingAutoSize : public BrowserPluginPropertyBinding { public: @@ -638,6 +673,8 @@ BrowserPluginBindings::BrowserPluginBindings(BrowserPlugin* instance) method_bindings_.push_back(new BrowserPluginBindingAttach); method_bindings_.push_back(new BrowserPluginBindingAttachWindowTo); + property_bindings_.push_back( + new BrowserPluginPropertyBindingAllowTransparency); property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); |