Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(982)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 using content::BackingStoreMac; 69 using content::BackingStoreMac;
70 using content::BrowserAccessibility; 70 using content::BrowserAccessibility;
71 using content::BrowserAccessibilityManager; 71 using content::BrowserAccessibilityManager;
72 using content::EditCommand; 72 using content::EditCommand;
73 using content::NativeWebKeyboardEvent; 73 using content::NativeWebKeyboardEvent;
74 using content::RenderViewHostImpl; 74 using content::RenderViewHostImpl;
75 using content::RenderWidgetHostImpl; 75 using content::RenderWidgetHostImpl;
76 using content::RenderWidgetHostViewMac; 76 using content::RenderWidgetHostViewMac;
77 using content::RenderWidgetHostViewMacEditCommandHelper; 77 using content::RenderWidgetHostViewMacEditCommandHelper;
78 using content::TextInputClientMac; 78 using content::TextInputClientMac;
79 using WebKit::WebInputEvent; 79 using blink::WebInputEvent;
80 using WebKit::WebInputEventFactory; 80 using blink::WebInputEventFactory;
81 using WebKit::WebMouseEvent; 81 using blink::WebMouseEvent;
82 using WebKit::WebMouseWheelEvent; 82 using blink::WebMouseWheelEvent;
83 83
84 enum CoreAnimationStatus { 84 enum CoreAnimationStatus {
85 CORE_ANIMATION_DISABLED, 85 CORE_ANIMATION_DISABLED,
86 CORE_ANIMATION_ENABLED_LAZY, 86 CORE_ANIMATION_ENABLED_LAZY,
87 CORE_ANIMATION_ENABLED_ALWAYS, 87 CORE_ANIMATION_ENABLED_ALWAYS,
88 }; 88 };
89 89
90 static CoreAnimationStatus GetCoreAnimationStatus() { 90 static CoreAnimationStatus GetCoreAnimationStatus() {
91 // TODO(sail) Remove this. 91 // TODO(sail) Remove this.
92 if (!CommandLine::ForCurrentProcess()->HasSwitch( 92 if (!CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 280 }
281 281
282 @end 282 @end
283 283
284 namespace { 284 namespace {
285 285
286 // Maximum number of characters we allow in a tooltip. 286 // Maximum number of characters we allow in a tooltip.
287 const size_t kMaxTooltipLength = 1024; 287 const size_t kMaxTooltipLength = 1024;
288 288
289 // TODO(suzhe): Upstream this function. 289 // TODO(suzhe): Upstream this function.
290 WebKit::WebColor WebColorFromNSColor(NSColor *color) { 290 blink::WebColor WebColorFromNSColor(NSColor *color) {
291 CGFloat r, g, b, a; 291 CGFloat r, g, b, a;
292 [color getRed:&r green:&g blue:&b alpha:&a]; 292 [color getRed:&r green:&g blue:&b alpha:&a];
293 293
294 return 294 return
295 std::max(0, std::min(static_cast<int>(lroundf(255.0f * a)), 255)) << 24 | 295 std::max(0, std::min(static_cast<int>(lroundf(255.0f * a)), 255)) << 24 |
296 std::max(0, std::min(static_cast<int>(lroundf(255.0f * r)), 255)) << 16 | 296 std::max(0, std::min(static_cast<int>(lroundf(255.0f * r)), 255)) << 16 |
297 std::max(0, std::min(static_cast<int>(lroundf(255.0f * g)), 255)) << 8 | 297 std::max(0, std::min(static_cast<int>(lroundf(255.0f * g)), 255)) << 8 |
298 std::max(0, std::min(static_cast<int>(lroundf(255.0f * b)), 255)); 298 std::max(0, std::min(static_cast<int>(lroundf(255.0f * b)), 255));
299 } 299 }
300 300
301 // Extract underline information from an attributed string. Mostly copied from 301 // Extract underline information from an attributed string. Mostly copied from
302 // third_party/WebKit/Source/WebKit/mac/WebView/WebHTMLView.mm 302 // third_party/WebKit/Source/WebKit/mac/WebView/WebHTMLView.mm
303 void ExtractUnderlines( 303 void ExtractUnderlines(
304 NSAttributedString* string, 304 NSAttributedString* string,
305 std::vector<WebKit::WebCompositionUnderline>* underlines) { 305 std::vector<blink::WebCompositionUnderline>* underlines) {
306 int length = [[string string] length]; 306 int length = [[string string] length];
307 int i = 0; 307 int i = 0;
308 while (i < length) { 308 while (i < length) {
309 NSRange range; 309 NSRange range;
310 NSDictionary* attrs = [string attributesAtIndex:i 310 NSDictionary* attrs = [string attributesAtIndex:i
311 longestEffectiveRange:&range 311 longestEffectiveRange:&range
312 inRange:NSMakeRange(i, length - i)]; 312 inRange:NSMakeRange(i, length - i)];
313 if (NSNumber *style = [attrs objectForKey:NSUnderlineStyleAttributeName]) { 313 if (NSNumber *style = [attrs objectForKey:NSUnderlineStyleAttributeName]) {
314 WebKit::WebColor color = SK_ColorBLACK; 314 blink::WebColor color = SK_ColorBLACK;
315 if (NSColor *colorAttr = 315 if (NSColor *colorAttr =
316 [attrs objectForKey:NSUnderlineColorAttributeName]) { 316 [attrs objectForKey:NSUnderlineColorAttributeName]) {
317 color = WebColorFromNSColor( 317 color = WebColorFromNSColor(
318 [colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]); 318 [colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]);
319 } 319 }
320 underlines->push_back(WebKit::WebCompositionUnderline( 320 underlines->push_back(blink::WebCompositionUnderline(
321 range.location, NSMaxRange(range), color, [style intValue] > 1)); 321 range.location, NSMaxRange(range), color, [style intValue] > 1));
322 } 322 }
323 i = range.location + range.length; 323 i = range.location + range.length;
324 } 324 }
325 } 325 }
326 326
327 // EnablePasswordInput() and DisablePasswordInput() are copied from 327 // EnablePasswordInput() and DisablePasswordInput() are copied from
328 // enableSecureTextInput() and disableSecureTextInput() functions in 328 // enableSecureTextInput() and disableSecureTextInput() functions in
329 // third_party/WebKit/WebCore/platform/SecureTextInput.cpp 329 // third_party/WebKit/WebCore/platform/SecureTextInput.cpp
330 // But we don't call EnableSecureEventInput() and DisableSecureEventInput() 330 // But we don't call EnableSecureEventInput() and DisableSecureEventInput()
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 // case from extension popup windows. 367 // case from extension popup windows.
368 NSWindow* ancestor_window = [enclosing_window parentWindow]; 368 NSWindow* ancestor_window = [enclosing_window parentWindow];
369 if (ancestor_window && (NSWidth([enclosing_window frame]) == 369 if (ancestor_window && (NSWidth([enclosing_window frame]) ==
370 NSWidth([ancestor_window frame]))) { 370 NSWidth([ancestor_window frame]))) {
371 enclosing_window = ancestor_window; 371 enclosing_window = ancestor_window;
372 } 372 }
373 373
374 return enclosing_window; 374 return enclosing_window;
375 } 375 }
376 376
377 WebKit::WebScreenInfo GetWebScreenInfo(NSView* view) { 377 blink::WebScreenInfo GetWebScreenInfo(NSView* view) {
378 gfx::Display display = 378 gfx::Display display =
379 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(view); 379 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(view);
380 380
381 NSScreen* screen = [NSScreen deepestScreen]; 381 NSScreen* screen = [NSScreen deepestScreen];
382 382
383 WebKit::WebScreenInfo results; 383 blink::WebScreenInfo results;
384 384
385 results.deviceScaleFactor = static_cast<int>(display.device_scale_factor()); 385 results.deviceScaleFactor = static_cast<int>(display.device_scale_factor());
386 results.depth = NSBitsPerPixelFromDepth([screen depth]); 386 results.depth = NSBitsPerPixelFromDepth([screen depth]);
387 results.depthPerComponent = NSBitsPerSampleFromDepth([screen depth]); 387 results.depthPerComponent = NSBitsPerSampleFromDepth([screen depth]);
388 results.isMonochrome = 388 results.isMonochrome =
389 [[screen colorSpace] colorSpaceModel] == NSGrayColorSpaceModel; 389 [[screen colorSpace] colorSpaceModel] == NSGrayColorSpaceModel;
390 results.rect = display.bounds(); 390 results.rect = display.bounds();
391 results.availableRect = display.work_area(); 391 results.availableRect = display.work_area();
392 return results; 392 return results;
393 } 393 }
394 394
395 } // namespace 395 } // namespace
396 396
397 namespace content { 397 namespace content {
398 398
399 /////////////////////////////////////////////////////////////////////////////// 399 ///////////////////////////////////////////////////////////////////////////////
400 // RenderWidgetHostView, public: 400 // RenderWidgetHostView, public:
401 401
402 // static 402 // static
403 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 403 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
404 RenderWidgetHost* widget) { 404 RenderWidgetHost* widget) {
405 return new RenderWidgetHostViewMac(widget); 405 return new RenderWidgetHostViewMac(widget);
406 } 406 }
407 407
408 // static 408 // static
409 void RenderWidgetHostViewPort::GetDefaultScreenInfo( 409 void RenderWidgetHostViewPort::GetDefaultScreenInfo(
410 WebKit::WebScreenInfo* results) { 410 blink::WebScreenInfo* results) {
411 *results = GetWebScreenInfo(NULL); 411 *results = GetWebScreenInfo(NULL);
412 } 412 }
413 413
414 /////////////////////////////////////////////////////////////////////////////// 414 ///////////////////////////////////////////////////////////////////////////////
415 // RenderWidgetHostViewMac, public: 415 // RenderWidgetHostViewMac, public:
416 416
417 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) 417 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget)
418 : render_widget_host_(RenderWidgetHostImpl::From(widget)), 418 : render_widget_host_(RenderWidgetHostImpl::From(widget)),
419 about_to_validate_and_paint_(false), 419 about_to_validate_and_paint_(false),
420 call_set_needs_display_in_rect_pending_(false), 420 call_set_needs_display_in_rect_pending_(false),
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 return handled; 619 return handled;
620 } 620 }
621 621
622 void RenderWidgetHostViewMac::InitAsChild( 622 void RenderWidgetHostViewMac::InitAsChild(
623 gfx::NativeView parent_view) { 623 gfx::NativeView parent_view) {
624 } 624 }
625 625
626 void RenderWidgetHostViewMac::InitAsPopup( 626 void RenderWidgetHostViewMac::InitAsPopup(
627 RenderWidgetHostView* parent_host_view, 627 RenderWidgetHostView* parent_host_view,
628 const gfx::Rect& pos) { 628 const gfx::Rect& pos) {
629 bool activatable = popup_type_ == WebKit::WebPopupTypeNone; 629 bool activatable = popup_type_ == blink::WebPopupTypeNone;
630 [cocoa_view_ setCloseOnDeactivate:YES]; 630 [cocoa_view_ setCloseOnDeactivate:YES];
631 [cocoa_view_ setCanBeKeyView:activatable ? YES : NO]; 631 [cocoa_view_ setCanBeKeyView:activatable ? YES : NO];
632 632
633 NSPoint origin_global = NSPointFromCGPoint(pos.origin().ToCGPoint()); 633 NSPoint origin_global = NSPointFromCGPoint(pos.origin().ToCGPoint());
634 if ([[NSScreen screens] count] > 0) { 634 if ([[NSScreen screens] count] > 0) {
635 origin_global.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height - 635 origin_global.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height -
636 pos.height() - origin_global.y; 636 pos.height() - origin_global.y;
637 } 637 }
638 638
639 popup_window_.reset([[RenderWidgetPopupWindow alloc] 639 popup_window_.reset([[RenderWidgetPopupWindow alloc]
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 clickCount:0 1132 clickCount:0
1133 pressure:0]; 1133 pressure:0];
1134 WebMouseEvent web_event = 1134 WebMouseEvent web_event =
1135 WebInputEventFactory::mouseEvent(event, cocoa_view_); 1135 WebInputEventFactory::mouseEvent(event, cocoa_view_);
1136 if (showing) 1136 if (showing)
1137 web_event.type = WebInputEvent::MouseLeave; 1137 web_event.type = WebInputEvent::MouseLeave;
1138 ForwardMouseEvent(web_event); 1138 ForwardMouseEvent(web_event);
1139 } 1139 }
1140 1140
1141 bool RenderWidgetHostViewMac::IsPopup() const { 1141 bool RenderWidgetHostViewMac::IsPopup() const {
1142 return popup_type_ != WebKit::WebPopupTypeNone; 1142 return popup_type_ != blink::WebPopupTypeNone;
1143 } 1143 }
1144 1144
1145 BackingStore* RenderWidgetHostViewMac::AllocBackingStore( 1145 BackingStore* RenderWidgetHostViewMac::AllocBackingStore(
1146 const gfx::Size& size) { 1146 const gfx::Size& size) {
1147 float scale = ScaleFactor(cocoa_view_); 1147 float scale = ScaleFactor(cocoa_view_);
1148 return new BackingStoreMac(render_widget_host_, size, scale); 1148 return new BackingStoreMac(render_widget_host_, size, scale);
1149 } 1149 }
1150 1150
1151 void RenderWidgetHostViewMac::CopyFromCompositingSurface( 1151 void RenderWidgetHostViewMac::CopyFromCompositingSurface(
1152 const gfx::Rect& src_subrect, 1152 const gfx::Rect& src_subrect,
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 } 1696 }
1697 software_frame_manager_->SwapToNewFrameComplete( 1697 software_frame_manager_->SwapToNewFrameComplete(
1698 !render_widget_host_->is_hidden()); 1698 !render_widget_host_->is_hidden());
1699 1699
1700 [cocoa_view_ setNeedsDisplay:YES]; 1700 [cocoa_view_ setNeedsDisplay:YES];
1701 } 1701 }
1702 1702
1703 void RenderWidgetHostViewMac::OnAcceleratedCompositingStateChange() { 1703 void RenderWidgetHostViewMac::OnAcceleratedCompositingStateChange() {
1704 } 1704 }
1705 1705
1706 void RenderWidgetHostViewMac::GetScreenInfo(WebKit::WebScreenInfo* results) { 1706 void RenderWidgetHostViewMac::GetScreenInfo(blink::WebScreenInfo* results) {
1707 *results = GetWebScreenInfo(GetNativeView()); 1707 *results = GetWebScreenInfo(GetNativeView());
1708 } 1708 }
1709 1709
1710 gfx::Rect RenderWidgetHostViewMac::GetBoundsInRootWindow() { 1710 gfx::Rect RenderWidgetHostViewMac::GetBoundsInRootWindow() {
1711 // TODO(shess): In case of !window, the view has been removed from 1711 // TODO(shess): In case of !window, the view has been removed from
1712 // the view hierarchy because the tab isn't main. Could retrieve 1712 // the view hierarchy because the tab isn't main. Could retrieve
1713 // the information from the main tab for our window. 1713 // the information from the main tab for our window.
1714 NSWindow* enclosing_window = ApparentWindowForView(cocoa_view_); 1714 NSWindow* enclosing_window = ApparentWindowForView(cocoa_view_);
1715 if (!enclosing_window) 1715 if (!enclosing_window)
1716 return gfx::Rect(); 1716 return gfx::Rect();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 1759
1760 // Unlock position of mouse cursor and unhide it. 1760 // Unlock position of mouse cursor and unhide it.
1761 CGAssociateMouseAndMouseCursorPosition(YES); 1761 CGAssociateMouseAndMouseCursorPosition(YES);
1762 [NSCursor unhide]; 1762 [NSCursor unhide];
1763 1763
1764 if (render_widget_host_) 1764 if (render_widget_host_)
1765 render_widget_host_->LostMouseLock(); 1765 render_widget_host_->LostMouseLock();
1766 } 1766 }
1767 1767
1768 void RenderWidgetHostViewMac::UnhandledWheelEvent( 1768 void RenderWidgetHostViewMac::UnhandledWheelEvent(
1769 const WebKit::WebMouseWheelEvent& event) { 1769 const blink::WebMouseWheelEvent& event) {
1770 // Only record a wheel event as unhandled if JavaScript handlers got a chance 1770 // Only record a wheel event as unhandled if JavaScript handlers got a chance
1771 // to see it (no-op wheel events are ignored by the event dispatcher) 1771 // to see it (no-op wheel events are ignored by the event dispatcher)
1772 if (event.deltaX || event.deltaY) 1772 if (event.deltaX || event.deltaY)
1773 [cocoa_view_ gotUnhandledWheelEvent]; 1773 [cocoa_view_ gotUnhandledWheelEvent];
1774 } 1774 }
1775 1775
1776 bool RenderWidgetHostViewMac::Send(IPC::Message* message) { 1776 bool RenderWidgetHostViewMac::Send(IPC::Message* message) {
1777 if (render_widget_host_) 1777 if (render_widget_host_)
1778 return render_widget_host_->Send(message); 1778 return render_widget_host_->Send(message);
1779 delete message; 1779 delete message;
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
2406 // edit commands, then we need to send the real key event and corresponding 2406 // edit commands, then we need to send the real key event and corresponding
2407 // edit commands here. This usually occurs when the input method wants to 2407 // edit commands here. This usually occurs when the input method wants to
2408 // finish current composition session but still wants the application to 2408 // finish current composition session but still wants the application to
2409 // handle the key event. See http://crbug.com/48161 for reference. 2409 // handle the key event. See http://crbug.com/48161 for reference.
2410 if (delayEventUntilAfterImeCompostion) { 2410 if (delayEventUntilAfterImeCompostion) {
2411 // If |delayEventUntilAfterImeCompostion| is YES, then a fake key down event 2411 // If |delayEventUntilAfterImeCompostion| is YES, then a fake key down event
2412 // with windowsKeyCode == 0xE5 has already been sent to webkit. 2412 // with windowsKeyCode == 0xE5 has already been sent to webkit.
2413 // So before sending the real key down event, we need to send a fake key up 2413 // So before sending the real key down event, we need to send a fake key up
2414 // event to balance it. 2414 // event to balance it.
2415 NativeWebKeyboardEvent fakeEvent = event; 2415 NativeWebKeyboardEvent fakeEvent = event;
2416 fakeEvent.type = WebKit::WebInputEvent::KeyUp; 2416 fakeEvent.type = blink::WebInputEvent::KeyUp;
2417 fakeEvent.skip_in_browser = true; 2417 fakeEvent.skip_in_browser = true;
2418 widgetHost->ForwardKeyboardEvent(fakeEvent); 2418 widgetHost->ForwardKeyboardEvent(fakeEvent);
2419 // Not checking |renderWidgetHostView_->render_widget_host_| here because 2419 // Not checking |renderWidgetHostView_->render_widget_host_| here because
2420 // a key event with |skip_in_browser| == true won't be handled by browser, 2420 // a key event with |skip_in_browser| == true won't be handled by browser,
2421 // thus it won't destroy the widget. 2421 // thus it won't destroy the widget.
2422 2422
2423 if (!editCommands_.empty()) { 2423 if (!editCommands_.empty()) {
2424 widgetHost->Send(new InputMsg_SetEditCommandsForNextKeyEvent( 2424 widgetHost->Send(new InputMsg_SetEditCommandsForNextKeyEvent(
2425 widgetHost->GetRoutingID(), editCommands_)); 2425 widgetHost->GetRoutingID(), editCommands_));
2426 } 2426 }
2427 widgetHost->ForwardKeyboardEvent(event); 2427 widgetHost->ForwardKeyboardEvent(event);
2428 2428
2429 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the 2429 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the
2430 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will 2430 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will
2431 // be set to NULL. So we check it here and return immediately if it's NULL. 2431 // be set to NULL. So we check it here and return immediately if it's NULL.
2432 if (!renderWidgetHostView_->render_widget_host_) 2432 if (!renderWidgetHostView_->render_widget_host_)
2433 return; 2433 return;
2434 } 2434 }
2435 2435
2436 const NSUInteger kCtrlCmdKeyMask = NSControlKeyMask | NSCommandKeyMask; 2436 const NSUInteger kCtrlCmdKeyMask = NSControlKeyMask | NSCommandKeyMask;
2437 // Only send a corresponding key press event if there is no marked text. 2437 // Only send a corresponding key press event if there is no marked text.
2438 if (!hasMarkedText_) { 2438 if (!hasMarkedText_) {
2439 if (!textInserted && textToBeInserted_.length() == 1) { 2439 if (!textInserted && textToBeInserted_.length() == 1) {
2440 // If a single character was inserted, then we just send it as a keypress 2440 // If a single character was inserted, then we just send it as a keypress
2441 // event. 2441 // event.
2442 event.type = WebKit::WebInputEvent::Char; 2442 event.type = blink::WebInputEvent::Char;
2443 event.text[0] = textToBeInserted_[0]; 2443 event.text[0] = textToBeInserted_[0];
2444 event.text[1] = 0; 2444 event.text[1] = 0;
2445 event.skip_in_browser = true; 2445 event.skip_in_browser = true;
2446 widgetHost->ForwardKeyboardEvent(event); 2446 widgetHost->ForwardKeyboardEvent(event);
2447 } else if ((!textInserted || delayEventUntilAfterImeCompostion) && 2447 } else if ((!textInserted || delayEventUntilAfterImeCompostion) &&
2448 [[theEvent characters] length] > 0 && 2448 [[theEvent characters] length] > 0 &&
2449 (([theEvent modifierFlags] & kCtrlCmdKeyMask) || 2449 (([theEvent modifierFlags] & kCtrlCmdKeyMask) ||
2450 (hasEditCommands_ && editCommands_.empty()))) { 2450 (hasEditCommands_ && editCommands_.empty()))) {
2451 // We don't get insertText: calls if ctrl or cmd is down, or the key event 2451 // We don't get insertText: calls if ctrl or cmd is down, or the key event
2452 // generates an insert command. So synthesize a keypress event for these 2452 // generates an insert command. So synthesize a keypress event for these
2453 // cases, unless the key event generated any other command. 2453 // cases, unless the key event generated any other command.
2454 event.type = WebKit::WebInputEvent::Char; 2454 event.type = blink::WebInputEvent::Char;
2455 event.skip_in_browser = true; 2455 event.skip_in_browser = true;
2456 widgetHost->ForwardKeyboardEvent(event); 2456 widgetHost->ForwardKeyboardEvent(event);
2457 } 2457 }
2458 } 2458 }
2459 2459
2460 // Possibly autohide the cursor. 2460 // Possibly autohide the cursor.
2461 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent]) 2461 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent])
2462 [NSCursor setHiddenUntilMouseMoves:YES]; 2462 [NSCursor setHiddenUntilMouseMoves:YES];
2463 } 2463 }
2464 2464
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
3531 selectedRange_ = newSelRange; 3531 selectedRange_ = newSelRange;
3532 markedText_ = base::SysNSStringToUTF16(im_text); 3532 markedText_ = base::SysNSStringToUTF16(im_text);
3533 hasMarkedText_ = (length > 0); 3533 hasMarkedText_ = (length > 0);
3534 3534
3535 underlines_.clear(); 3535 underlines_.clear();
3536 if (isAttributedString) { 3536 if (isAttributedString) {
3537 ExtractUnderlines(string, &underlines_); 3537 ExtractUnderlines(string, &underlines_);
3538 } else { 3538 } else {
3539 // Use a thin black underline by default. 3539 // Use a thin black underline by default.
3540 underlines_.push_back( 3540 underlines_.push_back(
3541 WebKit::WebCompositionUnderline(0, length, SK_ColorBLACK, false)); 3541 blink::WebCompositionUnderline(0, length, SK_ColorBLACK, false));
3542 } 3542 }
3543 3543
3544 // If we are handling a key down event, then SetComposition() will be 3544 // If we are handling a key down event, then SetComposition() will be
3545 // called in keyEvent: method. 3545 // called in keyEvent: method.
3546 // Input methods of Mac use setMarkedText calls with an empty text to cancel 3546 // Input methods of Mac use setMarkedText calls with an empty text to cancel
3547 // an ongoing composition. So, we should check whether or not the given text 3547 // an ongoing composition. So, we should check whether or not the given text
3548 // is empty to update the input method state. (Our input method backend can 3548 // is empty to update the input method state. (Our input method backend can
3549 // automatically cancels an ongoing composition when we send an empty text. 3549 // automatically cancels an ongoing composition when we send an empty text.
3550 // So, it is OK to send an empty text to the renderer.) 3550 // So, it is OK to send an empty text to the renderer.)
3551 if (!handlingKeyDown_) { 3551 if (!handlingKeyDown_) {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
3929 return YES; 3929 return YES;
3930 } 3930 }
3931 3931
3932 - (BOOL)isOpaque { 3932 - (BOOL)isOpaque {
3933 if (renderWidgetHostView_->use_core_animation_) 3933 if (renderWidgetHostView_->use_core_animation_)
3934 return YES; 3934 return YES;
3935 return [super isOpaque]; 3935 return [super isOpaque];
3936 } 3936 }
3937 3937
3938 @end 3938 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698