Chromium Code Reviews| 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 d1df25251c718fc27151643c891160406a6f233b..f55f0d60548a3fbd4beec0e25e5e13dbbdf3050e 100644 |
| --- a/ui/views/cocoa/bridged_content_view.mm |
| +++ b/ui/views/cocoa/bridged_content_view.mm |
| @@ -23,6 +23,7 @@ |
| #import "ui/events/keycodes/keyboard_code_conversion_mac.h" |
| #include "ui/gfx/canvas_paint_mac.h" |
| #include "ui/gfx/decorated_text.h" |
| +#include "ui/gfx/decorated_text_mac.h" |
|
tapted
2016/12/21 11:20:27
nit: import
spqchan
2016/12/21 22:00:13
Done.
|
| #include "ui/gfx/geometry/rect.h" |
| #import "ui/gfx/mac/coordinate_conversion.h" |
| #include "ui/gfx/path.h" |
| @@ -212,42 +213,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; |
| @@ -266,6 +231,7 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) { |
| } // namespace |
| +// TODO(spqchan): Implement support with the Speech submenu is the main menu. |
|
tapted
2016/12/21 11:20:27
is -> in
spqchan
2016/12/21 22:00:13
Done.
|
| @interface BridgedContentView () |
| // Returns the active menu controller corresponding to |hostedView_|, |
| @@ -836,7 +802,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; |
| } |
| @@ -845,7 +811,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]; |
| } |