mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
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
This commit is contained in:
commit
721271dcd3
57 changed files with 928 additions and 183 deletions
|
@ -21,12 +21,14 @@ use script_layout_interface::wrapper_traits::{
|
|||
};
|
||||
use script_traits::LayoutMsg as ConstellationMsg;
|
||||
use script_traits::UntrustedNodeAddress;
|
||||
use servo_arc::Arc as ServoArc;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use style::computed_values::position::T as Position;
|
||||
use style::context::{StyleContext, ThreadLocalStyleContext};
|
||||
use style::dom::OpaqueNode;
|
||||
use style::dom::TElement;
|
||||
use style::properties::style_structs::Font;
|
||||
use style::properties::{LonghandId, PropertyDeclarationId, PropertyId};
|
||||
use style::selector_parser::PseudoElement;
|
||||
use style::stylist::RuleInclusion;
|
||||
|
@ -65,6 +67,9 @@ pub struct LayoutThreadData {
|
|||
/// A queued response for the resolved style property of an element.
|
||||
pub resolved_style_response: String,
|
||||
|
||||
/// A queued response for the resolved font style for canvas.
|
||||
pub resolved_font_style_response: Option<ServoArc<Font>>,
|
||||
|
||||
/// A queued response for the offset parent/rect of a node.
|
||||
pub offset_parent_response: OffsetParentResponse,
|
||||
|
||||
|
@ -139,6 +144,12 @@ impl LayoutRPC for LayoutRPCImpl {
|
|||
ResolvedStyleResponse(rw_data.resolved_style_response.clone())
|
||||
}
|
||||
|
||||
fn resolved_font_style(&self) -> Option<ServoArc<Font>> {
|
||||
let &LayoutRPCImpl(ref rw_data) = self;
|
||||
let rw_data = rw_data.lock().unwrap();
|
||||
rw_data.resolved_font_style_response.clone()
|
||||
}
|
||||
|
||||
fn offset_parent(&self) -> OffsetParentResponse {
|
||||
let &LayoutRPCImpl(ref rw_data) = self;
|
||||
let rw_data = rw_data.lock().unwrap();
|
||||
|
@ -376,3 +387,11 @@ pub fn process_element_inner_text_query<'dom>(_node: impl LayoutNode<'dom>) -> S
|
|||
pub fn process_text_index_request(_node: OpaqueNode, _point: Point2D<Au>) -> TextIndexResponse {
|
||||
TextIndexResponse(None)
|
||||
}
|
||||
|
||||
pub fn process_resolved_font_style_query<'dom>(
|
||||
_node: impl LayoutNode<'dom>,
|
||||
_property: &PropertyId,
|
||||
_value: &str,
|
||||
) -> Option<ServoArc<Font>> {
|
||||
None
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue