Oriol Brufau 2024-03-30 14:30:13 +01:00 committed by GitHub
parent a7ad92d9a3
commit fff9ef87e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 97 additions and 181 deletions

View file

@ -20,7 +20,6 @@ bitflags = { workspace = true }
byteorder = { workspace = true }
canvas_traits = { workspace = true }
crossbeam-channel = { workspace = true }
cssparser = { workspace = true }
euclid = { workspace = true }
font-kit = "0.11"
fnv = { workspace = true }

View file

@ -7,7 +7,6 @@ use std::mem;
use std::sync::{Arc, Mutex};
use canvas_traits::canvas::*;
use cssparser::RgbaLegacy;
use euclid::default::{Point2D, Rect, Size2D, Transform2D, Vector2D};
use euclid::{point2, vec2};
use font_kit::family_name::FamilyName;
@ -22,6 +21,7 @@ use ipc_channel::ipc::{IpcSender, IpcSharedMemory};
use log::{debug, error, warn};
use num_traits::ToPrimitive;
use servo_arc::Arc as ServoArc;
use style::color::parsing::RgbaLegacy;
use style::properties::style_structs::Font as FontStyleStruct;
use style::values::computed::font;
use style_traits::values::ToCss;

View file

@ -3,13 +3,13 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use canvas_traits::canvas::*;
use cssparser::RgbaLegacy;
use euclid::default::{Point2D, Rect, Size2D, Transform2D, Vector2D};
use euclid::Angle;
use font_kit::font::Font;
use log::warn;
use lyon_geom::Arc;
use raqote::PathOp;
use style::color::parsing::RgbaLegacy;
use crate::canvas_data;
use crate::canvas_data::{

View file

@ -26,6 +26,7 @@ use style::values::computed::font::{
FontWeight, SingleFontFamily,
};
use style::values::computed::{FontLanguageOverride, XLang};
use style::values::generics::font::LineHeight;
use webrender_api::{FontInstanceKey, FontKey, IdNamespace};
struct TestFontSource {
@ -112,6 +113,7 @@ fn style() -> FontStyleStruct {
font_stretch: FontStretch::hundred(),
hash: 0,
font_language_override: FontLanguageOverride::normal(),
line_height: LineHeight::Normal,
_x_lang: XLang::get_initial_value(),
};
style.compute_font_hash();

View file

@ -1527,7 +1527,6 @@ where
},
// XXX: Non-None image types unimplemented.
Image::ImageSet(..) |
Image::Rect(..) |
Image::Gradient(..) |
Image::PaintWorklet(..) |
Image::CrossFade(..) |

View file

@ -796,10 +796,6 @@ impl Fragment {
Image::CrossFade(..) | Image::ImageSet(..) => {
unreachable!("Shouldn't be parsed by Servo for now")
},
Image::Rect(ref rect) => {
// This is a (boxed) empty enum on non-Gecko
match **rect {}
},
}
}
}

View file

@ -771,7 +771,7 @@ impl CollapsedBorder {
CollapsedBorder {
style: BorderStyle::None,
width: Au(0),
color: Color::TRANSPARENT,
color: Color::TRANSPARENT_BLACK,
provenance: CollapsedBorderFrom::Table,
}
}

View file

@ -23,7 +23,7 @@ use style::computed_values::word_break::T as WordBreak;
use style::logical_geometry::{LogicalSize, WritingMode};
use style::properties::style_structs::Font as FontStyleStruct;
use style::properties::ComputedValues;
use style::values::generics::text::LineHeight;
use style::values::generics::font::LineHeight;
use style::values::specified::text::{TextTransform, TextTransformCase};
use unicode_bidi as bidi;
use unicode_script::Script;
@ -550,8 +550,9 @@ pub fn font_metrics_for_style(
/// Returns the line block-size needed by the given computed style and font size.
pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) -> Au {
let font_size = style.get_font().font_size.computed_size();
match style.get_inherited_text().line_height {
let font = style.get_font();
let font_size = font.font_size.computed_size();
match font.line_height {
LineHeight::Normal => metrics.line_gap,
LineHeight::Number(l) => Au::from(font_size * l.0),
LineHeight::Length(l) => Au::from(l),

View file

@ -777,8 +777,6 @@ impl<'a> BuilderForBoxFragment<'a> {
Image::PaintWorklet(_) => {
// TODO: Add support for PaintWorklet rendering.
},
// Gecko-only value, represented as a (boxed) empty enum on non-Gecko.
Image::Rect(ref rect) => match **rect {},
Image::ImageSet(..) | Image::CrossFade(..) => {
unreachable!("Shouldn't be parsed on Servo for now")
},

View file

@ -84,7 +84,7 @@ use style::logical_geometry::WritingMode;
use style::properties::ComputedValues;
use style::values::computed::Length;
use style::values::generics::box_::VerticalAlignKeyword;
use style::values::generics::text::LineHeight;
use style::values::generics::font::LineHeight;
use style::values::specified::text::{TextAlignKeyword, TextDecorationLine};
use style::values::specified::{TextAlignLast, TextJustify};
use style::Zero;
@ -1829,7 +1829,7 @@ impl InlineContainerState {
// when `line-height` is normal.
let mut ascent = font_metrics.ascent;
let mut descent = font_metrics.descent;
if style.get_inherited_text().line_height == LineHeight::Normal {
if style.get_font().line_height == LineHeight::Normal {
let half_leading_from_line_gap =
(font_metrics.line_gap - descent - ascent).scale_by(0.5);
ascent += half_leading_from_line_gap;
@ -1856,7 +1856,7 @@ impl InlineContainerState {
// zero in this case, the line may get some height when taking them into
// considering with other zero line height boxes that converge on other block axis
// locations when using the above formula.
if style.get_inherited_text().line_height != LineHeight::Normal {
if style.get_font().line_height != LineHeight::Normal {
let half_leading =
(Au::from_f32_px(line_height.px()) - (ascent + descent)).scale_by(0.5);
ascent += half_leading;
@ -2217,8 +2217,9 @@ fn place_pending_floats(ifc: &mut InlineFormattingContextState, line_items: &mut
}
fn line_height(parent_style: &ComputedValues, font_metrics: &FontMetrics) -> Length {
let font_size = parent_style.get_font().font_size.computed_size();
match parent_style.get_inherited_text().line_height {
let font = parent_style.get_font();
let font_size = font.font_size.computed_size();
match font.line_height {
LineHeight::Normal => Length::from(font_metrics.line_gap),
LineHeight::Number(number) => font_size * number.0,
LineHeight::Length(length) => length.0,

View file

@ -12,7 +12,7 @@ use servo_arc::Arc;
use style::properties::ComputedValues;
use style::values::computed::Length;
use style::values::generics::box_::{GenericVerticalAlign, VerticalAlignKeyword};
use style::values::generics::text::LineHeight;
use style::values::generics::font::LineHeight;
use style::values::specified::box_::DisplayOutside;
use style::values::specified::text::TextDecorationLine;
use style::Zero;
@ -581,8 +581,9 @@ impl FloatLineItem {
}
fn line_height(parent_style: &ComputedValues, font_metrics: &FontMetrics) -> Length {
let font_size = parent_style.get_font().font_size.computed_size();
match parent_style.get_inherited_text().line_height {
let font = parent_style.get_font();
let font_size = font.font_size.computed_size();
match font.line_height {
LineHeight::Normal => Length::from(font_metrics.line_gap),
LineHeight::Number(number) => font_size * number.0,
LineHeight::Length(length) => length.0,

View file

@ -39,7 +39,6 @@ where
]),
// XXX: Non-None image types unimplemented.
Image::ImageSet(..) |
Image::Rect(..) |
Image::Gradient(..) |
Image::CrossFade(..) |
Image::PaintWorklet(..) |

View file

@ -29,7 +29,7 @@ use style::shared_lock::SharedRwLock;
use style::stylesheets::{CssRuleType, Origin, UrlExtraData};
use style::stylist::RuleInclusion;
use style::traversal::resolve_style;
use style::values::generics::text::LineHeight;
use style::values::generics::font::LineHeight;
use style_traits::{ParsingMode, ToCss};
use webrender_api::ExternalScrollId;
@ -161,8 +161,9 @@ pub fn process_resolved_style_request<'dom>(
// For line height, the resolved value is the computed value if it
// is "normal" and the used value otherwise.
if longhand_id == LonghandId::LineHeight {
let font_size = style.get_font().font_size.computed_size();
return match style.get_inherited_text().line_height {
let font = style.get_font();
let font_size = font.font_size.computed_size();
return match font.line_height {
LineHeight::Normal => computed_style(),
LineHeight::Number(value) => (font_size * value.0).to_css_string(),
LineHeight::Length(value) => value.0.to_css_string(),

View file

@ -12,7 +12,7 @@ use canvas_traits::canvas::{
FillRule, LineCapStyle, LineJoinStyle, LinearGradientStyle, RadialGradientStyle,
RepetitionStyle, TextAlign, TextBaseline,
};
use cssparser::{Parser, ParserInput, RgbaLegacy};
use cssparser::{Parser, ParserInput};
use euclid::default::{Point2D, Rect, Size2D, Transform2D};
use euclid::vec2;
use ipc_channel::ipc::{self, IpcSender, IpcSharedMemory};
@ -22,6 +22,7 @@ use pixels::PixelFormat;
use profile_traits::ipc as profiled_ipc;
use script_traits::ScriptMsg;
use servo_url::{ImmutableOrigin, ServoUrl};
use style::color::parsing::RgbaLegacy;
use style::color::{AbsoluteColor, ColorSpace};
use style::context::QuirksMode;
use style::parser::ParserContext;

View file

@ -628,7 +628,7 @@ pub trait LayoutElementHelpers<'dom> {
fn get_lang_for_layout(self) -> String;
fn get_state_for_layout(self) -> ElementState;
fn insert_selector_flags(self, flags: ElementSelectorFlags);
fn has_selector_flags(self, flags: ElementSelectorFlags) -> bool;
fn get_selector_flags(self) -> ElementSelectorFlags;
/// The shadow root this element is a host of.
fn get_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>>;
fn get_attr_for_layout(
@ -708,7 +708,7 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
};
if let Some(color) = bgcolor {
use cssparser::FromParsedColor;
use style::color::parsing::FromParsedColor;
hints.push(from_declaration(
shared_lock,
PropertyDeclaration::BackgroundColor(specified::Color::from_rgba(
@ -748,7 +748,7 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
};
if let Some(color) = color {
use cssparser::FromParsedColor;
use style::color::parsing::FromParsedColor;
hints.push(from_declaration(
shared_lock,
PropertyDeclaration::Color(longhands::color::SpecifiedValue(
@ -1108,8 +1108,8 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
#[inline]
#[allow(unsafe_code)]
fn has_selector_flags(self, flags: ElementSelectorFlags) -> bool {
unsafe { (self.unsafe_get()).selector_flags.get().contains(flags) }
fn get_selector_flags(self) -> ElementSelectorFlags {
unsafe { self.unsafe_get().selector_flags.get() }
}
#[inline]

View file

@ -2,13 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use cssparser::RgbaLegacy;
use dom_struct::dom_struct;
use embedder_traits::EmbedderMsg;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use servo_url::ServoUrl;
use style::attr::AttrValue;
use style::color::parsing::RgbaLegacy;
use crate::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::HTMLBodyElementBinding::HTMLBodyElementMethods;

View file

@ -2,12 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use cssparser::RgbaLegacy;
use dom_struct::dom_struct;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use servo_atoms::Atom;
use style::attr::AttrValue;
use style::color::parsing::RgbaLegacy;
use style::str::{read_numbers, HTML_SPACE_CHARACTERS};
use crate::dom::attr::Attr;

View file

@ -2,11 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use cssparser::RgbaLegacy;
use dom_struct::dom_struct;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use style::color::parsing::RgbaLegacy;
use crate::dom::bindings::codegen::Bindings::HTMLHRElementBinding::HTMLHRElementMethods;
use crate::dom::bindings::inheritance::Castable;

View file

@ -2,11 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use cssparser::RgbaLegacy;
use dom_struct::dom_struct;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use style::color::parsing::RgbaLegacy;
use style::context::QuirksMode;
use crate::dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethods;

View file

@ -4,11 +4,11 @@
use std::cell::Cell;
use cssparser::RgbaLegacy;
use dom_struct::dom_struct;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use style::attr::{parse_unsigned_integer, AttrValue, LengthOrPercentageOrAuto};
use style::color::parsing::RgbaLegacy;
use crate::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods;

View file

@ -2,11 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use cssparser::RgbaLegacy;
use dom_struct::dom_struct;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use style::attr::AttrValue;
use style::color::parsing::RgbaLegacy;
use crate::dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods;
use crate::dom::bindings::codegen::Bindings::HTMLTableRowElementBinding::HTMLTableRowElementMethods;

View file

@ -2,11 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use cssparser::RgbaLegacy;
use dom_struct::dom_struct;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use style::attr::AttrValue;
use style::color::parsing::RgbaLegacy;
use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::HTMLTableSectionElementMethods;
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;

View file

@ -453,6 +453,21 @@ impl<'dom, LayoutDataType: LayoutDataTrait> style::dom::TElement
) -> euclid::default::Size2D<Option<app_units::Au>> {
todo!();
}
fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool {
self.element.get_selector_flags().contains(flags)
}
fn relative_selector_search_direction(&self) -> Option<ElementSelectorFlags> {
let flags = self.element.get_selector_flags().intersection(
ElementSelectorFlags::RELATIVE_SELECTOR_SEARCH_DIRECTION_ANCESTOR_SIBLING,
);
if flags.is_empty() {
None
} else {
Some(flags)
}
}
}
impl<'dom, LayoutDataType: LayoutDataTrait> ::selectors::Element

View file

@ -16,7 +16,6 @@ xr-profile = ["webxr-api/profile", "time"]
[dependencies]
crossbeam-channel = { workspace = true }
cssparser = { workspace = true }
euclid = { workspace = true }
ipc-channel = { workspace = true }
lazy_static = { workspace = true }

View file

@ -5,12 +5,12 @@
use std::default::Default;
use std::str::FromStr;
use cssparser::RgbaLegacy;
use euclid::default::{Point2D, Rect, Size2D, Transform2D};
use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSender, IpcSharedMemory};
use malloc_size_of_derive::MallocSizeOf;
use serde::{Deserialize, Serialize};
use serde_bytes::ByteBuf;
use style::color::parsing::RgbaLegacy;
use style::properties::style_structs::Font as FontStyleStruct;
use webrender_api::ImageKey;

View file

@ -441,7 +441,6 @@ pub trait ThreadSafeLayoutElement<'dom>:
&style_pseudo,
RuleInclusion::All,
data.styles.primary(),
data.styles.primary(),
/* is_probe = */ false,
/* matching_func = */ None,
)