Changeset 142095 in webkit
- Timestamp:
- Feb 7, 2013 4:34:08 AM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r142087 r142095 1 2013-02-07 Michael Brüning <michael.bruning@digia.com> 2 3 [Qt][WK2] Fold QtWebPageLoadClient into QQuickWebViewPrivate and move to C API. 4 https://bugs.webkit.org/show_bug.cgi?id=108473 5 6 Reviewed by Simon Hausmann. 7 Signed off for WebKit2 by Benjamin Poulain. 8 9 This patch removes the QtWebPageLoadClient and moves the functionality into the 10 QQuickWebViewPrivate as most callback methods are calling the private webview 11 indirectly anyway. 12 13 The patch also moves as much of the functionality to the C API as is possible with 14 the current C API. 15 16 * Target.pri: 17 * UIProcess/API/qt/qquickwebview.cpp: 18 (QQuickWebViewPrivate::initialize): 19 (QQuickWebViewPrivate::didStartProvisionalLoadForFrame): 20 (QQuickWebViewPrivate::didReceiveServerRedirectForProvisionalLoadForFrame): 21 (QQuickWebViewPrivate::didFailLoad): 22 (QQuickWebViewPrivate::didCommitLoadForFrame): 23 (QQuickWebViewPrivate::didFinishLoadForFrame): 24 (QQuickWebViewPrivate::didSameDocumentNavigationForFrame): 25 (QQuickWebViewPrivate::didReceiveTitleForFrame): 26 (QQuickWebViewPrivate::didStartProgress): 27 (QQuickWebViewPrivate::didChangeProgress): 28 (QQuickWebViewPrivate::didFinishProgress): 29 (QQuickWebViewPrivate::didChangeBackForwardList): 30 (QQuickWebViewPrivate::setTransparentBackground): 31 (QQuickWebViewPrivate::transparentBackground): 32 (QQuickWebViewPrivate::loadProgressDidChange): 33 * UIProcess/API/qt/qquickwebview_p.h: 34 (WebKit): 35 * UIProcess/API/qt/qquickwebview_p_p.h: 36 (WebKit): 37 (QQuickWebViewPrivate): 38 * UIProcess/qt/QtWebError.cpp: 39 (WebKit::QtWebError::url): 40 * UIProcess/qt/QtWebPageLoadClient.cpp: Removed. 41 * UIProcess/qt/QtWebPageLoadClient.h: Removed. 42 1 43 2013-02-05 Eunmi Lee <eunmi15.lee@samsung.com> and Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> 2 44 -
trunk/Source/WebKit2/Target.pri
r142073 r142095 786 786 UIProcess/qt/QtDownloadManager.h \ 787 787 UIProcess/qt/QtPageClient.h \ 788 UIProcess/qt/QtWebPageLoadClient.h \789 788 UIProcess/qt/QtWebPagePolicyClient.h \ 790 789 UIProcess/qt/QtWebPageSGNode.h \ … … 813 812 UIProcess/qt/QtDownloadManager.cpp \ 814 813 UIProcess/qt/QtPageClient.cpp \ 815 UIProcess/qt/QtWebPageLoadClient.cpp \816 814 UIProcess/qt/QtWebPagePolicyClient.cpp \ 817 815 UIProcess/qt/QtWebPageSGNode.cpp \ -
trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
r142073 r142095 33 33 #include "QtWebIconDatabaseClient.h" 34 34 #include "QtWebPageEventHandler.h" 35 #include "QtWebPageLoadClient.h"36 35 #include "QtWebPagePolicyClient.h" 37 36 #include "WebBackForwardList.h" … … 331 330 } 332 331 333 pageLoadClient.reset(new QtWebPageLoadClient(webPage.get(), q_ptr)); 332 { 333 WKPageLoaderClient loadClient; 334 memset(&loadClient, 0, sizeof(WKPageLoaderClient)); 335 loadClient.version = kWKPageLoaderClientCurrentVersion; 336 loadClient.clientInfo = this; 337 loadClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame; 338 loadClient.didReceiveServerRedirectForProvisionalLoadForFrame = didReceiveServerRedirectForProvisionalLoadForFrame; 339 loadClient.didFailProvisionalLoadWithErrorForFrame = didFailLoad; 340 loadClient.didCommitLoadForFrame = didCommitLoadForFrame; 341 loadClient.didFinishLoadForFrame = didFinishLoadForFrame; 342 loadClient.didFailLoadWithErrorForFrame = didFailLoad; 343 loadClient.didSameDocumentNavigationForFrame = didSameDocumentNavigationForFrame; 344 loadClient.didReceiveTitleForFrame = didReceiveTitleForFrame; 345 loadClient.didStartProgress = didStartProgress; 346 loadClient.didChangeProgress = didChangeProgress; 347 loadClient.didFinishProgress = didFinishProgress; 348 loadClient.didChangeBackForwardList = didChangeBackForwardList; 349 WKPageSetPageLoaderClient(webPage.get(), &loadClient); 350 } 351 334 352 pagePolicyClient.reset(new QtWebPagePolicyClient(webPage.get(), q_ptr)); 335 353 pageUIClient.reset(new QtWebPageUIClient(webPage.get(), q_ptr)); … … 357 375 } 358 376 359 void QQuickWebViewPrivate::loadDidStop() 360 { 361 Q_Q(QQuickWebView); 377 void QQuickWebViewPrivate::didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void* clientInfo) 378 { 379 if (!WKFrameIsMainFrame(frame)) 380 return; 381 382 WKRetainPtr<WKURLRef> url = adoptWK(WKFrameCopyProvisionalURL(frame)); 383 384 QQuickWebView* const q = toQQuickWebViewPrivate(clientInfo)->q_func(); 385 386 q->emitUrlChangeIfNeeded(); 387 QWebLoadRequest loadRequest(WKURLCopyQUrl(url.get()), QQuickWebView::LoadStartedStatus); 388 emit q->loadingChanged(&loadRequest); 389 } 390 391 void QQuickWebViewPrivate::didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void* clientInfo) 392 { 393 if (!WKFrameIsMainFrame(frame)) 394 return; 395 396 toQQuickWebViewPrivate(clientInfo)->q_func()->emitUrlChangeIfNeeded(); 397 } 398 399 void QQuickWebViewPrivate::didFailLoad(WKPageRef, WKFrameRef frame, WKErrorRef errorRef, WKTypeRef, const void* clientInfo) 400 { 401 if (!WKFrameIsMainFrame(frame)) 402 return; 403 404 QQuickWebView* const q = toQQuickWebViewPrivate(clientInfo)->q_func(); 362 405 ASSERT(!q->loading()); 363 QWebLoadRequest loadRequest(q->url(), QQuickWebView::LoadStoppedStatus); 406 407 QtWebError error(errorRef); 408 if (error.isCancellation()) { 409 QWebLoadRequest loadRequest(q->url(), QQuickWebView::LoadStoppedStatus); 410 emit q->loadingChanged(&loadRequest); 411 return; 412 } 413 414 int errorCode = error.errorCode(); 415 if (errorCode == kWKErrorCodeFrameLoadInterruptedByPolicyChange && errorCode == kWKErrorCodePlugInWillHandleLoad) { 416 QWebLoadRequest loadRequest(q->url(), QQuickWebView::LoadSucceededStatus); 417 q->emitUrlChangeIfNeeded(); 418 emit q->loadingChanged(&loadRequest); 419 return; 420 } 421 422 // We set the unreachable url unconditionally so that the current 423 // active url of the webview when the loadingChanged signal is 424 // emitted reflects the failed url, not the previously committed 425 // url. This also ensures that if the user does not do a loadHtml 426 // with an error page and and unreachable url as a reponse to the 427 // failed load, we can still detect the failed url for reloads. 428 // We need to find a way to do this via the C API or find another 429 // way to do this. 430 toImpl(frame)->setUnreachableURL(error.url()); 431 q->emitUrlChangeIfNeeded(); 432 QWebLoadRequest loadRequest(error.url(), QQuickWebView::LoadFailedStatus, error.description(), static_cast<QQuickWebView::ErrorDomain>(error.type()), errorCode); 364 433 emit q->loadingChanged(&loadRequest); 365 434 } 366 435 367 void QQuickWebViewPrivate::setTransparentBackground(bool enable) 368 { 369 webPageProxy->setDrawsTransparentBackground(enable); 370 } 371 372 bool QQuickWebViewPrivate::transparentBackground() const 373 { 374 return webPageProxy->drawsTransparentBackground(); 375 } 376 377 void QQuickWebViewPrivate::provisionalLoadDidStart(const WTF::String& url) 378 { 379 Q_Q(QQuickWebView); 380 381 q->emitUrlChangeIfNeeded(); 382 383 QWebLoadRequest loadRequest(QString(url), QQuickWebView::LoadStartedStatus); 384 emit q->loadingChanged(&loadRequest); 385 } 386 387 void QQuickWebViewPrivate::didReceiveServerRedirectForProvisionalLoad(const WTF::String&) 388 { 389 Q_Q(QQuickWebView); 390 391 q->emitUrlChangeIfNeeded(); 392 } 393 394 void QQuickWebViewPrivate::loadDidCommit() 395 { 396 Q_Q(QQuickWebView); 436 void QQuickWebViewPrivate::didCommitLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void* clientInfo) 437 { 438 if (!WKFrameIsMainFrame(frame)) 439 return; 440 QQuickWebViewPrivate* d = toQQuickWebViewPrivate(clientInfo); 441 442 PageViewportController* pageViewportController = d->viewportController(); 443 if (pageViewportController) 444 pageViewportController->didCommitLoad(); 445 446 QQuickWebView* const q = d->q_func(); 397 447 ASSERT(q->loading()); 398 399 m_betweenLoadCommitAndFirstFrame = true; 448 d->m_betweenLoadCommitAndFirstFrame = true; 400 449 emit q->navigationHistoryChanged(); 401 450 emit q->titleChanged(); 402 451 } 403 452 404 void QQuickWebViewPrivate::didSameDocumentNavigation() 405 { 406 Q_Q(QQuickWebView); 407 453 void QQuickWebViewPrivate::didFinishLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void* clientInfo) 454 { 455 if (!WKFrameIsMainFrame(frame)) 456 return; 457 458 QQuickWebView* const q = toQQuickWebViewPrivate(clientInfo)->q_func(); 459 ASSERT(!q->loading()); 460 461 QWebLoadRequest loadRequest(q->url(), QQuickWebView::LoadSucceededStatus); 462 emit q->loadingChanged(&loadRequest); 463 } 464 465 void QQuickWebViewPrivate::didSameDocumentNavigationForFrame(WKPageRef, WKFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef userData, const void* clientInfo) 466 { 467 if (!WKFrameIsMainFrame(frame)) 468 return; 469 QQuickWebView* const q = toQQuickWebViewPrivate(clientInfo)->q_func(); 408 470 q->emitUrlChangeIfNeeded(); 409 471 emit q->navigationHistoryChanged(); 410 472 } 411 473 412 void QQuickWebViewPrivate::titleDidChange() 474 void QQuickWebViewPrivate::didReceiveTitleForFrame(WKPageRef, WKStringRef title, WKFrameRef frame, WKTypeRef, const void* clientInfo) 475 { 476 if (!WKFrameIsMainFrame(frame)) 477 return; 478 emit toQQuickWebViewPrivate(clientInfo)->q_func()->titleChanged(); 479 } 480 481 void QQuickWebViewPrivate::didStartProgress(WKPageRef, const void* clientInfo) 482 { 483 toQQuickWebViewPrivate(clientInfo)->loadProgressDidChange(0); 484 } 485 486 void QQuickWebViewPrivate::didChangeProgress(WKPageRef page, const void* clientInfo) 487 { 488 toQQuickWebViewPrivate(clientInfo)->loadProgressDidChange(WKPageGetEstimatedProgress(page) * 100); 489 } 490 491 void QQuickWebViewPrivate::didFinishProgress(WKPageRef, const void* clientInfo) 492 { 493 toQQuickWebViewPrivate(clientInfo)->loadProgressDidChange(100); 494 } 495 496 void QQuickWebViewPrivate::didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef, WKArrayRef, const void *clientInfo) 497 { 498 toQQuickWebViewPrivate(clientInfo)->navigationHistory->d->reset(); 499 } 500 501 void QQuickWebViewPrivate::setTransparentBackground(bool enable) 502 { 503 webPageProxy->setDrawsTransparentBackground(enable); 504 } 505 506 bool QQuickWebViewPrivate::transparentBackground() const 507 { 508 return webPageProxy->drawsTransparentBackground(); 509 } 510 511 void QQuickWebViewPrivate::loadProgressDidChange(int loadProgress) 413 512 { 414 513 Q_Q(QQuickWebView); 415 514 416 emit q->titleChanged();417 }418 419 void QQuickWebViewPrivate::loadProgressDidChange(int loadProgress)420 {421 Q_Q(QQuickWebView);422 423 515 m_loadProgress = loadProgress; 424 516 425 517 emit q->loadProgressChanged(); 426 }427 428 void QQuickWebViewPrivate::backForwardListDidChange()429 {430 navigationHistory->d->reset();431 }432 433 void QQuickWebViewPrivate::loadDidSucceed()434 {435 Q_Q(QQuickWebView);436 ASSERT(!q->loading());437 438 QWebLoadRequest loadRequest(q->url(), QQuickWebView::LoadSucceededStatus);439 emit q->loadingChanged(&loadRequest);440 }441 442 void QQuickWebViewPrivate::loadDidFail(const QtWebError& error)443 {444 Q_Q(QQuickWebView);445 ASSERT(!q->loading());446 447 QWebLoadRequest loadRequest(error.url(), QQuickWebView::LoadFailedStatus, error.description(), static_cast<QQuickWebView::ErrorDomain>(error.type()), error.errorCode());448 emit q->loadingChanged(&loadRequest);449 518 } 450 519 -
trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
r138618 r142095 52 52 struct QtRefCountedNetworkRequestData; 53 53 class PageViewportControllerClientQt; 54 class QtWebPageLoadClient;55 54 class QtWebPageFindClient; 56 55 class QtWebPagePolicyClient; … … 222 221 friend class QWebKitTest; 223 222 friend class WebKit::PageViewportControllerClientQt; 224 friend class WebKit::QtWebPageLoadClient;225 223 friend class WebKit::QtWebPageFindClient; 226 224 friend class WebKit::QtWebPagePolicyClient; -
trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
r142073 r142095 45 45 class QtWebContext; 46 46 class QtWebError; 47 class QtWebPageLoadClient;48 47 class QtWebPagePolicyClient; 49 48 class WebPageProxy; … … 74 73 virtual void onComponentComplete() { } 75 74 76 virtual void provisionalLoadDidStart(const WTF::String& url);77 virtual void didReceiveServerRedirectForProvisionalLoad(const WTF::String& url);78 virtual void loadDidCommit();79 virtual void didSameDocumentNavigation();80 virtual void titleDidChange();81 75 virtual void loadProgressDidChange(int loadProgress); 82 virtual void backForwardListDidChange();83 virtual void loadDidSucceed();84 virtual void loadDidStop();85 virtual void loadDidFail(const WebKit::QtWebError& error);86 76 virtual void handleMouseEvent(QMouseEvent*); 87 77 … … 161 151 }; 162 152 153 // WKPageLoadClient callbacks. 154 static void didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo); 155 static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo); 156 static void didFailLoad(WKPageRef, WKFrameRef, WKErrorRef, WKTypeRef userData, const void* clientInfo); 157 static void didCommitLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo); 158 static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo); 159 static void didSameDocumentNavigationForFrame(WKPageRef, WKFrameRef, WKSameDocumentNavigationType, WKTypeRef userData, const void* clientInfo); 160 static void didReceiveTitleForFrame(WKPageRef, WKStringRef, WKFrameRef, WKTypeRef userData, const void* clientInfo); 161 static void didStartProgress(WKPageRef, const void* clientInfo); 162 static void didChangeProgress(WKPageRef, const void* clientInfo); 163 static void didFinishProgress(WKPageRef, const void* clientInfo); 164 static void didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef, WKArrayRef, const void *clientInfo); 165 163 166 QQuickWebViewPrivate(QQuickWebView* viewport); 164 167 RefPtr<WebKit::QtWebContext> context; … … 172 175 OwnPtr<QWebPreferences> preferences; 173 176 174 QScopedPointer<WebKit::QtWebPageLoadClient> pageLoadClient;175 177 QScopedPointer<WebKit::QtWebPagePolicyClient> pagePolicyClient; 176 178 QScopedPointer<WebKit::QtWebPageUIClient> pageUIClient; -
trunk/Source/WebKit2/UIProcess/qt/QtWebError.cpp
r118148 r142095 58 58 QString QtWebError::url() const 59 59 { 60 return toImpl(error.get())->failingURL();60 return WKStringCopyQString(WKURLCopyString(WKErrorCopyFailingURL(error.get()))); 61 61 } 62 62
Note: See TracChangeset
for help on using the changeset viewer.