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