Commit 4785ac5f authored by fsamuel@chromium.org's avatar fsamuel@chromium.org

Revert 170866

> Browser Plugin: Update DOM Node attributes when properties are updated
> 
> BUG=163611
> Test=BrowserPluginHostTest.*, BrowserPluginTest.*, WebViewTest.*
> 
> Review URL: https://codereview.chromium.org/11418261

TBR=fsamuel@chromium.org
Review URL: https://codereview.chromium.org/11415279

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170867 0039d316-1c4b-4281-b951-d872f2087c98
parent 06972614
...@@ -90,14 +90,6 @@ function WebView(node) { ...@@ -90,14 +90,6 @@ function WebView(node) {
this.node_, this.node_,
{attributes: true, attributeFilter: WEB_VIEW_ATTRIBUTES}); {attributes: true, attributeFilter: WEB_VIEW_ATTRIBUTES});
var handleObjectMutation = this.handleObjectMutation_.bind(this);
var objectObserver = new WebKitMutationObserver(function(mutations) {
mutations.forEach(handleObjectMutation);
});
objectObserver.observe(
this.objectNode_,
{attributes: true, attributeFilter: WEB_VIEW_ATTRIBUTES});
var objectNode = this.objectNode_; var objectNode = this.objectNode_;
// Expose getters and setters for the attributes. // Expose getters and setters for the attributes.
WEB_VIEW_ATTRIBUTES.forEach(function(attributeName) { WEB_VIEW_ATTRIBUTES.forEach(function(attributeName) {
...@@ -134,18 +126,10 @@ function WebView(node) { ...@@ -134,18 +126,10 @@ function WebView(node) {
* @private * @private
*/ */
WebView.prototype.handleMutation_ = function(mutation) { WebView.prototype.handleMutation_ = function(mutation) {
this.objectNode_[mutation.attributeName] = this.node_[mutation.attributeName] =
this.node_.getAttribute(mutation.attributeName); this.node_.getAttribute(mutation.attributeName);
}; };
/**
* @private
*/
WebView.prototype.handleObjectMutation_ = function(mutation) {
this.node_.setAttribute(mutation.attributeName,
this.objectNode_.getAttribute(mutation.attributeName));
};
/** /**
* @private * @private
*/ */
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/json/json_string_value_serializer.h" #include "base/json/json_string_value_serializer.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "content/common/browser_plugin_messages.h" #include "content/common/browser_plugin_messages.h"
...@@ -67,8 +66,8 @@ const char kOldWidth[] = "oldWidth"; ...@@ -67,8 +66,8 @@ const char kOldWidth[] = "oldWidth";
const char kPartition[] = "partition"; const char kPartition[] = "partition";
const char kPersistPrefix[] = "persist:"; const char kPersistPrefix[] = "persist:";
const char kProcessId[] = "processId"; const char kProcessId[] = "processId";
const char kReason[] = "reason";
const char kSrc[] = "src"; const char kSrc[] = "src";
const char kReason[] = "reason";
const char kURL[] = "url"; const char kURL[] = "url";
// Error messages. // Error messages.
...@@ -260,27 +259,6 @@ bool BrowserPlugin::DamageBufferMatches( ...@@ -260,27 +259,6 @@ bool BrowserPlugin::DamageBufferMatches(
} }
#endif #endif
void BrowserPlugin::UpdateDOMAttribute(
const std::string& attribute_name,
const std::string& attribute_value) {
if (!container())
return;
WebKit::WebElement element = container()->element();
WebKit::WebString web_attribute_name =
WebKit::WebString::fromUTF8(attribute_name);
std::string current_value(element.getAttribute(web_attribute_name).utf8());
if (current_value == attribute_value)
return;
if (attribute_value.empty()) {
element.removeAttribute(web_attribute_name);
} else {
element.setAttribute(web_attribute_name,
WebKit::WebString::fromUTF8(attribute_value));
}
}
void BrowserPlugin::SetMaxHeightAttribute(int max_height) { void BrowserPlugin::SetMaxHeightAttribute(int max_height) {
if (max_height_ == max_height) if (max_height_ == max_height)
return; return;
...@@ -635,10 +613,8 @@ void BrowserPlugin::LoadCommit( ...@@ -635,10 +613,8 @@ void BrowserPlugin::LoadCommit(
// If the guest has just committed a new navigation then it is no longer // If the guest has just committed a new navigation then it is no longer
// crashed. // crashed.
guest_crashed_ = false; guest_crashed_ = false;
if (params.is_top_level) { if (params.is_top_level)
src_ = params.url.spec(); src_ = params.url.spec();
UpdateDOMAttribute(kSrc, src_.c_str());
}
process_id_ = params.process_id; process_id_ = params.process_id;
current_nav_entry_index_ = params.current_entry_index; current_nav_entry_index_ = params.current_entry_index;
nav_entry_count_ = params.entry_count; nav_entry_count_ = params.entry_count;
......
...@@ -36,11 +36,6 @@ class CONTENT_EXPORT BrowserPlugin : ...@@ -36,11 +36,6 @@ class CONTENT_EXPORT BrowserPlugin :
// Called only by tests to clean up before we blow away the MockRenderProcess. // Called only by tests to clean up before we blow away the MockRenderProcess.
void Cleanup(); void Cleanup();
// Update Browser Plugin's DOM Node attribute |attribute_name| with the value
// |attribute_value|.
void UpdateDOMAttribute(const std::string& attribute_name,
const std::string& attribute_value);
// Get the src attribute value of the BrowserPlugin instance. // Get the src attribute value of the BrowserPlugin instance.
std::string src_attribute() const { return src_; } std::string src_attribute() const { return src_; }
// Set the src attribute value of the BrowserPlugin instance. // Set the src attribute value of the BrowserPlugin instance.
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/string16.h" #include "base/string16.h"
#include "base/string_number_conversions.h"
#include "base/string_split.h" #include "base/string_split.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "content/renderer/browser_plugin/browser_plugin.h" #include "content/renderer/browser_plugin/browser_plugin.h"
...@@ -393,7 +392,6 @@ class BrowserPluginPropertyBinding { ...@@ -393,7 +392,6 @@ class BrowserPluginPropertyBinding {
explicit BrowserPluginPropertyBinding(const char name[]) : name_(name) { explicit BrowserPluginPropertyBinding(const char name[]) : name_(name) {
} }
virtual ~BrowserPluginPropertyBinding() {} virtual ~BrowserPluginPropertyBinding() {}
const std::string& name() const { return name_; }
bool MatchesName(NPIdentifier name) const { bool MatchesName(NPIdentifier name) const {
return WebBindings::getStringIdentifier(name_.c_str()) == name; return WebBindings::getStringIdentifier(name_.c_str()) == name;
} }
...@@ -402,12 +400,6 @@ class BrowserPluginPropertyBinding { ...@@ -402,12 +400,6 @@ class BrowserPluginPropertyBinding {
virtual bool SetProperty(BrowserPluginBindings* bindings, virtual bool SetProperty(BrowserPluginBindings* bindings,
NPObject* np_obj, NPObject* np_obj,
const NPVariant* variant) = 0; const NPVariant* variant) = 0;
virtual std::string GetDOMAttributeValue(BrowserPlugin* browser_plugin) = 0;
// Updates the DOM Attribute value with the current property value.
void UpdateDOMAttribute(BrowserPluginBindings* bindings) {
bindings->instance()->UpdateDOMAttribute(name(),
GetDOMAttributeValue(bindings->instance()));
}
private: private:
std::string name_; std::string name_;
...@@ -422,21 +414,17 @@ class BrowserPluginPropertyBindingAutoSize ...@@ -422,21 +414,17 @@ class BrowserPluginPropertyBindingAutoSize
} }
virtual bool GetProperty(BrowserPluginBindings* bindings, virtual bool GetProperty(BrowserPluginBindings* bindings,
NPVariant* result) OVERRIDE { NPVariant* result) OVERRIDE {
bool auto_size = bindings->instance()->auto_size_attribute(); bool autosize = bindings->instance()->auto_size_attribute();
BOOLEAN_TO_NPVARIANT(auto_size, *result); BOOLEAN_TO_NPVARIANT(autosize, *result);
return true; return true;
} }
virtual bool SetProperty(BrowserPluginBindings* bindings, virtual bool SetProperty(BrowserPluginBindings* bindings,
NPObject* np_obj, NPObject* np_obj,
const NPVariant* variant) OVERRIDE { const NPVariant* variant) OVERRIDE {
bool auto_size = NPVARIANT_TO_BOOLEAN(*variant); bool autosize = NPVARIANT_TO_BOOLEAN(*variant);
bindings->instance()->SetAutoSizeAttribute(auto_size); bindings->instance()->SetAutoSizeAttribute(autosize);
return true; return true;
} }
virtual std::string GetDOMAttributeValue(
BrowserPlugin* browser_plugin) OVERRIDE {
return browser_plugin->auto_size_attribute() ? "true" : "false";
}
private: private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingAutoSize); DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingAutoSize);
}; };
...@@ -461,9 +449,6 @@ class BrowserPluginPropertyBindingContentWindow ...@@ -461,9 +449,6 @@ class BrowserPluginPropertyBindingContentWindow
const NPVariant* variant) OVERRIDE { const NPVariant* variant) OVERRIDE {
return false; return false;
} }
virtual std::string GetDOMAttributeValue(BrowserPlugin* browser_plugin) {
return std::string();
}
private: private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingContentWindow); DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingContentWindow);
}; };
...@@ -487,10 +472,6 @@ class BrowserPluginPropertyBindingMaxHeight ...@@ -487,10 +472,6 @@ class BrowserPluginPropertyBindingMaxHeight
bindings->instance()->SetMaxHeightAttribute(max_height); bindings->instance()->SetMaxHeightAttribute(max_height);
return true; return true;
} }
virtual std::string GetDOMAttributeValue(
BrowserPlugin* browser_plugin) OVERRIDE {
return base::IntToString(browser_plugin->max_height_attribute());
}
private: private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMaxHeight); DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMaxHeight);
}; };
...@@ -514,10 +495,6 @@ class BrowserPluginPropertyBindingMaxWidth ...@@ -514,10 +495,6 @@ class BrowserPluginPropertyBindingMaxWidth
bindings->instance()->SetMaxWidthAttribute(max_width); bindings->instance()->SetMaxWidthAttribute(max_width);
return true; return true;
} }
virtual std::string GetDOMAttributeValue(
BrowserPlugin* browser_plugin) OVERRIDE {
return base::IntToString(browser_plugin->max_width_attribute());
}
private: private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMaxWidth); DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMaxWidth);
}; };
...@@ -541,10 +518,6 @@ class BrowserPluginPropertyBindingMinHeight ...@@ -541,10 +518,6 @@ class BrowserPluginPropertyBindingMinHeight
bindings->instance()->SetMinHeightAttribute(min_height); bindings->instance()->SetMinHeightAttribute(min_height);
return true; return true;
} }
virtual std::string GetDOMAttributeValue(
BrowserPlugin* browser_plugin) OVERRIDE {
return base::IntToString(browser_plugin->min_height_attribute());
}
private: private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinHeight); DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinHeight);
}; };
...@@ -568,10 +541,6 @@ class BrowserPluginPropertyBindingMinWidth ...@@ -568,10 +541,6 @@ class BrowserPluginPropertyBindingMinWidth
bindings->instance()->SetMinWidthAttribute(min_width); bindings->instance()->SetMinWidthAttribute(min_width);
return true; return true;
} }
virtual std::string GetDOMAttributeValue(
BrowserPlugin* browser_plugin) OVERRIDE {
return base::IntToString(browser_plugin->min_width_attribute());
}
private: private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinWidth); DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinWidth);
}; };
...@@ -600,10 +569,6 @@ class BrowserPluginPropertyBindingPartition ...@@ -600,10 +569,6 @@ class BrowserPluginPropertyBindingPartition
} }
return true; return true;
} }
virtual std::string GetDOMAttributeValue(
BrowserPlugin* browser_plugin) OVERRIDE {
return browser_plugin->GetPartitionAttribute();
}
private: private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingPartition); DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingPartition);
}; };
...@@ -630,10 +595,6 @@ class BrowserPluginPropertyBindingSrc : public BrowserPluginPropertyBinding { ...@@ -630,10 +595,6 @@ class BrowserPluginPropertyBindingSrc : public BrowserPluginPropertyBinding {
} }
return true; return true;
} }
virtual std::string GetDOMAttributeValue(
BrowserPlugin* browser_plugin) OVERRIDE {
return browser_plugin->src_attribute();
}
private: private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingSrc); DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingSrc);
}; };
...@@ -719,13 +680,8 @@ bool BrowserPluginBindings::SetProperty(NPObject* np_obj, ...@@ -719,13 +680,8 @@ bool BrowserPluginBindings::SetProperty(NPObject* np_obj,
for (PropertyBindingList::iterator iter = property_bindings_.begin(); for (PropertyBindingList::iterator iter = property_bindings_.begin();
iter != property_bindings_.end(); iter != property_bindings_.end();
++iter) { ++iter) {
if ((*iter)->MatchesName(name)) { if ((*iter)->MatchesName(name))
if ((*iter)->SetProperty(this, np_obj, variant)) { return (*iter)->SetProperty(this, np_obj, variant);
(*iter)->UpdateDOMAttribute(this);
return true;
}
break;
}
} }
return false; return false;
} }
......
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