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

Rollup of changes #2 #512

Merged
merged 42 commits into from Jun 11, 2013
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c14a137
Update rust-geom
pcwalton May 29, 2013
233a204
Implement the beginnings of the box model for render boxes
pcwalton May 29, 2013
a1d1289
Add NSPR and NSS submodules
pcwalton May 29, 2013
0af3bbf
Add NSS and NSPR to the build
pcwalton May 29, 2013
2d1a00c
Don't clip layers to the screen area
pcwalton May 29, 2013
67eb533
Clamp scrolling to the page boundaries
pcwalton May 29, 2013
d97f002
Stop hammering on the compositor
pcwalton May 29, 2013
02c5772
Fix corrupted textures when resizing.
pcwalton May 30, 2013
dcfabb7
Don't try to remove whitespace twice if it's the only node.
pcwalton May 30, 2013
e2bcd36
Color links blue
pcwalton May 30, 2013
2e4cecc
Add flows if requested to the display list info.
pcwalton May 30, 2013
ea1a406
base and bounds methods for DisplayItem
May 25, 2013
f77eef5
Basic hit testing functionality
pcwalton May 31, 2013
facb707
Update rust-css and rust-netsurfcss
pcwalton May 31, 2013
d5e4793
Add horizontal borders, margins and padding. Broken until rust-css su…
May 30, 2013
708f9b4
Fix method names and dynamic borrow check failures
pcwalton May 31, 2013
0b91af3
Refactor a bit and compute vertical margins as well.
pcwalton May 31, 2013
72ca765
Update rust-css and fix some dynamic borrow check failures
pcwalton Jun 1, 2013
f1fcd4d
Add comments and compute heights properly
pcwalton Jun 1, 2013
cddf67a
Update border rendering
May 31, 2013
fb2ce2c
Rename `with_imm_base` to `with_base`.
pcwalton Jun 3, 2013
e6ff135
test_slam_layout, a new layout perf test case
pcwalton Jun 4, 2013
8d3b6ae
Stop rendering when script queries layout
pcwalton Jun 4, 2013
40a69fc
Address review comments
pcwalton Jun 4, 2013
7a435fc
Refactor document damage to distinguish it from layout/style damage.
pcwalton Jun 5, 2013
5750069
Use the scroll hack
pcwalton Jun 6, 2013
ae5b2df
Roll up block layout changes
pcwalton Jun 6, 2013
9c25474
Only warn, don't assert, if the node range length is zero.
pcwalton Jun 6, 2013
97eb567
Update the configure script to pass --enable-64bit
pcwalton Jun 6, 2013
c65d51f
Address review comments
pcwalton Jun 6, 2013
98a730c
Use full paths for submodules in the configure script
pcwalton Jun 6, 2013
bb6ae7a
Update NSS to fix build issues.
metajack Jun 11, 2013
5425154
Merge remote-tracking branch 'origin/master' into pcwalton-master
metajack Jun 11, 2013
a2c4f72
Fix spacing.
metajack Jun 11, 2013
4cf4302
Update nss.
metajack Jun 11, 2013
ea1c883
Fix warning.
metajack Jun 11, 2013
16ca6f2
Add missing field.
metajack Jun 11, 2013
a42cf9b
Fix types.
metajack Jun 11, 2013
b635079
Revert rust-css and rust-netsurfcss to working versions.
metajack Jun 11, 2013
f0692e5
Update rust-glut.
metajack Jun 11, 2013
a5e3605
Fix rust-css tests.
metajack Jun 11, 2013
cdd5de7
Disable tests for nspr and nss.
metajack Jun 11, 2013
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Address review comments

  • Loading branch information
pcwalton committed Jun 4, 2013
commit 40a69fc51758356b9ecd9c5e3e3b2754cbb85fe7
@@ -102,70 +102,83 @@ impl BlockFlowData {
}
}

/* if not an anonymous block context, add in block box's widths.
these widths will not include child elements, just padding etc. */
self.box.map(|&box| {
//Can compute border width here since it doesn't depend on anything
// If not an anonymous block context, add in the block box's widths. These widths will not
// include child elements, just padding etc.
for self.box.each |&box| {
// Can compute border width here since it doesn't depend on anything.
let style = box.style();
do box.with_model |model| {
model.compute_borders(style)
}
min_width = min_width.add(&box.get_min_width(ctx));
pref_width = pref_width.add(&box.get_pref_width(ctx));
});
}

self.common.min_width = min_width;
self.common.pref_width = pref_width;
}

/// Computes left and right margins and width based on CSS 2.1 secion 10.3.3.
/// Requires borders and padding to already be computed
priv fn compute_horiz( &self,
width: MaybeAuto,
left_margin: MaybeAuto,
right_margin: MaybeAuto,
available_width: Au) -> (Au, Au, Au) {

//If width is not 'auto', and width + margins > available_width, all 'auto' margins are treated as '0'
let (left_margin, right_margin) = match width{
/// Requires borders and padding to already be computed.
fn compute_horiz(&self,
width: MaybeAuto,
left_margin: MaybeAuto,
right_margin: MaybeAuto,
available_width: Au)
-> (Au, Au, Au) {
// If width is not 'auto', and width + margins > available_width, all 'auto' margins are
// treated as '0'.
let (left_margin, right_margin) = match width {
Auto => (left_margin, right_margin),
Specified(width) => {
let left = left_margin.spec_or_default(Au(0));
let right = right_margin.spec_or_default(Au(0));

if((left + right + width) > available_width) {
if (left + right + width) > available_width {
(Specified(left), Specified(right))
} else {
(left_margin, right_margin)
}
}
};

//Invariant: left_margin_Au + width_Au + right_margin_Au == available_width
// Invariant: left_margin_Au + width_Au + right_margin_Au == available_width
let (left_margin_Au, width_Au, right_margin_Au) = match (left_margin, width, right_margin) {
//If all have a computed value other than 'auto', the system is over-constrained and we need to discard a margin.
//if direction is ltr, ignore the specified right margin and solve for it. If it is rtl, ignore the specified
//left margin. FIXME(eatkinson): this assumes the direction is ltr
(Specified(margin_l), Specified(width), Specified(margin_r)) => (margin_l, width, available_width - (margin_l + width )),
// If all have a computed value other than 'auto', the system is over-constrained and
// we need to discard a margin. If direction is ltr, ignore the specified right margin
// and solve for it. If it is rtl, ignore the specified left margin.
//
// FIXME(eatkinson): this assumes the direction is ltr
(Specified(margin_l), Specified(width), Specified(_)) => {
(margin_l, width, available_width - (margin_l + width))
}

//If exactly one value is 'auto', solve for it
(Auto, Specified(width), Specified(margin_r)) => (available_width - (width + margin_r), width, margin_r),
(Specified(margin_l), Auto, Specified(margin_r)) => (margin_l, available_width - (margin_l + margin_r), margin_r),
(Specified(margin_l), Specified(width), Auto) => (margin_l, width, available_width - (margin_l + width)),
// If exactly one value is 'auto', solve for it
(Auto, Specified(width), Specified(margin_r)) => {
(available_width - (width + margin_r), width, margin_r)
}
(Specified(margin_l), Auto, Specified(margin_r)) => {
(margin_l, available_width - (margin_l + margin_r), margin_r)
}
(Specified(margin_l), Specified(width), Auto) => {
(margin_l, width, available_width - (margin_l + width))
}

//If width is set to 'auto', any other 'auto' value becomes '0', and width is solved for
// If width is set to 'auto', any other 'auto' value becomes '0', and width is solved
// for.
(Auto, Auto, Specified(margin_r)) => (Au(0), available_width - margin_r, margin_r),
(Specified(margin_l), Auto, Auto) => (margin_l, available_width - margin_l, Au(0)),
(Auto, Auto, Auto) => (Au(0), available_width, Au(0)),

//If left and right margins are auto, they become equal
// If left and right margins are auto, they become equal.
(Auto, Specified(width), Auto) => {
let margin = (available_width - width).scale_by(0.5);
(margin, width, margin)
}

};
//return values in same order as params

// Return values in same order as params.
(width_Au, left_margin_Au, right_margin_Au)
}

@@ -184,25 +197,31 @@ impl BlockFlowData {
let mut remaining_width = self.common.position.size.width;
let mut x_offset = Au(0);

self.box.map(|&box| {
for self.box.each |&box| {
let style = box.style();
do box.with_model |model| {
//Can compute padding here since we know containing block width
// Can compute padding here since we know containing block width.
model.compute_padding(style, remaining_width);

//Margins are 0 right now so model.noncontent_width() is just borders + padding.
// Margins are 0 right now so model.noncontent_width() is just borders + padding.
let available_width = remaining_width - model.noncontent_width();

//Top and bottom margins for blocks are 0 if auto
let margin_top = MaybeAuto::from_margin(style.margin_top()).spec_or_default(Au(0));
let margin_bottom = MaybeAuto::from_margin(style.margin_bottom()).spec_or_default(Au(0));
// Top and bottom margins for blocks are 0 if auto.
let margin_top = MaybeAuto::from_margin(style.margin_top());
let margin_top = margin_top.spec_or_default(Au(0));
let margin_bottom = MaybeAuto::from_margin(style.margin_bottom());
let margin_bottom = margin_bottom.spec_or_default(Au(0));

let (width, margin_left, margin_right) = (MaybeAuto::from_width(style.width()),
MaybeAuto::from_margin(style.margin_left()),
MaybeAuto::from_margin(style.margin_right()));
let (width, margin_left, margin_right) =
(MaybeAuto::from_width(style.width()),
MaybeAuto::from_margin(style.margin_left()),
MaybeAuto::from_margin(style.margin_right()));

let (width, margin_left, margin_right) =
self.compute_horiz(width, margin_left, margin_right, available_width);
// FIXME(pcwalton): We discard the width here. Is that correct?
let (_, margin_left, margin_right) = self.compute_horiz(width,
margin_left,
margin_right,
available_width);

model.margin.top = margin_top;
model.margin.right = margin_right;
@@ -221,7 +240,7 @@ impl BlockFlowData {
base.model.border.left + base.model.border.right;
base.position.size.width = remaining_width + pb;
}
});
}

for BlockFlow(self).each_child |kid| {
assert!(kid.starts_block_flow() || kid.starts_inline_flow());
@@ -8,12 +8,10 @@ use geom::rect::Rect;
use gfx::font_context::FontContext;
use gfx::geometry::Au;
use servo_net::local_image_cache::LocalImageCache;
use std::net::url::Url;

/// Data needed by the layout task.
pub struct LayoutContext {
font_ctx: @mut FontContext,
image_cache: @mut LocalImageCache,
doc_url: Url,
screen_size: Rect<Au>
screen_size: Rect<Au>,
}
@@ -115,12 +115,10 @@ impl Layout {
let image_cache = self.local_image_cache;
let font_ctx = self.font_ctx;
let screen_size = self.screen_size.unwrap();
let doc_url = self.doc_url.clone();

LayoutContext {
image_cache: image_cache,
font_ctx: font_ctx,
doc_url: doc_url.unwrap(),
screen_size: Rect(Point2D(Au(0), Au(0)), screen_size),
}
}
@@ -348,10 +346,12 @@ impl Layout {
let display_list = &display_list.take().list;
for display_list.each_reverse |display_item| {
let bounds = display_item.bounds();

// FIXME(pcwalton): Move this to be a method on Rect.
if x <= bounds.origin.x + bounds.size.width &&
bounds.origin.x <= x &&
y < bounds.origin.y + bounds.size.height &&
bounds.origin.y < y {
x >= bounds.origin.x &&
y < bounds.origin.y + bounds.size.height &&
y >= bounds.origin.y {
resp = Ok(HitTestResponse(display_item.base().extra.node()));
break;
}
@@ -22,12 +22,17 @@ use newcss::values::{CSSBorderWidthThick, CSSBorderWidthThin};
use newcss::values::{CSSWidth, CSSWidthLength, CSSWidthPercentage, CSSWidthAuto};
use newcss::values::{CSSMargin, CSSMarginLength, CSSMarginPercentage, CSSMarginAuto};
use newcss::values::{CSSPadding, CSSPaddingLength, CSSPaddingPercentage};

/// Encapsulates the borders, padding, and margins, which we collectively call the "box model".
pub struct BoxModel {
/// The size of the borders.
border: SideOffsets2D<Au>,
/// The size of the padding.
padding: SideOffsets2D<Au>,
/// The size of the margins.
margin: SideOffsets2D<Au>,
cb_width: Au,
/// The width of the content box.
content_box_width: Au,
}

/// Useful helper data type when computing values for blocks and positioned elements.
@@ -75,7 +80,7 @@ impl Zero for BoxModel {
border: Zero::zero(),
padding: Zero::zero(),
margin: Zero::zero(),
cb_width: Zero::zero(),
content_box_width: Zero::zero(),
}
}

@@ -85,7 +90,7 @@ impl Zero for BoxModel {
}

impl BoxModel {
/// Populates the box model parameters from the given computed style.
/// Populates the box model border parameters from the given computed style.
pub fn compute_borders(&mut self, style: CompleteStyle) {
// Compute the borders.
self.border.top = self.compute_border_width(style.border_top_width());
@@ -94,11 +99,16 @@ impl BoxModel {
self.border.left = self.compute_border_width(style.border_left_width());
}

pub fn compute_padding(&mut self, style: CompleteStyle, cb_width: Au){
self.padding.top = self.compute_padding_length(style.padding_top(), cb_width);
self.padding.right = self.compute_padding_length(style.padding_right(), cb_width);
self.padding.bottom = self.compute_padding_length(style.padding_bottom(), cb_width);
self.padding.left = self.compute_padding_length(style.padding_left(), cb_width);
/// Populates the box model padding parameters from the given computed style.
pub fn compute_padding(&mut self, style: CompleteStyle, content_box_width: Au) {
self.padding.top = self.compute_padding_length(style.padding_top(),
content_box_width);
self.padding.right = self.compute_padding_length(style.padding_right(),
content_box_width);
self.padding.bottom = self.compute_padding_length(style.padding_bottom(),
content_box_width);
self.padding.left = self.compute_padding_length(style.padding_left(),
content_box_width);
}

pub fn noncontent_width(&self) -> Au {
@@ -112,7 +122,7 @@ impl BoxModel {
}

/// Helper function to compute the border width in app units from the CSS border width.
priv fn compute_border_width(&self, width: CSSBorderWidth) -> Au {
fn compute_border_width(&self, width: CSSBorderWidth) -> Au {
match width {
CSSBorderWidthLength(Px(v)) |
CSSBorderWidthLength(Em(v)) |
@@ -126,18 +136,17 @@ impl BoxModel {
}
}

priv fn compute_padding_length(&self, padding: CSSPadding, cb_width: Au) -> Au {
fn compute_padding_length(&self, padding: CSSPadding, content_box_width: Au) -> Au {
match padding {
CSSPaddingLength(Px(v)) |
CSSPaddingLength(Pt(v)) |
CSSPaddingLength(Em(v)) => {
// FIXME(eatkinson): Handle 'em' and 'pt' correctly
Au::from_frac_px(v)
}
CSSPaddingPercentage(p) => cb_width.scale_by(p)
CSSPaddingPercentage(p) => content_box_width.scale_by(p)
}
}

}

//
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.