servo: Merge #15481 - stylo: Note need to flush styles when we set dirty descendant bits (from heycam:flush-styles); r=bholley

<!-- Please describe your changes on the following line: -->

This is the Servo-side part of https://bugzilla.mozilla.org/show_bug.cgi?id=1331294, already reviewed by @bholley.

---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 2771b24ab36fb7953780660c275ec295de479599

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 35eda8a03fbfb0e83da1b0d500eeaf67f48a004e
This commit is contained in:
Cameron McCormack 2017-02-09 19:27:33 -08:00
Родитель 5e110e6c80
Коммит eff56205a4
2 изменённых файлов: 13 добавлений и 24 удалений

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

@ -633,6 +633,10 @@ extern "C" {
extern "C" {
pub fn Gecko_UnsetNodeFlags(node: RawGeckoNodeBorrowed, flags: u32);
}
extern "C" {
pub fn Gecko_SetOwnerDocumentNeedsStyleFlush(element:
RawGeckoElementBorrowed);
}
extern "C" {
pub fn Gecko_GetStyleContext(node: RawGeckoNodeBorrowed,
aPseudoTagOrNull: *mut nsIAtom)
@ -1125,10 +1129,6 @@ extern "C" {
extern "C" {
pub fn Servo_Element_ClearData(node: RawGeckoElementBorrowed);
}
extern "C" {
pub fn Servo_Element_ShouldTraverse(node: RawGeckoElementBorrowed)
-> bool;
}
extern "C" {
pub fn Servo_StyleSheet_Empty(parsing_mode: SheetParsingMode)
-> RawServoStyleSheetStrong;
@ -1472,7 +1472,7 @@ extern "C" {
extern "C" {
pub fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
set: RawServoStyleSetBorrowed,
root_behavior: TraversalRootBehavior);
root_behavior: TraversalRootBehavior) -> bool;
}
extern "C" {
pub fn Servo_AssertTreeIsClean(root: RawGeckoElementBorrowed);

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

@ -28,6 +28,7 @@ use style::gecko::selector_parser::{SelectorImpl, PseudoElement};
use style::gecko::traversal::RecalcStyleOnly;
use style::gecko::wrapper::DUMMY_BASE_URL;
use style::gecko::wrapper::GeckoElement;
use style::gecko_bindings::bindings;
use style::gecko_bindings::bindings::{RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockStrong};
use style::gecko_bindings::bindings::{RawServoStyleRuleBorrowed, RawServoStyleRuleStrong};
use style::gecko_bindings::bindings::{RawServoStyleSetBorrowed, RawServoStyleSetOwned};
@ -163,14 +164,19 @@ fn traverse_subtree(element: GeckoElement, raw_data: RawServoStyleSetBorrowed,
}
}
/// Traverses the subtree rooted at `root` for restyling. Returns whether a
/// Gecko post-traversal (to perform lazy frame construction, or consume any
/// RestyleData, or drop any ElementData) is required.
#[no_mangle]
pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
raw_data: RawServoStyleSetBorrowed,
behavior: structs::TraversalRootBehavior) -> () {
behavior: structs::TraversalRootBehavior) -> bool {
let element = GeckoElement(root);
debug!("Servo_TraverseSubtree: {:?}", element);
traverse_subtree(element, raw_data,
behavior == structs::TraversalRootBehavior::UnstyledChildrenOnly);
element.has_dirty_descendants() || element.mutate_data().unwrap().has_restyle()
}
#[no_mangle]
@ -341,24 +347,6 @@ pub extern "C" fn Servo_Element_ClearData(element: RawGeckoElementBorrowed) -> (
GeckoElement(element).clear_data();
}
#[no_mangle]
pub extern "C" fn Servo_Element_ShouldTraverse(element: RawGeckoElementBorrowed) -> bool {
let element = GeckoElement(element);
debug_assert!(!element.has_dirty_descendants(),
"only call Servo_Element_ShouldTraverse if you know the element \
does not have dirty descendants");
let result = match element.borrow_data() {
// Note that we check for has_restyle here rather than has_current_styles,
// because we also want the traversal code to trigger if there's restyle
// damage. We really only need the Gecko post-traversal in that case, so
// the servo traversal will be a no-op, but it's cheap enough that we
// don't bother distinguishing the two cases.
Some(d) => !d.has_styles() || d.has_restyle(),
None => true,
};
result
}
#[no_mangle]
pub extern "C" fn Servo_StyleSheet_Empty(mode: SheetParsingMode) -> RawServoStyleSheetStrong {
let url = ServoUrl::parse("about:blank").unwrap();
@ -1077,6 +1065,7 @@ unsafe fn maybe_restyle<'a>(data: &'a mut AtomicRefMut<ElementData>, element: Ge
if curr.has_dirty_descendants() { break; }
curr.set_dirty_descendants();
}
bindings::Gecko_SetOwnerDocumentNeedsStyleFlush(element.0);
// Ensure and return the RestyleData.
Some(data.ensure_restyle())