mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Expose stylist::set_device() for gecko
MozReview-Commit-ID: L655tvOwyKH
This commit is contained in:
parent
bcddb19eb8
commit
4b096486e7
5 changed files with 1097 additions and 591 deletions
|
@ -1982,6 +1982,11 @@ extern "C" {
|
||||||
viewport_units_used:
|
viewport_units_used:
|
||||||
*mut bool) -> u8;
|
*mut bool) -> u8;
|
||||||
}
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Servo_StyleSet_SetDevice(set: RawServoStyleSetBorrowed,
|
||||||
|
pres_context: RawGeckoPresContextOwned)
|
||||||
|
-> u8;
|
||||||
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_StyleSet_CompatModeChanged(raw_data:
|
pub fn Servo_StyleSet_CompatModeChanged(raw_data:
|
||||||
RawServoStyleSetBorrowed);
|
RawServoStyleSetBorrowed);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1070,34 +1070,32 @@ impl Stylist {
|
||||||
/// Also, the device that arrives here may need to take the viewport rules
|
/// Also, the device that arrives here may need to take the viewport rules
|
||||||
/// into account.
|
/// into account.
|
||||||
///
|
///
|
||||||
/// feature = "servo" because gecko only has one device, and manually tracks
|
/// For Gecko, this is called when XBL bindings are used by different
|
||||||
/// when the device is dirty.
|
/// documents.
|
||||||
///
|
|
||||||
/// FIXME(emilio): The semantics of the device for Servo and Gecko are
|
|
||||||
/// different enough we may want to unify them.
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
pub fn set_device(
|
pub fn set_device(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut device: Device,
|
mut device: Device,
|
||||||
guard: &SharedRwLockReadGuard,
|
guard: &SharedRwLockReadGuard,
|
||||||
) -> OriginSet {
|
) -> OriginSet {
|
||||||
let cascaded_rule = {
|
if viewport_rule::enabled() {
|
||||||
let stylesheets = self.stylesheets.iter();
|
let cascaded_rule = {
|
||||||
|
let stylesheets = self.stylesheets.iter();
|
||||||
|
|
||||||
ViewportRule {
|
ViewportRule {
|
||||||
declarations: viewport_rule::Cascade::from_stylesheets(
|
declarations: viewport_rule::Cascade::from_stylesheets(
|
||||||
stylesheets.clone(),
|
stylesheets.clone(),
|
||||||
guard,
|
guard,
|
||||||
&device
|
&device
|
||||||
).finish(),
|
).finish(),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
self.viewport_constraints =
|
||||||
|
ViewportConstraints::maybe_new(&device, &cascaded_rule, self.quirks_mode);
|
||||||
|
|
||||||
|
if let Some(ref constraints) = self.viewport_constraints {
|
||||||
|
device.account_for_viewport_rule(constraints);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
self.viewport_constraints =
|
|
||||||
ViewportConstraints::maybe_new(&device, &cascaded_rule, self.quirks_mode);
|
|
||||||
|
|
||||||
if let Some(ref constraints) = self.viewport_constraints {
|
|
||||||
device.account_for_viewport_rule(constraints);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.device = device;
|
self.device = device;
|
||||||
|
|
|
@ -102,7 +102,7 @@ use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
|
||||||
use style::gecko_bindings::sugar::refptr::RefPtr;
|
use style::gecko_bindings::sugar::refptr::RefPtr;
|
||||||
use style::gecko_properties::style_structs;
|
use style::gecko_properties::style_structs;
|
||||||
use style::invalidation::element::restyle_hints;
|
use style::invalidation::element::restyle_hints;
|
||||||
use style::media_queries::{MediaList, parse_media_query_list};
|
use style::media_queries::{Device, MediaList, parse_media_query_list};
|
||||||
use style::parser::{ParserContext, self};
|
use style::parser::{ParserContext, self};
|
||||||
use style::properties::{CascadeFlags, ComputedValues, Importance};
|
use style::properties::{CascadeFlags, ComputedValues, Importance};
|
||||||
use style::properties::{IS_FIELDSET_CONTENT, IS_LINK, IS_VISITED_LINK, LonghandIdSet};
|
use style::properties::{IS_FIELDSET_CONTENT, IS_LINK, IS_VISITED_LINK, LonghandIdSet};
|
||||||
|
@ -948,6 +948,25 @@ pub extern "C" fn Servo_StyleSet_MediumFeaturesChanged(
|
||||||
OriginFlags::from(origins_in_which_rules_changed).0
|
OriginFlags::from(origins_in_which_rules_changed).0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Servo_StyleSet_SetDevice(
|
||||||
|
raw_data: RawServoStyleSetBorrowed,
|
||||||
|
pres_context: RawGeckoPresContextOwned
|
||||||
|
) -> u8 {
|
||||||
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
|
let guard = global_style_data.shared_lock.read();
|
||||||
|
|
||||||
|
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||||
|
let device = Device::new(pres_context);
|
||||||
|
let origins_in_which_rules_changed =
|
||||||
|
data.stylist.set_device(device, &guard);
|
||||||
|
|
||||||
|
// We'd like to return `OriginFlags` here, but bindgen bitfield enums don't
|
||||||
|
// work as return values with the Linux 32-bit ABI at the moment because
|
||||||
|
// they wrap the value in a struct, so for now just unwrap it.
|
||||||
|
OriginFlags::from(origins_in_which_rules_changed).0
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_StyleSet_PrependStyleSheet(
|
pub extern "C" fn Servo_StyleSet_PrependStyleSheet(
|
||||||
raw_data: RawServoStyleSetBorrowed,
|
raw_data: RawServoStyleSetBorrowed,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue