mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix Servo build.
This commit is contained in:
parent
d9d9fed7d5
commit
083857a4b0
7 changed files with 56 additions and 25 deletions
|
@ -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_origin::single_value::T as BackgroundOrigin;
|
||||
use style::computed_values::border_image_outset::T as BorderImageOutset;
|
||||
use style::properties::ComputedValues;
|
||||
use style::properties::style_structs::{self, Background};
|
||||
use style::values::Either;
|
||||
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.
|
||||
|
||||
// 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();
|
||||
let end_offset = position_to_offset(end_stop.position.unwrap(), total_length);
|
||||
stop_run = Some(StopRun {
|
||||
start_offset: start_offset,
|
||||
end_offset: end_offset,
|
||||
start_offset,
|
||||
end_offset,
|
||||
start_index: i - 1,
|
||||
stop_count: end_index,
|
||||
})
|
||||
|
@ -518,7 +523,7 @@ fn convert_gradient_stops(gradient_items: &[GradientItem], total_length: Au) ->
|
|||
assert!(offset.is_finite());
|
||||
stops.push(GradientStop {
|
||||
offset: offset,
|
||||
color: stop.color.to_layout(),
|
||||
color: style.resolve_color(stop.color).to_layout(),
|
||||
})
|
||||
}
|
||||
stops
|
||||
|
@ -533,6 +538,7 @@ fn as_gradient_extend_mode(repeating: bool) -> ExtendMode {
|
|||
}
|
||||
|
||||
pub fn convert_linear_gradient(
|
||||
style: &ComputedValues,
|
||||
size: Size2D<Au>,
|
||||
stops: &[GradientItem],
|
||||
direction: LineDirection,
|
||||
|
@ -581,19 +587,20 @@ pub fn convert_linear_gradient(
|
|||
// 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 stops = convert_gradient_stops(stops, length);
|
||||
let stops = convert_gradient_stops(style, stops, length);
|
||||
|
||||
let center = Point2D::new(size.width / 2, size.height / 2);
|
||||
|
||||
Gradient {
|
||||
start_point: (center - delta).to_layout(),
|
||||
end_point: (center + delta).to_layout(),
|
||||
stops: stops,
|
||||
stops,
|
||||
extend_mode: as_gradient_extend_mode(repeating),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn convert_radial_gradient(
|
||||
style: &ComputedValues,
|
||||
size: Size2D<Au>,
|
||||
stops: &[GradientItem],
|
||||
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 {
|
||||
center: center.to_layout(),
|
||||
|
|
|
@ -1116,6 +1116,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
let display_item = match gradient.kind {
|
||||
GradientKind::Linear(angle_or_corner) => {
|
||||
let gradient = convert_linear_gradient(
|
||||
style,
|
||||
placement.tile_size,
|
||||
&gradient.items[..],
|
||||
angle_or_corner,
|
||||
|
@ -1130,6 +1131,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
},
|
||||
GradientKind::Radial(shape, center, _angle) => {
|
||||
let gradient = convert_radial_gradient(
|
||||
style,
|
||||
placement.tile_size,
|
||||
&gradient.items[..],
|
||||
shape,
|
||||
|
@ -1298,6 +1300,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
Either::Second(Image::Gradient(ref gradient)) => Some(match gradient.kind {
|
||||
GradientKind::Linear(angle_or_corner) => BorderDetails::Gradient(GradientBorder {
|
||||
gradient: convert_linear_gradient(
|
||||
style,
|
||||
bounds.size,
|
||||
&gradient.items[..],
|
||||
angle_or_corner,
|
||||
|
@ -1308,6 +1311,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
GradientKind::Radial(shape, center, _angle) => {
|
||||
BorderDetails::RadialGradient(RadialGradientBorder {
|
||||
gradient: convert_radial_gradient(
|
||||
style,
|
||||
bounds.size,
|
||||
&gradient.items[..],
|
||||
shape,
|
||||
|
|
|
@ -16,7 +16,7 @@ use dom::medialist::MediaList;
|
|||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
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::shared_lock::{Locked, ToCssWithGuard};
|
||||
use style::stylesheets::{CssRuleType, MediaRule};
|
||||
|
@ -79,8 +79,11 @@ impl CSSMediaRule {
|
|||
ParsingMode::DEFAULT,
|
||||
quirks_mode);
|
||||
|
||||
let new_medialist = parse_media_query_list(&context, &mut input,
|
||||
window.css_error_reporter());
|
||||
let new_medialist = StyleMediaList::parse(
|
||||
&context,
|
||||
&mut input,
|
||||
window.css_error_reporter(),
|
||||
);
|
||||
let mut guard = self.cssconditionrule.shared_lock().write();
|
||||
|
||||
// Clone an Arc because we can’t borrow `guard` twice at the same time.
|
||||
|
|
|
@ -29,7 +29,7 @@ use std::borrow::ToOwned;
|
|||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
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::str::HTML_SPACE_CHARACTERS;
|
||||
use style::stylesheets::{CssRuleType, Stylesheet};
|
||||
|
@ -277,12 +277,21 @@ impl HTMLLinkElement {
|
|||
let mut input = ParserInput::new(&mq_str);
|
||||
let mut css_parser = CssParser::new(&mut input);
|
||||
let doc_url = document.url();
|
||||
let context = CssParserContext::new_for_cssom(&doc_url, Some(CssRuleType::Media),
|
||||
ParsingMode::DEFAULT,
|
||||
document.quirks_mode());
|
||||
// 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,
|
||||
document.quirks_mode(),
|
||||
);
|
||||
let window = document.window();
|
||||
let media = parse_media_query_list(&context, &mut css_parser,
|
||||
window.css_error_reporter());
|
||||
let media = MediaList::parse(
|
||||
&context,
|
||||
&mut css_parser,
|
||||
window.css_error_reporter(),
|
||||
);
|
||||
|
||||
let im_attribute = element.get_attribute(&ns!(), &local_name!("integrity"));
|
||||
let integrity_val = im_attribute.r().map(|a| a.value());
|
||||
|
|
|
@ -21,7 +21,7 @@ use html5ever::{LocalName, Prefix};
|
|||
use net_traits::ReferrerPolicy;
|
||||
use servo_arc::Arc;
|
||||
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::stylesheets::{CssRuleType, Stylesheet, Origin};
|
||||
use style_traits::ParsingMode;
|
||||
|
@ -91,9 +91,11 @@ impl HTMLStyleElement {
|
|||
let shared_lock = node.owner_doc().style_shared_lock().clone();
|
||||
let mut input = ParserInput::new(&mq_str);
|
||||
let css_error_reporter = window.css_error_reporter();
|
||||
let mq = Arc::new(shared_lock.wrap(parse_media_query_list(&context,
|
||||
&mut CssParser::new(&mut input),
|
||||
css_error_reporter)));
|
||||
let mq = Arc::new(shared_lock.wrap(MediaList::parse(
|
||||
&context,
|
||||
&mut CssParser::new(&mut input),
|
||||
css_error_reporter),
|
||||
));
|
||||
let loader = StylesheetLoader::for_element(self.upcast());
|
||||
let sheet = Stylesheet::from_str(&data, window.get_url(),
|
||||
Origin::Author, mq,
|
||||
|
|
|
@ -13,8 +13,8 @@ use dom::cssstylesheet::CSSStyleSheet;
|
|||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use servo_arc::Arc;
|
||||
use style::media_queries::{MediaQuery, parse_media_query_list};
|
||||
use style::media_queries::MediaList as StyleMediaList;
|
||||
use style::media_queries::MediaQuery;
|
||||
use style::parser::ParserContext;
|
||||
use style::shared_lock::{SharedRwLock, Locked};
|
||||
use style::stylesheets::CssRuleType;
|
||||
|
@ -80,8 +80,11 @@ impl MediaListMethods for MediaList {
|
|||
let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media),
|
||||
ParsingMode::DEFAULT,
|
||||
quirks_mode);
|
||||
*media_queries = parse_media_query_list(&context, &mut parser,
|
||||
window.css_error_reporter());
|
||||
*media_queries = StyleMediaList::parse(
|
||||
&context,
|
||||
&mut parser,
|
||||
window.css_error_reporter(),
|
||||
);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom/#dom-medialist-length
|
||||
|
|
|
@ -1020,8 +1020,11 @@ impl WindowMethods for Window {
|
|||
let context = CssParserContext::new_for_cssom(&url, Some(CssRuleType::Media),
|
||||
ParsingMode::DEFAULT,
|
||||
quirks_mode);
|
||||
let media_query_list = media_queries::parse_media_query_list(&context, &mut parser,
|
||||
self.css_error_reporter());
|
||||
let media_query_list = media_queries::MediaList::parse(
|
||||
&context,
|
||||
&mut parser,
|
||||
self.css_error_reporter(),
|
||||
);
|
||||
let document = self.Document();
|
||||
let mql = MediaQueryList::new(&document, media_query_list);
|
||||
self.media_query_lists.push(&*mql);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue