Changeset 86102 in webkit
- Timestamp:
- May 9, 2011 4:24:56 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r86100 r86102 1 2011-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 1 27 2011-05-09 Adam Barth <abarth@webkit.org> 2 28 -
trunk/Source/WebCore/platform/ScrollView.cpp
r85188 r86102 1246 1246 } 1247 1247 1248 #if !PLATFORM(WX) && !PLATFORM( GTK) && !PLATFORM(EFL)1248 #if !PLATFORM(WX) && !PLATFORM(EFL) 1249 1249 1250 1250 void ScrollView::platformInit() -
trunk/Source/WebCore/platform/ScrollView.h
r84752 r86102 40 40 #endif 41 41 42 #if PLATFORM(GTK)43 #include "GRefPtrGtk.h"44 typedef struct _GtkAdjustment GtkAdjustment;45 #endif46 47 42 #if PLATFORM(WX) 48 43 class wxScrollWinEvent; … … 403 398 #endif 404 399 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 #endif416 417 400 #if PLATFORM(WX) 418 401 public: -
trunk/Source/WebCore/platform/gtk/MainFrameScrollbarGtk.cpp
r84793 r86102 3 3 * Copyright (C) 2010 Gustavo Noronha Silva <gns@gnome.org> 4 4 * Copyright (C) 2010 Collabora Ltd. 5 * Copyright (C) 2010 Igalia S.L.5 * Copyright (C) 2010, 2011 Igalia S.L. 6 6 * 7 7 * This library is free software; you can redistribute it and/or … … 23 23 #include "MainFrameScrollbarGtk.h" 24 24 25 #include "GraphicsContext.h"26 25 #include "GtkVersioning.h" 27 26 #include "IntRect.h" … … 31 30 using namespace WebCore; 32 31 33 PassRefPtr<MainFrameScrollbarGtk> MainFrameScrollbarGtk::create(ScrollableArea* scrollableArea, ScrollbarOrientation orientation , GtkAdjustment* adj)32 PassRefPtr<MainFrameScrollbarGtk> MainFrameScrollbarGtk::create(ScrollableArea* scrollableArea, ScrollbarOrientation orientation) 34 33 { 35 return adoptRef(new MainFrameScrollbarGtk(scrollableArea, orientation , adj));34 return adoptRef(new MainFrameScrollbarGtk(scrollableArea, orientation)); 36 35 } 37 36 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. 43 MainFrameScrollbarGtk::MainFrameScrollbarGtk(ScrollableArea* scrollableArea, ScrollbarOrientation orientation) 46 44 : Scrollbar(scrollableArea, orientation, RegularScrollbar) 47 , m_adjustment(0)48 45 { 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. 52 47 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 to90 // reset the values so that the surrounding scrollbar gets updated, or91 // 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 WebCore120 // scrollbar. If this is the case, deactivate this signal handler. WebCore will121 // 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);130 48 } 131 49 -
trunk/Source/WebCore/platform/gtk/MainFrameScrollbarGtk.h
r76378 r86102 21 21 #define MainFrameScrollbarGtk_h 22 22 23 #include "GRefPtrGtk.h"24 23 #include "Scrollbar.h" 25 24 #include <wtf/PassRefPtr.h> 26 27 typedef struct _GtkAdjustment GtkAdjustment;28 25 29 26 namespace WebCore { … … 31 28 class MainFrameScrollbarGtk : public Scrollbar { 32 29 public: 33 static PassRefPtr<MainFrameScrollbarGtk> create(ScrollableArea*, ScrollbarOrientation, GtkAdjustment*); 34 35 ~MainFrameScrollbarGtk(); 30 static PassRefPtr<MainFrameScrollbarGtk> create(ScrollableArea*, ScrollbarOrientation); 36 31 virtual void paint(GraphicsContext*, const IntRect&); 37 void detachAdjustment();38 void attachAdjustment(GtkAdjustment*);39 40 protected:41 virtual void updateThumbPosition();42 virtual void updateThumbProportion();43 32 44 33 private: 45 MainFrameScrollbarGtk(ScrollableArea*, ScrollbarOrientation, GtkAdjustment*); 46 static void gtkValueChanged(GtkAdjustment*, MainFrameScrollbarGtk*); 47 48 GRefPtr<GtkAdjustment> m_adjustment; 34 MainFrameScrollbarGtk(ScrollableArea*, ScrollbarOrientation); 49 35 }; 50 36 -
trunk/Source/WebCore/platform/gtk/ScrollViewGtk.cpp
r85188 r86102 32 32 #include "ScrollView.h" 33 33 34 #include "ChromeClient.h"35 #include "FloatRect.h"36 #include "Frame.h"37 #include "FrameView.h"38 #include "GraphicsContext.h"39 #include "GtkVersioning.h"40 34 #include "HostWindow.h" 41 #include "IntRect.h"42 35 #include "MainFrameScrollbarGtk.h" 43 #include "Page.h"44 #include "PlatformMouseEvent.h"45 #include "PlatformWheelEvent.h"46 36 #include "ScrollbarTheme.h" 47 37 #include <gtk/gtk.h> … … 50 40 51 41 namespace WebCore { 52 53 void ScrollView::platformInit()54 {55 }56 57 void ScrollView::platformDestroy()58 {59 m_horizontalAdjustment = 0;60 m_verticalAdjustment = 0;61 }62 42 63 43 PassRefPtr<Scrollbar> ScrollView::createScrollbar(ScrollbarOrientation orientation) … … 72 52 // may be null here. 73 53 if (orientation == HorizontalScrollbar) 74 return MainFrameScrollbarGtk::create(this, orientation , m_horizontalAdjustment.get());54 return MainFrameScrollbarGtk::create(this, orientation); 75 55 76 56 // 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); 162 58 } 163 59 … … 217 113 // We don't need to report policy changes on ScrollView's unless this 218 114 // one has an adjustment attached and it is a main frame. 219 if ( !m_horizontalAdjustment ||parent() || !isFrameView())115 if (parent() || !isFrameView()) 220 116 return; 221 117 -
trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp
r84979 r86102 40 40 #include "Frame.h" 41 41 #include "FrameView.h" 42 #include "GRefPtrGtk.h" 42 43 #include "GraphicsContext.h" 43 44 #include "GtkVersioning.h" -
trunk/Source/WebKit/gtk/ChangeLog
r85998 r86102 1 2011-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 1 50 2011-05-06 Kent Tamura <tkent@chromium.org> 2 51 -
trunk/Source/WebKit/gtk/GNUmakefile.am
r85229 r86102 191 191 Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.cpp \ 192 192 Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.h \ 193 Source/WebKit/gtk/WebCoreSupport/GtkAdjustmentWatcher.cpp \ 194 Source/WebKit/gtk/WebCoreSupport/GtkAdjustmentWatcher.h \ 193 195 Source/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp \ 194 196 Source/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h \ -
trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
r85987 r86102 73 73 ChromeClient::ChromeClient(WebKitWebView* webView) 74 74 : m_webView(webView) 75 , m_adjustmentWatcher(webView) 75 76 , m_closeSoonTimer(0) 76 77 , m_pendingScrollInvalidations(false) … … 450 451 cairo_region_destroy(invalidRegion); 451 452 #endif 453 454 m_adjustmentWatcher.updateAdjustmentsFromScrollbarsLater(); 452 455 } 453 456 … … 486 489 || (requisition.width != size.width())) 487 490 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(); 488 496 } 489 497 … … 491 499 { 492 500 WebKitWebFrame* webFrame = webkit_web_view_get_main_frame(m_webView); 501 if (!webFrame) 502 return; 493 503 494 504 g_object_notify(G_OBJECT(webFrame), "horizontal-scrollbar-policy"); … … 726 736 #endif 727 737 728 729 } 738 } -
trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h
r85832 r86102 23 23 24 24 #include "ChromeClient.h" 25 #include "GtkAdjustmentWatcher.h" 25 26 #include "KURL.h" 26 27 #include "PopupMenu.h" … … 38 39 public: 39 40 ChromeClient(WebKitWebView*); 41 virtual void* webView() const { return m_webView; } 42 GtkAdjustmentWatcher* adjustmentWatcher() { return &m_adjustmentWatcher; } 40 43 41 44 virtual void chromeDestroyed(); 42 45 43 virtual void* webView() const { return m_webView; }44 46 virtual void setWindowRect(const WebCore::FloatRect&); 45 47 virtual WebCore::FloatRect windowRect(); … … 153 155 private: 154 156 WebKitWebView* m_webView; 157 GtkAdjustmentWatcher m_adjustmentWatcher; 155 158 WebCore::KURL m_hoveredLinkURL; 156 159 unsigned int m_closeSoonTimer; -
trunk/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
r85785 r86102 1347 1347 void FrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame* cachedFrame) 1348 1348 { 1349 // We need to do this here in order to disconnect the scrollbars1350 // that are being used by the frame that is being cached from the1351 // adjustments, otherwise they will react to changes in the1352 // adjustments, and bad things will happen.1353 if (cachedFrame->view())1354 cachedFrame->view()->setGtkAdjustments(0, 0);1355 1349 } 1356 1350 … … 1359 1353 WebKitWebView* containingWindow = getViewFromFrame(frame); 1360 1354 webkit_web_view_clear_resources(containingWindow); 1361 1362 WebKitWebViewPrivate* priv = containingWindow->priv;1363 view->setGtkAdjustments(priv->horizontalAdjustment.get(), priv->verticalAdjustment.get(), resetValues);1364 1355 1365 1356 // Invalidate the viewport attributes - they will only be valid 1366 1357 // again if the page we're beginning to load now has an 1367 1358 // 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"); 1370 1362 1371 1363 if (priv->currentMenu) { -
trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp
r85864 r86102 77 77 #include "ResourceHandle.h" 78 78 #include "ScriptValue.h" 79 #include "Scrollbar.h"80 79 #include "Settings.h" 81 80 #include "webkit/WebKitDOMDocumentPrivate.h" … … 425 424 static void setHorizontalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment) 426 425 { 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); 435 430 } 436 431 437 432 static void setVerticalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment) 438 433 { 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); 447 438 } 448 439 449 440 static GtkAdjustment* getHorizontalAdjustment(WebKitWebView* webView) 450 441 { 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; 452 446 } 453 447 454 448 static GtkAdjustment* getVerticalAdjustment(WebKitWebView* webView) 455 449 { 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; 457 454 } 458 455 … … 897 894 static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation) 898 895 { 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); 900 897 901 898 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 902 899 903 Frame* frame = core(webView)->mainFrame(); 900 Page* page = core(webView); 901 Frame* frame = page->mainFrame(); 904 902 if (!frame->view()) 905 903 return; 906 904 907 905 frame->view()->resize(allocation->width, allocation->height); 906 static_cast<WebKit::ChromeClient*>(page->chrome()->client())->adjustmentWatcher()->updateAdjustmentsFromScrollbars(); 908 907 } 909 908 … … 1025 1024 1026 1025 #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)) 1026 static 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) 1030 1031 return; 1031 1032 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); 1039 1036 } 1040 1037 #endif … … 1299 1296 // These smart pointers are cleared manually, because some cleanup operations are 1300 1297 // very sensitive to their value. We may crash if these are done in the wrong order. 1301 priv->horizontalAdjustment.clear();1302 priv->verticalAdjustment.clear();1303 1298 priv->backForwardList.clear(); 1304 1299 … … 3472 3467 priv->viewportAttributes->priv->webView = webView; 3473 3468 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 3478 3469 gtk_widget_set_can_focus(GTK_WIDGET(webView), TRUE); 3479 3470 priv->mainFrame = WEBKIT_WEB_FRAME(webkit_web_frame_new(webView)); -
trunk/Source/WebKit/gtk/webkit/webkitwebviewprivate.h
r85221 r86102 72 72 gboolean transparent; 73 73 74 GRefPtr<GtkAdjustment> horizontalAdjustment;75 GRefPtr<GtkAdjustment> verticalAdjustment;76 77 74 #ifndef GTK_API_VERSION_2 78 75 // GtkScrollablePolicy needs to be checked when
Note: See TracChangeset
for help on using the changeset viewer.