| 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/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 | 26 |
| 26 namespace blink { | 27 namespace blink { |
| 27 | 28 |
| 28 static inline bool textShouldBePainted(const LayoutSVGInlineText& textLayoutObje
ct) | 29 static inline bool textShouldBePainted(const LayoutSVGInlineText& textLayoutObje
ct) |
| 29 { | 30 { |
| 30 // Font::pixelSize(), returns FontDescription::computedPixelSize(), which re
turns "int(x + 0.5)". | 31 // Font::pixelSize(), returns FontDescription::computedPixelSize(), which re
turns "int(x + 0.5)". |
| 31 // If the absolute font size on screen is below x=0.5, don't render anything
. | 32 // If the absolute font size on screen is below x=0.5, don't render anything
. |
| 32 return textLayoutObject.scaledFont().getFontDescription().computedPixelSize(
); | 33 return textLayoutObject.scaledFont().getFontDescription().computedPixelSize(
); |
| 33 } | 34 } |
| 34 | 35 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // Adjust the paint-server coordinate space. | 307 // Adjust the paint-server coordinate space. |
| 307 paintServerTransform.scale(scalingFactor); | 308 paintServerTransform.scale(scalingFactor); |
| 308 additionalPaintServerTransform = &paintServerTransform; | 309 additionalPaintServerTransform = &paintServerTransform; |
| 309 } | 310 } |
| 310 | 311 |
| 311 if (!SVGPaintContext::paintForLayoutObject(paintInfo, style, *LineLayoutAPIS
him::layoutObjectFrom(m_svgInlineTextBox.parent()->getLineLayoutItem()), resourc
eMode, paint, additionalPaintServerTransform)) | 312 if (!SVGPaintContext::paintForLayoutObject(paintInfo, style, *LineLayoutAPIS
him::layoutObjectFrom(m_svgInlineTextBox.parent()->getLineLayoutItem()), resourc
eMode, paint, additionalPaintServerTransform)) |
| 312 return false; | 313 return false; |
| 313 paint.setAntiAlias(true); | 314 paint.setAntiAlias(true); |
| 314 | 315 |
| 315 if (hasShadow) { | 316 if (hasShadow) { |
| 316 OwnPtr<DrawLooperBuilder> drawLooperBuilder = shadowList->createDrawLoop
er(DrawLooperBuilder::ShadowRespectsAlpha, style.visitedDependentColor(CSSProper
tyColor)); | 317 std::unique_ptr<DrawLooperBuilder> drawLooperBuilder = shadowList->creat
eDrawLooper(DrawLooperBuilder::ShadowRespectsAlpha, style.visitedDependentColor(
CSSPropertyColor)); |
| 317 paint.setLooper(toSkSp(drawLooperBuilder->detachDrawLooper())); | 318 paint.setLooper(toSkSp(drawLooperBuilder->detachDrawLooper())); |
| 318 } | 319 } |
| 319 | 320 |
| 320 if (resourceMode == ApplyToStrokeMode) { | 321 if (resourceMode == ApplyToStrokeMode) { |
| 321 StrokeData strokeData; | 322 StrokeData strokeData; |
| 322 SVGLayoutSupport::applyStrokeStyleToStrokeData(strokeData, style, *LineL
ayoutAPIShim::layoutObjectFrom(m_svgInlineTextBox.parent()->getLineLayoutItem())
, 1); | 323 SVGLayoutSupport::applyStrokeStyleToStrokeData(strokeData, style, *LineL
ayoutAPIShim::layoutObjectFrom(m_svgInlineTextBox.parent()->getLineLayoutItem())
, 1); |
| 323 if (style.svgStyle().vectorEffect() != VE_NON_SCALING_STROKE) | 324 if (style.svgStyle().vectorEffect() != VE_NON_SCALING_STROKE) |
| 324 strokeData.setThickness(strokeData.thickness() * scalingFactor); | 325 strokeData.setThickness(strokeData.thickness() * scalingFactor); |
| 325 strokeData.setupPaint(&paint); | 326 strokeData.setupPaint(&paint); |
| 326 } | 327 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 stateSaver.save(); | 496 stateSaver.save(); |
| 496 paintInfo.context.concatCTM(fragment.buildFragmentTransform()); | 497 paintInfo.context.concatCTM(fragment.buildFragmentTransform()); |
| 497 } | 498 } |
| 498 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment
(fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, style); | 499 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment
(fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, style); |
| 499 paintInfo.context.setFillColor(color); | 500 paintInfo.context.setFillColor(color); |
| 500 paintInfo.context.fillRect(fragmentRect); | 501 paintInfo.context.fillRect(fragmentRect); |
| 501 } | 502 } |
| 502 } | 503 } |
| 503 | 504 |
| 504 } // namespace blink | 505 } // namespace blink |
| OLD | NEW |