mirror of
https://github.com/servo/servo.git
synced 2025-09-10 06:58:21 +01:00
rule tree: Remove unsound transmute()
RuleTreeDeclarationsIterator would yield &PropertyDeclaration with the lifetime of the rule tree, but the reference would only be valid as long as the iterator was holding the corresponding lock. The lock would be released when the iterator’s `.next()` method moves to the next rule tree node, or when the iterator is dropped. Also change apply_declaration to not require a `Clone` iterator (since closures unfortunately don’t implement `Clone`). Instead have it take a callable that returns a fresh iterator.
This commit is contained in:
parent
de4fe6e2b6
commit
98bd99b74c
6 changed files with 58 additions and 176 deletions
|
@ -131,15 +131,14 @@ pub extern "C" fn Servo_RestyleWithAddedDeclaration(declarations: RawServoDeclar
|
|||
previous_style: ServoComputedValuesBorrowed)
|
||||
-> ServoComputedValuesStrong
|
||||
{
|
||||
use style::declarations_iterators::RawDeclarationsIterator;
|
||||
|
||||
let previous_style = ComputedValues::as_arc(&previous_style);
|
||||
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||
|
||||
let guard = declarations.read();
|
||||
|
||||
let declarations =
|
||||
RawDeclarationsIterator::new(&guard.declarations);
|
||||
let declarations = || {
|
||||
guard.declarations.iter().rev().map(|&(ref decl, _importance)| decl)
|
||||
};
|
||||
|
||||
// FIXME (bug 1303229): Use the actual viewport size here
|
||||
let computed = apply_declarations(Size2D::new(Au(0), Au(0)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue