[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75
atwilson at chromium.org
atwilson at chromium.org
Thu Oct 29 20:43:57 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit 60b8da96fab61329319fcccc674a73319655ee2f
Author: atwilson at chromium.org <atwilson at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Oct 13 21:44:38 2009 +0000
window attributes (like localStorage) that are disabled at runtime are still visible
https://bugs.webkit.org/show_bug.cgi?id=30240
Patch by Drew Wilson <atwilson at atwilson-macpro.local> on 2009-10-13
Reviewed by Dimitri Glazkov.
Adding codegen/bindings to support runtime disabling of attributes.
No new tests (only supported by chrome currently)
* bindings/scripts/CodeGeneratorV8.pm:
Refactored the guts of GenerateBatchedAttributeData into a separate GenerateSingleBatchedAttribute with a passed-in indentation level to allow generating a single BatchedAttribute struct.
Added support for the EnabledAtRuntime extended attribute, which generates a call to the appropriate XXXXEnabled() API before adding the attribute to the instance.
* bindings/v8/V8Proxy.cpp:
(WebCore::batchConfigureAttributes):
Refactored attribute setting code into a common inline routine.
* bindings/v8/V8Proxy.h:
(WebCore::configureAttribute):
Inline function which configures a single attribute given a BatchedAttribute struct.
* bindings/v8/custom/V8CustomBinding.h:
Added (DECLARE_)ACCESSOR_RUNTIME_ENABLER to allow enabling attributes at runtime.
* bindings/v8/custom/V8DOMWindowCustom.cpp:
Added code to enable window.Audio only if MediaPlayer.isAvailable() == true
* page/DOMWindow.idl:
Added [EnabledAtRuntime] extended attribute to the Audio attribute.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49510 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7839630..ea57e11 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,30 @@
+2009-10-13 Drew Wilson <atwilson at atwilson-macpro.local>
+
+ Reviewed by Dimitri Glazkov.
+
+ window attributes (like localStorage) that are disabled at runtime are still visible
+ https://bugs.webkit.org/show_bug.cgi?id=30240
+
+ Adding codegen/bindings to support runtime disabling of attributes.
+
+ No new tests (only supported by chrome currently)
+
+ * bindings/scripts/CodeGeneratorV8.pm:
+ Refactored the guts of GenerateBatchedAttributeData into a separate GenerateSingleBatchedAttribute with a passed-in indentation level to allow generating a single BatchedAttribute struct.
+ Added support for the EnabledAtRuntime extended attribute, which generates a call to the appropriate XXXXEnabled() API before adding the attribute to the instance.
+ * bindings/v8/V8Proxy.cpp:
+ (WebCore::batchConfigureAttributes):
+ Refactored attribute setting code into a common inline routine.
+ * bindings/v8/V8Proxy.h:
+ (WebCore::configureAttribute):
+ Inline function which configures a single attribute given a BatchedAttribute struct.
+ * bindings/v8/custom/V8CustomBinding.h:
+ Added (DECLARE_)ACCESSOR_RUNTIME_ENABLER to allow enabling attributes at runtime.
+ * bindings/v8/custom/V8DOMWindowCustom.cpp:
+ Added code to enable window.Audio only if MediaPlayer.isAvailable() == true
+ * page/DOMWindow.idl:
+ Added [EnabledAtRuntime] extended attribute to the Audio attribute.
+
2009-10-13 Michelangelo De Simone <micdesim at gmail.com>
Reviewed by Adam Barth.
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index eb33c65..cd7d538 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -948,126 +948,134 @@ sub GenerateBatchedAttributeData
my $attributes = shift;
foreach my $attribute (@$attributes) {
- my $attrName = $attribute->signature->name;
- my $attrExt = $attribute->signature->extendedAttributes;
-
- my $accessControl = "v8::DEFAULT";
- if ($attrExt->{"DoNotCheckDomainSecurityOnGet"}) {
- $accessControl = "v8::ALL_CAN_READ";
- } elsif ($attrExt->{"DoNotCheckDomainSecurityOnSet"}) {
- $accessControl = "v8::ALL_CAN_WRITE";
- } elsif ($attrExt->{"DoNotCheckDomainSecurity"}) {
- $accessControl = "v8::ALL_CAN_READ";
- if (!($attribute->type =~ /^readonly/) && !($attrExt->{"V8ReadOnly"})) {
- $accessControl .= "|v8::ALL_CAN_WRITE";
- }
- }
- if ($attrExt->{"V8DisallowShadowing"}) {
- $accessControl .= "|v8::PROHIBITS_OVERWRITING";
- }
- $accessControl = "static_cast<v8::AccessControl>(" . $accessControl . ")";
-
- my $customAccessor =
- $attrExt->{"Custom"} ||
- $attrExt->{"CustomSetter"} ||
- $attrExt->{"CustomGetter"} ||
- $attrExt->{"V8Custom"} ||
- $attrExt->{"V8CustomSetter"} ||
- $attrExt->{"V8CustomGetter"} ||
- "";
- if ($customAccessor eq 1) {
- # use the naming convension, interface + (capitalize) attr name
- $customAccessor = $interfaceName . $codeGenerator->WK_ucfirst($attrName);
- }
+ my $conditionalString = GenerateConditionalString($attribute->signature);
+ push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString;
+ GenerateSingleBatchedAttribute($interfaceName, $attribute, ",", "");
+ push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
+ }
+}
- my $getter;
- my $setter;
- my $propAttr = "v8::None";
- my $hasCustomSetter = 0;
+sub GenerateSingleBatchedAttribute
+{
+ my $interfaceName = shift;
+ my $attribute = shift;
+ my $delimiter = shift;
+ my $indent = shift;
+ my $attrName = $attribute->signature->name;
+ my $attrExt = $attribute->signature->extendedAttributes;
- # Check attributes.
- if ($attrExt->{"DontEnum"}) {
- $propAttr .= "|v8::DontEnum";
- }
- if ($attrExt->{"V8DisallowShadowing"}) {
- $propAttr .= "|v8::DontDelete";
+ my $accessControl = "v8::DEFAULT";
+ if ($attrExt->{"DoNotCheckDomainSecurityOnGet"}) {
+ $accessControl = "v8::ALL_CAN_READ";
+ } elsif ($attrExt->{"DoNotCheckDomainSecurityOnSet"}) {
+ $accessControl = "v8::ALL_CAN_WRITE";
+ } elsif ($attrExt->{"DoNotCheckDomainSecurity"}) {
+ $accessControl = "v8::ALL_CAN_READ";
+ if (!($attribute->type =~ /^readonly/) && !($attrExt->{"V8ReadOnly"})) {
+ $accessControl .= "|v8::ALL_CAN_WRITE";
}
+ }
+ if ($attrExt->{"V8DisallowShadowing"}) {
+ $accessControl .= "|v8::PROHIBITS_OVERWRITING";
+ }
+ $accessControl = "static_cast<v8::AccessControl>(" . $accessControl . ")";
- my $on_proto = "0 /* on instance */";
- my $data = "V8ClassIndex::INVALID_CLASS_INDEX /* no data */";
+ my $customAccessor =
+ $attrExt->{"Custom"} ||
+ $attrExt->{"CustomSetter"} ||
+ $attrExt->{"CustomGetter"} ||
+ $attrExt->{"V8Custom"} ||
+ $attrExt->{"V8CustomSetter"} ||
+ $attrExt->{"V8CustomGetter"} ||
+ "";
+ if ($customAccessor eq 1) {
+ # use the naming convension, interface + (capitalize) attr name
+ $customAccessor = $interfaceName . $codeGenerator->WK_ucfirst($attrName);
+ }
- # Constructor
- if ($attribute->signature->type =~ /Constructor$/) {
- my $constructorType = $codeGenerator->StripModule($attribute->signature->type);
- $constructorType =~ s/Constructor$//;
- my $constructorIndex = uc($constructorType);
- if ($customAccessor) {
- $getter = "V8Custom::v8${customAccessor}AccessorGetter";
- } else {
- $data = "V8ClassIndex::${constructorIndex}";
- $getter = "${interfaceName}Internal::${interfaceName}ConstructorGetter";
- }
- $setter = "0";
- $propAttr = "v8::ReadOnly";
+ my $getter;
+ my $setter;
+ my $propAttr = "v8::None";
+ my $hasCustomSetter = 0;
- } else {
- # Default Getter and Setter
- $getter = "${interfaceName}Internal::${attrName}AttrGetter";
- $setter = "${interfaceName}Internal::${attrName}AttrSetter";
-
- # Custom Setter
- if ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) {
- $hasCustomSetter = 1;
- $setter = "V8Custom::v8${customAccessor}AccessorSetter";
- }
+ # Check attributes.
+ if ($attrExt->{"DontEnum"}) {
+ $propAttr .= "|v8::DontEnum";
+ }
+ if ($attrExt->{"V8DisallowShadowing"}) {
+ $propAttr .= "|v8::DontDelete";
+ }
- # Custom Getter
- if ($attrExt->{"CustomGetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) {
- $getter = "V8Custom::v8${customAccessor}AccessorGetter";
- }
+ my $on_proto = "0 /* on instance */";
+ my $data = "V8ClassIndex::INVALID_CLASS_INDEX /* no data */";
+
+ # Constructor
+ if ($attribute->signature->type =~ /Constructor$/) {
+ my $constructorType = $codeGenerator->StripModule($attribute->signature->type);
+ $constructorType =~ s/Constructor$//;
+ my $constructorIndex = uc($constructorType);
+ if ($customAccessor) {
+ $getter = "V8Custom::v8${customAccessor}AccessorGetter";
+ } else {
+ $data = "V8ClassIndex::${constructorIndex}";
+ $getter = "${interfaceName}Internal::${interfaceName}ConstructorGetter";
}
+ $setter = "0";
+ $propAttr = "v8::ReadOnly";
- # Replaceable
- if ($attrExt->{"Replaceable"} && !$hasCustomSetter) {
- $setter = "0";
- # Handle the special case of window.top being marked as Replaceable.
- # FIXME: Investigate whether we could treat window.top as replaceable
- # and allow shadowing without it being a security hole.
- if (!($interfaceName eq "DOMWindow" and $attrName eq "top")) {
- $propAttr .= "|v8::ReadOnly";
- }
+ } else {
+ # Default Getter and Setter
+ $getter = "${interfaceName}Internal::${attrName}AttrGetter";
+ $setter = "${interfaceName}Internal::${attrName}AttrSetter";
+
+ # Custom Setter
+ if ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) {
+ $hasCustomSetter = 1;
+ $setter = "V8Custom::v8${customAccessor}AccessorSetter";
}
- # Read only attributes
- if ($attribute->type =~ /^readonly/ || $attrExt->{"V8ReadOnly"}) {
- $setter = "0";
+ # Custom Getter
+ if ($attrExt->{"CustomGetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) {
+ $getter = "V8Custom::v8${customAccessor}AccessorGetter";
}
+ }
- # An accessor can be installed on the proto
- if ($attrExt->{"v8OnProto"}) {
- $on_proto = "1 /* on proto */";
+ # Replaceable
+ if ($attrExt->{"Replaceable"} && !$hasCustomSetter) {
+ $setter = "0";
+ # Handle the special case of window.top being marked as Replaceable.
+ # FIXME: Investigate whether we could treat window.top as replaceable
+ # and allow shadowing without it being a security hole.
+ if (!($interfaceName eq "DOMWindow" and $attrName eq "top")) {
+ $propAttr .= "|v8::ReadOnly";
}
+ }
- my $commentInfo = "Attribute '$attrName' (Type: '" . $attribute->type .
- "' ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')";
-
- my $conditionalString = GenerateConditionalString($attribute->signature);
- push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString;
+ # Read only attributes
+ if ($attribute->type =~ /^readonly/ || $attrExt->{"V8ReadOnly"}) {
+ $setter = "0";
+ }
- push(@implContent, <<END);
- // $commentInfo
- { "$attrName",
- $getter,
- $setter,
- $data,
- $accessControl,
- static_cast<v8::PropertyAttribute>($propAttr),
- $on_proto },
-END
- push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
+ # An accessor can be installed on the proto
+ if ($attrExt->{"v8OnProto"}) {
+ $on_proto = "1 /* on proto */";
}
-}
+ my $commentInfo = "Attribute '$attrName' (Type: '" . $attribute->type .
+ "' ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')";
+
+ push(@implContent, $indent . " {\n");
+ push(@implContent, $indent . " \/\/ $commentInfo\n");
+ push(@implContent, $indent . " \"$attrName\",\n");
+ push(@implContent, $indent . " $getter,\n");
+ push(@implContent, $indent . " $setter,\n");
+ push(@implContent, $indent . " $data,\n");
+ push(@implContent, $indent . " $accessControl,\n");
+ push(@implContent, $indent . " static_cast<v8::PropertyAttribute>($propAttr),\n");
+ push(@implContent, $indent . " $on_proto\n");
+ push(@implContent, $indent . " }" . $delimiter . "\n");
+END
+}
sub GenerateImplementation
{
@@ -1180,20 +1188,24 @@ sub GenerateImplementation
# For the DOMWindow interface we partition the attributes into the
# ones that disallows shadowing and the rest.
- my @disallows_shadowing;
+ my @disallowsShadowing;
+ # Also separate out attributes that are enabled at runtime so we can process them specially.
+ my @enabledAtRuntime;
my @normal;
- if ($interfaceName eq "DOMWindow") {
- foreach my $attribute (@$attributes) {
- if ($attribute->signature->extendedAttributes->{"V8DisallowShadowing"}) {
- push(@disallows_shadowing, $attribute);
- } else {
- push(@normal, $attribute);
- }
+ foreach my $attribute (@$attributes) {
+ if ($interfaceName eq "DOMWindow" && $attribute->signature->extendedAttributes->{"V8DisallowShadowing"}) {
+ push(@disallowsShadowing, $attribute);
+ } elsif ($attribute->signature->extendedAttributes->{"EnabledAtRuntime"}) {
+ push(@enabledAtRuntime, $attribute);
+ } else {
+ push(@normal, $attribute);
}
- # Put the attributes that disallow shadowing on the shadow object.
- $attributes = \@normal;
+ }
+ $attributes = \@normal;
+ # Put the attributes that disallow shadowing on the shadow object.
+ if (@disallowsShadowing) {
push(@implContent, "static const BatchedAttribute shadow_attrs[] = {\n");
- GenerateBatchedAttributeData($dataNode, \@disallows_shadowing);
+ GenerateBatchedAttributeData($dataNode, \@disallowsShadowing);
push(@implContent, "};\n");
}
@@ -1275,6 +1287,21 @@ END
END
}
+ # Setup the enable-at-runtime attrs if we have them
+ foreach my $runtime_attr (@enabledAtRuntime) {
+ $enable_function = $interfaceName . $codeGenerator->WK_ucfirst($runtime_attr->signature->name);
+ my $conditionalString = GenerateConditionalString($runtime_attr->signature);
+ push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString;
+ push(@implContent, " if (V8Custom::v8${enable_function}Enabled()) {\n");
+ push(@implContent, " static const BatchedAttribute attrData =\\\n");
+ GenerateSingleBatchedAttribute($interfaceName, $runtime_attr, ";", " ");
+ push(@implContent, <<END);
+ configureAttribute(instance, proto, attrData);
+ }
+END
+ push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
+ }
+
# Define our functions with Set() or SetAccessor()
foreach my $function (@{$dataNode->functions}) {
my $attrExt = $function->signature->extendedAttributes;
diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp
index 21ec7cc..19539e2 100644
--- a/WebCore/bindings/v8/V8Proxy.cpp
+++ b/WebCore/bindings/v8/V8Proxy.cpp
@@ -72,15 +72,8 @@ const char* V8Proxy::kContextDebugDataValue = "value";
void batchConfigureAttributes(v8::Handle<v8::ObjectTemplate> instance, v8::Handle<v8::ObjectTemplate> proto, const BatchedAttribute* attributes, size_t attributeCount)
{
- for (size_t i = 0; i < attributeCount; ++i) {
- const BatchedAttribute* attribute = &attributes[i];
- (attribute->onProto ? proto : instance)->SetAccessor(v8::String::New(attribute->name),
- attribute->getter,
- attribute->setter,
- attribute->data == V8ClassIndex::INVALID_CLASS_INDEX ? v8::Handle<v8::Value>() : v8::Integer::New(V8ClassIndex::ToInt(attribute->data)),
- attribute->settings,
- attribute->attribute);
- }
+ for (size_t i = 0; i < attributeCount; ++i)
+ configureAttribute(instance, proto, attributes[i]);
}
void batchConfigureConstants(v8::Handle<v8::FunctionTemplate> functionDescriptor, v8::Handle<v8::ObjectTemplate> proto, const BatchedConstant* constants, size_t constantCount)
diff --git a/WebCore/bindings/v8/V8Proxy.h b/WebCore/bindings/v8/V8Proxy.h
index f21366d..e864ba4 100644
--- a/WebCore/bindings/v8/V8Proxy.h
+++ b/WebCore/bindings/v8/V8Proxy.h
@@ -82,6 +82,16 @@ namespace WebCore {
void batchConfigureAttributes(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::ObjectTemplate>, const BatchedAttribute*, size_t attributeCount);
+ inline void configureAttribute(v8::Handle<v8::ObjectTemplate> instance, v8::Handle<v8::ObjectTemplate> proto, const BatchedAttribute& attribute)
+ {
+ (attribute.onProto ? proto : instance)->SetAccessor(v8::String::New(attribute.name),
+ attribute.getter,
+ attribute.setter,
+ attribute.data == V8ClassIndex::INVALID_CLASS_INDEX ? v8::Handle<v8::Value>() : v8::Integer::New(V8ClassIndex::ToInt(attribute.data)),
+ attribute.settings,
+ attribute.attribute);
+ }
+
// BatchedConstant translates into calls to Set() for setting up an object's
// constants. It sets the constant on both the FunctionTemplate and the
// ObjectTemplate. PropertyAttributes is always ReadOnly.
diff --git a/WebCore/bindings/v8/custom/V8CustomBinding.h b/WebCore/bindings/v8/custom/V8CustomBinding.h
index d8cc354..840f04c 100644
--- a/WebCore/bindings/v8/custom/V8CustomBinding.h
+++ b/WebCore/bindings/v8/custom/V8CustomBinding.h
@@ -78,6 +78,8 @@ struct NPObject;
bool V8Custom::v8##NAME##IndexedSecurityCheck(v8::Local<v8::Object> host, \
uint32_t index, v8::AccessType type, v8::Local<v8::Value> data)
+#define ACCESSOR_RUNTIME_ENABLER(NAME) bool V8Custom::v8##NAME##Enabled()
+
namespace WebCore {
class DOMWindow;
@@ -232,6 +234,8 @@ namespace WebCore {
static bool v8##NAME##IndexedSecurityCheck(v8::Local<v8::Object> host, \
uint32_t index, v8::AccessType type, v8::Local<v8::Value> data)
+#define DECLARE_ACCESSOR_RUNTIME_ENABLER(NAME) static bool v8##NAME##Enabled()
+
DECLARE_PROPERTY_ACCESSOR(CanvasRenderingContext2DStrokeStyle);
DECLARE_PROPERTY_ACCESSOR(CanvasRenderingContext2DFillStyle);
DECLARE_PROPERTY_ACCESSOR(DOMWindowEvent);
@@ -241,6 +245,7 @@ namespace WebCore {
#if ENABLE(VIDEO)
DECLARE_PROPERTY_ACCESSOR_GETTER(DOMWindowAudio);
+ DECLARE_ACCESSOR_RUNTIME_ENABLER(DOMWindowAudio);
#endif
DECLARE_PROPERTY_ACCESSOR_GETTER(DOMWindowImage);
diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
index 0dc5a96..a579c98 100644
--- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
@@ -45,6 +45,7 @@
#include "FrameLoadRequest.h"
#include "FrameView.h"
#include "HTMLCollection.h"
+#include "MediaPlayer.h"
#include "Page.h"
#include "PlatformScreen.h"
#include "ScheduledAction.h"
@@ -235,6 +236,11 @@ ACCESSOR_GETTER(DOMWindowAudio)
return V8DOMWrapper::getConstructor(V8ClassIndex::AUDIO, window);
}
+ACCESSOR_RUNTIME_ENABLER(DOMWindowAudio)
+{
+ return MediaPlayer::isAvailable();
+}
+
#endif
ACCESSOR_GETTER(DOMWindowImage)
diff --git a/WebCore/page/DOMWindow.idl b/WebCore/page/DOMWindow.idl
index 1855a28..10f9c7d 100644
--- a/WebCore/page/DOMWindow.idl
+++ b/WebCore/page/DOMWindow.idl
@@ -523,7 +523,7 @@ module window {
attribute StorageEventConstructor StorageEvent;
#endif
- attribute [CustomGetter,Conditional=VIDEO] HTMLAudioElementConstructor Audio; // Usable with the new operator
+ attribute [CustomGetter,Conditional=VIDEO,EnabledAtRuntime] HTMLAudioElementConstructor Audio; // Usable with the new operator
attribute [Conditional=VIDEO] HTMLAudioElementConstructor HTMLAudioElement;
attribute [Conditional=VIDEO] HTMLMediaElementConstructor HTMLMediaElement;
attribute [Conditional=VIDEO] HTMLVideoElementConstructor HTMLVideoElement;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list