From cc4b16095359b4af1fdf80e8fe3540811e9445bf Mon Sep 17 00:00:00 2001 From: "hausmann@webkit.org" Date: Thu, 22 Nov 2012 13:57:53 +0000 Subject: [PATCH] [Qt] Separate QWidget dependant code into separate WebKitWidgets static library https://bugs.webkit.org/show_bug.cgi?id=102800 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Simon Hausmann , Pierre Rossi on 2012-11-22 Reviewed by Tor Arne Vestbø. This patch separates code that needs to use QWidget related APIs in WebKit/qt/WebCoreSupport and Api from code that doesn't. This means for example FrameLoaderClientQt.cpp remains in the WebKit1 static library, while qwebpage.cpp and qwebframe.cpp become part of the WebKitWidgets static library. WebKit1 is compiled without QT += widgets and therefore any widget related dependency has been moved "up" and out of WebKit1 into the WebKitWidgets library. Between the code in WebKit.a and WebKitWidgets.a new adapters and interfaces have been introduced, such as QWebPageAdapter and QWebFrameAdapter. QWebPageAdapter, when used from WebKit1, is a way to call out into the API layer, implemented by QWebPage (QWebPagePrivate). The other way around if QWebPage wants to access WebCore or WebCoreSupport related functionality, it will go through QWebPageAdapater (as base class). The separation in the direction up into the API layer is complete with this patch, no code in WebKit1 depends on QtWidgets. The separation the other way around, code in the API layer not using any WebCore types, is not complete yet. Some classes such as QWebSettings, QWebElement or DumpRenderTreeSupportQt remain in WebKit1. While they are API layer, they do not depend on widget related Qt APIs and they make much more use of WebCore internal APIs and therefore are easier to keep in WebKit1. In the future we plan to place a real shared library boundary between WebKit1 and WebKitWidgets, by keeping the WebKit1 static library as part of the QtWebKit shared library and by turning the WebKitWidgets static library into a shared one. .: * Source/api.pri: * WebKit.pro: Source/WebCore: * platform/qt/QWebPageClient.h: (QWebPageClient): Source/WebKit: * WebKit1.pri: * WebKit1.pro: * WebKitWidgets.pri: Copied from Source/WebKit/WebKit1.pri. * WebKitWidgets.pro: Added. Source/WebKit/qt: * Api/qgraphicswebview.cpp: (QGraphicsWebViewPrivate::pageClient): (QGraphicsWebViewPrivate::detachCurrentPage): (QGraphicsWebView::setPage): * Api/qwebelement.cpp: (QWebElement::webFrame): * Api/qwebframe.cpp: (QWebFramePrivate::setPage): (QWebFramePrivate::didStartProvisionalLoad): (QWebFramePrivate::handleProgressFinished): (QWebFramePrivate::emitInitialLayoutCompleted): (QWebFramePrivate::emitIconChanged): (QWebFramePrivate::emitLoadStarted): (QWebFramePrivate::emitLoadFinished): (QWebFramePrivate::createChildFrame): (QWebFramePrivate::apiHandle): (QWebFramePrivate::handle): (QWebFramePrivate::contentsSizeDidChange): (QWebFramePrivate::scrollBarPolicy): (QWebFrame::QWebFrame): (QWebFrame::~QWebFrame): (QWebFrame::setUrl): (QWebFrame::load): (QWebFrame::scrollPosition): (QWebFrame::geometry): (QWebFramePrivate::kit): (QWebFrame::handle): * Api/qwebframe.h: * Api/qwebframe_p.h: (QWebFramePrivate::QWebFramePrivate): (QWebFramePrivate): * Api/qwebhistory.cpp: (QWebHistoryPrivate::page): * Api/qwebhistory_p.h: (QWebHistoryPrivate): * Api/qwebinspector.cpp: (QWebInspectorPrivate::setFrontend): * Api/qwebinspector_p.h: (QWebInspectorPrivate): * Api/qwebpage.cpp: (QWebPagePrivate::QWebPagePrivate): (QWebPagePrivate::~QWebPagePrivate): (QWebPagePrivate::core): (QWebPagePrivate::show): (QWebPagePrivate::setFocus): (QWebPagePrivate::unfocus): (QWebPagePrivate::setWindowRect): (QWebPagePrivate::viewportSize): (QWebPagePrivate::createWindow): (QWebPagePrivate::javaScriptConsoleMessage): (QWebPagePrivate::javaScriptAlert): (QWebPagePrivate::javaScriptConfirm): (QWebPagePrivate::javaScriptPrompt): (QWebPagePrivate::printRequested): (QWebPagePrivate::databaseQuotaExceeded): (QWebPagePrivate::applicationCacheQuotaExceeded): (QWebPagePrivate::setToolTip): (QWebPagePrivate::createFullScreenVideoHandler): (QWebPagePrivate::mainFrameAdapter): (QWebPagePrivate::chooseFiles): (QWebPagePrivate::acceptNavigationRequest): (QWebPagePrivate::emitRestoreFrameStateRequested): (QWebPagePrivate::emitSaveFrameStateRequested): (QWebPagePrivate::emitDownloadRequested): (QWebPagePrivate::emitFrameCreated): (QWebPagePrivate::errorPageExtension): (QWebPagePrivate::createPlugin): (QWebPagePrivate::adapterForWidget): (QWebPagePrivate::createMainFrame): (QWebPagePrivate::createContextMenu): (QWebPagePrivate::inspectorHandle): (QWebPagePrivate::setInspectorFrontend): (QWebPagePrivate::setInspectorWindowTitle): (QWebPagePrivate::createWebInspector): (iterateContextMenu): (QWebPagePrivate::menuActionsAsText): (QWebPagePrivate::emitViewportChangeRequested): (QWebPagePrivate::mouseMoveEvent): (QWebPagePrivate::mousePressEvent): (QWebPagePrivate::mouseDoubleClickEvent): (QWebPagePrivate::mouseTripleClickEvent): (QWebPagePrivate::mouseReleaseEvent): (QWebPagePrivate::handleSoftwareInputPanel): (QWebPagePrivate::wheelEvent): (QWebPagePrivate::gestureEvent): (QWebPage::setView): (QWebPage::javaScriptConsoleMessage): (QWebPage::javaScriptAlert): (QWebPage::javaScriptConfirm): (QWebPage::javaScriptPrompt): (QWebPage::shouldInterruptJavaScript): (QWebPage::setFeaturePermission): (QWebPagePrivate::colorSelectionRequested): (QWebPagePrivate::createSelectPopup): (QWebPagePrivate::viewRectRelativeToWindow): (QWebPagePrivate::geolocationPermissionRequested): (QWebPagePrivate::geolocationPermissionRequestCancelled): (QWebPagePrivate::notificationsPermissionRequested): (QWebPagePrivate::notificationsPermissionRequestCancelled): (QWebPagePrivate::respondToChangedContents): (QWebPagePrivate::respondToChangedSelection): (QWebPagePrivate::microFocusChanged): (QWebPagePrivate::triggerCopyAction): (QWebPagePrivate::triggerActionForKeyEvent): (QWebPagePrivate::clearUndoStack): (QWebPagePrivate::canUndo): (QWebPagePrivate::canRedo): (QWebPagePrivate::undo): (QWebPagePrivate::redo): (QWebPagePrivate::createUndoStep): (QWebPagePrivate::editorCommandForKeyEvent): (QWebPage::viewportSize): (QWebPage::setViewportSize): (QWebPage::viewportAttributesForSize): (QWebPage::event): (QWebPage::extension): (QWebPage::handle): (QWebPage::chooseFile): (QWebPage::setNetworkAccessManager): (QWebPage::networkAccessManager): * Api/qwebpage.h: * Api/qwebpage_p.h: (WebCore): (QWebPagePrivate): * Api/qwebsettings.cpp: * Api/qwebsettings.h: * Api/qwebview.cpp: (QWebViewPrivate::detachCurrentPage): * WebCoreSupport/ChromeClientQt.cpp: (WebCore::ChromeClientQt::ChromeClientQt): (WebCore::ChromeClientQt::setWindowRect): (WebCore::ChromeClientQt::focus): (WebCore::ChromeClientQt::unfocus): (WebCore::ChromeClientQt::createWindow): (WebCore::ChromeClientQt::show): (WebCore::ChromeClientQt::setToolbarsVisible): (WebCore::ChromeClientQt::setStatusbarVisible): (WebCore::ChromeClientQt::setMenubarVisible): (WebCore::ChromeClientQt::addMessageToConsole): (WebCore::ChromeClientQt::closeWindowSoon): (WebCore::ChromeClientQt::runJavaScriptAlert): (WebCore::ChromeClientQt::runJavaScriptConfirm): (WebCore::ChromeClientQt::runJavaScriptPrompt): (WebCore::ChromeClientQt::setStatusbarText): (WebCore::ChromeClientQt::shouldInterruptJavaScript): (WebCore::ChromeClientQt::keyboardUIMode): (WebCore::ChromeClientQt::windowResizerRect): * WebCoreSupport/ChromeClientQt.h: (ChromeClientQt): * WebCoreSupport/ContextMenuClientQt.cpp: * WebCoreSupport/ContextMenuClientQt.h: (ContextMenuClientQt): * WebCoreSupport/DefaultFullScreenVideoHandler.cpp: Added. (DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler): (DefaultFullScreenVideoHandler::~DefaultFullScreenVideoHandler): (DefaultFullScreenVideoHandler::requiresFullScreenForVideoPlayback): (DefaultFullScreenVideoHandler::enterFullScreen): (DefaultFullScreenVideoHandler::exitFullScreen): * WebCoreSupport/DefaultFullScreenVideoHandler.h: Copied from Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h. (WebKit): (DefaultFullScreenVideoHandler): * WebCoreSupport/DragClientQt.cpp: (WebCore::DragClientQt::startDrag): * WebCoreSupport/DragClientQt.h: (WebCore): (WebCore::DragClientQt::DragClientQt): (DragClientQt): * WebCoreSupport/DumpRenderTreeSupportQt.cpp: (toGeolocationClientMock): (toDeviceOrientationClientMock): (DumpRenderTreeSupportQt::initialize): (DumpRenderTreeSupportQt::setDumpRenderTreeModeEnabled): (DumpRenderTreeSupportQt::setFrameFlatteningEnabled): (DumpRenderTreeSupportQt::webPageSetGroupName): (DumpRenderTreeSupportQt::webPageGroupName): (DumpRenderTreeSupportQt::webInspectorExecuteScript): (DumpRenderTreeSupportQt::webInspectorShow): (DumpRenderTreeSupportQt::webInspectorClose): (DumpRenderTreeSupportQt::hasDocumentElement): (DumpRenderTreeSupportQt::pauseAnimation): (DumpRenderTreeSupportQt::pauseTransitionOfProperty): (DumpRenderTreeSupportQt::numberOfActiveAnimations): (DumpRenderTreeSupportQt::clearFrameName): (DumpRenderTreeSupportQt::setCaretBrowsingEnabled): (DumpRenderTreeSupportQt::setAuthorAndUserStylesEnabled): (DumpRenderTreeSupportQt::setSmartInsertDeleteEnabled): (DumpRenderTreeSupportQt::setSelectTrailingWhitespaceEnabled): (DumpRenderTreeSupportQt::executeCoreCommandByName): (DumpRenderTreeSupportQt::isCommandEnabled): (DumpRenderTreeSupportQt::findString): (DumpRenderTreeSupportQt::selectedRange): (DumpRenderTreeSupportQt::firstRectForCharacterRange): (DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId): (DumpRenderTreeSupportQt::setWindowsBehaviorAsEditingBehavior): (DumpRenderTreeSupportQt::viewportAsText): (DumpRenderTreeSupportQt::scalePageBy): (DumpRenderTreeSupportQt::setMockDeviceOrientation): (DumpRenderTreeSupportQt::resetGeolocationMock): (DumpRenderTreeSupportQt::setMockGeolocationPermission): (DumpRenderTreeSupportQt::setMockGeolocationPosition): (DumpRenderTreeSupportQt::setMockGeolocationPositionUnavailableError): (DumpRenderTreeSupportQt::numberOfPendingGeolocationPermissionRequests): (DumpRenderTreeSupportQt::shouldClose): (DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld): (DumpRenderTreeSupportQt::addUserStyleSheet): (DumpRenderTreeSupportQt::removeUserStyleSheets): (DumpRenderTreeSupportQt::setDefersLoading): (DumpRenderTreeSupportQt::goBack): (DumpRenderTreeSupportQt::responseMimeType): (DumpRenderTreeSupportQt::clearOpener): (DumpRenderTreeSupportQt::setInteractiveFormValidationEnabled): (DumpRenderTreeSupportQt::contextMenu): (DumpRenderTreeSupportQt::setMinimumTimerInterval): (DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows): (DumpRenderTreeSupportQt::mediaContentUrlByElementId): (DumpRenderTreeSupportQt::setAlternateHtml): (DumpRenderTreeSupportQt::confirmComposition): (DumpRenderTreeSupportQt::injectInternalsObject): (DumpRenderTreeSupportQt::resetInternalsObject): (DumpRenderTreeSupportQt::paintPagesWithBoundaries): (DumpRenderTreeSupportQt::setTrackRepaintRects): (DumpRenderTreeSupportQt::trackRepaintRects): (DumpRenderTreeSupportQt::getTrackedRepaintRects): * WebCoreSupport/DumpRenderTreeSupportQt.h: * WebCoreSupport/EditorClientQt.cpp: (dumpRange): (WebCore::EditorClientQt::shouldShowDeleteInterface): (WebCore::EditorClientQt::shouldInsertText): (WebCore::EditorClientQt::shouldChangeSelectedRange): (WebCore::EditorClientQt::shouldApplyStyle): (WebCore::EditorClientQt::respondToChangedContents): (WebCore::EditorClientQt::respondToChangedSelection): (WebCore::EditorClientQt::registerUndoStep): (WebCore::EditorClientQt::clearUndoRedoOperations): (WebCore::EditorClientQt::canUndo): (WebCore::EditorClientQt::canRedo): (WebCore::EditorClientQt::undo): (WebCore::EditorClientQt::redo): (WebCore::EditorClientQt::shouldInsertNode): (WebCore::EditorClientQt::smartInsertDeleteEnabled): (WebCore::EditorClientQt::toggleSmartInsertDelete): (WebCore::EditorClientQt::isSelectTrailingWhitespaceEnabled): (WebCore::EditorClientQt::handleKeyboardEvent): (WebCore::EditorClientQt::EditorClientQt): (WebCore::EditorClientQt::setInputMethodState): * WebCoreSupport/EditorClientQt.h: (EditorClientQt): (WebCore::EditorClientQt::setSmartInsertDeleteEnabled): (WebCore::EditorClientQt::setSelectTrailingWhitespaceEnabled): * WebCoreSupport/FrameLoaderClientQt.cpp: (drtDescriptionSuitableForTestResult): (WebCore::FrameLoaderClientQt::setFrame): (WebCore::FrameLoaderClientQt::transitionToCommittedForNewPage): (WebCore::FrameLoaderClientQt::dispatchDidChangeLocationWithinPage): (WebCore::FrameLoaderClientQt::dispatchDidStartProvisionalLoad): (WebCore::FrameLoaderClientQt::dispatchDidCommitLoad): (WebCore::FrameLoaderClientQt::dispatchDidFinishDocumentLoad): (WebCore::FrameLoaderClientQt::dispatchDidFinishLoad): (WebCore::FrameLoaderClientQt::dispatchDidLayout): (WebCore::FrameLoaderClientQt::dispatchWillSubmitForm): (WebCore::FrameLoaderClientQt::postProgressStartedNotification): (WebCore::FrameLoaderClientQt::postProgressFinishedNotification): (WebCore::FrameLoaderClientQt::frameLoadCompleted): (WebCore::FrameLoaderClientQt::restoreViewState): (WebCore::FrameLoaderClientQt::userAgent): (WebCore::FrameLoaderClientQt::dispatchDidReceiveIcon): (WebCore::FrameLoaderClientQt::frameLoaderDestroyed): (WebCore::FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld): (WebCore::FrameLoaderClientQt::didPerformFirstNavigation): (WebCore::FrameLoaderClientQt::onIconLoadedForPageURL): (WebCore::FrameLoaderClientQt::updateGlobalHistoryRedirectLinks): (WebCore::FrameLoaderClientQt::saveViewStateToItem): (WebCore::FrameLoaderClientQt::cancelledError): (WebCore::FrameLoaderClientQt::blockedError): (WebCore::FrameLoaderClientQt::cannotShowURLError): (WebCore::FrameLoaderClientQt::interruptedForPolicyChangeError): (WebCore::FrameLoaderClientQt::cannotShowMIMETypeError): (WebCore::FrameLoaderClientQt::fileDoesNotExistError): (WebCore::FrameLoaderClientQt::pluginWillHandleLoadError): (WebCore::FrameLoaderClientQt::download): (WebCore::FrameLoaderClientQt::dispatchWillSendRequest): (WebCore::FrameLoaderClientQt::dispatchDidReceiveResponse): (WebCore::FrameLoaderClientQt::dispatchDidFinishLoading): (WebCore::FrameLoaderClientQt::dispatchDidFailLoading): (WebCore::FrameLoaderClientQt::callErrorPageExtension): (WebCore::FrameLoaderClientQt::dispatchCreatePage): (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction): (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction): (WebCore::FrameLoaderClientQt::startDownload): (WebCore::FrameLoaderClientQt::createFrame): (WebCore::FrameLoaderClientQt::createPlugin): (WebCore::FrameLoaderClientQt::createJavaAppletWidget): (WebCore::FrameLoaderClientQt::chooseFile): (WebCore::FrameLoaderClientQt::createNetworkingContext): (WebCore): (WebCore::FrameLoaderClientQt::webFrame): (WebCore::FrameLoaderClientQt::emitLoadStarted): (WebCore::FrameLoaderClientQt::emitLoadFinished): * WebCoreSupport/FrameLoaderClientQt.h: (FrameLoaderClientQt): * WebCoreSupport/FrameNetworkingContextQt.cpp: (WebCore::FrameNetworkingContextQt::FrameNetworkingContextQt): (WebCore::FrameNetworkingContextQt::create): (WebCore::FrameNetworkingContextQt::networkAccessManager): * WebCoreSupport/FrameNetworkingContextQt.h: (FrameNetworkingContextQt): * WebCoreSupport/FullScreenVideoQt.cpp: (WebCore): (WebCore::FullScreenVideoQt::FullScreenVideoQt): * WebCoreSupport/FullScreenVideoQt.h: (WebCore): * WebCoreSupport/FullScreenVideoWidget.cpp: * WebCoreSupport/FullScreenVideoWidget.h: * WebCoreSupport/GeolocationClientQt.cpp: (WebCore::GeolocationClientQt::GeolocationClientQt): (WebCore::GeolocationClientQt::positionUpdated): (WebCore::GeolocationClientQt::startUpdating): (WebCore::GeolocationClientQt::requestPermission): (WebCore::GeolocationClientQt::cancelPermissionRequest): * WebCoreSupport/GeolocationClientQt.h: (GeolocationClientQt): * WebCoreSupport/GeolocationPermissionClientQt.cpp: (WebCore::GeolocationPermissionClientQt::requestGeolocationPermissionForFrame): (WebCore::GeolocationPermissionClientQt::cancelGeolocationPermissionRequestForFrame): (WebCore::GeolocationPermissionClientQt::setPermission): * WebCoreSupport/GeolocationPermissionClientQt.h: (GeolocationPermissionClientQt): * WebCoreSupport/InitWebCoreQt.cpp: (WebKit): (WebKit::setWebKitWidgetsInitCallback): (WebKit::initializeWebKitQt): (WebKit::setImagePlatformResource): (WebCore::initializeWebCoreQt): * WebCoreSupport/InitWebCoreQt.h: (WebCore): (WebKit): * WebCoreSupport/InitWebKitQt.cpp: Added. (WebKit): (WebKit::initializeWebKitWidgets): * WebCoreSupport/InitWebKitQt.h: Copied from Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h. (WebKit): * WebCoreSupport/InspectorClientQt.cpp: (WebCore): (WebCore::InspectorClientQt::InspectorClientQt): (WebCore::InspectorClientQt::openInspectorFrontend): (WebCore::InspectorClientQt::attachAndReplaceRemoteFrontend): (WebCore::InspectorClientQt::detachRemoteFrontend): (WebCore::InspectorClientQt::hideHighlight): (WebCore::InspectorClientQt::sendMessageToFrontend): (WebCore::InspectorFrontendClientQt::InspectorFrontendClientQt): (WebCore::InspectorFrontendClientQt::updateWindowTitle): (WebCore::InspectorFrontendClientQt::destroyInspectorView): * WebCoreSupport/InspectorClientQt.h: (InspectorClientQt): (InspectorFrontendClientQt): * WebCoreSupport/InspectorClientWebPage.cpp: Added. (InspectorClientWebPage::InspectorClientWebPage): (InspectorClientWebPage::createWindow): (InspectorClientWebPage::javaScriptWindowObjectCleared): * WebCoreSupport/InspectorClientWebPage.h: Copied from Source/WebKit/qt/WebCoreSupport/WebSystemInterface.h. (WebKit): (InspectorClientWebPage): * WebCoreSupport/InspectorServerQt.cpp: (WebCore::InspectorServerRequestHandlerQt::tcpReadyRead): (WebCore::InspectorServerRequestHandlerQt::webSocketReadyRead): * WebCoreSupport/InspectorServerQt.h: (InspectorServerQt): (InspectorServerRequestHandlerQt): * WebCoreSupport/NotificationPresenterClientQt.cpp: (WebCore::NotificationWrapper::NotificationWrapper): (WebCore::NotificationPresenterClientQt::displayNotification): (WebCore::NotificationPresenterClientQt::requestPermission): (WebCore::NotificationPresenterClientQt::cancelRequestsForPermission): (WebCore::NotificationPresenterClientQt::dumpShowText): (WebCore::NotificationPresenterClientQt::toPage): (WebCore::NotificationPresenterClientQt::toFrame): * WebCoreSupport/NotificationPresenterClientQt.h: (WebCore::NotificationWrapper::~NotificationWrapper): (NotificationWrapper): (NotificationPresenterClientQt): (WebCore::NotificationPresenterClientQt::hasSystemTrayIcon): (WebCore::NotificationPresenterClientQt::setSystemTrayIcon): (CallbacksInfo): (WebCore): * WebCoreSupport/PageClientQt.cpp: (createPlatformGraphicsContext3DFromWidget): (QWebPageClient::ownerWindow): (WebCore::PageClientQWidget::ownerWidget): (WebCore::PageClientQWidget::createPlatformGraphicsContext3D): (WebCore::PageClientQGraphicsWidget::ownerWidget): (WebCore::PageClientQGraphicsWidget::createPlatformGraphicsContext3D): * WebCoreSupport/PageClientQt.h: (PageClientQWidget): (WebCore::QGraphicsItemOverlay::QGraphicsItemOverlay): (WebCore::PageClientQGraphicsWidget::PageClientQGraphicsWidget): (PageClientQGraphicsWidget): * WebCoreSupport/PlatformStrategiesQt.cpp: (PlatformStrategiesQt::getPluginInfo): * WebCoreSupport/PopupMenuQt.cpp: (SelectData::SelectData): * WebCoreSupport/QGraphicsWidgetPluginImpl.cpp: Added. (QGraphicsWidgetPluginImpl::~QGraphicsWidgetPluginImpl): (QGraphicsWidgetPluginImpl::update): (QGraphicsWidgetPluginImpl::setGeometryAndClip): (QGraphicsWidgetPluginImpl::setVisible): (QGraphicsWidgetPluginImpl::setWidgetParent): (QGraphicsWidgetPluginImpl::handle): * WebCoreSupport/QGraphicsWidgetPluginImpl.h: Added. (QGraphicsWidgetPluginImpl): (QGraphicsWidgetPluginImpl::QGraphicsWidgetPluginImpl): * WebCoreSupport/QWebFrameAdapter.cpp: Added. (cacheLoadControlToCachePolicy): (QWebFrameData::QWebFrameData): (QWebFrameAdapter::QWebFrameAdapter): (QWebFrameAdapter::~QWebFrameAdapter): (QWebFrameAdapter::load): (QWebFrameAdapter::handleGestureEvent): (QWebFrameAdapter::scrollPosition): (QWebFrameAdapter::frameRect): (QWebFrameAdapter::init): (QWebFrameAdapter::kit): (QWebFrameAdapter::ensureAbsoluteUrl): * WebCoreSupport/QWebFrameAdapter.h: Added. (WebCore): (QWebFrameData): (QWebFrameAdapter): (QWebFrameAdapter::hasView): * WebCoreSupport/QWebPageAdapter.cpp: Added. (QWebPageAdapter::QWebPageAdapter): (QWebPageAdapter::~QWebPageAdapter): (QWebPageAdapter::init): (QWebPageAdapter::deletePage): (QWebPageAdapter::kit): (QWebPageAdapter::viewportArguments): (QWebPageAdapter::registerUndoStep): (QWebPageAdapter::setNetworkAccessManager): (QWebPageAdapter::networkAccessManager): * WebCoreSupport/QWebPageAdapter.h: Added. (WebCore): (QWebPageAdapter): (ErrorPageOption): (ErrorPageReturn): * WebCoreSupport/QWebUndoCommand.cpp: Copied from Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h. (QWebUndoCommand::QWebUndoCommand): (QWebUndoCommand::undo): (QWebUndoCommand::redo): * WebCoreSupport/QWebUndoCommand.h: Copied from Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h. (QWebUndoCommand): * WebCoreSupport/QWidgetPluginImpl.cpp: Added. (QWidgetPluginImpl::~QWidgetPluginImpl): (QWidgetPluginImpl::update): (QWidgetPluginImpl::setGeometryAndClip): (QWidgetPluginImpl::setVisible): (QWidgetPluginImpl::setStyleSheet): (QWidgetPluginImpl::setWidgetParent): (QWidgetPluginImpl::handle): * WebCoreSupport/QWidgetPluginImpl.h: Copied from Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h. (QWidgetPluginImpl): (QWidgetPluginImpl::QWidgetPluginImpl): * WebCoreSupport/QtFallbackWebPopup.cpp: (WebCore::QtFallbackWebPopup::QtFallbackWebPopup): (WebCore::QtFallbackWebPopup::show): (WebCore::QtFallbackWebPopup::pageClient): * WebCoreSupport/QtFallbackWebPopup.h: (QtFallbackWebPopup): * WebCoreSupport/QtPluginWidgetAdapter.h: Copied from Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h. (QtPluginWidgetAdapter): * WebCoreSupport/QtWebComboBox.cpp: (WebCore::QtWebComboBox::showPopupAtCursorPosition): * WebCoreSupport/QtWebComboBox.h: * WebCoreSupport/SearchPopupMenuQt.h: (SearchPopupMenuQt): * WebCoreSupport/UndoStepQt.cpp: (UndoStepQt::UndoStepQt): (UndoStepQt::text): * WebCoreSupport/UndoStepQt.h: (UndoStepQt): * WebCoreSupport/WebEventConversion.cpp: (WebCore::mouseEventTypeAndMouseButtonFromQEvent): (WebKitPlatformWheelEvent): (WebCore::WebKitPlatformWheelEvent::applyDelta): (WebCore::WebKitPlatformWheelEvent::WebKitPlatformWheelEvent): (WebKitPlatformGestureEvent): (WebCore::toPlatformEventType): (WebCore::WebKitPlatformGestureEvent::WebKitPlatformGestureEvent): (WebCore): (WebCore::convertWheelEvent): (WebCore::convertGesture): * WebCoreSupport/WebEventConversion.h: (QGestureEventFacade): (WebCore): * WebCoreSupport/WebSystemInterface.h: * tests/qwebpage/tst_qwebpage.cpp: (tst_QWebPage::loadHtml5Video): (tst_QWebPage::multiplePageGroupsAndLocalStorage): (tst_QWebPage::thirdPartyCookiePolicy): Source/WebKit2: * qt/MainQt.cpp: (WebKit): (main): Tools: * DumpRenderTree/qt/DumpRenderTreeQt.cpp: (WebCore::WebPage::resetSettings): (WebCore::WebPage::createWindow): (WebCore::DumpRenderTree::DumpRenderTree): (WebCore::DumpRenderTree::resetToConsistentStateBeforeTesting): (WebCore::DumpRenderTree::initJSObjects): (WebCore::DumpRenderTree::dumpFrameScrollPosition): (WebCore::DumpRenderTree::dumpFramesAsText): (WebCore::DumpRenderTree::dump): (WebCore::DumpRenderTree::createWindow): (WebCore::DumpRenderTree::pageAdapter): (WebCore): (WebCore::DumpRenderTree::mainFrameAdapter): * DumpRenderTree/qt/DumpRenderTreeQt.h: (DumpRenderTree): * DumpRenderTree/qt/EventSenderQt.cpp: (EventSender::contextClick): (EventSender::scalePageBy): * DumpRenderTree/qt/TestRunnerQt.cpp: (TestRunner::reset): (TestRunner::display): (TestRunner::closeWebInspector): (TestRunner::showWebInspector): (TestRunner::evaluateInWebInspector): (TestRunner::setFrameFlatteningEnabled): (TestRunner::goBack): (TestRunner::setDefersLoading): (TestRunner::pauseAnimationAtTimeOnElementWithId): (TestRunner::pauseTransitionAtTimeOnElementWithId): (TestRunner::numberOfActiveAnimations): (TestRunner::setCaretBrowsingEnabled): (TestRunner::setAuthorAndUserStylesEnabled): (TestRunner::callShouldCloseOnWebView): (TestRunner::setSmartInsertDeleteEnabled): (TestRunner::setSelectTrailingWhitespaceEnabled): (TestRunner::execCommand): (TestRunner::isCommandEnabled): (TestRunner::findString): (TestRunner::elementDoesAutoCompleteForElementWithId): (TestRunner::setMockDeviceOrientation): (TestRunner::setGeolocationPermission): (TestRunner::numberOfPendingGeolocationPermissionRequests): (TestRunner::setMockGeolocationPositionUnavailableError): (TestRunner::setMockGeolocationPosition): (TestRunner::evaluateScriptInIsolatedWorld): (TestRunner::addUserStyleSheet): (TestRunner::setMinimumTimerInterval): * DumpRenderTree/qt/TextInputControllerQt.cpp: (TextInputController::selectedRange): (TextInputController::firstRectForCharacterRange): (TextInputController::unmarkText): * DumpRenderTree/qt/WorkQueueItemQt.cpp: (LoadAlternateHTMLStringItem::invoke): * qmake/mkspecs/features/default_post.prf: * qmake/mkspecs/features/production_build.prf: * qmake/mkspecs/features/webkit_modules.prf: * qmake/mkspecs/modules/webkitwidgets.prf: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@135515 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- ChangeLog | 41 + Source/WebCore/ChangeLog | 40 + Source/WebCore/platform/qt/QWebPageClient.h | 2 +- Source/WebKit/ChangeLog | 42 ++ Source/WebKit/WebKit1.pri | 9 +- Source/WebKit/WebKit1.pro | 110 ++- Source/WebKit/WebKitWidgets.pri | 33 + Source/WebKit/WebKitWidgets.pro | 75 ++ Source/WebKit/qt/Api/qgraphicswebview.cpp | 6 +- Source/WebKit/qt/Api/qwebelement.cpp | 6 +- Source/WebKit/qt/Api/qwebframe.cpp | 227 +++--- Source/WebKit/qt/Api/qwebframe.h | 7 +- Source/WebKit/qt/Api/qwebframe_p.h | 62 +- Source/WebKit/qt/Api/qwebhistory.cpp | 7 +- Source/WebKit/qt/Api/qwebhistory_p.h | 4 +- Source/WebKit/qt/Api/qwebinspector.cpp | 4 +- Source/WebKit/qt/Api/qwebinspector_p.h | 2 +- Source/WebKit/qt/Api/qwebpage.cpp | 711 ++++++++++++++---- Source/WebKit/qt/Api/qwebpage.h | 3 +- Source/WebKit/qt/Api/qwebpage_p.h | 125 +-- Source/WebKit/qt/Api/qwebsettings.cpp | 34 +- Source/WebKit/qt/Api/qwebsettings.h | 1 + Source/WebKit/qt/Api/qwebview.cpp | 4 +- Source/WebKit/qt/ChangeLog | 535 +++++++++++++ .../qt/WebCoreSupport/ChromeClientQt.cpp | 211 +++--- .../WebKit/qt/WebCoreSupport/ChromeClientQt.h | 16 +- .../qt/WebCoreSupport/ContextMenuClientQt.cpp | 3 +- .../qt/WebCoreSupport/ContextMenuClientQt.h | 2 +- .../DefaultFullScreenVideoHandler.cpp | 72 ++ .../DefaultFullScreenVideoHandler.h | 50 ++ .../WebKit/qt/WebCoreSupport/DragClientQt.cpp | 8 +- .../WebKit/qt/WebCoreSupport/DragClientQt.h | 8 +- .../DumpRenderTreeSupportQt.cpp | 399 +++------- .../WebCoreSupport/DumpRenderTreeSupportQt.h | 145 ++-- .../qt/WebCoreSupport/EditorClientQt.cpp | 91 ++- .../WebKit/qt/WebCoreSupport/EditorClientQt.h | 10 +- .../qt/WebCoreSupport/FrameLoaderClientQt.cpp | 443 +++++------ .../qt/WebCoreSupport/FrameLoaderClientQt.h | 23 +- .../FrameNetworkingContextQt.cpp | 16 +- .../WebCoreSupport/FrameNetworkingContextQt.h | 5 +- .../qt/WebCoreSupport/FullScreenVideoQt.cpp | 51 +- .../qt/WebCoreSupport/FullScreenVideoQt.h | 19 - .../WebCoreSupport/FullScreenVideoWidget.cpp | 3 +- .../qt/WebCoreSupport/FullScreenVideoWidget.h | 2 +- .../qt/WebCoreSupport/GeolocationClientQt.cpp | 23 +- .../qt/WebCoreSupport/GeolocationClientQt.h | 8 +- .../GeolocationPermissionClientQt.cpp | 27 +- .../GeolocationPermissionClientQt.h | 13 +- .../qt/WebCoreSupport/InitWebCoreQt.cpp | 32 +- .../WebKit/qt/WebCoreSupport/InitWebCoreQt.h | 16 + .../WebKit/qt/WebCoreSupport/InitWebKitQt.cpp | 50 ++ .../WebKit/qt/WebCoreSupport/InitWebKitQt.h | 29 + .../qt/WebCoreSupport/InspectorClientQt.cpp | 114 +-- .../qt/WebCoreSupport/InspectorClientQt.h | 19 +- .../WebCoreSupport/InspectorClientWebPage.cpp | 71 ++ .../WebCoreSupport/InspectorClientWebPage.h | 53 ++ .../qt/WebCoreSupport/InspectorServerQt.cpp | 18 +- .../qt/WebCoreSupport/InspectorServerQt.h | 6 +- .../NotificationPresenterClientQt.cpp | 36 +- .../NotificationPresenterClientQt.h | 34 +- .../WebKit/qt/WebCoreSupport/PageClientQt.cpp | 19 +- .../WebKit/qt/WebCoreSupport/PageClientQt.h | 37 +- .../WebCoreSupport/PlatformStrategiesQt.cpp | 17 +- .../WebKit/qt/WebCoreSupport/PopupMenuQt.cpp | 3 +- .../QGraphicsWidgetPluginImpl.cpp | 66 ++ .../QGraphicsWidgetPluginImpl.h | 47 ++ .../qt/WebCoreSupport/QWebFrameAdapter.cpp | 210 ++++++ .../qt/WebCoreSupport/QWebFrameAdapter.h | 114 +++ .../qt/WebCoreSupport/QWebPageAdapter.cpp | 104 +++ .../qt/WebCoreSupport/QWebPageAdapter.h | 171 +++++ .../qt/WebCoreSupport/QWebUndoCommand.cpp | 44 ++ .../qt/WebCoreSupport/QWebUndoCommand.h | 43 ++ .../qt/WebCoreSupport/QWidgetPluginImpl.cpp | 72 ++ .../qt/WebCoreSupport/QWidgetPluginImpl.h | 44 ++ .../qt/WebCoreSupport/QtFallbackWebPopup.cpp | 15 +- .../qt/WebCoreSupport/QtFallbackWebPopup.h | 8 +- .../qt/WebCoreSupport/QtPluginWidgetAdapter.h | 38 + .../qt/WebCoreSupport/QtWebComboBox.cpp | 3 +- .../WebKit/qt/WebCoreSupport/QtWebComboBox.h | 3 +- .../qt/WebCoreSupport/SearchPopupMenuQt.h | 2 +- .../WebKit/qt/WebCoreSupport/UndoStepQt.cpp | 19 +- Source/WebKit/qt/WebCoreSupport/UndoStepQt.h | 17 +- .../qt/WebCoreSupport/WebEventConversion.cpp | 135 +--- .../qt/WebCoreSupport/WebEventConversion.h | 23 +- .../qt/WebCoreSupport/WebSystemInterface.h | 5 + .../WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 38 +- Source/WebKit2/ChangeLog | 41 + Source/WebKit2/qt/MainQt.cpp | 23 +- Source/api.pri | 7 +- Tools/ChangeLog | 95 +++ Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp | 59 +- Tools/DumpRenderTree/qt/DumpRenderTreeQt.h | 6 +- Tools/DumpRenderTree/qt/EventSenderQt.cpp | 4 +- Tools/DumpRenderTree/qt/TestRunnerQt.cpp | 56 +- .../qt/TextInputControllerQt.cpp | 6 +- Tools/DumpRenderTree/qt/WorkQueueItemQt.cpp | 2 +- Tools/qmake/mkspecs/features/default_post.prf | 2 +- .../mkspecs/features/production_build.prf | 2 +- .../qmake/mkspecs/features/webkit_modules.prf | 2 +- Tools/qmake/mkspecs/modules/webkitwidgets.prf | 9 + WebKit.pro | 4 + 101 files changed, 3957 insertions(+), 1874 deletions(-) create mode 100644 Source/WebKit/WebKitWidgets.pri create mode 100644 Source/WebKit/WebKitWidgets.pro create mode 100644 Source/WebKit/qt/WebCoreSupport/DefaultFullScreenVideoHandler.cpp create mode 100644 Source/WebKit/qt/WebCoreSupport/DefaultFullScreenVideoHandler.h create mode 100644 Source/WebKit/qt/WebCoreSupport/InitWebKitQt.cpp create mode 100644 Source/WebKit/qt/WebCoreSupport/InitWebKitQt.h create mode 100644 Source/WebKit/qt/WebCoreSupport/InspectorClientWebPage.cpp create mode 100644 Source/WebKit/qt/WebCoreSupport/InspectorClientWebPage.h create mode 100644 Source/WebKit/qt/WebCoreSupport/QGraphicsWidgetPluginImpl.cpp create mode 100644 Source/WebKit/qt/WebCoreSupport/QGraphicsWidgetPluginImpl.h create mode 100644 Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp create mode 100644 Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.h create mode 100644 Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp create mode 100644 Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h create mode 100644 Source/WebKit/qt/WebCoreSupport/QWebUndoCommand.cpp create mode 100644 Source/WebKit/qt/WebCoreSupport/QWebUndoCommand.h create mode 100644 Source/WebKit/qt/WebCoreSupport/QWidgetPluginImpl.cpp create mode 100644 Source/WebKit/qt/WebCoreSupport/QWidgetPluginImpl.h create mode 100644 Source/WebKit/qt/WebCoreSupport/QtPluginWidgetAdapter.h create mode 100644 Tools/qmake/mkspecs/modules/webkitwidgets.prf diff --git a/ChangeLog b/ChangeLog index 814a8bc794e..17a62bd7c22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,44 @@ +2012-11-22 Simon Hausmann , Pierre Rossi + + [Qt] Separate QWidget dependant code into separate WebKitWidgets static library + https://bugs.webkit.org/show_bug.cgi?id=102800 + + Reviewed by Tor Arne Vestbø. + + This patch separates code that needs to use QWidget related APIs in + WebKit/qt/WebCoreSupport and Api from code that doesn't. This means for + example FrameLoaderClientQt.cpp remains in the WebKit1 static library, + while qwebpage.cpp and qwebframe.cpp become part of the WebKitWidgets + static library. WebKit1 is compiled without QT += widgets and therefore + any widget related dependency has been moved "up" and out of WebKit1 into + the WebKitWidgets library. + + Between the code in WebKit.a and WebKitWidgets.a new adapters and + interfaces have been introduced, such as QWebPageAdapter and + QWebFrameAdapter. QWebPageAdapter, when used from WebKit1, is a way to + call out into the API layer, implemented by QWebPage (QWebPagePrivate). + The other way around if QWebPage wants to access WebCore or + WebCoreSupport related functionality, it will go through + QWebPageAdapater (as base class). The separation in the direction up + into the API layer is complete with this patch, no code in WebKit1 + depends on QtWidgets. The separation the other way around, code in the + API layer not using any WebCore types, is not complete yet. + + Some classes such as QWebSettings, QWebElement or + DumpRenderTreeSupportQt remain in WebKit1. While they are API layer, + they do not depend on widget related Qt APIs and they make much more + use of WebCore internal APIs and therefore are easier to keep in + WebKit1. + + In the future we plan to place a real shared library boundary between + WebKit1 and WebKitWidgets, by keeping the WebKit1 static library as + part of the QtWebKit shared library and by turning the WebKitWidgets + static library into a shared one. + + + * Source/api.pri: + * WebKit.pro: + 2012-11-21 Ryuan Choi [EFL] Remove unnecessary definition, -DENABLE_SPELLCHECK=1 diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 2bb2b52c0ec..7f8f0b4c5e5 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,43 @@ +2012-11-22 Simon Hausmann , Pierre Rossi + + [Qt] Separate QWidget dependant code into separate WebKitWidgets static library + https://bugs.webkit.org/show_bug.cgi?id=102800 + + Reviewed by Tor Arne Vestbø. + + This patch separates code that needs to use QWidget related APIs in + WebKit/qt/WebCoreSupport and Api from code that doesn't. This means for + example FrameLoaderClientQt.cpp remains in the WebKit1 static library, + while qwebpage.cpp and qwebframe.cpp become part of the WebKitWidgets + static library. WebKit1 is compiled without QT += widgets and therefore + any widget related dependency has been moved "up" and out of WebKit1 into + the WebKitWidgets library. + + Between the code in WebKit.a and WebKitWidgets.a new adapters and + interfaces have been introduced, such as QWebPageAdapter and + QWebFrameAdapter. QWebPageAdapter, when used from WebKit1, is a way to + call out into the API layer, implemented by QWebPage (QWebPagePrivate). + The other way around if QWebPage wants to access WebCore or + WebCoreSupport related functionality, it will go through + QWebPageAdapater (as base class). The separation in the direction up + into the API layer is complete with this patch, no code in WebKit1 + depends on QtWidgets. The separation the other way around, code in the + API layer not using any WebCore types, is not complete yet. + + Some classes such as QWebSettings, QWebElement or + DumpRenderTreeSupportQt remain in WebKit1. While they are API layer, + they do not depend on widget related Qt APIs and they make much more + use of WebCore internal APIs and therefore are easier to keep in + WebKit1. + + In the future we plan to place a real shared library boundary between + WebKit1 and WebKitWidgets, by keeping the WebKit1 static library as + part of the QtWebKit shared library and by turning the WebKitWidgets + static library into a shared one. + + * platform/qt/QWebPageClient.h: + (QWebPageClient): + 2012-11-22 Dan Carney [V8] Add context checks to WorldContextHandle and V8DOMWindowShell diff --git a/Source/WebCore/platform/qt/QWebPageClient.h b/Source/WebCore/platform/qt/QWebPageClient.h index cda0b0f4d63..ae3fb4e2fa0 100644 --- a/Source/WebCore/platform/qt/QWebPageClient.h +++ b/Source/WebCore/platform/qt/QWebPageClient.h @@ -91,7 +91,7 @@ class QWebPageClient { virtual QPalette palette() const = 0; virtual int screenNumber() const = 0; - virtual QWidget* ownerWidget() const = 0; + virtual QObject* ownerWidget() const = 0; virtual QRect geometryRelativeToOwnerWidget() const = 0; virtual QObject* pluginParent() const = 0; diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog index 6f392306ba0..f2f774ac446 100644 --- a/Source/WebKit/ChangeLog +++ b/Source/WebKit/ChangeLog @@ -1,3 +1,45 @@ +2012-11-22 Simon Hausmann , Pierre Rossi + + [Qt] Separate QWidget dependant code into separate WebKitWidgets static library + https://bugs.webkit.org/show_bug.cgi?id=102800 + + Reviewed by Tor Arne Vestbø. + + This patch separates code that needs to use QWidget related APIs in + WebKit/qt/WebCoreSupport and Api from code that doesn't. This means for + example FrameLoaderClientQt.cpp remains in the WebKit1 static library, + while qwebpage.cpp and qwebframe.cpp become part of the WebKitWidgets + static library. WebKit1 is compiled without QT += widgets and therefore + any widget related dependency has been moved "up" and out of WebKit1 into + the WebKitWidgets library. + + Between the code in WebKit.a and WebKitWidgets.a new adapters and + interfaces have been introduced, such as QWebPageAdapter and + QWebFrameAdapter. QWebPageAdapter, when used from WebKit1, is a way to + call out into the API layer, implemented by QWebPage (QWebPagePrivate). + The other way around if QWebPage wants to access WebCore or + WebCoreSupport related functionality, it will go through + QWebPageAdapater (as base class). The separation in the direction up + into the API layer is complete with this patch, no code in WebKit1 + depends on QtWidgets. The separation the other way around, code in the + API layer not using any WebCore types, is not complete yet. + + Some classes such as QWebSettings, QWebElement or + DumpRenderTreeSupportQt remain in WebKit1. While they are API layer, + they do not depend on widget related Qt APIs and they make much more + use of WebCore internal APIs and therefore are easier to keep in + WebKit1. + + In the future we plan to place a real shared library boundary between + WebKit1 and WebKitWidgets, by keeping the WebKit1 static library as + part of the QtWebKit shared library and by turning the WebKitWidgets + static library into a shared one. + + * WebKit1.pri: + * WebKit1.pro: + * WebKitWidgets.pri: Copied from Source/WebKit/WebKit1.pri. + * WebKitWidgets.pro: Added. + 2012-11-21 Kai Koehne [Qt] MinGW: Don't add OpenGL library dependencies here diff --git a/Source/WebKit/WebKit1.pri b/Source/WebKit/WebKit1.pri index f988b4c6bd9..0297fcc92d1 100644 --- a/Source/WebKit/WebKit1.pri +++ b/Source/WebKit/WebKit1.pri @@ -18,16 +18,9 @@ enable?(DEVICE_ORIENTATION)|enable?(ORIENTATION_EVENTS) { enable?(GEOLOCATION): QT += location -use?(QT_MULTIMEDIA): QT *= multimediawidgets - contains(CONFIG, texmap): DEFINES += WTF_USE_TEXTURE_MAPPER=1 use?(PLUGIN_BACKEND_XLIB): PKGCONFIG += x11 -QT += network widgets -have?(QTQUICK): QT += quick -have?(QTPRINTSUPPORT): QT += printsupport +QT += network -use?(TEXTURE_MAPPER_GL)|enable?(WEBGL) { - QT *= opengl -} diff --git a/Source/WebKit/WebKit1.pro b/Source/WebKit/WebKit1.pro index 75d4d79de5a..fee99e8851b 100644 --- a/Source/WebKit/WebKit1.pro +++ b/Source/WebKit/WebKit1.pro @@ -15,30 +15,20 @@ QT += gui CONFIG += staticlib SOURCES += \ - $$PWD/qt/Api/qwebframe.cpp \ - $$PWD/qt/Api/qgraphicswebview.cpp \ - $$PWD/qt/Api/qwebpage.cpp \ - $$PWD/qt/Api/qwebview.cpp \ + $$PWD/qt/Api/qhttpheader.cpp \ + $$PWD/qt/Api/qwebdatabase.cpp \ $$PWD/qt/Api/qwebelement.cpp \ $$PWD/qt/Api/qwebhistory.cpp \ - $$PWD/qt/Api/qwebsettings.cpp \ $$PWD/qt/Api/qwebhistoryinterface.cpp \ - $$PWD/qt/Api/qwebplugindatabase.cpp \ $$PWD/qt/Api/qwebpluginfactory.cpp \ $$PWD/qt/Api/qwebsecurityorigin.cpp \ + $$PWD/qt/Api/qwebsettings.cpp \ $$PWD/qt/Api/qwebscriptworld.cpp \ - $$PWD/qt/Api/qwebdatabase.cpp \ - $$PWD/qt/Api/qwebinspector.cpp \ - $$PWD/qt/Api/qwebkitversion.cpp \ - $$PWD/qt/Api/qhttpheader.cpp \ - $$PWD/qt/WebCoreSupport/QtFallbackWebPopup.cpp \ - $$PWD/qt/WebCoreSupport/QtWebComboBox.cpp \ $$PWD/qt/WebCoreSupport/ChromeClientQt.cpp \ $$PWD/qt/WebCoreSupport/ContextMenuClientQt.cpp \ $$PWD/qt/WebCoreSupport/DragClientQt.cpp \ $$PWD/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp \ $$PWD/qt/WebCoreSupport/EditorClientQt.cpp \ - $$PWD/qt/WebCoreSupport/UndoStepQt.cpp \ $$PWD/qt/WebCoreSupport/FrameLoaderClientQt.cpp \ $$PWD/qt/WebCoreSupport/FrameNetworkingContextQt.cpp \ $$PWD/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp \ @@ -46,67 +36,72 @@ SOURCES += \ $$PWD/qt/WebCoreSupport/InspectorClientQt.cpp \ $$PWD/qt/WebCoreSupport/InspectorServerQt.cpp \ $$PWD/qt/WebCoreSupport/NotificationPresenterClientQt.cpp \ - $$PWD/qt/WebCoreSupport/PageClientQt.cpp \ + $$PWD/qt/WebCoreSupport/PlatformStrategiesQt.cpp \ $$PWD/qt/WebCoreSupport/PopupMenuQt.cpp \ - $$PWD/qt/WebCoreSupport/QStyleFacadeImp.cpp \ $$PWD/qt/WebCoreSupport/QtPlatformPlugin.cpp \ + $$PWD/qt/WebCoreSupport/QWebFrameAdapter.cpp \ + $$PWD/qt/WebCoreSupport/QWebPageAdapter.cpp \ $$PWD/qt/WebCoreSupport/SearchPopupMenuQt.cpp \ $$PWD/qt/WebCoreSupport/TextCheckerClientQt.cpp \ - $$PWD/qt/WebCoreSupport/PlatformStrategiesQt.cpp \ + $$PWD/qt/WebCoreSupport/UndoStepQt.cpp \ $$PWD/qt/WebCoreSupport/WebEventConversion.cpp HEADERS += \ - $$PWD/qt/Api/qwebframe.h \ - $$PWD/qt/Api/qwebframe_p.h \ - $$PWD/qt/Api/qgraphicswebview.h \ - $$PWD/qt/Api/qwebkitglobal.h \ - $$PWD/qt/Api/qwebkitplatformplugin.h \ - $$PWD/qt/Api/qwebpage.h \ - $$PWD/qt/Api/qwebview.h \ - $$PWD/qt/Api/qwebsettings.h \ - $$PWD/qt/Api/qwebhistoryinterface.h \ + $$PWD/qt/Api/qhttpheader_p.h \ $$PWD/qt/Api/qwebdatabase.h \ - $$PWD/qt/Api/qwebsecurityorigin.h \ $$PWD/qt/Api/qwebelement.h \ $$PWD/qt/Api/qwebelement_p.h \ - $$PWD/qt/Api/qwebpluginfactory.h \ $$PWD/qt/Api/qwebhistory.h \ - $$PWD/qt/Api/qwebinspector.h \ - $$PWD/qt/Api/qwebkitversion.h \ - $$PWD/qt/Api/qwebplugindatabase_p.h \ - $$PWD/qt/Api/qhttpheader_p.h \ - $$PWD/qt/WebCoreSupport/InitWebCoreQt.h \ - $$PWD/qt/WebCoreSupport/InspectorServerQt.h \ - $$PWD/qt/WebCoreSupport/QtFallbackWebPopup.h \ - $$PWD/qt/WebCoreSupport/QtWebComboBox.h \ + $$PWD/qt/Api/qwebhistory_p.h \ + $$PWD/qt/Api/qwebhistoryinterface.h \ + $$PWD/qt/Api/qwebpluginfactory.h \ + $$PWD/qt/Api/qwebsecurityorigin.h \ + $$PWD/qt/Api/qwebsettings.h \ + $$PWD/qt/Api/qwebscriptworld_p.h \ + $$PWD/qt/WebCoreSupport/ChromeClientQt.h \ + $$PWD/qt/WebCoreSupport/ContextMenuClientQt.h \ + $$PWD/qt/WebCoreSupport/DragClientQt.h \ + $$PWD/qt/WebCoreSupport/EditorClientQt.h \ $$PWD/qt/WebCoreSupport/FrameLoaderClientQt.h \ $$PWD/qt/WebCoreSupport/FrameNetworkingContextQt.h \ $$PWD/qt/WebCoreSupport/GeolocationPermissionClientQt.h \ + $$PWD/qt/WebCoreSupport/InitWebCoreQt.h \ + $$PWD/qt/WebCoreSupport/InspectorClientQt.h \ + $$PWD/qt/WebCoreSupport/InspectorServerQt.h \ $$PWD/qt/WebCoreSupport/NotificationPresenterClientQt.h \ - $$PWD/qt/WebCoreSupport/PageClientQt.h \ + $$PWD/qt/WebCoreSupport/PlatformStrategiesQt.h \ $$PWD/qt/WebCoreSupport/PopupMenuQt.h \ - $$PWD/qt/WebCoreSupport/QStyleFacadeImp.h \ $$PWD/qt/WebCoreSupport/QtPlatformPlugin.h \ + $$PWD/qt/WebCoreSupport/QtPluginWidgetAdapter.h \ + $$PWD/qt/WebCoreSupport/QWebFrameAdapter.h \ + $$PWD/qt/WebCoreSupport/QWebPageAdapter.h \ $$PWD/qt/WebCoreSupport/SearchPopupMenuQt.h \ $$PWD/qt/WebCoreSupport/TextCheckerClientQt.h \ - $$PWD/qt/WebCoreSupport/PlatformStrategiesQt.h \ + $$PWD/qt/WebCoreSupport/UndoStepQt.h \ $$PWD/qt/WebCoreSupport/WebEventConversion.h -contains(QT_CONFIG,accessibility) { - SOURCES += $$PWD/qt/Api/qwebviewaccessible.cpp - HEADERS += $$PWD/qt/Api/qwebviewaccessible_p.h -} - INCLUDEPATH += \ - $$PWD/qt/Api \ $$PWD/qt/WebCoreSupport -enable?(VIDEO) { - !use?(QTKIT):!use?(GSTREAMER):use?(QT_MULTIMEDIA) { - HEADERS += $$PWD/qt/WebCoreSupport/FullScreenVideoWidget.h - SOURCES += $$PWD/qt/WebCoreSupport/FullScreenVideoWidget.cpp - } +use?(3D_GRAPHICS): WEBKIT += angle +enable?(GEOLOCATION) { + HEADERS += \ + $$PWD/qt/WebCoreSupport/GeolocationClientQt.h + SOURCES += \ + $$PWD/qt/WebCoreSupport/GeolocationClientQt.cpp +} + +enable?(ICONDATABASE) { + HEADERS += \ + $$PWD/../WebCore/loader/icon/IconDatabaseClient.h \ + $$PWD/qt/WebCoreSupport/IconDatabaseClientQt.h + + SOURCES += \ + $$PWD/qt/WebCoreSupport/IconDatabaseClientQt.cpp +} + +enable?(VIDEO) { use?(QTKIT) | use?(GSTREAMER) | use?(QT_MULTIMEDIA) { HEADERS += $$PWD/qt/WebCoreSupport/FullScreenVideoQt.h SOURCES += $$PWD/qt/WebCoreSupport/FullScreenVideoQt.cpp @@ -134,21 +129,4 @@ enable?(VIDEO) { } } -enable?(ICONDATABASE) { - HEADERS += \ - $$PWD/../WebCore/loader/icon/IconDatabaseClient.h \ - $$PWD/qt/WebCoreSupport/IconDatabaseClientQt.h - - SOURCES += \ - $$PWD/qt/WebCoreSupport/IconDatabaseClientQt.cpp -} - -enable?(GEOLOCATION) { - HEADERS += \ - $$PWD/qt/WebCoreSupport/GeolocationClientQt.h - SOURCES += \ - $$PWD/qt/WebCoreSupport/GeolocationClientQt.cpp -} - -use?(3D_GRAPHICS): WEBKIT += angle diff --git a/Source/WebKit/WebKitWidgets.pri b/Source/WebKit/WebKitWidgets.pri new file mode 100644 index 00000000000..54c61485f27 --- /dev/null +++ b/Source/WebKit/WebKitWidgets.pri @@ -0,0 +1,33 @@ +# ------------------------------------------------------------------- +# This file contains shared rules used both when building WebKitWidgets +# itself, and by targets that use WebKitWidgets. +# +# See 'Tools/qmake/README' for an overview of the build system +# ------------------------------------------------------------------- + +SOURCE_DIR = $${ROOT_WEBKIT_DIR}/Source/WebKit + +INCLUDEPATH += \ + $$SOURCE_DIR/qt/Api \ + $$SOURCE_DIR/qt/WebCoreSupport \ + $$ROOT_WEBKIT_DIR/Source/WTF/wtf/qt + +enable?(DEVICE_ORIENTATION)|enable?(ORIENTATION_EVENTS) { + QT += sensors +} + +enable?(GEOLOCATION): QT += location + +use?(QT_MULTIMEDIA): QT *= multimediawidgets + +contains(CONFIG, texmap): DEFINES += WTF_USE_TEXTURE_MAPPER=1 + +use?(PLUGIN_BACKEND_XLIB): PKGCONFIG += x11 + +QT += network widgets +have?(QTQUICK): QT += quick +have?(QTPRINTSUPPORT): QT += printsupport + +use?(TEXTURE_MAPPER_GL)|enable?(WEBGL) { + QT *= opengl +} diff --git a/Source/WebKit/WebKitWidgets.pro b/Source/WebKit/WebKitWidgets.pro new file mode 100644 index 00000000000..5ca754192b7 --- /dev/null +++ b/Source/WebKit/WebKitWidgets.pro @@ -0,0 +1,75 @@ +# ------------------------------------------------------------------- +# Target file for the WebKitWidgets static library +# +# See 'Tools/qmake/README' for an overview of the build system +# ------------------------------------------------------------------- + +TEMPLATE = lib +TARGET = WebKitWidgets + +include(WebKitWidgets.pri) + +WEBKIT += wtf javascriptcore webcore webkit1 +QT += gui + +CONFIG += staticlib + +SOURCES += \ + $$PWD/qt/Api/qgraphicswebview.cpp \ + $$PWD/qt/Api/qwebframe.cpp \ + $$PWD/qt/Api/qwebpage.cpp \ + $$PWD/qt/Api/qwebview.cpp \ + $$PWD/qt/Api/qwebplugindatabase.cpp \ + $$PWD/qt/Api/qwebinspector.cpp \ + $$PWD/qt/Api/qwebkitversion.cpp \ + $$PWD/qt/WebCoreSupport/QtFallbackWebPopup.cpp \ + $$PWD/qt/WebCoreSupport/QtWebComboBox.cpp \ + $$PWD/qt/WebCoreSupport/QWebUndoCommand.cpp \ + $$PWD/qt/WebCoreSupport/DefaultFullScreenVideoHandler.cpp \ + $$PWD/qt/WebCoreSupport/InitWebKitQt.cpp \ + $$PWD/qt/WebCoreSupport/InspectorClientWebPage.cpp \ + $$PWD/qt/WebCoreSupport/PageClientQt.cpp \ + $$PWD/qt/WebCoreSupport/QStyleFacadeImp.cpp \ + $$PWD/qt/WebCoreSupport/QGraphicsWidgetPluginImpl.cpp \ + $$PWD/qt/WebCoreSupport/QWidgetPluginImpl.cpp + +HEADERS += \ + $$PWD/qt/Api/qgraphicswebview.h \ + $$PWD/qt/Api/qwebframe.h \ + $$PWD/qt/Api/qwebframe_p.h \ + $$PWD/qt/Api/qwebkitglobal.h \ + $$PWD/qt/Api/qwebkitplatformplugin.h \ + $$PWD/qt/Api/qwebpage.h \ + $$PWD/qt/Api/qwebpage_p.h \ + $$PWD/qt/Api/qwebview.h \ + $$PWD/qt/Api/qwebinspector.h \ + $$PWD/qt/Api/qwebkitversion.h \ + $$PWD/qt/Api/qwebplugindatabase_p.h \ + $$PWD/qt/WebCoreSupport/InitWebKitQt.h \ + $$PWD/qt/WebCoreSupport/InspectorClientWebPage.h \ + $$PWD/qt/WebCoreSupport/DefaultFullScreenVideoHandler.h \ + $$PWD/qt/WebCoreSupport/QtFallbackWebPopup.h \ + $$PWD/qt/WebCoreSupport/QtWebComboBox.h \ + $$PWD/qt/WebCoreSupport/QWebUndoCommand.h \ + $$PWD/qt/WebCoreSupport/PageClientQt.h \ + $$PWD/qt/WebCoreSupport/QGraphicsWidgetPluginImpl.h \ + $$PWD/qt/WebCoreSupport/QStyleFacadeImp.h \ + $$PWD/qt/WebCoreSupport/QWidgetPluginImpl.h + +contains(QT_CONFIG, accessibility) { + SOURCES += $$PWD/qt/Api/qwebviewaccessible.cpp + HEADERS += $$PWD/qt/Api/qwebviewaccessible_p.h +} + +INCLUDEPATH += \ + $$PWD/qt/Api \ + $$PWD/qt/WebCoreSupport + +enable?(VIDEO) { + !use?(QTKIT):!use?(GSTREAMER):use?(QT_MULTIMEDIA) { + HEADERS += $$PWD/qt/WebCoreSupport/FullScreenVideoWidget.h + SOURCES += $$PWD/qt/WebCoreSupport/FullScreenVideoWidget.cpp + } +} + +use?(3D_GRAPHICS): WEBKIT += angle diff --git a/Source/WebKit/qt/Api/qgraphicswebview.cpp b/Source/WebKit/qt/Api/qgraphicswebview.cpp index ef42c95186e..84b4e801bd1 100644 --- a/Source/WebKit/qt/Api/qgraphicswebview.cpp +++ b/Source/WebKit/qt/Api/qgraphicswebview.cpp @@ -88,7 +88,7 @@ class QGraphicsWebViewPrivate { PageClientQGraphicsWidget* pageClient() const { - return static_cast (page->d->client.get()); + return static_cast (page->d->client.data()); } }; @@ -468,7 +468,7 @@ void QGraphicsWebViewPrivate::detachCurrentPage() return; page->d->view = 0; - page->d->client = nullptr; + page->d->client.reset(); // if the page was created by us, we own it and need to // destroy it as well. @@ -501,7 +501,7 @@ void QGraphicsWebView::setPage(QWebPage* page) if (!d->page) return; - d->page->d->client = adoptPtr(new PageClientQGraphicsWidget(this, page)); + d->page->d->client.reset(new PageClientQGraphicsWidget(this, page)); if (d->overlay()) d->overlay()->prepareGraphicsItemGeometryChange(); diff --git a/Source/WebKit/qt/Api/qwebelement.cpp b/Source/WebKit/qt/Api/qwebelement.cpp index 108b9b06f1d..82f579d9550 100644 --- a/Source/WebKit/qt/Api/qwebelement.cpp +++ b/Source/WebKit/qt/Api/qwebelement.cpp @@ -39,6 +39,7 @@ #include "JSHTMLElement.h" #include "JSObject.h" #include "PropertyNameArray.h" +#include #include #include "qt_runtime.h" #include "NodeList.h" @@ -47,8 +48,6 @@ #include "StaticNodeList.h" #include "StyleResolver.h" #include "markup.h" -#include "qwebframe.h" -#include "qwebframe_p.h" #include "runtime_root.h" #include #include @@ -706,7 +705,8 @@ QWebFrame *QWebElement::webFrame() const Frame* frame = document->frame(); if (!frame) return 0; - return QWebFramePrivate::kit(frame); + QWebFrameAdapter* frameAdapter = QWebFrameAdapter::kit(frame); + return frameAdapter->apiHandle(); } static bool setupScriptContext(WebCore::Element* element, JSC::JSValue& thisValue, ScriptState*& state, ScriptController*& scriptController) diff --git a/Source/WebKit/qt/Api/qwebframe.cpp b/Source/WebKit/qt/Api/qwebframe.cpp index 1310348ed89..89474dd2e6b 100644 --- a/Source/WebKit/qt/Api/qwebframe.cpp +++ b/Source/WebKit/qt/Api/qwebframe.cpp @@ -106,54 +106,6 @@ QT_BEGIN_NAMESPACE extern Q_GUI_EXPORT int qt_defaultDpi(); QT_END_NAMESPACE -static inline ResourceRequestCachePolicy cacheLoadControlToCachePolicy(uint cacheLoadControl) -{ - switch (cacheLoadControl) { - case QNetworkRequest::AlwaysNetwork: - return WebCore::ReloadIgnoringCacheData; - case QNetworkRequest::PreferCache: - return WebCore::ReturnCacheDataElseLoad; - case QNetworkRequest::AlwaysCache: - return WebCore::ReturnCacheDataDontLoad; - default: - break; - } - return WebCore::UseProtocolCachePolicy; -} - -QWebFrameData::QWebFrameData(WebCore::Page* parentPage, WebCore::Frame* parentFrame, - WebCore::HTMLFrameOwnerElement* ownerFrameElement, - const WTF::String& frameName) - : name(frameName) - , ownerElement(ownerFrameElement) - , page(parentPage) - , allowsScrolling(true) - , marginWidth(0) - , marginHeight(0) -{ - frameLoaderClient = new FrameLoaderClientQt(); - frame = Frame::create(page, ownerElement, frameLoaderClient); - - // FIXME: All of the below should probably be moved over into WebCore - frame->tree()->setName(name); - if (parentFrame) - parentFrame->tree()->appendChild(frame); -} - -void QWebFramePrivate::init(QWebFrame *qframe, QWebFrameData *frameData) -{ - q = qframe; - - allowsScrolling = frameData->allowsScrolling; - marginWidth = frameData->marginWidth; - marginHeight = frameData->marginHeight; - frame = frameData->frame.get(); - frameLoaderClient = frameData->frameLoaderClient; - frameLoaderClient->setFrame(qframe, frame); - - frame->init(); -} - void QWebFramePrivate::setPage(QWebPage* newPage) { if (page == newPage) @@ -166,6 +118,7 @@ void QWebFramePrivate::setPage(QWebPage* newPage) q->setParent(newPage); page = newPage; + pageAdapter = newPage->handle(); emit q->pageChanged(); } @@ -375,6 +328,11 @@ void QWebFramePrivate::emitUrlChanged() emit q->urlChanged(url); } +void QWebFramePrivate::didStartProvisionalLoad() +{ + emit q->provisionalLoad(); +} + void QWebFramePrivate::_q_orientationChanged() { #if ENABLE(ORIENTATION_EVENTS) @@ -409,6 +367,65 @@ void QWebFramePrivate::didClearWindowObject() emit q->javaScriptWindowObjectCleared(); } +bool QWebFramePrivate::handleProgressFinished(QPoint *localPos) +{ + QWidget *view = q->page()->view(); + if (!view || !localPos) + return false; + *localPos = view->mapFromGlobal(QCursor::pos()); + return view->hasFocus() && view->rect().contains(*localPos); +} + +void QWebFramePrivate::emitInitialLayoutCompleted() +{ + emit q->initialLayoutCompleted(); +} + +void QWebFramePrivate::emitIconChanged() +{ + emit q->iconChanged(); +} + +void QWebFramePrivate::emitLoadStarted(bool originatingLoad) +{ + if (page && originatingLoad) + emit page->loadStarted(); + emit q->loadStarted(); +} + +void QWebFramePrivate::emitLoadFinished(bool originatingLoad, bool ok) +{ + if (page && originatingLoad) + emit page->loadFinished(ok); + emit q->loadFinished(ok); +} + +QWebFrameAdapter* QWebFramePrivate::createChildFrame(QWebFrameData* frameData) +{ + QWebFrame* newFrame = new QWebFrame(/*parent frame*/q, frameData); + return newFrame->d; +} + +QWebFrame *QWebFramePrivate::apiHandle() +{ + return q; +} + +QObject *QWebFramePrivate::handle() +{ + return q; +} + +void QWebFramePrivate::contentsSizeDidChange(const QSize &size) +{ + emit q->contentsSizeChanged(size); +} + +int QWebFramePrivate::scrollBarPolicy(Qt::Orientation orientation) const +{ + return (int) q->scrollBarPolicy(orientation); +} + /*! \class QWebFrame \since 4.4 @@ -472,29 +489,27 @@ void QWebFramePrivate::didClearWindowObject() \value AllLayers Includes all the above layers */ -QWebFrame::QWebFrame(QWebPage *parent, QWebFrameData *frameData) - : QObject(parent) +QWebFrame::QWebFrame(QWebPage *parentPage) + : QObject(parentPage) , d(new QWebFramePrivate) { - d->page = parent; - d->init(this, frameData); + d->page = parentPage; + d->q = this; + d->init(/*page adapter*/ parentPage->handle()); - if (!frameData->url.isEmpty()) { - WebCore::ResourceRequest request(frameData->url, frameData->referrer); - d->frame->loader()->load(request, frameData->name, false); - } #if ENABLE(ORIENTATION_EVENTS) connect(&d->m_orientation, SIGNAL(readingChanged()), this, SLOT(_q_orientationChanged())); d->m_orientation.start(); #endif } -QWebFrame::QWebFrame(QWebFrame *parent, QWebFrameData *frameData) +QWebFrame::QWebFrame(QWebFrame* parent, QWebFrameData* frameData) : QObject(parent) , d(new QWebFramePrivate) { d->page = parent->d->page; - d->init(this, frameData); + d->q = this; + d->init(parent->d->pageAdapter, frameData); #if ENABLE(ORIENTATION_EVENTS) connect(&d->m_orientation, SIGNAL(readingChanged()), this, SLOT(_q_orientationChanged())); d->m_orientation.start(); @@ -503,9 +518,6 @@ QWebFrame::QWebFrame(QWebFrame *parent, QWebFrameData *frameData) QWebFrame::~QWebFrame() { - if (d->frame && d->frame->loader() && d->frame->loader()->client()) - static_cast(d->frame->loader()->client())->m_webFrame = 0; - delete d; } @@ -674,22 +686,6 @@ static inline bool isCoreFrameClear(WebCore::Frame* frame) return frame->document()->url().isEmpty(); } -static inline QUrl ensureAbsoluteUrl(const QUrl &url) -{ - if (!url.isValid() || !url.isRelative()) - return url; - - // This contains the URL with absolute path but without - // the query and the fragment part. - QUrl baseUrl = QUrl::fromLocalFile(QFileInfo(url.toLocalFile()).absoluteFilePath()); - - // The path is removed so the query and the fragment parts are there. - QString pathRemoved = url.toString(QUrl::RemovePath); - QUrl toResolve(pathRemoved); - - return baseUrl.resolved(toResolve); -} - /*! \property QWebFrame::url \brief the url of the frame currently viewed @@ -704,7 +700,7 @@ static inline QUrl ensureAbsoluteUrl(const QUrl &url) void QWebFrame::setUrl(const QUrl &url) { clearCoreFrame(d->frame); - const QUrl absolute = ensureAbsoluteUrl(url); + const QUrl absolute = QWebFrameAdapter::ensureAbsoluteUrl(url); d->url = absolute; load(absolute); } @@ -798,58 +794,7 @@ void QWebFrame::load(const QNetworkRequest &req, QNetworkAccessManager::Operation operation, const QByteArray &body) { - if (d->parentFrame()) - d->page->d->insideOpenCall = true; - - QUrl url = ensureAbsoluteUrl(req.url()); - - WebCore::ResourceRequest request(url); - - switch (operation) { - case QNetworkAccessManager::HeadOperation: - request.setHTTPMethod("HEAD"); - break; - case QNetworkAccessManager::GetOperation: - request.setHTTPMethod("GET"); - break; - case QNetworkAccessManager::PutOperation: - request.setHTTPMethod("PUT"); - break; - case QNetworkAccessManager::PostOperation: - request.setHTTPMethod("POST"); - break; - case QNetworkAccessManager::DeleteOperation: - request.setHTTPMethod("DELETE"); - break; - case QNetworkAccessManager::CustomOperation: - request.setHTTPMethod(req.attribute(QNetworkRequest::CustomVerbAttribute).toByteArray().constData()); - break; - case QNetworkAccessManager::UnknownOperation: - // eh? - break; - } - - QVariant cacheLoad = req.attribute(QNetworkRequest::CacheLoadControlAttribute); - if (cacheLoad.isValid()) { - bool ok; - uint cacheLoadValue = cacheLoad.toUInt(&ok); - if (ok) - request.setCachePolicy(cacheLoadControlToCachePolicy(cacheLoadValue)); - } - - QList httpHeaders = req.rawHeaderList(); - for (int i = 0; i < httpHeaders.size(); ++i) { - const QByteArray &headerName = httpHeaders.at(i); - request.addHTTPHeaderField(QString::fromLatin1(headerName), QString::fromLatin1(req.rawHeader(headerName))); - } - - if (!body.isEmpty()) - request.setHTTPBody(WebCore::FormData::create(body.constData(), body.size())); - - d->frame->loader()->load(request, false); - - if (d->parentFrame()) - d->page->d->insideOpenCall = false; + d->load(req, operation, body); } /*! @@ -1088,10 +1033,7 @@ void QWebFrame::scroll(int dx, int dy) QPoint QWebFrame::scrollPosition() const { - if (!d->frame->view()) - return QPoint(0, 0); - - IntSize ofs = d->frame->view()->scrollOffset(); + IntSize ofs = d->scrollPosition(); return QPoint(ofs.width(), ofs.height()); } @@ -1248,9 +1190,7 @@ QPoint QWebFrame::pos() const */ QRect QWebFrame::geometry() const { - if (!d->frame->view()) - return QRect(); - return d->frame->view()->frameRect(); + return d->frameRect(); } /*! @@ -1479,6 +1419,11 @@ QWebFrame* QWebFramePrivate::kit(const WebCore::Frame* coreFrame) return qobject_cast(coreFrame->loader()->networkingContext()->originatingObject()); } +QWebFrame *QWebFramePrivate::kit(const QWebFrameAdapter* frameAdapter) +{ + return static_cast(frameAdapter)->q; +} + /*! \fn void QWebFrame::javaScriptWindowObjectCleared() @@ -1859,4 +1804,12 @@ QWebFrame *QWebHitTestResult::frame() const return d->frame.data(); } +/*! + * \internal + */ +QWebFrameAdapter *QWebFrame::handle() const +{ + return d; +} + #include "moc_qwebframe.cpp" diff --git a/Source/WebKit/qt/Api/qwebframe.h b/Source/WebKit/qt/Api/qwebframe.h index ca96661e35c..fe00d81f5a0 100644 --- a/Source/WebKit/qt/Api/qwebframe.h +++ b/Source/WebKit/qt/Api/qwebframe.h @@ -41,8 +41,10 @@ class QPrinter; QT_END_NAMESPACE class QWebNetworkRequest; +class QWebFrameAdapter; class QWebFramePrivate; class QWebPage; +class QWebPageAdapter; class QWebHitTestResult; class QWebHistoryItem; class QWebSecurityOrigin; @@ -115,8 +117,8 @@ class QWEBKIT_EXPORT QWebFrame : public QObject { Q_PROPERTY(QPoint scrollPosition READ scrollPosition WRITE setScrollPosition) Q_PROPERTY(bool focus READ hasFocus) private: - QWebFrame(QWebPage *parent, QWebFrameData *frameData); - QWebFrame(QWebFrame *parent, QWebFrameData *frameData); + QWebFrame(QWebPage *parentPage); + QWebFrame(QWebFrame* parent, QWebFrameData*); ~QWebFrame(); public: @@ -200,6 +202,7 @@ class QWEBKIT_EXPORT QWebFrame : public QObject { virtual bool event(QEvent *); QWebSecurityOrigin securityOrigin() const; + QWebFrameAdapter* handle() const; public Q_SLOTS: QVariant evaluateJavaScript(const QString& scriptSource); diff --git a/Source/WebKit/qt/Api/qwebframe_p.h b/Source/WebKit/qt/Api/qwebframe_p.h index d6779f2bc59..dbdcbc85a45 100644 --- a/Source/WebKit/qt/Api/qwebframe_p.h +++ b/Source/WebKit/qt/Api/qwebframe_p.h @@ -21,24 +21,25 @@ #ifndef QWEBFRAME_P_H #define QWEBFRAME_P_H +#include "QWebFrameAdapter.h" + #include "qwebframe.h" #include "qwebpage_p.h" #include "EventHandler.h" +#include "Frame.h" #include "GraphicsContext.h" #include "KURL.h" #if ENABLE(ORIENTATION_EVENTS) #include "qorientationsensor.h" #endif // ENABLE(ORIENTATION_EVENTS). #include "qwebelement.h" -#include "wtf/RefPtr.h" -#include "Frame.h" -#include "ViewportArguments.h" -#include - #if USE(ACCELERATED_COMPOSITING) #include "texmap/TextureMapper.h" #endif +#include "ViewportArguments.h" +#include +#include namespace WebCore { @@ -50,42 +51,17 @@ namespace WebCore { } class QWebPage; -class QWebFrameData { -public: - QWebFrameData(WebCore::Page*, WebCore::Frame* parentFrame = 0, - WebCore::HTMLFrameOwnerElement* = 0, - const WTF::String& frameName = WTF::String()); - - WebCore::KURL url; - WTF::String name; - WebCore::HTMLFrameOwnerElement* ownerElement; - WebCore::Page* page; - RefPtr frame; - WebCore::FrameLoaderClientQt* frameLoaderClient; - - WTF::String referrer; - bool allowsScrolling; - int marginWidth; - int marginHeight; -}; - -class QWebFramePrivate { +class QWebFramePrivate : public QWebFrameAdapter { public: QWebFramePrivate() : q(0) , horizontalScrollBarPolicy(Qt::ScrollBarAsNeeded) , verticalScrollBarPolicy(Qt::ScrollBarAsNeeded) - , frameLoaderClient(0) - , frame(0) , page(0) - , allowsScrolling(true) - , marginWidth(-1) - , marginHeight(-1) #if USE(ACCELERATED_COMPOSITING) , rootTextureMapperLayer(0) #endif {} - void init(QWebFrame* qframe, QWebFrameData* frameData); void setPage(QWebPage*); inline QWebFrame *parentFrame() { return qobject_cast(q->parent()); } @@ -95,6 +71,7 @@ class QWebFramePrivate { static WebCore::Frame* core(const QWebFrame*); static QWebFrame* kit(const WebCore::Frame*); + static QWebFrame* kit(const QWebFrameAdapter*); void renderRelativeCoords(WebCore::GraphicsContext*, QFlags, const QRegion& clip); #if USE(TILED_BACKING_STORE) @@ -105,22 +82,29 @@ class QWebFramePrivate { void renderCompositedLayers(WebCore::GraphicsContext*, const WebCore::IntRect& clip); #endif void renderFrameExtras(WebCore::GraphicsContext*, QFlags, const QRegion& clip); - void emitUrlChanged(); void _q_orientationChanged(); - void didClearWindowObject(); + + // Adapter implementation + virtual QWebFrame* apiHandle() OVERRIDE; + virtual QObject* handle() OVERRIDE; + virtual void contentsSizeDidChange(const QSize &) OVERRIDE; + virtual int scrollBarPolicy(Qt::Orientation) const OVERRIDE; + virtual void emitUrlChanged() OVERRIDE; + virtual void didStartProvisionalLoad() OVERRIDE; + virtual void didClearWindowObject() OVERRIDE; + virtual bool handleProgressFinished(QPoint*) OVERRIDE; + virtual void emitInitialLayoutCompleted() OVERRIDE; + virtual void emitIconChanged() OVERRIDE; + virtual void emitLoadStarted(bool originatingLoad) OVERRIDE; + virtual void emitLoadFinished(bool originatingLoad, bool ok) OVERRIDE; + virtual QWebFrameAdapter* createChildFrame(QWebFrameData*) OVERRIDE; QWebFrame *q; Qt::ScrollBarPolicy horizontalScrollBarPolicy; Qt::ScrollBarPolicy verticalScrollBarPolicy; - WebCore::FrameLoaderClientQt *frameLoaderClient; - WebCore::Frame *frame; QWebPage *page; - WebCore::KURL url; - bool allowsScrolling; - int marginWidth; - int marginHeight; #if USE(ACCELERATED_COMPOSITING) WebCore::TextureMapperLayer* rootTextureMapperLayer; OwnPtr textureMapper; diff --git a/Source/WebKit/qt/Api/qwebhistory.cpp b/Source/WebKit/qt/Api/qwebhistory.cpp index f7849666e0f..a945b592bb2 100644 --- a/Source/WebKit/qt/Api/qwebhistory.cpp +++ b/Source/WebKit/qt/Api/qwebhistory.cpp @@ -20,15 +20,16 @@ #include "config.h" #include "qwebhistory.h" #include "qwebhistory_p.h" -#include "qwebframe_p.h" #include "BackForwardListImpl.h" +#include "Frame.h" #include "IconDatabaseBase.h" #include "Image.h" #include "IntSize.h" #include "KURL.h" #include "Page.h" #include "PageGroup.h" +#include #include #include @@ -552,9 +553,9 @@ QDataStream& operator>>(QDataStream& source, QWebHistory& history) return source; } -QWebPagePrivate* QWebHistoryPrivate::page() +QWebPageAdapter* QWebHistoryPrivate::page() { - return QWebFramePrivate::kit(static_cast(lst)->page()->mainFrame())->page()->handle(); + return QWebPageAdapter::kit(static_cast(lst)->page()); } WebCore::HistoryItem* QWebHistoryItemPrivate::core(const QWebHistoryItem* q) diff --git a/Source/WebKit/qt/Api/qwebhistory_p.h b/Source/WebKit/qt/Api/qwebhistory_p.h index aaee386329c..17634ebc088 100644 --- a/Source/WebKit/qt/Api/qwebhistory_p.h +++ b/Source/WebKit/qt/Api/qwebhistory_p.h @@ -26,7 +26,7 @@ #include #include -class QWebPagePrivate; +class QWebPageAdapter; class QWEBKIT_EXPORT QWebHistoryItemPrivate : public QSharedData { public: @@ -63,7 +63,7 @@ class QWebHistoryPrivate : public QSharedData { lst->deref(); } - QWebPagePrivate* page(); + QWebPageAdapter* page(); WebCore::BackForwardListImpl* lst; }; diff --git a/Source/WebKit/qt/Api/qwebinspector.cpp b/Source/WebKit/qt/Api/qwebinspector.cpp index 2fbbab249a0..55089e1a1fc 100644 --- a/Source/WebKit/qt/Api/qwebinspector.cpp +++ b/Source/WebKit/qt/Api/qwebinspector.cpp @@ -184,12 +184,12 @@ void QWebInspector::closeEvent(QCloseEvent* event) } /*! \internal */ -void QWebInspectorPrivate::setFrontend(QWidget* newFrontend) +void QWebInspectorPrivate::setFrontend(QObject* newFrontend) { if (frontend) frontend->setParent(0); - frontend = newFrontend; + frontend = qobject_cast(newFrontend); if (frontend) { frontend->setParent(q); diff --git a/Source/WebKit/qt/Api/qwebinspector_p.h b/Source/WebKit/qt/Api/qwebinspector_p.h index 4d327cc5a91..908de84edc1 100644 --- a/Source/WebKit/qt/Api/qwebinspector_p.h +++ b/Source/WebKit/qt/Api/qwebinspector_p.h @@ -35,7 +35,7 @@ class QWebInspectorPrivate { , frontend(0) {} - void setFrontend(QWidget* newFrontend); + void setFrontend(QObject* newFrontend); void adjustFrontendSize(const QSize& size); QWebInspector* q; diff --git a/Source/WebKit/qt/Api/qwebpage.cpp b/Source/WebKit/qt/Api/qwebpage.cpp index 02383ac6741..68a3ff1f3e2 100644 --- a/Source/WebKit/qt/Api/qwebpage.cpp +++ b/Source/WebKit/qt/Api/qwebpage.cpp @@ -22,18 +22,6 @@ #include "config.h" #include "qwebpage.h" -#include "qwebview.h" -#include "qwebframe.h" -#include "qwebpage_p.h" -#include "qwebframe_p.h" -#include "qwebhistory.h" -#include "qwebhistory_p.h" -#include "qwebinspector.h" -#include "qwebinspector_p.h" -#include "qwebsettings.h" -#include "qwebkitplatformplugin.h" -#include "qwebkitversion.h" - #include "CSSComputedStyleDeclaration.h" #include "CSSParser.h" #include "ApplicationCacheStorage.h" @@ -45,6 +33,9 @@ #include "ContextMenu.h" #include "ContextMenuClientQt.h" #include "ContextMenuController.h" +#if USE(QT_MULTIMEDIA) +#include "DefaultFullScreenVideoHandler.h" +#endif #if ENABLE(DEVICE_ORIENTATION) #include "DeviceMotionClientQt.h" #include "DeviceOrientationClientMock.h" @@ -62,7 +53,6 @@ #include "Frame.h" #include "FrameLoadRequest.h" #include "FrameLoader.h" -#include "FrameLoader.h" #include "FrameLoaderClientQt.h" #include "FrameTree.h" #include "FrameView.h" @@ -78,8 +68,9 @@ #include "HTMLNames.h" #include "HitTestResult.h" #include "Image.h" -#include "InitWebCoreQt.h" +#include "InitWebKitQt.h" #include "InspectorClientQt.h" +#include "InspectorClientWebPage.h" #include "InspectorController.h" #include "InspectorServerQt.h" #include "KURL.h" @@ -88,20 +79,22 @@ #include "NavigationAction.h" #include "NetworkingContext.h" #include "NodeList.h" -#include "NotificationPresenterClientQt.h" #include "NotImplemented.h" +#include "NotificationPresenterClientQt.h" #include "Page.h" #include "PageClientQt.h" #include "PageGroup.h" #include "Pasteboard.h" -#include "PlatformGestureEvent.h" #include "PlatformKeyboardEvent.h" #include "PlatformTouchEvent.h" #include "PlatformWheelEvent.h" #include "PluginDatabase.h" -#include "PluginDatabase.h" #include "PluginPackage.h" #include "ProgressTracker.h" +#include "QGraphicsWidgetPluginImpl.h" +#include "QWebUndoCommand.h" +#include "QWidgetPluginImpl.h" +#include "QtFallbackWebPopup.h" #include "QtPlatformPlugin.h" #include "RenderTextControl.h" #include "RenderThemeQt.h" @@ -114,16 +107,30 @@ #include "SystemInfo.h" #endif // Q_OS_WIN32 #include "TextIterator.h" +#include "UndoStepQt.h" #include "UserAgentQt.h" #include "WebEventConversion.h" #include "WebKitVersion.h" #include "WindowFeatures.h" #include "WorkerThread.h" +#include "qwebframe.h" +#include "qwebframe_p.h" +#include "qwebhistory.h" +#include "qwebhistory_p.h" +#include "qwebinspector.h" +#include "qwebinspector_p.h" +#include "qwebkitplatformplugin.h" +#include "qwebkitversion.h" +#include "qwebpage_p.h" +#include "qwebsettings.h" +#include "qwebview.h" + #include #include #include #include +#include #include #include #include @@ -137,24 +144,25 @@ #include #include #include +#include #include -#include -#include +#include #include -#include #include #include #include +#if USE(QT_MOBILITY_SYSTEMINFO) +#include +#endif +#include #include +#include #include -#include -#include +#include +#include #if defined(Q_WS_X11) #include #endif -#if USE(QT_MOBILITY_SYSTEMINFO) -#include -#endif using namespace WebCore; @@ -163,8 +171,6 @@ QT_BEGIN_NAMESPACE extern Q_GUI_EXPORT int qt_defaultDpi(); QT_END_NAMESPACE -bool QWebPagePrivate::drtRun = false; - // Lookup table mapping QWebPage::WebActions to the associated Editor commands static const char* editorCommandWebActions[] = { @@ -300,40 +306,32 @@ static inline Qt::DropAction dragOpToDropAction(unsigned actions) QWebPagePrivate::QWebPagePrivate(QWebPage *qq) : q(qq) - , page(0) #ifndef QT_NO_UNDOSTACK , undoStack(0) #endif - , insideOpenCall(false) , m_totalBytes(0) , m_bytesReceived() , clickCausedFocus(false) - , networkManager(0) - , forwardUnsupportedContent(false) - , smartInsertDeleteEnabled(true) - , selectTrailingWhitespaceEnabled(false) , linkPolicy(QWebPage::DontDelegateLinks) - , viewportSize(QSize(0, 0)) - , settings(0) + , m_viewportSize(QSize(0, 0)) , useFixedLayout(false) - , pluginFactory(0) , inspectorFrontend(0) , inspector(0) , inspectorIsInternalOnly(false) , m_lastDropAction(Qt::IgnoreAction) { #if ENABLE(GEOLOCATION) || ENABLE(DEVICE_ORIENTATION) - bool useMock = QWebPagePrivate::drtRun; + bool useMock = QWebPageAdapter::drtRun; #endif - WebCore::initializeWebCoreQt(); + WebKit::initializeWebKitWidgets(); Page::PageClients pageClients; - pageClients.chromeClient = new ChromeClientQt(q); + pageClients.chromeClient = new ChromeClientQt(this); pageClients.contextMenuClient = new ContextMenuClientQt(); - pageClients.editorClient = new EditorClientQt(q); - pageClients.dragClient = new DragClientQt(q); - pageClients.inspectorClient = new InspectorClientQt(q); + pageClients.editorClient = new EditorClientQt(this); + pageClients.dragClient = new DragClientQt(pageClients.chromeClient); + pageClients.inspectorClient = new InspectorClientQt(this); page = new Page(pageClients); #if ENABLE(GEOLOCATION) if (useMock) { @@ -342,7 +340,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) WebCore::provideGeolocationTo(page, mock); mock->setController(WebCore::GeolocationController::from(page)); } else - WebCore::provideGeolocationTo(page, new GeolocationClientQt(q)); + WebCore::provideGeolocationTo(page, new GeolocationClientQt(this)); #endif #if ENABLE(DEVICE_ORIENTATION) if (useMock) @@ -351,9 +349,6 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) WebCore::provideDeviceOrientationTo(page, new DeviceOrientationClientQt); WebCore::provideDeviceMotionTo(page, new DeviceMotionClientQt); #endif -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) - WebCore::provideNotification(page, NotificationPresenterClientQt::notificationPresenter()); -#endif // By default each page is put into their own unique page group, which affects popup windows // and visited links. Page groups (per process only) is a feature making it possible to use @@ -364,7 +359,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) page->addLayoutMilestones(DidFirstVisuallyNonEmptyLayout); - settings = new QWebSettings(page->settings()); + QWebPageAdapter::init(page); history.d = new QWebHistoryPrivate(static_cast(page->backForwardList())); memset(actions, 0, sizeof(actions)); @@ -372,8 +367,13 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) PageGroup::setShouldTrackVisitedLinks(true); #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) - NotificationPresenterClientQt::notificationPresenter()->addClient(); -#endif + NotificationPresenterClientQt* presenter = NotificationPresenterClientQt::notificationPresenter(); + presenter->addClient(); +#ifndef QT_NO_SYSTEMTRAYICON + if (!presenter->hasSystemTrayIcon()) + presenter->setSystemTrayIcon(new QSystemTrayIcon); +#endif // QT_NO_SYSTEMTRAYICON +#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) } QWebPagePrivate::~QWebPagePrivate() @@ -384,8 +384,6 @@ QWebPagePrivate::~QWebPagePrivate() #ifndef QT_NO_UNDOSTACK delete undoStack; #endif - delete settings; - delete page; if (inspector) { // If the inspector is ours, delete it, otherwise just detach from it. @@ -394,41 +392,220 @@ QWebPagePrivate::~QWebPagePrivate() else inspector->setPage(0); } + // Explicitly destruct the WebCore page at this point when the + // QWebPagePrivate / QWebPageAdapater vtables are still intact, + // in order for various destruction callbacks out of WebCore to + // work. + deletePage(); +} -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) - NotificationPresenterClientQt::notificationPresenter()->removeClient(); +WebCore::Page* QWebPagePrivate::core(const QWebPage* page) +{ + return page->d->page; +} + +void QWebPagePrivate::show() +{ + if (!view) + return; + view->window()->show(); +} + +void QWebPagePrivate::setFocus() +{ + if (!view) + return; + view->setFocus(); +} + +void QWebPagePrivate::unfocus() +{ + if (!view) + return; + view->clearFocus(); +} + +void QWebPagePrivate::setWindowRect(const QRect &rect) +{ + emit q->geometryChangeRequested(rect); +} + +QSize QWebPagePrivate::viewportSize() const +{ + return q->viewportSize(); +} + +QWebPageAdapter *QWebPagePrivate::createWindow(bool dialog) +{ + QWebPage *newPage = q->createWindow(dialog ? QWebPage::WebModalDialog : QWebPage::WebBrowserWindow); + if (!newPage) + return 0; + // Make sure the main frame exists, as WebCore expects it when returning from this ChromeClient::createWindow() + newPage->d->createMainFrame(); + return newPage->d; +} + +void QWebPagePrivate::javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID) +{ + q->javaScriptConsoleMessage(message, lineNumber, sourceID); +} + +void QWebPagePrivate::javaScriptAlert(QWebFrameAdapter* frame, const QString& msg) +{ + q->javaScriptAlert(QWebFramePrivate::kit(frame), msg); +} + +bool QWebPagePrivate::javaScriptConfirm(QWebFrameAdapter* frame, const QString& msg) +{ + return q->javaScriptConfirm(QWebFramePrivate::kit(frame), msg); +} + +bool QWebPagePrivate::javaScriptPrompt(QWebFrameAdapter *frame, const QString &msg, const QString &defaultValue, QString *result) +{ + return q->javaScriptPrompt(QWebFramePrivate::kit(frame), msg, defaultValue, result); +} + +void QWebPagePrivate::printRequested(QWebFrameAdapter *frame) +{ + emit q->printRequested(QWebFramePrivate::kit(frame)); +} + +void QWebPagePrivate::databaseQuotaExceeded(QWebFrameAdapter* frame, const QString& databaseName) +{ + emit q->databaseQuotaExceeded(QWebFramePrivate::kit(frame), databaseName); +} + +void QWebPagePrivate::applicationCacheQuotaExceeded(QWebSecurityOrigin *origin, quint64 defaultOriginQuota, quint64 c) +{ + emit q->applicationCacheQuotaExceeded(origin, defaultOriginQuota, defaultOriginQuota); +} + +void QWebPagePrivate::setToolTip(const QString &tip) +{ +#ifndef QT_NO_TOOLTIP + if (!view) + return; + + if (tip.isEmpty()) { + view->setToolTip(QString()); + QToolTip::hideText(); + } else { + QString dtip = QLatin1String("

") + QString(tip).toHtmlEscaped() + QLatin1String("

"); + view->setToolTip(dtip); + } +#else + Q_UNUSED(tip); #endif } -WebCore::ViewportArguments QWebPagePrivate::viewportArguments() +#if USE(QT_MULTIMEDIA) +QWebFullScreenVideoHandler *QWebPagePrivate::createFullScreenVideoHandler() { - return page ? page->viewportArguments() : WebCore::ViewportArguments(); + return new WebKit::DefaultFullScreenVideoHandler; } +#endif -WebCore::Page* QWebPagePrivate::core(const QWebPage* page) +QWebFrameAdapter *QWebPagePrivate::mainFrameAdapter() { - return page->d->page; + return q->mainFrame()->d; } -QWebPagePrivate* QWebPagePrivate::priv(QWebPage* page) +QStringList QWebPagePrivate::chooseFiles(QWebFrameAdapter *frame, bool allowMultiple, const QStringList &suggestedFileNames) { - return page->d; + if (allowMultiple && q->supportsExtension(QWebPage::ChooseMultipleFilesExtension)) { + QWebPage::ChooseMultipleFilesExtensionOption option; + option.parentFrame = QWebFramePrivate::kit(frame); + option.suggestedFileNames = suggestedFileNames; + + QWebPage::ChooseMultipleFilesExtensionReturn output; + q->extension(QWebPage::ChooseMultipleFilesExtension, &option, &output); + + return output.fileNames; + } + // Single file + QStringList result; + QString suggestedFile; + if (!suggestedFileNames.isEmpty()) + suggestedFile = suggestedFileNames.first(); + QString file = q->chooseFile(QWebFramePrivate::kit(frame), suggestedFile); + if (!file.isEmpty()) + result << file; + return result; } -bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type) +bool QWebPagePrivate::acceptNavigationRequest(QWebFrameAdapter *frameAdapter, const QNetworkRequest &request, int type) { + QWebFrame *frame = frameAdapter ? QWebFramePrivate::kit(frameAdapter): 0; if (insideOpenCall && frame == mainFrame.data()) return true; - return q->acceptNavigationRequest(frame, request, type); + return q->acceptNavigationRequest(frame, request, QWebPage::NavigationType(type)); +} + +void QWebPagePrivate::emitRestoreFrameStateRequested(QWebFrameAdapter *frame) +{ + emit q->restoreFrameStateRequested(QWebFramePrivate::kit(frame)); +} + +void QWebPagePrivate::emitSaveFrameStateRequested(QWebFrameAdapter *frame, QWebHistoryItem *item) +{ + emit q->saveFrameStateRequested(QWebFramePrivate::kit(frame), item); +} + +void QWebPagePrivate::emitDownloadRequested(const QNetworkRequest &request) +{ + emit q->downloadRequested(request); +} + +void QWebPagePrivate::emitFrameCreated(QWebFrameAdapter *frame) +{ + emit q->frameCreated(QWebFramePrivate::kit(frame)); +} + +bool QWebPagePrivate::errorPageExtension(QWebPageAdapter::ErrorPageOption *opt, QWebPageAdapter::ErrorPageReturn *out) +{ + QWebPage::ErrorPageExtensionOption option; + if (opt->domain == QLatin1String("QtNetwork")) + option.domain = QWebPage::QtNetwork; + else if (opt->domain == QLatin1String("HTTP")) + option.domain = QWebPage::Http; + else if (opt->domain == QLatin1String("WebKit")) + option.domain = QWebPage::WebKit; + else + return false; + option.url = opt->url; + option.frame = QWebFramePrivate::kit(opt->frame); + option.error = opt->error; + option.errorString = opt->errorString; + QWebPage::ErrorPageExtensionReturn output; + if (!q->extension(QWebPage::ErrorPageExtension, &option, &output)) + return false; + out->baseUrl = output.baseUrl; + out->content = output.content; + out->contentType = output.contentType; + out->encoding = output.encoding; + return true; +} + +QtPluginWidgetAdapter *QWebPagePrivate::createPlugin(const QString &classid, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) +{ + QObject *widget = q->createPlugin(classid, url, paramNames, paramValues); + return adapterForWidget(widget); +} + +QtPluginWidgetAdapter *QWebPagePrivate::adapterForWidget(QObject *object) const +{ + if (QWidget *widget = qobject_cast(object)) + return new QWidgetPluginImpl(widget); + if (QGraphicsWidget *widget = qobject_cast(object)) + return new QGraphicsWidgetPluginImpl(widget); + return 0; } void QWebPagePrivate::createMainFrame() { if (!mainFrame) { - QWebFrameData frameData(page); - mainFrame = new QWebFrame(q, &frameData); - + mainFrame = new QWebFrame(q); emit q->frameCreated(mainFrame.data()); } } @@ -475,49 +652,49 @@ QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMen if (!client || !webcoreMenu) return 0; - QMenu* menu = new QMenu(client->ownerWidget()); + QMenu* menu = new QMenu(q->view()); for (int i = 0; i < items->count(); ++i) { const ContextMenuItem &item = items->at(i); switch (item.type()) { - case WebCore::CheckableActionType: /* fall through */ - case WebCore::ActionType: { - QWebPage::WebAction action = webActionForContextMenuAction(item.action()); - QAction *a = q->action(action); - if (a) { - ContextMenuItem it(item); - page->contextMenuController()->checkOrEnableIfNeeded(it); - PlatformMenuItemDescription desc = it.releasePlatformDescription(); - a->setEnabled(desc.enabled); - a->setChecked(desc.checked); - a->setCheckable(item.type() == WebCore::CheckableActionType); - - menu->addAction(a); - visitedWebActions->setBit(action); - } - break; + case WebCore::CheckableActionType: /* fall through */ + case WebCore::ActionType: { + QWebPage::WebAction action = webActionForContextMenuAction(item.action()); + QAction *a = q->action(action); + if (a) { + ContextMenuItem it(item); + page->contextMenuController()->checkOrEnableIfNeeded(it); + PlatformMenuItemDescription desc = it.releasePlatformDescription(); + a->setEnabled(desc.enabled); + a->setChecked(desc.checked); + a->setCheckable(item.type() == WebCore::CheckableActionType); + + menu->addAction(a); + visitedWebActions->setBit(action); } - case WebCore::SeparatorType: - menu->addSeparator(); - break; - case WebCore::SubmenuType: { - QMenu *subMenu = createContextMenu(webcoreMenu, item.platformSubMenu(), visitedWebActions); + break; + } + case WebCore::SeparatorType: + menu->addSeparator(); + break; + case WebCore::SubmenuType: { + QMenu *subMenu = createContextMenu(webcoreMenu, item.platformSubMenu(), visitedWebActions); - bool anyEnabledAction = false; + bool anyEnabledAction = false; - QList actions = subMenu->actions(); - for (int i = 0; i < actions.count(); ++i) { - if (actions.at(i)->isVisible()) - anyEnabledAction |= actions.at(i)->isEnabled(); - } - - // don't show sub-menus with just disabled actions - if (anyEnabledAction) { - subMenu->setTitle(item.title()); - menu->addAction(subMenu->menuAction()); - } else - delete subMenu; - break; + QList actions = subMenu->actions(); + for (int i = 0; i < actions.count(); ++i) { + if (actions.at(i)->isVisible()) + anyEnabledAction |= actions.at(i)->isEnabled(); } + + // don't show sub-menus with just disabled actions + if (anyEnabledAction) { + subMenu->setTitle(item.title()); + menu->addAction(subMenu->menuAction()); + } else + delete subMenu; + break; + } } } return menu; @@ -619,6 +796,65 @@ void QWebPagePrivate::updateNavigationActions() updateAction(QWebPage::ReloadAndBypassCache); } +QObject *QWebPagePrivate::inspectorHandle() +{ + return getOrCreateInspector(); +} + +void QWebPagePrivate::setInspectorFrontend(QObject* frontend) +{ + inspectorFrontend = qobject_cast(frontend); + if (inspector) + inspector->d->setFrontend(frontend); +} + +void QWebPagePrivate::setInspectorWindowTitle(const QString& title) +{ + if (inspector) + inspector->setWindowTitle(title); +} + +void QWebPagePrivate::createWebInspector(QObject** inspectorView, QWebPageAdapter** inspectorPage) +{ + QWebPage* page = new WebKit::InspectorClientWebPage; + *inspectorView = page->view(); + *inspectorPage = page->d; +} + +#ifndef QT_NO_MENU +static QStringList iterateContextMenu(QMenu* menu) +{ + if (!menu) + return QStringList(); + + QStringList items; + QList actions = menu->actions(); + for (int i = 0; i < actions.count(); ++i) { + if (actions.at(i)->isSeparator()) + items << QLatin1String(""); + else + items << actions.at(i)->text(); + if (actions.at(i)->menu()) + items << iterateContextMenu(actions.at(i)->menu()); + } + return items; +} +#endif + +QStringList QWebPagePrivate::menuActionsAsText() +{ +#ifndef QT_NO_MENU + return iterateContextMenu(currentContextMenu.data()); +#else + return QStringList(); +#endif +} + +void QWebPagePrivate::emitViewportChangeRequested() +{ + emit q->viewportChangeRequested(); +} + void QWebPagePrivate::updateEditorActions() { updateAction(QWebPage::Cut); @@ -682,8 +918,7 @@ void QWebPagePrivate::timerEvent(QTimerEvent *ev) q->timerEvent(ev); } -template -void QWebPagePrivate::mouseMoveEvent(T* ev) +void QWebPagePrivate::mouseMoveEvent(QMouseEvent* ev) { WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data()); if (!frame->view()) @@ -693,8 +928,7 @@ void QWebPagePrivate::mouseMoveEvent(T* ev) ev->setAccepted(accepted); } -template -void QWebPagePrivate::mousePressEvent(T* ev) +void QWebPagePrivate::mousePressEvent(QMouseEvent* ev) { WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data()); if (!frame->view()) @@ -729,8 +963,7 @@ void QWebPagePrivate::mousePressEvent(T* ev) clickCausedFocus = true; } -template -void QWebPagePrivate::mouseDoubleClickEvent(T *ev) +void QWebPagePrivate::mouseDoubleClickEvent(QMouseEvent *ev) { WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data()); if (!frame->view()) @@ -747,8 +980,7 @@ void QWebPagePrivate::mouseDoubleClickEvent(T *ev) tripleClick = QPointF(ev->pos()).toPoint(); } -template -void QWebPagePrivate::mouseTripleClickEvent(T *ev) +void QWebPagePrivate::mouseTripleClickEvent(QMouseEvent *ev) { WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data()); if (!frame->view()) @@ -762,8 +994,7 @@ void QWebPagePrivate::mouseTripleClickEvent(T *ev) ev->setAccepted(accepted); } -template -void QWebPagePrivate::mouseReleaseEvent(T *ev) +void QWebPagePrivate::mouseReleaseEvent(QMouseEvent *ev) { WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data()); if (!frame->view()) @@ -790,7 +1021,7 @@ void QWebPagePrivate::handleSoftwareInputPanel(Qt::MouseButton button, const QPo && frame->document()->focusedNode() && button == Qt::LeftButton && qApp->autoSipEnabled()) { QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( - client->ownerWidget()->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); + client->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) { HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(frame->view()->windowToContents(pos), false); if (result.isContentEditable()) { @@ -833,14 +1064,13 @@ QMenu *QWebPage::createStandardContextMenu() } #ifndef QT_NO_WHEELEVENT -template -void QWebPagePrivate::wheelEvent(T *ev) +void QWebPagePrivate::wheelEvent(QWheelEvent *ev) { WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data()); if (!frame->view()) return; - PlatformWheelEvent pev = convertWheelEvent(ev); + PlatformWheelEvent pev = convertWheelEvent(ev, QApplication::wheelScrollLines()); bool accepted = frame->eventHandler()->handleWheelEvent(pev); ev->setAccepted(accepted); } @@ -1340,33 +1570,39 @@ bool QWebPagePrivate::touchEvent(QTouchEvent* event) bool QWebPagePrivate::gestureEvent(QGestureEvent* event) { -#if ENABLE(GESTURE_EVENTS) - WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data()); - if (!frame->view()) + QWebFrameAdapter* frame = mainFrame.data()->d; + if (!frame->hasView()) return false; - // QGestureEvents can contain updates for multiple gestures. bool handled = false; +#if ENABLE(GESTURE_EVENTS) + // QGestureEvent lives in Widgets, we'll need a dummy struct to mule the info it contains to the "other side" + QGestureEventFacade gestureFacade; + QGesture* gesture = event->gesture(Qt::TapGesture); // Beware that gestures send by DumpRenderTree will have state Qt::NoGesture, // due to not originating from a GestureRecognizer. if (gesture && (gesture->state() == Qt::GestureStarted || gesture->state() == Qt::NoGesture)) { - frame->eventHandler()->handleGestureEvent(convertGesture(event, gesture)); - event->setAccepted(true); + gestureFacade.type = Qt::TapGesture; + QPointF globalPos = static_cast(gesture)->position(); + gestureFacade.globalPos = globalPos.toPoint(); + gestureFacade.pos = event->widget()->mapFromGlobal(globalPos.toPoint()); + frame->handleGestureEvent(&gestureFacade); handled = true; } gesture = event->gesture(Qt::TapAndHoldGesture); if (gesture && (gesture->state() == Qt::GestureStarted || gesture->state() == Qt::NoGesture)) { - frame->eventHandler()->sendContextMenuEventForGesture(convertGesture(event, gesture)); - event->setAccepted(true); + gestureFacade.type = Qt::TapAndHoldGesture; + QPointF globalPos = static_cast(gesture)->position(); + gestureFacade.globalPos = globalPos.toPoint(); + gestureFacade.pos = event->widget()->mapFromGlobal(globalPos.toPoint()); + frame->handleGestureEvent(&gestureFacade); handled = true; } +#endif // ENABLE(GESTURE_EVENTS) + event->setAccepted(handled); return handled; -#else - event->ignore(); - return false; -#endif } /*! @@ -2037,12 +2273,12 @@ void QWebPage::setView(QWidget* view) if (d->client) { if (d->client->isQWidgetClient()) - static_cast(d->client.get())->view = view; + static_cast(d->client.data())->view = view; return; } if (view) - d->client = adoptPtr(new PageClientQWidget(view, this)); + d->client.reset(new PageClientQWidget(view, this)); } /*! @@ -2068,7 +2304,7 @@ void QWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, // Catch plugin logDestroy message for LayoutTests/plugins/open-and-close-window-with-plugin.html // At this point DRT's WebPage has already been destroyed - if (QWebPagePrivate::drtRun) { + if (QWebPageAdapter::drtRun) { if (message == QLatin1String("PLUGIN: NPP_Destroy")) { fprintf(stdout, "CONSOLE MESSAGE: "); if (lineNumber) @@ -2088,8 +2324,7 @@ void QWebPage::javaScriptAlert(QWebFrame *frame, const QString& msg) { Q_UNUSED(frame) #ifndef QT_NO_MESSAGEBOX - QWidget* parent = (d->client) ? d->client->ownerWidget() : 0; - QMessageBox box(parent); + QMessageBox box(view()); box.setWindowTitle(tr("JavaScript Alert - %1").arg(mainFrame()->url().host())); box.setTextFormat(Qt::PlainText); box.setText(msg); @@ -2110,8 +2345,7 @@ bool QWebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg) #ifdef QT_NO_MESSAGEBOX return true; #else - QWidget* parent = (d->client) ? d->client->ownerWidget() : 0; - QMessageBox box(parent); + QMessageBox box(view()); box.setWindowTitle(tr("JavaScript Confirm - %1").arg(mainFrame()->url().host())); box.setTextFormat(Qt::PlainText); box.setText(msg); @@ -2136,8 +2370,7 @@ bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QStr bool ok = false; #ifndef QT_NO_INPUTDIALOG - QWidget* parent = (d->client) ? d->client->ownerWidget() : 0; - QInputDialog dlg(parent); + QInputDialog dlg(view()); dlg.setWindowTitle(tr("JavaScript Prompt - %1").arg(mainFrame()->url().host())); // Hack to force the dialog's QLabel into plain text mode @@ -2181,8 +2414,7 @@ bool QWebPage::shouldInterruptJavaScript() #ifdef QT_NO_MESSAGEBOX return false; #else - QWidget* parent = (d->client) ? d->client->ownerWidget() : 0; - return QMessageBox::Yes == QMessageBox::information(parent, tr("JavaScript Problem - %1").arg(mainFrame()->url().host()), tr("The script on this page appears to have a problem. Do you want to stop the script?"), QMessageBox::Yes, QMessageBox::No); + return QMessageBox::Yes == QMessageBox::information(view(), tr("JavaScript Problem - %1").arg(mainFrame()->url().host()), tr("The script on this page appears to have a problem. Do you want to stop the script?"), QMessageBox::Yes, QMessageBox::No); #endif } @@ -2197,7 +2429,8 @@ void QWebPage::setFeaturePermission(QWebFrame* frame, Feature feature, Permissio break; case Geolocation: #if ENABLE(GEOLOCATION) - GeolocationPermissionClientQt::geolocationPermissionClient()->setPermission(frame, policy); + if (policy != PermissionUnknown) + GeolocationPermissionClientQt::geolocationPermissionClient()->setPermission(frame->d, (policy == PermissionGrantedByUser)); #endif break; @@ -2461,20 +2694,146 @@ QColor QWebPagePrivate::colorSelectionRequested(const QColor &selectedColor) { QColor ret = selectedColor; #ifndef QT_NO_COLORDIALOG - QWidget* parent = (client) ? client->ownerWidget() : 0; - ret = QColorDialog::getColor(selectedColor, parent); + ret = QColorDialog::getColor(selectedColor, q->view()); if (!ret.isValid()) ret = selectedColor; #endif return ret; } +QWebSelectMethod *QWebPagePrivate::createSelectPopup() +{ + return new QtFallbackWebPopup(this); +} + +QRect QWebPagePrivate::viewRectRelativeToWindow() +{ + + QWidget* ownerWidget= client.isNull() ? 0 : qobject_cast(client->ownerWidget()); + if (!ownerWidget) + return QRect(); + QWidget* topLevelWidget = ownerWidget->window(); + + QPoint topLeftCorner = ownerWidget->mapFrom(topLevelWidget, QPoint(0, 0)); + return QRect(topLeftCorner, ownerWidget->size()); +} + +void QWebPagePrivate::geolocationPermissionRequested(QWebFrameAdapter* frame) +{ + emit q->featurePermissionRequested(QWebFramePrivate::kit(frame), QWebPage::Geolocation); +} + +void QWebPagePrivate::geolocationPermissionRequestCancelled(QWebFrameAdapter* frame) +{ + emit q->featurePermissionRequestCanceled(QWebFramePrivate::kit(frame), QWebPage::Geolocation); +} + +void QWebPagePrivate::notificationsPermissionRequested(QWebFrameAdapter* frame) +{ + emit q->featurePermissionRequested(QWebFramePrivate::kit(frame), QWebPage::Notifications); +} + +void QWebPagePrivate::notificationsPermissionRequestCancelled(QWebFrameAdapter* frame) +{ + emit q->featurePermissionRequestCanceled(QWebFramePrivate::kit(frame), QWebPage::Notifications); +} + +void QWebPagePrivate::respondToChangedContents() +{ + updateEditorActions(); + + emit q->contentsChanged(); +} + +void QWebPagePrivate::respondToChangedSelection() +{ + updateEditorActions(); + emit q->selectionChanged(); +} + +void QWebPagePrivate::microFocusChanged() +{ + emit q->microFocusChanged(); +} + +void QWebPagePrivate::triggerCopyAction() +{ + q->triggerAction(QWebPage::Copy); +} + +void QWebPagePrivate::triggerActionForKeyEvent(QKeyEvent* event) +{ + QWebPage::WebAction action = editorActionForKeyEvent(event); + q->triggerAction(action); +} + +void QWebPagePrivate::clearUndoStack() +{ +#ifndef QT_NO_UNDOSTACK + if (undoStack) + undoStack->clear(); +#endif +} + +bool QWebPagePrivate::canUndo() const +{ +#ifndef QT_NO_UNDOSTACK + if (!undoStack) + return false; + return undoStack->canUndo(); +#else + return false; +#endif +} + +bool QWebPagePrivate::canRedo() const +{ +#ifndef QT_NO_UNDOSTACK + if (!undoStack) + return false; + return undoStack->canRedo(); +#else + return false; +#endif +} + +void QWebPagePrivate::undo() +{ +#ifndef QT_NO_UNDOSTACK + if (undoStack) + undoStack->undo(); +#endif +} + +void QWebPagePrivate::redo() +{ +#ifndef QT_NO_UNDOSTACK + if (undoStack) + undoStack->redo(); +#endif +} + +void QWebPagePrivate::createUndoStep(QSharedPointer step) +{ +#ifndef QT_NO_UNDOSTACK + // Call undoStack() getter first to ensure stack is created + // if it doesn't exist yet. + q->undoStack()->push(new QWebUndoCommand(step)); +#endif +} + +const char *QWebPagePrivate::editorCommandForKeyEvent(QKeyEvent* event) +{ + QWebPage::WebAction action = editorActionForKeyEvent(event); + return editorCommandForWebActions(action); +} + QSize QWebPage::viewportSize() const { if (d->mainFrame && d->mainFrame.data()->d->frame->view()) return d->mainFrame.data()->d->frame->view()->frameRect().size(); - return d->viewportSize; + return d->m_viewportSize; } /*! @@ -2491,7 +2850,7 @@ QSize QWebPage::viewportSize() const */ void QWebPage::setViewportSize(const QSize &size) const { - d->viewportSize = size; + d->m_viewportSize = size; QWebFrame *frame = mainFrame(); if (frame->d->frame && frame->d->frame->view()) { @@ -2577,7 +2936,7 @@ QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& av // Both environment variables need to be set - or they will be ignored. if (deviceWidth < 0 && deviceHeight < 0) { - QSize size = queryDeviceSizeForScreenContainingWidget((d->client) ? d->client->ownerWidget() : 0); + QSize size = queryDeviceSizeForScreenContainingWidget(view()); deviceWidth = size.width(); deviceHeight = size.height(); } @@ -3093,18 +3452,34 @@ bool QWebPage::event(QEvent *ev) d->mouseReleaseEvent(static_cast(ev)); break; #if !defined(QT_NO_GRAPHICSVIEW) - case QEvent::GraphicsSceneMouseMove: - d->mouseMoveEvent(static_cast(ev)); + case QEvent::GraphicsSceneMouseMove: { + QGraphicsSceneMouseEvent *gsEv = static_cast(ev); + QMouseEvent dummyEvent(QEvent::MouseMove, gsEv->pos(), gsEv->screenPos(), gsEv->button(), gsEv->buttons(), gsEv->modifiers()); + d->mouseMoveEvent(&dummyEvent); + ev->setAccepted(dummyEvent.isAccepted()); break; - case QEvent::GraphicsSceneMousePress: - d->mousePressEvent(static_cast(ev)); + } + case QEvent::GraphicsSceneMouseRelease: { + QGraphicsSceneMouseEvent *gsEv = static_cast(ev); + QMouseEvent dummyEvent(QEvent::MouseButtonRelease, gsEv->pos(), gsEv->screenPos(), gsEv->button(), gsEv->buttons(), gsEv->modifiers()); + d->mouseReleaseEvent(&dummyEvent); + ev->setAccepted(dummyEvent.isAccepted()); break; - case QEvent::GraphicsSceneMouseDoubleClick: - d->mouseDoubleClickEvent(static_cast(ev)); + } + case QEvent::GraphicsSceneMousePress: { + QGraphicsSceneMouseEvent *gsEv = static_cast(ev); + QMouseEvent dummyEvent(QEvent::MouseButtonPress, gsEv->pos(), gsEv->screenPos(), gsEv->button(), gsEv->buttons(), gsEv->modifiers()); + d->mousePressEvent(&dummyEvent); + ev->setAccepted(dummyEvent.isAccepted()); break; - case QEvent::GraphicsSceneMouseRelease: - d->mouseReleaseEvent(static_cast(ev)); + } + case QEvent::GraphicsSceneMouseDoubleClick: { + QGraphicsSceneMouseEvent *gsEv = static_cast(ev); + QMouseEvent dummyEvent(QEvent::MouseButtonDblClick, gsEv->pos(), gsEv->screenPos(), gsEv->button(), gsEv->buttons(), gsEv->modifiers()); + d->mouseDoubleClickEvent(&dummyEvent); + ev->setAccepted(dummyEvent.isAccepted()); break; + } #endif #ifndef QT_NO_CONTEXTMENU case QEvent::ContextMenu: @@ -3121,9 +3496,13 @@ bool QWebPage::event(QEvent *ev) d->wheelEvent(static_cast(ev)); break; #if !defined(QT_NO_GRAPHICSVIEW) - case QEvent::GraphicsSceneWheel: - d->wheelEvent(static_cast(ev)); + case QEvent::GraphicsSceneWheel: { + QGraphicsSceneWheelEvent *gsEv = static_cast(ev); + QWheelEvent dummyEvent(gsEv->pos(), gsEv->screenPos(), gsEv->delta(), gsEv->buttons(), gsEv->modifiers(), gsEv->orientation()); + d->wheelEvent(&dummyEvent); + ev->setAccepted(dummyEvent.isAccepted()); break; + } #endif #endif case QEvent::KeyPress: @@ -3639,8 +4018,7 @@ bool QWebPage::extension(Extension extension, const ExtensionOption *option, Ext if (extension == ChooseMultipleFilesExtension) { // FIXME: do not ignore suggestedFiles QStringList suggestedFiles = static_cast(option)->suggestedFileNames; - QWidget* parent = (d->client) ? d->client->ownerWidget() : 0; - QStringList names = QFileDialog::getOpenFileNames(parent, QString::null); + QStringList names = QFileDialog::getOpenFileNames(view(), QString::null); static_cast(output)->fileNames = names; return true; } @@ -3664,6 +4042,14 @@ bool QWebPage::supportsExtension(Extension extension) const #endif } +/*! + * \internal + */ +QWebPageAdapter *QWebPage::handle() const +{ + return d; +} + /*! Finds the specified string, \a subString, in the page, using the given \a options. @@ -3732,8 +4118,7 @@ QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& suggestedFil { Q_UNUSED(parentFrame) #ifndef QT_NO_FILEDIALOG - QWidget* parent = (d->client) ? d->client->ownerWidget() : 0; - return QFileDialog::getOpenFileName(parent, QString::null, suggestedFile); + return QFileDialog::getOpenFileName(view(), QString::null, suggestedFile); #else return QString::null; #endif @@ -3750,11 +4135,7 @@ QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& suggestedFil */ void QWebPage::setNetworkAccessManager(QNetworkAccessManager *manager) { - if (manager == d->networkManager) - return; - if (d->networkManager && d->networkManager->parent() == this) - delete d->networkManager; - d->networkManager = manager; + d->setNetworkAccessManager(manager); } /*! @@ -3765,11 +4146,7 @@ void QWebPage::setNetworkAccessManager(QNetworkAccessManager *manager) */ QNetworkAccessManager *QWebPage::networkAccessManager() const { - if (!d->networkManager) { - QWebPage *that = const_cast(this); - that->d->networkManager = new QNetworkAccessManager(that); - } - return d->networkManager; + return d->networkAccessManager(); } /*! diff --git a/Source/WebKit/qt/Api/qwebpage.h b/Source/WebKit/qt/Api/qwebpage.h index b2caa131dea..f975ab05677 100644 --- a/Source/WebKit/qt/Api/qwebpage.h +++ b/Source/WebKit/qt/Api/qwebpage.h @@ -46,6 +46,7 @@ class QWebFrameData; class QWebHistoryItem; class QWebHitTestResult; class QWebNetworkInterface; +class QWebPageAdapter; class QWebPagePrivate; class QWebPluginFactory; class QWebSecurityOrigin; @@ -365,7 +366,7 @@ class QWEBKIT_EXPORT QWebPage : public QObject { virtual bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0); virtual bool supportsExtension(Extension extension) const; - inline QWebPagePrivate* handle() const { return d; } + QWebPageAdapter* handle() const; public Q_SLOTS: bool shouldInterruptJavaScript(); diff --git a/Source/WebKit/qt/Api/qwebpage_p.h b/Source/WebKit/qt/Api/qwebpage_p.h index 79432299132..2136e3cbc15 100644 --- a/Source/WebKit/qt/Api/qwebpage_p.h +++ b/Source/WebKit/qt/Api/qwebpage_p.h @@ -21,29 +21,22 @@ #ifndef QWEBPAGE_P_H #define QWEBPAGE_P_H -#include +#include "QWebPageAdapter.h" + +#include "qwebframe.h" +#include "qwebhistory.h" +#include "qwebpage.h" +#include #include -#include #include #include #include +#include +#include -#include "qwebpage.h" -#include "qwebhistory.h" -#include "qwebframe.h" - -#include "IntPoint.h" -#include "KURL.h" - -#include -#include -#include - -#include "ViewportArguments.h" namespace WebCore { - class ChromeClientQt; class ContextMenuClientQt; class ContextMenuItem; class ContextMenu; @@ -54,7 +47,6 @@ namespace WebCore { class IntRect; class Node; class NodeList; - class Page; class Frame; } @@ -64,8 +56,10 @@ class QMenu; class QBitArray; QT_END_NAMESPACE +class QtPluginWidgetAdapter; class QWebInspector; -class QWebPageClient; +class QWebFrameAdapter; +class UndoStepQt; class QtViewportAttributesPrivate : public QSharedData { public: @@ -76,13 +70,73 @@ class QtViewportAttributesPrivate : public QSharedData { QWebPage::ViewportAttributes* q; }; -class QWebPagePrivate { +class QWebPagePrivate : public QWebPageAdapter { public: QWebPagePrivate(QWebPage*); ~QWebPagePrivate(); static WebCore::Page* core(const QWebPage*); - static QWebPagePrivate* priv(QWebPage*); + + // Adapter implementation + virtual void show() OVERRIDE; + virtual void setFocus() OVERRIDE; + virtual void unfocus() OVERRIDE; + virtual void setWindowRect(const QRect &) OVERRIDE; + virtual QSize viewportSize() const OVERRIDE; + virtual QWebPageAdapter* createWindow(bool /*dialog*/) OVERRIDE; + virtual QObject* handle() OVERRIDE { return q; } + virtual void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) OVERRIDE; + virtual void javaScriptAlert(QWebFrameAdapter*, const QString& msg) OVERRIDE; + virtual bool javaScriptConfirm(QWebFrameAdapter*, const QString& msg) OVERRIDE; + virtual bool javaScriptPrompt(QWebFrameAdapter*, const QString& msg, const QString& defaultValue, QString* result) OVERRIDE; + virtual void printRequested(QWebFrameAdapter*) OVERRIDE; + virtual void databaseQuotaExceeded(QWebFrameAdapter*, const QString& databaseName) OVERRIDE; + virtual void applicationCacheQuotaExceeded(QWebSecurityOrigin*, quint64 defaultOriginQuota, quint64 totalSpaceNeeded) OVERRIDE; + virtual void setToolTip(const QString&) OVERRIDE; +#if USE(QT_MULTIMEDIA) + virtual QWebFullScreenVideoHandler* createFullScreenVideoHandler() OVERRIDE; +#endif + virtual QWebFrameAdapter* mainFrameAdapter() OVERRIDE; + virtual QStringList chooseFiles(QWebFrameAdapter*, bool allowMultiple, const QStringList& suggestedFileNames) OVERRIDE; + virtual QColor colorSelectionRequested(const QColor& selectedColor) OVERRIDE; + virtual QWebSelectMethod* createSelectPopup() OVERRIDE; + virtual QRect viewRectRelativeToWindow() OVERRIDE; + virtual void geolocationPermissionRequested(QWebFrameAdapter*) OVERRIDE; + virtual void geolocationPermissionRequestCancelled(QWebFrameAdapter*) OVERRIDE; + virtual void notificationsPermissionRequested(QWebFrameAdapter*) OVERRIDE; + virtual void notificationsPermissionRequestCancelled(QWebFrameAdapter*) OVERRIDE; + + virtual void respondToChangedContents() OVERRIDE; + virtual void respondToChangedSelection() OVERRIDE; + virtual void microFocusChanged() OVERRIDE; + virtual void triggerCopyAction() OVERRIDE; + virtual void triggerActionForKeyEvent(QKeyEvent*) OVERRIDE; + virtual void clearUndoStack() OVERRIDE; + virtual bool canUndo() const OVERRIDE; + virtual bool canRedo() const OVERRIDE; + virtual void undo() OVERRIDE; + virtual void redo() OVERRIDE; + virtual void createUndoStep(QSharedPointer) OVERRIDE; + virtual const char* editorCommandForKeyEvent(QKeyEvent*) OVERRIDE; + + void updateNavigationActions() OVERRIDE; + + virtual QObject* inspectorHandle() OVERRIDE; + virtual void setInspectorFrontend(QObject*) OVERRIDE; + virtual void setInspectorWindowTitle(const QString&) OVERRIDE; + virtual void createWebInspector(QObject** inspectorView, QWebPageAdapter** inspectorPage) OVERRIDE; + virtual QStringList menuActionsAsText() OVERRIDE; + virtual void emitViewportChangeRequested() OVERRIDE; + virtual bool acceptNavigationRequest(QWebFrameAdapter*, const QNetworkRequest&, int type) OVERRIDE; + virtual void emitRestoreFrameStateRequested(QWebFrameAdapter*) OVERRIDE; + virtual void emitSaveFrameStateRequested(QWebFrameAdapter*, QWebHistoryItem*) OVERRIDE; + virtual void emitDownloadRequested(const QNetworkRequest&) OVERRIDE; + virtual void emitFrameCreated(QWebFrameAdapter*) OVERRIDE; + virtual QString userAgentForUrl(const QUrl &url) const OVERRIDE { return q->userAgentForUrl(url); } + virtual bool supportsErrorPageExtension() const OVERRIDE { return q->supportsExtension(QWebPage::ErrorPageExtension); } + virtual bool errorPageExtension(ErrorPageOption *, ErrorPageReturn *) OVERRIDE; + virtual QtPluginWidgetAdapter* createPlugin(const QString &, const QUrl &, const QStringList &, const QStringList &) OVERRIDE; + virtual QtPluginWidgetAdapter* adapterForWidget(QObject *) const OVERRIDE; void createMainFrame(); #ifndef QT_NO_CONTEXTMENU @@ -92,23 +146,20 @@ class QWebPagePrivate { void _q_webActionTriggered(bool checked); void _q_cleanupLeakMessages(); void updateAction(QWebPage::WebAction action); - void updateNavigationActions(); void updateEditorActions(); - QColor colorSelectionRequested(const QColor& selectedColor); - void timerEvent(QTimerEvent*); - template void mouseMoveEvent(T*); - template void mousePressEvent(T*); - template void mouseDoubleClickEvent(T*); - template void mouseTripleClickEvent(T*); - template void mouseReleaseEvent(T*); + void mouseMoveEvent(QMouseEvent*); + void mousePressEvent(QMouseEvent*); + void mouseDoubleClickEvent(QMouseEvent*); + void mouseTripleClickEvent(QMouseEvent*); + void mouseReleaseEvent(QMouseEvent*); #ifndef QT_NO_CONTEXTMENU void contextMenuEvent(const QPoint& globalPos); #endif #ifndef QT_NO_WHEELEVENT - template void wheelEvent(T*); + void wheelEvent(QWheelEvent*); #endif void keyPressEvent(QKeyEvent*); void keyReleaseEvent(QKeyEvent*); @@ -159,16 +210,12 @@ class QWebPagePrivate { WebCore::InspectorController* inspectorController(); quint16 inspectorServerPort(); - WebCore::ViewportArguments viewportArguments(); - #ifndef QT_NO_SHORTCUT static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event); #endif static const char* editorCommandForWebActions(QWebPage::WebAction action); QWebPage *q; - WebCore::Page *page; - OwnPtr client; QPointer mainFrame; #ifndef QT_NO_UNDOSTACK @@ -177,7 +224,6 @@ class QWebPagePrivate { QPointer view; - bool insideOpenCall; quint64 m_totalBytes; quint64 m_bytesReceived; @@ -186,15 +232,9 @@ class QWebPagePrivate { bool clickCausedFocus; - bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type); - QNetworkAccessManager *networkManager; - - bool forwardUnsupportedContent; - bool smartInsertDeleteEnabled; - bool selectTrailingWhitespaceEnabled; QWebPage::LinkDelegationPolicy linkPolicy; - QSize viewportSize; + QSize m_viewportSize; QSize fixedLayoutSize; QWebHistory history; @@ -202,20 +242,15 @@ class QWebPagePrivate { #ifndef QT_NO_CONTEXTMENU QPointer currentContextMenu; #endif - QWebSettings *settings; QPalette palette; bool useFixedLayout; QAction *actions[QWebPage::WebActionCount]; - QWebPluginFactory *pluginFactory; - QWidget* inspectorFrontend; QWebInspector* inspector; bool inspectorIsInternalOnly; // True if created through the Inspect context menu action Qt::DropAction m_lastDropAction; - - static bool drtRun; }; #endif diff --git a/Source/WebKit/qt/Api/qwebsettings.cpp b/Source/WebKit/qt/Api/qwebsettings.cpp index 768c80256ec..74d8524d8c5 100644 --- a/Source/WebKit/qt/Api/qwebsettings.cpp +++ b/Source/WebKit/qt/Api/qwebsettings.cpp @@ -20,41 +20,39 @@ #include "config.h" #include "qwebsettings.h" -#include "qwebpage.h" -#include "qwebpage_p.h" #include "qwebplugindatabase_p.h" #include "AbstractDatabase.h" -#include "MemoryCache.h" +#include "ApplicationCacheStorage.h" #include "CrossOriginPreflightResultCache.h" +#include "DatabaseTracker.h" +#include "FileSystem.h" #include "FontCache.h" +#include "IconDatabase.h" +#include "Image.h" #if ENABLE(ICONDATABASE) #include "IconDatabaseClientQt.h" #endif #include "InitWebCoreQt.h" +#include "IntSize.h" +#include "KURL.h" +#include "MemoryCache.h" +#include "NetworkStateNotifier.h" #include "Page.h" #include "PageCache.h" -#include "Settings.h" -#include "KURL.h" -#include "IconDatabase.h" #include "PluginDatabase.h" -#include "Image.h" -#include "IntSize.h" -#include "ApplicationCacheStorage.h" -#include "DatabaseTracker.h" -#include "FileSystem.h" -#include - -#include -#include +#include "Settings.h" #include +#include +#include +#include #include #include +#include #include -#include -#include +#include + -#include "NetworkStateNotifier.h" void QWEBKIT_EXPORT qt_networkAccessAllowed(bool isAllowed) { diff --git a/Source/WebKit/qt/Api/qwebsettings.h b/Source/WebKit/qt/Api/qwebsettings.h index 5e7d3e1b4d3..49721b7cb93 100644 --- a/Source/WebKit/qt/Api/qwebsettings.h +++ b/Source/WebKit/qt/Api/qwebsettings.h @@ -163,6 +163,7 @@ class QWEBKIT_EXPORT QWebSettings { inline QWebSettingsPrivate* handle() const { return d; } private: + friend class QWebPageAdapter; friend class QWebPagePrivate; friend class QWebSettingsPrivate; diff --git a/Source/WebKit/qt/Api/qwebview.cpp b/Source/WebKit/qt/Api/qwebview.cpp index 9f2af5787ee..2eda6a18efd 100644 --- a/Source/WebKit/qt/Api/qwebview.cpp +++ b/Source/WebKit/qt/Api/qwebview.cpp @@ -227,9 +227,9 @@ void QWebViewPrivate::detachCurrentPage() // to destroy it. if (page->d->client && page->d->client->isQWidgetClient()) - page->d->client.clear(); + page->d->client.reset(); - page->d->client.release(); + page->d->client.take(); // if the page was created by us, we own it and need to // destroy it as well. diff --git a/Source/WebKit/qt/ChangeLog b/Source/WebKit/qt/ChangeLog index f0791bfc02f..bbc4c42b9b5 100644 --- a/Source/WebKit/qt/ChangeLog +++ b/Source/WebKit/qt/ChangeLog @@ -1,3 +1,538 @@ +2012-11-22 Simon Hausmann , Pierre Rossi + + [Qt] Separate QWidget dependant code into separate WebKitWidgets static library + https://bugs.webkit.org/show_bug.cgi?id=102800 + + Reviewed by Tor Arne Vestbø. + + This patch separates code that needs to use QWidget related APIs in + WebKit/qt/WebCoreSupport and Api from code that doesn't. This means for + example FrameLoaderClientQt.cpp remains in the WebKit1 static library, + while qwebpage.cpp and qwebframe.cpp become part of the WebKitWidgets + static library. WebKit1 is compiled without QT += widgets and therefore + any widget related dependency has been moved "up" and out of WebKit1 into + the WebKitWidgets library. + + Between the code in WebKit.a and WebKitWidgets.a new adapters and + interfaces have been introduced, such as QWebPageAdapter and + QWebFrameAdapter. QWebPageAdapter, when used from WebKit1, is a way to + call out into the API layer, implemented by QWebPage (QWebPagePrivate). + The other way around if QWebPage wants to access WebCore or + WebCoreSupport related functionality, it will go through + QWebPageAdapater (as base class). The separation in the direction up + into the API layer is complete with this patch, no code in WebKit1 + depends on QtWidgets. The separation the other way around, code in the + API layer not using any WebCore types, is not complete yet. + + Some classes such as QWebSettings, QWebElement or + DumpRenderTreeSupportQt remain in WebKit1. While they are API layer, + they do not depend on widget related Qt APIs and they make much more + use of WebCore internal APIs and therefore are easier to keep in + WebKit1. + + In the future we plan to place a real shared library boundary between + WebKit1 and WebKitWidgets, by keeping the WebKit1 static library as + part of the QtWebKit shared library and by turning the WebKitWidgets + static library into a shared one. + + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::pageClient): + (QGraphicsWebViewPrivate::detachCurrentPage): + (QGraphicsWebView::setPage): + * Api/qwebelement.cpp: + (QWebElement::webFrame): + * Api/qwebframe.cpp: + (QWebFramePrivate::setPage): + (QWebFramePrivate::didStartProvisionalLoad): + (QWebFramePrivate::handleProgressFinished): + (QWebFramePrivate::emitInitialLayoutCompleted): + (QWebFramePrivate::emitIconChanged): + (QWebFramePrivate::emitLoadStarted): + (QWebFramePrivate::emitLoadFinished): + (QWebFramePrivate::createChildFrame): + (QWebFramePrivate::apiHandle): + (QWebFramePrivate::handle): + (QWebFramePrivate::contentsSizeDidChange): + (QWebFramePrivate::scrollBarPolicy): + (QWebFrame::QWebFrame): + (QWebFrame::~QWebFrame): + (QWebFrame::setUrl): + (QWebFrame::load): + (QWebFrame::scrollPosition): + (QWebFrame::geometry): + (QWebFramePrivate::kit): + (QWebFrame::handle): + * Api/qwebframe.h: + * Api/qwebframe_p.h: + (QWebFramePrivate::QWebFramePrivate): + (QWebFramePrivate): + * Api/qwebhistory.cpp: + (QWebHistoryPrivate::page): + * Api/qwebhistory_p.h: + (QWebHistoryPrivate): + * Api/qwebinspector.cpp: + (QWebInspectorPrivate::setFrontend): + * Api/qwebinspector_p.h: + (QWebInspectorPrivate): + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): + (QWebPagePrivate::~QWebPagePrivate): + (QWebPagePrivate::core): + (QWebPagePrivate::show): + (QWebPagePrivate::setFocus): + (QWebPagePrivate::unfocus): + (QWebPagePrivate::setWindowRect): + (QWebPagePrivate::viewportSize): + (QWebPagePrivate::createWindow): + (QWebPagePrivate::javaScriptConsoleMessage): + (QWebPagePrivate::javaScriptAlert): + (QWebPagePrivate::javaScriptConfirm): + (QWebPagePrivate::javaScriptPrompt): + (QWebPagePrivate::printRequested): + (QWebPagePrivate::databaseQuotaExceeded): + (QWebPagePrivate::applicationCacheQuotaExceeded): + (QWebPagePrivate::setToolTip): + (QWebPagePrivate::createFullScreenVideoHandler): + (QWebPagePrivate::mainFrameAdapter): + (QWebPagePrivate::chooseFiles): + (QWebPagePrivate::acceptNavigationRequest): + (QWebPagePrivate::emitRestoreFrameStateRequested): + (QWebPagePrivate::emitSaveFrameStateRequested): + (QWebPagePrivate::emitDownloadRequested): + (QWebPagePrivate::emitFrameCreated): + (QWebPagePrivate::errorPageExtension): + (QWebPagePrivate::createPlugin): + (QWebPagePrivate::adapterForWidget): + (QWebPagePrivate::createMainFrame): + (QWebPagePrivate::createContextMenu): + (QWebPagePrivate::inspectorHandle): + (QWebPagePrivate::setInspectorFrontend): + (QWebPagePrivate::setInspectorWindowTitle): + (QWebPagePrivate::createWebInspector): + (iterateContextMenu): + (QWebPagePrivate::menuActionsAsText): + (QWebPagePrivate::emitViewportChangeRequested): + (QWebPagePrivate::mouseMoveEvent): + (QWebPagePrivate::mousePressEvent): + (QWebPagePrivate::mouseDoubleClickEvent): + (QWebPagePrivate::mouseTripleClickEvent): + (QWebPagePrivate::mouseReleaseEvent): + (QWebPagePrivate::handleSoftwareInputPanel): + (QWebPagePrivate::wheelEvent): + (QWebPagePrivate::gestureEvent): + (QWebPage::setView): + (QWebPage::javaScriptConsoleMessage): + (QWebPage::javaScriptAlert): + (QWebPage::javaScriptConfirm): + (QWebPage::javaScriptPrompt): + (QWebPage::shouldInterruptJavaScript): + (QWebPage::setFeaturePermission): + (QWebPagePrivate::colorSelectionRequested): + (QWebPagePrivate::createSelectPopup): + (QWebPagePrivate::viewRectRelativeToWindow): + (QWebPagePrivate::geolocationPermissionRequested): + (QWebPagePrivate::geolocationPermissionRequestCancelled): + (QWebPagePrivate::notificationsPermissionRequested): + (QWebPagePrivate::notificationsPermissionRequestCancelled): + (QWebPagePrivate::respondToChangedContents): + (QWebPagePrivate::respondToChangedSelection): + (QWebPagePrivate::microFocusChanged): + (QWebPagePrivate::triggerCopyAction): + (QWebPagePrivate::triggerActionForKeyEvent): + (QWebPagePrivate::clearUndoStack): + (QWebPagePrivate::canUndo): + (QWebPagePrivate::canRedo): + (QWebPagePrivate::undo): + (QWebPagePrivate::redo): + (QWebPagePrivate::createUndoStep): + (QWebPagePrivate::editorCommandForKeyEvent): + (QWebPage::viewportSize): + (QWebPage::setViewportSize): + (QWebPage::viewportAttributesForSize): + (QWebPage::event): + (QWebPage::extension): + (QWebPage::handle): + (QWebPage::chooseFile): + (QWebPage::setNetworkAccessManager): + (QWebPage::networkAccessManager): + * Api/qwebpage.h: + * Api/qwebpage_p.h: + (WebCore): + (QWebPagePrivate): + * Api/qwebsettings.cpp: + * Api/qwebsettings.h: + * Api/qwebview.cpp: + (QWebViewPrivate::detachCurrentPage): + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::ChromeClientQt): + (WebCore::ChromeClientQt::setWindowRect): + (WebCore::ChromeClientQt::focus): + (WebCore::ChromeClientQt::unfocus): + (WebCore::ChromeClientQt::createWindow): + (WebCore::ChromeClientQt::show): + (WebCore::ChromeClientQt::setToolbarsVisible): + (WebCore::ChromeClientQt::setStatusbarVisible): + (WebCore::ChromeClientQt::setMenubarVisible): + (WebCore::ChromeClientQt::addMessageToConsole): + (WebCore::ChromeClientQt::closeWindowSoon): + (WebCore::ChromeClientQt::runJavaScriptAlert): + (WebCore::ChromeClientQt::runJavaScriptConfirm): + (WebCore::ChromeClientQt::runJavaScriptPrompt): + (WebCore::ChromeClientQt::setStatusbarText): + (WebCore::ChromeClientQt::shouldInterruptJavaScript): + (WebCore::ChromeClientQt::keyboardUIMode): + (WebCore::ChromeClientQt::windowResizerRect): + * WebCoreSupport/ChromeClientQt.h: + (ChromeClientQt): + * WebCoreSupport/ContextMenuClientQt.cpp: + * WebCoreSupport/ContextMenuClientQt.h: + (ContextMenuClientQt): + * WebCoreSupport/DefaultFullScreenVideoHandler.cpp: Added. + (DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler): + (DefaultFullScreenVideoHandler::~DefaultFullScreenVideoHandler): + (DefaultFullScreenVideoHandler::requiresFullScreenForVideoPlayback): + (DefaultFullScreenVideoHandler::enterFullScreen): + (DefaultFullScreenVideoHandler::exitFullScreen): + * WebCoreSupport/DefaultFullScreenVideoHandler.h: Copied from Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h. + (WebKit): + (DefaultFullScreenVideoHandler): + * WebCoreSupport/DragClientQt.cpp: + (WebCore::DragClientQt::startDrag): + * WebCoreSupport/DragClientQt.h: + (WebCore): + (WebCore::DragClientQt::DragClientQt): + (DragClientQt): + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (toGeolocationClientMock): + (toDeviceOrientationClientMock): + (DumpRenderTreeSupportQt::initialize): + (DumpRenderTreeSupportQt::setDumpRenderTreeModeEnabled): + (DumpRenderTreeSupportQt::setFrameFlatteningEnabled): + (DumpRenderTreeSupportQt::webPageSetGroupName): + (DumpRenderTreeSupportQt::webPageGroupName): + (DumpRenderTreeSupportQt::webInspectorExecuteScript): + (DumpRenderTreeSupportQt::webInspectorShow): + (DumpRenderTreeSupportQt::webInspectorClose): + (DumpRenderTreeSupportQt::hasDocumentElement): + (DumpRenderTreeSupportQt::pauseAnimation): + (DumpRenderTreeSupportQt::pauseTransitionOfProperty): + (DumpRenderTreeSupportQt::numberOfActiveAnimations): + (DumpRenderTreeSupportQt::clearFrameName): + (DumpRenderTreeSupportQt::setCaretBrowsingEnabled): + (DumpRenderTreeSupportQt::setAuthorAndUserStylesEnabled): + (DumpRenderTreeSupportQt::setSmartInsertDeleteEnabled): + (DumpRenderTreeSupportQt::setSelectTrailingWhitespaceEnabled): + (DumpRenderTreeSupportQt::executeCoreCommandByName): + (DumpRenderTreeSupportQt::isCommandEnabled): + (DumpRenderTreeSupportQt::findString): + (DumpRenderTreeSupportQt::selectedRange): + (DumpRenderTreeSupportQt::firstRectForCharacterRange): + (DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId): + (DumpRenderTreeSupportQt::setWindowsBehaviorAsEditingBehavior): + (DumpRenderTreeSupportQt::viewportAsText): + (DumpRenderTreeSupportQt::scalePageBy): + (DumpRenderTreeSupportQt::setMockDeviceOrientation): + (DumpRenderTreeSupportQt::resetGeolocationMock): + (DumpRenderTreeSupportQt::setMockGeolocationPermission): + (DumpRenderTreeSupportQt::setMockGeolocationPosition): + (DumpRenderTreeSupportQt::setMockGeolocationPositionUnavailableError): + (DumpRenderTreeSupportQt::numberOfPendingGeolocationPermissionRequests): + (DumpRenderTreeSupportQt::shouldClose): + (DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld): + (DumpRenderTreeSupportQt::addUserStyleSheet): + (DumpRenderTreeSupportQt::removeUserStyleSheets): + (DumpRenderTreeSupportQt::setDefersLoading): + (DumpRenderTreeSupportQt::goBack): + (DumpRenderTreeSupportQt::responseMimeType): + (DumpRenderTreeSupportQt::clearOpener): + (DumpRenderTreeSupportQt::setInteractiveFormValidationEnabled): + (DumpRenderTreeSupportQt::contextMenu): + (DumpRenderTreeSupportQt::setMinimumTimerInterval): + (DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows): + (DumpRenderTreeSupportQt::mediaContentUrlByElementId): + (DumpRenderTreeSupportQt::setAlternateHtml): + (DumpRenderTreeSupportQt::confirmComposition): + (DumpRenderTreeSupportQt::injectInternalsObject): + (DumpRenderTreeSupportQt::resetInternalsObject): + (DumpRenderTreeSupportQt::paintPagesWithBoundaries): + (DumpRenderTreeSupportQt::setTrackRepaintRects): + (DumpRenderTreeSupportQt::trackRepaintRects): + (DumpRenderTreeSupportQt::getTrackedRepaintRects): + * WebCoreSupport/DumpRenderTreeSupportQt.h: + * WebCoreSupport/EditorClientQt.cpp: + (dumpRange): + (WebCore::EditorClientQt::shouldShowDeleteInterface): + (WebCore::EditorClientQt::shouldInsertText): + (WebCore::EditorClientQt::shouldChangeSelectedRange): + (WebCore::EditorClientQt::shouldApplyStyle): + (WebCore::EditorClientQt::respondToChangedContents): + (WebCore::EditorClientQt::respondToChangedSelection): + (WebCore::EditorClientQt::registerUndoStep): + (WebCore::EditorClientQt::clearUndoRedoOperations): + (WebCore::EditorClientQt::canUndo): + (WebCore::EditorClientQt::canRedo): + (WebCore::EditorClientQt::undo): + (WebCore::EditorClientQt::redo): + (WebCore::EditorClientQt::shouldInsertNode): + (WebCore::EditorClientQt::smartInsertDeleteEnabled): + (WebCore::EditorClientQt::toggleSmartInsertDelete): + (WebCore::EditorClientQt::isSelectTrailingWhitespaceEnabled): + (WebCore::EditorClientQt::handleKeyboardEvent): + (WebCore::EditorClientQt::EditorClientQt): + (WebCore::EditorClientQt::setInputMethodState): + * WebCoreSupport/EditorClientQt.h: + (EditorClientQt): + (WebCore::EditorClientQt::setSmartInsertDeleteEnabled): + (WebCore::EditorClientQt::setSelectTrailingWhitespaceEnabled): + * WebCoreSupport/FrameLoaderClientQt.cpp: + (drtDescriptionSuitableForTestResult): + (WebCore::FrameLoaderClientQt::setFrame): + (WebCore::FrameLoaderClientQt::transitionToCommittedForNewPage): + (WebCore::FrameLoaderClientQt::dispatchDidChangeLocationWithinPage): + (WebCore::FrameLoaderClientQt::dispatchDidStartProvisionalLoad): + (WebCore::FrameLoaderClientQt::dispatchDidCommitLoad): + (WebCore::FrameLoaderClientQt::dispatchDidFinishDocumentLoad): + (WebCore::FrameLoaderClientQt::dispatchDidFinishLoad): + (WebCore::FrameLoaderClientQt::dispatchDidLayout): + (WebCore::FrameLoaderClientQt::dispatchWillSubmitForm): + (WebCore::FrameLoaderClientQt::postProgressStartedNotification): + (WebCore::FrameLoaderClientQt::postProgressFinishedNotification): + (WebCore::FrameLoaderClientQt::frameLoadCompleted): + (WebCore::FrameLoaderClientQt::restoreViewState): + (WebCore::FrameLoaderClientQt::userAgent): + (WebCore::FrameLoaderClientQt::dispatchDidReceiveIcon): + (WebCore::FrameLoaderClientQt::frameLoaderDestroyed): + (WebCore::FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld): + (WebCore::FrameLoaderClientQt::didPerformFirstNavigation): + (WebCore::FrameLoaderClientQt::onIconLoadedForPageURL): + (WebCore::FrameLoaderClientQt::updateGlobalHistoryRedirectLinks): + (WebCore::FrameLoaderClientQt::saveViewStateToItem): + (WebCore::FrameLoaderClientQt::cancelledError): + (WebCore::FrameLoaderClientQt::blockedError): + (WebCore::FrameLoaderClientQt::cannotShowURLError): + (WebCore::FrameLoaderClientQt::interruptedForPolicyChangeError): + (WebCore::FrameLoaderClientQt::cannotShowMIMETypeError): + (WebCore::FrameLoaderClientQt::fileDoesNotExistError): + (WebCore::FrameLoaderClientQt::pluginWillHandleLoadError): + (WebCore::FrameLoaderClientQt::download): + (WebCore::FrameLoaderClientQt::dispatchWillSendRequest): + (WebCore::FrameLoaderClientQt::dispatchDidReceiveResponse): + (WebCore::FrameLoaderClientQt::dispatchDidFinishLoading): + (WebCore::FrameLoaderClientQt::dispatchDidFailLoading): + (WebCore::FrameLoaderClientQt::callErrorPageExtension): + (WebCore::FrameLoaderClientQt::dispatchCreatePage): + (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction): + (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction): + (WebCore::FrameLoaderClientQt::startDownload): + (WebCore::FrameLoaderClientQt::createFrame): + (WebCore::FrameLoaderClientQt::createPlugin): + (WebCore::FrameLoaderClientQt::createJavaAppletWidget): + (WebCore::FrameLoaderClientQt::chooseFile): + (WebCore::FrameLoaderClientQt::createNetworkingContext): + (WebCore): + (WebCore::FrameLoaderClientQt::webFrame): + (WebCore::FrameLoaderClientQt::emitLoadStarted): + (WebCore::FrameLoaderClientQt::emitLoadFinished): + * WebCoreSupport/FrameLoaderClientQt.h: + (FrameLoaderClientQt): + * WebCoreSupport/FrameNetworkingContextQt.cpp: + (WebCore::FrameNetworkingContextQt::FrameNetworkingContextQt): + (WebCore::FrameNetworkingContextQt::create): + (WebCore::FrameNetworkingContextQt::networkAccessManager): + * WebCoreSupport/FrameNetworkingContextQt.h: + (FrameNetworkingContextQt): + * WebCoreSupport/FullScreenVideoQt.cpp: + (WebCore): + (WebCore::FullScreenVideoQt::FullScreenVideoQt): + * WebCoreSupport/FullScreenVideoQt.h: + (WebCore): + * WebCoreSupport/FullScreenVideoWidget.cpp: + * WebCoreSupport/FullScreenVideoWidget.h: + * WebCoreSupport/GeolocationClientQt.cpp: + (WebCore::GeolocationClientQt::GeolocationClientQt): + (WebCore::GeolocationClientQt::positionUpdated): + (WebCore::GeolocationClientQt::startUpdating): + (WebCore::GeolocationClientQt::requestPermission): + (WebCore::GeolocationClientQt::cancelPermissionRequest): + * WebCoreSupport/GeolocationClientQt.h: + (GeolocationClientQt): + * WebCoreSupport/GeolocationPermissionClientQt.cpp: + (WebCore::GeolocationPermissionClientQt::requestGeolocationPermissionForFrame): + (WebCore::GeolocationPermissionClientQt::cancelGeolocationPermissionRequestForFrame): + (WebCore::GeolocationPermissionClientQt::setPermission): + * WebCoreSupport/GeolocationPermissionClientQt.h: + (GeolocationPermissionClientQt): + * WebCoreSupport/InitWebCoreQt.cpp: + (WebKit): + (WebKit::setWebKitWidgetsInitCallback): + (WebKit::initializeWebKitQt): + (WebKit::setImagePlatformResource): + (WebCore::initializeWebCoreQt): + * WebCoreSupport/InitWebCoreQt.h: + (WebCore): + (WebKit): + * WebCoreSupport/InitWebKitQt.cpp: Added. + (WebKit): + (WebKit::initializeWebKitWidgets): + * WebCoreSupport/InitWebKitQt.h: Copied from Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h. + (WebKit): + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore): + (WebCore::InspectorClientQt::InspectorClientQt): + (WebCore::InspectorClientQt::openInspectorFrontend): + (WebCore::InspectorClientQt::attachAndReplaceRemoteFrontend): + (WebCore::InspectorClientQt::detachRemoteFrontend): + (WebCore::InspectorClientQt::hideHighlight): + (WebCore::InspectorClientQt::sendMessageToFrontend): + (WebCore::InspectorFrontendClientQt::InspectorFrontendClientQt): + (WebCore::InspectorFrontendClientQt::updateWindowTitle): + (WebCore::InspectorFrontendClientQt::destroyInspectorView): + * WebCoreSupport/InspectorClientQt.h: + (InspectorClientQt): + (InspectorFrontendClientQt): + * WebCoreSupport/InspectorClientWebPage.cpp: Added. + (InspectorClientWebPage::InspectorClientWebPage): + (InspectorClientWebPage::createWindow): + (InspectorClientWebPage::javaScriptWindowObjectCleared): + * WebCoreSupport/InspectorClientWebPage.h: Copied from Source/WebKit/qt/WebCoreSupport/WebSystemInterface.h. + (WebKit): + (InspectorClientWebPage): + * WebCoreSupport/InspectorServerQt.cpp: + (WebCore::InspectorServerRequestHandlerQt::tcpReadyRead): + (WebCore::InspectorServerRequestHandlerQt::webSocketReadyRead): + * WebCoreSupport/InspectorServerQt.h: + (InspectorServerQt): + (InspectorServerRequestHandlerQt): + * WebCoreSupport/NotificationPresenterClientQt.cpp: + (WebCore::NotificationWrapper::NotificationWrapper): + (WebCore::NotificationPresenterClientQt::displayNotification): + (WebCore::NotificationPresenterClientQt::requestPermission): + (WebCore::NotificationPresenterClientQt::cancelRequestsForPermission): + (WebCore::NotificationPresenterClientQt::dumpShowText): + (WebCore::NotificationPresenterClientQt::toPage): + (WebCore::NotificationPresenterClientQt::toFrame): + * WebCoreSupport/NotificationPresenterClientQt.h: + (WebCore::NotificationWrapper::~NotificationWrapper): + (NotificationWrapper): + (NotificationPresenterClientQt): + (WebCore::NotificationPresenterClientQt::hasSystemTrayIcon): + (WebCore::NotificationPresenterClientQt::setSystemTrayIcon): + (CallbacksInfo): + (WebCore): + * WebCoreSupport/PageClientQt.cpp: + (createPlatformGraphicsContext3DFromWidget): + (QWebPageClient::ownerWindow): + (WebCore::PageClientQWidget::ownerWidget): + (WebCore::PageClientQWidget::createPlatformGraphicsContext3D): + (WebCore::PageClientQGraphicsWidget::ownerWidget): + (WebCore::PageClientQGraphicsWidget::createPlatformGraphicsContext3D): + * WebCoreSupport/PageClientQt.h: + (PageClientQWidget): + (WebCore::QGraphicsItemOverlay::QGraphicsItemOverlay): + (WebCore::PageClientQGraphicsWidget::PageClientQGraphicsWidget): + (PageClientQGraphicsWidget): + * WebCoreSupport/PlatformStrategiesQt.cpp: + (PlatformStrategiesQt::getPluginInfo): + * WebCoreSupport/PopupMenuQt.cpp: + (SelectData::SelectData): + * WebCoreSupport/QGraphicsWidgetPluginImpl.cpp: Added. + (QGraphicsWidgetPluginImpl::~QGraphicsWidgetPluginImpl): + (QGraphicsWidgetPluginImpl::update): + (QGraphicsWidgetPluginImpl::setGeometryAndClip): + (QGraphicsWidgetPluginImpl::setVisible): + (QGraphicsWidgetPluginImpl::setWidgetParent): + (QGraphicsWidgetPluginImpl::handle): + * WebCoreSupport/QGraphicsWidgetPluginImpl.h: Added. + (QGraphicsWidgetPluginImpl): + (QGraphicsWidgetPluginImpl::QGraphicsWidgetPluginImpl): + * WebCoreSupport/QWebFrameAdapter.cpp: Added. + (cacheLoadControlToCachePolicy): + (QWebFrameData::QWebFrameData): + (QWebFrameAdapter::QWebFrameAdapter): + (QWebFrameAdapter::~QWebFrameAdapter): + (QWebFrameAdapter::load): + (QWebFrameAdapter::handleGestureEvent): + (QWebFrameAdapter::scrollPosition): + (QWebFrameAdapter::frameRect): + (QWebFrameAdapter::init): + (QWebFrameAdapter::kit): + (QWebFrameAdapter::ensureAbsoluteUrl): + * WebCoreSupport/QWebFrameAdapter.h: Added. + (WebCore): + (QWebFrameData): + (QWebFrameAdapter): + (QWebFrameAdapter::hasView): + * WebCoreSupport/QWebPageAdapter.cpp: Added. + (QWebPageAdapter::QWebPageAdapter): + (QWebPageAdapter::~QWebPageAdapter): + (QWebPageAdapter::init): + (QWebPageAdapter::deletePage): + (QWebPageAdapter::kit): + (QWebPageAdapter::viewportArguments): + (QWebPageAdapter::registerUndoStep): + (QWebPageAdapter::setNetworkAccessManager): + (QWebPageAdapter::networkAccessManager): + * WebCoreSupport/QWebPageAdapter.h: Added. + (WebCore): + (QWebPageAdapter): + (ErrorPageOption): + (ErrorPageReturn): + * WebCoreSupport/QWebUndoCommand.cpp: Copied from Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h. + (QWebUndoCommand::QWebUndoCommand): + (QWebUndoCommand::undo): + (QWebUndoCommand::redo): + * WebCoreSupport/QWebUndoCommand.h: Copied from Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h. + (QWebUndoCommand): + * WebCoreSupport/QWidgetPluginImpl.cpp: Added. + (QWidgetPluginImpl::~QWidgetPluginImpl): + (QWidgetPluginImpl::update): + (QWidgetPluginImpl::setGeometryAndClip): + (QWidgetPluginImpl::setVisible): + (QWidgetPluginImpl::setStyleSheet): + (QWidgetPluginImpl::setWidgetParent): + (QWidgetPluginImpl::handle): + * WebCoreSupport/QWidgetPluginImpl.h: Copied from Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h. + (QWidgetPluginImpl): + (QWidgetPluginImpl::QWidgetPluginImpl): + * WebCoreSupport/QtFallbackWebPopup.cpp: + (WebCore::QtFallbackWebPopup::QtFallbackWebPopup): + (WebCore::QtFallbackWebPopup::show): + (WebCore::QtFallbackWebPopup::pageClient): + * WebCoreSupport/QtFallbackWebPopup.h: + (QtFallbackWebPopup): + * WebCoreSupport/QtPluginWidgetAdapter.h: Copied from Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h. + (QtPluginWidgetAdapter): + * WebCoreSupport/QtWebComboBox.cpp: + (WebCore::QtWebComboBox::showPopupAtCursorPosition): + * WebCoreSupport/QtWebComboBox.h: + * WebCoreSupport/SearchPopupMenuQt.h: + (SearchPopupMenuQt): + * WebCoreSupport/UndoStepQt.cpp: + (UndoStepQt::UndoStepQt): + (UndoStepQt::text): + * WebCoreSupport/UndoStepQt.h: + (UndoStepQt): + * WebCoreSupport/WebEventConversion.cpp: + (WebCore::mouseEventTypeAndMouseButtonFromQEvent): + (WebKitPlatformWheelEvent): + (WebCore::WebKitPlatformWheelEvent::applyDelta): + (WebCore::WebKitPlatformWheelEvent::WebKitPlatformWheelEvent): + (WebKitPlatformGestureEvent): + (WebCore::toPlatformEventType): + (WebCore::WebKitPlatformGestureEvent::WebKitPlatformGestureEvent): + (WebCore): + (WebCore::convertWheelEvent): + (WebCore::convertGesture): + * WebCoreSupport/WebEventConversion.h: + (QGestureEventFacade): + (WebCore): + * WebCoreSupport/WebSystemInterface.h: + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::loadHtml5Video): + (tst_QWebPage::multiplePageGroupsAndLocalStorage): + (tst_QWebPage::thirdPartyCookiePolicy): + 2012-11-21 Allan Sandfeld Jensen Position in QWebHitTestResult does not match documentation diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp index eaaeb012f86..e3635c04f93 100644 --- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp @@ -53,27 +53,25 @@ #include "NetworkingContext.h" #include "NotImplemented.h" #include "Page.h" -#include "PageClientQt.h" #include "PopupMenuQt.h" -#include "QtFallbackWebPopup.h" +#include "QWebFrameAdapter.h" +#include "QWebPageAdapter.h" #include "QWebPageClient.h" #include "ScrollbarTheme.h" #include "SearchPopupMenuQt.h" #include "SecurityOrigin.h" +#include "TiledBackingStore.h" #include "ViewportArguments.h" #include "WindowFeatures.h" - -#include "qgraphicswebview.h" -#include "qwebframe_p.h" -#include "qwebpage.h" -#include "qwebpage_p.h" +#include "qwebkitplatformplugin.h" #include "qwebsecurityorigin.h" #include "qwebsecurityorigin_p.h" -#include "qwebview.h" +#include "qwebsettings.h" + #include #include #include -#include +#include #include #if ENABLE(VIDEO) && ((USE(GSTREAMER) && !defined(GST_API_VERSION_1)) || USE(QT_MULTIMEDIA) || USE(QTKIT)) @@ -124,8 +122,8 @@ class RefreshAnimation : public QAbstractAnimation { bool ChromeClientQt::dumpVisitedLinksCallbacks = false; -ChromeClientQt::ChromeClientQt(QWebPage* webPage) - : m_webPage(webPage) +ChromeClientQt::ChromeClientQt(QWebPageAdapter* webPageAdapter) + : m_webPage(webPageAdapter) , m_eventLoop(0) #if ENABLE(VIDEO) && ((USE(GSTREAMER) && !defined(GST_API_VERSION_1)) || USE(QT_MULTIMEDIA) || USE(QTKIT)) , m_fullScreenVideo(0) @@ -148,8 +146,7 @@ void ChromeClientQt::setWindowRect(const FloatRect& rect) { if (!m_webPage) return; - emit m_webPage->geometryChangeRequested(QRect(qRound(rect.x()), qRound(rect.y()), - qRound(rect.width()), qRound(rect.height()))); + m_webPage->setWindowRect(QRect(qRound(rect.x()), qRound(rect.y()), qRound(rect.width()), qRound(rect.height()))); } /*! @@ -182,11 +179,7 @@ void ChromeClientQt::focus() { if (!m_webPage) return; - QWidget* view = m_webPage->view(); - if (!view) - return; - - view->setFocus(); + m_webPage->setFocus(); } @@ -194,10 +187,7 @@ void ChromeClientQt::unfocus() { if (!m_webPage) return; - QWidget* view = m_webPage->view(); - if (!view) - return; - view->clearFocus(); + m_webPage->unfocus(); } bool ChromeClientQt::canTakeFocus(FocusDirection) @@ -227,24 +217,18 @@ void ChromeClientQt::focusedFrameChanged(Frame*) Page* ChromeClientQt::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& features, const NavigationAction&) { - QWebPage* newPage = m_webPage->createWindow(features.dialog ? QWebPage::WebModalDialog : QWebPage::WebBrowserWindow); + QWebPageAdapter* newPage = m_webPage->createWindow(features.dialog); if (!newPage) return 0; - // A call to QWebPage::mainFrame() implicitly creates the main frame. - // Make sure it exists, as WebCore expects it when returning from this call. - newPage->mainFrame(); - return newPage->d->page; + return newPage->page; } void ChromeClientQt::show() { if (!m_webPage) return; - QWidget* view = m_webPage->view(); - if (!view) - return; - view->window()->show(); + m_webPage->show(); } @@ -266,7 +250,7 @@ void ChromeClientQt::runModal() void ChromeClientQt::setToolbarsVisible(bool visible) { toolBarsVisible = visible; - emit m_webPage->toolBarVisibilityChangeRequested(visible); + QMetaObject::invokeMethod(m_webPage->handle(), "toolBarVisibilityChangeRequested", Q_ARG(bool, visible)); } @@ -278,7 +262,7 @@ bool ChromeClientQt::toolbarsVisible() void ChromeClientQt::setStatusbarVisible(bool visible) { - emit m_webPage->statusBarVisibilityChangeRequested(visible); + QMetaObject::invokeMethod(m_webPage->handle(), "statusBarVisibilityChangeRequested", Q_ARG(bool, visible)); statusBarVisible = visible; } @@ -305,7 +289,7 @@ bool ChromeClientQt::scrollbarsVisible() void ChromeClientQt::setMenubarVisible(bool visible) { menuBarVisible = visible; - emit m_webPage->menuBarVisibilityChangeRequested(visible); + QMetaObject::invokeMethod(m_webPage->handle(), "menuBarVisibilityChangeRequested", Q_ARG(bool, visible)); } bool ChromeClientQt::menubarVisible() @@ -318,8 +302,7 @@ void ChromeClientQt::setResizable(bool) notImplemented(); } -void ChromeClientQt::addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, - unsigned int lineNumber, const String& sourceID) +void ChromeClientQt::addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID) { QString x = message; QString y = sourceID; @@ -343,30 +326,26 @@ bool ChromeClientQt::runBeforeUnloadConfirmPanel(const String& message, Frame* f void ChromeClientQt::closeWindowSoon() { - m_webPage->d->page->setGroupName(String()); - m_webPage->mainFrame()->d->frame->loader()->stopAllLoaders(); - emit m_webPage->windowCloseRequested(); + m_webPage->page->setGroupName(String()); + m_webPage->page->mainFrame()->loader()->stopAllLoaders(); + QMetaObject::invokeMethod(m_webPage->handle(), "windowCloseRequested"); } void ChromeClientQt::runJavaScriptAlert(Frame* f, const String& msg) { - QString x = msg; - QWebFrame* webFrame = qobject_cast(f->loader()->networkingContext()->originatingObject()); - m_webPage->javaScriptAlert(webFrame, x); + m_webPage->javaScriptAlert(QWebFrameAdapter::kit(f), msg); } bool ChromeClientQt::runJavaScriptConfirm(Frame* f, const String& msg) { - QString x = msg; - QWebFrame* webFrame = qobject_cast(f->loader()->networkingContext()->originatingObject()); - return m_webPage->javaScriptConfirm(webFrame, x); + return m_webPage->javaScriptConfirm(QWebFrameAdapter::kit(f), msg); } bool ChromeClientQt::runJavaScriptPrompt(Frame* f, const String& message, const String& defaultValue, String& result) { QString x = result; - QWebFrame* webFrame = qobject_cast(f->loader()->networkingContext()->originatingObject()); - bool rc = m_webPage->javaScriptPrompt(webFrame, (QString)message, (QString)defaultValue, &x); + QWebFrameAdapter* webFrame = QWebFrameAdapter::kit(f); + bool rc = m_webPage->javaScriptPrompt(webFrame, message, defaultValue, &x); // Fix up a quirk in the QInputDialog class. If no input happened the string should be empty // but it is null. See https://bugs.webkit.org/show_bug.cgi?id=30914. @@ -381,19 +360,19 @@ bool ChromeClientQt::runJavaScriptPrompt(Frame* f, const String& message, const void ChromeClientQt::setStatusbarText(const String& msg) { QString x = msg; - emit m_webPage->statusBarMessage(x); + QMetaObject::invokeMethod(m_webPage->handle(), "statusBarMessage", Q_ARG(QString, x)); } bool ChromeClientQt::shouldInterruptJavaScript() { bool shouldInterrupt = false; - QMetaObject::invokeMethod(m_webPage, "shouldInterruptJavaScript", Qt::DirectConnection, Q_RETURN_ARG(bool, shouldInterrupt)); + QMetaObject::invokeMethod(m_webPage->handle(), "shouldInterruptJavaScript", Qt::DirectConnection, Q_RETURN_ARG(bool, shouldInterrupt)); return shouldInterrupt; } KeyboardUIMode ChromeClientQt::keyboardUIMode() { - return m_webPage->settings()->testAttribute(QWebSettings::LinksIncludedInFocusChain) + return m_webPage->settings->testAttribute(QWebSettings::LinksIncludedInFocusChain) ? KeyboardAccessTabsToLinks : KeyboardAccessDefault; } @@ -407,11 +386,10 @@ IntRect ChromeClientQt::windowResizerRect() const if (!pageClient) return IntRect(); - QWidget* ownerWidget = pageClient->ownerWidget(); - if (!ownerWidget) + QWindow* topLevelWidget = pageClient->ownerWindow(); + if (!topLevelWidget) return IntRect(); - QWidget* topLevelWidget = ownerWidget->window(); QRect topLevelGeometry(topLevelWidget->geometry()); // There's no API in Qt to query for the size of the resizer, so we assume @@ -423,12 +401,13 @@ IntRect ChromeClientQt::windowResizerRect() const // it might even be on the lower left side of the window, but in WebKit we // always draw scrollbars on the right hand side, so we assume this to be the // location when computing the resize rect to reserve for WebKit. - QPoint resizeCornerTopLeft = ownerWidget->mapFrom(topLevelWidget, - QPoint(topLevelGeometry.width(), topLevelGeometry.height()) - - QPoint(scollbarThickness, scollbarThickness)); + QPoint resizeCornerTopLeft = QPoint(topLevelGeometry.width(), topLevelGeometry.height()) + - QPoint(scollbarThickness, scollbarThickness)) + - m_webPage->viewRectRelativeToWindow().topLeft(); QRect resizeCornerRect = QRect(resizeCornerTopLeft, QSize(scollbarThickness, scollbarThickness)); return resizeCornerRect.intersected(pageClient->geometryRelativeToOwnerWidget()); + #else return IntRect(); #endif @@ -438,7 +417,7 @@ void ChromeClientQt::invalidateRootView(const IntRect& windowRect, bool) { #if USE(TILED_BACKING_STORE) if (platformPageClient()) { - WebCore::TiledBackingStore* backingStore = QWebFramePrivate::core(m_webPage->mainFrame())->tiledBackingStore(); + WebCore::TiledBackingStore* backingStore = m_webPage->mainFrameAdapter()->frame->tiledBackingStore(); if (!backingStore) return; backingStore->invalidate(windowRect); @@ -448,7 +427,7 @@ void ChromeClientQt::invalidateRootView(const IntRect& windowRect, bool) #endif } -void ChromeClientQt::invalidateContentsAndRootView(const IntRect& windowRect, bool immediate) +void ChromeClientQt::invalidateContentsAndRootView(const IntRect& windowRect, bool) { // No double buffer, so only update the QWidget if content changed. if (platformPageClient()) { @@ -457,9 +436,9 @@ void ChromeClientQt::invalidateContentsAndRootView(const IntRect& windowRect, bo if (!rect.isEmpty()) platformPageClient()->update(rect); } - QMetaObject::invokeMethod(m_webPage, "repaintRequested", Qt::QueuedConnection, Q_ARG(QRect, windowRect)); + QMetaObject::invokeMethod(m_webPage->handle(), "repaintRequested", Qt::QueuedConnection, Q_ARG(QRect, windowRect)); - // FIXME: There is no "immediate" support for window painting. This should be done always whenever the flag + // FIXME: There is no "immediate" support for window painting. This should be done always whenever the flag // is set. } @@ -472,14 +451,18 @@ void ChromeClientQt::scroll(const IntSize& delta, const IntRect& scrollViewRect, { if (platformPageClient()) platformPageClient()->scroll(delta.width(), delta.height(), scrollViewRect); - emit m_webPage->scrollRequested(delta.width(), delta.height(), scrollViewRect); + QMetaObject::invokeMethod(m_webPage->handle(), "scrollRequested", Q_ARG(int, delta.width()), Q_ARG(int, delta.height()), Q_ARG(QRect, scrollViewRect)); } #if USE(TILED_BACKING_STORE) void ChromeClientQt::delegatedScrollRequested(const IntPoint& point) { - QPoint currentPosition(m_webPage->mainFrame()->scrollPosition()); - emit m_webPage->scrollRequested(point.x() - currentPosition.x(), point.y() - currentPosition.y(), QRect(QPoint(0, 0), m_webPage->viewportSize())); + + IntSize currentPosition = m_webPage->mainFrameAdapter()->scrollPosition(); + int x = point.x() - currentPosition.width(); + int y = point.y() - currentPosition.height(); + const QRect rect(QPoint(0, 0), m_webPage->viewportSize()); + QMetaObject::invokeMethod(m_webPage->handle(), "scrollRequested", Q_ARG(int, x), Q_ARG(int, y), Q_ARG(QRect, rect)); } #endif @@ -489,12 +472,12 @@ IntRect ChromeClientQt::rootViewToScreen(const IntRect& rect) const if (!pageClient) return rect; - QWidget* ownerWidget = pageClient->ownerWidget(); - if (!ownerWidget) - return rect; + QWindow* ownerWindow = pageClient->ownerWindow(); + if (!ownerWindow) + return rect; QRect screenRect(rect); - screenRect.translate(ownerWidget->mapToGlobal(QPoint(0, 0))); + screenRect.translate(ownerWindow->mapToGlobal(m_webPage->viewRectRelativeToWindow().topLeft())); return screenRect; } @@ -505,22 +488,22 @@ IntPoint ChromeClientQt::screenToRootView(const IntPoint& point) const if (!pageClient) return point; - QWidget* ownerWidget = pageClient->ownerWidget(); - if (!ownerWidget) + QWindow* ownerWindow = pageClient->ownerWindow(); + if (!ownerWindow) return point; - return ownerWidget->mapFromGlobal(point); + return ownerWindow->mapFromGlobal(point) - m_webPage->viewRectRelativeToWindow().topLeft(); } PlatformPageClient ChromeClientQt::platformPageClient() const { - return m_webPage->d->client.get(); + return m_webPage->client.data(); } void ChromeClientQt::contentsSizeChanged(Frame* frame, const IntSize& size) const { if (frame->loader()->networkingContext()) - QWebFramePrivate::kit(frame)->contentsSizeChanged(size); + QWebFrameAdapter::kit(frame)->contentsSizeDidChange(size); } void ChromeClientQt::mouseDidMoveOverElement(const HitTestResult& result, unsigned) @@ -532,33 +515,19 @@ void ChromeClientQt::mouseDidMoveOverElement(const HitTestResult& result, unsign lastHoverURL = result.absoluteLinkURL(); lastHoverTitle = result.title(dir); lastHoverContent = result.textContent(); - emit m_webPage->linkHovered(lastHoverURL.string(), - lastHoverTitle, lastHoverContent); + QMetaObject::invokeMethod(m_webPage->handle(), "linkHovered", Q_ARG(QString, lastHoverURL.string()), + Q_ARG(QString, lastHoverTitle), Q_ARG(QString, lastHoverContent)); } } void ChromeClientQt::setToolTip(const String &tip, TextDirection) { -#ifndef QT_NO_TOOLTIP - QWidget* view = m_webPage->view(); - if (!view) - return; - - if (tip.isEmpty()) { - view->setToolTip(QString()); - QToolTip::hideText(); - } else { - QString dtip = QLatin1String("

") + QString(tip).toHtmlEscaped() + QLatin1String("

"); - view->setToolTip(dtip); - } -#else - Q_UNUSED(tip); -#endif + m_webPage->setToolTip(tip); } void ChromeClientQt::print(Frame* frame) { - emit m_webPage->printRequested(QWebFramePrivate::kit(frame)); + emit m_webPage->printRequested(QWebFrameAdapter::kit(frame)); } #if ENABLE(SQL_DATABASE) @@ -569,7 +538,7 @@ void ChromeClientQt::exceededDatabaseQuota(Frame* frame, const String& databaseN if (!DatabaseTracker::tracker().hasEntryForOrigin(frame->document()->securityOrigin())) DatabaseTracker::tracker().setQuota(frame->document()->securityOrigin(), quota); - emit m_webPage->databaseQuotaExceeded(QWebFramePrivate::kit(frame), databaseName); + m_webPage->databaseQuotaExceeded(QWebFrameAdapter::kit(frame), databaseName); } #endif @@ -588,7 +557,7 @@ void ChromeClientQt::reachedApplicationCacheOriginQuota(SecurityOrigin* origin, QWebSecurityOrigin* securityOrigin = new QWebSecurityOrigin(priv); if (!WebCore::cacheStorage().calculateQuotaForOrigin(origin, quota)) - WebCore::cacheStorage().storeUpdatedQuotaForOrigin(origin, defaultOriginQuota); + WebCore::cacheStorage().storeUpdatedQuotaForOrigin(origin, defaultOriginQuota); emit m_webPage->applicationCacheQuotaExceeded(securityOrigin, defaultOriginQuota, static_cast(totalSpaceNeeded)); } @@ -596,7 +565,7 @@ void ChromeClientQt::reachedApplicationCacheOriginQuota(SecurityOrigin* origin, #if ENABLE(INPUT_TYPE_COLOR) PassOwnPtr ChromeClientQt::createColorChooser(ColorChooserClient* client, const Color& color) { - const QColor selectedColor = m_webPage->d->colorSelectionRequested(QColor(color)); + const QColor selectedColor = m_webPage->colorSelectionRequested(QColor(color)); client->didChooseColor(selectedColor); client->didEndChooser(); return nullptr; @@ -606,32 +575,22 @@ PassOwnPtr ChromeClientQt::createColorChooser(ColorChooserClient* void ChromeClientQt::runOpenPanel(Frame* frame, PassRefPtr prpFileChooser) { RefPtr fileChooser = prpFileChooser; - bool supportMulti = m_webPage->supportsExtension(QWebPage::ChooseMultipleFilesExtension); - - if (fileChooser->settings().allowsMultipleFiles && supportMulti) { - QWebPage::ChooseMultipleFilesExtensionOption option; - option.parentFrame = QWebFramePrivate::kit(frame); - if (!fileChooser->settings().selectedFiles.isEmpty()) - for (unsigned i = 0; i < fileChooser->settings().selectedFiles.size(); ++i) - option.suggestedFileNames += fileChooser->settings().selectedFiles[i]; + QStringList suggestedFileNames; + for (unsigned i = 0; i < fileChooser->settings().selectedFiles.size(); ++i) + suggestedFileNames += fileChooser->settings().selectedFiles[i]; - QWebPage::ChooseMultipleFilesExtensionReturn output; - m_webPage->extension(QWebPage::ChooseMultipleFilesExtension, &option, &output); + const bool allowMultiple = fileChooser->settings().allowsMultipleFiles; - if (!output.fileNames.isEmpty()) { + QStringList result = m_webPage->chooseFiles(QWebFrameAdapter::kit(frame), allowMultiple, suggestedFileNames); + if (!result.isEmpty()) { + if (allowMultiple) { Vector names; - for (int i = 0; i < output.fileNames.count(); ++i) - names.append(output.fileNames.at(i)); + for (int i = 0; i < result.count(); ++i) + names.append(result.at(i)); fileChooser->chooseFiles(names); - } - } else { - QString suggestedFile; - if (!fileChooser->settings().selectedFiles.isEmpty()) - suggestedFile = fileChooser->settings().selectedFiles[0]; - QString file = m_webPage->chooseFile(QWebFramePrivate::kit(frame), suggestedFile); - if (!file.isEmpty()) - fileChooser->chooseFile(file); + } else + fileChooser->chooseFile(result.first()); } } @@ -662,7 +621,7 @@ void ChromeClientQt::scheduleAnimation() void ChromeClientQt::serviceScriptedAnimations() { - m_webPage->mainFrame()->d->frame->view()->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(currentTime())); + m_webPage->mainFrameAdapter()->frame->view()->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(currentTime())); } #endif @@ -703,8 +662,10 @@ IntRect ChromeClientQt::visibleRectForTiledBackingStore() const if (!platformPageClient() || !m_webPage) return IntRect(); - if (!platformPageClient()->viewResizesToContentsEnabled()) - return QRect(m_webPage->mainFrame()->scrollPosition(), m_webPage->mainFrame()->geometry().size()); + if (!platformPageClient()->viewResizesToContentsEnabled()) { + IntSize offset = m_webPage->mainFrameAdapter()->scrollPosition(); + return QRect(QPoint(offset.width(), offset.height()), m_webPage->mainFrameAdapter()->frameRect().size()); + } return enclosingIntRect(FloatRect(platformPageClient()->graphicsItemVisibleRect())); } @@ -751,7 +712,7 @@ PassOwnPtr ChromeClientQt::createSelectPopup() const return result.release(); #if !defined(QT_NO_COMBOBOX) - return adoptPtr(new QtFallbackWebPopup(this)); + return adoptPtr(m_webPage->createSelectPopup()); #else return nullptr; #endif @@ -759,8 +720,18 @@ PassOwnPtr ChromeClientQt::createSelectPopup() const void ChromeClientQt::dispatchViewportPropertiesDidChange(const ViewportArguments&) const { - emit m_webPage->viewportChangeRequested(); + m_webPage->emitViewportChangeRequested(); +} + +#if USE(QT_MULTIMEDIA) +QWebFullScreenVideoHandler* ChromeClientQt::createFullScreenVideoHandler() +{ + QWebFullScreenVideoHandler* handler = m_platformPlugin.createFullScreenVideoHandler().leakPtr(); + if (!handler) + handler = m_webPage->createFullScreenVideoHandler(); + return handler; } +#endif bool ChromeClientQt::selectItemWritingDirectionIsNatural() { @@ -794,7 +765,7 @@ void ChromeClientQt::populateVisitedLinks() // in a separate database if (dumpVisitedLinksCallbacks) { printf("Asked to populate visited links for WebView \"%s\"\n", - qPrintable(m_webPage->mainFrame()->url().toString())); + qPrintable(QUrl(m_webPage->mainFrameAdapter()->url).toString())); } } diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h index f7359d2e287..96d8625c050 100644 --- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h @@ -42,6 +42,8 @@ class QEventLoop; QT_END_NAMESPACE class QWebPage; +class QWebPageAdapter; +class QWebFullScreenVideoHandler; namespace WebCore { @@ -59,7 +61,7 @@ class FullScreenVideoQt; class ChromeClientQt : public ChromeClient { public: - ChromeClientQt(QWebPage*); + ChromeClientQt(QWebPageAdapter*); virtual ~ChromeClientQt(); virtual void chromeDestroyed(); @@ -98,7 +100,7 @@ class ChromeClientQt : public ChromeClient { virtual void setResizable(bool); - virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID); + virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID); virtual bool canRunBeforeUnloadConfirmPanel(); virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame*); @@ -156,7 +158,7 @@ class ChromeClientQt : public ChromeClient { #if ENABLE(TOUCH_EVENTS) virtual void needTouchEvents(bool) { } #endif - + #if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA) || USE(QTKIT)) virtual bool supportsFullscreenForNode(const Node*); virtual void enterFullscreenForNode(Node*); @@ -169,8 +171,8 @@ class ChromeClientQt : public ChromeClient { virtual PassOwnPtr createColorChooser(ColorChooserClient*, const Color&); #endif - virtual void runOpenPanel(Frame*, PassRefPtr); - virtual void loadIconForFiles(const Vector&, FileIconLoader*); + virtual void runOpenPanel(Frame*, PassRefPtr); + virtual void loadIconForFiles(const Vector&, FileIconLoader*); virtual void formStateDidChange(const Node*) { } @@ -198,7 +200,9 @@ class ChromeClientQt : public ChromeClient { virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const { return true; } virtual void numWheelEventHandlersChanged(unsigned) { } - QWebPage* m_webPage; + QWebFullScreenVideoHandler* createFullScreenVideoHandler(); + + QWebPageAdapter* m_webPage; KURL lastHoverURL; String lastHoverTitle; String lastHoverContent; diff --git a/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp index 29180e06284..d2984c3d4f0 100644 --- a/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp @@ -30,9 +30,8 @@ #include "HitTestResult.h" #include "KURL.h" #include "NotImplemented.h" -#include -#include +#include namespace WebCore { diff --git a/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h b/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h index 0420f8d4a9c..eabac1b1a4f 100644 --- a/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h @@ -40,7 +40,7 @@ class ContextMenuClientQt : public ContextMenuClient { virtual PlatformMenuDescription getCustomMenuFromDefaultItems(ContextMenu*); virtual void contextMenuItemSelected(ContextMenuItem*, const ContextMenu*); - virtual void downloadURL(const KURL& url); + virtual void downloadURL(const KURL&); virtual void lookUpInDictionary(Frame*); virtual void speak(const String&); virtual bool isSpeaking(); diff --git a/Source/WebKit/qt/WebCoreSupport/DefaultFullScreenVideoHandler.cpp b/Source/WebKit/qt/WebCoreSupport/DefaultFullScreenVideoHandler.cpp new file mode 100644 index 00000000000..0fe24e8bd52 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/DefaultFullScreenVideoHandler.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "DefaultFullScreenVideoHandler.h" + +#if USE(QT_MULTIMEDIA) + +#include "FullScreenVideoWidget.h" + +using namespace WebKit; + +bool DefaultFullScreenVideoHandler::s_shouldForceFullScreenVideoPlayback = false; + +DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler() + : QWebFullScreenVideoHandler() + , m_fullScreenWidget(new FullScreenVideoWidget) +{ + connect(m_fullScreenWidget, SIGNAL(didExitFullScreen()), this, SIGNAL(fullScreenClosed())); + m_fullScreenWidget->hide(); + + m_fullScreenWidget->close(); +} + +DefaultFullScreenVideoHandler::~DefaultFullScreenVideoHandler() +{ + delete m_fullScreenWidget; +} + +bool DefaultFullScreenVideoHandler::requiresFullScreenForVideoPlayback() const +{ + static bool initialized = false; + if (!initialized) { + QByteArray forceFullScreen = qgetenv("QT_WEBKIT_FORCE_FULLSCREEN_VIDEO"); + if (!forceFullScreen.isEmpty()) + s_shouldForceFullScreenVideoPlayback = true; + + initialized = true; + } + + return s_shouldForceFullScreenVideoPlayback; +} + +void DefaultFullScreenVideoHandler::enterFullScreen(QMediaPlayer* player) +{ + m_fullScreenWidget->show(player); +} + +void DefaultFullScreenVideoHandler::exitFullScreen() +{ + m_fullScreenWidget->close(); +} +#endif + + diff --git a/Source/WebKit/qt/WebCoreSupport/DefaultFullScreenVideoHandler.h b/Source/WebKit/qt/WebCoreSupport/DefaultFullScreenVideoHandler.h new file mode 100644 index 00000000000..e943c55e440 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/DefaultFullScreenVideoHandler.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +#ifndef DefaultFullScreenVideoHandler_h +#define DefaultFullScreenVideoHandler_h + +#include "qwebkitplatformplugin.h" + +namespace WebKit { + +class FullScreenVideoWidget; + +// We do not use ENABLE or USE because moc does not expand these macros. +#if defined(WTF_USE_QT_MULTIMEDIA) && WTF_USE_QT_MULTIMEDIA +class DefaultFullScreenVideoHandler : public QWebFullScreenVideoHandler { + Q_OBJECT +public: + DefaultFullScreenVideoHandler(); + virtual ~DefaultFullScreenVideoHandler(); + bool requiresFullScreenForVideoPlayback() const; + +public Q_SLOTS: + void enterFullScreen(QMediaPlayer*); + void exitFullScreen(); + +private: + static bool s_shouldForceFullScreenVideoPlayback; + FullScreenVideoWidget *m_fullScreenWidget; +}; +#endif + +} // namespace WebKit + +#endif // DefaultFullScreenVideoHandler_h diff --git a/Source/WebKit/qt/WebCoreSupport/DragClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/DragClientQt.cpp index cb632834009..2e0d05ed123 100644 --- a/Source/WebKit/qt/WebCoreSupport/DragClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/DragClientQt.cpp @@ -26,16 +26,16 @@ #include "config.h" #include "DragClientQt.h" +#include "ChromeClient.h" #include "ClipboardQt.h" #include "DragController.h" #include "Frame.h" #include "Page.h" #include "PlatformMouseEvent.h" -#include "qwebpage.h" #include #include - +#include namespace WebCore { @@ -93,7 +93,7 @@ void DragClientQt::startDrag(DragImageRef dragImage, const IntPoint&, const IntP #ifndef QT_NO_DRAGANDDROP QMimeData* clipboardData = static_cast(clipboard)->clipboardData(); static_cast(clipboard)->invalidateWritableData(); - QWidget* view = m_webPage->view(); + QObject* view = m_chromeClient->platformPageClient()->ownerWidget(); if (view) { QDrag* drag = new QDrag(view); if (dragImage) @@ -105,7 +105,7 @@ void DragClientQt::startDrag(DragImageRef dragImage, const IntPoint&, const IntP Qt::DropAction actualDropAction = drag->exec(dragOperationsToDropActions(dragOperationMask)); // Send dragEnd event - PlatformMouseEvent me(m_webPage->view()->mapFromGlobal(QCursor::pos()), QCursor::pos(), LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, 0); + PlatformMouseEvent me(m_chromeClient->screenToRootView(QCursor::pos()), QCursor::pos(), LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, 0); frame->eventHandler()->dragSourceEndedAt(me, dropActionToDragOperation(actualDropAction)); } frame->page()->dragController()->dragEnded(); diff --git a/Source/WebKit/qt/WebCoreSupport/DragClientQt.h b/Source/WebKit/qt/WebCoreSupport/DragClientQt.h index 15724f1e148..aa8b8085b81 100644 --- a/Source/WebKit/qt/WebCoreSupport/DragClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/DragClientQt.h @@ -28,13 +28,13 @@ #include "DragClient.h" -class QWebPage; - namespace WebCore { +class ChromeClient; + class DragClientQt : public DragClient { public: - DragClientQt(QWebPage* webPage) : m_webPage(webPage) {}; + DragClientQt(ChromeClient* chromeClient) : m_chromeClient(chromeClient) { }; virtual void willPerformDragDestinationAction(DragDestinationAction, DragData*); virtual DragDestinationAction actionMaskForDrag(DragData*); virtual void dragControllerDestroyed(); @@ -42,7 +42,7 @@ class DragClientQt : public DragClient { virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*); virtual void startDrag(DragImageRef, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard*, Frame*, bool linkDrag = false); private: - QWebPage* m_webPage; + ChromeClient* m_chromeClient; }; } diff --git a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index edf20a46050..8d08c4a10dd 100644 --- a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -43,8 +43,6 @@ #include "FrameLoaderClientQt.h" #include "FrameView.h" #include "GCController.h" -#include "JSNode.h" -#include "qt_runtime.h" #include "GeolocationClient.h" #include "GeolocationClientMock.h" #include "GeolocationController.h" @@ -53,8 +51,8 @@ #include "HTMLFormElement.h" #include "HTMLInputElement.h" #include "HistoryItem.h" -#include "InitWebCoreQt.h" #include "InspectorController.h" +#include "JSNode.h" #include "NodeList.h" #include "NotificationPresenterClientQt.h" #include "Page.h" @@ -63,6 +61,8 @@ #include "PluginView.h" #include "PositionError.h" #include "PrintContext.h" +#include "QWebFrameAdapter.h" +#include "QWebPageAdapter.h" #include "RenderListItem.h" #include "RenderTreeAsText.h" #include "SchemeRegistry.h" @@ -76,15 +76,10 @@ #include "ThirdPartyCookiesQt.h" #include "WebCoreTestSupport.h" #include "WorkerThread.h" -#include - +#include "qt_runtime.h" #include "qwebelement.h" -#include "qwebframe.h" -#include "qwebframe_p.h" #include "qwebhistory.h" #include "qwebhistory_p.h" -#include "qwebpage.h" -#include "qwebpage_p.h" #include "qwebscriptworld.h" #if ENABLE(VIDEO) && USE(QT_MULTIMEDIA) @@ -92,9 +87,8 @@ #include "MediaPlayerPrivateQt.h" #endif -#include -#include #include +#include using namespace WebCore; @@ -103,15 +97,15 @@ QMap m_worldMap; #if ENABLE(GEOLOCATION) GeolocationClientMock* toGeolocationClientMock(GeolocationClient* client) { - ASSERT(QWebPagePrivate::drtRun); - return static_cast(client); + ASSERT(QWebPageAdapter::drtRun); + return static_cast(client); } #endif #if ENABLE(DEVICE_ORIENTATION) DeviceOrientationClientMock* toDeviceOrientationClientMock(DeviceOrientationClient* client) { - ASSERT(QWebPagePrivate::drtRun); + ASSERT(QWebPageAdapter::drtRun); return static_cast(client); } #endif @@ -198,7 +192,6 @@ DumpRenderTreeSupportQt::~DumpRenderTreeSupportQt() void DumpRenderTreeSupportQt::initialize() { - WebCore::initializeWebCoreQt(); QtDRTNodeRuntime::initialize(); } @@ -225,58 +218,58 @@ int DumpRenderTreeSupportQt::workerThreadCount() void DumpRenderTreeSupportQt::setDumpRenderTreeModeEnabled(bool b) { - QWebPagePrivate::drtRun = b; + QWebPageAdapter::drtRun = b; #if ENABLE(NETSCAPE_PLUGIN_API) && defined(XP_UNIX) // PluginViewQt (X11) needs a few workarounds when running under DRT PluginView::setIsRunningUnderDRT(b); #endif } -void DumpRenderTreeSupportQt::setFrameFlatteningEnabled(QWebPage* page, bool enabled) +void DumpRenderTreeSupportQt::setFrameFlatteningEnabled(QWebPageAdapter* adapter, bool enabled) { - QWebPagePrivate::core(page)->settings()->setFrameFlatteningEnabled(enabled); + adapter->page->settings()->setFrameFlatteningEnabled(enabled); } -void DumpRenderTreeSupportQt::webPageSetGroupName(QWebPage* page, const QString& groupName) +void DumpRenderTreeSupportQt::webPageSetGroupName(QWebPageAdapter *adapter, const QString& groupName) { - page->handle()->page->setGroupName(groupName); + adapter->page->setGroupName(groupName); } -QString DumpRenderTreeSupportQt::webPageGroupName(QWebPage* page) +QString DumpRenderTreeSupportQt::webPageGroupName(QWebPageAdapter* adapter) { - return page->handle()->page->groupName(); + return adapter->page->groupName(); } -void DumpRenderTreeSupportQt::webInspectorExecuteScript(QWebPage* page, long callId, const QString& script) +void DumpRenderTreeSupportQt::webInspectorExecuteScript(QWebPageAdapter* adapter, long callId, const QString& script) { #if ENABLE(INSPECTOR) - if (!page->handle()->page->inspectorController()) + if (!adapter->page->inspectorController()) return; - page->handle()->page->inspectorController()->evaluateForTestInFrontend(callId, script); + adapter->page->inspectorController()->evaluateForTestInFrontend(callId, script); #endif } -void DumpRenderTreeSupportQt::webInspectorClose(QWebPage* page) +void DumpRenderTreeSupportQt::webInspectorShow(QWebPageAdapter* adapter) { #if ENABLE(INSPECTOR) - if (!page->handle()->page->inspectorController()) + if (!adapter->page->inspectorController()) return; - page->handle()->page->inspectorController()->close(); + adapter->page->inspectorController()->show(); #endif } -void DumpRenderTreeSupportQt::webInspectorShow(QWebPage* page) +void DumpRenderTreeSupportQt::webInspectorClose(QWebPageAdapter* adapter) { #if ENABLE(INSPECTOR) - if (!page->handle()->page->inspectorController()) + if (!adapter->page->inspectorController()) return; - page->handle()->page->inspectorController()->show(); + adapter->page->inspectorController()->close(); #endif } -bool DumpRenderTreeSupportQt::hasDocumentElement(QWebFrame* frame) +bool DumpRenderTreeSupportQt::hasDocumentElement(QWebFrameAdapter *adapter) { - return QWebFramePrivate::core(frame)->document()->documentElement(); + return adapter->frame->document()->documentElement(); } void DumpRenderTreeSupportQt::setAutofilled(const QWebElement& element, bool isAutofilled) @@ -306,9 +299,9 @@ void DumpRenderTreeSupportQt::setValueForUser(const QWebElement& element, const // Pause a given CSS animation or transition on the target node at a specific time. // If the animation or transition is already paused, it will update its pause time. // This method is only intended to be used for testing the CSS animation and transition system. -bool DumpRenderTreeSupportQt::pauseAnimation(QWebFrame *frame, const QString &animationName, double time, const QString &elementId) +bool DumpRenderTreeSupportQt::pauseAnimation(QWebFrameAdapter *adapter, const QString &animationName, double time, const QString &elementId) { - Frame* coreFrame = QWebFramePrivate::core(frame); + Frame* coreFrame = adapter->frame; if (!coreFrame) return false; @@ -326,9 +319,9 @@ bool DumpRenderTreeSupportQt::pauseAnimation(QWebFrame *frame, const QString &an return controller->pauseAnimationAtTime(coreNode->renderer(), animationName, time); } -bool DumpRenderTreeSupportQt::pauseTransitionOfProperty(QWebFrame *frame, const QString &propertyName, double time, const QString &elementId) +bool DumpRenderTreeSupportQt::pauseTransitionOfProperty(QWebFrameAdapter *adapter, const QString &propertyName, double time, const QString &elementId) { - Frame* coreFrame = QWebFramePrivate::core(frame); + Frame* coreFrame = adapter->frame; if (!coreFrame) return false; @@ -347,9 +340,9 @@ bool DumpRenderTreeSupportQt::pauseTransitionOfProperty(QWebFrame *frame, const } // Returns the total number of currently running animations (includes both CSS transitions and CSS animations). -int DumpRenderTreeSupportQt::numberOfActiveAnimations(QWebFrame *frame) +int DumpRenderTreeSupportQt::numberOfActiveAnimations(QWebFrameAdapter *adapter) { - Frame* coreFrame = QWebFramePrivate::core(frame); + Frame* coreFrame = adapter->frame; if (!coreFrame) return false; @@ -360,9 +353,9 @@ int DumpRenderTreeSupportQt::numberOfActiveAnimations(QWebFrame *frame) return controller->numberOfActiveAnimations(coreFrame->document()); } -void DumpRenderTreeSupportQt::clearFrameName(QWebFrame* frame) +void DumpRenderTreeSupportQt::clearFrameName(QWebFrameAdapter *adapter) { - Frame* coreFrame = QWebFramePrivate::core(frame); + Frame* coreFrame = adapter->frame; coreFrame->tree()->clearName(); } @@ -381,24 +374,6 @@ void DumpRenderTreeSupportQt::garbageCollectorCollectOnAlternateThread(bool wait gcController().garbageCollectOnAlternateThreadForDebugging(waitUntilDone); } -// Suspend active DOM objects in this frame. -void DumpRenderTreeSupportQt::suspendActiveDOMObjects(QWebFrame* frame) -{ - Frame* coreFrame = QWebFramePrivate::core(frame); - if (coreFrame->document()) - // FIXME: This function should be changed take a ReasonForSuspension parameter - // https://bugs.webkit.org/show_bug.cgi?id=45732 - coreFrame->document()->suspendActiveDOMObjects(ActiveDOMObject::JavaScriptDebuggerPaused); -} - -// Resume active DOM objects in this frame. -void DumpRenderTreeSupportQt::resumeActiveDOMObjects(QWebFrame* frame) -{ - Frame* coreFrame = QWebFramePrivate::core(frame); - if (coreFrame->document()) - coreFrame->document()->resumeActiveDOMObjects(); -} - void DumpRenderTreeSupportQt::whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains) { SecurityPolicy::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); @@ -419,39 +394,39 @@ void DumpRenderTreeSupportQt::setDomainRelaxationForbiddenForURLScheme(bool forb SchemeRegistry::setDomainRelaxationForbiddenForURLScheme(forbidden, scheme); } -void DumpRenderTreeSupportQt::setCaretBrowsingEnabled(QWebPage* page, bool value) +void DumpRenderTreeSupportQt::setCaretBrowsingEnabled(QWebPageAdapter* adapter, bool value) { - page->handle()->page->settings()->setCaretBrowsingEnabled(value); + adapter->page->settings()->setCaretBrowsingEnabled(value); } -void DumpRenderTreeSupportQt::setAuthorAndUserStylesEnabled(QWebPage* page, bool value) +void DumpRenderTreeSupportQt::setAuthorAndUserStylesEnabled(QWebPageAdapter* adapter, bool value) { - page->handle()->page->settings()->setAuthorAndUserStylesEnabled(value); + adapter->page->settings()->setAuthorAndUserStylesEnabled(value); } -void DumpRenderTreeSupportQt::setSmartInsertDeleteEnabled(QWebPage* page, bool enabled) +void DumpRenderTreeSupportQt::setSmartInsertDeleteEnabled(QWebPageAdapter *adapter, bool enabled) { - page->d->smartInsertDeleteEnabled = enabled; + static_cast(adapter->page->editorClient())->setSmartInsertDeleteEnabled(enabled); } -void DumpRenderTreeSupportQt::setSelectTrailingWhitespaceEnabled(QWebPage* page, bool enabled) +void DumpRenderTreeSupportQt::setSelectTrailingWhitespaceEnabled(QWebPageAdapter *adapter, bool enabled) { - page->d->selectTrailingWhitespaceEnabled = enabled; + static_cast(adapter->page->editorClient())->setSelectTrailingWhitespaceEnabled(enabled); } -void DumpRenderTreeSupportQt::executeCoreCommandByName(QWebPage* page, const QString& name, const QString& value) +void DumpRenderTreeSupportQt::executeCoreCommandByName(QWebPageAdapter* adapter, const QString& name, const QString& value) { - page->handle()->page->focusController()->focusedOrMainFrame()->editor()->command(name).execute(value); + adapter->page->focusController()->focusedOrMainFrame()->editor()->command(name).execute(value); } -bool DumpRenderTreeSupportQt::isCommandEnabled(QWebPage* page, const QString& name) +bool DumpRenderTreeSupportQt::isCommandEnabled(QWebPageAdapter *adapter, const QString& name) { - return page->handle()->page->focusController()->focusedOrMainFrame()->editor()->command(name).isEnabled(); + return adapter->page->focusController()->focusedOrMainFrame()->editor()->command(name).isEnabled(); } -bool DumpRenderTreeSupportQt::findString(QWebPage* page, const QString& string, const QStringList& optionArray) +bool DumpRenderTreeSupportQt::findString(QWebPageAdapter *adapter, const QString& string, const QStringList& optionArray) { // 1. Parse the options from the array WebCore::FindOptions options = 0; @@ -473,7 +448,7 @@ bool DumpRenderTreeSupportQt::findString(QWebPage* page, const QString& string, } // 2. find the string - WebCore::Frame* frame = page->handle()->page->focusController()->focusedOrMainFrame(); + WebCore::Frame* frame = adapter->page->focusController()->focusedOrMainFrame(); return frame && frame->editor()->findString(string, options); } @@ -514,9 +489,9 @@ QVariantMap DumpRenderTreeSupportQt::computedStyleIncludingVisitedInfo(const QWe return res; } -QVariantList DumpRenderTreeSupportQt::selectedRange(QWebPage* page) +QVariantList DumpRenderTreeSupportQt::selectedRange(QWebPageAdapter *adapter) { - WebCore::Frame* frame = page->handle()->page->focusController()->focusedOrMainFrame(); + WebCore::Frame* frame = adapter->page->focusController()->focusedOrMainFrame(); QVariantList selectedRange; RefPtr range = frame->selection()->toNormalizedRange().get(); @@ -538,9 +513,9 @@ QVariantList DumpRenderTreeSupportQt::selectedRange(QWebPage* page) } -QVariantList DumpRenderTreeSupportQt::firstRectForCharacterRange(QWebPage* page, int location, int length) +QVariantList DumpRenderTreeSupportQt::firstRectForCharacterRange(QWebPageAdapter *adapter, int location, int length) { - WebCore::Frame* frame = page->handle()->page->focusController()->focusedOrMainFrame(); + WebCore::Frame* frame = adapter->page->focusController()->focusedOrMainFrame(); QVariantList rect; if ((location + length < location) && (location + length)) @@ -556,9 +531,9 @@ QVariantList DumpRenderTreeSupportQt::firstRectForCharacterRange(QWebPage* page, return rect; } -bool DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId(QWebFrame* frame, const QString& elementId) +bool DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId(QWebFrameAdapter *adapter, const QString& elementId) { - Frame* coreFrame = QWebFramePrivate::core(frame); + Frame* coreFrame = adapter->frame; if (!coreFrame) return false; @@ -574,9 +549,9 @@ bool DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId(QWebFrame* return inputElement->isTextField() && !inputElement->isPasswordField() && inputElement->shouldAutocomplete(); } -void DumpRenderTreeSupportQt::setWindowsBehaviorAsEditingBehavior(QWebPage* page) +void DumpRenderTreeSupportQt::setWindowsBehaviorAsEditingBehavior(QWebPageAdapter* adapter) { - Page* corePage = QWebPagePrivate::core(page); + Page* corePage = adapter->page; if (!corePage) return; corePage->settings()->setEditingBehaviorType(EditingWindowsBehavior); @@ -676,15 +651,15 @@ void DumpRenderTreeSupportQt::dumpNotification(bool b) #endif } -QString DumpRenderTreeSupportQt::viewportAsText(QWebPage* page, int deviceDPI, const QSize& deviceSize, const QSize& availableSize) +QString DumpRenderTreeSupportQt::viewportAsText(QWebPageAdapter* adapter, int deviceDPI, const QSize& deviceSize, const QSize& availableSize) { - WebCore::ViewportArguments args = page->d->viewportArguments(); + WebCore::ViewportArguments args = adapter->viewportArguments(); float devicePixelRatio = deviceDPI / WebCore::ViewportArguments::deprecatedTargetDPI; WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(args, - /* desktop-width */ 980, - /* device-width */ deviceSize.width(), - /* device-height */ deviceSize.height(), + /* desktop-width */980, + /* device-width */deviceSize.width(), + /* device-height */deviceSize.height(), devicePixelRatio, availableSize); WebCore::restrictMinimumScaleFactorToViewportSize(conf, availableSize, devicePixelRatio); @@ -692,72 +667,72 @@ QString DumpRenderTreeSupportQt::viewportAsText(QWebPage* page, int deviceDPI, c QString res; res = res.sprintf("viewport size %dx%d scale %f with limits [%f, %f] and userScalable %f\n", - static_cast(conf.layoutSize.width()), - static_cast(conf.layoutSize.height()), - conf.initialScale, - conf.minimumScale, - conf.maximumScale, - conf.userScalable); + static_cast(conf.layoutSize.width()), + static_cast(conf.layoutSize.height()), + conf.initialScale, + conf.minimumScale, + conf.maximumScale, + conf.userScalable); return res; } -void DumpRenderTreeSupportQt::scalePageBy(QWebFrame* frame, float scalefactor, const QPoint& origin) +void DumpRenderTreeSupportQt::scalePageBy(QWebFrameAdapter* adapter, float scalefactor, const QPoint& origin) { - WebCore::Frame* coreFrame = QWebFramePrivate::core(frame); + WebCore::Frame* coreFrame = adapter->frame; if (Page* page = coreFrame->page()) page->setPageScaleFactor(scalefactor, origin); } -void DumpRenderTreeSupportQt::setMockDeviceOrientation(QWebPage* page, bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma) +void DumpRenderTreeSupportQt::setMockDeviceOrientation(QWebPageAdapter* adapter, bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma) { #if ENABLE(DEVICE_ORIENTATION) - Page* corePage = QWebPagePrivate::core(page); + Page* corePage = adapter->page; DeviceOrientationClientMock* mockClient = toDeviceOrientationClientMock(DeviceOrientationController::from(corePage)->deviceOrientationClient()); mockClient->setOrientation(DeviceOrientationData::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma)); #endif } -void DumpRenderTreeSupportQt::resetGeolocationMock(QWebPage* page) +void DumpRenderTreeSupportQt::resetGeolocationMock(QWebPageAdapter* adapter) { #if ENABLE(GEOLOCATION) - Page* corePage = QWebPagePrivate::core(page); + Page* corePage = adapter->page; GeolocationClientMock* mockClient = toGeolocationClientMock(GeolocationController::from(corePage)->client()); mockClient->reset(); #endif } -void DumpRenderTreeSupportQt::setMockGeolocationPermission(QWebPage* page, bool allowed) +void DumpRenderTreeSupportQt::setMockGeolocationPermission(QWebPageAdapter* adapter, bool allowed) { #if ENABLE(GEOLOCATION) - Page* corePage = QWebPagePrivate::core(page); + Page* corePage = adapter->page; GeolocationClientMock* mockClient = toGeolocationClientMock(GeolocationController::from(corePage)->client()); mockClient->setPermission(allowed); #endif } -void DumpRenderTreeSupportQt::setMockGeolocationPosition(QWebPage* page, double latitude, double longitude, double accuracy) +void DumpRenderTreeSupportQt::setMockGeolocationPosition(QWebPageAdapter* adapter, double latitude, double longitude, double accuracy) { #if ENABLE(GEOLOCATION) - Page* corePage = QWebPagePrivate::core(page); + Page* corePage = adapter->page; GeolocationClientMock* mockClient = toGeolocationClientMock(GeolocationController::from(corePage)->client()); mockClient->setPosition(GeolocationPosition::create(currentTime(), latitude, longitude, accuracy)); #endif } -void DumpRenderTreeSupportQt::setMockGeolocationPositionUnavailableError(QWebPage* page, const QString& message) +void DumpRenderTreeSupportQt::setMockGeolocationPositionUnavailableError(QWebPageAdapter* adapter, const QString& message) { #if ENABLE(GEOLOCATION) - Page* corePage = QWebPagePrivate::core(page); + Page* corePage = adapter->page; GeolocationClientMock* mockClient = static_cast(GeolocationController::from(corePage)->client()); mockClient->setPositionUnavailableError(message); #endif } -int DumpRenderTreeSupportQt::numberOfPendingGeolocationPermissionRequests(QWebPage* page) +int DumpRenderTreeSupportQt::numberOfPendingGeolocationPermissionRequests(QWebPageAdapter* adapter) { #if ENABLE(GEOLOCATION) - Page* corePage = QWebPagePrivate::core(page); + Page* corePage = adapter->page; GeolocationClientMock* mockClient = toGeolocationClientMock(GeolocationController::from(corePage)->client()); return mockClient->numberOfPendingPermissionRequests(); #else @@ -794,9 +769,9 @@ QMap DumpRenderTreeSupportQt::getChildHistoryItems(con return kids; } -bool DumpRenderTreeSupportQt::shouldClose(QWebFrame* frame) +bool DumpRenderTreeSupportQt::shouldClose(QWebFrameAdapter *adapter) { - WebCore::Frame* coreFrame = QWebFramePrivate::core(frame); + WebCore::Frame* coreFrame = adapter->frame; return coreFrame->loader()->shouldClose(); } @@ -805,7 +780,7 @@ void DumpRenderTreeSupportQt::clearScriptWorlds() m_worldMap.clear(); } -void DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(QWebFrame* frame, int worldID, const QString& script) +void DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(QWebFrameAdapter *adapter, int worldID, const QString& script) { QWebScriptWorld* scriptWorld; if (!worldID) { @@ -816,7 +791,7 @@ void DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(QWebFrame* frame, in } else scriptWorld = m_worldMap.value(worldID); - WebCore::Frame* coreFrame = QWebFramePrivate::core(frame); + WebCore::Frame* coreFrame = adapter->frame; ScriptController* proxy = coreFrame->script(); @@ -825,14 +800,14 @@ void DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(QWebFrame* frame, in proxy->executeScriptInWorld(scriptWorld->world(), script, true); } -void DumpRenderTreeSupportQt::addUserStyleSheet(QWebPage* page, const QString& sourceCode) +void DumpRenderTreeSupportQt::addUserStyleSheet(QWebPageAdapter* adapter, const QString& sourceCode) { - page->handle()->page->group().addUserStyleSheetToWorld(mainThreadNormalWorld(), sourceCode, QUrl(), Vector(), Vector(), WebCore::InjectInAllFrames); + adapter->page->group().addUserStyleSheetToWorld(mainThreadNormalWorld(), sourceCode, QUrl(), Vector(), Vector(), WebCore::InjectInAllFrames); } -void DumpRenderTreeSupportQt::removeUserStyleSheets(QWebPage* page) +void DumpRenderTreeSupportQt::removeUserStyleSheets(QWebPageAdapter* adapter) { - page->handle()->page->group().removeUserStyleSheetsFromWorld(mainThreadNormalWorld()); + adapter->page->group().removeUserStyleSheetsFromWorld(mainThreadNormalWorld()); } void DumpRenderTreeSupportQt::simulateDesktopNotificationClick(const QString& title) @@ -842,31 +817,31 @@ void DumpRenderTreeSupportQt::simulateDesktopNotificationClick(const QString& ti #endif } -void DumpRenderTreeSupportQt::setDefersLoading(QWebPage* page, bool flag) +void DumpRenderTreeSupportQt::setDefersLoading(QWebPageAdapter* adapter, bool flag) { - Page* corePage = QWebPagePrivate::core(page); + Page* corePage = adapter->page; if (corePage) corePage->setDefersLoading(flag); } -void DumpRenderTreeSupportQt::goBack(QWebPage* page) +void DumpRenderTreeSupportQt::goBack(QWebPageAdapter* adapter) { - Page* corePage = QWebPagePrivate::core(page); + Page* corePage = adapter->page; if (corePage) corePage->goBack(); } // API Candidate? -QString DumpRenderTreeSupportQt::responseMimeType(QWebFrame* frame) +QString DumpRenderTreeSupportQt::responseMimeType(QWebFrameAdapter* adapter) { - WebCore::Frame* coreFrame = QWebFramePrivate::core(frame); + WebCore::Frame* coreFrame = adapter->frame; WebCore::DocumentLoader* docLoader = coreFrame->loader()->documentLoader(); return docLoader->responseMIMEType(); } -void DumpRenderTreeSupportQt::clearOpener(QWebFrame* frame) +void DumpRenderTreeSupportQt::clearOpener(QWebFrameAdapter* adapter) { - WebCore::Frame* coreFrame = QWebFramePrivate::core(frame); + WebCore::Frame* coreFrame = adapter->frame; coreFrame->loader()->setOpener(0); } @@ -875,40 +850,16 @@ void DumpRenderTreeSupportQt::addURLToRedirect(const QString& origin, const QStr FrameLoaderClientQt::URLsToRedirect[origin] = destination; } -void DumpRenderTreeSupportQt::setInteractiveFormValidationEnabled(QWebPage* page, bool enable) +void DumpRenderTreeSupportQt::setInteractiveFormValidationEnabled(QWebPageAdapter* adapter, bool enable) { - Page* corePage = QWebPagePrivate::core(page); + Page* corePage = adapter->page; if (corePage) corePage->settings()->setInteractiveFormValidationEnabled(enable); } -#ifndef QT_NO_MENU -static QStringList iterateContextMenu(QMenu* menu) -{ - if (!menu) - return QStringList(); - - QStringList items; - QList actions = menu->actions(); - for (int i = 0; i < actions.count(); ++i) { - if (actions.at(i)->isSeparator()) - items << QLatin1String(""); - else - items << actions.at(i)->text(); - if (actions.at(i)->menu()) - items << iterateContextMenu(actions.at(i)->menu()); - } - return items; -} -#endif - -QStringList DumpRenderTreeSupportQt::contextMenu(QWebPage* page) +QStringList DumpRenderTreeSupportQt::contextMenu(QWebPageAdapter* page) { -#ifndef QT_NO_CONTEXTMENU - return iterateContextMenu(page->d->currentContextMenu.data()); -#else - return QStringList(); -#endif + return page->menuActionsAsText(); } double DumpRenderTreeSupportQt::defaultMinimumTimerInterval() @@ -916,18 +867,18 @@ double DumpRenderTreeSupportQt::defaultMinimumTimerInterval() return Settings::defaultMinDOMTimerInterval(); } -void DumpRenderTreeSupportQt::setMinimumTimerInterval(QWebPage* page, double interval) +void DumpRenderTreeSupportQt::setMinimumTimerInterval(QWebPageAdapter* adapter, double interval) { - Page* corePage = QWebPagePrivate::core(page); + Page* corePage = adapter->page; if (!corePage) return; corePage->settings()->setMinDOMTimerInterval(interval); } -bool DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(QWebPage *page, const QUrl& url, const QUrl& firstPartyUrl) +bool DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(QWebPageAdapter *adapter, const QUrl& url, const QUrl& firstPartyUrl) { - Page* corePage = QWebPagePrivate::core(page); + Page* corePage = adapter->page; return thirdPartyCookiePolicyPermits(corePage->mainFrame()->loader()->networkingContext(), url, firstPartyUrl); } @@ -936,12 +887,12 @@ void DumpRenderTreeSupportQt::enableMockScrollbars() Settings::setMockScrollbarsEnabled(true); } -QUrl DumpRenderTreeSupportQt::mediaContentUrlByElementId(QWebFrame* frame, const QString& elementId) +QUrl DumpRenderTreeSupportQt::mediaContentUrlByElementId(QWebFrameAdapter* adapter, const QString& elementId) { QUrl res; #if ENABLE(VIDEO) && USE(QT_MULTIMEDIA) - Frame* coreFrame = QWebFramePrivate::core(frame); + Frame* coreFrame = adapter->frame; if (!coreFrame) return res; @@ -967,10 +918,10 @@ QUrl DumpRenderTreeSupportQt::mediaContentUrlByElementId(QWebFrame* frame, const } // API Candidate? -void DumpRenderTreeSupportQt::setAlternateHtml(QWebFrame* frame, const QString& html, const QUrl& baseUrl, const QUrl& failingUrl) +void DumpRenderTreeSupportQt::setAlternateHtml(QWebFrameAdapter* adapter, const QString& html, const QUrl& baseUrl, const QUrl& failingUrl) { KURL kurl(baseUrl); - WebCore::Frame* coreFrame = QWebFramePrivate::core(frame); + WebCore::Frame* coreFrame = adapter->frame; WebCore::ResourceRequest request(kurl); const QByteArray utf8 = html.toUtf8(); WTF::RefPtr data = WebCore::SharedBuffer::create(utf8.constData(), utf8.length()); @@ -978,9 +929,9 @@ void DumpRenderTreeSupportQt::setAlternateHtml(QWebFrame* frame, const QString& coreFrame->loader()->load(request, substituteData, false); } -void DumpRenderTreeSupportQt::confirmComposition(QWebPage* page, const char* text) +void DumpRenderTreeSupportQt::confirmComposition(QWebPageAdapter *adapter, const char* text) { - Frame* frame = page->handle()->page->focusController()->focusedOrMainFrame(); + Frame* frame = adapter->page->focusController()->focusedOrMainFrame(); if (!frame) return; @@ -997,15 +948,9 @@ void DumpRenderTreeSupportQt::confirmComposition(QWebPage* page, const char* tex editor->insertText(String::fromUTF8(text), 0); } -QString DumpRenderTreeSupportQt::layerTreeAsText(QWebFrame* frame) -{ - WebCore::Frame* coreFrame = QWebFramePrivate::core(frame); - return coreFrame->layerTreeAsText(); -} - -void DumpRenderTreeSupportQt::injectInternalsObject(QWebFrame* frame) +void DumpRenderTreeSupportQt::injectInternalsObject(QWebFrameAdapter* adapter) { - WebCore::Frame* coreFrame = QWebFramePrivate::core(frame); + WebCore::Frame* coreFrame = adapter->frame; JSDOMWindow* window = toJSDOMWindow(coreFrame, mainThreadNormalWorld()); Q_ASSERT(window); @@ -1022,9 +967,9 @@ void DumpRenderTreeSupportQt::injectInternalsObject(JSContextRef context) WebCoreTestSupport::injectInternalsObject(context); } -void DumpRenderTreeSupportQt::resetInternalsObject(QWebFrame* frame) +void DumpRenderTreeSupportQt::resetInternalsObject(QWebFrameAdapter* adapter) { - WebCore::Frame* coreFrame = QWebFramePrivate::core(frame); + WebCore::Frame* coreFrame = adapter->frame; JSDOMWindow* window = toJSDOMWindow(coreFrame, mainThreadNormalWorld()); Q_ASSERT(window); @@ -1041,9 +986,9 @@ void DumpRenderTreeSupportQt::resetInternalsObject(JSContextRef context) WebCoreTestSupport::resetInternalsObject(context); } -QImage DumpRenderTreeSupportQt::paintPagesWithBoundaries(QWebFrame* qframe) +QImage DumpRenderTreeSupportQt::paintPagesWithBoundaries(QWebFrameAdapter* adapter) { - Frame* frame = QWebFramePrivate::core(qframe); + Frame* frame = adapter->frame; PrintContext printContext(frame); QRect rect = frame->view()->frameRect(); @@ -1084,119 +1029,21 @@ QImage DumpRenderTreeSupportQt::paintPagesWithBoundaries(QWebFrame* qframe) return image; } -void DumpRenderTreeSupportQt::setTrackRepaintRects(QWebFrame* frame, bool enable) +void DumpRenderTreeSupportQt::setTrackRepaintRects(QWebFrameAdapter* adapter, bool enable) { - QWebFramePrivate::core(frame)->view()->setTracksRepaints(enable); + adapter->frame->view()->setTracksRepaints(enable); } -bool DumpRenderTreeSupportQt::trackRepaintRects(QWebFrame* frame) +bool DumpRenderTreeSupportQt::trackRepaintRects(QWebFrameAdapter* adapter) { - return QWebFramePrivate::core(frame)->view()->isTrackingRepaints(); + return adapter->frame->view()->isTrackingRepaints(); } -void DumpRenderTreeSupportQt::getTrackedRepaintRects(QWebFrame* frame, QVector& result) +void DumpRenderTreeSupportQt::getTrackedRepaintRects(QWebFrameAdapter* adapter, QVector& result) { - Frame* coreFrame = QWebFramePrivate::core(frame); + Frame* coreFrame = adapter->frame; const Vector& rects = coreFrame->view()->trackedRepaintRects(); result.resize(rects.size()); for (size_t i = 0; i < rects.size(); ++i) result.append(rects[i]); } - -// Provide a backward compatibility with previously exported private symbols as of QtWebKit 4.6 release - -void QWEBKIT_EXPORT qt_resumeActiveDOMObjects(QWebFrame* frame) -{ - DumpRenderTreeSupportQt::resumeActiveDOMObjects(frame); -} - -void QWEBKIT_EXPORT qt_suspendActiveDOMObjects(QWebFrame* frame) -{ - DumpRenderTreeSupportQt::suspendActiveDOMObjects(frame); -} - -void QWEBKIT_EXPORT qt_drt_clearFrameName(QWebFrame* frame) -{ - DumpRenderTreeSupportQt::clearFrameName(frame); -} - -void QWEBKIT_EXPORT qt_drt_garbageCollector_collect() -{ - DumpRenderTreeSupportQt::garbageCollectorCollect(); -} - -void QWEBKIT_EXPORT qt_drt_garbageCollector_collectOnAlternateThread(bool waitUntilDone) -{ - DumpRenderTreeSupportQt::garbageCollectorCollectOnAlternateThread(waitUntilDone); -} - -int QWEBKIT_EXPORT qt_drt_javaScriptObjectsCount() -{ - return DumpRenderTreeSupportQt::javaScriptObjectsCount(); -} - -int QWEBKIT_EXPORT qt_drt_numberOfActiveAnimations(QWebFrame* frame) -{ - return DumpRenderTreeSupportQt::numberOfActiveAnimations(frame); -} - -void QWEBKIT_EXPORT qt_drt_overwritePluginDirectories() -{ - DumpRenderTreeSupportQt::overwritePluginDirectories(); -} - -bool QWEBKIT_EXPORT qt_drt_pauseAnimation(QWebFrame* frame, const QString& animationName, double time, const QString& elementId) -{ - return DumpRenderTreeSupportQt::pauseAnimation(frame, animationName, time, elementId); -} - -bool QWEBKIT_EXPORT qt_drt_pauseTransitionOfProperty(QWebFrame* frame, const QString& propertyName, double time, const QString &elementId) -{ - return DumpRenderTreeSupportQt::pauseTransitionOfProperty(frame, propertyName, time, elementId); -} - -void QWEBKIT_EXPORT qt_drt_resetOriginAccessWhiteLists() -{ - DumpRenderTreeSupportQt::resetOriginAccessWhiteLists(); -} - -void QWEBKIT_EXPORT qt_drt_run(bool b) -{ - DumpRenderTreeSupportQt::setDumpRenderTreeModeEnabled(b); -} - -void QWEBKIT_EXPORT qt_drt_whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains) -{ - DumpRenderTreeSupportQt::whiteListAccessFromOrigin(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains); -} - -QString QWEBKIT_EXPORT qt_webpage_groupName(QWebPage* page) -{ - return DumpRenderTreeSupportQt::webPageGroupName(page); -} - -void QWEBKIT_EXPORT qt_webpage_setGroupName(QWebPage* page, const QString& groupName) -{ - DumpRenderTreeSupportQt::webPageSetGroupName(page, groupName); -} - -void QWEBKIT_EXPORT qt_dump_frame_loader(bool b) -{ - DumpRenderTreeSupportQt::dumpFrameLoader(b); -} - -void QWEBKIT_EXPORT qt_dump_resource_load_callbacks(bool b) -{ - DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(b); -} - -void QWEBKIT_EXPORT qt_dump_editing_callbacks(bool b) -{ - DumpRenderTreeSupportQt::dumpEditingCallbacks(b); -} - -void QWEBKIT_EXPORT qt_dump_set_accepts_editing(bool b) -{ - DumpRenderTreeSupportQt::dumpSetAcceptsEditing(b); -} - diff --git a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h index d0600ffa7da..72505b8d352 100644 --- a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h +++ b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h @@ -43,7 +43,8 @@ class QtDRTNodeRuntime; class QWebElement; class QWebFrame; -class QWebPage; +class QWebFrameAdapter; +class QWebPageAdapter; class QWebHistoryItem; class QWebScriptWorld; @@ -89,25 +90,23 @@ class QWEBKIT_EXPORT DumpRenderTreeSupportQt { static void initialize(); - static void executeCoreCommandByName(QWebPage* page, const QString& name, const QString& value); - static bool isCommandEnabled(QWebPage* page, const QString& name); - static bool findString(QWebPage* page, const QString& string, const QStringList& optionArray); - static void setSmartInsertDeleteEnabled(QWebPage* page, bool enabled); - static void setSelectTrailingWhitespaceEnabled(QWebPage* page, bool enabled); - static QVariantList selectedRange(QWebPage* page); - static QVariantList firstRectForCharacterRange(QWebPage* page, int location, int length); - static void confirmComposition(QWebPage*, const char* text); + static void executeCoreCommandByName(QWebPageAdapter*, const QString& name, const QString& value); + static bool isCommandEnabled(QWebPageAdapter*, const QString& name); + static bool findString(QWebPageAdapter*, const QString&, const QStringList& optionArray); + static void setSmartInsertDeleteEnabled(QWebPageAdapter*, bool enabled); + static void setSelectTrailingWhitespaceEnabled(QWebPageAdapter*, bool enabled); + static QVariantList selectedRange(QWebPageAdapter*); + static QVariantList firstRectForCharacterRange(QWebPageAdapter*, int location, int length); + static void confirmComposition(QWebPageAdapter*, const char* text); - static bool pauseAnimation(QWebFrame*, const QString& name, double time, const QString& elementId); - static bool pauseTransitionOfProperty(QWebFrame*, const QString& name, double time, const QString& elementId); - static void suspendActiveDOMObjects(QWebFrame* frame); - static void resumeActiveDOMObjects(QWebFrame* frame); + static bool pauseAnimation(QWebFrameAdapter*, const QString& name, double time, const QString& elementId); + static bool pauseTransitionOfProperty(QWebFrameAdapter*, const QString& name, double time, const QString& elementId); static void setDomainRelaxationForbiddenForURLScheme(bool forbidden, const QString& scheme); - static void setFrameFlatteningEnabled(QWebPage*, bool); - static void setCaretBrowsingEnabled(QWebPage* page, bool value); - static void setAuthorAndUserStylesEnabled(QWebPage*, bool); - static void setDumpRenderTreeModeEnabled(bool b); + static void setFrameFlatteningEnabled(QWebPageAdapter*, bool); + static void setCaretBrowsingEnabled(QWebPageAdapter*, bool value); + static void setAuthorAndUserStylesEnabled(QWebPageAdapter*, bool); + static void setDumpRenderTreeModeEnabled(bool); static void garbageCollectorCollect(); static void garbageCollectorCollectOnAlternateThread(bool waitUntilDone); @@ -115,20 +114,20 @@ class QWEBKIT_EXPORT DumpRenderTreeSupportQt { static void setValueForUser(const QWebElement&, const QString& value); static int javaScriptObjectsCount(); static void clearScriptWorlds(); - static void evaluateScriptInIsolatedWorld(QWebFrame* frame, int worldID, const QString& script); + static void evaluateScriptInIsolatedWorld(QWebFrameAdapter*, int worldID, const QString& script); - static void webInspectorExecuteScript(QWebPage* page, long callId, const QString& script); - static void webInspectorShow(QWebPage* page); - static void webInspectorClose(QWebPage* page); + static void webInspectorExecuteScript(QWebPageAdapter*, long callId, const QString& script); + static void webInspectorShow(QWebPageAdapter*); + static void webInspectorClose(QWebPageAdapter*); - static QString webPageGroupName(QWebPage *page); - static void webPageSetGroupName(QWebPage* page, const QString& groupName); - static void clearFrameName(QWebFrame* frame); + static QString webPageGroupName(QWebPageAdapter*); + static void webPageSetGroupName(QWebPageAdapter*, const QString& groupName); + static void clearFrameName(QWebFrameAdapter*); static void overwritePluginDirectories(); - static int numberOfActiveAnimations(QWebFrame*); - static bool hasDocumentElement(QWebFrame* frame); - static bool elementDoesAutoCompleteForElementWithId(QWebFrame* frame, const QString& elementId); - static void setWindowsBehaviorAsEditingBehavior(QWebPage*); + static int numberOfActiveAnimations(QWebFrameAdapter*); + static bool hasDocumentElement(QWebFrameAdapter*); + static bool elementDoesAutoCompleteForElementWithId(QWebFrameAdapter*, const QString& elementId); + static void setWindowsBehaviorAsEditingBehavior(QWebPageAdapter*); static void clearAllApplicationCaches(); @@ -136,86 +135,84 @@ class QWEBKIT_EXPORT DumpRenderTreeSupportQt { static void removeWhiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains); static void resetOriginAccessWhiteLists(); - static void setMockDeviceOrientation(QWebPage*, bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma); + static void setMockDeviceOrientation(QWebPageAdapter*, bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma); - static void resetGeolocationMock(QWebPage*); - static void setMockGeolocationPermission(QWebPage*, bool allowed); - static void setMockGeolocationPosition(QWebPage*, double latitude, double longitude, double accuracy); - static void setMockGeolocationPositionUnavailableError(QWebPage*, const QString& message); - static int numberOfPendingGeolocationPermissionRequests(QWebPage*); + static void resetGeolocationMock(QWebPageAdapter*); + static void setMockGeolocationPermission(QWebPageAdapter*, bool allowed); + static void setMockGeolocationPosition(QWebPageAdapter*, double latitude, double longitude, double accuracy); + static void setMockGeolocationPositionUnavailableError(QWebPageAdapter*, const QString& message); + static int numberOfPendingGeolocationPermissionRequests(QWebPageAdapter*); static int workerThreadCount(); static QString markerTextForListItem(const QWebElement& listItem); - static QVariantMap computedStyleIncludingVisitedInfo(const QWebElement& element); + static QVariantMap computedStyleIncludingVisitedInfo(const QWebElement&); - static void dumpFrameLoader(bool b); + static void dumpFrameLoader(bool); static void dumpProgressFinishedCallback(bool); - static void dumpUserGestureInFrameLoader(bool b); - static void dumpResourceLoadCallbacks(bool b); - static void dumpResourceResponseMIMETypes(bool b); + static void dumpUserGestureInFrameLoader(bool); + static void dumpResourceLoadCallbacks(bool); + static void dumpResourceResponseMIMETypes(bool); static void dumpResourceLoadCallbacksPath(const QString& path); static void dumpWillCacheResponseCallbacks(bool); - static void setWillSendRequestReturnsNullOnRedirect(bool b); - static void setWillSendRequestReturnsNull(bool b); - static void setWillSendRequestClearHeaders(const QStringList& headers); - static void dumpHistoryCallbacks(bool b); - static void dumpVisitedLinksCallbacks(bool b); + static void setWillSendRequestReturnsNullOnRedirect(bool); + static void setWillSendRequestReturnsNull(bool); + static void setWillSendRequestClearHeaders(const QStringList&); + static void dumpHistoryCallbacks(bool); + static void dumpVisitedLinksCallbacks(bool); - static void setDeferMainResourceDataLoad(bool b); + static void setDeferMainResourceDataLoad(bool); - static void dumpEditingCallbacks(bool b); - static void dumpSetAcceptsEditing(bool b); + static void dumpEditingCallbacks(bool); + static void dumpSetAcceptsEditing(bool); - static void dumpNotification(bool b); + static void dumpNotification(bool); + static QString viewportAsText(QWebPageAdapter*, int deviceDPI, const QSize& deviceSize, const QSize& availableSize); - static QMap getChildHistoryItems(const QWebHistoryItem& historyItem); - static bool isTargetItem(const QWebHistoryItem& historyItem); - static QString historyItemTarget(const QWebHistoryItem& historyItem); + static QMap getChildHistoryItems(const QWebHistoryItem&); + static bool isTargetItem(const QWebHistoryItem&); + static QString historyItemTarget(const QWebHistoryItem&); - static bool shouldClose(QWebFrame* frame); + static bool shouldClose(QWebFrameAdapter*); static void setCustomPolicyDelegate(bool enabled, bool permissive); - static void addUserStyleSheet(QWebPage* page, const QString& sourceCode); - static void removeUserStyleSheets(QWebPage*); + static void addUserStyleSheet(QWebPageAdapter*, const QString& sourceCode); + static void removeUserStyleSheets(QWebPageAdapter*); static void simulateDesktopNotificationClick(const QString& title); - static QString viewportAsText(QWebPage*, int deviceDPI, const QSize& deviceSize, const QSize& availableSize); - static void scalePageBy(QWebFrame*, float scale, const QPoint& origin); + static void scalePageBy(QWebFrameAdapter*, float scale, const QPoint& origin); - static QString responseMimeType(QWebFrame*); - static void clearOpener(QWebFrame*); + static QString responseMimeType(QWebFrameAdapter*); + static void clearOpener(QWebFrameAdapter*); static void addURLToRedirect(const QString& origin, const QString& destination); - static QStringList contextMenu(QWebPage*); + static QStringList contextMenu(QWebPageAdapter*); static double defaultMinimumTimerInterval(); // Not really tied to WebView - static void setMinimumTimerInterval(QWebPage*, double); + static void setMinimumTimerInterval(QWebPageAdapter*, double); - static QUrl mediaContentUrlByElementId(QWebFrame*, const QString& elementId); - static void setAlternateHtml(QWebFrame*, const QString& html, const QUrl& baseUrl, const QUrl& failingUrl); + static QUrl mediaContentUrlByElementId(QWebFrameAdapter*, const QString& elementId); + static void setAlternateHtml(QWebFrameAdapter*, const QString& html, const QUrl& baseUrl, const QUrl& failingUrl); - static QString layerTreeAsText(QWebFrame*); - - static void injectInternalsObject(QWebFrame*); + static void injectInternalsObject(QWebFrameAdapter*); static void injectInternalsObject(JSContextRef); - static void resetInternalsObject(QWebFrame*); + static void resetInternalsObject(QWebFrameAdapter*); static void resetInternalsObject(JSContextRef); - static void setInteractiveFormValidationEnabled(QWebPage*, bool); + static void setInteractiveFormValidationEnabled(QWebPageAdapter*, bool); - static void setDefersLoading(QWebPage*, bool flag); - static void goBack(QWebPage*); + static void setDefersLoading(QWebPageAdapter*, bool flag); + static void goBack(QWebPageAdapter*); - static bool thirdPartyCookiePolicyAllows(QWebPage*, const QUrl&, const QUrl& firstPartyUrl); + static bool thirdPartyCookiePolicyAllows(QWebPageAdapter*, const QUrl&, const QUrl& firstPartyUrl); static void enableMockScrollbars(); - static QImage paintPagesWithBoundaries(QWebFrame*); + static QImage paintPagesWithBoundaries(QWebFrameAdapter*); - static void setTrackRepaintRects(QWebFrame*, bool enable); - static bool trackRepaintRects(QWebFrame*); - static void getTrackedRepaintRects(QWebFrame*, QVector& result); + static void setTrackRepaintRects(QWebFrameAdapter*, bool enable); + static bool trackRepaintRects(QWebFrameAdapter*); + static void getTrackedRepaintRects(QWebFrameAdapter*, QVector& result); }; #endif diff --git a/Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp index eb73c9e9d45..78c36f2b9ba 100644 --- a/Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp @@ -32,7 +32,6 @@ #include "EditorClientQt.h" #include "Document.h" -#include "UndoStepQt.h" #include "Editor.h" #include "FocusController.h" #include "Frame.h" @@ -44,6 +43,7 @@ #include "Page.h" #include "Pasteboard.h" #include "PlatformKeyboardEvent.h" +#include "QWebPageAdapter.h" #include "QWebPageClient.h" #include "Range.h" #include "Settings.h" @@ -51,11 +51,10 @@ #include "StylePropertySet.h" #include "WindowsKeyboardCodes.h" #include "qguiapplication.h" -#include "qwebpage.h" -#include "qwebpage_p.h" #include -#include +#include +#include #include #include @@ -80,8 +79,8 @@ static QString dumpRange(WebCore::Range *range) WebCore::ExceptionCode code; QString str = QString::fromLatin1("range from %1 of %2 to %3 of %4") - .arg(range->startOffset(code)).arg(dumpPath(range->startContainer(code))) - .arg(range->endOffset(code)).arg(dumpPath(range->endContainer(code))); + .arg(range->startOffset(code)).arg(dumpPath(range->startContainer(code))) + .arg(range->endOffset(code)).arg(dumpPath(range->endContainer(code))); return str; } @@ -104,7 +103,7 @@ bool EditorClientQt::shouldDeleteRange(Range* range) bool EditorClientQt::shouldShowDeleteInterface(HTMLElement* element) { - if (QWebPagePrivate::drtRun) + if (QWebPageAdapter::drtRun) return element->getAttribute(classAttr) == "needsDeletionUI"; return false; } @@ -148,7 +147,7 @@ bool EditorClientQt::shouldInsertText(const String& string, Range* range, Editor }; printf("EDITING DELEGATE: shouldInsertText:%s replacingDOMRange:%s givenAction:%s\n", - QString(string).toUtf8().constData(), dumpRange(range).toUtf8().constData(), insertactionstring[action]); + QString(string).toUtf8().constData(), dumpRange(range).toUtf8().constData(), insertactionstring[action]); } return acceptsEditing; } @@ -166,19 +165,18 @@ bool EditorClientQt::shouldChangeSelectedRange(Range* currentRange, Range* propo }; printf("EDITING DELEGATE: shouldChangeSelectedDOMRange:%s toDOMRange:%s affinity:%s stillSelecting:%s\n", - dumpRange(currentRange).toUtf8().constData(), - dumpRange(proposedRange).toUtf8().constData(), - affinitystring[selectionAffinity], boolstring[stillSelecting]); + dumpRange(currentRange).toUtf8().constData(), + dumpRange(proposedRange).toUtf8().constData(), + affinitystring[selectionAffinity], boolstring[stillSelecting]); } return acceptsEditing; } -bool EditorClientQt::shouldApplyStyle(WebCore::StylePropertySet* style, - WebCore::Range* range) +bool EditorClientQt::shouldApplyStyle(WebCore::StylePropertySet* style, WebCore::Range* range) { if (dumpEditingCallbacks) printf("EDITING DELEGATE: shouldApplyStyle:%s toElementsInDOMRange:%s\n", - QString(style->asText()).toUtf8().constData(), dumpRange(range).toUtf8().constData()); + QString(style->asText()).toUtf8().constData(), dumpRange(range).toUtf8().constData()); return acceptsEditing; } @@ -199,9 +197,8 @@ void EditorClientQt::respondToChangedContents() { if (dumpEditingCallbacks) printf("EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n"); - m_page->d->updateEditorActions(); - emit m_page->contentsChanged(); + m_page->respondToChangedContents(); } void EditorClientQt::respondToChangedSelection(Frame* frame) @@ -220,8 +217,7 @@ void EditorClientQt::respondToChangedSelection(Frame* frame) Pasteboard::generalPasteboard()->setSelectionMode(oldSelectionMode); } - m_page->d->updateEditorActions(); - emit m_page->selectionChanged(); + m_page->respondToChangedSelection(); if (!frame->editor()->ignoreCompositionSelectionChange()) emit m_page->microFocusChanged(); } @@ -250,10 +246,10 @@ bool EditorClientQt::selectWordBeforeMenuEvent() void EditorClientQt::registerUndoStep(WTF::PassRefPtr step) { #ifndef QT_NO_UNDOSTACK - Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame(); + Frame* frame = m_page->page->focusController()->focusedOrMainFrame(); if (m_inUndoRedo || (frame && !frame->editor()->lastEditCommand() /* HACK!! Don't recreate undos */)) return; - m_page->undoStack()->push(new UndoStepQt(step)); + m_page->registerUndoStep(step); #endif // QT_NO_UNDOSTACK } @@ -264,7 +260,7 @@ void EditorClientQt::registerRedoStep(WTF::PassRefPtr) void EditorClientQt::clearUndoRedoOperations() { #ifndef QT_NO_UNDOSTACK - return m_page->undoStack()->clear(); + return m_page->clearUndoStack(); #endif } @@ -283,7 +279,7 @@ bool EditorClientQt::canUndo() const #ifdef QT_NO_UNDOSTACK return false; #else - return m_page->undoStack()->canUndo(); + return m_page->canUndo(); #endif } @@ -292,7 +288,7 @@ bool EditorClientQt::canRedo() const #ifdef QT_NO_UNDOSTACK return false; #else - return m_page->undoStack()->canRedo(); + return m_page->canRedo(); #endif } @@ -300,7 +296,7 @@ void EditorClientQt::undo() { #ifndef QT_NO_UNDOSTACK m_inUndoRedo = true; - m_page->undoStack()->undo(); + m_page->undo(); m_inUndoRedo = false; #endif } @@ -309,7 +305,7 @@ void EditorClientQt::redo() { #ifndef QT_NO_UNDOSTACK m_inUndoRedo = true; - m_page->undoStack()->redo(); + m_page->redo(); m_inUndoRedo = false; #endif } @@ -324,7 +320,7 @@ bool EditorClientQt::shouldInsertNode(Node* node, Range* range, EditorInsertActi }; printf("EDITING DELEGATE: shouldInsertNode:%s replacingDOMRange:%s givenAction:%s\n", dumpPath(node).toUtf8().constData(), - dumpRange(range).toUtf8().constData(), insertactionstring[action]); + dumpRange(range).toUtf8().constData(), insertactionstring[action]); } return acceptsEditing; } @@ -336,18 +332,18 @@ void EditorClientQt::pageDestroyed() bool EditorClientQt::smartInsertDeleteEnabled() { - return m_page->d->smartInsertDeleteEnabled; + return m_smartInsertDeleteEnabled; } void EditorClientQt::toggleSmartInsertDelete() { - bool current = m_page->d->smartInsertDeleteEnabled; - m_page->d->smartInsertDeleteEnabled = !current; + bool current = m_smartInsertDeleteEnabled; + m_smartInsertDeleteEnabled = !current; } bool EditorClientQt::isSelectTrailingWhitespaceEnabled() { - return m_page->d->selectTrailingWhitespaceEnabled; + return m_selectTrailingWhitespaceEnabled; } void EditorClientQt::toggleContinuousSpellChecking() @@ -416,7 +412,7 @@ const char* editorCommandForKeyDownEvent(const KeyboardEvent* event) void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event) { - Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame(); + Frame* frame = m_page->page->focusController()->focusedOrMainFrame(); if (!frame) return; @@ -444,20 +440,19 @@ void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event) } #ifndef QT_NO_SHORTCUT - QWebPage::WebAction action = QWebPagePrivate::editorActionForKeyEvent(kevent->qtEvent()); - if (action != QWebPage::NoWebAction && !doSpatialNavigation) { - const char* cmd = QWebPagePrivate::editorCommandForWebActions(action); + const char* cmd = m_page->editorCommandForKeyEvent(kevent->qtEvent()); + if (cmd && !doSpatialNavigation) { // WebKit doesn't have enough information about mode to decide how commands that just insert text if executed via Editor should be treated, // so we leave it upon WebCore to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated // (e.g. Tab that inserts a Tab character, or Enter). - if (cmd && frame->editor()->command(cmd).isTextInsertion() + if (frame->editor()->command(cmd).isTextInsertion() && kevent->type() == PlatformEvent::RawKeyDown) return; - m_page->triggerAction(action); + m_page->triggerActionForKeyEvent(kevent->qtEvent()); event->setDefaultHandled(); return; - } else + } #endif // QT_NO_SHORTCUT { String commandName = editorCommandForKeyDownEvent(event); @@ -501,7 +496,7 @@ void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event) } // Non editable content. - if (m_page->handle()->page->settings()->caretBrowsingEnabled()) { + if (m_page->page->settings()->caretBrowsingEnabled()) { switch (kevent->windowsVirtualKeyCode()) { case VK_LEFT: case VK_RIGHT: @@ -511,15 +506,13 @@ void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event) case VK_END: { #ifndef QT_NO_SHORTCUT - QWebPage::WebAction action = QWebPagePrivate::editorActionForKeyEvent(kevent->qtEvent()); - ASSERT(action != QWebPage::NoWebAction); - m_page->triggerAction(action); + m_page->triggerActionForKeyEvent(kevent->qtEvent()); event->setDefaultHandled(); #endif return; } case VK_PRIOR: // PageUp - case VK_NEXT: // PageDown + case VK_NEXT: // PageDown { String commandName = editorCommandForKeyDownEvent(event); ASSERT(!commandName.isEmpty()); @@ -532,7 +525,7 @@ void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event) #ifndef QT_NO_SHORTCUT if (kevent->qtEvent() == QKeySequence::Copy) { - m_page->triggerAction(QWebPage::Copy); + m_page->triggerCopyAction(); event->setDefaultHandled(); return; } @@ -543,8 +536,12 @@ void EditorClientQt::handleInputMethodKeydown(KeyboardEvent*) { } -EditorClientQt::EditorClientQt(QWebPage* page) - : m_page(page), m_editing(false), m_inUndoRedo(false) +EditorClientQt::EditorClientQt(QWebPageAdapter* pageAdapter) + : m_page(pageAdapter) + , m_editing(false) + , m_inUndoRedo(false) + , m_smartInsertDeleteEnabled(true) + , m_selectTrailingWhitespaceEnabled(false) { } @@ -607,12 +604,12 @@ void EditorClientQt::willSetInputMethodState() void EditorClientQt::setInputMethodState(bool active) { - QWebPageClient* webPageClient = m_page->d->client.get(); + QWebPageClient* webPageClient = m_page->client.data(); if (webPageClient) { Qt::InputMethodHints hints; HTMLInputElement* inputElement = 0; - Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame(); + Frame* frame = m_page->page->focusController()->focusedOrMainFrame(); if (frame && frame->document() && frame->document()->focusedNode()) if (frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag)) inputElement = static_cast(frame->document()->focusedNode()); diff --git a/Source/WebKit/qt/WebCoreSupport/EditorClientQt.h b/Source/WebKit/qt/WebCoreSupport/EditorClientQt.h index 863c67b7187..c49be4a4037 100644 --- a/Source/WebKit/qt/WebCoreSupport/EditorClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/EditorClientQt.h @@ -36,12 +36,13 @@ #include class QWebPage; +class QWebPageAdapter; namespace WebCore { class EditorClientQt : public EditorClient { public: - EditorClientQt(QWebPage* page); + EditorClientQt(QWebPageAdapter*); virtual void pageDestroyed(); virtual void frameWillDetachPage(Frame*) { } @@ -109,14 +110,19 @@ class EditorClientQt : public EditorClient { bool isEditing() const; + void setSmartInsertDeleteEnabled(bool b) { m_smartInsertDeleteEnabled = b; } + void setSelectTrailingWhitespaceEnabled(bool b) { m_selectTrailingWhitespaceEnabled = b; } + static bool dumpEditingCallbacks; static bool acceptsEditing; private: TextCheckerClientQt m_textCheckerClient; - QWebPage* m_page; + QWebPageAdapter* m_page; bool m_editing; bool m_inUndoRedo; // our undo stack works differently - don't re-enter! + bool m_smartInsertDeleteEnabled; + bool m_selectTrailingWhitespaceEnabled; }; } diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index 0731d93158a..7a23ee2683c 100644 --- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -59,7 +59,10 @@ #include "PluginDatabase.h" #include "ProgressTracker.h" #include "QNetworkReplyHandler.h" +#include "QWebFrameAdapter.h" +#include "QWebPageAdapter.h" #include "QWebPageClient.h" +#include "QtPluginWidgetAdapter.h" #include "RenderPart.h" #include "ResourceHandle.h" #include "ResourceHandleInternal.h" @@ -69,34 +72,30 @@ #include "Settings.h" #include "ViewportArguments.h" #include "WebEventConversion.h" - -#include "qwebframe.h" -#include "qwebframe_p.h" +#include "qwebhistory.h" #include "qwebhistory_p.h" #include "qwebhistoryinterface.h" -#include "qwebpage.h" -#include "qwebpage_p.h" #include "qwebpluginfactory.h" #include #include #include -#include -#include +#include #include #include #include #include +#include static QMap dumpAssignedUrls; // Compare with the file "WebKit/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm". static QString drtDescriptionSuitableForTestResult(WebCore::Frame* webCoreFrame) { - QWebFrame* frame = QWebFramePrivate::kit(webCoreFrame); - QString name = frame->frameName(); + QWebFrameAdapter* frame = QWebFrameAdapter::kit(webCoreFrame); + QString name = webCoreFrame->tree()->uniqueName(); - bool isMainFrame = frame == frame->page()->mainFrame(); + bool isMainFrame = frame == frame->pageAdapter->mainFrameAdapter(); if (isMainFrame) { if (!name.isEmpty()) return QString::fromLatin1("main frame \"%1\"").arg(name); @@ -216,24 +215,24 @@ FrameLoaderClientQt::~FrameLoaderClientQt() { } -void FrameLoaderClientQt::setFrame(QWebFrame* webFrame, Frame* frame) +void FrameLoaderClientQt::setFrame(QWebFrameAdapter* webFrame, Frame* frame) { m_webFrame = webFrame; m_frame = frame; - if (!m_webFrame || !m_webFrame->page()) { + if (!m_webFrame || !m_webFrame->pageAdapter) { qWarning("FrameLoaderClientQt::setFrame frame without Page!"); return; } connect(this, SIGNAL(loadProgress(int)), - m_webFrame->page(), SIGNAL(loadProgress(int))); + m_webFrame->pageAdapter->handle(), SIGNAL(loadProgress(int))); connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), - m_webFrame->page(), SIGNAL(unsupportedContent(QNetworkReply*))); + m_webFrame->pageAdapter->handle(), SIGNAL(unsupportedContent(QNetworkReply*))); connect(this, SIGNAL(titleChanged(QString)), - m_webFrame, SIGNAL(titleChanged(QString))); + m_webFrame->handle(), SIGNAL(titleChanged(QString))); } void FrameLoaderClientQt::callPolicyFunction(FramePolicyFunction function, PolicyAction action) @@ -261,11 +260,11 @@ void FrameLoaderClientQt::transitionToCommittedForNewPage() ASSERT(m_frame); ASSERT(m_webFrame); - QBrush brush = m_webFrame->page()->palette().brush(QPalette::Base); + QObject* qWebPage = m_webFrame->pageAdapter->handle(); + QBrush brush = qWebPage->property("palette").value().brush(QPalette::Base); QColor backgroundColor = brush.style() == Qt::SolidPattern ? brush.color() : QColor(); - QWebPage* page = m_webFrame->page(); - const QSize preferredLayoutSize = page->preferredContentsSize(); + const QSize preferredLayoutSize = qWebPage->property("preferredContentsSize").toSize(); ScrollbarMode hScrollbar = (ScrollbarMode) m_webFrame->scrollBarPolicy(Qt::Horizontal); ScrollbarMode vScrollbar = (ScrollbarMode) m_webFrame->scrollBarPolicy(Qt::Vertical); @@ -275,17 +274,18 @@ void FrameLoaderClientQt::transitionToCommittedForNewPage() // The HistoryController will update the scroll position later if needed. IntRect currentVisibleContentRect = m_frame->view() ? IntRect(IntPoint::zero(), m_frame->view()->fixedVisibleContentRect().size()) : IntRect(); - m_frame->createView(m_webFrame->page()->viewportSize(), - backgroundColor, !backgroundColor.alpha(), - preferredLayoutSize.isValid() ? IntSize(preferredLayoutSize) : IntSize(), - currentVisibleContentRect, - preferredLayoutSize.isValid(), - hScrollbar, hLock, - vScrollbar, vLock); + m_frame->createView(qWebPage->property("viewportSize").toSize(), + backgroundColor, !backgroundColor.alpha(), + preferredLayoutSize.isValid() ? IntSize(preferredLayoutSize) : IntSize(), + currentVisibleContentRect, + preferredLayoutSize.isValid(), + hScrollbar, hLock, + vScrollbar, vLock); bool isMainFrame = m_frame == m_frame->page()->mainFrame(); - if (isMainFrame && page->d->client) { - bool resizesToContents = page->d->client->viewResizesToContentsEnabled(); + if (isMainFrame &&m_webFrame->pageAdapter->client) { + bool resizesToContents = m_webFrame->pageAdapter->client->viewResizesToContentsEnabled(); + m_frame->view()->setPaintsEntireContents(resizesToContents); m_frame->view()->setDelegatesScrolling(resizesToContents); } @@ -392,8 +392,8 @@ void FrameLoaderClientQt::dispatchDidChangeLocationWithinPage() if (!m_webFrame) return; - m_webFrame->d->emitUrlChanged(); - m_webFrame->page()->d->updateNavigationActions(); + m_webFrame->emitUrlChanged(); + m_webFrame->pageAdapter->updateNavigationActions(); } @@ -440,7 +440,7 @@ void FrameLoaderClientQt::dispatchDidStartProvisionalLoad() return; emitLoadStarted(); postProgressEstimateChangedNotification(); - emit m_webFrame->provisionalLoad(); + m_webFrame->didStartProvisionalLoad(); } @@ -478,8 +478,8 @@ void FrameLoaderClientQt::dispatchDidCommitLoad() if (m_frame->tree()->parent() || !m_webFrame) return; - m_webFrame->d->emitUrlChanged(); - m_webFrame->page()->d->updateNavigationActions(); + m_webFrame->emitUrlChanged(); + m_webFrame->pageAdapter->updateNavigationActions(); // We should assume first the frame has no title. If it has, then the above dispatchDidReceiveTitle() // will be called very soon with the correct title. @@ -490,7 +490,7 @@ void FrameLoaderClientQt::dispatchDidCommitLoad() if (!isMainFrame) return; - emit m_webFrame->page()->viewportChangeRequested(); + emit m_webFrame->pageAdapter->emitViewportChangeRequested(); } @@ -499,7 +499,7 @@ void FrameLoaderClientQt::dispatchDidFinishDocumentLoad() if (dumpFrameLoaderCallbacks) printf("%s - didFinishDocumentLoadForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame))); - if (QWebPagePrivate::drtRun) { + if (QWebPageAdapter::drtRun) { int unloadEventCount = m_frame->document()->domWindow()->pendingUnloadEventListeners(); if (unloadEventCount) printf("%s - has %u onunload handler(s)\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)), unloadEventCount); @@ -508,7 +508,7 @@ void FrameLoaderClientQt::dispatchDidFinishDocumentLoad() if (m_frame->tree()->parent() || !m_webFrame) return; - m_webFrame->page()->d->updateNavigationActions(); + m_webFrame->pageAdapter->updateNavigationActions(); } @@ -520,7 +520,7 @@ void FrameLoaderClientQt::dispatchDidFinishLoad() if (!m_webFrame) return; - m_webFrame->page()->d->updateNavigationActions(); + m_webFrame->pageAdapter->updateNavigationActions(); emitLoadFinished(true); } @@ -530,7 +530,7 @@ void FrameLoaderClientQt::dispatchDidLayout(LayoutMilestones milestones) return; if (milestones & DidFirstVisuallyNonEmptyLayout) - emit m_webFrame->initialLayoutCompleted(); + m_webFrame->emitInitialLayoutCompleted(); } void FrameLoaderClientQt::dispatchShow() @@ -545,8 +545,7 @@ void FrameLoaderClientQt::cancelPolicyCheck() } -void FrameLoaderClientQt::dispatchWillSubmitForm(FramePolicyFunction function, - PassRefPtr) +void FrameLoaderClientQt::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr) { notImplemented(); // FIXME: This is surely too simple. @@ -560,7 +559,7 @@ void FrameLoaderClientQt::postProgressStartedNotification() m_isOriginatingLoad = true; if (m_frame->tree()->parent() || !m_webFrame) return; - m_webFrame->page()->d->updateNavigationActions(); + m_webFrame->pageAdapter->updateNavigationActions(); } void FrameLoaderClientQt::postProgressEstimateChangedNotification() @@ -577,14 +576,11 @@ void FrameLoaderClientQt::postProgressFinishedNotification() // Send a mousemove event to: // (1) update the cursor to change according to whatever is underneath the mouse cursor right now; // (2) display the tool tip if the mouse hovers a node which has a tool tip. - if (m_frame && m_frame->eventHandler() && m_webFrame->page()) { - QWidget* view = m_webFrame->page()->view(); - if (view && view->hasFocus()) { - QPoint localPos = view->mapFromGlobal(QCursor::pos()); - if (view->rect().contains(localPos)) { - QMouseEvent event(QEvent::MouseMove, localPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier); - m_frame->eventHandler()->mouseMoved(convertMouseEvent(&event, 0)); - } + if (m_frame && m_frame->eventHandler() && m_webFrame) { + QPoint localPos; + if (m_webFrame->handleProgressFinished(&localPos)) { + QMouseEvent event(QEvent::MouseMove, localPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier); + m_frame->eventHandler()->mouseMoved(convertMouseEvent(&event, 0)); } } } @@ -655,7 +651,7 @@ void FrameLoaderClientQt::frameLoadCompleted() // Note that this can be called multiple times. if (!m_webFrame) return; - m_webFrame->page()->d->updateNavigationActions(); + m_webFrame->pageAdapter->updateNavigationActions(); } @@ -663,7 +659,7 @@ void FrameLoaderClientQt::restoreViewState() { if (!m_webFrame) return; - emit m_webFrame->page()->restoreFrameStateRequested(m_webFrame); + m_webFrame->pageAdapter->emitRestoreFrameStateRequested(m_webFrame); } @@ -700,21 +696,23 @@ void FrameLoaderClientQt::setTitle(const StringWithDirection& title, const KURL& String FrameLoaderClientQt::userAgent(const KURL& url) { - if (m_webFrame) { - return m_webFrame->page()->userAgentForUrl(url).remove(QLatin1Char('\n')).remove(QLatin1Char('\r')); - } + if (m_webFrame) + return m_webFrame->pageAdapter->userAgentForUrl(url).remove(QLatin1Char('\n')).remove(QLatin1Char('\r')); return String(); } void FrameLoaderClientQt::dispatchDidReceiveIcon() { if (m_webFrame) - emit m_webFrame->iconChanged(); + m_webFrame->emitIconChanged(); } void FrameLoaderClientQt::frameLoaderDestroyed() { - delete m_webFrame; + // Delete QWebFrame (handle()), which owns QWebFramePrivate, which + // _is_ a QWebFrameAdapter. + if (m_webFrame) + delete m_webFrame->handle(); m_frame = 0; m_webFrame = 0; @@ -732,7 +730,7 @@ void FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* w return; if (m_webFrame) - m_webFrame->d->didClearWindowObject(); + m_webFrame->didClearWindowObject(); } void FrameLoaderClientQt::documentElementAvailable() @@ -744,7 +742,7 @@ void FrameLoaderClientQt::didPerformFirstNavigation() const { if (m_frame->tree()->parent() || !m_webFrame) return; - m_webFrame->page()->d->updateNavigationActions(); + m_webFrame->pageAdapter->updateNavigationActions(); } void FrameLoaderClientQt::registerForIconNotification(bool shouldRegister) @@ -760,8 +758,8 @@ void FrameLoaderClientQt::registerForIconNotification(bool shouldRegister) void FrameLoaderClientQt::onIconLoadedForPageURL(const QString& url) { #if ENABLE(ICONDATABASE) - if (m_webFrame && m_webFrame->url() == url) - emit m_webFrame->iconChanged(); + if (m_webFrame && m_webFrame->url == url) + m_webFrame->emitIconChanged(); #endif } @@ -799,16 +797,16 @@ void FrameLoaderClientQt::updateGlobalHistoryRedirectLinks() if (!loader->clientRedirectSourceForHistory().isNull()) { if (dumpHistoryCallbacks) { printf("WebView performed a client redirect from \"%s\" to \"%s\".\n", - qPrintable(QString(loader->clientRedirectSourceForHistory())), - qPrintable(QString(loader->clientRedirectDestinationForHistory()))); + qPrintable(QString(loader->clientRedirectSourceForHistory())), + qPrintable(QString(loader->clientRedirectDestinationForHistory()))); } } if (!loader->serverRedirectSourceForHistory().isNull()) { if (dumpHistoryCallbacks) { printf("WebView performed a server redirect from \"%s\" to \"%s\".\n", - qPrintable(QString(loader->serverRedirectSourceForHistory())), - qPrintable(QString(loader->serverRedirectDestinationForHistory()))); + qPrintable(QString(loader->serverRedirectSourceForHistory())), + qPrintable(QString(loader->serverRedirectDestinationForHistory()))); } } } @@ -850,7 +848,7 @@ void FrameLoaderClientQt::didDetectXSS(const KURL&, bool) void FrameLoaderClientQt::saveViewStateToItem(WebCore::HistoryItem* item) { QWebHistoryItem historyItem(new QWebHistoryItemPrivate(item)); - emit m_webFrame->page()->saveFrameStateRequested(m_webFrame, &historyItem); + m_webFrame->pageAdapter->emitSaveFrameStateRequested(m_webFrame, &historyItem); } bool FrameLoaderClientQt::canCachePage() const @@ -896,7 +894,7 @@ void FrameLoaderClientQt::committedLoad(WebCore::DocumentLoader* loader, const c WebCore::ResourceError FrameLoaderClientQt::cancelledError(const WebCore::ResourceRequest& request) { ResourceError error = ResourceError("QtNetwork", QNetworkReply::OperationCanceledError, request.url().string(), - QCoreApplication::translate("QWebFrame", "Request cancelled", 0)); + QCoreApplication::translate("QWebFrame", "Request cancelled", 0)); error.setIsCancellation(true); return error; } @@ -916,38 +914,38 @@ enum { WebCore::ResourceError FrameLoaderClientQt::blockedError(const WebCore::ResourceRequest& request) { return ResourceError("WebKitErrorDomain", WebKitErrorCannotUseRestrictedPort, request.url().string(), - QCoreApplication::translate("QWebFrame", "Request blocked", 0)); + QCoreApplication::translate("QWebFrame", "Request blocked", 0)); } WebCore::ResourceError FrameLoaderClientQt::cannotShowURLError(const WebCore::ResourceRequest& request) { return ResourceError("WebKitErrorDomain", WebKitErrorCannotShowURL, request.url().string(), - QCoreApplication::translate("QWebFrame", "Cannot show URL", 0)); + QCoreApplication::translate("QWebFrame", "Cannot show URL", 0)); } WebCore::ResourceError FrameLoaderClientQt::interruptedForPolicyChangeError(const WebCore::ResourceRequest& request) { return ResourceError("WebKitErrorDomain", WebKitErrorFrameLoadInterruptedByPolicyChange, request.url().string(), - QCoreApplication::translate("QWebFrame", "Frame load interrupted by policy change", 0)); + QCoreApplication::translate("QWebFrame", "Frame load interrupted by policy change", 0)); } WebCore::ResourceError FrameLoaderClientQt::cannotShowMIMETypeError(const WebCore::ResourceResponse& response) { return ResourceError("WebKitErrorDomain", WebKitErrorCannotShowMIMEType, response.url().string(), - QCoreApplication::translate("QWebFrame", "Cannot show mimetype", 0)); + QCoreApplication::translate("QWebFrame", "Cannot show mimetype", 0)); } WebCore::ResourceError FrameLoaderClientQt::fileDoesNotExistError(const WebCore::ResourceResponse& response) { return ResourceError("QtNetwork", QNetworkReply::ContentNotFoundError, response.url().string(), - QCoreApplication::translate("QWebFrame", "File does not exist", 0)); + QCoreApplication::translate("QWebFrame", "File does not exist", 0)); } WebCore::ResourceError FrameLoaderClientQt::pluginWillHandleLoadError(const WebCore::ResourceResponse& response) { return ResourceError("WebKit", WebKitErrorPluginWillHandleLoad, response.url().string(), - QCoreApplication::translate("QWebFrame", "Loading is handled by the media engine", 0)); + QCoreApplication::translate("QWebFrame", "Loading is handled by the media engine", 0)); } bool FrameLoaderClientQt::shouldFallBack(const WebCore::ResourceError& error) @@ -991,8 +989,7 @@ void FrameLoaderClientQt::download(WebCore::ResourceHandle* handle, const WebCor QNetworkReplyHandler* handler = handle->getInternal()->m_job; QNetworkReply* reply = handler->release(); if (reply) { - QWebPage* page = m_webFrame->page(); - if (page->forwardUnsupportedContent()) + if (m_webFrame->pageAdapter->forwardUnsupportedContent) emit unsupportedContent(reply); else reply->abort(); @@ -1024,9 +1021,9 @@ void FrameLoaderClientQt::dispatchWillSendRequest(WebCore::DocumentLoader*, unsi { if (dumpResourceLoadCallbacks) printf("%s - willSendRequest %s redirectResponse %s\n", - qPrintable(dumpAssignedUrls[identifier]), - qPrintable(drtDescriptionSuitableForTestResult(newRequest)), - (redirectResponse.isNull()) ? "(null)" : qPrintable(drtDescriptionSuitableForTestResult(redirectResponse))); + qPrintable(dumpAssignedUrls[identifier]), + qPrintable(drtDescriptionSuitableForTestResult(newRequest)), + (redirectResponse.isNull()) ? "(null)" : qPrintable(drtDescriptionSuitableForTestResult(redirectResponse))); if (sendRequestReturnsNull) { blockRequest(newRequest); @@ -1043,11 +1040,11 @@ void FrameLoaderClientQt::dispatchWillSendRequest(WebCore::DocumentLoader*, unsi QString host = url.host(); QString urlScheme = url.scheme().toLower(); - if (QWebPagePrivate::drtRun + if (QWebPageAdapter::drtRun && !host.isEmpty() && (urlScheme == QLatin1String("http") || urlScheme == QLatin1String("https"))) { - QUrl testURL = m_webFrame->page()->mainFrame()->requestedUrl(); + QUrl testURL = m_webFrame->pageAdapter->mainFrameAdapter()->frameLoaderClient->lastRequestedUrl(); QString testHost = testURL.host(); QString testURLScheme = testURL.scheme().toLower(); @@ -1061,9 +1058,9 @@ void FrameLoaderClientQt::dispatchWillSendRequest(WebCore::DocumentLoader*, unsi } for (int i = 0; i < sendRequestClearHeaders.size(); ++i) - newRequest.setHTTPHeaderField(sendRequestClearHeaders.at(i).toLocal8Bit().constData(), QString()); + newRequest.setHTTPHeaderField(sendRequestClearHeaders.at(i).toLocal8Bit().constData(), QString()); - if (QWebPagePrivate::drtRun) { + if (QWebPageAdapter::drtRun) { QMap::const_iterator it = URLsToRedirect.constFind(url.toString()); if (it != URLsToRedirect.constEnd()) newRequest.setURL(QUrl(it.value())); @@ -1094,17 +1091,17 @@ void FrameLoaderClientQt::dispatchDidReceiveResponse(WebCore::DocumentLoader*, u m_response = response; if (dumpWillCacheResponseCallbacks) printf("%s - willCacheResponse: called\n", - qPrintable(dumpAssignedUrls[identifier])); + qPrintable(dumpAssignedUrls[identifier])); if (dumpResourceLoadCallbacks) printf("%s - didReceiveResponse %s\n", - qPrintable(dumpAssignedUrls[identifier]), - qPrintable(drtDescriptionSuitableForTestResult(response))); + qPrintable(dumpAssignedUrls[identifier]), + qPrintable(drtDescriptionSuitableForTestResult(response))); if (dumpResourceResponseMIMETypes) { printf("%s has MIME type %s\n", - qPrintable(QString(response.url().lastPathComponent())), - qPrintable(QString(response.mimeType()))); + qPrintable(QString(response.url().lastPathComponent())), + qPrintable(QString(response.mimeType()))); } } @@ -1116,15 +1113,15 @@ void FrameLoaderClientQt::dispatchDidFinishLoading(WebCore::DocumentLoader*, uns { if (dumpResourceLoadCallbacks) printf("%s - didFinishLoading\n", - (dumpAssignedUrls.contains(identifier) ? qPrintable(dumpAssignedUrls[identifier]) : "")); + (dumpAssignedUrls.contains(identifier) ? qPrintable(dumpAssignedUrls[identifier]) : "")); } void FrameLoaderClientQt::dispatchDidFailLoading(WebCore::DocumentLoader* loader, unsigned long identifier, const WebCore::ResourceError& error) { if (dumpResourceLoadCallbacks) printf("%s - didFailLoadingWithError: %s\n", - (dumpAssignedUrls.contains(identifier) ? qPrintable(dumpAssignedUrls[identifier]) : ""), - qPrintable(drtDescriptionSuitableForTestResult(error))); + (dumpAssignedUrls.contains(identifier) ? qPrintable(dumpAssignedUrls[identifier]) : ""), + qPrintable(drtDescriptionSuitableForTestResult(error))); } bool FrameLoaderClientQt::dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int) @@ -1135,27 +1132,19 @@ bool FrameLoaderClientQt::dispatchDidLoadResourceFromMemoryCache(WebCore::Docume bool FrameLoaderClientQt::callErrorPageExtension(const WebCore::ResourceError& error) { - QWebPage* page = m_webFrame->page(); - if (!page->supportsExtension(QWebPage::ErrorPageExtension)) + QWebPageAdapter* page = m_webFrame->pageAdapter; + if (!page->supportsErrorPageExtension()) return false; - - QWebPage::ErrorPageExtensionOption option; - if (error.domain() == "QtNetwork") - option.domain = QWebPage::QtNetwork; - else if (error.domain() == "HTTP") - option.domain = QWebPage::Http; - else if (error.domain() == "WebKit") - option.domain = QWebPage::WebKit; - else - return false; - + QWebPageAdapter::ErrorPageOption option; option.url = QUrl(error.failingURL()); option.frame = m_webFrame; + option.domain = error.domain(); option.error = error.errorCode(); option.errorString = error.localizedDescription(); - QWebPage::ErrorPageExtensionReturn output; - if (!page->extension(QWebPage::ErrorPageExtension, &option, &output)) + QWebPageAdapter::ErrorPageReturn output; + + if (!page->errorPageExtension(&option, &output)) return false; KURL baseUrl(output.baseUrl); @@ -1200,10 +1189,10 @@ WebCore::Frame* FrameLoaderClientQt::dispatchCreatePage(const WebCore::Navigatio { if (!m_webFrame) return 0; - QWebPage *newPage = m_webFrame->page()->createWindow(QWebPage::WebBrowserWindow); + QWebPageAdapter* newPage = m_webFrame->pageAdapter->createWindow(/* modalDialog = */ false); if (!newPage) return 0; - return newPage->mainFrame()->d->frame; + return newPage->mainFrameAdapter()->frame; } void FrameLoaderClientQt::dispatchDecidePolicyForResponse(FramePolicyFunction function, const WebCore::ResourceResponse& response, const WebCore::ResourceRequest&) @@ -1230,9 +1219,8 @@ void FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction(FramePolicyFunc { Q_ASSERT(m_webFrame); QNetworkRequest r(request.toNetworkRequest(m_frame->loader()->networkingContext())); - QWebPage* page = m_webFrame->page(); - if (!page->d->acceptNavigationRequest(0, r, QWebPage::NavigationType(action.type()))) { + if (!m_webFrame->pageAdapter->acceptNavigationRequest(0, r, (int)action.type())) { if (action.type() == NavigationTypeFormSubmitted || action.type() == NavigationTypeFormResubmitted) m_frame->loader()->resetMultipleFormSubmissionProtection(); @@ -1251,7 +1239,6 @@ void FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction(FramePolicyFun { Q_ASSERT(m_webFrame); QNetworkRequest r(request.toNetworkRequest(m_frame->loader()->networkingContext())); - QWebPage*page = m_webFrame->page(); PolicyAction result; // Currently, this is only enabled by DRT. @@ -1260,27 +1247,27 @@ void FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction(FramePolicyFun for (const Event* event = action.event(); event; event = event->underlyingEvent()) { if (event->isMouseEvent()) { const MouseEvent* mouseEvent = static_cast(event); - node = QWebFramePrivate::core(m_webFrame)->eventHandler()->hitTestResultAtPoint( + node = m_webFrame->frame->eventHandler()->hitTestResultAtPoint( mouseEvent->absoluteLocation(), false).innerNonSharedNode(); break; } } printf("Policy delegate: attempt to load %s with navigation type '%s'%s\n", - qPrintable(drtDescriptionSuitableForTestResult(request.url())), navigationTypeToString(action.type()), - (node) ? qPrintable(QString::fromLatin1(" originating from ") + drtDescriptionSuitableForTestResult(node, 0)) : ""); + qPrintable(drtDescriptionSuitableForTestResult(request.url())), navigationTypeToString(action.type()), + (node) ? qPrintable(QString::fromLatin1(" originating from ") + drtDescriptionSuitableForTestResult(node, 0)) : ""); if (policyDelegatePermissive) result = PolicyUse; else result = PolicyIgnore; - page->d->acceptNavigationRequest(m_webFrame, r, QWebPage::NavigationType(action.type())); + m_webFrame->pageAdapter->acceptNavigationRequest(m_webFrame, r, (int)action.type()); callPolicyFunction(function, result); return; } - if (!page->d->acceptNavigationRequest(m_webFrame, r, QWebPage::NavigationType(action.type()))) { + if (!m_webFrame->pageAdapter->acceptNavigationRequest(m_webFrame, r, (int)action.type())) { if (action.type() == NavigationTypeFormSubmitted || action.type() == NavigationTypeFormResubmitted) m_frame->loader()->resetMultipleFormSubmissionProtection(); @@ -1305,40 +1292,39 @@ void FrameLoaderClientQt::startDownload(const WebCore::ResourceRequest& request, if (!m_webFrame) return; - emit m_webFrame->page()->downloadRequested(request.toNetworkRequest(m_frame->loader()->networkingContext())); + m_webFrame->pageAdapter->emitDownloadRequested(request.toNetworkRequest(m_frame->loader()->networkingContext())); } -PassRefPtr FrameLoaderClientQt::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, - const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) +PassRefPtr FrameLoaderClientQt::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) { if (!m_webFrame) return 0; QWebFrameData frameData(m_frame->page(), m_frame, ownerElement, name); - if (url.isEmpty()) - frameData.url = blankURL(); - else - frameData.url = url; - frameData.referrer = referrer; frameData.allowsScrolling = allowsScrolling; frameData.marginWidth = marginWidth; frameData.marginHeight = marginHeight; - QPointer webFrame = new QWebFrame(m_webFrame, &frameData); + QWebFrameAdapter* childWebFrame = m_webFrame->createChildFrame(&frameData); // The creation of the frame may have run arbitrary JavaScript that removed it from the page already. - if (!webFrame.data()->d->frame->page()) { + if (!childWebFrame->frame->page()) { + QPointer qWebFrame = childWebFrame->handle(); frameData.frame.release(); - ASSERT(webFrame.isNull()); + ASSERT_UNUSED(qWebFrame, !qWebFrame); return 0; } - emit m_webFrame->page()->frameCreated(webFrame.data()); + m_webFrame->pageAdapter->emitFrameCreated(childWebFrame); // FIXME: Set override encoding if we have one. - m_frame->loader()->loadURLIntoChildFrame(frameData.url, frameData.referrer, frameData.frame.get()); + KURL urlToLoad = url; + if (urlToLoad.isEmpty()) + urlToLoad = blankURL(); + + m_frame->loader()->loadURLIntoChildFrame(urlToLoad, frameData.referrer, frameData.frame.get()); // The frame's onload handler may have removed it from the document. if (!frameData.frame->tree()->parent()) @@ -1399,44 +1385,45 @@ static const CSSPropertyID qstyleSheetProperties[] = { const unsigned numqStyleSheetProperties = sizeof(qstyleSheetProperties) / sizeof(qstyleSheetProperties[0]); -class QtPluginWidget: public Widget -{ +class QtPluginWidget: public Widget { public: - QtPluginWidget(QWidget* w = 0): Widget(w) {} + QtPluginWidget(QtPluginWidgetAdapter* w) + : Widget(w->handle()) + , m_adapter(w) + { + setBindingObject(w->handle()); + } + ~QtPluginWidget() { - if (platformWidget()) - platformWidget()->deleteLater(); + delete m_adapter; } + + inline QtPluginWidgetAdapter* widgetAdapter() const + { + return m_adapter; + } + virtual void invalidateRect(const IntRect& r) { if (platformWidget()) - static_cast(platformWidget())->update(r); + widgetAdapter()->update(r); } virtual void frameRectsChanged() { - QWidget* widget = static_cast(platformWidget()); + QtPluginWidgetAdapter* widget = widgetAdapter(); if (!widget) return; - - IntRect windowRect = convertToContainingWindow(IntRect(0, 0, frameRect().width(), frameRect().height())); - widget->setGeometry(windowRect); + QRect windowRect = convertToContainingWindow(IntRect(0, 0, frameRect().width(), frameRect().height())); ScrollView* parentScrollView = parent(); - if (!parentScrollView) - return; - - ASSERT(parentScrollView->isFrameView()); - IntRect clipRect(static_cast(parentScrollView)->windowClipRect()); - clipRect.move(-windowRect.x(), -windowRect.y()); - clipRect.intersect(widget->rect()); - - QRegion clipRegion = QRegion(clipRect); - widget->setMask(clipRegion); - - handleVisibility(); - - widget->update(); + QRect clipRect; + if (parentScrollView) { + ASSERT(parentScrollView->isFrameView()); + clipRect = static_cast(parentScrollView)->windowClipRect(); + clipRect.translate(-windowRect.x(), -windowRect.y()); + } + widget->setGeometryAndClip(windowRect, clipRect, isVisible()); } virtual void show() @@ -1444,75 +1431,25 @@ class QtPluginWidget: public Widget Widget::show(); handleVisibility(); } + virtual void hide() + { + if (platformWidget()) + widgetAdapter()->setVisible(false); + } private: + QtPluginWidgetAdapter* m_adapter; + void handleVisibility() { if (!isVisible()) return; - - QWidget* widget = static_cast(platformWidget()); - // If setMask is set with an empty QRegion, no clipping will - // be performed, so in that case we hide the platformWidget. - QRegion mask = widget->mask(); - widget->setVisible(!mask.isEmpty()); + widgetAdapter()->setVisible(true); } }; -#if !defined(QT_NO_GRAPHICSVIEW) -class QtPluginGraphicsWidget: public Widget -{ -public: - static RefPtr create(QGraphicsWidget* w = 0) - { - return adoptRef(new QtPluginGraphicsWidget(w)); - } - ~QtPluginGraphicsWidget() - { - if (graphicsWidget) - graphicsWidget->deleteLater(); - } - virtual void invalidateRect(const IntRect& r) - { - QGraphicsScene* scene = graphicsWidget ? graphicsWidget->scene() : 0; - if (scene) - scene->update(QRect(r)); - } - virtual void frameRectsChanged() - { - if (!graphicsWidget) - return; - - IntRect windowRect = convertToContainingWindow(IntRect(0, 0, frameRect().width(), frameRect().height())); - graphicsWidget->setGeometry(QRect(windowRect)); - - // FIXME: Make the code handle clipping of graphics widgets. - } - virtual void show() - { - if (graphicsWidget) - graphicsWidget->show(); - } - virtual void hide() - { - if (graphicsWidget) - graphicsWidget->hide(); - } -private: - QtPluginGraphicsWidget(QGraphicsWidget* w = 0) - : Widget(0) - , graphicsWidget(w) - { - setBindingObject(graphicsWidget); - } - - QGraphicsWidget* graphicsWidget; -}; -#endif // QT_NO_GRAPHICSVIEW - -PassRefPtr FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, HTMLPlugInElement* element, const KURL& url, const Vector& paramNames, - const Vector& paramValues, const String& mimeType, bool loadManually) +PassRefPtr FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, HTMLPlugInElement* element, const KURL& url, const Vector& paramNames, const Vector& paramValues, const String& mimeType, bool loadManually) { // qDebug()<<"------ Creating plugin in FrameLoaderClientQt::createPlugin for "<page()->createPlugin(classid, qurl, params, values); + pluginAdapter = m_webFrame->pageAdapter->createPlugin(classid, qurl, params, values); #ifndef QT_NO_STYLE_STYLESHEET - QWidget* widget = qobject_cast(object); + QtPluginWidgetAdapter* widget = qobject_cast(pluginAdapter); if (widget && mimeType == "application/x-qt-styled-widget") { - QString styleSheet = element->getAttribute("style"); + StringBuilder styleSheet; + styleSheet.append(element->getAttribute("style")); if (!styleSheet.isEmpty()) - styleSheet += QLatin1Char(';'); + styleSheet.append(';'); for (unsigned i = 0; i < numqStyleSheetProperties; ++i) { CSSPropertyID property = qstyleSheetProperties[i]; - styleSheet += QString::fromLatin1(getPropertyName(property)); - styleSheet += QLatin1Char(':'); - styleSheet += CSSComputedStyleDeclaration::create(element)->getPropertyValue(property); - styleSheet += QLatin1Char(';'); + styleSheet.append(getPropertyName(property)); + styleSheet.append(':'); + styleSheet.append(CSSComputedStyleDeclaration::create(element)->getPropertyValue(property)); + styleSheet.append(';'); } - widget->setStyleSheet(styleSheet); + widget->setStyleSheet(styleSheet.toString()); } #endif // QT_NO_STYLE_STYLESHEET } - if (!object) { - QWebPluginFactory* factory = m_webFrame->page()->pluginFactory(); + if (!pluginAdapter) { + QWebPluginFactory* factory = m_webFrame->pageAdapter->pluginFactory; if (factory) - object = factory->create(mimeType, qurl, params, values); + pluginAdapter = m_webFrame->pageAdapter->adapterForWidget(factory->create(mimeType, qurl, params, values)); } - - if (object) { - QWidget* widget = qobject_cast(object); + if (pluginAdapter) { + QtPluginWidgetAdapter* widget = qobject_cast(pluginAdapter); if (widget) { - QWidget* parentWidget = 0; - if (m_webFrame->page()->d->client) - parentWidget = qobject_cast(m_webFrame->page()->d->client->pluginParent()); + QObject* parentWidget = 0; + if (m_webFrame->pageAdapter->client) + parentWidget = m_webFrame->pageAdapter->client->pluginParent(); if (parentWidget) // Don't reparent to nothing (i.e. keep whatever parent QWebPage::createPlugin() chose. - widget->setParent(parentWidget); - widget->hide(); - RefPtr w = adoptRef(new QtPluginWidget()); - w->setPlatformWidget(widget); + widget->setWidgetParent(parentWidget); + widget->setVisible(false); + RefPtr w = adoptRef(new QtPluginWidget(widget)); // Make sure it's invisible until properly placed into the layout. w->setFrameRect(IntRect(0, 0, 0, 0)); return w; } -#if !defined(QT_NO_GRAPHICSVIEW) - QGraphicsWidget* graphicsWidget = qobject_cast(object); - if (graphicsWidget) { - QGraphicsObject* parentWidget = 0; - if (m_webFrame->page()->d->client) - parentWidget = qobject_cast(m_webFrame->page()->d->client->pluginParent()); - graphicsWidget->hide(); - if (parentWidget) // Don't reparent to nothing (i.e. keep whatever parent QWebPage::createPlugin() chose. - graphicsWidget->setParentItem(parentWidget); - RefPtr w = QtPluginGraphicsWidget::create(graphicsWidget); - // Make sure it's invisible until properly placed into the layout. - w->setFrameRect(IntRect(0, 0, 0, 0)); - return w; - } -#endif // QT_NO_GRAPHICSVIEW - // FIXME: Make things work for widgetless plugins as well. - delete object; + delete pluginAdapter; } #if ENABLE(NETSCAPE_PLUGIN_API) else { // NPAPI Plugins @@ -1632,8 +1552,7 @@ void FrameLoaderClientQt::redirectDataToPlugin(Widget* pluginWidget) m_hasSentResponseToPlugin = false; } -PassRefPtr FrameLoaderClientQt::createJavaAppletWidget(const IntSize& pluginSize, HTMLAppletElement* element, const KURL& url, - const Vector& paramNames, const Vector& paramValues) +PassRefPtr FrameLoaderClientQt::createJavaAppletWidget(const IntSize& pluginSize, HTMLAppletElement* element, const KURL& url, const Vector& paramNames, const Vector& paramValues) { return createPlugin(pluginSize, element, url, paramNames, paramValues, "application/x-java-applet", true); } @@ -1645,23 +1564,26 @@ String FrameLoaderClientQt::overrideMediaType() const QString FrameLoaderClientQt::chooseFile(const QString& oldFile) { - return m_webFrame->page()->chooseFile(m_webFrame, oldFile); + QStringList result = m_webFrame->pageAdapter->chooseFiles(m_webFrame, /*allowMulti*/ false, (QStringList() << oldFile)); + return result.isEmpty() ? QString() : result.first(); } PassRefPtr FrameLoaderClientQt::createNetworkingContext() { - QVariant value = m_webFrame->page()->property("_q_MIMESniffingDisabled"); + QVariant value = m_webFrame->pageAdapter->handle()->property("_q_MIMESniffingDisabled"); bool MIMESniffingDisabled = value.isValid() && value.toBool(); - return FrameNetworkingContextQt::create(m_frame, m_webFrame, !MIMESniffingDisabled, m_webFrame->page()->networkAccessManager()); + return FrameNetworkingContextQt::create(m_frame, m_webFrame->handle(), !MIMESniffingDisabled); +} + +QWebFrameAdapter* FrameLoaderClientQt::webFrame() const +{ + return m_webFrame; } void FrameLoaderClientQt::emitLoadStarted() { - QWebPage* webPage = m_webFrame->page(); - if (m_isOriginatingLoad && webPage) - emit webPage->loadStarted(); - emit m_webFrame->loadStarted(); + m_webFrame->emitLoadStarted(m_isOriginatingLoad); } void FrameLoaderClientQt::emitLoadFinished(bool ok) @@ -1670,10 +1592,7 @@ void FrameLoaderClientQt::emitLoadFinished(bool ok) const bool wasOriginatingLoad = m_isOriginatingLoad; m_isOriginatingLoad = false; - QWebPage* webPage = m_webFrame->page(); - if (wasOriginatingLoad && webPage) - emit webPage->loadFinished(ok); - emit m_webFrame->loadFinished(ok); + m_webFrame->emitLoadFinished(wasOriginatingLoad, ok); } } diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h index 03102de3e2b..a965de0fbb7 100644 --- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h @@ -30,14 +30,13 @@ #ifndef FrameLoaderClientQt_h #define FrameLoaderClientQt_h - #include "Frame.h" #include "FrameLoader.h" #include "FrameLoaderClient.h" #include "KURL.h" -#include "WebCore/plugins/PluginView.h" #include "ResourceError.h" #include "ResourceResponse.h" +#include "WebCore/plugins/PluginView.h" #include #include #include @@ -49,6 +48,7 @@ class QNetworkReply; QT_END_NAMESPACE class QWebFrame; +class QWebFrameAdapter; namespace WebCore { @@ -65,8 +65,8 @@ struct LoadErrorResetToken; class FrameLoaderClientQt : public QObject, public FrameLoaderClient { Q_OBJECT - friend class ::QWebFrame; - void callPolicyFunction(FramePolicyFunction function, PolicyAction action); + friend class ::QWebFrameAdapter; + void callPolicyFunction(FramePolicyFunction, PolicyAction); bool callErrorPageExtension(const ResourceError&); Q_SIGNALS: @@ -79,7 +79,7 @@ class FrameLoaderClientQt : public QObject, public FrameLoaderClient { ~FrameLoaderClientQt(); virtual void frameLoaderDestroyed(); - void setFrame(QWebFrame* webFrame, Frame* frame); + void setFrame(QWebFrameAdapter*, Frame*); virtual bool hasWebView() const; // mainly for assertions @@ -128,9 +128,9 @@ class FrameLoaderClientQt : public QObject, public FrameLoaderClient { virtual WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&); virtual void dispatchShow(); - virtual void dispatchDecidePolicyForResponse(FramePolicyFunction function, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&); - virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr, const WTF::String&); - virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr); + virtual void dispatchDecidePolicyForResponse(FramePolicyFunction, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&); + virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr, const WTF::String&); + virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr); virtual void cancelPolicyCheck(); virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&); @@ -204,8 +204,7 @@ class FrameLoaderClientQt : public QObject, public FrameLoaderClient { virtual bool canCachePage() const; virtual void download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&); - virtual PassRefPtr createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, - const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight); + virtual PassRefPtr createFrame(const KURL&, const String& name, HTMLFrameOwnerElement*, const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight); virtual PassRefPtr createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector&, const Vector&, const String&, bool); virtual void recreatePlugin(Widget*) { } virtual void redirectDataToPlugin(Widget* pluginWidget); @@ -227,6 +226,8 @@ class FrameLoaderClientQt : public QObject, public FrameLoaderClient { const KURL& lastRequestedUrl() const { return m_lastRequestedUrl; } + QWebFrameAdapter* webFrame() const; + static bool dumpFrameLoaderCallbacks; static bool dumpProgressFinishedCallback; static bool dumpUserGestureInFrameLoaderCallbacks; @@ -251,7 +252,7 @@ private Q_SLOTS: void emitLoadFinished(bool ok); Frame *m_frame; - QWebFrame *m_webFrame; + QWebFrameAdapter *m_webFrame; ResourceResponse m_response; // Plugin view to redirect data to diff --git a/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.cpp b/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.cpp index 7e99624b583..0745a1a36e2 100644 --- a/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.cpp @@ -18,29 +18,27 @@ */ #include "config.h" - #include "FrameNetworkingContextQt.h" -#include "qwebframe.h" -#include "qwebframe_p.h" -#include "qwebpage.h" +#include "QWebPageAdapter.h" +#include "qwebsettings.h" + #include #include #include namespace WebCore { -FrameNetworkingContextQt::FrameNetworkingContextQt(Frame* frame, QObject* originatingObject, bool mimeSniffingEnabled, QNetworkAccessManager* networkAccessManager) +FrameNetworkingContextQt::FrameNetworkingContextQt(Frame* frame, QObject* originatingObject, bool mimeSniffingEnabled) : FrameNetworkingContext(frame) , m_originatingObject(originatingObject) - , m_networkAccessManager(networkAccessManager) , m_mimeSniffingEnabled(mimeSniffingEnabled) { } -PassRefPtr FrameNetworkingContextQt::create(Frame* frame, QObject* originatingObject, bool mimeSniffingEnabled, QNetworkAccessManager* networkAccessManager) +PassRefPtr FrameNetworkingContextQt::create(Frame* frame, QObject* originatingObject, bool mimeSniffingEnabled) { - return adoptRef(new FrameNetworkingContextQt(frame, originatingObject, mimeSniffingEnabled, networkAccessManager)); + return adoptRef(new FrameNetworkingContextQt(frame, originatingObject, mimeSniffingEnabled)); } QObject* FrameNetworkingContextQt::originatingObject() const @@ -50,7 +48,7 @@ QObject* FrameNetworkingContextQt::originatingObject() const QNetworkAccessManager* FrameNetworkingContextQt::networkAccessManager() const { - return (qobject_cast(m_originatingObject))->page()->networkAccessManager(); + return QWebPageAdapter::kit(frame()->page())->networkAccessManager(); } bool FrameNetworkingContextQt::mimeSniffingEnabled() const diff --git a/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.h b/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.h index c95e630ac21..b58abe48d9b 100644 --- a/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.h +++ b/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.h @@ -26,10 +26,10 @@ namespace WebCore { class FrameNetworkingContextQt : public FrameNetworkingContext { public: - static PassRefPtr create(Frame*, QObject* originatingObject, bool mimeSniffingEnabled, QNetworkAccessManager*); + static PassRefPtr create(Frame*, QObject* originatingObject, bool mimeSniffingEnabled); private: - FrameNetworkingContextQt(Frame*, QObject* originatingObject, bool mimeSniffingEnabled, QNetworkAccessManager*); + FrameNetworkingContextQt(Frame*, QObject* originatingObject, bool mimeSniffingEnabled); virtual QObject* originatingObject() const; virtual QNetworkAccessManager* networkAccessManager() const; @@ -37,7 +37,6 @@ class FrameNetworkingContextQt : public FrameNetworkingContext { virtual bool thirdPartyCookiePolicyPermission(const QUrl&) const; QObject* m_originatingObject; - QNetworkAccessManager* m_networkAccessManager; bool m_mimeSniffingEnabled; }; diff --git a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp index 3b244c65733..25e357aba52 100644 --- a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp @@ -23,7 +23,6 @@ #include "ChromeClientQt.h" #if USE(QT_MULTIMEDIA) -#include "FullScreenVideoWidget.h" #include "MediaPlayerPrivateQt.h" #endif #include "HTMLNames.h" @@ -40,10 +39,8 @@ #endif #if USE(QT_MULTIMEDIA) -#include #include #endif -#include namespace WebCore { @@ -90,49 +87,6 @@ void GStreamerFullScreenVideoHandler::exitFullScreen() } #endif -#if USE(QT_MULTIMEDIA) -bool DefaultFullScreenVideoHandler::s_shouldForceFullScreenVideoPlayback = false; - -DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler() - : QWebFullScreenVideoHandler() - , m_fullScreenWidget(new FullScreenVideoWidget) -{ - connect(m_fullScreenWidget, SIGNAL(didExitFullScreen()), this, SIGNAL(fullScreenClosed())); - m_fullScreenWidget->hide(); - - m_fullScreenWidget->close(); -} - -DefaultFullScreenVideoHandler::~DefaultFullScreenVideoHandler() -{ - delete m_fullScreenWidget; -} - -bool DefaultFullScreenVideoHandler::requiresFullScreenForVideoPlayback() const -{ - static bool initialized = false; - if (!initialized) { - QByteArray forceFullScreen = qgetenv("QT_WEBKIT_FORCE_FULLSCREEN_VIDEO"); - if (!forceFullScreen.isEmpty()) - s_shouldForceFullScreenVideoPlayback = true; - - initialized = true; - } - - return s_shouldForceFullScreenVideoPlayback; -} - -void DefaultFullScreenVideoHandler::enterFullScreen(QMediaPlayer* player) -{ - m_fullScreenWidget->show(player); -} - -void DefaultFullScreenVideoHandler::exitFullScreen() -{ - m_fullScreenWidget->close(); -} -#endif - FullScreenVideoQt::FullScreenVideoQt(ChromeClientQt* chromeClient) : m_chromeClient(chromeClient) , m_videoElement(0) @@ -140,10 +94,7 @@ FullScreenVideoQt::FullScreenVideoQt(ChromeClientQt* chromeClient) Q_ASSERT(m_chromeClient); #if USE(QT_MULTIMEDIA) - m_FullScreenVideoHandler = m_chromeClient->m_platformPlugin.createFullScreenVideoHandler().leakPtr(); - if (!m_FullScreenVideoHandler) - m_FullScreenVideoHandler = new DefaultFullScreenVideoHandler; - + m_FullScreenVideoHandler = m_chromeClient->createFullScreenVideoHandler(); if (m_FullScreenVideoHandler) connect(m_FullScreenVideoHandler, SIGNAL(fullScreenClosed()), this, SLOT(aboutToClose())); #endif diff --git a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h index 34bc90c0d8c..81a288da572 100644 --- a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h +++ b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h @@ -65,25 +65,6 @@ public Q_SLOTS: }; #endif -// We do not use ENABLE or USE because moc does not expand these macros. -#if defined(WTF_USE_QT_MULTIMEDIA) && WTF_USE_QT_MULTIMEDIA -class DefaultFullScreenVideoHandler : public QWebFullScreenVideoHandler { - Q_OBJECT -public: - DefaultFullScreenVideoHandler(); - virtual ~DefaultFullScreenVideoHandler(); - bool requiresFullScreenForVideoPlayback() const; - -public Q_SLOTS: - void enterFullScreen(QMediaPlayer*); - void exitFullScreen(); - -private: - static bool s_shouldForceFullScreenVideoPlayback; - FullScreenVideoWidget *m_fullScreenWidget; -}; -#endif - class FullScreenVideoQt : public QObject { Q_OBJECT public: diff --git a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.cpp b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.cpp index bb5e2b9f612..4105d02c622 100644 --- a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.cpp +++ b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.cpp @@ -25,6 +25,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "FullScreenVideoWidget.h" #include @@ -35,7 +36,7 @@ static const int gHideMouseCursorDelay = 3000; -namespace WebCore { +namespace WebKit { FullScreenVideoWidget::FullScreenVideoWidget() : QVideoWidget() diff --git a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.h b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.h index 7e7f8df1c6e..201cc49d1e4 100644 --- a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.h +++ b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.h @@ -35,7 +35,7 @@ QT_BEGIN_NAMESPACE class QMediaPlayer; QT_END_NAMESPACE -namespace WebCore { +namespace WebKit { class FullScreenVideoWidget : public QVideoWidget { Q_OBJECT diff --git a/Source/WebKit/qt/WebCoreSupport/GeolocationClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/GeolocationClientQt.cpp index b6b4d70bd10..26d1b407a8c 100644 --- a/Source/WebKit/qt/WebCoreSupport/GeolocationClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/GeolocationClientQt.cpp @@ -33,10 +33,8 @@ #include "GeolocationPosition.h" #include "HTMLFormElement.h" #include "Page.h" -#include "qwebframe.h" -#include "qwebframe_p.h" -#include "qwebpage.h" -#include "qwebpage_p.h" +#include "QWebFrameAdapter.h" +#include "QWebPageAdapter.h" #include @@ -44,8 +42,8 @@ namespace WebCore { static const char failedToStartServiceErrorMessage[] = "Failed to start Geolocation service"; -GeolocationClientQt::GeolocationClientQt(const QWebPage* page) - : m_page(page) +GeolocationClientQt::GeolocationClientQt(const QWebPageAdapter* page) + : m_webPage(page) , m_lastPosition(0) , m_location(0) { @@ -85,12 +83,9 @@ void GeolocationClientQt::positionUpdated(const QGeoPositionInfo& geoPosition) double timeStampInSeconds = geoPosition.timestamp().toMSecsSinceEpoch() / 1000; - m_lastPosition = GeolocationPosition::create(timeStampInSeconds, latitude, longitude, - accuracy, providesAltitude, altitude, - providesAltitudeAccuracy, altitudeAccuracy, - providesHeading, heading, providesSpeed, speed); + m_lastPosition = GeolocationPosition::create(timeStampInSeconds, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed); - WebCore::Page* page = QWebPagePrivate::core(m_page); + WebCore::Page* page = m_webPage->page; GeolocationController::from(page)->positionChanged(m_lastPosition.get()); } @@ -100,7 +95,7 @@ void GeolocationClientQt::startUpdating() connect(m_location, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); if (!m_location) { - WebCore::Page* page = QWebPagePrivate::core(m_page); + WebCore::Page* page = m_webPage->page; RefPtr error = GeolocationError::create(GeolocationError::PositionUnavailable, failedToStartServiceErrorMessage); GeolocationController::from(page)->errorOccurred(error.get()); return; @@ -124,14 +119,14 @@ void GeolocationClientQt::setEnableHighAccuracy(bool) void GeolocationClientQt::requestPermission(Geolocation* geolocation) { ASSERT(geolocation); - QWebFrame* webFrame = QWebFramePrivate::kit(geolocation->frame()); + QWebFrameAdapter* webFrame = QWebFrameAdapter::kit(geolocation->frame()); GeolocationPermissionClientQt::geolocationPermissionClient()->requestGeolocationPermissionForFrame(webFrame, geolocation); } void GeolocationClientQt::cancelPermissionRequest(Geolocation* geolocation) { ASSERT(geolocation); - QWebFrame* webFrame = QWebFramePrivate::kit(geolocation->frame()); + QWebFrameAdapter* webFrame = QWebFrameAdapter::kit(geolocation->frame()); GeolocationPermissionClientQt::geolocationPermissionClient()->cancelGeolocationPermissionRequestForFrame(webFrame, geolocation); } diff --git a/Source/WebKit/qt/WebCoreSupport/GeolocationClientQt.h b/Source/WebKit/qt/WebCoreSupport/GeolocationClientQt.h index 2e94bdebc2b..c2287867fbe 100644 --- a/Source/WebKit/qt/WebCoreSupport/GeolocationClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/GeolocationClientQt.h @@ -28,16 +28,16 @@ #include "GeolocationClient.h" +#include #include #include -#include QT_BEGIN_NAMESPACE class QGeoPositionInfoSource; QT_END_NAMESPACE -class QWebPage; +class QWebPageAdapter; namespace WebCore { @@ -46,7 +46,7 @@ class GeolocationClientQt : public QObject, public GeolocationClient { Q_OBJECT public: - GeolocationClientQt(const QWebPage*); + GeolocationClientQt(const QWebPageAdapter*); virtual ~GeolocationClientQt(); virtual void geolocationDestroyed(); @@ -63,7 +63,7 @@ private Q_SLOTS: void positionUpdated(const QGeoPositionInfo&); private: - const QWebPage* m_page; + const QWebPageAdapter* m_webPage; RefPtr m_lastPosition; QGeoPositionInfoSource* m_location; }; diff --git a/Source/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp index 7500e993fdb..04e47688a60 100644 --- a/Source/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp @@ -32,10 +32,9 @@ #include "GeolocationPermissionClientQt.h" #include "Geolocation.h" - -#include "qwebframe.h" +#include "QWebFrameAdapter.h" +#include "QWebPageAdapter.h" #include "qwebkitglobal.h" -#include "qwebpage.h" namespace WebCore { @@ -60,36 +59,30 @@ GeolocationPermissionClientQt::~GeolocationPermissionClientQt() { } -void GeolocationPermissionClientQt::requestGeolocationPermissionForFrame(QWebFrame* webFrame, Geolocation* listener) +void GeolocationPermissionClientQt::requestGeolocationPermissionForFrame(QWebFrameAdapter* webFrame, Geolocation* listener) { m_pendingPermissionRequests.insert(webFrame, listener); - QWebPage* page = webFrame->page(); - emit page->featurePermissionRequested(webFrame, QWebPage::Geolocation); + QWebPageAdapter* page = QWebPageAdapter::kit(webFrame->frame->page()); + page->geolocationPermissionRequested(webFrame); } -void GeolocationPermissionClientQt::cancelGeolocationPermissionRequestForFrame(QWebFrame* webFrame, Geolocation* listener) +void GeolocationPermissionClientQt::cancelGeolocationPermissionRequestForFrame(QWebFrameAdapter* webFrame, Geolocation* listener) { m_pendingPermissionRequests.remove(webFrame); - QWebPage* page = webFrame->page(); - emit page->featurePermissionRequestCanceled(webFrame, QWebPage::Geolocation); + QWebPageAdapter* page = QWebPageAdapter::kit(webFrame->frame->page()); + page->geolocationPermissionRequestCancelled(webFrame); } -void GeolocationPermissionClientQt::setPermission(QWebFrame* webFrame, QWebPage::PermissionPolicy permission) +void GeolocationPermissionClientQt::setPermission(QWebFrameAdapter* webFrame, bool granted) { if (!m_pendingPermissionRequests.contains(webFrame)) return; Geolocation* listener = m_pendingPermissionRequests.value(webFrame); - - if (permission == QWebPage::PermissionGrantedByUser) - listener->setIsAllowed(true); - else if (permission == QWebPage::PermissionDeniedByUser) - listener->setIsAllowed(false); - else - return; + listener->setIsAllowed(granted); m_pendingPermissionRequests.remove(webFrame); } diff --git a/Source/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h b/Source/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h index 1b4540d87b6..71183b497fa 100644 --- a/Source/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h @@ -34,12 +34,11 @@ #if ENABLE(GEOLOCATION) #include "Geolocation.h" -#include "qwebpage.h" #include -class QWebFrame; -class QWebPage; +class QWebFrameAdapter; +class QWebPageAdapter; namespace WebCore { @@ -48,13 +47,13 @@ class GeolocationPermissionClientQt { GeolocationPermissionClientQt(); ~GeolocationPermissionClientQt(); - void requestGeolocationPermissionForFrame(QWebFrame*, Geolocation*); - void cancelGeolocationPermissionRequestForFrame(QWebFrame*, Geolocation*); - void setPermission(QWebFrame*, QWebPage::PermissionPolicy); + void requestGeolocationPermissionForFrame(QWebFrameAdapter*, Geolocation*); + void cancelGeolocationPermissionRequestForFrame(QWebFrameAdapter*, Geolocation*); + void setPermission(QWebFrameAdapter*, bool /*granted*/); static GeolocationPermissionClientQt* geolocationPermissionClient(); private: - QHash m_pendingPermissionRequests; + QHash m_pendingPermissionRequests; }; } diff --git a/Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.cpp b/Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.cpp index d6065c14e5a..e75b852fe18 100644 --- a/Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.cpp @@ -44,19 +44,31 @@ #include "qwebelement_p.h" #include -#include -#include #include namespace WebKit { -// Called also from WebKit2's WebProcess. -Q_DECL_EXPORT void initializeWebKit2Theme() +static QtStyleFactoryFunction initCallback = 0; + +void setWebKitWidgetsInitCallback(QtStyleFactoryFunction callback) { - if (qgetenv("QT_WEBKIT_THEME_NAME") == "qstyle") { - WebCore::RenderThemeQStyle::setStyleFactoryFunction(WebKit::QStyleFacadeImp::create); + initCallback = callback; +} + +// Called also from WebKit2's WebProcess +Q_DECL_EXPORT void initializeWebKitQt() +{ + if (initCallback) { + WebCore::RenderThemeQStyle::setStyleFactoryFunction(initCallback); WebCore::RenderThemeQt::setCustomTheme(WebCore::RenderThemeQStyle::create, new WebCore::ScrollbarThemeQStyle); } + + WebCore::initializeWebCoreQt(); +} + +Q_DECL_EXPORT void setImagePlatformResource(const char* name, const QPixmap& pixmap) +{ + WebCore::Image::setPlatformResource(name, pixmap); } } @@ -79,18 +91,10 @@ void initializeWebCoreQt() PlatformStrategiesQt::initialize(); QtWebElementRuntime::initialize(); - RenderThemeQStyle::setStyleFactoryFunction(WebKit::QStyleFacadeImp::create); - RenderThemeQt::setCustomTheme(RenderThemeQStyle::create, new ScrollbarThemeQStyle); - #if USE(QTKIT) InitWebCoreSystemInterface(); #endif - // QWebSettings::SearchCancelButtonGraphic - Image::setPlatformResource("searchCancelButton", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton)); - // QWebSettings::SearchCancelButtonPressedGraphic - Image::setPlatformResource("searchCancelButtonPressed", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton)); - initialized = true; } diff --git a/Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.h b/Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.h index df1aaf77627..e84e0dad2ed 100644 --- a/Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.h +++ b/Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.h @@ -30,6 +30,22 @@ #ifndef InitWebCoreQt_h #define InitWebCoreQt_h +#include "qimage.h" + +namespace WebCore { +class Page; +class QStyleFacade; +} +typedef WebCore::QStyleFacade* (*QtStyleFactoryFunction)(WebCore::Page*); + +namespace WebKit { + +void setWebKitWidgetsInitCallback(QtStyleFactoryFunction); +void initializeWebKitQt(); +void setImagePlatformResource(const char* /* name */, const QPixmap&); + +} + namespace WebCore { void initializeWebCoreQt(); diff --git a/Source/WebKit/qt/WebCoreSupport/InitWebKitQt.cpp b/Source/WebKit/qt/WebCoreSupport/InitWebKitQt.cpp new file mode 100644 index 00000000000..71886037da5 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/InitWebKitQt.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "InitWebKitQt.h" + +#include "InitWebCoreQt.h" + +#include "QStyleFacadeImp.h" + +#include +#include + +namespace WebKit { + +Q_DECL_EXPORT void initializeWebKitWidgets() +{ + static bool initialized = false; + if (initialized) + return; + + setWebKitWidgetsInitCallback(QStyleFacadeImp::create); + initializeWebKitQt(); + + // QWebSettings::SearchCancelButtonGraphic + setImagePlatformResource("searchCancelButton", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton)); + // QWebSettings::SearchCancelButtonPressedGraphic + setImagePlatformResource("searchCancelButtonPressed", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton)); + + initialized = true; +} + +} diff --git a/Source/WebKit/qt/WebCoreSupport/InitWebKitQt.h b/Source/WebKit/qt/WebCoreSupport/InitWebKitQt.h new file mode 100644 index 00000000000..b2f5711a813 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/InitWebKitQt.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef InitWebKitQt_h +#define InitWebKitQt_h + +namespace WebKit { + +void initializeWebKitWidgets(); + +} +#endif diff --git a/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp index 025ad659da0..1bfaa7b7078 100644 --- a/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp @@ -38,62 +38,22 @@ #include "InspectorServerQt.h" #include "NotImplemented.h" #include "Page.h" +#include "QWebFrameAdapter.h" +#include "QWebPageAdapter.h" #include "ScriptDebugServer.h" -#include "qwebinspector.h" -#include "qwebinspector_p.h" -#include "qwebpage.h" -#include "qwebpage_p.h" -#include "qwebview.h" +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include namespace WebCore { static const QLatin1String settingStoragePrefix("Qt/QtWebKit/QWebInspector/"); static const QLatin1String settingStorageTypeSuffix(".type"); -class InspectorClientWebPage : public QWebPage { - Q_OBJECT - friend class InspectorClientQt; -public: - InspectorClientWebPage(QObject* parent = 0) - : QWebPage(parent) - { - connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), SLOT(javaScriptWindowObjectCleared())); - } - - QWebPage* createWindow(QWebPage::WebWindowType) - { - QWebView* view = new QWebView; - QWebPage* page = new QWebPage; - view->setPage(page); - view->setAttribute(Qt::WA_DeleteOnClose); - return page; - } - -public Q_SLOTS: - void javaScriptWindowObjectCleared() - { -#ifndef QT_NO_PROPERTIES - QVariant inspectorJavaScriptWindowObjects = property("_q_inspectorJavaScriptWindowObjects"); - if (!inspectorJavaScriptWindowObjects.isValid()) - return; - QMap javaScriptNameObjectMap = inspectorJavaScriptWindowObjects.toMap(); - QWebFrame* frame = mainFrame(); - QMap::const_iterator it = javaScriptNameObjectMap.constBegin(); - for ( ; it != javaScriptNameObjectMap.constEnd(); ++it) { - QString name = it.key(); - QVariant value = it.value(); - QObject* obj = value.value(); - frame->addToJavaScriptWindowObject(name, obj); - } -#endif - } -}; - namespace { #if ENABLE(INSPECTOR) @@ -112,7 +72,7 @@ class InspectorFrontendSettingsQt : public InspectorFrontendClientLocal::Setting if (qsettings.status() == QSettings::AccessError) { // QCoreApplication::setOrganizationName and QCoreApplication::setApplicationName haven't been called qWarning("QWebInspector: QSettings couldn't read configuration setting [%s].", - qPrintable(static_cast(name))); + qPrintable(static_cast(name))); return String(); } @@ -134,7 +94,7 @@ class InspectorFrontendSettingsQt : public InspectorFrontendClientLocal::Setting QSettings qsettings; if (qsettings.status() == QSettings::AccessError) { qWarning("QWebInspector: QSettings couldn't persist configuration setting [%s].", - qPrintable(static_cast(name))); + qPrintable(static_cast(name))); return; } @@ -175,7 +135,7 @@ class InspectorFrontendSettingsQt : public InspectorFrontendClientLocal::Setting } -InspectorClientQt::InspectorClientQt(QWebPage* page) +InspectorClientQt::InspectorClientQt(QWebPageAdapter* page) : m_inspectedWebPage(page) , m_frontendWebPage(0) , m_frontendClient(0) @@ -204,12 +164,12 @@ WebCore::InspectorFrontendChannel* InspectorClientQt::openInspectorFrontend(WebC { WebCore::InspectorFrontendChannel* frontendChannel = 0; #if ENABLE(INSPECTOR) - OwnPtr inspectorView = adoptPtr(new QWebView); - // FIXME: Where does inspectorPage get deleted? - InspectorClientWebPage* inspectorPage = new InspectorClientWebPage(inspectorView.get()); - inspectorView->setPage(inspectorPage); + QObject* view = 0; + QWebPageAdapter* inspectorPage = 0; + m_inspectedWebPage->createWebInspector(&view, &inspectorPage); + OwnPtr inspectorView = adoptPtr(view); - QWebInspector* inspector = m_inspectedWebPage->d->getOrCreateInspector(); + QObject* inspector = m_inspectedWebPage->inspectorHandle(); // Remote frontend was attached. if (m_remoteFrontEndChannel) return 0; @@ -228,21 +188,20 @@ WebCore::InspectorFrontendChannel* InspectorClientQt::openInspectorFrontend(WebC #ifndef QT_NO_PROPERTIES QVariant inspectorJavaScriptWindowObjects = inspector->property("_q_inspectorJavaScriptWindowObjects"); if (inspectorJavaScriptWindowObjects.isValid()) - inspectorPage->setProperty("_q_inspectorJavaScriptWindowObjects", inspectorJavaScriptWindowObjects); + inspectorPage->handle()->setProperty("_q_inspectorJavaScriptWindowObjects", inspectorJavaScriptWindowObjects); #endif - inspectorView->page()->mainFrame()->load(inspectorUrl); - m_inspectedWebPage->d->inspectorFrontend = inspectorView.get(); - inspector->d->setFrontend(inspectorView.get()); + inspectorPage->mainFrameAdapter()->load(QNetworkRequest(inspectorUrl)); + m_inspectedWebPage->setInspectorFrontend(inspectorView.get()); // Is 'controller' the same object as 'inspectorController' (which appears to be unused)? - InspectorController* controller = inspectorView->page()->d->page->inspectorController(); - OwnPtr frontendClient = adoptPtr(new InspectorFrontendClientQt(m_inspectedWebPage, inspectorView.release(), this)); + InspectorController* controller = inspectorPage->page->inspectorController(); + OwnPtr frontendClient = adoptPtr(new InspectorFrontendClientQt(m_inspectedWebPage, inspectorView.release(), inspectorPage->page, this)); m_frontendClient = frontendClient.get(); controller->setInspectorFrontendClient(frontendClient.release()); m_frontendWebPage = inspectorPage; // Web Inspector should not belong to any other page groups since it is a specialized debugger window. - m_frontendWebPage->handle()->page->setGroupName("__WebInspectorPageGroup__"); + m_frontendWebPage->page->setGroupName("__WebInspectorPageGroup__"); frontendChannel = this; #endif return frontendChannel; @@ -273,7 +232,7 @@ void InspectorClientQt::attachAndReplaceRemoteFrontend(InspectorServerRequestHan { #if ENABLE(INSPECTOR) m_remoteFrontEndChannel = channel; - m_inspectedWebPage->d->inspectorController()->connectFrontend(this); + m_inspectedWebPage->page->inspectorController()->connectFrontend(this); #endif } @@ -281,7 +240,7 @@ void InspectorClientQt::detachRemoteFrontend() { #if ENABLE(INSPECTOR) m_remoteFrontEndChannel = 0; - m_inspectedWebPage->d->inspectorController()->disconnectFrontend(); + m_inspectedWebPage->page->inspectorController()->disconnectFrontend(); #endif } @@ -292,9 +251,9 @@ void InspectorClientQt::highlight() void InspectorClientQt::hideHighlight() { - WebCore::Frame* frame = m_inspectedWebPage->d->page->mainFrame(); + WebCore::Frame* frame = m_inspectedWebPage->page->mainFrame(); if (frame) { - QRect rect = m_inspectedWebPage->mainFrame()->geometry(); + QRect rect = m_inspectedWebPage->mainFrameAdapter()->frameRect(); if (!rect.isEmpty()) frame->view()->invalidateRect(rect); } @@ -311,7 +270,7 @@ bool InspectorClientQt::sendMessageToFrontend(const String& message) if (!m_frontendWebPage) return false; - Page* frontendPage = QWebPagePrivate::core(m_frontendWebPage); + Page* frontendPage = m_frontendWebPage->page; return doDispatchMessageOnFrontendPage(frontendPage, message); #else return false; @@ -319,8 +278,8 @@ bool InspectorClientQt::sendMessageToFrontend(const String& message) } #if ENABLE(INSPECTOR) -InspectorFrontendClientQt::InspectorFrontendClientQt(QWebPage* inspectedWebPage, PassOwnPtr inspectorView, InspectorClientQt* inspectorClient) - : InspectorFrontendClientLocal(inspectedWebPage->d->page->inspectorController(), inspectorView->page()->d->page, adoptPtr(new InspectorFrontendSettingsQt())) +InspectorFrontendClientQt::InspectorFrontendClientQt(QWebPageAdapter* inspectedWebPage, PassOwnPtr inspectorView, WebCore::Page* inspectorPage, InspectorClientQt* inspectorClient) + : InspectorFrontendClientLocal(inspectedWebPage->page->inspectorController(), inspectorPage, adoptPtr(new InspectorFrontendSettingsQt())) , m_inspectedWebPage(inspectedWebPage) , m_inspectorView(inspectorView) , m_destroyingInspectorView(false) @@ -386,10 +345,8 @@ void InspectorFrontendClientQt::inspectedURLChanged(const String& newURL) void InspectorFrontendClientQt::updateWindowTitle() { - if (m_inspectedWebPage->d->inspector) { - QString caption = QCoreApplication::translate("QWebPage", "Web Inspector - %2").arg(m_inspectedURL); - m_inspectedWebPage->d->inspector->setWindowTitle(caption); - } + QString caption = QCoreApplication::translate("QWebPage", "Web Inspector - %2").arg(m_inspectedURL); + m_inspectedWebPage->setInspectorWindowTitle(caption); } void InspectorFrontendClientQt::destroyInspectorView(bool notifyInspectorController) @@ -399,20 +356,20 @@ void InspectorFrontendClientQt::destroyInspectorView(bool notifyInspectorControl m_destroyingInspectorView = true; // Inspected page may have already been destroyed. - if (m_inspectedWebPage && m_inspectedWebPage->d->inspector) { + if (m_inspectedWebPage) { // Clear reference from QWebInspector to the frontend view. - m_inspectedWebPage->d->inspector->d->setFrontend(0); + m_inspectedWebPage->setInspectorFrontend(0); } #if ENABLE(INSPECTOR) if (notifyInspectorController) - m_inspectedWebPage->d->inspectorController()->disconnectFrontend(); + m_inspectedWebPage->page->inspectorController()->disconnectFrontend(); #endif if (m_inspectorClient) m_inspectorClient->releaseFrontendPage(); // Clear pointer before deleting WebView to avoid recursive calls to its destructor. - OwnPtr inspectorView = m_inspectorView.release(); + OwnPtr inspectorView = m_inspectorView.release(); } void InspectorFrontendClientQt::inspectorClientDestroyed() @@ -424,4 +381,3 @@ void InspectorFrontendClientQt::inspectorClientDestroyed() #endif } -#include "InspectorClientQt.moc" diff --git a/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.h b/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.h index 49ba000ad1a..c6da4d61c57 100644 --- a/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.h @@ -33,11 +33,14 @@ #include "InspectorClient.h" #include "InspectorFrontendChannel.h" #include "InspectorFrontendClientLocal.h" -#include + +#include +#include #include #include #include +class QWebPageAdapter; class QWebPage; class QWebView; @@ -48,7 +51,7 @@ class Page; class InspectorClientQt : public InspectorClient, public InspectorFrontendChannel { public: - InspectorClientQt(QWebPage*); + InspectorClientQt(QWebPageAdapter*); virtual void inspectorDestroyed(); @@ -67,8 +70,8 @@ class InspectorClientQt : public InspectorClient, public InspectorFrontendChanne void detachRemoteFrontend(); private: - QWebPage* m_inspectedWebPage; - QWebPage* m_frontendWebPage; + QWebPageAdapter* m_inspectedWebPage; + QWebPageAdapter* m_frontendWebPage; InspectorFrontendClientQt* m_frontendClient; bool m_remoteInspector; InspectorServerRequestHandlerQt* m_remoteFrontEndChannel; @@ -78,7 +81,7 @@ class InspectorClientQt : public InspectorClient, public InspectorFrontendChanne class InspectorFrontendClientQt : public InspectorFrontendClientLocal { public: - InspectorFrontendClientQt(QWebPage* inspectedWebPage, PassOwnPtr inspectorView, InspectorClientQt* inspectorClient); + InspectorFrontendClientQt(QWebPageAdapter* inspectedWebPage, PassOwnPtr inspectorView, WebCore::Page* inspectorPage, InspectorClientQt*); virtual ~InspectorFrontendClientQt(); virtual void frontendLoaded(); @@ -93,7 +96,7 @@ class InspectorFrontendClientQt : public InspectorFrontendClientLocal { virtual void attachWindow(); virtual void detachWindow(); - virtual void setAttachedWindowHeight(unsigned height); + virtual void setAttachedWindowHeight(unsigned); virtual void inspectedURLChanged(const String& newURL); @@ -102,8 +105,8 @@ class InspectorFrontendClientQt : public InspectorFrontendClientLocal { private: void updateWindowTitle(); void destroyInspectorView(bool notifyInspectorController); - QWebPage* m_inspectedWebPage; - OwnPtr m_inspectorView; + QWebPageAdapter* m_inspectedWebPage; + OwnPtr m_inspectorView; QString m_inspectedURL; bool m_destroyingInspectorView; InspectorClientQt* m_inspectorClient; diff --git a/Source/WebKit/qt/WebCoreSupport/InspectorClientWebPage.cpp b/Source/WebKit/qt/WebCoreSupport/InspectorClientWebPage.cpp new file mode 100644 index 00000000000..dc4730b3295 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/InspectorClientWebPage.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 2008 Holger Hans Peter Freyther + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "InspectorClientWebPage.h" + +#include + +using namespace WebKit; + +InspectorClientWebPage::InspectorClientWebPage() +{ + QWebView* view = new QWebView; + view->setPage(this); + setParent(view); + connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), SLOT(javaScriptWindowObjectCleared())); +} + +QWebPage* InspectorClientWebPage::createWindow(QWebPage::WebWindowType) +{ + QWebView* view = new QWebView; + QWebPage* page = new QWebPage; + view->setPage(page); + view->setAttribute(Qt::WA_DeleteOnClose); + return page; +} + +void InspectorClientWebPage::javaScriptWindowObjectCleared() +{ + QVariant inspectorJavaScriptWindowObjects = property("_q_inspectorJavaScriptWindowObjects"); + if (!inspectorJavaScriptWindowObjects.isValid()) + return; + QMap javaScriptNameObjectMap = inspectorJavaScriptWindowObjects.toMap(); + QWebFrame* frame = mainFrame(); + QMap::const_iterator it = javaScriptNameObjectMap.constBegin(); + for ( ; it != javaScriptNameObjectMap.constEnd(); ++it) { + QString name = it.key(); + QVariant value = it.value(); + QObject* obj = value.value(); + frame->addToJavaScriptWindowObject(name, obj); + } +} + diff --git a/Source/WebKit/qt/WebCoreSupport/InspectorClientWebPage.h b/Source/WebKit/qt/WebCoreSupport/InspectorClientWebPage.h new file mode 100644 index 00000000000..887f29b0cf5 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/InspectorClientWebPage.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 2008 Holger Hans Peter Freyther + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef InspectorClientWebPage_h +#define InspectorClientWebPage_h + +#include +#include + +namespace WebKit { + +class InspectorClientWebPage : public QWebPage { + Q_OBJECT + friend class InspectorClientQt; +public: + InspectorClientWebPage(); + + QWebPage* createWindow(QWebPage::WebWindowType); + +public Q_SLOTS: + void javaScriptWindowObjectCleared(); +}; + +} // namespace WebKit + +#endif // InspectorClientWebPage_h diff --git a/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp b/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp index 65bbad0f094..abf9c3f7870 100644 --- a/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp @@ -23,16 +23,15 @@ #include "InspectorClientQt.h" #include "InspectorController.h" #include "Page.h" +#include "QWebFrameAdapter.h" +#include "QWebPageAdapter.h" #include "qhttpheader_p.h" -#include "qwebpage.h" -#include "qwebpage_p.h" #include #include #include #include #include #include -#include #include #include #include @@ -224,12 +223,11 @@ void InspectorServerRequestHandlerQt::tcpReadyRead() // If no path is specified, generate an index page. if (m_path.isEmpty() || (m_path == QString(QLatin1Char('/')))) { QString indexHtml = QLatin1String("Remote Web Inspector")); response = indexHtml.toLatin1(); @@ -356,8 +354,8 @@ void InspectorServerRequestHandlerQt::webSocketReadyRead() #if ENABLE(INSPECTOR) if (m_inspectorClient) { - InspectorController* inspectorController = m_inspectorClient->m_inspectedWebPage->d->page->inspectorController(); - inspectorController->dispatchMessageFromFrontend(QString::fromUtf8(payload)); + InspectorController* inspectorController = m_inspectorClient->m_inspectedWebPage->page->inspectorController(); + inspectorController->dispatchMessageFromFrontend(QString::fromUtf8(payload)); } #endif diff --git a/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.h b/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.h index b0bb0c79d58..2754b58d907 100644 --- a/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.h +++ b/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.h @@ -45,8 +45,8 @@ class InspectorServerQt : public QObject { void listen(quint16 port); - void registerClient(InspectorClientQt* client); - void unregisterClient(InspectorClientQt* client); + void registerClient(InspectorClientQt*); + void unregisterClient(InspectorClientQt*); void close(); InspectorClientQt* inspectorClientForPage(int pageNum); @@ -70,7 +70,7 @@ class InspectorServerRequestHandlerQt : public QObject { Q_OBJECT public: - InspectorServerRequestHandlerQt(QTcpSocket *tcpConnection, InspectorServerQt *server); + InspectorServerRequestHandlerQt(QTcpSocket* tcpConnection, InspectorServerQt*); virtual ~InspectorServerRequestHandlerQt(); virtual int webSocketSend(const QString& message); virtual int webSocketSend(const char *payload, size_t length); diff --git a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp index 56ed0b4cb7c..06840c455b8 100644 --- a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp @@ -33,18 +33,16 @@ #include "NotificationPresenterClientQt.h" #include "Document.h" -#include "DumpRenderTreeSupportQt.h" #include "EventNames.h" #include "KURL.h" #include "Page.h" +#include "QWebFrameAdapter.h" +#include "QWebPageAdapter.h" #include "QtPlatformPlugin.h" #include "ScriptExecutionContext.h" #include "SecurityOrigin.h" #include "UserGestureIndicator.h" - -#include "qwebframe_p.h" #include "qwebkitglobal.h" -#include "qwebpage.h" namespace WebCore { @@ -72,10 +70,6 @@ NotificationWrapper::NotificationWrapper() , m_displayEventTimer(this, &NotificationWrapper::sendDisplayEvent) { #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) - -#ifndef QT_NO_SYSTEMTRAYICON - m_notificationIcon = nullptr; -#endif m_presenter = nullptr; #endif } @@ -209,7 +203,6 @@ void NotificationPresenterClientQt::displayNotification(Notification* notificati #ifndef QT_NO_SYSTEMTRAYICON if (!dumpNotification) wrapper->m_closeTimer.startOneShot(notificationTimeout); - wrapper->m_notificationIcon = adoptPtr(new QSystemTrayIcon()); #endif } @@ -227,9 +220,9 @@ void NotificationPresenterClientQt::displayNotification(Notification* notificati } #ifndef QT_NO_SYSTEMTRAYICON - wrapper->connect(wrapper->m_notificationIcon.get(), SIGNAL(messageClicked()), wrapper, SLOT(notificationClicked())); - wrapper->m_notificationIcon->show(); - wrapper->m_notificationIcon->showMessage(notification->title(), notification->body()); + wrapper->connect(m_systemTrayIcon.data(), SIGNAL(messageClicked()), wrapper, SLOT(notificationClicked())); + QMetaObject::invokeMethod(m_systemTrayIcon.data(), "show"); + QMetaObject::invokeMethod(m_systemTrayIcon.data(), "showMessage", Q_ARG(QString, notification->title()), Q_ARG(QString, notification->body())); #endif } @@ -324,11 +317,10 @@ void NotificationPresenterClientQt::requestPermission(ScriptExecutionContext* co CallbacksInfo info; info.m_frame = toFrame(context); info.m_callbacks.append(cb); - m_pendingPermissionRequests.insert(context, info); if (toPage(context) && toFrame(context)) { m_pendingPermissionRequests.insert(context, info); - emit toPage(context)->featurePermissionRequested(toFrame(context), QWebPage::Notifications); + toPage(context)->notificationsPermissionRequested(toFrame(context)); } } } @@ -346,10 +338,10 @@ void NotificationPresenterClientQt::cancelRequestsForPermission(ScriptExecutionC if (iter == m_pendingPermissionRequests.end()) return; - QWebFrame* frame = iter.value().m_frame; + QWebFrameAdapter* frame = iter.value().m_frame; if (!frame) return; - QWebPage* page = frame->page(); + QWebPageAdapter* page = QWebPageAdapter::kit(frame->frame->page()); m_pendingPermissionRequests.erase(iter); if (!page) @@ -358,7 +350,7 @@ void NotificationPresenterClientQt::cancelRequestsForPermission(ScriptExecutionC if (dumpNotification) printf("DESKTOP NOTIFICATION PERMISSION REQUEST CANCELLED: %s\n", QString(context->securityOrigin()->toString()).toUtf8().constData()); - emit page->featurePermissionRequestCanceled(frame, QWebPage::Notifications); + page->notificationsPermissionRequestCancelled(frame); } void NotificationPresenterClientQt::allowNotificationForFrame(Frame* frame) @@ -436,13 +428,13 @@ void NotificationPresenterClientQt::dumpShowText(Notification* notification) printf("DESKTOP NOTIFICATION: contents at %s\n", QString(notification->url().string()).toUtf8().constData()); else { printf("DESKTOP NOTIFICATION:%s icon %s, title %s, text %s\n", - notification->dir() == "rtl" ? "(RTL)" : "", + notification->dir() == "rtl" ? "(RTL)" : "", QString(notification->iconURL().string()).toUtf8().constData(), QString(notification->title()).toUtf8().constData(), QString(notification->body()).toUtf8().constData()); } } -QWebPage* NotificationPresenterClientQt::toPage(ScriptExecutionContext* context) +QWebPageAdapter* NotificationPresenterClientQt::toPage(ScriptExecutionContext* context) { if (!context || context->isWorkerContext()) return 0; @@ -453,10 +445,10 @@ QWebPage* NotificationPresenterClientQt::toPage(ScriptExecutionContext* context) if (!page || !page->mainFrame()) return 0; - return QWebFramePrivate::kit(page->mainFrame())->page(); + return QWebPageAdapter::kit(page); } -QWebFrame* NotificationPresenterClientQt::toFrame(ScriptExecutionContext* context) +QWebFrameAdapter* NotificationPresenterClientQt::toFrame(ScriptExecutionContext* context) { if (!context || context->isWorkerContext()) return 0; @@ -465,7 +457,7 @@ QWebFrame* NotificationPresenterClientQt::toFrame(ScriptExecutionContext* contex if (!document || !document->frame()) return 0; - return QWebFramePrivate::kit(document->frame()); + return QWebFrameAdapter::kit(document->frame()); } #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) diff --git a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h index 5819b4d8013..78668f35f57 100644 --- a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h @@ -36,14 +36,13 @@ #include "NotificationClient.h" #include "QtPlatformPlugin.h" #include "Timer.h" - #include "qwebkitplatformplugin.h" #include -#include +#include -class QWebFrame; -class QWebPage; +class QWebFrameAdapter; +class QWebPageAdapter; namespace WebCore { @@ -55,7 +54,7 @@ class NotificationWrapper : public QObject, public QWebNotificationData { Q_OBJECT public: NotificationWrapper(); - ~NotificationWrapper() {} + ~NotificationWrapper() { } void close(); void close(Timer*); @@ -69,14 +68,12 @@ public Q_SLOTS: void notificationClosed(); void notificationClicked(); -public: -#ifndef QT_NO_SYSTEMTRAYICON - OwnPtr m_notificationIcon; -#endif - +private: OwnPtr m_presenter; Timer m_closeTimer; Timer m_displayEventTimer; + + friend class NotificationPresenterClientQt; }; #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) @@ -109,6 +106,10 @@ class NotificationPresenterClientQt : public NotificationClient { static bool dumpNotification; void addClient() { m_clientCount++; } +#ifndef QT_NO_SYSTEMTRAYICON + bool hasSystemTrayIcon() const { return !m_systemTrayIcon.isNull(); } + void setSystemTrayIcon(QObject* icon) { m_systemTrayIcon.reset(icon); } +#endif void removeClient(); static NotificationPresenterClientQt* notificationPresenter(); @@ -124,12 +125,12 @@ class NotificationPresenterClientQt : public NotificationClient { void detachNotification(Notification*); void dumpReplacedIdText(Notification*); void dumpShowText(Notification*); - QWebPage* toPage(ScriptExecutionContext*); - QWebFrame* toFrame(ScriptExecutionContext*); + QWebPageAdapter* toPage(ScriptExecutionContext*); + QWebFrameAdapter* toFrame(ScriptExecutionContext*); int m_clientCount; struct CallbacksInfo { - QWebFrame* m_frame; + QWebFrameAdapter* m_frame; QList > m_callbacks; }; QHash m_pendingPermissionRequests; @@ -137,10 +138,13 @@ class NotificationPresenterClientQt : public NotificationClient { NotificationsQueue m_notifications; QtPlatformPlugin m_platformPlugin; +#ifndef QT_NO_SYSTEMTRAYICON + QScopedPointer m_systemTrayIcon; +#endif }; -#endif +#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) } -#endif +#endif // NotificationPresenterClientQt_h diff --git a/Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp index 141f98e3082..92ab84b64a5 100644 --- a/Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp @@ -35,8 +35,7 @@ #if USE(3D_GRAPHICS) #include -static void createPlatformGraphicsContext3DFromWidget(QWidget* widget, PlatformGraphicsContext3D* context, - PlatformGraphicsSurface3D* surface, QObject** surfaceOwner) +static void createPlatformGraphicsContext3DFromWidget(QWidget* widget, PlatformGraphicsContext3D* context, PlatformGraphicsSurface3D* surface, QObject** surfaceOwner) { #ifdef QT_OPENGL_LIB *context = 0; @@ -73,7 +72,7 @@ static void createPlatformGraphicsContext3DFromWidget(QWidget* widget, PlatformG QWindow* QWebPageClient::ownerWindow() const { - QWidget* widget = ownerWidget(); + QWidget* widget = qobject_cast(ownerWidget()); if (!widget) return 0; if (QWindow *window = widget->windowHandle()) @@ -204,7 +203,7 @@ int PageClientQWidget::screenNumber() const return 0; } -QWidget* PageClientQWidget::ownerWidget() const +QObject* PageClientQWidget::ownerWidget() const { return view; } @@ -238,9 +237,7 @@ void PageClientQWidget::setWidgetVisible(Widget* widget, bool visible) } #if USE(3D_GRAPHICS) -void PageClientQWidget::createPlatformGraphicsContext3D(PlatformGraphicsContext3D* context, - PlatformGraphicsSurface3D* surface, - QObject** surfaceOwner) +void PageClientQWidget::createPlatformGraphicsContext3D(PlatformGraphicsContext3D* context, PlatformGraphicsSurface3D* surface, QObject** surfaceOwner) { createPlatformGraphicsContext3DFromWidget(view, context, surface, surfaceOwner); } @@ -363,7 +360,7 @@ int PageClientQGraphicsWidget::screenNumber() const return 0; } -QWidget* PageClientQGraphicsWidget::ownerWidget() const +QObject* PageClientQGraphicsWidget::ownerWidget() const { if (QGraphicsScene* scene = view->scene()) { const QList views = scene->views(); @@ -428,11 +425,9 @@ QRectF PageClientQGraphicsWidget::windowRect() const #endif // QT_NO_GRAPHICSVIEW #if USE(3D_GRAPHICS) -void PageClientQGraphicsWidget::createPlatformGraphicsContext3D(PlatformGraphicsContext3D* context, - PlatformGraphicsSurface3D* surface, - QObject** surfaceOwner) +void PageClientQGraphicsWidget::createPlatformGraphicsContext3D(PlatformGraphicsContext3D* context, PlatformGraphicsSurface3D* surface, QObject** surfaceOwner) { - createPlatformGraphicsContext3DFromWidget(ownerWidget(), context, surface, surfaceOwner); + createPlatformGraphicsContext3DFromWidget(qobject_cast(ownerWidget()), context, surface, surfaceOwner); } #endif diff --git a/Source/WebKit/qt/WebCoreSupport/PageClientQt.h b/Source/WebKit/qt/WebCoreSupport/PageClientQt.h index e6b9e1694d4..72dca42c15b 100644 --- a/Source/WebKit/qt/WebCoreSupport/PageClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/PageClientQt.h @@ -31,15 +31,14 @@ #include "qwebframe_p.h" #include "qwebpage.h" #include "qwebpage_p.h" +#include #include #include #include +#include #include #include #include -#include - -#include namespace WebCore { @@ -75,18 +74,18 @@ class PageClientQWidget : public QWebPageClient { virtual void scroll(int dx, int dy, const QRect&); virtual void update(const QRect& dirtyRect); - virtual void setInputMethodEnabled(bool enable); + virtual void setInputMethodEnabled(bool); virtual bool inputMethodEnabled() const; - virtual void setInputMethodHints(Qt::InputMethodHints hints); + virtual void setInputMethodHints(Qt::InputMethodHints); #ifndef QT_NO_CURSOR virtual QCursor cursor() const; - virtual void updateCursor(const QCursor& cursor); + virtual void updateCursor(const QCursor&); #endif virtual QPalette palette() const; virtual int screenNumber() const; - virtual QWidget* ownerWidget() const; + virtual QObject* ownerWidget() const; virtual QRect geometryRelativeToOwnerWidget() const; virtual QObject* pluginParent() const; @@ -100,9 +99,7 @@ class PageClientQWidget : public QWebPageClient { virtual void setWidgetVisible(Widget*, bool visible); #if USE(3D_GRAPHICS) - virtual void createPlatformGraphicsContext3D(PlatformGraphicsContext3D*, - PlatformGraphicsSurface3D*, - QObject**); + virtual void createPlatformGraphicsContext3D(PlatformGraphicsContext3D*, PlatformGraphicsSurface3D*, QObject**); #endif QWidget* view; @@ -132,9 +129,9 @@ class PageClientQWidget : public QWebPageClient { class QGraphicsItemOverlay : public QGraphicsObject { public: QGraphicsItemOverlay(QGraphicsWidget* view, QWebPage* p) - :QGraphicsObject(view) - , q(view) - , page(p) + : QGraphicsObject(view) + , q(view) + , page(p) { setPos(0, 0); setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); @@ -172,7 +169,7 @@ class PageClientQGraphicsWidget : public QWebPageClient { #endif , overlay(0) { - Q_ASSERT(view); + Q_ASSERT(view); #if USE(ACCELERATED_COMPOSITING) // the overlay and stays alive for the lifetime of // this QGraphicsWebView as the scrollbars are needed when there's no compositing @@ -186,18 +183,18 @@ class PageClientQGraphicsWidget : public QWebPageClient { virtual void scroll(int dx, int dy, const QRect&); virtual void update(const QRect& dirtyRect); - virtual void setInputMethodEnabled(bool enable); + virtual void setInputMethodEnabled(bool); virtual bool inputMethodEnabled() const; - virtual void setInputMethodHints(Qt::InputMethodHints hints); + virtual void setInputMethodHints(Qt::InputMethodHints); #ifndef QT_NO_CURSOR virtual QCursor cursor() const; - virtual void updateCursor(const QCursor& cursor); + virtual void updateCursor(const QCursor&); #endif virtual QPalette palette() const; virtual int screenNumber() const; - virtual QWidget* ownerWidget() const; + virtual QObject* ownerWidget() const; virtual QRect geometryRelativeToOwnerWidget() const; virtual QObject* pluginParent() const; @@ -209,9 +206,7 @@ class PageClientQGraphicsWidget : public QWebPageClient { virtual void setWidgetVisible(Widget*, bool); #if USE(3D_GRAPHICS) - virtual void createPlatformGraphicsContext3D(PlatformGraphicsContext3D*, - PlatformGraphicsSurface3D*, - QObject**); + virtual void createPlatformGraphicsContext3D(PlatformGraphicsContext3D*, PlatformGraphicsSurface3D*, QObject**); #endif #if USE(TILED_BACKING_STORE) diff --git a/Source/WebKit/qt/WebCoreSupport/PlatformStrategiesQt.cpp b/Source/WebKit/qt/WebCoreSupport/PlatformStrategiesQt.cpp index c31d9b00750..5d9e755d02f 100644 --- a/Source/WebKit/qt/WebCoreSupport/PlatformStrategiesQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/PlatformStrategiesQt.cpp @@ -32,16 +32,17 @@ #include "Chrome.h" #include "ChromeClientQt.h" +#include "QWebPageAdapter.h" +#include "qwebhistoryinterface.h" +#include "qwebpluginfactory.h" + #include -#include "NotImplemented.h" +#include #include #include #include #include #include -#include -#include -#include #include using namespace WebCore; @@ -99,9 +100,9 @@ void PlatformStrategiesQt::refreshPlugins() void PlatformStrategiesQt::getPluginInfo(const WebCore::Page* page, Vector& outPlugins) { - QWebPage* qPage = static_cast(page->chrome()->client())->m_webPage; + QWebPageAdapter* qPage = static_cast(page->chrome()->client())->m_webPage; QWebPluginFactory* factory; - if (qPage && (factory = qPage->pluginFactory())) { + if (qPage && (factory = qPage->pluginFactory)) { QList qplugins = factory->plugins(); for (int i = 0; i < qplugins.count(); ++i) { @@ -117,7 +118,7 @@ void PlatformStrategiesQt::getPluginInfo(const WebCore::Page* page, VectoritemText(idx) : ""); } diff --git a/Source/WebKit/qt/WebCoreSupport/QGraphicsWidgetPluginImpl.cpp b/Source/WebKit/qt/WebCoreSupport/QGraphicsWidgetPluginImpl.cpp new file mode 100644 index 00000000000..5137933a0fa --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/QGraphicsWidgetPluginImpl.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "QGraphicsWidgetPluginImpl.h" + +#include +#include + +#ifndef QT_NO_GRAPHICSVIEW + +QGraphicsWidgetPluginImpl::~QGraphicsWidgetPluginImpl() +{ + m_graphicsWidget->deleteLater(); +} + +void QGraphicsWidgetPluginImpl::update(const QRect &rect) +{ + QGraphicsScene* scene = m_graphicsWidget->scene(); + if (scene) + scene->update(rect); +} + +void QGraphicsWidgetPluginImpl::setGeometryAndClip(const QRect &geometry, const QRect &, bool) +{ + m_graphicsWidget->setGeometry(geometry); + // FIXME: Make the code handle clipping of graphics widgets. +} + +void QGraphicsWidgetPluginImpl::setVisible(bool visible) +{ + m_graphicsWidget->setVisible(visible); +} + +void QGraphicsWidgetPluginImpl::setWidgetParent(QObject* parent) +{ + QGraphicsObject* parentItem = qobject_cast(parent); + if (parentItem) + m_graphicsWidget->setParentItem(parentItem); +} + +QObject* QGraphicsWidgetPluginImpl::handle() const +{ + return m_graphicsWidget; +} + +#include "moc_QGraphicsWidgetPluginImpl.cpp" + +#endif // !defined(QT_NO_GRAPHICSVIEW) diff --git a/Source/WebKit/qt/WebCoreSupport/QGraphicsWidgetPluginImpl.h b/Source/WebKit/qt/WebCoreSupport/QGraphicsWidgetPluginImpl.h new file mode 100644 index 00000000000..7f758226c4f --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/QGraphicsWidgetPluginImpl.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#ifndef QGraphicsWidgetPluginImpl_h +#define QGraphicsWidgetPluginImpl_h + +#ifndef QT_NO_GRAPHICSVIEW + +#include "QtPluginWidgetAdapter.h" + +QT_BEGIN_NAMESPACE +class QGraphicsWidget; +QT_END_NAMESPACE + +class QGraphicsWidgetPluginImpl : public QtPluginWidgetAdapter { + Q_OBJECT +public: + QGraphicsWidgetPluginImpl(QGraphicsWidget *w) : m_graphicsWidget(w) { } + virtual ~QGraphicsWidgetPluginImpl(); + virtual void update(const QRect &) OVERRIDE; + virtual void setGeometryAndClip(const QRect&, const QRect&, bool) OVERRIDE; + virtual void setVisible(bool); + virtual void setStyleSheet(const QString&) OVERRIDE { } + virtual void setWidgetParent(QObject*) OVERRIDE; + virtual QObject* handle() const OVERRIDE; +private: + QGraphicsWidget *m_graphicsWidget; +}; +#endif // !defined(QT_NO_GRAPHICSVIEW) + +#endif // QGraphicsWidgetPluginImpl_h diff --git a/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp new file mode 100644 index 00000000000..e86413cf05d --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp @@ -0,0 +1,210 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "QWebFrameAdapter.h" + +#include "Frame.h" +#include "FrameLoaderClientQt.h" +#include "QWebPageAdapter.h" +#if ENABLE(GESTURE_EVENTS) +#include "PlatformGestureEvent.h" +#include "WebEventConversion.h" +#endif + +#include +#include + +using namespace WebCore; + +static inline ResourceRequestCachePolicy cacheLoadControlToCachePolicy(uint cacheLoadControl) +{ + switch (cacheLoadControl) { + case QNetworkRequest::AlwaysNetwork: + return WebCore::ReloadIgnoringCacheData; + case QNetworkRequest::PreferCache: + return WebCore::ReturnCacheDataElseLoad; + case QNetworkRequest::AlwaysCache: + return WebCore::ReturnCacheDataDontLoad; + default: + break; + } + return WebCore::UseProtocolCachePolicy; +} + +QWebFrameData::QWebFrameData(WebCore::Page* parentPage, WebCore::Frame* parentFrame, WebCore::HTMLFrameOwnerElement* ownerFrameElement, const WTF::String& frameName) + : name(frameName) + , ownerElement(ownerFrameElement) + , page(parentPage) + , allowsScrolling(true) + , marginWidth(0) + , marginHeight(0) +{ + frameLoaderClient = new FrameLoaderClientQt(); + frame = Frame::create(page, ownerElement, frameLoaderClient); + + // FIXME: All of the below should probably be moved over into WebCore + frame->tree()->setName(name); + if (parentFrame) + parentFrame->tree()->appendChild(frame); +} + +QWebFrameAdapter::QWebFrameAdapter() + : pageAdapter(0) + , allowsScrolling(true) + , marginWidth(-1) + , marginHeight(-1) + , frame(0) + , frameLoaderClient(0) +{ +} + +QWebFrameAdapter::~QWebFrameAdapter() +{ + if (frameLoaderClient) + frameLoaderClient->m_webFrame = 0; +} + +void QWebFrameAdapter::load(const QNetworkRequest& req, QNetworkAccessManager::Operation operation, const QByteArray& body) +{ + if (frame->tree()->parent()) + pageAdapter->insideOpenCall = true; + + QUrl url = ensureAbsoluteUrl(req.url()); + + WebCore::ResourceRequest request(url); + + switch (operation) { + case QNetworkAccessManager::HeadOperation: + request.setHTTPMethod("HEAD"); + break; + case QNetworkAccessManager::GetOperation: + request.setHTTPMethod("GET"); + break; + case QNetworkAccessManager::PutOperation: + request.setHTTPMethod("PUT"); + break; + case QNetworkAccessManager::PostOperation: + request.setHTTPMethod("POST"); + break; + case QNetworkAccessManager::DeleteOperation: + request.setHTTPMethod("DELETE"); + break; + case QNetworkAccessManager::CustomOperation: + request.setHTTPMethod(req.attribute(QNetworkRequest::CustomVerbAttribute).toByteArray().constData()); + break; + case QNetworkAccessManager::UnknownOperation: + // eh? + break; + } + + QVariant cacheLoad = req.attribute(QNetworkRequest::CacheLoadControlAttribute); + if (cacheLoad.isValid()) { + bool ok; + uint cacheLoadValue = cacheLoad.toUInt(&ok); + if (ok) + request.setCachePolicy(cacheLoadControlToCachePolicy(cacheLoadValue)); + } + + QList httpHeaders = req.rawHeaderList(); + for (int i = 0; i < httpHeaders.size(); ++i) { + const QByteArray &headerName = httpHeaders.at(i); + request.addHTTPHeaderField(QString::fromLatin1(headerName), QString::fromLatin1(req.rawHeader(headerName))); + } + + if (!body.isEmpty()) + request.setHTTPBody(WebCore::FormData::create(body.constData(), body.size())); + + frame->loader()->load(request, false); + + if (frame->tree()->parent()) + pageAdapter->insideOpenCall = false; +} + +#if ENABLE(GESTURE_EVENTS) +void QWebFrameAdapter::handleGestureEvent(QGestureEventFacade* gestureEvent) +{ + ASSERT(hasView()); + switch (gestureEvent->type) { + case Qt::TapGesture: + frame->eventHandler()->handleGestureEvent(convertGesture(gestureEvent)); + break; + case Qt::TapAndHoldGesture: + frame->eventHandler()->sendContextMenuEventForGesture(convertGesture(gestureEvent)); + break; + default: + ASSERT_NOT_REACHED(); + } +} +#endif + +WebCore::IntSize QWebFrameAdapter::scrollPosition() const +{ + if (!hasView()) + return IntSize(); + return frame->view()->scrollOffset(); +} + +IntRect QWebFrameAdapter::frameRect() const +{ + if (!hasView()) + return IntRect(); + return frame->view()->frameRect(); +} + +void QWebFrameAdapter::init(QWebPageAdapter* pageAdapter) +{ + QWebFrameData frameData(pageAdapter->page); + init(pageAdapter, &frameData); +} + +void QWebFrameAdapter::init(QWebPageAdapter* pageAdapter, QWebFrameData* frameData) +{ + this->pageAdapter = pageAdapter; + allowsScrolling = frameData->allowsScrolling; + marginWidth = frameData->marginWidth; + marginHeight = frameData->marginHeight; + frame = frameData->frame.get(); + frameLoaderClient = frameData->frameLoaderClient; + frameLoaderClient->setFrame(this, frame); + + frame->init(); +} + +QWebFrameAdapter* QWebFrameAdapter::kit(const Frame* frame) +{ + return static_cast(frame->loader()->client())->webFrame(); +} + +QUrl QWebFrameAdapter::ensureAbsoluteUrl(const QUrl& url) +{ + if (!url.isValid() || !url.isRelative()) + return url; + + // This contains the URL with absolute path but without + // the query and the fragment part. + QUrl baseUrl = QUrl::fromLocalFile(QFileInfo(url.toLocalFile()).absoluteFilePath()); + + // The path is removed so the query and the fragment parts are there. + QString pathRemoved = url.toString(QUrl::RemovePath); + QUrl toResolve(pathRemoved); + + return baseUrl.resolved(toResolve); +} diff --git a/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.h b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.h new file mode 100644 index 00000000000..17c41d53935 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.h @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#ifndef QWebFrameAdapter_h +#define QWebFrameAdapter_h + +#include "FrameLoaderClientQt.h" +#include "PlatformEvent.h" + +#include +#include +#include +#include + +#include +#include + +namespace WebCore { +class Frame; +} + +QT_BEGIN_NAMESPACE +class QPoint; +QT_END_NAMESPACE + +#if ENABLE(GESTURE_EVENTS) +class QGestureEventFacade; +#endif +class QWebFrame; +class QWebPageAdapter; + +class QWebFrameData { +public: + QWebFrameData(WebCore::Page*, WebCore::Frame* parentFrame = 0, WebCore::HTMLFrameOwnerElement* = 0, const WTF::String& frameName = WTF::String()); + + WTF::String name; + WebCore::HTMLFrameOwnerElement* ownerElement; + WebCore::Page* page; + RefPtr frame; + WebCore::FrameLoaderClientQt* frameLoaderClient; + + WTF::String referrer; + bool allowsScrolling; + int marginWidth; + int marginHeight; +}; + +class QWebFrameAdapter { +public: + static QUrl ensureAbsoluteUrl(const QUrl&); + + QWebFrameAdapter(); + virtual ~QWebFrameAdapter(); + + virtual QWebFrame* apiHandle() = 0; + virtual QObject* handle() = 0; + virtual void contentsSizeDidChange(const QSize&) = 0; + virtual int scrollBarPolicy(Qt::Orientation) const = 0; + virtual void emitUrlChanged() = 0; + virtual void didStartProvisionalLoad() = 0; + virtual void didClearWindowObject() = 0; + virtual bool handleProgressFinished(QPoint*) = 0; + virtual void emitInitialLayoutCompleted() = 0; + virtual void emitIconChanged() = 0; + virtual void emitLoadStarted(bool originatingLoad) = 0; + virtual void emitLoadFinished(bool originatingLoad, bool ok) = 0; + virtual QWebFrameAdapter* createChildFrame(QWebFrameData*) = 0; + + void load(const QNetworkRequest&, QNetworkAccessManager::Operation = QNetworkAccessManager::GetOperation, const QByteArray& body = QByteArray()); + inline bool hasView() const { return frame && frame->view(); } +#if ENABLE(GESTURE_EVENTS) + void handleGestureEvent(QGestureEventFacade*); +#endif + QWebFrameAdapter* createFrame(QWebFrameData*); + + WebCore::IntSize scrollPosition() const; + WebCore::IntRect frameRect() const; + QWebPageAdapter* pageAdapter; + +// protected: + bool allowsScrolling; + int marginWidth; + int marginHeight; + +// private: + void init(QWebPageAdapter*); + void init(QWebPageAdapter*, QWebFrameData*); + + WebCore::Frame *frame; + WebCore::FrameLoaderClientQt *frameLoaderClient; + WebCore::KURL url; + + static QWebFrameAdapter* kit(const WebCore::Frame*); + +// friend class ChromeClientQt; +}; + +#endif // QWebFrameAdapter_h diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp new file mode 100644 index 00000000000..3d639d99a86 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "QWebPageAdapter.h" + +#include "Chrome.h" +#include "ChromeClientQt.h" +#include "NotificationPresenterClientQt.h" +#include "QWebFrameAdapter.h" +#include "UndoStepQt.h" +#include "qwebpluginfactory.h" +#include "qwebsettings.h" +#include +#include + +using namespace WebCore; + +bool QWebPageAdapter::drtRun = false; + +QWebPageAdapter::QWebPageAdapter() + : settings(0) + , page(0) + , pluginFactory(0) + , forwardUnsupportedContent(false) + , insideOpenCall(false) + , networkManager(0) +{ +} + +QWebPageAdapter::~QWebPageAdapter() +{ + delete page; + delete settings; + +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) + NotificationPresenterClientQt::notificationPresenter()->removeClient(); +#endif +} + +void QWebPageAdapter::init(Page* page) +{ + this->page = page; + settings = new QWebSettings(page->settings()); + +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) + WebCore::provideNotification(page, NotificationPresenterClientQt::notificationPresenter()); +#endif +} + +void QWebPageAdapter::deletePage() +{ + delete page; + page = 0; +} + +QWebPageAdapter* QWebPageAdapter::kit(Page* page) +{ + return static_cast(page->chrome()->client())->m_webPage; +} + +ViewportArguments QWebPageAdapter::viewportArguments() +{ + return page ? page->viewportArguments() : WebCore::ViewportArguments(); +} + + +void QWebPageAdapter::registerUndoStep(WTF::PassRefPtr step) +{ + createUndoStep(QSharedPointer(new UndoStepQt(step))); +} + +void QWebPageAdapter::setNetworkAccessManager(QNetworkAccessManager *manager) +{ + if (manager == networkManager) + return; + if (networkManager && networkManager->parent() == handle()) + delete networkManager; + networkManager = manager; +} + +QNetworkAccessManager* QWebPageAdapter::networkAccessManager() +{ + if (!networkManager) + networkManager = new QNetworkAccessManager(handle()); + return networkManager; +} diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h new file mode 100644 index 00000000000..f6d6247095e --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#ifndef QWebPageAdapter_h +#define QWebPageAdapter_h + +#include "QWebPageClient.h" +#include "ViewportArguments.h" + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QKeyEvent; +class QNetworkAccessManager; +QT_END_NAMESPACE + +namespace WebCore { +class Page; +class ChromeClientQt; +class GeolocationClientQt; +class UndoStep; +} + +class QtPluginWidgetAdapter; +class QWebFrameAdapter; +class QWebHistoryItem; +class QWebPageClient; +class QWebPluginFactory; +class QWebSecurityOrigin; +class QWebSelectMethod; +class QWebSettings; +class QWebFullScreenVideoHandler; +class UndoStepQt; + + +class QWebPageAdapter { +public: + QWebPageAdapter(); + virtual ~QWebPageAdapter(); + + void init(WebCore::Page*); + // Called manually from ~QWebPage destructor to ensure that + // the QWebPageAdapter and the QWebPagePrivate are intact when + // various destruction callbacks from WebCore::Page::~Page() hit us. + void deletePage(); + + virtual void show() = 0; + virtual void setFocus() = 0; + virtual void unfocus() = 0; + virtual void setWindowRect(const QRect&) = 0; + virtual QSize viewportSize() const = 0; + virtual QWebPageAdapter* createWindow(bool /*dialog*/) = 0; + virtual QObject* handle() = 0; + virtual void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) = 0; + virtual void javaScriptAlert(QWebFrameAdapter*, const QString& msg) = 0; + virtual bool javaScriptConfirm(QWebFrameAdapter*, const QString& msg) = 0; + virtual bool javaScriptPrompt(QWebFrameAdapter*, const QString& msg, const QString& defaultValue, QString* result) = 0; + virtual void printRequested(QWebFrameAdapter*) = 0; + virtual void databaseQuotaExceeded(QWebFrameAdapter*, const QString& databaseName) = 0; + virtual void applicationCacheQuotaExceeded(QWebSecurityOrigin*, quint64 defaultOriginQuota, quint64 totalSpaceNeeded) = 0; + virtual void setToolTip(const QString&) = 0; + virtual QStringList chooseFiles(QWebFrameAdapter*, bool allowMultiple, const QStringList& suggestedFileNames) = 0; + virtual QColor colorSelectionRequested(const QColor& selectedColor) = 0; + virtual QWebSelectMethod* createSelectPopup() = 0; + virtual QRect viewRectRelativeToWindow() = 0; + +#if USE(QT_MULTIMEDIA) + virtual QWebFullScreenVideoHandler* createFullScreenVideoHandler() = 0; +#endif + virtual void geolocationPermissionRequested(QWebFrameAdapter*) = 0; + virtual void geolocationPermissionRequestCancelled(QWebFrameAdapter*) = 0; + virtual void notificationsPermissionRequested(QWebFrameAdapter*) = 0; + virtual void notificationsPermissionRequestCancelled(QWebFrameAdapter*) = 0; + + virtual void respondToChangedContents() = 0; + virtual void respondToChangedSelection() = 0; + virtual void microFocusChanged() = 0; + virtual void triggerCopyAction() = 0; + virtual void triggerActionForKeyEvent(QKeyEvent*) = 0; + virtual void clearUndoStack() = 0; + virtual bool canUndo() const = 0; + virtual bool canRedo() const = 0; + virtual void undo() = 0; + virtual void redo() = 0; + virtual const char* editorCommandForKeyEvent(QKeyEvent*) = 0; + virtual void createUndoStep(QSharedPointer) = 0; + + virtual void updateNavigationActions() = 0; + + virtual QWebFrameAdapter* mainFrameAdapter() = 0; + + virtual QObject* inspectorHandle() = 0; + virtual void setInspectorFrontend(QObject*) = 0; + virtual void setInspectorWindowTitle(const QString&) = 0; + virtual void createWebInspector(QObject** inspectorView, QWebPageAdapter** inspectorPage) = 0; + virtual QStringList menuActionsAsText() = 0; + virtual void emitViewportChangeRequested() = 0; + virtual bool acceptNavigationRequest(QWebFrameAdapter*, const QNetworkRequest&, int type) = 0; + virtual void emitRestoreFrameStateRequested(QWebFrameAdapter *) = 0; + virtual void emitSaveFrameStateRequested(QWebFrameAdapter *, QWebHistoryItem*) = 0; + virtual void emitDownloadRequested(const QNetworkRequest&) = 0; + virtual void emitFrameCreated(QWebFrameAdapter*) = 0; + virtual QString userAgentForUrl(const QUrl&) const = 0; + virtual bool supportsErrorPageExtension() const = 0; + struct ErrorPageOption { + QUrl url; + QWebFrameAdapter* frame; + QString domain; + int error; + QString errorString; + }; + struct ErrorPageReturn { + QString contentType; + QString encoding; + QUrl baseUrl; + QByteArray content; + }; + virtual bool errorPageExtension(ErrorPageOption*, ErrorPageReturn*) = 0; + virtual QtPluginWidgetAdapter* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) = 0; + virtual QtPluginWidgetAdapter* adapterForWidget(QObject*) const = 0; + + + static QWebPageAdapter* kit(WebCore::Page*); + WebCore::ViewportArguments viewportArguments(); + void registerUndoStep(WTF::PassRefPtr); + + void setNetworkAccessManager(QNetworkAccessManager*); + QNetworkAccessManager* networkAccessManager(); + + QWebSettings *settings; + + WebCore::Page *page; + QScopedPointer client; + + QWebPluginFactory *pluginFactory; + + bool forwardUnsupportedContent; + bool insideOpenCall; + +private: + QNetworkAccessManager *networkManager; + +public: + static bool drtRun; + + friend class WebCore::ChromeClientQt; + friend class WebCore::GeolocationClientQt; +}; + +#endif // QWebPageAdapter_h diff --git a/Source/WebKit/qt/WebCoreSupport/QWebUndoCommand.cpp b/Source/WebKit/qt/WebCoreSupport/QWebUndoCommand.cpp new file mode 100644 index 00000000000..a196df50d74 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/QWebUndoCommand.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#include "config.h" +#include "QWebUndoCommand.h" + +#include "UndoStepQt.h" + +#ifndef QT_NO_UNDOCOMMAND +QWebUndoCommand::QWebUndoCommand(QSharedPointer undoStep, QUndoCommand* parent) + : QUndoCommand(parent) + , m_step(undoStep) +{ + Q_ASSERT(undoStep); + setText(m_step->text()); +} + +void QWebUndoCommand::undo() +{ + m_step->undo(); +} + +void QWebUndoCommand::redo() +{ + m_step->redo(); +} + +#endif // QT_NO_UNDOCOMMAND diff --git a/Source/WebKit/qt/WebCoreSupport/QWebUndoCommand.h b/Source/WebKit/qt/WebCoreSupport/QWebUndoCommand.h new file mode 100644 index 00000000000..6e6121adc29 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/QWebUndoCommand.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#ifndef QWebUndoCommand_h +#define QWebUndoCommand_h + +#include +#include + +class UndoStepQt; + +#ifndef QT_NO_UNDOCOMMAND + +class QWebUndoCommand : public QUndoCommand { +public: + QWebUndoCommand(QSharedPointer, QUndoCommand *parent = 0); + + void undo(); + void redo(); + +private: + QSharedPointer m_step; +}; + +#endif // QT_NO_UNDOCOMMAND + +#endif // QWebUndoCommand_h diff --git a/Source/WebKit/qt/WebCoreSupport/QWidgetPluginImpl.cpp b/Source/WebKit/qt/WebCoreSupport/QWidgetPluginImpl.cpp new file mode 100644 index 00000000000..2beabf1d085 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/QWidgetPluginImpl.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "QWidgetPluginImpl.h" + +#include + +QWidgetPluginImpl::~QWidgetPluginImpl() +{ + m_widget->deleteLater(); +} + +void QWidgetPluginImpl::update(const QRect &rect) +{ + m_widget->update(rect); +} + +void QWidgetPluginImpl::setGeometryAndClip(const QRect &geometry, const QRect &clipRect, bool isVisible) +{ + m_widget->setGeometry(geometry); + if (!clipRect.isNull()) { + QRect clip(clipRect.intersected(m_widget->rect())); + m_widget->setMask(QRegion(clip)); + } + m_widget->update(); + setVisible(isVisible); +} + +void QWidgetPluginImpl::setVisible(bool visible) +{ + // If setMask is set with an empty QRegion, no clipping will + // be performed, so in that case we hide the platformWidget. + QRegion mask = m_widget->mask(); + m_widget->setVisible(visible && !mask.isEmpty()); +} + +void QWidgetPluginImpl::setStyleSheet(const QString &stylesheet) +{ + m_widget->setStyleSheet(stylesheet); +} + +void QWidgetPluginImpl::setWidgetParent(QObject *parent) +{ + if (!parent->isWidgetType()) + return; + m_widget->setParent(qobject_cast(parent)); +} + +QObject* QWidgetPluginImpl::handle() const +{ + return m_widget; +} + +#include "moc_QWidgetPluginImpl.cpp" diff --git a/Source/WebKit/qt/WebCoreSupport/QWidgetPluginImpl.h b/Source/WebKit/qt/WebCoreSupport/QWidgetPluginImpl.h new file mode 100644 index 00000000000..7459b7eff58 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/QWidgetPluginImpl.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#ifndef QWidgetPluginImpl_h +#define QWidgetPluginImpl_h + +#include "QtPluginWidgetAdapter.h" + +QT_BEGIN_NAMESPACE +class QWidget; +QT_END_NAMESPACE + +class QWidgetPluginImpl : public QtPluginWidgetAdapter { + Q_OBJECT +public: + QWidgetPluginImpl(QWidget *w) : m_widget(w) { } + virtual ~QWidgetPluginImpl(); + virtual void update(const QRect &) OVERRIDE; + virtual void setGeometryAndClip(const QRect&, const QRect&, bool isVisible) OVERRIDE; + virtual void setVisible(bool) OVERRIDE; + virtual void setStyleSheet(const QString&) OVERRIDE; + virtual void setWidgetParent(QObject *) OVERRIDE; + virtual QObject* handle() const OVERRIDE; +private: + QWidget *m_widget; +}; + +#endif // QWidgetPluginImpl_h diff --git a/Source/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp b/Source/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp index cdc6ee0c996..b2fbf624aa9 100644 --- a/Source/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp +++ b/Source/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp @@ -23,18 +23,18 @@ #ifndef QT_NO_COMBOBOX -#include "ChromeClientQt.h" -#include "QtWebComboBox.h" +#include "QWebPageAdapter.h" #include "QWebPageClient.h" +#include "QtWebComboBox.h" #include "qgraphicswebview.h" #include #include namespace WebCore { -QtFallbackWebPopup::QtFallbackWebPopup(const ChromeClientQt* chromeClient) +QtFallbackWebPopup::QtFallbackWebPopup(const QWebPageAdapter* page) : m_combo(0) - , m_chromeClient(chromeClient) + , m_page(page) { } @@ -63,9 +63,8 @@ void QtFallbackWebPopup::show(const QWebSelectData& data) proxy->setWidget(m_combo); proxy->setGeometry(rect); } else { - m_combo->setParent(pageClient()->ownerWidget()); - m_combo->setGeometry(QRect(rect.left(), rect.top(), - rect.width(), m_combo->sizeHint().height())); + m_combo->setParent(qobject_cast(pageClient()->ownerWidget())); + m_combo->setGeometry(QRect(rect.left(), rect.top(), rect.width(), m_combo->sizeHint().height())); } m_combo->showPopupAtCursorPosition(); @@ -131,7 +130,7 @@ void QtFallbackWebPopup::deleteComboBox() QWebPageClient* QtFallbackWebPopup::pageClient() const { - return m_chromeClient->platformPageClient(); + return m_page->client.data(); } } diff --git a/Source/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h b/Source/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h index f753373be43..69b49bdbf88 100644 --- a/Source/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h +++ b/Source/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h @@ -23,8 +23,6 @@ #include "qwebkitplatformplugin.h" #include -#include - #ifndef QT_NO_COMBOBOX QT_BEGIN_NAMESPACE @@ -32,16 +30,16 @@ class QGraphicsProxyWidget; QT_END_NAMESPACE class QWebPageClient; +class QWebPageAdapter; namespace WebCore { -class ChromeClientQt; class QtWebComboBox; class QtFallbackWebPopup : public QWebSelectMethod { Q_OBJECT public: - QtFallbackWebPopup(const ChromeClientQt*); + QtFallbackWebPopup(const QWebPageAdapter*); ~QtFallbackWebPopup(); virtual void show(const QWebSelectData&); @@ -59,7 +57,7 @@ private Q_SLOTS: private: QtWebComboBox* m_combo; - const ChromeClientQt* m_chromeClient; + const QWebPageAdapter* m_page; QRect m_geometry; QFont m_font; diff --git a/Source/WebKit/qt/WebCoreSupport/QtPluginWidgetAdapter.h b/Source/WebKit/qt/WebCoreSupport/QtPluginWidgetAdapter.h new file mode 100644 index 00000000000..8494d3db2a9 --- /dev/null +++ b/Source/WebKit/qt/WebCoreSupport/QtPluginWidgetAdapter.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#ifndef QtPluginWidgetAdapter_h +#define QtPluginWidgetAdapter_h + +#include +#include +#include + +class QtPluginWidgetAdapter : public QObject { + Q_OBJECT +public: + virtual void update(const QRect&) = 0; + virtual void setGeometryAndClip(const QRect&, const QRect&, bool isVisible = false) = 0; + virtual void setVisible(bool) = 0; + virtual void setStyleSheet(const QString&) = 0; + virtual void setWidgetParent(QObject*) = 0; + virtual QObject* handle() const = 0; +}; + +#endif // QtPluginWidgetAdapter_h diff --git a/Source/WebKit/qt/WebCoreSupport/QtWebComboBox.cpp b/Source/WebKit/qt/WebCoreSupport/QtWebComboBox.cpp index f52465f0dc8..2c22cd476c6 100644 --- a/Source/WebKit/qt/WebCoreSupport/QtWebComboBox.cpp +++ b/Source/WebKit/qt/WebCoreSupport/QtWebComboBox.cpp @@ -41,8 +41,7 @@ QtWebComboBox::QtWebComboBox() void QtWebComboBox::showPopupAtCursorPosition() { - QMouseEvent event(QEvent::MouseButtonPress, QCursor::pos(), Qt::LeftButton, - Qt::LeftButton, Qt::NoModifier); + QMouseEvent event(QEvent::MouseButtonPress, QCursor::pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QCoreApplication::sendEvent(this, &event); } diff --git a/Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h b/Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h index 42647576678..e32427edf4d 100644 --- a/Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h +++ b/Source/WebKit/qt/WebCoreSupport/QtWebComboBox.h @@ -21,9 +21,8 @@ #ifndef QtWebComboBox_h #define QtWebComboBox_h -#include - #include +#include #ifndef QT_NO_COMBOBOX diff --git a/Source/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.h b/Source/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.h index 11a96410528..4ae8582a3f0 100644 --- a/Source/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.h +++ b/Source/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.h @@ -27,7 +27,7 @@ namespace WebCore { class SearchPopupMenuQt : public SearchPopupMenu { public: - SearchPopupMenuQt(PassRefPtr popup); + SearchPopupMenuQt(PassRefPtr); virtual PopupMenu* popupMenu(); virtual void saveRecentSearches(const AtomicString& name, const Vector& searchItems); diff --git a/Source/WebKit/qt/WebCoreSupport/UndoStepQt.cpp b/Source/WebKit/qt/WebCoreSupport/UndoStepQt.cpp index 15df2ee502c..6e2d54f7846 100644 --- a/Source/WebKit/qt/WebCoreSupport/UndoStepQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/UndoStepQt.cpp @@ -20,9 +20,10 @@ #include "config.h" #include "UndoStepQt.h" +#include + using namespace WebCore; -#ifndef QT_NO_UNDOCOMMAND static QString undoNameForEditAction(const EditAction editAction) { switch (editAction) { @@ -106,26 +107,18 @@ static QString undoNameForEditAction(const EditAction editAction) return QString(); } -UndoStepQt::UndoStepQt(WTF::RefPtr step, QUndoCommand *parent) - : QUndoCommand(parent) - , m_step(step) - , m_first(true) -{ - setText(undoNameForEditAction(step->editingAction())); -} -#else UndoStepQt::UndoStepQt(WTF::RefPtr step) : m_step(step) , m_first(true) { + m_text = undoNameForEditAction(step->editingAction()); } -#endif + UndoStepQt::~UndoStepQt() { } - void UndoStepQt::redo() { if (m_first) { @@ -143,5 +136,9 @@ void UndoStepQt::undo() m_step->unapply(); } +QString UndoStepQt::text() const +{ + return m_text; +} // vim: ts=4 sw=4 et diff --git a/Source/WebKit/qt/WebCoreSupport/UndoStepQt.h b/Source/WebKit/qt/WebCoreSupport/UndoStepQt.h index 3c143403a77..85d7991c379 100644 --- a/Source/WebKit/qt/WebCoreSupport/UndoStepQt.h +++ b/Source/WebKit/qt/WebCoreSupport/UndoStepQt.h @@ -20,29 +20,24 @@ #ifndef UndoStepQt_h #define UndoStepQt_h -#include #include + +#include #include -class UndoStepQt -#ifndef QT_NO_UNDOCOMMAND - : public QUndoCommand -#endif -{ +class UndoStepQt { public: -#ifndef QT_NO_UNDOCOMMAND - UndoStepQt(WTF::RefPtr step, QUndoCommand *parent = 0); -#else - UndoStepQt(WTF::RefPtr step); -#endif + UndoStepQt(WTF::RefPtr); ~UndoStepQt(); void redo(); void undo(); + QString text() const; private: WTF::RefPtr m_step; bool m_first; + QString m_text; }; #endif diff --git a/Source/WebKit/qt/WebCoreSupport/WebEventConversion.cpp b/Source/WebKit/qt/WebCoreSupport/WebEventConversion.cpp index d6159241e4f..4449c15570e 100644 --- a/Source/WebKit/qt/WebCoreSupport/WebEventConversion.cpp +++ b/Source/WebKit/qt/WebCoreSupport/WebEventConversion.cpp @@ -27,13 +27,8 @@ #include "PlatformTouchEvent.h" #include "PlatformTouchPoint.h" #include "PlatformWheelEvent.h" -#include -#include -#include -#include #include #include -#include #include namespace WebCore { @@ -53,54 +48,28 @@ static void mouseEventModifiersFromQtKeyboardModifiers(Qt::KeyboardModifiers key static void mouseEventTypeAndMouseButtonFromQEvent(const QEvent* event, PlatformEvent::Type& mouseEventType, MouseButton& mouseButton) { - enum { MouseEvent, GraphicsSceneMouseEvent } frameworkMouseEventType; switch (event->type()) { case QEvent::MouseButtonDblClick: case QEvent::MouseButtonPress: - frameworkMouseEventType = MouseEvent; mouseEventType = PlatformEvent::MousePressed; break; case QEvent::MouseButtonRelease: - frameworkMouseEventType = MouseEvent; mouseEventType = PlatformEvent::MouseReleased; break; case QEvent::MouseMove: - frameworkMouseEventType = MouseEvent; - mouseEventType = PlatformEvent::MouseMoved; - break; - case QEvent::GraphicsSceneMouseDoubleClick: - case QEvent::GraphicsSceneMousePress: - frameworkMouseEventType = GraphicsSceneMouseEvent; - mouseEventType = PlatformEvent::MousePressed; - break; - case QEvent::GraphicsSceneMouseRelease: - frameworkMouseEventType = GraphicsSceneMouseEvent; - mouseEventType = PlatformEvent::MouseReleased; - break; - case QEvent::GraphicsSceneMouseMove: - frameworkMouseEventType = GraphicsSceneMouseEvent; mouseEventType = PlatformEvent::MouseMoved; break; default: ASSERT_NOT_REACHED(); - frameworkMouseEventType = MouseEvent; mouseEventType = PlatformEvent::MouseMoved; break; } Qt::MouseButtons mouseButtons; - switch (frameworkMouseEventType) { - case MouseEvent: { - const QMouseEvent* mouseEvent = static_cast(event); - mouseButtons = mouseEventType == PlatformEvent::MouseMoved ? mouseEvent->buttons() : mouseEvent->button(); - break; - } - case GraphicsSceneMouseEvent: { - const QGraphicsSceneMouseEvent* mouseEvent = static_cast(event); - mouseButtons = mouseEventType == PlatformEvent::MouseMoved ? mouseEvent->buttons() : mouseEvent->button(); - break; - } - } + + const QMouseEvent* mouseEvent = static_cast(event); + mouseButtons = mouseEventType == PlatformEvent::MouseMoved ? mouseEvent->buttons() : mouseEvent->button(); + if (mouseButtons & Qt::LeftButton) mouseButton = LeftButton; @@ -114,27 +83,9 @@ static void mouseEventTypeAndMouseButtonFromQEvent(const QEvent* event, Platform class WebKitPlatformMouseEvent : public PlatformMouseEvent { public: - WebKitPlatformMouseEvent(QGraphicsSceneMouseEvent*, int clickCount); WebKitPlatformMouseEvent(QInputEvent*, int clickCount); }; -WebKitPlatformMouseEvent::WebKitPlatformMouseEvent(QGraphicsSceneMouseEvent* event, int clickCount) -{ - m_timestamp = WTF::currentTime(); - - // FIXME: Why don't we handle a context menu event here as we do in PlatformMouseEvent(QInputEvent*, int)? - // See . - PlatformEvent::Type type; - mouseEventTypeAndMouseButtonFromQEvent(event, type, m_button); - - m_type = type; - m_position = IntPoint(event->pos().toPoint()); - m_globalPosition = IntPoint(event->screenPos()); - - m_clickCount = clickCount; - mouseEventModifiersFromQtKeyboardModifiers(event->modifiers(), m_modifiers); -} - WebKitPlatformMouseEvent::WebKitPlatformMouseEvent(QInputEvent* event, int clickCount) { m_timestamp = WTF::currentTime(); @@ -169,21 +120,15 @@ PlatformMouseEvent convertMouseEvent(QInputEvent* event, int clickCount) return WebKitPlatformMouseEvent(event, clickCount); } -PlatformMouseEvent convertMouseEvent(QGraphicsSceneMouseEvent* event, int clickCount) -{ - return WebKitPlatformMouseEvent(event, clickCount); -} - class WebKitPlatformWheelEvent : public PlatformWheelEvent { public: - WebKitPlatformWheelEvent(QGraphicsSceneWheelEvent*); - WebKitPlatformWheelEvent(QWheelEvent*); + WebKitPlatformWheelEvent(QWheelEvent*, int wheelScrollLines); private: - void applyDelta(int delta, Qt::Orientation); + void applyDelta(int delta, Qt::Orientation, int wheelScrollLines); }; -void WebKitPlatformWheelEvent::applyDelta(int delta, Qt::Orientation orientation) +void WebKitPlatformWheelEvent::applyDelta(int delta, Qt::Orientation orientation, int wheelScrollLines) { if (orientation == Qt::Horizontal) { m_deltaX = delta; @@ -198,22 +143,11 @@ void WebKitPlatformWheelEvent::applyDelta(int delta, Qt::Orientation orientation // Since we request the scroll delta by the pixel, convert the wheel delta to pixel delta using the standard scroll step. // Use the same single scroll step as QTextEdit (in QTextEditPrivate::init [h,v]bar->setSingleStep) static const float cDefaultQtScrollStep = 20.f; - m_deltaX = m_wheelTicksX * QApplication::wheelScrollLines() * cDefaultQtScrollStep; - m_deltaY = m_wheelTicksY * QApplication::wheelScrollLines() * cDefaultQtScrollStep; + m_deltaX = m_wheelTicksX * wheelScrollLines * cDefaultQtScrollStep; + m_deltaY = m_wheelTicksY * wheelScrollLines * cDefaultQtScrollStep; } -WebKitPlatformWheelEvent::WebKitPlatformWheelEvent(QGraphicsSceneWheelEvent* e) -{ - m_timestamp = WTF::currentTime(); - mouseEventModifiersFromQtKeyboardModifiers(e->modifiers(), m_modifiers); - m_position = e->pos().toPoint(); - m_globalPosition = e->screenPos(); - m_granularity = ScrollByPixelWheelEvent; - m_directionInvertedFromDevice = false; - applyDelta(e->delta(), e->orientation()); -} - -WebKitPlatformWheelEvent::WebKitPlatformWheelEvent(QWheelEvent* e) +WebKitPlatformWheelEvent::WebKitPlatformWheelEvent(QWheelEvent* e, int wheelScrollLines) { m_timestamp = WTF::currentTime(); mouseEventModifiersFromQtKeyboardModifiers(e->modifiers(), m_modifiers); @@ -221,7 +155,7 @@ WebKitPlatformWheelEvent::WebKitPlatformWheelEvent(QWheelEvent* e) m_globalPosition = e->globalPos(); m_granularity = ScrollByPixelWheelEvent; m_directionInvertedFromDevice = false; - applyDelta(e->delta(), e->orientation()); + applyDelta(e->delta(), e->orientation(), wheelScrollLines); } #if ENABLE(TOUCH_EVENTS) @@ -309,43 +243,35 @@ WebKitPlatformTouchPoint::WebKitPlatformTouchPoint(const QTouchEvent::TouchPoint #if ENABLE(GESTURE_EVENTS) class WebKitPlatformGestureEvent : public PlatformGestureEvent { public: - WebKitPlatformGestureEvent(const QGestureEvent*, const QGesture*); + WebKitPlatformGestureEvent(QGestureEventFacade*); }; -WebKitPlatformGestureEvent::WebKitPlatformGestureEvent(const QGestureEvent* event, const QGesture* gesture) +static inline PlatformEvent::Type toPlatformEventType(Qt::GestureType type) { - switch (gesture->gestureType()) { - case Qt::TapGesture: { - m_type = PlatformEvent::GestureTap; - QPointF globalPos = static_cast(gesture)->position(); - m_globalPosition = globalPos.toPoint(); - m_position = event->widget()->mapFromGlobal(globalPos.toPoint()); - break; - } - case Qt::TapAndHoldGesture: { - m_type = PlatformEvent::GestureLongPress; - QPointF globalPos = static_cast(gesture)->position(); - m_globalPosition = globalPos.toPoint(); - m_position = event->widget()->mapFromGlobal(globalPos.toPoint()); - break; - } + switch (type) { + case Qt::TapGesture: + return PlatformEvent::GestureTap; + case Qt::TapAndHoldGesture: + return PlatformEvent::GestureLongPress; default: ASSERT_NOT_REACHED(); - break; + return PlatformEvent::NoType; } - m_timestamp = WTF::currentTime(); } -#endif - -PlatformWheelEvent convertWheelEvent(QWheelEvent* event) +WebKitPlatformGestureEvent::WebKitPlatformGestureEvent(QGestureEventFacade* event) { - return WebKitPlatformWheelEvent(event); + m_type = toPlatformEventType(event->type); + m_globalPosition = event->globalPos; + m_position = event->pos; + m_timestamp = WTF::currentTime(); } -PlatformWheelEvent convertWheelEvent(QGraphicsSceneWheelEvent* event) +#endif + +PlatformWheelEvent convertWheelEvent(QWheelEvent* event, int wheelScrollLines) { - return WebKitPlatformWheelEvent(event); + return WebKitPlatformWheelEvent(event, wheelScrollLines); } #if ENABLE(TOUCH_EVENTS) @@ -356,10 +282,9 @@ PlatformTouchEvent convertTouchEvent(QTouchEvent* event) #endif #if ENABLE(GESTURE_EVENTS) -PlatformGestureEvent convertGesture(QGestureEvent* event, QGesture* gesture) +PlatformGestureEvent convertGesture(QGestureEventFacade* event) { - return WebKitPlatformGestureEvent(event, gesture); + return WebKitPlatformGestureEvent(event); } #endif - } diff --git a/Source/WebKit/qt/WebCoreSupport/WebEventConversion.h b/Source/WebKit/qt/WebCoreSupport/WebEventConversion.h index 3224eee9096..0cf8cd84960 100644 --- a/Source/WebKit/qt/WebCoreSupport/WebEventConversion.h +++ b/Source/WebKit/qt/WebCoreSupport/WebEventConversion.h @@ -19,27 +19,30 @@ Boston, MA 02110-1301, USA. */ -#include +#ifndef WebEventConversion_h +#define WebEventConversion_h + +#include QT_BEGIN_NAMESPACE class QInputEvent; -class QGraphicsSceneMouseEvent; class QWheelEvent; -class QGraphicsSceneWheelEvent; class QTouchEvent; -class QGesture; -class QGestureEvent; QT_END_NAMESPACE +struct QGestureEventFacade { + Qt::GestureType type; + QPoint globalPos; + QPoint pos; +}; + namespace WebCore { class PlatformMouseEvent; class PlatformWheelEvent; PlatformMouseEvent convertMouseEvent(QInputEvent*, int clickCount); -PlatformMouseEvent convertMouseEvent(QGraphicsSceneMouseEvent*, int clickCount); -PlatformWheelEvent convertWheelEvent(QWheelEvent*); -PlatformWheelEvent convertWheelEvent(QGraphicsSceneWheelEvent*); +PlatformWheelEvent convertWheelEvent(QWheelEvent*, int wheelScrollLines); #if ENABLE(TOUCH_EVENTS) class PlatformTouchEvent; @@ -48,6 +51,8 @@ PlatformTouchEvent convertTouchEvent(QTouchEvent*); #if ENABLE(GESTURE_EVENTS) class PlatformGestureEvent; -PlatformGestureEvent convertGesture(QGestureEvent*, QGesture*); +PlatformGestureEvent convertGesture(QGestureEventFacade*); #endif } + +#endif diff --git a/Source/WebKit/qt/WebCoreSupport/WebSystemInterface.h b/Source/WebKit/qt/WebCoreSupport/WebSystemInterface.h index 467b5ba374f..9b03d4afcb2 100644 --- a/Source/WebKit/qt/WebCoreSupport/WebSystemInterface.h +++ b/Source/WebKit/qt/WebCoreSupport/WebSystemInterface.h @@ -26,6 +26,11 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef WebSystemInterface_h +#define WebSystemInterface_h + #include void InitWebCoreSystemInterface(); + +#endif diff --git a/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index ff40b55f039..fd82c287614 100644 --- a/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -548,7 +548,7 @@ void tst_QWebPage::loadHtml5Video() QByteArray url("http://does.not/exist?a=1%2Cb=2"); m_view->setHtml("

"); QTest::qWait(2000); - QUrl mUrl = DumpRenderTreeSupportQt::mediaContentUrlByElementId(m_page->mainFrame(), "video"); + QUrl mUrl = DumpRenderTreeSupportQt::mediaContentUrlByElementId(m_page->mainFrame()->handle(), "video"); QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=65452", Continue); QCOMPARE(mUrl.toEncoded(), url); #else @@ -1026,12 +1026,12 @@ void tst_QWebPage::multiplePageGroupsAndLocalStorage() view1.page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); view1.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(tmpDirPath() + "/path1")); - DumpRenderTreeSupportQt::webPageSetGroupName(view1.page(), "group1"); + DumpRenderTreeSupportQt::webPageSetGroupName(view1.page()->handle(), "group1"); view2.page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); view2.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(tmpDirPath() + "/path2")); - DumpRenderTreeSupportQt::webPageSetGroupName(view2.page(), "group2"); - QCOMPARE(DumpRenderTreeSupportQt::webPageGroupName(view1.page()), QString("group1")); - QCOMPARE(DumpRenderTreeSupportQt::webPageGroupName(view2.page()), QString("group2")); + DumpRenderTreeSupportQt::webPageSetGroupName(view2.page()->handle(), "group2"); + QCOMPARE(DumpRenderTreeSupportQt::webPageGroupName(view1.page()->handle()), QString("group1")); + QCOMPARE(DumpRenderTreeSupportQt::webPageGroupName(view2.page()->handle()), QString("group2")); view1.setHtml(QString(" "), QUrl("http://www.myexample.com")); @@ -3062,35 +3062,35 @@ void tst_QWebPage::thirdPartyCookiePolicy() QVERIFY(m_page->networkAccessManager()->cookieJar()); // These are all first-party cookies, so should pass. - QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://www.example.com"), QUrl("http://example.com"))); - QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://www.example.com"), QUrl("http://doc.example.com"))); - QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://aaa.www.example.com"), QUrl("http://doc.example.com"))); - QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://example.com"), QUrl("http://www.example.com"))); - QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://www.example.co.uk"), QUrl("http://example.co.uk"))); - QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://www.example.co.uk"), QUrl("http://doc.example.co.uk"))); - QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://aaa.www.example.co.uk"), QUrl("http://doc.example.co.uk"))); - QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://example.co.uk"), QUrl("http://www.example.co.uk"))); // These are all third-party cookies, so should fail. - QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://www.example.com"), QUrl("http://slashdot.org"))); - QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://example.com"), QUrl("http://anotherexample.com"))); - QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://anotherexample.com"), QUrl("http://example.com"))); - QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://www.example.co.uk"), QUrl("http://slashdot.co.uk"))); - QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://example.co.uk"), QUrl("http://anotherexample.co.uk"))); - QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page, + QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(), QUrl("http://anotherexample.co.uk"), QUrl("http://example.co.uk"))); } diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index ac8d8893673..dda5c094943 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,44 @@ +2012-11-22 Simon Hausmann , Pierre Rossi + + [Qt] Separate QWidget dependant code into separate WebKitWidgets static library + https://bugs.webkit.org/show_bug.cgi?id=102800 + + Reviewed by Tor Arne Vestbø. + + This patch separates code that needs to use QWidget related APIs in + WebKit/qt/WebCoreSupport and Api from code that doesn't. This means for + example FrameLoaderClientQt.cpp remains in the WebKit1 static library, + while qwebpage.cpp and qwebframe.cpp become part of the WebKitWidgets + static library. WebKit1 is compiled without QT += widgets and therefore + any widget related dependency has been moved "up" and out of WebKit1 into + the WebKitWidgets library. + + Between the code in WebKit.a and WebKitWidgets.a new adapters and + interfaces have been introduced, such as QWebPageAdapter and + QWebFrameAdapter. QWebPageAdapter, when used from WebKit1, is a way to + call out into the API layer, implemented by QWebPage (QWebPagePrivate). + The other way around if QWebPage wants to access WebCore or + WebCoreSupport related functionality, it will go through + QWebPageAdapater (as base class). The separation in the direction up + into the API layer is complete with this patch, no code in WebKit1 + depends on QtWidgets. The separation the other way around, code in the + API layer not using any WebCore types, is not complete yet. + + Some classes such as QWebSettings, QWebElement or + DumpRenderTreeSupportQt remain in WebKit1. While they are API layer, + they do not depend on widget related Qt APIs and they make much more + use of WebCore internal APIs and therefore are easier to keep in + WebKit1. + + In the future we plan to place a real shared library boundary between + WebKit1 and WebKitWidgets, by keeping the WebKit1 static library as + part of the QtWebKit shared library and by turning the WebKitWidgets + static library into a shared one. + + * qt/MainQt.cpp: + (WebKit): + (main): + 2012-11-22 Kenneth Rohde Christiansen [WK2][EFL] No need to remove surface before replacing diff --git a/Source/WebKit2/qt/MainQt.cpp b/Source/WebKit2/qt/MainQt.cpp index 1e1ce2b3d01..0990c01f872 100644 --- a/Source/WebKit2/qt/MainQt.cpp +++ b/Source/WebKit2/qt/MainQt.cpp @@ -42,9 +42,10 @@ typedef QApplication ApplicationType; namespace WebKit { Q_DECL_IMPORT int WebProcessMainQt(QGuiApplication*); -#if defined(HAVE_WEBKIT1) -Q_DECL_IMPORT void initializeWebKit2Theme(); +#if !defined(QT_NO_WIDGETS) +Q_DECL_IMPORT void initializeWebKitWidgets(); #endif +Q_DECL_IMPORT void initializeWebKitQt(); } #if !defined(NDEBUG) && defined(Q_OS_UNIX) @@ -82,15 +83,23 @@ int main(int argc, char** argv) } #endif -#if defined(HAVE_WEBKIT1) - WebKit::initializeWebKit2Theme(); -#endif - // Has to be done before QApplication is constructed in case // QApplication itself produces debug output. QByteArray suppressOutput = qgetenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT"); if (!suppressOutput.isEmpty() && suppressOutput != "0") qInstallMessageHandler(messageHandler); - return WebKit::WebProcessMainQt(new ApplicationType(argc, argv)); + // QApplication must be created before we call initializeWebKitWidgets() so that + // the standard pixmaps can be fetched from the style. + ApplicationType* appInstance = new ApplicationType(argc, argv); + +#if !defined(QT_NO_WIDGETS) + if (qgetenv("QT_WEBKIT_THEME_NAME") == "qstyle") + WebKit::initializeWebKitWidgets(); + else +#endif + WebKit::initializeWebKitQt(); + + + return WebKit::WebProcessMainQt(appInstance); } diff --git a/Source/api.pri b/Source/api.pri index a47b7359de8..f6c3c3c75f7 100644 --- a/Source/api.pri +++ b/Source/api.pri @@ -14,12 +14,15 @@ WEBKIT_DESTDIR = $${ROOT_BUILD_DIR}/lib WEBKIT += wtf javascriptcore webcore -build?(webkit1): WEBKIT += webkit1 +build?(webkit1): WEBKIT += webkitwidgets webkit1 build?(webkit2): WEBKIT += webkit2 # Ensure that changes to the WebKit1 and WebKit2 API will trigger a qmake of this # file, which in turn runs syncqt to update the forwarding headers. -build?(webkit1): QMAKE_INTERNAL_INCLUDED_FILES *= WebKit/WebKit1.pro +build?(webkit1): { + QMAKE_INTERNAL_INCLUDED_FILES *= WebKit/WebKit1.pro + QMAKE_INTERNAL_INCLUDED_FILES *= WebKit/WebKitWidgets.pro +} build?(webkit2): QMAKE_INTERNAL_INCLUDED_FILES *= WebKit2/Target.pri use?(3D_GRAPHICS): WEBKIT += angle diff --git a/Tools/ChangeLog b/Tools/ChangeLog index 01635736127..13b7c979445 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,98 @@ +2012-11-22 Simon Hausmann , Pierre Rossi + + [Qt] Separate QWidget dependant code into separate WebKitWidgets static library + https://bugs.webkit.org/show_bug.cgi?id=102800 + + Reviewed by Tor Arne Vestbø. + + This patch separates code that needs to use QWidget related APIs in + WebKit/qt/WebCoreSupport and Api from code that doesn't. This means for + example FrameLoaderClientQt.cpp remains in the WebKit1 static library, + while qwebpage.cpp and qwebframe.cpp become part of the WebKitWidgets + static library. WebKit1 is compiled without QT += widgets and therefore + any widget related dependency has been moved "up" and out of WebKit1 into + the WebKitWidgets library. + + Between the code in WebKit.a and WebKitWidgets.a new adapters and + interfaces have been introduced, such as QWebPageAdapter and + QWebFrameAdapter. QWebPageAdapter, when used from WebKit1, is a way to + call out into the API layer, implemented by QWebPage (QWebPagePrivate). + The other way around if QWebPage wants to access WebCore or + WebCoreSupport related functionality, it will go through + QWebPageAdapater (as base class). The separation in the direction up + into the API layer is complete with this patch, no code in WebKit1 + depends on QtWidgets. The separation the other way around, code in the + API layer not using any WebCore types, is not complete yet. + + Some classes such as QWebSettings, QWebElement or + DumpRenderTreeSupportQt remain in WebKit1. While they are API layer, + they do not depend on widget related Qt APIs and they make much more + use of WebCore internal APIs and therefore are easier to keep in + WebKit1. + + In the future we plan to place a real shared library boundary between + WebKit1 and WebKitWidgets, by keeping the WebKit1 static library as + part of the QtWebKit shared library and by turning the WebKitWidgets + static library into a shared one. + + * DumpRenderTree/qt/DumpRenderTreeQt.cpp: + (WebCore::WebPage::resetSettings): + (WebCore::WebPage::createWindow): + (WebCore::DumpRenderTree::DumpRenderTree): + (WebCore::DumpRenderTree::resetToConsistentStateBeforeTesting): + (WebCore::DumpRenderTree::initJSObjects): + (WebCore::DumpRenderTree::dumpFrameScrollPosition): + (WebCore::DumpRenderTree::dumpFramesAsText): + (WebCore::DumpRenderTree::dump): + (WebCore::DumpRenderTree::createWindow): + (WebCore::DumpRenderTree::pageAdapter): + (WebCore): + (WebCore::DumpRenderTree::mainFrameAdapter): + * DumpRenderTree/qt/DumpRenderTreeQt.h: + (DumpRenderTree): + * DumpRenderTree/qt/EventSenderQt.cpp: + (EventSender::contextClick): + (EventSender::scalePageBy): + * DumpRenderTree/qt/TestRunnerQt.cpp: + (TestRunner::reset): + (TestRunner::display): + (TestRunner::closeWebInspector): + (TestRunner::showWebInspector): + (TestRunner::evaluateInWebInspector): + (TestRunner::setFrameFlatteningEnabled): + (TestRunner::goBack): + (TestRunner::setDefersLoading): + (TestRunner::pauseAnimationAtTimeOnElementWithId): + (TestRunner::pauseTransitionAtTimeOnElementWithId): + (TestRunner::numberOfActiveAnimations): + (TestRunner::setCaretBrowsingEnabled): + (TestRunner::setAuthorAndUserStylesEnabled): + (TestRunner::callShouldCloseOnWebView): + (TestRunner::setSmartInsertDeleteEnabled): + (TestRunner::setSelectTrailingWhitespaceEnabled): + (TestRunner::execCommand): + (TestRunner::isCommandEnabled): + (TestRunner::findString): + (TestRunner::elementDoesAutoCompleteForElementWithId): + (TestRunner::setMockDeviceOrientation): + (TestRunner::setGeolocationPermission): + (TestRunner::numberOfPendingGeolocationPermissionRequests): + (TestRunner::setMockGeolocationPositionUnavailableError): + (TestRunner::setMockGeolocationPosition): + (TestRunner::evaluateScriptInIsolatedWorld): + (TestRunner::addUserStyleSheet): + (TestRunner::setMinimumTimerInterval): + * DumpRenderTree/qt/TextInputControllerQt.cpp: + (TextInputController::selectedRange): + (TextInputController::firstRectForCharacterRange): + (TextInputController::unmarkText): + * DumpRenderTree/qt/WorkQueueItemQt.cpp: + (LoadAlternateHTMLStringItem::invoke): + * qmake/mkspecs/features/default_post.prf: + * qmake/mkspecs/features/production_build.prf: + * qmake/mkspecs/features/webkit_modules.prf: + * qmake/mkspecs/modules/webkitwidgets.prf: Added. + 2012-11-22 Christophe Dumez WebKitTestRunner needs layoutTestController.setCacheModel diff --git a/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp index 34ee5ad4a1e..16c237866e1 100755 --- a/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp +++ b/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp @@ -36,6 +36,7 @@ #include "DumpRenderTreeSupportQt.h" #include "EventSenderQt.h" #include "GCControllerQt.h" +#include "InitWebKitQt.h" #include "QtTestSupport.h" #include "TestRunnerQt.h" #include "TextInputControllerQt.h" @@ -62,19 +63,14 @@ #include #include #include - -#include -#include - #include #include - +#include +#include #ifndef Q_OS_WIN #include #endif -#include - namespace WebCore { const int databaseDefaultQuota = 5 * 1024 * 1024; @@ -206,14 +202,14 @@ void WebPage::resetSettings() QWebSettings::setMaximumPagesInCache(0); // reset to default settings()->setUserStyleSheetUrl(QUrl()); // reset to default - DumpRenderTreeSupportQt::setMinimumTimerInterval(this, DumpRenderTreeSupportQt::defaultMinimumTimerInterval()); + DumpRenderTreeSupportQt::setMinimumTimerInterval(handle(), DumpRenderTreeSupportQt::defaultMinimumTimerInterval()); - DumpRenderTreeSupportQt::resetInternalsObject(mainFrame()); + DumpRenderTreeSupportQt::resetInternalsObject(mainFrame()->handle()); m_pendingGeolocationRequests.clear(); } -QWebPage *WebPage::createWindow(QWebPage::WebWindowType) +QWebPage* WebPage::createWindow(QWebPage::WebWindowType) { return m_drt->createWindow(); } @@ -399,6 +395,7 @@ DumpRenderTree::DumpRenderTree() if (viewMode == "graphics") setGraphicsBased(true); + WebKit::initializeWebKitWidgets(); DumpRenderTreeSupportQt::initialize(); // Set running in DRT mode for qwebpage to create testable objects. @@ -421,7 +418,7 @@ DumpRenderTree::DumpRenderTree() } // Use a frame group name for all pages created by DumpRenderTree to allow // testing of cross-page frame lookup. - DumpRenderTreeSupportQt::webPageSetGroupName(m_page, "org.webkit.qt.DumpRenderTree"); + DumpRenderTreeSupportQt::webPageSetGroupName(pageAdapter(), "org.webkit.qt.DumpRenderTree"); m_mainView->setContextMenuPolicy(Qt::NoContextMenu); m_mainView->resize(QSize(TestRunner::maxViewWidth, TestRunner::maxViewHeight)); @@ -470,7 +467,7 @@ DumpRenderTree::DumpRenderTree() QObject::connect(this, SIGNAL(quit()), qApp, SLOT(quit()), Qt::QueuedConnection); DumpRenderTreeSupportQt::setDumpRenderTreeModeEnabled(true); - DumpRenderTreeSupportQt::setInteractiveFormValidationEnabled(webPage(), true); + DumpRenderTreeSupportQt::setInteractiveFormValidationEnabled(pageAdapter(), true); DumpRenderTreeSupportQt::enableMockScrollbars(); QFocusEvent event(QEvent::FocusIn, Qt::ActiveWindowFocusReason); @@ -541,9 +538,9 @@ void DumpRenderTree::resetToConsistentStateBeforeTesting(const QUrl& url) #endif clearHistory(m_page); - DumpRenderTreeSupportQt::scalePageBy(m_page->mainFrame(), 1, QPoint(0, 0)); - DumpRenderTreeSupportQt::clearFrameName(m_page->mainFrame()); - DumpRenderTreeSupportQt::removeUserStyleSheets(m_page); + DumpRenderTreeSupportQt::scalePageBy(mainFrameAdapter(), 1, QPoint(0, 0)); + DumpRenderTreeSupportQt::clearFrameName(mainFrameAdapter()); + DumpRenderTreeSupportQt::removeUserStyleSheets(pageAdapter()); m_page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); m_page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded); @@ -561,7 +558,7 @@ void DumpRenderTree::resetToConsistentStateBeforeTesting(const QUrl& url) DumpRenderTreeSupportQt::resetOriginAccessWhiteLists(); - DumpRenderTreeSupportQt::setWindowsBehaviorAsEditingBehavior(m_page); + DumpRenderTreeSupportQt::setWindowsBehaviorAsEditingBehavior(pageAdapter()); QLocale::setDefault(QLocale::c()); @@ -570,7 +567,7 @@ void DumpRenderTree::resetToConsistentStateBeforeTesting(const QUrl& url) setlocale(LC_ALL, ""); #endif - DumpRenderTreeSupportQt::clearOpener(m_page->mainFrame()); + DumpRenderTreeSupportQt::clearOpener(mainFrameAdapter()); } static bool isGlobalHistoryTest(const QUrl& url) @@ -739,7 +736,7 @@ void DumpRenderTree::initJSObjects() frame->addToJavaScriptWindowObject(QLatin1String("eventSender"), m_eventSender); frame->addToJavaScriptWindowObject(QLatin1String("textInputController"), m_textInputController); frame->addToJavaScriptWindowObject(QLatin1String("GCController"), m_gcController); - DumpRenderTreeSupportQt::injectInternalsObject(frame); + DumpRenderTreeSupportQt::injectInternalsObject(frame->handle()); } void DumpRenderTree::showPage() @@ -757,7 +754,7 @@ void DumpRenderTree::hidePage() QString DumpRenderTree::dumpFrameScrollPosition(QWebFrame* frame) { - if (!frame || !DumpRenderTreeSupportQt::hasDocumentElement(frame)) + if (!frame || !DumpRenderTreeSupportQt::hasDocumentElement(frame->handle())) return QString(); QString result; @@ -779,7 +776,7 @@ QString DumpRenderTree::dumpFrameScrollPosition(QWebFrame* frame) QString DumpRenderTree::dumpFramesAsText(QWebFrame* frame) { - if (!frame || !DumpRenderTreeSupportQt::hasDocumentElement(frame)) + if (!frame || !DumpRenderTreeSupportQt::hasDocumentElement(frame->handle())) return QString(); QString result; @@ -907,7 +904,7 @@ void DumpRenderTree::dump() fprintf(stdout, "Source:\n\n%s\n", markup.toUtf8().constData()); } - QString mimeType = DumpRenderTreeSupportQt::responseMimeType(mainFrame); + QString mimeType = DumpRenderTreeSupportQt::responseMimeType(mainFrame->handle()); if (mimeType == "text/plain") m_controller->dumpAsText(); @@ -947,11 +944,11 @@ void DumpRenderTree::dump() mainFrame->render(&painter); painter.end(); } else - image = DumpRenderTreeSupportQt::paintPagesWithBoundaries(mainFrame); + image = DumpRenderTreeSupportQt::paintPagesWithBoundaries(mainFrame->handle()); - if (DumpRenderTreeSupportQt::trackRepaintRects(m_page->mainFrame())) { + if (DumpRenderTreeSupportQt::trackRepaintRects(mainFrameAdapter())) { QVector repaintRects; - DumpRenderTreeSupportQt::getTrackedRepaintRects(m_page->mainFrame(), repaintRects); + DumpRenderTreeSupportQt::getTrackedRepaintRects(mainFrameAdapter(), repaintRects); QImage mask(image.size(), image.format()); mask.fill(QColor(0, 0, 0, 0.66 * 255)); @@ -963,7 +960,7 @@ void DumpRenderTree::dump() QPainter painter(&image); painter.drawImage(image.rect(), mask); - DumpRenderTreeSupportQt::setTrackRepaintRects(m_page->mainFrame(), false); + DumpRenderTreeSupportQt::setTrackRepaintRects(mainFrameAdapter(), false); } QCryptographicHash hash(QCryptographicHash::Md5); @@ -1098,7 +1095,7 @@ QWebPage *DumpRenderTree::createWindow() // Use a frame group name for all pages created by DumpRenderTree to allow // testing of cross-page frame lookup. - DumpRenderTreeSupportQt::webPageSetGroupName(page, "org.webkit.qt.DumpRenderTree"); + DumpRenderTreeSupportQt::webPageSetGroupName(page->handle(), "org.webkit.qt.DumpRenderTree"); return page; } @@ -1134,6 +1131,16 @@ void DumpRenderTree::switchFocus(bool focused) } +QWebPageAdapter* DumpRenderTree::pageAdapter() const +{ + return m_page->handle(); +} + +QWebFrameAdapter* DumpRenderTree::mainFrameAdapter() const +{ + return m_page->mainFrame()->handle(); +} + QList DumpRenderTree::getAllPages() const { QList pages; diff --git a/Tools/DumpRenderTree/qt/DumpRenderTreeQt.h b/Tools/DumpRenderTree/qt/DumpRenderTreeQt.h index 98429c44ec9..5b88b527662 100644 --- a/Tools/DumpRenderTree/qt/DumpRenderTreeQt.h +++ b/Tools/DumpRenderTree/qt/DumpRenderTreeQt.h @@ -53,7 +53,8 @@ class QUrl; class QFile; QT_END_NAMESPACE -class QWebFrame; +class QWebFrameAdapter; +class QWebPageAdapter; class TestRunner; class DumpRenderTreeSupportQt; @@ -97,6 +98,9 @@ Q_OBJECT void switchFocus(bool focused); WebPage *webPage() const { return m_page; } + QWebPageAdapter *pageAdapter() const; + QWebFrameAdapter *mainFrameAdapter() const; + QList getAllPages() const; void processArgsLine(const QStringList&); diff --git a/Tools/DumpRenderTree/qt/EventSenderQt.cpp b/Tools/DumpRenderTree/qt/EventSenderQt.cpp index dcf9f1bb210..80be131788d 100644 --- a/Tools/DumpRenderTree/qt/EventSenderQt.cpp +++ b/Tools/DumpRenderTree/qt/EventSenderQt.cpp @@ -431,7 +431,7 @@ QStringList EventSender::contextClick() QContextMenuEvent ctxEvent(QContextMenuEvent::Mouse, m_mousePos); sendEvent(m_page->view(), &ctxEvent); } - return DumpRenderTreeSupportQt::contextMenu(m_page); + return DumpRenderTreeSupportQt::contextMenu(m_page->handle()); } void EventSender::scheduleAsynchronousClick() @@ -616,7 +616,7 @@ void EventSender::textZoomOut() void EventSender::scalePageBy(float scaleFactor, float x, float y) { if (QWebFrame* frame = m_page->mainFrame()) - DumpRenderTreeSupportQt::scalePageBy(frame, scaleFactor, QPoint(x, y)); + DumpRenderTreeSupportQt::scalePageBy(frame->handle(), scaleFactor, QPoint(x, y)); } QWebFrame* EventSender::frameUnderMouse() const diff --git a/Tools/DumpRenderTree/qt/TestRunnerQt.cpp b/Tools/DumpRenderTree/qt/TestRunnerQt.cpp index 6067514f055..d93505fc5fa 100644 --- a/Tools/DumpRenderTree/qt/TestRunnerQt.cpp +++ b/Tools/DumpRenderTree/qt/TestRunnerQt.cpp @@ -92,7 +92,7 @@ void TestRunner::reset() DumpRenderTreeSupportQt::setCustomPolicyDelegate(false, false); DumpRenderTreeSupportQt::dumpHistoryCallbacks(false); DumpRenderTreeSupportQt::dumpVisitedLinksCallbacks(false); - DumpRenderTreeSupportQt::resetGeolocationMock(m_drt->webPage()); + DumpRenderTreeSupportQt::resetGeolocationMock(m_drt->pageAdapter()); setIconDatabaseEnabled(false); clearAllDatabases(); // The default state for DRT is to block third-party cookies, mimicing the Mac port @@ -243,7 +243,7 @@ void TestRunner::simulateLegacyWebNotificationClick(const QString& title) void TestRunner::display() { - DumpRenderTreeSupportQt::setTrackRepaintRects(m_topLoadingFrame, true); + DumpRenderTreeSupportQt::setTrackRepaintRects(m_topLoadingFrame->handle(), true); emit showPage(); } @@ -417,7 +417,7 @@ QString TestRunner::decodeHostName(const QString& host) void TestRunner::closeWebInspector() { - DumpRenderTreeSupportQt::webInspectorClose(m_drt->webPage()); + DumpRenderTreeSupportQt::webInspectorClose(m_drt->pageAdapter()); m_drt->webPage()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, false); } @@ -434,27 +434,27 @@ void TestRunner::setAsynchronousSpellCheckingEnabled(bool) void TestRunner::showWebInspector() { m_drt->webPage()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); - DumpRenderTreeSupportQt::webInspectorShow(m_drt->webPage()); + DumpRenderTreeSupportQt::webInspectorShow(m_drt->pageAdapter()); } void TestRunner::evaluateInWebInspector(long callId, const QString& script) { - DumpRenderTreeSupportQt::webInspectorExecuteScript(m_drt->webPage(), callId, script); + DumpRenderTreeSupportQt::webInspectorExecuteScript(m_drt->pageAdapter(), callId, script); } void TestRunner::setFrameFlatteningEnabled(bool enabled) { - DumpRenderTreeSupportQt::setFrameFlatteningEnabled(m_drt->webPage(), enabled); + DumpRenderTreeSupportQt::setFrameFlatteningEnabled(m_drt->pageAdapter(), enabled); } void TestRunner::goBack() { - DumpRenderTreeSupportQt::goBack(m_drt->webPage()); + DumpRenderTreeSupportQt::goBack(m_drt->pageAdapter()); } void TestRunner::setDefersLoading(bool flag) { - DumpRenderTreeSupportQt::setDefersLoading(m_drt->webPage(), flag); + DumpRenderTreeSupportQt::setDefersLoading(m_drt->pageAdapter(), flag); } void TestRunner::setAllowUniversalAccessFromFileURLs(bool enabled) @@ -544,7 +544,7 @@ bool TestRunner::pauseAnimationAtTimeOnElementWithId(const QString& animationNam { QWebFrame* frame = m_drt->webPage()->mainFrame(); Q_ASSERT(frame); - return DumpRenderTreeSupportQt::pauseAnimation(frame, animationName, time, elementId); + return DumpRenderTreeSupportQt::pauseAnimation(frame->handle(), animationName, time, elementId); } bool TestRunner::pauseTransitionAtTimeOnElementWithId(const QString& propertyName, @@ -553,14 +553,14 @@ bool TestRunner::pauseTransitionAtTimeOnElementWithId(const QString& propertyNam { QWebFrame* frame = m_drt->webPage()->mainFrame(); Q_ASSERT(frame); - return DumpRenderTreeSupportQt::pauseTransitionOfProperty(frame, propertyName, time, elementId); + return DumpRenderTreeSupportQt::pauseTransitionOfProperty(frame->handle(), propertyName, time, elementId); } unsigned TestRunner::numberOfActiveAnimations() const { QWebFrame* frame = m_drt->webPage()->mainFrame(); Q_ASSERT(frame); - return DumpRenderTreeSupportQt::numberOfActiveAnimations(frame); + return DumpRenderTreeSupportQt::numberOfActiveAnimations(frame->handle()); } void TestRunner::disableImageLoading() @@ -698,12 +698,12 @@ void TestRunner::setUserStyleSheetLocation(const QString& url) void TestRunner::setCaretBrowsingEnabled(bool value) { - DumpRenderTreeSupportQt::setCaretBrowsingEnabled(m_drt->webPage(), value); + DumpRenderTreeSupportQt::setCaretBrowsingEnabled(m_drt->pageAdapter(), value); } void TestRunner::setAuthorAndUserStylesEnabled(bool value) { - DumpRenderTreeSupportQt::setAuthorAndUserStylesEnabled(m_drt->webPage(), value); + DumpRenderTreeSupportQt::setAuthorAndUserStylesEnabled(m_drt->pageAdapter(), value); } void TestRunner::setUserStyleSheetEnabled(bool enabled) @@ -728,7 +728,7 @@ int TestRunner::workerThreadCount() bool TestRunner::callShouldCloseOnWebView() { - return DumpRenderTreeSupportQt::shouldClose(m_drt->webPage()->mainFrame()); + return DumpRenderTreeSupportQt::shouldClose(m_drt->mainFrameAdapter()); } void TestRunner::setScrollbarPolicy(const QString& orientation, const QString& policy) @@ -757,27 +757,27 @@ void TestRunner::setScrollbarPolicy(const QString& orientation, const QString& p void TestRunner::setSmartInsertDeleteEnabled(bool enable) { - DumpRenderTreeSupportQt::setSmartInsertDeleteEnabled(m_drt->webPage(), enable); + DumpRenderTreeSupportQt::setSmartInsertDeleteEnabled(m_drt->pageAdapter(), enable); } void TestRunner::setSelectTrailingWhitespaceEnabled(bool enable) { - DumpRenderTreeSupportQt::setSelectTrailingWhitespaceEnabled(m_drt->webPage(), enable); + DumpRenderTreeSupportQt::setSelectTrailingWhitespaceEnabled(m_drt->pageAdapter(), enable); } void TestRunner::execCommand(const QString& name, const QString& value) { - DumpRenderTreeSupportQt::executeCoreCommandByName(m_drt->webPage(), name, value); + DumpRenderTreeSupportQt::executeCoreCommandByName(m_drt->pageAdapter(), name, value); } bool TestRunner::isCommandEnabled(const QString& name) const { - return DumpRenderTreeSupportQt::isCommandEnabled(m_drt->webPage(), name); + return DumpRenderTreeSupportQt::isCommandEnabled(m_drt->pageAdapter(), name); } bool TestRunner::findString(const QString& string, const QStringList& optionArray) { - return DumpRenderTreeSupportQt::findString(m_drt->webPage(), string, optionArray); + return DumpRenderTreeSupportQt::findString(m_drt->pageAdapter(), string, optionArray); } QString TestRunner::markerTextForListItem(const QWebElement& listItem) @@ -792,7 +792,7 @@ QVariantMap TestRunner::computedStyleIncludingVisitedInfo(const QWebElement& ele bool TestRunner::elementDoesAutoCompleteForElementWithId(const QString& elementId) { - return DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId(m_drt->webPage()->mainFrame(), elementId); + return DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId(m_drt->mainFrameAdapter(), elementId); } void TestRunner::authenticateSession(const QString&, const QString&, const QString&) @@ -812,7 +812,7 @@ void TestRunner::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bo { QList pages = m_drt->getAllPages(); foreach (WebCore::WebPage* page, pages) - DumpRenderTreeSupportQt::setMockDeviceOrientation(page, canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma); + DumpRenderTreeSupportQt::setMockDeviceOrientation(page->handle(), canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma); } void TestRunner::setGeolocationPermission(bool allow) @@ -820,7 +820,7 @@ void TestRunner::setGeolocationPermission(bool allow) setGeolocationPermissionCommon(allow); QList pages = m_drt->getAllPages(); foreach (WebCore::WebPage* page, pages) - DumpRenderTreeSupportQt::setMockGeolocationPermission(page, allow); + DumpRenderTreeSupportQt::setMockGeolocationPermission(page->handle(), allow); } int TestRunner::numberOfPendingGeolocationPermissionRequests() @@ -828,7 +828,7 @@ int TestRunner::numberOfPendingGeolocationPermissionRequests() int pendingPermissionCount = 0; QList pages = m_drt->getAllPages(); foreach (WebCore::WebPage* page, pages) - pendingPermissionCount += DumpRenderTreeSupportQt::numberOfPendingGeolocationPermissionRequests(page); + pendingPermissionCount += DumpRenderTreeSupportQt::numberOfPendingGeolocationPermissionRequests(page->handle()); return pendingPermissionCount; } @@ -843,14 +843,14 @@ void TestRunner::setMockGeolocationPositionUnavailableError(const QString& messa { QList pages = m_drt->getAllPages(); foreach (WebCore::WebPage* page, pages) - DumpRenderTreeSupportQt::setMockGeolocationPositionUnavailableError(page, message); + DumpRenderTreeSupportQt::setMockGeolocationPositionUnavailableError(page->handle(), message); } void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy) { QList pages = m_drt->getAllPages(); foreach (WebCore::WebPage* page, pages) - DumpRenderTreeSupportQt::setMockGeolocationPosition(page, latitude, longitude, accuracy); + DumpRenderTreeSupportQt::setMockGeolocationPosition(page->handle(), latitude, longitude, accuracy); } void TestRunner::addMockSpeechInputResult(const QString& result, double confidence, const QString& language) @@ -878,12 +878,12 @@ void TestRunner::evaluateScriptInIsolatedWorldAndReturnValue(int worldID, const void TestRunner::evaluateScriptInIsolatedWorld(int worldID, const QString& script) { - DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(m_drt->webPage()->mainFrame(), worldID, script); + DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(m_drt->mainFrameAdapter(), worldID, script); } void TestRunner::addUserStyleSheet(const QString& sourceCode) { - DumpRenderTreeSupportQt::addUserStyleSheet(m_drt->webPage(), sourceCode); + DumpRenderTreeSupportQt::addUserStyleSheet(m_drt->pageAdapter(), sourceCode); } void TestRunner::removeAllVisitedLinks() @@ -900,7 +900,7 @@ void TestRunner::addURLToRedirect(const QString& origin, const QString& destinat void TestRunner::setMinimumTimerInterval(double minimumTimerInterval) { - DumpRenderTreeSupportQt::setMinimumTimerInterval(m_drt->webPage(), minimumTimerInterval); + DumpRenderTreeSupportQt::setMinimumTimerInterval(m_drt->pageAdapter(), minimumTimerInterval); } void TestRunner::originsWithLocalStorage() diff --git a/Tools/DumpRenderTree/qt/TextInputControllerQt.cpp b/Tools/DumpRenderTree/qt/TextInputControllerQt.cpp index d5645a523e9..38e489d78f7 100644 --- a/Tools/DumpRenderTree/qt/TextInputControllerQt.cpp +++ b/Tools/DumpRenderTree/qt/TextInputControllerQt.cpp @@ -149,15 +149,15 @@ void TextInputController::insertText(const QString& string) QVariantList TextInputController::selectedRange() { - return DumpRenderTreeSupportQt::selectedRange(qobject_cast(parent())); + return DumpRenderTreeSupportQt::selectedRange(qobject_cast(parent())->handle()); } QVariantList TextInputController::firstRectForCharacterRange(int location, int length) { - return DumpRenderTreeSupportQt::firstRectForCharacterRange(qobject_cast(parent()), location, length); + return DumpRenderTreeSupportQt::firstRectForCharacterRange(qobject_cast(parent())->handle(), location, length); } void TextInputController::unmarkText() { - DumpRenderTreeSupportQt::confirmComposition(qobject_cast(parent()), 0); + DumpRenderTreeSupportQt::confirmComposition(qobject_cast(parent())->handle(), 0); } diff --git a/Tools/DumpRenderTree/qt/WorkQueueItemQt.cpp b/Tools/DumpRenderTree/qt/WorkQueueItemQt.cpp index b0933666760..7cf9fcaf102 100644 --- a/Tools/DumpRenderTree/qt/WorkQueueItemQt.cpp +++ b/Tools/DumpRenderTree/qt/WorkQueueItemQt.cpp @@ -81,7 +81,7 @@ bool LoadAlternateHTMLStringItem::invoke() const if (!frame) return false; - DumpRenderTreeSupportQt::setAlternateHtml(frame, m_content, QUrl(m_baseURL), QUrl(m_failingURL)); + DumpRenderTreeSupportQt::setAlternateHtml(frame->handle(), m_content, QUrl(m_baseURL), QUrl(m_failingURL)); return true; } diff --git a/Tools/qmake/mkspecs/features/default_post.prf b/Tools/qmake/mkspecs/features/default_post.prf index 4776d1d9209..9c0f3232f9b 100644 --- a/Tools/qmake/mkspecs/features/default_post.prf +++ b/Tools/qmake/mkspecs/features/default_post.prf @@ -177,7 +177,7 @@ contains(QT, webkitwidgets) { # need to link to any intermediate shared libraries. force_static_libs_as_shared { WEBKIT += wtf javascriptcore webcore - build?(webkit1): WEBKIT += webkit1 + build?(webkit1): WEBKIT += webkitwidgets webkit1 build?(webkit2): WEBKIT += webkit2 } diff --git a/Tools/qmake/mkspecs/features/production_build.prf b/Tools/qmake/mkspecs/features/production_build.prf index b3f36abb485..c980d09d094 100644 --- a/Tools/qmake/mkspecs/features/production_build.prf +++ b/Tools/qmake/mkspecs/features/production_build.prf @@ -8,7 +8,7 @@ CONFIG *= use_all_in_one_files # by compiling any static library like WTF or JSC with release flags instead and keep debug # symbols for the static libraries that implement API. linux-*|win32-g++*:if(CONFIG(debug, debug|release)|contains(QT_CONFIG,separate_debug_info)):contains(TEMPLATE, lib):staticlib { - !equals(TARGET, WebKit2):!equals(TARGET, WebKit1) { + !equals(TARGET, WebKit2):!equals(TARGET, WebKitWidgets) { CONFIG += no_debug_info CONFIG -= separate_debug_info QMAKE_CFLAGS += $$QMAKE_CFLAGS_RELEASE diff --git a/Tools/qmake/mkspecs/features/webkit_modules.prf b/Tools/qmake/mkspecs/features/webkit_modules.prf index b2f3353648d..505b82658e2 100644 --- a/Tools/qmake/mkspecs/features/webkit_modules.prf +++ b/Tools/qmake/mkspecs/features/webkit_modules.prf @@ -7,7 +7,7 @@ # Reorder libraries so that the link and include order is correct, # and make sure the case matches the original case. -libraries = WebKit1 WebKit2 WebCore ANGLE JavaScriptCore WTF +libraries = WebKitWidgets WebKit1 WebKit2 WebCore ANGLE JavaScriptCore WTF for(library, libraries) { contains(WEBKIT, $$lower($$library)) { WEBKIT -= $$lower($$library) diff --git a/Tools/qmake/mkspecs/modules/webkitwidgets.prf b/Tools/qmake/mkspecs/modules/webkitwidgets.prf new file mode 100644 index 00000000000..ca1643c8df0 --- /dev/null +++ b/Tools/qmake/mkspecs/modules/webkitwidgets.prf @@ -0,0 +1,9 @@ +# ------------------------------------------------------------------- +# Module file for WebKitWidget, used by targets that depend on WebKitWidget +# +# See 'Tools/qmake/README' for an overview of the build system +# ------------------------------------------------------------------- + +WEBKIT.webkitwidgets.root_source_dir = $${ROOT_WEBKIT_DIR}/Source/WebKit + +include($${WEBKIT.webkitwidgets.root_source_dir}/WebKitWidgets.pri) diff --git a/WebKit.pro b/WebKit.pro index 876d5541266..fba5b997ac7 100644 --- a/WebKit.pro +++ b/WebKit.pro @@ -32,6 +32,10 @@ build?(webkit1) { webkit1.file = Source/WebKit/WebKit1.pro webkit1.makefile = Makefile.WebKit1 SUBDIRS += webkit1 + + webkitwidgets.file = Source/WebKit/WebKitWidgets.pro + webkitwidgets.makefile = Makefile.WebKitWidgets + SUBDIRS += webkitwidgets } build?(webkit2) {