aboutsummaryrefslogtreecommitdiffstats
path: root/ports/geckolib
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-05-21 23:22:35 -0500
committerGitHub <noreply@github.com>2017-05-21 23:22:35 -0500
commit8cd4330b2afdaf6f5a1724539a25a27850d41e29 (patch)
tree00d48a523f4e950b835ee19ca81773f901e18baf /ports/geckolib
parentb42ee29c1bc66484406c289c70aa5c4795728743 (diff)
parent36a87bc19dd56667aafd7e43896db6c34764fd1e (diff)
downloadservo-8cd4330b2afdaf6f5a1724539a25a27850d41e29.tar.gz
servo-8cd4330b2afdaf6f5a1724539a25a27850d41e29.zip
Auto merge of #16959 - hiikezoe:font-serialization-for-canvas, r=Manishearth,emilio
Font serialization for canvas <!-- Please describe your changes on the following line: --> This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1362914 --- <!-- 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 - [X] These changes do not require tests because it's for stylo <!-- 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/16959) <!-- Reviewable:end -->
Diffstat (limited to 'ports/geckolib')
-rw-r--r--ports/geckolib/glue.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs
index bc4db3e7204..c3617682dc7 100644
--- a/ports/geckolib/glue.rs
+++ b/ports/geckolib/glue.rs
@@ -1435,6 +1435,29 @@ pub extern "C" fn Servo_DeclarationBlock_SerializeOneValue(
}
#[no_mangle]
+pub extern "C" fn Servo_SerializeFontValueForCanvas(
+ declarations: RawServoDeclarationBlockBorrowed,
+ buffer: *mut nsAString) {
+ use style::properties::shorthands::font;
+
+ read_locked_arc(declarations, |decls: &PropertyDeclarationBlock| {
+ let longhands = match font::LonghandsToSerialize::from_iter(decls.declarations_iter()) {
+ Ok(l) => l,
+ Err(()) => {
+ warn!("Unexpected property!");
+ return;
+ }
+ };
+
+ let mut string = String::new();
+ let rv = longhands.to_css_for_canvas(&mut string);
+ debug_assert!(rv.is_ok());
+
+ write!(unsafe { &mut *buffer }, "{}", string).expect("Failed to copy string");
+ })
+}
+
+#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_Count(declarations: RawServoDeclarationBlockBorrowed) -> u32 {
read_locked_arc(declarations, |decls: &PropertyDeclarationBlock| {
decls.declarations().len() as u32