Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tschneidereit committed Jul 21, 2015
1 parent 317d2ac commit 126938a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
15 changes: 9 additions & 6 deletions components/layout/layout_task.rs
Expand Up @@ -70,6 +70,7 @@ use std::sync::{Arc, Mutex, MutexGuard};
use std::thread;
use style::computed_values::{filter, mix_blend_mode};
use style::media_queries::{MediaType, MediaQueryList, Device};
use style::properties::style_structs;
use style::selector_matching::Stylist;
use style::stylesheets::{Origin, Stylesheet, CSSRuleIteratorExt};
use url::Url;
Expand Down Expand Up @@ -126,7 +127,7 @@ pub struct LayoutTaskData {
/// A queued response for the content boxes of a node.
pub content_boxes_response: Vec<Rect<Au>>,

/// A queued response for the client {top, left, width, height} of a node.
/// A queued response for the client {top, left, width, height} of a node in pixels.
pub client_rect_response: Rect<i32>,

/// The list of currently-running animations.
Expand Down Expand Up @@ -1436,11 +1437,13 @@ impl FragmentLocatingFragmentIterator {

impl FragmentBorderBoxIterator for FragmentLocatingFragmentIterator {
fn process(&mut self, fragment: &Fragment, border_box: &Rect<Au>) {
let border_style_struct = fragment.style.get_border();
let top_width = border_style_struct.border_top_width;
let right_width = border_style_struct.border_right_width;
let bottom_width = border_style_struct.border_bottom_width;
let left_width = border_style_struct.border_left_width;
let style_structs::Border {
border_top_width: top_width,
border_right_width: right_width,
border_bottom_width: bottom_width,
border_left_width: left_width,
..
} = *fragment.style.get_border();
self.client_rect.origin.y = top_width.to_px();
self.client_rect.origin.x = left_width.to_px();
self.client_rect.size.width = (border_box.size.width - left_width - right_width).to_px();
Expand Down
2 changes: 1 addition & 1 deletion components/script/layout_interface.rs
Expand Up @@ -95,7 +95,7 @@ pub trait LayoutRPC {
fn content_box(&self) -> ContentBoxResponse;
/// Requests the dimensions of all the content boxes, as in the `getClientRects()` call.
fn content_boxes(&self) -> ContentBoxesResponse;
/// Requests the clientTop.
/// Requests the geometry of this node. Used by APIs such as `clientTop`.
fn node_geometry(&self) -> NodeGeometryResponse;
/// Requests the node containing the point of interest
fn hit_test(&self, node: TrustedNodeAddress, point: Point2D<f32>) -> Result<HitTestResponse, ()>;
Expand Down
28 changes: 10 additions & 18 deletions tests/wpt/mozilla/tests/mozilla/client-top-left-height-width.html
Expand Up @@ -76,17 +76,13 @@
<div id="with-border">my div</div>
<div id="with-border-and-padding">my div</div>
<div id="abs1">
<div id="abs2">
<div id="abs3">
<span id="span1">X</span>
</div>
</div>
<span id="span1">X</span>
</div>
<div id='rotated'>rotated</div>
<div id='inline-block'>inline-block</div>
<div id='display-none'>display-none</div>
<script>
test_rect = function(name, left, top, height, width) {
function test_rect(name, left, top, height, width) {
var div = document.getElementById(name);
var rect = div.getBoundingClientRect();

Expand All @@ -96,18 +92,14 @@
assert_equals(div.clientWidth, width);
}

test(function() {
test_rect('no-border', 0, 0, 100, 100);
test_rect('with-border', 10, 10, 100, 100);
test_rect('with-border-and-padding', 10, 10, 120, 120);
test_rect('abs1', 0, 0, 120, 100);
test_rect('rotated', 0, 0, 100, 100);
test_rect('abs2', 0, 0, 80, 80);
test_rect('abs3', 0, 0, 40, 48);
test_rect('span1', 0, 0, 0, 0);
test_rect('inline-block', 0, 0, 100, 100);
test_rect('display-none', 0, 0, 0, 0);
});
test(function() { test_rect('no-border', 0, 0, 100, 100); }, 'Block without border');
test(function() { test_rect('with-border', 10, 10, 100, 100); }, 'Block with border');
test(function() { test_rect('with-border-and-padding', 10, 10, 120, 120); }, 'Block without border and padding');
test(function() { test_rect('abs1', 0, 0, 120, 100); }, 'Absolutely positioned block');
test(function() { test_rect('rotated', 0, 0, 100, 100); }, 'Rotated block');
test(function() { test_rect('span1', 0, 0, 0, 0); }, 'Span');
test(function() { test_rect('inline-block', 0, 0, 100, 100); }, 'Inline block');
test(function() { test_rect('display-none', 0, 0, 0, 0); }, 'display: none');
</script>
</body>
</html>

0 comments on commit 126938a

Please sign in to comment.