Changeset 143461 in webkit


Ignore:
Timestamp:
Feb 20, 2013 7:24:26 AM (11 years ago)
Author:
commit-queue@webkit.org
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 <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):

Location:
trunk/Source/WebKit/blackberry
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/Api/WebPageClient.h

    r142482 r143461  
    154154    virtual int32_t checkSpellingOfStringAsync(wchar_t* text, const unsigned length) = 0;
    155155
    156     virtual void notifySelectionDetailsChanged(const Platform::IntRect& documentStartRect, const Platform::IntRect& documentEndRect, const Platform::IntRectRegion& documentRegion, bool overrideTouchHandling = false) = 0;
     156    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;
    157157    virtual void cancelSelectionVisuals() = 0;
    158158    virtual void notifySelectionHandlesReversed() = 0;
  • trunk/Source/WebKit/blackberry/ChangeLog

    r143460 r143461  
     12013-02-20  Yongxin Dai  <yodai@rim.com>
     2
     3        [BlackBerry] Read "data-blackberry-text-selection-handle-position" attribute from element
     4        https://bugs.webkit.org/show_bug.cgi?id=110235
     5
     6        Reviewed by Yong Li.
     7
     8        PR #257207.
     9
     10        Read "data-blackberry-text-selection-handle-position" attribute from element and pass it along
     11        with notifySelectionDetailsChanged(). If "data-blackberry-text-selection-handle-position" attribute
     12        is specified in the element, the selection handle is always flipped to the required position.
     13        along with selected text within element.
     14
     15        Reviewed Internally by Mike Fenton.
     16
     17        * Api/WebPageClient.h:
     18        * WebKitSupport/DOMSupport.cpp:
     19        (BlackBerry::WebKit::DOMSupport::selectionContainerElement):
     20        (DOMSupport):
     21        (BlackBerry::WebKit::DOMSupport::elementHandlePositionAttribute):
     22        * WebKitSupport/DOMSupport.h:
     23        * WebKitSupport/SelectionHandler.cpp:
     24        (BlackBerry::WebKit::SelectionHandler::requestedSelectionHandlePosition):
     25        (WebKit):
     26        (BlackBerry::WebKit::SelectionHandler::selectionPositionChanged):
     27        * WebKitSupport/SelectionHandler.h:
     28        (SelectionHandler):
     29
    1302013-02-20  Alberto Garcia  <albgarcia@rim.com>
    231
  • trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp

    r143391 r143461  
    602602}
    603603
     604Element* selectionContainerElement(const VisibleSelection& selection)
     605{
     606    if (!selection.isRange())
     607        return 0;
     608
     609    Node* startContainer = 0;
     610    if (selection.firstRange())
     611        startContainer = selection.firstRange()->startContainer();
     612
     613    if (!startContainer)
     614        return 0;
     615
     616    Element* element = 0;
     617    if (startContainer->isInShadowTree())
     618        element = startContainer->shadowHost();
     619    else if (startContainer->isElementNode())
     620        element = static_cast<Element*>(startContainer);
     621    else
     622        element = startContainer->parentElement();
     623
     624    return element;
     625}
     626
     627BlackBerry::Platform::RequestedHandlePosition elementHandlePositionAttribute(const WebCore::Element* element)
     628{
     629    BlackBerry::Platform::RequestedHandlePosition position = BlackBerry::Platform::SmartPlacement;
     630    if (!element)
     631        return position;
     632
     633    DEFINE_STATIC_LOCAL(QualifiedName, qualifiedAttrNameForHandlePosition, (nullAtom, "data-blackberry-text-selection-handle-position", nullAtom));
     634    AtomicString attributeString;
     635    if (element->fastHasAttribute(qualifiedAttrNameForHandlePosition))
     636        attributeString = element->fastGetAttribute(qualifiedAttrNameForHandlePosition);
     637
     638    if (attributeString.isNull() || attributeString.isEmpty())
     639        return position;
     640
     641    if (equalIgnoringCase(attributeString, "above"))
     642        position = BlackBerry::Platform::Above;
     643    else if (equalIgnoringCase(attributeString, "below"))
     644        position = BlackBerry::Platform::Below;
     645    return position;
     646}
     647
    604648} // DOMSupport
    605649} // WebKit
  • trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h

    r143391 r143461  
    2323#include "IntRect.h"
    2424
     25#include <BlackBerryPlatformInputEvents.h>
    2526#include <wtf/Vector.h>
    2627
     
    102103bool isFixedPositionOrHasFixedPositionAncestor(WebCore::RenderObject*);
    103104
     105WebCore::Element* selectionContainerElement(const WebCore::VisibleSelection&);
     106BlackBerry::Platform::RequestedHandlePosition elementHandlePositionAttribute(const WebCore::Element*);
     107
    104108} // DOMSupport
    105109} // WebKit
  • trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp

    r142977 r143461  
    893893}
    894894
     895RequestedHandlePosition SelectionHandler::requestedSelectionHandlePosition(const VisibleSelection& selection) const
     896{
     897    Element* element = DOMSupport::selectionContainerElement(selection);
     898    return DOMSupport::elementHandlePositionAttribute(element);
     899}
     900
    895901// Note: This is the only function in SelectionHandler in which the coordinate
    896902// system is not entirely WebKit.
     
    10141020        m_webPage->m_selectionOverlay->draw(visibleSelectionRegion);
    10151021
    1016     m_webPage->m_client->notifySelectionDetailsChanged(startCaret, endCaret, visibleSelectionRegion, inputNodeOverridesTouch());
     1022    m_webPage->m_client->notifySelectionDetailsChanged(startCaret, endCaret, visibleSelectionRegion, inputNodeOverridesTouch(), requestedSelectionHandlePosition(frame->selection()->selection()));
    10171023    SelectionTimingLog(Platform::LogLevelInfo,
    10181024        "SelectionHandler::selectionPositionChanged completed at %f",
  • trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h

    r142120 r143461  
    9090
    9191    bool inputNodeOverridesTouch() const;
     92    BlackBerry::Platform::RequestedHandlePosition requestedSelectionHandlePosition(const WebCore::VisibleSelection&) const;
    9293
    9394    bool selectNodeIfFatFingersResultIsLink(FatFingersResult);
Note: See TracChangeset for help on using the changeset viewer.