Skip to content
Permalink
Browse files
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):

Canonical link: https://commits.webkit.org/61048@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70514 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Xan Lopez committed Oct 26, 2010
1 parent 28d01df commit e8501dcf09ca5e5c7d90d787c81f511e5065536e
Showing 5 changed files with 152 additions and 26 deletions.
@@ -1,3 +1,19 @@
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.

2010-10-26 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r70512.
@@ -341,6 +341,8 @@ class ScrollView : public Widget, public ScrollbarClient {
#if PLATFORM(GTK)
public:
void setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, bool resetValues = true);
void setHorizontalAdjustment(GtkAdjustment* hadj, bool resetValues = true);
void setVerticalAdjustment(GtkAdjustment* vadj, bool resetValues = true);
void setScrollOffset(const IntSize& offset) { m_scrollOffset = offset; }

private:
@@ -78,47 +78,29 @@ PassRefPtr<Scrollbar> ScrollView::createScrollbar(ScrollbarOrientation orientati
return MainFrameScrollbarGtk::create(this, orientation, m_verticalAdjustment.get());
}

/*
* The following is assumed:
* (hadj && vadj) || (!hadj && !vadj)
*/
void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, bool resetValues)
void ScrollView::setHorizontalAdjustment(GtkAdjustment* hadj, bool resetValues)
{
ASSERT(!hadj == !vadj);

// If this is a non-main frame ScrollView, we do not want to set the
// m_horizontalAdjustments & m_verticalAdjustments members. At the same
// time we want to to allow FrameLoaderClientGtk.cpp to call
// ScrollView::setGtkAdjustments(0, 0) unconditionally.
ASSERT(!parent() || !hadj);
if (parent())
return;

m_horizontalAdjustment = hadj;
m_verticalAdjustment = vadj;

if (!m_horizontalAdjustment) {
MainFrameScrollbarGtk* hScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(horizontalScrollbar());
if (hScrollbar)
hScrollbar->detachAdjustment();

MainFrameScrollbarGtk* vScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(verticalScrollbar());
if (vScrollbar)
vScrollbar->detachAdjustment();

return;
}

// We may be lacking scrollbars when returning to a cached
// page, this kicks the page to recreate the scrollbars.
setHasVerticalScrollbar(true);
setHasHorizontalScrollbar(true);

MainFrameScrollbarGtk* hScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(horizontalScrollbar());
hScrollbar->attachAdjustment(m_horizontalAdjustment.get());

MainFrameScrollbarGtk* vScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(verticalScrollbar());
vScrollbar->attachAdjustment(m_verticalAdjustment.get());
if (!m_horizontalAdjustment)
return;

// We used to reset everything to 0 here, but when page cache
// is enabled we reuse FrameViews that are cached. Since their
@@ -127,22 +109,59 @@ void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, boo
// set in the normal case), we make sure they are up-to-date
// here. This is needed for the parent scrolling widget to be
// able to report correct values.

int horizontalPageStep = max(max<int>(frameRect().width() * Scrollbar::minFractionToStepWhenPaging(), frameRect().width() - Scrollbar::maxOverlapBetweenPages()), 1);
gtk_adjustment_configure(m_horizontalAdjustment.get(),
resetValues ? 0 : scrollOffset().width(), 0,
resetValues ? 0 : contentsSize().width(),
resetValues ? 0 : Scrollbar::pixelsPerLineStep(),
resetValues ? 0 : horizontalPageStep,
resetValues ? 0 : frameRect().width());
}

int verticalPageStep = max(max<int>(frameRect().height() * Scrollbar::minFractionToStepWhenPaging(), frameRect().height() - Scrollbar::maxOverlapBetweenPages()), 1);
void ScrollView::setVerticalAdjustment(GtkAdjustment* vadj, bool resetValues)
{
ASSERT(!parent() || !vadj);
if (parent())
return;

m_verticalAdjustment = vadj;

if (!m_verticalAdjustment) {
MainFrameScrollbarGtk* vScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(verticalScrollbar());
if (vScrollbar)
vScrollbar->detachAdjustment();
}

// We may be lacking scrollbars when returning to a cached
// page, this kicks the page to recreate the scrollbars.
setHasVerticalScrollbar(true);

MainFrameScrollbarGtk* vScrollbar = reinterpret_cast<MainFrameScrollbarGtk*>(verticalScrollbar());
vScrollbar->attachAdjustment(m_verticalAdjustment.get());

if (!m_verticalAdjustment)
return;

// We used to reset everything to 0 here, but when page cache
// is enabled we reuse FrameViews that are cached. Since their
// size is not going to change when being restored, (which is
// what would cause the upper limit in the adjusments to be
// set in the normal case), we make sure they are up-to-date
// here. This is needed for the parent scrolling widget to be
// able to report correct values.
int verticalPageStep = max(max<int>(frameRect().width() * Scrollbar::minFractionToStepWhenPaging(), frameRect().width() - Scrollbar::maxOverlapBetweenPages()), 1);
gtk_adjustment_configure(m_verticalAdjustment.get(),
resetValues ? 0 : scrollOffset().height(), 0,
resetValues ? 0 : contentsSize().height(),
resetValues ? 0 : scrollOffset().width(), 0,
resetValues ? 0 : contentsSize().width(),
resetValues ? 0 : Scrollbar::pixelsPerLineStep(),
resetValues ? 0 : verticalPageStep,
resetValues ? 0 : frameRect().height());
resetValues ? 0 : frameRect().width());
}

void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, bool resetValues)
{
setHorizontalAdjustment(hadj, resetValues);
setVerticalAdjustment(vadj, resetValues);
}

void ScrollView::platformAddChild(Widget* child)
@@ -1,3 +1,22 @@
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):

2010-10-22 Sam Weinig <sam@webkit.org>

Reviewed by Anders Carlsson.
@@ -196,12 +196,23 @@ enum {
PROP_CUSTOM_ENCODING,
PROP_ICON_URI,
PROP_IM_CONTEXT,
#ifdef GTK_API_VERSION_2
PROP_VIEW_MODE
#else
PROP_VIEW_MODE,
PROP_HADJUSTMENT,
PROP_VADJUSTMENT
#endif
};

static guint webkit_web_view_signals[LAST_SIGNAL] = { 0, };

#ifdef GTK_API_VERSION_2
G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER)
#else
G_DEFINE_TYPE_WITH_CODE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER,
G_IMPLEMENT_INTERFACE(GTK_TYPE_SCROLLABLE, 0))
#endif

static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView);
static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures);
@@ -385,6 +396,42 @@ static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget)
return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event);
}

#ifndef GTK_API_VERSION_2
static void setHorizontalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment)
{
if (!core(webView))
return;

webView->priv->horizontalAdjustment = adjustment;
FrameView* view = core(webkit_web_view_get_main_frame(webView))->view();
if (!view)
return;
view->setHorizontalAdjustment(adjustment);
}

static void setVerticalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment)
{
if (!core(webView))
return;

webView->priv->verticalAdjustment = adjustment;
FrameView* view = core(webkit_web_view_get_main_frame(webView))->view();
if (!view)
return;
view->setVerticalAdjustment(adjustment);
}

static GtkAdjustment* getHorizontalAdjustment(WebKitWebView* webView)
{
return webView->priv->horizontalAdjustment.get();
}

static GtkAdjustment* getVerticalAdjustment(WebKitWebView* webView)
{
return webView->priv->verticalAdjustment.get();
}
#endif

static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
{
WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
@@ -444,6 +491,14 @@ static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue*
case PROP_VIEW_MODE:
g_value_set_enum(value, webkit_web_view_get_view_mode(webView));
break;
#ifndef GTK_API_VERSION_2
case PROP_HADJUSTMENT:
g_value_set_object(value, getHorizontalAdjustment(webView));
break;
case PROP_VADJUSTMENT:
g_value_set_object(value, getVerticalAdjustment(webView));
break;
#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
@@ -478,6 +533,14 @@ static void webkit_web_view_set_property(GObject* object, guint prop_id, const G
case PROP_VIEW_MODE:
webkit_web_view_set_view_mode(webView, static_cast<WebKitWebViewViewMode>(g_value_get_enum(value)));
break;
#ifndef GTK_API_VERSION_2
case PROP_HADJUSTMENT:
setHorizontalAdjustment(webView, static_cast<GtkAdjustment*>(g_value_get_object(value)));
break;
case PROP_VADJUSTMENT:
setVerticalAdjustment(webView, static_cast<GtkAdjustment*>(g_value_get_object(value)));
break;
#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
@@ -908,6 +971,7 @@ static void webkit_web_view_realize(GtkWidget* widget)
gtk_im_context_set_client_window(priv->imContext.get(), window);
}

#ifdef GTK_API_VERSION_2
static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* hadj, GtkAdjustment* vadj)
{
if (!core(webView))
@@ -921,6 +985,7 @@ static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAd
return;
view->setGtkAdjustments(hadj, vadj);
}
#endif

static void webkit_web_view_container_add(GtkContainer* container, GtkWidget* widget)
{
@@ -2525,6 +2590,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
/*
* make us scrollable (e.g. addable to a GtkScrolledWindow)
*/
#ifdef GTK_API_VERSION_2
webViewClass->set_scroll_adjustments = webkit_web_view_set_scroll_adjustments;
GTK_WIDGET_CLASS(webViewClass)->set_scroll_adjustments_signal = g_signal_new("set-scroll-adjustments",
G_TYPE_FROM_CLASS(webViewClass),
@@ -2534,6 +2600,10 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
webkit_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE, 2,
GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
#else
g_object_class_override_property(objectClass, PROP_HADJUSTMENT, "hadjustment");
g_object_class_override_property(objectClass, PROP_VADJUSTMENT, "vadjustment");
#endif

/*
* Key bindings

0 comments on commit e8501dc

Please sign in to comment.