Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Side by Side Diff: third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp

Issue 2704123003: Expand FrameSeleciton::isCaret() to increase chances of hoisting update layout (Closed)
Patch Set: 2017-02-21T12:50:46 Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/editing/FrameSelection.h" 5 #include "core/editing/FrameSelection.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/Element.h" 10 #include "core/dom/Element.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 document().view()->updateAllLifecyclePhases(); 71 document().view()->updateAllLifecyclePhases();
72 72
73 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION); 73 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION);
74 document().body()->focus(); 74 document().body()->focus();
75 EXPECT_TRUE(document().body()->isFocused()); 75 EXPECT_TRUE(document().body()->isFocused());
76 76
77 selection().setCaretVisible(true); 77 selection().setCaretVisible(true);
78 selection().setSelection( 78 selection().setSelection(
79 SelectionInDOMTree::Builder().collapse(Position(text, 0)).build()); 79 SelectionInDOMTree::Builder().collapse(Position(text, 0)).build());
80 document().view()->updateAllLifecyclePhases(); 80 document().view()->updateAllLifecyclePhases();
81 EXPECT_TRUE(selection().isCaret()); 81 EXPECT_TRUE(
82 selection().computeVisibleSelectionInDOMTreeDeprecated().isCaret());
82 EXPECT_TRUE(toLayoutBlock(document().body()->layoutObject()) 83 EXPECT_TRUE(toLayoutBlock(document().body()->layoutObject())
83 ->shouldPaintCursorCaret()); 84 ->shouldPaintCursorCaret());
84 85
85 int startCount = layoutCount(); 86 int startCount = layoutCount();
86 { 87 {
87 // To force layout in next updateLayout calling, widen view. 88 // To force layout in next updateLayout calling, widen view.
88 FrameView& frameView = dummyPageHolder().frameView(); 89 FrameView& frameView = dummyPageHolder().frameView();
89 IntRect frameRect = frameView.frameRect(); 90 IntRect frameRect = frameView.frameRect();
90 frameRect.setWidth(frameRect.width() + 1); 91 frameRect.setWidth(frameRect.width() + 1);
91 frameRect.setHeight(frameRect.height() + 1); 92 frameRect.setHeight(frameRect.height() + 1);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 EXPECT_EQ(selection().start(), caretPosition().position()); 272 EXPECT_EQ(selection().start(), caretPosition().position());
272 document().updateStyleAndLayout(); 273 document().updateStyleAndLayout();
273 selection().updateIfNeeded(); 274 selection().updateIfNeeded();
274 275
275 EXPECT_EQ(Position(), selection().start()) 276 EXPECT_EQ(Position(), selection().start())
276 << "selection().updateIfNeeded() does nothing."; 277 << "selection().updateIfNeeded() does nothing.";
277 EXPECT_EQ(selection().start(), caretPosition().position()); 278 EXPECT_EQ(selection().start(), caretPosition().position());
278 } 279 }
279 280
280 } // namespace blink 281 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698