Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CanvasRenderingContext2D.font property #26176

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Set up basic code for parsing css font value

  • Loading branch information
pylbrecht committed May 11, 2020
commit b70a255c94a2630db8bf6295e3e1f719a9e6fa43
@@ -49,6 +49,12 @@ use std::cell::Cell;
use std::fmt;
use std::str::FromStr;
use std::sync::Arc;
use style::context::QuirksMode;
use style::parser::ParserContext;
use style::properties::shorthands::font;
use style::stylesheets::origin::Origin;
use style::stylesheets::CssRuleType;
use style_traits::ParsingMode;

#[unrooted_must_root_lint::must_root]
#[derive(Clone, JSTraceable, MallocSizeOf)]
@@ -1565,8 +1571,22 @@ impl CanvasState {
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-font
pub fn set_font(&self, _value: DOMString) {
unimplemented!()
pub fn set_font(&self, value: DOMString) {
let mut input = ParserInput::new(&value);
let mut parser = Parser::new(&mut input);
let context = ParserContext::new(
Origin::Author,
&self.base_url,
Some(CssRuleType::Style),
ParsingMode::DEFAULT,
QuirksMode::NoQuirks,
None,
None,
);
match font::parse_value(&context, &mut parser) {
Ok(_longhands) => unimplemented!("TODO: handle parsed values"),
Err(_err) => unimplemented!("TODO: handle parse errors"),
}
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.