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

Side by Side Diff: webkit/glue/plugins/webplugin_delegate_impl_mac.mm

Issue 3072026: Remove the coordinate hack for zoomed plugin pages on the Mac. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #import <QuartzCore/QuartzCore.h> 6 #import <QuartzCore/QuartzCore.h>
7 7
8 #include "webkit/glue/plugins/webplugin_delegate_impl.h" 8 #include "webkit/glue/plugins/webplugin_delegate_impl.h"
9 9
10 #include <string> 10 #include <string>
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 return false; 490 return false;
491 #ifndef NP_NO_CARBON 491 #ifndef NP_NO_CARBON
492 if (instance()->event_model() == NPEventModelCarbon && 492 if (instance()->event_model() == NPEventModelCarbon &&
493 !np_cg_context_.context) { 493 !np_cg_context_.context) {
494 return false; 494 return false;
495 } 495 }
496 #endif 496 #endif
497 497
498 if (WebInputEvent::isMouseEventType(event.type) || 498 if (WebInputEvent::isMouseEventType(event.type) ||
499 event.type == WebInputEvent::MouseWheel) { 499 event.type == WebInputEvent::MouseWheel) {
500 // Ideally we would compute the content origin from the web event using the
501 // code below as a safety net for missed content area location changes.
502 // Because of <http://crbug.com/9996>, however, only globalX/Y are right if
503 // the page has been zoomed, so for now the coordinates we get aren't
504 // trustworthy enough to use for corrections.
505 #if PLUGIN_SCALING_FIXED
506 // Check our plugin location before we send the event to the plugin, just 500 // Check our plugin location before we send the event to the plugin, just
507 // in case we somehow missed a plugin frame change. 501 // in case we somehow missed a plugin frame change.
508 const WebMouseEvent* mouse_event = 502 const WebMouseEvent* mouse_event =
509 static_cast<const WebMouseEvent*>(&event); 503 static_cast<const WebMouseEvent*>(&event);
510 gfx::Point content_origin( 504 gfx::Point content_origin(
511 mouse_event->globalX - mouse_event->x - window_rect_.x(), 505 mouse_event->globalX - mouse_event->x - window_rect_.x(),
512 mouse_event->globalY - mouse_event->y - window_rect_.y()); 506 mouse_event->globalY - mouse_event->y - window_rect_.y());
513 if (content_origin.x() != content_area_origin_.x() || 507 if (content_origin.x() != content_area_origin_.x() ||
514 content_origin.y() != content_area_origin_.y()) { 508 content_origin.y() != content_area_origin_.y()) {
515 DLOG(WARNING) << "Stale plugin content area location: " 509 DLOG(WARNING) << "Stale plugin content area location: "
516 << content_area_origin_ << " instead of " 510 << content_area_origin_ << " instead of "
517 << content_origin; 511 << content_origin;
518 SetContentAreaOrigin(content_origin); 512 SetContentAreaOrigin(content_origin);
519 } 513 }
520 #endif
521 514
522 current_windowless_cursor_.GetCursorInfo(cursor_info); 515 current_windowless_cursor_.GetCursorInfo(cursor_info);
523 } 516 }
524 517
525 #ifndef NP_NO_CARBON 518 #ifndef NP_NO_CARBON
526 if (instance()->event_model() == NPEventModelCarbon) { 519 if (instance()->event_model() == NPEventModelCarbon) {
527 #ifndef NP_NO_QUICKDRAW 520 #ifndef NP_NO_QUICKDRAW
528 if (instance()->drawing_model() == NPDrawingModelQuickDraw) { 521 if (instance()->drawing_model() == NPDrawingModelQuickDraw) {
529 if (quirks_ & PLUGIN_QUIRK_ALLOW_FASTER_QUICKDRAW_PATH) { 522 if (quirks_ & PLUGIN_QUIRK_ALLOW_FASTER_QUICKDRAW_PATH) {
530 // Mouse event handling doesn't work correctly in the fast path mode, 523 // Mouse event handling doesn't work correctly in the fast path mode,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 // When an external drag ends, we need to synthesize a MouseEntered. 579 // When an external drag ends, we need to synthesize a MouseEntered.
587 NPCocoaEvent enter_event = *(static_cast<NPCocoaEvent*>(plugin_event)); 580 NPCocoaEvent enter_event = *(static_cast<NPCocoaEvent*>(plugin_event));
588 enter_event.type = NPCocoaEventMouseEntered; 581 enter_event.type = NPCocoaEventMouseEntered;
589 NPAPI::ScopedCurrentPluginEvent event_scope(instance(), &enter_event); 582 NPAPI::ScopedCurrentPluginEvent event_scope(instance(), &enter_event);
590 instance()->NPP_HandleEvent(&enter_event); 583 instance()->NPP_HandleEvent(&enter_event);
591 } 584 }
592 return false; 585 return false;
593 } 586 }
594 } 587 }
595 588
596 #ifndef PLUGIN_SCALING_FIXED
597 // Because of <http://crbug.com/9996>, the non-global coordinates we get for
598 // zoomed pages are wrong. As a temporary hack around that bug, override the
599 // coordinates we are given with ones computed based on our knowledge of where
600 // the plugin is on screen. We only need to do this for Cocoa, since Carbon
601 // only uses the global coordinates.
602 if (instance()->event_model() == NPEventModelCocoa &&
603 (WebInputEvent::isMouseEventType(event.type) ||
604 event.type == WebInputEvent::MouseWheel)) {
605 const WebMouseEvent* mouse_event =
606 static_cast<const WebMouseEvent*>(&event);
607 NPCocoaEvent* cocoa_event = static_cast<NPCocoaEvent*>(plugin_event);
608 cocoa_event->data.mouse.pluginX =
609 mouse_event->globalX - content_area_origin_.x() - window_rect_.x();
610 cocoa_event->data.mouse.pluginY =
611 mouse_event->globalY - content_area_origin_.y() - window_rect_.y();
612 }
613 #endif
614
615 // Send the plugin the event. 589 // Send the plugin the event.
616 scoped_ptr<NPAPI::ScopedCurrentPluginEvent> event_scope(NULL); 590 scoped_ptr<NPAPI::ScopedCurrentPluginEvent> event_scope(NULL);
617 if (instance()->event_model() == NPEventModelCocoa) { 591 if (instance()->event_model() == NPEventModelCocoa) {
618 event_scope.reset(new NPAPI::ScopedCurrentPluginEvent( 592 event_scope.reset(new NPAPI::ScopedCurrentPluginEvent(
619 instance(), static_cast<NPCocoaEvent*>(plugin_event))); 593 instance(), static_cast<NPCocoaEvent*>(plugin_event)));
620 } 594 }
621 bool handled = instance()->NPP_HandleEvent(plugin_event) != 0; 595 bool handled = instance()->NPP_HandleEvent(plugin_event) != 0;
622 596
623 // Plugins don't give accurate information about whether or not they handled 597 // Plugins don't give accurate information about whether or not they handled
624 // events, so browsers on the Mac ignore the return value. 598 // events, so browsers on the Mac ignore the return value.
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 return; 1125 return;
1152 } 1126 }
1153 1127
1154 qd_manager_->SetFastPathEnabled(enabled); 1128 qd_manager_->SetFastPathEnabled(enabled);
1155 qd_port_.port = qd_manager_->port(); 1129 qd_port_.port = qd_manager_->port();
1156 WindowlessSetWindow(); 1130 WindowlessSetWindow();
1157 // Send a paint event so that the new buffer gets updated immediately. 1131 // Send a paint event so that the new buffer gets updated immediately.
1158 WindowlessPaint(buffer_context_, clip_rect_); 1132 WindowlessPaint(buffer_context_, clip_rect_);
1159 } 1133 }
1160 #endif // !NP_NO_QUICKDRAW 1134 #endif // !NP_NO_QUICKDRAW
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698