| 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 "public/platform/WebFont.h" | 5 #include "public/platform/WebFont.h" |
| 6 | 6 |
| 7 #include "platform/fonts/Font.h" | 7 #include "platform/fonts/Font.h" |
| 8 #include "platform/fonts/FontCache.h" | 8 #include "platform/fonts/FontCache.h" |
| 9 #include "platform/fonts/FontDescription.h" | 9 #include "platform/fonts/FontDescription.h" |
| 10 #include "platform/graphics/GraphicsContext.h" | 10 #include "platform/graphics/GraphicsContext.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 FloatRect textClipRect(clip); | 84 FloatRect textClipRect(clip); |
| 85 TextRun textRun(run); | 85 TextRun textRun(run); |
| 86 TextRunPaintInfo runInfo(textRun); | 86 TextRunPaintInfo runInfo(textRun); |
| 87 runInfo.bounds = textClipRect; | 87 runInfo.bounds = textClipRect; |
| 88 | 88 |
| 89 IntRect intRect(clip); | 89 IntRect intRect(clip); |
| 90 SkPictureBuilder pictureBuilder(intRect); | 90 SkPictureBuilder pictureBuilder(intRect); |
| 91 GraphicsContext& context = pictureBuilder.context(); | 91 GraphicsContext& context = pictureBuilder.context(); |
| 92 | 92 |
| 93 { | 93 { |
| 94 DrawingRecorder drawingRecorder(context, pictureBuilder, DisplayItem::We
bFont, intRect); | 94 DrawingRecorder drawingRecorder(context, pictureBuilder, DisplayItem::kW
ebFont, intRect); |
| 95 context.save(); | 95 context.save(); |
| 96 context.setFillColor(color); | 96 context.setFillColor(color); |
| 97 context.clip(textClipRect); | 97 context.clip(textClipRect); |
| 98 context.drawText(m_private->getFont(), runInfo, leftBaseline); | 98 context.drawText(m_private->getFont(), runInfo, leftBaseline); |
| 99 context.restore(); | 99 context.restore(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 pictureBuilder.endRecording()->playback(canvas); | 102 pictureBuilder.endRecording()->playback(canvas); |
| 103 } | 103 } |
| 104 | 104 |
| 105 int WebFont::calculateWidth(const WebTextRun& run) const | 105 int WebFont::calculateWidth(const WebTextRun& run) const |
| 106 { | 106 { |
| 107 return m_private->getFont().width(run, 0); | 107 return m_private->getFont().width(run, 0); |
| 108 } | 108 } |
| 109 | 109 |
| 110 int WebFont::offsetForPosition(const WebTextRun& run, float position) const | 110 int WebFont::offsetForPosition(const WebTextRun& run, float position) const |
| 111 { | 111 { |
| 112 return m_private->getFont().offsetForPosition(run, position, true); | 112 return m_private->getFont().offsetForPosition(run, position, true); |
| 113 } | 113 } |
| 114 | 114 |
| 115 WebFloatRect WebFont::selectionRectForText(const WebTextRun& run, const WebFloat
Point& leftBaseline, int height, int from, int to) const | 115 WebFloatRect WebFont::selectionRectForText(const WebTextRun& run, const WebFloat
Point& leftBaseline, int height, int from, int to) const |
| 116 { | 116 { |
| 117 return m_private->getFont().selectionRectForText(run, leftBaseline, height,
from, to); | 117 return m_private->getFont().selectionRectForText(run, leftBaseline, height,
from, to); |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace blink | 120 } // namespace blink |
| OLD | NEW |