Changeset 86102 in webkit


Ignore:
Timestamp:
May 9, 2011 4:24:56 PM (13 years ago)
Author:
Martin Robinson
Message:

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

Reviewed by Gustavo Noronha Silva.

[GTK] Untangle GtkAdjustments from WebCore
https://bugs.webkit.org/show_bug.cgi?id=59821

Completely remove the ability for WebKit to set GtkAdjustments on ScrollViews
and, consequently, Scrollbars. Handling adjustment updates can now be managed
in WebKit.

No new tests. This is covered by existing Scrollbar tests.

  • platform/ScrollView.cpp: platformInit and platformDestroy can now be shared between ScrollView.cpp and ScrollViewGtk.cpp.
  • platform/ScrollView.h: Remove unused methods.
  • platform/gtk/MainFrameScrollbarGtk.cpp: (MainFrameScrollbarGtk::create): No longer need to pass in the adjustment. (MainFrameScrollbarGtk::MainFrameScrollbarGtk): Update the comments here.
  • platform/gtk/MainFrameScrollbarGtk.h: Lots of code removal.
  • platform/gtk/ScrollViewGtk.cpp: Ditto. (WebCore::ScrollView::createScrollbar): Ditto. (WebCore::ScrollView::setScrollbarModes): Ditto.
  • plugins/gtk/PluginViewGtk.cpp: This file needs the GRefPtrGtk.h include now that it doesn't receive it transitively.

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

Reviewed by Gustavo Noronha Silva.

[GTK] Untangle GtkAdjustments from WebCore
https://bugs.webkit.org/show_bug.cgi?id=59821

Have ChromeClient manage the GtkAdjustments of the parent widget instead of passing
them to WebCore to manage. This simplifies the code quite a bit and should be less
crash prone in the future.

  • GNUmakefile.am: Added new GtkAdjustmentWatcher class to the sources list.
  • WebCoreSupport/ChromeClientGtk.cpp: Added new GtkAdjustmentWatcher member. (WebKit::ChromeClient::ChromeClient) Initialize the new member. (WebKit::ChromeClient::scroll): Poke the adjustment watcher to update the adjustments. (WebKit::ChromeClient::contentsSizeChanged): Ditto. (WebKit::ChromeClient::scrollbarsModeDidChange): This may now be called at a time when there is no main frame, so do an early return in that case.
  • WebCoreSupport/ChromeClientGtk.h: Add the new member. (WebKit::ChromeClient::adjustmentWatcher): Add this getter for WebKitWebView.
  • WebCoreSupport/FrameLoaderClientGtk.cpp: Remove calls which pushed the adjustments into WebCore. (WebKit::FrameLoaderClient::savePlatformDataToCachedFrame): (WebKit::postCommitFrameViewSetup):
  • WebCoreSupport/GtkAdjustmentWatcher.cpp: Added. (WebKit::GtkAdjustmentWatcher::GtkAdjustmentWatcher): (WebKit::updateAdjustmentFromScrollbar): (WebKit::GtkAdjustmentWatcher::updateAdjustmentsFromScrollbars): (WebKit::updateAdjustmentCallback): (WebKit::GtkAdjustmentWatcher::updateAdjustmentsFromScrollbarsLater): (WebKit::adjustmentValueChangedCallback): (WebKit::setAdjustment): (WebKit::GtkAdjustmentWatcher::setHorizontalAdjustment): (WebKit::GtkAdjustmentWatcher::setVerticalAdjustment): (WebKit::GtkAdjustmentWatcher::adjustmentValueChanged):
  • WebCoreSupport/GtkAdjustmentWatcher.h: Added. (WebKit::GtkAdjustmentWatcher::horizontalAdjustment): (WebKit::GtkAdjustmentWatcher::verticalAdjustment):
  • webkit/webkitwebview.cpp: (setHorizontalAdjustment): (setVerticalAdjustment): Remove the adjustment member. Call into the adjustment watcher. (getHorizontalAdjustment): Ditto. (getVerticalAdjustment): Ditto. (webkit_web_view_size_allocate): Ditto. (webkit_web_view_set_scroll_adjustments): Ditto. (webkit_web_view_dispose): Ditto. (webkit_web_view_init): Ditto.
  • webkit/webkitwebviewprivate.h: Ditto.
Location:
trunk/Source
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86100 r86102  
     12011-04-29  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Gustavo Noronha Silva.
     4
     5        [GTK] Untangle GtkAdjustments from WebCore
     6        https://bugs.webkit.org/show_bug.cgi?id=59821
     7
     8        Completely remove the ability for WebKit to set GtkAdjustments on ScrollViews
     9        and, consequently, Scrollbars. Handling adjustment updates can now be managed
     10        in WebKit.
     11
     12        No new tests. This is covered by existing Scrollbar tests.
     13
     14        * platform/ScrollView.cpp: platformInit and platformDestroy can now be shared
     15        between ScrollView.cpp and ScrollViewGtk.cpp.
     16        * platform/ScrollView.h: Remove unused methods.
     17        * platform/gtk/MainFrameScrollbarGtk.cpp:
     18        (MainFrameScrollbarGtk::create): No longer need to pass in the adjustment.
     19        (MainFrameScrollbarGtk::MainFrameScrollbarGtk): Update the comments here.
     20        * platform/gtk/MainFrameScrollbarGtk.h: Lots of code removal.
     21        * platform/gtk/ScrollViewGtk.cpp: Ditto.
     22        (WebCore::ScrollView::createScrollbar): Ditto.
     23        (WebCore::ScrollView::setScrollbarModes): Ditto.
     24        * plugins/gtk/PluginViewGtk.cpp: This file needs the GRefPtrGtk.h include now
     25        that it doesn't receive it transitively.
     26
    1272011-05-09  Adam Barth  <abarth@webkit.org>
    228
  • trunk/Source/WebCore/platform/ScrollView.cpp

    r85188 r86102  
    12461246}
    12471247
    1248 #if !PLATFORM(WX) && !PLATFORM(GTK) && !PLATFORM(EFL)
     1248#if !PLATFORM(WX) && !PLATFORM(EFL)
    12491249
    12501250void ScrollView::platformInit()
  • trunk/Source/WebCore/platform/ScrollView.h

    r84752 r86102  
    4040#endif
    4141
    42 #if PLATFORM(GTK)
    43 #include "GRefPtrGtk.h"
    44 typedef struct _GtkAdjustment GtkAdjustment;
    45 #endif
    46 
    4742#if PLATFORM(WX)
    4843class wxScrollWinEvent;
     
    403398#endif
    404399
    405 #if PLATFORM(GTK)
    406 public:
    407     void setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, bool resetValues = true);
    408     void setHorizontalAdjustment(GtkAdjustment* hadj, bool resetValues = true);
    409     void setVerticalAdjustment(GtkAdjustment* vadj, bool resetValues = true);
    410     void setScrollOffset(const IntSize& offset) { m_scrollOffset = offset; }
    411 
    412 private:
    413     GRefPtr<GtkAdjustment> m_horizontalAdjustment;
    414     GRefPtr<GtkAdjustment> m_verticalAdjustment;
    415 #endif
    416 
    417400#if PLATFORM(WX)
    418401public:
  • trunk/Source/WebCore/platform/gtk/MainFrameScrollbarGtk.cpp

    r84793 r86102  
    33 *  Copyright (C) 2010 Gustavo Noronha Silva <gns@gnome.org>
    44 *  Copyright (C) 2010 Collabora Ltd.
    5  *  Copyright (C) 2010 Igalia S.L.
     5 *  Copyright (C) 2010, 2011 Igalia S.L.
    66 *
    77 *  This library is free software; you can redistribute it and/or
     
    2323#include "MainFrameScrollbarGtk.h"
    2424
    25 #include "GraphicsContext.h"
    2625#include "GtkVersioning.h"
    2726#include "IntRect.h"
     
    3130using namespace WebCore;
    3231
    33 PassRefPtr<MainFrameScrollbarGtk> MainFrameScrollbarGtk::create(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, GtkAdjustment* adj)
     32PassRefPtr<MainFrameScrollbarGtk> MainFrameScrollbarGtk::create(ScrollableArea* scrollableArea, ScrollbarOrientation orientation)
    3433{
    35     return adoptRef(new MainFrameScrollbarGtk(scrollableArea, orientation, adj));
     34    return adoptRef(new MainFrameScrollbarGtk(scrollableArea, orientation));
    3635}
    3736
    38 // Main frame scrollbars are slaves to a GtkAdjustment. If a main frame
    39 // scrollbar has an m_adjustment, it belongs to the container (a GtkWidget such
    40 // as GtkScrolledWindow). The adjustment may also be null, in which case there
    41 // is no containing view or the parent ScrollView is in some sort of transition
    42 // state. These scrollbars are never painted, as the container takes care of
    43 // that. They exist only to shuttle data from the GtkWidget container into
    44 // WebCore and vice-versa.
    45 MainFrameScrollbarGtk::MainFrameScrollbarGtk(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, GtkAdjustment* adjustment)
     37// A MainFrameScrollbar is just a non-painting scrollbar. Otherwise it is fully
     38// functional. A non-painting scrollbar allows a main-frame ScrollView to use
     39// a containing GtkScrolledWindow as its user interface. The ChromeClient in the
     40// WebKit layer just listens for scrolling and sizing changes and updates its
     41// container (the GtkScrolledWindow) accordingly. The ScrollView is responsible
     42// for deciding whether or not to create a MainFrameScrollbar or native scrollbar.
     43MainFrameScrollbarGtk::MainFrameScrollbarGtk(ScrollableArea* scrollableArea, ScrollbarOrientation orientation)
    4644    : Scrollbar(scrollableArea, orientation, RegularScrollbar)
    47     , m_adjustment(0)
    4845{
    49     attachAdjustment(adjustment);
    50 
    51     // We have nothing to show as we are solely operating on the GtkAdjustment.
     46    // We don't want to take up any space.
    5247    resize(0, 0);
    53 }
    54 
    55 MainFrameScrollbarGtk::~MainFrameScrollbarGtk()
    56 {
    57     if (m_adjustment)
    58         detachAdjustment();
    59 }
    60 
    61 void MainFrameScrollbarGtk::attachAdjustment(GtkAdjustment* adjustment)
    62 {
    63     if (m_adjustment.get() == adjustment)
    64         return;
    65     if (m_adjustment)
    66         detachAdjustment();
    67 
    68     m_adjustment = adjustment;
    69     if (!m_adjustment)
    70         return;
    71 
    72     // In some cases this adjustment may still be attached to a living MainFrameScrollbar.
    73     // If that's the case we want to force a disconnection now, before we modify the values.
    74     g_signal_handlers_disconnect_matched(m_adjustment.get(), G_SIGNAL_MATCH_FUNC, 0, 0, 0,
    75                                          reinterpret_cast<void*>(MainFrameScrollbarGtk::gtkValueChanged), 0);
    76 
    77     updateThumbProportion();
    78     updateThumbPosition();
    79     g_signal_connect(m_adjustment.get(), "value-changed", G_CALLBACK(MainFrameScrollbarGtk::gtkValueChanged), this);
    80 }
    81 
    82 void MainFrameScrollbarGtk::detachAdjustment()
    83 {
    84     if (!m_adjustment)
    85         return;
    86 
    87     g_signal_handlers_disconnect_by_func(G_OBJECT(m_adjustment.get()), (gpointer)MainFrameScrollbarGtk::gtkValueChanged, this);
    88 
    89     // For the case where we only operate on the GtkAdjustment it is best to
    90     // reset the values so that the surrounding scrollbar gets updated, or
    91     // e.g. for a GtkScrolledWindow the scrollbar gets hidden.
    92     gtk_adjustment_configure(m_adjustment.get(), 0, 0, 0, 0, 0, 0);
    93 
    94     m_adjustment = 0;
    95 }
    96 
    97 void MainFrameScrollbarGtk::updateThumbPosition()
    98 {
    99     if (!m_adjustment || gtk_adjustment_get_value(m_adjustment.get()) == m_currentPos)
    100         return;
    101     gtk_adjustment_set_value(m_adjustment.get(), m_currentPos);
    102 }
    103 
    104 void MainFrameScrollbarGtk::updateThumbProportion()
    105 {
    106     if (!m_adjustment)
    107         return;
    108     gtk_adjustment_configure(m_adjustment.get(),
    109                              gtk_adjustment_get_value(m_adjustment.get()),
    110                              gtk_adjustment_get_lower(m_adjustment.get()),
    111                              m_totalSize,
    112                              m_lineStep,
    113                              m_pageStep,
    114                              m_visibleSize);
    115 }
    116 
    117 void MainFrameScrollbarGtk::gtkValueChanged(GtkAdjustment*, MainFrameScrollbarGtk* that)
    118 {
    119     // If we've been removed from our parent, we no longer get to control the WebCore
    120     // scrollbar. If this is the case, deactivate this signal handler. WebCore will
    121     // create a fresh MainFrameScrollbar when the scrollbar reappears.
    122     if (!that->parent()) {
    123         that->detachAdjustment();
    124         return;
    125     }
    126 
    127     int newValue = static_cast<int>(gtk_adjustment_get_value(that->m_adjustment.get()));
    128     if (newValue != that->value())
    129         that->scrollableArea()->scrollToOffsetWithoutAnimation(that->orientation(), newValue);
    13048}
    13149
  • trunk/Source/WebCore/platform/gtk/MainFrameScrollbarGtk.h

    r76378 r86102  
    2121#define MainFrameScrollbarGtk_h
    2222
    23 #include "GRefPtrGtk.h"
    2423#include "Scrollbar.h"
    2524#include <wtf/PassRefPtr.h>
    26 
    27 typedef struct _GtkAdjustment GtkAdjustment;
    2825
    2926namespace WebCore {
     
    3128class MainFrameScrollbarGtk : public Scrollbar {
    3229public:
    33     static PassRefPtr<MainFrameScrollbarGtk> create(ScrollableArea*, ScrollbarOrientation, GtkAdjustment*);
    34 
    35     ~MainFrameScrollbarGtk();
     30    static PassRefPtr<MainFrameScrollbarGtk> create(ScrollableArea*, ScrollbarOrientation);
    3631    virtual void paint(GraphicsContext*, const IntRect&);
    37     void detachAdjustment();
    38     void attachAdjustment(GtkAdjustment*);
    39 
    40 protected:
    41     virtual void updateThumbPosition();
    42     virtual void updateThumbProportion();
    4332
    4433private:
    45     MainFrameScrollbarGtk(ScrollableArea*, ScrollbarOrientation, GtkAdjustment*);
    46     static void gtkValueChanged(GtkAdjustment*, MainFrameScrollbarGtk*);
    47 
    48     GRefPtr<GtkAdjustment> m_adjustment;
     34    MainFrameScrollbarGtk(ScrollableArea*, ScrollbarOrientation);
    4935};
    5036
  • trunk/Source/WebCore/platform/gtk/ScrollViewGtk.cpp

    r85188 r86102  
    3232#include "ScrollView.h"
    3333
    34 #include "ChromeClient.h"
    35 #include "FloatRect.h"
    36 #include "Frame.h"
    37 #include "FrameView.h"
    38 #include "GraphicsContext.h"
    39 #include "GtkVersioning.h"
    4034#include "HostWindow.h"
    41 #include "IntRect.h"
    4235#include "MainFrameScrollbarGtk.h"
    43 #include "Page.h"
    44 #include "PlatformMouseEvent.h"
    45 #include "PlatformWheelEvent.h"
    4636#include "ScrollbarTheme.h"
    4737#include <gtk/gtk.h>
     
    5040
    5141namespace WebCore {
    52 
    53 void ScrollView::platformInit()
    54 {
    55 }
    56 
    57 void ScrollView::platformDestroy()
    58 {
    59     m_horizontalAdjustment = 0;
    60     m_verticalAdjustment = 0;
    61 }
    6242
    6343PassRefPtr<Scrollbar> ScrollView::createScrollbar(ScrollbarOrientation orientation)
     
    7252    // may be null here.
    7353    if (orientation == HorizontalScrollbar)
    74         return MainFrameScrollbarGtk::create(this, orientation, m_horizontalAdjustment.get());
     54        return MainFrameScrollbarGtk::create(this, orientation);
    7555
    7656    // VerticalScrollbar
    77     return MainFrameScrollbarGtk::create(this, orientation, m_verticalAdjustment.get());
    78 }
    79 
    80 void ScrollView::setHorizontalAdjustment(GtkAdjustment* hadj, bool resetValues)
    81 {
    82     ASSERT(!parent() || !hadj);
    83     if (parent())
    84         return;
    85 
    86     m_horizontalAdjustment = hadj;
    87 
    88     if (!m_horizontalAdjustment) {
    89         MainFrameScrollbarGtk* hScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(horizontalScrollbar());
    90         if (hScrollbar)
    91             hScrollbar->detachAdjustment();
    92 
    93         return;
    94     }
    95 
    96     // We may be lacking scrollbars when returning to a cached
    97     // page, this kicks the page to recreate the scrollbars.
    98     setHasHorizontalScrollbar(true);
    99 
    100     MainFrameScrollbarGtk* hScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(horizontalScrollbar());
    101     hScrollbar->attachAdjustment(m_horizontalAdjustment.get());
    102 
    103     // We used to reset everything to 0 here, but when page cache
    104     // is enabled we reuse FrameViews that are cached. Since their
    105     // size is not going to change when being restored, (which is
    106     // what would cause the upper limit in the adjusments to be
    107     // set in the normal case), we make sure they are up-to-date
    108     // here. This is needed for the parent scrolling widget to be
    109     // able to report correct values.
    110     int horizontalPageStep = max(max<int>(frameRect().width() * Scrollbar::minFractionToStepWhenPaging(), frameRect().width() - Scrollbar::maxOverlapBetweenPages()), 1);
    111     gtk_adjustment_configure(m_horizontalAdjustment.get(),
    112                              resetValues ? 0 : scrollOffset().width(), 0,
    113                              resetValues ? 0 : contentsSize().width(),
    114                              resetValues ? 0 : Scrollbar::pixelsPerLineStep(),
    115                              resetValues ? 0 : horizontalPageStep,
    116                              resetValues ? 0 : frameRect().width());
    117 }
    118 
    119 void ScrollView::setVerticalAdjustment(GtkAdjustment* vadj, bool resetValues)
    120 {
    121     ASSERT(!parent() || !vadj);
    122     if (parent())
    123         return;
    124 
    125     m_verticalAdjustment = vadj;
    126 
    127     if (!m_verticalAdjustment) {
    128         MainFrameScrollbarGtk* vScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(verticalScrollbar());
    129         if (vScrollbar)
    130             vScrollbar->detachAdjustment();
    131 
    132         return;
    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     // We used to reset everything to 0 here, but when page cache
    143     // is enabled we reuse FrameViews that are cached. Since their
    144     // size is not going to change when being restored, (which is
    145     // what would cause the upper limit in the adjusments to be
    146     // set in the normal case), we make sure they are up-to-date
    147     // here. This is needed for the parent scrolling widget to be
    148     // able to report correct values.
    149     int verticalPageStep = max(max<int>(frameRect().width() * Scrollbar::minFractionToStepWhenPaging(), frameRect().width() - Scrollbar::maxOverlapBetweenPages()), 1);
    150     gtk_adjustment_configure(m_verticalAdjustment.get(),
    151                              resetValues ? 0 : scrollOffset().height(), 0,
    152                              resetValues ? 0 : contentsSize().height(),
    153                              resetValues ? 0 : Scrollbar::pixelsPerLineStep(),
    154                              resetValues ? 0 : verticalPageStep,
    155                              resetValues ? 0 : frameRect().height());
    156 }
    157 
    158 void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, bool resetValues)
    159 {
    160     setHorizontalAdjustment(hadj, resetValues);
    161     setVerticalAdjustment(vadj, resetValues);
     57    return MainFrameScrollbarGtk::create(this, orientation);
    16258}
    16359
     
    217113    // We don't need to report policy changes on ScrollView's unless this
    218114    // one has an adjustment attached and it is a main frame.
    219     if (!m_horizontalAdjustment || parent() || !isFrameView())
     115    if (parent() || !isFrameView())
    220116        return;
    221117
  • trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp

    r84979 r86102  
    4040#include "Frame.h"
    4141#include "FrameView.h"
     42#include "GRefPtrGtk.h"
    4243#include "GraphicsContext.h"
    4344#include "GtkVersioning.h"
  • trunk/Source/WebKit/gtk/ChangeLog

    r85998 r86102  
     12011-04-29  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Gustavo Noronha Silva.
     4
     5        [GTK] Untangle GtkAdjustments from WebCore
     6        https://bugs.webkit.org/show_bug.cgi?id=59821
     7
     8        Have ChromeClient manage the GtkAdjustments of the parent widget instead of passing
     9        them to WebCore to manage. This simplifies the code quite a bit and should be less
     10        crash prone in the future.
     11
     12        * GNUmakefile.am: Added new GtkAdjustmentWatcher class to the sources list.
     13        * WebCoreSupport/ChromeClientGtk.cpp: Added new GtkAdjustmentWatcher member.
     14        (WebKit::ChromeClient::ChromeClient) Initialize the new member.
     15        (WebKit::ChromeClient::scroll): Poke the adjustment watcher to update the adjustments.
     16        (WebKit::ChromeClient::contentsSizeChanged): Ditto.
     17        (WebKit::ChromeClient::scrollbarsModeDidChange): This may now be called at a time when there
     18        is no main frame, so do an early return in that case.
     19        * WebCoreSupport/ChromeClientGtk.h: Add the new member.
     20        (WebKit::ChromeClient::adjustmentWatcher): Add this getter for WebKitWebView.
     21        * WebCoreSupport/FrameLoaderClientGtk.cpp: Remove calls which pushed the adjustments into
     22        WebCore.
     23        (WebKit::FrameLoaderClient::savePlatformDataToCachedFrame):
     24        (WebKit::postCommitFrameViewSetup):
     25        * WebCoreSupport/GtkAdjustmentWatcher.cpp: Added.
     26        (WebKit::GtkAdjustmentWatcher::GtkAdjustmentWatcher):
     27        (WebKit::updateAdjustmentFromScrollbar):
     28        (WebKit::GtkAdjustmentWatcher::updateAdjustmentsFromScrollbars):
     29        (WebKit::updateAdjustmentCallback):
     30        (WebKit::GtkAdjustmentWatcher::updateAdjustmentsFromScrollbarsLater):
     31        (WebKit::adjustmentValueChangedCallback):
     32        (WebKit::setAdjustment):
     33        (WebKit::GtkAdjustmentWatcher::setHorizontalAdjustment):
     34        (WebKit::GtkAdjustmentWatcher::setVerticalAdjustment):
     35        (WebKit::GtkAdjustmentWatcher::adjustmentValueChanged):
     36        * WebCoreSupport/GtkAdjustmentWatcher.h: Added.
     37        (WebKit::GtkAdjustmentWatcher::horizontalAdjustment):
     38        (WebKit::GtkAdjustmentWatcher::verticalAdjustment):
     39        * webkit/webkitwebview.cpp:
     40        (setHorizontalAdjustment):
     41        (setVerticalAdjustment): Remove the adjustment member. Call into the adjustment watcher.
     42        (getHorizontalAdjustment): Ditto.
     43        (getVerticalAdjustment): Ditto.
     44        (webkit_web_view_size_allocate): Ditto.
     45        (webkit_web_view_set_scroll_adjustments): Ditto.
     46        (webkit_web_view_dispose): Ditto.
     47        (webkit_web_view_init): Ditto.
     48        * webkit/webkitwebviewprivate.h: Ditto.
     49
    1502011-05-06  Kent Tamura  <tkent@chromium.org>
    251
  • trunk/Source/WebKit/gtk/GNUmakefile.am

    r85229 r86102  
    191191        Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.cpp \
    192192        Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.h \
     193        Source/WebKit/gtk/WebCoreSupport/GtkAdjustmentWatcher.cpp \
     194        Source/WebKit/gtk/WebCoreSupport/GtkAdjustmentWatcher.h \
    193195        Source/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp \
    194196        Source/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h \
  • trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp

    r85987 r86102  
    7373ChromeClient::ChromeClient(WebKitWebView* webView)
    7474    : m_webView(webView)
     75    , m_adjustmentWatcher(webView)
    7576    , m_closeSoonTimer(0)
    7677    , m_pendingScrollInvalidations(false)
     
    450451    cairo_region_destroy(invalidRegion);
    451452#endif
     453
     454    m_adjustmentWatcher.updateAdjustmentsFromScrollbarsLater();
    452455}
    453456
     
    486489        || (requisition.width != size.width()))
    487490        gtk_widget_queue_resize_no_redraw(widget);
     491
     492    // If this was a main frame size change, update the scrollbars.
     493    if (frame != frame->page()->mainFrame())
     494        return;
     495    m_adjustmentWatcher.updateAdjustmentsFromScrollbarsLater();
    488496}
    489497
     
    491499{
    492500    WebKitWebFrame* webFrame = webkit_web_view_get_main_frame(m_webView);
     501    if (!webFrame)
     502        return;
    493503
    494504    g_object_notify(G_OBJECT(webFrame), "horizontal-scrollbar-policy");
     
    726736#endif
    727737
    728 
    729 }
     738}
  • trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h

    r85832 r86102  
    2323
    2424#include "ChromeClient.h"
     25#include "GtkAdjustmentWatcher.h"
    2526#include "KURL.h"
    2627#include "PopupMenu.h"
     
    3839    public:
    3940        ChromeClient(WebKitWebView*);
     41        virtual void* webView() const { return m_webView; }
     42        GtkAdjustmentWatcher* adjustmentWatcher() { return &m_adjustmentWatcher; }
    4043
    4144        virtual void chromeDestroyed();
    4245
    43         virtual void* webView() const { return m_webView; }
    4446        virtual void setWindowRect(const WebCore::FloatRect&);
    4547        virtual WebCore::FloatRect windowRect();
     
    153155    private:
    154156        WebKitWebView* m_webView;
     157        GtkAdjustmentWatcher m_adjustmentWatcher;
    155158        WebCore::KURL m_hoveredLinkURL;
    156159        unsigned int m_closeSoonTimer;
  • trunk/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp

    r85785 r86102  
    13471347void FrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame* cachedFrame)
    13481348{
    1349     // We need to do this here in order to disconnect the scrollbars
    1350     // that are being used by the frame that is being cached from the
    1351     // adjustments, otherwise they will react to changes in the
    1352     // adjustments, and bad things will happen.
    1353     if (cachedFrame->view())
    1354         cachedFrame->view()->setGtkAdjustments(0, 0);
    13551349}
    13561350
     
    13591353    WebKitWebView* containingWindow = getViewFromFrame(frame);
    13601354    webkit_web_view_clear_resources(containingWindow);
    1361 
    1362     WebKitWebViewPrivate* priv = containingWindow->priv;
    1363     view->setGtkAdjustments(priv->horizontalAdjustment.get(), priv->verticalAdjustment.get(), resetValues);
    13641355
    13651356    // Invalidate the viewport attributes - they will only be valid
    13661357    // again if the page we're beginning to load now has an
    13671358    // appropriate viewport meta tag.
    1368     containingWindow->priv->viewportAttributes->priv->isValid = FALSE;
    1369     g_object_notify(G_OBJECT(containingWindow->priv->viewportAttributes.get()), "valid");
     1359    WebKitWebViewPrivate* priv = containingWindow->priv;
     1360    priv->viewportAttributes->priv->isValid = FALSE;
     1361    g_object_notify(G_OBJECT(priv->viewportAttributes.get()), "valid");
    13701362
    13711363    if (priv->currentMenu) {
  • trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp

    r85864 r86102  
    7777#include "ResourceHandle.h"
    7878#include "ScriptValue.h"
    79 #include "Scrollbar.h"
    8079#include "Settings.h"
    8180#include "webkit/WebKitDOMDocumentPrivate.h"
     
    425424static void setHorizontalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment)
    426425{
    427     if (!core(webView))
    428         return;
    429 
    430     webView->priv->horizontalAdjustment = adjustment;
    431     FrameView* view = core(webkit_web_view_get_main_frame(webView))->view();
    432     if (!view)
    433         return;
    434     view->setHorizontalAdjustment(adjustment);
     426    // This may be called after the page has been destroyed, in which case we do nothing.
     427    Page* page = core(webView);
     428    if (page)
     429        static_cast<WebKit::ChromeClient*>(page->chrome()->client())->adjustmentWatcher()->setHorizontalAdjustment(adjustment);
    435430}
    436431
    437432static void setVerticalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment)
    438433{
    439     if (!core(webView))
    440         return;
    441 
    442     webView->priv->verticalAdjustment = adjustment;
    443     FrameView* view = core(webkit_web_view_get_main_frame(webView))->view();
    444     if (!view)
    445         return;
    446     view->setVerticalAdjustment(adjustment);
     434    // This may be called after the page has been destroyed, in which case we do nothing.
     435    Page* page = core(webView);
     436    if (page)
     437        static_cast<WebKit::ChromeClient*>(page->chrome()->client())->adjustmentWatcher()->setVerticalAdjustment(adjustment);
    447438}
    448439
    449440static GtkAdjustment* getHorizontalAdjustment(WebKitWebView* webView)
    450441{
    451     return webView->priv->horizontalAdjustment.get();
     442    Page* page = core(webView);
     443    if (page)
     444        return static_cast<WebKit::ChromeClient*>(page->chrome()->client())->horizontalAdjustment();
     445    return 0;
    452446}
    453447
    454448static GtkAdjustment* getVerticalAdjustment(WebKitWebView* webView)
    455449{
    456     return webView->priv->verticalAdjustment.get();
     450    Page* page = core(webView);
     451    if (page)
     452        return static_cast<WebKit::ChromeClient*>(page->chrome()->client())->verticalAdjustment();
     453    return 0;
    457454}
    458455
     
    897894static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
    898895{
    899     GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget,allocation);
     896    GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget, allocation);
    900897
    901898    WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
    902899
    903     Frame* frame = core(webView)->mainFrame();
     900    Page* page = core(webView);
     901    Frame* frame = page->mainFrame();
    904902    if (!frame->view())
    905903        return;
    906904
    907905    frame->view()->resize(allocation->width, allocation->height);
     906    static_cast<WebKit::ChromeClient*>(page->chrome()->client())->adjustmentWatcher()->updateAdjustmentsFromScrollbars();
    908907}
    909908
     
    10251024
    10261025#ifdef GTK_API_VERSION_2
    1027 static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* hadj, GtkAdjustment* vadj)
    1028 {
    1029     if (!core(webView))
     1026static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* horizontalAdjustment, GtkAdjustment* verticalAdjustment)
     1027{
     1028    // This may be called after the page has been destroyed, in which case we do nothing.
     1029    Page* page = core(webView);
     1030    if (!page)
    10301031        return;
    10311032
    1032     webView->priv->horizontalAdjustment = hadj;
    1033     webView->priv->verticalAdjustment = vadj;
    1034 
    1035     FrameView* view = core(webkit_web_view_get_main_frame(webView))->view();
    1036     if (!view)
    1037         return;
    1038     view->setGtkAdjustments(hadj, vadj);
     1033    WebKit::ChromeClient* client = static_cast<WebKit::ChromeClient*>(page->chrome()->client());
     1034    client->adjustmentWatcher()->setHorizontalAdjustment(horizontalAdjustment);
     1035    client->adjustmentWatcher()->setVerticalAdjustment(verticalAdjustment);
    10391036}
    10401037#endif
     
    12991296    // These smart pointers are cleared manually, because some cleanup operations are
    13001297    // very sensitive to their value. We may crash if these are done in the wrong order.
    1301     priv->horizontalAdjustment.clear();
    1302     priv->verticalAdjustment.clear();
    13031298    priv->backForwardList.clear();
    13041299
     
    34723467    priv->viewportAttributes->priv->webView = webView;
    34733468
    3474     // The smart pointer will call g_object_ref_sink on these adjustments.
    3475     priv->horizontalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
    3476     priv->verticalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
    3477 
    34783469    gtk_widget_set_can_focus(GTK_WIDGET(webView), TRUE);
    34793470    priv->mainFrame = WEBKIT_WEB_FRAME(webkit_web_frame_new(webView));
  • trunk/Source/WebKit/gtk/webkit/webkitwebviewprivate.h

    r85221 r86102  
    7272    gboolean transparent;
    7373
    74     GRefPtr<GtkAdjustment> horizontalAdjustment;
    75     GRefPtr<GtkAdjustment> verticalAdjustment;
    76 
    7774#ifndef GTK_API_VERSION_2
    7875    // GtkScrollablePolicy needs to be checked when
Note: See TracChangeset for help on using the changeset viewer.