Commit 0d92c744 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Move UpdateCompositedSelectionIfNeeded() after pre-paint.

This makes it safe to use property trees and LayerState
on GraphicsLayers.

Bug: 929028

Change-Id: I5b6ca533b0c3c4c30e5f6f75132064f0d4b7b987
Reviewed-on: https://chromium-review.googlesource.com/c/1459518Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630119}
parent d3415886
......@@ -13,6 +13,7 @@
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/forms/text_control_element.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/testing/use_mock_scrollbar_settings.h"
......@@ -50,11 +51,13 @@ class ComputeLayerSelectionTest : public EditingTestBase {
TEST_F(ComputeLayerSelectionTest, ComputeLayerSelection) {
SetBodyContent(R"HTML(
<!DOCTYPE html>
input {
font: 10px/1 Ahem;
padding: 0;
border: 0;
}
<style>
input {
font: 10px/1 Ahem;
padding: 0;
border: 0;
}
</style>
<input id=target width=20 value='test test test test test tes tes test'
style='width: 100px; height: 20px;'>
)HTML");
......@@ -67,6 +70,35 @@ TEST_F(ComputeLayerSelectionTest, ComputeLayerSelection) {
EXPECT_TRUE(composited_selection.end.hidden);
}
TEST_F(ComputeLayerSelectionTest, DontCrashOnLayerCreation) {
SetBodyContent(R"HTML(
<!DOCTYPE html>
<style>
input {
font: 10px/1 Ahem;
padding: 0;
border: 0;
width: 100px; height: 20px;
position: relative;
}
</style>
<input id=target width=20 value='test test test test test tes tes test'>
)HTML");
Element* target = GetDocument().getElementById("target");
FocusAndSelectAll(ToHTMLInputElement(target));
const cc::LayerSelection& composited_selection =
ComputeLayerSelection(Selection());
EXPECT_FALSE(composited_selection.start.hidden);
EXPECT_TRUE(composited_selection.end.hidden);
target->setAttribute(html_names::kStyleAttr, "will-change: transform");
UpdateAllLifecyclePhasesForTest();
// Passes if no crash.
}
TEST_F(ComputeLayerSelectionTest, PositionInScrollableRoot) {
SetBodyContent(R"HTML(
<!DOCTYPE html>
......
......@@ -2306,14 +2306,7 @@ bool LocalFrameView::RunCompositingLifecyclePhase(
*this);
}
// We need to run more phases only if the target is beyond kCompositingClean.
if (target_state > DocumentLifecycle::kCompositingClean) {
// TODO(vmpstr): Why is composited selection only updated if we're moving
// past kCompositingClean?
UpdateCompositedSelectionIfNeeded();
return true;
}
return false;
return target_state > DocumentLifecycle::kCompositingClean;
}
bool LocalFrameView::RunPrePaintLifecyclePhase(
......@@ -2354,6 +2347,8 @@ bool LocalFrameView::RunPrePaintLifecyclePhase(
PrePaintTreeWalk().WalkTree(*this);
}
UpdateCompositedSelectionIfNeeded();
ForAllNonThrottledLocalFrameViews([](LocalFrameView& frame_view) {
frame_view.Lifecycle().AdvanceTo(DocumentLifecycle::kPrePaintClean);
});
......
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