mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #9421 - jdm:iframe-painting-after-navigation-redux, r=jdm
compositing: Fix a couple of bugs that prevented iframes from painting after navigation. The first bug was that iframes were not reflowed in their parent DOM when the child page navigated. This is fixed by simply having the constellation notify the appropriate script thread when navigation occurs. The second bug was that the compositor was unable to adjust the pipeline for existing iframe layers, only new ones. This patch adds logic to do that. The third bug was that we have ad-hoc reflow calls throughout script/, and we didn't trigger any reflow from the code that dispatches the `load` event for the iframe so the test for the first two issues would always time out. The second commit adds another reflow call to do that, and also bites the bullet and adds a catch-all reflow (which does nothing if there's no dirty nodes in the document) at the return to the event loop. Closes #8081. Extension of #9285. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9421) <!-- Reviewable:end -->
This commit is contained in:
commit
0fa9d32c69
10 changed files with 180 additions and 27 deletions
|
@ -23,9 +23,10 @@ use dom::htmlelement::HTMLElement;
|
|||
use dom::node::{Node, UnbindContext, window_from_node};
|
||||
use dom::urlhelper::UrlHelper;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom::window::Window;
|
||||
use dom::window::{ReflowReason, Window};
|
||||
use js::jsapi::{JSAutoCompartment, JSAutoRequest, RootedValue, JSContext, MutableHandleValue};
|
||||
use js::jsval::{UndefinedValue, NullValue};
|
||||
use layout_interface::ReflowQueryType;
|
||||
use msg::constellation_msg::{ConstellationChan};
|
||||
use msg::constellation_msg::{NavigationDirection, PipelineId, SubpageId};
|
||||
use page::IterablePage;
|
||||
|
@ -34,6 +35,7 @@ use script_traits::{IFrameLoadInfo, MozBrowserEvent, ScriptMsg as ConstellationM
|
|||
use std::ascii::AsciiExt;
|
||||
use std::cell::Cell;
|
||||
use string_cache::Atom;
|
||||
use style::context::ReflowGoal;
|
||||
use url::Url;
|
||||
use util::prefs;
|
||||
use util::str::{DOMString, LengthOrPercentageOrAuto};
|
||||
|
@ -211,6 +213,10 @@ impl HTMLIFrameElement {
|
|||
let window = window_from_node(self);
|
||||
self.upcast::<EventTarget>().fire_simple_event("load", GlobalRef::Window(window.r()));
|
||||
// TODO Step 5 - unset child document `mut iframe load` flag
|
||||
|
||||
window.reflow(ReflowGoal::ForDisplay,
|
||||
ReflowQueryType::NoQuery,
|
||||
ReflowReason::IFrameLoadEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,9 @@ pub enum ReflowReason {
|
|||
ImageLoaded,
|
||||
RequestAnimationFrame,
|
||||
WebFontLoaded,
|
||||
FramedContentChanged,
|
||||
IFrameLoadEvent,
|
||||
MissingExplicitReflow,
|
||||
}
|
||||
|
||||
pub type ScrollPoint = Point2D<Au>;
|
||||
|
@ -1425,6 +1428,9 @@ fn debug_reflow_events(goal: &ReflowGoal, query_type: &ReflowQueryType, reason:
|
|||
ReflowReason::ImageLoaded => "\tImageLoaded",
|
||||
ReflowReason::RequestAnimationFrame => "\tRequestAnimationFrame",
|
||||
ReflowReason::WebFontLoaded => "\tWebFontLoaded",
|
||||
ReflowReason::FramedContentChanged => "\tFramedContentChanged",
|
||||
ReflowReason::IFrameLoadEvent => "\tIFrameLoadEvent",
|
||||
ReflowReason::MissingExplicitReflow => "\tMissingExplicitReflow",
|
||||
});
|
||||
|
||||
println!("{}", debug_msg);
|
||||
|
|
|
@ -1028,6 +1028,14 @@ impl ScriptThread {
|
|||
window.reflow(ReflowGoal::ForDisplay,
|
||||
ReflowQueryType::NoQuery,
|
||||
ReflowReason::ImageLoaded);
|
||||
} else {
|
||||
// Reflow currently happens when explicitly invoked by code that
|
||||
// knows the document could have been modified. This should really
|
||||
// be driven by the compositor on an as-needed basis instead, to
|
||||
// minimize unnecessary work.
|
||||
window.reflow(ReflowGoal::ForDisplay,
|
||||
ReflowQueryType::NoQuery,
|
||||
ReflowReason::MissingExplicitReflow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1131,6 +1139,8 @@ impl ScriptThread {
|
|||
ConstellationControlMsg::DispatchFrameLoadEvent {
|
||||
target: pipeline_id, parent: containing_id } =>
|
||||
self.handle_frame_load_event(containing_id, pipeline_id),
|
||||
ConstellationControlMsg::FramedContentChanged(containing_pipeline_id, subpage_id) =>
|
||||
self.handle_framed_content_changed(containing_pipeline_id, subpage_id),
|
||||
ConstellationControlMsg::ReportCSSError(pipeline_id, filename, line, column, msg) =>
|
||||
self.handle_css_error_reporting(pipeline_id, filename, line, column, msg),
|
||||
}
|
||||
|
@ -1487,6 +1497,22 @@ impl ScriptThread {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_framed_content_changed(&self,
|
||||
parent_pipeline_id: PipelineId,
|
||||
subpage_id: SubpageId) {
|
||||
let borrowed_page = self.root_page();
|
||||
let page = borrowed_page.find(parent_pipeline_id).unwrap();
|
||||
let doc = page.document();
|
||||
let frame_element = doc.find_iframe(subpage_id);
|
||||
if let Some(ref frame_element) = frame_element {
|
||||
frame_element.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
||||
let window = page.window();
|
||||
window.reflow(ReflowGoal::ForDisplay,
|
||||
ReflowQueryType::NoQuery,
|
||||
ReflowReason::FramedContentChanged);
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles a mozbrowser event, for example see:
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart
|
||||
fn handle_mozbrowser_event_msg(&self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue