diff options
Diffstat (limited to 'WebKit/qt/Api')
-rw-r--r-- | WebKit/qt/Api/qgraphicswebview.cpp | 4 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebelement.cpp | 2 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebframe.cpp | 9 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebinspector.cpp | 2 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage.cpp | 70 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage.h | 16 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage_p.h | 2 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebsettings.h | 4 |
8 files changed, 72 insertions, 37 deletions
diff --git a/WebKit/qt/Api/qgraphicswebview.cpp b/WebKit/qt/Api/qgraphicswebview.cpp index 6cc2aa0..c8438f3 100644 --- a/WebKit/qt/Api/qgraphicswebview.cpp +++ b/WebKit/qt/Api/qgraphicswebview.cpp @@ -140,8 +140,8 @@ void QGraphicsWebViewPrivate::updateResizesToContentsForPage() QObject::disconnect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), q, SLOT(_q_contentsSizeChanged(const QSize&))); } - page->d->page->settings()->setShouldDelegateScrolling(resizesToContents); page->d->page->mainFrame()->view()->setPaintsEntireContents(resizesToContents); + page->d->page->mainFrame()->view()->setDelegatesScrolling(resizesToContents); } void QGraphicsWebViewPrivate::_q_contentsSizeChanged(const QSize& size) @@ -413,8 +413,6 @@ void QGraphicsWebViewPrivate::detachCurrentPage() if (!page) return; - page->d->page->settings()->setShouldDelegateScrolling(false); - page->d->view.clear(); // The client has always to be deleted. diff --git a/WebKit/qt/Api/qwebelement.cpp b/WebKit/qt/Api/qwebelement.cpp index 8f40c0f..60ae3a0 100644 --- a/WebKit/qt/Api/qwebelement.cpp +++ b/WebKit/qt/Api/qwebelement.cpp @@ -1020,7 +1020,7 @@ void QWebElement::appendInside(const QString &markup) return; HTMLElement* htmlElement = static_cast<HTMLElement*>(m_element); - RefPtr<DocumentFragment> fragment = htmlElement->deprecatedCreateContextualFragment(markup); + RefPtr<DocumentFragment> fragment = htmlElement->Element::deprecatedCreateContextualFragment(markup); ExceptionCode exception = 0; m_element->appendChild(fragment, exception); diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp index 203bd60..3cdbef2 100644 --- a/WebKit/qt/Api/qwebframe.cpp +++ b/WebKit/qt/Api/qwebframe.cpp @@ -558,6 +558,10 @@ void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object qDebug() << "Warning: couldn't get window object"; return; } + if (!root) { + qDebug() << "Warning: couldn't get root object"; + return; + } JSC::ExecState* exec = window->globalExec(); @@ -833,6 +837,11 @@ void QWebFrame::load(const QNetworkRequest &req, case QNetworkAccessManager::DeleteOperation: request.setHTTPMethod("DELETE"); break; +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + case QNetworkAccessManager::CustomOperation: + request.setHTTPMethod(req.attribute(QNetworkRequest::CustomVerbAttribute).toByteArray().constData()); + break; +#endif case QNetworkAccessManager::UnknownOperation: // eh? break; diff --git a/WebKit/qt/Api/qwebinspector.cpp b/WebKit/qt/Api/qwebinspector.cpp index 27148f7..6706f2a 100644 --- a/WebKit/qt/Api/qwebinspector.cpp +++ b/WebKit/qt/Api/qwebinspector.cpp @@ -91,6 +91,8 @@ QWebInspector::~QWebInspector() { // Remove association principally to prevent deleting a child frontend setPage(0); + delete d; + d = 0; } /*! diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index a29d417..030923f 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -141,6 +141,11 @@ using namespace WebCore; +// from text/qfont.cpp +QT_BEGIN_NAMESPACE +extern Q_GUI_EXPORT int qt_defaultDpi(); +QT_END_NAMESPACE + bool QWebPagePrivate::drtRun = false; // Lookup table mapping QWebPage::WebActions to the associated Editor commands @@ -286,6 +291,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) , selectTrailingWhitespaceEnabled(false) , linkPolicy(QWebPage::DontDelegateLinks) , viewportSize(QSize(0, 0)) + , pixelRatio(1) #ifndef QT_NO_CONTEXTMENU , currentContextMenu(0) #endif @@ -1067,11 +1073,9 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev) if (node) setSelectionRange(node, qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length))); - if (!ev->preeditString().isEmpty()) { - editor->setComposition(ev->preeditString(), underlines, - (a.length < 0) ? a.start + a.length : a.start, - (a.length < 0) ? a.start : a.start + a.length); - } else { + if (!ev->preeditString().isEmpty()) + editor->setComposition(ev->preeditString(), underlines, qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length))); + else { // If we are in the middle of a composition, an empty pre-edit string and a selection of zero // cancels the current composition if (editor->hasComposition() && (a.start + a.length == 0)) @@ -1082,10 +1086,16 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev) } } - if (!ev->commitString().isEmpty()) + if (node && ev->replacementLength() > 0) { + int cursorPos = frame->selection()->extent().offsetInContainerNode(); + int start = cursorPos + ev->replacementStart(); + setSelectionRange(node, start, start + ev->replacementLength()); + // Commit regardless of whether commitString is empty, to get rid of selection. + editor->confirmComposition(ev->commitString()); + } else if (!ev->commitString().isEmpty()) editor->confirmComposition(ev->commitString()); else if (!hasSelection && !ev->preeditString().isEmpty()) - editor->setComposition(ev->preeditString(), underlines, 0, ev->preeditString().length()); + editor->setComposition(ev->preeditString(), underlines, 0, 0); ev->accept(); } @@ -1370,10 +1380,8 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const return QVariant(QFont()); } case Qt::ImCursorPosition: { - if (editor->hasComposition()) { - RefPtr<Range> range = editor->compositionRange(); - return QVariant(frame->selection()->end().offsetInContainerNode() - TextIterator::rangeLength(range.get())); - } + if (editor->hasComposition()) + return QVariant(frame->selection()->end().offsetInContainerNode()); return QVariant(frame->selection()->extent().offsetInContainerNode()); } case Qt::ImSurroundingText: { @@ -1387,7 +1395,7 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const return QVariant(); } case Qt::ImCurrentSelection: { - if (renderTextControl) { + if (!editor->hasComposition() && renderTextControl) { int start = frame->selection()->start().offsetInContainerNode(); int end = frame->selection()->end().offsetInContainerNode(); if (end > start) @@ -1397,10 +1405,8 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const } case Qt::ImAnchorPosition: { - if (editor->hasComposition()) { - RefPtr<Range> range = editor->compositionRange(); - return QVariant(frame->selection()->start().offsetInContainerNode() - TextIterator::rangeLength(range.get())); - } + if (editor->hasComposition()) + return QVariant(frame->selection()->start().offsetInContainerNode()); return QVariant(frame->selection()->base().offsetInContainerNode()); } case Qt::ImMaximumTextLength: { @@ -2117,16 +2123,16 @@ bool QWebPage::shouldInterruptJavaScript() #endif } -void QWebPage::setUserPermission(QWebFrame* frame, PermissionDomain domain, PermissionPolicy policy) +void QWebPage::setFeaturePermission(QWebFrame* frame, Feature feature, PermissionPolicy policy) { - switch (domain) { - case NotificationsPermissionDomain: + switch (feature) { + case Notifications: #if ENABLE(NOTIFICATIONS) - if (policy == PermissionGranted) + if (policy == PermissionGrantedByUser) NotificationPresenterClientQt::notificationPresenter()->allowNotificationForFrame(frame->d->frame); #endif break; - case GeolocationPermissionDomain: + case Geolocation: #if ENABLE(GEOLOCATION) GeolocationPermissionClientQt::geolocationPermissionClient()->setPermission(frame, policy); #endif @@ -2451,14 +2457,30 @@ static QSize queryDeviceSizeForScreenContainingWidget(const QWidget* widget) environment variables QTWEBKIT_DEVICE_WIDTH and QTWEBKIT_DEVICE_HEIGHT, which both needs to be set. + The ViewportAttributes includes a pixel density ratio, which will also be exposed to + the web author though the -webkit-pixel-ratio media feature. This is the ratio + between 1 density-independent pixel (DPI) and physical pixels. + + A density-independent pixel is equivalent to one physical pixel on a 160 DPI screen, + so on our platform assumes that as the baseline density. + + The conversion of DIP units to screen pixels is quite simple: + + pixels = DIPs * (density / 160). + + Thus, on a 240 DPI screen, 1 DIPs would equal 1.5 physical pixels. + An invalid instance will be returned in the case an empty size is passed to the method. + + \note The density is automatically obtained from the DPI of the screen where the page + is being shown, but as many X11 servers are reporting wrong DPI, it is possible to + override it using QX11Info::setAppDpiY(). */ QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& availableSize) const { static int desktopWidth = 980; - static int deviceDPI = 160; ViewportAttributes result; @@ -2475,7 +2497,7 @@ QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& av deviceHeight = size.height(); } - WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(d->viewportArguments(), desktopWidth, deviceWidth, deviceHeight, deviceDPI, availableSize); + WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(d->viewportArguments(), desktopWidth, deviceWidth, deviceHeight, qt_defaultDpi(), availableSize); result.m_isValid = true; result.m_size = conf.layoutSize; @@ -2485,6 +2507,8 @@ QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& av result.m_devicePixelRatio = conf.devicePixelRatio; result.m_isUserScalable = conf.userScalable; + d->pixelRatio = conf.devicePixelRatio; + return result; } diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h index 9fa3518..f1f5d24 100644 --- a/WebKit/qt/Api/qwebpage.h +++ b/WebKit/qt/Api/qwebpage.h @@ -198,14 +198,14 @@ public: }; enum PermissionPolicy { - PermissionGranted, PermissionUnknown, - PermissionDenied + PermissionGrantedByUser, + PermissionDeniedByUser }; - enum PermissionDomain { - NotificationsPermissionDomain, - GeolocationPermissionDomain + enum Feature { + Notifications, + Geolocation }; class QWEBKIT_EXPORT ViewportAttributes { @@ -308,7 +308,7 @@ public: QMenu *createStandardContextMenu(); - void setUserPermission(QWebFrame* frame, PermissionDomain domain, PermissionPolicy policy); + void setFeaturePermission(QWebFrame* frame, Feature feature, PermissionPolicy policy); QStringList supportedContentTypes() const; bool supportsContentType(const QString& mimeType) const; @@ -393,8 +393,8 @@ Q_SIGNALS: void viewportChangeRequested(); - void requestPermissionFromUser(QWebFrame* frame, QWebPage::PermissionDomain domain); - void cancelRequestsForPermission(QWebFrame* frame, QWebPage::PermissionDomain domain); + void featurePermissionRequested(QWebFrame* frame, QWebPage::Feature feature); + void featurePermissionRequestCanceled(QWebFrame* frame, QWebPage::Feature feature); protected: virtual QWebPage *createWindow(WebWindowType type); diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h index 1b9cd66..624ff99 100644 --- a/WebKit/qt/Api/qwebpage_p.h +++ b/WebKit/qt/Api/qwebpage_p.h @@ -188,6 +188,8 @@ public: QSize viewportSize; QSize fixedLayoutSize; + qreal pixelRatio; + QWebHistory history; QWebHitTestResult hitTestResult; #ifndef QT_NO_CONTEXTMENU diff --git a/WebKit/qt/Api/qwebsettings.h b/WebKit/qt/Api/qwebsettings.h index 7dad72f..0569ab0 100644 --- a/WebKit/qt/Api/qwebsettings.h +++ b/WebKit/qt/Api/qwebsettings.h @@ -75,9 +75,9 @@ public: TiledBackingStoreEnabled, FrameFlatteningEnabled, SiteSpecificQuirksEnabled, + JavascriptCanCloseWindows, WebGLEnabled, - HyperlinkAuditingEnabled, - JavascriptCanCloseWindows + HyperlinkAuditingEnabled }; enum WebGraphic { MissingImageGraphic, |