[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

commit-queue at webkit.org commit-queue at webkit.org
Fri Jan 21 14:37:52 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit 6243bd91aac6a76ae7a517aaabae4807a0cd26d1
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 23 16:23:24 2010 +0000

    2010-12-23  Dawit Alemayehu  <adawit at kde.org>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [Qt] Add a 'hasSelection' function to QWebView and QWebPage.
            https://bugs.webkit.org/show_bug.cgi?id=48722
    
            This is a convenience API that optimizes the case where checking for
            the presence of selected content and accessing the selected content
            are two separate actions in the client. See comment #12 in the above
            bug report link for details.
    
            * Api/qwebpage.cpp:
            (QWebPage::hasSelection):
            * Api/qwebpage.h:
            * Api/qwebview.cpp:
            (QWebView::hasSelection):
            * Api/qwebview.h:
            * tests/qwebpage/tst_qwebpage.cpp:
            (tst_QWebPage::textSelection):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74558 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp
index e82bd45..f0124b8 100644
--- a/WebKit/qt/Api/qwebpage.cpp
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -2624,6 +2624,21 @@ bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &
 }
 
 /*!
+    \property QWebPage::hasSelection
+    \brief whether this page contains selected content or not.
+
+    \sa selectionChanged()
+*/
+bool QWebPage::hasSelection() const
+{
+    d->createMainFrame();
+    WebCore::Frame* frame = d->page->focusController()->focusedOrMainFrame();
+    if (frame)
+        return (frame->selection()->selection().selectionType() != VisibleSelection::NoSelection);
+    return false;
+}
+
+/*!
     \property QWebPage::selectedText
     \brief the text currently selected
 
diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h
index 1e0b3b7..d828f17 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(bool hasSelection READ hasSelection)
     Q_PROPERTY(QSize viewportSize READ viewportSize WRITE setViewportSize)
     Q_PROPERTY(QSize preferredContentsSize READ preferredContentsSize WRITE setPreferredContentsSize)
     Q_PROPERTY(bool forwardUnsupportedContent READ forwardUnsupportedContent WRITE setForwardUnsupportedContent)
@@ -268,6 +269,7 @@ public:
     quint64 totalBytes() const;
     quint64 bytesReceived() const;
 
+    bool hasSelection() const;
     QString selectedText() const;
 
 #ifndef QT_NO_ACTION
diff --git a/WebKit/qt/Api/qwebview.cpp b/WebKit/qt/Api/qwebview.cpp
index 31ee521..0b60625 100644
--- a/WebKit/qt/Api/qwebview.cpp
+++ b/WebKit/qt/Api/qwebview.cpp
@@ -572,6 +572,21 @@ QIcon QWebView::icon() const
 }
 
 /*!
+    \property QWebView::hasSelection
+    \brief whether this page contains selected content or not.
+
+    By default, this property is false.
+
+    \sa selectionChanged()
+*/
+bool QWebView::hasSelection() const
+{
+    if (d->page)
+        return d->page->hasSelection();
+    return false;
+}
+
+/*!
     \property QWebView::selectedText
     \brief the text currently selected
 
diff --git a/WebKit/qt/Api/qwebview.h b/WebKit/qt/Api/qwebview.h
index 1d651d5..d90fa3e 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(bool hasSelection READ hasSelection)
     Q_PROPERTY(bool modified READ isModified)
     //Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
     Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false)
@@ -73,6 +74,7 @@ public:
     QUrl url() const;
     QIcon icon() const;
 
+    bool hasSelection() const;
     QString selectedText() const;
 
 #ifndef QT_NO_ACTION
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 7016d6c..0044784 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,24 @@
+2010-12-23  Dawit Alemayehu  <adawit at kde.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Add a 'hasSelection' function to QWebView and QWebPage.
+        https://bugs.webkit.org/show_bug.cgi?id=48722
+
+        This is a convenience API that optimizes the case where checking for
+        the presence of selected content and accessing the selected content
+        are two separate actions in the client. See comment #12 in the above
+        bug report link for details.
+
+        * Api/qwebpage.cpp:
+        (QWebPage::hasSelection):
+        * Api/qwebpage.h:
+        * Api/qwebview.cpp:
+        (QWebView::hasSelection):
+        * Api/qwebview.h:
+        * tests/qwebpage/tst_qwebpage.cpp:
+        (tst_QWebPage::textSelection):
+
 2010-12-20  Benjamin Poulain  <benjamin.poulain at nokia.com>
 
         Reviewed by Andreas Kling.
diff --git a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
index 4645a06..8d3921c 100644
--- a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -1099,6 +1099,9 @@ void tst_QWebPage::textSelection()
     // ..but SelectAll is awalys enabled
     QCOMPARE(page->action(QWebPage::SelectAll)->isEnabled(), true);
 
+    // Verify hasSelection returns false since there is no selection yet...
+    QCOMPARE(page->hasSelection(), false);
+
     // this will select the first paragraph
     QString selectScript = "var range = document.createRange(); " \
         "var node = document.getElementById(\"one\"); " \
@@ -1107,6 +1110,9 @@ void tst_QWebPage::textSelection()
     page->mainFrame()->evaluateJavaScript(selectScript);
     QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox"));
 
+    // Make sure hasSelection returns true, since there is selected text now...
+    QCOMPARE(page->hasSelection(), true);
+
     // here the actions are enabled after a selection has been created
     QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), true);
     QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), true);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list