mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Convert back to physical some layout coordinates.
This commit is contained in:
parent
36ed8d4212
commit
353b1a17d5
5 changed files with 71 additions and 71 deletions
|
@ -1110,16 +1110,18 @@ impl BlockFlow {
|
|||
.relative_containing_block_size,
|
||||
None);
|
||||
|
||||
// FIXME(#2795): Get the real container size
|
||||
let container_size = Size2D::zero();
|
||||
|
||||
// Add the box that starts the block context.
|
||||
let mut display_list = DisplayList::new();
|
||||
let mut accumulator =
|
||||
self.fragment.build_display_list(&mut display_list,
|
||||
layout_context,
|
||||
self.base.abs_position
|
||||
.add_point(&offset)
|
||||
+ rel_offset,
|
||||
background_border_level,
|
||||
None);
|
||||
let mut accumulator = self.fragment.build_display_list(
|
||||
&mut display_list,
|
||||
layout_context,
|
||||
self.base.abs_position + (offset + rel_offset).to_physical(
|
||||
self.base.writing_mode, container_size),
|
||||
background_border_level,
|
||||
None);
|
||||
|
||||
let mut child_layers = DList::new();
|
||||
for kid in self.base.child_iter() {
|
||||
|
@ -1592,17 +1594,22 @@ impl Flow for BlockFlow {
|
|||
}
|
||||
|
||||
fn compute_absolute_position(&mut self) {
|
||||
// FIXME(#2795): Get the real container size
|
||||
let container_size = Size2D::zero();
|
||||
|
||||
if self.is_absolutely_positioned() {
|
||||
let position_start = self.base.position.start.to_physical(
|
||||
self.base.writing_mode, container_size);
|
||||
self.base
|
||||
.absolute_position_info
|
||||
.absolute_containing_block_position = if self.is_fixed() {
|
||||
// The viewport is initially at (0, 0).
|
||||
self.base.position.start
|
||||
position_start
|
||||
} else {
|
||||
// Absolute position of the containing block + position of absolute flow w/r/t the
|
||||
// containing block.
|
||||
self.base.absolute_position_info.absolute_containing_block_position
|
||||
.add_point(&self.base.position.start)
|
||||
+ position_start
|
||||
};
|
||||
|
||||
// Set the absolute position, which will be passed down later as part
|
||||
|
@ -1622,8 +1629,8 @@ impl Flow for BlockFlow {
|
|||
if self.is_positioned() {
|
||||
self.base.absolute_position_info.absolute_containing_block_position =
|
||||
self.base.abs_position
|
||||
.add_point(&self.generated_containing_block_rect().start)
|
||||
+ relative_offset
|
||||
+ (self.generated_containing_block_rect().start
|
||||
+ relative_offset).to_physical(self.base.writing_mode, container_size)
|
||||
}
|
||||
|
||||
let float_offset = if self.is_float() {
|
||||
|
@ -1640,14 +1647,14 @@ impl Flow for BlockFlow {
|
|||
|
||||
// Process children.
|
||||
let this_position = self.base.abs_position;
|
||||
let writing_mode = self.base.writing_mode;
|
||||
for kid in self.base.child_iter() {
|
||||
if !kid.is_absolutely_positioned() {
|
||||
let kid_base = flow::mut_base(kid);
|
||||
kid_base.abs_position =
|
||||
this_position
|
||||
.add_point(&kid_base.position.start)
|
||||
kid_base.abs_position = this_position + (
|
||||
kid_base.position.start
|
||||
.add_point(&float_offset)
|
||||
+ relative_offset;
|
||||
+ relative_offset).to_physical(writing_mode, container_size);
|
||||
kid_base.absolute_position_info = absolute_position_info
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,13 +46,15 @@ use table_cell::TableCellFlow;
|
|||
use wrapper::ThreadSafeLayoutNode;
|
||||
|
||||
use collections::dlist::DList;
|
||||
use geom::Point2D;
|
||||
use gfx::display_list::DisplayList;
|
||||
use gfx::render_task::RenderLayer;
|
||||
use servo_msg::compositor_msg::LayerId;
|
||||
use servo_util::geometry::Au;
|
||||
use servo_util::logical_geometry::WritingMode;
|
||||
use servo_util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize};
|
||||
use servo_util::logical_geometry::{LogicalRect, LogicalSize};
|
||||
use std::mem;
|
||||
use std::num::Zero;
|
||||
use std::fmt;
|
||||
use std::iter::Zip;
|
||||
use std::sync::atomics::{AtomicUint, Relaxed, SeqCst};
|
||||
|
@ -596,7 +598,7 @@ pub struct AbsolutePositionInfo {
|
|||
/// The size of the containing block for relatively-positioned descendants.
|
||||
pub relative_containing_block_size: LogicalSize<Au>,
|
||||
/// The position of the absolute containing block.
|
||||
pub absolute_containing_block_position: LogicalPoint<Au>,
|
||||
pub absolute_containing_block_position: Point2D<Au>,
|
||||
/// Whether the absolute containing block forces positioned descendants to be layerized.
|
||||
///
|
||||
/// FIXME(pcwalton): Move into `FlowFlags`.
|
||||
|
@ -609,7 +611,7 @@ impl AbsolutePositionInfo {
|
|||
// of the root layer.
|
||||
AbsolutePositionInfo {
|
||||
relative_containing_block_size: LogicalSize::zero(writing_mode),
|
||||
absolute_containing_block_position: LogicalPoint::zero(writing_mode),
|
||||
absolute_containing_block_position: Zero::zero(),
|
||||
layers_needed_for_positioned_flows: false,
|
||||
}
|
||||
}
|
||||
|
@ -660,7 +662,7 @@ pub struct BaseFlow {
|
|||
pub collapsible_margins: CollapsibleMargins,
|
||||
|
||||
/// The position of this flow in page coordinates, computed during display list construction.
|
||||
pub abs_position: LogicalPoint<Au>,
|
||||
pub abs_position: Point2D<Au>,
|
||||
|
||||
/// Details about descendants with position 'absolute' or 'fixed' for which we are the
|
||||
/// containing block. This is in tree order. This includes any direct children.
|
||||
|
@ -724,7 +726,7 @@ impl BaseFlow {
|
|||
|
||||
floats: Floats::new(writing_mode),
|
||||
collapsible_margins: CollapsibleMargins::new(),
|
||||
abs_position: LogicalPoint::zero(writing_mode),
|
||||
abs_position: Zero::zero(),
|
||||
abs_descendants: Descendants::new(),
|
||||
absolute_static_i_offset: Au::new(0),
|
||||
fixed_static_i_offset: Au::new(0),
|
||||
|
|
|
@ -37,7 +37,7 @@ use servo_net::image::holder::ImageHolder;
|
|||
use servo_net::local_image_cache::LocalImageCache;
|
||||
use servo_util::geometry::Au;
|
||||
use servo_util::geometry;
|
||||
use servo_util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, LogicalMargin};
|
||||
use servo_util::logical_geometry::{LogicalRect, LogicalSize, LogicalMargin};
|
||||
use servo_util::range::*;
|
||||
use servo_util::namespace;
|
||||
use servo_util::smallvec::SmallVec;
|
||||
|
@ -776,15 +776,15 @@ impl Fragment {
|
|||
|
||||
fn build_debug_borders_around_text_fragments(&self,
|
||||
display_list: &mut DisplayList,
|
||||
flow_origin: LogicalPoint<Au>,
|
||||
flow_origin: Point2D<Au>,
|
||||
text_fragment: &ScannedTextFragmentInfo) {
|
||||
let mut fragment_bounds = self.border_box.clone();
|
||||
fragment_bounds.start.i = fragment_bounds.start.i + flow_origin.i;
|
||||
fragment_bounds.start.b = fragment_bounds.start.b + flow_origin.b;
|
||||
// FIXME(#2795): Get the real container size
|
||||
let container_size = Size2D::zero();
|
||||
let absolute_fragment_bounds = fragment_bounds.to_physical(
|
||||
self.style.writing_mode, container_size);
|
||||
// Fragment position wrt to the owning flow.
|
||||
let fragment_bounds = self.border_box.to_physical(self.style.writing_mode, container_size);
|
||||
let absolute_fragment_bounds = Rect(
|
||||
fragment_bounds.origin + flow_origin,
|
||||
fragment_bounds.size);
|
||||
|
||||
// Compute the text fragment bounds and draw a border surrounding them.
|
||||
let border_display_item = box BorderDisplayItem {
|
||||
|
@ -797,13 +797,11 @@ impl Fragment {
|
|||
|
||||
// Draw a rectangle representing the baselines.
|
||||
let ascent = text_fragment.run.ascent();
|
||||
let baseline = LogicalRect::new(
|
||||
self.style.writing_mode,
|
||||
fragment_bounds.start.i,
|
||||
fragment_bounds.start.b + ascent,
|
||||
fragment_bounds.size.inline,
|
||||
Au(0)
|
||||
).to_physical(self.style.writing_mode, container_size);
|
||||
let mut baseline = self.border_box.clone();
|
||||
baseline.start.b = baseline.start.b + ascent;
|
||||
baseline.size.block = Au(0);
|
||||
let mut baseline = baseline.to_physical(self.style.writing_mode, container_size);
|
||||
baseline.origin = baseline.origin + flow_origin;
|
||||
|
||||
let line_display_item = box LineDisplayItem {
|
||||
base: BaseDisplayItem::new(baseline, self.node, ContentStackingLevel),
|
||||
|
@ -815,14 +813,14 @@ impl Fragment {
|
|||
|
||||
fn build_debug_borders_around_fragment(&self,
|
||||
display_list: &mut DisplayList,
|
||||
flow_origin: LogicalPoint<Au>) {
|
||||
let mut fragment_bounds = self.border_box.clone();
|
||||
fragment_bounds.start.i = fragment_bounds.start.i + flow_origin.i;
|
||||
fragment_bounds.start.b = fragment_bounds.start.b + flow_origin.b;
|
||||
flow_origin: Point2D<Au>) {
|
||||
// FIXME(#2795): Get the real container size
|
||||
let container_size = Size2D::zero();
|
||||
let absolute_fragment_bounds = fragment_bounds.to_physical(
|
||||
self.style.writing_mode, container_size);
|
||||
// Fragment position wrt to the owning flow.
|
||||
let fragment_bounds = self.border_box.to_physical(self.style.writing_mode, container_size);
|
||||
let absolute_fragment_bounds = Rect(
|
||||
fragment_bounds.origin + flow_origin,
|
||||
fragment_bounds.size);
|
||||
|
||||
// This prints a debug border around the border of this fragment.
|
||||
let border_display_item = box BorderDisplayItem {
|
||||
|
@ -845,18 +843,17 @@ impl Fragment {
|
|||
pub fn build_display_list(&self,
|
||||
display_list: &mut DisplayList,
|
||||
layout_context: &LayoutContext,
|
||||
flow_origin: LogicalPoint<Au>,
|
||||
flow_origin: Point2D<Au>,
|
||||
background_and_border_level: BackgroundAndBorderLevel,
|
||||
inline_fragment_context: Option<InlineFragmentContext>)
|
||||
-> ChildDisplayListAccumulator {
|
||||
// Fragment position wrt to the owning flow.
|
||||
let mut fragment_bounds = self.border_box.clone();
|
||||
fragment_bounds.start.i = fragment_bounds.start.i + flow_origin.i;
|
||||
fragment_bounds.start.b = fragment_bounds.start.b + flow_origin.b;
|
||||
// FIXME(#2795): Get the real container size
|
||||
let container_size = Size2D::zero();
|
||||
let absolute_fragment_bounds = fragment_bounds.to_physical(
|
||||
self.style.writing_mode, container_size);
|
||||
// Fragment position wrt to the owning flow.
|
||||
let fragment_bounds = self.border_box.to_physical(self.style.writing_mode, container_size);
|
||||
let absolute_fragment_bounds = Rect(
|
||||
fragment_bounds.origin + flow_origin,
|
||||
fragment_bounds.size);
|
||||
debug!("Fragment::build_display_list at rel={}, abs={}: {}",
|
||||
self.border_box,
|
||||
absolute_fragment_bounds,
|
||||
|
@ -1413,21 +1410,18 @@ impl Fragment {
|
|||
#[inline(never)]
|
||||
fn finalize_position_and_size_of_iframe(&self,
|
||||
iframe_fragment: &IframeFragmentInfo,
|
||||
offset: LogicalPoint<Au>,
|
||||
offset: Point2D<Au>,
|
||||
layout_context: &LayoutContext) {
|
||||
let inline_start = offset.i + self.margin.inline_start + self.border_padding.inline_start;
|
||||
let block_start = offset.b + self.margin.block_start + self.border_padding.block_start;
|
||||
let inline_size = self.content_box().size.inline;
|
||||
let block_size = self.content_box().size.block;
|
||||
// FIXME(#2795): Get the real container size
|
||||
let container_size = Size2D::zero();
|
||||
let rect = LogicalRect::new(
|
||||
self.style.writing_mode,
|
||||
geometry::to_frac_px(inline_start) as f32,
|
||||
geometry::to_frac_px(block_start) as f32,
|
||||
geometry::to_frac_px(inline_size) as f32,
|
||||
geometry::to_frac_px(block_size) as f32
|
||||
).to_physical(self.style.writing_mode, container_size);
|
||||
let mbp = (self.margin + self.border_padding).to_physical(self.style.writing_mode);
|
||||
let content_size = self.content_box().size.to_physical(self.style.writing_mode);
|
||||
|
||||
let left = offset.x + mbp.left;
|
||||
let top = offset.y + mbp.top;
|
||||
let width = content_size.width;
|
||||
let height = content_size.height;
|
||||
let origin = Point2D(geometry::to_frac_px(left) as f32, geometry::to_frac_px(top) as f32);
|
||||
let size = Size2D(geometry::to_frac_px(width) as f32, geometry::to_frac_px(height) as f32);
|
||||
let rect = Rect(origin, size);
|
||||
|
||||
debug!("finalizing position and size of iframe for {:?},{:?}",
|
||||
iframe_fragment.pipeline_id,
|
||||
|
|
|
@ -16,7 +16,7 @@ use text;
|
|||
use wrapper::ThreadSafeLayoutNode;
|
||||
|
||||
use collections::{Deque, RingBuf};
|
||||
use geom::Size2D;
|
||||
use geom::Rect;
|
||||
use gfx::display_list::ContentLevel;
|
||||
use gfx::font::FontMetrics;
|
||||
use gfx::font_context::FontContext;
|
||||
|
@ -927,12 +927,8 @@ impl InlineFlow {
|
|||
}
|
||||
|
||||
pub fn build_display_list_inline(&mut self, layout_context: &LayoutContext) {
|
||||
let abs_rect = LogicalRect::from_point_size(
|
||||
self.base.writing_mode, self.base.abs_position, self.base.position.size);
|
||||
// FIXME(#2795): Get the real container size
|
||||
let container_size = Size2D::zero();
|
||||
if !abs_rect.to_physical(self.base.writing_mode, container_size)
|
||||
.intersects(&layout_context.shared.dirty) {
|
||||
let size = self.base.position.size.to_physical(self.base.writing_mode);
|
||||
if !Rect(self.base.abs_position, size).intersects(&layout_context.shared.dirty) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -947,7 +943,8 @@ impl InlineFlow {
|
|||
Some(context));
|
||||
drop(fragment.build_display_list(&mut self.base.display_list,
|
||||
layout_context,
|
||||
self.base.abs_position + rel_offset,
|
||||
self.base.abs_position.add_size(
|
||||
&rel_offset.to_physical(self.base.writing_mode)),
|
||||
ContentLevel,
|
||||
Some(context)));
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b41f144a3a8b6388d0956f341bcffa5bbaecc899
|
||||
Subproject commit c733f78e06bd02f7498e93b391e0f6094d91786a
|
Loading…
Add table
Add a link
Reference in a new issue