Changeset 85795 in webkit


Ignore:
Timestamp:
May 4, 2011 3:32:28 PM (13 years ago)
Author:
Adam Roben
Message:

Clip and reposition windowed plugins when the UI process paints

This ensures that their geometry updates in sync with the rest of the page.

Most of this patch is just plumbing the scheduleWindowedPluginGeometryUpdate and
scheduleChildWindowGeometryUpdate calls through from NetscapePlugin all the way over to
WebView. I've tried to call out the other parts below.

Fixes <http://webkit.org/b/60210> <rdar://problem/8483441> REGRESSION (WebKit2): Windowed
plugins don't scroll at the same speed as the rest of the page

Reviewed by Darin Adler and Anders Carlsson.

  • UIProcess/PageClient.h:
  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/win/WebPageProxyWin.cpp:

(WebKit::WebPageProxy::scheduleChildWindowGeometryUpdate):
Added plumbing.

  • UIProcess/win/WebView.cpp:

(WebKit::WebView::onPaintEvent): Update child windows before painting so that they will stay
in sync with the rest of the page.
(WebKit::WebView::scheduleChildWindowGeometryUpdate): Add this update information to the
set of geometries to update on the next paint.
(WebKit::setWindowRegion): Moved this helper function here from NetscapePluginWin.cpp.
(WebKit::WebView::updateChildWindowGeometries): Update the size, position, and clip rects of
all the child windows with scheduled geometry updates.

  • UIProcess/win/WebView.h: Added new members to track and update child window geometries.
  • WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp:

(WebKit::NetscapePlugin::platformPostInitialize): Don't show the window immediately. Let the
UI process take care of it.
(WebKit::NetscapePlugin::platformGeometryDidChange): Don't update the window's position or
clip rect. Let the UI process take care of it.

  • WebProcess/Plugins/PluginController.h:
  • WebProcess/Plugins/PluginView.cpp:

(WebKit::PluginView::scheduleWindowedPluginGeometryUpdate):

  • WebProcess/Plugins/PluginView.h:
  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/win/WebPageWin.cpp:

(WebKit::WebPage::scheduleChildWindowGeometryUpdate):
Added plumbing.

Location:
trunk/Source/WebKit2
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r85794 r85795  
     12011-05-04  Adam Roben  <aroben@apple.com>
     2
     3        Clip and reposition windowed plugins when the UI process paints
     4
     5        This ensures that their geometry updates in sync with the rest of the page.
     6
     7        Most of this patch is just plumbing the scheduleWindowedPluginGeometryUpdate and
     8        scheduleChildWindowGeometryUpdate calls through from NetscapePlugin all the way over to
     9        WebView. I've tried to call out the other parts below.
     10
     11        Fixes <http://webkit.org/b/60210> <rdar://problem/8483441> REGRESSION (WebKit2): Windowed
     12        plugins don't scroll at the same speed as the rest of the page
     13
     14        Reviewed by Darin Adler and Anders Carlsson.
     15
     16        * UIProcess/PageClient.h:
     17        * UIProcess/WebPageProxy.h:
     18        * UIProcess/WebPageProxy.messages.in:
     19        * UIProcess/win/WebPageProxyWin.cpp:
     20        (WebKit::WebPageProxy::scheduleChildWindowGeometryUpdate):
     21        Added plumbing.
     22
     23        * UIProcess/win/WebView.cpp:
     24        (WebKit::WebView::onPaintEvent): Update child windows before painting so that they will stay
     25        in sync with the rest of the page.
     26        (WebKit::WebView::scheduleChildWindowGeometryUpdate): Add this update information to the
     27        set of geometries to update on the next paint.
     28        (WebKit::setWindowRegion): Moved this helper function here from NetscapePluginWin.cpp.
     29        (WebKit::WebView::updateChildWindowGeometries): Update the size, position, and clip rects of
     30        all the child windows with scheduled geometry updates.
     31
     32        * UIProcess/win/WebView.h: Added new members to track and update child window geometries.
     33
     34        * WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp:
     35        (WebKit::NetscapePlugin::platformPostInitialize): Don't show the window immediately. Let the
     36        UI process take care of it.
     37        (WebKit::NetscapePlugin::platformGeometryDidChange): Don't update the window's position or
     38        clip rect. Let the UI process take care of it.
     39
     40        * WebProcess/Plugins/PluginController.h:
     41        * WebProcess/Plugins/PluginView.cpp:
     42        (WebKit::PluginView::scheduleWindowedPluginGeometryUpdate):
     43        * WebProcess/Plugins/PluginView.h:
     44        * WebProcess/WebPage/WebPage.h:
     45        * WebProcess/WebPage/win/WebPageWin.cpp:
     46        (WebKit::WebPage::scheduleChildWindowGeometryUpdate):
     47        Added plumbing.
     48
    1492011-05-04  Anders Carlsson  <andersca@apple.com>
    250
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r85245 r85795  
    140140    virtual HWND nativeWindow() = 0;
    141141    virtual void setGestureReachedScrollingLimit(bool) = 0;
     142    virtual void scheduleChildWindowGeometryUpdate(HWND, const WebCore::IntRect& rectInParentClientCoordinates, const WebCore::IntRect& clipRectInChildClientCoordinates) = 0;
    142143#endif
    143144
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r85746 r85795  
    734734    void updateBackingStoreDiscardableState();
    735735
     736#if PLATFORM(WIN)
     737    void scheduleChildWindowGeometryUpdate(uint64_t window, const WebCore::IntRect& rectInParentClientCoordinates, const WebCore::IntRect& clipRectInChildClientCoordinates);
     738#endif
     739
    736740    PageClient* m_pageClient;
    737741    WebLoaderClient m_loaderClient;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r85502 r85795  
    242242    # Windows 7 Gesture Messages
    243243    SetGestureReachedScrollingLimit(bool limitReached)
     244
     245    # Miscellaneous Windows messages
     246    ScheduleChildWindowGeometryUpdate(uint64_t window, WebCore::IntRect rectInParentClientCoordinates, WebCore::IntRect clipRectInChildClientCoordinates)
    244247#endif
    245248
  • trunk/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp

    r84785 r85795  
    7171}
    7272
     73void WebPageProxy::scheduleChildWindowGeometryUpdate(uint64_t window, const IntRect& rectInParentClientCoordinates, const IntRect& clipRectInChildClientCoordinates)
     74{
     75    m_pageClient->scheduleChildWindowGeometryUpdate(reinterpret_cast<HWND>(window), rectInParentClientCoordinates, clipRectInChildClientCoordinates);
     76}
     77
    7378} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/win/WebView.cpp

    r85794 r85795  
    686686LRESULT WebView::onPaintEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled)
    687687{
     688    // Update child windows now so that any areas of our window they reveal will be included in the
     689    // invalid region that ::BeginPaint sees.
     690    updateChildWindowGeometries();
     691
    688692    PAINTSTRUCT paintStruct;
    689693    HDC hdc = ::BeginPaint(m_window, &paintStruct);
     
    15251529}
    15261530
     1531void WebView::scheduleChildWindowGeometryUpdate(HWND window, const WebCore::IntRect& rectInParentClientCoordinates, const WebCore::IntRect& clipRectInChildClientCoordinates)
     1532{
     1533    ChildWindowGeometry geometry;
     1534    geometry.rectInParentClientCoordinates = rectInParentClientCoordinates;
     1535    geometry.clipRectInChildClientCoordinates = clipRectInChildClientCoordinates;
     1536
     1537    m_childWindowGeometriesToUpdate.set(window, geometry);
     1538}
     1539
     1540static void setWindowRegion(HWND window, PassOwnPtr<HRGN> popRegion)
     1541{
     1542    OwnPtr<HRGN> region = popRegion;
     1543
     1544    if (!::SetWindowRgn(window, region.get(), TRUE))
     1545        return;
     1546
     1547    // Windows owns the region now.
     1548    region.leakPtr();
     1549}
     1550
     1551void WebView::updateChildWindowGeometries()
     1552{
     1553    HashMap<HWND, ChildWindowGeometry> geometriesToUpdate;
     1554    geometriesToUpdate.swap(m_childWindowGeometriesToUpdate);
     1555
     1556    HDWP deferWindowPos = ::BeginDeferWindowPos(geometriesToUpdate.size());
     1557
     1558    HashMap<HWND, ChildWindowGeometry>::const_iterator end = geometriesToUpdate.end();
     1559    for (HashMap<HWND, ChildWindowGeometry>::const_iterator it = geometriesToUpdate.begin(); it != end; ++it) {
     1560        HWND window = it->first;
     1561        if (!::IsWindow(window))
     1562            continue;
     1563
     1564        const ChildWindowGeometry& geometry = it->second;
     1565
     1566        const IntRect& windowRect = geometry.rectInParentClientCoordinates;
     1567        deferWindowPos = ::DeferWindowPos(deferWindowPos, window, 0, windowRect.x(), windowRect.y(), windowRect.width(), windowRect.height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
     1568
     1569        const IntRect& clipRect = geometry.clipRectInChildClientCoordinates;
     1570        setWindowRegion(window, adoptPtr(::CreateRectRgn(clipRect.x(), clipRect.y(), clipRect.maxX(), clipRect.maxY())));
     1571    }
     1572
     1573    ::EndDeferWindowPos(deferWindowPos);
     1574}
     1575
    15271576// WebCore::WindowMessageListener
    15281577
  • trunk/Source/WebKit2/UIProcess/win/WebView.h

    r85699 r85795  
    161161    HCURSOR cursorToShow() const;
    162162    void updateNativeCursor();
     163
     164    void updateChildWindowGeometries();
    163165
    164166    // PageClient
     
    210212
    211213    virtual HWND nativeWindow();
     214    virtual void scheduleChildWindowGeometryUpdate(HWND, const WebCore::IntRect& rectInParentClientCoordinates, const WebCore::IntRect& clipRectInChildClientCoordinates);
    212215
    213216    virtual void setGestureReachedScrollingLimit(bool limitReached) { m_gestureReachedScrollingLimit = limitReached; }
     
    266269    bool m_gestureReachedScrollingLimit;
    267270
     271    struct ChildWindowGeometry {
     272        WebCore::IntRect rectInParentClientCoordinates;
     273        WebCore::IntRect clipRectInChildClientCoordinates;
     274    };
     275
     276    HashMap<HWND, ChildWindowGeometry> m_childWindowGeometriesToUpdate;
     277
    268278#if ENABLE(FULLSCREEN_API)
    269279    OwnPtr<WebCore::FullScreenController> m_fullScreenController;
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp

    r85753 r85795  
    102102    registerPluginView();
    103103
    104     m_window = ::CreateWindowExW(0, windowClassName, 0, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, containingWindow(), 0, instanceHandle(), 0);
     104    // Start out with the window hidden. The UI process will take care of showing it once it's correctly positioned the window.
     105    m_window = ::CreateWindowExW(0, windowClassName, 0, WS_CHILD, 0, 0, 0, 0, containingWindow(), 0, instanceHandle(), 0);
    105106    if (!m_window)
    106107        return false;
     
    139140}
    140141
    141 enum RedrawOrNot { DoNotRedraw, Redraw };
    142 static void setWindowRegion(HWND window, PassOwnPtr<HRGN> popRegion, RedrawOrNot redrawOrNot)
    143 {
    144     OwnPtr<HRGN> region = popRegion;
    145 
    146     if (!::SetWindowRgn(window, region.get(), redrawOrNot == Redraw))
    147         return;
    148 
    149     // Windows owns the region now.
    150     region.leakPtr();
    151 }
    152 
    153142void NetscapePlugin::platformGeometryDidChange()
    154143{
     
    159148    clipRectInPluginWindowCoordinates.move(-m_frameRect.x(), -m_frameRect.y());
    160149
    161     OwnPtr<HRGN> clipRegion = adoptPtr(::CreateRectRgn(clipRectInPluginWindowCoordinates.x(), clipRectInPluginWindowCoordinates.y(), clipRectInPluginWindowCoordinates.maxX(), clipRectInPluginWindowCoordinates.maxY()));
    162     setWindowRegion(m_window, clipRegion.release(), Redraw);
    163 
    164     // FIXME: We should only update the size here and let the UI process update our position so
    165     // that we can keep our position in sync when scrolling, etc.
    166     ::MoveWindow(m_window, m_frameRect.x(), m_frameRect.y(), m_frameRect.width(), m_frameRect.height(), TRUE);
     150    // We only update the size here and let the UI process update our position and clip rect so
     151    // that we can keep our position in sync when scrolling, etc. See <http://webkit.org/b/60210>.
     152    ::SetWindowPos(m_window, 0, 0, 0, m_frameRect.width(), m_frameRect.height(), SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
     153
     154    m_pluginController->scheduleWindowedPluginGeometryUpdate(m_window, m_frameRect, clipRectInPluginWindowCoordinates);
    167155}
    168156
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginController.h

    r85502 r85795  
    9090    // The window to use as the parent of the plugin's window.
    9191    virtual HWND nativeParentWindow() = 0;
     92
     93    // Tells the controller that the given HWND needs to be positioned and clipped to the given
     94    // coordinates sometime soon. The controller will decide exactly when this will happen.
     95    virtual void scheduleWindowedPluginGeometryUpdate(HWND, const WebCore::IntRect& rectInParentClientCoordinates, const WebCore::IntRect& clipRectInPluginWindowCoordinates) = 0;
    9296#endif
    9397
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp

    r85567 r85795  
    10041004    return m_webPage->nativeWindow();
    10051005}
     1006
     1007void PluginView::scheduleWindowedPluginGeometryUpdate(HWND pluginWindow, const IntRect& rectInParentClientCoordinates, const IntRect& clipRectInPluginWindowCoordinates)
     1008{
     1009    m_webPage->scheduleChildWindowGeometryUpdate(pluginWindow, rectInParentClientCoordinates, clipRectInPluginWindowCoordinates);
     1010}
    10061011#endif
    10071012
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h

    r85502 r85795  
    133133#if PLATFORM(WIN)
    134134    virtual HWND nativeParentWindow();
     135    virtual void scheduleWindowedPluginGeometryUpdate(HWND, const WebCore::IntRect& rectInClientCoordinates, const WebCore::IntRect& clipRectInPluginWindowCoordinates);
    135136#endif
    136137#if PLATFORM(MAC)
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r85783 r85795  
    259259#elif PLATFORM(WIN)
    260260    HWND nativeWindow() const { return m_nativeWindow; }
     261    void scheduleChildWindowGeometryUpdate(HWND, const WebCore::IntRect& rectInParentClientCoordinates, const WebCore::IntRect& clipRectInChildClientCoordinates);
    261262#endif
    262263
  • trunk/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp

    r85783 r85795  
    2828
    2929#include "FontSmoothingLevel.h"
     30#include "WebCoreArgumentCoders.h"
    3031#include "WebEvent.h"
    3132#include "WebPageProxyMessages.h"
    3233#include "WebPreferencesStore.h"
     34#include "WebProcess.h"
    3335#include <WebCore/FocusController.h>
    3436#include <WebCore/FontRenderingMode.h>
     
    458460}
    459461
     462void WebPage::scheduleChildWindowGeometryUpdate(HWND window, const IntRect& rectInParentClientCoordinates, const IntRect& clipRectInChildClientCoordinates)
     463{
     464    WebProcess::shared().connection()->send(Messages::WebPageProxy::ScheduleChildWindowGeometryUpdate(reinterpret_cast<uint64_t>(window), rectInParentClientCoordinates, clipRectInChildClientCoordinates), m_pageID);
     465}
     466
    460467} // namespace WebKit
Note: See TracChangeset for help on using the changeset viewer.