| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 343 |
| 344 if (event->type() == eventNames().mousedownEvent) { | 344 if (event->type() == eventNames().mousedownEvent) { |
| 345 // Ensure that the frame containing the plugin has focus. | 345 // Ensure that the frame containing the plugin has focus. |
| 346 Frame* containingFrame = parentView->frame(); | 346 Frame* containingFrame = parentView->frame(); |
| 347 if (Page* currentPage = containingFrame->page()) | 347 if (Page* currentPage = containingFrame->page()) |
| 348 currentPage->focusController()->setFocusedFrame(containingFrame); | 348 currentPage->focusController()->setFocusedFrame(containingFrame); |
| 349 // Give focus to our containing HTMLPluginElement. | 349 // Give focus to our containing HTMLPluginElement. |
| 350 containingFrame->document()->setFocusedNode(m_element); | 350 containingFrame->document()->setFocusedNode(m_element); |
| 351 } | 351 } |
| 352 | 352 |
| 353 WebCursorInfo cursorInfo; |
| 354 bool handled = m_webPlugin->handleInputEvent(webEvent, cursorInfo); |
| 355 #if !PLATFORM(DARWIN) |
| 353 // TODO(pkasting): http://b/1119691 This conditional seems exactly | 356 // TODO(pkasting): http://b/1119691 This conditional seems exactly |
| 354 // backwards, but it matches Safari's code, and if I reverse it, giving | 357 // backwards, but if I reverse it, giving focus to a transparent |
| 355 // focus to a transparent (windowless) plugin fails. | 358 // (windowless) plugin fails. |
| 356 WebCursorInfo cursorInfo; | 359 handled = !handled; |
| 357 if (!m_webPlugin->handleInputEvent(webEvent, cursorInfo)) | 360 // TODO(awalker): oddly, the above is not true in Mac builds. Looking |
| 361 // at Apple's corresponding code for Mac and Windows (PluginViewMac and |
| 362 // PluginViewWin), setDefaultHandled() gets called when handleInputEvent() |
| 363 // returns true, which then indicates to WebCore that the plugin wants to |
| 364 // swallow the event--which is what we want. Calling setDefaultHandled() |
| 365 // fixes several Mac Chromium bugs, but does indeed prevent windowless plugins |
| 366 // from getting focus in Windows builds, as pkasting notes above. So for |
| 367 // now, we only do so in Mac builds. |
| 368 #endif |
| 369 if (handled) |
| 358 event->setDefaultHandled(); | 370 event->setDefaultHandled(); |
| 359 | 371 |
| 360 // A windowless plugin can change the cursor in response to a mouse move | 372 // A windowless plugin can change the cursor in response to a mouse move |
| 361 // event. We need to reflect the changed cursor in the frame view as the | 373 // event. We need to reflect the changed cursor in the frame view as the |
| 362 // mouse is moved in the boundaries of the windowless plugin. | 374 // mouse is moved in the boundaries of the windowless plugin. |
| 363 webKitClient()->setCursorForPlugin(cursorInfo, parentView->frame()); | 375 webKitClient()->setCursorForPlugin(cursorInfo, parentView->frame()); |
| 364 } | 376 } |
| 365 | 377 |
| 366 void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event) | 378 void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event) |
| 367 { | 379 { |
| 368 WebKeyboardEventBuilder webEvent(*event); | 380 WebKeyboardEventBuilder webEvent(*event); |
| 369 if (webEvent.type == WebInputEvent::Undefined) | 381 if (webEvent.type == WebInputEvent::Undefined) |
| 370 return; | 382 return; |
| 371 | 383 |
| 384 WebCursorInfo cursor_info; |
| 385 bool handled = m_webPlugin->handleInputEvent(webEvent, cursor_info); |
| 386 #if !PLATFORM(DARWIN) |
| 372 // TODO(pkasting): http://b/1119691 See above. | 387 // TODO(pkasting): http://b/1119691 See above. |
| 373 WebCursorInfo cursor_info; | 388 handled = !handled; |
| 374 if (!m_webPlugin->handleInputEvent(webEvent, cursor_info)) | 389 #endif |
| 390 if (handled) |
| 375 event->setDefaultHandled(); | 391 event->setDefaultHandled(); |
| 376 } | 392 } |
| 377 | 393 |
| 378 void WebPluginContainerImpl::calculateGeometry(const IntRect& frameRect, | 394 void WebPluginContainerImpl::calculateGeometry(const IntRect& frameRect, |
| 379 IntRect& windowRect, | 395 IntRect& windowRect, |
| 380 IntRect& clipRect, | 396 IntRect& clipRect, |
| 381 Vector<IntRect>& cutOutRects) | 397 Vector<IntRect>& cutOutRects) |
| 382 { | 398 { |
| 383 windowRect = IntRect( | 399 windowRect = IntRect( |
| 384 parent()->contentsToWindow(frameRect.location()), frameRect.size()); | 400 parent()->contentsToWindow(frameRect.location()), frameRect.size()); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 roundedIntPoint(iframeRenderer->localToAbsolute()); | 541 roundedIntPoint(iframeRenderer->localToAbsolute()); |
| 526 RenderBox* rbox = toRenderBox(iframeRenderer); | 542 RenderBox* rbox = toRenderBox(iframeRenderer); |
| 527 IntSize size(rbox->width(), rbox->height()); | 543 IntSize size(rbox->width(), rbox->height()); |
| 528 cutOutRects.append(IntRect(point, size)); | 544 cutOutRects.append(IntRect(point, size)); |
| 529 } | 545 } |
| 530 } | 546 } |
| 531 } | 547 } |
| 532 } | 548 } |
| 533 | 549 |
| 534 } // namespace WebKit | 550 } // namespace WebKit |
| OLD | NEW |