Changeset 148302 in webkit


Ignore:
Timestamp:
Apr 12, 2013 1:44:38 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] Enable selecting text in single line input field without selection point being actually on the targeted text vertically
https://bugs.webkit.org/show_bug.cgi?id=114515

Patch by Yongxin Dai <yodai@rim.com> on 2013-04-12
Reviewed by Rob Buis.

PR #317924.
Internally reviewed by Mike Fenton.

It was still hard to select text in URL bar with an inverted selection handle.
We improve the issue by replacing the Y coordinate of selection point with Y
coordinate of start caret for single line input filed. Thus, the Y coordinate
is always valid regardless of the actual location of the selection handle.

  • WebKitSupport/SelectionHandler.cpp:

(BlackBerry::WebKit::SelectionHandler::setSelection):
(BlackBerry::WebKit::SelectionHandler::startCaretViewportRect):
(WebKit):
(BlackBerry::WebKit::SelectionHandler::caretPositionChanged):

  • WebKitSupport/SelectionHandler.h:

(SelectionHandler):

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/ChangeLog

    r148277 r148302  
     12013-04-12  Yongxin Dai  <yodai@rim.com>
     2
     3        [BlackBerry] Enable selecting text in single line input field without selection point being actually on the targeted text vertically
     4        https://bugs.webkit.org/show_bug.cgi?id=114515
     5
     6        Reviewed by Rob Buis.
     7
     8        PR #317924.
     9        Internally reviewed by Mike Fenton.
     10
     11        It was still hard to select text in URL bar with an inverted selection handle.
     12        We improve the issue by replacing the Y coordinate of selection point with Y
     13        coordinate of start caret for single line input filed. Thus, the Y coordinate
     14        is always valid regardless of the actual location of the selection handle.
     15
     16        * WebKitSupport/SelectionHandler.cpp:
     17        (BlackBerry::WebKit::SelectionHandler::setSelection):
     18        (BlackBerry::WebKit::SelectionHandler::startCaretViewportRect):
     19        (WebKit):
     20        (BlackBerry::WebKit::SelectionHandler::caretPositionChanged):
     21        * WebKitSupport/SelectionHandler.h:
     22        (SelectionHandler):
     23
    1242013-04-12  Carlos Garcia Campos  <cgarcia@igalia.com>
    225
  • trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp

    r147497 r148302  
    477477}
    478478
    479 void SelectionHandler::setSelection(const WebCore::IntPoint& start, const WebCore::IntPoint& end)
     479void SelectionHandler::setSelection(WebCore::IntPoint start, WebCore::IntPoint end)
    480480{
    481481    m_selectionActive = true;
     
    504504    // At least one of the locations must be valid.
    505505    ASSERT(startIsValid || m_lastUpdatedEndPointIsValid);
     506
     507    if (m_webPage->m_inputHandler->isInputMode() && !m_webPage->m_inputHandler->isMultilineInputMode()) {
     508        WebCore::IntRect caret(startCaretViewportRect(m_webPage->frameOffset(focusedFrame)));
     509        if (!caret.isEmpty()) {
     510            int centerOfCaretY = caret.center().y();
     511            if (startIsValid)
     512                start.setY(centerOfCaretY);
     513            if (m_lastUpdatedEndPointIsValid)
     514                end.setY(centerOfCaretY);
     515        }
     516    }
    506517
    507518    WebCore::IntPoint relativeStart = start;
     
    622633    }
    623634    return false;
     635}
     636
     637WebCore::IntRect SelectionHandler::startCaretViewportRect(const WebCore::IntPoint& frameOffset) const
     638{
     639    WebCore::IntRect caretRect;
     640    Frame* frame = m_webPage->focusedOrMainFrame();
     641    if (!frame)
     642        return caretRect;
     643
     644    if (frame->selection()->selectionType() != VisibleSelection::NoSelection) {
     645        caretRect = frame->selection()->selection().visibleStart().absoluteCaretBounds();
     646        caretRect.moveBy(frameOffset);
     647    }
     648
     649    return caretRect;
    624650}
    625651
     
    12751301    ASSERT(m_webPage->m_inputHandler->isInputMode());
    12761302
     1303    WebCore::IntRect clippingRectForContent(clippingRectForVisibleContent());
    12771304    WebCore::IntPoint frameOffset(m_webPage->frameOffset(m_webPage->focusedOrMainFrame()));
    1278     WebCore::IntRect clippingRectForContent(clippingRectForVisibleContent());
    12791305    if (m_webPage->focusedOrMainFrame()->selection()->selectionType() == VisibleSelection::CaretSelection) {
    1280         caretLocation = m_webPage->focusedOrMainFrame()->selection()->selection().visibleStart().absoluteCaretBounds();
    1281         caretLocation.move(frameOffset.x(), frameOffset.y());
    1282 
    1283         // Clip against the containing frame and node boundaries.
    1284         caretLocation.intersect(clippingRectForContent);
     1306        caretLocation = startCaretViewportRect(frameOffset);
     1307        if (!caretLocation.isEmpty())
     1308            caretLocation.intersect(clippingRectForContent); // Clip against the containing frame and node boundaries.
    12851309    }
    12861310
     
    12951319
    12961320    if (!nodeBoundingBox.isEmpty()) {
    1297         nodeBoundingBox.move(frameOffset.x(), frameOffset.y());
     1321        nodeBoundingBox.moveBy(frameOffset);
    12981322
    12991323        // Clip against the containing frame and node boundaries.
  • trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h

    r145720 r148302  
    6464    bool selectionContains(const WebCore::IntPoint&);
    6565
    66     void setSelection(const WebCore::IntPoint& start, const WebCore::IntPoint& end);
     66    void setSelection(WebCore::IntPoint start, WebCore::IntPoint end);
    6767    void selectAtPoint(const WebCore::IntPoint&, SelectionExpansionType);
    6868    void selectObject(const WebCore::IntPoint&, WebCore::TextGranularity);
     
    108108    bool selectNodeIfFatFingersResultIsLink(FatFingersResult);
    109109
     110    WebCore::IntRect startCaretViewportRect(const WebCore::IntPoint& frameOffset) const;
     111
    110112    WebPagePrivate* m_webPage;
    111113
Note: See TracChangeset for help on using the changeset viewer.