Updated fixes to some clippy warnings in components/script

This commit is contained in:
jahielkomu 2024-03-31 17:19:04 +03:00
parent e74a03724f
commit 2a37c3dec8
58 changed files with 156 additions and 265 deletions

46
Cargo.lock generated
View file

@ -329,7 +329,7 @@ dependencies = [
"bitflags 2.5.0",
"cexpr",
"clang-sys",
"itertools 0.10.5",
"itertools 0.12.1",
"lazy_static",
"lazycell",
"log",
@ -572,7 +572,6 @@ dependencies = [
"byteorder",
"canvas_traits",
"crossbeam-channel",
"cssparser",
"euclid",
"fnv",
"font-kit",
@ -603,7 +602,6 @@ name = "canvas_traits"
version = "0.0.1"
dependencies = [
"crossbeam-channel",
"cssparser",
"euclid",
"ipc-channel",
"lazy_static",
@ -1081,9 +1079,9 @@ dependencies = [
[[package]]
name = "cssparser"
version = "0.32.0"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d54fe63cb80af11947c98a880393db44448d0b512f9b6c318398ae355794cb9"
checksum = "9be934d936a0fbed5bcdc01042b770de1398bf79d0e192f49fa7faea0e99281e"
dependencies = [
"cssparser-macros",
"dtoa-short",
@ -1110,7 +1108,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e16e44ab292b1dddfdaf7be62cfd8877df52f2f3fde5858d95bab606be259f20"
dependencies = [
"bitflags 2.5.0",
"libloading 0.7.4",
"libloading 0.8.3",
"winapi",
]
@ -1200,7 +1198,7 @@ dependencies = [
[[package]]
name = "derive_common"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2023-09-01#bcdebc41b2a2222e9fa5ae6d7d1572025c32dc47"
source = "git+https://github.com/servo/stylo?branch=2023-10-16#bab07f5fa1d0101d6b3c274e3715d1c1ef77e33c"
dependencies = [
"darling",
"proc-macro2",
@ -1306,7 +1304,7 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
dependencies = [
"libloading 0.7.4",
"libloading 0.8.3",
]
[[package]]
@ -3450,7 +3448,7 @@ dependencies = [
[[package]]
name = "malloc_size_of"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2023-09-01#bcdebc41b2a2222e9fa5ae6d7d1572025c32dc47"
source = "git+https://github.com/servo/stylo?branch=2023-10-16#bab07f5fa1d0101d6b3c274e3715d1c1ef77e33c"
dependencies = [
"accountable-refcell",
"app_units",
@ -5063,9 +5061,9 @@ dependencies = [
[[package]]
name = "selectors"
version = "0.24.0"
source = "git+https://github.com/servo/stylo?branch=2023-09-01#bcdebc41b2a2222e9fa5ae6d7d1572025c32dc47"
source = "git+https://github.com/servo/stylo?branch=2023-10-16#bab07f5fa1d0101d6b3c274e3715d1c1ef77e33c"
dependencies = [
"bitflags 1.3.2",
"bitflags 2.5.0",
"cssparser",
"derive_more",
"fxhash",
@ -5351,7 +5349,7 @@ dependencies = [
[[package]]
name = "servo_arc"
version = "0.2.0"
source = "git+https://github.com/servo/stylo?branch=2023-09-01#bcdebc41b2a2222e9fa5ae6d7d1572025c32dc47"
source = "git+https://github.com/servo/stylo?branch=2023-10-16#bab07f5fa1d0101d6b3c274e3715d1c1ef77e33c"
dependencies = [
"nodrop",
"serde",
@ -5361,7 +5359,7 @@ dependencies = [
[[package]]
name = "servo_atoms"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2023-09-01#bcdebc41b2a2222e9fa5ae6d7d1572025c32dc47"
source = "git+https://github.com/servo/stylo?branch=2023-10-16#bab07f5fa1d0101d6b3c274e3715d1c1ef77e33c"
dependencies = [
"string_cache",
"string_cache_codegen",
@ -5559,7 +5557,7 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
[[package]]
name = "size_of_test"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2023-09-01#bcdebc41b2a2222e9fa5ae6d7d1572025c32dc47"
source = "git+https://github.com/servo/stylo?branch=2023-10-16#bab07f5fa1d0101d6b3c274e3715d1c1ef77e33c"
dependencies = [
"static_assertions",
]
@ -5685,7 +5683,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "static_prefs"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2023-09-01#bcdebc41b2a2222e9fa5ae6d7d1572025c32dc47"
source = "git+https://github.com/servo/stylo?branch=2023-10-16#bab07f5fa1d0101d6b3c274e3715d1c1ef77e33c"
[[package]]
name = "strict-num"
@ -5722,12 +5720,12 @@ dependencies = [
[[package]]
name = "style"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2023-09-01#bcdebc41b2a2222e9fa5ae6d7d1572025c32dc47"
source = "git+https://github.com/servo/stylo?branch=2023-10-16#bab07f5fa1d0101d6b3c274e3715d1c1ef77e33c"
dependencies = [
"app_units",
"arrayvec",
"atomic_refcell",
"bitflags 1.3.2",
"bitflags 2.5.0",
"byteorder",
"cssparser",
"derive_more",
@ -5781,7 +5779,7 @@ dependencies = [
[[package]]
name = "style_config"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2023-09-01#bcdebc41b2a2222e9fa5ae6d7d1572025c32dc47"
source = "git+https://github.com/servo/stylo?branch=2023-10-16#bab07f5fa1d0101d6b3c274e3715d1c1ef77e33c"
dependencies = [
"lazy_static",
]
@ -5789,7 +5787,7 @@ dependencies = [
[[package]]
name = "style_derive"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2023-09-01#bcdebc41b2a2222e9fa5ae6d7d1572025c32dc47"
source = "git+https://github.com/servo/stylo?branch=2023-10-16#bab07f5fa1d0101d6b3c274e3715d1c1ef77e33c"
dependencies = [
"darling",
"derive_common",
@ -5820,10 +5818,10 @@ dependencies = [
[[package]]
name = "style_traits"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2023-09-01#bcdebc41b2a2222e9fa5ae6d7d1572025c32dc47"
source = "git+https://github.com/servo/stylo?branch=2023-10-16#bab07f5fa1d0101d6b3c274e3715d1c1ef77e33c"
dependencies = [
"app_units",
"bitflags 1.3.2",
"bitflags 2.5.0",
"cssparser",
"euclid",
"lazy_static",
@ -6174,7 +6172,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "to_shmem"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2023-09-01#bcdebc41b2a2222e9fa5ae6d7d1572025c32dc47"
source = "git+https://github.com/servo/stylo?branch=2023-10-16#bab07f5fa1d0101d6b3c274e3715d1c1ef77e33c"
dependencies = [
"cssparser",
"servo_arc",
@ -6187,7 +6185,7 @@ dependencies = [
[[package]]
name = "to_shmem_derive"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2023-09-01#bcdebc41b2a2222e9fa5ae6d7d1572025c32dc47"
source = "git+https://github.com/servo/stylo?branch=2023-10-16#bab07f5fa1d0101d6b3c274e3715d1c1ef77e33c"
dependencies = [
"darling",
"derive_common",
@ -7007,7 +7005,7 @@ dependencies = [
"js-sys",
"khronos-egl",
"libc",
"libloading 0.7.4",
"libloading 0.8.3",
"log",
"metal 0.27.0",
"naga",

View file

@ -26,7 +26,7 @@ compositing_traits = { path = "components/shared/compositing" }
content-security-policy = { version = "0.5", features = ["serde"] }
cookie = "0.12"
crossbeam-channel = "0.5"
cssparser = "0.32"
cssparser = { version = "0.33", features = ["serde"] }
darling = { version = "0.20", default-features = false }
data-url = "0.1.0"
devtools_traits = { path = "components/shared/devtools" }
@ -64,7 +64,7 @@ keyboard-types = "0.6"
lazy_static = "1.4"
libc = "0.2"
log = "0.4"
malloc_size_of = { git = "https://github.com/servo/stylo", branch = "2023-09-01", features = ["servo"] }
malloc_size_of = { git = "https://github.com/servo/stylo", branch = "2023-10-16", features = ["servo"] }
malloc_size_of_derive = "0.1"
mime = "0.3.13"
mime_guess = "2.0.3"
@ -87,31 +87,31 @@ rustls = { version = "0.21.10", features = ["dangerous_configuration"] }
rustls-pemfile = "1.0.4"
script_layout_interface = { path = "components/shared/script_layout" }
script_traits = { path = "components/shared/script" }
selectors = { git = "https://github.com/servo/stylo", branch = "2023-09-01" }
selectors = { git = "https://github.com/servo/stylo", branch = "2023-10-16" }
serde = "1.0.197"
serde_bytes = "0.11"
serde_json = "1.0"
servo-media = { git = "https://github.com/servo/media" }
servo-media-dummy = { git = "https://github.com/servo/media" }
servo-media-gstreamer = { git = "https://github.com/servo/media" }
servo_arc = { git = "https://github.com/servo/stylo", branch = "2023-09-01" }
servo_atoms = { git = "https://github.com/servo/stylo", branch = "2023-09-01" }
size_of_test = { git = "https://github.com/servo/stylo", branch = "2023-09-01" }
servo_arc = { git = "https://github.com/servo/stylo", branch = "2023-10-16" }
servo_atoms = { git = "https://github.com/servo/stylo", branch = "2023-10-16" }
size_of_test = { git = "https://github.com/servo/stylo", branch = "2023-10-16" }
smallbitvec = "2.5.3"
smallvec = "1.13"
sparkle = "0.1.26"
string_cache = "0.8"
string_cache_codegen = "0.5"
style = { git = "https://github.com/servo/stylo", branch = "2023-09-01", features = ["servo"] }
style_config = { git = "https://github.com/servo/stylo", branch = "2023-09-01" }
style_traits = { git = "https://github.com/servo/stylo", branch = "2023-09-01", features = ["servo"] }
style = { git = "https://github.com/servo/stylo", branch = "2023-10-16", features = ["servo"] }
style_config = { git = "https://github.com/servo/stylo", branch = "2023-10-16" }
style_traits = { git = "https://github.com/servo/stylo", branch = "2023-10-16", features = ["servo"] }
# NOTE: the sm-angle feature only enables ANGLE on Windows, not other platforms!
surfman = { version = "0.9", features = ["chains", "sm-angle", "sm-angle-default"] }
syn = { version = "2", default-features = false, features = ["clone-impls", "derive", "parsing"] }
synstructure = "0.13"
thin-vec = "0.2.13"
time = "0.1.41"
to_shmem = { git = "https://github.com/servo/stylo", branch = "2023-09-01" }
to_shmem = { git = "https://github.com/servo/stylo", branch = "2023-10-16" }
tokio = "1"
tokio-rustls = "0.24"
tungstenite = "0.20"

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

@ -543,9 +543,9 @@ pub enum ProtoOrIfaceIndex {
Constructor(PrototypeList::Constructor),
}
impl Into<usize> for ProtoOrIfaceIndex {
fn into(self) -> usize {
match self {
impl From<ProtoOrIfaceIndex> for usize {
fn from(index: ProtoOrIfaceIndex) -> usize {
match index {
ProtoOrIfaceIndex::ID(id) => id as usize,
ProtoOrIfaceIndex::Constructor(constructor) => constructor as usize,
}

View file

@ -51,9 +51,9 @@ impl ByteString {
}
}
impl Into<Vec<u8>> for ByteString {
fn into(self) -> Vec<u8> {
self.0
impl From<ByteString> for Vec<u8> {
fn from(byte_string: ByteString) -> Vec<u8> {
byte_string.0
}
}
@ -640,21 +640,21 @@ impl From<DOMString> for String {
}
}
impl Into<Vec<u8>> for DOMString {
fn into(self) -> Vec<u8> {
self.0.into()
impl From<DOMString> for Vec<u8> {
fn from(contents: DOMString) -> Vec<u8> {
contents.0.into()
}
}
impl<'a> Into<Cow<'a, str>> for DOMString {
fn into(self) -> Cow<'a, str> {
self.0.into()
impl<'a> From<DOMString> for Cow<'a, str> {
fn from(contents: DOMString) -> Cow<'a, str> {
contents.0.into()
}
}
impl<'a> Into<CowRcStr<'a>> for DOMString {
fn into(self) -> CowRcStr<'a> {
self.0.into()
impl<'a> From<DOMString> for CowRcStr<'a> {
fn from(contents: DOMString) -> CowRcStr<'a> {
contents.0.into()
}
}

View file

@ -110,15 +110,13 @@ pub fn xml_name_type(name: &str) -> XMLName {
fn is_valid_continuation(c: char) -> bool {
is_valid_start(c) ||
match c {
matches!(c,
'-' |
'.' |
'0'..='9' |
'\u{B7}' |
'\u{300}'..='\u{36F}' |
'\u{203F}'..='\u{2040}' => true,
_ => false,
}
'\u{203F}'..='\u{2040}')
}
let mut iter = name.chars();

View file

@ -64,14 +64,14 @@ impl CryptoMethods for Crypto {
}
fn is_integer_buffer(array_type: Type) -> bool {
match array_type {
matches!(
array_type,
Type::Uint8 |
Type::Uint8Clamped |
Type::Int8 |
Type::Uint16 |
Type::Int16 |
Type::Uint32 |
Type::Int32 => true,
_ => false,
}
Type::Int32
)
}

View file

@ -345,16 +345,17 @@ impl Element {
self.is.borrow().clone()
}
/// <https://dom.spec.whatwg.org/#concept-element-custom-element-state>
pub fn set_custom_element_state(&self, state: CustomElementState) {
// no need to inflate rare data for uncustomized
if state != CustomElementState::Uncustomized || self.rare_data().is_some() {
self.ensure_rare_data().custom_element_state = state;
}
// https://dom.spec.whatwg.org/#concept-element-defined
let in_defined_state = match state {
CustomElementState::Uncustomized | CustomElementState::Custom => true,
_ => false,
};
let in_defined_state = matches!(
state,
CustomElementState::Uncustomized | CustomElementState::Custom
);
self.set_state(ElementState::DEFINED, in_defined_state)
}
@ -627,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(
@ -707,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(
@ -747,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(
@ -1107,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]
@ -1393,21 +1394,18 @@ impl Element {
}
// <a>, <input>, <select>, and <textrea> are inherently focusable.
match node.type_id() {
matches!(
node.type_id(),
NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLAnchorElement,
)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(
)) | NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLInputElement,
)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(
)) | NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLSelectElement,
)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(
)) | NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLTextAreaElement,
)) => true,
_ => false,
}
))
)
}
pub fn is_actually_disabled(&self) -> bool {
@ -1493,7 +1491,7 @@ impl Element {
.map(|js| DomRoot::from_ref(&**js))
}
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
/// <https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name>
pub fn get_attribute_by_name(&self, name: DOMString) -> Option<DomRoot<Attr>> {
let name = &self.parsed_name(name);
let maybe_attribute = self
@ -1506,10 +1504,7 @@ impl Element {
if *name == local_name!("id") || *name == local_name!("name") {
match maybe_attr {
None => true,
Some(ref attr) => match *attr.value() {
AttrValue::Atom(_) => true,
_ => false,
},
Some(ref attr) => matches!(*attr.value(), AttrValue::Atom(_)),
}
} else {
true
@ -2932,10 +2927,7 @@ impl VirtualMethods for Element {
//
// Juggle a bit to keep the borrow checker happy
// while avoiding the extra clone.
let is_declaration = match *attr.value() {
AttrValue::Declaration(..) => true,
_ => false,
};
let is_declaration = matches!(*attr.value(), AttrValue::Declaration(..));
let block = if is_declaration {
let mut value = AttrValue::String(String::new());

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

@ -3454,10 +3454,10 @@ impl UniqueId {
}
}
impl Into<LayoutNodeType> for NodeTypeId {
impl From<NodeTypeId> for LayoutNodeType {
#[inline(always)]
fn into(self) -> LayoutNodeType {
match self {
fn from(node_type: NodeTypeId) -> LayoutNodeType {
match node_type {
NodeTypeId::Element(e) => LayoutNodeType::Element(e.into()),
NodeTypeId::CharacterData(CharacterDataTypeId::Text(_)) => LayoutNodeType::Text,
x => unreachable!("Layout should not traverse nodes of type {:?}", x),
@ -3465,10 +3465,10 @@ impl Into<LayoutNodeType> for NodeTypeId {
}
}
impl Into<LayoutElementType> for ElementTypeId {
impl From<ElementTypeId> for LayoutElementType {
#[inline(always)]
fn into(self) -> LayoutElementType {
match self {
fn from(element_type: ElementTypeId) -> LayoutElementType {
match element_type {
ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement) => {
LayoutElementType::HTMLBodyElement
},

View file

@ -24,10 +24,7 @@ gl_enums! {
impl TexImageTarget {
pub fn is_cubic(&self) -> bool {
match *self {
TexImageTarget::Texture2D => false,
_ => true,
}
!matches!(*self, TexImageTarget::Texture2D)
}
pub fn dimensions(self) -> u8 {

View file

@ -2520,6 +2520,7 @@ impl Window {
impl Window {
#[allow(unsafe_code)]
#[allow(clippy::too_many_arguments)]
pub fn new(
runtime: Rc<Runtime>,
script_chan: MainThreadScriptChan,

View file

@ -99,9 +99,9 @@ impl XRSystem {
}
}
impl Into<SessionMode> for XRSessionMode {
fn into(self) -> SessionMode {
match self {
impl From<XRSessionMode> for SessionMode {
fn from(mode: XRSessionMode) -> SessionMode {
match mode {
XRSessionMode::Immersive_vr => SessionMode::ImmersiveVR,
XRSessionMode::Immersive_ar => SessionMode::ImmersiveAR,
XRSessionMode::Inline => SessionMode::Inline,

View file

@ -149,10 +149,7 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ServoLayoutElement<'dom, LayoutDataT
fn is_root(&self) -> bool {
match self.as_node().parent_node() {
None => false,
Some(node) => match node.script_type_id() {
NodeTypeId::Document(_) => true,
_ => false,
},
Some(node) => matches!(node.script_type_id(), NodeTypeId::Document(_)),
}
}
}
@ -456,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
@ -587,15 +599,11 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ::selectors::Element
NonTSPseudoClass::Lang(ref lang) => self.match_element_lang(None, lang),
NonTSPseudoClass::ServoNonZeroBorder => {
match self
.element
.get_attr_for_layout(&ns!(), &local_name!("border"))
{
None | Some(&AttrValue::UInt(_, 0)) => false,
_ => true,
}
},
NonTSPseudoClass::ServoNonZeroBorder => !matches!(
self.element
.get_attr_for_layout(&ns!(), &local_name!("border")),
None | Some(&AttrValue::UInt(_, 0))
),
NonTSPseudoClass::ReadOnly => !self
.element
.get_state_for_layout()

View file

@ -97,9 +97,6 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ServoLayoutNode<'dom, LayoutDataType
phantom: PhantomData,
}
}
/// # Safety
///
/// This function should not be called if there is no TrustedNodeAddress.
pub unsafe fn new(address: &TrustedNodeAddress) -> Self {
ServoLayoutNode::from_layout_js(LayoutDom::from_trusted_node_address(*address))
}

View file

@ -71,9 +71,6 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ServoShadowRoot<'dom, LayoutDataType
}
}
/// # Safety
///
/// This function should not mutate StyleSharedRwLockReadGuard.
pub unsafe fn flush_stylesheets(
&self,
stylist: &mut Stylist,

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,
)

View file

@ -21,9 +21,10 @@ fn srgb_legacy_from_floats(red: f32, green: f32, blue: f32, alpha: f32) -> Absol
// Color
#[test]
fn test_rgba_color_interepolation_preserves_transparent() {
let transparent = AbsoluteColor::TRANSPARENT_BLACK;
assert_eq!(
interpolate_color(AbsoluteColor::TRANSPARENT, AbsoluteColor::TRANSPARENT, 0.5),
AbsoluteColor::TRANSPARENT
interpolate_color(transparent, transparent, 0.5),
transparent
);
}

View file

@ -4,11 +4,10 @@
use cssparser::{Parser, ParserInput};
use euclid::{Scale, Size2D};
use servo_arc::Arc;
use style::applicable_declarations::CascadePriority;
use style::context::QuirksMode;
use style::custom_properties::{
CustomPropertiesBuilder, CustomPropertiesMap, Name, SpecifiedValue,
ComputedCustomProperties, CustomPropertiesBuilder, Name, SpecifiedValue,
};
use style::media_queries::{Device, MediaType};
use style::properties::{CustomDeclaration, CustomDeclarationValue};
@ -19,8 +18,8 @@ use test::{self, Bencher};
fn cascade(
name_and_value: &[(&str, &str)],
inherited: Option<&Arc<CustomPropertiesMap>>,
) -> Option<Arc<CustomPropertiesMap>> {
inherited: &ComputedCustomProperties,
) -> ComputedCustomProperties {
let declarations = name_and_value
.iter()
.map(|&(name, value)| {
@ -39,7 +38,7 @@ fn cascade(
Scale::new(1.0),
);
let stylist = Stylist::new(device, QuirksMode::NoQuirks);
let mut builder = CustomPropertiesBuilder::new(inherited, &stylist);
let mut builder = CustomPropertiesBuilder::new(inherited, &stylist, false);
for declaration in &declarations {
builder.cascade(
@ -54,11 +53,14 @@ fn cascade(
#[bench]
fn cascade_custom_simple(b: &mut Bencher) {
b.iter(|| {
let parent = cascade(&[("foo", "10px"), ("bar", "100px")], None);
let parent = cascade(
&[("foo", "10px"), ("bar", "100px")],
&ComputedCustomProperties::default(),
);
test::black_box(cascade(
&[("baz", "calc(40em + 4px)"), ("bazz", "calc(30em + 4px)")],
parent.as_ref(),
&parent,
))
})
}

View file

@ -1,12 +0,0 @@
[opacity-valid.html]
[e.style['opacity'\] = "clamp(50%, 0%, 70%)" should set the property value]
expected: FAIL
[e.style['opacity'\] = "clamp(50%, 80%, 70%)" should set the property value]
expected: FAIL
[e.style['opacity'\] = "min(50%, 0%)" should set the property value]
expected: FAIL
[e.style['opacity'\] = "max(0%, 50%)" should set the property value]
expected: FAIL

View file

@ -1,2 +0,0 @@
[rlh-in-monospace.html]
expected: FAIL

View file

@ -1,3 +0,0 @@
[getComputedStyle-calc-mixed-units-002.html]
[testing width: calc(8lh + 7px)]
expected: FAIL

View file

@ -1,2 +0,0 @@
[lh-unit-001.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[lh-unit-002.html]
expected: FAIL

View file

@ -1,3 +0,0 @@
[lh-unit-005.html]
[lh relative to line-height inherited from parent]
expected: FAIL

View file

@ -1,3 +0,0 @@
[rlh-invalidation.html]
[CSS Values and Units Test: rlh invalidation]
expected: FAIL

View file

@ -82,21 +82,3 @@
[widows: inherit]
expected: FAIL
[content: attr( |bar )]
expected: FAIL
[content: attr(foo-bar, "fallback")]
expected: FAIL
[content: attr(foo_bar, "fallback")]
expected: FAIL
[content: attr(|bar, "fallback")]
expected: FAIL
[content: attr(foo, "")]
expected: FAIL
[content: attr( |foo , "" )]
expected: FAIL

View file

@ -1,3 +0,0 @@
[parent-style-relative-units.html]
[Font-size based on canvas element line-height]
expected: FAIL

View file

@ -1,12 +0,0 @@
[opacity-valid.html]
[e.style['opacity'\] = "clamp(50%, 0%, 70%)" should set the property value]
expected: FAIL
[e.style['opacity'\] = "clamp(50%, 80%, 70%)" should set the property value]
expected: FAIL
[e.style['opacity'\] = "min(50%, 0%)" should set the property value]
expected: FAIL
[e.style['opacity'\] = "max(0%, 50%)" should set the property value]
expected: FAIL

View file

@ -1,2 +0,0 @@
[rlh-in-monospace.html]
expected: FAIL

View file

@ -1,3 +0,0 @@
[getComputedStyle-calc-mixed-units-002.html]
[testing width: calc(8lh + 7px)]
expected: FAIL

View file

@ -1,2 +0,0 @@
[lh-unit-001.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[lh-unit-002.html]
expected: FAIL

View file

@ -1,3 +0,0 @@
[lh-unit-005.html]
[lh relative to line-height inherited from parent]
expected: FAIL

View file

@ -1,3 +0,0 @@
[rlh-invalidation.html]
[CSS Values and Units Test: rlh invalidation]
expected: FAIL

View file

@ -148,21 +148,3 @@
[unicode-bidi: inherit]
expected: FAIL
[content: attr( |bar )]
expected: FAIL
[content: attr(foo-bar, "fallback")]
expected: FAIL
[content: attr(foo_bar, "fallback")]
expected: FAIL
[content: attr(|bar, "fallback")]
expected: FAIL
[content: attr(foo, "")]
expected: FAIL
[content: attr( |foo , "" )]
expected: FAIL

View file

@ -1,3 +0,0 @@
[parent-style-relative-units.html]
[Font-size based on canvas element line-height]
expected: FAIL