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

Side by Side Diff: third_party/WebKit/Source/platform/exported/WebFont.cpp

Issue 1774943003: blink: Rename platform/ methods to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-platform: rebase-yayyyyyyyy Created 4 years, 9 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
OLDNEW
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 15 matching lines...) Expand all
26 } 26 }
27 27
28 class WebFont::Impl final : public DisplayItemClient { 28 class WebFont::Impl final : public DisplayItemClient {
29 public: 29 public:
30 explicit Impl(const WebFontDescription& description) 30 explicit Impl(const WebFontDescription& description)
31 : m_font(description) 31 : m_font(description)
32 { 32 {
33 m_font.update(nullptr); 33 m_font.update(nullptr);
34 } 34 }
35 35
36 const Font& font() const { return m_font; } 36 const Font& getFont() const { return m_font; }
37 String debugName() const final { return "WebFont::Impl"; } 37 String debugName() const final { return "WebFont::Impl"; }
38 LayoutRect visualRect() const final 38 LayoutRect visualRect() const final
39 { 39 {
40 // TODO(chrishtr): fix this. 40 // TODO(chrishtr): fix this.
41 return LayoutRect(); 41 return LayoutRect();
42 } 42 }
43 43
44 private: 44 private:
45 Font m_font; 45 Font m_font;
46 }; 46 };
47 47
48 WebFont::WebFont(const WebFontDescription& description) 48 WebFont::WebFont(const WebFontDescription& description)
49 : m_private(new Impl(description)) 49 : m_private(new Impl(description))
50 { 50 {
51 } 51 }
52 52
53 WebFont::~WebFont() 53 WebFont::~WebFont()
54 { 54 {
55 m_private.reset(0); 55 m_private.reset(0);
56 } 56 }
57 57
58 WebFontDescription WebFont::fontDescription() const 58 WebFontDescription WebFont::getFontDescription() const
59 { 59 {
60 return WebFontDescription(m_private->font().fontDescription()); 60 return WebFontDescription(m_private->getFont().getFontDescription());
61 } 61 }
62 62
63 int WebFont::ascent() const 63 int WebFont::ascent() const
64 { 64 {
65 return m_private->font().fontMetrics().ascent(); 65 return m_private->getFont().getFontMetrics().ascent();
66 } 66 }
67 67
68 int WebFont::descent() const 68 int WebFont::descent() const
69 { 69 {
70 return m_private->font().fontMetrics().descent(); 70 return m_private->getFont().getFontMetrics().descent();
71 } 71 }
72 72
73 int WebFont::height() const 73 int WebFont::height() const
74 { 74 {
75 return m_private->font().fontMetrics().height(); 75 return m_private->getFont().getFontMetrics().height();
76 } 76 }
77 77
78 int WebFont::lineSpacing() const 78 int WebFont::lineSpacing() const
79 { 79 {
80 return m_private->font().fontMetrics().lineSpacing(); 80 return m_private->getFont().getFontMetrics().lineSpacing();
81 } 81 }
82 82
83 float WebFont::xHeight() const 83 float WebFont::xHeight() const
84 { 84 {
85 return m_private->font().fontMetrics().xHeight(); 85 return m_private->getFont().getFontMetrics().xHeight();
86 } 86 }
87 87
88 void WebFont::drawText(WebCanvas* canvas, const WebTextRun& run, 88 void WebFont::drawText(WebCanvas* canvas, const WebTextRun& run,
89 const WebFloatPoint& leftBaseline, WebColor color, const WebRect& clip) cons t 89 const WebFloatPoint& leftBaseline, WebColor color, const WebRect& clip) cons t
90 { 90 {
91 FontCachePurgePreventer fontCachePurgePreventer; 91 FontCachePurgePreventer fontCachePurgePreventer;
92 FloatRect textClipRect(clip); 92 FloatRect textClipRect(clip);
93 TextRun textRun(run); 93 TextRun textRun(run);
94 TextRunPaintInfo runInfo(textRun); 94 TextRunPaintInfo runInfo(textRun);
95 runInfo.bounds = textClipRect; 95 runInfo.bounds = textClipRect;
96 96
97 IntRect intRect(clip); 97 IntRect intRect(clip);
98 SkPictureBuilder pictureBuilder(intRect); 98 SkPictureBuilder pictureBuilder(intRect);
99 GraphicsContext& context = pictureBuilder.context(); 99 GraphicsContext& context = pictureBuilder.context();
100 100
101 ASSERT(!DrawingRecorder::useCachedDrawingIfPossible(context, *m_private, Dis playItem::WebFont)); 101 ASSERT(!DrawingRecorder::useCachedDrawingIfPossible(context, *m_private, Dis playItem::WebFont));
102 { 102 {
103 DrawingRecorder drawingRecorder(context, *m_private, DisplayItem::WebFon t, intRect); 103 DrawingRecorder drawingRecorder(context, *m_private, DisplayItem::WebFon t, intRect);
104 context.save(); 104 context.save();
105 context.setFillColor(color); 105 context.setFillColor(color);
106 context.clip(textClipRect); 106 context.clip(textClipRect);
107 context.drawText(m_private->font(), runInfo, leftBaseline); 107 context.drawText(m_private->getFont(), runInfo, leftBaseline);
108 context.restore(); 108 context.restore();
109 } 109 }
110 110
111 pictureBuilder.endRecording()->playback(canvas); 111 pictureBuilder.endRecording()->playback(canvas);
112 } 112 }
113 113
114 int WebFont::calculateWidth(const WebTextRun& run) const 114 int WebFont::calculateWidth(const WebTextRun& run) const
115 { 115 {
116 return m_private->font().width(run, 0); 116 return m_private->getFont().width(run, 0);
117 } 117 }
118 118
119 int WebFont::offsetForPosition(const WebTextRun& run, float position) const 119 int WebFont::offsetForPosition(const WebTextRun& run, float position) const
120 { 120 {
121 return m_private->font().offsetForPosition(run, position, true); 121 return m_private->getFont().offsetForPosition(run, position, true);
122 } 122 }
123 123
124 WebFloatRect WebFont::selectionRectForText(const WebTextRun& run, const WebFloat Point& leftBaseline, int height, int from, int to) const 124 WebFloatRect WebFont::selectionRectForText(const WebTextRun& run, const WebFloat Point& leftBaseline, int height, int from, int to) const
125 { 125 {
126 return m_private->font().selectionRectForText(run, leftBaseline, height, fro m, to); 126 return m_private->getFont().selectionRectForText(run, leftBaseline, height, from, to);
127 } 127 }
128 128
129 } // namespace blink 129 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698