servo: Merge #16819 - stylo: Propagate quirks mode information from Gecko to Servo (from canaltinova:quirk-mode); r=bholley,emilio

r=bholley in bugzilla

---
<!-- 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 [Bug 1360488](https://bugzilla.mozilla.org/show_bug.cgi?id=1360488)

Source-Repo: https://github.com/servo/servo
Source-Revision: 94ac822132bd78a412f847a704c9ddf3eb91151c

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 2ea77efd7e0f31ea403f9952644c6ff30aaf4466
This commit is contained in:
Nazım Can Altınova 2017-05-13 20:50:10 -05:00
Родитель 76442db0fb
Коммит 6e17bb55a1
9 изменённых файлов: 48 добавлений и 14 удалений

Просмотреть файл

@ -418,7 +418,7 @@ impl LayoutThread {
let font_cache_receiver = let font_cache_receiver =
ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_font_cache_receiver); ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_font_cache_receiver);
let stylist = Stylist::new(device); let stylist = Stylist::new(device, QuirksMode::NoQuirks);
let outstanding_web_fonts_counter = Arc::new(AtomicUsize::new(0)); let outstanding_web_fonts_counter = Arc::new(AtomicUsize::new(0));
let ua_stylesheets = &*UA_STYLESHEETS; let ua_stylesheets = &*UA_STYLESHEETS;
let guard = ua_stylesheets.shared_lock.read(); let guard = ua_stylesheets.shared_lock.read();

Просмотреть файл

@ -699,6 +699,7 @@ mod bindings {
"nsCursorImage", "nsCursorImage",
"nsFont", "nsFont",
"nsIAtom", "nsIAtom",
"nsCompatibility",
"nsMediaFeature", "nsMediaFeature",
"nsRestyleHint", "nsRestyleHint",
"nsStyleBackground", "nsStyleBackground",

Просмотреть файл

@ -9,6 +9,7 @@ use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use dom::OpaqueNode; use dom::OpaqueNode;
use gecko_bindings::bindings::RawServoStyleSet; use gecko_bindings::bindings::RawServoStyleSet;
use gecko_bindings::structs::RawGeckoPresContextOwned; use gecko_bindings::structs::RawGeckoPresContextOwned;
use gecko_bindings::structs::nsIDocument;
use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use media_queries::Device; use media_queries::Device;
use parking_lot::RwLock; use parking_lot::RwLock;
@ -56,11 +57,14 @@ impl PerDocumentStyleData {
/// Create a dummy `PerDocumentStyleData`. /// Create a dummy `PerDocumentStyleData`.
pub fn new(pres_context: RawGeckoPresContextOwned) -> Self { pub fn new(pres_context: RawGeckoPresContextOwned) -> Self {
let device = Device::new(pres_context); let device = Device::new(pres_context);
let quirks_mode = unsafe {
(*(*device.pres_context).mDocument.raw::<nsIDocument>()).mCompatMode
};
let (new_anims_sender, new_anims_receiver) = channel(); let (new_anims_sender, new_anims_receiver) = channel();
PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl { PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl {
stylist: Stylist::new(device), stylist: Stylist::new(device, quirks_mode.into()),
stylesheets: StylesheetSet::new(), stylesheets: StylesheetSet::new(),
new_animations_sender: new_anims_sender, new_animations_sender: new_anims_sender,
new_animations_receiver: new_anims_receiver, new_animations_receiver: new_anims_receiver,

Просмотреть файл

@ -53,6 +53,7 @@ use gecko_bindings::structs::nsChangeHint;
use gecko_bindings::structs::nsCursorImage; use gecko_bindings::structs::nsCursorImage;
use gecko_bindings::structs::nsFont; use gecko_bindings::structs::nsFont;
use gecko_bindings::structs::nsIAtom; use gecko_bindings::structs::nsIAtom;
use gecko_bindings::structs::nsCompatibility;
use gecko_bindings::structs::nsMediaFeature; use gecko_bindings::structs::nsMediaFeature;
use gecko_bindings::structs::nsRestyleHint; use gecko_bindings::structs::nsRestyleHint;
use gecko_bindings::structs::nsStyleBackground; use gecko_bindings::structs::nsStyleBackground;
@ -1966,7 +1967,8 @@ extern "C" {
} }
extern "C" { extern "C" {
pub fn Servo_ParseStyleAttribute(data: *const nsACString, pub fn Servo_ParseStyleAttribute(data: *const nsACString,
extra_data: *mut RawGeckoURLExtraData) extra_data: *mut RawGeckoURLExtraData,
quirks_mode: nsCompatibility)
-> RawServoDeclarationBlockStrong; -> RawServoDeclarationBlockStrong;
} }
extern "C" { extern "C" {

Просмотреть файл

@ -336,8 +336,9 @@ impl<'le> fmt::Debug for GeckoElement<'le> {
impl<'le> GeckoElement<'le> { impl<'le> GeckoElement<'le> {
/// Parse the style attribute of an element. /// Parse the style attribute of an element.
pub fn parse_style_attribute(value: &str, pub fn parse_style_attribute(value: &str,
url_data: &UrlExtraData) -> PropertyDeclarationBlock { url_data: &UrlExtraData,
parse_style_attribute(value, url_data, &RustLogReporter, QuirksMode::NoQuirks) quirks_mode: QuirksMode) -> PropertyDeclarationBlock {
parse_style_attribute(value, url_data, &RustLogReporter, quirks_mode)
} }
fn flags(&self) -> u32 { fn flags(&self) -> u32 {

Просмотреть файл

@ -5,6 +5,7 @@
//! Rust sugar and convenience methods for Gecko types. //! Rust sugar and convenience methods for Gecko types.
mod ns_com_ptr; mod ns_com_ptr;
mod ns_compatibility;
mod ns_css_shadow_array; mod ns_css_shadow_array;
pub mod ns_css_value; pub mod ns_css_value;
mod ns_style_auto_array; mod ns_style_auto_array;

Просмотреть файл

@ -0,0 +1,18 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Little helper for `nsCompatibility`.
use context::QuirksMode;
use gecko_bindings::structs::nsCompatibility;
impl From<nsCompatibility> for QuirksMode {
fn from(mode: nsCompatibility) -> QuirksMode {
match mode {
nsCompatibility::eCompatibility_FullStandards => QuirksMode::NoQuirks,
nsCompatibility::eCompatibility_AlmostStandards => QuirksMode::LimitedQuirks,
nsCompatibility::eCompatibility_NavQuirks => QuirksMode::Quirks,
}
}
}

Просмотреть файл

@ -189,16 +189,17 @@ impl<'a> ExtraStyleData<'a> {
} }
impl Stylist { impl Stylist {
/// Construct a new `Stylist`, using a given `Device`. If more members are /// Construct a new `Stylist`, using given `Device` and `QuirksMode`.
/// added here, think about whether they should be reset in clear(). /// If more members are added here, think about whether they should
/// be reset in clear().
#[inline] #[inline]
pub fn new(device: Device) -> Self { pub fn new(device: Device, quirks_mode: QuirksMode) -> Self {
let mut stylist = Stylist { let mut stylist = Stylist {
viewport_constraints: None, viewport_constraints: None,
device: Arc::new(device), device: Arc::new(device),
is_device_dirty: true, is_device_dirty: true,
is_cleared: true, is_cleared: true,
quirks_mode: QuirksMode::NoQuirks, quirks_mode: quirks_mode,
element_map: PerPseudoElementSelectorMap::new(), element_map: PerPseudoElementSelectorMap::new(),
pseudos_map: Default::default(), pseudos_map: Default::default(),
@ -778,6 +779,11 @@ impl Stylist {
self.viewport_constraints.as_ref() self.viewport_constraints.as_ref()
} }
/// Returns the Quirks Mode of the document.
pub fn quirks_mode(&self) -> QuirksMode {
self.quirks_mode
}
/// Sets the quirks mode of the document. /// Sets the quirks mode of the document.
pub fn set_quirks_mode(&mut self, quirks_mode: QuirksMode) { pub fn set_quirks_mode(&mut self, quirks_mode: QuirksMode) {
// FIXME(emilio): We don't seem to change the quirks mode dynamically // FIXME(emilio): We don't seem to change the quirks mode dynamically

Просмотреть файл

@ -67,6 +67,7 @@ use style::gecko_bindings::structs::RawGeckoPresContextOwned;
use style::gecko_bindings::structs::ServoElementSnapshotTable; use style::gecko_bindings::structs::ServoElementSnapshotTable;
use style::gecko_bindings::structs::URLExtraData; use style::gecko_bindings::structs::URLExtraData;
use style::gecko_bindings::structs::nsCSSValueSharedList; use style::gecko_bindings::structs::nsCSSValueSharedList;
use style::gecko_bindings::structs::nsCompatibility;
use style::gecko_bindings::structs::nsresult; use style::gecko_bindings::structs::nsresult;
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasFFI, HasArcFFI, HasBoxFFI}; use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasFFI, HasArcFFI, HasBoxFFI};
use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong}; use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
@ -167,8 +168,7 @@ fn create_shared_context<'a>(global_style_data: &GlobalStyleData,
guards: StylesheetGuards::same(guard), guards: StylesheetGuards::same(guard),
error_reporter: &DEFAULT_ERROR_REPORTER, error_reporter: &DEFAULT_ERROR_REPORTER,
timer: Timer::new(), timer: Timer::new(),
// FIXME Find the real QuirksMode information for this document quirks_mode: per_doc_data.stylist.quirks_mode(),
quirks_mode: QuirksMode::NoQuirks,
traversal_flags: traversal_flags, traversal_flags: traversal_flags,
snapshot_map: snapshot_map, snapshot_map: snapshot_map,
} }
@ -1196,13 +1196,14 @@ pub extern "C" fn Servo_ParseEasing(easing: *const nsAString,
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_ParseStyleAttribute(data: *const nsACString, pub extern "C" fn Servo_ParseStyleAttribute(data: *const nsACString,
raw_extra_data: *mut URLExtraData) raw_extra_data: *mut URLExtraData,
quirks_mode: nsCompatibility)
-> RawServoDeclarationBlockStrong { -> RawServoDeclarationBlockStrong {
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;
let value = unsafe { data.as_ref().unwrap().as_str_unchecked() }; let value = unsafe { data.as_ref().unwrap().as_str_unchecked() };
let url_data = unsafe { RefPtr::from_ptr_ref(&raw_extra_data) }; let url_data = unsafe { RefPtr::from_ptr_ref(&raw_extra_data) };
Arc::new(global_style_data.shared_lock.wrap( Arc::new(global_style_data.shared_lock.wrap(
GeckoElement::parse_style_attribute(value, url_data))).into_strong() GeckoElement::parse_style_attribute(value, url_data, quirks_mode.into()))).into_strong()
} }
#[no_mangle] #[no_mangle]
@ -2075,7 +2076,7 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis
font_metrics_provider: &metrics, font_metrics_provider: &metrics,
cached_system_font: None, cached_system_font: None,
in_media_query: false, in_media_query: false,
quirks_mode: QuirksMode::NoQuirks, quirks_mode: data.stylist.quirks_mode(),
}; };
for (index, keyframe) in keyframes.iter().enumerate() { for (index, keyframe) in keyframes.iter().enumerate() {