Fix Servo build.

This commit is contained in:
Emilio Cobos Álvarez 2018-06-18 19:32:59 +02:00
parent d9d9fed7d5
commit 083857a4b0
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
7 changed files with 56 additions and 25 deletions

View file

@ -20,6 +20,7 @@ use style::computed_values::background_attachment::single_value::T as Background
use style::computed_values::background_clip::single_value::T as BackgroundClip; use style::computed_values::background_clip::single_value::T as BackgroundClip;
use style::computed_values::background_origin::single_value::T as BackgroundOrigin; use style::computed_values::background_origin::single_value::T as BackgroundOrigin;
use style::computed_values::border_image_outset::T as BorderImageOutset; use style::computed_values::border_image_outset::T as BorderImageOutset;
use style::properties::ComputedValues;
use style::properties::style_structs::{self, Background}; use style::properties::style_structs::{self, Background};
use style::values::Either; use style::values::Either;
use style::values::computed::{Angle, GradientItem, BackgroundSize as ComputedBackgroundSize}; use style::values::computed::{Angle, GradientItem, BackgroundSize as ComputedBackgroundSize};
@ -429,7 +430,11 @@ fn convert_ellipse_size_keyword(
} }
} }
fn convert_gradient_stops(gradient_items: &[GradientItem], total_length: Au) -> Vec<GradientStop> { fn convert_gradient_stops(
style: &ComputedValues,
gradient_items: &[GradientItem],
total_length: Au,
) -> Vec<GradientStop> {
// Determine the position of each stop per CSS-IMAGES § 3.4. // Determine the position of each stop per CSS-IMAGES § 3.4.
// Only keep the color stops, discard the color interpolation hints. // Only keep the color stops, discard the color interpolation hints.
@ -497,8 +502,8 @@ fn convert_gradient_stops(gradient_items: &[GradientItem], total_length: Au) ->
.unwrap(); .unwrap();
let end_offset = position_to_offset(end_stop.position.unwrap(), total_length); let end_offset = position_to_offset(end_stop.position.unwrap(), total_length);
stop_run = Some(StopRun { stop_run = Some(StopRun {
start_offset: start_offset, start_offset,
end_offset: end_offset, end_offset,
start_index: i - 1, start_index: i - 1,
stop_count: end_index, stop_count: end_index,
}) })
@ -518,7 +523,7 @@ fn convert_gradient_stops(gradient_items: &[GradientItem], total_length: Au) ->
assert!(offset.is_finite()); assert!(offset.is_finite());
stops.push(GradientStop { stops.push(GradientStop {
offset: offset, offset: offset,
color: stop.color.to_layout(), color: style.resolve_color(stop.color).to_layout(),
}) })
} }
stops stops
@ -533,6 +538,7 @@ fn as_gradient_extend_mode(repeating: bool) -> ExtendMode {
} }
pub fn convert_linear_gradient( pub fn convert_linear_gradient(
style: &ComputedValues,
size: Size2D<Au>, size: Size2D<Au>,
stops: &[GradientItem], stops: &[GradientItem],
direction: LineDirection, direction: LineDirection,
@ -581,19 +587,20 @@ pub fn convert_linear_gradient(
// This is the length of the gradient line. // This is the length of the gradient line.
let length = Au::from_f32_px((delta.x.to_f32_px() * 2.0).hypot(delta.y.to_f32_px() * 2.0)); let length = Au::from_f32_px((delta.x.to_f32_px() * 2.0).hypot(delta.y.to_f32_px() * 2.0));
let stops = convert_gradient_stops(stops, length); let stops = convert_gradient_stops(style, stops, length);
let center = Point2D::new(size.width / 2, size.height / 2); let center = Point2D::new(size.width / 2, size.height / 2);
Gradient { Gradient {
start_point: (center - delta).to_layout(), start_point: (center - delta).to_layout(),
end_point: (center + delta).to_layout(), end_point: (center + delta).to_layout(),
stops: stops, stops,
extend_mode: as_gradient_extend_mode(repeating), extend_mode: as_gradient_extend_mode(repeating),
} }
} }
pub fn convert_radial_gradient( pub fn convert_radial_gradient(
style: &ComputedValues,
size: Size2D<Au>, size: Size2D<Au>,
stops: &[GradientItem], stops: &[GradientItem],
shape: EndingShape, shape: EndingShape,
@ -620,7 +627,7 @@ pub fn convert_radial_gradient(
}, },
}; };
let stops = convert_gradient_stops(stops, radius.width); let stops = convert_gradient_stops(style, stops, radius.width);
RadialGradient { RadialGradient {
center: center.to_layout(), center: center.to_layout(),

View file

@ -1116,6 +1116,7 @@ impl FragmentDisplayListBuilding for Fragment {
let display_item = match gradient.kind { let display_item = match gradient.kind {
GradientKind::Linear(angle_or_corner) => { GradientKind::Linear(angle_or_corner) => {
let gradient = convert_linear_gradient( let gradient = convert_linear_gradient(
style,
placement.tile_size, placement.tile_size,
&gradient.items[..], &gradient.items[..],
angle_or_corner, angle_or_corner,
@ -1130,6 +1131,7 @@ impl FragmentDisplayListBuilding for Fragment {
}, },
GradientKind::Radial(shape, center, _angle) => { GradientKind::Radial(shape, center, _angle) => {
let gradient = convert_radial_gradient( let gradient = convert_radial_gradient(
style,
placement.tile_size, placement.tile_size,
&gradient.items[..], &gradient.items[..],
shape, shape,
@ -1298,6 +1300,7 @@ impl FragmentDisplayListBuilding for Fragment {
Either::Second(Image::Gradient(ref gradient)) => Some(match gradient.kind { Either::Second(Image::Gradient(ref gradient)) => Some(match gradient.kind {
GradientKind::Linear(angle_or_corner) => BorderDetails::Gradient(GradientBorder { GradientKind::Linear(angle_or_corner) => BorderDetails::Gradient(GradientBorder {
gradient: convert_linear_gradient( gradient: convert_linear_gradient(
style,
bounds.size, bounds.size,
&gradient.items[..], &gradient.items[..],
angle_or_corner, angle_or_corner,
@ -1308,6 +1311,7 @@ impl FragmentDisplayListBuilding for Fragment {
GradientKind::Radial(shape, center, _angle) => { GradientKind::Radial(shape, center, _angle) => {
BorderDetails::RadialGradient(RadialGradientBorder { BorderDetails::RadialGradient(RadialGradientBorder {
gradient: convert_radial_gradient( gradient: convert_radial_gradient(
style,
bounds.size, bounds.size,
&gradient.items[..], &gradient.items[..],
shape, shape,

View file

@ -16,7 +16,7 @@ use dom::medialist::MediaList;
use dom::window::Window; use dom::window::Window;
use dom_struct::dom_struct; use dom_struct::dom_struct;
use servo_arc::Arc; use servo_arc::Arc;
use style::media_queries::parse_media_query_list; use style::media_queries::MediaList as StyleMediaList;
use style::parser::ParserContext; use style::parser::ParserContext;
use style::shared_lock::{Locked, ToCssWithGuard}; use style::shared_lock::{Locked, ToCssWithGuard};
use style::stylesheets::{CssRuleType, MediaRule}; use style::stylesheets::{CssRuleType, MediaRule};
@ -79,8 +79,11 @@ impl CSSMediaRule {
ParsingMode::DEFAULT, ParsingMode::DEFAULT,
quirks_mode); quirks_mode);
let new_medialist = parse_media_query_list(&context, &mut input, let new_medialist = StyleMediaList::parse(
window.css_error_reporter()); &context,
&mut input,
window.css_error_reporter(),
);
let mut guard = self.cssconditionrule.shared_lock().write(); let mut guard = self.cssconditionrule.shared_lock().write();
// Clone an Arc because we cant borrow `guard` twice at the same time. // Clone an Arc because we cant borrow `guard` twice at the same time.

View file

@ -29,7 +29,7 @@ use std::borrow::ToOwned;
use std::cell::Cell; use std::cell::Cell;
use std::default::Default; use std::default::Default;
use style::attr::AttrValue; use style::attr::AttrValue;
use style::media_queries::parse_media_query_list; use style::media_queries::MediaList;
use style::parser::ParserContext as CssParserContext; use style::parser::ParserContext as CssParserContext;
use style::str::HTML_SPACE_CHARACTERS; use style::str::HTML_SPACE_CHARACTERS;
use style::stylesheets::{CssRuleType, Stylesheet}; use style::stylesheets::{CssRuleType, Stylesheet};
@ -277,12 +277,21 @@ impl HTMLLinkElement {
let mut input = ParserInput::new(&mq_str); let mut input = ParserInput::new(&mq_str);
let mut css_parser = CssParser::new(&mut input); let mut css_parser = CssParser::new(&mut input);
let doc_url = document.url(); let doc_url = document.url();
let context = CssParserContext::new_for_cssom(&doc_url, Some(CssRuleType::Media), // FIXME(emilio): This looks somewhat fishy, since we use the context
// only to parse the media query list, CssRuleType::Media doesn't make
// much sense.
let context = CssParserContext::new_for_cssom(
&doc_url,
Some(CssRuleType::Media),
ParsingMode::DEFAULT, ParsingMode::DEFAULT,
document.quirks_mode()); document.quirks_mode(),
);
let window = document.window(); let window = document.window();
let media = parse_media_query_list(&context, &mut css_parser, let media = MediaList::parse(
window.css_error_reporter()); &context,
&mut css_parser,
window.css_error_reporter(),
);
let im_attribute = element.get_attribute(&ns!(), &local_name!("integrity")); let im_attribute = element.get_attribute(&ns!(), &local_name!("integrity"));
let integrity_val = im_attribute.r().map(|a| a.value()); let integrity_val = im_attribute.r().map(|a| a.value());

View file

@ -21,7 +21,7 @@ use html5ever::{LocalName, Prefix};
use net_traits::ReferrerPolicy; use net_traits::ReferrerPolicy;
use servo_arc::Arc; use servo_arc::Arc;
use std::cell::Cell; use std::cell::Cell;
use style::media_queries::parse_media_query_list; use style::media_queries::MediaList;
use style::parser::ParserContext as CssParserContext; use style::parser::ParserContext as CssParserContext;
use style::stylesheets::{CssRuleType, Stylesheet, Origin}; use style::stylesheets::{CssRuleType, Stylesheet, Origin};
use style_traits::ParsingMode; use style_traits::ParsingMode;
@ -91,9 +91,11 @@ impl HTMLStyleElement {
let shared_lock = node.owner_doc().style_shared_lock().clone(); let shared_lock = node.owner_doc().style_shared_lock().clone();
let mut input = ParserInput::new(&mq_str); let mut input = ParserInput::new(&mq_str);
let css_error_reporter = window.css_error_reporter(); let css_error_reporter = window.css_error_reporter();
let mq = Arc::new(shared_lock.wrap(parse_media_query_list(&context, let mq = Arc::new(shared_lock.wrap(MediaList::parse(
&context,
&mut CssParser::new(&mut input), &mut CssParser::new(&mut input),
css_error_reporter))); css_error_reporter),
));
let loader = StylesheetLoader::for_element(self.upcast()); let loader = StylesheetLoader::for_element(self.upcast());
let sheet = Stylesheet::from_str(&data, window.get_url(), let sheet = Stylesheet::from_str(&data, window.get_url(),
Origin::Author, mq, Origin::Author, mq,

View file

@ -13,8 +13,8 @@ use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window; use dom::window::Window;
use dom_struct::dom_struct; use dom_struct::dom_struct;
use servo_arc::Arc; use servo_arc::Arc;
use style::media_queries::{MediaQuery, parse_media_query_list};
use style::media_queries::MediaList as StyleMediaList; use style::media_queries::MediaList as StyleMediaList;
use style::media_queries::MediaQuery;
use style::parser::ParserContext; use style::parser::ParserContext;
use style::shared_lock::{SharedRwLock, Locked}; use style::shared_lock::{SharedRwLock, Locked};
use style::stylesheets::CssRuleType; use style::stylesheets::CssRuleType;
@ -80,8 +80,11 @@ impl MediaListMethods for MediaList {
let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media), let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media),
ParsingMode::DEFAULT, ParsingMode::DEFAULT,
quirks_mode); quirks_mode);
*media_queries = parse_media_query_list(&context, &mut parser, *media_queries = StyleMediaList::parse(
window.css_error_reporter()); &context,
&mut parser,
window.css_error_reporter(),
);
} }
// https://drafts.csswg.org/cssom/#dom-medialist-length // https://drafts.csswg.org/cssom/#dom-medialist-length

View file

@ -1020,8 +1020,11 @@ impl WindowMethods for Window {
let context = CssParserContext::new_for_cssom(&url, Some(CssRuleType::Media), let context = CssParserContext::new_for_cssom(&url, Some(CssRuleType::Media),
ParsingMode::DEFAULT, ParsingMode::DEFAULT,
quirks_mode); quirks_mode);
let media_query_list = media_queries::parse_media_query_list(&context, &mut parser, let media_query_list = media_queries::MediaList::parse(
self.css_error_reporter()); &context,
&mut parser,
self.css_error_reporter(),
);
let document = self.Document(); let document = self.Document();
let mql = MediaQueryList::new(&document, media_query_list); let mql = MediaQueryList::new(&document, media_query_list);
self.media_query_lists.push(&*mql); self.media_query_lists.push(&*mql);