Skip to content

Commit

Permalink
Bug 1302949 - Add a method to restyle with an added declaration; r=Ma…
Browse files Browse the repository at this point in the history
…nishearth

MozReview-Commit-ID: AbX0PCjjEM6
  • Loading branch information
birtles authored and Manishearth committed Oct 9, 2016
1 parent 1c78e1c commit 45e0b90
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions components/style/gecko_bindings/bindings.rs
Expand Up @@ -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)
Expand Down
33 changes: 32 additions & 1 deletion ports/geckolib/glue.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 45e0b90

Please sign in to comment.