mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
layout: Ensure a element's style is up to date when processing queries.
This commit is contained in:
parent
17772d1618
commit
6b60383f24
4 changed files with 109 additions and 11 deletions
|
@ -30,6 +30,7 @@ use std::ops::Deref;
|
|||
use std::sync::{Arc, Mutex};
|
||||
use string_cache::Atom;
|
||||
use style::computed_values;
|
||||
use style::context::StyleContext;
|
||||
use style::logical_geometry::{WritingMode, BlockFlowDirection, InlineBaseDirection};
|
||||
use style::properties::longhands::{display, position};
|
||||
use style::properties::style_structs;
|
||||
|
@ -37,7 +38,7 @@ use style::selector_impl::PseudoElement;
|
|||
use style::selector_matching::Stylist;
|
||||
use style::values::LocalToCss;
|
||||
use style_traits::cursor::Cursor;
|
||||
use wrapper::ThreadSafeLayoutNodeHelpers;
|
||||
use wrapper::{LayoutNodeLayoutData, ThreadSafeLayoutNodeHelpers};
|
||||
|
||||
/// Mutable data belonging to the LayoutThread.
|
||||
///
|
||||
|
@ -616,9 +617,32 @@ pub fn process_node_scroll_area_request< N: LayoutNode>(requested_node: N, layou
|
|||
|
||||
/// Return the resolved value of property for a given (pseudo)element.
|
||||
/// https://drafts.csswg.org/cssom/#resolved-value
|
||||
pub fn process_resolved_style_request<N: LayoutNode>(
|
||||
requested_node: N, pseudo: &Option<PseudoElement>,
|
||||
property: &Atom, layout_root: &mut FlowRef) -> Option<String> {
|
||||
pub fn process_resolved_style_request<'a, N, C>(requested_node: N,
|
||||
style_context: &'a C,
|
||||
pseudo: &Option<PseudoElement>,
|
||||
property: &Atom,
|
||||
layout_root: &mut FlowRef) -> Option<String>
|
||||
where N: LayoutNode,
|
||||
C: StyleContext<'a>
|
||||
{
|
||||
use style::traversal::ensure_node_styled;
|
||||
|
||||
// This node might have display: none, or it's style might be not up to
|
||||
// date, so we might need to do style recalc.
|
||||
//
|
||||
// XXX: Is a bit shame we have to do this instead of in style :/
|
||||
let mut cur = Some(requested_node);
|
||||
while let Some(current) = cur {
|
||||
if current.borrow_data().is_some() {
|
||||
break;
|
||||
}
|
||||
|
||||
current.initialize_data();
|
||||
cur = current.parent_node();
|
||||
}
|
||||
|
||||
ensure_node_styled(requested_node, style_context);
|
||||
|
||||
let layout_node = requested_node.to_threadsafe();
|
||||
let layout_node = match *pseudo {
|
||||
Some(PseudoElement::Before) => layout_node.get_before_pseudo(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue