OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "platform/fonts/FontDescription.h" | 35 #include "platform/fonts/FontDescription.h" |
36 #include "platform/graphics/GraphicsContext.h" | 36 #include "platform/graphics/GraphicsContext.h" |
37 #include "platform/text/TextRun.h" | 37 #include "platform/text/TextRun.h" |
38 #include "public/platform/WebFloatPoint.h" | 38 #include "public/platform/WebFloatPoint.h" |
39 #include "public/platform/WebFloatRect.h" | 39 #include "public/platform/WebFloatRect.h" |
40 #include "public/platform/WebRect.h" | 40 #include "public/platform/WebRect.h" |
41 #include "public/web/WebFontDescription.h" | 41 #include "public/web/WebFontDescription.h" |
42 #include "public/web/WebTextRun.h" | 42 #include "public/web/WebTextRun.h" |
43 #include <skia/ext/platform_canvas.h> | 43 #include <skia/ext/platform_canvas.h> |
44 | 44 |
45 using namespace blink; | |
46 | |
47 namespace blink { | 45 namespace blink { |
48 | 46 |
49 WebFont* WebFont::create(const WebFontDescription& desc) | 47 WebFont* WebFont::create(const WebFontDescription& desc) |
50 { | 48 { |
51 return new WebFontImpl(desc); | 49 return new WebFontImpl(desc); |
52 } | 50 } |
53 | 51 |
54 WebFontImpl::WebFontImpl(const FontDescription& desc) | 52 WebFontImpl::WebFontImpl(const FontDescription& desc) |
55 : m_font(desc) | 53 : m_font(desc) |
56 { | 54 { |
(...skipping 28 matching lines...) Expand all Loading... |
85 float WebFontImpl::xHeight() const | 83 float WebFontImpl::xHeight() const |
86 { | 84 { |
87 return m_font.fontMetrics().xHeight(); | 85 return m_font.fontMetrics().xHeight(); |
88 } | 86 } |
89 | 87 |
90 void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFl
oatPoint& leftBaseline, | 88 void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFl
oatPoint& leftBaseline, |
91 WebColor color, const WebRect& clip, bool canvasIsOpa
que, | 89 WebColor color, const WebRect& clip, bool canvasIsOpa
que, |
92 int from, int to) const | 90 int from, int to) const |
93 { | 91 { |
94 FontCachePurgePreventer fontCachePurgePreventer; | 92 FontCachePurgePreventer fontCachePurgePreventer; |
95 blink::FloatRect textClipRect(clip); | 93 FloatRect textClipRect(clip); |
96 TextRun textRun(run); | 94 TextRun textRun(run); |
97 TextRunPaintInfo runInfo(textRun); | 95 TextRunPaintInfo runInfo(textRun); |
98 runInfo.from = from; | 96 runInfo.from = from; |
99 runInfo.to = to == -1 ? textRun.length() : to; | 97 runInfo.to = to == -1 ? textRun.length() : to; |
100 runInfo.bounds = textClipRect; | 98 runInfo.bounds = textClipRect; |
101 GraphicsContext gc(canvas); | 99 GraphicsContext gc(canvas); |
102 | 100 |
103 gc.save(); | 101 gc.save(); |
104 gc.setCertainlyOpaque(canvasIsOpaque); | 102 gc.setCertainlyOpaque(canvasIsOpaque); |
105 gc.setFillColor(color); | 103 gc.setFillColor(color); |
(...skipping 14 matching lines...) Expand all Loading... |
120 return m_font.offsetForPosition(run, position, true); | 118 return m_font.offsetForPosition(run, position, true); |
121 } | 119 } |
122 | 120 |
123 WebFloatRect WebFontImpl::selectionRectForText(const WebTextRun& run, const WebF
loatPoint& leftBaseline, int height, int from, int to) const | 121 WebFloatRect WebFontImpl::selectionRectForText(const WebTextRun& run, const WebF
loatPoint& leftBaseline, int height, int from, int to) const |
124 { | 122 { |
125 FontCachePurgePreventer fontCachePurgePreventer; | 123 FontCachePurgePreventer fontCachePurgePreventer; |
126 return m_font.selectionRectForText(run, leftBaseline, height, from, to); | 124 return m_font.selectionRectForText(run, leftBaseline, height, from, to); |
127 } | 125 } |
128 | 126 |
129 } // namespace blink | 127 } // namespace blink |
OLD | NEW |