Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acid2 2 #1988

Merged
merged 23 commits into from
Apr 4, 2014
Merged

Acid2 2 #1988

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e6adc54
style: Parse `min-height` and `max-height`
pcwalton Mar 28, 2014
d136d7a
style: Implement `-servo-minimum-line-height`, a derived property from
pcwalton Mar 28, 2014
1b04165
style: Parse `background-position` and `background-attachment`.
pcwalton Mar 28, 2014
dae4166
util: Add some utility methods to `SmallVec`.
pcwalton Mar 28, 2014
f8e3e50
util: Add a `rect_contains_point` utility method
pcwalton Mar 28, 2014
cd9d824
servo: Implement stacking contexts and allow multiple layers per
pcwalton Mar 28, 2014
9874d0f
layout: Take `min-height` and `max-height` into account
pcwalton Mar 28, 2014
e6665a2
layout: Take padding into account for inline boxes
pcwalton Mar 28, 2014
4fd950e
layout: Update `parallel.rs` to use `OpaqueNodeMethods`
pcwalton Mar 28, 2014
98bf325
layout: Support multiple boxes per node; don't store fixed/absolute
pcwalton Mar 28, 2014
392afdb
layout: Implement `-servo-minimum-line-height`
pcwalton Mar 28, 2014
10aed5b
layout: Rewrite the margin collapse code to work with negative margins.
pcwalton Mar 28, 2014
901c448
layout: Implement enough of automatic table layout to pass Acid2.
june0cho Mar 28, 2014
4c53a21
layout: Implement pseudo-elements.
hyunjunekim Mar 28, 2014
42170c7
test: Add many reftests for parts of Acid2.
pcwalton Mar 28, 2014
30b7f5d
support: Update submodules.
pcwalton Mar 28, 2014
c49f23f
layout: Address review feedback.
pcwalton Mar 31, 2014
2e5b210
test: Fix some reftests.
pcwalton Mar 31, 2014
aabda89
layout: Fix percentages in relatively positioned elements
pcwalton Apr 1, 2014
5609650
layout: Address some more review comments
pcwalton Apr 1, 2014
9712e6d
layout: Address review comments for `min-height` and `max-height`
pcwalton Apr 1, 2014
8e14579
Adress more #1988 (Acid 2) review comments.
SimonSapin Apr 3, 2014
9e3f7a0
Computed value of 'height: <percentage>' is 'auto' in some cases.
SimonSapin Apr 3, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
263 changes: 180 additions & 83 deletions src/components/gfx/display_list.rs

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions src/components/gfx/render_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use font_context::FontContext;
use style::computed_values::border_style;

use azure::azure_hl::{B8G8R8A8, Color, ColorPattern, DrawOptions};
use azure::azure_hl::{DrawSurfaceOptions, DrawTarget, Linear, StrokeOptions};
use azure::azure_hl::{B8G8R8A8, Color, ColorPattern, DrawOptions, DrawSurfaceOptions, DrawTarget};
use azure::azure_hl::{Linear, SourceOp, StrokeOptions};
use azure::AZ_CAP_BUTT;
use azure::AzFloat;
use geom::point::Point2D;
Expand Down Expand Up @@ -45,7 +45,7 @@ impl<'a> RenderContext<'a> {

pub fn draw_solid_color(&self, bounds: &Rect<Au>, color: Color) {
self.draw_target.make_current();
self.draw_target.fill_rect(&bounds.to_azure_rect(), &ColorPattern(color));
self.draw_target.fill_rect(&bounds.to_azure_rect(), &ColorPattern(color), None);
}

pub fn draw_border(&self,
Expand Down Expand Up @@ -121,13 +121,15 @@ impl<'a> RenderContext<'a> {
}

pub fn clear(&self) {
let pattern = ColorPattern(Color(1.0, 1.0, 1.0, 1.0));
let pattern = ColorPattern(Color(0.0, 0.0, 0.0, 0.0));
let rect = Rect(Point2D(self.page_rect.origin.x as AzFloat,
self.page_rect.origin.y as AzFloat),
Size2D(self.screen_rect.size.width as AzFloat,
self.screen_rect.size.height as AzFloat));
let mut draw_options = DrawOptions(1.0, 0);
draw_options.set_composition_op(SourceOp);
self.draw_target.make_current();
self.draw_target.fill_rect(&rect, &pattern);
self.draw_target.fill_rect(&rect, &pattern, Some(&draw_options));
}

fn draw_border_segment(&self, direction: Direction, bounds: &Rect<Au>, border: SideOffsets2D<f32>, color: SideOffsets2D<Color>, style: SideOffsets2D<border_style::T>) {
Expand Down
372 changes: 206 additions & 166 deletions src/components/gfx/render_task.rs

Large diffs are not rendered by default.

239 changes: 142 additions & 97 deletions src/components/main/compositing/compositor.rs

Large diffs are not rendered by default.

697 changes: 452 additions & 245 deletions src/components/main/compositing/compositor_layer.rs

Large diffs are not rendered by default.

106 changes: 75 additions & 31 deletions src/components/main/compositing/compositor_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use geom::point::Point2D;
use geom::rect::Rect;
use geom::size::Size2D;
use layers::platform::surface::{NativeCompositingGraphicsContext, NativeGraphicsMetadata};
use servo_msg::compositor_msg::{Epoch, RenderListener, LayerBufferSet, RenderState, ReadyState};
use servo_msg::compositor_msg::ScriptListener;
use servo_msg::compositor_msg::{Epoch, LayerBufferSet, LayerId, LayerMetadata, ReadyState};
use servo_msg::compositor_msg::{RenderListener, RenderState, ScriptListener, ScrollPolicy};
use servo_msg::constellation_msg::{ConstellationChan, PipelineId};
use servo_util::opts::Opts;
use servo_util::time::ProfilerChan;
Expand Down Expand Up @@ -45,12 +45,15 @@ impl ScriptListener for CompositorChan {
self.chan.send(msg);
}

fn invalidate_rect(&self, id: PipelineId, rect: Rect<uint>) {
self.chan.send(InvalidateRect(id, rect));
fn invalidate_rect(&self, pipeline_id: PipelineId, layer_id: LayerId, rect: Rect<uint>) {
self.chan.send(InvalidateRect(pipeline_id, layer_id, rect));
}

fn scroll_fragment_point(&self, id: PipelineId, point: Point2D<f32>) {
self.chan.send(ScrollFragmentPoint(id, point));
fn scroll_fragment_point(&self,
pipeline_id: PipelineId,
layer_id: LayerId,
point: Point2D<f32>) {
self.chan.send(ScrollFragmentPoint(pipeline_id, layer_id, point));
}

fn close(&self) {
Expand All @@ -72,30 +75,68 @@ impl RenderListener for CompositorChan {
port.recv()
}

fn paint(&self, id: PipelineId, layer_buffer_set: ~LayerBufferSet, epoch: Epoch) {
self.chan.send(Paint(id, layer_buffer_set, epoch))
fn paint(&self,
pipeline_id: PipelineId,
layer_id: LayerId,
layer_buffer_set: ~LayerBufferSet,
epoch: Epoch) {
self.chan.send(Paint(pipeline_id, layer_id, layer_buffer_set, epoch))
}

fn new_layer(&self, id: PipelineId, page_size: Size2D<uint>) {
fn create_layer_group_for_pipeline(&self, id: PipelineId, page_size: Size2D<uint>) {
let Size2D { width, height } = page_size;
self.chan.send(NewLayer(id, Size2D(width as f32, height as f32)))
self.chan.send(CreateRootCompositorLayerIfNecessary(id,
LayerId::null(),
Size2D(width as f32, height as f32)))
}
fn set_layer_page_size_and_color(&self, id: PipelineId, page_size: Size2D<uint>, epoch: Epoch, color: Color) {
let Size2D { width, height } = page_size;
self.chan.send(SetUnRenderedColor(id, color));
self.chan.send(SetLayerPageSize(id, Size2D(width as f32, height as f32), epoch))

fn initialize_layers_for_pipeline(&self,
pipeline_id: PipelineId,
metadata: ~[LayerMetadata],
epoch: Epoch) {
// FIXME(#2004, pcwalton): This assumes that the first layer determines the page size, and
// that all other layers are immediate children of it. This is sufficient to handle
// `position: fixed` but will not be sufficient to handle `overflow: scroll` or transforms.
let mut first = true;
for metadata in metadata.iter() {
let origin = Point2D(metadata.position.origin.x as f32,
metadata.position.origin.y as f32);
let size = Size2D(metadata.position.size.width as f32,
metadata.position.size.height as f32);
let rect = Rect(origin, size);
if first {
self.chan.send(CreateRootCompositorLayerIfNecessary(pipeline_id,
metadata.id,
size));
first = false
} else {
self.chan
.send(CreateDescendantCompositorLayerIfNecessary(pipeline_id,
metadata.id,
rect,
metadata.scroll_policy));
}

self.chan.send(SetUnRenderedColor(pipeline_id,
metadata.id,
metadata.background_color));
self.chan.send(SetLayerPageSize(pipeline_id, metadata.id, size, epoch));
}
}

fn set_layer_clip_rect(&self, id: PipelineId, new_rect: Rect<uint>) {
fn set_layer_clip_rect(&self,
pipeline_id: PipelineId,
layer_id: LayerId,
new_rect: Rect<uint>) {
let new_rect = Rect(Point2D(new_rect.origin.x as f32,
new_rect.origin.y as f32),
Size2D(new_rect.size.width as f32,
new_rect.size.height as f32));
self.chan.send(SetLayerClipRect(id, new_rect))
self.chan.send(SetLayerClipRect(pipeline_id, layer_id, new_rect))
}

fn delete_layer(&self, id: PipelineId) {
self.chan.send(DeleteLayer(id))
fn delete_layer_group(&self, id: PipelineId) {
self.chan.send(DeleteLayerGroup(id))
}

fn set_render_state(&self, render_state: RenderState) {
Expand Down Expand Up @@ -133,29 +174,32 @@ pub enum Msg {
/// The headless compositor returns `None`.
GetGraphicsMetadata(Chan<Option<NativeGraphicsMetadata>>),

/// Alerts the compositor that there is a new layer to be rendered.
NewLayer(PipelineId, Size2D<f32>),
/// Alerts the compositor that the specified layer's page has changed size.
SetLayerPageSize(PipelineId, Size2D<f32>, Epoch),
/// Tells the compositor to create the root layer for a pipeline if necessary (i.e. if no layer
/// with that ID exists).
CreateRootCompositorLayerIfNecessary(PipelineId, LayerId, Size2D<f32>),
/// Tells the compositor to create a descendant layer for a pipeline if necessary (i.e. if no
/// layer with that ID exists).
CreateDescendantCompositorLayerIfNecessary(PipelineId, LayerId, Rect<f32>, ScrollPolicy),
/// Alerts the compositor that the specified layer has changed size.
SetLayerPageSize(PipelineId, LayerId, Size2D<f32>, Epoch),
/// Alerts the compositor that the specified layer's clipping rect has changed.
SetLayerClipRect(PipelineId, Rect<f32>),
/// Alerts the compositor that the specified layer has been deleted.
DeleteLayer(PipelineId),
SetLayerClipRect(PipelineId, LayerId, Rect<f32>),
/// Alerts the compositor that the specified pipeline has been deleted.
DeleteLayerGroup(PipelineId),
/// Invalidate a rect for a given layer
InvalidateRect(PipelineId, Rect<uint>),
InvalidateRect(PipelineId, LayerId, Rect<uint>),
/// Scroll a page in a window
ScrollFragmentPoint(PipelineId, Point2D<f32>),
ScrollFragmentPoint(PipelineId, LayerId, Point2D<f32>),
/// Requests that the compositor paint the given layer buffer set for the given page size.
Paint(PipelineId, ~LayerBufferSet, Epoch),
Paint(PipelineId, LayerId, ~LayerBufferSet, Epoch),
/// Alerts the compositor to the current status of page loading.
ChangeReadyState(ReadyState),
/// Alerts the compositor to the current status of rendering.
ChangeRenderState(RenderState),
/// Sets the channel to the current layout and render tasks, along with their id
SetIds(SendableFrameTree, Chan<()>, ConstellationChan),

SetUnRenderedColor(PipelineId, Color),

/// Sets the color of unrendered content for a layer.
SetUnRenderedColor(PipelineId, LayerId, Color),
/// The load of a page for a given URL has completed.
LoadComplete(PipelineId, Url),
}
Expand Down
9 changes: 5 additions & 4 deletions src/components/main/compositing/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ impl NullCompositor {
// we'll notice and think about whether it needs a response, like
// SetIds.

NewLayer(..) | SetLayerPageSize(..) | SetLayerClipRect(..) | DeleteLayer(..) |
Paint(..) | InvalidateRect(..) | ChangeReadyState(..) | ChangeRenderState(..)|
ScrollFragmentPoint(..) | SetUnRenderedColor(..) | LoadComplete(..)
=> ()
CreateRootCompositorLayerIfNecessary(..) |
CreateDescendantCompositorLayerIfNecessary(..) | SetLayerPageSize(..) |
SetLayerClipRect(..) | DeleteLayerGroup(..) | Paint(..) | InvalidateRect(..) |
ChangeReadyState(..) | ChangeRenderState(..) | ScrollFragmentPoint(..) |
SetUnRenderedColor(..) | LoadComplete(..) => ()
}
}
}
Expand Down
16 changes: 10 additions & 6 deletions src/components/main/compositing/quadtree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,21 +460,25 @@ impl<T: Tile> QuadtreeNode<T> {
/// treated as invalid as well.
/// NOTE: this method will sometimes modify the tree by deleting tiles.
/// See the QuadTree function description for more details.
fn get_tile_rects(&mut self, window: Rect<f32>, clip: Size2D<f32>, scale: f32, tile_size: f32, override: bool) ->
(~[BufferRequest], ~[T], int) {

fn get_tile_rects(&mut self,
window: Rect<f32>,
clip: Size2D<f32>,
scale: f32,
tile_size: f32,
override: bool)
-> (~[BufferRequest], ~[T], int) {
let w_x = window.origin.x;
let w_y = window.origin.y;
let w_width = window.size.width;
let w_height = window.size.height;
let s_x = self.origin.x;
let s_y = self.origin.y;
let s_size = self.size;

// if window is outside of visible region, nothing to do
if w_x + w_width < s_x || w_x > s_x + s_size
|| w_y + w_height < s_y || w_y > s_y + s_size
|| w_x >= clip.width || w_y >= clip.height {
|| w_y + w_height < s_y || w_y > s_y + s_size
|| w_x >= clip.width || w_y >= clip.height {
return (~[], ~[], 0);
}

Expand Down
30 changes: 10 additions & 20 deletions src/components/main/constellation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use script::script_task::{ResizeMsg, ResizeInactiveMsg, ExitPipelineMsg};
use script::layout_interface;
use script::layout_interface::LayoutChan;
use script::script_task::ScriptChan;
use servo_msg::compositor_msg::LayerId;
use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, FailureMsg, Failure, FrameRectMsg};
use servo_msg::constellation_msg::{IFrameSandboxState, IFrameUnsandboxed, InitLoadUrlMsg};
use servo_msg::constellation_msg::{LoadCompleteMsg, LoadIframeUrlMsg, LoadUrlMsg, Msg, NavigateMsg};
Expand Down Expand Up @@ -98,15 +99,6 @@ pub struct SendableChildFrameTree {
rect: Option<Rect<f32>>,
}

// impl SendableFrameTree {
// fn contains(&self, id: PipelineId) -> bool {
// self.pipeline.id == id ||
// self.children.iter().any(|&SendableChildFrameTree { frame_tree: ref frame_tree, .. }| {
// frame_tree.contains(id)
// })
// }
// }

enum ReplaceResult {
ReplacedNode(Rc<FrameTree>),
OriginalNode(Rc<FrameTree>),
Expand Down Expand Up @@ -511,11 +503,12 @@ impl Constellation {
== subpage_id
};

let frames = self.find_all(pipeline_id);

{
// Update a child's frame rect and inform its script task of the change,
// if it hasn't been already. Optionally inform the compositor if
// resize happens immediately.
let compositor_chan = self.compositor_chan.clone();
let update_child_rect = |child_frame_tree: &mut ChildFrameTree, is_active: bool| {
child_frame_tree.rect = Some(rect.clone());
// NOTE: work around borrowchk issues
Expand All @@ -524,21 +517,19 @@ impl Constellation {
let Size2D { width, height } = rect.size;
if is_active {
let pipeline = pipeline.get().borrow();
let ScriptChan(ref chan) = pipeline.script_chan;
chan.send(ResizeMsg(pipeline.id, Size2D {
let ScriptChan(ref script_chan) = pipeline.script_chan;
script_chan.send(ResizeMsg(pipeline.id, Size2D {
width: width as uint,
height: height as uint
}));
compositor_chan.send(SetLayerClipRect(pipeline.id, rect));
self.compositor_chan.send(SetLayerClipRect(pipeline.id,
LayerId::null(),
rect));
} else {
let pipeline = pipeline.get().borrow();
let ScriptChan(ref chan) = pipeline.script_chan;
chan.send(ResizeInactiveMsg(pipeline.id,
Size2D(width as uint, height as uint)));
already_sent.insert(pipeline.id);
}
let pipeline = pipeline.get().borrow();
already_sent.insert(pipeline.id);
}
};
};

// If the subframe is in the current frame tree, the compositor needs the new size
Expand All @@ -554,7 +545,6 @@ impl Constellation {
}

// Update all frames with matching pipeline- and subpage-ids
let frames = self.find_all(pipeline_id);
for frame_tree in frames.iter() {
// NOTE: work around borrowchk issues
let mut tmp = frame_tree.borrow().children.borrow_mut();
Expand Down
38 changes: 30 additions & 8 deletions src/components/main/css/node_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use layout::incremental::RestyleDamage;
use layout::util::LayoutDataAccess;
use layout::wrapper::{TLayoutNode, ThreadSafeLayoutNode};

use layout::wrapper::{After, AfterBlock, Before, BeforeBlock, Normal};
use std::cast;
use style::ComputedValues;
use sync::Arc;
Expand All @@ -25,13 +25,35 @@ impl<'ln> NodeUtil for ThreadSafeLayoutNode<'ln> {
fn get_css_select_results<'a>(&'a self) -> &'a Arc<ComputedValues> {
unsafe {
let layout_data_ref = self.borrow_layout_data();
cast::transmute_region(layout_data_ref.get()
.as_ref()
.unwrap()
.data
.style
.as_ref()
.unwrap())
match self.get_element_type() {
Before | BeforeBlock => {
cast::transmute_region(layout_data_ref.get()
.as_ref()
.unwrap()
.data
.before_style
.as_ref()
.unwrap())
}
After | AfterBlock => {
cast::transmute_region(layout_data_ref.get()
.as_ref()
.unwrap()
.data
.after_style
.as_ref()
.unwrap())
}
Normal => {
cast::transmute_region(layout_data_ref.get()
.as_ref()
.unwrap()
.data
.style
.as_ref()
.unwrap())
}
}
}
}

Expand Down
Loading