aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/htmlscriptelement.rs85
-rw-r--r--components/style/properties/helpers.mako.rs62
-rw-r--r--components/style/properties/helpers/animated_properties.mako.rs2
-rw-r--r--components/style/properties/longhand/background.mako.rs4
-rw-r--r--components/style/properties/longhand/effects.mako.rs94
-rwxr-xr-xetc/ci/upload_docs.sh3
-rw-r--r--python/requirements.txt1
7 files changed, 119 insertions, 132 deletions
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs
index 707e12ee59f..442f3063524 100644
--- a/components/script/dom/htmlscriptelement.rs
+++ b/components/script/dom/htmlscriptelement.rs
@@ -61,7 +61,7 @@ pub struct HTMLScriptElement {
parser_document: JS<Document>,
/// The source this script was loaded from
- load: DOMRefCell<Option<ScriptOrigin>>,
+ load: DOMRefCell<Option<Result<ScriptOrigin, NetworkError>>>,
}
impl HTMLScriptElement {
@@ -111,9 +111,28 @@ static SCRIPT_JS_MIMES: StaticStringVec = &[
];
#[derive(HeapSizeOf, JSTraceable)]
-pub enum ScriptOrigin {
- Internal(DOMString, Url),
- External(Result<(String, Url), NetworkError>),
+pub struct ScriptOrigin {
+ text: DOMString,
+ url: Url,
+ external: bool,
+}
+
+impl ScriptOrigin {
+ fn internal(text: DOMString, url: Url) -> ScriptOrigin {
+ ScriptOrigin {
+ text: text,
+ url: url,
+ external: false,
+ }
+ }
+
+ fn external(text: DOMString, url: Url) -> ScriptOrigin {
+ ScriptOrigin {
+ text: text,
+ url: url,
+ external: true,
+ }
+ }
}
/// The context required for asynchronously loading an external script source.
@@ -172,14 +191,14 @@ impl AsyncResponseListener for ScriptContext {
// Step 7.
let source_text = encoding.decode(&self.data, DecoderTrap::Replace).unwrap();
- (source_text, metadata.final_url)
+ ScriptOrigin::external(DOMString::from(source_text), metadata.final_url)
});
// Step 9.
// https://html.spec.whatwg.org/multipage/#prepare-a-script
// Step 18.6 (When the chosen algorithm asynchronously completes).
let elem = self.elem.root();
- *elem.load.borrow_mut() = Some(ScriptOrigin::External(load));
+ *elem.load.borrow_mut() = Some(load);
elem.ready_to_be_parser_executed.set(true);
let document = document_from_node(elem.r());
@@ -374,13 +393,13 @@ impl HTMLScriptElement {
// TODO: check for script nesting levels.
doc.get_script_blocking_stylesheets_count() > 0 {
doc.set_pending_parsing_blocking_script(Some(self));
- *self.load.borrow_mut() = Some(ScriptOrigin::Internal(text, base_url));
+ *self.load.borrow_mut() = Some(Ok(ScriptOrigin::internal(text, base_url)));
self.ready_to_be_parser_executed.set(true);
// Step 20.f: otherwise.
} else {
assert!(!text.is_empty());
self.ready_to_be_parser_executed.set(true);
- *self.load.borrow_mut() = Some(ScriptOrigin::Internal(text, base_url));
+ *self.load.borrow_mut() = Some(Ok(ScriptOrigin::internal(text, base_url)));
self.execute();
return NextParserState::Continue;
}
@@ -409,66 +428,58 @@ impl HTMLScriptElement {
}
let load = self.load.borrow_mut().take().unwrap();
-
- // Step 2.
- let (source, external, url) = match load {
- // Step 2.a.
- ScriptOrigin::External(Err(e)) => {
+ let script = match load {
+ // Step 2.
+ Err(e) => {
warn!("error loading script {:?}", e);
self.dispatch_error_event();
return;
}
- // Step 2.b.1.a.
- ScriptOrigin::External(Ok((text, url))) => {
- debug!("loading external script, url = {}", url);
- (DOMString::from(text), true, url)
- },
-
- // Step 2.b.1.c.
- ScriptOrigin::Internal(text, url) => {
- (text, false, url)
- }
+ Ok(script) => script,
};
- // Step 2.b.2.
+ if script.external {
+ debug!("loading external script, url = {}", script.url);
+ }
+
+ // TODO(#12446): beforescriptexecute.
if !self.dispatch_before_script_execute_event() {
return;
}
- // Step 2.b.3.
+ // Step 3.
// TODO: If the script is from an external file, then increment the
// ignore-destructive-writes counter of the script element's node
// document. Let neutralised doc be that Document.
- // Step 2.b.4.
+ // Step 4.
let document = document_from_node(self);
let document = document.r();
let old_script = document.GetCurrentScript();
- // Step 2.b.5.
+ // Step 5.a.1.
document.set_current_script(Some(self));
- // Step 2.b.6.
- // TODO: Create a script...
+ // Step 5.a.2.
let window = window_from_node(self);
rooted!(in(window.get_cx()) let mut rval = UndefinedValue());
- window.evaluate_script_on_global_with_result(&*source,
- url.as_str(),
- rval.handle_mut());
+ window.evaluate_script_on_global_with_result(&script.text,
+ script.url.as_str(),
+ rval.handle_mut());
- // Step 2.b.7.
+ // Step 6.
document.set_current_script(old_script.r());
- // Step 2.b.8.
+ // Step 7.
// TODO: Decrement the ignore-destructive-writes counter of neutralised
// doc, if it was incremented in the earlier step.
- // Step 2.b.9.
+ // TODO(#12446): afterscriptexecute.
self.dispatch_after_script_execute_event();
- // Step 2.b.10.
- if external {
+ // Step 8.
+ if script.external {
self.dispatch_load_event();
} else {
window.dom_manipulation_task_source().queue_simple_event(self.upcast(), atom!("load"), window.r());
diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs
index 2b16f527e91..374cd6a011e 100644
--- a/components/style/properties/helpers.mako.rs
+++ b/components/style/properties/helpers.mako.rs
@@ -37,12 +37,18 @@
// and handle the empty case correctly
<%doc>
To be used in cases where we have a grammar like
- "<thing> [ , <thing> ]*", but only support a single value
- in servo
+ "<thing> [ , <thing> ]*". `gecko_only` should be set
+ to True for cases where Servo takes a single value
+ and Stylo supports vector values.
+
+ Setting allow_empty to False allows for cases where the vector
+ is empty. The grammar for these is usually "none | <thing> [ , <thing> ]*".
+ We assume that the default/initial value is an empty vector for these.
+ `initial_value` need not be defined for these.
</%doc>
-<%def name="gecko_autoarray_longhand(name, **kwargs)">
+<%def name="vector_longhand(name, gecko_only=False, allow_empty=False, **kwargs)">
<%call expr="longhand(name, **kwargs)">
- % if product == "gecko":
+ % if product == "gecko" or not gecko_only:
use cssparser::ToCss;
use std::fmt;
@@ -63,10 +69,17 @@
impl ToCss for computed_value::T {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
- if !self.0.is_empty() {
- try!(self.0[0].to_css(dest));
+ let mut iter = self.0.iter();
+ if let Some(val) = iter.next() {
+ try!(val.to_css(dest));
+ } else {
+ % if allow_empty:
+ try!(dest.write_str("none"));
+ % else:
+ error!("Found empty value for property ${name}");
+ % endif
}
- for i in self.0.iter().skip(1) {
+ for i in iter {
try!(dest.write_str(", "));
try!(i.to_css(dest));
}
@@ -80,10 +93,17 @@
impl ToCss for SpecifiedValue {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
- if !self.0.is_empty() {
- try!(self.0[0].to_css(dest))
+ let mut iter = self.0.iter();
+ if let Some(val) = iter.next() {
+ try!(val.to_css(dest));
+ } else {
+ % if allow_empty:
+ try!(dest.write_str("none"));
+ % else:
+ error!("Found empty value for property ${name}");
+ % endif
}
- for i in self.0.iter().skip(1) {
+ for i in iter {
try!(dest.write_str(", "));
try!(i.to_css(dest));
}
@@ -91,12 +111,26 @@
}
}
pub fn get_initial_value() -> computed_value::T {
- computed_value::T(vec![single_value::get_initial_value()])
+ % if allow_empty:
+ computed_value::T(vec![])
+ % else:
+ computed_value::T(vec![single_value::get_initial_value()])
+ % endif
}
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
- input.parse_comma_separated(|parser| {
- single_value::parse(context, parser)
- }).map(|ok| SpecifiedValue(ok))
+ % if allow_empty:
+ if input.try(|input| input.expect_ident_matching("none")).is_ok() {
+ Ok(SpecifiedValue(Vec::new()))
+ } else {
+ input.parse_comma_separated(|parser| {
+ single_value::parse(context, parser)
+ }).map(SpecifiedValue)
+ }
+ % else:
+ input.parse_comma_separated(|parser| {
+ single_value::parse(context, parser)
+ }).map(SpecifiedValue)
+ % endif
}
impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T;
diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs
index 1043aaf24bc..aa72a0865b5 100644
--- a/components/style/properties/helpers/animated_properties.mako.rs
+++ b/components/style/properties/helpers/animated_properties.mako.rs
@@ -16,7 +16,7 @@ use properties::longhands::line_height::computed_value::T as LineHeight;
use properties::longhands::text_shadow::computed_value::T as TextShadowList;
use properties::longhands::text_shadow::computed_value::TextShadow;
use properties::longhands::box_shadow::computed_value::T as BoxShadowList;
-use properties::longhands::box_shadow::computed_value::BoxShadow;
+use properties::longhands::box_shadow::single_value::computed_value::T as BoxShadow;
use properties::longhands::transform::computed_value::ComputedMatrix;
use properties::longhands::transform::computed_value::ComputedOperation as TransformOperation;
use properties::longhands::transform::computed_value::T as TransformList;
diff --git a/components/style/properties/longhand/background.mako.rs b/components/style/properties/longhand/background.mako.rs
index f66e8d85af1..26dbf123df8 100644
--- a/components/style/properties/longhand/background.mako.rs
+++ b/components/style/properties/longhand/background.mako.rs
@@ -10,7 +10,7 @@ ${helpers.predefined_type("background-color", "CSSColor",
"::cssparser::Color::RGBA(::cssparser::RGBA { red: 0., green: 0., blue: 0., alpha: 0. }) /* transparent */",
animatable=True)}
-<%helpers:gecko_autoarray_longhand name="background-image" animatable="False">
+<%helpers:vector_longhand gecko_only="True" name="background-image" animatable="False">
use cssparser::ToCss;
use std::fmt;
use values::specified::Image;
@@ -70,7 +70,7 @@ ${helpers.predefined_type("background-color", "CSSColor",
}
}
}
-</%helpers:gecko_autoarray_longhand>
+</%helpers:vector_longhand>
<%helpers:longhand name="background-position" animatable="True">
use cssparser::ToCss;
diff --git a/components/style/properties/longhand/effects.mako.rs b/components/style/properties/longhand/effects.mako.rs
index 4fa881c93fd..fa747076da1 100644
--- a/components/style/properties/longhand/effects.mako.rs
+++ b/components/style/properties/longhand/effects.mako.rs
@@ -12,18 +12,14 @@ ${helpers.predefined_type("opacity",
"1.0",
animatable=True)}
-<%helpers:longhand name="box-shadow" animatable="True">
+<%helpers:vector_longhand name="box-shadow" allow_empty="True" animatable="True">
use cssparser::{self, ToCss};
use std::fmt;
use values::LocalToCss;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
- pub struct SpecifiedValue(Vec<SpecifiedBoxShadow>);
-
- #[derive(Debug, Clone, PartialEq)]
- #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
- pub struct SpecifiedBoxShadow {
+ pub struct SpecifiedValue {
pub offset_x: specified::Length,
pub offset_y: specified::Length,
pub blur_radius: specified::Length,
@@ -34,23 +30,6 @@ ${helpers.predefined_type("opacity",
impl ToCss for SpecifiedValue {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
- let mut iter = self.0.iter();
- if let Some(shadow) = iter.next() {
- try!(shadow.to_css(dest));
- } else {
- try!(dest.write_str("none"));
- return Ok(())
- }
- for shadow in iter {
- try!(dest.write_str(", "));
- try!(shadow.to_css(dest));
- }
- Ok(())
- }
- }
-
- impl ToCss for SpecifiedBoxShadow {
- fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
if self.inset {
try!(dest.write_str("inset "));
}
@@ -75,13 +54,9 @@ ${helpers.predefined_type("opacity",
use std::fmt;
use values::computed;
- #[derive(Clone, PartialEq, Debug)]
- #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
- pub struct T(pub Vec<BoxShadow>);
-
#[derive(Clone, PartialEq, Copy, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
- pub struct BoxShadow {
+ pub struct T {
pub offset_x: Au,
pub offset_y: Au,
pub blur_radius: Au,
@@ -93,23 +68,6 @@ ${helpers.predefined_type("opacity",
impl ToCss for computed_value::T {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
- let mut iter = self.0.iter();
- if let Some(shadow) = iter.next() {
- try!(shadow.to_css(dest));
- } else {
- try!(dest.write_str("none"));
- return Ok(())
- }
- for shadow in iter {
- try!(dest.write_str(", "));
- try!(shadow.to_css(dest));
- }
- Ok(())
- }
- }
-
- impl ToCss for computed_value::BoxShadow {
- fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
if self.inset {
try!(dest.write_str("inset "));
}
@@ -126,44 +84,26 @@ ${helpers.predefined_type("opacity",
}
}
- #[inline]
- pub fn get_initial_value() -> computed_value::T {
- computed_value::T(Vec::new())
- }
-
- pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
- if input.try(|input| input.expect_ident_matching("none")).is_ok() {
- Ok(SpecifiedValue(Vec::new()))
- } else {
- input.parse_comma_separated(parse_one_box_shadow).map(SpecifiedValue)
- }
- }
-
impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T;
#[inline]
fn to_computed_value<Cx: TContext>(&self, context: &Cx) -> computed_value::T {
- computed_value::T(self.0.iter().map(|value| compute_one_box_shadow(value, context)).collect())
- }
- }
-
- pub fn compute_one_box_shadow<Cx: TContext>(value: &SpecifiedBoxShadow, context: &Cx)
- -> computed_value::BoxShadow {
- computed_value::BoxShadow {
- offset_x: value.offset_x.to_computed_value(context),
- offset_y: value.offset_y.to_computed_value(context),
- blur_radius: value.blur_radius.to_computed_value(context),
- spread_radius: value.spread_radius.to_computed_value(context),
- color: value.color
- .as_ref()
- .map(|color| color.parsed)
- .unwrap_or(cssparser::Color::CurrentColor),
- inset: value.inset,
+ computed_value::T {
+ offset_x: self.offset_x.to_computed_value(context),
+ offset_y: self.offset_y.to_computed_value(context),
+ blur_radius: self.blur_radius.to_computed_value(context),
+ spread_radius: self.spread_radius.to_computed_value(context),
+ color: self.color
+ .as_ref()
+ .map(|color| color.parsed)
+ .unwrap_or(cssparser::Color::CurrentColor),
+ inset: self.inset,
+ }
}
}
- pub fn parse_one_box_shadow(input: &mut Parser) -> Result<SpecifiedBoxShadow, ()> {
+ pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
use app_units::Au;
let mut lengths = [specified::Length::Absolute(Au(0)); 4];
let mut lengths_parsed = false;
@@ -213,7 +153,7 @@ ${helpers.predefined_type("opacity",
return Err(())
}
- Ok(SpecifiedBoxShadow {
+ Ok(SpecifiedValue {
offset_x: lengths[0],
offset_y: lengths[1],
blur_radius: lengths[2],
@@ -222,7 +162,7 @@ ${helpers.predefined_type("opacity",
inset: inset,
})
}
-</%helpers:longhand>
+</%helpers:vector_longhand>
// FIXME: This prop should be animatable
<%helpers:longhand name="clip" animatable="False">
diff --git a/etc/ci/upload_docs.sh b/etc/ci/upload_docs.sh
index c172c4331cc..c5aed30699d 100755
--- a/etc/ci/upload_docs.sh
+++ b/etc/ci/upload_docs.sh
@@ -16,7 +16,8 @@ cp etc/doc.servo.org/* target/doc/
python components/style/properties/build.py servo html
-OUT_DIR="`pwd`/target/doc" make -f makefile.cargo -C components/script dom_docs
+OUT_DIR="`pwd`/target/doc/servo" make -f makefile.cargo -C components/script dom_docs
+rm -rf target/doc/servo/.cache
ghp-import -n target/doc
git push -qf "https://${TOKEN}@github.com/servo/doc.servo.org.git" gh-pages
diff --git a/python/requirements.txt b/python/requirements.txt
index cf6ddc136b0..cd137325d59 100644
--- a/python/requirements.txt
+++ b/python/requirements.txt
@@ -3,6 +3,7 @@ mach == 0.6.0
mozdebug == 0.1
mozinfo == 0.8
mozlog == 3.0
+setuptools == 18.5
toml == 0.9.1
# For Python linting