mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Auto merge of #14848 - bzbarsky:initial-styles, r=bholley
Stop using global initial styles for stylo; the initial styles need to be per-document <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix https://bugzilla.mozilla.org/show_bug.cgi?id=1298588 <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests on the servo side because behavior is unchanged. Gecko-side tests probably exist. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14848) <!-- Reviewable:end -->
This commit is contained in:
commit
143dfc879e
20 changed files with 287 additions and 152 deletions
|
@ -54,7 +54,6 @@ use style::logical_geometry::Direction;
|
||||||
use style::properties::{self, ServoComputedValues};
|
use style::properties::{self, ServoComputedValues};
|
||||||
use style::selector_parser::{PseudoElement, RestyleDamage};
|
use style::selector_parser::{PseudoElement, RestyleDamage};
|
||||||
use style::servo::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW};
|
use style::servo::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW};
|
||||||
use style::stylist::Stylist;
|
|
||||||
use style::values::Either;
|
use style::values::Either;
|
||||||
use table::TableFlow;
|
use table::TableFlow;
|
||||||
use table_caption::TableCaptionFlow;
|
use table_caption::TableCaptionFlow;
|
||||||
|
@ -470,7 +469,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
}
|
}
|
||||||
|
|
||||||
inline_flow_ref.finish();
|
inline_flow_ref.finish();
|
||||||
legalizer.add_child(&self.style_context().stylist, flow, inline_flow_ref)
|
legalizer.add_child(self.style_context(), flow, inline_flow_ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_block_flow_using_construction_result_of_child(
|
fn build_block_flow_using_construction_result_of_child(
|
||||||
|
@ -503,7 +502,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
legalizer,
|
legalizer,
|
||||||
node);
|
node);
|
||||||
}
|
}
|
||||||
legalizer.add_child(&self.style_context().stylist, flow, kid_flow)
|
legalizer.add_child(self.style_context(), flow, kid_flow)
|
||||||
}
|
}
|
||||||
abs_descendants.push_descendants(kid_abs_descendants);
|
abs_descendants.push_descendants(kid_abs_descendants);
|
||||||
}
|
}
|
||||||
|
@ -537,7 +536,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
node);
|
node);
|
||||||
|
|
||||||
// Push the flow generated by the {ib} split onto our list of flows.
|
// Push the flow generated by the {ib} split onto our list of flows.
|
||||||
legalizer.add_child(&self.style_context().stylist, flow, kid_flow)
|
legalizer.add_child(self.style_context(), flow, kid_flow)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the fragments to the list we're maintaining.
|
// Add the fragments to the list we're maintaining.
|
||||||
|
@ -662,7 +661,8 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
if node_is_input_or_text_area {
|
if node_is_input_or_text_area {
|
||||||
style = self.style_context()
|
style = self.style_context()
|
||||||
.stylist
|
.stylist
|
||||||
.style_for_anonymous_box(&PseudoElement::ServoInputText, &style)
|
.style_for_anonymous_box(&PseudoElement::ServoInputText, &style,
|
||||||
|
&self.style_context().default_computed_values)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.create_fragments_for_node_text_content(&mut initial_fragments, node, &style)
|
self.create_fragments_for_node_text_content(&mut initial_fragments, node, &style)
|
||||||
|
@ -1094,7 +1094,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
let wrapper_style = self.style_context()
|
let wrapper_style = self.style_context()
|
||||||
.stylist
|
.stylist
|
||||||
.style_for_anonymous_box(&PseudoElement::ServoTableWrapper,
|
.style_for_anonymous_box(&PseudoElement::ServoTableWrapper,
|
||||||
&table_style);
|
&table_style, &self.style_context().default_computed_values);
|
||||||
let wrapper_fragment =
|
let wrapper_fragment =
|
||||||
Fragment::from_opaque_node_and_style(node.opaque(),
|
Fragment::from_opaque_node_and_style(node.opaque(),
|
||||||
PseudoElementType::Normal,
|
PseudoElementType::Normal,
|
||||||
|
@ -1123,7 +1123,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
caption_side::T::top);
|
caption_side::T::top);
|
||||||
|
|
||||||
if let ConstructionResult::Flow(table_flow, table_abs_descendants) = construction_result {
|
if let ConstructionResult::Flow(table_flow, table_abs_descendants) = construction_result {
|
||||||
legalizer.add_child(&self.style_context().stylist, &mut wrapper_flow, table_flow);
|
legalizer.add_child(self.style_context(), &mut wrapper_flow, table_flow);
|
||||||
abs_descendants.push_descendants(table_abs_descendants);
|
abs_descendants.push_descendants(table_abs_descendants);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1889,16 +1889,16 @@ impl Legalizer {
|
||||||
|
|
||||||
/// Makes the `child` flow a new child of `parent`. Anonymous flows are automatically inserted
|
/// Makes the `child` flow a new child of `parent`. Anonymous flows are automatically inserted
|
||||||
/// to keep the tree legal.
|
/// to keep the tree legal.
|
||||||
fn add_child(&mut self, stylist: &Stylist, parent: &mut FlowRef, mut child: FlowRef) {
|
fn add_child(&mut self, context: &SharedStyleContext, parent: &mut FlowRef, mut child: FlowRef) {
|
||||||
while !self.stack.is_empty() {
|
while !self.stack.is_empty() {
|
||||||
if self.try_to_add_child(stylist, parent, &mut child) {
|
if self.try_to_add_child(context, parent, &mut child) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.flush_top_of_stack(parent)
|
self.flush_top_of_stack(parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
while !self.try_to_add_child(stylist, parent, &mut child) {
|
while !self.try_to_add_child(context, parent, &mut child) {
|
||||||
self.push_next_anonymous_flow(stylist, parent)
|
self.push_next_anonymous_flow(context, parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1915,7 +1915,7 @@ impl Legalizer {
|
||||||
/// This method attempts to create anonymous blocks in between `parent` and `child` if and only
|
/// This method attempts to create anonymous blocks in between `parent` and `child` if and only
|
||||||
/// if those blocks will only ever have `child` as their sole child. At present, this is only
|
/// if those blocks will only ever have `child` as their sole child. At present, this is only
|
||||||
/// true for anonymous block children of flex flows.
|
/// true for anonymous block children of flex flows.
|
||||||
fn try_to_add_child(&mut self, stylist: &Stylist, parent: &mut FlowRef, child: &mut FlowRef)
|
fn try_to_add_child(&mut self, context: &SharedStyleContext, parent: &mut FlowRef, child: &mut FlowRef)
|
||||||
-> bool {
|
-> bool {
|
||||||
let mut parent = self.stack.last_mut().unwrap_or(parent);
|
let mut parent = self.stack.last_mut().unwrap_or(parent);
|
||||||
let (parent_class, child_class) = (parent.class(), child.class());
|
let (parent_class, child_class) = (parent.class(), child.class());
|
||||||
|
@ -1947,7 +1947,7 @@ impl Legalizer {
|
||||||
(FlowClass::Flex, FlowClass::Inline) => {
|
(FlowClass::Flex, FlowClass::Inline) => {
|
||||||
flow::mut_base(FlowRef::deref_mut(child)).flags.insert(MARGINS_CANNOT_COLLAPSE);
|
flow::mut_base(FlowRef::deref_mut(child)).flags.insert(MARGINS_CANNOT_COLLAPSE);
|
||||||
let mut block_wrapper =
|
let mut block_wrapper =
|
||||||
Legalizer::create_anonymous_flow(stylist,
|
Legalizer::create_anonymous_flow(context,
|
||||||
parent,
|
parent,
|
||||||
&[PseudoElement::ServoAnonymousBlock],
|
&[PseudoElement::ServoAnonymousBlock],
|
||||||
SpecificFragmentInfo::Generic,
|
SpecificFragmentInfo::Generic,
|
||||||
|
@ -1999,32 +1999,32 @@ impl Legalizer {
|
||||||
|
|
||||||
/// Adds the anonymous flow that would be necessary to make an illegal child of `parent` legal
|
/// Adds the anonymous flow that would be necessary to make an illegal child of `parent` legal
|
||||||
/// to the stack.
|
/// to the stack.
|
||||||
fn push_next_anonymous_flow(&mut self, stylist: &Stylist, parent: &FlowRef) {
|
fn push_next_anonymous_flow(&mut self, context: &SharedStyleContext, parent: &FlowRef) {
|
||||||
let parent_class = self.stack.last().unwrap_or(parent).class();
|
let parent_class = self.stack.last().unwrap_or(parent).class();
|
||||||
match parent_class {
|
match parent_class {
|
||||||
FlowClass::TableRow => {
|
FlowClass::TableRow => {
|
||||||
self.push_new_anonymous_flow(stylist,
|
self.push_new_anonymous_flow(context,
|
||||||
parent,
|
parent,
|
||||||
&[PseudoElement::ServoAnonymousTableCell],
|
&[PseudoElement::ServoAnonymousTableCell],
|
||||||
SpecificFragmentInfo::TableCell,
|
SpecificFragmentInfo::TableCell,
|
||||||
TableCellFlow::from_fragment)
|
TableCellFlow::from_fragment)
|
||||||
}
|
}
|
||||||
FlowClass::Table | FlowClass::TableRowGroup => {
|
FlowClass::Table | FlowClass::TableRowGroup => {
|
||||||
self.push_new_anonymous_flow(stylist,
|
self.push_new_anonymous_flow(context,
|
||||||
parent,
|
parent,
|
||||||
&[PseudoElement::ServoAnonymousTableRow],
|
&[PseudoElement::ServoAnonymousTableRow],
|
||||||
SpecificFragmentInfo::TableRow,
|
SpecificFragmentInfo::TableRow,
|
||||||
TableRowFlow::from_fragment)
|
TableRowFlow::from_fragment)
|
||||||
}
|
}
|
||||||
FlowClass::TableWrapper => {
|
FlowClass::TableWrapper => {
|
||||||
self.push_new_anonymous_flow(stylist,
|
self.push_new_anonymous_flow(context,
|
||||||
parent,
|
parent,
|
||||||
&[PseudoElement::ServoAnonymousTable],
|
&[PseudoElement::ServoAnonymousTable],
|
||||||
SpecificFragmentInfo::Table,
|
SpecificFragmentInfo::Table,
|
||||||
TableFlow::from_fragment)
|
TableFlow::from_fragment)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.push_new_anonymous_flow(stylist,
|
self.push_new_anonymous_flow(context,
|
||||||
parent,
|
parent,
|
||||||
&[PseudoElement::ServoTableWrapper,
|
&[PseudoElement::ServoTableWrapper,
|
||||||
PseudoElement::ServoAnonymousTableWrapper],
|
PseudoElement::ServoAnonymousTableWrapper],
|
||||||
|
@ -2036,13 +2036,13 @@ impl Legalizer {
|
||||||
|
|
||||||
/// Creates an anonymous flow and pushes it onto the stack.
|
/// Creates an anonymous flow and pushes it onto the stack.
|
||||||
fn push_new_anonymous_flow<F>(&mut self,
|
fn push_new_anonymous_flow<F>(&mut self,
|
||||||
stylist: &Stylist,
|
context: &SharedStyleContext,
|
||||||
reference: &FlowRef,
|
reference: &FlowRef,
|
||||||
pseudos: &[PseudoElement],
|
pseudos: &[PseudoElement],
|
||||||
specific_fragment_info: SpecificFragmentInfo,
|
specific_fragment_info: SpecificFragmentInfo,
|
||||||
constructor: extern "Rust" fn(Fragment) -> F)
|
constructor: extern "Rust" fn(Fragment) -> F)
|
||||||
where F: Flow {
|
where F: Flow {
|
||||||
let new_flow = Legalizer::create_anonymous_flow(stylist,
|
let new_flow = Legalizer::create_anonymous_flow(context,
|
||||||
reference,
|
reference,
|
||||||
pseudos,
|
pseudos,
|
||||||
specific_fragment_info,
|
specific_fragment_info,
|
||||||
|
@ -2055,7 +2055,7 @@ impl Legalizer {
|
||||||
///
|
///
|
||||||
/// This method invokes the supplied constructor function on the given specific fragment info
|
/// This method invokes the supplied constructor function on the given specific fragment info
|
||||||
/// in order to actually generate the flow.
|
/// in order to actually generate the flow.
|
||||||
fn create_anonymous_flow<F>(stylist: &Stylist,
|
fn create_anonymous_flow<F>(context: &SharedStyleContext,
|
||||||
reference: &FlowRef,
|
reference: &FlowRef,
|
||||||
pseudos: &[PseudoElement],
|
pseudos: &[PseudoElement],
|
||||||
specific_fragment_info: SpecificFragmentInfo,
|
specific_fragment_info: SpecificFragmentInfo,
|
||||||
|
@ -2065,7 +2065,7 @@ impl Legalizer {
|
||||||
let reference_block = reference.as_block();
|
let reference_block = reference.as_block();
|
||||||
let mut new_style = reference_block.fragment.style.clone();
|
let mut new_style = reference_block.fragment.style.clone();
|
||||||
for pseudo in pseudos {
|
for pseudo in pseudos {
|
||||||
new_style = stylist.style_for_anonymous_box(pseudo, &new_style)
|
new_style = context.stylist.style_for_anonymous_box(pseudo, &new_style, &context.default_computed_values)
|
||||||
}
|
}
|
||||||
let fragment = reference_block.fragment
|
let fragment = reference_block.fragment
|
||||||
.create_similar_anonymous_fragment(new_style,
|
.create_similar_anonymous_fragment(new_style,
|
||||||
|
|
|
@ -118,6 +118,7 @@ use style::error_reporting::{ParseErrorReporter, StdoutErrorReporter};
|
||||||
use style::logical_geometry::LogicalPoint;
|
use style::logical_geometry::LogicalPoint;
|
||||||
use style::media_queries::{Device, MediaType};
|
use style::media_queries::{Device, MediaType};
|
||||||
use style::parser::ParserContextExtraData;
|
use style::parser::ParserContextExtraData;
|
||||||
|
use style::properties::ComputedValues;
|
||||||
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW};
|
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW};
|
||||||
use style::stylesheets::{Origin, Stylesheet, UserAgentStylesheets};
|
use style::stylesheets::{Origin, Stylesheet, UserAgentStylesheets};
|
||||||
use style::stylist::Stylist;
|
use style::stylist::Stylist;
|
||||||
|
@ -527,6 +528,11 @@ impl LayoutThread {
|
||||||
local_context_creation_data: Mutex::new(thread_local_style_context_creation_data),
|
local_context_creation_data: Mutex::new(thread_local_style_context_creation_data),
|
||||||
timer: self.timer.clone(),
|
timer: self.timer.clone(),
|
||||||
quirks_mode: self.quirks_mode.unwrap(),
|
quirks_mode: self.quirks_mode.unwrap(),
|
||||||
|
// FIXME(bz): This isn't really right, but it's no more wrong
|
||||||
|
// than what we used to do. See
|
||||||
|
// https://github.com/servo/servo/issues/14773 for fixing it
|
||||||
|
// properly.
|
||||||
|
default_computed_values: Arc::new(ComputedValues::initial_values().clone()),
|
||||||
},
|
},
|
||||||
image_cache_thread: Mutex::new(self.image_cache_thread.clone()),
|
image_cache_thread: Mutex::new(self.image_cache_thread.clone()),
|
||||||
image_cache_sender: Mutex::new(self.image_cache_sender.clone()),
|
image_cache_sender: Mutex::new(self.image_cache_sender.clone()),
|
||||||
|
|
|
@ -391,6 +391,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
||||||
context.stylist.precomputed_values_for_pseudo(
|
context.stylist.precomputed_values_for_pseudo(
|
||||||
&style_pseudo,
|
&style_pseudo,
|
||||||
Some(&data.styles().primary.values),
|
Some(&data.styles().primary.values),
|
||||||
|
&context.default_computed_values,
|
||||||
false);
|
false);
|
||||||
data.styles_mut().pseudos
|
data.styles_mut().pseudos
|
||||||
.insert(style_pseudo.clone(), new_style.unwrap());
|
.insert(style_pseudo.clone(), new_style.unwrap());
|
||||||
|
@ -407,7 +408,8 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
||||||
.lazily_compute_pseudo_element_style(
|
.lazily_compute_pseudo_element_style(
|
||||||
self,
|
self,
|
||||||
&style_pseudo,
|
&style_pseudo,
|
||||||
&data.styles().primary.values);
|
&data.styles().primary.values,
|
||||||
|
&context.default_computed_values);
|
||||||
data.styles_mut().pseudos
|
data.styles_mut().pseudos
|
||||||
.insert(style_pseudo.clone(), new_style.unwrap());
|
.insert(style_pseudo.clone(), new_style.unwrap());
|
||||||
}
|
}
|
||||||
|
|
|
@ -430,6 +430,7 @@ fn compute_style_for_animation_step(context: &SharedStyleContext,
|
||||||
/* is_root = */ false,
|
/* is_root = */ false,
|
||||||
iter,
|
iter,
|
||||||
previous_style,
|
previous_style,
|
||||||
|
&context.default_computed_values,
|
||||||
/* cascade_info = */ None,
|
/* cascade_info = */ None,
|
||||||
context.error_reporter.clone(),
|
context.error_reporter.clone(),
|
||||||
/* Metrics provider */ None,
|
/* Metrics provider */ None,
|
||||||
|
|
|
@ -392,6 +392,7 @@ mod bindings {
|
||||||
// for clang.
|
// for clang.
|
||||||
"nsPIDOMWindow", // <- Takes the vtable from a template parameter, and we can't
|
"nsPIDOMWindow", // <- Takes the vtable from a template parameter, and we can't
|
||||||
// generate it conditionally.
|
// generate it conditionally.
|
||||||
|
"RawGeckoPresContext", // Just passing it through.
|
||||||
"JS::Rooted",
|
"JS::Rooted",
|
||||||
"mozilla::Maybe",
|
"mozilla::Maybe",
|
||||||
"gfxSize", // <- union { struct { T width; T height; }; T components[2] };
|
"gfxSize", // <- union { struct { T width; T height; }; T components[2] };
|
||||||
|
@ -467,6 +468,7 @@ mod bindings {
|
||||||
"RawGeckoDocument",
|
"RawGeckoDocument",
|
||||||
"RawGeckoElement",
|
"RawGeckoElement",
|
||||||
"RawGeckoNode",
|
"RawGeckoNode",
|
||||||
|
"RawGeckoPresContext",
|
||||||
"ThreadSafeURIHolder",
|
"ThreadSafeURIHolder",
|
||||||
"ThreadSafePrincipalHolder",
|
"ThreadSafePrincipalHolder",
|
||||||
"ConsumeStyleBehavior",
|
"ConsumeStyleBehavior",
|
||||||
|
@ -560,6 +562,7 @@ mod bindings {
|
||||||
"RawGeckoElement",
|
"RawGeckoElement",
|
||||||
"RawGeckoDocument",
|
"RawGeckoDocument",
|
||||||
"RawServoDeclarationBlockStrong",
|
"RawServoDeclarationBlockStrong",
|
||||||
|
"RawGeckoPresContext",
|
||||||
];
|
];
|
||||||
let servo_borrow_types = [
|
let servo_borrow_types = [
|
||||||
"nsCSSValue",
|
"nsCSSValue",
|
||||||
|
|
|
@ -13,6 +13,7 @@ use error_reporting::ParseErrorReporter;
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
use matching::StyleSharingCandidateCache;
|
use matching::StyleSharingCandidateCache;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
|
use properties::ComputedValues;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
|
@ -82,6 +83,10 @@ pub struct SharedStyleContext {
|
||||||
|
|
||||||
/// The QuirksMode state which the document needs to be rendered with
|
/// The QuirksMode state which the document needs to be rendered with
|
||||||
pub quirks_mode: QuirksMode,
|
pub quirks_mode: QuirksMode,
|
||||||
|
|
||||||
|
/// The default computed values to use for elements with no rules
|
||||||
|
/// applying to them.
|
||||||
|
pub default_computed_values: Arc<ComputedValues>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A thread-local style context.
|
/// A thread-local style context.
|
||||||
|
|
|
@ -8,11 +8,13 @@ use animation::Animation;
|
||||||
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
|
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
|
||||||
use dom::OpaqueNode;
|
use dom::OpaqueNode;
|
||||||
use euclid::size::TypedSize2D;
|
use euclid::size::TypedSize2D;
|
||||||
|
use gecko_bindings::bindings::RawGeckoPresContextBorrowed;
|
||||||
use gecko_bindings::bindings::RawServoStyleSet;
|
use gecko_bindings::bindings::RawServoStyleSet;
|
||||||
use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
||||||
use media_queries::{Device, MediaType};
|
use media_queries::{Device, MediaType};
|
||||||
use num_cpus;
|
use num_cpus;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
|
use properties::ComputedValues;
|
||||||
use rayon;
|
use rayon;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -55,6 +57,9 @@ pub struct PerDocumentStyleDataImpl {
|
||||||
|
|
||||||
/// The number of threads of the work queue.
|
/// The number of threads of the work queue.
|
||||||
pub num_threads: usize,
|
pub num_threads: usize,
|
||||||
|
|
||||||
|
/// Default computed values for this document.
|
||||||
|
pub default_computed_values: Arc<ComputedValues>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The data itself is an `AtomicRefCell`, which guarantees the proper semantics
|
/// The data itself is an `AtomicRefCell`, which guarantees the proper semantics
|
||||||
|
@ -73,10 +78,15 @@ lazy_static! {
|
||||||
|
|
||||||
impl PerDocumentStyleData {
|
impl PerDocumentStyleData {
|
||||||
/// Create a dummy `PerDocumentStyleData`.
|
/// Create a dummy `PerDocumentStyleData`.
|
||||||
pub fn new() -> Self {
|
pub fn new(pres_context: RawGeckoPresContextBorrowed) -> Self {
|
||||||
// FIXME(bholley): Real window size.
|
// FIXME(bholley): Real window size.
|
||||||
let window_size: TypedSize2D<f32, ViewportPx> = TypedSize2D::new(800.0, 600.0);
|
let window_size: TypedSize2D<f32, ViewportPx> = TypedSize2D::new(800.0, 600.0);
|
||||||
let device = Device::new(MediaType::Screen, window_size);
|
let default_computed_values = ComputedValues::default_values(pres_context);
|
||||||
|
|
||||||
|
// FIXME(bz): We're going to need to either update the computed values
|
||||||
|
// in the Stylist's Device or give the Stylist a new Device when our
|
||||||
|
// default_computed_values changes.
|
||||||
|
let device = Device::new(MediaType::Screen, window_size, &default_computed_values);
|
||||||
|
|
||||||
let (new_anims_sender, new_anims_receiver) = channel();
|
let (new_anims_sender, new_anims_receiver) = channel();
|
||||||
|
|
||||||
|
@ -96,6 +106,7 @@ impl PerDocumentStyleData {
|
||||||
rayon::ThreadPool::new(configuration).ok()
|
rayon::ThreadPool::new(configuration).ok()
|
||||||
},
|
},
|
||||||
num_threads: *NUM_THREADS,
|
num_threads: *NUM_THREADS,
|
||||||
|
default_computed_values: default_computed_values,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ type nsAString_internal = nsAString;
|
||||||
use gecko_bindings::structs::RawGeckoDocument;
|
use gecko_bindings::structs::RawGeckoDocument;
|
||||||
use gecko_bindings::structs::RawGeckoElement;
|
use gecko_bindings::structs::RawGeckoElement;
|
||||||
use gecko_bindings::structs::RawGeckoNode;
|
use gecko_bindings::structs::RawGeckoNode;
|
||||||
|
use gecko_bindings::structs::RawGeckoPresContext;
|
||||||
use gecko_bindings::structs::ThreadSafeURIHolder;
|
use gecko_bindings::structs::ThreadSafeURIHolder;
|
||||||
use gecko_bindings::structs::ThreadSafePrincipalHolder;
|
use gecko_bindings::structs::ThreadSafePrincipalHolder;
|
||||||
use gecko_bindings::structs::ConsumeStyleBehavior;
|
use gecko_bindings::structs::ConsumeStyleBehavior;
|
||||||
|
@ -206,6 +207,8 @@ pub type RawGeckoDocumentBorrowed<'a> = &'a RawGeckoDocument;
|
||||||
pub type RawGeckoDocumentBorrowedOrNull<'a> = Option<&'a RawGeckoDocument>;
|
pub type RawGeckoDocumentBorrowedOrNull<'a> = Option<&'a RawGeckoDocument>;
|
||||||
pub type RawServoDeclarationBlockStrongBorrowed<'a> = &'a RawServoDeclarationBlockStrong;
|
pub type RawServoDeclarationBlockStrongBorrowed<'a> = &'a RawServoDeclarationBlockStrong;
|
||||||
pub type RawServoDeclarationBlockStrongBorrowedOrNull<'a> = Option<&'a RawServoDeclarationBlockStrong>;
|
pub type RawServoDeclarationBlockStrongBorrowedOrNull<'a> = Option<&'a RawServoDeclarationBlockStrong>;
|
||||||
|
pub type RawGeckoPresContextBorrowed<'a> = &'a RawGeckoPresContext;
|
||||||
|
pub type RawGeckoPresContextBorrowedOrNull<'a> = Option<&'a RawGeckoPresContext>;
|
||||||
pub type nsCSSValueBorrowed<'a> = &'a nsCSSValue;
|
pub type nsCSSValueBorrowed<'a> = &'a nsCSSValue;
|
||||||
pub type nsCSSValueBorrowedOrNull<'a> = Option<&'a nsCSSValue>;
|
pub type nsCSSValueBorrowedOrNull<'a> = Option<&'a nsCSSValue>;
|
||||||
pub type nsCSSValueBorrowedMut<'a> = &'a mut nsCSSValue;
|
pub type nsCSSValueBorrowedMut<'a> = &'a mut nsCSSValue;
|
||||||
|
@ -730,7 +733,9 @@ extern "C" {
|
||||||
*mut nsCSSValueSharedList);
|
*mut nsCSSValueSharedList);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleFont(ptr: *mut nsStyleFont);
|
pub fn Gecko_Construct_Default_nsStyleFont(ptr: *mut nsStyleFont,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleFont(ptr: *mut nsStyleFont,
|
pub fn Gecko_CopyConstruct_nsStyleFont(ptr: *mut nsStyleFont,
|
||||||
|
@ -740,7 +745,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleFont(ptr: *mut nsStyleFont);
|
pub fn Gecko_Destroy_nsStyleFont(ptr: *mut nsStyleFont);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleColor(ptr: *mut nsStyleColor);
|
pub fn Gecko_Construct_Default_nsStyleColor(ptr: *mut nsStyleColor,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleColor(ptr: *mut nsStyleColor,
|
pub fn Gecko_CopyConstruct_nsStyleColor(ptr: *mut nsStyleColor,
|
||||||
|
@ -750,7 +757,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleColor(ptr: *mut nsStyleColor);
|
pub fn Gecko_Destroy_nsStyleColor(ptr: *mut nsStyleColor);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleList(ptr: *mut nsStyleList);
|
pub fn Gecko_Construct_Default_nsStyleList(ptr: *mut nsStyleList,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleList(ptr: *mut nsStyleList,
|
pub fn Gecko_CopyConstruct_nsStyleList(ptr: *mut nsStyleList,
|
||||||
|
@ -760,7 +769,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleList(ptr: *mut nsStyleList);
|
pub fn Gecko_Destroy_nsStyleList(ptr: *mut nsStyleList);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleText(ptr: *mut nsStyleText);
|
pub fn Gecko_Construct_Default_nsStyleText(ptr: *mut nsStyleText,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleText(ptr: *mut nsStyleText,
|
pub fn Gecko_CopyConstruct_nsStyleText(ptr: *mut nsStyleText,
|
||||||
|
@ -770,7 +781,10 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleText(ptr: *mut nsStyleText);
|
pub fn Gecko_Destroy_nsStyleText(ptr: *mut nsStyleText);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleVisibility(ptr: *mut nsStyleVisibility);
|
pub fn Gecko_Construct_Default_nsStyleVisibility(ptr:
|
||||||
|
*mut nsStyleVisibility,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleVisibility(ptr: *mut nsStyleVisibility,
|
pub fn Gecko_CopyConstruct_nsStyleVisibility(ptr: *mut nsStyleVisibility,
|
||||||
|
@ -781,8 +795,10 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleVisibility(ptr: *mut nsStyleVisibility);
|
pub fn Gecko_Destroy_nsStyleVisibility(ptr: *mut nsStyleVisibility);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleUserInterface(ptr:
|
pub fn Gecko_Construct_Default_nsStyleUserInterface(ptr:
|
||||||
*mut nsStyleUserInterface);
|
*mut nsStyleUserInterface,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleUserInterface(ptr:
|
pub fn Gecko_CopyConstruct_nsStyleUserInterface(ptr:
|
||||||
|
@ -794,7 +810,10 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleUserInterface(ptr: *mut nsStyleUserInterface);
|
pub fn Gecko_Destroy_nsStyleUserInterface(ptr: *mut nsStyleUserInterface);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleTableBorder(ptr: *mut nsStyleTableBorder);
|
pub fn Gecko_Construct_Default_nsStyleTableBorder(ptr:
|
||||||
|
*mut nsStyleTableBorder,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleTableBorder(ptr:
|
pub fn Gecko_CopyConstruct_nsStyleTableBorder(ptr:
|
||||||
|
@ -806,7 +825,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleTableBorder(ptr: *mut nsStyleTableBorder);
|
pub fn Gecko_Destroy_nsStyleTableBorder(ptr: *mut nsStyleTableBorder);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleSVG(ptr: *mut nsStyleSVG);
|
pub fn Gecko_Construct_Default_nsStyleSVG(ptr: *mut nsStyleSVG,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleSVG(ptr: *mut nsStyleSVG,
|
pub fn Gecko_CopyConstruct_nsStyleSVG(ptr: *mut nsStyleSVG,
|
||||||
|
@ -816,7 +837,10 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleSVG(ptr: *mut nsStyleSVG);
|
pub fn Gecko_Destroy_nsStyleSVG(ptr: *mut nsStyleSVG);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleVariables(ptr: *mut nsStyleVariables);
|
pub fn Gecko_Construct_Default_nsStyleVariables(ptr:
|
||||||
|
*mut nsStyleVariables,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleVariables(ptr: *mut nsStyleVariables,
|
pub fn Gecko_CopyConstruct_nsStyleVariables(ptr: *mut nsStyleVariables,
|
||||||
|
@ -827,7 +851,10 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleVariables(ptr: *mut nsStyleVariables);
|
pub fn Gecko_Destroy_nsStyleVariables(ptr: *mut nsStyleVariables);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleBackground(ptr: *mut nsStyleBackground);
|
pub fn Gecko_Construct_Default_nsStyleBackground(ptr:
|
||||||
|
*mut nsStyleBackground,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleBackground(ptr: *mut nsStyleBackground,
|
pub fn Gecko_CopyConstruct_nsStyleBackground(ptr: *mut nsStyleBackground,
|
||||||
|
@ -838,7 +865,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleBackground(ptr: *mut nsStyleBackground);
|
pub fn Gecko_Destroy_nsStyleBackground(ptr: *mut nsStyleBackground);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStylePosition(ptr: *mut nsStylePosition);
|
pub fn Gecko_Construct_Default_nsStylePosition(ptr: *mut nsStylePosition,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStylePosition(ptr: *mut nsStylePosition,
|
pub fn Gecko_CopyConstruct_nsStylePosition(ptr: *mut nsStylePosition,
|
||||||
|
@ -848,7 +877,10 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStylePosition(ptr: *mut nsStylePosition);
|
pub fn Gecko_Destroy_nsStylePosition(ptr: *mut nsStylePosition);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleTextReset(ptr: *mut nsStyleTextReset);
|
pub fn Gecko_Construct_Default_nsStyleTextReset(ptr:
|
||||||
|
*mut nsStyleTextReset,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleTextReset(ptr: *mut nsStyleTextReset,
|
pub fn Gecko_CopyConstruct_nsStyleTextReset(ptr: *mut nsStyleTextReset,
|
||||||
|
@ -859,7 +891,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleTextReset(ptr: *mut nsStyleTextReset);
|
pub fn Gecko_Destroy_nsStyleTextReset(ptr: *mut nsStyleTextReset);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleDisplay(ptr: *mut nsStyleDisplay);
|
pub fn Gecko_Construct_Default_nsStyleDisplay(ptr: *mut nsStyleDisplay,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleDisplay(ptr: *mut nsStyleDisplay,
|
pub fn Gecko_CopyConstruct_nsStyleDisplay(ptr: *mut nsStyleDisplay,
|
||||||
|
@ -869,7 +903,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleDisplay(ptr: *mut nsStyleDisplay);
|
pub fn Gecko_Destroy_nsStyleDisplay(ptr: *mut nsStyleDisplay);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleContent(ptr: *mut nsStyleContent);
|
pub fn Gecko_Construct_Default_nsStyleContent(ptr: *mut nsStyleContent,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleContent(ptr: *mut nsStyleContent,
|
pub fn Gecko_CopyConstruct_nsStyleContent(ptr: *mut nsStyleContent,
|
||||||
|
@ -879,7 +915,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleContent(ptr: *mut nsStyleContent);
|
pub fn Gecko_Destroy_nsStyleContent(ptr: *mut nsStyleContent);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleUIReset(ptr: *mut nsStyleUIReset);
|
pub fn Gecko_Construct_Default_nsStyleUIReset(ptr: *mut nsStyleUIReset,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleUIReset(ptr: *mut nsStyleUIReset,
|
pub fn Gecko_CopyConstruct_nsStyleUIReset(ptr: *mut nsStyleUIReset,
|
||||||
|
@ -889,7 +927,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleUIReset(ptr: *mut nsStyleUIReset);
|
pub fn Gecko_Destroy_nsStyleUIReset(ptr: *mut nsStyleUIReset);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleTable(ptr: *mut nsStyleTable);
|
pub fn Gecko_Construct_Default_nsStyleTable(ptr: *mut nsStyleTable,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleTable(ptr: *mut nsStyleTable,
|
pub fn Gecko_CopyConstruct_nsStyleTable(ptr: *mut nsStyleTable,
|
||||||
|
@ -899,7 +939,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleTable(ptr: *mut nsStyleTable);
|
pub fn Gecko_Destroy_nsStyleTable(ptr: *mut nsStyleTable);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleMargin(ptr: *mut nsStyleMargin);
|
pub fn Gecko_Construct_Default_nsStyleMargin(ptr: *mut nsStyleMargin,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleMargin(ptr: *mut nsStyleMargin,
|
pub fn Gecko_CopyConstruct_nsStyleMargin(ptr: *mut nsStyleMargin,
|
||||||
|
@ -909,7 +951,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleMargin(ptr: *mut nsStyleMargin);
|
pub fn Gecko_Destroy_nsStyleMargin(ptr: *mut nsStyleMargin);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStylePadding(ptr: *mut nsStylePadding);
|
pub fn Gecko_Construct_Default_nsStylePadding(ptr: *mut nsStylePadding,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStylePadding(ptr: *mut nsStylePadding,
|
pub fn Gecko_CopyConstruct_nsStylePadding(ptr: *mut nsStylePadding,
|
||||||
|
@ -919,7 +963,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStylePadding(ptr: *mut nsStylePadding);
|
pub fn Gecko_Destroy_nsStylePadding(ptr: *mut nsStylePadding);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleBorder(ptr: *mut nsStyleBorder);
|
pub fn Gecko_Construct_Default_nsStyleBorder(ptr: *mut nsStyleBorder,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleBorder(ptr: *mut nsStyleBorder,
|
pub fn Gecko_CopyConstruct_nsStyleBorder(ptr: *mut nsStyleBorder,
|
||||||
|
@ -929,7 +975,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleBorder(ptr: *mut nsStyleBorder);
|
pub fn Gecko_Destroy_nsStyleBorder(ptr: *mut nsStyleBorder);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleOutline(ptr: *mut nsStyleOutline);
|
pub fn Gecko_Construct_Default_nsStyleOutline(ptr: *mut nsStyleOutline,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleOutline(ptr: *mut nsStyleOutline,
|
pub fn Gecko_CopyConstruct_nsStyleOutline(ptr: *mut nsStyleOutline,
|
||||||
|
@ -939,7 +987,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleOutline(ptr: *mut nsStyleOutline);
|
pub fn Gecko_Destroy_nsStyleOutline(ptr: *mut nsStyleOutline);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleXUL(ptr: *mut nsStyleXUL);
|
pub fn Gecko_Construct_Default_nsStyleXUL(ptr: *mut nsStyleXUL,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleXUL(ptr: *mut nsStyleXUL,
|
pub fn Gecko_CopyConstruct_nsStyleXUL(ptr: *mut nsStyleXUL,
|
||||||
|
@ -949,7 +999,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleXUL(ptr: *mut nsStyleXUL);
|
pub fn Gecko_Destroy_nsStyleXUL(ptr: *mut nsStyleXUL);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleSVGReset(ptr: *mut nsStyleSVGReset);
|
pub fn Gecko_Construct_Default_nsStyleSVGReset(ptr: *mut nsStyleSVGReset,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleSVGReset(ptr: *mut nsStyleSVGReset,
|
pub fn Gecko_CopyConstruct_nsStyleSVGReset(ptr: *mut nsStyleSVGReset,
|
||||||
|
@ -959,7 +1011,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleSVGReset(ptr: *mut nsStyleSVGReset);
|
pub fn Gecko_Destroy_nsStyleSVGReset(ptr: *mut nsStyleSVGReset);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleColumn(ptr: *mut nsStyleColumn);
|
pub fn Gecko_Construct_Default_nsStyleColumn(ptr: *mut nsStyleColumn,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleColumn(ptr: *mut nsStyleColumn,
|
pub fn Gecko_CopyConstruct_nsStyleColumn(ptr: *mut nsStyleColumn,
|
||||||
|
@ -969,7 +1023,9 @@ extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleColumn(ptr: *mut nsStyleColumn);
|
pub fn Gecko_Destroy_nsStyleColumn(ptr: *mut nsStyleColumn);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Construct_nsStyleEffects(ptr: *mut nsStyleEffects);
|
pub fn Gecko_Construct_Default_nsStyleEffects(ptr: *mut nsStyleEffects,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyConstruct_nsStyleEffects(ptr: *mut nsStyleEffects,
|
pub fn Gecko_CopyConstruct_nsStyleEffects(ptr: *mut nsStyleEffects,
|
||||||
|
@ -978,6 +1034,9 @@ extern "C" {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_Destroy_nsStyleEffects(ptr: *mut nsStyleEffects);
|
pub fn Gecko_Destroy_nsStyleEffects(ptr: *mut nsStyleEffects);
|
||||||
}
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Gecko_Construct_nsStyleVariables(ptr: *mut nsStyleVariables);
|
||||||
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_Element_ClearData(node: RawGeckoElementBorrowed);
|
pub fn Servo_Element_ClearData(node: RawGeckoElementBorrowed);
|
||||||
}
|
}
|
||||||
|
@ -1028,7 +1087,14 @@ extern "C" {
|
||||||
-> ServoCssRulesStrong;
|
-> ServoCssRulesStrong;
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_StyleSet_Init() -> RawServoStyleSetOwned;
|
pub fn Servo_StyleSet_Init(pres_context: RawGeckoPresContextBorrowed)
|
||||||
|
-> RawServoStyleSetOwned;
|
||||||
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Servo_StyleSet_RecomputeDefaultStyles(set:
|
||||||
|
RawServoStyleSetBorrowed,
|
||||||
|
pres_context:
|
||||||
|
RawGeckoPresContextBorrowed);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_StyleSet_AppendStyleSheet(set: RawServoStyleSetBorrowed,
|
pub fn Servo_StyleSet_AppendStyleSheet(set: RawServoStyleSetBorrowed,
|
||||||
|
@ -1112,7 +1178,8 @@ extern "C" {
|
||||||
-> RawServoDeclarationBlockStrong;
|
-> RawServoDeclarationBlockStrong;
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_RestyleWithAddedDeclaration(declarations:
|
pub fn Servo_RestyleWithAddedDeclaration(set: RawServoStyleSetBorrowed,
|
||||||
|
declarations:
|
||||||
RawServoDeclarationBlockBorrowed,
|
RawServoDeclarationBlockBorrowed,
|
||||||
previous_style:
|
previous_style:
|
||||||
ServoComputedValuesBorrowed)
|
ServoComputedValuesBorrowed)
|
||||||
|
@ -1225,7 +1292,8 @@ extern "C" {
|
||||||
-> ServoComputedValuesStrong;
|
-> ServoComputedValuesStrong;
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_ComputedValues_Inherit(parent_style:
|
pub fn Servo_ComputedValues_Inherit(set: RawServoStyleSetBorrowed,
|
||||||
|
parent_style:
|
||||||
ServoComputedValuesBorrowedOrNull)
|
ServoComputedValuesBorrowedOrNull)
|
||||||
-> ServoComputedValuesStrong;
|
-> ServoComputedValuesStrong;
|
||||||
}
|
}
|
||||||
|
@ -1250,6 +1318,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
pub fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
||||||
|
set: RawServoStyleSetBorrowed,
|
||||||
consume: ConsumeStyleBehavior)
|
consume: ConsumeStyleBehavior)
|
||||||
-> ServoComputedValuesStrong;
|
-> ServoComputedValuesStrong;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11613,12 +11613,14 @@ pub mod root {
|
||||||
pub type RawGeckoNode = root::nsINode;
|
pub type RawGeckoNode = root::nsINode;
|
||||||
pub type RawGeckoElement = root::mozilla::dom::Element;
|
pub type RawGeckoElement = root::mozilla::dom::Element;
|
||||||
pub type RawGeckoDocument = root::nsIDocument;
|
pub type RawGeckoDocument = root::nsIDocument;
|
||||||
|
pub type RawGeckoPresContext = [u64; 156usize];
|
||||||
pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode;
|
pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode;
|
||||||
pub type RawGeckoNodeBorrowedOrNull = *const root::RawGeckoNode;
|
pub type RawGeckoNodeBorrowedOrNull = *const root::RawGeckoNode;
|
||||||
pub type RawGeckoElementBorrowed = *const root::RawGeckoElement;
|
pub type RawGeckoElementBorrowed = *const root::RawGeckoElement;
|
||||||
pub type RawGeckoElementBorrowedOrNull = *const root::RawGeckoElement;
|
pub type RawGeckoElementBorrowedOrNull = *const root::RawGeckoElement;
|
||||||
pub type RawGeckoDocumentBorrowed = *const root::RawGeckoDocument;
|
pub type RawGeckoDocumentBorrowed = *const root::RawGeckoDocument;
|
||||||
pub type RawGeckoDocumentBorrowedOrNull = *const root::RawGeckoDocument;
|
pub type RawGeckoDocumentBorrowedOrNull = *const root::RawGeckoDocument;
|
||||||
|
pub type RawGeckoPresContextBorrowed = *const [u64; 156usize];
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum nsCSSTokenSerializationType {
|
pub enum nsCSSTokenSerializationType {
|
||||||
|
|
|
@ -11540,12 +11540,14 @@ pub mod root {
|
||||||
pub type RawGeckoNode = root::nsINode;
|
pub type RawGeckoNode = root::nsINode;
|
||||||
pub type RawGeckoElement = root::mozilla::dom::Element;
|
pub type RawGeckoElement = root::mozilla::dom::Element;
|
||||||
pub type RawGeckoDocument = root::nsIDocument;
|
pub type RawGeckoDocument = root::nsIDocument;
|
||||||
|
pub type RawGeckoPresContext = [u64; 152usize];
|
||||||
pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode;
|
pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode;
|
||||||
pub type RawGeckoNodeBorrowedOrNull = *const root::RawGeckoNode;
|
pub type RawGeckoNodeBorrowedOrNull = *const root::RawGeckoNode;
|
||||||
pub type RawGeckoElementBorrowed = *const root::RawGeckoElement;
|
pub type RawGeckoElementBorrowed = *const root::RawGeckoElement;
|
||||||
pub type RawGeckoElementBorrowedOrNull = *const root::RawGeckoElement;
|
pub type RawGeckoElementBorrowedOrNull = *const root::RawGeckoElement;
|
||||||
pub type RawGeckoDocumentBorrowed = *const root::RawGeckoDocument;
|
pub type RawGeckoDocumentBorrowed = *const root::RawGeckoDocument;
|
||||||
pub type RawGeckoDocumentBorrowedOrNull = *const root::RawGeckoDocument;
|
pub type RawGeckoDocumentBorrowedOrNull = *const root::RawGeckoDocument;
|
||||||
|
pub type RawGeckoPresContextBorrowed = *const [u64; 152usize];
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum nsCSSTokenSerializationType {
|
pub enum nsCSSTokenSerializationType {
|
||||||
|
|
|
@ -470,6 +470,7 @@ trait PrivateMatchMethods: TElement {
|
||||||
cascade(shared_context.viewport_size,
|
cascade(shared_context.viewport_size,
|
||||||
rule_node,
|
rule_node,
|
||||||
Some(&***parent_style),
|
Some(&***parent_style),
|
||||||
|
&shared_context.default_computed_values,
|
||||||
Some(&mut cascade_info),
|
Some(&mut cascade_info),
|
||||||
shared_context.error_reporter.clone(),
|
shared_context.error_reporter.clone(),
|
||||||
cascade_flags)
|
cascade_flags)
|
||||||
|
@ -478,6 +479,7 @@ trait PrivateMatchMethods: TElement {
|
||||||
cascade(shared_context.viewport_size,
|
cascade(shared_context.viewport_size,
|
||||||
rule_node,
|
rule_node,
|
||||||
None,
|
None,
|
||||||
|
&shared_context.default_computed_values,
|
||||||
Some(&mut cascade_info),
|
Some(&mut cascade_info),
|
||||||
shared_context.error_reporter.clone(),
|
shared_context.error_reporter.clone(),
|
||||||
cascade_flags)
|
cascade_flags)
|
||||||
|
|
|
@ -10,14 +10,16 @@ use Atom;
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use cssparser::{Delimiter, Parser, Token};
|
use cssparser::{Delimiter, Parser, Token};
|
||||||
use euclid::size::{Size2D, TypedSize2D};
|
use euclid::size::{Size2D, TypedSize2D};
|
||||||
|
use properties::ComputedValues;
|
||||||
use serialize_comma_separated_list;
|
use serialize_comma_separated_list;
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
use std::sync::Arc;
|
||||||
use style_traits::{ToCss, ViewportPx};
|
use style_traits::{ToCss, ViewportPx};
|
||||||
use values::computed::{self, ToComputedValue};
|
use values::computed::{self, ToComputedValue};
|
||||||
use values::specified;
|
use values::specified;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub struct MediaList {
|
pub struct MediaList {
|
||||||
|
@ -47,10 +49,18 @@ pub enum Range<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Range<specified::Length> {
|
impl Range<specified::Length> {
|
||||||
fn to_computed_range(&self, viewport_size: Size2D<Au>) -> Range<Au> {
|
fn to_computed_range(&self, viewport_size: Size2D<Au>, default_values: &ComputedValues) -> Range<Au> {
|
||||||
// http://dev.w3.org/csswg/mediaqueries3/#units
|
// http://dev.w3.org/csswg/mediaqueries3/#units
|
||||||
// em units are relative to the initial font-size.
|
// em units are relative to the initial font-size.
|
||||||
let context = computed::Context::initial(viewport_size, false);
|
let context = computed::Context {
|
||||||
|
is_root_element: false,
|
||||||
|
viewport_size: viewport_size,
|
||||||
|
inherited_style: default_values,
|
||||||
|
// This cloning business is kind of dumb.... It's because Context
|
||||||
|
// insists on having an actual ComputedValues inside itself.
|
||||||
|
style: default_values.clone(),
|
||||||
|
font_metrics_provider: None
|
||||||
|
};
|
||||||
|
|
||||||
match *self {
|
match *self {
|
||||||
Range::Min(ref width) => Range::Min(width.to_computed_value(&context)),
|
Range::Min(ref width) => Range::Min(width.to_computed_value(&context)),
|
||||||
|
@ -225,9 +235,12 @@ impl MediaType {
|
||||||
pub struct Device {
|
pub struct Device {
|
||||||
pub media_type: MediaType,
|
pub media_type: MediaType,
|
||||||
pub viewport_size: TypedSize2D<f32, ViewportPx>,
|
pub viewport_size: TypedSize2D<f32, ViewportPx>,
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
pub default_values: Arc<ComputedValues>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Device {
|
impl Device {
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
pub fn new(media_type: MediaType, viewport_size: TypedSize2D<f32, ViewportPx>) -> Device {
|
pub fn new(media_type: MediaType, viewport_size: TypedSize2D<f32, ViewportPx>) -> Device {
|
||||||
Device {
|
Device {
|
||||||
media_type: media_type,
|
media_type: media_type,
|
||||||
|
@ -235,6 +248,26 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
pub fn default_values(&self) -> &ComputedValues {
|
||||||
|
ComputedValues::initial_values()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
pub fn new(media_type: MediaType, viewport_size: TypedSize2D<f32, ViewportPx>,
|
||||||
|
default_values: &Arc<ComputedValues>) -> Device {
|
||||||
|
Device {
|
||||||
|
media_type: media_type,
|
||||||
|
viewport_size: viewport_size,
|
||||||
|
default_values: default_values.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
pub fn default_values(&self) -> &ComputedValues {
|
||||||
|
&*self.default_values
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn au_viewport_size(&self) -> Size2D<Au> {
|
pub fn au_viewport_size(&self) -> Size2D<Au> {
|
||||||
Size2D::new(Au::from_f32_px(self.viewport_size.width),
|
Size2D::new(Au::from_f32_px(self.viewport_size.width),
|
||||||
|
@ -337,7 +370,7 @@ impl MediaList {
|
||||||
let query_match = media_match && mq.expressions.iter().all(|expression| {
|
let query_match = media_match && mq.expressions.iter().all(|expression| {
|
||||||
match *expression {
|
match *expression {
|
||||||
Expression::Width(ref value) =>
|
Expression::Width(ref value) =>
|
||||||
value.to_computed_range(viewport_size).evaluate(viewport_size.width),
|
value.to_computed_range(viewport_size, device.default_values()).evaluate(viewport_size.width),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ use custom_properties::ComputedValuesMap;
|
||||||
use gecko_bindings::bindings;
|
use gecko_bindings::bindings;
|
||||||
% for style_struct in data.style_structs:
|
% for style_struct in data.style_structs:
|
||||||
use gecko_bindings::structs::${style_struct.gecko_ffi_name};
|
use gecko_bindings::structs::${style_struct.gecko_ffi_name};
|
||||||
use gecko_bindings::bindings::Gecko_Construct_${style_struct.gecko_ffi_name};
|
use gecko_bindings::bindings::Gecko_Construct_Default_${style_struct.gecko_ffi_name};
|
||||||
use gecko_bindings::bindings::Gecko_CopyConstruct_${style_struct.gecko_ffi_name};
|
use gecko_bindings::bindings::Gecko_CopyConstruct_${style_struct.gecko_ffi_name};
|
||||||
use gecko_bindings::bindings::Gecko_Destroy_${style_struct.gecko_ffi_name};
|
use gecko_bindings::bindings::Gecko_Destroy_${style_struct.gecko_ffi_name};
|
||||||
% endfor
|
% endfor
|
||||||
|
@ -40,6 +40,7 @@ use gecko_bindings::bindings::Gecko_SetMozBinding;
|
||||||
use gecko_bindings::bindings::Gecko_SetNullImageValue;
|
use gecko_bindings::bindings::Gecko_SetNullImageValue;
|
||||||
use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
||||||
use gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom};
|
use gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom};
|
||||||
|
use gecko_bindings::bindings::RawGeckoPresContextBorrowed;
|
||||||
use gecko_bindings::structs;
|
use gecko_bindings::structs;
|
||||||
use gecko_bindings::structs::nsStyleVariables;
|
use gecko_bindings::structs::nsStyleVariables;
|
||||||
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
|
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
|
||||||
|
@ -53,7 +54,6 @@ use properties::longhands;
|
||||||
use std::fmt::{self, Debug};
|
use std::fmt::{self, Debug};
|
||||||
use std::mem::{transmute, zeroed};
|
use std::mem::{transmute, zeroed};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ pub struct ComputedValues {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ComputedValues {
|
impl ComputedValues {
|
||||||
pub fn inherit_from(parent: &Arc<Self>) -> Arc<Self> {
|
pub fn inherit_from(parent: &Arc<Self>, default: &Arc<Self>) -> Arc<Self> {
|
||||||
Arc::new(ComputedValues {
|
Arc::new(ComputedValues {
|
||||||
custom_properties: parent.custom_properties.clone(),
|
custom_properties: parent.custom_properties.clone(),
|
||||||
shareable: parent.shareable,
|
shareable: parent.shareable,
|
||||||
|
@ -86,7 +86,7 @@ impl ComputedValues {
|
||||||
% if style_struct.inherited:
|
% if style_struct.inherited:
|
||||||
${style_struct.ident}: parent.${style_struct.ident}.clone(),
|
${style_struct.ident}: parent.${style_struct.ident}.clone(),
|
||||||
% else:
|
% else:
|
||||||
${style_struct.ident}: Self::initial_values().${style_struct.ident}.clone(),
|
${style_struct.ident}: default.${style_struct.ident}.clone(),
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
})
|
})
|
||||||
|
@ -111,37 +111,16 @@ impl ComputedValues {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn style_for_child_text_node(parent: &Arc<Self>) -> Arc<Self> {
|
pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> {
|
||||||
// Gecko expects text nodes to be styled as if they were elements that
|
Arc::new(ComputedValues {
|
||||||
// matched no rules (that is, inherited style structs are inherited and
|
|
||||||
// non-inherited style structs are set to their initial values).
|
|
||||||
ComputedValues::inherit_from(parent)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn initial_values() -> &'static Self {
|
|
||||||
unsafe {
|
|
||||||
debug_assert!(!raw_initial_values().is_null());
|
|
||||||
&*raw_initial_values()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe fn initialize() {
|
|
||||||
debug_assert!(raw_initial_values().is_null());
|
|
||||||
set_raw_initial_values(Box::into_raw(Box::new(ComputedValues {
|
|
||||||
% for style_struct in data.style_structs:
|
|
||||||
${style_struct.ident}: style_structs::${style_struct.name}::initial(),
|
|
||||||
% endfor
|
|
||||||
custom_properties: None,
|
custom_properties: None,
|
||||||
shareable: true,
|
shareable: true,
|
||||||
writing_mode: WritingMode::empty(),
|
writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious
|
||||||
root_font_size: longhands::font_size::get_initial_value(),
|
root_font_size: longhands::font_size::get_initial_value(), // FIXME(bz): Also seems dubious?
|
||||||
})));
|
% for style_struct in data.style_structs:
|
||||||
}
|
${style_struct.ident}: style_structs::${style_struct.name}::default(pres_context),
|
||||||
|
% endfor
|
||||||
pub unsafe fn shutdown() {
|
})
|
||||||
debug_assert!(!raw_initial_values().is_null());
|
|
||||||
let _ = Box::from_raw(raw_initial_values());
|
|
||||||
set_raw_initial_values(ptr::null_mut());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
% for style_struct in data.style_structs:
|
% for style_struct in data.style_structs:
|
||||||
|
@ -415,10 +394,11 @@ def set_gecko_property(ffi_name, expr):
|
||||||
<%def name="impl_style_struct(style_struct)">
|
<%def name="impl_style_struct(style_struct)">
|
||||||
impl ${style_struct.gecko_struct_name} {
|
impl ${style_struct.gecko_struct_name} {
|
||||||
#[allow(dead_code, unused_variables)]
|
#[allow(dead_code, unused_variables)]
|
||||||
pub fn initial() -> Arc<Self> {
|
pub fn default(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> {
|
||||||
let mut result = Arc::new(${style_struct.gecko_struct_name} { gecko: unsafe { zeroed() } });
|
let mut result = Arc::new(${style_struct.gecko_struct_name} { gecko: unsafe { zeroed() } });
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_Construct_${style_struct.gecko_ffi_name}(&mut Arc::get_mut(&mut result).unwrap().gecko);
|
Gecko_Construct_Default_${style_struct.gecko_ffi_name}(&mut Arc::get_mut(&mut result).unwrap().gecko,
|
||||||
|
pres_context);
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
@ -2646,13 +2626,3 @@ pub unsafe extern "C" fn Servo_GetStyleVariables(_cv: ServoComputedValuesBorrowe
|
||||||
&*EMPTY_VARIABLES_STRUCT
|
&*EMPTY_VARIABLES_STRUCT
|
||||||
}
|
}
|
||||||
|
|
||||||
// To avoid UB, we store the initial values as a atomic. It would be nice to
|
|
||||||
// store them as AtomicPtr, but we can't have static AtomicPtr without const
|
|
||||||
// fns, which aren't in stable Rust.
|
|
||||||
static INITIAL_VALUES_STORAGE: AtomicUsize = ATOMIC_USIZE_INIT;
|
|
||||||
unsafe fn raw_initial_values() -> *mut ComputedValues {
|
|
||||||
INITIAL_VALUES_STORAGE.load(Ordering::Relaxed) as *mut ComputedValues
|
|
||||||
}
|
|
||||||
unsafe fn set_raw_initial_values(v: *mut ComputedValues) {
|
|
||||||
INITIAL_VALUES_STORAGE.store(v as usize, Ordering::Relaxed);
|
|
||||||
}
|
|
||||||
|
|
|
@ -210,6 +210,7 @@
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
pub fn cascade_property(declaration: &PropertyDeclaration,
|
pub fn cascade_property(declaration: &PropertyDeclaration,
|
||||||
inherited_style: &ComputedValues,
|
inherited_style: &ComputedValues,
|
||||||
|
default_style: &Arc<ComputedValues>,
|
||||||
context: &mut computed::Context,
|
context: &mut computed::Context,
|
||||||
seen: &mut PropertyBitField,
|
seen: &mut PropertyBitField,
|
||||||
cacheable: &mut bool,
|
cacheable: &mut bool,
|
||||||
|
@ -260,7 +261,7 @@
|
||||||
DeclaredValue::Initial => {
|
DeclaredValue::Initial => {
|
||||||
// We assume that it's faster to use copy_*_from rather than
|
// We assume that it's faster to use copy_*_from rather than
|
||||||
// set_*(get_initial_value());
|
// set_*(get_initial_value());
|
||||||
let initial_struct = ComputedValues::initial_values()
|
let initial_struct = default_style
|
||||||
.get_${data.current_style_struct.name_lower}();
|
.get_${data.current_style_struct.name_lower}();
|
||||||
context.mutate_style().mutate_${data.current_style_struct.name_lower}()
|
context.mutate_style().mutate_${data.current_style_struct.name_lower}()
|
||||||
.copy_${property.ident}_from(initial_struct ${maybe_wm});
|
.copy_${property.ident}_from(initial_struct ${maybe_wm});
|
||||||
|
|
|
@ -1658,6 +1658,7 @@ mod lazy_static_module {
|
||||||
pub type CascadePropertyFn =
|
pub type CascadePropertyFn =
|
||||||
extern "Rust" fn(declaration: &PropertyDeclaration,
|
extern "Rust" fn(declaration: &PropertyDeclaration,
|
||||||
inherited_style: &ComputedValues,
|
inherited_style: &ComputedValues,
|
||||||
|
default_style: &Arc<ComputedValues>,
|
||||||
context: &mut computed::Context,
|
context: &mut computed::Context,
|
||||||
seen: &mut PropertyBitField,
|
seen: &mut PropertyBitField,
|
||||||
cacheable: &mut bool,
|
cacheable: &mut bool,
|
||||||
|
@ -1704,13 +1705,14 @@ bitflags! {
|
||||||
pub fn cascade(viewport_size: Size2D<Au>,
|
pub fn cascade(viewport_size: Size2D<Au>,
|
||||||
rule_node: &StrongRuleNode,
|
rule_node: &StrongRuleNode,
|
||||||
parent_style: Option<<&ComputedValues>,
|
parent_style: Option<<&ComputedValues>,
|
||||||
|
default_style: &Arc<ComputedValues>,
|
||||||
cascade_info: Option<<&mut CascadeInfo>,
|
cascade_info: Option<<&mut CascadeInfo>,
|
||||||
error_reporter: StdBox<ParseErrorReporter + Send>,
|
error_reporter: StdBox<ParseErrorReporter + Send>,
|
||||||
flags: CascadeFlags)
|
flags: CascadeFlags)
|
||||||
-> ComputedValues {
|
-> ComputedValues {
|
||||||
let (is_root_element, inherited_style) = match parent_style {
|
let (is_root_element, inherited_style) = match parent_style {
|
||||||
Some(parent_style) => (false, parent_style),
|
Some(parent_style) => (false, parent_style),
|
||||||
None => (true, ComputedValues::initial_values()),
|
None => (true, &**default_style),
|
||||||
};
|
};
|
||||||
// Hold locks until after the apply_declarations() call returns.
|
// Hold locks until after the apply_declarations() call returns.
|
||||||
// Use filter_map because the root node has no style source.
|
// Use filter_map because the root node has no style source.
|
||||||
|
@ -1735,6 +1737,7 @@ pub fn cascade(viewport_size: Size2D<Au>,
|
||||||
is_root_element,
|
is_root_element,
|
||||||
iter_declarations,
|
iter_declarations,
|
||||||
inherited_style,
|
inherited_style,
|
||||||
|
default_style,
|
||||||
cascade_info,
|
cascade_info,
|
||||||
error_reporter,
|
error_reporter,
|
||||||
None,
|
None,
|
||||||
|
@ -1747,6 +1750,7 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
||||||
is_root_element: bool,
|
is_root_element: bool,
|
||||||
iter_declarations: F,
|
iter_declarations: F,
|
||||||
inherited_style: &ComputedValues,
|
inherited_style: &ComputedValues,
|
||||||
|
default_style: &Arc<ComputedValues>,
|
||||||
mut cascade_info: Option<<&mut CascadeInfo>,
|
mut cascade_info: Option<<&mut CascadeInfo>,
|
||||||
mut error_reporter: StdBox<ParseErrorReporter + Send>,
|
mut error_reporter: StdBox<ParseErrorReporter + Send>,
|
||||||
font_metrics_provider: Option<<&FontMetricsProvider>,
|
font_metrics_provider: Option<<&FontMetricsProvider>,
|
||||||
|
@ -1773,8 +1777,6 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
||||||
::custom_properties::finish_cascade(
|
::custom_properties::finish_cascade(
|
||||||
custom_properties, &inherited_custom_properties);
|
custom_properties, &inherited_custom_properties);
|
||||||
|
|
||||||
let initial_values = ComputedValues::initial_values();
|
|
||||||
|
|
||||||
let starting_style = if !flags.contains(INHERIT_ALL) {
|
let starting_style = if !flags.contains(INHERIT_ALL) {
|
||||||
ComputedValues::new(custom_properties,
|
ComputedValues::new(custom_properties,
|
||||||
flags.contains(SHAREABLE),
|
flags.contains(SHAREABLE),
|
||||||
|
@ -1784,7 +1786,7 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
||||||
% if style_struct.inherited:
|
% if style_struct.inherited:
|
||||||
inherited_style.clone_${style_struct.name_lower}(),
|
inherited_style.clone_${style_struct.name_lower}(),
|
||||||
% else:
|
% else:
|
||||||
initial_values.clone_${style_struct.name_lower}(),
|
default_style.clone_${style_struct.name_lower}(),
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
)
|
)
|
||||||
|
@ -1864,6 +1866,7 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
||||||
let discriminant = longhand_id as usize;
|
let discriminant = longhand_id as usize;
|
||||||
(CASCADE_PROPERTY[discriminant])(declaration,
|
(CASCADE_PROPERTY[discriminant])(declaration,
|
||||||
inherited_style,
|
inherited_style,
|
||||||
|
default_style,
|
||||||
&mut context,
|
&mut context,
|
||||||
&mut seen,
|
&mut seen,
|
||||||
&mut cacheable,
|
&mut cacheable,
|
||||||
|
|
|
@ -11,7 +11,9 @@ use data::ComputedStyle;
|
||||||
use dom::{PresentationalHintsSynthetizer, TElement};
|
use dom::{PresentationalHintsSynthetizer, TElement};
|
||||||
use error_reporting::StdoutErrorReporter;
|
use error_reporting::StdoutErrorReporter;
|
||||||
use keyframes::KeyframesAnimation;
|
use keyframes::KeyframesAnimation;
|
||||||
use media_queries::{Device, MediaType};
|
use media_queries::Device;
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
use media_queries::MediaType;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use properties::{self, CascadeFlags, ComputedValues, INHERIT_ALL, Importance};
|
use properties::{self, CascadeFlags, ComputedValues, INHERIT_ALL, Importance};
|
||||||
use properties::{PropertyDeclaration, PropertyDeclarationBlock};
|
use properties::{PropertyDeclaration, PropertyDeclarationBlock};
|
||||||
|
@ -34,6 +36,7 @@ use std::slice;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style_traits::viewport::ViewportConstraints;
|
use style_traits::viewport::ViewportConstraints;
|
||||||
use stylesheets::{CssRule, Origin, StyleRule, Stylesheet, UserAgentStylesheets};
|
use stylesheets::{CssRule, Origin, StyleRule, Stylesheet, UserAgentStylesheets};
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
use viewport::{self, MaybeNew, ViewportRule};
|
use viewport::{self, MaybeNew, ViewportRule};
|
||||||
|
|
||||||
pub use ::fnv::FnvHashMap;
|
pub use ::fnv::FnvHashMap;
|
||||||
|
@ -274,6 +277,7 @@ impl Stylist {
|
||||||
pub fn precomputed_values_for_pseudo(&self,
|
pub fn precomputed_values_for_pseudo(&self,
|
||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
parent: Option<&Arc<ComputedValues>>,
|
parent: Option<&Arc<ComputedValues>>,
|
||||||
|
default: &Arc<ComputedValues>,
|
||||||
inherit_all: bool)
|
inherit_all: bool)
|
||||||
-> Option<ComputedStyle> {
|
-> Option<ComputedStyle> {
|
||||||
debug_assert!(SelectorImpl::pseudo_element_cascade_type(pseudo).is_precomputed());
|
debug_assert!(SelectorImpl::pseudo_element_cascade_type(pseudo).is_precomputed());
|
||||||
|
@ -293,6 +297,7 @@ impl Stylist {
|
||||||
properties::cascade(self.device.au_viewport_size(),
|
properties::cascade(self.device.au_viewport_size(),
|
||||||
&rule_node,
|
&rule_node,
|
||||||
parent.map(|p| &**p),
|
parent.map(|p| &**p),
|
||||||
|
default,
|
||||||
None,
|
None,
|
||||||
Box::new(StdoutErrorReporter),
|
Box::new(StdoutErrorReporter),
|
||||||
flags);
|
flags);
|
||||||
|
@ -306,7 +311,8 @@ impl Stylist {
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
pub fn style_for_anonymous_box(&self,
|
pub fn style_for_anonymous_box(&self,
|
||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
parent_style: &Arc<ComputedValues>)
|
parent_style: &Arc<ComputedValues>,
|
||||||
|
default_style: &Arc<ComputedValues>)
|
||||||
-> Arc<ComputedValues> {
|
-> Arc<ComputedValues> {
|
||||||
// For most (but not all) pseudo-elements, we inherit all values from the parent.
|
// For most (but not all) pseudo-elements, we inherit all values from the parent.
|
||||||
let inherit_all = match *pseudo {
|
let inherit_all = match *pseudo {
|
||||||
|
@ -325,7 +331,7 @@ impl Stylist {
|
||||||
unreachable!("That pseudo doesn't represent an anonymous box!")
|
unreachable!("That pseudo doesn't represent an anonymous box!")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.precomputed_values_for_pseudo(&pseudo, Some(parent_style), inherit_all)
|
self.precomputed_values_for_pseudo(&pseudo, Some(parent_style), default_style, inherit_all)
|
||||||
.expect("style_for_anonymous_box(): No precomputed values for that pseudo!")
|
.expect("style_for_anonymous_box(): No precomputed values for that pseudo!")
|
||||||
.values
|
.values
|
||||||
}
|
}
|
||||||
|
@ -340,7 +346,8 @@ impl Stylist {
|
||||||
pub fn lazily_compute_pseudo_element_style<E>(&self,
|
pub fn lazily_compute_pseudo_element_style<E>(&self,
|
||||||
element: &E,
|
element: &E,
|
||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
parent: &Arc<ComputedValues>)
|
parent: &Arc<ComputedValues>,
|
||||||
|
default: &Arc<ComputedValues>)
|
||||||
-> Option<ComputedStyle>
|
-> Option<ComputedStyle>
|
||||||
where E: ElementExt +
|
where E: ElementExt +
|
||||||
fmt::Debug +
|
fmt::Debug +
|
||||||
|
@ -368,6 +375,7 @@ impl Stylist {
|
||||||
properties::cascade(self.device.au_viewport_size(),
|
properties::cascade(self.device.au_viewport_size(),
|
||||||
&rule_node,
|
&rule_node,
|
||||||
Some(&**parent),
|
Some(&**parent),
|
||||||
|
default,
|
||||||
None,
|
None,
|
||||||
Box::new(StdoutErrorReporter),
|
Box::new(StdoutErrorReporter),
|
||||||
CascadeFlags::empty());
|
CascadeFlags::empty());
|
||||||
|
@ -380,6 +388,10 @@ impl Stylist {
|
||||||
///
|
///
|
||||||
/// This means that we may need to rebuild style data even if the
|
/// This means that we may need to rebuild style data even if the
|
||||||
/// stylesheets haven't changed.
|
/// stylesheets haven't changed.
|
||||||
|
///
|
||||||
|
/// Viewport_Constraints::maybe_new is servo-only (see the comment above it
|
||||||
|
/// explaining why), so we need to be servo-only too, since we call it.
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
pub fn set_device(&mut self, mut device: Device, stylesheets: &[Arc<Stylesheet>]) {
|
pub fn set_device(&mut self, mut device: Device, stylesheets: &[Arc<Stylesheet>]) {
|
||||||
let cascaded_rule = ViewportRule {
|
let cascaded_rule = ViewportRule {
|
||||||
declarations: viewport::Cascade::from_stylesheets(stylesheets, &device).finish(),
|
declarations: viewport::Cascade::from_stylesheets(stylesheets, &device).finish(),
|
||||||
|
|
|
@ -62,20 +62,6 @@ impl<'a> Context<'a> {
|
||||||
pub fn style(&self) -> &ComputedValues { &self.style }
|
pub fn style(&self) -> &ComputedValues { &self.style }
|
||||||
/// A mutable reference to the current style.
|
/// A mutable reference to the current style.
|
||||||
pub fn mutate_style(&mut self) -> &mut ComputedValues { &mut self.style }
|
pub fn mutate_style(&mut self) -> &mut ComputedValues { &mut self.style }
|
||||||
|
|
||||||
/// Creates a dummy computed context for use in multiple places, like
|
|
||||||
/// evaluating media queries.
|
|
||||||
pub fn initial(viewport_size: Size2D<Au>, is_root_element: bool) -> Self {
|
|
||||||
let initial_style = ComputedValues::initial_values();
|
|
||||||
// FIXME: Enforce a font metrics provider.
|
|
||||||
Context {
|
|
||||||
is_root_element: is_root_element,
|
|
||||||
viewport_size: viewport_size,
|
|
||||||
inherited_style: initial_style,
|
|
||||||
style: initial_style.clone(),
|
|
||||||
font_metrics_provider: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A trait to represent the conversion between computed and specified values.
|
/// A trait to represent the conversion between computed and specified values.
|
||||||
|
|
|
@ -9,13 +9,18 @@
|
||||||
|
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important};
|
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important};
|
||||||
use cssparser::ToCss as ParserToCss;
|
use cssparser::ToCss as ParserToCss;
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
use euclid::scale_factor::ScaleFactor;
|
use euclid::scale_factor::ScaleFactor;
|
||||||
use euclid::size::{Size2D, TypedSize2D};
|
#[cfg(feature = "servo")]
|
||||||
|
use euclid::size::Size2D;
|
||||||
|
use euclid::size::TypedSize2D;
|
||||||
use media_queries::Device;
|
use media_queries::Device;
|
||||||
use parser::{ParserContext, log_css_error};
|
use parser::{ParserContext, log_css_error};
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
use properties::ComputedValues;
|
use properties::ComputedValues;
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
@ -25,6 +30,7 @@ use std::str::Chars;
|
||||||
use style_traits::{ToCss, ViewportPx};
|
use style_traits::{ToCss, ViewportPx};
|
||||||
use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom};
|
use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom};
|
||||||
use stylesheets::{Stylesheet, Origin};
|
use stylesheets::{Stylesheet, Origin};
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
use values::computed::{Context, ToComputedValue};
|
use values::computed::{Context, ToComputedValue};
|
||||||
use values::specified::{Length, LengthOrPercentageOrAuto, ViewportPercentageLength};
|
use values::specified::{Length, LengthOrPercentageOrAuto, ViewportPercentageLength};
|
||||||
|
|
||||||
|
@ -605,6 +611,11 @@ pub trait MaybeNew {
|
||||||
-> Option<ViewportConstraints>;
|
-> Option<ViewportConstraints>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// MaybeNew for ViewportConstraints uses ComputedValues::initial_values which
|
||||||
|
/// is servo-only (not present in gecko). Once it has been changed to properly
|
||||||
|
/// use per-document initial computed values, or not use the initial computed
|
||||||
|
/// values at all, it can go back to being compiled unconditionally.
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
impl MaybeNew for ViewportConstraints {
|
impl MaybeNew for ViewportConstraints {
|
||||||
fn maybe_new(initial_viewport: TypedSize2D<f32, ViewportPx>,
|
fn maybe_new(initial_viewport: TypedSize2D<f32, ViewportPx>,
|
||||||
rule: &ViewportRule)
|
rule: &ViewportRule)
|
||||||
|
|
|
@ -36,6 +36,7 @@ use style::gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedVal
|
||||||
use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong};
|
use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong};
|
||||||
use style::gecko_bindings::bindings::{nsACString, nsAString};
|
use style::gecko_bindings::bindings::{nsACString, nsAString};
|
||||||
use style::gecko_bindings::bindings::RawGeckoElementBorrowed;
|
use style::gecko_bindings::bindings::RawGeckoElementBorrowed;
|
||||||
|
use style::gecko_bindings::bindings::RawGeckoPresContextBorrowed;
|
||||||
use style::gecko_bindings::bindings::RawServoImportRuleBorrowed;
|
use style::gecko_bindings::bindings::RawServoImportRuleBorrowed;
|
||||||
use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
||||||
use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t;
|
use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t;
|
||||||
|
@ -81,17 +82,12 @@ pub extern "C" fn Servo_Initialize() -> () {
|
||||||
// See https://doc.rust-lang.org/log/env_logger/index.html for instructions.
|
// See https://doc.rust-lang.org/log/env_logger/index.html for instructions.
|
||||||
env_logger::init().unwrap();
|
env_logger::init().unwrap();
|
||||||
|
|
||||||
// Allocate our default computed values.
|
|
||||||
unsafe { ComputedValues::initialize(); }
|
|
||||||
|
|
||||||
// Pretend that we're a Servo Layout thread, to make some assertions happy.
|
// Pretend that we're a Servo Layout thread, to make some assertions happy.
|
||||||
thread_state::initialize(thread_state::LAYOUT);
|
thread_state::initialize(thread_state::LAYOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_Shutdown() -> () {
|
pub extern "C" fn Servo_Shutdown() -> () {
|
||||||
// Destroy our default computed values.
|
|
||||||
unsafe { ComputedValues::shutdown(); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_shared_context(per_doc_data: &PerDocumentStyleDataImpl) -> SharedStyleContext {
|
fn create_shared_context(per_doc_data: &PerDocumentStyleDataImpl) -> SharedStyleContext {
|
||||||
|
@ -111,20 +107,12 @@ fn create_shared_context(per_doc_data: &PerDocumentStyleDataImpl) -> SharedStyle
|
||||||
timer: Timer::new(),
|
timer: Timer::new(),
|
||||||
// FIXME Find the real QuirksMode information for this document
|
// FIXME Find the real QuirksMode information for this document
|
||||||
quirks_mode: QuirksMode::NoQuirks,
|
quirks_mode: QuirksMode::NoQuirks,
|
||||||
|
default_computed_values: per_doc_data.default_computed_values.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn traverse_subtree(element: GeckoElement, raw_data: RawServoStyleSetBorrowed,
|
fn traverse_subtree(element: GeckoElement, raw_data: RawServoStyleSetBorrowed,
|
||||||
unstyled_children_only: bool) {
|
unstyled_children_only: bool) {
|
||||||
// Force the creation of our lazily-constructed initial computed values on
|
|
||||||
// the main thread, since it's not safe to call elsewhere.
|
|
||||||
//
|
|
||||||
// FIXME(bholley): this should move into Servo_Initialize as soon as we get
|
|
||||||
// rid of the HackilyFindSomeDeviceContext stuff that happens during
|
|
||||||
// initial_values computation, since that stuff needs to be called further
|
|
||||||
// along in startup than the sensible place to call Servo_Initialize.
|
|
||||||
ComputedValues::initial_values();
|
|
||||||
|
|
||||||
// When new content is inserted in a display:none subtree, we will call into
|
// When new content is inserted in a display:none subtree, we will call into
|
||||||
// servo to try to style it. Detect that here and bail out.
|
// servo to try to style it. Detect that here and bail out.
|
||||||
if let Some(parent) = element.parent_element() {
|
if let Some(parent) = element.parent_element() {
|
||||||
|
@ -168,7 +156,8 @@ pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_RestyleWithAddedDeclaration(declarations: RawServoDeclarationBlockBorrowed,
|
pub extern "C" fn Servo_RestyleWithAddedDeclaration(raw_data: RawServoStyleSetBorrowed,
|
||||||
|
declarations: RawServoDeclarationBlockBorrowed,
|
||||||
previous_style: ServoComputedValuesBorrowed)
|
previous_style: ServoComputedValuesBorrowed)
|
||||||
-> ServoComputedValuesStrong
|
-> ServoComputedValuesStrong
|
||||||
{
|
{
|
||||||
|
@ -181,11 +170,14 @@ pub extern "C" fn Servo_RestyleWithAddedDeclaration(declarations: RawServoDeclar
|
||||||
guard.declarations.iter().rev().map(|&(ref decl, _importance)| decl)
|
guard.declarations.iter().rev().map(|&(ref decl, _importance)| decl)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||||
|
|
||||||
// FIXME (bug 1303229): Use the actual viewport size here
|
// FIXME (bug 1303229): Use the actual viewport size here
|
||||||
let computed = apply_declarations(Size2D::new(Au(0), Au(0)),
|
let computed = apply_declarations(Size2D::new(Au(0), Au(0)),
|
||||||
/* is_root_element = */ false,
|
/* is_root_element = */ false,
|
||||||
declarations,
|
declarations,
|
||||||
previous_style,
|
previous_style,
|
||||||
|
&data.default_computed_values,
|
||||||
None,
|
None,
|
||||||
Box::new(StdoutErrorReporter),
|
Box::new(StdoutErrorReporter),
|
||||||
None,
|
None,
|
||||||
|
@ -529,7 +521,8 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
||||||
|
|
||||||
|
|
||||||
let maybe_parent = ComputedValues::arc_from_borrowed(&parent_style_or_null);
|
let maybe_parent = ComputedValues::arc_from_borrowed(&parent_style_or_null);
|
||||||
let new_computed = data.stylist.precomputed_values_for_pseudo(&pseudo, maybe_parent, false)
|
let new_computed = data.stylist.precomputed_values_for_pseudo(&pseudo, maybe_parent,
|
||||||
|
&data.default_computed_values, false)
|
||||||
.map(|styles| styles.values);
|
.map(|styles| styles.values);
|
||||||
new_computed.map_or(Strong::null(), |c| c.into_strong())
|
new_computed.map_or(Strong::null(), |c| c.into_strong())
|
||||||
}
|
}
|
||||||
|
@ -542,6 +535,7 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
||||||
{
|
{
|
||||||
let element = GeckoElement(element);
|
let element = GeckoElement(element);
|
||||||
let data = unsafe { element.ensure_data() }.borrow_mut();
|
let data = unsafe { element.ensure_data() }.borrow_mut();
|
||||||
|
let doc_data = PerDocumentStyleData::from_ffi(raw_data);
|
||||||
|
|
||||||
// FIXME(bholley): Assert against this.
|
// FIXME(bholley): Assert against this.
|
||||||
if data.get_styles().is_none() {
|
if data.get_styles().is_none() {
|
||||||
|
@ -549,11 +543,10 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
||||||
return if is_probe {
|
return if is_probe {
|
||||||
Strong::null()
|
Strong::null()
|
||||||
} else {
|
} else {
|
||||||
Arc::new(ComputedValues::initial_values().clone()).into_strong()
|
doc_data.borrow().default_computed_values.clone().into_strong()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let doc_data = PerDocumentStyleData::from_ffi(raw_data);
|
|
||||||
match get_pseudo_style(element, pseudo_tag, data.styles(), doc_data) {
|
match get_pseudo_style(element, pseudo_tag, data.styles(), doc_data) {
|
||||||
Some(values) => values.into_strong(),
|
Some(values) => values.into_strong(),
|
||||||
None if !is_probe => data.styles().primary.values.clone().into_strong(),
|
None if !is_probe => data.styles().primary.values.clone().into_strong(),
|
||||||
|
@ -572,20 +565,23 @@ fn get_pseudo_style(element: GeckoElement, pseudo_tag: *mut nsIAtom,
|
||||||
PseudoElementCascadeType::Lazy => {
|
PseudoElementCascadeType::Lazy => {
|
||||||
let d = doc_data.borrow_mut();
|
let d = doc_data.borrow_mut();
|
||||||
let base = &styles.primary.values;
|
let base = &styles.primary.values;
|
||||||
d.stylist.lazily_compute_pseudo_element_style(&element, &pseudo, base)
|
d.stylist.lazily_compute_pseudo_element_style(&element, &pseudo, base, &d.default_computed_values)
|
||||||
.map(|s| s.values.clone())
|
.map(|s| s.values.clone())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_ComputedValues_Inherit(parent_style: ServoComputedValuesBorrowedOrNull)
|
pub extern "C" fn Servo_ComputedValues_Inherit(
|
||||||
|
raw_data: RawServoStyleSetBorrowed,
|
||||||
|
parent_style: ServoComputedValuesBorrowedOrNull)
|
||||||
-> ServoComputedValuesStrong {
|
-> ServoComputedValuesStrong {
|
||||||
|
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||||
let maybe_arc = ComputedValues::arc_from_borrowed(&parent_style);
|
let maybe_arc = ComputedValues::arc_from_borrowed(&parent_style);
|
||||||
let style = if let Some(reference) = maybe_arc.as_ref() {
|
let style = if let Some(reference) = maybe_arc.as_ref() {
|
||||||
ComputedValues::inherit_from(reference)
|
ComputedValues::inherit_from(reference, &data.default_computed_values)
|
||||||
} else {
|
} else {
|
||||||
Arc::new(ComputedValues::initial_values().clone())
|
data.default_computed_values.clone()
|
||||||
};
|
};
|
||||||
style.into_strong()
|
style.into_strong()
|
||||||
}
|
}
|
||||||
|
@ -601,11 +597,21 @@ pub extern "C" fn Servo_ComputedValues_Release(ptr: ServoComputedValuesBorrowed)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_StyleSet_Init() -> RawServoStyleSetOwned {
|
pub extern "C" fn Servo_StyleSet_Init(pres_context: RawGeckoPresContextBorrowed)
|
||||||
let data = Box::new(PerDocumentStyleData::new());
|
-> RawServoStyleSetOwned {
|
||||||
|
let data = Box::new(PerDocumentStyleData::new(pres_context));
|
||||||
data.into_ffi()
|
data.into_ffi()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Servo_StyleSet_RecomputeDefaultStyles(
|
||||||
|
raw_data: RawServoStyleSetBorrowed,
|
||||||
|
pres_context: RawGeckoPresContextBorrowed) {
|
||||||
|
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||||
|
data.default_computed_values = ComputedValues::default_values(pres_context);
|
||||||
|
// FIXME(bz): We need to update our Stylist's Device's computed values, but how?
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_StyleSet_Drop(data: RawServoStyleSetOwned) -> () {
|
pub extern "C" fn Servo_StyleSet_Drop(data: RawServoStyleSetOwned) -> () {
|
||||||
let _ = data.into_box::<PerDocumentStyleData>();
|
let _ = data.into_box::<PerDocumentStyleData>();
|
||||||
|
@ -928,6 +934,7 @@ pub extern "C" fn Servo_CheckChangeHint(element: RawGeckoElementBorrowed) -> nsC
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
||||||
|
raw_data: RawServoStyleSetBorrowed,
|
||||||
consume: structs::ConsumeStyleBehavior)
|
consume: structs::ConsumeStyleBehavior)
|
||||||
-> ServoComputedValuesStrong
|
-> ServoComputedValuesStrong
|
||||||
{
|
{
|
||||||
|
@ -935,10 +942,11 @@ pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
||||||
debug!("Servo_ResolveStyle: {:?}, consume={:?}", element, consume);
|
debug!("Servo_ResolveStyle: {:?}, consume={:?}", element, consume);
|
||||||
|
|
||||||
let mut data = unsafe { element.ensure_data() }.borrow_mut();
|
let mut data = unsafe { element.ensure_data() }.borrow_mut();
|
||||||
|
let per_doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||||
|
|
||||||
if !data.has_current_styles() {
|
if !data.has_current_styles() {
|
||||||
error!("Resolving style on unstyled element with lazy computation forbidden.");
|
error!("Resolving style on unstyled element with lazy computation forbidden.");
|
||||||
return Arc::new(ComputedValues::initial_values().clone()).into_strong();
|
return per_doc_data.default_computed_values.clone().into_strong();
|
||||||
}
|
}
|
||||||
|
|
||||||
let values = data.styles().primary.values.clone();
|
let values = data.styles().primary.values.clone();
|
||||||
|
|
|
@ -8,6 +8,7 @@ use euclid::size::Size2D;
|
||||||
use media_queries::CSSErrorReporterTest;
|
use media_queries::CSSErrorReporterTest;
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
|
use style::properties::ComputedValues;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::Origin;
|
||||||
use style::values::computed;
|
use style::values::computed;
|
||||||
use style::values::computed::{Angle, Context, ToComputedValue};
|
use style::values::computed::{Angle, Context, ToComputedValue};
|
||||||
|
@ -43,7 +44,14 @@ fn test_linear_gradient() {
|
||||||
// Note that Angle(PI) is correct for top-to-bottom rendering, whereas Angle(0) would render bottom-to-top.
|
// Note that Angle(PI) is correct for top-to-bottom rendering, whereas Angle(0) would render bottom-to-top.
|
||||||
// ref: https://developer.mozilla.org/en-US/docs/Web/CSS/angle
|
// ref: https://developer.mozilla.org/en-US/docs/Web/CSS/angle
|
||||||
let container = Size2D::new(Au::default(), Au::default());
|
let container = Size2D::new(Au::default(), Au::default());
|
||||||
let specified_context = Context::initial(container, true);
|
let initial_style = ComputedValues::initial_values();
|
||||||
|
let specified_context = Context {
|
||||||
|
is_root_element: true,
|
||||||
|
viewport_size: container,
|
||||||
|
inherited_style: initial_style,
|
||||||
|
style: initial_style.clone(),
|
||||||
|
font_metrics_provider: None,
|
||||||
|
};
|
||||||
assert_eq!(specified::AngleOrCorner::None.to_computed_value(&specified_context),
|
assert_eq!(specified::AngleOrCorner::None.to_computed_value(&specified_context),
|
||||||
computed::AngleOrCorner::Angle(Angle(PI)));
|
computed::AngleOrCorner::Angle(Angle(PI)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue