aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/window.rs
diff options
context:
space:
mode:
authorbors-servo <servo-ops@mozilla.com>2020-06-12 13:43:51 -0400
committerGitHub <noreply@github.com>2020-06-12 13:43:51 -0400
commit721271dcd3c20db5ca8cf146e2b5907647afb4d6 (patch)
tree75360f129a6172fd64040d46d88bdc2a8b0f66d0 /components/script/dom/window.rs
parentcb92a15600771a69a796f88975d8100f4be296ae (diff)
parent502f34a9db36202cd89f7a1b48bd138d2ce6f46e (diff)
downloadservo-721271dcd3c20db5ca8cf146e2b5907647afb4d6.tar.gz
servo-721271dcd3c20db5ca8cf146e2b5907647afb4d6.zip
Auto merge of #26697 - utsavoza:ugo/issue-11681/22-05-2020, r=jdm
Implement CanvasRenderingContext2d.fillText The PR consists of broadly two main changes: - Implementation of Canvas2dRenderingContext.font - Basic implementation of Canvas2dRenderingContext.fillText Although I am not fully sure about the long term goals for the canvas backend in Servo, I assumed limited scope for font and text handling (should support simple text drawing with font selection) in the current implementation as I believe a more complete implementation would eventually be brought in as a part of #22957. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #11681 - [x] There are tests for these changes
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r--components/script/dom/window.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index c050579918e..d7fde4f27d5 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -118,6 +118,7 @@ use script_traits::{
};
use script_traits::{TimerSchedulerMsg, WebrenderIpcSender, WindowSizeData, WindowSizeType};
use selectors::attr::CaseSensitivity;
+use servo_arc::Arc as ServoArc;
use servo_geometry::{f32_rect_to_au_rect, MaxRect};
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
use std::borrow::Cow;
@@ -136,7 +137,8 @@ use style::dom::OpaqueNode;
use style::error_reporting::{ContextualParseError, ParseErrorReporter};
use style::media_queries;
use style::parser::ParserContext as CssParserContext;
-use style::properties::PropertyId;
+use style::properties::style_structs::Font;
+use style::properties::{PropertyId, ShorthandId};
use style::selector_parser::PseudoElement;
use style::str::HTML_SPACE_CHARACTERS;
use style::stylesheets::CssRuleType;
@@ -1847,6 +1849,18 @@ impl Window {
)
}
+ pub fn resolved_font_style_query(&self, node: &Node, value: String) -> Option<ServoArc<Font>> {
+ let id = PropertyId::Shorthand(ShorthandId::Font);
+ if !self.layout_reflow(QueryMsg::ResolvedFontStyleQuery(
+ node.to_trusted_node_address(),
+ id,
+ value,
+ )) {
+ return None;
+ }
+ self.layout_rpc.resolved_font_style()
+ }
+
pub fn layout(&self) -> &dyn LayoutRPC {
&*self.layout_rpc
}
@@ -2500,6 +2514,7 @@ fn debug_reflow_events(id: PipelineId, reflow_goal: &ReflowGoal, reason: &Reflow
&QueryMsg::NodeScrollGeometryQuery(_n) => "\tNodeScrollGeometryQuery",
&QueryMsg::NodeScrollIdQuery(_n) => "\tNodeScrollIdQuery",
&QueryMsg::ResolvedStyleQuery(_, _, _) => "\tResolvedStyleQuery",
+ &QueryMsg::ResolvedFontStyleQuery(..) => "\nResolvedFontStyleQuery",
&QueryMsg::OffsetParentQuery(_n) => "\tOffsetParentQuery",
&QueryMsg::StyleQuery => "\tStyleQuery",
&QueryMsg::TextIndexQuery(..) => "\tTextIndexQuery",