mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #17123 - KuoE0:bug-1358993, r=heycam
Store the pointer of reusable sheets in StylesheetLoader. <!-- Please describe your changes on the following line: --> To make stylo support reusable style sheets, we need to store the pointer of reusable style sheets we got from gecko. And we pass them back to gecko to reuse. --- <!-- 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 1358993](https://bugzilla.mozilla.org/show_bug.cgi?id=1358993). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because the test cases are in Gecko. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- 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/17123) <!-- Reviewable:end -->
This commit is contained in:
commit
63be9d7af2
5 changed files with 5329 additions and 3796 deletions
|
@ -201,6 +201,7 @@ use gecko_bindings::structs::nscolor;
|
|||
use gecko_bindings::structs::nscoord;
|
||||
use gecko_bindings::structs::nsresult;
|
||||
use gecko_bindings::structs::Loader;
|
||||
use gecko_bindings::structs::LoaderReusableStyleSheets;
|
||||
use gecko_bindings::structs::ServoStyleSheet;
|
||||
use gecko_bindings::structs::EffectCompositor_CascadeLevel;
|
||||
use gecko_bindings::structs::UpdateAnimationsTasks;
|
||||
|
@ -540,6 +541,8 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_LoadStyleSheet(loader: *mut Loader,
|
||||
parent: *mut ServoStyleSheet,
|
||||
reusable_sheets:
|
||||
*mut LoaderReusableStyleSheets,
|
||||
child_sheet: RawServoStyleSheetBorrowed,
|
||||
base_url_data: *mut RawGeckoURLExtraData,
|
||||
url_bytes: *const u8, url_length: u32,
|
||||
|
@ -1769,7 +1772,9 @@ extern "C" {
|
|||
data: *const nsACString,
|
||||
extra_data:
|
||||
*mut RawGeckoURLExtraData,
|
||||
line_number_offset: u32);
|
||||
line_number_offset: u32,
|
||||
reusable_sheets:
|
||||
*mut LoaderReusableStyleSheets);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSheet_HasRules(sheet: RawServoStyleSheetBorrowed)
|
||||
|
@ -1799,6 +1804,10 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Servo_StyleSet_RebuildData(set: RawServoStyleSetBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSet_MediumFeaturesChanged(set: RawServoStyleSetBorrowed)
|
||||
-> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSet_AppendStyleSheet(set: RawServoStyleSetBorrowed,
|
||||
sheet: RawServoStyleSheetBorrowed,
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -65,12 +65,12 @@ use style::gecko_bindings::bindings::nsTimingFunctionBorrowed;
|
|||
use style::gecko_bindings::bindings::nsTimingFunctionBorrowedMut;
|
||||
use style::gecko_bindings::structs;
|
||||
use style::gecko_bindings::structs::{CSSPseudoElementType, CompositeOperation};
|
||||
use style::gecko_bindings::structs::{Loader, LoaderReusableStyleSheets};
|
||||
use style::gecko_bindings::structs::{RawServoStyleRule, ServoStyleSheet};
|
||||
use style::gecko_bindings::structs::{SheetParsingMode, nsIAtom, nsCSSPropertyID};
|
||||
use style::gecko_bindings::structs::{nsCSSFontFaceRule, nsCSSCounterStyleRule};
|
||||
use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, PropertyValuePair};
|
||||
use style::gecko_bindings::structs::IterationCompositeOperation;
|
||||
use style::gecko_bindings::structs::Loader;
|
||||
use style::gecko_bindings::structs::MallocSizeOf;
|
||||
use style::gecko_bindings::structs::RawGeckoPresContextOwned;
|
||||
use style::gecko_bindings::structs::ServoElementSnapshotTable;
|
||||
|
@ -721,7 +721,7 @@ pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(loader: *mut Loader,
|
|||
let loader = if loader.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(StylesheetLoader::new(loader, stylesheet))
|
||||
Some(StylesheetLoader::new(loader, stylesheet, ptr::null_mut()))
|
||||
};
|
||||
|
||||
// FIXME(emilio): loader.as_ref() doesn't typecheck for some reason?
|
||||
|
@ -750,7 +750,8 @@ pub extern "C" fn Servo_StyleSheet_ClearAndUpdate(stylesheet: RawServoStyleSheet
|
|||
gecko_stylesheet: *mut ServoStyleSheet,
|
||||
data: *const nsACString,
|
||||
extra_data: *mut URLExtraData,
|
||||
line_number_offset: u32)
|
||||
line_number_offset: u32,
|
||||
reusable_sheets: *mut LoaderReusableStyleSheets)
|
||||
{
|
||||
let input = unsafe { data.as_ref().unwrap().as_str_unchecked() };
|
||||
let url_data = unsafe { RefPtr::from_ptr_ref(&extra_data) };
|
||||
|
@ -758,7 +759,7 @@ pub extern "C" fn Servo_StyleSheet_ClearAndUpdate(stylesheet: RawServoStyleSheet
|
|||
let loader = if loader.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(StylesheetLoader::new(loader, gecko_stylesheet))
|
||||
Some(StylesheetLoader::new(loader, gecko_stylesheet, reusable_sheets))
|
||||
};
|
||||
|
||||
// FIXME(emilio): loader.as_ref() doesn't typecheck for some reason?
|
||||
|
@ -950,7 +951,7 @@ pub extern "C" fn Servo_CssRules_InsertRule(rules: ServoCssRulesBorrowed,
|
|||
let loader = if loader.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(StylesheetLoader::new(loader, gecko_stylesheet))
|
||||
Some(StylesheetLoader::new(loader, gecko_stylesheet, ptr::null_mut()))
|
||||
};
|
||||
let loader = loader.as_ref().map(|loader| loader as &StyleStylesheetLoader);
|
||||
let rule = unsafe { rule.as_ref().unwrap().as_str_unchecked() };
|
||||
|
|
|
@ -3,18 +3,20 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use style::gecko_bindings::bindings::Gecko_LoadStyleSheet;
|
||||
use style::gecko_bindings::structs::{Loader, ServoStyleSheet};
|
||||
use style::gecko_bindings::structs::{Loader, ServoStyleSheet, LoaderReusableStyleSheets};
|
||||
use style::gecko_bindings::sugar::ownership::{HasArcFFI, FFIArcHelpers};
|
||||
use style::media_queries::MediaList;
|
||||
use style::shared_lock::Locked;
|
||||
use style::stylearc::Arc;
|
||||
use style::stylesheets::{ImportRule, Stylesheet, StylesheetLoader as StyleStylesheetLoader};
|
||||
|
||||
pub struct StylesheetLoader(*mut Loader, *mut ServoStyleSheet);
|
||||
pub struct StylesheetLoader(*mut Loader, *mut ServoStyleSheet, *mut LoaderReusableStyleSheets);
|
||||
|
||||
impl StylesheetLoader {
|
||||
pub fn new(loader: *mut Loader, parent: *mut ServoStyleSheet) -> Self {
|
||||
StylesheetLoader(loader, parent)
|
||||
pub fn new(loader: *mut Loader,
|
||||
parent: *mut ServoStyleSheet,
|
||||
reusable_sheets: *mut LoaderReusableStyleSheets) -> Self {
|
||||
StylesheetLoader(loader, parent, reusable_sheets)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +39,7 @@ impl StyleStylesheetLoader for StylesheetLoader {
|
|||
unsafe {
|
||||
Gecko_LoadStyleSheet(self.0,
|
||||
self.1,
|
||||
self.2,
|
||||
Stylesheet::arc_as_borrowed(&import.stylesheet),
|
||||
base_url_data,
|
||||
spec_bytes,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue