Changeset 70514 in webkit
- Timestamp:
- Oct 26, 2010 1:37:32 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r70513 r70514 1 2010-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 1 17 2010-10-26 Sheriff Bot <webkit.review.bot@gmail.com> 2 18 -
trunk/WebCore/platform/ScrollView.h
r70509 r70514 342 342 public: 343 343 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); 344 346 void setScrollOffset(const IntSize& offset) { m_scrollOffset = offset; } 345 347 -
trunk/WebCore/platform/gtk/ScrollViewGtk.cpp
r66885 r70514 79 79 } 80 80 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. 81 void ScrollView::setHorizontalAdjustment(GtkAdjustment* hadj, bool resetValues) 82 { 93 83 ASSERT(!parent() || !hadj); 94 84 if (parent()) … … 96 86 97 87 m_horizontalAdjustment = hadj; 98 m_verticalAdjustment = vadj;99 88 100 89 if (!m_horizontalAdjustment) { … … 102 91 if (hScrollbar) 103 92 hScrollbar->detachAdjustment(); 104 105 MainFrameScrollbarGtk* vScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(verticalScrollbar());106 if (vScrollbar)107 vScrollbar->detachAdjustment();108 109 return;110 93 } 111 94 112 95 // We may be lacking scrollbars when returning to a cached 113 96 // page, this kicks the page to recreate the scrollbars. 114 setHasVerticalScrollbar(true);115 97 setHasHorizontalScrollbar(true); 116 98 … … 118 100 hScrollbar->attachAdjustment(m_horizontalAdjustment.get()); 119 101 120 MainFrameScrollbarGtk* vScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(verticalScrollbar());121 vScrollbar->attachAdjustment(m_verticalAdjustment.get());102 if (!m_horizontalAdjustment) 103 return; 122 104 123 105 // We used to reset everything to 0 here, but when page cache … … 128 110 // here. This is needed for the parent scrolling widget to be 129 111 // able to report correct values. 130 131 112 int horizontalPageStep = max(max<int>(frameRect().width() * Scrollbar::minFractionToStepWhenPaging(), frameRect().width() - Scrollbar::maxOverlapBetweenPages()), 1); 132 113 gtk_adjustment_configure(m_horizontalAdjustment.get(), … … 136 117 resetValues ? 0 : horizontalPageStep, 137 118 resetValues ? 0 : frameRect().width()); 138 139 int verticalPageStep = max(max<int>(frameRect().height() * Scrollbar::minFractionToStepWhenPaging(), frameRect().height() - Scrollbar::maxOverlapBetweenPages()), 1); 119 } 120 121 void 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); 140 153 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(), 143 156 resetValues ? 0 : Scrollbar::pixelsPerLineStep(), 144 157 resetValues ? 0 : verticalPageStep, 145 resetValues ? 0 : frameRect().height()); 158 resetValues ? 0 : frameRect().width()); 159 } 160 161 void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, bool resetValues) 162 { 163 setHorizontalAdjustment(hadj, resetValues); 164 setVerticalAdjustment(vadj, resetValues); 146 165 } 147 166 -
trunk/WebKit/gtk/ChangeLog
r70333 r70514 1 2010-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 1 20 2010-10-22 Sam Weinig <sam@webkit.org> 2 21 -
trunk/WebKit/gtk/webkit/webkitwebview.cpp
r69919 r70514 197 197 PROP_ICON_URI, 198 198 PROP_IM_CONTEXT, 199 #ifdef GTK_API_VERSION_2 199 200 PROP_VIEW_MODE 201 #else 202 PROP_VIEW_MODE, 203 PROP_HADJUSTMENT, 204 PROP_VADJUSTMENT 205 #endif 200 206 }; 201 207 202 208 static guint webkit_web_view_signals[LAST_SIGNAL] = { 0, }; 203 209 210 #ifdef GTK_API_VERSION_2 204 211 G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER) 212 #else 213 G_DEFINE_TYPE_WITH_CODE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER, 214 G_IMPLEMENT_INTERFACE(GTK_TYPE_SCROLLABLE, 0)) 215 #endif 205 216 206 217 static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView); … … 385 396 return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event); 386 397 } 398 399 #ifndef GTK_API_VERSION_2 400 static 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 412 static 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 424 static GtkAdjustment* getHorizontalAdjustment(WebKitWebView* webView) 425 { 426 return webView->priv->horizontalAdjustment.get(); 427 } 428 429 static GtkAdjustment* getVerticalAdjustment(WebKitWebView* webView) 430 { 431 return webView->priv->verticalAdjustment.get(); 432 } 433 #endif 387 434 388 435 static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) … … 445 492 g_value_set_enum(value, webkit_web_view_get_view_mode(webView)); 446 493 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 447 502 default: 448 503 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); … … 479 534 webkit_web_view_set_view_mode(webView, static_cast<WebKitWebViewViewMode>(g_value_get_enum(value))); 480 535 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 481 544 default: 482 545 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); … … 909 972 } 910 973 974 #ifdef GTK_API_VERSION_2 911 975 static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* hadj, GtkAdjustment* vadj) 912 976 { … … 922 986 view->setGtkAdjustments(hadj, vadj); 923 987 } 988 #endif 924 989 925 990 static void webkit_web_view_container_add(GtkContainer* container, GtkWidget* widget) … … 2526 2591 * make us scrollable (e.g. addable to a GtkScrolledWindow) 2527 2592 */ 2593 #ifdef GTK_API_VERSION_2 2528 2594 webViewClass->set_scroll_adjustments = webkit_web_view_set_scroll_adjustments; 2529 2595 GTK_WIDGET_CLASS(webViewClass)->set_scroll_adjustments_signal = g_signal_new("set-scroll-adjustments", … … 2535 2601 G_TYPE_NONE, 2, 2536 2602 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 2537 2607 2538 2608 /*
Note: See TracChangeset
for help on using the changeset viewer.