Changeset 70514 in webkit


Ignore:
Timestamp:
Oct 26, 2010 1:37:32 AM (14 years ago)
Author:
xan@webkit.org
Message:

WebCore:

2010-10-26 Xan Lopez <xlopez@igalia.com>

Reviewed by Martin Robinson.

[GTK] Port to new GtkScrollable interface in GTK+ 3.x
https://bugs.webkit.org/show_bug.cgi?id=48202

The new GtkScrollable API sets the adjustments individually, so
adjust the code for this fact.

  • platform/ScrollView.h:
  • platform/gtk/ScrollViewGtk.cpp: (WebCore::ScrollView::setHorizontalAdjustment): new method to set the horizontal adjustment. (WebCore::ScrollView::setVerticalAdjustment): new method to set the vertical adjustment. (WebCore::ScrollView::setGtkAdjustments): make this just call the other two methods.

WebKit/gtk:

2010-10-26 Xan Lopez <xlopez@igalia.com>

Reviewed by Martin Robinson.

[GTK] Port to new GtkScrollable interface in GTK+ 3.x
https://bugs.webkit.org/show_bug.cgi?id=48202

Use the new GtkScrollable interface when compiling against GTK+
3.x.

  • webkit/webkitwebview.cpp: (setHorizontalAdjustment): (setVerticalAdjustment): (getHorizontalAdjustment): (getVerticalAdjustment): (webkit_web_view_get_property): (webkit_web_view_set_property): (webkit_web_view_class_init):
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r70513 r70514  
     12010-10-26  Xan Lopez  <xlopez@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [GTK] Port to new GtkScrollable interface in GTK+ 3.x
     6        https://bugs.webkit.org/show_bug.cgi?id=48202
     7
     8        The new GtkScrollable API sets the adjustments individually, so
     9        adjust the code for this fact.
     10
     11        * platform/ScrollView.h:
     12        * platform/gtk/ScrollViewGtk.cpp:
     13        (WebCore::ScrollView::setHorizontalAdjustment): new method to set the horizontal adjustment.
     14        (WebCore::ScrollView::setVerticalAdjustment): new method to set the vertical adjustment.
     15        (WebCore::ScrollView::setGtkAdjustments): make this just call the other two methods.
     16
    1172010-10-26  Sheriff Bot  <webkit.review.bot@gmail.com>
    218
  • trunk/WebCore/platform/ScrollView.h

    r70509 r70514  
    342342public:
    343343    void setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, bool resetValues = true);
     344    void setHorizontalAdjustment(GtkAdjustment* hadj, bool resetValues = true);
     345    void setVerticalAdjustment(GtkAdjustment* vadj, bool resetValues = true);
    344346    void setScrollOffset(const IntSize& offset) { m_scrollOffset = offset; }
    345347
  • trunk/WebCore/platform/gtk/ScrollViewGtk.cpp

    r66885 r70514  
    7979}
    8080
    81 /*
    82  * The following is assumed:
    83  *   (hadj && vadj) || (!hadj && !vadj)
    84  */
    85 void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, bool resetValues)
    86 {
    87     ASSERT(!hadj == !vadj);
    88 
    89     // If this is a non-main frame ScrollView, we do not want to set the
    90     // m_horizontalAdjustments & m_verticalAdjustments members. At the same
    91     // time we want to to allow FrameLoaderClientGtk.cpp to call
    92     // ScrollView::setGtkAdjustments(0, 0) unconditionally.
     81void ScrollView::setHorizontalAdjustment(GtkAdjustment* hadj, bool resetValues)
     82{
    9383    ASSERT(!parent() || !hadj);
    9484    if (parent())
     
    9686
    9787    m_horizontalAdjustment = hadj;
    98     m_verticalAdjustment = vadj;
    9988
    10089    if (!m_horizontalAdjustment) {
     
    10291        if (hScrollbar)
    10392            hScrollbar->detachAdjustment();
    104 
    105         MainFrameScrollbarGtk* vScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(verticalScrollbar());
    106         if (vScrollbar)
    107             vScrollbar->detachAdjustment();
    108 
    109         return;
    11093    }
    11194
    11295    // We may be lacking scrollbars when returning to a cached
    11396    // page, this kicks the page to recreate the scrollbars.
    114     setHasVerticalScrollbar(true);
    11597    setHasHorizontalScrollbar(true);
    11698
     
    118100    hScrollbar->attachAdjustment(m_horizontalAdjustment.get());
    119101
    120     MainFrameScrollbarGtk* vScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(verticalScrollbar());
    121     vScrollbar->attachAdjustment(m_verticalAdjustment.get());
     102    if (!m_horizontalAdjustment)
     103        return;
    122104
    123105    // We used to reset everything to 0 here, but when page cache
     
    128110    // here. This is needed for the parent scrolling widget to be
    129111    // able to report correct values.
    130 
    131112    int horizontalPageStep = max(max<int>(frameRect().width() * Scrollbar::minFractionToStepWhenPaging(), frameRect().width() - Scrollbar::maxOverlapBetweenPages()), 1);
    132113    gtk_adjustment_configure(m_horizontalAdjustment.get(),
     
    136117                             resetValues ? 0 : horizontalPageStep,
    137118                             resetValues ? 0 : frameRect().width());
    138 
    139     int verticalPageStep = max(max<int>(frameRect().height() * Scrollbar::minFractionToStepWhenPaging(), frameRect().height() - Scrollbar::maxOverlapBetweenPages()), 1);
     119}
     120
     121void ScrollView::setVerticalAdjustment(GtkAdjustment* vadj, bool resetValues)
     122{
     123    ASSERT(!parent() || !vadj);
     124    if (parent())
     125        return;
     126
     127    m_verticalAdjustment = vadj;
     128
     129    if (!m_verticalAdjustment) {
     130        MainFrameScrollbarGtk* vScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(verticalScrollbar());
     131        if (vScrollbar)
     132            vScrollbar->detachAdjustment();
     133    }
     134
     135    // We may be lacking scrollbars when returning to a cached
     136    // page, this kicks the page to recreate the scrollbars.
     137    setHasVerticalScrollbar(true);
     138
     139    MainFrameScrollbarGtk* vScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(verticalScrollbar());
     140    vScrollbar->attachAdjustment(m_verticalAdjustment.get());
     141
     142    if (!m_verticalAdjustment)
     143        return;
     144
     145    // We used to reset everything to 0 here, but when page cache
     146    // is enabled we reuse FrameViews that are cached. Since their
     147    // size is not going to change when being restored, (which is
     148    // what would cause the upper limit in the adjusments to be
     149    // set in the normal case), we make sure they are up-to-date
     150    // here. This is needed for the parent scrolling widget to be
     151    // able to report correct values.
     152    int verticalPageStep = max(max<int>(frameRect().width() * Scrollbar::minFractionToStepWhenPaging(), frameRect().width() - Scrollbar::maxOverlapBetweenPages()), 1);
    140153    gtk_adjustment_configure(m_verticalAdjustment.get(),
    141                              resetValues ? 0 : scrollOffset().height(), 0,
    142                              resetValues ? 0 : contentsSize().height(),
     154                             resetValues ? 0 : scrollOffset().width(), 0,
     155                             resetValues ? 0 : contentsSize().width(),
    143156                             resetValues ? 0 : Scrollbar::pixelsPerLineStep(),
    144157                             resetValues ? 0 : verticalPageStep,
    145                              resetValues ? 0 : frameRect().height());
     158                             resetValues ? 0 : frameRect().width());
     159}
     160
     161void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, bool resetValues)
     162{
     163    setHorizontalAdjustment(hadj, resetValues);
     164    setVerticalAdjustment(vadj, resetValues);
    146165}
    147166
  • trunk/WebKit/gtk/ChangeLog

    r70333 r70514  
     12010-10-26  Xan Lopez  <xlopez@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [GTK] Port to new GtkScrollable interface in GTK+ 3.x
     6        https://bugs.webkit.org/show_bug.cgi?id=48202
     7
     8        Use the new GtkScrollable interface when compiling against GTK+
     9        3.x.
     10
     11        * webkit/webkitwebview.cpp:
     12        (setHorizontalAdjustment):
     13        (setVerticalAdjustment):
     14        (getHorizontalAdjustment):
     15        (getVerticalAdjustment):
     16        (webkit_web_view_get_property):
     17        (webkit_web_view_set_property):
     18        (webkit_web_view_class_init):
     19
    1202010-10-22  Sam Weinig  <sam@webkit.org>
    221
  • trunk/WebKit/gtk/webkit/webkitwebview.cpp

    r69919 r70514  
    197197    PROP_ICON_URI,
    198198    PROP_IM_CONTEXT,
     199#ifdef GTK_API_VERSION_2
    199200    PROP_VIEW_MODE
     201#else
     202    PROP_VIEW_MODE,
     203    PROP_HADJUSTMENT,
     204    PROP_VADJUSTMENT
     205#endif
    200206};
    201207
    202208static guint webkit_web_view_signals[LAST_SIGNAL] = { 0, };
    203209
     210#ifdef GTK_API_VERSION_2
    204211G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER)
     212#else
     213G_DEFINE_TYPE_WITH_CODE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER,
     214                        G_IMPLEMENT_INTERFACE(GTK_TYPE_SCROLLABLE, 0))
     215#endif
    205216
    206217static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView);
     
    385396    return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event);
    386397}
     398
     399#ifndef GTK_API_VERSION_2
     400static void setHorizontalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment)
     401{
     402    if (!core(webView))
     403        return;
     404
     405    webView->priv->horizontalAdjustment = adjustment;
     406    FrameView* view = core(webkit_web_view_get_main_frame(webView))->view();
     407    if (!view)
     408        return;
     409    view->setHorizontalAdjustment(adjustment);
     410}
     411
     412static void setVerticalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment)
     413{
     414    if (!core(webView))
     415        return;
     416
     417    webView->priv->verticalAdjustment = adjustment;
     418    FrameView* view = core(webkit_web_view_get_main_frame(webView))->view();
     419    if (!view)
     420        return;
     421    view->setVerticalAdjustment(adjustment);
     422}
     423
     424static GtkAdjustment* getHorizontalAdjustment(WebKitWebView* webView)
     425{
     426    return webView->priv->horizontalAdjustment.get();
     427}
     428
     429static GtkAdjustment* getVerticalAdjustment(WebKitWebView* webView)
     430{
     431    return webView->priv->verticalAdjustment.get();
     432}
     433#endif
    387434
    388435static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
     
    445492        g_value_set_enum(value, webkit_web_view_get_view_mode(webView));
    446493        break;
     494#ifndef GTK_API_VERSION_2
     495    case PROP_HADJUSTMENT:
     496        g_value_set_object(value, getHorizontalAdjustment(webView));
     497        break;
     498    case PROP_VADJUSTMENT:
     499        g_value_set_object(value, getVerticalAdjustment(webView));
     500        break;
     501#endif
    447502    default:
    448503        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
     
    479534        webkit_web_view_set_view_mode(webView, static_cast<WebKitWebViewViewMode>(g_value_get_enum(value)));
    480535        break;
     536#ifndef GTK_API_VERSION_2
     537    case PROP_HADJUSTMENT:
     538        setHorizontalAdjustment(webView, static_cast<GtkAdjustment*>(g_value_get_object(value)));
     539        break;
     540    case PROP_VADJUSTMENT:
     541        setVerticalAdjustment(webView, static_cast<GtkAdjustment*>(g_value_get_object(value)));
     542        break;
     543#endif
    481544    default:
    482545        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
     
    909972}
    910973
     974#ifdef GTK_API_VERSION_2
    911975static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* hadj, GtkAdjustment* vadj)
    912976{
     
    922986    view->setGtkAdjustments(hadj, vadj);
    923987}
     988#endif
    924989
    925990static void webkit_web_view_container_add(GtkContainer* container, GtkWidget* widget)
     
    25262591     * make us scrollable (e.g. addable to a GtkScrolledWindow)
    25272592     */
     2593#ifdef GTK_API_VERSION_2
    25282594    webViewClass->set_scroll_adjustments = webkit_web_view_set_scroll_adjustments;
    25292595    GTK_WIDGET_CLASS(webViewClass)->set_scroll_adjustments_signal = g_signal_new("set-scroll-adjustments",
     
    25352601            G_TYPE_NONE, 2,
    25362602            GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
     2603#else
     2604    g_object_class_override_property(objectClass, PROP_HADJUSTMENT, "hadjustment");
     2605    g_object_class_override_property(objectClass, PROP_VADJUSTMENT, "vadjustment");
     2606#endif
    25372607
    25382608    /*
Note: See TracChangeset for help on using the changeset viewer.