Skip to content

Commit

Permalink
Support stringifier attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
saschanaz committed Oct 29, 2019
1 parent 97c01fc commit 691af0e
Show file tree
Hide file tree
Showing 14 changed files with 11 additions and 73 deletions.
8 changes: 3 additions & 5 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -3667,6 +3667,8 @@ def definition_body(self):

@staticmethod
def makeNativeName(descriptor, method):
if method.underlyingAttr:
return CGSpecializedGetter.makeNativeName(descriptor, method.underlyingAttr)
name = method.identifier.name
nativeName = descriptor.binaryNameFor(name)
if nativeName == name:
Expand Down Expand Up @@ -5762,7 +5764,7 @@ def members():
for m in descriptor.interface.members:
if (m.isMethod() and not m.isStatic() and
not m.isMaplikeOrSetlikeOrIterableMethod() and
(not m.isIdentifierLess() or m.isStringifier()) and
(not m.isIdentifierLess() or (m.isStringifier() and not m.underlyingAttr)) and
not m.isDefaultToJSON()):
name = CGSpecializedMethod.makeNativeName(descriptor, m)
infallible = 'infallible' in descriptor.getExtendedAttributes(m)
Expand Down Expand Up @@ -6172,10 +6174,6 @@ def reexportedName(name):
cgThings.append(CGSpecializedMethod(descriptor, m))
cgThings.append(CGMemberJITInfo(descriptor, m))
elif m.isAttr():
if m.stringifier:
raise TypeError("Stringifier attributes not supported yet. "
"See https://github.com/servo/servo/issues/7590\n"
"%s" % m.location)
if m.getExtendedAttribute("Unscopable"):
assert not m.isStatic()
unscopableNames.append(m.identifier.name)
Expand Down
5 changes: 0 additions & 5 deletions components/script/dom/domtokenlist.rs
Expand Up @@ -177,11 +177,6 @@ impl DOMTokenListMethods for DOMTokenList {
Ok(())
}

// https://dom.spec.whatwg.org/#concept-dtl-serialize
fn Stringifier(&self) -> DOMString {
self.element.get_string_attribute(&self.local_name)
}

// check-tidy: no specs after this line
fn IndexedGetter(&self, index: u32) -> Option<DOMString> {
self.Item(index)
Expand Down
5 changes: 0 additions & 5 deletions components/script/dom/htmlanchorelement.rs
Expand Up @@ -526,11 +526,6 @@ impl HTMLAnchorElementMethods for HTMLAnchorElement {
// Step 5.
self.update_href(url);
}

// https://html.spec.whatwg.org/multipage/#dom-hyperlink-href
fn Stringifier(&self) -> DOMString {
DOMString::from(self.Href().0)
}
}

impl Activatable for HTMLAnchorElement {
Expand Down
7 changes: 1 addition & 6 deletions components/script/dom/location.rs
Expand Up @@ -9,7 +9,7 @@ use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::bindings::str::{DOMString, USVString};
use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::urlhelper::UrlHelper;
use crate::dom::window::Window;
Expand Down Expand Up @@ -246,11 +246,6 @@ impl LocationMethods for Location {
Ok(())
}

// https://html.spec.whatwg.org/multipage/#dom-location-href
fn Stringifier(&self) -> Fallible<DOMString> {
Ok(DOMString::from(self.GetHref()?.0))
}

// https://html.spec.whatwg.org/multipage/#dom-location-search
fn GetSearch(&self) -> Fallible<USVString> {
self.check_same_origin_domain()?;
Expand Down
5 changes: 0 additions & 5 deletions components/script/dom/url.rs
Expand Up @@ -270,11 +270,6 @@ impl URLMethods for URL {
.or_init(|| URLSearchParams::new(&self.global(), Some(self)))
}

// https://url.spec.whatwg.org/#dom-url-href
fn Stringifier(&self) -> DOMString {
DOMString::from(self.Href().0)
}

// https://url.spec.whatwg.org/#dom-url-username
fn Username(&self) -> USVString {
UrlHelper::Username(&self.url.borrow())
Expand Down
3 changes: 1 addition & 2 deletions components/script/dom/webidls/DOMTokenList.webidl
Expand Up @@ -22,8 +22,7 @@ interface DOMTokenList {
void replace(DOMString token, DOMString newToken);

[CEReactions, Pure]
attribute DOMString value;
stringifier attribute DOMString value;

stringifier;
iterable<DOMString?>;
};
Expand Up @@ -4,10 +4,8 @@

// https://html.spec.whatwg.org/multipage/#htmlhyperlinkelementutils
interface mixin HTMLHyperlinkElementUtils {
// [CEReactions]
// stringifier attribute USVString href;
[CEReactions]
attribute USVString href;
stringifier attribute USVString href;
readonly attribute USVString origin;
[CEReactions]
attribute USVString protocol;
Expand All @@ -27,9 +25,4 @@ interface mixin HTMLHyperlinkElementUtils {
attribute USVString search;
[CEReactions]
attribute USVString hash;

// Adding a separate stringifier method until
// https://github.com/servo/servo/issues/7590 adds attribute stringifier
// support.
stringifier;
};
7 changes: 1 addition & 6 deletions components/script/dom/webidls/Location.webidl
Expand Up @@ -4,7 +4,7 @@

// https://html.spec.whatwg.org/multipage/#location
[Exposed=Window, Unforgeable] interface Location {
/*stringifier*/ [Throws] attribute USVString href;
[Throws] stringifier attribute USVString href;
[Throws] readonly attribute USVString origin;
[Throws] attribute USVString protocol;
[Throws] attribute USVString host;
Expand All @@ -19,9 +19,4 @@
[Throws] void reload();

//[SameObject] readonly attribute USVString[] ancestorOrigins;

// This is only doing as well as gecko right now.
// https://github.com/servo/servo/issues/7590 is on file for
// adding attribute stringifier support.
[Throws] stringifier;
};
3 changes: 1 addition & 2 deletions components/script/dom/webidls/MediaList.webidl
Expand Up @@ -3,10 +3,9 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

// https://drafts.csswg.org/cssom/#the-medialist-interface
// [LegacyArrayClass]
[Exposed=Window]
interface MediaList {
/* stringifier */ attribute [TreatNullAs=EmptyString] DOMString mediaText;
stringifier attribute [TreatNullAs=EmptyString] DOMString mediaText;
readonly attribute unsigned long length;
getter DOMString? item(unsigned long index);
void appendMedium(DOMString medium);
Expand Down
7 changes: 1 addition & 6 deletions components/script/dom/webidls/URL.webidl
Expand Up @@ -8,7 +8,7 @@
interface URL {
[Throws] constructor(USVString url, optional USVString base);
[SetterThrows]
/*stringifier*/ attribute USVString href;
stringifier attribute USVString href;
readonly attribute USVString origin;
attribute USVString protocol;
attribute USVString username;
Expand All @@ -27,9 +27,4 @@ interface URL {
static void revokeObjectURL(DOMString url);

USVString toJSON();

// This is only doing as well as gecko right now.
// https://github.com/servo/servo/issues/7590 is on file for
// adding attribute stringifier support.
stringifier;
};
7 changes: 1 addition & 6 deletions components/script/dom/webidls/WorkerLocation.webidl
Expand Up @@ -5,7 +5,7 @@
// https://html.spec.whatwg.org/multipage/#worker-locations
[Exposed=Worker]
interface WorkerLocation {
/*stringifier*/ readonly attribute USVString href;
stringifier readonly attribute USVString href;
readonly attribute USVString origin;
readonly attribute USVString protocol;
readonly attribute USVString host;
Expand All @@ -14,9 +14,4 @@ interface WorkerLocation {
readonly attribute USVString pathname;
readonly attribute USVString search;
readonly attribute USVString hash;

// This is only doing as well as gecko right now.
// https://github.com/servo/servo/issues/7590 is on file for
// adding attribute stringifier support.
stringifier;
};
7 changes: 1 addition & 6 deletions components/script/dom/workerlocation.rs
Expand Up @@ -6,7 +6,7 @@ use crate::dom::bindings::codegen::Bindings::WorkerLocationBinding;
use crate::dom::bindings::codegen::Bindings::WorkerLocationBinding::WorkerLocationMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::{DOMString, USVString};
use crate::dom::bindings::str::USVString;
use crate::dom::urlhelper::UrlHelper;
use crate::dom::workerglobalscope::WorkerGlobalScope;
use dom_struct::dom_struct;
Expand Down Expand Up @@ -87,9 +87,4 @@ impl WorkerLocationMethods for WorkerLocation {
fn Search(&self) -> USVString {
UrlHelper::Search(&self.url)
}

// https://html.spec.whatwg.org/multipage/#dom-workerlocation-href
fn Stringifier(&self) -> DOMString {
DOMString::from(self.Href().0)
}
}
8 changes: 0 additions & 8 deletions tests/wpt/metadata/css/cssom/MediaList.html.ini

This file was deleted.

3 changes: 0 additions & 3 deletions tests/wpt/metadata/css/cssom/idlharness.html.ini
Expand Up @@ -95,9 +95,6 @@
[Stringification of sheet.cssRules[2\].cssRules[0\]]
expected: FAIL

[MediaList interface: stringifier]
expected: FAIL

[CSSImportRule interface: attribute media]
expected: FAIL

Expand Down

0 comments on commit 691af0e

Please sign in to comment.