Created
June 4, 2013 22:33
-
-
Save jdm/5710216 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs | |
| index 403bdf6..1664c67 100644 | |
| --- a/src/components/main/layout/layout_task.rs | |
| +++ b/src/components/main/layout/layout_task.rs | |
| @@ -137,8 +137,11 @@ impl Layout { | |
| /// The high-level routine that performs layout tasks. | |
| fn handle_build(&mut self, data: &BuildData) { | |
| // FIXME: Isolate this transmutation into a "bridge" module. | |
| + let style_node: &AbstractNode<LayoutView> = unsafe { | |
| + transmute(&data.style_root) | |
| + }; | |
| let node: &AbstractNode<LayoutView> = unsafe { | |
| - transmute(&data.node) | |
| + transmute(&data.root) | |
| }; | |
| // FIXME: Bad copy! | |
| @@ -176,7 +179,7 @@ impl Layout { | |
| NoDamage | ReflowDamage => {} | |
| MatchSelectorsDamage => { | |
| do profile(time::LayoutSelectorMatchCategory, self.profiler_chan.clone()) { | |
| - node.restyle_subtree(self.css_select_ctx); | |
| + style_node.restyle_subtree(self.css_select_ctx); | |
| } | |
| } | |
| } | |
| diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs | |
| index ba52025..00b980a 100644 | |
| --- a/src/components/script/dom/document.rs | |
| +++ b/src/components/script/dom/document.rs | |
| @@ -50,9 +50,9 @@ pub impl Document { | |
| Some(HTMLCollection::new(elements)) | |
| } | |
| - fn content_changed(&self) { | |
| + fn content_changed(&self, node: AbstractNode<ScriptView>) { | |
| for self.window.each |window| { | |
| - window.content_changed() | |
| + window.content_changed(node) | |
| } | |
| } | |
| diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs | |
| index 742fdb4..381694c 100644 | |
| --- a/src/components/script/dom/element.rs | |
| +++ b/src/components/script/dom/element.rs | |
| @@ -152,7 +152,7 @@ pub impl<'self> Element { | |
| } | |
| match self.parent.owner_doc { | |
| - Some(owner) => owner.content_changed(), | |
| + Some(owner) => owner.content_changed(self.parent.abstract.get()), | |
| None => {} | |
| } | |
| } | |
| diff --git a/src/components/script/dom/window.rs b/src/components/script/dom/window.rs | |
| index c94e648..412fdbb 100644 | |
| --- a/src/components/script/dom/window.rs | |
| +++ b/src/components/script/dom/window.rs | |
| @@ -4,6 +4,7 @@ | |
| use dom::bindings::utils::WrapperCache; | |
| use dom::bindings::window; | |
| +use dom::node::{AbstractNode, ScriptView}; | |
| use layout_interface::MatchSelectorsDamage; | |
| use script_task::{ExitMsg, FireTimerMsg, ScriptMsg, ScriptContext}; | |
| @@ -81,9 +82,9 @@ pub impl Window { | |
| TimerMessage_Fire(~TimerData(argc, argv))); | |
| } | |
| - fn content_changed(&self) { | |
| + fn content_changed(&self, node: AbstractNode<ScriptView>) { | |
| unsafe { | |
| - (*self.script_context).trigger_relayout(MatchSelectorsDamage); | |
| + (*self.script_context).trigger_relayout(MatchSelectorsDamage, node); | |
| } | |
| } | |
| diff --git a/src/components/script/layout_interface.rs b/src/components/script/layout_interface.rs | |
| index cf2306c..7a0c207 100644 | |
| --- a/src/components/script/layout_interface.rs | |
| +++ b/src/components/script/layout_interface.rs | |
| @@ -83,7 +83,8 @@ impl Damage { | |
| /// Information needed for a reflow. | |
| pub struct BuildData { | |
| - node: AbstractNode<ScriptView>, | |
| + root: AbstractNode<ScriptView>, | |
| + style_root: AbstractNode<ScriptView>, | |
| /// What reflow needs to be done. | |
| damage: Damage, | |
| /// The URL of the page. | |
| diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs | |
| index 7e3e042..aca8726 100644 | |
| --- a/src/components/script/script_task.rs | |
| +++ b/src/components/script/script_task.rs | |
| @@ -8,7 +8,7 @@ | |
| use dom::bindings::utils::GlobalStaticData; | |
| use dom::document::Document; | |
| use dom::event::{Event, ResizeEvent, ReflowEvent}; | |
| -use dom::node::define_bindings; | |
| +use dom::node::{AbstractNode, ScriptView, define_bindings}; | |
| use dom::window::Window; | |
| use layout_interface::{AddStylesheetMsg, BuildData, BuildMsg, Damage, LayoutQuery}; | |
| use layout_interface::{LayoutResponse, LayoutTask, MatchSelectorsDamage, NoDamage}; | |
| @@ -283,7 +283,7 @@ impl ScriptContext { | |
| null(), | |
| &rval); | |
| - self.relayout(true) | |
| + self.relayout(true, None) | |
| } | |
| /// Handles a request to exit the script task and shut down layout. | |
| @@ -349,7 +349,7 @@ impl ScriptContext { | |
| // Perform the initial reflow. | |
| self.damage.add(MatchSelectorsDamage); | |
| - self.relayout(true); | |
| + self.relayout(true, None); | |
| // Define debug functions. | |
| self.js_compartment.define_functions(debug_fns); | |
| @@ -384,9 +384,9 @@ impl ScriptContext { | |
| } | |
| /// Initiate an asynchronous relayout operation | |
| - pub fn trigger_relayout(&mut self, damage: Damage) { | |
| + pub fn trigger_relayout(&mut self, damage: Damage, node: AbstractNode<ScriptView>) { | |
| self.damage.add(damage); | |
| - self.relayout(false); | |
| + self.relayout(false, Some(node)); | |
| } | |
| /// This method will wait until the layout task has completed its current action, join the | |
| @@ -394,7 +394,7 @@ impl ScriptContext { | |
| /// computation to finish. | |
| /// | |
| /// This function fails if there is no root frame. | |
| - fn relayout(&mut self, render: bool) { | |
| + fn relayout(&mut self, render: bool, node: Option<AbstractNode<ScriptView>>) { | |
| debug!("script: performing relayout"); | |
| // Now, join the layout so that they will see the latest changes we have made. | |
| @@ -409,7 +409,8 @@ impl ScriptContext { | |
| Some(ref root_frame) => { | |
| // Send new document and relevant styles to layout. | |
| let data = ~BuildData { | |
| - node: root_frame.document.root, | |
| + root: root_frame.document.root, | |
| + style_root: node.get_or_default(root_frame.document.root), | |
| url: copy root_frame.url, | |
| script_chan: self.script_chan.clone(), | |
| window_size: self.window_size, | |
| @@ -446,7 +447,7 @@ impl ScriptContext { | |
| self.window_size = Size2D(new_width, new_height); | |
| if self.root_frame.is_some() { | |
| - self.relayout(true) | |
| + self.relayout(true, None) | |
| } | |
| response_chan.send(()) | |
| @@ -458,7 +459,7 @@ impl ScriptContext { | |
| self.damage.add(MatchSelectorsDamage); | |
| if self.root_frame.is_some() { | |
| - self.relayout(true) | |
| + self.relayout(true, None) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment