mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Bug 1298588 part 3, servo piece. Add a default ComputedValues member to PerDocumentStyleData. r=bholley
This commit is contained in:
parent
8908743719
commit
34bb2f1e6c
3 changed files with 154 additions and 1 deletions
|
@ -14,6 +14,7 @@ use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
|||
use media_queries::{Device, MediaType};
|
||||
use num_cpus;
|
||||
use parking_lot::RwLock;
|
||||
use properties::ComputedValues;
|
||||
use rayon;
|
||||
use std::cmp;
|
||||
use std::collections::HashMap;
|
||||
|
@ -56,6 +57,9 @@ pub struct PerDocumentStyleDataImpl {
|
|||
|
||||
/// The number of threads of the work queue.
|
||||
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
|
||||
|
@ -74,7 +78,6 @@ lazy_static! {
|
|||
|
||||
impl PerDocumentStyleData {
|
||||
/// Create a dummy `PerDocumentStyleData`.
|
||||
#[allow(unused_variables)] // temporary until we make use of the ctor arg.
|
||||
pub fn new(pres_context: RawGeckoPresContextBorrowed) -> Self {
|
||||
// FIXME(bholley): Real window size.
|
||||
let window_size: TypedSize2D<f32, ViewportPx> = TypedSize2D::new(800.0, 600.0);
|
||||
|
@ -98,6 +101,7 @@ impl PerDocumentStyleData {
|
|||
rayon::ThreadPool::new(configuration).ok()
|
||||
},
|
||||
num_threads: *NUM_THREADS,
|
||||
default_computed_values: ComputedValues::default_values(pres_context),
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
@ -735,6 +735,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleFont(ptr: *mut nsStyleFont);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleFont(ptr: *mut nsStyleFont,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleFont(ptr: *mut nsStyleFont,
|
||||
other: *const nsStyleFont);
|
||||
|
@ -745,6 +750,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleColor(ptr: *mut nsStyleColor);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleColor(ptr: *mut nsStyleColor,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleColor(ptr: *mut nsStyleColor,
|
||||
other: *const nsStyleColor);
|
||||
|
@ -755,6 +765,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleList(ptr: *mut nsStyleList);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleList(ptr: *mut nsStyleList,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleList(ptr: *mut nsStyleList,
|
||||
other: *const nsStyleList);
|
||||
|
@ -765,6 +780,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleText(ptr: *mut nsStyleText);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleText(ptr: *mut nsStyleText,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleText(ptr: *mut nsStyleText,
|
||||
other: *const nsStyleText);
|
||||
|
@ -775,6 +795,12 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleVisibility(ptr: *mut nsStyleVisibility);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleVisibility(ptr:
|
||||
*mut nsStyleVisibility,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleVisibility(ptr: *mut nsStyleVisibility,
|
||||
other:
|
||||
|
@ -787,6 +813,12 @@ extern "C" {
|
|||
pub fn Gecko_Construct_nsStyleUserInterface(ptr:
|
||||
*mut nsStyleUserInterface);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleUserInterface(ptr:
|
||||
*mut nsStyleUserInterface,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleUserInterface(ptr:
|
||||
*mut nsStyleUserInterface,
|
||||
|
@ -799,6 +831,12 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleTableBorder(ptr: *mut nsStyleTableBorder);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleTableBorder(ptr:
|
||||
*mut nsStyleTableBorder,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleTableBorder(ptr:
|
||||
*mut nsStyleTableBorder,
|
||||
|
@ -811,6 +849,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleSVG(ptr: *mut nsStyleSVG);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleSVG(ptr: *mut nsStyleSVG,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleSVG(ptr: *mut nsStyleSVG,
|
||||
other: *const nsStyleSVG);
|
||||
|
@ -821,6 +864,12 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleVariables(ptr: *mut nsStyleVariables);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleVariables(ptr:
|
||||
*mut nsStyleVariables,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleVariables(ptr: *mut nsStyleVariables,
|
||||
other:
|
||||
|
@ -832,6 +881,12 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleBackground(ptr: *mut nsStyleBackground);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleBackground(ptr:
|
||||
*mut nsStyleBackground,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleBackground(ptr: *mut nsStyleBackground,
|
||||
other:
|
||||
|
@ -843,6 +898,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStylePosition(ptr: *mut nsStylePosition);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStylePosition(ptr: *mut nsStylePosition,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStylePosition(ptr: *mut nsStylePosition,
|
||||
other: *const nsStylePosition);
|
||||
|
@ -853,6 +913,12 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleTextReset(ptr: *mut nsStyleTextReset);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleTextReset(ptr:
|
||||
*mut nsStyleTextReset,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleTextReset(ptr: *mut nsStyleTextReset,
|
||||
other:
|
||||
|
@ -864,6 +930,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleDisplay(ptr: *mut nsStyleDisplay);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleDisplay(ptr: *mut nsStyleDisplay,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleDisplay(ptr: *mut nsStyleDisplay,
|
||||
other: *const nsStyleDisplay);
|
||||
|
@ -874,6 +945,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleContent(ptr: *mut nsStyleContent);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleContent(ptr: *mut nsStyleContent,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleContent(ptr: *mut nsStyleContent,
|
||||
other: *const nsStyleContent);
|
||||
|
@ -884,6 +960,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleUIReset(ptr: *mut nsStyleUIReset);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleUIReset(ptr: *mut nsStyleUIReset,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleUIReset(ptr: *mut nsStyleUIReset,
|
||||
other: *const nsStyleUIReset);
|
||||
|
@ -894,6 +975,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleTable(ptr: *mut nsStyleTable);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleTable(ptr: *mut nsStyleTable,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleTable(ptr: *mut nsStyleTable,
|
||||
other: *const nsStyleTable);
|
||||
|
@ -904,6 +990,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleMargin(ptr: *mut nsStyleMargin);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleMargin(ptr: *mut nsStyleMargin,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleMargin(ptr: *mut nsStyleMargin,
|
||||
other: *const nsStyleMargin);
|
||||
|
@ -914,6 +1005,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStylePadding(ptr: *mut nsStylePadding);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStylePadding(ptr: *mut nsStylePadding,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStylePadding(ptr: *mut nsStylePadding,
|
||||
other: *const nsStylePadding);
|
||||
|
@ -924,6 +1020,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleBorder(ptr: *mut nsStyleBorder);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleBorder(ptr: *mut nsStyleBorder,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleBorder(ptr: *mut nsStyleBorder,
|
||||
other: *const nsStyleBorder);
|
||||
|
@ -934,6 +1035,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleOutline(ptr: *mut nsStyleOutline);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleOutline(ptr: *mut nsStyleOutline,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleOutline(ptr: *mut nsStyleOutline,
|
||||
other: *const nsStyleOutline);
|
||||
|
@ -944,6 +1050,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleXUL(ptr: *mut nsStyleXUL);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleXUL(ptr: *mut nsStyleXUL,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleXUL(ptr: *mut nsStyleXUL,
|
||||
other: *const nsStyleXUL);
|
||||
|
@ -954,6 +1065,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleSVGReset(ptr: *mut nsStyleSVGReset);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleSVGReset(ptr: *mut nsStyleSVGReset,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleSVGReset(ptr: *mut nsStyleSVGReset,
|
||||
other: *const nsStyleSVGReset);
|
||||
|
@ -964,6 +1080,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleColumn(ptr: *mut nsStyleColumn);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleColumn(ptr: *mut nsStyleColumn,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleColumn(ptr: *mut nsStyleColumn,
|
||||
other: *const nsStyleColumn);
|
||||
|
@ -974,6 +1095,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_Construct_nsStyleEffects(ptr: *mut nsStyleEffects);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleEffects(ptr: *mut nsStyleEffects,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyConstruct_nsStyleEffects(ptr: *mut nsStyleEffects,
|
||||
other: *const nsStyleEffects);
|
||||
|
|
|
@ -16,6 +16,7 @@ use gecko_bindings::bindings;
|
|||
% for style_struct in data.style_structs:
|
||||
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_Destroy_${style_struct.gecko_ffi_name};
|
||||
% endfor
|
||||
|
@ -40,6 +41,7 @@ use gecko_bindings::bindings::Gecko_SetMozBinding;
|
|||
use gecko_bindings::bindings::Gecko_SetNullImageValue;
|
||||
use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
||||
use gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom};
|
||||
use gecko_bindings::bindings::RawGeckoPresContextBorrowed;
|
||||
use gecko_bindings::structs;
|
||||
use gecko_bindings::structs::nsStyleVariables;
|
||||
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
|
||||
|
@ -125,6 +127,18 @@ impl ComputedValues {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> {
|
||||
Arc::new(ComputedValues {
|
||||
custom_properties: None,
|
||||
shareable: true,
|
||||
writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious
|
||||
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 initialize() {
|
||||
debug_assert!(raw_initial_values().is_null());
|
||||
set_raw_initial_values(Box::into_raw(Box::new(ComputedValues {
|
||||
|
@ -422,6 +436,15 @@ impl ${style_struct.gecko_struct_name} {
|
|||
}
|
||||
result
|
||||
}
|
||||
#[allow(dead_code, unused_variables)]
|
||||
pub fn default(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> {
|
||||
let mut result = Arc::new(${style_struct.gecko_struct_name} { gecko: unsafe { zeroed() } });
|
||||
unsafe {
|
||||
Gecko_Construct_Default_${style_struct.gecko_ffi_name}(&mut Arc::get_mut(&mut result).unwrap().gecko,
|
||||
pres_context);
|
||||
}
|
||||
result
|
||||
}
|
||||
pub fn get_gecko(&self) -> &${style_struct.gecko_ffi_name} {
|
||||
&self.gecko
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue