diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2010-01-12 11:28:22 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2010-01-12 11:28:22 (GMT) |
commit | 04bdf9f6a77e9ebf96431f89b8240a037b3d2b09 (patch) | |
tree | b79f63e113a1b025421dcafb821e026376011a64 /src/3rdparty/webkit | |
parent | d1f73b7be62b0f6e9294b5d78ccd0680cb9fe118 (diff) | |
download | Qt-04bdf9f6a77e9ebf96431f89b8240a037b3d2b09.zip Qt-04bdf9f6a77e9ebf96431f89b8240a037b3d2b09.tar.gz Qt-04bdf9f6a77e9ebf96431f89b8240a037b3d2b09.tar.bz2 |
Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( bd6591b4acaf2172ab05702153ef539c0ac89cbb )
Changes in WebKit/qt since the last update:
++ b/WebKit/qt/ChangeLog
2009-12-18 Joe Ligman <joseph.ligman@nokia.com>
Reviewed by Kenneth Rohde Christiansen.
[Qt] Add new API to QWebFrame to scrollRecursively starting with any css overflow
then checking current frame and then ancestors
https://bugs.webkit.org/show_bug.cgi?id=32668
* Api/qwebframe.cpp:
(QWebFramePrivate::scrollOverflow):
(QWebFrame::scrollRecursively):
* Api/qwebframe.h:
* Api/qwebframe_p.h:
* tests/qwebframe/qwebframe.qrc:
* tests/qwebframe/testiframe.html: Added.
* tests/qwebframe/testiframe2.html: Added.
* tests/qwebframe/tst_qwebframe.cpp:
Diffstat (limited to 'src/3rdparty/webkit')
-rw-r--r-- | src/3rdparty/webkit/VERSION | 2 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebCore/ChangeLog | 13 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebCore/xml/XSLTProcessorQt.cpp | 30 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp | 84 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h | 2 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebKit/qt/ChangeLog | 18 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.qrc | 2 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe.html | 54 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe2.html | 21 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp | 67 |
10 files changed, 292 insertions, 1 deletions
diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 0b88429..b69ac98 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - 99ccc1c3e4db5354246720f9b9aa3d282e64497d + bd6591b4acaf2172ab05702153ef539c0ac89cbb diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 516fadd..ab5b131 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,16 @@ +2010-01-12 Jakub Wieczorek <faw217@gmail.com> + + Reviewed by Adam Barth. + + [Qt] XSL stylesheets can load documents from a different origin + + https://bugs.webkit.org/show_bug.cgi?id=33423 + + * xml/XSLTProcessorQt.cpp: + (WebCore::XSLTUriResolver::XSLTUriResolver): + (WebCore::XSLTUriResolver::resolve): + (WebCore::XSLTProcessor::transformToString): + 2010-01-07 Yael Aharon <yael.aharon@nokia.com> Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebCore/xml/XSLTProcessorQt.cpp b/src/3rdparty/webkit/WebCore/xml/XSLTProcessorQt.cpp index 50ee427..3e05ca0 100644 --- a/src/3rdparty/webkit/WebCore/xml/XSLTProcessorQt.cpp +++ b/src/3rdparty/webkit/WebCore/xml/XSLTProcessorQt.cpp @@ -36,6 +36,7 @@ #include <wtf/Vector.h> #include <qabstractmessagehandler.h> +#include <qabstracturiresolver.h> #include <qbuffer.h> #include <qsourcelocation.h> #include <qxmlquery.h> @@ -87,6 +88,31 @@ void XSLTMessageHandler::handleMessage(QtMsgType type, const QString& descriptio sourceLocation.line(), sourceLocation.uri().toString()); } +class XSLTUriResolver : public QAbstractUriResolver { + +public: + XSLTUriResolver(Document* document); + virtual QUrl resolve(const QUrl& relative, const QUrl& baseURI) const; + +private: + Document* m_document; +}; + +XSLTUriResolver::XSLTUriResolver(Document* document) + : QAbstractUriResolver() + , m_document(document) +{ +} + +QUrl XSLTUriResolver::resolve(const QUrl& relative, const QUrl& baseURI) const +{ + QUrl url = baseURI.resolved(relative); + + if (!m_document->frame() || !m_document->securityOrigin()->canRequest(url)) + return QUrl(); + return url; +} + bool XSLTProcessor::transformToString(Node* sourceNode, String&, String& resultString, String&) { bool success = false; @@ -107,6 +133,7 @@ bool XSLTProcessor::transformToString(Node* sourceNode, String&, String& resultS QXmlQuery query(QXmlQuery::XSLT20); XSLTMessageHandler messageHandler(ownerDocument.get()); + XSLTUriResolver uriResolver(ownerDocument.get()); query.setMessageHandler(&messageHandler); XSLTProcessor::ParameterMap::iterator end = m_parameters.end(); @@ -132,6 +159,9 @@ bool XSLTProcessor::transformToString(Node* sourceNode, String&, String& resultS query.setFocus(&inputBuffer); query.setQuery(&styleSheetBuffer, QUrl(stylesheet->href())); + + query.setUriResolver(&uriResolver); + success = query.evaluateTo(&outputBuffer); outputBuffer.reset(); resultString = QString::fromUtf8(outputBuffer.readAll()).trimmed(); diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp index 90d98be..29bde0d 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp @@ -324,6 +324,45 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer l } } +static bool webframe_scrollOverflow(WebCore::Frame* frame, int dx, int dy) +{ + if (!frame || !frame->document() || !frame->eventHandler()) + return false; + + Node* node = frame->document()->focusedNode(); + if (!node) + node = frame->document()->elementFromPoint(frame->eventHandler()->currentMousePosition().x(), + frame->eventHandler()->currentMousePosition().y()); + if (!node) + return false; + + RenderObject* renderer = node->renderer(); + if (!renderer) + return false; + + if (renderer->isListBox()) + return false; + + RenderLayer* renderLayer = renderer->enclosingLayer(); + if (!renderLayer) + return false; + + bool scrolledHorizontal = false; + bool scrolledVertical = false; + + if (dx > 0) + scrolledHorizontal = renderLayer->scroll(ScrollRight, ScrollByPixel, dx); + else if (dx < 0) + scrolledHorizontal = renderLayer->scroll(ScrollLeft, ScrollByPixel, qAbs(dx)); + + if (dy > 0) + scrolledVertical = renderLayer->scroll(ScrollDown, ScrollByPixel, dy); + else if (dy < 0) + scrolledVertical = renderLayer->scroll(ScrollUp, ScrollByPixel, qAbs(dy)); + + return (scrolledHorizontal || scrolledVertical); +} + /*! \class QWebFrame \since 4.4 @@ -1008,6 +1047,51 @@ void QWebFrame::scroll(int dx, int dy) } /*! + \since 4.7 + \internal + Scrolls nested frames starting at this frame, \a dx pixels to the right + and \a dy pixels downward. Both \a dx and \a dy may be negative. First attempts + to scroll elements with CSS overflow followed by this frame. If this + frame doesn't scroll, attempts to scroll the parent + + \sa QWebFrame::scroll +*/ +bool QWEBKIT_EXPORT qtwebkit_webframe_scrollRecursively(QWebFrame* qFrame, int dx, int dy) +{ + Frame* frame = QWebFramePrivate::core(qFrame); + bool scrolledHorizontal = false; + bool scrolledVertical = false; + bool scrolledOverflow = webframe_scrollOverflow(frame, dx, dy); + + if (!scrolledOverflow) { + if (!frame || !frame->view()) + return false; + + do { + IntSize scrollOffset = frame->view()->scrollOffset(); + IntPoint maxScrollOffset = frame->view()->maximumScrollPosition(); + + if (dx > 0) // scroll right + scrolledHorizontal = scrollOffset.width() < maxScrollOffset.x(); + else if (dx < 0) // scroll left + scrolledHorizontal = scrollOffset.width() > 0; + + if (dy > 0) // scroll down + scrolledVertical = scrollOffset.height() < maxScrollOffset.y(); + else if (dy < 0) //scroll up + scrolledVertical = scrollOffset.height() > 0; + + if (scrolledHorizontal || scrolledVertical) { + frame->view()->scrollBy(IntSize(dx, dy)); + return true; + } + frame = frame->tree()->parent(); + } while (frame && frame->view()); + } + return (scrolledHorizontal || scrolledVertical || scrolledOverflow); +} + +/*! \property QWebFrame::scrollPosition \since 4.5 \brief the position the frame is currently scrolled to. diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h index 081e65d..095d134 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h @@ -83,6 +83,8 @@ public: void renderPrivate(QPainter*, QWebFrame::RenderLayer, const QRegion& clip); + bool scrollOverflow(int dx, int dy); + QWebFrame *q; Qt::ScrollBarPolicy horizontalScrollBarPolicy; Qt::ScrollBarPolicy verticalScrollBarPolicy; diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 31fad69..357b787 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,21 @@ +2009-12-18 Joe Ligman <joseph.ligman@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Add new API to QWebFrame to scrollRecursively starting with any css overflow + then checking current frame and then ancestors + https://bugs.webkit.org/show_bug.cgi?id=32668 + + * Api/qwebframe.cpp: + (QWebFramePrivate::scrollOverflow): + (QWebFrame::scrollRecursively): + * Api/qwebframe.h: + * Api/qwebframe_p.h: + * tests/qwebframe/qwebframe.qrc: + * tests/qwebframe/testiframe.html: Added. + * tests/qwebframe/testiframe2.html: Added. + * tests/qwebframe/tst_qwebframe.cpp: + 2010-01-07 Yael Aharon <yael.aharon@nokia.com> Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.qrc b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.qrc index 9615e27..8afa0c1 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.qrc +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.qrc @@ -4,5 +4,7 @@ <file>style.css</file> <file>test1.html</file> <file>test2.html</file> +<file>testiframe.html</file> +<file>testiframe2.html</file> </qresource> </RCC> diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe.html b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe.html new file mode 100644 index 0000000..9f3ae85 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe.html @@ -0,0 +1,54 @@ +</html> +<html> +<head> +<title></title> +<style type="text/css"> +<!-- +#header { + background: #0f0; + position: absolute; + top: 0px; + left: 0px; + width: 800px; + height: 100px; +} +#content1 { + background: #ff0; + position: absolute; + top: 101px; + left: 0px; + width: 400px; + height: 400px; + overflow: scroll; +} +#content2 { + background: #ff7; + position: absolute; + top: 101px; + left: 401px; + width: 400px; + height: 400px; +} +#footer { + background: #0f0; + position: absolute; + top: 502px; + left: 0px; + width: 800px; + height: 200px; +} +--> +</style> +</head> +<body> +<div id="header"></div> +<div id="content1">You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible.</div> +<iframe id="content2" name="control" src="testiframe2.html"> </iframe> +<div id="footer"></div> +</body> +</html>
\ No newline at end of file diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe2.html b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe2.html new file mode 100644 index 0000000..1913a89 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe2.html @@ -0,0 +1,21 @@ +</html> +<html> +<head> +<title></title> +<style type="text/css"> +<!-- +#content { + background: #fff; + position: absolute; + top: 0px; + left: 0px; + width: 800px; + height: 800px; +} +--> +</style> +</head> +<body> +<div id="content"> </div> +</body> +</html>
\ No newline at end of file diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp index 8cc7953..609f8b4 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -606,6 +606,7 @@ private slots: void scrollPosition(); void evaluateWillCauseRepaint(); void qObjectWrapperWithSameIdentity(); + void scrollRecursively(); private: QString evalJS(const QString&s) { @@ -2824,5 +2825,71 @@ void tst_QWebFrame::qObjectWrapperWithSameIdentity() QCOMPARE(mainFrame->toPlainText(), QString("test2")); } +bool QWEBKIT_EXPORT qtwebkit_webframe_scrollRecursively(QWebFrame* qFrame, int dx, int dy); + +void tst_QWebFrame::scrollRecursively() +{ + // The test content is + // a nested frame set + // The main frame scrolls + // and has two children + // an iframe and a div overflow + // both scroll + QWebView webView; + QWebPage* webPage = webView.page(); + QSignalSpy loadSpy(webPage, SIGNAL(loadFinished(bool))); + QUrl url = QUrl("qrc:///testiframe.html"); + webPage->mainFrame()->load(url); + QTRY_COMPARE(loadSpy.count(), 1); + + QList<QWebFrame*> children = webPage->mainFrame()->childFrames(); + QVERIFY(children.count() == 1); + + // 1st test + // call scrollRecursively over mainframe + // verify scrolled + // verify scroll postion changed + QPoint scrollPosition(webPage->mainFrame()->scrollPosition()); + QVERIFY(qtwebkit_webframe_scrollRecursively(webPage->mainFrame(), 10, 10)); + QVERIFY(scrollPosition != webPage->mainFrame()->scrollPosition()); + + // 2nd test + // call scrollRecursively over child iframe + // verify scrolled + // verify child scroll position changed + // verify parent's scroll position did not change + scrollPosition = webPage->mainFrame()->scrollPosition(); + QPoint childScrollPosition = children.at(0)->scrollPosition(); + QVERIFY(qtwebkit_webframe_scrollRecursively(children.at(0), 10, 10)); + QVERIFY(scrollPosition == webPage->mainFrame()->scrollPosition()); + QVERIFY(childScrollPosition != children.at(0)->scrollPosition()); + + // 3rd test + // call scrollRecursively over div overflow + // verify scrolled == true + // verify parent and child frame's scroll postion did not change + QWebElement div = webPage->mainFrame()->documentElement().findFirst("#content1"); + QMouseEvent evpres(QEvent::MouseMove, div.geometry().center(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); + webPage->event(&evpres); + scrollPosition = webPage->mainFrame()->scrollPosition(); + childScrollPosition = children.at(0)->scrollPosition(); + QVERIFY(qtwebkit_webframe_scrollRecursively(webPage->mainFrame(), 5, 5)); + QVERIFY(childScrollPosition == children.at(0)->scrollPosition()); + QVERIFY(scrollPosition == webPage->mainFrame()->scrollPosition()); + + // 4th test + // call scrollRecursively twice over childs iframe + // verify scrolled == true first time + // verify parent's scroll == true second time + // verify parent and childs scroll position changed + childScrollPosition = children.at(0)->scrollPosition(); + QVERIFY(qtwebkit_webframe_scrollRecursively(children.at(0), -10, -10)); + QVERIFY(childScrollPosition != children.at(0)->scrollPosition()); + scrollPosition = webPage->mainFrame()->scrollPosition(); + QVERIFY(qtwebkit_webframe_scrollRecursively(children.at(0), -10, -10)); + QVERIFY(scrollPosition != webPage->mainFrame()->scrollPosition()); + +} + QTEST_MAIN(tst_QWebFrame) #include "tst_qwebframe.moc" |