Skip to content

Commit

Permalink
Auto merge of #16712 - z1mvader:atomize_ns_prefix, r=SimonSapin
Browse files Browse the repository at this point in the history
Changed all prefixes from DOMString to the atomic Prefix from html5ever

<!-- Please describe your changes on the following line: -->
I just changed the `prefix` parameters on the constructors of several HTML elements. The type now is `Option<Prefix>`. I also changed the sizes of the `sizeof.rs` unit test to match the new values.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #16700  (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because it should not affect anything else

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16712)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed May 3, 2017
2 parents 74c36cb + 62821a6 commit ed7686b
Show file tree
Hide file tree
Showing 76 changed files with 231 additions and 275 deletions.
12 changes: 4 additions & 8 deletions components/script/dom/create.rs
Expand Up @@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use dom::bindings::js::Root;
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::Element;
use dom::element::ElementCreator;
Expand Down Expand Up @@ -77,11 +76,11 @@ use dom::htmlulistelement::HTMLUListElement;
use dom::htmlunknownelement::HTMLUnknownElement;
use dom::htmlvideoelement::HTMLVideoElement;
use dom::svgsvgelement::SVGSVGElement;
use html5ever::QualName;
use html5ever::{QualName, Prefix};
use servo_config::prefs::PREFS;

fn create_svg_element(name: QualName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document)
-> Root<Element> {
assert!(name.ns == ns!(svg));
Expand All @@ -108,7 +107,7 @@ fn create_svg_element(name: QualName,
}

fn create_html_element(name: QualName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document,
creator: ElementCreator)
-> Root<Element> {
Expand Down Expand Up @@ -277,10 +276,7 @@ pub fn create_element(name: QualName,
document: &Document,
creator: ElementCreator)
-> Root<Element> {
// FIXME(ajeffrey): Convert directly from Prefix to DOMString.

let prefix = name.prefix.as_ref().map(|p| DOMString::from(&**p));

let prefix = name.prefix.clone();
match name.ns {
ns!(html) => create_html_element(name, prefix, document, creator),
ns!(svg) => create_svg_element(name, prefix, document),
Expand Down
12 changes: 6 additions & 6 deletions components/script/dom/element.rs
Expand Up @@ -123,7 +123,7 @@ pub struct Element {
local_name: LocalName,
tag_name: TagName,
namespace: Namespace,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
attrs: DOMRefCell<Vec<JS<Attr>>>,
id_attribute: DOMRefCell<Option<Atom>>,
#[ignore_heap_size_of = "Arc"]
Expand Down Expand Up @@ -202,14 +202,14 @@ impl Element {
}

pub fn new_inherited(local_name: LocalName,
namespace: Namespace, prefix: Option<DOMString>,
namespace: Namespace, prefix: Option<Prefix>,
document: &Document) -> Element {
Element::new_inherited_with_state(ElementState::empty(), local_name,
namespace, prefix, document)
}

pub fn new_inherited_with_state(state: ElementState, local_name: LocalName,
namespace: Namespace, prefix: Option<DOMString>,
namespace: Namespace, prefix: Option<Prefix>,
document: &Document)
-> Element {
Element {
Expand All @@ -230,7 +230,7 @@ impl Element {

pub fn new(local_name: LocalName,
namespace: Namespace,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> Root<Element> {
Node::reflect_node(
box Element::new_inherited(local_name, namespace, prefix, document),
Expand Down Expand Up @@ -815,7 +815,7 @@ impl Element {
&self.namespace
}

pub fn prefix(&self) -> Option<&DOMString> {
pub fn prefix(&self) -> Option<&Prefix> {
self.prefix.as_ref()
}

Expand Down Expand Up @@ -1408,7 +1408,7 @@ impl ElementMethods for Element {

// https://dom.spec.whatwg.org/#dom-element-prefix
fn GetPrefix(&self) -> Option<DOMString> {
self.prefix.clone()
self.prefix.as_ref().map(|p| DOMString::from(&**p))
}

// https://dom.spec.whatwg.org/#dom-element-tagname
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/htmlanchorelement.rs
Expand Up @@ -25,7 +25,7 @@ use dom::node::{Node, document_from_node};
use dom::urlhelper::UrlHelper;
use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use html5ever::LocalName;
use html5ever::{LocalName, Prefix};
use net_traits::ReferrerPolicy;
use num_traits::ToPrimitive;
use script_traits::MozBrowserEvent;
Expand All @@ -43,7 +43,7 @@ pub struct HTMLAnchorElement {

impl HTMLAnchorElement {
fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> HTMLAnchorElement {
HTMLAnchorElement {
htmlelement:
Expand All @@ -55,7 +55,7 @@ impl HTMLAnchorElement {

#[allow(unrooted_must_root)]
pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> Root<HTMLAnchorElement> {
Node::reflect_node(box HTMLAnchorElement::new_inherited(local_name, prefix, document),
document,
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/htmlappletelement.rs
Expand Up @@ -12,7 +12,7 @@ use dom::htmlelement::HTMLElement;
use dom::node::Node;
use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use html5ever::LocalName;
use html5ever::{LocalName, Prefix};
use style::attr::AttrValue;

#[dom_struct]
Expand All @@ -22,7 +22,7 @@ pub struct HTMLAppletElement {

impl HTMLAppletElement {
fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> HTMLAppletElement {
HTMLAppletElement {
htmlelement:
Expand All @@ -32,7 +32,7 @@ impl HTMLAppletElement {

#[allow(unrooted_must_root)]
pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> Root<HTMLAppletElement> {
Node::reflect_node(box HTMLAppletElement::new_inherited(local_name, prefix, document),
document,
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/htmlareaelement.rs
Expand Up @@ -20,7 +20,7 @@ use dom::node::{Node, document_from_node};
use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use euclid::point::Point2D;
use html5ever::LocalName;
use html5ever::{LocalName, Prefix};
use net_traits::ReferrerPolicy;
use std::default::Default;
use std::f32;
Expand Down Expand Up @@ -221,7 +221,7 @@ pub struct HTMLAreaElement {
}

impl HTMLAreaElement {
fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLAreaElement {
fn new_inherited(local_name: LocalName, prefix: Option<Prefix>, document: &Document) -> HTMLAreaElement {
HTMLAreaElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
rel_list: Default::default(),
Expand All @@ -230,7 +230,7 @@ impl HTMLAreaElement {

#[allow(unrooted_must_root)]
pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> Root<HTMLAreaElement> {
Node::reflect_node(box HTMLAreaElement::new_inherited(local_name, prefix, document),
document,
Expand Down
7 changes: 3 additions & 4 deletions components/script/dom/htmlaudioelement.rs
Expand Up @@ -4,12 +4,11 @@

use dom::bindings::codegen::Bindings::HTMLAudioElementBinding;
use dom::bindings::js::Root;
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlmediaelement::HTMLMediaElement;
use dom::node::Node;
use dom_struct::dom_struct;
use html5ever::LocalName;
use html5ever::{LocalName, Prefix};

#[dom_struct]
pub struct HTMLAudioElement {
Expand All @@ -18,7 +17,7 @@ pub struct HTMLAudioElement {

impl HTMLAudioElement {
fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> HTMLAudioElement {
HTMLAudioElement {
htmlmediaelement:
Expand All @@ -28,7 +27,7 @@ impl HTMLAudioElement {

#[allow(unrooted_must_root)]
pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> Root<HTMLAudioElement> {
Node::reflect_node(box HTMLAudioElement::new_inherited(local_name, prefix, document),
document,
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/htmlbaseelement.rs
Expand Up @@ -14,7 +14,7 @@ use dom::htmlelement::HTMLElement;
use dom::node::{Node, UnbindContext, document_from_node};
use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use html5ever::LocalName;
use html5ever::{LocalName, Prefix};
use servo_url::ServoUrl;
use style::attr::AttrValue;

Expand All @@ -24,15 +24,15 @@ pub struct HTMLBaseElement {
}

impl HTMLBaseElement {
fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLBaseElement {
fn new_inherited(local_name: LocalName, prefix: Option<Prefix>, document: &Document) -> HTMLBaseElement {
HTMLBaseElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> Root<HTMLBaseElement> {
Node::reflect_node(box HTMLBaseElement::new_inherited(local_name, prefix, document),
document,
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/htmlbodyelement.rs
Expand Up @@ -18,7 +18,7 @@ use dom::htmlelement::HTMLElement;
use dom::node::{Node, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use html5ever::LocalName;
use html5ever::{LocalName, Prefix};
use script_traits::ScriptMsg as ConstellationMsg;
use servo_url::ServoUrl;
use style::attr::AttrValue;
Expand All @@ -34,15 +34,15 @@ pub struct HTMLBodyElement {
}

impl HTMLBodyElement {
fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document)
fn new_inherited(local_name: LocalName, prefix: Option<Prefix>, document: &Document)
-> HTMLBodyElement {
HTMLBodyElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
}
}

#[allow(unrooted_must_root)]
pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document)
pub fn new(local_name: LocalName, prefix: Option<Prefix>, document: &Document)
-> Root<HTMLBodyElement> {
Node::reflect_node(box HTMLBodyElement::new_inherited(local_name, prefix, document),
document,
Expand Down
7 changes: 3 additions & 4 deletions components/script/dom/htmlbrelement.rs
Expand Up @@ -4,28 +4,27 @@

use dom::bindings::codegen::Bindings::HTMLBRElementBinding;
use dom::bindings::js::Root;
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use dom_struct::dom_struct;
use html5ever::LocalName;
use html5ever::{LocalName, Prefix};

#[dom_struct]
pub struct HTMLBRElement {
htmlelement: HTMLElement,
}

impl HTMLBRElement {
fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLBRElement {
fn new_inherited(local_name: LocalName, prefix: Option<Prefix>, document: &Document) -> HTMLBRElement {
HTMLBRElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> Root<HTMLBRElement> {
Node::reflect_node(box HTMLBRElement::new_inherited(local_name, prefix, document),
document,
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/htmlbuttonelement.rs
Expand Up @@ -24,7 +24,7 @@ use dom::validation::Validatable;
use dom::validitystate::{ValidityState, ValidationFlags};
use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use html5ever::LocalName;
use html5ever::{LocalName, Prefix};
use std::cell::Cell;
use std::default::Default;
use style::element_state::*;
Expand All @@ -47,7 +47,7 @@ pub struct HTMLButtonElement {

impl HTMLButtonElement {
fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> HTMLButtonElement {
HTMLButtonElement {
htmlelement:
Expand All @@ -60,7 +60,7 @@ impl HTMLButtonElement {

#[allow(unrooted_must_root)]
pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> Root<HTMLButtonElement> {
Node::reflect_node(box HTMLButtonElement::new_inherited(local_name, prefix, document),
document,
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/htmlcanvaselement.rs
Expand Up @@ -27,7 +27,7 @@ use dom::virtualmethods::VirtualMethods;
use dom::webglrenderingcontext::{LayoutCanvasWebGLRenderingContextHelpers, WebGLRenderingContext};
use dom_struct::dom_struct;
use euclid::size::Size2D;
use html5ever::LocalName;
use html5ever::{LocalName, Prefix};
use image::ColorType;
use image::png::PNGEncoder;
use ipc_channel::ipc::{self, IpcSender};
Expand Down Expand Up @@ -56,7 +56,7 @@ pub struct HTMLCanvasElement {

impl HTMLCanvasElement {
fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> HTMLCanvasElement {
HTMLCanvasElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
Expand All @@ -66,7 +66,7 @@ impl HTMLCanvasElement {

#[allow(unrooted_must_root)]
pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> Root<HTMLCanvasElement> {
Node::reflect_node(box HTMLCanvasElement::new_inherited(local_name, prefix, document),
document,
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/htmldataelement.rs
Expand Up @@ -10,7 +10,7 @@ use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use dom_struct::dom_struct;
use html5ever::LocalName;
use html5ever::{LocalName, Prefix};

#[dom_struct]
pub struct HTMLDataElement {
Expand All @@ -19,7 +19,7 @@ pub struct HTMLDataElement {

impl HTMLDataElement {
fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> HTMLDataElement {
HTMLDataElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
Expand All @@ -28,7 +28,7 @@ impl HTMLDataElement {

#[allow(unrooted_must_root)]
pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
prefix: Option<Prefix>,
document: &Document) -> Root<HTMLDataElement> {
Node::reflect_node(box HTMLDataElement::new_inherited(local_name, prefix, document),
document,
Expand Down

0 comments on commit ed7686b

Please sign in to comment.