| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 NSDictionary* attrs = [string attributesAtIndex:i | 270 NSDictionary* attrs = [string attributesAtIndex:i |
| 271 longestEffectiveRange:&range | 271 longestEffectiveRange:&range |
| 272 inRange:NSMakeRange(i, length - i)]; | 272 inRange:NSMakeRange(i, length - i)]; |
| 273 if (NSNumber *style = [attrs objectForKey:NSUnderlineStyleAttributeName]) { | 273 if (NSNumber *style = [attrs objectForKey:NSUnderlineStyleAttributeName]) { |
| 274 blink::WebColor color = SK_ColorBLACK; | 274 blink::WebColor color = SK_ColorBLACK; |
| 275 if (NSColor *colorAttr = | 275 if (NSColor *colorAttr = |
| 276 [attrs objectForKey:NSUnderlineColorAttributeName]) { | 276 [attrs objectForKey:NSUnderlineColorAttributeName]) { |
| 277 color = WebColorFromNSColor( | 277 color = WebColorFromNSColor( |
| 278 [colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]); | 278 [colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]); |
| 279 } | 279 } |
| 280 underlines->push_back(blink::WebCompositionUnderline( | 280 underlines->push_back( |
| 281 range.location, NSMaxRange(range), color, [style intValue] > 1)); | 281 blink::WebCompositionUnderline(range.location, |
| 282 NSMaxRange(range), |
| 283 color, |
| 284 [style intValue] > 1, |
| 285 SK_ColorTRANSPARENT)); |
| 282 } | 286 } |
| 283 i = range.location + range.length; | 287 i = range.location + range.length; |
| 284 } | 288 } |
| 285 } | 289 } |
| 286 | 290 |
| 287 // EnablePasswordInput() and DisablePasswordInput() are copied from | 291 // EnablePasswordInput() and DisablePasswordInput() are copied from |
| 288 // enableSecureTextInput() and disableSecureTextInput() functions in | 292 // enableSecureTextInput() and disableSecureTextInput() functions in |
| 289 // third_party/WebKit/WebCore/platform/SecureTextInput.cpp | 293 // third_party/WebKit/WebCore/platform/SecureTextInput.cpp |
| 290 // But we don't call EnableSecureEventInput() and DisableSecureEventInput() | 294 // But we don't call EnableSecureEventInput() and DisableSecureEventInput() |
| 291 // here, because they are already called in webkit and they are system wide | 295 // here, because they are already called in webkit and they are system wide |
| (...skipping 3292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3584 // |markedRange_| will get set on a callback from ImeSetComposition(). | 3588 // |markedRange_| will get set on a callback from ImeSetComposition(). |
| 3585 selectedRange_ = newSelRange; | 3589 selectedRange_ = newSelRange; |
| 3586 markedText_ = base::SysNSStringToUTF16(im_text); | 3590 markedText_ = base::SysNSStringToUTF16(im_text); |
| 3587 hasMarkedText_ = (length > 0); | 3591 hasMarkedText_ = (length > 0); |
| 3588 | 3592 |
| 3589 underlines_.clear(); | 3593 underlines_.clear(); |
| 3590 if (isAttributedString) { | 3594 if (isAttributedString) { |
| 3591 ExtractUnderlines(string, &underlines_); | 3595 ExtractUnderlines(string, &underlines_); |
| 3592 } else { | 3596 } else { |
| 3593 // Use a thin black underline by default. | 3597 // Use a thin black underline by default. |
| 3594 underlines_.push_back( | 3598 underlines_.push_back(blink::WebCompositionUnderline( |
| 3595 blink::WebCompositionUnderline(0, length, SK_ColorBLACK, false)); | 3599 0, length, SK_ColorBLACK, false, SK_ColorTRANSPARENT)); |
| 3596 } | 3600 } |
| 3597 | 3601 |
| 3598 // If we are handling a key down event, then SetComposition() will be | 3602 // If we are handling a key down event, then SetComposition() will be |
| 3599 // called in keyEvent: method. | 3603 // called in keyEvent: method. |
| 3600 // Input methods of Mac use setMarkedText calls with an empty text to cancel | 3604 // Input methods of Mac use setMarkedText calls with an empty text to cancel |
| 3601 // an ongoing composition. So, we should check whether or not the given text | 3605 // an ongoing composition. So, we should check whether or not the given text |
| 3602 // is empty to update the input method state. (Our input method backend can | 3606 // is empty to update the input method state. (Our input method backend can |
| 3603 // automatically cancels an ongoing composition when we send an empty text. | 3607 // automatically cancels an ongoing composition when we send an empty text. |
| 3604 // So, it is OK to send an empty text to the renderer.) | 3608 // So, it is OK to send an empty text to the renderer.) |
| 3605 if (!handlingKeyDown_) { | 3609 if (!handlingKeyDown_) { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3926 | 3930 |
| 3927 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3931 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3928 // regions that are not draggable. (See ControlRegionView in | 3932 // regions that are not draggable. (See ControlRegionView in |
| 3929 // native_app_window_cocoa.mm). This requires the render host view to be | 3933 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3930 // draggable by default. | 3934 // draggable by default. |
| 3931 - (BOOL)mouseDownCanMoveWindow { | 3935 - (BOOL)mouseDownCanMoveWindow { |
| 3932 return YES; | 3936 return YES; |
| 3933 } | 3937 } |
| 3934 | 3938 |
| 3935 @end | 3939 @end |
| OLD | NEW |