Index: ui/views/cocoa/bridged_content_view.mm |
diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm |
index 15ac3500bc7c36ed0e51d48931e75860ac9ef2ce..e20284650bae3cf8bc2f8c02cc93ea3c35eb1709 100644 |
--- a/ui/views/cocoa/bridged_content_view.mm |
+++ b/ui/views/cocoa/bridged_content_view.mm |
@@ -24,6 +24,7 @@ |
#import "ui/events/keycodes/keyboard_code_conversion_mac.h" |
#include "ui/gfx/canvas_paint_mac.h" |
#include "ui/gfx/decorated_text.h" |
+#import "ui/gfx/decorated_text_mac.h" |
#include "ui/gfx/geometry/rect.h" |
#import "ui/gfx/mac/coordinate_conversion.h" |
#include "ui/gfx/path.h" |
@@ -213,42 +214,6 @@ ui::KeyEvent GetCharacterEventFromNSEvent(NSEvent* event) { |
ui::KeyboardCodeFromNSEvent(event), ui::EF_NONE); |
} |
-NSAttributedString* GetAttributedString( |
- const gfx::DecoratedText& decorated_text) { |
- base::scoped_nsobject<NSMutableAttributedString> str( |
- [[NSMutableAttributedString alloc] |
- initWithString:base::SysUTF16ToNSString(decorated_text.text)]); |
- [str beginEditing]; |
- |
- NSValue* const line_style = |
- @(NSUnderlineStyleSingle | NSUnderlinePatternSolid); |
- |
- for (const auto& attribute : decorated_text.attributes) { |
- DCHECK(!attribute.range.is_reversed()); |
- DCHECK_LE(attribute.range.end(), [str length]); |
- |
- NSMutableDictionary* attrs = [NSMutableDictionary dictionary]; |
- NSRange range = attribute.range.ToNSRange(); |
- |
- if (attribute.font.GetNativeFont()) |
- attrs[NSFontAttributeName] = attribute.font.GetNativeFont(); |
- |
- // NSFont does not have underline as an attribute. Hence handle it |
- // separately. |
- const bool underline = attribute.font.GetStyle() & gfx::Font::UNDERLINE; |
- if (underline) |
- attrs[NSUnderlineStyleAttributeName] = line_style; |
- |
- if (attribute.strike) |
- attrs[NSStrikethroughStyleAttributeName] = line_style; |
- |
- [str setAttributes:attrs range:range]; |
- } |
- |
- [str endEditing]; |
- return str.autorelease(); |
-} |
- |
ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) { |
if (action == @selector(undo:)) |
return ui::TextEditCommand::UNDO; |
@@ -267,6 +232,8 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) { |
} // namespace |
+// TODO(spqchan): Implement support with the Speech submenu is in the main |
tapted
2017/01/13 21:37:33
nit: with -> when
spqchan
2017/01/26 18:27:01
Done.
|
+// menu. |
@interface BridgedContentView () |
// Returns the active menu controller corresponding to |hostedView_|, |
@@ -842,7 +809,7 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) { |
views::View::ConvertPointToTarget(hostedView_, target, &locationInTarget); |
gfx::DecoratedText decoratedWord; |
gfx::Point baselinePoint; |
- if (!wordLookupClient->GetDecoratedWordAtPoint( |
+ if (!wordLookupClient->GetDecoratedWordAndBaselineAtPoint( |
locationInTarget, &decoratedWord, &baselinePoint)) { |
return; |
} |
@@ -851,7 +818,8 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) { |
views::View::ConvertPointToTarget(target, hostedView_, &baselinePoint); |
NSPoint baselinePointAppKit = NSMakePoint( |
baselinePoint.x(), NSHeight([self frame]) - baselinePoint.y()); |
- [self showDefinitionForAttributedString:GetAttributedString(decoratedWord) |
+ [self showDefinitionForAttributedString: |
+ gfx::GetAttributedStringFromDecoratedText(decoratedWord) |
atPoint:baselinePointAppKit]; |
} |