diff options
author | Ben Murdoch <benm@google.com> | 2011-06-02 12:07:03 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-10 10:47:21 +0100 |
commit | 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch) | |
tree | e4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebKit/qt/WebCoreSupport | |
parent | 87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff) | |
download | external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2 |
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebKit/qt/WebCoreSupport')
16 files changed, 465 insertions, 268 deletions
diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp index bec4bc4..ea2c826 100644 --- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp @@ -75,13 +75,15 @@ #include <qtooltip.h> #include <wtf/OwnPtr.h> -#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) +#if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA)) #include "FullScreenVideoQt.h" #include "HTMLMediaElement.h" #include "HTMLNames.h" #include "HTMLVideoElement.h" +#if USE(QT_MULTIMEDIA) #include "MediaPlayerPrivateQt.h" #endif +#endif namespace WebCore { @@ -90,7 +92,7 @@ bool ChromeClientQt::dumpVisitedLinksCallbacks = false; ChromeClientQt::ChromeClientQt(QWebPage* webPage) : m_webPage(webPage) , m_eventLoop(0) -#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) +#if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA)) , m_fullScreenVideo(0) #endif { @@ -102,7 +104,7 @@ ChromeClientQt::~ChromeClientQt() if (m_eventLoop) m_eventLoop->exit(); -#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) +#if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA)) delete m_fullScreenVideo; #endif } @@ -397,9 +399,18 @@ IntRect ChromeClientQt::windowResizerRect() const #endif } -void ChromeClientQt::invalidateWindow(const IntRect&, bool) +void ChromeClientQt::invalidateWindow(const IntRect& windowRect, bool) { - notImplemented(); +#if ENABLE(TILED_BACKING_STORE) + if (platformPageClient()) { + WebCore::TiledBackingStore* backingStore = QWebFramePrivate::core(m_webPage->mainFrame())->tiledBackingStore(); + if (!backingStore) + return; + backingStore->invalidate(windowRect); + } +#else + Q_UNUSED(windowRect); +#endif } void ChromeClientQt::invalidateContentsAndWindow(const IntRect& windowRect, bool immediate) @@ -650,7 +661,7 @@ IntRect ChromeClientQt::visibleRectForTiledBackingStore() const } #endif -#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) +#if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA)) FullScreenVideoQt* ChromeClientQt::fullScreenVideo() { if (!m_fullScreenVideo) @@ -673,13 +684,6 @@ void ChromeClientQt::enterFullscreenForNode(Node* node) { ASSERT(node && node->hasTagName(HTMLNames::videoTag)); - HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node); - PlatformMedia platformMedia = videoElement->platformMedia(); - - ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType); - if (platformMedia.type != PlatformMedia::QtMediaPlayerType) - return; - fullScreenVideo()->enterFullScreenForNode(node); } @@ -687,13 +691,6 @@ void ChromeClientQt::exitFullscreenForNode(Node* node) { ASSERT(node && node->hasTagName(HTMLNames::videoTag)); - HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node); - PlatformMedia platformMedia = videoElement->platformMedia(); - - ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType); - if (platformMedia.type != PlatformMedia::QtMediaPlayerType) - return; - fullScreenVideo()->exitFullScreenForNode(node); } #endif diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h index a12c2ec..c69daf5 100644 --- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h @@ -26,15 +26,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ChromeClientQt_H -#define ChromeClientQt_H +#ifndef ChromeClientQt_h +#define ChromeClientQt_h #include "ChromeClient.h" #include "FloatRect.h" -#include "RefCounted.h" #include "KURL.h" #include "PlatformString.h" #include "QtPlatformPlugin.h" +#include <wtf/RefCounted.h> QT_BEGIN_NAMESPACE class QEventLoop; @@ -44,176 +44,172 @@ class QWebPage; namespace WebCore { - class FileChooser; - class FloatRect; - class Page; - struct FrameLoadRequest; - class QtAbstractWebPopup; - struct ViewportArguments; -#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) - class FullScreenVideoQt; +class FileChooser; +class FloatRect; +class Page; +struct FrameLoadRequest; +class QtAbstractWebPopup; +struct ViewportArguments; +#if ENABLE(VIDEO) +class FullScreenVideoQt; #endif - class ChromeClientQt : public ChromeClient - { - public: - ChromeClientQt(QWebPage* webPage); - virtual ~ChromeClientQt(); - virtual void chromeDestroyed(); +class ChromeClientQt : public ChromeClient { +public: + ChromeClientQt(QWebPage*); + virtual ~ChromeClientQt(); + virtual void chromeDestroyed(); - virtual void setWindowRect(const FloatRect&); - virtual FloatRect windowRect(); + virtual void setWindowRect(const FloatRect&); + virtual FloatRect windowRect(); - virtual FloatRect pageRect(); + virtual FloatRect pageRect(); - virtual float scaleFactor(); + virtual float scaleFactor(); - virtual void focus(); - virtual void unfocus(); + virtual void focus(); + virtual void unfocus(); - virtual bool canTakeFocus(FocusDirection); - virtual void takeFocus(FocusDirection); + virtual bool canTakeFocus(FocusDirection); + virtual void takeFocus(FocusDirection); - virtual void focusedNodeChanged(Node*); - virtual void focusedFrameChanged(Frame*); + virtual void focusedNodeChanged(Node*); + virtual void focusedFrameChanged(Frame*); - virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&); - virtual void show(); + virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&); + virtual void show(); - virtual bool canRunModal(); - virtual void runModal(); + virtual bool canRunModal(); + virtual void runModal(); - virtual void setToolbarsVisible(bool); - virtual bool toolbarsVisible(); + virtual void setToolbarsVisible(bool); + virtual bool toolbarsVisible(); - virtual void setStatusbarVisible(bool); - virtual bool statusbarVisible(); + virtual void setStatusbarVisible(bool); + virtual bool statusbarVisible(); - virtual void setScrollbarsVisible(bool); - virtual bool scrollbarsVisible(); + virtual void setScrollbarsVisible(bool); + virtual bool scrollbarsVisible(); - virtual void setMenubarVisible(bool); - virtual bool menubarVisible(); + virtual void setMenubarVisible(bool); + virtual bool menubarVisible(); - virtual void setResizable(bool); + 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 int lineNumber, const String& sourceID); - virtual bool canRunBeforeUnloadConfirmPanel(); - virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame); + virtual bool canRunBeforeUnloadConfirmPanel(); + virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame*); - virtual void closeWindowSoon(); + virtual void closeWindowSoon(); - virtual void runJavaScriptAlert(Frame*, const String&); - virtual bool runJavaScriptConfirm(Frame*, const String&); - virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result); - virtual bool shouldInterruptJavaScript(); + virtual void runJavaScriptAlert(Frame*, const String&); + virtual bool runJavaScriptConfirm(Frame*, const String&); + virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result); + virtual bool shouldInterruptJavaScript(); - virtual void setStatusbarText(const String&); + virtual void setStatusbarText(const String&); - virtual WebCore::KeyboardUIMode keyboardUIMode(); - virtual IntRect windowResizerRect() const; + virtual KeyboardUIMode keyboardUIMode(); + virtual IntRect windowResizerRect() const; - virtual void invalidateWindow(const IntRect&, bool); - virtual void invalidateContentsAndWindow(const IntRect&, bool); - virtual void invalidateContentsForSlowScroll(const IntRect&, bool); - virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect); + virtual void invalidateWindow(const IntRect&, bool); + virtual void invalidateContentsAndWindow(const IntRect&, bool); + virtual void invalidateContentsForSlowScroll(const IntRect&, bool); + virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect); #if ENABLE(TILED_BACKING_STORE) - virtual void delegatedScrollRequested(const IntPoint& scrollPoint); + virtual void delegatedScrollRequested(const IntPoint& scrollPoint); #endif - virtual IntPoint screenToWindow(const IntPoint&) const; - virtual IntRect windowToScreen(const IntRect&) const; - virtual PlatformPageClient platformPageClient() const; - virtual void contentsSizeChanged(Frame*, const IntSize&) const; + virtual IntPoint screenToWindow(const IntPoint&) const; + virtual IntRect windowToScreen(const IntRect&) const; + virtual PlatformPageClient platformPageClient() const; + virtual void contentsSizeChanged(Frame*, const IntSize&) const; - virtual void scrollbarsModeDidChange() const { } - virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags); + virtual void scrollbarsModeDidChange() const { } + virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags); - virtual void setToolTip(const String&, TextDirection); + virtual void setToolTip(const String&, TextDirection); - virtual void print(Frame*); + virtual void print(Frame*); #if ENABLE(DATABASE) - virtual void exceededDatabaseQuota(Frame*, const String&); + virtual void exceededDatabaseQuota(Frame*, const String&); #endif #if ENABLE(OFFLINE_WEB_APPLICATIONS) - virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); - virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*); + virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); + virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*); #endif #if ENABLE(CONTEXT_MENUS) virtual void showContextMenu() { } #endif #if ENABLE(NOTIFICATIONS) - virtual NotificationPresenter* notificationPresenter() const; + virtual NotificationPresenter* notificationPresenter() const; #endif #if USE(ACCELERATED_COMPOSITING) - // see ChromeClient.h - // this is a hook for WebCore to tell us what we need to do with the GraphicsLayers - virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*); - virtual void setNeedsOneShotDrawingSynchronization(); - virtual void scheduleCompositingLayerSync(); - virtual CompositingTriggerFlags allowedCompositingTriggers() const; + // This is a hook for WebCore to tell us what we need to do with the GraphicsLayers. + virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*); + virtual void setNeedsOneShotDrawingSynchronization(); + virtual void scheduleCompositingLayerSync(); + virtual CompositingTriggerFlags allowedCompositingTriggers() const; #endif #if ENABLE(TILED_BACKING_STORE) - virtual IntRect visibleRectForTiledBackingStore() const; + virtual IntRect visibleRectForTiledBackingStore() const; #endif #if ENABLE(TOUCH_EVENTS) - virtual void needTouchEvents(bool) { } + virtual void needTouchEvents(bool) { } #endif -#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) - virtual bool supportsFullscreenForNode(const Node*); - virtual void enterFullscreenForNode(Node*); - virtual void exitFullscreenForNode(Node*); - virtual bool requiresFullscreenForVideoPlayback(); - FullScreenVideoQt* fullScreenVideo(); +#if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA)) + virtual bool supportsFullscreenForNode(const Node*); + virtual void enterFullscreenForNode(Node*); + virtual void exitFullscreenForNode(Node*); + virtual bool requiresFullscreenForVideoPlayback(); + FullScreenVideoQt* fullScreenVideo(); #endif + virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>); + virtual void chooseIconForFiles(const Vector<String>&, FileChooser*); - virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>); - virtual void chooseIconForFiles(const Vector<String>&, FileChooser*); + virtual void formStateDidChange(const Node*) { } - virtual void formStateDidChange(const Node*) { } + virtual void setCursor(const Cursor&); - virtual void setCursor(const Cursor&); + virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const { } - virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const { } + virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) { } + virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) { } - virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) { } - virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) { } + virtual bool selectItemWritingDirectionIsNatural(); + virtual bool selectItemAlignmentFollowsMenuWritingDirection(); + virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const; + virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const; + virtual void populateVisitedLinks(); - virtual bool selectItemWritingDirectionIsNatural(); - virtual bool selectItemAlignmentFollowsMenuWritingDirection(); - virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const; - virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const; - virtual void populateVisitedLinks(); + QWebSelectMethod* createSelectPopup() const; - QWebSelectMethod* createSelectPopup() const; + virtual void dispatchViewportDataDidChange(const ViewportArguments&) const; - virtual void dispatchViewportDataDidChange(const ViewportArguments&) const; + QWebPage* m_webPage; + KURL lastHoverURL; + String lastHoverTitle; + String lastHoverContent; - QWebPage* m_webPage; - WebCore::KURL lastHoverURL; - WTF::String lastHoverTitle; - WTF::String lastHoverContent; + bool toolBarsVisible; + bool statusBarVisible; + bool menuBarVisible; + QEventLoop* m_eventLoop; - bool toolBarsVisible; - bool statusBarVisible; - bool menuBarVisible; - QEventLoop* m_eventLoop; - -#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) - FullScreenVideoQt* m_fullScreenVideo; +#if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA)) + FullScreenVideoQt* m_fullScreenVideo; #endif - static bool dumpVisitedLinksCallbacks; + static bool dumpVisitedLinksCallbacks; - mutable QtPlatformPlugin m_platformPlugin; - }; + mutable QtPlatformPlugin m_platformPlugin; +}; } #endif diff --git a/Source/WebKit/qt/WebCoreSupport/DragClientQt.h b/Source/WebKit/qt/WebCoreSupport/DragClientQt.h index 38b463b..15724f1 100644 --- a/Source/WebKit/qt/WebCoreSupport/DragClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/DragClientQt.h @@ -23,23 +23,28 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef DragClientQt_h +#define DragClientQt_h + #include "DragClient.h" + class QWebPage; + namespace WebCore { class DragClientQt : public DragClient { public: DragClientQt(QWebPage* webPage) : m_webPage(webPage) {}; - virtual void willPerformDragDestinationAction(DragDestinationAction, - DragData*); - virtual WebCore::DragDestinationAction actionMaskForDrag(DragData*); + virtual void willPerformDragDestinationAction(DragDestinationAction, DragData*); + virtual DragDestinationAction actionMaskForDrag(DragData*); virtual void dragControllerDestroyed(); virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint&); virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*); - virtual void startDrag(DragImageRef dragImage, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard*, Frame*, bool linkDrag = false); + virtual void startDrag(DragImageRef, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard*, Frame*, bool linkDrag = false); private: QWebPage* m_webPage; }; } +#endif diff --git a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index ba712d1..81102c3 100644 --- a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -26,6 +26,7 @@ #include "ApplicationCacheStorage.h" #include "CSSComputedStyleDeclaration.h" #include "ChromeClientQt.h" +#include "ContainerNode.h" #include "ContextMenu.h" #include "ContextMenuClientQt.h" #include "ContextMenuController.h" @@ -82,7 +83,7 @@ #include "qwebpage_p.h" #include "qwebscriptworld.h" -#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) +#if ENABLE(VIDEO) && USE(QT_MULTIMEDIA) #include "HTMLVideoElement.h" #include "MediaPlayerPrivateQt.h" #endif @@ -822,6 +823,17 @@ void DumpRenderTreeSupportQt::setMockGeolocationError(QWebPage* page, int errorC #endif } +int DumpRenderTreeSupportQt::numberOfPendingGeolocationPermissionRequests(QWebPage* page) +{ +#if ENABLE(CLIENT_BASED_GEOLOCATION) + Page* corePage = QWebPagePrivate::core(page); + GeolocationClientMock* mockClient = toGeolocationClientMock(corePage->geolocationController()->client()); + return mockClient->numberOfPendingPermissionRequests(); +#else + return -1; +#endif +} + bool DumpRenderTreeSupportQt::isTargetItem(const QWebHistoryItem& historyItem) { QWebHistoryItem it = historyItem; @@ -1014,7 +1026,7 @@ QUrl DumpRenderTreeSupportQt::mediaContentUrlByElementId(QWebFrame* frame, const { QUrl res; -#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) +#if ENABLE(VIDEO) && USE(QT_MULTIMEDIA) Frame* coreFrame = QWebFramePrivate::core(frame); if (!coreFrame) return res; @@ -1052,6 +1064,19 @@ void DumpRenderTreeSupportQt::setAlternateHtml(QWebFrame* frame, const QString& coreFrame->loader()->load(request, substituteData, false); } +QVariant DumpRenderTreeSupportQt::shadowRoot(const QWebElement& element) +{ + WebCore::Element* webElement = element.m_element; + if (!webElement) + return QVariant(); + + ContainerNode* webShadowRoot = webElement->shadowRoot(); + if (!webShadowRoot) + return QVariant(); + + return QVariant::fromValue(QDRTNode(webShadowRoot)); +} + // Provide a backward compatibility with previously exported private symbols as of QtWebKit 4.6 release void QWEBKIT_EXPORT qt_resumeActiveDOMObjects(QWebFrame* frame) diff --git a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h index 78752d8..4be6053 100644 --- a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h +++ b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h @@ -147,6 +147,7 @@ public: static void setMockGeolocationPermission(QWebPage*, bool allowed); static void setMockGeolocationPosition(QWebPage*, double latitude, double longitude, double accuracy); static void setMockGeolocationError(QWebPage*, int errorCode, const QString& message); + static int numberOfPendingGeolocationPermissionRequests(QWebPage*); static int workerThreadCount(); @@ -199,6 +200,8 @@ public: static QUrl mediaContentUrlByElementId(QWebFrame*, const QString& elementId); static void setAlternateHtml(QWebFrame*, const QString& html, const QUrl& baseUrl, const QUrl& failingUrl); + + static QVariant shadowRoot(const QWebElement&); }; #endif diff --git a/Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp index e7bbd2c..0110144 100644 --- a/Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp @@ -420,7 +420,7 @@ void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event) return; // FIXME: refactor all of this to use Actions or something like them - if (start->rendererIsEditable()) { + if (start->isContentEditable()) { bool doSpatialNavigation = false; if (isSpatialNavigationEnabled(frame)) { if (!kevent->modifiers()) { diff --git a/Source/WebKit/qt/WebCoreSupport/EditorClientQt.h b/Source/WebKit/qt/WebCoreSupport/EditorClientQt.h index 0450603..0d8e8c6 100644 --- a/Source/WebKit/qt/WebCoreSupport/EditorClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/EditorClientQt.h @@ -109,7 +109,7 @@ public: virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses); virtual void willSetInputMethodState(); virtual void setInputMethodState(bool enabled); - virtual void requestCheckingOfString(SpellChecker*, int, const String&) {} + virtual void requestCheckingOfString(SpellChecker*, int, WebCore::TextCheckingTypeMask, const String&) {} virtual TextCheckerClient* textChecker() { return this; } bool isEditing() const; diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index d318494..d083f8f 100644 --- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -31,71 +31,72 @@ */ #include "config.h" +#include "FrameLoaderClientQt.h" + #include "CSSComputedStyleDeclaration.h" #include "CSSPropertyNames.h" +#include "DocumentLoader.h" #include "FormState.h" -#include "FrameLoaderClientQt.h" #include "FrameNetworkingContextQt.h" #include "FrameTree.h" #include "FrameView.h" -#include "DocumentLoader.h" +#include "HTMLAppletElement.h" +#include "HTMLFormElement.h" +#include "HTMLPlugInElement.h" +#include "HTTPParsers.h" +#include "HistoryItem.h" #include "HitTestResult.h" #if ENABLE(ICONDATABASE) #include "IconDatabaseClientQt.h" #endif #if USE(JSC) #include "JSDOMWindowBase.h" -#elif USE(V8) -#include "V8DOMWindow.h" #endif #include "MIMETypeRegistry.h" #include "MouseEvent.h" -#include "ResourceResponse.h" +#include "NotImplemented.h" #include "Page.h" #include "PluginData.h" #include "PluginDatabase.h" #include "ProgressTracker.h" -#include "RenderPart.h" -#include "ResourceRequest.h" -#include "HistoryItem.h" -#include "HTMLAppletElement.h" -#include "HTMLFormElement.h" -#include "HTMLPlugInElement.h" -#include "HTTPParsers.h" -#include "NotImplemented.h" #include "QNetworkReplyHandler.h" -#include "ResourceHandleInternal.h" +#include "QWebPageClient.h" +#include "RenderPart.h" #include "ResourceHandle.h" +#include "ResourceHandleInternal.h" +#include "ResourceRequest.h" +#include "ResourceResponse.h" #include "ScriptController.h" #include "Settings.h" -#include "QWebPageClient.h" +#if USE(V8) +#include "V8DOMWindow.h" +#endif #include "ViewportArguments.h" -#include "qwebpage.h" -#include "qwebpage_p.h" #include "qwebframe.h" #include "qwebframe_p.h" +#include "qwebhistory_p.h" #include "qwebhistoryinterface.h" +#include "qwebpage.h" +#include "qwebpage_p.h" #include "qwebpluginfactory.h" -#include <qfileinfo.h> - #include <QCoreApplication> #include <QDebug> +#include <QFileInfo> #include <QGraphicsScene> #include <QGraphicsWidget> -#include <QNetworkRequest> #include <QNetworkReply> +#include <QNetworkRequest> #include <QStringList> -#include "qwebhistory_p.h" #include <wtf/OwnPtr.h> static QMap<unsigned long, QString> dumpAssignedUrls; -// Compare with WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm -static QString drtDescriptionSuitableForTestResult(WebCore::Frame* _frame) +// Compare with the file "WebKit/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm". +static QString drtDescriptionSuitableForTestResult(WebCore::Frame* webCoreFrame) { - QWebFrame* frame = QWebFramePrivate::kit(_frame); + QWebFrame* frame = QWebFramePrivate::kit(webCoreFrame); QString name = frame->frameName(); bool isMainFrame = frame == frame->page()->mainFrame(); @@ -103,11 +104,10 @@ static QString drtDescriptionSuitableForTestResult(WebCore::Frame* _frame) if (!name.isEmpty()) return QString::fromLatin1("main frame \"%1\"").arg(name); return QLatin1String("main frame"); - } else { - if (!name.isEmpty()) - return QString::fromLatin1("frame \"%1\"").arg(name); - return QLatin1String("frame (anonymous)"); } + if (!name.isEmpty()) + return QString::fromLatin1("frame \"%1\"").arg(name); + return QLatin1String("frame (anonymous)"); } static QString drtPrintFrameUserGestureStatus(WebCore::Frame* frame) @@ -117,12 +117,12 @@ static QString drtPrintFrameUserGestureStatus(WebCore::Frame* frame) return QString::fromLatin1("Frame with user gesture \"%1\"").arg(QLatin1String("false")); } -static QString drtDescriptionSuitableForTestResult(const WebCore::KURL& _url) +static QString drtDescriptionSuitableForTestResult(const WebCore::KURL& kurl) { - if (_url.isEmpty() || !_url.isLocalFile()) - return _url.string(); - // Remove the leading path from file urls - return QString(_url.string()).remove(WebCore::FrameLoaderClientQt::dumpResourceLoadCallbacksPath).mid(1); + if (kurl.isEmpty() || !kurl.isLocalFile()) + return kurl.string(); + // Remove the leading path from file urls. + return QString(kurl.string()).remove(WebCore::FrameLoaderClientQt::dumpResourceLoadCallbacksPath).mid(1); } static QString drtDescriptionSuitableForTestResult(const WebCore::ResourceError& error) @@ -166,8 +166,7 @@ static QString drtDescriptionSuitableForTestResult(const RefPtr<WebCore::Node> n return result; } -namespace WebCore -{ +namespace WebCore { bool FrameLoaderClientQt::dumpFrameLoaderCallbacks = false; bool FrameLoaderClientQt::dumpUserGestureInFrameLoaderCallbacks = false; @@ -184,7 +183,7 @@ bool FrameLoaderClientQt::policyDelegateEnabled = false; bool FrameLoaderClientQt::policyDelegatePermissive = false; QMap<QString, QString> FrameLoaderClientQt::URLsToRedirect = QMap<QString, QString>(); -// Taken from DumpRenderTree/chromium/WebViewHost.cpp +// Taken from the file "WebKit/Tools/DumpRenderTree/chromium/WebViewHost.cpp". static const char* navigationTypeToString(NavigationType type) { switch (type) { @@ -250,7 +249,7 @@ void FrameLoaderClientQt::callPolicyFunction(FramePolicyFunction function, Polic bool FrameLoaderClientQt::hasWebView() const { - //notImplemented(); + // notImplemented(); return true; } @@ -331,7 +330,7 @@ void FrameLoaderClientQt::forceLayoutForNonHTML() void FrameLoaderClientQt::setCopiesOnScroll() { - // apparently mac specific + // Apparently this is mac specific. } @@ -346,7 +345,7 @@ void FrameLoaderClientQt::detachedFromParent3() void FrameLoaderClientQt::dispatchDidHandleOnloadEvents() { - // don't need this one + // Don't need this one. if (dumpFrameLoaderCallbacks) printf("%s - didHandleOnloadEventsForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame))); } @@ -387,7 +386,7 @@ void FrameLoaderClientQt::dispatchDidChangeLocationWithinPage() if (!m_webFrame) return; - emit m_webFrame->urlChanged(m_webFrame->url()); + m_webFrame->d->emitUrlChanged(); m_webFrame->page()->d->updateNavigationActions(); } @@ -447,15 +446,16 @@ void FrameLoaderClientQt::dispatchDidStartProvisionalLoad() } -void FrameLoaderClientQt::dispatchDidReceiveTitle(const String& title) +void FrameLoaderClientQt::dispatchDidReceiveTitle(const StringWithDirection& title) { + // FIXME: Use direction of title. if (dumpFrameLoaderCallbacks) - printf("%s - didReceiveTitle: %s\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)), qPrintable(QString(title))); + printf("%s - didReceiveTitle: %s\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)), qPrintable(QString(title.string()))); if (!m_webFrame) return; - emit titleChanged(title); + emit titleChanged(title.string()); } @@ -467,7 +467,7 @@ void FrameLoaderClientQt::dispatchDidChangeIcons() if (!m_webFrame) return; - // FIXME: To be notified of changing icon URLS add notification + // FIXME: In order to get notified of icon URLS' changes, add a notification. // emit iconsChanged(); } @@ -480,7 +480,7 @@ void FrameLoaderClientQt::dispatchDidCommitLoad() if (m_frame->tree()->parent() || !m_webFrame) return; - emit m_webFrame->urlChanged(m_webFrame->url()); + m_webFrame->d->emitUrlChanged(); m_webFrame->page()->d->updateNavigationActions(); // We should assume first the frame has no title. If it has, then the above dispatchDidReceiveTitle() @@ -546,7 +546,7 @@ void FrameLoaderClientQt::dispatchShow() void FrameLoaderClientQt::cancelPolicyCheck() { -// qDebug() << "FrameLoaderClientQt::cancelPolicyCheck"; + // qDebug() << "FrameLoaderClientQt::cancelPolicyCheck"; } @@ -554,7 +554,7 @@ void FrameLoaderClientQt::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr<FormState>) { notImplemented(); - // FIXME: This is surely too simple + // FIXME: This is surely too simple. callPolicyFunction(function, PolicyUse); } @@ -573,7 +573,7 @@ void FrameLoaderClientQt::revertToProvisionalState(DocumentLoader*) void FrameLoaderClientQt::postProgressStartedNotification() { if (m_webFrame && m_frame->page()) { - // A new load starts, so lets clear the previous error. + // As a new load have started, clear the previous error. m_loadError = ResourceError(); emit loadStarted(); postProgressEstimateChangedNotification(); @@ -591,9 +591,9 @@ void FrameLoaderClientQt::postProgressEstimateChangedNotification() 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 + // 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()) { @@ -611,19 +611,19 @@ void FrameLoaderClientQt::postProgressFinishedNotification() void FrameLoaderClientQt::setMainFrameDocumentReady(bool) { - // this is only interesting once we provide an external API for the DOM + // This is only interesting once we provide an external API for the DOM. } void FrameLoaderClientQt::willChangeTitle(DocumentLoader*) { - // no need for, dispatchDidReceiveTitle is the right callback + // No need for, dispatchDidReceiveTitle is the right callback. } void FrameLoaderClientQt::didChangeTitle(DocumentLoader*) { - // no need for, dispatchDidReceiveTitle is the right callback + // No need for, dispatchDidReceiveTitle is the right callback. } @@ -631,8 +631,8 @@ void FrameLoaderClientQt::finishedLoading(DocumentLoader* loader) { if (!m_pluginView) { // This is necessary to create an empty document. See bug 634004. - // However, we only want to do this if makeRepresentation has been called, to - // match the behavior on the Mac. + // However, we only want to do this if makeRepresentation has been called, + // to match the behavior on the Mac. if (m_hasRepresentation) loader->writer()->setEncoding("", false); return; @@ -681,7 +681,7 @@ String FrameLoaderClientQt::generatedMIMETypeForURLScheme(const String&) const void FrameLoaderClientQt::frameLoadCompleted() { - // Note: Can be called multiple times. + // Note that this can be called multiple times. } @@ -695,13 +695,13 @@ void FrameLoaderClientQt::restoreViewState() void FrameLoaderClientQt::provisionalLoadStarted() { - // don't need to do anything here + // Don't need to do anything here. } void FrameLoaderClientQt::didFinishLoad() { -// notImplemented(); + // notImplemented(); } @@ -709,16 +709,17 @@ void FrameLoaderClientQt::prepareForDataSourceReplacement() { } -void FrameLoaderClientQt::setTitle(const String& title, const KURL& url) +void FrameLoaderClientQt::setTitle(const StringWithDirection& title, const KURL& url) { // Used by Apple WebKit to update the title of an existing history item. // QtWebKit doesn't accomodate this on history items. If it ever does, - // it should be privateBrowsing-aware.For now, we are just passing + // it should be privateBrowsing-aware. For now, we are just passing // globalhistory layout tests. + // FIXME: Use direction of title. if (dumpHistoryCallbacks) { printf("WebView updated the title for history URL \"%s\" to \"%s\".\n", qPrintable(drtDescriptionSuitableForTestResult(url)), - qPrintable(QString(title))); + qPrintable(QString(title.string()))); } } @@ -733,9 +734,8 @@ String FrameLoaderClientQt::userAgent(const KURL& url) void FrameLoaderClientQt::dispatchDidReceiveIcon() { - if (m_webFrame) { + if (m_webFrame) emit m_webFrame->iconChanged(); - } } void FrameLoaderClientQt::frameLoaderDestroyed() @@ -757,9 +757,8 @@ void FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* w if (world != mainThreadNormalWorld()) return; - if (m_webFrame) { + if (m_webFrame) emit m_webFrame->javaScriptWindowObjectCleared(); - } } void FrameLoaderClientQt::documentElementAvailable() @@ -795,7 +794,7 @@ void FrameLoaderClientQt::onIconLoadedForPageURL(const QString& url) void FrameLoaderClientQt::updateGlobalHistory() { - QWebHistoryInterface *history = QWebHistoryInterface::defaultInterface(); + QWebHistoryInterface* history = QWebHistoryInterface::defaultInterface(); WebCore::DocumentLoader* loader = m_frame->loader()->documentLoader(); if (history) history->addHistoryEntry(loader->urlForHistory().prettyURL()); @@ -803,7 +802,7 @@ void FrameLoaderClientQt::updateGlobalHistory() if (dumpHistoryCallbacks) { printf("WebView navigated to url \"%s\" with title \"%s\" with HTTP equivalent method \"%s\". The navigation was %s and was %s%s.\n", qPrintable(drtDescriptionSuitableForTestResult(loader->urlForHistory())), - qPrintable(QString(loader->title())), + qPrintable(QString(loader->title().string())), qPrintable(QString(loader->request().httpMethod())), ((loader->substituteData().isValid() || (loader->response().httpStatusCode() >= 400)) ? "a failure" : "successful"), ((!loader->clientRedirectSourceForHistory().isEmpty()) ? "a client redirect from " : "not a client redirect"), @@ -840,12 +839,12 @@ void FrameLoaderClientQt::updateGlobalHistoryRedirectLinks() } } -bool FrameLoaderClientQt::shouldGoToHistoryItem(WebCore::HistoryItem *) const +bool FrameLoaderClientQt::shouldGoToHistoryItem(WebCore::HistoryItem*) const { return true; } -bool FrameLoaderClientQt::shouldStopLoadingForHistoryItem(WebCore::HistoryItem *) const +bool FrameLoaderClientQt::shouldStopLoadingForHistoryItem(WebCore::HistoryItem*) const { return true; } @@ -905,13 +904,13 @@ void FrameLoaderClientQt::committedLoad(WebCore::DocumentLoader* loader, const c if (!m_pluginView) loader->commitData(data, length); - // We re-check here as the plugin can have been created + // We re-check here as the plugin can have been created. if (m_pluginView && m_pluginView->isPluginView()) { if (!m_hasSentResponseToPlugin) { m_pluginView->didReceiveResponse(loader->response()); - // didReceiveResponse sets up a new stream to the plug-in. on a full-page plug-in, a failure in - // setting up this stream can cause the main document load to be cancelled, setting m_pluginView - // to null + // The function didReceiveResponse sets up a new stream to the plug-in. + // On a full-page plug-in, a failure in setting up this stream can cause the + // main document load to be cancelled, setting m_pluginView to null. if (!m_pluginView) return; m_hasSentResponseToPlugin = true; @@ -928,12 +927,12 @@ WebCore::ResourceError FrameLoaderClientQt::cancelledError(const WebCore::Resour return error; } -// copied from WebKit/Misc/WebKitErrors[Private].h +// This was copied from file "WebKit/Source/WebKit/mac/Misc/WebKitErrors.h". enum { WebKitErrorCannotShowMIMEType = 100, WebKitErrorCannotShowURL = 101, WebKitErrorFrameLoadInterruptedByPolicyChange = 102, - WebKitErrorCannotUseRestrictedPort = 103, + WebKitErrorCannotUseRestrictedPort = 103, WebKitErrorCannotFindPlugIn = 200, WebKitErrorCannotLoadPlugIn = 201, WebKitErrorJavaUnavailable = 202, @@ -1011,7 +1010,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(); + QWebPage* page = m_webFrame->page(); if (page->forwardUnsupportedContent()) emit page->unsupportedContent(reply); else @@ -1027,6 +1026,7 @@ void FrameLoaderClientQt::assignIdentifierToInitialRequest(unsigned long identif void FrameLoaderClientQt::dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest& newRequest, const WebCore::ResourceResponse& redirectResponse) { + QUrl url = newRequest.url(); if (dumpResourceLoadCallbacks) printf("%s - willSendRequest %s redirectResponse %s\n", @@ -1034,28 +1034,42 @@ void FrameLoaderClientQt::dispatchWillSendRequest(WebCore::DocumentLoader*, unsi qPrintable(drtDescriptionSuitableForTestResult(newRequest)), (redirectResponse.isNull()) ? "(null)" : qPrintable(drtDescriptionSuitableForTestResult(redirectResponse))); - if (sendRequestReturnsNull) + if (sendRequestReturnsNull) { newRequest.setURL(QUrl()); + return; + } if (sendRequestReturnsNullOnRedirect && !redirectResponse.isNull()) { printf("Returning null for this redirect\n"); newRequest.setURL(QUrl()); + return; + } + + if (QWebPagePrivate::drtRun + && url.isValid() + && (url.scheme().toLower() == QLatin1String("http") || url.scheme().toLower() == QLatin1String("https")) + && url.host() != QLatin1String("127.0.0.1") + && url.host() != QLatin1String("255.255.255.255") + && url.host().toLower() != QLatin1String("localhost")) { + + printf("Blocked access to external URL %s\n", qPrintable(drtDescriptionSuitableForTestResult(newRequest.url()))); + newRequest.setURL(QUrl()); + return; } for (int i = 0; i < sendRequestClearHeaders.size(); ++i) newRequest.setHTTPHeaderField(sendRequestClearHeaders.at(i).toLocal8Bit().constData(), QString()); if (QWebPagePrivate::drtRun) { - QString url = newRequest.url().string(); - if (URLsToRedirect.contains(url)) - newRequest.setURL(QUrl(URLsToRedirect[url])); + QMap<QString, QString>::const_iterator it = URLsToRedirect.constFind(url.toString()); + if (it != URLsToRedirect.constEnd()) + newRequest.setURL(QUrl(it.value())); } - // seems like the Mac code doesn't do anything here by default neither - //qDebug() << "FrameLoaderClientQt::dispatchWillSendRequest" << request.isNull() << request.url().string`(); + // Seems like the Mac code doesn't do anything here by default neither. + // qDebug() << "FrameLoaderClientQt::dispatchWillSendRequest" << request.isNull() << url; } -bool -FrameLoaderClientQt::shouldUseCredentialStorage(DocumentLoader*, unsigned long) +bool FrameLoaderClientQt::shouldUseCredentialStorage(DocumentLoader*, unsigned long) { notImplemented(); return false; @@ -1082,7 +1096,7 @@ void FrameLoaderClientQt::dispatchDidReceiveResponse(WebCore::DocumentLoader*, u if (dumpResourceResponseMIMETypes) { printf("%s has MIME type %s\n", - qPrintable(QFileInfo(drtDescriptionSuitableForTestResult(response.url())).fileName()), + qPrintable(QString(response.url().lastPathComponent())), qPrintable(QString(response.mimeType()))); } } @@ -1178,7 +1192,7 @@ WebCore::Frame* FrameLoaderClientQt::dispatchCreatePage(const WebCore::Navigatio void FrameLoaderClientQt::dispatchDecidePolicyForResponse(FramePolicyFunction function, const WebCore::ResourceResponse& response, const WebCore::ResourceRequest&) { - // we need to call directly here + // We need to call directly here. if (WebCore::contentDispositionType(response.httpHeaderField("Content-Disposition")) == WebCore::ContentDispositionAttachment) callPolicyFunction(function, PolicyDownload); else if (canShowMIMEType(response.mimeType())) @@ -1215,7 +1229,7 @@ void FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction(FramePolicyFun QWebPage*page = m_webFrame->page(); PolicyAction result; - // Currently, this is only enabled by DRT + // Currently, this is only enabled by DRT. if (policyDelegateEnabled) { RefPtr<Node> node; for (const Event* event = action.event(); event; event = event->underlyingEvent()) { @@ -1296,7 +1310,7 @@ PassRefPtr<Frame> FrameLoaderClientQt::createFrame(const KURL& url, const String emit m_webFrame->page()->frameCreated(webFrame); - // ### set override encoding if we have one + // FIXME: Set override encoding if we have one. m_frame->loader()->loadURLIntoChildFrame(frameData.url, frameData.referrer, frameData.frame.get()); @@ -1331,7 +1345,7 @@ void FrameLoaderClientQt::transferLoadingResourceFromPage(unsigned long, Documen ObjectContentType FrameLoaderClientQt::objectContentType(const KURL& url, const String& mimeTypeIn, bool shouldPreferPlugInsForImages) { -// qDebug()<<" ++++++++++++++++ url is "<<url.prettyURL()<<", mime = "<<mimeTypeIn; + // qDebug()<<" ++++++++++++++++ url is "<<url.prettyURL()<<", mime = "<<mimeTypeIn; QFileInfo fi(url.path()); String extension = fi.suffix(); if (mimeTypeIn == "application/x-qt-plugin" || mimeTypeIn == "application/x-qt-styled-widget") @@ -1432,8 +1446,8 @@ private: if (!isVisible()) return; - // if setMask is set with an empty QRegion, no clipping will - // be performed, so in that case we hide the platformWidget + // If setMask is set with an empty QRegion, no clipping will + // be performed, so in that case we hide the platformWidget. QRegion mask = platformWidget()->mask(); platformWidget()->setVisible(!mask.isEmpty()); } @@ -1467,7 +1481,7 @@ public: IntRect windowRect = convertToContainingWindow(IntRect(0, 0, frameRect().width(), frameRect().height())); graphicsWidget->setGeometry(QRect(windowRect)); - // FIXME: clipping of graphics widgets + // FIXME: Make the code handle clipping of graphics widgets. } virtual void show() { @@ -1494,8 +1508,8 @@ private: PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) { -// qDebug()<<"------ Creating plugin in FrameLoaderClientQt::createPlugin for "<<url.prettyURL() << mimeType; -// qDebug()<<"------\t url = "<<url.prettyURL(); + // qDebug()<<"------ Creating plugin in FrameLoaderClientQt::createPlugin for "<<url.prettyURL() << mimeType; + // qDebug()<<"------\t url = "<<url.prettyURL(); if (!m_webFrame) return 0; @@ -1553,12 +1567,12 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, QWidget* parentWidget = 0; if (m_webFrame->page()->d->client) parentWidget = qobject_cast<QWidget*>(m_webFrame->page()->d->client->pluginParent()); - if (parentWidget) // don't reparent to nothing (i.e. keep whatever parent QWebPage::createPlugin() chose. + if (parentWidget) // Don't reparent to nothing (i.e. keep whatever parent QWebPage::createPlugin() chose. widget->setParent(parentWidget); widget->hide(); RefPtr<QtPluginWidget> w = adoptRef(new QtPluginWidget()); w->setPlatformWidget(widget); - // Make sure it's invisible until properly placed into the layout + // Make sure it's invisible until properly placed into the layout. w->setFrameRect(IntRect(0, 0, 0, 0)); return w; } @@ -1570,16 +1584,16 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, if (m_webFrame->page()->d->client) parentWidget = qobject_cast<QGraphicsObject*>(m_webFrame->page()->d->client->pluginParent()); graphicsWidget->hide(); - if (parentWidget) // don't reparent to nothing (i.e. keep whatever parent QWebPage::createPlugin() chose. + if (parentWidget) // Don't reparent to nothing (i.e. keep whatever parent QWebPage::createPlugin() chose. graphicsWidget->setParentItem(parentWidget); RefPtr<QtPluginGraphicsWidget> w = QtPluginGraphicsWidget::create(graphicsWidget); - // Make sure it's invisible until properly placed into the layout + // 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 + // FIXME: Make things work for widgetless plugins as well. delete object; } #if ENABLE(NETSCAPE_PLUGIN_API) @@ -1592,16 +1606,16 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, #if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5) size_t wmodeIndex = params.find("wmode"); if (wmodeIndex == -1) { - // Disable XEmbed mode and force it to opaque mode + // Disable XEmbed mode and force it to opaque mode. params.append("wmode"); values.append("opaque"); } else if (!isQWebView) { - // Disable transparency if client is not a QWebView + // Disable transparency if client is not a QWebView. values[wmodeIndex] = "opaque"; } #else if (!isQWebView) { - // inject wmode=opaque when there is no client or the client is not a QWebView + // Inject wmode=opaque when there is no client or the client is not a QWebView. size_t wmodeIndex = params.find("wmode"); if (wmodeIndex == -1) { params.append("wmode"); @@ -1646,7 +1660,10 @@ QString FrameLoaderClientQt::chooseFile(const QString& oldFile) PassRefPtr<FrameNetworkingContext> FrameLoaderClientQt::createNetworkingContext() { - return FrameNetworkingContextQt::create(m_frame, m_webFrame, m_webFrame->page()->networkAccessManager()); + QVariant value = m_webFrame->page()->property("_q_MIMESniffingDisabled"); + bool MIMESniffingDisabled = value.isValid() && value.toBool(); + + return FrameNetworkingContextQt::create(m_frame, m_webFrame, !MIMESniffingDisabled, m_webFrame->page()->networkAccessManager()); } } diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h index 3ec5f20..900489d 100644 --- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h @@ -110,7 +110,7 @@ public: virtual void dispatchWillClose(); virtual void dispatchDidReceiveIcon(); virtual void dispatchDidStartProvisionalLoad(); - virtual void dispatchDidReceiveTitle(const String& title); + virtual void dispatchDidReceiveTitle(const StringWithDirection&); virtual void dispatchDidChangeIcons(); virtual void dispatchDidCommitLoad(); virtual void dispatchDidFailProvisionalLoad(const ResourceError&); @@ -186,7 +186,7 @@ public: virtual void prepareForDataSourceReplacement(); virtual WTF::PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&); - virtual void setTitle(const String& title, const KURL&); + virtual void setTitle(const StringWithDirection&, const KURL&); virtual String userAgent(const WebCore::KURL&); diff --git a/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.cpp b/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.cpp index b3b0f00..502a418 100644 --- a/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.cpp @@ -28,16 +28,17 @@ namespace WebCore { -FrameNetworkingContextQt::FrameNetworkingContextQt(Frame* frame, QObject* originatingObject, QNetworkAccessManager* networkAccessManager) +FrameNetworkingContextQt::FrameNetworkingContextQt(Frame* frame, QObject* originatingObject, bool mimeSniffingEnabled, QNetworkAccessManager* networkAccessManager) : FrameNetworkingContext(frame) , m_originatingObject(originatingObject) , m_networkAccessManager(networkAccessManager) + , m_mimeSniffingEnabled(mimeSniffingEnabled) { } -PassRefPtr<FrameNetworkingContextQt> FrameNetworkingContextQt::create(Frame* frame, QObject* originatingObject, QNetworkAccessManager* networkAccessManager) +PassRefPtr<FrameNetworkingContextQt> FrameNetworkingContextQt::create(Frame* frame, QObject* originatingObject, bool mimeSniffingEnabled, QNetworkAccessManager* networkAccessManager) { - return adoptRef(new FrameNetworkingContextQt(frame, originatingObject, networkAccessManager)); + return adoptRef(new FrameNetworkingContextQt(frame, originatingObject, mimeSniffingEnabled, networkAccessManager)); } QObject* FrameNetworkingContextQt::originatingObject() const @@ -50,4 +51,9 @@ QNetworkAccessManager* FrameNetworkingContextQt::networkAccessManager() const return (qobject_cast<QWebFrame*>(m_originatingObject))->page()->networkAccessManager(); } +bool FrameNetworkingContextQt::mimeSniffingEnabled() const +{ + return m_mimeSniffingEnabled; +} + } diff --git a/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.h b/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.h index 461023e..f23ba95 100644 --- a/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.h +++ b/Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.h @@ -26,16 +26,18 @@ namespace WebCore { class FrameNetworkingContextQt : public FrameNetworkingContext { public: - static PassRefPtr<FrameNetworkingContextQt> create(Frame*, QObject* originatingObject, QNetworkAccessManager*); + static PassRefPtr<FrameNetworkingContextQt> create(Frame*, QObject* originatingObject, bool mimeSniffingEnabled, QNetworkAccessManager*); private: - FrameNetworkingContextQt(Frame*, QObject* originatingObject, QNetworkAccessManager*); + FrameNetworkingContextQt(Frame*, QObject* originatingObject, bool mimeSniffingEnabled, QNetworkAccessManager*); virtual QObject* originatingObject() const; virtual QNetworkAccessManager* networkAccessManager() const; + virtual bool mimeSniffingEnabled() 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 ccca43c..7939370 100644 --- a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp @@ -22,18 +22,71 @@ #include "FullScreenVideoQt.h" #include "ChromeClientQt.h" +#if USE(QT_MULTIMEDIA) #include "FullScreenVideoWidget.h" +#include "MediaPlayerPrivateQt.h" +#endif #include "HTMLNames.h" #include "HTMLVideoElement.h" -#include "MediaPlayerPrivateQt.h" #include "Node.h" +#if USE(GSTREAMER) +#include "GStreamerGWorld.h" +#include "PlatformVideoWindowPrivate.h" +#endif +#if USE(QT_MULTIMEDIA) #include <QGraphicsVideoItem> #include <QMediaPlayer> +#endif +#include <QWidget> namespace WebCore { +#if USE(GSTREAMER) +GStreamerFullScreenVideoHandler::GStreamerFullScreenVideoHandler() + : m_videoElement(0) + , m_fullScreenWidget(0) +{ +} + +void GStreamerFullScreenVideoHandler::setVideoElement(HTMLVideoElement* element) +{ + m_videoElement = element; +} + +void GStreamerFullScreenVideoHandler::enterFullScreen() +{ + if (m_videoElement->platformMedia().type != WebCore::PlatformMedia::GStreamerGWorldType) + return; + + GStreamerGWorld* gstreamerGWorld = m_videoElement->platformMedia().media.gstreamerGWorld; + + if (!gstreamerGWorld->enterFullscreen()) + return; + + m_fullScreenWidget = reinterpret_cast<FullScreenVideoWindow*>(gstreamerGWorld->platformVideoWindow()->window()); + m_fullScreenWidget->setVideoElement(m_videoElement); + connect(m_fullScreenWidget, SIGNAL(closed()), this, SLOT(windowClosed())); + m_fullScreenWidget->showFullScreen(); +} + +void GStreamerFullScreenVideoHandler::windowClosed() +{ + m_videoElement->exitFullscreen(); +} + +void GStreamerFullScreenVideoHandler::exitFullScreen() +{ + if (m_videoElement->platformMedia().type == WebCore::PlatformMedia::GStreamerGWorldType) + m_videoElement->platformMedia().media.gstreamerGWorld->exitFullscreen(); + + m_fullScreenWidget->setVideoElement(0); + m_fullScreenWidget->close(); +} +#endif + +#if USE(QT_MULTIMEDIA) bool DefaultFullScreenVideoHandler::s_shouldForceFullScreenVideoPlayback = false; DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler() @@ -42,6 +95,8 @@ DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler() { connect(m_fullScreenWidget, SIGNAL(didExitFullScreen()), this, SIGNAL(fullScreenClosed())); m_fullScreenWidget->hide(); + + m_fullScreenWidget->close(); } DefaultFullScreenVideoHandler::~DefaultFullScreenVideoHandler() @@ -72,24 +127,36 @@ void DefaultFullScreenVideoHandler::exitFullScreen() { m_fullScreenWidget->close(); } +#endif FullScreenVideoQt::FullScreenVideoQt(ChromeClientQt* chromeClient) : m_chromeClient(chromeClient) , m_videoElement(0) { Q_ASSERT(m_chromeClient); - m_FullScreenVideoHandler = m_chromeClient->m_platformPlugin.createFullScreenVideoHandler(); +#if USE(QT_MULTIMEDIA) + m_FullScreenVideoHandler = m_chromeClient->m_platformPlugin.createFullScreenVideoHandler(); if (!m_FullScreenVideoHandler) m_FullScreenVideoHandler = new DefaultFullScreenVideoHandler; if (m_FullScreenVideoHandler) connect(m_FullScreenVideoHandler, SIGNAL(fullScreenClosed()), this, SLOT(aboutToClose())); +#endif + +#if USE(GSTREAMER) + m_FullScreenVideoHandlerGStreamer = new GStreamerFullScreenVideoHandler; +#endif } FullScreenVideoQt::~FullScreenVideoQt() { +#if USE(QT_MULTIMEDIA) delete m_FullScreenVideoHandler; +#endif +#if USE(GSTREAMER) + delete m_FullScreenVideoHandlerGStreamer; +#endif } void FullScreenVideoQt::enterFullScreenForNode(Node* node) @@ -97,25 +164,54 @@ void FullScreenVideoQt::enterFullScreenForNode(Node* node) Q_ASSERT(node); Q_ASSERT(m_FullScreenVideoHandler); + m_videoElement = static_cast<HTMLVideoElement*>(node); + +#if USE(QT_MULTIMEDIA) + HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node); + PlatformMedia platformMedia = videoElement->platformMedia(); + + ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType); + if (platformMedia.type != PlatformMedia::QtMediaPlayerType) + return; + if (!m_FullScreenVideoHandler) return; - MediaPlayerPrivateQt* mediaPlayerQt = mediaPlayerForNode(node); + MediaPlayerPrivateQt* mediaPlayerQt = mediaPlayer(); mediaPlayerQt->removeVideoItem(); m_FullScreenVideoHandler->enterFullScreen(mediaPlayerQt->mediaPlayer()); +#endif + +#if USE(GSTREAMER) + m_FullScreenVideoHandlerGStreamer->setVideoElement(m_videoElement); + m_FullScreenVideoHandlerGStreamer->enterFullScreen(); +#endif } void FullScreenVideoQt::exitFullScreenForNode(Node* node) { Q_ASSERT(node); + +#if USE(QT_MULTIMEDIA) + HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node); + PlatformMedia platformMedia = videoElement->platformMedia(); + + ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType); + if (platformMedia.type != PlatformMedia::QtMediaPlayerType) + return; + Q_ASSERT(m_FullScreenVideoHandler); if (!m_FullScreenVideoHandler) return; m_FullScreenVideoHandler->exitFullScreen(); - MediaPlayerPrivateQt* mediaPlayerQt = mediaPlayerForNode(node); + MediaPlayerPrivateQt* mediaPlayerQt = mediaPlayer(); mediaPlayerQt->restoreVideoItem(); +#endif +#if USE(GSTREAMER) + m_FullScreenVideoHandlerGStreamer->exitFullScreen(); +#endif } void FullScreenVideoQt::aboutToClose() @@ -124,24 +220,33 @@ void FullScreenVideoQt::aboutToClose() m_videoElement->exitFullscreen(); } +#if USE(QT_MULTIMEDIA) MediaPlayerPrivateQt* FullScreenVideoQt::mediaPlayer() { Q_ASSERT(m_videoElement); PlatformMedia platformMedia = m_videoElement->platformMedia(); return static_cast<MediaPlayerPrivateQt*>(platformMedia.media.qtMediaPlayer); } +#endif -MediaPlayerPrivateQt* FullScreenVideoQt::mediaPlayerForNode(Node* node) +bool FullScreenVideoQt::requiresFullScreenForVideoPlayback() { - Q_ASSERT(node); - if (node) - m_videoElement = static_cast<HTMLVideoElement*>(node); - return mediaPlayer(); +#if USE(QT_MULTIMEDIA) + return m_FullScreenVideoHandler ? m_FullScreenVideoHandler->requiresFullScreenForVideoPlayback() : false; +#endif +#if USE(GSTREAMER) + return false; +#endif } -bool FullScreenVideoQt::requiresFullScreenForVideoPlayback() +bool FullScreenVideoQt::isValid() const { - return m_FullScreenVideoHandler ? m_FullScreenVideoHandler->requiresFullScreenForVideoPlayback() : false; +#if USE(QT_MULTIMEDIA) + return m_FullScreenVideoHandler; +#endif +#if USE(GSTREAMER) + return m_FullScreenVideoHandlerGStreamer; +#endif } } diff --git a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h index a48a882..fda153d 100644 --- a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h +++ b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h @@ -22,6 +22,7 @@ #include "qwebkitplatformplugin.h" #include <QObject> +#include <wtf/Platform.h> QT_BEGIN_NAMESPACE class QGraphicsVideoItem; @@ -34,8 +35,35 @@ class ChromeClientQt; class FullScreenVideoWidget; class HTMLVideoElement; class Node; +#if USE(QT_MULTIMEDIA) class MediaPlayerPrivateQt; +#endif +// We do not use ENABLE or USE because moc does not expand these macros. +#if defined(WTF_USE_GSTREAMER) && WTF_USE_GSTREAMER +class FullScreenVideoWindow; + +class GStreamerFullScreenVideoHandler : public QObject { + Q_OBJECT +public: + GStreamerFullScreenVideoHandler(); + ~GStreamerFullScreenVideoHandler() { } + void setVideoElement(HTMLVideoElement*); + + void enterFullScreen(); + void exitFullScreen(); + +public Q_SLOTS: + void windowClosed(); + +private: + HTMLVideoElement* m_videoElement; + FullScreenVideoWindow* m_fullScreenWidget; +}; +#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: @@ -51,6 +79,7 @@ private: static bool s_shouldForceFullScreenVideoPlayback; FullScreenVideoWidget *m_fullScreenWidget; }; +#endif class FullScreenVideoQt : public QObject { Q_OBJECT @@ -61,11 +90,12 @@ public: virtual void enterFullScreenForNode(Node*); virtual void exitFullScreenForNode(Node*); bool requiresFullScreenForVideoPlayback(); - bool isValid() const { return m_FullScreenVideoHandler; } + bool isValid() const; private: +#if USE(QT_MULTIMEDIA) MediaPlayerPrivateQt* mediaPlayer(); - MediaPlayerPrivateQt* mediaPlayerForNode(Node* = 0); +#endif private slots: void aboutToClose(); @@ -73,7 +103,12 @@ private slots: private: ChromeClientQt* m_chromeClient; HTMLVideoElement* m_videoElement; +#if USE(QT_MULTIMEDIA) QWebFullScreenVideoHandler* m_FullScreenVideoHandler; +#endif +#if USE(GSTREAMER) + GStreamerFullScreenVideoHandler* m_FullScreenVideoHandlerGStreamer; +#endif }; } diff --git a/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp index 6b557db..36ec697 100644 --- a/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp @@ -32,6 +32,7 @@ #include "InspectorClientQt.h" #include "Frame.h" +#include "FrameView.h" #include "InspectorController.h" #include "InspectorFrontend.h" #include "InspectorServerQt.h" @@ -262,12 +263,17 @@ void InspectorClientQt::detachRemoteFrontend() void InspectorClientQt::highlight(Node*) { - notImplemented(); + hideHighlight(); } void InspectorClientQt::hideHighlight() { - notImplemented(); + WebCore::Frame* frame = m_inspectedWebPage->d->page->mainFrame(); + if (frame) { + QRect rect = m_inspectedWebPage->mainFrame()->geometry(); + if (!rect.isEmpty()) + frame->view()->invalidateRect(rect); + } } bool InspectorClientQt::sendMessageToFrontend(const String& message) diff --git a/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp b/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp index ea56134..12204ac 100644 --- a/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp +++ b/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp @@ -127,7 +127,7 @@ QWebTouchModifier* QtPlatformPlugin::createTouchModifier() return p ? static_cast<QWebTouchModifier*>(p->createExtension(QWebKitPlatformPlugin::TouchInteraction)) : 0; } -#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) +#if ENABLE(VIDEO) && USE(QT_MULTIMEDIA) QWebFullScreenVideoHandler* QtPlatformPlugin::createFullScreenVideoHandler() { QWebKitPlatformPlugin* p = plugin(); diff --git a/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h b/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h index 71ee2bb..685195d 100644 --- a/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h +++ b/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h @@ -29,7 +29,7 @@ class QWebNotificationPresenter; class QWebHapticFeedbackPlayer; class QWebSelectData; class QWebTouchModifier; -#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) +#if ENABLE(VIDEO) && USE(QT_MULTIMEDIA) class QWebFullScreenVideoHandler; #endif @@ -44,7 +44,7 @@ public: QWebNotificationPresenter* createNotificationPresenter(); QWebHapticFeedbackPlayer* createHapticFeedbackPlayer(); QWebTouchModifier* createTouchModifier(); -#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) +#if ENABLE(VIDEO) && USE(QT_MULTIMEDIA) QWebFullScreenVideoHandler* createFullScreenVideoHandler(); #endif |