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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 document().view()->updateAllLifecyclePhases(); | 94 document().view()->updateAllLifecyclePhases(); |
95 | 95 |
96 VisibleSelection validSelection(Position(text, 0), Position(text, 0)); | 96 VisibleSelection validSelection(Position(text, 0), Position(text, 0)); |
97 setSelection(validSelection); | 97 setSelection(validSelection); |
98 selection().setCaretRectNeedsUpdate(); | 98 selection().setCaretRectNeedsUpdate(); |
99 EXPECT_TRUE(selection().isCaretBoundsDirty()); | 99 EXPECT_TRUE(selection().isCaretBoundsDirty()); |
100 selection().invalidateCaretRect(); | 100 selection().invalidateCaretRect(); |
101 EXPECT_FALSE(selection().isCaretBoundsDirty()); | 101 EXPECT_FALSE(selection().isCaretBoundsDirty()); |
102 | 102 |
103 document().body()->removeChild(text); | 103 document().body()->removeChild(text); |
104 document().updateLayoutIgnorePendingStylesheets(); | 104 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
105 selection().setCaretRectNeedsUpdate(); | 105 selection().setCaretRectNeedsUpdate(); |
106 EXPECT_TRUE(selection().isCaretBoundsDirty()); | 106 EXPECT_TRUE(selection().isCaretBoundsDirty()); |
107 selection().invalidateCaretRect(); | 107 selection().invalidateCaretRect(); |
108 EXPECT_FALSE(selection().isCaretBoundsDirty()); | 108 EXPECT_FALSE(selection().isCaretBoundsDirty()); |
109 } | 109 } |
110 | 110 |
111 TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) | 111 TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) |
112 { | 112 { |
113 Text* text = appendTextNode("Hello, World!"); | 113 Text* text = appendTextNode("Hello, World!"); |
114 document().view()->updateAllLifecyclePhases(); | 114 document().view()->updateAllLifecyclePhases(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 EXPECT_TRUE(isPreviousCaretDirtyForTesting()); | 171 EXPECT_TRUE(isPreviousCaretDirtyForTesting()); |
172 selection().invalidateCaretRect(); | 172 selection().invalidateCaretRect(); |
173 EXPECT_FALSE(selection().isCaretBoundsDirty()); | 173 EXPECT_FALSE(selection().isCaretBoundsDirty()); |
174 EXPECT_TRUE(isPreviousCaretDirtyForTesting()); | 174 EXPECT_TRUE(isPreviousCaretDirtyForTesting()); |
175 | 175 |
176 // Simulate to remove the last character. | 176 // Simulate to remove the last character. |
177 document().body()->removeChild(text); | 177 document().body()->removeChild(text); |
178 // This line is the objective of this test. | 178 // This line is the objective of this test. |
179 // As removing the last character, early previousCaret invalidation is execu
ted. | 179 // As removing the last character, early previousCaret invalidation is execu
ted. |
180 EXPECT_FALSE(isPreviousCaretDirtyForTesting()); | 180 EXPECT_FALSE(isPreviousCaretDirtyForTesting()); |
181 document().updateLayoutIgnorePendingStylesheets(); | 181 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
182 selection().setCaretRectNeedsUpdate(); | 182 selection().setCaretRectNeedsUpdate(); |
183 EXPECT_TRUE(selection().isCaretBoundsDirty()); | 183 EXPECT_TRUE(selection().isCaretBoundsDirty()); |
184 EXPECT_FALSE(isPreviousCaretDirtyForTesting()); | 184 EXPECT_FALSE(isPreviousCaretDirtyForTesting()); |
185 selection().invalidateCaretRect(); | 185 selection().invalidateCaretRect(); |
186 EXPECT_FALSE(selection().isCaretBoundsDirty()); | 186 EXPECT_FALSE(selection().isCaretBoundsDirty()); |
187 EXPECT_TRUE(isPreviousCaretDirtyForTesting()); | 187 EXPECT_TRUE(isPreviousCaretDirtyForTesting()); |
188 } | 188 } |
189 | 189 |
190 #define EXPECT_EQ_SELECTED_TEXT(text) \ | 190 #define EXPECT_EQ_SELECTED_TEXT(text) \ |
191 EXPECT_EQ(text, WebString(selection().selectedText()).utf8()) | 191 EXPECT_EQ(text, WebString(selection().selectedText()).utf8()) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 283 |
284 TEST_F(FrameSelectionTest, SelectAllWithUnselectableRoot) | 284 TEST_F(FrameSelectionTest, SelectAllWithUnselectableRoot) |
285 { | 285 { |
286 Element* select = document().createElement("select", ASSERT_NO_EXCEPTION); | 286 Element* select = document().createElement("select", ASSERT_NO_EXCEPTION); |
287 document().replaceChild(select, document().documentElement()); | 287 document().replaceChild(select, document().documentElement()); |
288 selection().selectAll(); | 288 selection().selectAll(); |
289 EXPECT_TRUE(selection().isNone()) << "Nothing should be selected if the cont
ent of the documentElement is not selctable."; | 289 EXPECT_TRUE(selection().isNone()) << "Nothing should be selected if the cont
ent of the documentElement is not selctable."; |
290 } | 290 } |
291 | 291 |
292 } // namespace blink | 292 } // namespace blink |
OLD | NEW |