- Revision
- 143461
- Author
- commit-qu...@webkit.org
- Date
- 2013-02-20 07:24:26 -0800 (Wed, 20 Feb 2013)
Log Message
[BlackBerry] Read "data-blackberry-text-selection-handle-position" attribute from element
https://bugs.webkit.org/show_bug.cgi?id=110235
Patch by Yongxin Dai <yo...@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):
Modified Paths
Diff
Modified: trunk/Source/WebKit/blackberry/Api/WebPageClient.h (143460 => 143461)
--- trunk/Source/WebKit/blackberry/Api/WebPageClient.h 2013-02-20 15:04:51 UTC (rev 143460)
+++ trunk/Source/WebKit/blackberry/Api/WebPageClient.h 2013-02-20 15:24:26 UTC (rev 143461)
@@ -153,7 +153,7 @@
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;
Modified: trunk/Source/WebKit/blackberry/ChangeLog (143460 => 143461)
--- trunk/Source/WebKit/blackberry/ChangeLog 2013-02-20 15:04:51 UTC (rev 143460)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2013-02-20 15:24:26 UTC (rev 143461)
@@ -1,3 +1,32 @@
+2013-02-20 Yongxin Dai <yo...@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 <albgar...@rim.com>
[BlackBerry] Fix usage of HitTestRequest::RequestType
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp (143460 => 143461)
--- trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp 2013-02-20 15:04:51 UTC (rev 143460)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp 2013-02-20 15:24:26 UTC (rev 143461)
@@ -601,6 +601,50 @@
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
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h (143460 => 143461)
--- trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h 2013-02-20 15:04:51 UTC (rev 143460)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h 2013-02-20 15:24:26 UTC (rev 143461)
@@ -22,6 +22,7 @@
#include "IntPoint.h"
#include "IntRect.h"
+#include <BlackBerryPlatformInputEvents.h>
#include <wtf/Vector.h>
namespace WTF {
@@ -101,6 +102,9 @@
bool isFixedPositionOrHasFixedPositionAncestor(WebCore::RenderObject*);
+WebCore::Element* selectionContainerElement(const WebCore::VisibleSelection&);
+BlackBerry::Platform::RequestedHandlePosition elementHandlePositionAttribute(const WebCore::Element*);
+
} // DOMSupport
} // WebKit
} // BlackBerry
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp (143460 => 143461)
--- trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp 2013-02-20 15:04:51 UTC (rev 143460)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp 2013-02-20 15:24:26 UTC (rev 143461)
@@ -892,6 +892,12 @@
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 @@
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());
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h (143460 => 143461)
--- trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h 2013-02-20 15:04:51 UTC (rev 143460)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h 2013-02-20 15:24:26 UTC (rev 143461)
@@ -89,6 +89,7 @@
WebCore::IntPoint clipPointToVisibleContainer(const WebCore::IntPoint&) const;
bool inputNodeOverridesTouch() const;
+ BlackBerry::Platform::RequestedHandlePosition requestedSelectionHandlePosition(const WebCore::VisibleSelection&) const;
bool selectNodeIfFatFingersResultIsLink(FatFingersResult);