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

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

Issue 2803363002: Rename caretDisplayItemClient() to getCaretDisplayItemClient(). (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/CaretDisplayItemClient.h" 5 #include "core/editing/CaretDisplayItemClient.h"
6 6
7 #include "core/HTMLNames.h" 7 #include "core/HTMLNames.h"
8 #include "core/editing/FrameSelection.h" 8 #include "core/editing/FrameSelection.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/layout/LayoutTestHelper.h" 10 #include "core/layout/LayoutTestHelper.h"
(...skipping 18 matching lines...) Expand all
29 return layoutView() 29 return layoutView()
30 .layer() 30 .layer()
31 ->graphicsLayerBacking() 31 ->graphicsLayerBacking()
32 ->getRasterInvalidationTracking(); 32 ->getRasterInvalidationTracking();
33 } 33 }
34 34
35 FrameSelection& selection() const { 35 FrameSelection& selection() const {
36 return document().view()->frame().selection(); 36 return document().view()->frame().selection();
37 } 37 }
38 38
39 const DisplayItemClient& caretDisplayItemClient() const { 39 const DisplayItemClient& getCaretDisplayItemClient() const {
40 return selection().caretDisplayItemClientForTesting(); 40 return selection().caretDisplayItemClientForTesting();
41 } 41 }
42 42
43 const LayoutBlock* caretLayoutBlock() const { 43 const LayoutBlock* caretLayoutBlock() const {
44 return static_cast<const CaretDisplayItemClient&>(caretDisplayItemClient()) 44 return static_cast<const CaretDisplayItemClient&>(
45 getCaretDisplayItemClient())
45 .m_layoutBlock; 46 .m_layoutBlock;
46 } 47 }
47 48
48 const LayoutBlock* previousCaretLayoutBlock() const { 49 const LayoutBlock* previousCaretLayoutBlock() const {
49 return static_cast<const CaretDisplayItemClient&>(caretDisplayItemClient()) 50 return static_cast<const CaretDisplayItemClient&>(
51 getCaretDisplayItemClient())
50 .m_previousLayoutBlock; 52 .m_previousLayoutBlock;
51 } 53 }
52 54
53 Text* appendTextNode(const String& data) { 55 Text* appendTextNode(const String& data) {
54 Text* text = document().createTextNode(data); 56 Text* text = document().createTextNode(data);
55 document().body()->appendChild(text); 57 document().body()->appendChild(text);
56 return text; 58 return text;
57 } 59 }
58 60
59 Element* appendBlock(const String& data) { 61 Element* appendBlock(const String& data) {
(...skipping 21 matching lines...) Expand all
81 Text* text = appendTextNode("Hello, World!"); 83 Text* text = appendTextNode("Hello, World!");
82 updateAllLifecyclePhases(); 84 updateAllLifecyclePhases();
83 const auto* block = toLayoutBlock(document().body()->layoutObject()); 85 const auto* block = toLayoutBlock(document().body()->layoutObject());
84 86
85 // Focus the body. Should invalidate the new caret. 87 // Focus the body. Should invalidate the new caret.
86 document().view()->setTracksPaintInvalidations(true); 88 document().view()->setTracksPaintInvalidations(true);
87 document().body()->focus(); 89 document().body()->focus();
88 updateAllLifecyclePhases(); 90 updateAllLifecyclePhases();
89 EXPECT_TRUE(block->shouldPaintCursorCaret()); 91 EXPECT_TRUE(block->shouldPaintCursorCaret());
90 92
91 LayoutRect caretVisualRect = caretDisplayItemClient().visualRect(); 93 LayoutRect caretVisualRect = getCaretDisplayItemClient().visualRect();
92 EXPECT_EQ(1, caretVisualRect.width()); 94 EXPECT_EQ(1, caretVisualRect.width());
93 EXPECT_EQ(block->location(), caretVisualRect.location()); 95 EXPECT_EQ(block->location(), caretVisualRect.location());
94 96
95 const auto* rasterInvalidations = 97 const auto* rasterInvalidations =
96 &getRasterInvalidationTracking()->trackedRasterInvalidations; 98 &getRasterInvalidationTracking()->trackedRasterInvalidations;
97 ASSERT_EQ(1u, rasterInvalidations->size()); 99 ASSERT_EQ(1u, rasterInvalidations->size());
98 EXPECT_EQ(enclosingIntRect(caretVisualRect), (*rasterInvalidations)[0].rect); 100 EXPECT_EQ(enclosingIntRect(caretVisualRect), (*rasterInvalidations)[0].rect);
99 EXPECT_EQ(block, (*rasterInvalidations)[0].client); 101 EXPECT_EQ(block, (*rasterInvalidations)[0].client);
100 EXPECT_EQ(PaintInvalidationCaret, (*rasterInvalidations)[0].reason); 102 EXPECT_EQ(PaintInvalidationCaret, (*rasterInvalidations)[0].reason);
101 103
102 std::unique_ptr<JSONArray> objectInvalidations = 104 std::unique_ptr<JSONArray> objectInvalidations =
103 document().view()->trackedObjectPaintInvalidationsAsJSON(); 105 document().view()->trackedObjectPaintInvalidationsAsJSON();
104 ASSERT_EQ(1u, objectInvalidations->size()); 106 ASSERT_EQ(1u, objectInvalidations->size());
105 String s; 107 String s;
106 JSONObject::cast(objectInvalidations->at(0))->get("object")->asString(&s); 108 JSONObject::cast(objectInvalidations->at(0))->get("object")->asString(&s);
107 EXPECT_EQ("Caret", s); 109 EXPECT_EQ("Caret", s);
108 document().view()->setTracksPaintInvalidations(false); 110 document().view()->setTracksPaintInvalidations(false);
109 111
110 // Move the caret to the end of the text. Should invalidate both the old and 112 // Move the caret to the end of the text. Should invalidate both the old and
111 // new carets. 113 // new carets.
112 document().view()->setTracksPaintInvalidations(true); 114 document().view()->setTracksPaintInvalidations(true);
113 selection().setSelection( 115 selection().setSelection(
114 SelectionInDOMTree::Builder().collapse(Position(text, 5)).build()); 116 SelectionInDOMTree::Builder().collapse(Position(text, 5)).build());
115 updateAllLifecyclePhases(); 117 updateAllLifecyclePhases();
116 EXPECT_TRUE(block->shouldPaintCursorCaret()); 118 EXPECT_TRUE(block->shouldPaintCursorCaret());
117 119
118 LayoutRect newCaretVisualRect = caretDisplayItemClient().visualRect(); 120 LayoutRect newCaretVisualRect = getCaretDisplayItemClient().visualRect();
119 EXPECT_EQ(caretVisualRect.size(), newCaretVisualRect.size()); 121 EXPECT_EQ(caretVisualRect.size(), newCaretVisualRect.size());
120 EXPECT_EQ(caretVisualRect.y(), newCaretVisualRect.y()); 122 EXPECT_EQ(caretVisualRect.y(), newCaretVisualRect.y());
121 EXPECT_LT(caretVisualRect.x(), newCaretVisualRect.x()); 123 EXPECT_LT(caretVisualRect.x(), newCaretVisualRect.x());
122 124
123 rasterInvalidations = 125 rasterInvalidations =
124 &getRasterInvalidationTracking()->trackedRasterInvalidations; 126 &getRasterInvalidationTracking()->trackedRasterInvalidations;
125 ASSERT_EQ(2u, rasterInvalidations->size()); 127 ASSERT_EQ(2u, rasterInvalidations->size());
126 EXPECT_EQ(enclosingIntRect(caretVisualRect), (*rasterInvalidations)[0].rect); 128 EXPECT_EQ(enclosingIntRect(caretVisualRect), (*rasterInvalidations)[0].rect);
127 EXPECT_EQ(block, (*rasterInvalidations)[0].client); 129 EXPECT_EQ(block, (*rasterInvalidations)[0].client);
128 EXPECT_EQ(PaintInvalidationCaret, (*rasterInvalidations)[0].reason); 130 EXPECT_EQ(PaintInvalidationCaret, (*rasterInvalidations)[0].reason);
129 EXPECT_EQ(enclosingIntRect(newCaretVisualRect), 131 EXPECT_EQ(enclosingIntRect(newCaretVisualRect),
130 (*rasterInvalidations)[1].rect); 132 (*rasterInvalidations)[1].rect);
131 EXPECT_EQ(block, (*rasterInvalidations)[1].client); 133 EXPECT_EQ(block, (*rasterInvalidations)[1].client);
132 EXPECT_EQ(PaintInvalidationCaret, (*rasterInvalidations)[1].reason); 134 EXPECT_EQ(PaintInvalidationCaret, (*rasterInvalidations)[1].reason);
133 135
134 objectInvalidations = 136 objectInvalidations =
135 document().view()->trackedObjectPaintInvalidationsAsJSON(); 137 document().view()->trackedObjectPaintInvalidationsAsJSON();
136 ASSERT_EQ(1u, objectInvalidations->size()); 138 ASSERT_EQ(1u, objectInvalidations->size());
137 JSONObject::cast(objectInvalidations->at(0))->get("object")->asString(&s); 139 JSONObject::cast(objectInvalidations->at(0))->get("object")->asString(&s);
138 EXPECT_EQ("Caret", s); 140 EXPECT_EQ("Caret", s);
139 document().view()->setTracksPaintInvalidations(false); 141 document().view()->setTracksPaintInvalidations(false);
140 142
141 // Remove selection. Should invalidate the old caret. 143 // Remove selection. Should invalidate the old caret.
142 LayoutRect oldCaretVisualRect = newCaretVisualRect; 144 LayoutRect oldCaretVisualRect = newCaretVisualRect;
143 document().view()->setTracksPaintInvalidations(true); 145 document().view()->setTracksPaintInvalidations(true);
144 selection().setSelection(SelectionInDOMTree()); 146 selection().setSelection(SelectionInDOMTree());
145 updateAllLifecyclePhases(); 147 updateAllLifecyclePhases();
146 EXPECT_FALSE(block->shouldPaintCursorCaret()); 148 EXPECT_FALSE(block->shouldPaintCursorCaret());
147 EXPECT_EQ(LayoutRect(), caretDisplayItemClient().visualRect()); 149 EXPECT_EQ(LayoutRect(), getCaretDisplayItemClient().visualRect());
148 150
149 rasterInvalidations = 151 rasterInvalidations =
150 &getRasterInvalidationTracking()->trackedRasterInvalidations; 152 &getRasterInvalidationTracking()->trackedRasterInvalidations;
151 ASSERT_EQ(1u, rasterInvalidations->size()); 153 ASSERT_EQ(1u, rasterInvalidations->size());
152 EXPECT_EQ(enclosingIntRect(oldCaretVisualRect), 154 EXPECT_EQ(enclosingIntRect(oldCaretVisualRect),
153 (*rasterInvalidations)[0].rect); 155 (*rasterInvalidations)[0].rect);
154 EXPECT_EQ(block, (*rasterInvalidations)[0].client); 156 EXPECT_EQ(block, (*rasterInvalidations)[0].client);
155 157
156 objectInvalidations = 158 objectInvalidations =
157 document().view()->trackedObjectPaintInvalidationsAsJSON(); 159 document().view()->trackedObjectPaintInvalidationsAsJSON();
158 ASSERT_EQ(1u, objectInvalidations->size()); 160 ASSERT_EQ(1u, objectInvalidations->size());
159 JSONObject::cast(objectInvalidations->at(0))->get("object")->asString(&s); 161 JSONObject::cast(objectInvalidations->at(0))->get("object")->asString(&s);
160 EXPECT_EQ("Caret", s); 162 EXPECT_EQ("Caret", s);
161 document().view()->setTracksPaintInvalidations(false); 163 document().view()->setTracksPaintInvalidations(false);
162 } 164 }
163 165
164 TEST_F(CaretDisplayItemClientTest, CaretMovesBetweenBlocks) { 166 TEST_F(CaretDisplayItemClientTest, CaretMovesBetweenBlocks) {
165 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION); 167 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION);
166 document().page()->focusController().setActive(true); 168 document().page()->focusController().setActive(true);
167 document().page()->focusController().setFocused(true); 169 document().page()->focusController().setFocused(true);
168 auto* blockElement1 = appendBlock("Block1"); 170 auto* blockElement1 = appendBlock("Block1");
169 auto* blockElement2 = appendBlock("Block2"); 171 auto* blockElement2 = appendBlock("Block2");
170 updateAllLifecyclePhases(); 172 updateAllLifecyclePhases();
171 auto* block1 = toLayoutBlock(blockElement1->layoutObject()); 173 auto* block1 = toLayoutBlock(blockElement1->layoutObject());
172 auto* block2 = toLayoutBlock(blockElement2->layoutObject()); 174 auto* block2 = toLayoutBlock(blockElement2->layoutObject());
173 175
174 // Focus the body. 176 // Focus the body.
175 document().body()->focus(); 177 document().body()->focus();
176 updateAllLifecyclePhases(); 178 updateAllLifecyclePhases();
177 LayoutRect caretVisualRect1 = caretDisplayItemClient().visualRect(); 179 LayoutRect caretVisualRect1 = getCaretDisplayItemClient().visualRect();
178 EXPECT_EQ(1, caretVisualRect1.width()); 180 EXPECT_EQ(1, caretVisualRect1.width());
179 EXPECT_EQ(block1->visualRect().location(), caretVisualRect1.location()); 181 EXPECT_EQ(block1->visualRect().location(), caretVisualRect1.location());
180 EXPECT_TRUE(block1->shouldPaintCursorCaret()); 182 EXPECT_TRUE(block1->shouldPaintCursorCaret());
181 EXPECT_FALSE(block2->shouldPaintCursorCaret()); 183 EXPECT_FALSE(block2->shouldPaintCursorCaret());
182 184
183 // Move the caret into block2. Should invalidate both the old and new carets. 185 // Move the caret into block2. Should invalidate both the old and new carets.
184 document().view()->setTracksPaintInvalidations(true); 186 document().view()->setTracksPaintInvalidations(true);
185 selection().setSelection(SelectionInDOMTree::Builder() 187 selection().setSelection(SelectionInDOMTree::Builder()
186 .collapse(Position(blockElement2, 0)) 188 .collapse(Position(blockElement2, 0))
187 .build()); 189 .build());
188 updateAllLifecyclePhases(); 190 updateAllLifecyclePhases();
189 191
190 LayoutRect caretVisualRect2 = caretDisplayItemClient().visualRect(); 192 LayoutRect caretVisualRect2 = getCaretDisplayItemClient().visualRect();
191 EXPECT_EQ(1, caretVisualRect2.width()); 193 EXPECT_EQ(1, caretVisualRect2.width());
192 EXPECT_EQ(block2->visualRect().location(), caretVisualRect2.location()); 194 EXPECT_EQ(block2->visualRect().location(), caretVisualRect2.location());
193 EXPECT_FALSE(block1->shouldPaintCursorCaret()); 195 EXPECT_FALSE(block1->shouldPaintCursorCaret());
194 EXPECT_TRUE(block2->shouldPaintCursorCaret()); 196 EXPECT_TRUE(block2->shouldPaintCursorCaret());
195 197
196 const auto* rasterInvalidations = 198 const auto* rasterInvalidations =
197 &getRasterInvalidationTracking()->trackedRasterInvalidations; 199 &getRasterInvalidationTracking()->trackedRasterInvalidations;
198 ASSERT_EQ(2u, rasterInvalidations->size()); 200 ASSERT_EQ(2u, rasterInvalidations->size());
199 EXPECT_EQ(enclosingIntRect(caretVisualRect1), (*rasterInvalidations)[0].rect); 201 EXPECT_EQ(enclosingIntRect(caretVisualRect1), (*rasterInvalidations)[0].rect);
200 EXPECT_EQ(block1, (*rasterInvalidations)[0].client); 202 EXPECT_EQ(block1, (*rasterInvalidations)[0].client);
201 EXPECT_EQ(PaintInvalidationCaret, (*rasterInvalidations)[0].reason); 203 EXPECT_EQ(PaintInvalidationCaret, (*rasterInvalidations)[0].reason);
202 EXPECT_EQ(enclosingIntRect(caretVisualRect2), (*rasterInvalidations)[1].rect); 204 EXPECT_EQ(enclosingIntRect(caretVisualRect2), (*rasterInvalidations)[1].rect);
203 EXPECT_EQ(block2, (*rasterInvalidations)[1].client); 205 EXPECT_EQ(block2, (*rasterInvalidations)[1].client);
204 EXPECT_EQ(PaintInvalidationCaret, (*rasterInvalidations)[1].reason); 206 EXPECT_EQ(PaintInvalidationCaret, (*rasterInvalidations)[1].reason);
205 207
206 std::unique_ptr<JSONArray> objectInvalidations = 208 std::unique_ptr<JSONArray> objectInvalidations =
207 document().view()->trackedObjectPaintInvalidationsAsJSON(); 209 document().view()->trackedObjectPaintInvalidationsAsJSON();
208 ASSERT_EQ(2u, objectInvalidations->size()); 210 ASSERT_EQ(2u, objectInvalidations->size());
209 document().view()->setTracksPaintInvalidations(false); 211 document().view()->setTracksPaintInvalidations(false);
210 212
211 // Move the caret back into block1. 213 // Move the caret back into block1.
212 document().view()->setTracksPaintInvalidations(true); 214 document().view()->setTracksPaintInvalidations(true);
213 selection().setSelection(SelectionInDOMTree::Builder() 215 selection().setSelection(SelectionInDOMTree::Builder()
214 .collapse(Position(blockElement1, 0)) 216 .collapse(Position(blockElement1, 0))
215 .build()); 217 .build());
216 updateAllLifecyclePhases(); 218 updateAllLifecyclePhases();
217 219
218 EXPECT_EQ(caretVisualRect1, caretDisplayItemClient().visualRect()); 220 EXPECT_EQ(caretVisualRect1, getCaretDisplayItemClient().visualRect());
219 EXPECT_TRUE(block1->shouldPaintCursorCaret()); 221 EXPECT_TRUE(block1->shouldPaintCursorCaret());
220 EXPECT_FALSE(block2->shouldPaintCursorCaret()); 222 EXPECT_FALSE(block2->shouldPaintCursorCaret());
221 223
222 rasterInvalidations = 224 rasterInvalidations =
223 &getRasterInvalidationTracking()->trackedRasterInvalidations; 225 &getRasterInvalidationTracking()->trackedRasterInvalidations;
224 ASSERT_EQ(2u, rasterInvalidations->size()); 226 ASSERT_EQ(2u, rasterInvalidations->size());
225 EXPECT_EQ(enclosingIntRect(caretVisualRect1), (*rasterInvalidations)[0].rect); 227 EXPECT_EQ(enclosingIntRect(caretVisualRect1), (*rasterInvalidations)[0].rect);
226 EXPECT_EQ(block1, (*rasterInvalidations)[0].client); 228 EXPECT_EQ(block1, (*rasterInvalidations)[0].client);
227 EXPECT_EQ(PaintInvalidationCaret, (*rasterInvalidations)[0].reason); 229 EXPECT_EQ(PaintInvalidationCaret, (*rasterInvalidations)[0].reason);
228 EXPECT_EQ(enclosingIntRect(caretVisualRect2), (*rasterInvalidations)[1].rect); 230 EXPECT_EQ(enclosingIntRect(caretVisualRect2), (*rasterInvalidations)[1].rect);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 TEST_F(CaretDisplayItemClientTest, CaretHideMoveAndShow) { 298 TEST_F(CaretDisplayItemClientTest, CaretHideMoveAndShow) {
297 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION); 299 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION);
298 document().page()->focusController().setActive(true); 300 document().page()->focusController().setActive(true);
299 document().page()->focusController().setFocused(true); 301 document().page()->focusController().setFocused(true);
300 302
301 Text* text = appendTextNode("Hello, World!"); 303 Text* text = appendTextNode("Hello, World!");
302 document().body()->focus(); 304 document().body()->focus();
303 updateAllLifecyclePhases(); 305 updateAllLifecyclePhases();
304 const auto* block = toLayoutBlock(document().body()->layoutObject()); 306 const auto* block = toLayoutBlock(document().body()->layoutObject());
305 307
306 LayoutRect caretVisualRect = caretDisplayItemClient().visualRect(); 308 LayoutRect caretVisualRect = getCaretDisplayItemClient().visualRect();
307 EXPECT_EQ(1, caretVisualRect.width()); 309 EXPECT_EQ(1, caretVisualRect.width());
308 EXPECT_EQ(block->location(), caretVisualRect.location()); 310 EXPECT_EQ(block->location(), caretVisualRect.location());
309 311
310 // Simulate that the blinking cursor becomes invisible. 312 // Simulate that the blinking cursor becomes invisible.
311 selection().setCaretVisible(false); 313 selection().setCaretVisible(false);
312 // Move the caret to the end of the text. 314 // Move the caret to the end of the text.
313 document().view()->setTracksPaintInvalidations(true); 315 document().view()->setTracksPaintInvalidations(true);
314 selection().setSelection( 316 selection().setSelection(
315 SelectionInDOMTree::Builder().collapse(Position(text, 5)).build()); 317 SelectionInDOMTree::Builder().collapse(Position(text, 5)).build());
316 // Simulate that the cursor blinking is restarted. 318 // Simulate that the cursor blinking is restarted.
317 selection().setCaretVisible(true); 319 selection().setCaretVisible(true);
318 updateAllLifecyclePhases(); 320 updateAllLifecyclePhases();
319 321
320 LayoutRect newCaretVisualRect = caretDisplayItemClient().visualRect(); 322 LayoutRect newCaretVisualRect = getCaretDisplayItemClient().visualRect();
321 EXPECT_EQ(caretVisualRect.size(), newCaretVisualRect.size()); 323 EXPECT_EQ(caretVisualRect.size(), newCaretVisualRect.size());
322 EXPECT_EQ(caretVisualRect.y(), newCaretVisualRect.y()); 324 EXPECT_EQ(caretVisualRect.y(), newCaretVisualRect.y());
323 EXPECT_LT(caretVisualRect.x(), newCaretVisualRect.x()); 325 EXPECT_LT(caretVisualRect.x(), newCaretVisualRect.x());
324 326
325 const auto& rasterInvalidations = 327 const auto& rasterInvalidations =
326 getRasterInvalidationTracking()->trackedRasterInvalidations; 328 getRasterInvalidationTracking()->trackedRasterInvalidations;
327 ASSERT_EQ(2u, rasterInvalidations.size()); 329 ASSERT_EQ(2u, rasterInvalidations.size());
328 EXPECT_EQ(enclosingIntRect(caretVisualRect), rasterInvalidations[0].rect); 330 EXPECT_EQ(enclosingIntRect(caretVisualRect), rasterInvalidations[0].rect);
329 EXPECT_EQ(block, rasterInvalidations[0].client); 331 EXPECT_EQ(block, rasterInvalidations[0].client);
330 EXPECT_EQ(PaintInvalidationCaret, rasterInvalidations[0].reason); 332 EXPECT_EQ(PaintInvalidationCaret, rasterInvalidations[0].reason);
(...skipping 25 matching lines...) Expand all
356 document().page()->focusController().setFocused(true); 358 document().page()->focusController().setFocused(true);
357 auto* container = document().getElementById("container"); 359 auto* container = document().getElementById("container");
358 auto* editor = document().getElementById("editor"); 360 auto* editor = document().getElementById("editor");
359 auto* editorBlock = toLayoutBlock(editor->layoutObject()); 361 auto* editorBlock = toLayoutBlock(editor->layoutObject());
360 selection().setSelection( 362 selection().setSelection(
361 SelectionInDOMTree::Builder().collapse(Position(editor, 0)).build()); 363 SelectionInDOMTree::Builder().collapse(Position(editor, 0)).build());
362 updateAllLifecyclePhases(); 364 updateAllLifecyclePhases();
363 365
364 EXPECT_TRUE(editorBlock->shouldPaintCursorCaret()); 366 EXPECT_TRUE(editorBlock->shouldPaintCursorCaret());
365 EXPECT_EQ(editorBlock, caretLayoutBlock()); 367 EXPECT_EQ(editorBlock, caretLayoutBlock());
366 EXPECT_EQ(LayoutRect(116, 105, 1, 1), caretDisplayItemClient().visualRect()); 368 EXPECT_EQ(LayoutRect(116, 105, 1, 1),
369 getCaretDisplayItemClient().visualRect());
367 370
368 // Composite container. 371 // Composite container.
369 container->setAttribute(HTMLNames::styleAttr, "will-change: transform"); 372 container->setAttribute(HTMLNames::styleAttr, "will-change: transform");
370 updateAllLifecyclePhases(); 373 updateAllLifecyclePhases();
371 EXPECT_EQ(LayoutRect(50, 50, 1, 1), caretDisplayItemClient().visualRect()); 374 EXPECT_EQ(LayoutRect(50, 50, 1, 1), getCaretDisplayItemClient().visualRect());
372 375
373 // Uncomposite container. 376 // Uncomposite container.
374 container->setAttribute(HTMLNames::styleAttr, ""); 377 container->setAttribute(HTMLNames::styleAttr, "");
375 updateAllLifecyclePhases(); 378 updateAllLifecyclePhases();
376 EXPECT_EQ(LayoutRect(116, 105, 1, 1), caretDisplayItemClient().visualRect()); 379 EXPECT_EQ(LayoutRect(116, 105, 1, 1),
380 getCaretDisplayItemClient().visualRect());
377 } 381 }
378 382
379 } // namespace blink 383 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698