| 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" |
| 11 #include "core/editing/EditingTestBase.h" | 11 #include "core/editing/EditingTestBase.h" |
| 12 #include "core/frame/FrameView.h" | 12 #include "core/frame/FrameView.h" |
| 13 #include "core/html/HTMLBodyElement.h" | 13 #include "core/html/HTMLBodyElement.h" |
| 14 #include "core/html/HTMLDocument.h" | 14 #include "core/html/HTMLDocument.h" |
| 15 #include "core/layout/LayoutView.h" | 15 #include "core/layout/LayoutView.h" |
| 16 #include "core/paint/PaintInfo.h" | 16 #include "core/paint/PaintInfo.h" |
| 17 #include "core/paint/PaintLayer.h" | 17 #include "core/paint/PaintLayer.h" |
| 18 #include "core/testing/DummyPageHolder.h" | 18 #include "core/testing/DummyPageHolder.h" |
| 19 #include "platform/graphics/paint/DrawingRecorder.h" | |
| 20 #include "platform/graphics/paint/PaintController.h" | 19 #include "platform/graphics/paint/PaintController.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "wtf/PassRefPtr.h" | 21 #include "wtf/PassRefPtr.h" |
| 23 #include "wtf/RefPtr.h" | 22 #include "wtf/RefPtr.h" |
| 24 #include "wtf/StdLibExtras.h" | 23 #include "wtf/StdLibExtras.h" |
| 25 #include <memory> | 24 #include <memory> |
| 26 | 25 |
| 27 namespace blink { | 26 namespace blink { |
| 28 | 27 |
| 29 class FrameSelectionTest : public EditingTestBase { | 28 class FrameSelectionTest : public EditingTestBase { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // To force layout in next updateLayout calling, widen view. | 108 // To force layout in next updateLayout calling, widen view. |
| 110 FrameView& frameView = dummyPageHolder().frameView(); | 109 FrameView& frameView = dummyPageHolder().frameView(); |
| 111 IntRect frameRect = frameView.frameRect(); | 110 IntRect frameRect = frameView.frameRect(); |
| 112 frameRect.setWidth(frameRect.width() + 1); | 111 frameRect.setWidth(frameRect.width() + 1); |
| 113 frameRect.setHeight(frameRect.height() + 1); | 112 frameRect.setHeight(frameRect.height() + 1); |
| 114 dummyPageHolder().frameView().setFrameRect(frameRect); | 113 dummyPageHolder().frameView().setFrameRect(frameRect); |
| 115 } | 114 } |
| 116 std::unique_ptr<PaintController> paintController = PaintController::create()
; | 115 std::unique_ptr<PaintController> paintController = PaintController::create()
; |
| 117 { | 116 { |
| 118 GraphicsContext context(*paintController); | 117 GraphicsContext context(*paintController); |
| 119 DrawingRecorder drawingRecorder(context, *dummyPageHolder().frameView().
layoutView(), DisplayItem::Caret, LayoutRect::infiniteIntRect()); | |
| 120 selection().paintCaret(context, LayoutPoint()); | 118 selection().paintCaret(context, LayoutPoint()); |
| 121 } | 119 } |
| 122 paintController->commitNewDisplayItems(); | 120 paintController->commitNewDisplayItems(); |
| 123 EXPECT_EQ(startCount, layoutCount()); | 121 EXPECT_EQ(startCount, layoutCount()); |
| 124 } | 122 } |
| 125 | 123 |
| 126 TEST_F(FrameSelectionTest, InvalidatePreviousCaretAfterRemovingLastCharacter) | 124 TEST_F(FrameSelectionTest, InvalidatePreviousCaretAfterRemovingLastCharacter) |
| 127 { | 125 { |
| 128 Text* text = appendTextNode("Hello, World!"); | 126 Text* text = appendTextNode("Hello, World!"); |
| 129 document().view()->updateAllLifecyclePhases(); | 127 document().view()->updateAllLifecyclePhases(); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 265 |
| 268 TEST_F(FrameSelectionTest, SelectAllWithUnselectableRoot) | 266 TEST_F(FrameSelectionTest, SelectAllWithUnselectableRoot) |
| 269 { | 267 { |
| 270 Element* select = document().createElement("select", ASSERT_NO_EXCEPTION); | 268 Element* select = document().createElement("select", ASSERT_NO_EXCEPTION); |
| 271 document().replaceChild(select, document().documentElement()); | 269 document().replaceChild(select, document().documentElement()); |
| 272 selection().selectAll(); | 270 selection().selectAll(); |
| 273 EXPECT_TRUE(selection().isNone()) << "Nothing should be selected if the cont
ent of the documentElement is not selctable."; | 271 EXPECT_TRUE(selection().isNone()) << "Nothing should be selected if the cont
ent of the documentElement is not selctable."; |
| 274 } | 272 } |
| 275 | 273 |
| 276 } // namespace blink | 274 } // namespace blink |
| OLD | NEW |