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