Commit 0122258c authored by Yoichi Osato's avatar Yoichi Osato Committed by Commit Bot

LayoutSelection::ComputeSelectionStatus must be called only at clean layout

ComputeSelectionStatus was called also at dirty layout only for test purpose.
However we should call it only at clean layout.
This patch DCHECKs the condition and brushes up the test not to do so.

Bug: 708452
Change-Id: If19ff331b4945a6506719b0154378960d50b8f1f
Reviewed-on: https://chromium-review.googlesource.com/c/1441732Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Commit-Queue: Yoichi Osato <yoichio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626921}
parent 31977c6e
......@@ -649,6 +649,9 @@ static LayoutTextSelectionStatus ComputeSelectionStatusForNode(
LayoutTextSelectionStatus LayoutSelection::ComputeSelectionStatus(
const LayoutText& layout_text) const {
Document& document = frame_selection_->GetDocument();
DCHECK_GE(document.Lifecycle().GetState(), DocumentLifecycle::kLayoutClean);
DCHECK(!document.IsSlotAssignmentOrLegacyDistributionDirty());
DCHECK(!has_pending_selection_);
const SelectionState selection_state = GetSelectionStateFor(layout_text);
if (selection_state == SelectionState::kNone)
......@@ -683,6 +686,9 @@ LayoutTextSelectionStatus FrameSelection::ComputeLayoutSelectionStatus(
// LayoutText and not of each NGPhysicalTextFragment for it.
LayoutSelectionStatus LayoutSelection::ComputeSelectionStatus(
const NGPaintFragment& fragment) const {
Document& document = frame_selection_->GetDocument();
DCHECK_GE(document.Lifecycle().GetState(), DocumentLifecycle::kLayoutClean);
DCHECK(!document.IsSlotAssignmentOrLegacyDistributionDirty());
const NGPhysicalTextFragment& text_fragment =
ToNGPhysicalTextFragmentOrDie(fragment.PhysicalFragment());
// We don't paint selection on ellipsis.
......
......@@ -777,11 +777,13 @@ TEST_P(LayoutSelectionTest, ClearByRemoveNode) {
Node* baz = GetDocument().body()->lastChild();
baz->remove();
GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
Selection().CommitAppearanceIfNeeded();
EXPECT_EQ(
"BODY, Contain, NotInvalidate \n"
" 'foo', Start(0,3), ShouldInvalidate \n"
" SPAN, Contain, NotInvalidate \n"
" 'bar', Inside(0,3), ShouldInvalidate ",
" 'bar', End(0,3), ShouldInvalidate ",
DumpSelectionInfo());
UpdateAllLifecyclePhasesForTest();
......@@ -808,12 +810,13 @@ TEST_P(LayoutSelectionTest, ClearByRemoveLayoutObject) {
Element* span_baz = ToElement(GetDocument().body()->lastChild());
span_baz->SetInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
GetDocument().UpdateStyleAndLayoutTreeIgnorePendingStylesheets();
GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
Selection().CommitAppearanceIfNeeded();
EXPECT_EQ(
"BODY, Contain, NotInvalidate \n"
" 'foo', Start(0,3), ShouldInvalidate \n"
" SPAN, Contain, NotInvalidate \n"
" 'bar', Inside(0,3), ShouldInvalidate \n"
" 'bar', End(0,3), ShouldInvalidate \n"
" SPAN, <null LayoutObject> \n"
" 'baz', <null LayoutObject> ",
DumpSelectionInfo());
......@@ -851,12 +854,13 @@ TEST_P(LayoutSelectionTest, ClearBySlotChange) {
GetDocument().body()->firstChild()->GetShadowRoot()->QuerySelector(
"slot");
slot->setAttribute("name", "s2");
GetDocument().UpdateStyleAndLayoutTreeIgnorePendingStylesheets();
GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
Selection().CommitAppearanceIfNeeded();
EXPECT_EQ(
"BODY, Contain, NotInvalidate \n"
" DIV, Contain, NotInvalidate \n"
" #shadow-root \n"
" 'Foo', Start(0,3), ShouldInvalidate \n"
" 'Foo', StartAndEnd(0,3), ShouldInvalidate \n"
" SLOT, <null LayoutObject> \n"
" 'baz', <null LayoutObject> \n"
" SPAN, <null LayoutObject> \n"
......
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