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

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

Issue 2777183003: Fix caret visual rect on compositing change (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 | « third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp ('k') | 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 334
335 auto objectInvalidations = 335 auto objectInvalidations =
336 document().view()->trackedObjectPaintInvalidationsAsJSON(); 336 document().view()->trackedObjectPaintInvalidationsAsJSON();
337 ASSERT_EQ(1u, objectInvalidations->size()); 337 ASSERT_EQ(1u, objectInvalidations->size());
338 String s; 338 String s;
339 JSONObject::cast(objectInvalidations->at(0))->get("object")->asString(&s); 339 JSONObject::cast(objectInvalidations->at(0))->get("object")->asString(&s);
340 EXPECT_EQ("Caret", s); 340 EXPECT_EQ("Caret", s);
341 document().view()->setTracksPaintInvalidations(false); 341 document().view()->setTracksPaintInvalidations(false);
342 } 342 }
343 343
344 TEST_F(CaretDisplayItemClientTest, CompositingChange) {
345 enableCompositing();
346 setBodyInnerHTML(
347 "<style>"
348 " body { margin: 0 }"
349 " #container { position: absolute; top: 55px; left: 66px; }"
350 "</style>"
351 "<div id='container'>"
352 " <div id='editor' contenteditable style='padding: 50px'>ABCDE</div>"
353 "</div>");
354
355 document().page()->focusController().setActive(true);
356 document().page()->focusController().setFocused(true);
357 auto* container = document().getElementById("container");
358 auto* editor = document().getElementById("editor");
359 auto* editorBlock = toLayoutBlock(editor->layoutObject());
360 selection().setSelection(
361 SelectionInDOMTree::Builder().collapse(Position(editor, 0)).build());
362 updateAllLifecyclePhases();
363
364 EXPECT_TRUE(editorBlock->shouldPaintCursorCaret());
365 EXPECT_EQ(editorBlock, caretLayoutBlock());
366 EXPECT_EQ(LayoutRect(116, 105, 1, 1), caretDisplayItemClient().visualRect());
367
368 // Composite container.
369 container->setAttribute(HTMLNames::styleAttr, "will-change: transform");
370 updateAllLifecyclePhases();
371 EXPECT_EQ(LayoutRect(50, 50, 1, 1), caretDisplayItemClient().visualRect());
372
373 // Uncomposite container.
374 container->setAttribute(HTMLNames::styleAttr, "");
375 updateAllLifecyclePhases();
376 EXPECT_EQ(LayoutRect(116, 105, 1, 1), caretDisplayItemClient().visualRect());
377 }
378
344 } // namespace blink 379 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698