Make iframe's load event trigger a reflow of the enclosing window. Add a catch-all reflow for all same-origin pages sharing an event loop.a

This commit is contained in:
Josh Matthews 2016-01-25 15:01:53 -05:00
parent e5a1af5b7a
commit 7eca462c5a
3 changed files with 19 additions and 1 deletions

View file

@ -23,9 +23,10 @@ use dom::htmlelement::HTMLElement;
use dom::node::{Node, UnbindContext, window_from_node}; use dom::node::{Node, UnbindContext, window_from_node};
use dom::urlhelper::UrlHelper; use dom::urlhelper::UrlHelper;
use dom::virtualmethods::VirtualMethods; use dom::virtualmethods::VirtualMethods;
use dom::window::Window; use dom::window::{ReflowReason, Window};
use js::jsapi::{JSAutoCompartment, JSAutoRequest, RootedValue, JSContext, MutableHandleValue}; use js::jsapi::{JSAutoCompartment, JSAutoRequest, RootedValue, JSContext, MutableHandleValue};
use js::jsval::{UndefinedValue, NullValue}; use js::jsval::{UndefinedValue, NullValue};
use layout_interface::ReflowQueryType;
use msg::constellation_msg::{ConstellationChan}; use msg::constellation_msg::{ConstellationChan};
use msg::constellation_msg::{NavigationDirection, PipelineId, SubpageId}; use msg::constellation_msg::{NavigationDirection, PipelineId, SubpageId};
use page::IterablePage; use page::IterablePage;
@ -34,6 +35,7 @@ use script_traits::{IFrameLoadInfo, MozBrowserEvent, ScriptMsg as ConstellationM
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use std::cell::Cell; use std::cell::Cell;
use string_cache::Atom; use string_cache::Atom;
use style::context::ReflowGoal;
use url::Url; use url::Url;
use util::prefs; use util::prefs;
use util::str::{DOMString, LengthOrPercentageOrAuto}; use util::str::{DOMString, LengthOrPercentageOrAuto};
@ -211,6 +213,10 @@ impl HTMLIFrameElement {
let window = window_from_node(self); let window = window_from_node(self);
self.upcast::<EventTarget>().fire_simple_event("load", GlobalRef::Window(window.r())); self.upcast::<EventTarget>().fire_simple_event("load", GlobalRef::Window(window.r()));
// TODO Step 5 - unset child document `mut iframe load` flag // TODO Step 5 - unset child document `mut iframe load` flag
window.reflow(ReflowGoal::ForDisplay,
ReflowQueryType::NoQuery,
ReflowReason::IFrameLoadEvent);
} }
} }

View file

@ -108,6 +108,8 @@ pub enum ReflowReason {
RequestAnimationFrame, RequestAnimationFrame,
WebFontLoaded, WebFontLoaded,
FramedContentChanged, FramedContentChanged,
IFrameLoadEvent,
MissingExplicitReflow,
} }
pub type ScrollPoint = Point2D<Au>; pub type ScrollPoint = Point2D<Au>;
@ -1427,6 +1429,8 @@ fn debug_reflow_events(goal: &ReflowGoal, query_type: &ReflowQueryType, reason:
ReflowReason::RequestAnimationFrame => "\tRequestAnimationFrame", ReflowReason::RequestAnimationFrame => "\tRequestAnimationFrame",
ReflowReason::WebFontLoaded => "\tWebFontLoaded", ReflowReason::WebFontLoaded => "\tWebFontLoaded",
ReflowReason::FramedContentChanged => "\tFramedContentChanged", ReflowReason::FramedContentChanged => "\tFramedContentChanged",
ReflowReason::IFrameLoadEvent => "\tIFrameLoadEvent",
ReflowReason::MissingExplicitReflow => "\tMissingExplicitReflow",
}); });
println!("{}", debug_msg); println!("{}", debug_msg);

View file

@ -1028,6 +1028,14 @@ impl ScriptThread {
window.reflow(ReflowGoal::ForDisplay, window.reflow(ReflowGoal::ForDisplay,
ReflowQueryType::NoQuery, ReflowQueryType::NoQuery,
ReflowReason::ImageLoaded); 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);
} }
} }
} }