diff options
Diffstat (limited to 'WebKit/qt')
33 files changed, 2002 insertions, 222 deletions
diff --git a/WebKit/qt/Api/DerivedSources.pro b/WebKit/qt/Api/DerivedSources.pro index 86d5dac..6fb52f2 100644 --- a/WebKit/qt/Api/DerivedSources.pro +++ b/WebKit/qt/Api/DerivedSources.pro @@ -10,7 +10,7 @@ DESTDIR = ../../../include/QtWebKit QUOTE = "" DOUBLE_ESCAPED_QUOTE = "" ESCAPE = "" -contains(QMAKE_HOST.os, "Windows"):isEmpty(QMAKE_SH) { +win32-msvc* | (contains(QMAKE_HOST.os, "Windows"):isEmpty(QMAKE_SH)) { # MinGW's make will run makefile commands using sh, even if make # was run from the Windows shell, if it finds sh in the path. ESCAPE = "^" diff --git a/WebKit/qt/Api/qwebelement.cpp b/WebKit/qt/Api/qwebelement.cpp index f7b1188..261631c 100644 --- a/WebKit/qt/Api/qwebelement.cpp +++ b/WebKit/qt/Api/qwebelement.cpp @@ -31,23 +31,33 @@ #include "FrameView.h" #include "GraphicsContext.h" #include "HTMLElement.h" +#if USE(JSC) #include "JSGlobalObject.h" #include "JSHTMLElement.h" #include "JSObject.h" -#include "NodeList.h" #include "PropertyNameArray.h" +#include <parser/SourceCode.h> +#include "qt_runtime.h" +#elif USE(V8) +#include "V8DOMWindow.h" +#include "V8Binding.h" +#include "NotImplemented.h" +#endif +#include "NodeList.h" #include "RenderImage.h" #include "StaticNodeList.h" -#include "qt_runtime.h" #include "qwebframe.h" #include "qwebframe_p.h" #include "runtime_root.h" -#include <parser/SourceCode.h> #include <wtf/Vector.h> #include <wtf/text/CString.h> #include <QPainter> +#if USE(V8) +using namespace V8::Bindings; +#endif + using namespace WebCore; class QWebElementPrivate { @@ -694,6 +704,7 @@ QWebFrame *QWebElement::webFrame() const return QWebFramePrivate::kit(frame); } +#if USE(JSC) static bool setupScriptContext(WebCore::Element* element, JSC::JSValue& thisValue, ScriptState*& state, ScriptController*& scriptController) { if (!element) @@ -721,6 +732,26 @@ static bool setupScriptContext(WebCore::Element* element, JSC::JSValue& thisValu return true; } +#elif USE(V8) +static bool setupScriptContext(WebCore::Element* element, v8::Handle<v8::Value>& thisValue, ScriptState*& state, ScriptController*& scriptController) +{ + if (!element) + return false; + + Document* document = element->document(); + if (!document) + return false; + + Frame* frame = document->frame(); + if (!frame) + return false; + + state = mainWorldScriptState(frame); + // Get V8 wrapper for DOM element + thisValue = toV8(frame->domWindow()); + return true; +} +#endif /*! @@ -732,12 +763,16 @@ QVariant QWebElement::evaluateJavaScript(const QString& scriptSource) return QVariant(); ScriptState* state = 0; +#if USE(JSC) JSC::JSValue thisValue; +#elif USE(V8) + v8::Handle<v8::Value> thisValue; +#endif ScriptController* scriptController = 0; if (!setupScriptContext(m_element, thisValue, state, scriptController)) return QVariant(); - +#if USE(JSC) JSC::ScopeChain& scopeChain = state->dynamicGlobalObject()->globalScopeChain(); JSC::UString script(reinterpret_cast_ptr<const UChar*>(scriptSource.data()), scriptSource.length()); JSC::Completion completion = JSC::evaluate(state, scopeChain, JSC::makeSource(script), thisValue); @@ -750,6 +785,10 @@ QVariant QWebElement::evaluateJavaScript(const QString& scriptSource) int distance = 0; return JSC::Bindings::convertValueToQVariant(state, result, QMetaType::Void, &distance); +#elif USE(V8) + notImplemented(); + return QVariant(); +#endif } /*! diff --git a/WebKit/qt/Api/qwebelement.h b/WebKit/qt/Api/qwebelement.h index c488d12..b94c372 100644 --- a/WebKit/qt/Api/qwebelement.h +++ b/WebKit/qt/Api/qwebelement.h @@ -32,11 +32,20 @@ namespace WebCore { class Node; } -namespace JSC { -namespace Bindings { + +#if defined(WTF_USE_V8) && WTF_USE_V8 +namespace V8 { + namespace Bindings { class QtWebElementRuntime; + } } +#else +namespace JSC { + namespace Bindings { + class QtWebElementRuntime; + } } +#endif QT_BEGIN_NAMESPACE class QPainter; @@ -160,7 +169,12 @@ private: friend class QWebHitTestResult; friend class QWebHitTestResultPrivate; friend class QWebPage; + +#if defined(WTF_USE_V8) && WTF_USE_V8 + friend class V8::Bindings::QtWebElementRuntime; +#else friend class JSC::Bindings::QtWebElementRuntime; +#endif QWebElementPrivate* d; WebCore::Element* m_element; diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp index 464b4a0..46580bb 100644 --- a/WebKit/qt/Api/qwebframe.cpp +++ b/WebKit/qt/Api/qwebframe.cpp @@ -21,8 +21,12 @@ #include "config.h" #include "qwebframe.h" +#if USE(JSC) #include "Bridge.h" #include "CallFrame.h" +#elif USE(V8) +#include "V8Binding.h" +#endif #include "Document.h" #include "DocumentLoader.h" #include "DragData.h" @@ -32,23 +36,35 @@ #include "FrameLoaderClientQt.h" #include "FrameTree.h" #include "FrameView.h" +#if USE(JSC) #include "GCController.h" +#elif USE(V8) +#include "V8GCController.h" +#endif #include "GraphicsContext.h" #include "HTMLMetaElement.h" #include "HitTestResult.h" #include "HTTPParsers.h" #include "IconDatabase.h" #include "InspectorController.h" +#if USE(JSC) #include "JSDOMBinding.h" #include "JSDOMWindowBase.h" #include "JSLock.h" #include "JSObject.h" +#elif USE(V8) +#include "V8DOMWrapper.h" +#include "V8DOMWindowShell.h" +#endif +#include "NetworkingContext.h" #include "NodeList.h" #include "Page.h" #include "PlatformMouseEvent.h" #include "PlatformWheelEvent.h" #include "PrintContext.h" +#if USE(JSC) #include "PutPropertySlot.h" +#endif #include "RenderLayer.h" #include "RenderTreeAsText.h" #include "RenderView.h" @@ -64,8 +80,10 @@ #include "TiledBackingStore.h" #include "htmlediting.h" #include "markup.h" +#if USE(JSC) #include "qt_instance.h" #include "qt_runtime.h" +#endif #include "qwebelement.h" #include "qwebframe_p.h" #include "qwebpage.h" @@ -74,8 +92,10 @@ #include "qwebsecurityorigin_p.h" #include "qwebscriptworld.h" #include "qwebscriptworld_p.h" +#if USE(JSC) #include "runtime_object.h" #include "runtime_root.h" +#endif #include "wtf/HashMap.h" #include <QMultiMap> #include <qdebug.h> @@ -476,7 +496,7 @@ void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object { if (!page()->settings()->testAttribute(QWebSettings::JavascriptEnabled)) return; - +#if USE(JSC) JSC::JSLock lock(JSC::SilenceAssertionsOnly); JSDOMWindow* window = toJSDOMWindow(d->frame, mainThreadNormalWorld()); JSC::Bindings::RootObject* root; @@ -497,6 +517,13 @@ void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object JSC::PutPropertySlot slot; window->put(exec, JSC::Identifier(exec, reinterpret_cast_ptr<const UChar*>(name.constData()), name.length()), runtimeObject, slot); +#elif USE(V8) + QScriptEngine* engine = d->frame->script()->qtScriptEngine(); + if (!engine) + return; + QScriptValue v = engine->newQObject(object, ownership); + engine->globalObject().property("window").setProperty(name, v); +#endif } /*! @@ -868,9 +895,9 @@ QList<QWebFrame*> QWebFrame::childFrames() const FrameTree *tree = d->frame->tree(); for (Frame *child = tree->firstChild(); child; child = child->tree()->nextSibling()) { FrameLoader *loader = child->loader(); - FrameLoaderClientQt *client = static_cast<FrameLoaderClientQt*>(loader->client()); - if (client) - rc.append(client->webFrame()); + QWebFrame* webFrame = qobject_cast<QWebFrame*>(loader->networkingContext()->originatingObject()); + if (webFrame) + rc.append(webFrame); } } @@ -1105,11 +1132,9 @@ void QWebFrame::render(QPainter* painter) */ void QWebFrame::setTextSizeMultiplier(qreal factor) { - FrameView* view = d->frame->view(); - if (!view) - return; + page()->settings()->setAttribute(QWebSettings::ZoomTextOnly, true); - view->setZoomFactor(factor, ZoomTextOnly); + d->frame->setPageAndTextZoomFactors(1, factor); } /*! @@ -1117,11 +1142,7 @@ void QWebFrame::setTextSizeMultiplier(qreal factor) */ qreal QWebFrame::textSizeMultiplier() const { - FrameView* view = d->frame->view(); - if (!view) - return 1; - - return view->zoomFactor(); + return d->zoomTextOnly ? d->frame->textZoomFactor() : d->frame->pageZoomFactor(); } /*! @@ -1132,24 +1153,15 @@ qreal QWebFrame::textSizeMultiplier() const void QWebFrame::setZoomFactor(qreal factor) { - Page* page = d->frame->page(); - if (!page) - return; - - FrameView* view = d->frame->view(); - if (!view) - return; - - view->setZoomFactor(factor, page->settings()->zoomMode()); + if (d->zoomTextOnly) + d->frame->setTextZoomFactor(factor); + else + d->frame->setPageZoomFactor(factor); } qreal QWebFrame::zoomFactor() const { - FrameView* view = d->frame->view(); - if (!view) - return 1; - - return view->zoomFactor(); + return d->zoomTextOnly ? d->frame->textZoomFactor() : d->frame->pageZoomFactor(); } /*! @@ -1388,9 +1400,17 @@ QVariant QWebFrame::evaluateJavaScript(const QString& scriptSource) ScriptController *proxy = d->frame->script(); QVariant rc; if (proxy) { - JSC::JSValue v = d->frame->script()->executeScript(ScriptSourceCode(scriptSource)).jsValue(); +#if USE(JSC) int distance = 0; + JSC::JSValue v = d->frame->script()->executeScript(ScriptSourceCode(scriptSource)).jsValue(); + rc = JSC::Bindings::convertValueToQVariant(proxy->globalObject(mainThreadNormalWorld())->globalExec(), v, QMetaType::Void, &distance); +#elif USE(V8) + QScriptEngine* engine = d->frame->script()->qtScriptEngine(); + if (!engine) + return rc; + rc = engine->evaluate(scriptSource).toVariant(); +#endif } return rc; } @@ -1414,7 +1434,7 @@ WebCore::Frame* QWebFramePrivate::core(const QWebFrame* webFrame) QWebFrame* QWebFramePrivate::kit(const WebCore::Frame* coreFrame) { - return static_cast<FrameLoaderClientQt*>(coreFrame->loader()->client())->webFrame(); + return qobject_cast<QWebFrame*>(coreFrame->loader()->networkingContext()->originatingObject()); } diff --git a/WebKit/qt/Api/qwebframe_p.h b/WebKit/qt/Api/qwebframe_p.h index b5dda62..6d6eca1 100644 --- a/WebKit/qt/Api/qwebframe_p.h +++ b/WebKit/qt/Api/qwebframe_p.h @@ -31,6 +31,7 @@ #include "qwebelement.h" #include "wtf/RefPtr.h" #include "Frame.h" +#include "ViewportArguments.h" namespace WebCore { class FrameLoaderClientQt; @@ -71,7 +72,7 @@ public: , allowsScrolling(true) , marginWidth(-1) , marginHeight(-1) - , initialLayoutComplete(false) + , zoomTextOnly(false) {} void init(QWebFrame* qframe, QWebFrameData* frameData); void setPage(QWebPage*); @@ -99,7 +100,8 @@ public: bool allowsScrolling; int marginWidth; int marginHeight; - bool initialLayoutComplete; + bool zoomTextOnly; + WebCore::ViewportArguments viewportArguments; }; class QWebHitTestResultPrivate { diff --git a/WebKit/qt/Api/qwebkitplatformplugin.h b/WebKit/qt/Api/qwebkitplatformplugin.h index 3c56c98..76496c5 100644 --- a/WebKit/qt/Api/qwebkitplatformplugin.h +++ b/WebKit/qt/Api/qwebkitplatformplugin.h @@ -27,6 +27,7 @@ */ #include <QObject> +#include <QUrl> class QWebSelectData { @@ -66,6 +67,7 @@ public: virtual const QString title() const = 0; virtual const QString message() const = 0; virtual const QByteArray iconData() const = 0; + virtual const QUrl openerPageUrl() const = 0; }; class QWebNotificationPresenter : public QObject @@ -79,6 +81,7 @@ public: Q_SIGNALS: void notificationClosed(); + void notificationClicked(); }; class QWebHapticFeedbackPlayer @@ -113,6 +116,6 @@ public: }; -Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.3"); +Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.4"); #endif // QWEBKITPLATFORMPLUGIN_H diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index 8bf9208..181b3a6 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -64,6 +64,7 @@ #include "FocusController.h" #include "Editor.h" #include "Scrollbar.h" +#include "NetworkingContext.h" #include "PlatformKeyboardEvent.h" #include "PlatformWheelEvent.h" #include "PluginDatabase.h" @@ -77,6 +78,7 @@ #include "HTMLNames.h" #include "HitTestResult.h" #include "WindowFeatures.h" +#include "WebPlatformStrategies.h" #include "LocalizedStrings.h" #include "Cache.h" #include "runtime/InitializeThreading.h" @@ -263,13 +265,15 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) , inspectorIsInternalOnly(false) { WebCore::InitializeLoggingChannelsIfNecessary(); - JSC::initializeThreading(); + ScriptController::initializeThreading(); WTF::initializeMainThread(); WebCore::SecurityOrigin::setLocalLoadPolicy(WebCore::SecurityOrigin::AllowLocalLoadsForLocalAndSubstituteData); #if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) WebCore::Font::setCodePath(WebCore::Font::Complex); #endif + WebPlatformStrategies::initialize(qq); + Page::PageClients pageClients; pageClients.chromeClient = new ChromeClientQt(q); pageClients.contextMenuClient = new ContextMenuClientQt(); @@ -1201,7 +1205,8 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev) (selection.length < 0) ? selection.start : selection.start + selection.length); } else #endif - editor->setComposition(preedit, underlines, preedit.length(), 0); + if (!preedit.isEmpty()) + editor->setComposition(preedit, underlines, preedit.length(), 0); } ev->accept(); @@ -1697,15 +1702,15 @@ InspectorController* QWebPagePrivate::inspectorController() /*! - \class QWebPage::ViewportHints + \class QWebPage::ViewportConfiguration \since 4.7 - \brief The QWebPage::ViewportHints class describes hints that can be applied to a viewport. + \brief The QWebPage::ViewportConfiguration class describes hints that can be applied to a viewport. - QWebPage::ViewportHints provides a description of a viewport, such as viewport geometry, + QWebPage::ViewportConfiguration provides a description of a viewport, such as viewport geometry, initial scale factor with limits, plus information about whether a user should be able to scale the contents in the viewport or not, ie. by zooming. - ViewportHints can be set by a web author using the viewport meta tag extension, documented + ViewportConfiguration can be set by a web author using the viewport meta tag extension, documented at \l{http://developer.apple.com/safari/library/documentation/appleapplications/reference/safariwebcontent/usingtheviewport/usingtheviewport.html}{Safari Reference Library: Using the Viewport Meta Tag}. All values might not be set, as such when dealing with the hints, the developer needs to @@ -1715,13 +1720,14 @@ InspectorController* QWebPagePrivate::inspectorController() */ /*! - Constructs an empty QWebPage::ViewportHints. + Constructs an empty QWebPage::ViewportConfiguration. */ -QWebPage::ViewportHints::ViewportHints() +QWebPage::ViewportConfiguration::ViewportConfiguration() : d(0) , m_initialScaleFactor(-1.0) , m_minimumScaleFactor(-1.0) , m_maximumScaleFactor(-1.0) + , m_devicePixelRatio(-1.0) , m_isUserScalable(true) , m_isValid(false) { @@ -1729,13 +1735,14 @@ QWebPage::ViewportHints::ViewportHints() } /*! - Constructs a QWebPage::ViewportHints which is a copy from \a other . + Constructs a QWebPage::ViewportConfiguration which is a copy from \a other . */ -QWebPage::ViewportHints::ViewportHints(const QWebPage::ViewportHints& other) +QWebPage::ViewportConfiguration::ViewportConfiguration(const QWebPage::ViewportConfiguration& other) : d(other.d) , m_initialScaleFactor(other.m_initialScaleFactor) , m_minimumScaleFactor(other.m_minimumScaleFactor) , m_maximumScaleFactor(other.m_maximumScaleFactor) + , m_devicePixelRatio(other.m_devicePixelRatio) , m_isUserScalable(other.m_isUserScalable) , m_isValid(other.m_isValid) , m_size(other.m_size) @@ -1744,18 +1751,18 @@ QWebPage::ViewportHints::ViewportHints(const QWebPage::ViewportHints& other) } /*! - Destroys the QWebPage::ViewportHints. + Destroys the QWebPage::ViewportConfiguration. */ -QWebPage::ViewportHints::~ViewportHints() +QWebPage::ViewportConfiguration::~ViewportConfiguration() { } /*! - Assigns the given QWebPage::ViewportHints to this viewport hints and returns a + Assigns the given QWebPage::ViewportConfiguration to this viewport hints and returns a reference to this. */ -QWebPage::ViewportHints& QWebPage::ViewportHints::operator=(const QWebPage::ViewportHints& other) +QWebPage::ViewportConfiguration& QWebPage::ViewportConfiguration::operator=(const QWebPage::ViewportConfiguration& other) { if (this != &other) { d = other.d; @@ -1770,30 +1777,30 @@ QWebPage::ViewportHints& QWebPage::ViewportHints::operator=(const QWebPage::View return *this; } -/*! \fn inline bool QWebPage::ViewportHints::isValid() const - Returns whether this is a valid ViewportHints or not. +/*! \fn inline bool QWebPage::ViewportConfiguration::isValid() const + Returns whether this is a valid ViewportConfiguration or not. - An invalid ViewportHints will have an empty QSize, negative values for scale factors and + An invalid ViewportConfiguration will have an empty QSize, negative values for scale factors and true for the boolean isUserScalable. */ -/*! \fn inline QSize QWebPage::ViewportHints::size() const +/*! \fn inline QSize QWebPage::ViewportConfiguration::size() const Returns the size of the viewport. */ -/*! \fn inline qreal QWebPage::ViewportHints::initialScaleFactor() const +/*! \fn inline qreal QWebPage::ViewportConfiguration::initialScaleFactor() const Returns the initial scale of the viewport as a multiplier. */ -/*! \fn inline qreal QWebPage::ViewportHints::minimumScaleFactor() const +/*! \fn inline qreal QWebPage::ViewportConfiguration::minimumScaleFactor() const Returns the minimum scale value of the viewport as a multiplier. */ -/*! \fn inline qreal QWebPage::ViewportHints::maximumScaleFactor() const +/*! \fn inline qreal QWebPage::ViewportConfiguration::maximumScaleFactor() const Returns the maximum scale value of the viewport as a multiplier. */ -/*! \fn inline bool QWebPage::ViewportHints::isUserScalable() const +/*! \fn inline bool QWebPage::ViewportConfiguration::isUserScalable() const Determines whether or not the scale can be modified by the user. */ @@ -1913,7 +1920,8 @@ QWebFrame *QWebPage::mainFrame() const QWebFrame *QWebPage::currentFrame() const { d->createMainFrame(); - return static_cast<WebCore::FrameLoaderClientQt *>(d->page->focusController()->focusedOrMainFrame()->loader()->client())->webFrame(); + WebCore::Frame *frame = d->page->focusController()->focusedOrMainFrame(); + return qobject_cast<QWebFrame*>(frame->loader()->networkingContext()->originatingObject()); } @@ -2317,6 +2325,30 @@ void QWebPage::setViewportSize(const QSize &size) const } } +QWebPage::ViewportConfiguration QWebPage::viewportConfigurationForSize(QSize availableSize) const +{ + static int desktopWidth = 980; + static int deviceDPI = 160; + + FloatRect rect = d->page->chrome()->windowRect(); + + int deviceWidth = rect.width(); + int deviceHeight = rect.height(); + + WebCore::ViewportConfiguration conf = WebCore::findConfigurationForViewportData(mainFrame()->d->viewportArguments, desktopWidth, deviceWidth, deviceHeight, deviceDPI, availableSize); + + ViewportConfiguration result; + + result.m_isValid = true; + result.m_size = conf.layoutViewport; + result.m_initialScaleFactor = conf.initialScale; + result.m_minimumScaleFactor = conf.minimumScale; + result.m_maximumScaleFactor = conf.maximumScale; + result.m_devicePixelRatio = conf.devicePixelRatio; + + return result; +} + QSize QWebPage::preferredContentsSize() const { QWebFrame* frame = d->mainFrame; @@ -2366,8 +2398,7 @@ void QWebPage::setPreferredContentsSize(const QSize& size) const } else if (view->useFixedLayout()) view->setUseFixedLayout(false); - if (frame->d->initialLayoutComplete) - view->layout(); + view->layout(); } /*! @@ -3699,25 +3730,12 @@ quint64 QWebPage::bytesReceived() const /*! \since 4.7 - \fn void QWebPage::viewportChangeRequested(const QWebPage::ViewportHints& hints) - - This signal is emitted before any layout of the contents, giving you the viewport \a arguments - the web page would like you to use when laying out its contents, including elements fixed to the - viewport. This viewport might be larger that your actual viewport, meaning that a initialScaleFactor - should be applied. When no scale is given, it is assumed that the contents should be scaled - such that the width of the scaled contents fits within the actual viewport. - - The minimum and maximum allowed scale represents the min and max values that the page - allows for scaling, and thus, affects the ability to zoom in on the page. - - Invalid values are supplied for the values not explicitly set by the web author; thus an - invalid viewport size, and negative values for scale factor and limits. The boolean - ViewportHints::isUserScalable is set to true. + \fn void QWebPage::viewportChangeRequested() Page authors can provide the supplied values by using the viewport meta tag. More information about this can be found at \l{http://developer.apple.com/safari/library/documentation/appleapplications/reference/safariwebcontent/usingtheviewport/usingtheviewport.html}{Safari Reference Library: Using the Viewport Meta Tag}. - \sa QWebPage::ViewportHints, setPreferredContentsSize(), QGraphicsWebView::setScale() + \sa QWebPage::ViewportConfiguration, setPreferredContentsSize(), QGraphicsWebView::setScale() */ /*! diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h index dda4a6a..b1441ff 100644 --- a/WebKit/qt/Api/qwebpage.h +++ b/WebKit/qt/Api/qwebpage.h @@ -48,7 +48,7 @@ class QWebHitTestResult; class QWebNetworkInterface; class QWebPagePrivate; class QWebPluginFactory; -class QtViewportHintsPrivate; +class QtViewportConfigurationPrivate; namespace WebCore { class ChromeClientQt; @@ -207,34 +207,35 @@ public: GeolocationPermissionDomain }; - class ViewportHints { + class ViewportConfiguration { public: - ViewportHints(); - ViewportHints(const QWebPage::ViewportHints& other); + ViewportConfiguration(); + ViewportConfiguration(const QWebPage::ViewportConfiguration& other); - ~ViewportHints(); + ~ViewportConfiguration(); - QWebPage::ViewportHints& operator=(const QWebPage::ViewportHints& other); + QWebPage::ViewportConfiguration& operator=(const QWebPage::ViewportConfiguration& other); inline qreal initialScaleFactor() const { return m_initialScaleFactor; }; inline qreal minimumScaleFactor() const { return m_minimumScaleFactor; }; inline qreal maximumScaleFactor() const { return m_maximumScaleFactor; }; - inline int targetDensityDpi() const { return m_targetDensityDpi; }; + inline qreal devicePixelRatio() const { return m_devicePixelRatio; }; inline bool isUserScalable() const { return m_isUserScalable; }; inline bool isValid() const { return m_isValid; }; inline QSize size() const { return m_size; }; private: - QSharedDataPointer<QtViewportHintsPrivate> d; + QSharedDataPointer<QtViewportConfigurationPrivate> d; qreal m_initialScaleFactor; qreal m_minimumScaleFactor; qreal m_maximumScaleFactor; - int m_targetDensityDpi; + qreal m_devicePixelRatio; bool m_isUserScalable; bool m_isValid; QSize m_size; friend class WebCore::ChromeClientQt; + friend class QWebPage; }; @@ -274,6 +275,7 @@ public: QSize viewportSize() const; void setViewportSize(const QSize &size) const; + ViewportConfiguration viewportConfigurationForSize(QSize availableSize) const; QSize preferredContentsSize() const; void setPreferredContentsSize(const QSize &size) const; @@ -384,7 +386,7 @@ Q_SIGNALS: void saveFrameStateRequested(QWebFrame* frame, QWebHistoryItem* item); void restoreFrameStateRequested(QWebFrame* frame); - void viewportChangeRequested(const QWebPage::ViewportHints& hints); + void viewportChangeRequested(); void requestPermissionFromUser(QWebFrame* frame, QWebPage::PermissionDomain domain); void checkPermissionFromUser(QWebFrame* frame, QWebPage::PermissionDomain domain, QWebPage::PermissionPolicy& policy); diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h index 6310eaf..82f5365 100644 --- a/WebKit/qt/Api/qwebpage_p.h +++ b/WebKit/qt/Api/qwebpage_p.h @@ -58,13 +58,13 @@ QT_END_NAMESPACE class QWebInspector; class QWebPageClient; -class QtViewportHintsPrivate : public QSharedData { +class QtViewportConfigurationPrivate : public QSharedData { public: - QtViewportHintsPrivate(QWebPage::ViewportHints* qq) + QtViewportConfigurationPrivate(QWebPage::ViewportConfiguration* qq) : q(qq) { } - QWebPage::ViewportHints* q; + QWebPage::ViewportConfiguration* q; }; class QWebPagePrivate { diff --git a/WebKit/qt/Api/qwebscriptworld.cpp b/WebKit/qt/Api/qwebscriptworld.cpp index 84b678d..74ab651 100644 --- a/WebKit/qt/Api/qwebscriptworld.cpp +++ b/WebKit/qt/Api/qwebscriptworld.cpp @@ -32,7 +32,9 @@ using namespace WebCore; */ QWebScriptWorld::QWebScriptWorld() { +#if USE(JSC) d = new QWebScriptWorldPrivate(ScriptController::createWorld()); +#endif } QWebScriptWorld::QWebScriptWorld(const QWebScriptWorld& other) diff --git a/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp index d88b0da..b71de25 100644 --- a/WebKit/qt/Api/qwebsettings.cpp +++ b/WebKit/qt/Api/qwebsettings.cpp @@ -217,10 +217,6 @@ void QWebSettingsPrivate::apply() QString storagePath = !localStoragePath.isEmpty() ? localStoragePath : global->localStoragePath; settings->setLocalStorageDatabasePath(storagePath); - value = attributes.value(QWebSettings::ZoomTextOnly, - global->attributes.value(QWebSettings::ZoomTextOnly)); - settings->setZoomMode(value ? WebCore::ZoomTextOnly : WebCore::ZoomPage); - value = attributes.value(QWebSettings::PrintElementBackgrounds, global->attributes.value(QWebSettings::PrintElementBackgrounds)); settings->setShouldPrintBackgrounds(value); diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog index 95e79a4..34edbd7 100644 --- a/WebKit/qt/ChangeLog +++ b/WebKit/qt/ChangeLog @@ -1,3 +1,557 @@ +2010-09-20 Jacob Dinu <dinu.jacob@nokia.com> + + Reviewed by Adam Barth. + + Added a new qwebpage test for loading a cached page + https://bugs.webkit.org/show_bug.cgi?id=41155 + + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::loadCachedPage): + +2010-09-08 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Fix forward includes generation for MSVC when sh is in PATH. + + MSVC's nmake isn't affected by having sh in PATH. + + * Api/DerivedSources.pro: + +2010-09-18 Ademar de Souza Reis Jr <ademar.reis@openbossa.org> + + Reviewed by Kenneth Rohde Christiansen. + + Enable Platform Strategies on Qt + + [Qt] Turn on PLATFORM_STRATEGIES + https://bugs.webkit.org/show_bug.cgi?id=45831 + + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): Initialize the PlatformStrategy + singleton. + * WebCoreSupport/WebPlatformStrategies.cpp: Added, code was moved + from platform/qt/Localizations.cpp and plugins/qt/PluginDataQt.cpp + (WebPlatformStrategies::initialize): create the singleton, + following the same "pattern" used by Mac and Win ports. + (WebPlatformStrategies::WebPlatformStrategies): + (WebPlatformStrategies::createPluginStrategy): + (WebPlatformStrategies::createLocalizationStrategy): + (WebPlatformStrategies::createVisitedLinkStrategy): + (WebPlatformStrategies::refreshPlugins): + (WebPlatformStrategies::getPluginInfo): + (WebPlatformStrategies::inputElementAltText): + (WebPlatformStrategies::resetButtonDefaultLabel): + (WebPlatformStrategies::searchableIndexIntroduction): + (WebPlatformStrategies::submitButtonDefaultLabel): + (WebPlatformStrategies::fileButtonChooseFileLabel): + (WebPlatformStrategies::fileButtonNoFileSelectedLabel): + (WebPlatformStrategies::contextMenuItemTagOpenLinkInNewWindow): + (WebPlatformStrategies::contextMenuItemTagDownloadLinkToDisk): + (WebPlatformStrategies::contextMenuItemTagCopyLinkToClipboard): + (WebPlatformStrategies::contextMenuItemTagOpenImageInNewWindow): + (WebPlatformStrategies::contextMenuItemTagDownloadImageToDisk): + (WebPlatformStrategies::contextMenuItemTagCopyImageToClipboard): + (WebPlatformStrategies::contextMenuItemTagOpenFrameInNewWindow): + (WebPlatformStrategies::contextMenuItemTagCopy): + (WebPlatformStrategies::contextMenuItemTagGoBack): + (WebPlatformStrategies::contextMenuItemTagGoForward): + (WebPlatformStrategies::contextMenuItemTagStop): + (WebPlatformStrategies::contextMenuItemTagReload): + (WebPlatformStrategies::contextMenuItemTagCut): + (WebPlatformStrategies::contextMenuItemTagPaste): + (WebPlatformStrategies::contextMenuItemTagNoGuessesFound): + (WebPlatformStrategies::contextMenuItemTagIgnoreSpelling): + (WebPlatformStrategies::contextMenuItemTagLearnSpelling): + (WebPlatformStrategies::contextMenuItemTagSearchWeb): + (WebPlatformStrategies::contextMenuItemTagLookUpInDictionary): + (WebPlatformStrategies::contextMenuItemTagOpenLink): + (WebPlatformStrategies::contextMenuItemTagIgnoreGrammar): + (WebPlatformStrategies::contextMenuItemTagSpellingMenu): + (WebPlatformStrategies::contextMenuItemTagShowSpellingPanel): + (WebPlatformStrategies::contextMenuItemTagCheckSpelling): + (WebPlatformStrategies::contextMenuItemTagCheckSpellingWhileTyping): + (WebPlatformStrategies::contextMenuItemTagCheckGrammarWithSpelling): + (WebPlatformStrategies::contextMenuItemTagFontMenu): + (WebPlatformStrategies::contextMenuItemTagBold): + (WebPlatformStrategies::contextMenuItemTagItalic): + (WebPlatformStrategies::contextMenuItemTagUnderline): + (WebPlatformStrategies::contextMenuItemTagOutline): + (WebPlatformStrategies::contextMenuItemTagWritingDirectionMenu): + (WebPlatformStrategies::contextMenuItemTagTextDirectionMenu): + (WebPlatformStrategies::contextMenuItemTagDefaultDirection): + (WebPlatformStrategies::contextMenuItemTagLeftToRight): + (WebPlatformStrategies::contextMenuItemTagRightToLeft): + (WebPlatformStrategies::contextMenuItemTagInspectElement): + (WebPlatformStrategies::searchMenuNoRecentSearchesText): + (WebPlatformStrategies::searchMenuRecentSearchesText): + (WebPlatformStrategies::searchMenuClearRecentSearchesText): + (WebPlatformStrategies::AXWebAreaText): + (WebPlatformStrategies::AXLinkText): + (WebPlatformStrategies::AXListMarkerText): + (WebPlatformStrategies::AXImageMapText): + (WebPlatformStrategies::AXHeadingText): + (WebPlatformStrategies::AXDefinitionListTermText): + (WebPlatformStrategies::AXDefinitionListDefinitionText): + (WebPlatformStrategies::AXButtonActionVerb): + (WebPlatformStrategies::AXRadioButtonActionVerb): + (WebPlatformStrategies::AXTextFieldActionVerb): + (WebPlatformStrategies::AXCheckedCheckBoxActionVerb): + (WebPlatformStrategies::AXUncheckedCheckBoxActionVerb): + (WebPlatformStrategies::AXMenuListActionVerb): + (WebPlatformStrategies::AXMenuListPopupActionVerb): + (WebPlatformStrategies::AXLinkActionVerb): + (WebPlatformStrategies::missingPluginText): + (WebPlatformStrategies::crashedPluginText): + (WebPlatformStrategies::multipleFileUploadText): + (WebPlatformStrategies::unknownFileSizeText): + (WebPlatformStrategies::imageTitle): + (WebPlatformStrategies::mediaElementLoadingStateText): + (WebPlatformStrategies::mediaElementLiveBroadcastStateText): + (WebPlatformStrategies::localizedMediaControlElementString): + (WebPlatformStrategies::localizedMediaControlElementHelpText): + (WebPlatformStrategies::localizedMediaTimeDescription): + (WebPlatformStrategies::validationMessageValueMissingText): + (WebPlatformStrategies::validationMessageTypeMismatchText): + (WebPlatformStrategies::validationMessagePatternMismatchText): + (WebPlatformStrategies::validationMessageTooLongText): + (WebPlatformStrategies::validationMessageRangeUnderflowText): + (WebPlatformStrategies::validationMessageRangeOverflowText): + (WebPlatformStrategies::validationMessageStepMismatchText): + (WebPlatformStrategies::isLinkVisited): + (WebPlatformStrategies::addVisitedLink): + * WebCoreSupport/WebPlatformStrategies.h: Added, based on Mac and Win + versions. + +2010-09-18 Andreas Kling <andreas.kling@nokia.com> + + Reviewed by Antonio Gomes. + + [Qt] V8 port: Add FrameLoaderClientQt::allowScriptExtension() + https://bugs.webkit.org/show_bug.cgi?id=46034 + + r67749 added FrameLoaderClient::allowScriptExtension() (V8-specific) + Add a stub implementation that simply returns false for now. + + * WebCoreSupport/FrameLoaderClientQt.h: + (WebCore::FrameLoaderClientQt::allowScriptExtension): + +2010-09-17 Darin Adler <darin@apple.com> + + Reviewed by Sam Weinig. + + REGRESSION (r60104): Zoom level is unexpectedly reset on page reload + https://bugs.webkit.org/show_bug.cgi?id=42863 + + * Api/qwebframe.cpp: + (QWebFrame::setTextSizeMultiplier): + (QWebFrame::textSizeMultiplier): + (QWebFrame::setZoomFactor): + (QWebFrame::zoomFactor): + Call functions on Frame instead of FrameView. + +2010-09-16 Darin Adler <darin@apple.com> + + Fix build. + + * WebCoreSupport/EditorClientQt.cpp: + (WebCore::EditorClientQt::setInputMethodState): Updated for change + in name of isUrlField to isURLField. + +2010-09-16 Darin Adler <darin@apple.com> + + Reviewed by Andreas Kling. + + Reduce use of HTMLInputElement::inputType so we can remove it later + https://bugs.webkit.org/show_bug.cgi?id=45903 + + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId): + Use isPasswordField. + +2010-09-16 Robert Hogan <robert@webkit.org> + + Reviewed by Antonio Gomes. + + [Qt] Support globalhistory tests + https://bugs.webkit.org/show_bug.cgi?id=45774 + + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::populateVisitedLinks): + * WebCoreSupport/ChromeClientQt.h: + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (DumpRenderTreeSupportQt::dumpHistoryCallbacks): + (DumpRenderTreeSupportQt::dumpVisitedLinksCallbacks): + * WebCoreSupport/DumpRenderTreeSupportQt.h: + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::setTitle): + (WebCore::FrameLoaderClientQt::updateGlobalHistory): + (WebCore::FrameLoaderClientQt::updateGlobalHistoryRedirectLinks): + * WebCoreSupport/FrameLoaderClientQt.h: + +2010-09-16 Diego Gonzalez <diegohcg@webkit.org> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Remove FrameLoaderClientQt::webFrame() to use NetworkingContext to get the WebFrame to avoid layering violations + https://bugs.webkit.org/show_bug.cgi?id=42293 + + * Api/qwebframe.cpp: + (QWebFrame::childFrames): + (QWebFramePrivate::kit): + * Api/qwebpage.cpp: + (QWebPage::currentFrame): + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::runJavaScriptAlert): + (WebCore::ChromeClientQt::runJavaScriptConfirm): + (WebCore::ChromeClientQt::runJavaScriptPrompt): + (WebCore::ChromeClientQt::contentsSizeChanged): + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::chooseFile): + * WebCoreSupport/FrameLoaderClientQt.h: + +2010-09-15 Simon Hausmann <simon.hausmann@nokia.com> + + [Qt] Update the Symbian def files + + Re-freeze with the viewport meta tag updates. + + * symbian/eabi/QtWebKitu.def: + +2010-09-14 Andreas Kling <andreas.kling@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] V8 port: Get inspector up and running + https://bugs.webkit.org/show_bug.cgi?id=45771 + + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::ensureDebuggerScriptLoaded): Added, loads DebuggerScript.js into ScriptDebugServer. + (WebCore::InspectorClientQt::openInspectorFrontend): Ensure that DebuggerScript.js is loaded + before opening an inspector. + +2010-09-14 Enrico Ros <eros@codeaurora.org> + + Reviewed by Andreas Kling. + + [Qt] Respect title attribute on option elements + https://bugs.webkit.org/show_bug.cgi?id=45084 + + Set the tooltip in the combo box model, so it's reflected in the view. + + * WebCoreSupport/QtFallbackWebPopup.cpp: + (WebCore::QtFallbackWebPopup::populate): + +2010-09-13 Daniel Bates <dbates@rim.com> + + https://bugs.webkit.org/show_bug.cgi?id=45732 + + Fix the Qt build. I missed this when reviewing the patch + for Bug #45732. + + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (DumpRenderTreeSupportQt::suspendActiveDOMObjects): Change enum value ActiveDOMObject::JavaScriptPaused to + ActiveDOMObject::JavaScriptDebuggerPaused + +2010-09-13 Eric Carlson <eric.carlson@apple.com> + + Reviewed by Daniel Bates. + + [Qt] DumpRenderTreeSupportQt::suspendActiveDOMObjects needs a new parameter + https://bugs.webkit.org/show_bug.cgi?id=45732 + + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (DumpRenderTreeSupportQt::suspendActiveDOMObjects): Pass ActiveDOMObject::JavaScriptPaused + to suspendActiveDOMObjects. + +2010-09-13 Enrica Casucci <enrica@apple.com> + + Reviewed by Sam Weinig. + + Paste should be implemented in WebCore like Copy and Cut for Mac also. + https://bugs.webkit.org/show_bug.cgi?id=45494 + <rdar://problem/7660537> + + On the Mac platform, the implementation of the paste operation is all done + at the WebKit level. In order to support it on WebKit2 it is necessary to + refactor the code and move this functionality at the level of WebCore like + we already have on Windows. + The original code relies on some in AppKit functions that call back into + WebKit causing problems in WebKit2. All this functionality has been moved + at the level of the editor client where it can be dealt with appropriately. + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::canShowMIMETypeAsHTML): Added stub. + * WebCoreSupport/FrameLoaderClientQt.h: + +2010-08-27 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org> + + Reviewed by Antti Koivisto. + + Add a Qt API for the viewport meta tag support based on the + following draft spec: + + http://people.opera.com/rune/TR/ED-css-viewport-20100806/ + + Add common handling of viewport meta tag based on new Opera spec + https://bugs.webkit.org/show_bug.cgi?id=44201 + + * Api/qwebframe_p.h: + (QWebFramePrivate::QWebFramePrivate): + * Api/qwebpage.cpp: + (QWebPage::ViewportConfiguration::ViewportConfiguration): + (QWebPage::ViewportConfiguration::~ViewportConfiguration): + (QWebPage::ViewportConfiguration::operator=): + (QWebPage::viewportConfigurationForSize): + (QWebPage::setPreferredContentsSize): + * Api/qwebpage.h: + * Api/qwebpage_p.h: + (QtViewportConfigurationPrivate::QtViewportConfigurationPrivate): + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::didReceiveViewportArguments): + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (DumpRenderTreeSupportQt::viewportAsText): + * WebCoreSupport/DumpRenderTreeSupportQt.h: + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::dispatchDidCommitLoad): + (WebCore::FrameLoaderClientQt::dispatchDidFirstLayout): + +2010-09-12 Martin Smith <martin.smith@nokia.com> + + Reviewed by Simon Hausmann. + + doc: Changed the title so lists of contents sort better. + + * docs/qtwebkit.qdoc: + +2010-09-12 David Boddie <david.boddie@nokia.com> + + Reviewed by Simon Hausmann. + + Doc: More work on the QML documentation. + + * declarative/qdeclarativewebview.cpp: + +2010-09-12 Martin Jones <martin.jones@nokia.com> + + Reviewed by Simon Hausmann. + + [Qml] Ensure WebView gets focus when an editable node is clicked on. + + Task-number: QTBUG-13342 + + * declarative/qdeclarativewebview.cpp: + (GraphicsWebView::mousePressEvent): + +2010-09-12 David Boddie <david.boddie@nokia.com> + + Reviewed by Simon Hausmann. + + Doc: qdoc fixes. + + * declarative/qdeclarativewebview.cpp: + +2010-09-12 Oswald Buddenhagen <oswald.buddenhagen@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] let WebKit inject itself into the qt configuration + + Task-number: QTBUG-12379 + + * qt_webkit_version.pri: Use the faster + instead of * + operator to add webkit to the config. + +2010-09-12 Martin Smith <martin.smith@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Fix group of declarative web view in QML docs. + + * declarative/qdeclarativewebview.cpp: + +2010-09-12 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Andreas Kling. + + [Qt] Partial implementation of Qt bridge using V8 and QtScript. + + * Api/qwebelement.cpp: + (QWebElement::evaluateJavaScript): Stub it out for now, + to compile, until we have a conversion path between v8::Object + and QScriptValue. + * Api/qwebframe.cpp: + (QWebFrame::addToJavaScriptWindowObject): Implemented using + few lines of QtScript code. + (QWebFrame::evaluateJavaScript): Ditto. + +2010-09-12 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Andreas Kling. + + Fix the build with V8. + + This is a temporary kludge until the scriptworld stuff is properly + ported, as part of the upcoming DRT work. + + * Api/qwebscriptworld.cpp: + (QWebScriptWorld::QWebScriptWorld): + +2010-09-11 Andreas Kling <andreas.kling@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] V8 port for Qt platform: Qt WebCoreSupport changes + https://bugs.webkit.org/show_bug.cgi?id=45149 + + Original patch by Vlad Burlik <volodimir.burlik@nokia.com> + + Implemented the V8 specifics needed in DumpRenderTreeSupportQt and + FrameLoaderClientQt. + + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (DumpRenderTreeSupportQt::javaScriptObjectsCount): + (DumpRenderTreeSupportQt::garbageCollectorCollect): + (DumpRenderTreeSupportQt::garbageCollectorCollectOnAlternateThread): + (DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld): + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::didCreateScriptContextForFrame): + (WebCore::FrameLoaderClientQt::didDestroyScriptContextForFrame): + (WebCore::FrameLoaderClientQt::didCreateIsolatedScriptContext): + (WebCore::FrameLoaderClientQt::createDocumentLoader): + * WebCoreSupport/FrameLoaderClientQt.h: + +2010-09-11 Vlad Burlik <volodimir.burlik@nokia.com> + + Reviewed by Andreas Kling. + + [Qt] V8 port for QT platform: QT API implementation changes + https://bugs.webkit.org/show_bug.cgi?id=45148 + + V8 Implementation of QWebFrame::addToJavaScriptWindowObject() + and QWebFrame::evaluateJavaScript() + + * Api/qwebelement.cpp: + (setupScriptContext): JSC and V8 variations + (QWebElement::evaluateJavaScript): + * Api/qwebelement.h: + * Api/qwebframe.cpp: QObject injection to V8 world + (QWebFrame::addToJavaScriptWindowObject): + (QWebFrame::evaluateJavaScript): + * Api/qwebpage.cpp: Use ScriptController type definitions instead of direct references to JSC or V8 + (QWebPagePrivate::QWebPagePrivate): + +2010-09-10 yi shen <yi.4.shen@nokia.com> + + Reviewed by Antonio Gomes. + + [Qt] selected text gets deleted when qgraphicswebview losts focus + https://bugs.webkit.org/show_bug.cgi?id=45539 + + * Api/qwebpage.cpp: + (QWebPagePrivate::inputMethodEvent): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::inputMethods): + +2010-09-10 Sam Weinig <sam@webkit.org> + + Fix Qt build. + + * Api/qwebsettings.cpp: + (QWebSettingsPrivate::apply): + +2010-09-10 Sam Weinig <sam@webkit.org> + + Reviewed by Darin Adler. + + Remove unnecessary constraint in WebCore of choosing either text zoom or full page zoom. + Precursor to <rdar://problem/7660657> + https://bugs.webkit.org/show_bug.cgi?id=45522 + + * Api/qwebframe.cpp: + (QWebFrame::setTextSizeMultiplier): + (QWebFrame::textSizeMultiplier): + (QWebFrame::setZoomFactor): + (QWebFrame::zoomFactor): + * Api/qwebframe_p.h: + (QWebFramePrivate::QWebFramePrivate): + Move tracking of text only zoom here from WebCore. + +2010-09-10 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Andreas Kling. + + [Qt] Support click event for notifications + https://bugs.webkit.org/show_bug.cgi?id=44836 + + Propagate click events to JavaScript from either the + platform plugn or from QSystemTrayIcon. + Also added the method NotificationWrapper::openerPageUrl so that + if the platform plugin can reopen the page that created the + notification directly, when the user clicks the notification. + + Added DumpRenderTreeSupportQt::simulateDesktopNotificationClick + for testing purpose. + + * Api/qwebkitplatformplugin.h: + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (DumpRenderTreeSupportQt::simulateDesktopNotificationClick): + * WebCoreSupport/DumpRenderTreeSupportQt.h: + * WebCoreSupport/NotificationPresenterClientQt.cpp: + (WebCore::NotificationWrapper::openerPageUrl): + (WebCore::NotificationWrapper::notificationClicked): + (WebCore::NotificationPresenterClientQt::displayNotification): + (WebCore::NotificationPresenterClientQt::notificationClicked): + * WebCoreSupport/NotificationPresenterClientQt.h: + * examples/platformplugin/WebNotificationPresenter.cpp: + (WebNotificationWidget::event): + * examples/platformplugin/WebNotificationPresenter.h: + (WebNotificationPresenter::WebNotificationPresenter): + * examples/platformplugin/qwebkitplatformplugin.h: + +2010-09-10 Adam Barth <abarth@webkit.org> + + Attempt to fix the failign Qt tests. This patch adapts code from + Chromium. The long-term fix is to remove the need for this code, but + that's a bit too complicated for a buildfix patch. + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::FrameLoaderClientQt): + (WebCore::FrameLoaderClientQt::makeRepresentation): + (WebCore::FrameLoaderClientQt::revertToProvisionalState): + (WebCore::FrameLoaderClientQt::finishedLoading): + * WebCoreSupport/FrameLoaderClientQt.h: + +2010-09-10 Adam Barth <abarth@webkit.org> + + Reviewed by Darin Fisher. + + Move code from WebKit-layer to DocumentLoader + https://bugs.webkit.org/show_bug.cgi?id=45569 + + This code didn't know that setEncoding can be called multiple times. + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::FrameLoaderClientQt): + (WebCore::FrameLoaderClientQt::finishedLoading): + (WebCore::FrameLoaderClientQt::setMainDocumentError): + (WebCore::FrameLoaderClientQt::committedLoad): + (WebCore::FrameLoaderClientQt::dispatchDidReceiveResponse): + (WebCore::FrameLoaderClientQt::dispatchDidFailLoading): + * WebCoreSupport/FrameLoaderClientQt.h: + +2010-09-10 Adam Barth <abarth@webkit.org> + + Reviewed by Eric Seidel. + + Main resource bytes shouldn't bounce through FrameLoader + https://bugs.webkit.org/show_bug.cgi?id=45496 + + Now return the bytes to the DocumentLoader. + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::committedLoad): + 2010-09-08 Darin Adler <darin@apple.com> Reviewed by Adam Barth. diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp index 8b01d4d..a5dfdc7 100644 --- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp @@ -44,6 +44,7 @@ #include "GeolocationPermissionClientQt.h" #include "HitTestResult.h" #include "Icon.h" +#include "NetworkingContext.h" #include "NotImplemented.h" #include "NotificationPresenterClientQt.h" #include "PageClientQt.h" @@ -74,6 +75,8 @@ namespace WebCore { +bool ChromeClientQt::dumpVisitedLinksCallbacks = false; + ChromeClientQt::ChromeClientQt(QWebPage* webPage) : m_webPage(webPage) , m_eventLoop(0) @@ -294,22 +297,22 @@ void ChromeClientQt::closeWindowSoon() void ChromeClientQt::runJavaScriptAlert(Frame* f, const String& msg) { QString x = msg; - FrameLoaderClientQt* fl = static_cast<FrameLoaderClientQt*>(f->loader()->client()); - m_webPage->javaScriptAlert(fl->webFrame(), x); + QWebFrame* webFrame = qobject_cast<QWebFrame*>(f->loader()->networkingContext()->originatingObject()); + m_webPage->javaScriptAlert(webFrame, x); } bool ChromeClientQt::runJavaScriptConfirm(Frame* f, const String& msg) { QString x = msg; - FrameLoaderClientQt* fl = static_cast<FrameLoaderClientQt*>(f->loader()->client()); - return m_webPage->javaScriptConfirm(fl->webFrame(), x); + QWebFrame* webFrame = qobject_cast<QWebFrame*>(f->loader()->networkingContext()->originatingObject()); + return m_webPage->javaScriptConfirm(webFrame, x); } bool ChromeClientQt::runJavaScriptPrompt(Frame* f, const String& message, const String& defaultValue, String& result) { QString x = result; - FrameLoaderClientQt* fl = static_cast<FrameLoaderClientQt*>(f->loader()->client()); - bool rc = m_webPage->javaScriptPrompt(fl->webFrame(), (QString)message, (QString)defaultValue, &x); + QWebFrame* webFrame = qobject_cast<QWebFrame*>(f->loader()->networkingContext()->originatingObject()); + bool rc = m_webPage->javaScriptPrompt(webFrame, (QString)message, (QString)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. @@ -444,7 +447,8 @@ PlatformPageClient ChromeClientQt::platformPageClient() const void ChromeClientQt::contentsSizeChanged(Frame* frame, const IntSize& size) const { - emit QWebFramePrivate::kit(frame)->contentsSizeChanged(size); + if (frame->loader()->networkingContext()) + QWebFramePrivate::kit(frame)->contentsSizeChanged(size); } void ChromeClientQt::mouseDidMoveOverElement(const HitTestResult& result, unsigned) @@ -640,22 +644,9 @@ QWebSelectMethod* ChromeClientQt::createSelectPopup() const void ChromeClientQt::didReceiveViewportArguments(Frame* frame, const ViewportArguments& arguments) const { - if (m_webPage->mainFrame()->d->initialLayoutComplete) - return; - - QSize viewportSize(arguments.width, arguments.height); - bool isUserScalable = arguments.userScalable == 1; - - QWebPage::ViewportHints hints; - hints.m_isValid = true; - hints.m_size = viewportSize; - hints.m_initialScaleFactor = arguments.initialScale; - hints.m_minimumScaleFactor = arguments.minimumScale; - hints.m_maximumScaleFactor = arguments.maximumScale; - hints.m_targetDensityDpi = arguments.targetDensityDpi; - hints.m_isUserScalable = isUserScalable; + m_webPage->mainFrame()->d->viewportArguments = arguments; - emit m_webPage->viewportChangeRequested(hints); + emit m_webPage->viewportChangeRequested(); } bool ChromeClientQt::selectItemWritingDirectionIsNatural() @@ -673,4 +664,14 @@ PassRefPtr<SearchPopupMenu> ChromeClientQt::createSearchPopupMenu(PopupMenuClien return adoptRef(new SearchPopupMenuQt(createPopupMenu(client))); } +void ChromeClientQt::populateVisitedLinks() +{ + // We don't need to do anything here because history is tied to QWebPage rather than stored + // in a separate database + if (dumpVisitedLinksCallbacks) { + printf("Asked to populate visited links for WebView \"%s\"\n", + qPrintable(m_webPage->mainFrame()->url().toString())); + } +} + } // namespace WebCore diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/WebKit/qt/WebCoreSupport/ChromeClientQt.h index d18f993..56801aa 100644 --- a/WebKit/qt/WebCoreSupport/ChromeClientQt.h +++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.h @@ -173,6 +173,7 @@ namespace WebCore { virtual bool selectItemWritingDirectionIsNatural(); virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const; virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const; + virtual void populateVisitedLinks(); QWebSelectMethod* createSelectPopup() const; @@ -188,6 +189,8 @@ namespace WebCore { bool menuBarVisible; QEventLoop* m_eventLoop; + static bool dumpVisitedLinksCallbacks; + mutable QtPlatformPlugin m_platformPlugin; }; } diff --git a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index c1be131..ed7ac32 100644 --- a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -24,6 +24,7 @@ #include "DumpRenderTreeSupportQt.h" #include "CSSComputedStyleDeclaration.h" +#include "ChromeClientQt.h" #include "ContextMenu.h" #include "ContextMenuClientQt.h" #include "ContextMenuController.h" @@ -34,7 +35,12 @@ #include "Frame.h" #include "FrameLoaderClientQt.h" #include "FrameView.h" +#if USE(JSC) #include "GCController.h" +#elif USE(V8) +#include "V8GCController.h" +#include "V8Proxy.h" +#endif #include "Geolocation.h" #include "GeolocationServiceMock.h" #include "Geoposition.h" @@ -296,17 +302,31 @@ void DumpRenderTreeSupportQt::clearFrameName(QWebFrame* frame) int DumpRenderTreeSupportQt::javaScriptObjectsCount() { +#if USE(JSC) return JSDOMWindowBase::commonJSGlobalData()->heap.globalObjectCount(); +#elif USE(V8) + // FIXME: Find a way to do this using V8. + return 1; +#endif } void DumpRenderTreeSupportQt::garbageCollectorCollect() { +#if USE(JSC) gcController().garbageCollectNow(); +#elif USE(V8) + v8::V8::LowMemoryNotification(); +#endif } void DumpRenderTreeSupportQt::garbageCollectorCollectOnAlternateThread(bool waitUntilDone) { +#if USE(JSC) gcController().garbageCollectOnAlternateThreadForDebugging(waitUntilDone); +#elif USE(V8) + // FIXME: Find a way to do this using V8. + garbageCollectorCollect(); +#endif } // Returns the value of counter in the element specified by \a id. @@ -347,7 +367,9 @@ void DumpRenderTreeSupportQt::suspendActiveDOMObjects(QWebFrame* frame) { Frame* coreFrame = QWebFramePrivate::core(frame); if (coreFrame->document()) - coreFrame->document()->suspendActiveDOMObjects(); + // 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. @@ -511,9 +533,7 @@ bool DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId(QWebFrame* if (!inputElement) return false; - return (inputElement->isTextField() - && inputElement->inputType() != HTMLInputElement::PASSWORD - && inputElement->autoComplete()); + return inputElement->isTextField() && !inputElement->isPasswordField() && inputElement->autoComplete(); } void DumpRenderTreeSupportQt::setEditingBehavior(QWebPage* page, const QString& editingBehavior) @@ -582,6 +602,16 @@ void DumpRenderTreeSupportQt::setCustomPolicyDelegate(bool enabled, bool permiss FrameLoaderClientQt::policyDelegatePermissive = permissive; } +void DumpRenderTreeSupportQt::dumpHistoryCallbacks(bool b) +{ + FrameLoaderClientQt::dumpHistoryCallbacks = b; +} + +void DumpRenderTreeSupportQt::dumpVisitedLinksCallbacks(bool b) +{ + ChromeClientQt::dumpVisitedLinksCallbacks = b; +} + void DumpRenderTreeSupportQt::dumpEditingCallbacks(bool b) { EditorClientQt::dumpEditingCallbacks = b; @@ -599,6 +629,27 @@ void DumpRenderTreeSupportQt::dumpNotification(bool b) #endif } +QString DumpRenderTreeSupportQt::viewportAsText(QWebPage* page, const QSize& availableSize) +{ + WebCore::ViewportArguments args = page->mainFrame()->d->viewportArguments; + WebCore::ViewportConfiguration conf = WebCore::findConfigurationForViewportData(args, + /* desktop-width */ 980, + /* device-width */ 320, + /* device-height */ 480, + /* device-dpi */ 160, + availableSize); + + QString res; + res = res.sprintf("viewport size %dx%d scale %f with limits [%f, %f]\n", + conf.layoutViewport.width(), + conf.layoutViewport.height(), + conf.initialScale, + conf.minimumScale, + conf.maximumScale); + + return res; +} + void DumpRenderTreeSupportQt::setMockGeolocationPosition(double latitude, double longitude, double accuracy) { #if ENABLE(GEOLOCATION) @@ -670,8 +721,16 @@ void DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(QWebFrame* frame, in ScriptController* proxy = coreFrame->script(); - if (proxy) - proxy->executeScriptInWorld(scriptWorld->world(), script, true); + if (!proxy) + return; +#if USE(JSC) + proxy->executeScriptInWorld(scriptWorld->world(), script, true); +#elif USE(V8) + ScriptSourceCode source(script); + Vector<ScriptSourceCode> sources; + sources.append(source); + proxy->evaluateInIsolatedWorld(0, sources, true); +#endif } bool DumpRenderTreeSupportQt::isPageBoxVisible(QWebFrame* frame, int pageIndex) @@ -698,6 +757,13 @@ void DumpRenderTreeSupportQt::addUserStyleSheet(QWebPage* page, const QString& s page->handle()->page->group().addUserStyleSheetToWorld(mainThreadNormalWorld(), sourceCode, QUrl(), 0, 0, WebCore::InjectInAllFrames); } +void DumpRenderTreeSupportQt::simulateDesktopNotificationClick(const QString& title) +{ +#if ENABLE(NOTIFICATIONS) + NotificationPresenterClientQt::notificationPresenter()->notificationClicked(title); +#endif +} + // 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/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h index 2069114..5a59475 100644 --- a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h +++ b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h @@ -106,6 +106,8 @@ public: 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 setDeferMainResourceDataLoad(bool b); @@ -127,7 +129,8 @@ public: static QString pageSizeAndMarginsInPixels(QWebFrame* frame, int pageIndex, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft); static QString pageProperty(QWebFrame* frame, const QString& propertyName, int pageNumber); static void addUserStyleSheet(QWebPage* page, const QString& sourceCode); - + static void simulateDesktopNotificationClick(const QString& title); + static QString viewportAsText(QWebPage*, const QSize&); }; #endif diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp index 0a9a0ea..080c459 100644 --- a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp @@ -612,7 +612,7 @@ void EditorClientQt::setInputMethodState(bool active) hints |= Qt::ImhDigitsOnly; if (inputElement->isEmailField()) hints |= Qt::ImhEmailCharactersOnly; - if (inputElement->isUrlField()) + if (inputElement->isURLField()) hints |= Qt::ImhUrlCharactersOnly; // Setting the Qt::WA_InputMethodEnabled attribute true and Qt::ImhHiddenText flag // for password fields. The Qt platform is responsible for determining which widget diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index 2d73f7f..4aadeb0 100644 --- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -40,7 +40,11 @@ #include "FrameView.h" #include "DocumentLoader.h" #include "HitTestResult.h" +#if USE(JSC) #include "JSDOMWindowBase.h" +#elif USE(V8) +#include "V8DOMWindow.h" +#endif #include "MIMETypeRegistry.h" #include "MouseEvent.h" #include "ResourceResponse.h" @@ -63,6 +67,7 @@ #include "ScriptString.h" #include "Settings.h" #include "QWebPageClient.h" +#include "ViewportArguments.h" #include "qwebpage.h" #include "qwebpage_p.h" @@ -160,6 +165,7 @@ bool FrameLoaderClientQt::sendRequestReturnsNullOnRedirect = false; bool FrameLoaderClientQt::sendRequestReturnsNull = false; bool FrameLoaderClientQt::dumpResourceResponseMIMETypes = false; bool FrameLoaderClientQt::deferMainResourceDataLoad = true; +bool FrameLoaderClientQt::dumpHistoryCallbacks = false; QStringList FrameLoaderClientQt::sendRequestClearHeaders; QString FrameLoaderClientQt::dumpResourceLoadCallbacksPath; @@ -189,10 +195,10 @@ static const char* navigationTypeToString(NavigationType type) FrameLoaderClientQt::FrameLoaderClientQt() : m_frame(0) , m_webFrame(0) - , m_firstData(false) , m_pluginView(0) , m_hasSentResponseToPlugin(false) - , m_loadError (ResourceError()) + , m_hasRepresentation(false) + , m_loadError(ResourceError()) { } @@ -225,11 +231,6 @@ void FrameLoaderClientQt::setFrame(QWebFrame* webFrame, Frame* frame) m_webFrame, SIGNAL(titleChanged(QString))); } -QWebFrame* FrameLoaderClientQt::webFrame() const -{ - return m_webFrame; -} - void FrameLoaderClientQt::callPolicyFunction(FramePolicyFunction function, PolicyAction action) { (m_frame->loader()->policyChecker()->*function)(action); @@ -277,7 +278,7 @@ void FrameLoaderClientQt::transitionToCommittedForNewPage() void FrameLoaderClientQt::makeRepresentation(DocumentLoader*) { - // don't need this for now I think. + m_hasRepresentation = true; } @@ -357,6 +358,18 @@ void FrameLoaderClientQt::dispatchDidChangeLocationWithinPage() m_webFrame->page()->d->updateNavigationActions(); } +#if USE(V8) +void FrameLoaderClientQt::didCreateScriptContextForFrame() +{ +} +void FrameLoaderClientQt::didDestroyScriptContextForFrame() +{ +} +void FrameLoaderClientQt::didCreateIsolatedScriptContext() +{ +} +#endif + void FrameLoaderClientQt::dispatchDidPushStateWithinPage() { if (dumpFrameLoaderCallbacks) @@ -429,7 +442,8 @@ void FrameLoaderClientQt::dispatchDidCommitLoad() if (m_frame->tree()->parent() || !m_webFrame) return; - m_webFrame->d->initialLayoutComplete = false; + // Clear the viewport arguments. + m_webFrame->d->viewportArguments = WebCore::ViewportArguments(); emit m_webFrame->urlChanged(m_webFrame->url()); m_webFrame->page()->d->updateNavigationActions(); @@ -443,7 +457,7 @@ void FrameLoaderClientQt::dispatchDidCommitLoad() if (!isMainFrame) return; - emit m_webFrame->page()->viewportChangeRequested(QWebPage::ViewportHints()); + emit m_webFrame->page()->viewportChangeRequested(); } @@ -481,7 +495,6 @@ void FrameLoaderClientQt::dispatchDidFinishLoad() void FrameLoaderClientQt::dispatchDidFirstLayout() { - m_webFrame->d->initialLayoutComplete = true; } void FrameLoaderClientQt::dispatchDidFirstVisuallyNonEmptyLayout() @@ -518,7 +531,7 @@ void FrameLoaderClientQt::dispatchDidLoadMainResource(DocumentLoader*) void FrameLoaderClientQt::revertToProvisionalState(DocumentLoader*) { - notImplemented(); + m_hasRepresentation = true; } @@ -582,21 +595,25 @@ void FrameLoaderClientQt::didChangeTitle(DocumentLoader*) void FrameLoaderClientQt::finishedLoading(DocumentLoader* loader) { if (!m_pluginView) { - if(m_firstData) { - FrameLoader *fl = loader->frameLoader(); - fl->writer()->setEncoding(m_response.textEncodingName(), false); - m_firstData = false; - } - } - else { - if (m_pluginView->isPluginView()) - m_pluginView->didFinishLoading(); - m_pluginView = 0; - m_hasSentResponseToPlugin = false; + // 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. + if (m_hasRepresentation) + loader->frameLoader()->writer()->setEncoding("", false); + return; } + if (m_pluginView->isPluginView()) + m_pluginView->didFinishLoading(); + m_pluginView = 0; + m_hasSentResponseToPlugin = false; } - +bool FrameLoaderClientQt::canShowMIMETypeAsHTML(const String& MIMEType) const +{ + notImplemented(); + return false; +} + bool FrameLoaderClientQt::canShowMIMEType(const String& MIMEType) const { String type = MIMEType; @@ -657,9 +674,17 @@ void FrameLoaderClientQt::prepareForDataSourceReplacement() { } -void FrameLoaderClientQt::setTitle(const String&, const KURL&) +void FrameLoaderClientQt::setTitle(const String& title, const KURL& url) { - // no need for, dispatchDidReceiveTitle is the right callback + // 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 + // globalhistory layout tests. + if (dumpHistoryCallbacks) { + printf("WebView updated the title for history URL \"%s\" to \"%s\".\n", + qPrintable(drtDescriptionSuitableForTestResult(url)), + qPrintable(QString(title))); + } } @@ -722,12 +747,48 @@ void FrameLoaderClientQt::registerForIconNotification(bool) void FrameLoaderClientQt::updateGlobalHistory() { QWebHistoryInterface *history = QWebHistoryInterface::defaultInterface(); + WebCore::DocumentLoader* loader = m_frame->loader()->documentLoader(); if (history) - history->addHistoryEntry(m_frame->loader()->documentLoader()->urlForHistory().prettyURL()); + history->addHistoryEntry(loader->urlForHistory().prettyURL()); + + 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->request().httpMethod())), + ((loader->substituteData().isValid() || (loader->response().httpStatusCode() >= 400)) ? "a failure" : "successful"), + ((!loader->clientRedirectSourceForHistory().isEmpty()) ? "a client redirect from " : "not a client redirect"), + (!loader->clientRedirectSourceForHistory().isEmpty()) ? qPrintable(drtDescriptionSuitableForTestResult(loader->clientRedirectSourceForHistory())) : ""); + } } void FrameLoaderClientQt::updateGlobalHistoryRedirectLinks() { + // Apple WebKit is the only port that makes use of this callback. It calls + // WebCore::HistoryItem::addRedirectURL() with the contents of + // loader->[server|client]RedirectDestinationForHistory(). + // WebCore can associate a bunch of redirect URLs with a particular + // item in the history, presumably this allows Safari to skip the redirections + // when navigating to that history item. That might be a feature Qt wants to + // offer through QWebHistoryInterface in the future. For now, we're just + // passing tests in LayoutTests/http/tests/globalhistory. + WebCore::DocumentLoader* loader = m_frame->loader()->documentLoader(); + + 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()))); + } + } + + 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()))); + } + } } bool FrameLoaderClientQt::shouldGoToHistoryItem(WebCore::HistoryItem *) const @@ -776,31 +837,19 @@ bool FrameLoaderClientQt::canCachePage() const void FrameLoaderClientQt::setMainDocumentError(WebCore::DocumentLoader* loader, const WebCore::ResourceError& error) { - if (!m_pluginView) { - if (m_firstData) { - loader->frameLoader()->writer()->setEncoding(m_response.textEncodingName(), false); - m_firstData = false; - } - } else { - if (m_pluginView->isPluginView()) - m_pluginView->didFail(error); - m_pluginView = 0; - m_hasSentResponseToPlugin = false; - } + if (!m_pluginView) + return; + if (m_pluginView->isPluginView()) + m_pluginView->didFail(error); + m_pluginView = 0; + m_hasSentResponseToPlugin = false; } +// FIXME: This function should be moved into WebCore. void FrameLoaderClientQt::committedLoad(WebCore::DocumentLoader* loader, const char* data, int length) { - if (!m_pluginView) { - if (!m_frame) - return; - FrameLoader *fl = loader->frameLoader(); - if (m_firstData) { - fl->writer()->setEncoding(m_response.textEncodingName(), false); - m_firstData = false; - } - fl->addData(data, length); - } + if (!m_pluginView) + loader->commitData(data, length); // We re-check here as the plugin can have been created if (m_pluginView && m_pluginView->isPluginView()) { @@ -887,7 +936,12 @@ WTF::PassRefPtr<WebCore::DocumentLoader> FrameLoaderClientQt::createDocumentLoad // Use the default timeout interval for JS as the HTML tokenizer delay. This ensures // that long-running JavaScript will still allow setHtml() to be synchronous, while // still giving a reasonable timeout to prevent deadlock. +#if USE(JSC) double delay = JSDOMWindowBase::commonJSGlobalData()->timeoutChecker.timeoutInterval() / 1000.0f; +#elif USE(V8) + // FIXME: Hard coded for now. + double delay = 10000 / 1000.0f; +#endif m_frame->page()->setCustomHTMLTokenizerTimeDelay(delay); } else m_frame->page()->setCustomHTMLTokenizerTimeDelay(-1); @@ -961,7 +1015,6 @@ void FrameLoaderClientQt::dispatchDidReceiveResponse(WebCore::DocumentLoader*, u { m_response = response; - m_firstData = true; if (dumpResourceLoadCallbacks) printf("%s - didReceiveResponse %s\n", qPrintable(dumpAssignedUrls[identifier]), @@ -991,12 +1044,6 @@ void FrameLoaderClientQt::dispatchDidFailLoading(WebCore::DocumentLoader* loader printf("%s - didFailLoadingWithError: %s\n", (dumpAssignedUrls.contains(identifier) ? qPrintable(dumpAssignedUrls[identifier]) : "<unknown>"), qPrintable(drtDescriptionSuitableForTestResult(error))); - - if (m_firstData) { - FrameLoader *fl = loader->frameLoader(); - fl->writer()->setEncoding(m_response.textEncodingName(), false); - m_firstData = false; - } } bool FrameLoaderClientQt::dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int) @@ -1518,7 +1565,7 @@ String FrameLoaderClientQt::overrideMediaType() const QString FrameLoaderClientQt::chooseFile(const QString& oldFile) { - return webFrame()->page()->chooseFile(webFrame(), oldFile); + return m_webFrame->page()->chooseFile(m_webFrame, oldFile); } PassRefPtr<FrameNetworkingContext> FrameLoaderClientQt::createNetworkingContext() diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h index e506900..fffda58 100644 --- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h +++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h @@ -75,7 +75,6 @@ public: virtual void frameLoaderDestroyed(); void setFrame(QWebFrame* webFrame, Frame* frame); - QWebFrame* webFrame() const; virtual bool hasWebView() const; // mainly for assertions @@ -174,6 +173,7 @@ public: virtual bool canHandleRequest(const WebCore::ResourceRequest&) const; virtual bool canShowMIMEType(const String& MIMEType) const; + virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const; virtual bool representationExistsForURLScheme(const String& URLScheme) const; virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const; @@ -211,6 +211,21 @@ public: virtual void documentElementAvailable(); virtual void didPerformFirstNavigation() const; +#if USE(V8) + // A frame's V8 context was created or destroyed. + virtual void didCreateScriptContextForFrame(); + virtual void didDestroyScriptContextForFrame(); + + // A context untied to a frame was created (through evaluateInIsolatedWorld). + // This context is not tied to the lifetime of its frame, and is destroyed + // in garbage collection. + virtual void didCreateIsolatedScriptContext(); + + // Returns true if we should allow the given V8 extension to be added to + // the script context at the currently loading page and given extension group. + virtual bool allowScriptExtension(const String& extensionName, int extensionGroup) { return false; } +#endif + virtual void registerForIconNotification(bool); QString chooseFile(const QString& oldFile); @@ -227,17 +242,22 @@ public: static bool policyDelegateEnabled; static bool policyDelegatePermissive; static bool deferMainResourceDataLoad; + static bool dumpHistoryCallbacks; private: Frame *m_frame; QWebFrame *m_webFrame; ResourceResponse m_response; - bool m_firstData; // Plugin view to redirect data to WebCore::PluginView* m_pluginView; bool m_hasSentResponseToPlugin; + // True if makeRepresentation was called. We don't actually have a concept + // of a "representation", but we need to know when we're expected to have one. + // See finishedLoading(). + bool m_hasRepresentation; + ResourceError m_loadError; }; diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp index 55aca7f..e6e6fde 100644 --- a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp @@ -37,12 +37,14 @@ #include "Page.h" #include "PlatformString.h" #include "ScriptController.h" +#include "ScriptDebugServer.h" #include "qwebinspector.h" #include "qwebinspector_p.h" #include "qwebpage.h" #include "qwebpage_p.h" #include "qwebview.h" #include <QtCore/QCoreApplication> +#include <QtCore/QFile> #include <QtCore/QSettings> #include <QtCore/QVariant> @@ -93,6 +95,22 @@ public slots: } }; +#if USE(V8) +static void ensureDebuggerScriptLoaded() +{ + static bool scriptLoaded = false; + if (scriptLoaded) + return; + + QFile debuggerScriptFile(":/webkit/inspector/DebuggerScript.js"); + if (debuggerScriptFile.open(QIODevice::ReadOnly)) { + QByteArray ba = debuggerScriptFile.readAll(); + ScriptDebugServer::shared().setDebuggerScriptSource(String(ba.constData(), ba.length())); + scriptLoaded = true; + } +} +#endif + InspectorClientQt::InspectorClientQt(QWebPage* page) : m_inspectedWebPage(page) , m_frontendWebPage(0) @@ -109,6 +127,10 @@ void InspectorClientQt::inspectorDestroyed() void InspectorClientQt::openInspectorFrontend(WebCore::InspectorController*) { +#if USE(V8) + ensureDebuggerScriptLoaded(); +#endif + QWebView* inspectorView = new QWebView; InspectorClientWebPage* inspectorPage = new InspectorClientWebPage(inspectorView); inspectorView->setPage(inspectorPage); diff --git a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp index c24c4d5..7b33d9e 100644 --- a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp @@ -118,6 +118,26 @@ const QByteArray NotificationWrapper::iconData() const return iconData; } +const QUrl NotificationWrapper::openerPageUrl() const +{ + QUrl url; +#if ENABLE(NOTIFICATIONS) + Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this); + if (notification) { + if (notification->scriptExecutionContext()) + url = static_cast<Document*>(notification->scriptExecutionContext())->page()->mainFrame()->document()->url(); + } +#endif + return url; +} + +void NotificationWrapper::notificationClicked() +{ +#if ENABLE(NOTIFICATIONS) + NotificationPresenterClientQt::notificationPresenter()->notificationClicked(this); +#endif +} + void NotificationWrapper::notificationClosed() { #if ENABLE(NOTIFICATIONS) @@ -204,11 +224,13 @@ void NotificationPresenterClientQt::displayNotification(Notification* notificati if (wrapper->m_presenter) { wrapper->connect(wrapper->m_presenter.get(), SIGNAL(notificationClosed()), wrapper, SLOT(notificationClosed()), Qt::QueuedConnection); + wrapper->connect(wrapper->m_presenter.get(), SIGNAL(notificationClicked()), wrapper, SLOT(notificationClicked())); wrapper->m_presenter->showNotification(wrapper); return; } #ifndef QT_NO_SYSTEMTRAYICON + wrapper->connect(wrapper->m_notificationIcon.get(), SIGNAL(messageClicked()), wrapper, SLOT(notificationClicked())); wrapper->m_notificationIcon->show(); wrapper->m_notificationIcon->showMessage(notification->contents().title(), notification->contents().body()); #endif @@ -237,6 +259,35 @@ void NotificationPresenterClientQt::cancel(NotificationWrapper* wrapper) cancel(notification); } +void NotificationPresenterClientQt::notificationClicked(NotificationWrapper* wrapper) +{ + Notification* notification = notificationForWrapper(wrapper); + if (notification) + sendEvent(notification, eventNames().clickEvent); +} + +void NotificationPresenterClientQt::notificationClicked(const QString& title) +{ + if (!dumpNotification) + return; + NotificationsQueue::ConstIterator end = m_notifications.end(); + NotificationsQueue::ConstIterator iter = m_notifications.begin(); + Notification* notification = 0; + while (iter != end) { + notification = iter.key(); + QString notificationTitle; + if (notification->isHTML()) + notificationTitle = notification->url().string(); + else + notificationTitle = notification->contents().title(); + if (notificationTitle == title) + break; + iter++; + } + if (notification) + sendEvent(notification, eventNames().clickEvent); +} + Notification* NotificationPresenterClientQt::notificationForWrapper(const NotificationWrapper* wrapper) const { NotificationsQueue::ConstIterator end = m_notifications.end(); diff --git a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h index e8481d4..2520f6c 100644 --- a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h +++ b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h @@ -61,9 +61,11 @@ public: const QString title() const; const QString message() const; const QByteArray iconData() const; + const QUrl openerPageUrl() const; public Q_SLOTS: void notificationClosed(); + void notificationClicked(); public: #ifndef QT_NO_SYSTEMTRAYICON @@ -102,6 +104,8 @@ public: static NotificationPresenterClientQt* notificationPresenter(); Notification* notificationForWrapper(const NotificationWrapper*) const; + void notificationClicked(NotificationWrapper*); + void notificationClicked(const QString& title); private: void sendEvent(Notification*, const AtomicString& eventName); diff --git a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp index 3b53476..3f69a47 100644 --- a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp +++ b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp @@ -232,6 +232,7 @@ void QtFallbackWebPopup::populate(const QWebSelectData& data) case QWebSelectData::Option: m_combo->insertItem(i, data.itemText(i)); model->item(i)->setEnabled(data.itemIsEnabled(i)); + model->item(i)->setToolTip(data.itemToolTip(i)); if (data.itemIsSelected(i)) currentIndex = i; break; diff --git a/WebKit/qt/WebCoreSupport/WebPlatformStrategies.cpp b/WebKit/qt/WebCoreSupport/WebPlatformStrategies.cpp new file mode 100644 index 0000000..948e0cd --- /dev/null +++ b/WebKit/qt/WebCoreSupport/WebPlatformStrategies.cpp @@ -0,0 +1,675 @@ +/* + * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net> + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 2008 Collabora Ltd. All rights reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 INdT - Instituto Nokia de Tecnologia + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "WebPlatformStrategies.h" + +#include "NotImplemented.h" +#include <IntSize.h> +#include <Page.h> +#include <PageGroup.h> +#include <PluginDatabase.h> +#include <QCoreApplication> +#include <QLocale> +#include <qwebpage.h> +#include <qwebpluginfactory.h> +#include <wtf/MathExtras.h> + +using namespace WebCore; + +void WebPlatformStrategies::initialize(QWebPage* webPage) +{ + DEFINE_STATIC_LOCAL(WebPlatformStrategies, platformStrategies, (webPage)); + Q_UNUSED(platformStrategies); +} + +WebPlatformStrategies::WebPlatformStrategies(QWebPage* webPage) + : m_page(webPage) +{ + setPlatformStrategies(this); +} + + +// PluginStrategy + +PluginStrategy* WebPlatformStrategies::createPluginStrategy() +{ + return this; +} + +LocalizationStrategy* WebPlatformStrategies::createLocalizationStrategy() +{ + return this; +} + +VisitedLinkStrategy* WebPlatformStrategies::createVisitedLinkStrategy() +{ + return this; +} + +void WebPlatformStrategies::refreshPlugins() +{ + PluginDatabase::installedPlugins()->refresh(); +} + +void WebPlatformStrategies::getPluginInfo(Vector<WebCore::PluginInfo>& outPlugins) +{ + QWebPluginFactory* factory = m_page->pluginFactory(); + if (factory) { + + QList<QWebPluginFactory::Plugin> qplugins = factory->plugins(); + for (int i = 0; i < qplugins.count(); ++i) { + const QWebPluginFactory::Plugin& qplugin = qplugins.at(i); + PluginInfo info; + info.name = qplugin.name; + info.desc = qplugin.description; + + for (int j = 0; j < qplugin.mimeTypes.count(); ++j) { + const QWebPluginFactory::MimeType& mimeType = qplugin.mimeTypes.at(j); + + MimeClassInfo mimeInfo; + mimeInfo.type = mimeType.name; + mimeInfo.desc = mimeType.description; + for (int k = 0; k < mimeType.fileExtensions.count(); ++k) + mimeInfo.extensions.append(mimeType.fileExtensions.at(k)); + + info.mimes.append(mimeInfo); + } + outPlugins.append(info); + } + } + + PluginDatabase* db = PluginDatabase::installedPlugins(); + const Vector<PluginPackage*> &plugins = db->plugins(); + + outPlugins.resize(plugins.size()); + + for (unsigned int i = 0; i < plugins.size(); ++i) { + PluginInfo info; + PluginPackage* package = plugins[i]; + + info.name = package->name(); + info.file = package->fileName(); + info.desc = package->description(); + + const MIMEToDescriptionsMap& mimeToDescriptions = package->mimeToDescriptions(); + MIMEToDescriptionsMap::const_iterator end = mimeToDescriptions.end(); + for (MIMEToDescriptionsMap::const_iterator it = mimeToDescriptions.begin(); it != end; ++it) { + MimeClassInfo mime; + + mime.type = it->first; + mime.desc = it->second; + mime.extensions = package->mimeToExtensions().get(mime.type); + + info.mimes.append(mime); + } + + outPlugins.append(info); + } + +} + + +// LocalizationStrategy + +String WebPlatformStrategies::inputElementAltText() +{ + return QCoreApplication::translate("QWebPage", "Submit", "Submit (input element) alt text for <input> elements with no alt, title, or value"); +} + +String WebPlatformStrategies::resetButtonDefaultLabel() +{ + return QCoreApplication::translate("QWebPage", "Reset", "default label for Reset buttons in forms on web pages"); +} + +String WebPlatformStrategies::searchableIndexIntroduction() +{ + return QCoreApplication::translate("QWebPage", "This is a searchable index. Enter search keywords: ", "text that appears at the start of nearly-obsolete web pages in the form of a 'searchable index'"); +} + +String WebPlatformStrategies::submitButtonDefaultLabel() +{ + return QCoreApplication::translate("QWebPage", "Submit", "default label for Submit buttons in forms on web pages"); +} + +String WebPlatformStrategies::fileButtonChooseFileLabel() +{ + return QCoreApplication::translate("QWebPage", "Choose File", "title for file button used in HTML forms"); +} + +String WebPlatformStrategies::fileButtonNoFileSelectedLabel() +{ + return QCoreApplication::translate("QWebPage", "No file selected", "text to display in file button used in HTML forms when no file is selected"); +} + +String WebPlatformStrategies::contextMenuItemTagOpenLinkInNewWindow() +{ + return QCoreApplication::translate("QWebPage", "Open in New Window", "Open in New Window context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagDownloadLinkToDisk() +{ + return QCoreApplication::translate("QWebPage", "Save Link...", "Download Linked File context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCopyLinkToClipboard() +{ + return QCoreApplication::translate("QWebPage", "Copy Link", "Copy Link context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagOpenImageInNewWindow() +{ + return QCoreApplication::translate("QWebPage", "Open Image", "Open Image in New Window context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagDownloadImageToDisk() +{ + return QCoreApplication::translate("QWebPage", "Save Image", "Download Image context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCopyImageToClipboard() +{ + return QCoreApplication::translate("QWebPage", "Copy Image", "Copy Link context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagOpenFrameInNewWindow() +{ + return QCoreApplication::translate("QWebPage", "Open Frame", "Open Frame in New Window context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCopy() +{ + return QCoreApplication::translate("QWebPage", "Copy", "Copy context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagGoBack() +{ + return QCoreApplication::translate("QWebPage", "Go Back", "Back context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagGoForward() +{ + return QCoreApplication::translate("QWebPage", "Go Forward", "Forward context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagStop() +{ + return QCoreApplication::translate("QWebPage", "Stop", "Stop context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagReload() +{ + return QCoreApplication::translate("QWebPage", "Reload", "Reload context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCut() +{ + return QCoreApplication::translate("QWebPage", "Cut", "Cut context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagPaste() +{ + return QCoreApplication::translate("QWebPage", "Paste", "Paste context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagNoGuessesFound() +{ + return QCoreApplication::translate("QWebPage", "No Guesses Found", "No Guesses Found context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagIgnoreSpelling() +{ + return QCoreApplication::translate("QWebPage", "Ignore", "Ignore Spelling context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagLearnSpelling() +{ + return QCoreApplication::translate("QWebPage", "Add To Dictionary", "Learn Spelling context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagSearchWeb() +{ + return QCoreApplication::translate("QWebPage", "Search The Web", "Search The Web context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagLookUpInDictionary() +{ + return QCoreApplication::translate("QWebPage", "Look Up In Dictionary", "Look Up in Dictionary context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagOpenLink() +{ + return QCoreApplication::translate("QWebPage", "Open Link", "Open Link context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagIgnoreGrammar() +{ + return QCoreApplication::translate("QWebPage", "Ignore", "Ignore Grammar context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagSpellingMenu() +{ + return QCoreApplication::translate("QWebPage", "Spelling", "Spelling and Grammar context sub-menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagShowSpellingPanel(bool show) +{ + return show ? QCoreApplication::translate("QWebPage", "Show Spelling and Grammar", "menu item title") : + QCoreApplication::translate("QWebPage", "Hide Spelling and Grammar", "menu item title"); +} + +String WebPlatformStrategies::contextMenuItemTagCheckSpelling() +{ + return QCoreApplication::translate("QWebPage", "Check Spelling", "Check spelling context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCheckSpellingWhileTyping() +{ + return QCoreApplication::translate("QWebPage", "Check Spelling While Typing", "Check spelling while typing context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCheckGrammarWithSpelling() +{ + return QCoreApplication::translate("QWebPage", "Check Grammar With Spelling", "Check grammar with spelling context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagFontMenu() +{ + return QCoreApplication::translate("QWebPage", "Fonts", "Font context sub-menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagBold() +{ + return QCoreApplication::translate("QWebPage", "Bold", "Bold context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagItalic() +{ + return QCoreApplication::translate("QWebPage", "Italic", "Italic context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagUnderline() +{ + return QCoreApplication::translate("QWebPage", "Underline", "Underline context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagOutline() +{ + return QCoreApplication::translate("QWebPage", "Outline", "Outline context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagWritingDirectionMenu() +{ + return QCoreApplication::translate("QWebPage", "Direction", "Writing direction context sub-menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagTextDirectionMenu() +{ + return QCoreApplication::translate("QWebPage", "Text Direction", "Text direction context sub-menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagDefaultDirection() +{ + return QCoreApplication::translate("QWebPage", "Default", "Default writing direction context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagLeftToRight() +{ + return QCoreApplication::translate("QWebPage", "Left to Right", "Left to Right context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagRightToLeft() +{ + return QCoreApplication::translate("QWebPage", "Right to Left", "Right to Left context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagInspectElement() +{ + return QCoreApplication::translate("QWebPage", "Inspect", "Inspect Element context menu item"); +} + +String WebPlatformStrategies::searchMenuNoRecentSearchesText() +{ + return QCoreApplication::translate("QWebPage", "No recent searches", "Label for only item in menu that appears when clicking on the search field image, when no searches have been performed"); +} + +String WebPlatformStrategies::searchMenuRecentSearchesText() +{ + return QCoreApplication::translate("QWebPage", "Recent searches", "label for first item in the menu that appears when clicking on the search field image, used as embedded menu title"); +} + +String WebPlatformStrategies::searchMenuClearRecentSearchesText() +{ + return QCoreApplication::translate("QWebPage", "Clear recent searches", "menu item in Recent Searches menu that empties menu's contents"); +} + +String WebPlatformStrategies::AXWebAreaText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXLinkText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXListMarkerText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXImageMapText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXHeadingText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXDefinitionListTermText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXDefinitionListDefinitionText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXButtonActionVerb() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXRadioButtonActionVerb() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXTextFieldActionVerb() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXCheckedCheckBoxActionVerb() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXUncheckedCheckBoxActionVerb() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXMenuListActionVerb() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXMenuListPopupActionVerb() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::AXLinkActionVerb() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::missingPluginText() +{ + return QCoreApplication::translate("QWebPage", "Missing Plug-in", "Label text to be used when a plug-in is missing"); +} + +String WebPlatformStrategies::crashedPluginText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::multipleFileUploadText(unsigned) +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::unknownFileSizeText() +{ + return QCoreApplication::translate("QWebPage", "Unknown", "Unknown filesize FTP directory listing item"); +} + +String WebPlatformStrategies::imageTitle(const String& filename, const IntSize& size) +{ + return QCoreApplication::translate("QWebPage", "%1 (%2x%3 pixels)", "Title string for images").arg(filename).arg(size.width()).arg(size.height()); +} + +String WebPlatformStrategies::mediaElementLoadingStateText() +{ + return QCoreApplication::translate("QWebPage", "Loading...", "Media controller status message when the media is loading"); +} + +String WebPlatformStrategies::mediaElementLiveBroadcastStateText() +{ + return QCoreApplication::translate("QWebPage", "Live Broadcast", "Media controller status message when watching a live broadcast"); +} + +#if ENABLE(VIDEO) + +String WebPlatformStrategies::localizedMediaControlElementString(const String& name) +{ + if (name == "AudioElement") + return QCoreApplication::translate("QWebPage", "Audio Element", "Media controller element"); + if (name == "VideoElement") + return QCoreApplication::translate("QWebPage", "Video Element", "Media controller element"); + if (name == "MuteButton") + return QCoreApplication::translate("QWebPage", "Mute Button", "Media controller element"); + if (name == "UnMuteButton") + return QCoreApplication::translate("QWebPage", "Unmute Button", "Media controller element"); + if (name == "PlayButton") + return QCoreApplication::translate("QWebPage", "Play Button", "Media controller element"); + if (name == "PauseButton") + return QCoreApplication::translate("QWebPage", "Pause Button", "Media controller element"); + if (name == "Slider") + return QCoreApplication::translate("QWebPage", "Slider", "Media controller element"); + if (name == "SliderThumb") + return QCoreApplication::translate("QWebPage", "Slider Thumb", "Media controller element"); + if (name == "RewindButton") + return QCoreApplication::translate("QWebPage", "Rewind Button", "Media controller element"); + if (name == "ReturnToRealtimeButton") + return QCoreApplication::translate("QWebPage", "Return to Real-time Button", "Media controller element"); + if (name == "CurrentTimeDisplay") + return QCoreApplication::translate("QWebPage", "Elapsed Time", "Media controller element"); + if (name == "TimeRemainingDisplay") + return QCoreApplication::translate("QWebPage", "Remaining Time", "Media controller element"); + if (name == "StatusDisplay") + return QCoreApplication::translate("QWebPage", "Status Display", "Media controller element"); + if (name == "FullscreenButton") + return QCoreApplication::translate("QWebPage", "Fullscreen Button", "Media controller element"); + if (name == "SeekForwardButton") + return QCoreApplication::translate("QWebPage", "Seek Forward Button", "Media controller element"); + if (name == "SeekBackButton") + return QCoreApplication::translate("QWebPage", "Seek Back Button", "Media controller element"); + + return String(); +} + +String WebPlatformStrategies::localizedMediaControlElementHelpText(const String& name) +{ + if (name == "AudioElement") + return QCoreApplication::translate("QWebPage", "Audio element playback controls and status display", "Media controller element"); + if (name == "VideoElement") + return QCoreApplication::translate("QWebPage", "Video element playback controls and status display", "Media controller element"); + if (name == "MuteButton") + return QCoreApplication::translate("QWebPage", "Mute audio tracks", "Media controller element"); + if (name == "UnMuteButton") + return QCoreApplication::translate("QWebPage", "Unmute audio tracks", "Media controller element"); + if (name == "PlayButton") + return QCoreApplication::translate("QWebPage", "Begin playback", "Media controller element"); + if (name == "PauseButton") + return QCoreApplication::translate("QWebPage", "Pause playback", "Media controller element"); + if (name == "Slider") + return QCoreApplication::translate("QWebPage", "Movie time scrubber", "Media controller element"); + if (name == "SliderThumb") + return QCoreApplication::translate("QWebPage", "Movie time scrubber thumb", "Media controller element"); + if (name == "RewindButton") + return QCoreApplication::translate("QWebPage", "Rewind movie", "Media controller element"); + if (name == "ReturnToRealtimeButton") + return QCoreApplication::translate("QWebPage", "Return streaming movie to real-time", "Media controller element"); + if (name == "CurrentTimeDisplay") + return QCoreApplication::translate("QWebPage", "Current movie time", "Media controller element"); + if (name == "TimeRemainingDisplay") + return QCoreApplication::translate("QWebPage", "Remaining movie time", "Media controller element"); + if (name == "StatusDisplay") + return QCoreApplication::translate("QWebPage", "Current movie status", "Media controller element"); + if (name == "FullscreenButton") + return QCoreApplication::translate("QWebPage", "Play movie in full-screen mode", "Media controller element"); + if (name == "SeekForwardButton") + return QCoreApplication::translate("QWebPage", "Seek quickly back", "Media controller element"); + if (name == "SeekBackButton") + return QCoreApplication::translate("QWebPage", "Seek quickly forward", "Media controller element"); + + ASSERT_NOT_REACHED(); + return String(); +} + +String WebPlatformStrategies::localizedMediaTimeDescription(float time) +{ + if (!isfinite(time)) + return QCoreApplication::translate("QWebPage", "Indefinite time", "Media time description"); + + int seconds = (int)fabsf(time); + int days = seconds / (60 * 60 * 24); + int hours = seconds / (60 * 60); + int minutes = (seconds / 60) % 60; + seconds %= 60; + + if (days) + return QCoreApplication::translate("QWebPage", "%1 days %2 hours %3 minutes %4 seconds", "Media time description").arg(days).arg(hours).arg(minutes).arg(seconds); + + if (hours) + return QCoreApplication::translate("QWebPage", "%1 hours %2 minutes %3 seconds", "Media time description").arg(hours).arg(minutes).arg(seconds); + + if (minutes) + return QCoreApplication::translate("QWebPage", "%1 minutes %2 seconds", "Media time description").arg(minutes).arg(seconds); + + return QCoreApplication::translate("QWebPage", "%1 seconds", "Media time description").arg(seconds); +} + +#else // ENABLE(VIDEO) +// FIXME: #if ENABLE(VIDEO) should be in the base class + +String WebPlatformStrategies::localizedMediaControlElementString(const String& name) +{ + return String(); +} + +String WebPlatformStrategies::localizedMediaControlElementHelpText(const String& name) +{ + return String(); +} + +String WebPlatformStrategies::localizedMediaTimeDescription(float time) +{ + return String(); +} + +#endif // ENABLE(VIDEO) + + +String WebPlatformStrategies::validationMessageValueMissingText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::validationMessageTypeMismatchText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::validationMessagePatternMismatchText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::validationMessageTooLongText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::validationMessageRangeUnderflowText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::validationMessageRangeOverflowText() +{ + notImplemented(); + return String(); +} + +String WebPlatformStrategies::validationMessageStepMismatchText() +{ + notImplemented(); + return String(); +} + + +// VisitedLinkStrategy + +bool WebPlatformStrategies::isLinkVisited(Page* page, LinkHash hash) +{ + return page->group().isLinkVisited(hash); +} + +void WebPlatformStrategies::addVisitedLink(Page* page, LinkHash hash) +{ + page->group().addVisitedLinkHash(hash); +} diff --git a/WebKit/qt/WebCoreSupport/WebPlatformStrategies.h b/WebKit/qt/WebCoreSupport/WebPlatformStrategies.h new file mode 100644 index 0000000..8ea60d9 --- /dev/null +++ b/WebKit/qt/WebCoreSupport/WebPlatformStrategies.h @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 INdT - Instituto Nokia de Tecnologia + * Copyright (C) 2008 Nokia Corporation 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 WebPlatformStrategies_h +#define WebPlatformStrategies_h + +#include <LocalizationStrategy.h> +#include <PlatformStrategies.h> +#include <PluginStrategy.h> +#include <VisitedLinkStrategy.h> + +class QWebPage; + +class WebPlatformStrategies : public WebCore::PlatformStrategies, private WebCore::PluginStrategy, private WebCore::LocalizationStrategy, private WebCore::VisitedLinkStrategy { +public: + static void initialize(QWebPage* webPage); + +private: + WebPlatformStrategies(QWebPage* webPage); + + // WebCore::PlatformStrategies + virtual WebCore::PluginStrategy* createPluginStrategy(); + virtual WebCore::LocalizationStrategy* createLocalizationStrategy(); + virtual WebCore::VisitedLinkStrategy* createVisitedLinkStrategy(); + + // WebCore::PluginStrategy + virtual void refreshPlugins(); + virtual void getPluginInfo(Vector<WebCore::PluginInfo>&); + + // WebCore::LocalizationStrategy + virtual WTF::String inputElementAltText(); + virtual WTF::String resetButtonDefaultLabel(); + virtual WTF::String searchableIndexIntroduction(); + virtual WTF::String submitButtonDefaultLabel(); + virtual WTF::String fileButtonChooseFileLabel(); + virtual WTF::String fileButtonNoFileSelectedLabel(); + virtual WTF::String contextMenuItemTagOpenLinkInNewWindow(); + virtual WTF::String contextMenuItemTagDownloadLinkToDisk(); + virtual WTF::String contextMenuItemTagCopyLinkToClipboard(); + virtual WTF::String contextMenuItemTagOpenImageInNewWindow(); + virtual WTF::String contextMenuItemTagDownloadImageToDisk(); + virtual WTF::String contextMenuItemTagCopyImageToClipboard(); + virtual WTF::String contextMenuItemTagOpenFrameInNewWindow(); + virtual WTF::String contextMenuItemTagCopy(); + virtual WTF::String contextMenuItemTagGoBack(); + virtual WTF::String contextMenuItemTagGoForward(); + virtual WTF::String contextMenuItemTagStop(); + virtual WTF::String contextMenuItemTagReload(); + virtual WTF::String contextMenuItemTagCut(); + virtual WTF::String contextMenuItemTagPaste(); + virtual WTF::String contextMenuItemTagNoGuessesFound(); + virtual WTF::String contextMenuItemTagIgnoreSpelling(); + virtual WTF::String contextMenuItemTagLearnSpelling(); + virtual WTF::String contextMenuItemTagSearchWeb(); + virtual WTF::String contextMenuItemTagLookUpInDictionary(); + virtual WTF::String contextMenuItemTagOpenLink(); + virtual WTF::String contextMenuItemTagIgnoreGrammar(); + virtual WTF::String contextMenuItemTagSpellingMenu(); + virtual WTF::String contextMenuItemTagShowSpellingPanel(bool show); + virtual WTF::String contextMenuItemTagCheckSpelling(); + virtual WTF::String contextMenuItemTagCheckSpellingWhileTyping(); + virtual WTF::String contextMenuItemTagCheckGrammarWithSpelling(); + virtual WTF::String contextMenuItemTagFontMenu(); + virtual WTF::String contextMenuItemTagBold(); + virtual WTF::String contextMenuItemTagItalic(); + virtual WTF::String contextMenuItemTagUnderline(); + virtual WTF::String contextMenuItemTagOutline(); + virtual WTF::String contextMenuItemTagWritingDirectionMenu(); + virtual WTF::String contextMenuItemTagTextDirectionMenu(); + virtual WTF::String contextMenuItemTagDefaultDirection(); + virtual WTF::String contextMenuItemTagLeftToRight(); + virtual WTF::String contextMenuItemTagRightToLeft(); + virtual WTF::String contextMenuItemTagInspectElement(); + virtual WTF::String searchMenuNoRecentSearchesText(); + virtual WTF::String searchMenuRecentSearchesText(); + virtual WTF::String searchMenuClearRecentSearchesText(); + virtual WTF::String AXWebAreaText(); + virtual WTF::String AXLinkText(); + virtual WTF::String AXListMarkerText(); + virtual WTF::String AXImageMapText(); + virtual WTF::String AXHeadingText(); + virtual WTF::String AXDefinitionListTermText(); + virtual WTF::String AXDefinitionListDefinitionText(); + virtual WTF::String AXButtonActionVerb(); + virtual WTF::String AXRadioButtonActionVerb(); + virtual WTF::String AXTextFieldActionVerb(); + virtual WTF::String AXCheckedCheckBoxActionVerb(); + virtual WTF::String AXUncheckedCheckBoxActionVerb(); + virtual WTF::String AXMenuListActionVerb(); + virtual WTF::String AXMenuListPopupActionVerb(); + virtual WTF::String AXLinkActionVerb(); + virtual WTF::String missingPluginText(); + virtual WTF::String crashedPluginText(); + virtual WTF::String multipleFileUploadText(unsigned numberOfFiles); + virtual WTF::String unknownFileSizeText(); + virtual WTF::String imageTitle(const WTF::String& filename, const WebCore::IntSize&); + virtual WTF::String mediaElementLoadingStateText(); + virtual WTF::String mediaElementLiveBroadcastStateText(); + virtual WTF::String localizedMediaControlElementString(const WTF::String&); + virtual WTF::String localizedMediaControlElementHelpText(const WTF::String&); + virtual WTF::String localizedMediaTimeDescription(float); + virtual WTF::String validationMessageValueMissingText(); + virtual WTF::String validationMessageTypeMismatchText(); + virtual WTF::String validationMessagePatternMismatchText(); + virtual WTF::String validationMessageTooLongText(); + virtual WTF::String validationMessageRangeUnderflowText(); + virtual WTF::String validationMessageRangeOverflowText(); + virtual WTF::String validationMessageStepMismatchText(); + + // WebCore::VisitedLinkStrategy + virtual bool isLinkVisited(WebCore::Page*, WebCore::LinkHash); + virtual void addVisitedLink(WebCore::Page*, WebCore::LinkHash); + + QWebPage* m_page; +}; + +#endif // WebPlatformStrategies_h diff --git a/WebKit/qt/declarative/qdeclarativewebview.cpp b/WebKit/qt/declarative/qdeclarativewebview.cpp index 9dcba60..94f08bd 100644 --- a/WebKit/qt/declarative/qdeclarativewebview.cpp +++ b/WebKit/qt/declarative/qdeclarativewebview.cpp @@ -91,7 +91,6 @@ GraphicsWebView::GraphicsWebView(QDeclarativeWebView* parent) void GraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* event) { - setFocus(); pressPoint = event->pos(); if (pressTime) { pressTimer.start(pressTime, this); @@ -101,6 +100,11 @@ void GraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* event) parent->setKeepMouseGrab(true); } QGraphicsWebView::mousePressEvent(event); + + QWebHitTestResult hit = page()->mainFrame()->hitTestContent(pressPoint.toPoint()); + if (hit.isContentEditable()) + parent->forceActiveFocus(); + setFocus(); } void GraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) @@ -139,47 +143,78 @@ void GraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) /*! \qmlclass WebView QDeclarativeWebView + \ingroup qml-view-elements \since 4.7 - \brief The WebView item allows you to add web content to a canvas. + \brief The WebView item allows you to add Web content to a canvas. \inherits Item - A WebView renders web content based on a URL. + A WebView renders Web content based on a URL. This type is made available by importing the \c QtWebKit module: \bold{import QtWebKit 1.0} - If the width and height of the item is not set, they will - dynamically adjust to a size appropriate for the content. - This width may be large for typical online web pages. + The WebView item includes no scrolling, scaling, toolbars, or other common browser + components. These must be implemented around WebView. See the \l{QML Web Browser} + example for a demonstration of this. - If the width or height is explictly set, the rendered website - will be clipped, not scaled, to fit into the set dimensions. + The page to be displayed by the item is specified using the \l url property, + and this can be changed to fetch and display a new page. While the page loads, + the \l progress property is updated to indicate how much of the page has been + loaded. - If the preferredWidth is set, the width will be this amount or larger, - usually laying out the web content to fit the preferredWidth. + \section1 Appearance - \qml - import QtWebKit 1.0 + If the width and height of the item is not set, they will dynamically adjust + to a size appropriate for the content. This width may be large for typical + online web pages, typically greater than 800 by 600 pixels. - WebView { - url: "http://www.nokia.com" - preferredWidth: 490 - preferredHeight: 400 - scale: 0.5 - smooth: false - smoothCache: true - } - \endqml + If the \l{Item::}{width} or \l{Item::}{height} is explictly set, the rendered Web site will be + clipped, not scaled, to fit into the set dimensions. - \image webview.png + If the preferredWidth property is set, the width will be this amount or larger, + usually laying out the Web content to fit the preferredWidth. - The item includes no scrolling, scaling, - toolbars, etc., those must be implemented around WebView. See the WebBrowser example - for a demonstration of this. + The appearance of the content can be controlled to a certain extent by changing + the settings.standardFontFamily property and other settings related to fonts. + + The page can be zoomed by calling the heuristicZoom() method, which performs a + series of tests to determine whether zoomed content will be displayed in an + appropriate way in the space allocated to the item. + + \section1 User Interaction and Navigation + + By default, certain mouse and touch events are delivered to other items in + preference to the Web content. For example, when a scrolling view is created + by placing a WebView in a Flickable, move events are delivered to the Flickable + so that the user can scroll the page. This prevents the user from accidentally + selecting text in a Web page instead of scrolling. + + The pressGrabTime property defines the time the user must touch or press a + mouse button over the WebView before the Web content will receive the move + events it needs to select text and images. + + When this item has keyboard focus, all keyboard input will be sent directly to + the Web page within. + + When the navigates by clicking on links, the item records the pages visited + in its internal history + + Because this item is designed to be used as a component in a browser, it + exposes \l{Action}{actions} for \l back, \l forward, \l reload and \l stop. + These can be triggered to change the current page displayed by the item. + + \section1 Example Usage + + \beginfloatright + \inlineimage webview.png + \endfloat + + The following example displays a scaled down Web page at a fixed size. + + \snippet doc/src/snippets/declarative/webview/webview.qml document - When this item has keyboard focus, all keyboard input will be sent directly to the - web page within. + \clearfloat \sa {declarative/modelviews/webview}{WebView example}, {demos/declarative/webbrowser}{Web Browser demo} */ @@ -388,7 +423,7 @@ void QDeclarativeWebView::setPreferredHeight(int height) } /*! - \qmlmethod bool WebView::evaluateJavaScript(string) + \qmlmethod bool WebView::evaluateJavaScript(string scriptSource) Evaluates the \a scriptSource JavaScript inside the context of the main web frame, and returns the result of the last executed statement. @@ -512,14 +547,14 @@ void QDeclarativeWebView::setRenderingEnabled(bool enabled) } /*! - \qmlsignal WebView::onDoubleClick(clickx, clicky) + \qmlsignal WebView::onDoubleClick(int clickx, int clicky) The WebView does not pass double-click events to the web engine, but rather emits this signals. */ /*! - \qmlmethod bool WebView::heuristicZoom(clickX,clickY,maxzoom) + \qmlmethod bool WebView::heuristicZoom(int clickX, int clickY, real maxzoom) Finds a zoom that: \list @@ -554,11 +589,11 @@ bool QDeclarativeWebView::heuristicZoom(int clickX, int clickY, qreal maxZoom) \qmlproperty int WebView::pressGrabTime The number of milliseconds the user must press before the WebView - starts passing move events through to the web engine (rather than + starts passing move events through to the Web engine (rather than letting other QML elements such as a Flickable take them). Defaults to 400ms. Set to 0 to always grab and pass move events to - the web engine. + the Web engine. */ int QDeclarativeWebView::pressGrabTime() const { @@ -975,7 +1010,7 @@ QString QDeclarativeWebPage::chooseFile(QWebFrame* originatingFrame, const QStri } /*! - \qmlsignal WebView::onAlert(message) + \qmlsignal WebView::onAlert(string message) The handler is called when the web engine sends a JavaScript alert. The \a message is the text to be displayed in the alert to the user. diff --git a/WebKit/qt/docs/qtwebkit.qdoc b/WebKit/qt/docs/qtwebkit.qdoc index d3f5502..0335d46 100644 --- a/WebKit/qt/docs/qtwebkit.qdoc +++ b/WebKit/qt/docs/qtwebkit.qdoc @@ -1,6 +1,6 @@ /*! \module QtWebKit - \title QtWebKit Module + \title WebKit in Qt \contentspage All Qt Modules \previouspage QtSvg \nextpage QtXml diff --git a/WebKit/qt/examples/platformplugin/WebNotificationPresenter.cpp b/WebKit/qt/examples/platformplugin/WebNotificationPresenter.cpp index c992236..d991ab1 100644 --- a/WebKit/qt/examples/platformplugin/WebNotificationPresenter.cpp +++ b/WebKit/qt/examples/platformplugin/WebNotificationPresenter.cpp @@ -57,7 +57,11 @@ void WebNotificationWidget::showNotification(const QWebNotificationData* data) bool WebNotificationWidget::event(QEvent* ev) { - if (ev->type() == QEvent::MouseButtonRelease || ev->type() == QEvent::Close) { + if (ev->type() == QEvent::MouseButtonRelease) { + emit notificationClicked(); + return true; + } + if (ev->type() == QEvent::Close) { emit notificationClosed(); return true; } diff --git a/WebKit/qt/examples/platformplugin/WebNotificationPresenter.h b/WebKit/qt/examples/platformplugin/WebNotificationPresenter.h index a2563b2..f46e5cb 100644 --- a/WebKit/qt/examples/platformplugin/WebNotificationPresenter.h +++ b/WebKit/qt/examples/platformplugin/WebNotificationPresenter.h @@ -36,6 +36,7 @@ public: Q_SIGNALS: void notificationClosed(); + void notificationClicked(); }; class WebNotificationPresenter : public QWebNotificationPresenter @@ -47,6 +48,7 @@ public: { m_widget = new WebNotificationWidget(); connect(m_widget, SIGNAL(notificationClosed()), this, SIGNAL(notificationClosed())); + connect(m_widget, SIGNAL(notificationClicked()), this, SIGNAL(notificationClicked())); } virtual ~WebNotificationPresenter() { m_widget->close(); delete m_widget; } diff --git a/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h b/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h index 3c56c98..76496c5 100644 --- a/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h +++ b/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h @@ -27,6 +27,7 @@ */ #include <QObject> +#include <QUrl> class QWebSelectData { @@ -66,6 +67,7 @@ public: virtual const QString title() const = 0; virtual const QString message() const = 0; virtual const QByteArray iconData() const = 0; + virtual const QUrl openerPageUrl() const = 0; }; class QWebNotificationPresenter : public QObject @@ -79,6 +81,7 @@ public: Q_SIGNALS: void notificationClosed(); + void notificationClicked(); }; class QWebHapticFeedbackPlayer @@ -113,6 +116,6 @@ public: }; -Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.3"); +Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.4"); #endif // QWEBKITPLATFORMPLUGIN_H diff --git a/WebKit/qt/qt_webkit_version.pri b/WebKit/qt/qt_webkit_version.pri index ca6299a..4147d8f 100644 --- a/WebKit/qt/qt_webkit_version.pri +++ b/WebKit/qt/qt_webkit_version.pri @@ -2,4 +2,4 @@ QT_WEBKIT_VERSION = 4.9.0 QT_WEBKIT_MAJOR_VERSION = 4 QT_WEBKIT_MINOR_VERSION = 9 QT_WEBKIT_PATCH_VERSION = 0 -QT_CONFIG *= webkit +QT_CONFIG += webkit diff --git a/WebKit/qt/symbian/eabi/QtWebKitu.def b/WebKit/qt/symbian/eabi/QtWebKitu.def index 9c3e152..8291197 100644 --- a/WebKit/qt/symbian/eabi/QtWebKitu.def +++ b/WebKit/qt/symbian/eabi/QtWebKitu.def @@ -797,7 +797,7 @@ EXPORTS _ZN23DumpRenderTreeSupportQtD1Ev @ 796 NONAME _ZN23DumpRenderTreeSupportQtD2Ev @ 797 NONAME _ZN8QWebPage23allowGeolocationRequestEP9QWebFrame @ 798 NONAME - _ZN8QWebPage23viewportChangeRequestedERKNS_13ViewportHintsE @ 799 NONAME + _ZN8QWebPage23viewportChangeRequestedERKNS_13ViewportHintsE @ 799 NONAME ABSENT _ZNK15QWebScriptWorld5worldEv @ 800 NONAME _ZN16QGraphicsWebView13setDeviceSizeERK5QSize @ 801 NONAME _ZN23DumpRenderTreeSupportQt12pagePropertyEP9QWebFrameRK7QStringi @ 802 NONAME @@ -812,4 +812,8 @@ EXPORTS _ZN8QWebPage25requestPermissionFromUserEP9QWebFrameNS_16PermissionDomainE @ 811 NONAME _ZN8QWebPage27cancelRequestsForPermissionEP9QWebFrameNS_16PermissionDomainE @ 812 NONAME _ZNK16QGraphicsWebView10deviceSizeEv @ 813 NONAME + _ZN23DumpRenderTreeSupportQt14viewportAsTextEP8QWebPageRK5QSize @ 814 NONAME + _ZN23DumpRenderTreeSupportQt32simulateDesktopNotificationClickERK7QString @ 815 NONAME + _ZN8QWebPage23viewportChangeRequestedEv @ 816 NONAME + _ZNK8QWebPage28viewportConfigurationForSizeE5QSize @ 817 NONAME diff --git a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 9a6c35f..10af94c 100644 --- a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -97,6 +97,7 @@ private slots: void backActionUpdate(); void frameAt(); void requestCache(); + void loadCachedPage(); void protectBindingsRuntimeObjectsFromCollector(); void localURLSchemes(); void testOptionalJSObjects(); @@ -1288,6 +1289,37 @@ void tst_QWebPage::requestCache() (int)QNetworkRequest::PreferCache); } +void tst_QWebPage::loadCachedPage() +{ + TestPage page; + QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); + page.settings()->setMaximumPagesInCache(3); + + page.mainFrame()->load(QUrl("data:text/html,This is first page")); + + QTRY_COMPARE(loadSpy.count(), 1); + QTRY_COMPARE(page.navigations.count(), 1); + + QUrl firstPageUrl = page.mainFrame()->url(); + page.mainFrame()->load(QUrl("data:text/html,This is second page")); + + QTRY_COMPARE(loadSpy.count(), 2); + QTRY_COMPARE(page.navigations.count(), 2); + + page.triggerAction(QWebPage::Stop); + QVERIFY(page.history()->canGoBack()); + + QSignalSpy urlSpy(page.mainFrame(), SIGNAL(urlChanged(QUrl))); + QVERIFY(urlSpy.isValid()); + + page.triggerAction(QWebPage::Back); + ::waitForSignal(page.mainFrame(), SIGNAL(urlChanged(QUrl))); + QCOMPARE(urlSpy.size(), 1); + + QList<QVariant> arguments1 = urlSpy.takeFirst(); + QCOMPARE(arguments1.at(0).toUrl(), firstPageUrl); + +} void tst_QWebPage::backActionUpdate() { QWebView view; @@ -1661,6 +1693,22 @@ void tst_QWebPage::inputMethods() QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel)); #endif +#if QT_VERSION >= 0x040600 + //START - Test for sending empty QInputMethodEvent + page->mainFrame()->setHtml("<html><body>" \ + "<input type='text' id='input3' value='QtWebKit2'/>" \ + "</body></html>"); + page->mainFrame()->evaluateJavaScript("var inputEle = document.getElementById('input3'); inputEle.focus(); inputEle.select();"); + + //Send empty QInputMethodEvent + QInputMethodEvent emptyEvent; + page->event(&emptyEvent); + + QString inputValue = page->mainFrame()->evaluateJavaScript("document.getElementById('input3').value").toString(); + QCOMPARE(inputValue, QString("QtWebKit2")); + //END - Test for sending empty QInputMethodEvent +#endif + delete container; } |