[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e
andreas.kling at nokia.com
andreas.kling at nokia.com
Fri Jan 21 15:07:26 UTC 2011
The following commit has been merged in the debian/experimental branch:
commit f493fdee80b1f7be979d8d77f3cb77e93e95d9bd
Author: andreas.kling at nokia.com <andreas.kling at nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Jan 7 13:59:20 2011 +0000
2011-01-07 Andreas Kling <kling at webkit.org>
Reviewed by Adam Barth.
[Qt] Add selectedHtml function to QWebView
https://bugs.webkit.org/show_bug.cgi?id=35028
Add QWebView::selectedHtml() and QWebPage::selectedHtml()
which return the current selection range's HTML representation.
* Api/qwebpage.cpp:
(QWebPage::selectedHtml):
* Api/qwebpage.h:
* Api/qwebview.cpp:
(QWebView::selectedText):
(QWebView::selectedHtml):
* Api/qwebview.h:
* tests/qwebpage/tst_qwebpage.cpp:
(tst_QWebPage::cursorMovements):
(tst_QWebPage::textSelection):
(tst_QWebPage::crashTests_LazyInitializationOfMainFrame):
(tst_QWebPage::findText):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75242 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp
index 483c8b6..eab514b 100644
--- a/WebKit/qt/Api/qwebpage.cpp
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -2650,7 +2650,7 @@ bool QWebPage::hasSelection() const
By default, this property contains an empty string.
- \sa selectionChanged()
+ \sa selectionChanged(), selectedHtml()
*/
QString QWebPage::selectedText() const
{
@@ -2661,6 +2661,21 @@ QString QWebPage::selectedText() const
return frame->editor()->selectedText();
}
+/*!
+ \since 4.8
+ \property QWebPage::selectedHtml
+ \brief the HTML currently selected
+
+ By default, this property contains an empty string.
+
+ \sa selectionChanged(), selectedText()
+*/
+QString QWebPage::selectedHtml() const
+{
+ d->createMainFrame();
+ return d->page->focusController()->focusedOrMainFrame()->editor()->selectedRange()->toHTML();
+}
+
#ifndef QT_NO_ACTION
/*!
Returns a QAction for the specified WebAction \a action.
diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h
index d828f17..b66adb2 100644
--- a/WebKit/qt/Api/qwebpage.h
+++ b/WebKit/qt/Api/qwebpage.h
@@ -72,6 +72,7 @@ class QWEBKIT_EXPORT QWebPage : public QObject {
Q_PROPERTY(bool modified READ isModified)
Q_PROPERTY(QString selectedText READ selectedText)
+ Q_PROPERTY(QString selectedHtml READ selectedHtml)
Q_PROPERTY(bool hasSelection READ hasSelection)
Q_PROPERTY(QSize viewportSize READ viewportSize WRITE setViewportSize)
Q_PROPERTY(QSize preferredContentsSize READ preferredContentsSize WRITE setPreferredContentsSize)
@@ -271,6 +272,7 @@ public:
bool hasSelection() const;
QString selectedText() const;
+ QString selectedHtml() const;
#ifndef QT_NO_ACTION
QAction *action(WebAction action) const;
diff --git a/WebKit/qt/Api/qwebview.cpp b/WebKit/qt/Api/qwebview.cpp
index 0b60625..f4b23f3 100644
--- a/WebKit/qt/Api/qwebview.cpp
+++ b/WebKit/qt/Api/qwebview.cpp
@@ -592,7 +592,7 @@ bool QWebView::hasSelection() const
By default, this property contains an empty string.
- \sa findText(), selectionChanged()
+ \sa findText(), selectionChanged(), selectedHtml()
*/
QString QWebView::selectedText() const
{
@@ -601,6 +601,22 @@ QString QWebView::selectedText() const
return QString();
}
+/*!
+ \since 4.8
+ \property QWebView::selectedHtml
+ \brief the HTML currently selected
+
+ By default, this property contains an empty string.
+
+ \sa findText(), selectionChanged(), selectedText()
+*/
+QString QWebView::selectedHtml() const
+{
+ if (d->page)
+ return d->page->selectedHtml();
+ return QString();
+}
+
#ifndef QT_NO_ACTION
/*!
Returns a pointer to a QAction that encapsulates the specified web action \a action.
diff --git a/WebKit/qt/Api/qwebview.h b/WebKit/qt/Api/qwebview.h
index d90fa3e..8b28f62 100644
--- a/WebKit/qt/Api/qwebview.h
+++ b/WebKit/qt/Api/qwebview.h
@@ -44,6 +44,7 @@ class QWEBKIT_EXPORT QWebView : public QWidget {
Q_PROPERTY(QUrl url READ url WRITE setUrl)
Q_PROPERTY(QIcon icon READ icon)
Q_PROPERTY(QString selectedText READ selectedText)
+ Q_PROPERTY(QString selectedHtml READ selectedHtml)
Q_PROPERTY(bool hasSelection READ hasSelection)
Q_PROPERTY(bool modified READ isModified)
//Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
@@ -76,6 +77,7 @@ public:
bool hasSelection() const;
QString selectedText() const;
+ QString selectedHtml() const;
#ifndef QT_NO_ACTION
QAction* pageAction(QWebPage::WebAction action) const;
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 1c133ab..4298d0e 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,26 @@
+2011-01-07 Andreas Kling <kling at webkit.org>
+
+ Reviewed by Adam Barth.
+
+ [Qt] Add selectedHtml function to QWebView
+ https://bugs.webkit.org/show_bug.cgi?id=35028
+
+ Add QWebView::selectedHtml() and QWebPage::selectedHtml()
+ which return the current selection range's HTML representation.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::selectedHtml):
+ * Api/qwebpage.h:
+ * Api/qwebview.cpp:
+ (QWebView::selectedText):
+ (QWebView::selectedHtml):
+ * Api/qwebview.h:
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::cursorMovements):
+ (tst_QWebPage::textSelection):
+ (tst_QWebPage::crashTests_LazyInitializationOfMainFrame):
+ (tst_QWebPage::findText):
+
2011-01-06 Robert Hogan <robert at webkit.org>
Reviewed by Antonio Gomes.
diff --git a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
index 6cf5b49..b71f665 100644
--- a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -935,6 +935,7 @@ void tst_QWebPage::cursorMovements()
"getSelection().addRange(range);";
page->mainFrame()->evaluateJavaScript(script);
QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox"));
+ QCOMPARE(page->selectedHtml().trimmed(), QString::fromLatin1("<span class=\"Apple-style-span\" style=\"border-collapse: separate; color: rgb(0, 0, 0); font-family: Times; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; \"><p id=\"one\">The quick brown fox</p></span>"));
// these actions must exist
QVERIFY(page->action(QWebPage::MoveToNextChar) != 0);
@@ -1165,6 +1166,7 @@ void tst_QWebPage::textSelection()
"getSelection().addRange(range);";
page->mainFrame()->evaluateJavaScript(selectScript);
QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox"));
+ QCOMPARE(page->selectedHtml().trimmed(), QString::fromLatin1("<span class=\"Apple-style-span\" style=\"border-collapse: separate; color: rgb(0, 0, 0); font-family: Times; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; \"><p id=\"one\">The quick brown fox</p></span>"));
// Make sure hasSelection returns true, since there is selected text now...
QCOMPARE(page->hasSelection(), true);
@@ -2380,6 +2382,10 @@ void tst_QWebPage::crashTests_LazyInitializationOfMainFrame()
}
{
QWebPage webPage;
+ webPage.selectedHtml();
+ }
+ {
+ QWebPage webPage;
webPage.triggerAction(QWebPage::Back, true);
}
{
@@ -2574,14 +2580,18 @@ void tst_QWebPage::findText()
m_view->setHtml(QString("<html><head></head><body><div>foo bar</div></body></html>"));
m_page->triggerAction(QWebPage::SelectAll);
QVERIFY(!m_page->selectedText().isEmpty());
+ QVERIFY(!m_page->selectedHtml().isEmpty());
m_page->findText("");
QVERIFY(m_page->selectedText().isEmpty());
+ QVERIFY(m_page->selectedHtml().isEmpty());
QStringList words = (QStringList() << "foo" << "bar");
foreach (QString subString, words) {
m_page->findText(subString, QWebPage::FindWrapsAroundDocument);
QCOMPARE(m_page->selectedText(), subString);
+ QCOMPARE(m_page->selectedHtml(), QString("<span class=\"Apple-style-span\" style=\"border-collapse: separate; color: rgb(0, 0, 0); font-family: Times; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; \">%1</span>").arg(subString));
m_page->findText("");
QVERIFY(m_page->selectedText().isEmpty());
+ QVERIFY(m_page->selectedHtml().isEmpty());
}
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list