| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/render_text_mac.h" | 5 #include "ui/gfx/render_text_mac.h" |
| 6 | 6 |
| 7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 Size RenderTextMac::GetStringSize() { | 26 Size RenderTextMac::GetStringSize() { |
| 27 EnsureLayout(); | 27 EnsureLayout(); |
| 28 return Size(std::ceil(string_size_.width()), string_size_.height()); | 28 return Size(std::ceil(string_size_.width()), string_size_.height()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 SizeF RenderTextMac::GetStringSizeF() { | 31 SizeF RenderTextMac::GetStringSizeF() { |
| 32 EnsureLayout(); | 32 EnsureLayout(); |
| 33 return string_size_; | 33 return string_size_; |
| 34 } | 34 } |
| 35 | 35 |
| 36 int RenderTextMac::GetBaseline() { | |
| 37 EnsureLayout(); | |
| 38 return common_baseline_; | |
| 39 } | |
| 40 | |
| 41 SelectionModel RenderTextMac::FindCursorPosition(const Point& point) { | 36 SelectionModel RenderTextMac::FindCursorPosition(const Point& point) { |
| 42 // TODO(asvitkine): Implement this. http://crbug.com/131618 | 37 // TODO(asvitkine): Implement this. http://crbug.com/131618 |
| 43 return SelectionModel(); | 38 return SelectionModel(); |
| 44 } | 39 } |
| 45 | 40 |
| 46 std::vector<RenderText::FontSpan> RenderTextMac::GetFontSpansForTesting() { | 41 std::vector<RenderText::FontSpan> RenderTextMac::GetFontSpansForTesting() { |
| 47 EnsureLayout(); | 42 EnsureLayout(); |
| 48 if (!runs_valid_) | 43 if (!runs_valid_) |
| 49 ComputeRuns(); | 44 ComputeRuns(); |
| 50 | 45 |
| 51 std::vector<RenderText::FontSpan> spans; | 46 std::vector<RenderText::FontSpan> spans; |
| 52 for (size_t i = 0; i < runs_.size(); ++i) { | 47 for (size_t i = 0; i < runs_.size(); ++i) { |
| 53 gfx::Font font(runs_[i].font_name, runs_[i].text_size); | 48 gfx::Font font(runs_[i].font_name, runs_[i].text_size); |
| 54 const CFRange cf_range = CTRunGetStringRange(runs_[i].ct_run); | 49 const CFRange cf_range = CTRunGetStringRange(runs_[i].ct_run); |
| 55 const Range range(cf_range.location, cf_range.location + cf_range.length); | 50 const Range range(cf_range.location, cf_range.location + cf_range.length); |
| 56 spans.push_back(RenderText::FontSpan(font, range)); | 51 spans.push_back(RenderText::FontSpan(font, range)); |
| 57 } | 52 } |
| 58 | 53 |
| 59 return spans; | 54 return spans; |
| 60 } | 55 } |
| 61 | 56 |
| 57 int RenderTextMac::GetBaselineOfTextLayout() { |
| 58 EnsureLayout(); |
| 59 return common_baseline_; |
| 60 } |
| 61 |
| 62 SelectionModel RenderTextMac::AdjacentCharSelectionModel( | 62 SelectionModel RenderTextMac::AdjacentCharSelectionModel( |
| 63 const SelectionModel& selection, | 63 const SelectionModel& selection, |
| 64 VisualCursorDirection direction) { | 64 VisualCursorDirection direction) { |
| 65 // TODO(asvitkine): Implement this. http://crbug.com/131618 | 65 // TODO(asvitkine): Implement this. http://crbug.com/131618 |
| 66 return SelectionModel(); | 66 return SelectionModel(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 SelectionModel RenderTextMac::AdjacentWordSelectionModel( | 69 SelectionModel RenderTextMac::AdjacentWordSelectionModel( |
| 70 const SelectionModel& selection, | 70 const SelectionModel& selection, |
| 71 VisualCursorDirection direction) { | 71 VisualCursorDirection direction) { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 run_origin.offset(run_width, 0); | 338 run_origin.offset(run_width, 0); |
| 339 } | 339 } |
| 340 runs_valid_ = true; | 340 runs_valid_ = true; |
| 341 } | 341 } |
| 342 | 342 |
| 343 RenderText* RenderText::CreateInstance() { | 343 RenderText* RenderText::CreateInstance() { |
| 344 return new RenderTextMac; | 344 return new RenderTextMac; |
| 345 } | 345 } |
| 346 | 346 |
| 347 } // namespace gfx | 347 } // namespace gfx |
| OLD | NEW |