Add special attribute for alternate selection touch handling.
authormifenton@rim.com <mifenton@rim.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 May 2012 15:32:53 +0000 (15:32 +0000)
committermifenton@rim.com <mifenton@rim.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 May 2012 15:32:53 +0000 (15:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=85284

Reviewed by Antonio Gomes.

PR 152975.

.:

Add manual test for -bb-selection-touchoverride.

Reviewed Internally by Gen Mak.

* ManualTests/blackberry/selection-touch-override.html: Added.

Source/WebKit/blackberry:

Add attribute -bb-selection-touchoverride to override
touch handling on selection overlay.

Reviewed Internally by Gen Mak.

* Api/WebPageClient.h:
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::SelectionHandler::inputNodeOverridesTouch):
(WebKit):
(BlackBerry::WebKit::SelectionHandler::selectionPositionChanged):
* WebKitSupport/SelectionHandler.h:
(SelectionHandler):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@115728 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
ManualTests/blackberry/selection-touch-override.html [new file with mode: 0644]
Source/WebKit/blackberry/Api/WebPageClient.h
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h

index aa2937e..af6dddf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2012-05-01  Mike Fenton  <mifenton@rim.com>
+
+        Add special attribute for alternate selection touch handling.
+        https://bugs.webkit.org/show_bug.cgi?id=85284
+
+        Reviewed by Antonio Gomes.
+
+        PR 152975.
+
+        Add manual test for -bb-selection-touchoverride.
+
+        Reviewed Internally by Gen Mak.
+
+        * ManualTests/blackberry/selection-touch-override.html: Added.
+
 2012-04-25  Raphael Kubo da Costa  <rakuco@webkit.org>
 
         [CMake] Add a proper license to FindSqlite.cmake.
diff --git a/ManualTests/blackberry/selection-touch-override.html b/ManualTests/blackberry/selection-touch-override.html
new file mode 100644 (file)
index 0000000..d1256f2
--- /dev/null
@@ -0,0 +1,2 @@
+<br><textarea cols="45" rows="5">Text Area without override attribute select all this text and tap on the selection, context menu should be shown!</textarea>
+<br><textarea cols="45" rows="5" -bb-selection-touchoverride="on">Text Area with override attribute select all this text and tap on the selection, caret should be placed!</textarea>
index e123568..3296609 100644 (file)
@@ -146,7 +146,7 @@ public:
     virtual void checkSpellingOfString(const unsigned short* text, int length, int& misspellingLocation, int& misspellingLength) = 0;
     virtual void requestSpellingSuggestionsForString(unsigned start, unsigned end) = 0;
 
-    virtual void notifySelectionDetailsChanged(const Platform::IntRect& start, const Platform::IntRect& end, const Platform::IntRectRegion&) = 0;
+    virtual void notifySelectionDetailsChanged(const Platform::IntRect& start, const Platform::IntRect& end, const Platform::IntRectRegion&, bool overrideTouchHandling = false) = 0;
     virtual void cancelSelectionVisuals() = 0;
     virtual void notifySelectionHandlesReversed() = 0;
     virtual void notifyCaretChanged(const Platform::IntRect& caret, bool userTouchTriggered, bool singleLineInput = false, const Platform::IntRect& singleLineBoundingBox = Platform::IntRect()) = 0;
index 61de1a9..6592109 100644 (file)
@@ -1,3 +1,25 @@
+2012-05-01  Mike Fenton  <mifenton@rim.com>
+
+        Add special attribute for alternate selection touch handling.
+        https://bugs.webkit.org/show_bug.cgi?id=85284
+
+        Reviewed by Antonio Gomes.
+
+        PR 152975.
+
+        Add attribute -bb-selection-touchoverride to override
+        touch handling on selection overlay.
+
+        Reviewed Internally by Gen Mak.
+
+        * Api/WebPageClient.h:
+        * WebKitSupport/SelectionHandler.cpp:
+        (BlackBerry::WebKit::SelectionHandler::inputNodeOverridesTouch):
+        (WebKit):
+        (BlackBerry::WebKit::SelectionHandler::selectionPositionChanged):
+        * WebKitSupport/SelectionHandler.h:
+        (SelectionHandler):
+
 2012-04-30  Benjamin Poulain  <benjamin@webkit.org>
 
         Add String::startsWith() and endsWith() for string literals
index b114abe..5456f7c 100644 (file)
@@ -817,6 +817,21 @@ static bool regionRectListContainsPoint(const IntRectRegion& region, const WebCo
     return false;
 }
 
+bool SelectionHandler::inputNodeOverridesTouch() const
+{
+    if (!m_webPage->m_inputHandler->isInputMode())
+        return false;
+
+    Node* focusedNode = m_webPage->focusedOrMainFrame()->document()->focusedNode();
+    if (!focusedNode || !focusedNode->isElementNode())
+        return false;
+
+    // TODO consider caching this in InputHandler so it is only calculated once per focus.
+    DEFINE_STATIC_LOCAL(QualifiedName, selectionTouchOverrideAttr, (nullAtom, "-bb-selection-touchoverride", nullAtom));
+    Element* element = static_cast<Element*>(focusedNode);
+    return DOMSupport::elementAttributeState(element, selectionTouchOverrideAttr) == DOMSupport::On;
+}
+
 // Note: This is the only function in SelectionHandler in which the coordinate
 // system is not entirely WebKit.
 void SelectionHandler::selectionPositionChanged(bool visualChangeOnly)
@@ -918,7 +933,7 @@ void SelectionHandler::selectionPositionChanged(bool visualChangeOnly)
                     startCaret.x(), startCaret.y(), startCaret.width(), startCaret.height(), endCaret.x(), endCaret.y(), endCaret.width(), endCaret.height());
 
 
-    m_webPage->m_client->notifySelectionDetailsChanged(startCaret, endCaret, visibleSelectionRegion);
+    m_webPage->m_client->notifySelectionDetailsChanged(startCaret, endCaret, visibleSelectionRegion, inputNodeOverridesTouch());
 }
 
 // NOTE: This function is not in WebKit coordinates.
index 3d668ea..f72af44 100644 (file)
@@ -81,6 +81,8 @@ private:
     unsigned short extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, WebCore::VisibleSelection& newSelection);
     WebCore::IntPoint clipPointToVisibleContainer(const WebCore::IntPoint&) const;
 
+    bool inputNodeOverridesTouch() const;
+
     WebPagePrivate* m_webPage;
 
     bool m_selectionActive;