Bug 1302949 - Add a method to restyle with an added declaration; r=Manishearth

MozReview-Commit-ID: AbX0PCjjEM6
This commit is contained in:
Brian Birtles 2016-09-16 10:58:53 +09:00 committed by Manish Goregaokar
parent 1c78e1cb20
commit 45e0b90d63
2 changed files with 37 additions and 1 deletions

View file

@ -952,6 +952,11 @@ extern "C" {
pub fn Servo_RestyleSubtree(node: RawGeckoNodeBorrowed,
set: RawServoStyleSetBorrowedMut);
}
extern "C" {
pub fn Servo_RestyleWithAddedDeclaration(declarations: ServoDeclarationBlockBorrowed,
previous_style: ServoComputedValuesBorrowed)
-> ServoComputedValuesStrong;
}
extern "C" {
pub fn Servo_GetStyleFont(computed_values:
ServoComputedValuesBorrowedOrNull)

View file

@ -43,8 +43,9 @@ use style::parallel;
use style::parser::{ParserContext, ParserContextExtraData};
use style::properties::{ComputedValues, Importance, PropertyDeclaration};
use style::properties::{PropertyDeclarationParseResult, PropertyDeclarationBlock};
use style::properties::parse_one_declaration;
use style::properties::{cascade, parse_one_declaration};
use style::selector_impl::PseudoElementCascadeType;
use style::selector_matching::ApplicableDeclarationBlock;
use style::sequential;
use style::string_cache::Atom;
use style::stylesheets::{Origin, Stylesheet};
@ -96,6 +97,7 @@ fn restyle_subtree(node: GeckoNode, raw_data: RawServoStyleSetBorrowedMut) {
LocalStyleContextCreationInfo::new(per_doc_data.new_animations_sender.clone());
let shared_style_context = SharedStyleContext {
// FIXME (bug 1303229): Use the actual viewport size here
viewport_size: Size2D::new(Au(0), Au(0)),
screen_size_changed: false,
generation: 0,
@ -125,6 +127,35 @@ pub extern "C" fn Servo_RestyleSubtree(node: RawGeckoNodeBorrowed,
restyle_subtree(node, raw_data);
}
#[no_mangle]
pub extern "C" fn Servo_RestyleWithAddedDeclaration(declarations: ServoDeclarationBlockBorrowed,
previous_style: ServoComputedValuesBorrowed)
-> ServoComputedValuesStrong
{
match GeckoDeclarationBlock::as_arc(&declarations).declarations {
Some(ref declarations) => {
let declaration_block = ApplicableDeclarationBlock {
mixed_declarations: declarations.clone(),
importance: Importance::Normal,
source_order: 0,
specificity: ::std::u32::MAX,
};
let previous_style = ComputedValues::as_arc(&previous_style);
// FIXME (bug 1303229): Use the actual viewport size here
let (computed, _) = cascade(Size2D::new(Au(0), Au(0)),
&[declaration_block],
false,
Some(previous_style),
None,
None,
Box::new(StdoutErrorReporter));
Arc::new(computed).into_strong()
},
None => ServoComputedValuesStrong::null(),
}
}
#[no_mangle]
pub extern "C" fn Servo_StyleWorkerThreadCount() -> u32 {
*NUM_THREADS as u32