Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up the parsers into a single interface #13675

Merged
merged 9 commits into from Oct 11, 2016
Next

Introduce ServoParser

This is a common inline parent to ServoHTMLParser and ServoXMLParser.
  • Loading branch information
nox committed Oct 11, 2016
commit ea27f9d5ec580a9e743f89e92702df1d25b580ec
@@ -2748,7 +2748,8 @@ def definition_body(self):
interface.get());
""" % {"id": name, "name": str_to_const_array(name)})

if len(self.descriptor.prototypeChain) == 1:
parentName = self.descriptor.getParentName()
if not parentName:
if self.descriptor.interface.getExtendedAttribute("ExceptionClass"):
getPrototypeProto = "prototype_proto.set(JS_GetErrorPrototype(cx))"
elif self.descriptor.interface.isIteratorInterface():
@@ -2757,7 +2758,7 @@ def definition_body(self):
getPrototypeProto = "prototype_proto.set(JS_GetObjectPrototype(cx, global))"
else:
getPrototypeProto = ("%s::GetProtoObject(cx, global, prototype_proto.handle_mut())" %
toBindingNamespace(self.descriptor.getParentName()))
toBindingNamespace(parentName))

code = [CGGeneric("""\
rooted!(in(cx) let mut prototype_proto = ptr::null_mut());
@@ -387,6 +387,7 @@ pub mod serviceworkercontainer;
pub mod serviceworkerglobalscope;
pub mod serviceworkerregistration;
pub mod servohtmlparser;
pub mod servoparser;
pub mod servoxmlparser;
pub mod storage;
pub mod storageevent;
@@ -14,13 +14,14 @@ use dom::bindings::codegen::Bindings::ServoHTMLParserBinding;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, Root};
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::str::DOMString;
use dom::bindings::trace::JSTraceable;
use dom::document::Document;
use dom::globalscope::GlobalScope;
use dom::htmlimageelement::HTMLImageElement;
use dom::node::Node;
use dom::servoparser::ServoParser;
use dom::window::Window;
use encoding::all::UTF_8;
use encoding::types::{DecoderTrap, Encoding};
@@ -212,7 +213,7 @@ impl PreInvoke for ParserContext {

#[dom_struct]
pub struct ServoHTMLParser {
reflector_: Reflector,
servoparser: ServoParser,
#[ignore_heap_size_of = "Defined in html5ever"]
tokenizer: DOMRefCell<Tokenizer>,
/// Input chunks received but not yet passed to the parser.
@@ -269,7 +270,7 @@ impl ServoHTMLParser {
let tok = tokenizer::Tokenizer::new(tb, Default::default());

let parser = ServoHTMLParser {
reflector_: Reflector::new(),
servoparser: ServoParser::new_inherited(),
tokenizer: DOMRefCell::new(tok),
pending_input: DOMRefCell::new(vec!()),
document: JS::from_ref(document),
@@ -305,7 +306,7 @@ impl ServoHTMLParser {
let tok = tokenizer::Tokenizer::new(tb, tok_opts);

let parser = ServoHTMLParser {
reflector_: Reflector::new(),
servoparser: ServoParser::new_inherited(),
tokenizer: DOMRefCell::new(tok),
pending_input: DOMRefCell::new(vec!()),
document: JS::from_ref(document),
@@ -0,0 +1,18 @@
/* 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::reflector::Reflector;

#[dom_struct]
pub struct ServoParser {
reflector: Reflector,
}

impl ServoParser {
pub fn new_inherited() -> Self {
ServoParser {
reflector: Reflector::new(),
}
}
}
@@ -5,10 +5,11 @@
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::ServoXMLParserBinding;
use dom::bindings::js::{JS, Root};
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::trace::JSTraceable;
use dom::document::Document;
use dom::node::Node;
use dom::servoparser::ServoParser;
use dom::window::Window;
use js::jsapi::JSTracer;
use msg::constellation_msg::PipelineId;
@@ -31,7 +32,7 @@ pub struct Sink {
#[must_root]
#[dom_struct]
pub struct ServoXMLParser {
reflector_: Reflector,
servoparser: ServoParser,
#[ignore_heap_size_of = "Defined in xml5ever"]
tokenizer: DOMRefCell<Tokenizer>,
/// Input chunks received but not yet passed to the parser.
@@ -85,7 +86,7 @@ impl ServoXMLParser {
let tok = tokenizer::XmlTokenizer::new(tb, Default::default());

let parser = ServoXMLParser {
reflector_: Reflector::new(),
servoparser: ServoParser::new_inherited(),
tokenizer: DOMRefCell::new(tok),
pending_input: DOMRefCell::new(vec!()),
document: JS::from_ref(document),
@@ -7,5 +7,5 @@

// FIXME: find a better way to hide this from content (#3688)
[NoInterfaceObject, Exposed=(Window,Worker)]
interface ServoHTMLParser {
interface ServoHTMLParser : ServoParser {
};
@@ -0,0 +1,10 @@
/* 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/. */

// This interface is entirely internal to Servo, and should not be accessible to
// web pages.

[Exposed=(Window,Worker),
Inline]
interface ServoParser {};
@@ -6,6 +6,6 @@
// web pages.

[NoInterfaceObject, Exposed=(Window,Worker)]
interface ServoXMLParser {
interface ServoXMLParser : ServoParser {
};

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.