Changeset 84979 in webkit


Ignore:
Timestamp:
Apr 26, 2011 4:35:25 PM (13 years ago)
Author:
Martin Robinson
Message:

2011-04-26 Martin Robinson <mrobinson@igalia.com>

Reviewed by Dirk Schulze.

[GTK] Flash in divs with overflow: auto is not positioned and clipped properly
https://bugs.webkit.org/show_bug.cgi?id=57644

Manual test: plugins/windowed-in-iframe-2.html

  • manual-tests/plugins/windowed-in-iframe-2.html: Added.
  • platform/gtk/WidgetGtk.cpp: (WebCore::Widget::setFrameRect): Like the Qt port, we notify the widget via frameRectsChanged.
  • plugins/PluginView.h: Added helper method to set the allocation and clip.
  • plugins/gtk/PluginViewGtk.cpp: (WebCore::PluginView::setNPWindowIfNeeded):Call the helper method instead of setting the allocation immediately. Bring this method into sync with the implementation in the Qt port. (WebCore::PluginView::updateWidgetAllocationAndClip): Added. (WebCore::PluginView::plugAddedCallback): Call the new helper method.
Location:
trunk/Source/WebCore
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84978 r84979  
     12011-04-26  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Dirk Schulze.
     4
     5        [GTK] Flash in divs with overflow: auto is not positioned and clipped properly
     6        https://bugs.webkit.org/show_bug.cgi?id=57644
     7
     8        Manual test: plugins/windowed-in-iframe-2.html
     9
     10        * manual-tests/plugins/windowed-in-iframe-2.html: Added.
     11        * platform/gtk/WidgetGtk.cpp:
     12        (WebCore::Widget::setFrameRect): Like the Qt port, we notify the widget via frameRectsChanged.
     13        * plugins/PluginView.h: Added helper method to set the allocation and clip.
     14        * plugins/gtk/PluginViewGtk.cpp:
     15        (WebCore::PluginView::setNPWindowIfNeeded):Call the helper method instead of setting
     16        the allocation immediately. Bring this method into sync with the implementation in
     17        the Qt port.
     18        (WebCore::PluginView::updateWidgetAllocationAndClip): Added.
     19        (WebCore::PluginView::plugAddedCallback): Call the new helper method.
     20
    1212011-04-26  Martin Robinson  <mrobinson@igalia.com>
    222
  • trunk/Source/WebCore/platform/gtk/WidgetGtk.cpp

    r80548 r84979  
    110110{
    111111    m_frame = rect;
     112    frameRectsChanged();
    112113}
    113114
  • trunk/Source/WebCore/plugins/PluginView.h

    r84071 r84979  
    439439        static gboolean plugRemovedCallback(GtkSocket*, PluginView*);
    440440        static void plugAddedCallback(GtkSocket*, PluginView*);
     441        void updateWidgetAllocationAndClip();
    441442        bool m_plugAdded;
    442443        IntRect m_delayedAllocation;
  • trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp

    r84371 r84979  
    494494        return;
    495495
    496     if (m_isWindowed) {
    497         m_npWindow.x = m_windowRect.x();
    498         m_npWindow.y = m_windowRect.y();
     496    // If width or height are null, set the clipRect to null, indicating that
     497    // the plugin is not visible/scrolled out.
     498    if (!m_clipRect.isEmpty()) {
     499        m_npWindow.clipRect.left = 0;
     500        m_npWindow.clipRect.right = 0;
     501        m_npWindow.clipRect.top = 0;
     502        m_npWindow.clipRect.bottom = 0;
     503    } else {
     504        // Clipping rectangle of the plug-in; the origin is the top left corner of the drawable or window.
     505        m_npWindow.clipRect.left = m_npWindow.x + m_clipRect.x();
     506        m_npWindow.clipRect.top = m_npWindow.y + m_clipRect.y();
     507        m_npWindow.clipRect.right = m_npWindow.x + m_clipRect.x() + m_clipRect.width();
     508        m_npWindow.clipRect.bottom = m_npWindow.y + m_clipRect.y() + m_clipRect.height();
     509    }
     510
     511    // FLASH WORKAROUND: Only set initially. Multiple calls to
     512    // setNPWindow() cause the plugin to crash in windowed mode.
     513    if (!m_plugin->quirks().contains(PluginQuirkDontCallSetWindowMoreThanOnce) || !m_isWindowed
     514        || m_npWindow.width == static_cast<uint32_t>(-1) || m_npWindow.height == static_cast<uint32_t>(-1)) {
    499515        m_npWindow.width = m_windowRect.width();
    500516        m_npWindow.height = m_windowRect.height();
    501 
    502         m_npWindow.clipRect.left = max(0, m_clipRect.x());
    503         m_npWindow.clipRect.top = max(0, m_clipRect.y());
    504         m_npWindow.clipRect.right = m_clipRect.x() + m_clipRect.width();
    505         m_npWindow.clipRect.bottom = m_clipRect.y() + m_clipRect.height();
    506     } else {
    507         m_npWindow.x = 0;
    508         m_npWindow.y = 0;
    509         m_npWindow.width = m_windowRect.width();
    510         m_npWindow.height = m_windowRect.height();
    511 
    512         m_npWindow.clipRect.left = 0;
    513         m_npWindow.clipRect.top = 0;
    514         m_npWindow.clipRect.right = 0;
    515         m_npWindow.clipRect.bottom = 0;
    516517    }
    517518
     
    535536#endif
    536537
    537     GtkAllocation allocation = { m_windowRect.x(), m_windowRect.y(), m_windowRect.width(), m_windowRect.height() };
    538 
     538    m_delayedAllocation = m_windowRect;
     539    updateWidgetAllocationAndClip();
     540}
     541
     542void PluginView::updateWidgetAllocationAndClip()
     543{
    539544    // If the window has not been embedded yet (the plug added), we delay setting its allocation until
    540545    // that point. This fixes issues with some Java plugin instances not rendering immediately.
    541     if (!m_plugAdded) {
    542         m_delayedAllocation = allocation;
    543         return;
    544     }
    545     gtk_widget_size_allocate(platformPluginWidget(), &allocation);
     546    if (!m_plugAdded || m_delayedAllocation.isEmpty())
     547        return;
     548
     549    GtkWidget* widget = platformPluginWidget();
     550    if (gtk_widget_get_realized(widget)) {
     551        GdkRectangle clipRect = m_clipRect;
     552#ifdef GTK_API_VERSION_2
     553        GdkRegion* clipRegion = gdk_region_rectangle(&clipRect);
     554        gdk_window_shape_combine_region(gtk_widget_get_window(widget), clipRegion, 0, 0);
     555        gdk_region_destroy(clipRegion);
     556#else
     557        cairo_region_t* clipRegion = cairo_region_create_rectangle(&clipRect);
     558        gdk_window_shape_combine_region(gtk_widget_get_window(widget), clipRegion, 0, 0);
     559        cairo_region_destroy(clipRegion);
     560#endif
     561    }
     562
     563    GtkAllocation allocation(m_delayedAllocation);
     564    gtk_widget_size_allocate(widget, &allocation);
     565    m_delayedAllocation = IntRect();
    546566}
    547567
     
    774794    ASSERT(socket);
    775795    ASSERT(view);
    776 
    777796    view->m_plugAdded = true;
    778     if (!view->m_delayedAllocation.isEmpty()) {
    779         GtkAllocation allocation(view->m_delayedAllocation);
    780         gtk_widget_size_allocate(GTK_WIDGET(socket), &allocation);
    781         view->m_delayedAllocation.setSize(IntSize());
    782     }
     797    view->updateWidgetAllocationAndClip();
    783798}
    784799
Note: See TracChangeset for help on using the changeset viewer.