Address review comments

This commit is contained in:
Till Schneidereit 2015-07-21 22:56:26 +02:00
parent 317d2ac547
commit 126938a963
3 changed files with 20 additions and 25 deletions

View file

@ -70,6 +70,7 @@ use std::sync::{Arc, Mutex, MutexGuard};
use std::thread; use std::thread;
use style::computed_values::{filter, mix_blend_mode}; use style::computed_values::{filter, mix_blend_mode};
use style::media_queries::{MediaType, MediaQueryList, Device}; use style::media_queries::{MediaType, MediaQueryList, Device};
use style::properties::style_structs;
use style::selector_matching::Stylist; use style::selector_matching::Stylist;
use style::stylesheets::{Origin, Stylesheet, CSSRuleIteratorExt}; use style::stylesheets::{Origin, Stylesheet, CSSRuleIteratorExt};
use url::Url; use url::Url;
@ -126,7 +127,7 @@ pub struct LayoutTaskData {
/// A queued response for the content boxes of a node. /// A queued response for the content boxes of a node.
pub content_boxes_response: Vec<Rect<Au>>, 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>, pub client_rect_response: Rect<i32>,
/// The list of currently-running animations. /// The list of currently-running animations.
@ -1436,11 +1437,13 @@ impl FragmentLocatingFragmentIterator {
impl FragmentBorderBoxIterator for FragmentLocatingFragmentIterator { impl FragmentBorderBoxIterator for FragmentLocatingFragmentIterator {
fn process(&mut self, fragment: &Fragment, border_box: &Rect<Au>) { fn process(&mut self, fragment: &Fragment, border_box: &Rect<Au>) {
let border_style_struct = fragment.style.get_border(); let style_structs::Border {
let top_width = border_style_struct.border_top_width; border_top_width: top_width,
let right_width = border_style_struct.border_right_width; border_right_width: right_width,
let bottom_width = border_style_struct.border_bottom_width; border_bottom_width: bottom_width,
let left_width = border_style_struct.border_left_width; border_left_width: left_width,
..
} = *fragment.style.get_border();
self.client_rect.origin.y = top_width.to_px(); self.client_rect.origin.y = top_width.to_px();
self.client_rect.origin.x = left_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(); self.client_rect.size.width = (border_box.size.width - left_width - right_width).to_px();

View file

@ -95,7 +95,7 @@ pub trait LayoutRPC {
fn content_box(&self) -> ContentBoxResponse; fn content_box(&self) -> ContentBoxResponse;
/// Requests the dimensions of all the content boxes, as in the `getClientRects()` call. /// Requests the dimensions of all the content boxes, as in the `getClientRects()` call.
fn content_boxes(&self) -> ContentBoxesResponse; 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; fn node_geometry(&self) -> NodeGeometryResponse;
/// Requests the node containing the point of interest /// Requests the node containing the point of interest
fn hit_test(&self, node: TrustedNodeAddress, point: Point2D<f32>) -> Result<HitTestResponse, ()>; fn hit_test(&self, node: TrustedNodeAddress, point: Point2D<f32>) -> Result<HitTestResponse, ()>;

View file

@ -76,17 +76,13 @@
<div id="with-border">my div</div> <div id="with-border">my div</div>
<div id="with-border-and-padding">my div</div> <div id="with-border-and-padding">my div</div>
<div id="abs1"> <div id="abs1">
<div id="abs2"> <span id="span1">X</span>
<div id="abs3">
<span id="span1">X</span>
</div>
</div>
</div> </div>
<div id='rotated'>rotated</div> <div id='rotated'>rotated</div>
<div id='inline-block'>inline-block</div> <div id='inline-block'>inline-block</div>
<div id='display-none'>display-none</div> <div id='display-none'>display-none</div>
<script> <script>
test_rect = function(name, left, top, height, width) { function test_rect(name, left, top, height, width) {
var div = document.getElementById(name); var div = document.getElementById(name);
var rect = div.getBoundingClientRect(); var rect = div.getBoundingClientRect();
@ -96,18 +92,14 @@
assert_equals(div.clientWidth, width); assert_equals(div.clientWidth, width);
} }
test(function() { test(function() { test_rect('no-border', 0, 0, 100, 100); }, 'Block without border');
test_rect('no-border', 0, 0, 100, 100); test(function() { test_rect('with-border', 10, 10, 100, 100); }, 'Block with border');
test_rect('with-border', 10, 10, 100, 100); test(function() { test_rect('with-border-and-padding', 10, 10, 120, 120); }, 'Block without border and padding');
test_rect('with-border-and-padding', 10, 10, 120, 120); test(function() { test_rect('abs1', 0, 0, 120, 100); }, 'Absolutely positioned block');
test_rect('abs1', 0, 0, 120, 100); test(function() { test_rect('rotated', 0, 0, 100, 100); }, 'Rotated block');
test_rect('rotated', 0, 0, 100, 100); test(function() { test_rect('span1', 0, 0, 0, 0); }, 'Span');
test_rect('abs2', 0, 0, 80, 80); test(function() { test_rect('inline-block', 0, 0, 100, 100); }, 'Inline block');
test_rect('abs3', 0, 0, 40, 48); test(function() { test_rect('display-none', 0, 0, 0, 0); }, 'display: none');
test_rect('span1', 0, 0, 0, 0);
test_rect('inline-block', 0, 0, 100, 100);
test_rect('display-none', 0, 0, 0, 0);
});
</script> </script>
</body> </body>
</html> </html>