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