Changeset 31877 in webkit


Ignore:
Timestamp:
Apr 14, 2008 1:06:02 PM (16 years ago)
Author:
alp@webkit.org
Message:

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):
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r31876 r31877  
     12008-04-14  Holger Freyther  <zecke@selfish.org>
     2
     3        Reviewed by Alp Toker.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=18411
     6        Enable Page caching and create FrameViews on the fly
     7
     8        Create the FrameView on the fly and cache pages
     9
     10        - Keep a copy of the GtkAdjustment to be able to reuse it for the
     11          FrameViews
     12        - Do not initially create a FrameView and update the WebKit code to
     13          cope with not having a view.
     14        - Cache seven pages by default.
     15
     16        * platform/gtk/ScrollViewGtk.cpp:
     17        (WebCore::ScrollView::setGtkAdjustments):
     18
    1192008-04-14  David Hyatt  <hyatt@apple.com>
    220
  • trunk/WebCore/platform/gtk/ScrollViewGtk.cpp

    r31235 r31877  
    288288        m_data->setHasHorizontalScrollbar(false);
    289289
    290 #if GLIB_CHECK_VERSION(2,10,0)
    291         g_object_ref_sink(m_data->horizontalAdjustment);
    292         g_object_ref_sink(m_data->verticalAdjustment);
    293 #else
    294290        g_object_ref(m_data->horizontalAdjustment);
    295         gtk_object_sink(GTK_OBJECT(m_data->horizontalAdjustment));
    296291        g_object_ref(m_data->verticalAdjustment);
    297         gtk_object_sink(GTK_OBJECT(m_data->verticalAdjustment));
    298 #endif
    299292    }
    300293
  • trunk/WebKit/gtk/ChangeLog

    r31790 r31877  
     12008-04-14  Holger Freyther  <zecke@selfish.org>
     2
     3        Reviewed by Alp Toker.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=18411
     6        Enable Page caching and create FrameViews on the fly
     7
     8        Create the FrameView on the fly and cache pages
     9
     10        - Keep a copy of the GtkAdjustment to be able to reuse it for the
     11          FrameViews
     12        - Do not initially create a FrameView and update the WebKit code to
     13          cope with not having a view.
     14        - Cache seven pages by default.
     15
     16        * WebCoreSupport/FrameLoaderClientGtk.cpp:
     17        (WebKit::FrameLoaderClient::createFrame):
     18        (WebKit::FrameLoaderClient::canCachePage):
     19        (WebKit::FrameLoaderClient::savePlatformDataToCachedPage):
     20        (WebKit::FrameLoaderClient::transitionToCommittedFromCachedPage):
     21        (WebKit::FrameLoaderClient::transitionToCommittedForNewPage):
     22        * webkit/webkitprivate.cpp:
     23        (webkit_init):
     24        * webkit/webkitprivate.h:
     25        * webkit/webkitwebframe.cpp:
     26        * webkit/webkitwebview.cpp:
     27
    1282008-04-10  Mario Bensi  <mbensi@pleyo.com>
    229
  • trunk/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp

    r31283 r31877  
    3636#include "PlatformString.h"
    3737#include "PluginDatabase.h"
     38#include "RenderPart.h"
    3839#include "ResourceRequest.h"
    3940#include "CString.h"
     
    285286        return 0;
    286287
    287     // Propagate the marginwidth/height and scrolling modes to the view.
    288     if (ownerElement->hasTagName(HTMLNames::frameTag) || ownerElement->hasTagName(HTMLNames::iframeTag)) {
    289         HTMLFrameElement* frameElt = static_cast<HTMLFrameElement*>(ownerElement);
    290         if (frameElt->scrollingMode() == ScrollbarAlwaysOff)
    291             childFrame->view()->setScrollbarsMode(ScrollbarAlwaysOff);
    292         int marginWidth = frameElt->getMarginWidth();
    293         int marginHeight = frameElt->getMarginHeight();
    294         if (marginWidth != -1)
    295             childFrame->view()->setMarginWidth(marginWidth);
    296         if (marginHeight != -1)
    297             childFrame->view()->setMarginHeight(marginHeight);
    298     }
    299 
    300288    return childFrame.release();
    301289}
     
    709697bool FrameLoaderClient::canCachePage() const
    710698{
    711     notImplemented();
    712     return false;
     699    return true;
    713700}
    714701
     
    741728void FrameLoaderClient::savePlatformDataToCachedPage(CachedPage*)
    742729{
    743     notImplemented();
    744730}
    745731
    746732void FrameLoaderClient::transitionToCommittedFromCachedPage(CachedPage*)
    747733{
    748     notImplemented();
    749734}
    750735
    751736void FrameLoaderClient::transitionToCommittedForNewPage()
    752737{
    753     notImplemented();
    754 }
    755 
    756 }
     738    Frame* frame = core(m_frame);
     739    ASSERT(frame);
     740
     741    Page* page = frame->page();
     742    ASSERT(page);
     743
     744    WebKitWebView* containingWindow = getViewFromFrame(m_frame);
     745    bool isMainFrame = frame == page->mainFrame();
     746    frame->setView(0);
     747
     748    FrameView* frameView;
     749    if (isMainFrame) {
     750        IntSize size = IntSize(GTK_WIDGET(containingWindow)->allocation.width,
     751                               GTK_WIDGET(containingWindow)->allocation.height);
     752        frameView = new FrameView(frame, size);
     753        WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(containingWindow);
     754        frameView->setGtkAdjustments(priv->horizontalAdjustment, priv->verticalAdjustment);
     755    } else
     756        frameView = new FrameView(frame);
     757
     758    frame->setView(frameView);
     759    // FrameViews are created with a ref count of 1. Release this ref since we've assigned it to frame.
     760    frameView->deref();
     761    frameView->setContainingWindow(GTK_WIDGET(containingWindow));
     762
     763    if (frame->ownerRenderer())
     764        frame->ownerRenderer()->setWidget(frameView);
     765
     766    if (!frame->ownerElement())
     767        return;
     768
     769    HTMLFrameOwnerElement* ownerElement = frame->ownerElement();
     770    if (ownerElement->hasTagName(HTMLNames::frameTag) || ownerElement->hasTagName(HTMLNames::iframeTag)) {
     771        HTMLFrameElement* frameElt = static_cast<HTMLFrameElement*>(ownerElement);
     772        if (frameElt->scrollingMode() == ScrollbarAlwaysOff)
     773            frameView->setScrollbarsMode(ScrollbarAlwaysOff);
     774        int marginWidth = frameElt->getMarginWidth();
     775        int marginHeight = frameElt->getMarginHeight();
     776        if (marginWidth != -1)
     777            frameView->setMarginWidth(marginWidth);
     778        if (marginHeight != -1)
     779            frameView->setMarginHeight(marginHeight);
     780    }
     781}
     782
     783}
  • trunk/WebKit/gtk/webkit/webkitprivate.cpp

    r31730 r31877  
    2626#include "Logging.h"
    2727#include "NotImplemented.h"
     28#include "PageCache.h"
    2829#include "Pasteboard.h"
    2930#include "PasteboardHelperGtk.h"
     
    9495    WebCore::InitializeLoggingChannelsIfNecessary();
    9596
     97    // FIXME: Expose this with an API
     98    WebCore::pageCache()->setCapacity(7);
     99
    96100#if ENABLE(DATABASE)
    97101    // FIXME: It should be possible for client applications to override this default location
  • trunk/WebKit/gtk/webkit/webkitprivate.h

    r31480 r31877  
    8686
    8787        gboolean transparent;
     88
     89        GtkAdjustment* horizontalAdjustment;
     90        GtkAdjustment* verticalAdjustment;
    8891    };
    8992
  • trunk/WebKit/gtk/webkit/webkitwebframe.cpp

    r31123 r31877  
    218218    WebKitWebViewPrivate* viewPriv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
    219219
     220    priv->webView = webView;
    220221    priv->client = new WebKit::FrameLoaderClient(frame);
    221222    priv->coreFrame = new Frame(viewPriv->corePage, 0, priv->client);
    222 
    223     FrameView* frameView = new FrameView(priv->coreFrame.get());
    224     frameView->setContainingWindow(GTK_WIDGET(webView));
    225     frameView->setGtkAdjustments(GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)),
    226                                  GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)));
    227     priv->coreFrame->setView(frameView);
    228     frameView->deref();
    229223    priv->coreFrame->init();
    230     priv->webView = webView;
    231224
    232225    return frame;
     
    239232    WebKitWebViewPrivate* viewPriv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
    240233
     234    priv->webView = webView;
    241235    priv->client = new WebKit::FrameLoaderClient(frame);
    242236    priv->coreFrame = new Frame(viewPriv->corePage, element, priv->client);
    243 
    244     FrameView* frameView = new FrameView(priv->coreFrame.get());
    245     frameView->setContainingWindow(GTK_WIDGET(webView));
    246     priv->coreFrame->setView(frameView);
    247     frameView->deref();
    248237    priv->coreFrame->init();
    249     priv->webView = webView;
    250238
    251239    return frame;
     
    489477    FrameView* view = coreFrame->view();
    490478
    491     if (view->layoutPending())
     479    if (view && view->layoutPending())
    492480        view->layout();
    493481
  • trunk/WebKit/gtk/webkit/webkitwebview.cpp

    r31676 r31877  
    115115    page->contextMenuController()->clearContextMenu();
    116116    Frame* focusedFrame = page->focusController()->focusedOrMainFrame();
     117
     118    if (!focusedFrame->view())
     119        return FALSE;
     120
    117121    focusedFrame->view()->setCursor(pointerCursor());
    118122    bool handledEvent = focusedFrame->eventHandler()->sendContextMenuEvent(event);
     
    152156    Page* page = core(WEBKIT_WEB_VIEW(widget));
    153157    FrameView* view = page->mainFrame()->view();
     158    if (!view)
     159        return FALSE;   
     160
    154161    Position start = page->mainFrame()->selectionController()->selection().start();
    155162    Position end = page->mainFrame()->selectionController()->selection().end();
     
    252259    GraphicsContext ctx(cr);
    253260    ctx.setGdkExposeEvent(event);
    254     if (frame->renderer()) {
     261    if (frame->renderer() && frame->view()) {
    255262        frame->view()->layoutIfNeededRecursive();
    256263
     
    275282    Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
    276283    PlatformKeyboardEvent keyboardEvent(event);
     284
     285    if (!frame->view())
     286        return FALSE;
    277287
    278288    if (frame->eventHandler()->keyEvent(keyboardEvent))
     
    318328
    319329    Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
     330    if (!frame->view())
     331        return FALSE;
     332
    320333    PlatformKeyboardEvent keyboardEvent(event);
    321334
     
    338351    if (event->button == 3)
    339352        return webkit_web_view_forward_context_menu_event(webView, PlatformMouseEvent(event));
     353
     354    if (!frame->view())
     355        return FALSE;
    340356
    341357    return frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
     
    357373    }
    358374
     375    if (!focusedFrame->view())
     376        return FALSE;
     377
    359378    return focusedFrame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event));
    360379}
     
    365384
    366385    Frame* frame = core(webView)->mainFrame();
     386    if (!frame->view())
     387        return FALSE;
     388
    367389    return frame->eventHandler()->mouseMoved(PlatformMouseEvent(event));
    368390}
     
    373395
    374396    Frame* frame = core(webView)->mainFrame();
     397    if (!frame->view())
     398        return FALSE;
     399
    375400    PlatformWheelEvent wheelEvent(event);
    376401    return frame->eventHandler()->handleWheelEvent(wheelEvent);
     
    384409
    385410    Frame* frame = core(webView)->mainFrame();
     411    if (!frame->view())
     412        return;
     413
    386414    frame->view()->resize(allocation->width, allocation->height);
    387415    frame->forceLayout();
     
    439467{
    440468    FrameView* view = core(webkit_web_view_get_main_frame(webView))->view();
     469
     470    if (hadj)
     471        g_object_ref(hadj);
     472    if (vadj)
     473        g_object_ref(vadj);
     474
     475    WebKitWebViewPrivate* priv = webView->priv;
     476
     477    if (priv->horizontalAdjustment)
     478        g_object_unref(priv->horizontalAdjustment);
     479    if (priv->verticalAdjustment)
     480        g_object_unref(priv->verticalAdjustment);
     481
     482    priv->horizontalAdjustment = hadj;
     483    priv->verticalAdjustment = vadj;
     484
     485    if (!view)
     486        return;
     487
    441488    view->setGtkAdjustments(hadj, vadj);
    442489}
     
    632679    delete priv->corePage;
    633680
     681    if (priv->horizontalAdjustment)
     682        g_object_unref(priv->horizontalAdjustment);
     683    if (priv->verticalAdjustment)
     684        g_object_unref(priv->verticalAdjustment);
    634685    g_object_unref(priv->backForwardList);
    635686    g_object_unref(priv->webSettings);
     
    12491300    priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient, new WebKit::EditorClient(webView), new WebKit::DragClient, new WebKit::InspectorClient);
    12501301
     1302    priv->horizontalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
     1303    priv->verticalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
     1304
     1305#if GLIB_CHECK_VERSION(2,10,0)
     1306    g_object_ref_sink(priv->horizontalAdjustment);
     1307    g_object_ref_sink(priv->verticalAdjustment);
     1308#else
     1309    g_object_ref(priv->horizontalAdjustment);
     1310    gtk_object_sink(GTK_OBJECT(priv->horizontalAdjustment));
     1311    g_object_ref(priv->verticalAdjustment);
     1312    gtk_object_sink(GTK_OBJECT(priv->verticalAdjustment));
     1313#endif
     1314
    12511315    GTK_WIDGET_SET_FLAGS(webView, GTK_CAN_FOCUS);
    12521316    priv->mainFrame = WEBKIT_WEB_FRAME(webkit_web_frame_new(webView));
Note: See TracChangeset for help on using the changeset viewer.