Commit eec0a93f authored by leviw's avatar leviw Committed by Commit bot

Ensure WebView plugins run their lifecycle even absent main frame Layout

The PluginView method layoutIfNeeded causes WebView plugins to update
their entire lifecycle, but we only call that if their layout is
dirtied. In the presence of some style changes, they can need
invalidation or compositing updates without layout, and our recursive
lifecycle update missed WebView plugins as it only recurses through
the Frame tree.

This change always updates child plugins when
FrameView::updateStyleAndLayoutIfNeededRecursive is called.

BUG=545039

Review URL: https://codereview.chromium.org/1708923002

Cr-Commit-Position: refs/heads/master@{#376114}
parent 67f195ef
<!DOCTYPE html>
<style>
html:first-letter { color: papayawhip; }
</style>
<script>
function boom() {
if (window.testRunner)
testRunner.dumpAsText();
// Trigger a full-document style recalc.
document.getElementsByTagName("style")[0].disabled = true;
// Force the style to update without running the rest of the lifecycle.
document.querySelector("embed").align;
}
</script>
<body onload="boom()">
<embed type="html">
Test passes if no crash.
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
#include "core/paint/FramePainter.h" #include "core/paint/FramePainter.h"
#include "core/paint/PaintLayer.h" #include "core/paint/PaintLayer.h"
#include "core/paint/PaintPropertyTreeBuilder.h" #include "core/paint/PaintPropertyTreeBuilder.h"
#include "core/plugins/PluginView.h"
#include "core/style/ComputedStyle.h" #include "core/style/ComputedStyle.h"
#include "core/svg/SVGDocumentExtensions.h" #include "core/svg/SVGDocumentExtensions.h"
#include "core/svg/SVGSVGElement.h" #include "core/svg/SVGSVGElement.h"
...@@ -2435,6 +2436,7 @@ void FrameView::scheduleVisualUpdateForPaintInvalidationIfNeeded() ...@@ -2435,6 +2436,7 @@ void FrameView::scheduleVisualUpdateForPaintInvalidationIfNeeded()
// Otherwise the paint invalidation will be handled in paint invalidation phase of this cycle. // Otherwise the paint invalidation will be handled in paint invalidation phase of this cycle.
} }
// TODO(leviw): We don't assert lifecycle information from documents in child PluginViews.
void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases) void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases)
{ {
Optional<TemporaryChange<bool>> isUpdatingAllLifecyclePhasesScope; Optional<TemporaryChange<bool>> isUpdatingAllLifecyclePhasesScope;
...@@ -2622,6 +2624,17 @@ void FrameView::updateStyleAndLayoutIfNeededRecursive() ...@@ -2622,6 +2624,17 @@ void FrameView::updateStyleAndLayoutIfNeededRecursive()
if (needsLayout()) if (needsLayout())
layout(); layout();
// WebView plugins need to update regardless of whether the LayoutEmbeddedObject
// that owns them needed layout.
// TODO(leviw): This currently runs the entire lifecycle on plugin WebViews. We
// should have a way to only run these other Documents to the same lifecycle stage
// as this frame.
const ChildrenWidgetSet* viewChildren = children();
for (const RefPtrWillBeMember<Widget>& child : *viewChildren) {
if ((*child).isPluginContainer())
toPluginView(child.get())->layoutIfNeeded();
}
// FIXME: Calling layout() shouldn't trigger script execution or have any // FIXME: Calling layout() shouldn't trigger script execution or have any
// observable effects on the frame tree but we're not quite there yet. // observable effects on the frame tree but we're not quite there yet.
WillBeHeapVector<RefPtrWillBeMember<FrameView>> frameViews; WillBeHeapVector<RefPtrWillBeMember<FrameView>> frameViews;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment