зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #18571 - Add a geckolib API to check for primary style reuse (from bholley:primary_reuse_api); r=emilio
https://bugzilla.mozilla.org/show_bug.cgi?id=1401317 Source-Repo: https://github.com/servo/servo Source-Revision: 3cea16e18f125e3839af4dd3f064b4194fde4953 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : d3e71cc94e07434947e7950699d2486e9c32fd9f
This commit is contained in:
Родитель
dc2b79debb
Коммит
cff6e00bcf
|
@ -1936,6 +1936,11 @@ extern "C" {
|
|||
pub fn Servo_Element_IsDisplayNone(element: RawGeckoElementBorrowed)
|
||||
-> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_Element_IsPrimaryStyleReusedViaRuleNode(element:
|
||||
RawGeckoElementBorrowed)
|
||||
-> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSheet_FromUTF8Bytes(loader: *mut Loader,
|
||||
gecko_stylesheet:
|
||||
|
|
|
@ -745,11 +745,16 @@ impl<E: TElement> StyleSharingCache<E> {
|
|||
/// Attempts to find an element in the cache with the given primary rule node and parent.
|
||||
pub fn lookup_by_rules(
|
||||
&mut self,
|
||||
shared_context: &SharedStyleContext,
|
||||
inherited: &ComputedValues,
|
||||
rules: &StrongRuleNode,
|
||||
visited_rules: Option<&StrongRuleNode>,
|
||||
target: E,
|
||||
) -> Option<PrimaryStyle> {
|
||||
if shared_context.options.disable_style_sharing_cache {
|
||||
return None;
|
||||
}
|
||||
|
||||
self.cache_mut().lookup(|candidate| {
|
||||
debug_assert_ne!(candidate.element, target);
|
||||
if !candidate.parent_style_identity().eq(inherited) {
|
||||
|
|
|
@ -195,6 +195,7 @@ where
|
|||
|
||||
if may_reuse {
|
||||
let cached = self.context.thread_local.sharing_cache.lookup_by_rules(
|
||||
self.context.shared,
|
||||
parent_style.unwrap(),
|
||||
inputs.rules.as_ref().unwrap(),
|
||||
inputs.visited_rules.as_ref(),
|
||||
|
|
|
@ -18,7 +18,7 @@ use std::ptr;
|
|||
use style::applicable_declarations::ApplicableDeclarationBlock;
|
||||
use style::context::{CascadeInputs, QuirksMode, SharedStyleContext, StyleContext};
|
||||
use style::context::ThreadLocalStyleContext;
|
||||
use style::data::ElementStyles;
|
||||
use style::data::{ElementStyles, self};
|
||||
use style::dom::{ShowSubtreeData, TElement, TNode};
|
||||
use style::driver;
|
||||
use style::element_state::ElementState;
|
||||
|
@ -842,13 +842,20 @@ pub extern "C" fn Servo_Element_GetPseudoComputedValues(element: RawGeckoElement
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_Element_IsDisplayNone(element: RawGeckoElementBorrowed) -> bool
|
||||
{
|
||||
pub extern "C" fn Servo_Element_IsDisplayNone(element: RawGeckoElementBorrowed) -> bool {
|
||||
let element = GeckoElement(element);
|
||||
let data = element.borrow_data().expect("Invoking Servo_Element_IsDisplayNone on unstyled element");
|
||||
data.styles.is_display_none()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_Element_IsPrimaryStyleReusedViaRuleNode(element: RawGeckoElementBorrowed) -> bool {
|
||||
let element = GeckoElement(element);
|
||||
let data = element.borrow_data()
|
||||
.expect("Invoking Servo_Element_IsPrimaryStyleReusedViaRuleNode on unstyled element");
|
||||
data.flags.contains(data::PRIMARY_STYLE_REUSED_VIA_RULE_NODE)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSheet_Empty(mode: SheetParsingMode) -> RawServoStyleSheetContentsStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
|
|
Загрузка…
Ссылка в новой задаче