mirror of
https://github.com/servo/servo.git
synced 2025-10-02 01:29:15 +01:00
Auto merge of #12757 - emilio:stylo, r=bholley,pcwalton
stylo: Stop restyling display: none elements, remove the has_changed hack that made us use ReconstructFrame unconditionally. <!-- Please describe your changes on the following line: --> --- <!-- 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 <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> r? @bholley <!-- 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/12757) <!-- Reviewable:end -->
This commit is contained in:
commit
1b2450339c
19 changed files with 543 additions and 180 deletions
|
@ -6,6 +6,7 @@ use context::StandaloneStyleContext;
|
|||
use std::mem;
|
||||
use style::context::SharedStyleContext;
|
||||
use style::dom::OpaqueNode;
|
||||
use style::traversal::RestyleResult;
|
||||
use style::traversal::{DomTraversalContext, recalc_style_at};
|
||||
use wrapper::GeckoNode;
|
||||
|
||||
|
@ -27,13 +28,18 @@ impl<'lc, 'ln> DomTraversalContext<GeckoNode<'ln>> for RecalcStyleOnly<'lc> {
|
|||
}
|
||||
}
|
||||
|
||||
fn process_preorder(&self, node: GeckoNode<'ln>) {
|
||||
fn process_preorder(&self, node: GeckoNode<'ln>) -> RestyleResult {
|
||||
// FIXME(pcwalton): Stop allocating here. Ideally this should just be done by the HTML
|
||||
// parser.
|
||||
node.initialize_data();
|
||||
|
||||
recalc_style_at(&self.context, self.root, node);
|
||||
recalc_style_at(&self.context, self.root, node)
|
||||
}
|
||||
|
||||
fn process_postorder(&self, _: GeckoNode<'ln>) {}
|
||||
fn process_postorder(&self, _: GeckoNode<'ln>) {
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
/// We don't use the post-order traversal for anything.
|
||||
fn needs_postorder_traversal(&self) -> bool { false }
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ use style::dom::{TDocument, TElement, TNode, TRestyleDamage, UnsafeNode};
|
|||
use style::element_state::ElementState;
|
||||
use style::error_reporting::StdoutErrorReporter;
|
||||
use style::gecko_glue::ArcHelpers;
|
||||
use style::gecko_selector_impl::{GeckoSelectorImpl, NonTSPseudoClass};
|
||||
use style::gecko_selector_impl::{GeckoSelectorImpl, NonTSPseudoClass, PseudoElement};
|
||||
use style::parser::ParserContextExtraData;
|
||||
use style::properties::{ComputedValues, parse_style_attribute};
|
||||
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock};
|
||||
|
@ -95,18 +95,21 @@ impl<'ln> GeckoNode<'ln> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct GeckoRestyleDamage(nsChangeHint);
|
||||
|
||||
impl TRestyleDamage for GeckoRestyleDamage {
|
||||
type PreExistingComputedValues = nsStyleContext;
|
||||
fn compute(source: Option<&nsStyleContext>,
|
||||
|
||||
fn empty() -> Self {
|
||||
use std::mem;
|
||||
GeckoRestyleDamage(unsafe { mem::transmute(0u32) })
|
||||
}
|
||||
|
||||
fn compute(source: &nsStyleContext,
|
||||
new_style: &Arc<ComputedValues>) -> Self {
|
||||
type Helpers = ArcHelpers<ServoComputedValues, ComputedValues>;
|
||||
let context = match source {
|
||||
Some(ctx) => ctx as *const nsStyleContext as *mut nsStyleContext,
|
||||
None => return Self::rebuild_and_reflow(),
|
||||
};
|
||||
let context = source as *const nsStyleContext as *mut nsStyleContext;
|
||||
|
||||
Helpers::borrow(new_style, |new_style| {
|
||||
let hint = unsafe { Gecko_CalcStyleDifference(context, new_style) };
|
||||
|
@ -194,10 +197,9 @@ impl<'ln> TNode for GeckoNode<'ln> {
|
|||
unimplemented!()
|
||||
}
|
||||
|
||||
fn has_changed(&self) -> bool {
|
||||
// FIXME(bholley) - Implement this to allow incremental reflows!
|
||||
true
|
||||
}
|
||||
// NOTE: This is not relevant for Gecko, since we get explicit restyle hints
|
||||
// when a content has changed.
|
||||
fn has_changed(&self) -> bool { false }
|
||||
|
||||
unsafe fn set_changed(&self, _value: bool) {
|
||||
unimplemented!()
|
||||
|
@ -310,13 +312,21 @@ impl<'ln> TNode for GeckoNode<'ln> {
|
|||
}
|
||||
|
||||
fn existing_style_for_restyle_damage<'a>(&'a self,
|
||||
current_cv: Option<&'a Arc<ComputedValues>>)
|
||||
current_cv: Option<&'a Arc<ComputedValues>>,
|
||||
pseudo: Option<&PseudoElement>)
|
||||
-> Option<&'a nsStyleContext> {
|
||||
if current_cv.is_none() {
|
||||
// Don't bother in doing an ffi call to get null back.
|
||||
return None;
|
||||
}
|
||||
|
||||
if pseudo.is_some() {
|
||||
// FIXME(emilio): This makes us reconstruct frame for pseudos every
|
||||
// restyle, add a FFI call to get the style context associated with
|
||||
// a PE.
|
||||
return None;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
let context_ptr = Gecko_GetStyleContext(self.node);
|
||||
context_ptr.as_ref()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue