diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
index 96fe1fc..7daf541 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
@@ -3679,3 +3679,35 @@ void webkit_web_view_restore_session_state(WebKitWebView* webView, WebKitWebView
 
     getPage(webView)->restoreFromSessionState(webkitWebViewSessionStateGetSessionState(state), false);
 }
+
+/**
+ * webkit_web_view_set_size_request_mode:
+ * @web_view: a #WebKitWebView
+ * @mode: a #WebKitWebViewSizeRequestMode
+ *
+ *
+ * Since: 2.14
+ */
+void webkit_web_view_set_size_request_mode(WebKitWebView* webView, WebKitWebViewSizeRequestMode mode)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+    WebViewBaseSizeRequestMode baseMode = WebViewBaseSizeRequestMode::Default;
+    switch (mode) {
+    case WEBKIT_SIZE_REQUEST_DEFAULT:
+        baseMode = WebViewBaseSizeRequestMode::Default;
+        break;
+    case WEBKIT_SIZE_REQUEST_CONTENTS:
+        baseMode = WebViewBaseSizeRequestMode::Contents;
+        break;
+    case WEBKIT_SIZE_REQUEST_CONTENTS_WIDTH:
+        baseMode = WebViewBaseSizeRequestMode::ContentsWidth;
+        break;
+    case WEBKIT_SIZE_REQUEST_CONTENTS_HEIGHT:
+        baseMode = WebViewBaseSizeRequestMode::ContentsHeight;
+        break;
+    default:
+        g_assert_not_reached();
+    }
+    webkitWebViewBaseSetSizeRequestMode(WEBKIT_WEB_VIEW_BASE(webView), baseMode);
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
index 700968f..0b53d4c 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
@@ -185,6 +185,23 @@ typedef enum {
   WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT,
 } WebKitSnapshotRegion;
 
+/**
+ * WebKitWebViewSizeRequestMode:
+ * @WEBKIT_SIZE_REQUEST_DEFAULT: Default
+ * @WEBKIT_SIZE_REQUEST_CONTENTS: Contents
+ * @WEBKIT_SIZE_REQUEST_CONTENTS_WIDTH: Width
+ * @WEBKIT_SIZE_REQUEST_CONTENTS_HEIGHT: Height
+ *
+ *
+ * Since: 2.14
+ */
+typedef enum {
+    WEBKIT_SIZE_REQUEST_DEFAULT,
+    WEBKIT_SIZE_REQUEST_CONTENTS,
+    WEBKIT_SIZE_REQUEST_CONTENTS_WIDTH,
+    WEBKIT_SIZE_REQUEST_CONTENTS_HEIGHT,
+} WebKitWebViewSizeRequestMode;
+
 struct _WebKitWebView {
     WebKitWebViewBase parent;
 
@@ -513,6 +530,10 @@ WEBKIT_API void
 webkit_web_view_restore_session_state                (WebKitWebView             *web_view,
                                                       WebKitWebViewSessionState *state);
 
+WEBKIT_API void
+webkit_web_view_set_size_request_mode                (WebKitWebView             *web_view,
+                                                      WebKitWebViewSizeRequestMode mode);
+
 G_END_DECLS
 
 #endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
index cb0ae33..7ff8860 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
@@ -29,6 +29,8 @@
 #include "config.h"
 #include "WebKitWebViewBase.h"
 
+#include <stdio.h>
+
 #include "APIPageConfiguration.h"
 #include "DrawingAreaProxyImpl.h"
 #include "InputMethodFilter.h"
@@ -192,6 +194,7 @@ struct _WebKitWebViewBasePrivate {
     KeyBindingTranslator keyBindingTranslator;
     TouchEventsMap touchEvents;
     IntSize contentsSize;
+    WebViewBaseSizeRequestMode sizeRequestMode;
 
     GtkWindow* toplevelOnScreenWindow;
     unsigned long toplevelFocusInEventID;
@@ -700,15 +703,41 @@ static void webkitWebViewBaseSizeAllocate(GtkWidget* widget, GtkAllocation* allo
 static void webkitWebViewBaseGetPreferredWidth(GtkWidget* widget, gint* minimumSize, gint* naturalSize)
 {
     WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;
-    *minimumSize = 0;
     *naturalSize = priv->contentsSize.width();
+    switch (priv->sizeRequestMode) {
+    case WebViewBaseSizeRequestMode::Contents:
+    case WebViewBaseSizeRequestMode::ContentsWidth:
+        if (gtk_widget_get_allocated_width(widget) >= *naturalSize)
+            *minimumSize = 0;
+        else
+            *minimumSize = *naturalSize;
+        break;
+    case WebViewBaseSizeRequestMode::ContentsHeight:
+    case WebViewBaseSizeRequestMode::Default:
+        *minimumSize = 0;
+        break;
+    }
+    printf("   %s: contentsSize:[%d,%d] out:nat:%d min:%d allocated:%d\n", __FUNCTION__, priv->contentsSize.width(), priv->contentsSize.height(), *naturalSize, *minimumSize, gtk_widget_get_allocated_width(widget));
 }
 
 static void webkitWebViewBaseGetPreferredHeight(GtkWidget* widget, gint* minimumSize, gint* naturalSize)
 {
     WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;
-    *minimumSize = 0;
     *naturalSize = priv->contentsSize.height();
+    switch (priv->sizeRequestMode) {
+    case WebViewBaseSizeRequestMode::Contents:
+    case WebViewBaseSizeRequestMode::ContentsHeight:
+        if (gtk_widget_get_allocated_height(widget) >= *naturalSize)
+            *minimumSize = 0;
+        else
+            *minimumSize = *naturalSize;
+        break;
+    case WebViewBaseSizeRequestMode::ContentsWidth:
+    case WebViewBaseSizeRequestMode::Default:
+        *minimumSize = 0;
+        break;
+    }
+    printf("   %s: contentsSize:[%d,%d] out:nat:%d min:%d allocated:%d\n", __FUNCTION__, priv->contentsSize.width(), priv->contentsSize.height(), *naturalSize, *minimumSize, gtk_widget_get_allocated_height(widget));
 }
 
 static void webkitWebViewBaseMap(GtkWidget* widget)
@@ -1531,7 +1560,19 @@ void webkitWebViewBaseSetContentsSize(WebKitWebViewBase* webkitWebViewBase, cons
     WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
     if (priv->contentsSize == contentsSize)
         return;
+    printf ("%s: [%d,%d] ~> [%d,%d]\n", __FUNCTION__, priv->contentsSize.width(), priv->contentsSize.height(), contentsSize.width(), contentsSize.height());
     priv->contentsSize = contentsSize;
+    if (priv->sizeRequestMode != WebViewBaseSizeRequestMode::Default)
+        gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
+}
+
+void webkitWebViewBaseSetSizeRequestMode(WebKitWebViewBase* webkitWebViewBase, WebViewBaseSizeRequestMode mode)
+{
+    WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
+    if (priv->sizeRequestMode == mode)
+        return;
+    priv->sizeRequestMode = mode;
+    gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
 }
 
 void webkitWebViewBaseResetClickCounter(WebKitWebViewBase* webkitWebViewBase)
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
index 9842e00..93ffdad 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
@@ -57,6 +57,9 @@ void webkitWebViewBaseSetInputMethodState(WebKitWebViewBase*, bool enabled);
 void webkitWebViewBaseUpdateTextInputState(WebKitWebViewBase*);
 void webkitWebViewBaseSetContentsSize(WebKitWebViewBase*, const WebCore::IntSize&);
 
+enum class WebViewBaseSizeRequestMode { Default, Contents, ContentsWidth, ContentsHeight };
+void webkitWebViewBaseSetSizeRequestMode(WebKitWebViewBase*, WebViewBaseSizeRequestMode);
+
 void webkitWebViewBaseSetFocus(WebKitWebViewBase*, bool focused);
 bool webkitWebViewBaseIsInWindowActive(WebKitWebViewBase*);
 bool webkitWebViewBaseIsFocused(WebKitWebViewBase*);
