servo: Merge #18657 - script: Remove HTMLAppletElement (from emilio:bye-applet); r=KiChjang
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 06 Nov 2017 10:46:44 -0600
changeset 443632 40a86fa71825a4ff615d604b10914ec27b9695cd
parent 443631 62b4fc74e72e6592f12827a53a318057fac8a59b
child 443633 449beb98e6718a47b6499baed768c4dd577d13da
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersKiChjang
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #18657 - script: Remove HTMLAppletElement (from emilio:bye-applet); r=KiChjang It was removed from the spec, there's no reason to keep it in tree. Source-Repo: https://github.com/servo/servo Source-Revision: a509ebf90ccd24ef80b27737faefa340a5af8916
servo/components/script/dom/create.rs
servo/components/script/dom/document.rs
servo/components/script/dom/htmlappletelement.rs
servo/components/script/dom/htmlcollection.rs
servo/components/script/dom/mod.rs
servo/components/script/dom/virtualmethods.rs
servo/components/script/dom/webidls/Document.webidl
servo/components/script/dom/webidls/HTMLAppletElement.webidl
servo/resources/presentational-hints.css
--- a/servo/components/script/dom/create.rs
+++ b/servo/components/script/dom/create.rs
@@ -5,17 +5,16 @@
 use dom::bindings::error::{report_pending_exception, throw_dom_exception};
 use dom::bindings::reflector::DomObject;
 use dom::bindings::root::DomRoot;
 use dom::customelementregistry::{is_valid_custom_element_name, upgrade_element};
 use dom::document::Document;
 use dom::element::{CustomElementCreationMode, CustomElementState, Element, ElementCreator};
 use dom::globalscope::GlobalScope;
 use dom::htmlanchorelement::HTMLAnchorElement;
-use dom::htmlappletelement::HTMLAppletElement;
 use dom::htmlareaelement::HTMLAreaElement;
 use dom::htmlaudioelement::HTMLAudioElement;
 use dom::htmlbaseelement::HTMLBaseElement;
 use dom::htmlbodyelement::HTMLBodyElement;
 use dom::htmlbrelement::HTMLBRElement;
 use dom::htmlbuttonelement::HTMLButtonElement;
 use dom::htmlcanvaselement::HTMLCanvasElement;
 use dom::htmldataelement::HTMLDataElement;
@@ -186,22 +185,23 @@ fn create_html_element(name: QualName,
     // Step 7.3
     if is_valid_custom_element_name(&*name.local) || is.is_some() {
         result.set_custom_element_state(CustomElementState::Undefined);
     }
 
     result
 }
 
-pub fn create_native_html_element(name: QualName,
-                                  prefix: Option<Prefix>,
-                                  document: &Document,
-                                  creator: ElementCreator)
-                                  -> DomRoot<Element> {
-    assert!(name.ns == ns!(html));
+pub fn create_native_html_element(
+    name: QualName,
+    prefix: Option<Prefix>,
+    document: &Document,
+    creator: ElementCreator,
+) -> DomRoot<Element> {
+    assert_eq!(name.ns, ns!(html));
 
     macro_rules! make(
         ($ctor:ident) => ({
             let obj = $ctor::new(name.local, prefix, document);
             DomRoot::upcast(obj)
         });
         ($ctor:ident, $($arg:expr),+) => ({
             let obj = $ctor::new(name.local, prefix, document, $($arg),+);
@@ -212,17 +212,16 @@ pub fn create_native_html_element(name: 
     // This is a big match, and the IDs for inline-interned atoms are not very structured.
     // Perhaps we should build a perfect hash from those IDs instead.
     // https://html.spec.whatwg.org/multipage/#elements-in-the-dom
     match name.local {
         local_name!("a")          => make!(HTMLAnchorElement),
         local_name!("abbr")       => make!(HTMLElement),
         local_name!("acronym")    => make!(HTMLElement),
         local_name!("address")    => make!(HTMLElement),
-        local_name!("applet")     => make!(HTMLAppletElement),
         local_name!("area")       => make!(HTMLAreaElement),
         local_name!("article")    => make!(HTMLElement),
         local_name!("aside")      => make!(HTMLElement),
         local_name!("audio")      => make!(HTMLAudioElement),
         local_name!("b")          => make!(HTMLElement),
         local_name!("base")       => make!(HTMLBaseElement),
         local_name!("bdi")        => make!(HTMLElement),
         local_name!("bdo")        => make!(HTMLElement),
--- a/servo/components/script/dom/document.rs
+++ b/servo/components/script/dom/document.rs
@@ -42,17 +42,16 @@ use dom::element::CustomElementCreationM
 use dom::errorevent::ErrorEvent;
 use dom::event::{Event, EventBubbles, EventCancelable, EventDefault, EventStatus};
 use dom::eventtarget::EventTarget;
 use dom::focusevent::FocusEvent;
 use dom::forcetouchevent::ForceTouchEvent;
 use dom::globalscope::GlobalScope;
 use dom::hashchangeevent::HashChangeEvent;
 use dom::htmlanchorelement::HTMLAnchorElement;
-use dom::htmlappletelement::HTMLAppletElement;
 use dom::htmlareaelement::HTMLAreaElement;
 use dom::htmlbaseelement::HTMLBaseElement;
 use dom::htmlbodyelement::HTMLBodyElement;
 use dom::htmlcollection::{CollectionFilter, HTMLCollection};
 use dom::htmlelement::HTMLElement;
 use dom::htmlembedelement::HTMLEmbedElement;
 use dom::htmlformelement::{FormControl, FormControlElementHelpers, HTMLFormElement};
 use dom::htmlheadelement::HTMLHeadElement;
@@ -408,24 +407,16 @@ impl CollectionFilter for ScriptsFilter 
 #[derive(JSTraceable, MallocSizeOf)]
 struct AnchorsFilter;
 impl CollectionFilter for AnchorsFilter {
     fn filter(&self, elem: &Element, _root: &Node) -> bool {
         elem.is::<HTMLAnchorElement>() && elem.has_attribute(&local_name!("href"))
     }
 }
 
-#[derive(JSTraceable, MallocSizeOf)]
-struct AppletsFilter;
-impl CollectionFilter for AppletsFilter {
-    fn filter(&self, elem: &Element, _root: &Node) -> bool {
-        elem.is::<HTMLAppletElement>()
-    }
-}
-
 impl Document {
     #[inline]
     pub fn loader(&self) -> Ref<DocumentLoader> {
         self.loader.borrow()
     }
 
     #[inline]
     pub fn loader_mut(&self) -> RefMut<DocumentLoader> {
@@ -3368,20 +3359,18 @@ impl DocumentMethods for Document {
         self.anchors.or_init(|| {
             let filter = Box::new(AnchorsFilter);
             HTMLCollection::create(&self.window, self.upcast(), filter)
         })
     }
 
     // https://html.spec.whatwg.org/multipage/#dom-document-applets
     fn Applets(&self) -> DomRoot<HTMLCollection> {
-        // FIXME: This should be return OBJECT elements containing applets.
         self.applets.or_init(|| {
-            let filter = Box::new(AppletsFilter);
-            HTMLCollection::create(&self.window, self.upcast(), filter)
+            HTMLCollection::always_empty(&self.window, self.upcast())
         })
     }
 
     // https://html.spec.whatwg.org/multipage/#dom-document-location
     fn GetLocation(&self) -> Option<DomRoot<Location>> {
         if self.is_fully_active() {
             Some(self.window.Location())
         } else {
@@ -3525,27 +3514,16 @@ impl DocumentMethods for Document {
                 NodeTypeId::Element(ElementTypeId::HTMLElement(type_)) => type_,
                 _ => return false,
             };
             let elem = match node.downcast::<Element>() {
                 Some(elem) => elem,
                 None => return false,
             };
             match html_elem_type {
-                HTMLElementTypeId::HTMLAppletElement => {
-                    match elem.get_attribute(&ns!(), &local_name!("name")) {
-                        Some(ref attr) if attr.value().as_atom() == name => true,
-                        _ => {
-                            match elem.get_attribute(&ns!(), &local_name!("id")) {
-                                Some(ref attr) => attr.value().as_atom() == name,
-                                None => false,
-                            }
-                        },
-                    }
-                },
                 HTMLElementTypeId::HTMLFormElement => {
                     match elem.get_attribute(&ns!(), &local_name!("name")) {
                         Some(ref attr) => attr.value().as_atom() == name,
                         None => false,
                     }
                 },
                 HTMLElementTypeId::HTMLImageElement => {
                     match elem.get_attribute(&ns!(), &local_name!("name")) {
deleted file mode 100644
--- a/servo/components/script/dom/htmlappletelement.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-use dom::bindings::codegen::Bindings::HTMLAppletElementBinding;
-use dom::bindings::codegen::Bindings::HTMLAppletElementBinding::HTMLAppletElementMethods;
-use dom::bindings::inheritance::Castable;
-use dom::bindings::root::DomRoot;
-use dom::bindings::str::DOMString;
-use dom::document::Document;
-use dom::htmlelement::HTMLElement;
-use dom::node::Node;
-use dom::virtualmethods::VirtualMethods;
-use dom_struct::dom_struct;
-use html5ever::{LocalName, Prefix};
-use style::attr::AttrValue;
-
-#[dom_struct]
-pub struct HTMLAppletElement {
-    htmlelement: HTMLElement
-}
-
-impl HTMLAppletElement {
-    fn new_inherited(local_name: LocalName,
-                     prefix: Option<Prefix>,
-                     document: &Document) -> HTMLAppletElement {
-        HTMLAppletElement {
-            htmlelement:
-                HTMLElement::new_inherited(local_name, prefix, document)
-        }
-    }
-
-    #[allow(unrooted_must_root)]
-    pub fn new(local_name: LocalName,
-               prefix: Option<Prefix>,
-               document: &Document) -> DomRoot<HTMLAppletElement> {
-        Node::reflect_node(Box::new(HTMLAppletElement::new_inherited(local_name, prefix, document)),
-                           document,
-                           HTMLAppletElementBinding::Wrap)
-    }
-}
-
-impl HTMLAppletElementMethods for HTMLAppletElement {
-    // https://html.spec.whatwg.org/multipage/#the-applet-element:dom-applet-name
-    make_getter!(Name, "name");
-
-    // https://html.spec.whatwg.org/multipage/#the-applet-element:dom-applet-name
-    make_atomic_setter!(SetName, "name");
-}
-
-impl VirtualMethods for HTMLAppletElement {
-    fn super_type(&self) -> Option<&VirtualMethods> {
-        Some(self.upcast::<HTMLElement>() as &VirtualMethods)
-    }
-
-    fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
-        match name {
-            &local_name!("name") => AttrValue::from_atomic(value.into()),
-            _ => self.super_type().unwrap().parse_plain_attribute(name, value),
-        }
-    }
-}
--- a/servo/components/script/dom/htmlcollection.rs
+++ b/servo/components/script/dom/htmlcollection.rs
@@ -75,16 +75,29 @@ impl HTMLCollection {
             // Default values for the cache
             cached_version: Cell::new(root.inclusive_descendants_version()),
             cached_cursor_element: MutNullableDom::new(None),
             cached_cursor_index: Cell::new(OptionU32::none()),
             cached_length: Cell::new(OptionU32::none()),
         }
     }
 
+    /// Returns a collection which is always empty.
+    pub fn always_empty(window: &Window, root: &Node) -> DomRoot<Self> {
+        #[derive(JSTraceable)]
+        struct NoFilter;
+        impl CollectionFilter for NoFilter {
+            fn filter<'a>(&self, _: &'a Element, _: &'a Node) -> bool {
+                false
+            }
+        }
+
+        Self::new(window, root, Box::new(NoFilter))
+    }
+
     #[allow(unrooted_must_root)]
     pub fn new(window: &Window, root: &Node, filter: Box<CollectionFilter + 'static>) -> DomRoot<HTMLCollection> {
         reflect_dom_object(Box::new(HTMLCollection::new_inherited(root, filter)),
                            window, HTMLCollectionBinding::Wrap)
     }
 
     pub fn create(window: &Window, root: &Node,
                   filter: Box<CollectionFilter + 'static>) -> DomRoot<HTMLCollection> {
--- a/servo/components/script/dom/mod.rs
+++ b/servo/components/script/dom/mod.rs
@@ -296,17 +296,16 @@ pub mod gamepadbutton;
 pub mod gamepadbuttonlist;
 pub mod gamepadevent;
 pub mod gamepadlist;
 pub mod globalscope;
 pub mod hashchangeevent;
 pub mod headers;
 pub mod history;
 pub mod htmlanchorelement;
-pub mod htmlappletelement;
 pub mod htmlareaelement;
 pub mod htmlaudioelement;
 pub mod htmlbaseelement;
 pub mod htmlbodyelement;
 pub mod htmlbrelement;
 pub mod htmlbuttonelement;
 pub mod htmlcanvaselement;
 pub mod htmlcollection;
--- a/servo/components/script/dom/virtualmethods.rs
+++ b/servo/components/script/dom/virtualmethods.rs
@@ -9,17 +9,16 @@ use dom::bindings::inheritance::HTMLElem
 use dom::bindings::inheritance::NodeTypeId;
 use dom::bindings::inheritance::SVGElementTypeId;
 use dom::bindings::inheritance::SVGGraphicsElementTypeId;
 use dom::bindings::str::DOMString;
 use dom::document::Document;
 use dom::element::{AttributeMutation, Element};
 use dom::event::Event;
 use dom::htmlanchorelement::HTMLAnchorElement;
-use dom::htmlappletelement::HTMLAppletElement;
 use dom::htmlareaelement::HTMLAreaElement;
 use dom::htmlbaseelement::HTMLBaseElement;
 use dom::htmlbodyelement::HTMLBodyElement;
 use dom::htmlbuttonelement::HTMLButtonElement;
 use dom::htmlcanvaselement::HTMLCanvasElement;
 use dom::htmldetailselement::HTMLDetailsElement;
 use dom::htmlelement::HTMLElement;
 use dom::htmlfieldsetelement::HTMLFieldSetElement;
@@ -149,19 +148,16 @@ pub trait VirtualMethods {
 /// method call on the trait object will invoke the corresponding method on the
 /// concrete type, propagating up the parent hierarchy unless otherwise
 /// interrupted.
 pub fn vtable_for(node: &Node) -> &VirtualMethods {
     match node.type_id() {
         NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) => {
             node.downcast::<HTMLAnchorElement>().unwrap() as &VirtualMethods
         }
-        NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAppletElement)) => {
-            node.downcast::<HTMLAppletElement>().unwrap() as &VirtualMethods
-        }
         NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) => {
             node.downcast::<HTMLAreaElement>().unwrap() as &VirtualMethods
         }
         NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBaseElement)) => {
             node.downcast::<HTMLBaseElement>().unwrap() as &VirtualMethods
         }
         NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement)) => {
             node.downcast::<HTMLBodyElement>().unwrap() as &VirtualMethods
--- a/servo/components/script/dom/webidls/Document.webidl
+++ b/servo/components/script/dom/webidls/Document.webidl
@@ -166,16 +166,17 @@ partial interface Document {
   // [CEReactions, TreatNullAs=EmptyString]
   // attribute DOMString alinkColor;
 
   [CEReactions, TreatNullAs=EmptyString]
   attribute DOMString bgColor;
 
   [SameObject]
   readonly attribute HTMLCollection anchors;
+
   [SameObject]
   readonly attribute HTMLCollection applets;
 
   void clear();
   void captureEvents();
   void releaseEvents();
 
   // Tracking issue for document.all: https://github.com/servo/servo/issues/7396
deleted file mode 100644
--- a/servo/components/script/dom/webidls/HTMLAppletElement.webidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-// https://html.spec.whatwg.org/multipage/#htmlappletelement
-// Note: intentionally not [HTMLConstructor]
-interface HTMLAppletElement : HTMLElement {
-  //         attribute DOMString align;
-  //         attribute DOMString alt;
-  //         attribute DOMString archive;
-  //         attribute DOMString code;
-  //         attribute DOMString codeBase;
-  //         attribute DOMString height;
-  //         attribute unsigned long hspace;
-             attribute DOMString name;
-  //         attribute DOMString _object; // the underscore is not part of the identifier
-  //         attribute unsigned long vspace;
-  //         attribute DOMString width;
-};
--- a/servo/resources/presentational-hints.css
+++ b/servo/resources/presentational-hints.css
@@ -134,41 +134,41 @@ hr[align=left] { margin-left: 0; margin-
 hr[align=right] { margin-left: auto; margin-right: 0; }
 hr[align=center] { margin-left: auto; margin-right: auto; }
 hr[color], hr[noshade] { border-style: solid; }
 
 
 
 iframe[frameborder="0"], iframe[frameborder=no i] { border: none; }
 
-applet[align=left i], embed[align=left i], iframe[align=left i], img[type=image i][align=left i], object[align=left i] {
+embed[align=left i], iframe[align=left i], img[type=image i][align=left i], object[align=left i] {
   float: left;
 }
-applet[align=right i], embed[align=right i], iframe[align=right i], img[type=image i][align=right i], object[align=right i] {
+embed[align=right i], iframe[align=right i], img[type=image i][align=right i], object[align=right i] {
   float: right;
 }
-applet[align=top i], embed[align=top i], iframe[align=top i], img[type=image i][align=top i], object[align=top i] {
+embed[align=top i], iframe[align=top i], img[type=image i][align=top i], object[align=top i] {
   vertical-align: top;
 }
-applet[align=baseline i], embed[align=baseline i], iframe[align=baseline i], img[type=image i][align=baseline i], object[align=baseline i] {
+embed[align=baseline i], iframe[align=baseline i], img[type=image i][align=baseline i], object[align=baseline i] {
   vertical-align: baseline;
 }
-applet[align=texttop i], embed[align=texttop i], iframe[align=texttop i], img[type=image i][align=texttop i], object[align=texttop i] {
+embed[align=texttop i], iframe[align=texttop i], img[type=image i][align=texttop i], object[align=texttop i] {
   vertical-align: text-top;
 }
-applet[align=absmiddle i], embed[align=absmiddle i], iframe[align=absmiddle i], img[type=image i][align=absmiddle i], object[align=absmiddle i],
-applet[align=abscenter i], embed[align=abscenter i], iframe[align=abscenter i], img[type=image i][align=abscenter i], object[align=abscenter i] {
+embed[align=absmiddle i], iframe[align=absmiddle i], img[type=image i][align=absmiddle i], object[align=absmiddle i],
+embed[align=abscenter i], iframe[align=abscenter i], img[type=image i][align=abscenter i], object[align=abscenter i] {
   vertical-align: middle;
 }
-applet[align=bottom i], embed[align=bottom i], iframe[align=bottom i], img[type=image i][align=bottom i], object[align=bottom i] {
+embed[align=bottom i], iframe[align=bottom i], img[type=image i][align=bottom i], object[align=bottom i] {
   vertical-align: bottom;
 }
 /*
 FIXME:
-:matches(applet, embed, iframe, img, input[type=image i], object):matches([align=center i], [align=middle i]) {
+:matches(embed, iframe, img, input[type=image i], object):matches([align=center i], [align=middle i]) {
   vertical-align: "aligns the vertical middle of the element with the parent element's baseline."
 }
 */
 
 /*
 
 Presentational attributes which can not currently be expressed in CSS.
 FIXME: Deal with them with attr(foo dimension) and the like?
@@ -230,24 +230,24 @@ hr
   color
   noshade
   size
   width
 
 legend
   align
 
-applet, embed, iframe, img, input[type=image i], object
+embed, iframe, img, input[type=image i], object
   hspace
   vspace
 
 img, input[type=image i], object
   border
 
-applet, embed, iframe, img, input[type=image i], object, video
+embed, iframe, img, input[type=image i], object, video
   width
   height
 
 */
 
 /*
 
 Extra