Changeset 141756 in webkit
- Timestamp:
- Feb 4, 2013 4:21:32 AM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r141749 r141756 1 2013-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 1 17 2013-02-04 Balazs Kelemen <kbalazs@webkit.org> 2 18 -
trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
r141310 r141756 66 66 #include <QtQuick/QQuickView> 67 67 #include <WKOpenPanelResultListener.h> 68 #include <WKPageGroup.h> 68 69 #include <WKSerializedScriptValue.h> 70 #include <WKString.h> 69 71 #include <WebCore/IntPoint.h> 70 72 #include <WebCore/IntRect.h> … … 296 298 void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef) 297 299 { 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)); 303 303 304 304 context = contextRef ? QtWebContext::create(toImpl(contextRef)) : QtWebContext::defaultContext(); 305 webPageProxy = context->createWebPage(&pageClient, pageGroup.get());305 webPageProxy = context->createWebPage(&pageClient, toImpl(pageGroup.get())); 306 306 webPageProxy->setUseFixedLayout(s_flickableViewportEnabled); 307 307 #if ENABLE(FULLSCREEN_API) … … 738 738 } 739 739 740 static QStringreadUserScript(const QUrl& url)740 static WKRetainPtr<WKStringRef> readUserScript(const QUrl& url) 741 741 { 742 742 QString path; … … 747 747 else { 748 748 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; 750 750 } 751 751 … … 753 753 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { 754 754 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; 756 756 } 757 757 758 Q String contents = QString::fromUtf8(file.readAll());758 QByteArray contents = file.readAll(); 759 759 if (contents.isEmpty()) 760 760 qWarning("QQuickWebView: Ignoring '%s' as user script because file is empty.", qPrintable(url.toString())); 761 761 762 return contents;762 return adoptWK(WKStringCreateWithUTF8CString(contents.constData())); 763 763 } 764 764 … … 767 767 // This feature works per-WebView because we keep an unique page group for 768 768 // each Page/WebView pair we create. 769 WebPageGroup* pageGroup = webPageProxy->pageGroup(); 770 pageGroup->removeAllUserScripts(); 769 WKPageGroupRemoveAllUserScripts(pageGroup.get()); 771 770 772 771 for (unsigned i = 0; i < userScripts.size(); ++i) { … … 777 776 } 778 777 779 QStringcontents = readUserScript(url);780 if ( contents.isEmpty())778 WKRetainPtr<WKStringRef> contents = readUserScript(url); 779 if (!contents || WKStringIsEmpty(contents.get())) 781 780 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); 783 782 } 784 783 } -
trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
r138618 r141756 34 34 #include <QtCore/QScopedPointer> 35 35 #include <WebCore/ViewportArguments.h> 36 #include <WebKit2/WKRetainPtr.h> 36 37 #include <wtf/OwnPtr.h> 37 38 #include <wtf/RefPtr.h> … … 162 163 RefPtr<WebKit::QtWebContext> context; 163 164 RefPtr<WebKit::WebPageProxy> webPageProxy; 165 WKRetainPtr<WKPageGroupRef> pageGroup; 164 166 165 167 WebKit::QtPageClient pageClient;
Note: See TracChangeset
for help on using the changeset viewer.