From 0221e3699644fd85af45957063a66aa4f3f0860a Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 15 Jan 2015 17:39:01 -0500 Subject: [PATCH] Bug 1118978 part 3. Add support for DependsOn=DeviceState. r=peterv --- dom/bindings/Codegen.py | 9 +++++++-- dom/bindings/parser/WebIDL.py | 9 +++++---- dom/bindings/test/TestBindingHeader.h | 2 ++ dom/bindings/test/TestCodeGen.webidl | 4 ++++ dom/bindings/test/TestExampleGen.webidl | 4 ++++ dom/bindings/test/TestJSImplGen.webidl | 4 ++++ 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 4bc944af1c19..3d18459ef3d9 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -8177,7 +8177,12 @@ class CGMemberJITInfo(CGThing): dependsOn = self.member.dependsOn assert affects in IDLInterfaceMember.AffectsValues assert dependsOn in IDLInterfaceMember.DependsOnValues - return affects == "Nothing" and dependsOn != "Everything" + # Things that are DependsOn=DeviceState are not movable, because we + # don't want them coalesced with each other or loop-hoisted, since + # their return value can change even if nothing is going on from our + # point of view. + return (affects == "Nothing" and + (dependsOn != "Everything" and dependsOn != "DeviceState")) def aliasSet(self): """Returns the alias set to store in the jitinfo. This may not be the @@ -8189,7 +8194,7 @@ class CGMemberJITInfo(CGThing): dependsOn = self.member.dependsOn assert dependsOn in IDLInterfaceMember.DependsOnValues - if dependsOn == "Nothing": + if dependsOn == "Nothing" or dependsOn == "DeviceState": assert self.member.affects == "Nothing" return "AliasNone" diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py index ae30938ecb91..9d5452b689f1 100644 --- a/dom/bindings/parser/WebIDL.py +++ b/dom/bindings/parser/WebIDL.py @@ -3044,7 +3044,7 @@ class IDLInterfaceMember(IDLObjectWithIdentifier): ) AffectsValues = ("Nothing", "Everything") - DependsOnValues = ("Nothing", "DOMState", "Everything") + DependsOnValues = ("Nothing", "DOMState", "DeviceState", "Everything") def __init__(self, location, identifier, tag): IDLObjectWithIdentifier.__init__(self, location, None, identifier) @@ -3425,9 +3425,10 @@ class IDLAttribute(IDLInterfaceMember): if not attr.hasValue(): raise WebIDLError("[DependsOn] takes an identifier", [attr.location]) - if attr.value() == "Nothing" and not self.readonly: - raise WebIDLError("[DependsOn=Nothing] only allowed on " - "readonly attributes", + if (attr.value() != "Everything" and attr.value() != "DOMState" and + not self.readonly): + raise WebIDLError("[DependsOn=%s] only allowed on " + "readonly attributes" % attr.value(), [attr.location, self.location]) self._setDependsOn(attr.value()) elif (identifier == "Pref" or diff --git a/dom/bindings/test/TestBindingHeader.h b/dom/bindings/test/TestBindingHeader.h index a5843b597a69..2c9130f2b3ae 100644 --- a/dom/bindings/test/TestBindingHeader.h +++ b/dom/bindings/test/TestBindingHeader.h @@ -187,9 +187,11 @@ public: int8_t DomDependentByte(); int8_t SetDomDependentByte(int8_t); int8_t ConstantByte(); + int8_t DeviceStateDependentByte(); int8_t ReturnByteSideEffectFree(); int8_t ReturnDOMDependentByte(); int8_t ReturnConstantByte(); + int8_t ReturnDeviceStateDependentByte(); void UnsafePrerenderMethod(); int32_t UnsafePrerenderWritable(); diff --git a/dom/bindings/test/TestCodeGen.webidl b/dom/bindings/test/TestCodeGen.webidl index 19862e837a8b..66a49c92da21 100644 --- a/dom/bindings/test/TestCodeGen.webidl +++ b/dom/bindings/test/TestCodeGen.webidl @@ -163,12 +163,16 @@ interface TestInterface { attribute byte domDependentByte; [Affects=Nothing, DependsOn=Nothing] readonly attribute byte constantByte; + [DependsOn=DeviceState, Affects=Nothing] + readonly attribute byte deviceStateDependentByte; [Affects=Nothing] byte returnByteSideEffectFree(); [Affects=Nothing, DependsOn=DOMState] byte returnDOMDependentByte(); [Affects=Nothing, DependsOn=Nothing] byte returnConstantByte(); + [DependsOn=DeviceState, Affects=Nothing] + byte returnDeviceStateDependentByte(); [UnsafeInPrerendering] void unsafePrerenderMethod(); diff --git a/dom/bindings/test/TestExampleGen.webidl b/dom/bindings/test/TestExampleGen.webidl index 6db9d69dab85..d37444fac311 100644 --- a/dom/bindings/test/TestExampleGen.webidl +++ b/dom/bindings/test/TestExampleGen.webidl @@ -42,12 +42,16 @@ interface TestExampleInterface { attribute byte domDependentByte; [Affects=Nothing, DependsOn=Nothing] readonly attribute byte constantByte; + [DependsOn=DeviceState, Affects=Nothing] + readonly attribute byte deviceStateDependentByte; [Affects=Nothing] byte returnByteSideEffectFree(); [Affects=Nothing, DependsOn=DOMState] byte returnDOMDependentByte(); [Affects=Nothing, DependsOn=Nothing] byte returnConstantByte(); + [DependsOn=DeviceState, Affects=Nothing] + byte returnDeviceStateDependentByte(); readonly attribute short readonlyShort; attribute short writableShort; diff --git a/dom/bindings/test/TestJSImplGen.webidl b/dom/bindings/test/TestJSImplGen.webidl index ead29c5a6aac..0a499618e7ec 100644 --- a/dom/bindings/test/TestJSImplGen.webidl +++ b/dom/bindings/test/TestJSImplGen.webidl @@ -51,12 +51,16 @@ interface TestJSImplInterface { attribute byte domDependentByte; [Affects=Nothing, DependsOn=Nothing] readonly attribute byte constantByte; + [DependsOn=DeviceState, Affects=Nothing] + readonly attribute byte deviceStateDependentByte; [Affects=Nothing] byte returnByteSideEffectFree(); [Affects=Nothing, DependsOn=DOMState] byte returnDOMDependentByte(); [Affects=Nothing, DependsOn=Nothing] byte returnConstantByte(); + [DependsOn=DeviceState, Affects=Nothing] + byte returnDeviceStateDependentByte(); readonly attribute short readonlyShort; attribute short writableShort;