mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #17771 - mrobinson:wr-update-shadows, r=emilio
Update WR (text-shadow improvements, iframe + image clips, depth buffer sharing) <!-- Please describe your changes on the following line: --> --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/17771) <!-- Reviewable:end -->
This commit is contained in:
commit
988a516a5b
4 changed files with 152 additions and 99 deletions
54
Cargo.lock
generated
54
Cargo.lock
generated
|
@ -333,7 +333,7 @@ dependencies = [
|
|||
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"offscreen_gl_context 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo_config 0.0.1",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -346,7 +346,7 @@ dependencies = [
|
|||
"heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ipc-channel 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -497,8 +497,8 @@ dependencies = [
|
|||
"servo_url 0.0.1",
|
||||
"style_traits 0.0.1",
|
||||
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -534,7 +534,7 @@ dependencies = [
|
|||
"servo_remutex 0.0.1",
|
||||
"servo_url 0.0.1",
|
||||
"style_traits 0.0.1",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
"webvr_traits 0.0.1",
|
||||
]
|
||||
|
||||
|
@ -770,7 +770,7 @@ dependencies = [
|
|||
"servo_geometry 0.0.1",
|
||||
"servo_url 0.0.1",
|
||||
"style_traits 0.0.1",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
"x11 2.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1074,7 +1074,7 @@ dependencies = [
|
|||
"truetype 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-bidi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
"xi-unicode 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xml5ever 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -1155,7 +1155,7 @@ dependencies = [
|
|||
"servo_url 0.0.1",
|
||||
"style_traits 0.0.1",
|
||||
"user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"x11 2.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -1470,7 +1470,7 @@ dependencies = [
|
|||
"style_traits 0.0.1",
|
||||
"unicode-bidi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1514,7 +1514,7 @@ dependencies = [
|
|||
"servo_geometry 0.0.1",
|
||||
"servo_url 0.0.1",
|
||||
"style 0.0.1",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1528,7 +1528,7 @@ dependencies = [
|
|||
"profile_traits 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"servo_url 0.0.1",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1612,8 +1612,8 @@ dependencies = [
|
|||
"style 0.0.1",
|
||||
"style_traits 0.0.1",
|
||||
"webdriver_server 0.0.1",
|
||||
"webrender 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
"webvr 0.0.1",
|
||||
"webvr_traits 0.0.1",
|
||||
]
|
||||
|
@ -1775,7 +1775,7 @@ dependencies = [
|
|||
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1825,7 +1825,7 @@ dependencies = [
|
|||
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1883,7 +1883,7 @@ dependencies = [
|
|||
"servo_url 0.0.1",
|
||||
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2484,7 +2484,7 @@ dependencies = [
|
|||
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"utf-8 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
"webvr 0.0.1",
|
||||
"webvr_traits 0.0.1",
|
||||
"xml5ever 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2515,7 +2515,7 @@ dependencies = [
|
|||
"servo_atoms 0.0.1",
|
||||
"servo_url 0.0.1",
|
||||
"style 0.0.1",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2560,7 +2560,7 @@ dependencies = [
|
|||
"style_traits 0.0.1",
|
||||
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
"webvr_traits 0.0.1",
|
||||
]
|
||||
|
||||
|
@ -3421,8 +3421,8 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "webrender"
|
||||
version = "0.47.0"
|
||||
source = "git+https://github.com/servo/webrender#33e6e285553e8f5ab4b17f3ff8f4eeecd76d2264"
|
||||
version = "0.48.0"
|
||||
source = "git+https://github.com/servo/webrender#80453c8168a176342801fcbabdcf06a601c07c4d"
|
||||
dependencies = [
|
||||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -3445,13 +3445,13 @@ dependencies = [
|
|||
"rayon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thread_profiler 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webrender_api"
|
||||
version = "0.47.0"
|
||||
source = "git+https://github.com/servo/webrender#33e6e285553e8f5ab4b17f3ff8f4eeecd76d2264"
|
||||
version = "0.48.0"
|
||||
source = "git+https://github.com/servo/webrender#80453c8168a176342801fcbabdcf06a601c07c4d"
|
||||
dependencies = [
|
||||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -3477,7 +3477,7 @@ dependencies = [
|
|||
"msg 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"servo_config 0.0.1",
|
||||
"webrender_api 0.47.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
|
||||
"webvr_traits 0.0.1",
|
||||
]
|
||||
|
||||
|
@ -3861,8 +3861,8 @@ dependencies = [
|
|||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
"checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff"
|
||||
"checksum webdriver 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d548aabf87411b1b4ba91fd07eacd8b238135c7131a452b8a9f6386209167e18"
|
||||
"checksum webrender 0.47.0 (git+https://github.com/servo/webrender)" = "<none>"
|
||||
"checksum webrender_api 0.47.0 (git+https://github.com/servo/webrender)" = "<none>"
|
||||
"checksum webrender 0.48.0 (git+https://github.com/servo/webrender)" = "<none>"
|
||||
"checksum webrender_api 0.48.0 (git+https://github.com/servo/webrender)" = "<none>"
|
||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||
"checksum ws 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "04614a58714f3fd4a8b1da4bcae9f031c532d35988c3d39627619248113f8be8"
|
||||
|
|
|
@ -605,6 +605,8 @@ pub enum DisplayItem {
|
|||
RadialGradient(Box<RadialGradientDisplayItem>),
|
||||
Line(Box<LineDisplayItem>),
|
||||
BoxShadow(Box<BoxShadowDisplayItem>),
|
||||
PushTextShadow(Box<PushTextShadowDisplayItem>),
|
||||
PopTextShadow(Box<PopTextShadowDisplayItem>),
|
||||
Iframe(Box<IframeDisplayItem>),
|
||||
PushStackingContext(Box<PushStackingContextItem>),
|
||||
PopStackingContext(Box<PopStackingContextItem>),
|
||||
|
@ -895,9 +897,6 @@ pub struct TextDisplayItem {
|
|||
|
||||
/// The orientation of the text: upright or sideways left/right.
|
||||
pub orientation: TextOrientation,
|
||||
|
||||
/// The blur radius for this text. If zero, this text is not blurred.
|
||||
pub blur_radius: Au,
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, HeapSizeOf, Deserialize, Serialize)]
|
||||
|
@ -1180,6 +1179,29 @@ pub struct BoxShadowDisplayItem {
|
|||
pub clip_mode: BoxShadowClipMode,
|
||||
}
|
||||
|
||||
/// Defines a text shadow that affects all items until the paired PopTextShadow.
|
||||
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct PushTextShadowDisplayItem {
|
||||
/// Fields common to all display items.
|
||||
pub base: BaseDisplayItem,
|
||||
|
||||
/// The offset of this shadow from the text.
|
||||
pub offset: Vector2D<Au>,
|
||||
|
||||
/// The color of this shadow.
|
||||
pub color: ColorF,
|
||||
|
||||
/// The blur radius for this shadow.
|
||||
pub blur_radius: Au,
|
||||
}
|
||||
|
||||
/// Defines a text shadow that affects all items until the next PopTextShadow.
|
||||
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct PopTextShadowDisplayItem {
|
||||
/// Fields common to all display items.
|
||||
pub base: BaseDisplayItem,
|
||||
}
|
||||
|
||||
/// Defines a stacking context.
|
||||
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct PushStackingContextItem {
|
||||
|
@ -1233,6 +1255,8 @@ impl DisplayItem {
|
|||
DisplayItem::RadialGradient(ref gradient) => &gradient.base,
|
||||
DisplayItem::Line(ref line) => &line.base,
|
||||
DisplayItem::BoxShadow(ref box_shadow) => &box_shadow.base,
|
||||
DisplayItem::PushTextShadow(ref push_text_shadow) => &push_text_shadow.base,
|
||||
DisplayItem::PopTextShadow(ref pop_text_shadow) => &pop_text_shadow.base,
|
||||
DisplayItem::Iframe(ref iframe) => &iframe.base,
|
||||
DisplayItem::PushStackingContext(ref stacking_context) => &stacking_context.base,
|
||||
DisplayItem::PopStackingContext(ref item) => &item.base,
|
||||
|
@ -1353,6 +1377,8 @@ impl fmt::Debug for DisplayItem {
|
|||
DisplayItem::RadialGradient(_) => "RadialGradient".to_owned(),
|
||||
DisplayItem::Line(_) => "Line".to_owned(),
|
||||
DisplayItem::BoxShadow(_) => "BoxShadow".to_owned(),
|
||||
DisplayItem::PushTextShadow(_) => "PushTextShadow".to_owned(),
|
||||
DisplayItem::PopTextShadow(_) => "PopTextShadow".to_owned(),
|
||||
DisplayItem::Iframe(_) => "Iframe".to_owned(),
|
||||
DisplayItem::PushStackingContext(_) |
|
||||
DisplayItem::PopStackingContext(_) |
|
||||
|
|
|
@ -25,10 +25,10 @@ use gfx::display_list::{BLUR_INFLATION_FACTOR, BaseDisplayItem, BorderDetails, B
|
|||
use gfx::display_list::{BorderRadii, BoxShadowClipMode, BoxShadowDisplayItem, ClippingRegion};
|
||||
use gfx::display_list::{DisplayItem, DisplayItemMetadata, DisplayList, DisplayListSection};
|
||||
use gfx::display_list::{GradientDisplayItem, IframeDisplayItem, ImageBorder, ImageDisplayItem};
|
||||
use gfx::display_list::{LineDisplayItem, NormalBorder, OpaqueNode, RadialGradientDisplayItem};
|
||||
use gfx::display_list::{ScrollRoot, ScrollRootType, SolidColorDisplayItem, StackingContext};
|
||||
use gfx::display_list::{StackingContextType, TextDisplayItem, TextOrientation, WebGLDisplayItem};
|
||||
use gfx::display_list::WebRenderImageInfo;
|
||||
use gfx::display_list::{LineDisplayItem, NormalBorder, OpaqueNode, PushTextShadowDisplayItem};
|
||||
use gfx::display_list::{PopTextShadowDisplayItem, RadialGradientDisplayItem, ScrollRoot};
|
||||
use gfx::display_list::{ScrollRootType, SolidColorDisplayItem, StackingContext, StackingContextType};
|
||||
use gfx::display_list::{TextDisplayItem, TextOrientation, WebGLDisplayItem, WebRenderImageInfo};
|
||||
use gfx_traits::{combine_id_with_fragment_type, FragmentType, StackingContextId};
|
||||
use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, LAST_FRAGMENT_OF_ELEMENT};
|
||||
use ipc_channel::ipc;
|
||||
|
@ -525,7 +525,7 @@ pub trait FragmentDisplayListBuilding {
|
|||
state: &mut DisplayListBuildState,
|
||||
text_fragment: &ScannedTextFragmentInfo,
|
||||
stacking_relative_content_box: &Rect<Au>,
|
||||
text_shadow: Option<&SimpleShadow>,
|
||||
text_shadows: &[SimpleShadow],
|
||||
clip: &Rect<Au>);
|
||||
|
||||
/// Creates the display item for a text decoration: underline, overline, or line-through.
|
||||
|
@ -533,8 +533,7 @@ pub trait FragmentDisplayListBuilding {
|
|||
state: &mut DisplayListBuildState,
|
||||
color: &RGBA,
|
||||
stacking_relative_box: &LogicalRect<Au>,
|
||||
clip: &Rect<Au>,
|
||||
blur: Au);
|
||||
clip: &Rect<Au>);
|
||||
|
||||
/// A helper method that `build_display_list` calls to create per-fragment-type display items.
|
||||
fn build_fragment_type_specific_display_items(&mut self,
|
||||
|
@ -1872,30 +1871,31 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
let stacking_relative_content_box =
|
||||
self.stacking_relative_content_box(stacking_relative_border_box);
|
||||
|
||||
// Adjust the clipping region as necessary to account for `border-radius`.
|
||||
let build_local_clip = |style: &ComputedValues| {
|
||||
let radii = build_border_radius_for_inner_rect(&stacking_relative_border_box, style);
|
||||
if !radii.is_square() {
|
||||
LocalClip::RoundedRect(
|
||||
stacking_relative_border_box.to_rectf(),
|
||||
ComplexClipRegion::new(stacking_relative_content_box.to_rectf(),
|
||||
radii.to_border_radius(),
|
||||
))
|
||||
} else {
|
||||
LocalClip::Rect(stacking_relative_border_box.to_rectf())
|
||||
}
|
||||
};
|
||||
|
||||
match self.specific {
|
||||
SpecificFragmentInfo::TruncatedFragment(box TruncatedFragmentInfo {
|
||||
text_info: Some(ref text_fragment),
|
||||
..
|
||||
}) |
|
||||
SpecificFragmentInfo::ScannedText(box ref text_fragment) => {
|
||||
// Create items for shadows.
|
||||
//
|
||||
// NB: According to CSS-BACKGROUNDS, text shadows render in *reverse* order (front
|
||||
// to back).
|
||||
|
||||
for text_shadow in self.style.get_inheritedtext().text_shadow.0.iter().rev() {
|
||||
self.build_display_list_for_text_fragment(state,
|
||||
&*text_fragment,
|
||||
&stacking_relative_content_box,
|
||||
Some(text_shadow),
|
||||
clip);
|
||||
}
|
||||
|
||||
// Create the main text display item.
|
||||
self.build_display_list_for_text_fragment(state,
|
||||
&*text_fragment,
|
||||
&stacking_relative_content_box,
|
||||
None,
|
||||
&self.style.get_inheritedtext().text_shadow.0,
|
||||
clip);
|
||||
|
||||
if opts::get().show_debug_fragment_borders {
|
||||
|
@ -1930,7 +1930,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
if !stacking_relative_content_box.is_empty() {
|
||||
let base = state.create_base_display_item(
|
||||
&stacking_relative_content_box,
|
||||
LocalClip::from(clip.to_rectf()),
|
||||
build_local_clip(&self.style),
|
||||
self.node,
|
||||
self.style.get_cursor(Cursor::Default),
|
||||
DisplayListSection::Content);
|
||||
|
@ -1941,7 +1941,8 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
let size = Size2D::new(item.bounds().size.width.to_f32_px(),
|
||||
item.bounds().size.height.to_f32_px());
|
||||
state.iframe_sizes.push((fragment_info.browsing_context_id, TypedSize2D::from_untyped(&size)));
|
||||
state.iframe_sizes.push((fragment_info.browsing_context_id,
|
||||
TypedSize2D::from_untyped(&size)));
|
||||
|
||||
state.add_display_item(item);
|
||||
}
|
||||
|
@ -1951,7 +1952,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
if let Some(ref image) = image_fragment.image {
|
||||
let base = state.create_base_display_item(
|
||||
&stacking_relative_content_box,
|
||||
LocalClip::from(clip.to_rectf()),
|
||||
build_local_clip(&self.style),
|
||||
self.node,
|
||||
self.style.get_cursor(Cursor::Default),
|
||||
DisplayListSection::Content);
|
||||
|
@ -1982,7 +1983,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
let base = state.create_base_display_item(
|
||||
&stacking_relative_content_box,
|
||||
LocalClip::from(clip.to_rectf()),
|
||||
build_local_clip(&self.style),
|
||||
self.node,
|
||||
self.style.get_cursor(Cursor::Default),
|
||||
DisplayListSection::Content);
|
||||
|
@ -2077,22 +2078,19 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
state: &mut DisplayListBuildState,
|
||||
text_fragment: &ScannedTextFragmentInfo,
|
||||
stacking_relative_content_box: &Rect<Au>,
|
||||
text_shadow: Option<&SimpleShadow>,
|
||||
text_shadows: &[SimpleShadow],
|
||||
clip: &Rect<Au>) {
|
||||
// NB: The order for painting text components (CSS Text Decoration Module Level 3) is:
|
||||
// shadows, underline, overline, text, text-emphasis, and then line-through.
|
||||
|
||||
// TODO(emilio): Allow changing more properties by ::selection
|
||||
let text_color = if let Some(shadow) = text_shadow {
|
||||
// If we're painting a shadow, paint the text the same color as the shadow.
|
||||
self.style().resolve_color(shadow.color)
|
||||
} else if text_fragment.selected() {
|
||||
// Otherwise, paint the text with the color as described in its styling.
|
||||
// Paint the text with the color as described in its styling.
|
||||
let text_color = if text_fragment.selected() {
|
||||
self.selected_style().get_color().color
|
||||
} else {
|
||||
self.style().get_color().color
|
||||
};
|
||||
let offset = text_shadow.map_or(Vector2D::zero(), |s| {
|
||||
Vector2D::new(s.horizontal, s.vertical)
|
||||
});
|
||||
let shadow_blur_radius = text_shadow.map(|s| s.blur).unwrap_or(Au(0));
|
||||
|
||||
|
||||
// Determine the orientation and cursor to use.
|
||||
let (orientation, cursor) = if self.style.writing_mode.is_vertical() {
|
||||
|
@ -2108,28 +2106,32 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
// FIXME(pcwalton): Get the real container size.
|
||||
let container_size = Size2D::zero();
|
||||
let metrics = &text_fragment.run.font_metrics;
|
||||
let stacking_relative_content_box = stacking_relative_content_box.translate(&offset);
|
||||
let baseline_origin = stacking_relative_content_box.origin +
|
||||
LogicalPoint::new(self.style.writing_mode,
|
||||
Au(0),
|
||||
metrics.ascent).to_physical(self.style.writing_mode,
|
||||
container_size).to_vector();
|
||||
|
||||
// Create the text display item.
|
||||
// Base item for all text/shadows
|
||||
let base = state.create_base_display_item(&stacking_relative_content_box,
|
||||
LocalClip::from(clip.to_rectf()),
|
||||
self.node,
|
||||
self.style().get_cursor(cursor),
|
||||
DisplayListSection::Content);
|
||||
state.add_display_item(DisplayItem::Text(box TextDisplayItem {
|
||||
base: base,
|
||||
text_run: text_fragment.run.clone(),
|
||||
range: text_fragment.range,
|
||||
text_color: text_color.to_gfx_color(),
|
||||
orientation: orientation,
|
||||
baseline_origin: baseline_origin,
|
||||
blur_radius: shadow_blur_radius,
|
||||
}));
|
||||
|
||||
// NB: According to CSS-BACKGROUNDS, text shadows render in *reverse* order (front
|
||||
// to back).
|
||||
|
||||
// Shadows
|
||||
for shadow in text_shadows.iter() {
|
||||
state.add_display_item(DisplayItem::PushTextShadow(box PushTextShadowDisplayItem {
|
||||
base: base.clone(),
|
||||
blur_radius: shadow.blur,
|
||||
offset: Vector2D::new(shadow.horizontal, shadow.vertical),
|
||||
color: self.style().resolve_color(shadow.color).to_gfx_color(),
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
// Create display items for text decorations.
|
||||
let mut text_decorations = self.style()
|
||||
|
@ -2142,8 +2144,10 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
let stacking_relative_content_box =
|
||||
LogicalRect::from_physical(self.style.writing_mode,
|
||||
stacking_relative_content_box,
|
||||
*stacking_relative_content_box,
|
||||
container_size);
|
||||
|
||||
// Underline
|
||||
if let Some(ref underline_color) = text_decorations.underline {
|
||||
let mut stacking_relative_box = stacking_relative_content_box;
|
||||
stacking_relative_box.start.b = stacking_relative_content_box.start.b +
|
||||
|
@ -2152,20 +2156,35 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
self.build_display_list_for_text_decoration(state,
|
||||
underline_color,
|
||||
&stacking_relative_box,
|
||||
clip,
|
||||
shadow_blur_radius);
|
||||
clip);
|
||||
}
|
||||
|
||||
// Overline
|
||||
if let Some(ref overline_color) = text_decorations.overline {
|
||||
let mut stacking_relative_box = stacking_relative_content_box;
|
||||
stacking_relative_box.size.block = metrics.underline_size;
|
||||
self.build_display_list_for_text_decoration(state,
|
||||
overline_color,
|
||||
&stacking_relative_box,
|
||||
clip,
|
||||
shadow_blur_radius);
|
||||
clip);
|
||||
}
|
||||
|
||||
// Text
|
||||
state.add_display_item(DisplayItem::Text(box TextDisplayItem {
|
||||
base: base.clone(),
|
||||
text_run: text_fragment.run.clone(),
|
||||
range: text_fragment.range,
|
||||
text_color: text_color.to_gfx_color(),
|
||||
orientation: orientation,
|
||||
baseline_origin: baseline_origin,
|
||||
}));
|
||||
|
||||
|
||||
// TODO(#17715): emit text-emphasis marks here.
|
||||
// (just push another TextDisplayItem?)
|
||||
|
||||
|
||||
// Line-Through
|
||||
if let Some(ref line_through_color) = text_decorations.line_through {
|
||||
let mut stacking_relative_box = stacking_relative_content_box;
|
||||
stacking_relative_box.start.b = stacking_relative_box.start.b + metrics.ascent -
|
||||
|
@ -2174,8 +2193,14 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
self.build_display_list_for_text_decoration(state,
|
||||
line_through_color,
|
||||
&stacking_relative_box,
|
||||
clip,
|
||||
shadow_blur_radius);
|
||||
clip);
|
||||
}
|
||||
|
||||
// Pair all the PushTextShadows
|
||||
for _ in text_shadows {
|
||||
state.add_display_item(DisplayItem::PopTextShadow(box PopTextShadowDisplayItem {
|
||||
base: base.clone(),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2183,31 +2208,21 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
state: &mut DisplayListBuildState,
|
||||
color: &RGBA,
|
||||
stacking_relative_box: &LogicalRect<Au>,
|
||||
clip: &Rect<Au>,
|
||||
blur_radius: Au) {
|
||||
// Perhaps surprisingly, text decorations are box shadows. This is because they may need
|
||||
// to have blur in the case of `text-shadow`, and this doesn't hurt performance because box
|
||||
// shadows are optimized into essentially solid colors if there is no need for the blur.
|
||||
//
|
||||
clip: &Rect<Au>) {
|
||||
// FIXME(pcwalton, #2795): Get the real container size.
|
||||
let container_size = Size2D::zero();
|
||||
let stacking_relative_box = stacking_relative_box.to_physical(self.style.writing_mode,
|
||||
container_size);
|
||||
let base = state.create_base_display_item(
|
||||
&shadow_bounds(&stacking_relative_box, blur_radius, Au(0)),
|
||||
&stacking_relative_box,
|
||||
LocalClip::from(clip.to_rectf()),
|
||||
self.node,
|
||||
self.style.get_cursor(Cursor::Default),
|
||||
DisplayListSection::Content);
|
||||
state.add_display_item(DisplayItem::BoxShadow(box BoxShadowDisplayItem {
|
||||
|
||||
state.add_display_item(DisplayItem::SolidColor(box SolidColorDisplayItem {
|
||||
base: base,
|
||||
box_bounds: stacking_relative_box,
|
||||
color: color.to_gfx_color(),
|
||||
offset: Vector2D::zero(),
|
||||
blur_radius: blur_radius,
|
||||
spread_radius: Au(0),
|
||||
border_radius: Au(0),
|
||||
clip_mode: BoxShadowClipMode::None,
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -289,7 +289,6 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
|||
item.text_run.font_key,
|
||||
item.text_color,
|
||||
item.text_run.actual_pt_size,
|
||||
item.blur_radius.to_f32_px(),
|
||||
None);
|
||||
}
|
||||
}
|
||||
|
@ -449,10 +448,23 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
|||
item.border_radius.to_f32_px(),
|
||||
item.clip_mode.to_clip_mode());
|
||||
}
|
||||
DisplayItem::PushTextShadow(ref item) => {
|
||||
let rect = item.base.bounds.to_rectf();
|
||||
builder.push_text_shadow(rect,
|
||||
Some(item.base.local_clip),
|
||||
webrender_api::TextShadow {
|
||||
blur_radius: item.blur_radius.to_f32_px(),
|
||||
offset: item.offset.to_vectorf(),
|
||||
color: item.color,
|
||||
});
|
||||
}
|
||||
DisplayItem::PopTextShadow(_) => {
|
||||
builder.pop_text_shadow();
|
||||
}
|
||||
DisplayItem::Iframe(ref item) => {
|
||||
let rect = item.base.bounds.to_rectf();
|
||||
let pipeline_id = item.iframe.to_webrender();
|
||||
builder.push_iframe(rect, pipeline_id);
|
||||
builder.push_iframe(rect, Some(item.base.local_clip), pipeline_id);
|
||||
}
|
||||
DisplayItem::PushStackingContext(ref item) => {
|
||||
let stacking_context = &item.stacking_context;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue