| 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/paint/PaintControllerPaintTest.h" | 5 #include "core/paint/PaintControllerPaintTest.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutText.h" | 7 #include "core/layout/LayoutText.h" |
| 8 #include "core/layout/line/InlineTextBox.h" | 8 #include "core/layout/line/InlineTextBox.h" |
| 9 #include "core/page/FocusController.h" | 9 #include "core/page/FocusController.h" |
| 10 #include "core/paint/LayoutObjectDrawingRecorder.h" | 10 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 11 #include "core/paint/PaintLayerPainter.h" | 11 #include "core/paint/PaintLayerPainter.h" |
| 12 #include "platform/graphics/GraphicsContext.h" | 12 #include "platform/graphics/GraphicsContext.h" |
| 13 #include "platform/graphics/paint/DrawingDisplayItem.h" | 13 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 INSTANTIATE_TEST_CASE_P(All, PaintControllerPaintTestForSlimmingPaintV1AndV2, ::
testing::Bool()); | 17 INSTANTIATE_TEST_CASE_P(All, PaintControllerPaintTestForSlimmingPaintV1AndV2, ::
testing::Bool()); |
| 18 | 18 |
| 19 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, FullDocumentPaintingWith
Caret) | 19 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, FullDocumentPaintingWith
Caret) |
| 20 { | 20 { |
| 21 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); | 21 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); |
| 22 document().page()->focusController().setActive(true); | 22 document().page()->focusController().setActive(true); |
| 23 document().page()->focusController().setFocused(true); | 23 document().page()->focusController().setFocused(true); |
| 24 Element& div = *toElement(document().body()->firstChild()); | 24 Element& div = *toElement(document().body()->firstChild()); |
| 25 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); | 25 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); |
| 26 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); | 26 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); |
| 27 | 27 |
| 28 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2, | 28 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, |
| 29 TestDisplayItem(layoutView(), documentBackgroundType), | 29 TestDisplayItem(layoutView(), documentBackgroundType), |
| 30 TestDisplayItem(textInlineBox, foregroundType)); | 30 TestDisplayItem(textInlineBox, foregroundType)); |
| 31 | 31 |
| 32 div.focus(); | 32 div.focus(); |
| 33 document().view()->updateAllLifecyclePhases(); | 33 document().view()->updateAllLifecyclePhases(); |
| 34 | 34 |
| 35 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 3, | 35 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3, |
| 36 TestDisplayItem(layoutView(), documentBackgroundType), | 36 TestDisplayItem(layoutView(), documentBackgroundType), |
| 37 TestDisplayItem(textInlineBox, foregroundType), | 37 TestDisplayItem(textInlineBox, foregroundType), |
| 38 TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New! | 38 TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New! |
| 39 } | 39 } |
| 40 | 40 |
| 41 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, InlineRelayout) | 41 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, InlineRelayout) |
| 42 { | 42 { |
| 43 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); | 43 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); |
| 44 Element& div = *toElement(document().body()->firstChild()); | 44 Element& div = *toElement(document().body()->firstChild()); |
| 45 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); | 45 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); |
| 46 LayoutText& text = *toLayoutText(divBlock.firstChild()); | 46 LayoutText& text = *toLayoutText(divBlock.firstChild()); |
| 47 InlineTextBox& firstTextBox = *text.firstTextBox(); | 47 InlineTextBox& firstTextBox = *text.firstTextBox(); |
| 48 | 48 |
| 49 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2, | 49 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, |
| 50 TestDisplayItem(layoutView(), documentBackgroundType), | 50 TestDisplayItem(layoutView(), documentBackgroundType), |
| 51 TestDisplayItem(firstTextBox, foregroundType)); | 51 TestDisplayItem(firstTextBox, foregroundType)); |
| 52 | 52 |
| 53 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); | 53 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); |
| 54 document().view()->updateAllLifecyclePhases(); | 54 document().view()->updateAllLifecyclePhases(); |
| 55 | 55 |
| 56 LayoutText& newText = *toLayoutText(divBlock.firstChild()); | 56 LayoutText& newText = *toLayoutText(divBlock.firstChild()); |
| 57 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); | 57 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); |
| 58 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); | 58 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); |
| 59 | 59 |
| 60 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 3, | 60 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3, |
| 61 TestDisplayItem(layoutView(), documentBackgroundType), | 61 TestDisplayItem(layoutView(), documentBackgroundType), |
| 62 TestDisplayItem(newFirstTextBox, foregroundType), | 62 TestDisplayItem(newFirstTextBox, foregroundType), |
| 63 TestDisplayItem(secondTextBox, foregroundType)); | 63 TestDisplayItem(secondTextBox, foregroundType)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace blink | 66 } // namespace blink |
| OLD | NEW |