OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/SVGInlineTextBoxPainter.h" | 5 #include "core/paint/SVGInlineTextBoxPainter.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/Range.h" | 8 #include "core/dom/Range.h" |
9 #include "core/editing/DOMSelection.h" | 9 #include "core/editing/DOMSelection.h" |
10 #include "core/frame/LocalDOMWindow.h" | 10 #include "core/frame/LocalDOMWindow.h" |
11 #include "core/layout/LayoutTestHelper.h" | 11 #include "core/layout/LayoutTestHelper.h" |
12 #include "core/layout/LayoutView.h" | 12 #include "core/layout/LayoutView.h" |
13 #include "core/layout/line/InlineTextBox.h" | 13 #include "core/layout/line/InlineTextBox.h" |
14 #include "core/layout/svg/LayoutSVGInlineText.h" | 14 #include "core/layout/svg/LayoutSVGInlineText.h" |
15 #include "core/layout/svg/LayoutSVGText.h" | 15 #include "core/layout/svg/LayoutSVGText.h" |
16 #include "core/paint/PaintLayer.h" | 16 #include "core/paint/PaintLayer.h" |
17 #include "platform/geometry/IntRectOutsets.h" | 17 #include "platform/geometry/IntRectOutsets.h" |
18 #include "platform/graphics/GraphicsLayer.h" | 18 #include "platform/graphics/GraphicsLayer.h" |
19 #include "platform/graphics/paint/DisplayItemList.h" | 19 #include "platform/graphics/paint/DisplayItemList.h" |
20 #include "platform/graphics/paint/DrawingDisplayItem.h" | 20 #include "platform/graphics/paint/DrawingDisplayItem.h" |
21 #include "platform/graphics/paint/PaintController.h" | 21 #include "platform/graphics/paint/PaintController.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 | 23 |
24 namespace blink { | 24 namespace blink { |
25 namespace { | 25 namespace { |
26 | 26 |
27 class SVGInlineTextBoxPainterTest : public RenderingTest { | 27 class SVGInlineTextBoxPainterTest : public RenderingTest { |
28 public: | 28 public: |
29 const DrawingDisplayItem* getDrawingForSVGTextById(const char* elementName) { | 29 const DrawingDisplayItem* getDrawingForSVGTextById(const char* elementName) { |
30 // Look up the inline text box that serves as the display item client for th
e painted text. | 30 // Look up the inline text box that serves as the display item client for |
| 31 // the painted text. |
31 LayoutSVGText* targetSVGText = toLayoutSVGText( | 32 LayoutSVGText* targetSVGText = toLayoutSVGText( |
32 document().getElementById(AtomicString(elementName))->layoutObject()); | 33 document().getElementById(AtomicString(elementName))->layoutObject()); |
33 LayoutSVGInlineText* targetInlineText = | 34 LayoutSVGInlineText* targetInlineText = |
34 targetSVGText->descendantTextNodes()[0]; | 35 targetSVGText->descendantTextNodes()[0]; |
35 const DisplayItemClient* targetClient = | 36 const DisplayItemClient* targetClient = |
36 static_cast<const DisplayItemClient*>(targetInlineText->firstTextBox()); | 37 static_cast<const DisplayItemClient*>(targetInlineText->firstTextBox()); |
37 | 38 |
38 // Find the appropriate drawing in the display item list. | 39 // Find the appropriate drawing in the display item list. |
39 const DisplayItemList& displayItemList = | 40 const DisplayItemList& displayItemList = |
40 rootPaintController().getDisplayItemList(); | 41 rootPaintController().getDisplayItemList(); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 165 |
165 const DrawingDisplayItem* drawingDisplayItem = | 166 const DrawingDisplayItem* drawingDisplayItem = |
166 getDrawingForSVGTextById("target"); | 167 getDrawingForSVGTextById("target"); |
167 assertTextDrawingEquals(drawingDisplayItem, "x"); | 168 assertTextDrawingEquals(drawingDisplayItem, "x"); |
168 EXPECT_RECT_EQ(IntRect(50, 3, 220, 238), | 169 EXPECT_RECT_EQ(IntRect(50, 3, 220, 238), |
169 cullRectFromDrawing(*drawingDisplayItem)); | 170 cullRectFromDrawing(*drawingDisplayItem)); |
170 } | 171 } |
171 | 172 |
172 } // namespace | 173 } // namespace |
173 } // namespace blink | 174 } // namespace blink |
OLD | NEW |