mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add test to constellation to avoid writing reftest image if there are pending frames.
Also change when pipelines become active. This makes the constellation activate a pipeline as the current frame when it is ready to do initial reflow, rather than when it is ready to paint. This fixes a number of intermittent failures that could previously occur if an iframe was not visible - which would mean it was never moved from a pending frame in the constellation to an active frame. (It happens that webrender exposes these intermittents as permanent failures).
This commit is contained in:
parent
d11f96e270
commit
b670430cb2
8 changed files with 109 additions and 118 deletions
|
@ -6,7 +6,7 @@ use app_units::Au;
|
|||
use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType, WorkerId};
|
||||
use dom::bindings::callback::ExceptionHandling;
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||
use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState};
|
||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::{EventHandlerNonNull, OnErrorEventHandlerNonNull};
|
||||
use dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOptions};
|
||||
|
@ -44,7 +44,8 @@ use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowGoal, ReflowQue
|
|||
use libc;
|
||||
use msg::ParseErrorReporter;
|
||||
use msg::compositor_msg::{LayerId, ScriptToCompositorMsg};
|
||||
use msg::constellation_msg::{ConstellationChan, LoadData, PipelineId, SubpageId, WindowSizeData};
|
||||
use msg::constellation_msg::{ConstellationChan, DocumentState, LoadData};
|
||||
use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData};
|
||||
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
|
||||
use net_traits::ResourceTask;
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask};
|
||||
|
@ -990,16 +991,43 @@ impl Window {
|
|||
///
|
||||
/// TODO(pcwalton): Only wait for style recalc, since we have off-main-thread layout.
|
||||
pub fn reflow(&self, goal: ReflowGoal, query_type: ReflowQueryType, reason: ReflowReason) {
|
||||
if query_type == ReflowQueryType::NoQuery && !self.Document().needs_reflow() {
|
||||
let for_display = query_type == ReflowQueryType::NoQuery;
|
||||
|
||||
if !for_display || self.Document().needs_reflow() {
|
||||
self.force_reflow(goal, query_type, reason);
|
||||
|
||||
// If window_size is `None`, we don't reflow, so the document stays dirty.
|
||||
// Otherwise, we shouldn't need a reflow immediately after a reflow.
|
||||
assert!(!self.Document().needs_reflow() || self.window_size.get().is_none());
|
||||
} else {
|
||||
debug!("Document doesn't need reflow - skipping it (reason {:?})", reason);
|
||||
return
|
||||
}
|
||||
|
||||
self.force_reflow(goal, query_type, reason);
|
||||
// If writing a screenshot, check if the script has reached a state
|
||||
// where it's safe to write the image. This means that:
|
||||
// 1) The reflow is for display (otherwise it could be a query)
|
||||
// 2) The html element doesn't contain the 'reftest-wait' class
|
||||
// 3) The load event has fired.
|
||||
// When all these conditions are met, notify the constellation
|
||||
// that this pipeline is ready to write the image (from the script task
|
||||
// perspective at least).
|
||||
if opts::get().output_file.is_some() && for_display {
|
||||
let document = self.Document();
|
||||
|
||||
// If window_size is `None`, we don't reflow, so the document stays dirty.
|
||||
// Otherwise, we shouldn't need a reflow immediately after a reflow.
|
||||
assert!(!self.Document().needs_reflow() || self.window_size.get().is_none());
|
||||
// Checks if the html element has reftest-wait attribute present.
|
||||
// See http://testthewebforward.org/docs/reftests.html
|
||||
let html_element = document.GetDocumentElement();
|
||||
let reftest_wait = html_element.map_or(false, |elem| {
|
||||
elem.has_class(&Atom::from("reftest-wait"))
|
||||
});
|
||||
|
||||
let ready_state = document.ReadyState();
|
||||
|
||||
if ready_state == DocumentReadyState::Complete && !reftest_wait {
|
||||
let event = ConstellationMsg::SetDocumentState(self.id, DocumentState::Idle);
|
||||
self.constellation_chan().0.send(event).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn layout(&self) -> &LayoutRPC {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue