| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <QuartzCore/QuartzCore.h> | 5 #include <QuartzCore/QuartzCore.h> |
| 6 | 6 |
| 7 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" | 7 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 return NULL; | 225 return NULL; |
| 226 } | 226 } |
| 227 | 227 |
| 228 /////////////////////////////////////////////////////////////////////////////// | 228 /////////////////////////////////////////////////////////////////////////////// |
| 229 // RenderWidgetHostViewMac, public: | 229 // RenderWidgetHostViewMac, public: |
| 230 | 230 |
| 231 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) | 231 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) |
| 232 : render_widget_host_(widget), | 232 : render_widget_host_(widget), |
| 233 about_to_validate_and_paint_(false), | 233 about_to_validate_and_paint_(false), |
| 234 call_set_needs_display_in_rect_pending_(false), | 234 call_set_needs_display_in_rect_pending_(false), |
| 235 text_input_type_(WebKit::WebTextInputTypeNone), | 235 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 236 spellcheck_enabled_(false), | 236 spellcheck_enabled_(false), |
| 237 spellcheck_checked_(false), | 237 spellcheck_checked_(false), |
| 238 is_loading_(false), | 238 is_loading_(false), |
| 239 is_hidden_(false), | 239 is_hidden_(false), |
| 240 shutdown_factory_(this), | 240 shutdown_factory_(this), |
| 241 needs_gpu_visibility_update_after_repaint_(false), | 241 needs_gpu_visibility_update_after_repaint_(false), |
| 242 compositing_surface_(gfx::kNullPluginWindow) { | 242 compositing_surface_(gfx::kNullPluginWindow) { |
| 243 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| goes away. | 243 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| goes away. |
| 244 // Since we autorelease it, our caller must put |native_view()| into the view | 244 // Since we autorelease it, our caller must put |native_view()| into the view |
| 245 // hierarchy right after calling us. | 245 // hierarchy right after calling us. |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 [ns_cursor set]; | 483 [ns_cursor set]; |
| 484 } | 484 } |
| 485 | 485 |
| 486 void RenderWidgetHostViewMac::SetIsLoading(bool is_loading) { | 486 void RenderWidgetHostViewMac::SetIsLoading(bool is_loading) { |
| 487 is_loading_ = is_loading; | 487 is_loading_ = is_loading; |
| 488 // If we ever decide to show the waiting cursor while the page is loading | 488 // If we ever decide to show the waiting cursor while the page is loading |
| 489 // like Chrome does on Windows, call |UpdateCursorIfNecessary()| here. | 489 // like Chrome does on Windows, call |UpdateCursorIfNecessary()| here. |
| 490 } | 490 } |
| 491 | 491 |
| 492 void RenderWidgetHostViewMac::ImeUpdateTextInputState( | 492 void RenderWidgetHostViewMac::ImeUpdateTextInputState( |
| 493 WebKit::WebTextInputType type, | 493 ui::TextInputType type, |
| 494 bool can_compose_inline, |
| 494 const gfx::Rect& caret_rect) { | 495 const gfx::Rect& caret_rect) { |
| 496 // TODO(kinaba): currently, can_compose_inline is ignored and always treated |
| 497 // as true. We need to support "can_compose_inline=false" for PPAPI plugins |
| 498 // that may want to avoid drawing composition-text by themselves and pass |
| 499 // the responsibility to the browser. |
| 495 if (text_input_type_ != type) { | 500 if (text_input_type_ != type) { |
| 496 text_input_type_ = type; | 501 text_input_type_ = type; |
| 497 if (HasFocus()) { | 502 if (HasFocus()) { |
| 498 SetTextInputActive(true); | 503 SetTextInputActive(true); |
| 499 | 504 |
| 500 // Let AppKit cache the new input context to make IMEs happy. | 505 // Let AppKit cache the new input context to make IMEs happy. |
| 501 // See http://crbug.com/73039. | 506 // See http://crbug.com/73039. |
| 502 [NSApp updateWindows]; | 507 [NSApp updateWindows]; |
| 503 } | 508 } |
| 504 } | 509 } |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 empty_document.role = WebAccessibility::ROLE_WEB_AREA; | 1027 empty_document.role = WebAccessibility::ROLE_WEB_AREA; |
| 1023 empty_document.state = 0; | 1028 empty_document.state = 0; |
| 1024 browser_accessibility_manager_.reset( | 1029 browser_accessibility_manager_.reset( |
| 1025 BrowserAccessibilityManager::Create(cocoa_view_, empty_document, NULL)); | 1030 BrowserAccessibilityManager::Create(cocoa_view_, empty_document, NULL)); |
| 1026 } | 1031 } |
| 1027 browser_accessibility_manager_->OnAccessibilityNotifications(params); | 1032 browser_accessibility_manager_->OnAccessibilityNotifications(params); |
| 1028 } | 1033 } |
| 1029 | 1034 |
| 1030 void RenderWidgetHostViewMac::SetTextInputActive(bool active) { | 1035 void RenderWidgetHostViewMac::SetTextInputActive(bool active) { |
| 1031 if (active) { | 1036 if (active) { |
| 1032 if (text_input_type_ == WebKit::WebTextInputTypePassword) | 1037 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD) |
| 1033 EnablePasswordInput(); | 1038 EnablePasswordInput(); |
| 1034 else | 1039 else |
| 1035 DisablePasswordInput(); | 1040 DisablePasswordInput(); |
| 1036 } else { | 1041 } else { |
| 1037 if (text_input_type_ == WebKit::WebTextInputTypePassword) | 1042 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD) |
| 1038 DisablePasswordInput(); | 1043 DisablePasswordInput(); |
| 1039 } | 1044 } |
| 1040 } | 1045 } |
| 1041 | 1046 |
| 1042 // RenderWidgetHostViewCocoa --------------------------------------------------- | 1047 // RenderWidgetHostViewCocoa --------------------------------------------------- |
| 1043 | 1048 |
| 1044 @implementation RenderWidgetHostViewCocoa | 1049 @implementation RenderWidgetHostViewCocoa |
| 1045 | 1050 |
| 1046 @synthesize selectedRange = selectedRange_; | 1051 @synthesize selectedRange = selectedRange_; |
| 1047 @synthesize markedRange = markedRange_; | 1052 @synthesize markedRange = markedRange_; |
| (...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2231 } | 2236 } |
| 2232 | 2237 |
| 2233 // Each RenderWidgetHostViewCocoa has its own input context, but we return | 2238 // Each RenderWidgetHostViewCocoa has its own input context, but we return |
| 2234 // nil when the caret is in non-editable content or password box to avoid | 2239 // nil when the caret is in non-editable content or password box to avoid |
| 2235 // making input methods do their work. | 2240 // making input methods do their work. |
| 2236 - (NSTextInputContext *)inputContext { | 2241 - (NSTextInputContext *)inputContext { |
| 2237 if (focusedPluginIdentifier_ != -1) | 2242 if (focusedPluginIdentifier_ != -1) |
| 2238 return [[ComplexTextInputPanel sharedComplexTextInputPanel] inputContext]; | 2243 return [[ComplexTextInputPanel sharedComplexTextInputPanel] inputContext]; |
| 2239 | 2244 |
| 2240 switch(renderWidgetHostView_->text_input_type_) { | 2245 switch(renderWidgetHostView_->text_input_type_) { |
| 2241 case WebKit::WebTextInputTypeNone: | 2246 case ui::TEXT_INPUT_TYPE_NONE: |
| 2242 case WebKit::WebTextInputTypePassword: | 2247 case ui::TEXT_INPUT_TYPE_PASSWORD: |
| 2243 return nil; | 2248 return nil; |
| 2244 default: | 2249 default: |
| 2245 return [super inputContext]; | 2250 return [super inputContext]; |
| 2246 } | 2251 } |
| 2247 } | 2252 } |
| 2248 | 2253 |
| 2249 - (BOOL)hasMarkedText { | 2254 - (BOOL)hasMarkedText { |
| 2250 // An input method calls this function to figure out whether or not an | 2255 // An input method calls this function to figure out whether or not an |
| 2251 // application is really composing a text. If it is composing, it calls | 2256 // application is really composing a text. If it is composing, it calls |
| 2252 // the markedRange method, and maybe calls the setMarkedText method. | 2257 // the markedRange method, and maybe calls the setMarkedText method. |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2523 | 2528 |
| 2524 // Overriding a NSResponder method to support application services. | 2529 // Overriding a NSResponder method to support application services. |
| 2525 | 2530 |
| 2526 - (id)validRequestorForSendType:(NSString*)sendType | 2531 - (id)validRequestorForSendType:(NSString*)sendType |
| 2527 returnType:(NSString*)returnType { | 2532 returnType:(NSString*)returnType { |
| 2528 id requestor = nil; | 2533 id requestor = nil; |
| 2529 BOOL sendTypeIsString = [sendType isEqual:NSStringPboardType]; | 2534 BOOL sendTypeIsString = [sendType isEqual:NSStringPboardType]; |
| 2530 BOOL returnTypeIsString = [returnType isEqual:NSStringPboardType]; | 2535 BOOL returnTypeIsString = [returnType isEqual:NSStringPboardType]; |
| 2531 BOOL hasText = !renderWidgetHostView_->selected_text().empty(); | 2536 BOOL hasText = !renderWidgetHostView_->selected_text().empty(); |
| 2532 BOOL takesText = | 2537 BOOL takesText = |
| 2533 renderWidgetHostView_->text_input_type_ != WebKit::WebTextInputTypeNone; | 2538 renderWidgetHostView_->text_input_type_ != ui::TEXT_INPUT_TYPE_NONE; |
| 2534 | 2539 |
| 2535 if (sendTypeIsString && hasText && !returnType) { | 2540 if (sendTypeIsString && hasText && !returnType) { |
| 2536 requestor = self; | 2541 requestor = self; |
| 2537 } else if (!sendType && returnTypeIsString && takesText) { | 2542 } else if (!sendType && returnTypeIsString && takesText) { |
| 2538 requestor = self; | 2543 requestor = self; |
| 2539 } else if (sendTypeIsString && returnTypeIsString && hasText && takesText) { | 2544 } else if (sendTypeIsString && returnTypeIsString && hasText && takesText) { |
| 2540 requestor = self; | 2545 requestor = self; |
| 2541 } else { | 2546 } else { |
| 2542 requestor = [super validRequestorForSendType:sendType | 2547 requestor = [super validRequestorForSendType:sendType |
| 2543 returnType:returnType]; | 2548 returnType:returnType]; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2581 if (!string) return NO; | 2586 if (!string) return NO; |
| 2582 | 2587 |
| 2583 // If the user is currently using an IME, confirm the IME input, | 2588 // If the user is currently using an IME, confirm the IME input, |
| 2584 // and then insert the text from the service, the same as TextEdit and Safari. | 2589 // and then insert the text from the service, the same as TextEdit and Safari. |
| 2585 [self confirmComposition]; | 2590 [self confirmComposition]; |
| 2586 [self insertText:string]; | 2591 [self insertText:string]; |
| 2587 return YES; | 2592 return YES; |
| 2588 } | 2593 } |
| 2589 | 2594 |
| 2590 @end | 2595 @end |
| OLD | NEW |