Commit f3e867a0 authored by alp@webkit.org's avatar alp@webkit.org

2008-04-14 Holger Freyther <zecke@selfish.org>

        Reviewed by Alp Toker.

        https://bugs.webkit.org/show_bug.cgi?id=18411
        Enable Page caching and create FrameViews on the fly

        Create the FrameView on the fly and cache pages

        - Keep a copy of the GtkAdjustment to be able to reuse it for the
          FrameViews
        - Do not initially create a FrameView and update the WebKit code to
          cope with not having a view.
        - Cache seven pages by default.

        * platform/gtk/ScrollViewGtk.cpp:
        (WebCore::ScrollView::setGtkAdjustments):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31877 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2ddd9396
2008-04-14 Holger Freyther <zecke@selfish.org>
Reviewed by Alp Toker.
https://bugs.webkit.org/show_bug.cgi?id=18411
Enable Page caching and create FrameViews on the fly
Create the FrameView on the fly and cache pages
- Keep a copy of the GtkAdjustment to be able to reuse it for the
FrameViews
- Do not initially create a FrameView and update the WebKit code to
cope with not having a view.
- Cache seven pages by default.
* platform/gtk/ScrollViewGtk.cpp:
(WebCore::ScrollView::setGtkAdjustments):
2008-04-14 David Hyatt <hyatt@apple.com>
Add a new optimized layout path for positioned objects that move. Also avoid always marking the <html>
......@@ -287,15 +287,8 @@ void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj)
m_data->setHasVerticalScrollbar(false);
m_data->setHasHorizontalScrollbar(false);
#if GLIB_CHECK_VERSION(2,10,0)
g_object_ref_sink(m_data->horizontalAdjustment);
g_object_ref_sink(m_data->verticalAdjustment);
#else
g_object_ref(m_data->horizontalAdjustment);
gtk_object_sink(GTK_OBJECT(m_data->horizontalAdjustment));
g_object_ref(m_data->verticalAdjustment);
gtk_object_sink(GTK_OBJECT(m_data->verticalAdjustment));
#endif
}
updateScrollbars(m_data->scrollOffset);
......
2008-04-14 Holger Freyther <zecke@selfish.org>
Reviewed by Alp Toker.
https://bugs.webkit.org/show_bug.cgi?id=18411
Enable Page caching and create FrameViews on the fly
Create the FrameView on the fly and cache pages
- Keep a copy of the GtkAdjustment to be able to reuse it for the
FrameViews
- Do not initially create a FrameView and update the WebKit code to
cope with not having a view.
- Cache seven pages by default.
* WebCoreSupport/FrameLoaderClientGtk.cpp:
(WebKit::FrameLoaderClient::createFrame):
(WebKit::FrameLoaderClient::canCachePage):
(WebKit::FrameLoaderClient::savePlatformDataToCachedPage):
(WebKit::FrameLoaderClient::transitionToCommittedFromCachedPage):
(WebKit::FrameLoaderClient::transitionToCommittedForNewPage):
* webkit/webkitprivate.cpp:
(webkit_init):
* webkit/webkitprivate.h:
* webkit/webkitwebframe.cpp:
* webkit/webkitwebview.cpp:
2008-04-10 Mario Bensi <mbensi@pleyo.com>
Reviewed by Alp Toker.
......
......@@ -35,6 +35,7 @@
#include "NotImplemented.h"
#include "PlatformString.h"
#include "PluginDatabase.h"
#include "RenderPart.h"
#include "ResourceRequest.h"
#include "CString.h"
#include "ProgressTracker.h"
......@@ -284,19 +285,6 @@ PassRefPtr<Frame> FrameLoaderClient::createFrame(const KURL& url, const String&
if (!childFrame->tree()->parent())
return 0;
// Propagate the marginwidth/height and scrolling modes to the view.
if (ownerElement->hasTagName(HTMLNames::frameTag) || ownerElement->hasTagName(HTMLNames::iframeTag)) {
HTMLFrameElement* frameElt = static_cast<HTMLFrameElement*>(ownerElement);
if (frameElt->scrollingMode() == ScrollbarAlwaysOff)
childFrame->view()->setScrollbarsMode(ScrollbarAlwaysOff);
int marginWidth = frameElt->getMarginWidth();
int marginHeight = frameElt->getMarginHeight();
if (marginWidth != -1)
childFrame->view()->setMarginWidth(marginWidth);
if (marginHeight != -1)
childFrame->view()->setMarginHeight(marginHeight);
}
return childFrame.release();
}
......@@ -708,8 +696,7 @@ bool FrameLoaderClient::shouldFallBack(const ResourceError&)
bool FrameLoaderClient::canCachePage() const
{
notImplemented();
return false;
return true;
}
Frame* FrameLoaderClient::dispatchCreatePage()
......@@ -740,17 +727,57 @@ void FrameLoaderClient::updateGlobalHistory(const KURL&)
void FrameLoaderClient::savePlatformDataToCachedPage(CachedPage*)
{
notImplemented();
}
void FrameLoaderClient::transitionToCommittedFromCachedPage(CachedPage*)
{
notImplemented();
}
void FrameLoaderClient::transitionToCommittedForNewPage()
{
notImplemented();
Frame* frame = core(m_frame);
ASSERT(frame);
Page* page = frame->page();
ASSERT(page);
WebKitWebView* containingWindow = getViewFromFrame(m_frame);
bool isMainFrame = frame == page->mainFrame();
frame->setView(0);
FrameView* frameView;
if (isMainFrame) {
IntSize size = IntSize(GTK_WIDGET(containingWindow)->allocation.width,
GTK_WIDGET(containingWindow)->allocation.height);
frameView = new FrameView(frame, size);
WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(containingWindow);
frameView->setGtkAdjustments(priv->horizontalAdjustment, priv->verticalAdjustment);
} else
frameView = new FrameView(frame);
frame->setView(frameView);
// FrameViews are created with a ref count of 1. Release this ref since we've assigned it to frame.
frameView->deref();
frameView->setContainingWindow(GTK_WIDGET(containingWindow));
if (frame->ownerRenderer())
frame->ownerRenderer()->setWidget(frameView);
if (!frame->ownerElement())
return;
HTMLFrameOwnerElement* ownerElement = frame->ownerElement();
if (ownerElement->hasTagName(HTMLNames::frameTag) || ownerElement->hasTagName(HTMLNames::iframeTag)) {
HTMLFrameElement* frameElt = static_cast<HTMLFrameElement*>(ownerElement);
if (frameElt->scrollingMode() == ScrollbarAlwaysOff)
frameView->setScrollbarsMode(ScrollbarAlwaysOff);
int marginWidth = frameElt->getMarginWidth();
int marginHeight = frameElt->getMarginHeight();
if (marginWidth != -1)
frameView->setMarginWidth(marginWidth);
if (marginHeight != -1)
frameView->setMarginHeight(marginHeight);
}
}
}
......@@ -25,6 +25,7 @@
#include "FrameLoaderClientGtk.h"
#include "Logging.h"
#include "NotImplemented.h"
#include "PageCache.h"
#include "Pasteboard.h"
#include "PasteboardHelperGtk.h"
#include <kjs/InitializeThreading.h>
......@@ -93,6 +94,9 @@ void webkit_init()
KJS::initializeThreading();
WebCore::InitializeLoggingChannelsIfNecessary();
// FIXME: Expose this with an API
WebCore::pageCache()->setCapacity(7);
#if ENABLE(DATABASE)
// FIXME: It should be possible for client applications to override this default location
gchar* databaseDirectory = g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL);
......
......@@ -85,6 +85,9 @@ extern "C" {
GtkTargetList* paste_target_list;
gboolean transparent;
GtkAdjustment* horizontalAdjustment;
GtkAdjustment* verticalAdjustment;
};
#define WEBKIT_WEB_FRAME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_FRAME, WebKitWebFramePrivate))
......
......@@ -217,17 +217,10 @@ WebKitWebFrame* webkit_web_frame_new(WebKitWebView* webView)
WebKitWebFramePrivate* priv = frame->priv;
WebKitWebViewPrivate* viewPriv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
priv->webView = webView;
priv->client = new WebKit::FrameLoaderClient(frame);
priv->coreFrame = new Frame(viewPriv->corePage, 0, priv->client);
FrameView* frameView = new FrameView(priv->coreFrame.get());
frameView->setContainingWindow(GTK_WIDGET(webView));
frameView->setGtkAdjustments(GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)),
GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)));
priv->coreFrame->setView(frameView);
frameView->deref();
priv->coreFrame->init();
priv->webView = webView;
return frame;
}
......@@ -238,15 +231,10 @@ WebKitWebFrame* webkit_web_frame_init_with_web_view(WebKitWebView* webView, HTML
WebKitWebFramePrivate* priv = frame->priv;
WebKitWebViewPrivate* viewPriv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
priv->webView = webView;
priv->client = new WebKit::FrameLoaderClient(frame);
priv->coreFrame = new Frame(viewPriv->corePage, element, priv->client);
FrameView* frameView = new FrameView(priv->coreFrame.get());
frameView->setContainingWindow(GTK_WIDGET(webView));
priv->coreFrame->setView(frameView);
frameView->deref();
priv->coreFrame->init();
priv->webView = webView;
return frame;
}
......@@ -488,7 +476,7 @@ gchar* webkit_web_frame_get_inner_text(WebKitWebFrame* frame)
FrameView* view = coreFrame->view();
if (view->layoutPending())
if (view && view->layoutPending())
view->layout();
Element* documentElement = coreFrame->document()->documentElement();
......
......@@ -114,6 +114,10 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie
Page* page = core(webView);
page->contextMenuController()->clearContextMenu();
Frame* focusedFrame = page->focusController()->focusedOrMainFrame();
if (!focusedFrame->view())
return FALSE;
focusedFrame->view()->setCursor(pointerCursor());
bool handledEvent = focusedFrame->eventHandler()->sendContextMenuEvent(event);
if (!handledEvent)
......@@ -151,6 +155,9 @@ static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget)
// The context menu event was generated from the keyboard, so show the context menu by the current selection.
Page* page = core(WEBKIT_WEB_VIEW(widget));
FrameView* view = page->mainFrame()->view();
if (!view)
return FALSE;
Position start = page->mainFrame()->selectionController()->selection().start();
Position end = page->mainFrame()->selectionController()->selection().end();
......@@ -251,7 +258,7 @@ static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose*
cairo_t* cr = gdk_cairo_create(event->window);
GraphicsContext ctx(cr);
ctx.setGdkExposeEvent(event);
if (frame->renderer()) {
if (frame->renderer() && frame->view()) {
frame->view()->layoutIfNeededRecursive();
if (priv->transparent) {
......@@ -275,6 +282,9 @@ static gboolean webkit_web_view_key_press_event(GtkWidget* widget, GdkEventKey*
Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
PlatformKeyboardEvent keyboardEvent(event);
if (!frame->view())
return FALSE;
if (frame->eventHandler()->keyEvent(keyboardEvent))
return TRUE;
......@@ -317,6 +327,9 @@ static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
if (!frame->view())
return FALSE;
PlatformKeyboardEvent keyboardEvent(event);
if (frame->eventHandler()->keyEvent(keyboardEvent))
......@@ -338,6 +351,9 @@ static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventBu
if (event->button == 3)
return webkit_web_view_forward_context_menu_event(webView, PlatformMouseEvent(event));
if (!frame->view())
return FALSE;
return frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
}
......@@ -356,6 +372,9 @@ static gboolean webkit_web_view_button_release_event(GtkWidget* widget, GdkEvent
#endif
}
if (!focusedFrame->view())
return FALSE;
return focusedFrame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event));
}
......@@ -364,6 +383,9 @@ static gboolean webkit_web_view_motion_event(GtkWidget* widget, GdkEventMotion*
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
Frame* frame = core(webView)->mainFrame();
if (!frame->view())
return FALSE;
return frame->eventHandler()->mouseMoved(PlatformMouseEvent(event));
}
......@@ -372,6 +394,9 @@ static gboolean webkit_web_view_scroll_event(GtkWidget* widget, GdkEventScroll*
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
Frame* frame = core(webView)->mainFrame();
if (!frame->view())
return FALSE;
PlatformWheelEvent wheelEvent(event);
return frame->eventHandler()->handleWheelEvent(wheelEvent);
}
......@@ -383,6 +408,9 @@ static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allo
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
Frame* frame = core(webView)->mainFrame();
if (!frame->view())
return;
frame->view()->resize(allocation->width, allocation->height);
frame->forceLayout();
frame->view()->adjustViewSize();
......@@ -438,6 +466,25 @@ static void webkit_web_view_realize(GtkWidget* widget)
static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* hadj, GtkAdjustment* vadj)
{
FrameView* view = core(webkit_web_view_get_main_frame(webView))->view();
if (hadj)
g_object_ref(hadj);
if (vadj)
g_object_ref(vadj);
WebKitWebViewPrivate* priv = webView->priv;
if (priv->horizontalAdjustment)
g_object_unref(priv->horizontalAdjustment);
if (priv->verticalAdjustment)
g_object_unref(priv->verticalAdjustment);
priv->horizontalAdjustment = hadj;
priv->verticalAdjustment = vadj;
if (!view)
return;
view->setGtkAdjustments(hadj, vadj);
}
......@@ -631,6 +678,10 @@ static void webkit_web_view_finalize(GObject* object)
core(priv->mainFrame)->loader()->detachChildren();
delete priv->corePage;
if (priv->horizontalAdjustment)
g_object_unref(priv->horizontalAdjustment);
if (priv->verticalAdjustment)
g_object_unref(priv->verticalAdjustment);
g_object_unref(priv->backForwardList);
g_object_unref(priv->webSettings);
g_object_unref(priv->mainFrame);
......@@ -1248,6 +1299,19 @@ static void webkit_web_view_init(WebKitWebView* webView)
priv->imContext = gtk_im_multicontext_new();
priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient, new WebKit::EditorClient(webView), new WebKit::DragClient, new WebKit::InspectorClient);
priv->horizontalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
priv->verticalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
#if GLIB_CHECK_VERSION(2,10,0)
g_object_ref_sink(priv->horizontalAdjustment);
g_object_ref_sink(priv->verticalAdjustment);
#else
g_object_ref(priv->horizontalAdjustment);
gtk_object_sink(GTK_OBJECT(priv->horizontalAdjustment));
g_object_ref(priv->verticalAdjustment);
gtk_object_sink(GTK_OBJECT(priv->verticalAdjustment));
#endif
GTK_WIDGET_SET_FLAGS(webView, GTK_CAN_FOCUS);
priv->mainFrame = WEBKIT_WEB_FRAME(webkit_web_frame_new(webView));
priv->lastPopupXPosition = priv->lastPopupYPosition = -1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment