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

Side by Side Diff: third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp

Issue 2144523002: Remove obsolete SVG small font rejection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/LayoutTests/svg/text/minimum-text-size-expected.html ('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 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/SVGInlineTextBoxPainter.h" 5 #include "core/paint/SVGInlineTextBoxPainter.h"
6 6
7 #include "core/editing/Editor.h" 7 #include "core/editing/Editor.h"
8 #include "core/editing/markers/DocumentMarkerController.h" 8 #include "core/editing/markers/DocumentMarkerController.h"
9 #include "core/editing/markers/RenderedDocumentMarker.h" 9 #include "core/editing/markers/RenderedDocumentMarker.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
11 #include "core/layout/LayoutTheme.h" 11 #include "core/layout/LayoutTheme.h"
12 #include "core/layout/api/LineLayoutAPIShim.h" 12 #include "core/layout/api/LineLayoutAPIShim.h"
13 #include "core/layout/api/SelectionState.h" 13 #include "core/layout/api/SelectionState.h"
14 #include "core/layout/line/InlineFlowBox.h" 14 #include "core/layout/line/InlineFlowBox.h"
15 #include "core/layout/svg/LayoutSVGInlineText.h" 15 #include "core/layout/svg/LayoutSVGInlineText.h"
16 #include "core/layout/svg/SVGLayoutSupport.h" 16 #include "core/layout/svg/SVGLayoutSupport.h"
17 #include "core/layout/svg/SVGResourcesCache.h" 17 #include "core/layout/svg/SVGResourcesCache.h"
18 #include "core/layout/svg/line/SVGInlineTextBox.h" 18 #include "core/layout/svg/line/SVGInlineTextBox.h"
19 #include "core/paint/InlineTextBoxPainter.h" 19 #include "core/paint/InlineTextBoxPainter.h"
20 #include "core/paint/LayoutObjectDrawingRecorder.h" 20 #include "core/paint/LayoutObjectDrawingRecorder.h"
21 #include "core/paint/PaintInfo.h" 21 #include "core/paint/PaintInfo.h"
22 #include "core/paint/SVGPaintContext.h" 22 #include "core/paint/SVGPaintContext.h"
23 #include "core/style/ShadowList.h" 23 #include "core/style/ShadowList.h"
24 #include "platform/graphics/GraphicsContextStateSaver.h" 24 #include "platform/graphics/GraphicsContextStateSaver.h"
25 #include <memory> 25 #include <memory>
26 26
27 namespace blink { 27 namespace blink {
28 28
29 static inline bool textShouldBePainted(const LayoutSVGInlineText& textLayoutObje ct)
30 {
31 // Font::pixelSize(), returns FontDescription::computedPixelSize(), which re turns "int(x + 0.5)".
32 // If the absolute font size on screen is below x=0.5, don't render anything .
33 return textLayoutObject.scaledFont().getFontDescription().computedPixelSize( );
34 }
35
36 bool SVGInlineTextBoxPainter::shouldPaintSelection(const PaintInfo& paintInfo) c onst 29 bool SVGInlineTextBoxPainter::shouldPaintSelection(const PaintInfo& paintInfo) c onst
37 { 30 {
38 return !paintInfo.isPrinting() && m_svgInlineTextBox.getSelectionState() != SelectionNone; 31 return !paintInfo.isPrinting() && m_svgInlineTextBox.getSelectionState() != SelectionNone;
39 } 32 }
40 33
41 FloatRect SVGInlineTextBoxPainter::boundsForDrawingRecorder( 34 FloatRect SVGInlineTextBoxPainter::boundsForDrawingRecorder(
42 const LayoutPoint& paintOffset, bool includeSelectionRect) const 35 const LayoutPoint& paintOffset, bool includeSelectionRect) const
43 { 36 {
44 // We compute the paint rect with what looks like the logical values, to mat ch the 37 // We compute the paint rect with what looks like the logical values, to mat ch the
45 // computation in SVGInlineTextBox::calculateBoundaries, and the fact that v ertical (etc) 38 // computation in SVGInlineTextBox::calculateBoundaries, and the fact that v ertical (etc)
(...skipping 17 matching lines...) Expand all
63 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != VISIBLE) 56 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != VISIBLE)
64 return; 57 return;
65 58
66 // We're explicitly not supporting composition & custom underlines and custo m highlighters -- unlike InlineTextBox. 59 // We're explicitly not supporting composition & custom underlines and custo m highlighters -- unlike InlineTextBox.
67 // If we ever need that for SVG, it's very easy to refactor and reuse the co de. 60 // If we ever need that for SVG, it's very easy to refactor and reuse the co de.
68 61
69 bool haveSelection = shouldPaintSelection(paintInfo); 62 bool haveSelection = shouldPaintSelection(paintInfo);
70 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) 63 if (!haveSelection && paintInfo.phase == PaintPhaseSelection)
71 return; 64 return;
72 65
73 LayoutSVGInlineText& textLayoutObject = toLayoutSVGInlineText(*LineLayoutAPI Shim::layoutObjectFrom(m_svgInlineTextBox.getLineLayoutItem()));
74 if (!textShouldBePainted(textLayoutObject))
75 return;
76
77 DisplayItem::Type displayItemType = DisplayItem::paintPhaseToDrawingType(pai ntInfo.phase); 66 DisplayItem::Type displayItemType = DisplayItem::paintPhaseToDrawingType(pai ntInfo.phase);
78 if (!DrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_svgInl ineTextBox, displayItemType)) { 67 if (!DrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_svgInl ineTextBox, displayItemType)) {
68 LayoutSVGInlineText& textLayoutObject = toLayoutSVGInlineText(*LineLayou tAPIShim::layoutObjectFrom(m_svgInlineTextBox.getLineLayoutItem()));
79 LayoutObject& parentLayoutObject = *LineLayoutAPIShim::layoutObjectFrom( m_svgInlineTextBox.parent()->getLineLayoutItem()); 69 LayoutObject& parentLayoutObject = *LineLayoutAPIShim::layoutObjectFrom( m_svgInlineTextBox.parent()->getLineLayoutItem());
80 const ComputedStyle& style = parentLayoutObject.styleRef(); 70 const ComputedStyle& style = parentLayoutObject.styleRef();
81 71
82 bool includeSelectionRect = paintInfo.phase != PaintPhaseSelection 72 bool includeSelectionRect = paintInfo.phase != PaintPhaseSelection
83 && (haveSelection || InlineTextBoxPainter::paintsMarkerHighlights(te xtLayoutObject)); 73 && (haveSelection || InlineTextBoxPainter::paintsMarkerHighlights(te xtLayoutObject));
84 DrawingRecorder recorder(paintInfo.context, m_svgInlineTextBox, displayI temType, 74 DrawingRecorder recorder(paintInfo.context, m_svgInlineTextBox, displayI temType,
85 boundsForDrawingRecorder(paintOffset, includeSelectionRect)); 75 boundsForDrawingRecorder(paintOffset, includeSelectionRect));
86 InlineTextBoxPainter(m_svgInlineTextBox).paintDocumentMarkers( 76 InlineTextBoxPainter(m_svgInlineTextBox).paintDocumentMarkers(
87 paintInfo, paintOffset, style, 77 paintInfo, paintOffset, style,
88 textLayoutObject.scaledFont(), DocumentMarkerPaintPhase::Background) ; 78 textLayoutObject.scaledFont(), DocumentMarkerPaintPhase::Background) ;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 164
175 ASSERT(!paintInfo.isPrinting()); 165 ASSERT(!paintInfo.isPrinting());
176 166
177 if (paintInfo.phase == PaintPhaseSelection || !shouldPaintSelection(paintInf o)) 167 if (paintInfo.phase == PaintPhaseSelection || !shouldPaintSelection(paintInf o))
178 return; 168 return;
179 169
180 Color backgroundColor = m_svgInlineTextBox.getLineLayoutItem().selectionBack groundColor(); 170 Color backgroundColor = m_svgInlineTextBox.getLineLayoutItem().selectionBack groundColor();
181 if (!backgroundColor.alpha()) 171 if (!backgroundColor.alpha())
182 return; 172 return;
183 173
184 LayoutSVGInlineText& textLayoutObject = toLayoutSVGInlineText(*LineLayoutAPI Shim::layoutObjectFrom(m_svgInlineTextBox.getLineLayoutItem()));
185 if (!textShouldBePainted(textLayoutObject))
186 return;
187
188 const ComputedStyle& style = m_svgInlineTextBox.parent()->getLineLayoutItem( ).styleRef(); 174 const ComputedStyle& style = m_svgInlineTextBox.parent()->getLineLayoutItem( ).styleRef();
189 175
190 int startPosition, endPosition; 176 int startPosition, endPosition;
191 m_svgInlineTextBox.selectionStartEnd(startPosition, endPosition); 177 m_svgInlineTextBox.selectionStartEnd(startPosition, endPosition);
192 178
193 const Vector<SVGTextFragmentWithRange> fragmentInfoList = collectFragmentsIn Range(startPosition, endPosition); 179 const Vector<SVGTextFragmentWithRange> fragmentInfoList = collectFragmentsIn Range(startPosition, endPosition);
194 for (const SVGTextFragmentWithRange& fragmentWithRange : fragmentInfoList) { 180 for (const SVGTextFragmentWithRange& fragmentWithRange : fragmentInfoList) {
195 const SVGTextFragment& fragment = fragmentWithRange.fragment; 181 const SVGTextFragment& fragment = fragmentWithRange.fragment;
196 GraphicsContextStateSaver stateSaver(paintInfo.context); 182 GraphicsContextStateSaver stateSaver(paintInfo.context);
197 if (fragment.isTransformed()) 183 if (fragment.isTransformed())
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 stateSaver.save(); 502 stateSaver.save();
517 paintInfo.context.concatCTM(fragment.buildFragmentTransform()); 503 paintInfo.context.concatCTM(fragment.buildFragmentTransform());
518 } 504 }
519 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment (fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, style); 505 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment (fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, style);
520 paintInfo.context.setFillColor(color); 506 paintInfo.context.setFillColor(color);
521 paintInfo.context.fillRect(fragmentRect); 507 paintInfo.context.fillRect(fragmentRect);
522 } 508 }
523 } 509 }
524 510
525 } // namespace blink 511 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/text/minimum-text-size-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698