| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/plugins/ppapi/ppb_font_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_font_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "ppapi/c/dev/ppb_font_dev.h" | 9 #include "ppapi/c/dev/ppb_font_dev.h" |
| 10 #include "ppapi/c/pp_rect.h" | 10 #include "ppapi/c/pp_rect.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 if (!font.get()) | 154 if (!font.get()) |
| 155 return -1; | 155 return -1; |
| 156 return font->MeasureText(text); | 156 return font->MeasureText(text); |
| 157 } | 157 } |
| 158 | 158 |
| 159 uint32_t CharacterOffsetForPixel(PP_Resource font_id, | 159 uint32_t CharacterOffsetForPixel(PP_Resource font_id, |
| 160 const PP_TextRun_Dev* text, | 160 const PP_TextRun_Dev* text, |
| 161 int32_t pixel_position) { | 161 int32_t pixel_position) { |
| 162 scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id)); | 162 scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id)); |
| 163 if (!font.get()) | 163 if (!font.get()) |
| 164 return false; | 164 return -1; |
| 165 return font->CharacterOffsetForPixel(text, pixel_position); | 165 return font->CharacterOffsetForPixel(text, pixel_position); |
| 166 } | 166 } |
| 167 | 167 |
| 168 int32_t PixelOffsetForCharacter(PP_Resource font_id, | 168 int32_t PixelOffsetForCharacter(PP_Resource font_id, |
| 169 const PP_TextRun_Dev* text, | 169 const PP_TextRun_Dev* text, |
| 170 uint32_t char_offset) { | 170 uint32_t char_offset) { |
| 171 scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id)); | 171 scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id)); |
| 172 if (!font.get()) | 172 if (!font.get()) |
| 173 return false; | 173 return false; |
| 174 return font->PixelOffsetForCharacter(text, char_offset); | 174 return font->PixelOffsetForCharacter(text, char_offset); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 return -1; | 293 return -1; |
| 294 | 294 |
| 295 WebFloatRect rect = font_->selectionRectForText( | 295 WebFloatRect rect = font_->selectionRectForText( |
| 296 run, WebFloatPoint(0.0f, 0.0f), font_->height(), 0, char_offset); | 296 run, WebFloatPoint(0.0f, 0.0f), font_->height(), 0, char_offset); |
| 297 return static_cast<int>(rect.width); | 297 return static_cast<int>(rect.width); |
| 298 } | 298 } |
| 299 | 299 |
| 300 } // namespace ppapi | 300 } // namespace ppapi |
| 301 } // namespace webkit | 301 } // namespace webkit |
| 302 | 302 |
| OLD | NEW |