| 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 "content/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 #include <QuartzCore/QuartzCore.h> | 8 #include <QuartzCore/QuartzCore.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 longestEffectiveRange:&range | 273 longestEffectiveRange:&range |
| 274 inRange:NSMakeRange(i, length - i)]; | 274 inRange:NSMakeRange(i, length - i)]; |
| 275 if (NSNumber *style = [attrs objectForKey:NSUnderlineStyleAttributeName]) { | 275 if (NSNumber *style = [attrs objectForKey:NSUnderlineStyleAttributeName]) { |
| 276 blink::WebColor color = SK_ColorBLACK; | 276 blink::WebColor color = SK_ColorBLACK; |
| 277 if (NSColor *colorAttr = | 277 if (NSColor *colorAttr = |
| 278 [attrs objectForKey:NSUnderlineColorAttributeName]) { | 278 [attrs objectForKey:NSUnderlineColorAttributeName]) { |
| 279 color = WebColorFromNSColor( | 279 color = WebColorFromNSColor( |
| 280 [colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]); | 280 [colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]); |
| 281 } | 281 } |
| 282 underlines->push_back(blink::WebCompositionUnderline( | 282 underlines->push_back(blink::WebCompositionUnderline( |
| 283 range.location, NSMaxRange(range), color, [style intValue] > 1)); | 283 range.location, NSMaxRange(range), color, [style intValue] > 1, |
| 284 SK_ColorTRANSPARENT)); |
| 284 } | 285 } |
| 285 i = range.location + range.length; | 286 i = range.location + range.length; |
| 286 } | 287 } |
| 287 } | 288 } |
| 288 | 289 |
| 289 // EnablePasswordInput() and DisablePasswordInput() are copied from | 290 // EnablePasswordInput() and DisablePasswordInput() are copied from |
| 290 // enableSecureTextInput() and disableSecureTextInput() functions in | 291 // enableSecureTextInput() and disableSecureTextInput() functions in |
| 291 // third_party/WebKit/WebCore/platform/SecureTextInput.cpp | 292 // third_party/WebKit/WebCore/platform/SecureTextInput.cpp |
| 292 // But we don't call EnableSecureEventInput() and DisableSecureEventInput() | 293 // But we don't call EnableSecureEventInput() and DisableSecureEventInput() |
| 293 // here, because they are already called in webkit and they are system wide | 294 // here, because they are already called in webkit and they are system wide |
| (...skipping 3371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3665 selectedRange_ = newSelRange; | 3666 selectedRange_ = newSelRange; |
| 3666 markedText_ = base::SysNSStringToUTF16(im_text); | 3667 markedText_ = base::SysNSStringToUTF16(im_text); |
| 3667 hasMarkedText_ = (length > 0); | 3668 hasMarkedText_ = (length > 0); |
| 3668 | 3669 |
| 3669 underlines_.clear(); | 3670 underlines_.clear(); |
| 3670 if (isAttributedString) { | 3671 if (isAttributedString) { |
| 3671 ExtractUnderlines(string, &underlines_); | 3672 ExtractUnderlines(string, &underlines_); |
| 3672 } else { | 3673 } else { |
| 3673 // Use a thin black underline by default. | 3674 // Use a thin black underline by default. |
| 3674 underlines_.push_back( | 3675 underlines_.push_back( |
| 3675 blink::WebCompositionUnderline(0, length, SK_ColorBLACK, false)); | 3676 blink::WebCompositionUnderline(0, length, SK_ColorBLACK, false, |
| 3677 SK_ColorTRANSPARENT)); |
| 3676 } | 3678 } |
| 3677 | 3679 |
| 3678 // If we are handling a key down event, then SetComposition() will be | 3680 // If we are handling a key down event, then SetComposition() will be |
| 3679 // called in keyEvent: method. | 3681 // called in keyEvent: method. |
| 3680 // Input methods of Mac use setMarkedText calls with an empty text to cancel | 3682 // Input methods of Mac use setMarkedText calls with an empty text to cancel |
| 3681 // an ongoing composition. So, we should check whether or not the given text | 3683 // an ongoing composition. So, we should check whether or not the given text |
| 3682 // is empty to update the input method state. (Our input method backend can | 3684 // is empty to update the input method state. (Our input method backend can |
| 3683 // automatically cancels an ongoing composition when we send an empty text. | 3685 // automatically cancels an ongoing composition when we send an empty text. |
| 3684 // So, it is OK to send an empty text to the renderer.) | 3686 // So, it is OK to send an empty text to the renderer.) |
| 3685 if (!handlingKeyDown_) { | 3687 if (!handlingKeyDown_) { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4006 | 4008 |
| 4007 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 4009 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 4008 // regions that are not draggable. (See ControlRegionView in | 4010 // regions that are not draggable. (See ControlRegionView in |
| 4009 // native_app_window_cocoa.mm). This requires the render host view to be | 4011 // native_app_window_cocoa.mm). This requires the render host view to be |
| 4010 // draggable by default. | 4012 // draggable by default. |
| 4011 - (BOOL)mouseDownCanMoveWindow { | 4013 - (BOOL)mouseDownCanMoveWindow { |
| 4012 return YES; | 4014 return YES; |
| 4013 } | 4015 } |
| 4014 | 4016 |
| 4015 @end | 4017 @end |
| OLD | NEW |