Auto merge of #9661 - jdm:devtools-inspector-get-layout, r=pcwalton

Completed implementation of devtools' `getLayout`.

Rebase of #7267. Fixes #3598.

This avoids all of the sketchy issues of trying to read the style data for margins from the script thread. I replaced it with a layout query that fetches the margin style properties for a given element.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9661)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-02-25 00:22:43 +05:30
commit 09e987b559
13 changed files with 225 additions and 42 deletions

View file

@ -185,7 +185,6 @@ unsafe impl Send for OpaqueStyleAndLayoutData {}
no_jsmanaged_fields!(OpaqueStyleAndLayoutData);
impl OpaqueStyleAndLayoutData {
/// Sends the style and layout data, if any, back to the layout thread to be destroyed.
pub fn dispose(self, node: &Node) {

View file

@ -41,7 +41,7 @@ use js::jsapi::{JSAutoCompartment, JSAutoRequest, JS_GC, JS_GetRuntime};
use js::rust::CompileOptionsWrapper;
use js::rust::Runtime;
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowQueryType};
use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowQueryType, MarginStyleResponse};
use libc;
use msg::constellation_msg::{ConstellationChan, LoadData, PipelineId, SubpageId, WindowSizeData};
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
@ -1099,6 +1099,13 @@ impl Window {
(element, response.rect)
}
pub fn margin_style_query(&self, node: TrustedNodeAddress) -> MarginStyleResponse {
self.reflow(ReflowGoal::ForScriptQuery,
ReflowQueryType::MarginStyleQuery(node),
ReflowReason::Query);
self.layout_rpc.margin_style()
}
pub fn init_browsing_context(&self, browsing_context: &BrowsingContext) {
assert!(self.browsing_context.get().is_none());
self.browsing_context.set(Some(&browsing_context));
@ -1420,6 +1427,7 @@ fn debug_reflow_events(goal: &ReflowGoal, query_type: &ReflowQueryType, reason:
ReflowQueryType::NodeGeometryQuery(_n) => "\tNodeGeometryQuery",
ReflowQueryType::ResolvedStyleQuery(_, _, _) => "\tResolvedStyleQuery",
ReflowQueryType::OffsetParentQuery(_n) => "\tOffsetParentQuery",
ReflowQueryType::MarginStyleQuery(_n) => "\tMarginStyleQuery",
});
debug_msg.push_str(match *reason {