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 @@ ...@@ -13,6 +13,7 @@
#include "third_party/blink/renderer/core/html/forms/html_input_element.h" #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/html/forms/text_control_element.h"
#include "third_party/blink/renderer/core/layout/layout_box.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/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/testing/use_mock_scrollbar_settings.h" #include "third_party/blink/renderer/core/testing/use_mock_scrollbar_settings.h"
...@@ -50,11 +51,13 @@ class ComputeLayerSelectionTest : public EditingTestBase { ...@@ -50,11 +51,13 @@ class ComputeLayerSelectionTest : public EditingTestBase {
TEST_F(ComputeLayerSelectionTest, ComputeLayerSelection) { TEST_F(ComputeLayerSelectionTest, ComputeLayerSelection) {
SetBodyContent(R"HTML( SetBodyContent(R"HTML(
<!DOCTYPE html> <!DOCTYPE html>
input { <style>
font: 10px/1 Ahem; input {
padding: 0; font: 10px/1 Ahem;
border: 0; padding: 0;
} border: 0;
}
</style>
<input id=target width=20 value='test test test test test tes tes test' <input id=target width=20 value='test test test test test tes tes test'
style='width: 100px; height: 20px;'> style='width: 100px; height: 20px;'>
)HTML"); )HTML");
...@@ -67,6 +70,35 @@ TEST_F(ComputeLayerSelectionTest, ComputeLayerSelection) { ...@@ -67,6 +70,35 @@ TEST_F(ComputeLayerSelectionTest, ComputeLayerSelection) {
EXPECT_TRUE(composited_selection.end.hidden); 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) { TEST_F(ComputeLayerSelectionTest, PositionInScrollableRoot) {
SetBodyContent(R"HTML( SetBodyContent(R"HTML(
<!DOCTYPE html> <!DOCTYPE html>
......
...@@ -2306,14 +2306,7 @@ bool LocalFrameView::RunCompositingLifecyclePhase( ...@@ -2306,14 +2306,7 @@ bool LocalFrameView::RunCompositingLifecyclePhase(
*this); *this);
} }
// We need to run more phases only if the target is beyond kCompositingClean. return target_state > DocumentLifecycle::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;
} }
bool LocalFrameView::RunPrePaintLifecyclePhase( bool LocalFrameView::RunPrePaintLifecyclePhase(
...@@ -2354,6 +2347,8 @@ bool LocalFrameView::RunPrePaintLifecyclePhase( ...@@ -2354,6 +2347,8 @@ bool LocalFrameView::RunPrePaintLifecyclePhase(
PrePaintTreeWalk().WalkTree(*this); PrePaintTreeWalk().WalkTree(*this);
} }
UpdateCompositedSelectionIfNeeded();
ForAllNonThrottledLocalFrameViews([](LocalFrameView& frame_view) { ForAllNonThrottledLocalFrameViews([](LocalFrameView& frame_view) {
frame_view.Lifecycle().AdvanceTo(DocumentLifecycle::kPrePaintClean); 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