Commit 75868fc9 authored by fsamuel's avatar fsamuel Committed by Commit bot

<webview> + <extensionview>: Create a maybeHandleMutation call into attributes

web_view.js and extension_view.js call into maybeHandleMutation which will call
handleMutation if the mutation is not set to be ignored. This removes access to
the ignoreMutation field outside of attribute objects.

This CL also fixes a bug in extensionview src attribute where it does not access
the ignoreMutation field properly.

BUG=none
TBR=lazyboy@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#316273}
parent ae2de626
...@@ -52,7 +52,7 @@ ExtensionViewImpl.prototype.handleAttributeMutation = function( ...@@ -52,7 +52,7 @@ ExtensionViewImpl.prototype.handleAttributeMutation = function(
return; return;
// Let the changed attribute handle its own mutation; // Let the changed attribute handle its own mutation;
this.attributes[attributeName].handleMutation(oldValue, newValue); this.attributes[attributeName].maybeHandleMutation(oldValue, newValue);
}; };
ExtensionViewImpl.prototype.onElementDetached = function() { ExtensionViewImpl.prototype.onElementDetached = function() {
...@@ -63,4 +63,4 @@ ExtensionViewImpl.prototype.onElementDetached = function() { ...@@ -63,4 +63,4 @@ ExtensionViewImpl.prototype.onElementDetached = function() {
GuestViewContainer.registerElement(ExtensionViewImpl); GuestViewContainer.registerElement(ExtensionViewImpl);
// Exports. // Exports.
exports.ExtensionViewImpl = ExtensionViewImpl; exports.ExtensionViewImpl = ExtensionViewImpl;
\ No newline at end of file
...@@ -55,6 +55,16 @@ ExtensionViewAttribute.prototype.defineProperty = function() { ...@@ -55,6 +55,16 @@ ExtensionViewAttribute.prototype.defineProperty = function() {
}; };
// Called when the attribute's value changes. // Called when the attribute's value changes.
ExtensionViewAttribute.prototype.maybeHandleMutation =
function(oldValue, newValue) {
if (this.ignoreMutation) {
return;
}
this.handleMutation(oldValue, newValue);
}
// Called when a change that isn't ignored occurs to the attribute's value.
ExtensionViewAttribute.prototype.handleMutation = ExtensionViewAttribute.prototype.handleMutation =
function(oldValue, newValue) {}; function(oldValue, newValue) {};
...@@ -76,9 +86,6 @@ SrcAttribute.prototype.setValueIgnoreMutation = function(value) { ...@@ -76,9 +86,6 @@ SrcAttribute.prototype.setValueIgnoreMutation = function(value) {
} }
SrcAttribute.prototype.handleMutation = function(oldValue, newValue) { SrcAttribute.prototype.handleMutation = function(oldValue, newValue) {
if (this.attributes[attributeName].ignoreMutation)
return;
if (!newValue && oldValue) { if (!newValue && oldValue) {
this.setValueIgnoreMutation(oldValue); this.setValueIgnoreMutation(oldValue);
return; return;
......
...@@ -107,13 +107,12 @@ WebViewImpl.prototype.setupElementProperties = function() { ...@@ -107,13 +107,12 @@ WebViewImpl.prototype.setupElementProperties = function() {
// This observer monitors mutations to attributes of the <webview>. // This observer monitors mutations to attributes of the <webview>.
WebViewImpl.prototype.handleAttributeMutation = function( WebViewImpl.prototype.handleAttributeMutation = function(
attributeName, oldValue, newValue) { attributeName, oldValue, newValue) {
if (!this.attributes[attributeName] || if (!this.attributes[attributeName]) {
this.attributes[attributeName].ignoreMutation) {
return; return;
} }
// Let the changed attribute handle its own mutation; // Let the changed attribute handle its own mutation;
this.attributes[attributeName].handleMutation(oldValue, newValue); this.attributes[attributeName].maybeHandleMutation(oldValue, newValue);
}; };
WebViewImpl.prototype.onSizeChanged = function(webViewEvent) { WebViewImpl.prototype.onSizeChanged = function(webViewEvent) {
......
...@@ -53,6 +53,15 @@ WebViewAttribute.prototype.defineProperty = function() { ...@@ -53,6 +53,15 @@ WebViewAttribute.prototype.defineProperty = function() {
}; };
// Called when the attribute's value changes. // Called when the attribute's value changes.
WebViewAttribute.prototype.maybeHandleMutation = function(oldValue, newValue) {
if (this.ignoreMutation) {
return;
}
this.handleMutation(oldValue, newValue);
};
// Called when a change that isn't ignored occurs to the attribute's value.
WebViewAttribute.prototype.handleMutation = function(oldValue, newValue) {}; WebViewAttribute.prototype.handleMutation = function(oldValue, newValue) {};
// An attribute that is treated as a Boolean. // An attribute that is treated as a Boolean.
......
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