Skip to content

Commit

Permalink
Move DL items from gfx to layout
Browse files Browse the repository at this point in the history
Implement corner clipping.
Remove PixelFormat from WebrenderImageInfo.
Use WebRender text shadow.
Remove MallocSizeOf and Deserialize for DL items.

Closes #19649, #19680, #19802
  • Loading branch information
pyfisch committed Apr 22, 2018
1 parent 782d4d4 commit c0be925
Show file tree
Hide file tree
Showing 26 changed files with 417 additions and 287 deletions.
6 changes: 1 addition & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions components/gfx/Cargo.toml
Expand Up @@ -28,15 +28,12 @@ lazy_static = "1"
libc = "0.2"
log = "0.3.5"
malloc_size_of = { path = "../malloc_size_of" }
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
ordered-float = "0.4"
range = {path = "../range"}
serde = "1.0"
servo_arc = {path = "../servo_arc"}
servo_atoms = {path = "../atoms"}
servo_geometry = {path = "../geometry"}
servo_url = {path = "../url"}
smallvec = "0.6"
style = {path = "../style"}
Expand Down
6 changes: 0 additions & 6 deletions components/gfx/lib.rs
Expand Up @@ -43,14 +43,11 @@ extern crate libc;
extern crate log;
#[cfg_attr(target_os = "windows", macro_use)]
extern crate malloc_size_of;
#[macro_use] extern crate malloc_size_of_derive;
extern crate msg;
extern crate net_traits;
extern crate ordered_float;
extern crate range;
#[macro_use] extern crate serde;
extern crate servo_arc;
extern crate servo_geometry;
extern crate servo_url;
#[macro_use] extern crate servo_atoms;
#[cfg(feature = "unstable")]
Expand All @@ -66,9 +63,6 @@ extern crate xi_unicode;
#[cfg(target_os = "android")]
extern crate xml5ever;

#[deny(unsafe_code)]
pub mod display_list;

// Fonts
#[macro_use] pub mod font;
pub mod font_cache_thread;
Expand Down
10 changes: 9 additions & 1 deletion components/gfx/platform/macos/font_context.rs
Expand Up @@ -2,7 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#[derive(Clone, Debug, MallocSizeOf)]
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};

#[derive(Clone, Debug)]
pub struct FontContextHandle {
ctx: ()
}
Expand All @@ -13,3 +15,9 @@ impl FontContextHandle {
FontContextHandle { ctx: () }
}
}

impl MallocSizeOf for FontContextHandle {
fn size_of(&self, _: &mut MallocSizeOfOps) -> usize {
0
}
}
2 changes: 1 addition & 1 deletion components/layout/animation.rs
Expand Up @@ -5,9 +5,9 @@
//! CSS transitions and animations.

use context::LayoutContext;
use display_list::items::OpaqueNode;
use flow::{Flow, GetBaseFlow};
use fnv::FnvHashMap;
use gfx::display_list::OpaqueNode;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::PipelineId;
use opaque_node::OpaqueNodeMethods;
Expand Down
2 changes: 1 addition & 1 deletion components/layout/block.rs
Expand Up @@ -32,13 +32,13 @@ use context::LayoutContext;
use display_list::{BlockFlowDisplayListBuilding, BorderPaintingMode};
use display_list::{DisplayListBuildState, StackingContextCollectionFlags};
use display_list::StackingContextCollectionState;
use display_list::items::DisplayListSection;
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
use floats::{ClearType, FloatKind, Floats, PlacementInfo};
use flow::{BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, ForceNonfloatedFlag, GetBaseFlow};
use flow::{ImmutableFlowUtils, LateAbsolutePositionInfo, OpaqueFlow, FragmentationContext, FlowFlags};
use flow_list::FlowList;
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow, FragmentFlags};
use gfx::display_list::DisplayListSection;
use gfx_traits::print_tree::PrintTree;
use incremental::RelayoutMode;
use layout_debug;
Expand Down
2 changes: 1 addition & 1 deletion components/layout/construct.rs
Expand Up @@ -17,6 +17,7 @@ use ServoArc;
use block::BlockFlow;
use context::{LayoutContext, with_thread_local_font_context};
use data::{LayoutDataFlags, LayoutData};
use display_list::items::OpaqueNode;
use flex::FlexFlow;
use floats::FloatKind;
use flow::{AbsoluteDescendants, Flow, FlowClass, GetBaseFlow, ImmutableFlowUtils};
Expand All @@ -27,7 +28,6 @@ use fragment::{Fragment, GeneratedContentInfo, IframeFragmentInfo, FragmentFlags
use fragment::{InlineAbsoluteHypotheticalFragmentInfo, TableColumnFragmentInfo};
use fragment::{InlineBlockFragmentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo};
use fragment::WhitespaceStrippingResult;
use gfx::display_list::OpaqueNode;
use inline::{InlineFlow, InlineFragmentNodeInfo, InlineFragmentNodeFlags};
use linked_list::prepend_from;
use list_item::{ListItemFlow, ListStyleTypeContent};
Expand Down
2 changes: 1 addition & 1 deletion components/layout/context.rs
Expand Up @@ -4,8 +4,8 @@

//! Data needed by the layout thread.

use display_list::items::{WebRenderImageInfo, OpaqueNode};
use fnv::FnvHasher;
use gfx::display_list::{WebRenderImageInfo, OpaqueNode};
use gfx::font_cache_thread::FontCacheThread;
use gfx::font_context::FontContext;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
Expand Down
58 changes: 42 additions & 16 deletions components/layout/display_list/background.rs
Expand Up @@ -13,8 +13,8 @@

use app_units::Au;
use display_list::ToLayout;
use display_list::items::{BorderDetails, Gradient, RadialGradient, WebRenderImageInfo};
use euclid::{Point2D, Rect, SideOffsets2D, Size2D, Vector2D};
use gfx::display_list::{self, BorderDetails, WebRenderImageInfo};
use model::{self, MaybeAuto};
use style::computed_values::background_attachment::single_value::T as BackgroundAttachment;
use style::computed_values::background_clip::single_value::T as BackgroundClip;
Expand Down Expand Up @@ -56,7 +56,9 @@ pub struct BackgroundPlacement {
pub tile_spacing: Size2D<Au>,
/// A clip area. While the background is rendered according to all the
/// measures above it is only shown within these bounds.
pub css_clip: Rect<Au>,
pub clip_rect: Rect<Au>,
/// Rounded corners for the clip_rect.
pub clip_radii: BorderRadius,
/// Whether or not the background is fixed to the viewport.
pub fixed: bool,
}
Expand Down Expand Up @@ -149,6 +151,26 @@ fn compute_background_image_size(
}
}

pub fn compute_background_clip(
bg_clip: BackgroundClip,
absolute_bounds: Rect<Au>,
border: SideOffsets2D<Au>,
border_padding: SideOffsets2D<Au>,
border_radii: BorderRadius,
) -> (Rect<Au>, BorderRadius) {
match bg_clip {
BackgroundClip::BorderBox => (absolute_bounds, border_radii),
BackgroundClip::PaddingBox => (
absolute_bounds.inner_rect(border),
calculate_inner_border_radii(border_radii, border),
),
BackgroundClip::ContentBox => (
absolute_bounds.inner_rect(border_padding),
calculate_inner_border_radii(border_radii, border_padding),
),
}
}

/// Determines where to place an element background image or gradient.
///
/// Photos have their resolution as intrinsic size while gradients have
Expand All @@ -160,6 +182,7 @@ pub fn compute_background_placement(
intrinsic_size: Option<Size2D<Au>>,
border: SideOffsets2D<Au>,
border_padding: SideOffsets2D<Au>,
border_radii: BorderRadius,
index: usize,
) -> BackgroundPlacement {
let bg_attachment = *get_cyclic(&bg.background_attachment.0, index);
Expand All @@ -170,11 +193,13 @@ pub fn compute_background_placement(
let bg_repeat = get_cyclic(&bg.background_repeat.0, index);
let bg_size = *get_cyclic(&bg.background_size.0, index);

let css_clip = match bg_clip {
BackgroundClip::BorderBox => absolute_bounds,
BackgroundClip::PaddingBox => absolute_bounds.inner_rect(border),
BackgroundClip::ContentBox => absolute_bounds.inner_rect(border_padding),
};
let (clip_rect, clip_radii) = compute_background_clip(
bg_clip,
absolute_bounds,
border,
border_padding,
border_radii,
);

let mut fixed = false;
let mut bounds = match bg_attachment {
Expand Down Expand Up @@ -202,8 +227,8 @@ pub fn compute_background_placement(
&mut tile_size.width,
&mut tile_spacing.width,
pos_x,
css_clip.origin.x,
css_clip.size.width,
clip_rect.origin.x,
clip_rect.size.width,
);
tile_image_axis(
bg_repeat.1,
Expand All @@ -212,15 +237,16 @@ pub fn compute_background_placement(
&mut tile_size.height,
&mut tile_spacing.height,
pos_y,
css_clip.origin.y,
css_clip.size.height,
clip_rect.origin.y,
clip_rect.size.height,
);

BackgroundPlacement {
bounds,
tile_size,
tile_spacing,
css_clip,
clip_rect,
clip_radii,
fixed,
}
}
Expand Down Expand Up @@ -508,7 +534,7 @@ pub fn convert_linear_gradient(
stops: &[GradientItem],
direction: LineDirection,
repeating: bool,
) -> display_list::Gradient {
) -> Gradient {
let angle = match direction {
LineDirection::Angle(angle) => angle.radians(),
LineDirection::Horizontal(x) => match x {
Expand Down Expand Up @@ -556,7 +582,7 @@ pub fn convert_linear_gradient(

let center = Point2D::new(size.width / 2, size.height / 2);

display_list::Gradient {
Gradient {
start_point: (center - delta).to_layout(),
end_point: (center + delta).to_layout(),
stops: stops,
Expand All @@ -570,7 +596,7 @@ pub fn convert_radial_gradient(
shape: EndingShape,
center: Position,
repeating: bool,
) -> display_list::RadialGradient {
) -> RadialGradient {
let center = Point2D::new(
center.horizontal.to_used_value(size.width),
center.vertical.to_used_value(size.height),
Expand All @@ -593,7 +619,7 @@ pub fn convert_radial_gradient(

let stops = convert_gradient_stops(stops, radius.width);

display_list::RadialGradient {
RadialGradient {
center: center.to_layout(),
radius: radius.to_layout(),
stops: stops,
Expand Down

0 comments on commit c0be925

Please sign in to comment.