mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
style: Miscellaneous servo build fixes.
This commit is contained in:
parent
eff8f0fca0
commit
332aec212c
14 changed files with 52 additions and 35 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -5329,9 +5329,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
|||
|
||||
[[package]]
|
||||
name = "smallbitvec"
|
||||
version = "2.3.0"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1764fe2b30ee783bfe3b9b37b2649d8d590b3148bb12e0079715d4d5c673562e"
|
||||
checksum = "797a4eaffb90d896f29698d45676f9f940a71936d7574996a7df54593ba209fa"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
|
|
|
@ -3331,7 +3331,7 @@ impl Document {
|
|||
pub fn element_state_will_change(&self, el: &Element) {
|
||||
let mut entry = self.ensure_pending_restyle(el);
|
||||
if entry.snapshot.is_none() {
|
||||
entry.snapshot = Some(Snapshot::new(el.html_element_in_html_document()));
|
||||
entry.snapshot = Some(Snapshot::new());
|
||||
}
|
||||
let snapshot = entry.snapshot.as_mut().unwrap();
|
||||
if snapshot.state.is_none() {
|
||||
|
@ -3347,7 +3347,7 @@ impl Document {
|
|||
// could in theory do it in the DOM I think.
|
||||
let mut entry = self.ensure_pending_restyle(el);
|
||||
if entry.snapshot.is_none() {
|
||||
entry.snapshot = Some(Snapshot::new(el.html_element_in_html_document()));
|
||||
entry.snapshot = Some(Snapshot::new());
|
||||
}
|
||||
if attr.local_name() == &local_name!("style") {
|
||||
entry.hint.insert(RestyleHint::RESTYLE_STYLE_ATTRIBUTE);
|
||||
|
@ -3359,12 +3359,21 @@ impl Document {
|
|||
|
||||
let snapshot = entry.snapshot.as_mut().unwrap();
|
||||
if attr.local_name() == &local_name!("id") {
|
||||
if snapshot.id_changed {
|
||||
return;
|
||||
}
|
||||
snapshot.id_changed = true;
|
||||
} else if attr.local_name() == &local_name!("class") {
|
||||
if snapshot.class_changed {
|
||||
return;
|
||||
}
|
||||
snapshot.class_changed = true;
|
||||
} else {
|
||||
snapshot.other_attributes_changed = true;
|
||||
}
|
||||
if !snapshot.changed_attrs.contains(attr.local_name()) {
|
||||
snapshot.changed_attrs.push(attr.local_name().clone());
|
||||
}
|
||||
if snapshot.attrs.is_none() {
|
||||
let attrs = el
|
||||
.attrs()
|
||||
|
|
|
@ -196,7 +196,7 @@ pub struct InvalidationMap {
|
|||
/// A list of document state dependencies in the rules we represent.
|
||||
pub document_state_selectors: Vec<DocumentStateDependency>,
|
||||
/// A map of other attribute affecting selectors.
|
||||
pub other_attribute_affecting_selectors: PrecomputedHashMap<Atom, SmallVec<[Dependency; 1]>>,
|
||||
pub other_attribute_affecting_selectors: PrecomputedHashMap<LocalName, SmallVec<[Dependency; 1]>>,
|
||||
}
|
||||
|
||||
impl InvalidationMap {
|
||||
|
@ -461,7 +461,6 @@ impl<'a> SelectorVisitor for SelectorDependencyCollector<'a> {
|
|||
}
|
||||
|
||||
fn visit_simple_selector(&mut self, s: &Component<SelectorImpl>) -> bool {
|
||||
#[cfg(feature = "gecko")]
|
||||
use crate::selector_parser::NonTSPseudoClass;
|
||||
|
||||
match *s {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#![allow(unsafe_code)]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
use crate::animation::AnimationState;
|
||||
use crate::computed_value_flags::ComputedValueFlags;
|
||||
use crate::context::{ElementCascadeInputs, QuirksMode, SelectorFlagsMap};
|
||||
use crate::context::{SharedStyleContext, StyleContext};
|
||||
|
@ -438,6 +437,8 @@ trait PrivateMatchMethods: TElement {
|
|||
_restyle_hint: RestyleHint,
|
||||
_important_rules_changed: bool,
|
||||
) {
|
||||
use crate::animation::AnimationState;
|
||||
|
||||
let this_opaque = self.as_node().opaque();
|
||||
let shared_context = context.shared;
|
||||
let mut animation_states = shared_context.animation_states.write();
|
||||
|
|
|
@ -68,8 +68,7 @@ pub type AnimationValueMap = FxHashMap<LonghandId, AnimationValue>;
|
|||
///
|
||||
/// FIXME: We need to add a path for custom properties, but that's trivial after
|
||||
/// this (is a similar path to that of PropertyDeclaration).
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MallocSizeOf)]
|
||||
#[repr(u16)]
|
||||
pub enum AnimationValue {
|
||||
% for prop in data.longhands:
|
||||
|
@ -420,6 +419,7 @@ impl AnimationValue {
|
|||
///
|
||||
/// SERVO ONLY: This doesn't properly handle things like updating 'em' units
|
||||
/// when animated font-size.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn set_in_style_for_servo(&self, style: &mut ComputedValues) {
|
||||
match self {
|
||||
% for prop in data.longhands:
|
||||
|
@ -439,6 +439,11 @@ impl AnimationValue {
|
|||
% endfor
|
||||
}
|
||||
}
|
||||
|
||||
/// As above, but a stub for Gecko.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn set_in_style_for_servo(&self, _: &mut ComputedValues) {
|
||||
}
|
||||
}
|
||||
|
||||
fn animate_discrete<T: Clone>(this: &T, other: &T, procedure: Procedure) -> Result<T, ()> {
|
||||
|
|
|
@ -278,9 +278,12 @@ impl SelectorMap<Rule> {
|
|||
}
|
||||
|
||||
impl<T: SelectorMapEntry> SelectorMap<T> {
|
||||
/// Inserts into the correct hash, trying id, class, localname and
|
||||
/// namespace.
|
||||
pub fn insert(&mut self, entry: T, quirks_mode: QuirksMode) -> Result<(), FailedAllocationError> {
|
||||
/// Inserts an entry into the correct bucket(s).
|
||||
pub fn insert(
|
||||
&mut self,
|
||||
entry: T,
|
||||
quirks_mode: QuirksMode,
|
||||
) -> Result<(), FailedAllocationError> {
|
||||
self.count += 1;
|
||||
|
||||
// NOTE(emilio): It'd be nice for this to be a separate function, but
|
||||
|
|
|
@ -615,15 +615,14 @@ impl DerefMut for SnapshotMap {
|
|||
}
|
||||
|
||||
/// Servo's version of an element snapshot.
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||
#[derive(Debug, Default, MallocSizeOf)]
|
||||
pub struct ServoElementSnapshot {
|
||||
/// The stored state of the element.
|
||||
pub state: Option<ElementState>,
|
||||
/// The set of stored attributes and its values.
|
||||
pub attrs: Option<Vec<(AttrIdentifier, AttrValue)>>,
|
||||
/// Whether this element is an HTML element in an HTML document.
|
||||
pub is_html_element_in_html_document: bool,
|
||||
/// The set of changed attributes and its values.
|
||||
pub changed_attrs: Vec<LocalName>,
|
||||
/// Whether the class attribute changed or not.
|
||||
pub class_changed: bool,
|
||||
/// Whether the id attribute changed or not.
|
||||
|
@ -634,15 +633,8 @@ pub struct ServoElementSnapshot {
|
|||
|
||||
impl ServoElementSnapshot {
|
||||
/// Create an empty element snapshot.
|
||||
pub fn new(is_html_element_in_html_document: bool) -> Self {
|
||||
ServoElementSnapshot {
|
||||
state: None,
|
||||
attrs: None,
|
||||
is_html_element_in_html_document: is_html_element_in_html_document,
|
||||
class_changed: false,
|
||||
id_changed: false,
|
||||
other_attributes_changed: false,
|
||||
}
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Returns whether the id attribute changed or not.
|
||||
|
@ -669,6 +661,17 @@ impl ServoElementSnapshot {
|
|||
.map(|&(_, ref v)| v)
|
||||
}
|
||||
|
||||
/// Executes the callback once for each attribute that changed.
|
||||
#[inline]
|
||||
pub fn each_attr_changed<F>(&self, mut callback: F)
|
||||
where
|
||||
F: FnMut(&LocalName),
|
||||
{
|
||||
for name in &self.changed_attrs {
|
||||
callback(name)
|
||||
}
|
||||
}
|
||||
|
||||
fn any_attr_ignore_ns<F>(&self, name: &LocalName, mut f: F) -> bool
|
||||
where
|
||||
F: FnMut(&AttrValue) -> bool,
|
||||
|
|
|
@ -15,7 +15,6 @@ use std::cell::UnsafeCell;
|
|||
use std::fmt;
|
||||
#[cfg(feature = "servo")]
|
||||
use std::mem;
|
||||
use std::mem::ManuallyDrop;
|
||||
#[cfg(feature = "gecko")]
|
||||
use std::ptr;
|
||||
use to_shmem::{SharedMemoryBuilder, ToShmem};
|
||||
|
|
|
@ -12,8 +12,7 @@ use crate::values::generics::color::{Color as GenericColor, ComplexColorRatios};
|
|||
///
|
||||
/// Unlike in computed values, each component value may exceed the
|
||||
/// range `[0.0, 1.0]`.
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, ToAnimatedZero)]
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedZero)]
|
||||
pub struct RGBA {
|
||||
/// The red component.
|
||||
pub red: f32,
|
||||
|
|
|
@ -35,7 +35,7 @@ pub use super::specified::{AlignSelf, JustifySelf};
|
|||
/// sucks :(.
|
||||
///
|
||||
/// See the discussion in https://bugzil.la/1384542.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss, ToResolvedValue)]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)]
|
||||
#[repr(C)]
|
||||
pub struct ComputedJustifyItems {
|
||||
/// The specified value for the property. Can contain the bare `legacy`
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
//! Generic types for CSS values related to flexbox.
|
||||
|
||||
/// A generic value for the `flex-basis` property.
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||
#[derive(
|
||||
Animate,
|
||||
Clone,
|
||||
ComputeSquaredDistance,
|
||||
Copy,
|
||||
Debug,
|
||||
MallocSizeOf,
|
||||
Parse,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
|
|
|
@ -174,13 +174,13 @@ impl<LengthPercentage> Size<LengthPercentage> {
|
|||
|
||||
/// A generic value for the `max-width` or `max-height` property.
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||
#[derive(
|
||||
Animate,
|
||||
Clone,
|
||||
ComputeSquaredDistance,
|
||||
Copy,
|
||||
Debug,
|
||||
MallocSizeOf,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
ToAnimatedValue,
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
/// Because the script task's GC does not trace layout, node data cannot be safely stored in layout
|
||||
/// data structures. Also, layout code tends to be faster when the DOM is not being accessed, for
|
||||
/// locality reasons. Using `OpaqueNode` enforces this invariant.
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf, Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
pub struct OpaqueNode(pub usize);
|
||||
|
||||
impl OpaqueNode {
|
||||
|
|
|
@ -20,7 +20,6 @@ pub use crate::origin::{ImmutableOrigin, MutableOrigin, OpaqueOrigin};
|
|||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::fmt;
|
||||
use std::hash::Hasher;
|
||||
use std::mem::ManuallyDrop;
|
||||
use std::net::IpAddr;
|
||||
use std::ops::{Index, Range, RangeFrom, RangeFull, RangeTo};
|
||||
use std::path::Path;
|
||||
|
@ -34,7 +33,7 @@ pub use url::Host;
|
|||
pub struct ServoUrl(#[ignore_malloc_size_of = "Arc"] Arc<Url>);
|
||||
|
||||
impl ToShmem for ServoUrl {
|
||||
fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> ManuallyDrop<Self> {
|
||||
fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> to_shmem::Result<Self> {
|
||||
unimplemented!("If servo wants to share stylesheets across processes, ToShmem for Url must be implemented")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue