Prevent JS execution and layout operations while DOM in inconsistent state.

This commit is contained in:
Josh Matthews 2018-12-09 22:08:33 -05:00
parent 231a37be24
commit 14b0de30db
4 changed files with 40 additions and 0 deletions

View file

@ -1361,6 +1361,7 @@ impl Window {
/// Returns true if layout actually happened, false otherwise.
#[allow(unsafe_code)]
pub fn force_reflow(&self, reflow_goal: ReflowGoal, reason: ReflowReason) -> bool {
self.Document().ensure_safe_to_run_script_or_layout();
// Check if we need to unsuppress reflow. Note that this needs to be
// *before* any early bailouts, or reflow might never be unsuppresed!
match reason {
@ -1497,6 +1498,7 @@ impl Window {
/// may happen in the only case a query reflow may bail out, that is, if the
/// viewport size is not present). See #11223 for an example of that.
pub fn reflow(&self, reflow_goal: ReflowGoal, reason: ReflowReason) -> bool {
self.Document().ensure_safe_to_run_script_or_layout();
let for_display = reflow_goal == ReflowGoal::Full;
let mut issued_reflow = false;