| 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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/mac/foundation_util.h" | 13 #include "base/mac/foundation_util.h" |
| 14 #include "base/mac/scoped_cftyperef.h" | 14 #include "base/mac/scoped_cftyperef.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
| 16 #include "skia/ext/skia_utils_mac.h" | 16 #include "skia/ext/skia_utils_mac.h" |
| 17 | 17 |
| 18 #include "base/debug/stack_trace.h" |
| 19 |
| 18 namespace gfx { | 20 namespace gfx { |
| 19 | 21 |
| 20 RenderTextMac::RenderTextMac() | 22 RenderTextMac::RenderTextMac() |
| 21 : common_baseline_(0), runs_valid_(false) { | 23 : common_baseline_(0), runs_valid_(false) { |
| 22 } | 24 } |
| 23 | 25 |
| 24 RenderTextMac::~RenderTextMac() { | 26 RenderTextMac::~RenderTextMac() { |
| 25 } | 27 } |
| 26 | 28 |
| 27 scoped_ptr<RenderText> RenderTextMac::CreateInstanceOfSameType() const { | 29 scoped_ptr<RenderText> RenderTextMac::CreateInstanceOfSameType() const { |
| 28 return make_scoped_ptr(new RenderTextMac); | 30 return make_scoped_ptr(new RenderTextMac); |
| 29 } | 31 } |
| 30 | 32 |
| 31 bool RenderTextMac::MultilineSupported() const { | 33 bool RenderTextMac::MultilineSupported() const { |
| 32 return false; | 34 return false; |
| 33 } | 35 } |
| 34 | 36 |
| 35 const base::string16& RenderTextMac::GetDisplayText() { | 37 const base::string16& RenderTextMac::GetDisplayText() { |
| 38 |
| 36 return text_elided() ? display_text() : layout_text(); | 39 return text_elided() ? display_text() : layout_text(); |
| 37 } | 40 } |
| 38 | 41 |
| 39 Size RenderTextMac::GetStringSize() { | 42 Size RenderTextMac::GetStringSize() { |
| 40 EnsureLayout(); | 43 EnsureLayout(); |
| 41 return Size(std::ceil(string_size_.width()), string_size_.height()); | 44 return Size(std::ceil(string_size_.width()), string_size_.height()); |
| 42 } | 45 } |
| 43 | 46 |
| 44 SizeF RenderTextMac::GetStringSizeF() { | 47 SizeF RenderTextMac::GetStringSizeF() { |
| 45 EnsureLayout(); | 48 EnsureLayout(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // TODO(asvitkine): Implement this. http://crbug.com/131618 | 108 // TODO(asvitkine): Implement this. http://crbug.com/131618 |
| 106 return index; | 109 return index; |
| 107 } | 110 } |
| 108 | 111 |
| 109 bool RenderTextMac::IsValidCursorIndex(size_t index) { | 112 bool RenderTextMac::IsValidCursorIndex(size_t index) { |
| 110 // TODO(asvitkine): Implement this. http://crbug.com/131618 | 113 // TODO(asvitkine): Implement this. http://crbug.com/131618 |
| 111 return IsValidLogicalIndex(index); | 114 return IsValidLogicalIndex(index); |
| 112 } | 115 } |
| 113 | 116 |
| 114 void RenderTextMac::OnLayoutTextAttributeChanged(bool text_changed) { | 117 void RenderTextMac::OnLayoutTextAttributeChanged(bool text_changed) { |
| 118 DLOG(INFO) << "OnLayoutTextAttributeChanged: " << GetDisplayText(); |
| 115 //DCHECK(!multiline()) << "RenderTextMac does not support multi line"; | 119 //DCHECK(!multiline()) << "RenderTextMac does not support multi line"; |
| 116 if (text_changed) { | 120 if (text_changed) { |
| 117 if (elide_behavior() != NO_ELIDE && | 121 if (elide_behavior() != NO_ELIDE && |
| 118 elide_behavior() != FADE_TAIL && | 122 elide_behavior() != FADE_TAIL && |
| 119 !layout_text().empty()) { | 123 !layout_text().empty()) { |
| 120 UpdateDisplayText(GetContentWidth()); | 124 UpdateDisplayText(GetContentWidth()); |
| 121 } else { | 125 } else { |
| 122 UpdateDisplayText(0); | 126 UpdateDisplayText(0); |
| 123 } | 127 } |
| 124 } | 128 } |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 CTUnderlineStyle value = kCTUnderlineStyleNone; | 366 CTUnderlineStyle value = kCTUnderlineStyleNone; |
| 363 if (underline && CFNumberGetValue(underline, kCFNumberSInt32Type, &value)) | 367 if (underline && CFNumberGetValue(underline, kCFNumberSInt32Type, &value)) |
| 364 run->underline = (value == kCTUnderlineStyleSingle); | 368 run->underline = (value == kCTUnderlineStyleSingle); |
| 365 | 369 |
| 366 run_origin.offset(run_width, 0); | 370 run_origin.offset(run_width, 0); |
| 367 } | 371 } |
| 368 runs_valid_ = true; | 372 runs_valid_ = true; |
| 369 } | 373 } |
| 370 | 374 |
| 371 } // namespace gfx | 375 } // namespace gfx |
| OLD | NEW |