| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "webkit/glue/plugins/plugin_host.h" | 7 #include "webkit/glue/plugins/plugin_host.h" |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 // this method, the plug-in recieves a paint message asynchronously. | 593 // this method, the plug-in recieves a paint message asynchronously. |
| 594 | 594 |
| 595 // The browser redraws invalid areas of the document and any windowless | 595 // The browser redraws invalid areas of the document and any windowless |
| 596 // plug-ins at regularly timed intervals. To force a paint message, the | 596 // plug-ins at regularly timed intervals. To force a paint message, the |
| 597 // plug-in can call NPN_ForceRedraw after calling this method. | 597 // plug-in can call NPN_ForceRedraw after calling this method. |
| 598 | 598 |
| 599 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 599 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
| 600 DCHECK(plugin.get() != NULL); | 600 DCHECK(plugin.get() != NULL); |
| 601 if (plugin.get() && plugin->webplugin()) { | 601 if (plugin.get() && plugin->webplugin()) { |
| 602 if (invalidRect) { | 602 if (invalidRect) { |
| 603 #if defined(OS_WIN) |
| 603 if (!plugin->windowless()) { | 604 if (!plugin->windowless()) { |
| 604 #if defined(OS_WIN) | |
| 605 RECT rect = {0}; | 605 RECT rect = {0}; |
| 606 rect.left = invalidRect->left; | 606 rect.left = invalidRect->left; |
| 607 rect.right = invalidRect->right; | 607 rect.right = invalidRect->right; |
| 608 rect.top = invalidRect->top; | 608 rect.top = invalidRect->top; |
| 609 rect.bottom = invalidRect->bottom; | 609 rect.bottom = invalidRect->bottom; |
| 610 ::InvalidateRect(plugin->window_handle(), &rect, FALSE); | 610 ::InvalidateRect(plugin->window_handle(), &rect, FALSE); |
| 611 #elif defined(OS_MACOSX) | |
| 612 NOTIMPLEMENTED(); | |
| 613 #else | |
| 614 NOTIMPLEMENTED(); | |
| 615 #endif | |
| 616 return; | 611 return; |
| 617 } | 612 } |
| 618 | 613 #elif defined(OS_LINUX) |
| 614 NOTIMPLEMENTED(); |
| 615 #endif |
| 619 gfx::Rect rect(invalidRect->left, | 616 gfx::Rect rect(invalidRect->left, |
| 620 invalidRect->top, | 617 invalidRect->top, |
| 621 invalidRect->right - invalidRect->left, | 618 invalidRect->right - invalidRect->left, |
| 622 invalidRect->bottom - invalidRect->top); | 619 invalidRect->bottom - invalidRect->top); |
| 623 plugin->webplugin()->InvalidateRect(rect); | 620 plugin->webplugin()->InvalidateRect(rect); |
| 624 } else { | 621 } else { |
| 625 plugin->webplugin()->Invalidate(); | 622 plugin->webplugin()->Invalidate(); |
| 626 } | 623 } |
| 627 } | 624 } |
| 628 } | 625 } |
| 629 | 626 |
| 630 void NPN_InvalidateRegion(NPP id, NPRegion invalidRegion) { | 627 void NPN_InvalidateRegion(NPP id, NPRegion invalidRegion) { |
| 631 // Invalidates a specified drawing region prior to repainting | 628 // Invalidates a specified drawing region prior to repainting |
| 632 // or refreshing a window-less plugin. | 629 // or refreshing a window-less plugin. |
| 633 // | 630 // |
| 634 // Similar to NPN_InvalidateRect. | 631 // Similar to NPN_InvalidateRect. |
| 635 | 632 |
| 636 // TODO: implement me | 633 // TODO: this is overkill--add platform-specific region handling (at the |
| 637 DLOG(INFO) << "NPN_InvalidateRegion is not implemented yet."; | 634 // very least, fetch the region's bounding box and pass it to InvalidateRect). |
| 635 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
| 636 DCHECK(plugin.get() != NULL); |
| 637 if (plugin.get() && plugin->webplugin()) { |
| 638 plugin->webplugin()->Invalidate(); |
| 639 } |
| 638 } | 640 } |
| 639 | 641 |
| 640 void NPN_ForceRedraw(NPP id) { | 642 void NPN_ForceRedraw(NPP id) { |
| 641 // Forces repaint for a windowless plug-in. | 643 // Forces repaint for a windowless plug-in. |
| 642 // | 644 // |
| 643 // Once a value has been invalidated with NPN_InvalidateRect/ | 645 // Once a value has been invalidated with NPN_InvalidateRect/ |
| 644 // NPN_InvalidateRegion, ForceRedraw can be used to force a paint message. | 646 // NPN_InvalidateRegion, ForceRedraw can be used to force a paint message. |
| 645 // | 647 // |
| 646 // The plugin will receive a WM_PAINT message, the lParam of the WM_PAINT | 648 // The plugin will receive a WM_PAINT message, the lParam of the WM_PAINT |
| 647 // message holds a pointer to an NPRect that is the bounding box of the | 649 // message holds a pointer to an NPRect that is the bounding box of the |
| 648 // update area. | 650 // update area. |
| 649 // Since the plugin and browser share the same HDC, before drawing, the | 651 // Since the plugin and browser share the same HDC, before drawing, the |
| 650 // plugin is responsible fro saving the current HDC settings, setting up | 652 // plugin is responsible fro saving the current HDC settings, setting up |
| 651 // its own environment, drawing, and restoring the HDC to the previous | 653 // its own environment, drawing, and restoring the HDC to the previous |
| 652 // settings. The HDC settings must be restored whenever control returns | 654 // settings. The HDC settings must be restored whenever control returns |
| 653 // back to the browser, either before returning from NPP_HandleEvent or | 655 // back to the browser, either before returning from NPP_HandleEvent or |
| 654 // before calling a drawing-related netscape method. | 656 // before calling a drawing-related netscape method. |
| 655 // | |
| 656 | 657 |
| 657 // TODO: implement me | 658 NOTIMPLEMENTED(); |
| 658 DLOG(INFO) << "NPN_ForceRedraw is not implemented yet."; | |
| 659 } | 659 } |
| 660 | 660 |
| 661 NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) { | 661 NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) { |
| 662 // Allows the plugin to query the browser for information | 662 // Allows the plugin to query the browser for information |
| 663 // | 663 // |
| 664 // Variables: | 664 // Variables: |
| 665 // NPNVxDisplay (unix only) | 665 // NPNVxDisplay (unix only) |
| 666 // NPNVxtAppContext (unix only) | 666 // NPNVxtAppContext (unix only) |
| 667 // NPNVnetscapeWindow (win only) - Gets the native window on which the | 667 // NPNVnetscapeWindow (win only) - Gets the native window on which the |
| 668 // plug-in drawing occurs, returns HWND | 668 // plug-in drawing occurs, returns HWND |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 void NPN_PluginThreadAsyncCall(NPP id, | 898 void NPN_PluginThreadAsyncCall(NPP id, |
| 899 void (*func)(void *), | 899 void (*func)(void *), |
| 900 void *userData) { | 900 void *userData) { |
| 901 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); | 901 scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); |
| 902 if (plugin) { | 902 if (plugin) { |
| 903 plugin->PluginThreadAsyncCall(func, userData); | 903 plugin->PluginThreadAsyncCall(func, userData); |
| 904 } | 904 } |
| 905 } | 905 } |
| 906 | 906 |
| 907 } // extern "C" | 907 } // extern "C" |
| OLD | NEW |