Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "bindings/core/v8/ExceptionStatePlaceholder.h" | 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
| 10 #include "core/dom/Text.h" | 10 #include "core/dom/Text.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 EXPECT_FALSE(selection().isCaretBoundsDirty()); | 88 EXPECT_FALSE(selection().isCaretBoundsDirty()); |
| 89 | 89 |
| 90 document().body()->removeChild(text); | 90 document().body()->removeChild(text); |
| 91 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 91 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 92 selection().setCaretRectNeedsUpdate(); | 92 selection().setCaretRectNeedsUpdate(); |
| 93 EXPECT_TRUE(selection().isCaretBoundsDirty()); | 93 EXPECT_TRUE(selection().isCaretBoundsDirty()); |
| 94 selection().invalidateCaretRect(); | 94 selection().invalidateCaretRect(); |
| 95 EXPECT_FALSE(selection().isCaretBoundsDirty()); | 95 EXPECT_FALSE(selection().isCaretBoundsDirty()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) | |
| 99 { | |
| 100 Text* text = appendTextNode("Hello, World!"); | |
| 101 document().view()->updateAllLifecyclePhases(); | |
| 102 | |
| 103 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION); | |
| 104 document().body()->focus(); | |
| 105 EXPECT_TRUE(document().body()->focused()); | |
| 106 | |
| 107 VisibleSelection validSelection(Position(text, 0), Position(text, 0)); | |
| 108 selection().setCaretVisible(true); | |
| 109 setSelection(validSelection); | |
| 110 EXPECT_TRUE(selection().isCaret()); | |
| 111 EXPECT_TRUE(shouldPaintCaretForTesting()); | |
| 112 | |
| 113 int startCount = layoutCount(); | |
| 114 { | |
| 115 // To force layout in next updateLayout calling, widen view. | |
| 116 FrameView& frameView = dummyPageHolder().frameView(); | |
| 117 IntRect frameRect = frameView.frameRect(); | |
| 118 frameRect.setWidth(frameRect.width() + 1); | |
| 119 frameRect.setHeight(frameRect.height() + 1); | |
| 120 dummyPageHolder().frameView().setFrameRect(frameRect); | |
| 121 } | |
| 122 std::unique_ptr<PaintController> paintController = PaintController::create() ; | |
| 123 { | |
| 124 GraphicsContext context(*paintController); | |
| 125 DrawingRecorder drawingRecorder(context, *dummyPageHolder().frameView(). layoutView(), DisplayItem::Caret, LayoutRect::infiniteIntRect()); | |
| 126 selection().paintCaret(context, LayoutPoint()); | |
| 127 } | |
| 128 paintController->commitNewDisplayItems(); | |
| 129 EXPECT_EQ(startCount, layoutCount()); | |
|
trchen
2016/07/28 00:04:36
This is bogus. Resizing the frame would invalidate
bokan
2016/07/28 13:24:56
Agree, this is sketchy. Could you file a bug to fo
trchen
2016/07/28 22:45:54
I think the original bug is already solved. Xianzh
bokan
2016/07/28 22:48:41
ok, sgtm, thanks.
| |
| 130 } | |
| 131 | |
| 132 TEST_F(FrameSelectionTest, InvalidatePreviousCaretAfterRemovingLastCharacter) | 98 TEST_F(FrameSelectionTest, InvalidatePreviousCaretAfterRemovingLastCharacter) |
| 133 { | 99 { |
| 134 Text* text = appendTextNode("Hello, World!"); | 100 Text* text = appendTextNode("Hello, World!"); |
| 135 document().view()->updateAllLifecyclePhases(); | 101 document().view()->updateAllLifecyclePhases(); |
| 136 | 102 |
| 137 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION); | 103 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION); |
| 138 document().body()->focus(); | 104 document().body()->focus(); |
| 139 EXPECT_TRUE(document().body()->focused()); | 105 EXPECT_TRUE(document().body()->focused()); |
| 140 | 106 |
| 141 selection().setCaretVisible(true); | 107 selection().setCaretVisible(true); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 selection().updateIfNeeded(); | 261 selection().updateIfNeeded(); |
| 296 | 262 |
| 297 // TODO(yosin): Once lazy canonicalization implemented, selection.start | 263 // TODO(yosin): Once lazy canonicalization implemented, selection.start |
| 298 // should be Position(HTML, 0). | 264 // should be Position(HTML, 0). |
| 299 EXPECT_EQ(Position(), selection().start()) | 265 EXPECT_EQ(Position(), selection().start()) |
| 300 << "updateIfNeeded() makes selection to null."; | 266 << "updateIfNeeded() makes selection to null."; |
| 301 EXPECT_EQ(selection().start(), caretPosition().position()); | 267 EXPECT_EQ(selection().start(), caretPosition().position()); |
| 302 } | 268 } |
| 303 | 269 |
| 304 } // namespace blink | 270 } // namespace blink |
| OLD | NEW |