[BlackBerry] Read "data-blackberry-text-selection-handle-position" attribute from...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2013 15:24:26 +0000 (15:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2013 15:24:26 +0000 (15:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=110235

Patch by Yongxin Dai <yodai@rim.com> on 2013-02-20
Reviewed by Yong Li.

PR #257207.

Read "data-blackberry-text-selection-handle-position" attribute from element and pass it along
with notifySelectionDetailsChanged(). If "data-blackberry-text-selection-handle-position" attribute
is specified in the element, the selection handle is always flipped to the required position.
along with selected text within element.

Reviewed Internally by Mike Fenton.

* Api/WebPageClient.h:
* WebKitSupport/DOMSupport.cpp:
(BlackBerry::WebKit::DOMSupport::selectionContainerElement):
(DOMSupport):
(BlackBerry::WebKit::DOMSupport::elementHandlePositionAttribute):
* WebKitSupport/DOMSupport.h:
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::SelectionHandler::requestedSelectionHandlePosition):
(WebKit):
(BlackBerry::WebKit::SelectionHandler::selectionPositionChanged):
* WebKitSupport/SelectionHandler.h:
(SelectionHandler):

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

Source/WebKit/blackberry/Api/WebPageClient.h
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp
Source/WebKit/blackberry/WebKitSupport/DOMSupport.h
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h

index 1f83f1e3fb9371123844e2aedb9d058359bdc8a0..024a765d97e9e52078be4c5f111b79b5a10d18ca 100644 (file)
@@ -153,7 +153,7 @@ public:
     virtual void requestSpellingCheckingOptions(imf_sp_text_t&, const BlackBerry::Platform::IntRect& documentCaretRect, const BlackBerry::Platform::IntSize& screenOffset, const bool shouldMoveDialog) = 0;
     virtual int32_t checkSpellingOfStringAsync(wchar_t* text, const unsigned length) = 0;
 
-    virtual void notifySelectionDetailsChanged(const Platform::IntRect& documentStartRect, const Platform::IntRect& documentEndRect, const Platform::IntRectRegion& documentRegion, bool overrideTouchHandling = false) = 0;
+    virtual void notifySelectionDetailsChanged(const Platform::IntRect& documentStartRect, const Platform::IntRect& documentEndRect, const Platform::IntRectRegion& documentRegion, bool overrideTouchHandling = false, BlackBerry::Platform::RequestedHandlePosition = BlackBerry::Platform::SmartPlacement) = 0;
     virtual void cancelSelectionVisuals() = 0;
     virtual void notifySelectionHandlesReversed() = 0;
     virtual void notifyCaretChanged(const Platform::IntRect& documentCaretRect, bool userTouchTriggered, bool isSingleLineInput = false, const Platform::IntRect& singleLineDocumentBoundingBox = Platform::IntRect(), bool textFieldIsEmpty = false) = 0;
index 900ae427fd60517c9ea419f52a5d36ed27160193..d191fa57e31a93054e15120fd6e8a62a98e36b9e 100644 (file)
@@ -1,3 +1,32 @@
+2013-02-20  Yongxin Dai  <yodai@rim.com>
+
+        [BlackBerry] Read "data-blackberry-text-selection-handle-position" attribute from element
+        https://bugs.webkit.org/show_bug.cgi?id=110235
+
+        Reviewed by Yong Li.
+
+        PR #257207.
+
+        Read "data-blackberry-text-selection-handle-position" attribute from element and pass it along
+        with notifySelectionDetailsChanged(). If "data-blackberry-text-selection-handle-position" attribute
+        is specified in the element, the selection handle is always flipped to the required position.
+        along with selected text within element.
+
+        Reviewed Internally by Mike Fenton.
+
+        * Api/WebPageClient.h:
+        * WebKitSupport/DOMSupport.cpp:
+        (BlackBerry::WebKit::DOMSupport::selectionContainerElement):
+        (DOMSupport):
+        (BlackBerry::WebKit::DOMSupport::elementHandlePositionAttribute):
+        * WebKitSupport/DOMSupport.h:
+        * WebKitSupport/SelectionHandler.cpp:
+        (BlackBerry::WebKit::SelectionHandler::requestedSelectionHandlePosition):
+        (WebKit):
+        (BlackBerry::WebKit::SelectionHandler::selectionPositionChanged):
+        * WebKitSupport/SelectionHandler.h:
+        (SelectionHandler):
+
 2013-02-20  Alberto Garcia  <albgarcia@rim.com>
 
         [BlackBerry] Fix usage of HitTestRequest::RequestType
index 3510d889e98d4f3b1aeb98372280ec10674ce405..bdae8214e8de8de7eb22d928acbe805242f513a9 100644 (file)
@@ -601,6 +601,50 @@ bool isFixedPositionOrHasFixedPositionAncestor(RenderObject* renderer)
     return false;
 }
 
+Element* selectionContainerElement(const VisibleSelection& selection)
+{
+    if (!selection.isRange())
+        return 0;
+
+    Node* startContainer = 0;
+    if (selection.firstRange())
+        startContainer = selection.firstRange()->startContainer();
+
+    if (!startContainer)
+        return 0;
+
+    Element* element = 0;
+    if (startContainer->isInShadowTree())
+        element = startContainer->shadowHost();
+    else if (startContainer->isElementNode())
+        element = static_cast<Element*>(startContainer);
+    else
+        element = startContainer->parentElement();
+
+    return element;
+}
+
+BlackBerry::Platform::RequestedHandlePosition elementHandlePositionAttribute(const WebCore::Element* element)
+{
+    BlackBerry::Platform::RequestedHandlePosition position = BlackBerry::Platform::SmartPlacement;
+    if (!element)
+        return position;
+
+    DEFINE_STATIC_LOCAL(QualifiedName, qualifiedAttrNameForHandlePosition, (nullAtom, "data-blackberry-text-selection-handle-position", nullAtom));
+    AtomicString attributeString;
+    if (element->fastHasAttribute(qualifiedAttrNameForHandlePosition))
+        attributeString = element->fastGetAttribute(qualifiedAttrNameForHandlePosition);
+
+    if (attributeString.isNull() || attributeString.isEmpty())
+        return position;
+
+    if (equalIgnoringCase(attributeString, "above"))
+        position = BlackBerry::Platform::Above;
+    else if (equalIgnoringCase(attributeString, "below"))
+        position = BlackBerry::Platform::Below;
+    return position;
+}
+
 } // DOMSupport
 } // WebKit
 } // BlackBerry
index c8d7c08a86853c7b277b94d261554a45adff8963..fde366e770f7543c30106160d13e9d2dc0a7dcb2 100644 (file)
@@ -22,6 +22,7 @@
 #include "IntPoint.h"
 #include "IntRect.h"
 
+#include <BlackBerryPlatformInputEvents.h>
 #include <wtf/Vector.h>
 
 namespace WTF {
@@ -101,6 +102,9 @@ bool isRangeTextAllWhitespace(WebCore::VisiblePosition startPosition, WebCore::V
 
 bool isFixedPositionOrHasFixedPositionAncestor(WebCore::RenderObject*);
 
+WebCore::Element* selectionContainerElement(const WebCore::VisibleSelection&);
+BlackBerry::Platform::RequestedHandlePosition elementHandlePositionAttribute(const WebCore::Element*);
+
 } // DOMSupport
 } // WebKit
 } // BlackBerry
index a5134d216c28ff61fc7c8748b5ff41d790d23ee3..5e32cc8610b15ee1d6ec4e24658db14b6f929f27 100644 (file)
@@ -892,6 +892,12 @@ bool SelectionHandler::inputNodeOverridesTouch() const
     return DOMSupport::elementAttributeState(element, selectionTouchOverrideAttr) == DOMSupport::On;
 }
 
+RequestedHandlePosition SelectionHandler::requestedSelectionHandlePosition(const VisibleSelection& selection) const
+{
+    Element* element = DOMSupport::selectionContainerElement(selection);
+    return DOMSupport::elementHandlePositionAttribute(element);
+}
+
 // Note: This is the only function in SelectionHandler in which the coordinate
 // system is not entirely WebKit.
 void SelectionHandler::selectionPositionChanged(bool forceUpdateWithoutChange)
@@ -1013,7 +1019,7 @@ void SelectionHandler::selectionPositionChanged(bool forceUpdateWithoutChange)
     if (m_webPage->m_selectionOverlay)
         m_webPage->m_selectionOverlay->draw(visibleSelectionRegion);
 
-    m_webPage->m_client->notifySelectionDetailsChanged(startCaret, endCaret, visibleSelectionRegion, inputNodeOverridesTouch());
+    m_webPage->m_client->notifySelectionDetailsChanged(startCaret, endCaret, visibleSelectionRegion, inputNodeOverridesTouch(), requestedSelectionHandlePosition(frame->selection()->selection()));
     SelectionTimingLog(Platform::LogLevelInfo,
         "SelectionHandler::selectionPositionChanged completed at %f",
         m_timer.elapsed());
index d431573bf7b5e1cec7e83fbea2caf415f3581995..76fc3a17397d944370de00503ccfc46af7ef702f 100644 (file)
@@ -89,6 +89,7 @@ private:
     WebCore::IntPoint clipPointToVisibleContainer(const WebCore::IntPoint&) const;
 
     bool inputNodeOverridesTouch() const;
+    BlackBerry::Platform::RequestedHandlePosition requestedSelectionHandlePosition(const WebCore::VisibleSelection&) const;
 
     bool selectNodeIfFatFingersResultIsLink(FatFingersResult);