Changeset 141756 in webkit


Ignore:
Timestamp:
Feb 4, 2013 4:21:32 AM (11 years ago)
Author:
Simon Hausmann
Message:

[WK2][Qt] Replace WebPageGroup usage for user scripts with WKPageGroupRef
https://bugs.webkit.org/show_bug.cgi?id=108651

Reviewed by Sam Weinig.

It's straight-forward port towards the C API.

  • UIProcess/API/qt/qquickwebview.cpp:

(QQuickWebViewPrivate::initialize):
(readUserScript):
(QQuickWebViewPrivate::updateUserScripts):

  • UIProcess/API/qt/qquickwebview_p_p.h:

(QQuickWebViewPrivate):

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r141749 r141756  
     12013-02-04  Simon Hausmann  <simon.hausmann@digia.com>
     2
     3        [WK2][Qt] Replace WebPageGroup usage for user scripts with WKPageGroupRef
     4        https://bugs.webkit.org/show_bug.cgi?id=108651
     5
     6        Reviewed by Sam Weinig.
     7
     8        It's straight-forward port towards the C API.
     9
     10        * UIProcess/API/qt/qquickwebview.cpp:
     11        (QQuickWebViewPrivate::initialize):
     12        (readUserScript):
     13        (QQuickWebViewPrivate::updateUserScripts):
     14        * UIProcess/API/qt/qquickwebview_p_p.h:
     15        (QQuickWebViewPrivate):
     16
    1172013-02-04  Balazs Kelemen  <kbalazs@webkit.org>
    218
  • trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp

    r141310 r141756  
    6666#include <QtQuick/QQuickView>
    6767#include <WKOpenPanelResultListener.h>
     68#include <WKPageGroup.h>
    6869#include <WKSerializedScriptValue.h>
     70#include <WKString.h>
    6971#include <WebCore/IntPoint.h>
    7072#include <WebCore/IntRect.h>
     
    296298void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
    297299{
    298     RefPtr<WebPageGroup> pageGroup;
    299     if (pageGroupRef)
    300         pageGroup = toImpl(pageGroupRef);
    301     else
    302         pageGroup = WebPageGroup::create();
     300    pageGroup = pageGroupRef;
     301    if (!pageGroup)
     302        pageGroup = adoptWK(WKPageGroupCreateWithIdentifier(0));
    303303
    304304    context = contextRef ? QtWebContext::create(toImpl(contextRef)) : QtWebContext::defaultContext();
    305     webPageProxy = context->createWebPage(&pageClient, pageGroup.get());
     305    webPageProxy = context->createWebPage(&pageClient, toImpl(pageGroup.get()));
    306306    webPageProxy->setUseFixedLayout(s_flickableViewportEnabled);
    307307#if ENABLE(FULLSCREEN_API)
     
    738738}
    739739
    740 static QString readUserScript(const QUrl& url)
     740static WKRetainPtr<WKStringRef> readUserScript(const QUrl& url)
    741741{
    742742    QString path;
     
    747747    else {
    748748        qWarning("QQuickWebView: Couldn't open '%s' as user script because only file:/// and qrc:/// URLs are supported.", qPrintable(url.toString()));
    749         return QString();
     749        return 0;
    750750    }
    751751
     
    753753    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
    754754        qWarning("QQuickWebView: Couldn't open '%s' as user script due to error '%s'.", qPrintable(url.toString()), qPrintable(file.errorString()));
    755         return QString();
     755        return 0;
    756756    }
    757757
    758     QString contents = QString::fromUtf8(file.readAll());
     758    QByteArray contents = file.readAll();
    759759    if (contents.isEmpty())
    760760        qWarning("QQuickWebView: Ignoring '%s' as user script because file is empty.", qPrintable(url.toString()));
    761761
    762     return contents;
     762    return adoptWK(WKStringCreateWithUTF8CString(contents.constData()));
    763763}
    764764
     
    767767    // This feature works per-WebView because we keep an unique page group for
    768768    // each Page/WebView pair we create.
    769     WebPageGroup* pageGroup = webPageProxy->pageGroup();
    770     pageGroup->removeAllUserScripts();
     769    WKPageGroupRemoveAllUserScripts(pageGroup.get());
    771770
    772771    for (unsigned i = 0; i < userScripts.size(); ++i) {
     
    777776        }
    778777
    779         QString contents = readUserScript(url);
    780         if (contents.isEmpty())
     778        WKRetainPtr<WKStringRef> contents = readUserScript(url);
     779        if (!contents || WKStringIsEmpty(contents.get()))
    781780            continue;
    782         pageGroup->addUserScript(String(contents), emptyString(), 0, 0, InjectInTopFrameOnly, InjectAtDocumentEnd);
     781        WKPageGroupAddUserScript(pageGroup.get(), contents.get(), /*baseURL*/ 0, /*whitelistedURLPatterns*/ 0, /*blacklistedURLPatterns*/ 0, kWKInjectInTopFrameOnly, kWKInjectAtDocumentEnd);
    783782    }
    784783}
  • trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h

    r138618 r141756  
    3434#include <QtCore/QScopedPointer>
    3535#include <WebCore/ViewportArguments.h>
     36#include <WebKit2/WKRetainPtr.h>
    3637#include <wtf/OwnPtr.h>
    3738#include <wtf/RefPtr.h>
     
    162163    RefPtr<WebKit::QtWebContext> context;
    163164    RefPtr<WebKit::WebPageProxy> webPageProxy;
     165    WKRetainPtr<WKPageGroupRef> pageGroup;
    164166
    165167    WebKit::QtPageClient pageClient;
Note: See TracChangeset for help on using the changeset viewer.