зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1359269 - Part 10: Make it a hard error to apply TreatNullAs on non-types; r=bzbarsky
Depends on D20060 Differential Revision: https://phabricator.services.mozilla.com/D20061 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8f2ed901bf
Коммит
e8ca5270f2
|
@ -4570,7 +4570,6 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
|||
isOptional=False,
|
||||
invalidEnumValueFatal=True,
|
||||
defaultValue=None,
|
||||
treatNullAs="Default",
|
||||
isNullOrUndefined=False,
|
||||
exceptionCode=None,
|
||||
lenientFloatCode=None,
|
||||
|
@ -4650,8 +4649,6 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
|||
|
||||
isClamp = type.clamp
|
||||
isEnforceRange = type.enforceRange
|
||||
if type.treatNullAsEmpty:
|
||||
treatNullAs = "EmptyString"
|
||||
|
||||
# If exceptionCode is not set, we'll just rethrow the exception we got.
|
||||
# Note that we can't just set failureCode to exceptionCode, because setting
|
||||
|
@ -5791,6 +5788,10 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
|||
undefinedBehavior = "eNull"
|
||||
else:
|
||||
undefinedBehavior = "eStringify"
|
||||
if type.treatNullAsEmpty:
|
||||
treatNullAs = "EmptyString"
|
||||
else:
|
||||
treatNullAs = "Default"
|
||||
nullBehavior = treatAs[treatNullAs]
|
||||
|
||||
def getConversionCode(varName):
|
||||
|
@ -6446,7 +6447,6 @@ class CGArgumentConverter(CGThing):
|
|||
not self.argument.variadic),
|
||||
invalidEnumValueFatal=self.invalidEnumValueFatal,
|
||||
defaultValue=self.argument.defaultValue,
|
||||
treatNullAs=self.argument.treatNullAs,
|
||||
lenientFloatCode=self.lenientFloatCode,
|
||||
isMember="Variadic" if self.argument.variadic else False,
|
||||
allowTreatNonCallableAsNull=self.argument.allowTreatNonCallableAsNull(),
|
||||
|
@ -8612,12 +8612,6 @@ class FakeArgument():
|
|||
self.variadic = False
|
||||
self.defaultValue = None
|
||||
self._allowTreatNonCallableAsNull = allowTreatNonCallableAsNull
|
||||
# For FakeArguments generated by maplike/setlike convenience functions,
|
||||
# we won't have an interfaceMember to pass in.
|
||||
if interfaceMember:
|
||||
self.treatNullAs = interfaceMember.treatNullAs
|
||||
else:
|
||||
self.treatNullAs = "Default"
|
||||
|
||||
self.identifier = FakeIdentifier(name)
|
||||
|
||||
|
@ -11319,7 +11313,6 @@ class CGProxySpecialOperation(CGPerSignatureCall):
|
|||
argument = arguments[1]
|
||||
info = getJSToNativeConversionInfo(
|
||||
argument.type, descriptor,
|
||||
treatNullAs=argument.treatNullAs,
|
||||
sourceDescription=("value being assigned to %s setter" %
|
||||
descriptor.interface.identifier.name))
|
||||
if argumentHandleValue is None:
|
||||
|
@ -16367,7 +16360,6 @@ class CGCallbackInterface(CGCallback):
|
|||
|
||||
class FakeMember():
|
||||
def __init__(self, name=None):
|
||||
self.treatNullAs = "Default"
|
||||
if name is not None:
|
||||
self.identifier = FakeIdentifier(name)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import runpy
|
|||
# (whether camelCase, _underscorePrefixed, etc.) and the given array of
|
||||
# extended attributes.
|
||||
def generateLine(propName, extendedAttrs):
|
||||
return " [%s] attribute DOMString %s;\n" % (", ".join(extendedAttrs),
|
||||
return " [%s] attribute [TreatNullAs=EmptyString] DOMString %s;\n" % (", ".join(extendedAttrs),
|
||||
propName)
|
||||
def generate(output, idlFilename, dataFile):
|
||||
propList = runpy.run_path(dataFile)["data"]
|
||||
|
@ -21,7 +21,7 @@ def generate(output, idlFilename, dataFile):
|
|||
continue
|
||||
# Unfortunately, even some of the getters here are fallible
|
||||
# (e.g. on nsComputedDOMStyle).
|
||||
extendedAttrs = ["CEReactions", "Throws", "TreatNullAs=EmptyString",
|
||||
extendedAttrs = ["CEReactions", "Throws",
|
||||
"SetterNeedsSubjectPrincipal=NonSystem"]
|
||||
if p.pref is not "":
|
||||
extendedAttrs.append('Pref="%s"' % p.pref)
|
||||
|
|
|
@ -420,48 +420,11 @@ class IDLObjectWithIdentifier(IDLObject):
|
|||
if parentScope:
|
||||
self.resolve(parentScope)
|
||||
|
||||
self.treatNullAs = "Default"
|
||||
|
||||
def resolve(self, parentScope):
|
||||
assert isinstance(parentScope, IDLScope)
|
||||
assert isinstance(self.identifier, IDLUnresolvedIdentifier)
|
||||
self.identifier.resolve(parentScope, self)
|
||||
|
||||
def checkForStringHandlingExtendedAttributes(self, attrs,
|
||||
isDictionaryMember=False,
|
||||
isOptional=False):
|
||||
"""
|
||||
A helper function to deal with TreatNullAs. Returns the list
|
||||
of attrs it didn't handle itself.
|
||||
"""
|
||||
assert isinstance(self, IDLArgument) or isinstance(self, IDLAttribute)
|
||||
unhandledAttrs = list()
|
||||
for attr in attrs:
|
||||
if not attr.hasValue():
|
||||
unhandledAttrs.append(attr)
|
||||
continue
|
||||
|
||||
identifier = attr.identifier()
|
||||
value = attr.value()
|
||||
if identifier == "TreatNullAs":
|
||||
if not self.type.isDOMString() or self.type.nullable():
|
||||
raise WebIDLError("[TreatNullAs] is only allowed on "
|
||||
"arguments or attributes whose type is "
|
||||
"DOMString",
|
||||
[self.location])
|
||||
if isDictionaryMember:
|
||||
raise WebIDLError("[TreatNullAs] is not allowed for "
|
||||
"dictionary members", [self.location])
|
||||
if value != 'EmptyString':
|
||||
raise WebIDLError("[TreatNullAs] must take the identifier "
|
||||
"'EmptyString', not '%s'" % value,
|
||||
[self.location])
|
||||
self.treatNullAs = value
|
||||
else:
|
||||
unhandledAttrs.append(attr)
|
||||
|
||||
return unhandledAttrs
|
||||
|
||||
|
||||
class IDLObjectWithScope(IDLObjectWithIdentifier, IDLScope):
|
||||
def __init__(self, location, parentScope, identifier):
|
||||
|
@ -3561,6 +3524,10 @@ class IDLValue(IDLObject):
|
|||
# extra normalization step.
|
||||
assert self.type.isDOMString()
|
||||
return self
|
||||
elif self.type.isDOMString() and type.treatNullAsEmpty:
|
||||
# TreatNullAsEmpty is a different type for resolution reasons,
|
||||
# however once you have a value it doesn't matter
|
||||
return self
|
||||
elif self.type.isString() and type.isByteString():
|
||||
# Allow ByteStrings to use a default value like DOMString.
|
||||
# No coercion is required as Codegen.py will handle the
|
||||
|
@ -4238,7 +4205,7 @@ class IDLAttribute(IDLInterfaceMember):
|
|||
assert not isinstance(t.name, IDLUnresolvedIdentifier)
|
||||
self.type = t
|
||||
|
||||
if self.readonly and (self.type.clamp or self.type.enforceRange):
|
||||
if self.readonly and (self.type.clamp or self.type.enforceRange or self.type.treatNullAsEmpty):
|
||||
raise WebIDLError("A readonly attribute cannot be [Clamp] or [EnforceRange]",
|
||||
[self.location])
|
||||
if self.type.isDictionary() and not self.getExtendedAttribute("Cached"):
|
||||
|
@ -4565,10 +4532,6 @@ class IDLAttribute(IDLInterfaceMember):
|
|||
self.type.resolveType(parentScope)
|
||||
IDLObjectWithIdentifier.resolve(self, parentScope)
|
||||
|
||||
def addExtendedAttributes(self, attrs):
|
||||
attrs = self.checkForStringHandlingExtendedAttributes(attrs)
|
||||
IDLInterfaceMember.addExtendedAttributes(self, attrs)
|
||||
|
||||
def hasLenientThis(self):
|
||||
return self.lenientThis
|
||||
|
||||
|
@ -4607,13 +4570,10 @@ class IDLArgument(IDLObjectWithIdentifier):
|
|||
assert not variadic or not defaultValue
|
||||
|
||||
def addExtendedAttributes(self, attrs):
|
||||
attrs = self.checkForStringHandlingExtendedAttributes(
|
||||
attrs,
|
||||
isDictionaryMember=self.dictionaryMember,
|
||||
isOptional=self.optional)
|
||||
for attribute in attrs:
|
||||
identifier = attribute.identifier()
|
||||
if self.allowTypeAttributes and (identifier == "EnforceRange" or identifier == "Clamp"):
|
||||
if self.allowTypeAttributes and (identifier == "EnforceRange" or identifier == "Clamp" or
|
||||
identifier == "TreatNullAs"):
|
||||
self.type = self.type.withExtendedAttributes([attribute])
|
||||
elif identifier == "TreatNonCallableAsNull":
|
||||
self._allowTreatNonCallableAsNull = True
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace InspectorUtils {
|
|||
sequence<StyleSheet> getAllStyleSheets(Document document, optional boolean documentOnly = false);
|
||||
sequence<CSSStyleRule> getCSSStyleRules(
|
||||
Element element,
|
||||
[TreatNullAs=EmptyString] optional DOMString pseudo = "");
|
||||
optional [TreatNullAs=EmptyString] DOMString pseudo = "");
|
||||
unsigned long getRuleLine(CSSRule rule);
|
||||
unsigned long getRuleColumn(CSSRule rule);
|
||||
unsigned long getRelativeRuleLine(CSSRule rule);
|
||||
|
@ -29,7 +29,7 @@ namespace InspectorUtils {
|
|||
Element element,
|
||||
CSSStyleRule rule,
|
||||
unsigned long selectorIndex,
|
||||
[TreatNullAs=EmptyString] optional DOMString pseudo = "");
|
||||
optional [TreatNullAs=EmptyString] DOMString pseudo = "");
|
||||
boolean isInheritedProperty(DOMString property);
|
||||
sequence<DOMString> getCSSPropertyNames(optional PropertyNamesOptions options);
|
||||
sequence<PropertyPref> getCSSPropertyPrefs();
|
||||
|
|
|
@ -277,7 +277,7 @@ interface Attr {
|
|||
};
|
||||
|
||||
interface CharacterData : Node {
|
||||
[TreatNullAs=EmptyString] attribute DOMString data;
|
||||
attribute [TreatNullAs=EmptyString] DOMString data;
|
||||
readonly attribute unsigned long length;
|
||||
DOMString substringData(unsigned long offset, unsigned long count);
|
||||
void appendData(DOMString data);
|
||||
|
|
|
@ -24,7 +24,7 @@ interface CSSStyleDeclaration {
|
|||
DOMString getPropertyValue(DOMString property);
|
||||
DOMString getPropertyPriority(DOMString property);
|
||||
[CEReactions, NeedsSubjectPrincipal=NonSystem, Throws]
|
||||
void setProperty(DOMString property, [TreatNullAs=EmptyString] DOMString value, [TreatNullAs=EmptyString] optional DOMString priority = "");
|
||||
void setProperty(DOMString property, [TreatNullAs=EmptyString] DOMString value, optional [TreatNullAs=EmptyString] DOMString priority = "");
|
||||
[CEReactions, Throws]
|
||||
DOMString removeProperty(DOMString property);
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
*/
|
||||
|
||||
interface CharacterData : Node {
|
||||
[TreatNullAs=EmptyString, Pure, SetterThrows]
|
||||
attribute DOMString data;
|
||||
[Pure, SetterThrows]
|
||||
attribute [TreatNullAs=EmptyString] DOMString data;
|
||||
[Pure]
|
||||
readonly attribute unsigned long length;
|
||||
[Throws]
|
||||
|
|
|
@ -204,10 +204,10 @@ partial interface Element {
|
|||
|
||||
// http://domparsing.spec.whatwg.org/#extensions-to-the-element-interface
|
||||
partial interface Element {
|
||||
[CEReactions, SetterNeedsSubjectPrincipal=NonSystem, Pure, SetterThrows, GetterCanOOM, TreatNullAs=EmptyString]
|
||||
attribute DOMString innerHTML;
|
||||
[CEReactions, Pure,SetterThrows,TreatNullAs=EmptyString]
|
||||
attribute DOMString outerHTML;
|
||||
[CEReactions, SetterNeedsSubjectPrincipal=NonSystem, Pure, SetterThrows, GetterCanOOM]
|
||||
attribute [TreatNullAs=EmptyString] DOMString innerHTML;
|
||||
[CEReactions, Pure, SetterThrows]
|
||||
attribute [TreatNullAs=EmptyString] DOMString outerHTML;
|
||||
[CEReactions, Throws]
|
||||
void insertAdjacentHTML(DOMString position, DOMString text);
|
||||
};
|
||||
|
|
|
@ -42,11 +42,11 @@ interface HTMLDocument : Document {
|
|||
[Throws]
|
||||
DOMString queryCommandValue(DOMString commandId);
|
||||
|
||||
[CEReactions, TreatNullAs=EmptyString] attribute DOMString fgColor;
|
||||
[CEReactions, TreatNullAs=EmptyString] attribute DOMString linkColor;
|
||||
[CEReactions, TreatNullAs=EmptyString] attribute DOMString vlinkColor;
|
||||
[CEReactions, TreatNullAs=EmptyString] attribute DOMString alinkColor;
|
||||
[CEReactions, TreatNullAs=EmptyString] attribute DOMString bgColor;
|
||||
[CEReactions] attribute [TreatNullAs=EmptyString] DOMString fgColor;
|
||||
[CEReactions] attribute [TreatNullAs=EmptyString] DOMString linkColor;
|
||||
[CEReactions] attribute [TreatNullAs=EmptyString] DOMString vlinkColor;
|
||||
[CEReactions] attribute [TreatNullAs=EmptyString] DOMString alinkColor;
|
||||
[CEReactions] attribute [TreatNullAs=EmptyString] DOMString bgColor;
|
||||
|
||||
void clear();
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
[HTMLConstructor]
|
||||
interface HTMLFontElement : HTMLElement {
|
||||
[CEReactions, TreatNullAs=EmptyString, SetterThrows] attribute DOMString color;
|
||||
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString color;
|
||||
[CEReactions, SetterThrows] attribute DOMString face;
|
||||
[CEReactions, SetterThrows] attribute DOMString size;
|
||||
};
|
||||
|
|
|
@ -29,10 +29,10 @@ interface HTMLFrameElement : HTMLElement {
|
|||
readonly attribute Document? contentDocument;
|
||||
readonly attribute WindowProxy? contentWindow;
|
||||
|
||||
[CEReactions, TreatNullAs=EmptyString, SetterThrows]
|
||||
attribute DOMString marginHeight;
|
||||
[CEReactions, TreatNullAs=EmptyString, SetterThrows]
|
||||
attribute DOMString marginWidth;
|
||||
[CEReactions, SetterThrows]
|
||||
attribute [TreatNullAs=EmptyString] DOMString marginHeight;
|
||||
[CEReactions, SetterThrows]
|
||||
attribute [TreatNullAs=EmptyString] DOMString marginWidth;
|
||||
};
|
||||
|
||||
HTMLFrameElement implements MozFrameLoaderOwner;
|
||||
|
|
|
@ -49,10 +49,10 @@ partial interface HTMLIFrameElement {
|
|||
[CEReactions, SetterThrows, Pure]
|
||||
attribute DOMString longDesc;
|
||||
|
||||
[CEReactions, TreatNullAs=EmptyString, SetterThrows, Pure]
|
||||
attribute DOMString marginHeight;
|
||||
[CEReactions, TreatNullAs=EmptyString, SetterThrows, Pure]
|
||||
attribute DOMString marginWidth;
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
attribute [TreatNullAs=EmptyString] DOMString marginHeight;
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
attribute [TreatNullAs=EmptyString] DOMString marginWidth;
|
||||
};
|
||||
|
||||
partial interface HTMLIFrameElement {
|
||||
|
|
|
@ -57,7 +57,7 @@ partial interface HTMLImageElement {
|
|||
[CEReactions, SetterThrows]
|
||||
attribute DOMString longDesc;
|
||||
|
||||
[CEReactions, TreatNullAs=EmptyString,SetterThrows] attribute DOMString border;
|
||||
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString border;
|
||||
};
|
||||
|
||||
// [Update me: not in whatwg spec yet]
|
||||
|
|
|
@ -68,8 +68,8 @@ partial interface HTMLObjectElement {
|
|||
[CEReactions, Pure, SetterThrows]
|
||||
attribute DOMString codeType;
|
||||
|
||||
[CEReactions, TreatNullAs=EmptyString, Pure, SetterThrows]
|
||||
attribute DOMString border;
|
||||
[CEReactions, Pure, SetterThrows]
|
||||
attribute [TreatNullAs=EmptyString] DOMString border;
|
||||
};
|
||||
|
||||
partial interface HTMLObjectElement {
|
||||
|
|
|
@ -48,6 +48,6 @@ partial interface HTMLTableCellElement {
|
|||
[CEReactions, SetterThrows]
|
||||
attribute DOMString vAlign;
|
||||
|
||||
[CEReactions, TreatNullAs=EmptyString, SetterThrows]
|
||||
attribute DOMString bgColor;
|
||||
[CEReactions, SetterThrows]
|
||||
attribute [TreatNullAs=EmptyString] DOMString bgColor;
|
||||
};
|
||||
|
|
|
@ -53,10 +53,10 @@ partial interface HTMLTableElement {
|
|||
[CEReactions, SetterThrows]
|
||||
attribute DOMString width;
|
||||
|
||||
[CEReactions, TreatNullAs=EmptyString, SetterThrows]
|
||||
attribute DOMString bgColor;
|
||||
[CEReactions, TreatNullAs=EmptyString, SetterThrows]
|
||||
attribute DOMString cellPadding;
|
||||
[CEReactions, TreatNullAs=EmptyString, SetterThrows]
|
||||
attribute DOMString cellSpacing;
|
||||
[CEReactions, SetterThrows]
|
||||
attribute [TreatNullAs=EmptyString] DOMString bgColor;
|
||||
[CEReactions, SetterThrows]
|
||||
attribute [TreatNullAs=EmptyString] DOMString cellPadding;
|
||||
[CEReactions, SetterThrows]
|
||||
attribute [TreatNullAs=EmptyString] DOMString cellSpacing;
|
||||
};
|
||||
|
|
|
@ -32,6 +32,6 @@ partial interface HTMLTableRowElement {
|
|||
[CEReactions, SetterThrows]
|
||||
attribute DOMString vAlign;
|
||||
|
||||
[CEReactions, TreatNullAs=EmptyString, SetterThrows]
|
||||
attribute DOMString bgColor;
|
||||
[CEReactions, SetterThrows]
|
||||
attribute [TreatNullAs=EmptyString] DOMString bgColor;
|
||||
};
|
||||
|
|
|
@ -13,8 +13,7 @@ interface MediaList {
|
|||
// Bug 824857 should remove this.
|
||||
stringifier;
|
||||
|
||||
[TreatNullAs=EmptyString]
|
||||
attribute DOMString mediaText;
|
||||
attribute [TreatNullAs=EmptyString] DOMString mediaText;
|
||||
|
||||
readonly attribute unsigned long length;
|
||||
getter DOMString? item(unsigned long index);
|
||||
|
|
|
@ -28,8 +28,8 @@ interface ShadowRoot : DocumentFragment
|
|||
HTMLCollection getElementsByTagName(DOMString localName);
|
||||
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
|
||||
HTMLCollection getElementsByClassName(DOMString classNames);
|
||||
[CEReactions, SetterThrows, TreatNullAs=EmptyString]
|
||||
attribute DOMString innerHTML;
|
||||
[CEReactions, SetterThrows]
|
||||
attribute [TreatNullAs=EmptyString] DOMString innerHTML;
|
||||
|
||||
// When JS invokes importNode or createElement, the binding code needs to
|
||||
// create a reflector, and so invoking those methods directly on the content
|
||||
|
|
|
@ -63,7 +63,7 @@ typedef OfflineResourceList ApplicationCache;
|
|||
[Replaceable, Throws, CrossOriginReadable] readonly attribute WindowProxy? parent;
|
||||
[Throws, NeedsSubjectPrincipal] readonly attribute Element? frameElement;
|
||||
//[Throws] WindowProxy? open(optional USVString url = "about:blank", optional DOMString target = "_blank", [TreatNullAs=EmptyString] optional DOMString features = "");
|
||||
[Throws] WindowProxy? open(optional DOMString url = "", optional DOMString target = "", [TreatNullAs=EmptyString] optional DOMString features = "");
|
||||
[Throws] WindowProxy? open(optional DOMString url = "", optional DOMString target = "", optional [TreatNullAs=EmptyString] DOMString features = "");
|
||||
getter object (DOMString name);
|
||||
|
||||
// the user agent
|
||||
|
|
Загрузка…
Ссылка в новой задаче