mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
auto merge of #5134 : pcwalton/servo/transforms, r=SimonSapin
r? @SimonSapin
This commit is contained in:
commit
203240c1d8
14 changed files with 964 additions and 35 deletions
|
@ -19,10 +19,10 @@ use fragment::{CoordinateSystem, Fragment, IframeFragmentInfo, ImageFragmentInfo
|
|||
use fragment::{ScannedTextFragmentInfo, SpecificFragmentInfo};
|
||||
use inline::InlineFlow;
|
||||
use list_item::ListItemFlow;
|
||||
use model::{self, MaybeAuto};
|
||||
use model::{self, MaybeAuto, ToGfxMatrix};
|
||||
use opaque_node::OpaqueNodeMethods;
|
||||
|
||||
use geom::{Point2D, Rect, Size2D, SideOffsets2D};
|
||||
use geom::{Matrix2D, Point2D, Rect, Size2D, SideOffsets2D};
|
||||
use gfx::color;
|
||||
use gfx::display_list::{BLUR_INFLATION_FACTOR, BaseDisplayItem, BorderDisplayItem};
|
||||
use gfx::display_list::{BorderRadii, BoxShadowClipMode, BoxShadowDisplayItem, ClippingRegion};
|
||||
|
@ -49,6 +49,7 @@ use style::values::specified::{AngleOrCorner, HorizontalDirection, VerticalDirec
|
|||
use style::values::computed::{Image, LinearGradient, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use style::values::RGBA;
|
||||
use style::computed_values::filter::Filter;
|
||||
use style::computed_values::transform::ComputedMatrix;
|
||||
use style::computed_values::{background_attachment, background_repeat, background_size};
|
||||
use style::computed_values::{border_style, image_rendering, overflow_x, position, visibility};
|
||||
use style::properties::style_structs::Border;
|
||||
|
@ -1369,6 +1370,22 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
|||
.relative_containing_block_mode,
|
||||
CoordinateSystem::Parent);
|
||||
|
||||
let transform_origin = self.fragment.style().get_effects().transform_origin;
|
||||
let transform_origin =
|
||||
Point2D(model::specified(transform_origin.horizontal,
|
||||
border_box.size.width).to_frac32_px(),
|
||||
model::specified(transform_origin.vertical,
|
||||
border_box.size.height).to_frac32_px());
|
||||
let transform = self.fragment
|
||||
.style()
|
||||
.get_effects()
|
||||
.transform
|
||||
.unwrap_or(ComputedMatrix::identity())
|
||||
.to_gfx_matrix(&border_box.size);
|
||||
let transform = Matrix2D::identity().translate(transform_origin.x, transform_origin.y)
|
||||
.mul(&transform)
|
||||
.translate(-transform_origin.x, -transform_origin.y);
|
||||
|
||||
// FIXME(pcwalton): Is this vertical-writing-direction-safe?
|
||||
let margin = self.fragment.margin.to_physical(self.base.writing_mode);
|
||||
let overflow = self.base.overflow.translate(&-Point2D(margin.left, Au(0)));
|
||||
|
@ -1384,6 +1401,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
|||
&border_box,
|
||||
&overflow,
|
||||
self.fragment.style().get_box().z_index.number_or_zero(),
|
||||
&transform,
|
||||
filters,
|
||||
self.fragment.style().get_effects().mix_blend_mode,
|
||||
layer))
|
||||
|
|
|
@ -2001,6 +2001,9 @@ impl Fragment {
|
|||
if self.style().get_effects().mix_blend_mode != mix_blend_mode::T::normal {
|
||||
return true
|
||||
}
|
||||
if self.style().get_effects().transform.is_some() {
|
||||
return true
|
||||
}
|
||||
match self.style().get_box().position {
|
||||
position::T::absolute | position::T::fixed => {
|
||||
// FIXME(pcwalton): This should only establish a new stacking context when
|
||||
|
|
|
@ -24,35 +24,49 @@ use wrapper::{LayoutNode, TLayoutNode, ThreadSafeLayoutNode};
|
|||
|
||||
use encoding::EncodingRef;
|
||||
use encoding::all::UTF_8;
|
||||
use geom::matrix2d::Matrix2D;
|
||||
use geom::point::Point2D;
|
||||
use geom::rect::Rect;
|
||||
use geom::size::Size2D;
|
||||
use geom::scale_factor::ScaleFactor;
|
||||
use geom::size::Size2D;
|
||||
use gfx::color;
|
||||
use gfx::display_list::{ClippingRegion, DisplayItemMetadata, DisplayList, OpaqueNode};
|
||||
use gfx::display_list::{StackingContext};
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use gfx::paint_task::{PaintChan, PaintLayer};
|
||||
use gfx::paint_task::Msg as PaintMsg;
|
||||
use gfx::paint_task::{PaintChan, PaintLayer};
|
||||
use layout_traits::{LayoutControlMsg, LayoutTaskFactory};
|
||||
use log;
|
||||
use script::dom::bindings::js::LayoutJS;
|
||||
use script::dom::node::{LayoutData, Node, NodeTypeId};
|
||||
use script::dom::element::ElementTypeId;
|
||||
use script::dom::htmlelement::HTMLElementTypeId;
|
||||
use script::layout_interface::{ContentBoxResponse, ContentBoxesResponse};
|
||||
use script::layout_interface::ReflowQueryType;
|
||||
use script::layout_interface::{HitTestResponse, LayoutChan, LayoutRPC};
|
||||
use script::layout_interface::{MouseOverResponse, Msg};
|
||||
use script::layout_interface::{Reflow, ReflowGoal, ScriptLayoutChan, TrustedNodeAddress};
|
||||
use script_traits::{ConstellationControlMsg, CompositorEvent, OpaqueScriptLayoutChannel};
|
||||
use script_traits::{ScriptControlChan, UntrustedNodeAddress};
|
||||
use msg::compositor_msg::ScrollPolicy;
|
||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||
use msg::constellation_msg::{ConstellationChan, Failure, PipelineExitType, PipelineId};
|
||||
use net::image_cache_task::{ImageCacheTask, ImageResponseMsg};
|
||||
use net::local_image_cache::{ImageResponder, LocalImageCache};
|
||||
use net::resource_task::{ResourceTask, load_bytes_iter};
|
||||
use script::dom::bindings::js::LayoutJS;
|
||||
use script::dom::element::ElementTypeId;
|
||||
use script::dom::htmlelement::HTMLElementTypeId;
|
||||
use script::dom::node::{LayoutData, Node, NodeTypeId};
|
||||
use script::layout_interface::ReflowQueryType;
|
||||
use script::layout_interface::{ContentBoxResponse, ContentBoxesResponse};
|
||||
use script::layout_interface::{HitTestResponse, LayoutChan, LayoutRPC};
|
||||
use script::layout_interface::{MouseOverResponse, Msg};
|
||||
use script::layout_interface::{Reflow, ReflowGoal, ScriptLayoutChan, TrustedNodeAddress};
|
||||
use script_traits::{ConstellationControlMsg, CompositorEvent, OpaqueScriptLayoutChannel};
|
||||
use script_traits::{ScriptControlChan, UntrustedNodeAddress};
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::Cell;
|
||||
use std::mem;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::ptr;
|
||||
use std::sync::mpsc::{channel, Sender, Receiver, Select};
|
||||
use std::sync::{Arc, Mutex, MutexGuard};
|
||||
use style::computed_values::{filter, mix_blend_mode};
|
||||
use style::media_queries::{MediaType, MediaQueryList, Device};
|
||||
use style::node::TNode;
|
||||
use style::selector_matching::Stylist;
|
||||
use style::stylesheets::{Origin, Stylesheet, iter_font_face_rules};
|
||||
use url::Url;
|
||||
use util::cursor::Cursor;
|
||||
use util::geometry::Au;
|
||||
use util::logical_geometry::LogicalPoint;
|
||||
|
@ -65,19 +79,6 @@ use util::task_state;
|
|||
use util::time::{TimeProfilerCategory, ProfilerMetadata, TimeProfilerChan};
|
||||
use util::time::{TimerMetadataFrameType, TimerMetadataReflowType, profile};
|
||||
use util::workqueue::WorkQueue;
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::Cell;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::sync::mpsc::{channel, Sender, Receiver, Select};
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use style::selector_matching::Stylist;
|
||||
use style::computed_values::{filter, mix_blend_mode};
|
||||
use style::stylesheets::{Origin, Stylesheet, iter_font_face_rules};
|
||||
use style::node::TNode;
|
||||
use style::media_queries::{MediaType, MediaQueryList, Device};
|
||||
use std::sync::{Arc, Mutex, MutexGuard};
|
||||
use url::Url;
|
||||
|
||||
/// Mutable data belonging to the LayoutTask.
|
||||
///
|
||||
|
@ -785,6 +786,7 @@ impl LayoutTask {
|
|||
&origin,
|
||||
&origin,
|
||||
0,
|
||||
&Matrix2D::identity(),
|
||||
filter::T::new(Vec::new()),
|
||||
mix_blend_mode::T::normal,
|
||||
Some(paint_layer)));
|
||||
|
|
|
@ -8,13 +8,15 @@
|
|||
|
||||
use fragment::Fragment;
|
||||
|
||||
use geom::SideOffsets2D;
|
||||
use style::values::computed::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone, LengthOrPercentage};
|
||||
use style::properties::ComputedValues;
|
||||
use util::geometry::Au;
|
||||
use util::logical_geometry::LogicalMargin;
|
||||
use geom::{Matrix2D, SideOffsets2D, Size2D};
|
||||
use std::cmp::{max, min};
|
||||
use std::fmt;
|
||||
use style::computed_values::transform::ComputedMatrix;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{LengthAndPercentage, LengthOrPercentageOrAuto};
|
||||
use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage};
|
||||
use util::geometry::Au;
|
||||
use util::logical_geometry::LogicalMargin;
|
||||
|
||||
/// A collapsible margin. See CSS 2.1 § 8.3.1.
|
||||
#[derive(Copy)]
|
||||
|
@ -390,3 +392,30 @@ pub fn padding_from_style(style: &ComputedValues, containing_block_inline_size:
|
|||
specified(padding_style.padding_bottom, containing_block_inline_size),
|
||||
specified(padding_style.padding_left, containing_block_inline_size)))
|
||||
}
|
||||
|
||||
pub trait ToGfxMatrix {
|
||||
fn to_gfx_matrix(&self, containing_size: &Size2D<Au>) -> Matrix2D<f32>;
|
||||
}
|
||||
|
||||
impl ToGfxMatrix for ComputedMatrix {
|
||||
fn to_gfx_matrix(&self, containing_size: &Size2D<Au>) -> Matrix2D<f32> {
|
||||
Matrix2D::new(self.m11 as f32,
|
||||
self.m12 as f32,
|
||||
self.m21 as f32,
|
||||
self.m22 as f32,
|
||||
self.m31.to_au(containing_size.width).to_subpx() as f32,
|
||||
self.m32.to_au(containing_size.height).to_subpx() as f32)
|
||||
}
|
||||
}
|
||||
|
||||
trait ToAu {
|
||||
fn to_au(&self, containing_size: Au) -> Au;
|
||||
}
|
||||
|
||||
impl ToAu for LengthAndPercentage {
|
||||
#[inline]
|
||||
fn to_au(&self, containing_size: Au) -> Au {
|
||||
self.length + Au::from_frac_px(self.percentage * containing_size.to_subpx())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue