Changeset 142011 in webkit


Ignore:
Timestamp:
Feb 6, 2013 11:07:27 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[Chromium] WebWidget should expose a way to determine the start/end of the selection bounds
https://bugs.webkit.org/show_bug.cgi?id=108667

Patch by Chris Hopman <cjhopman@chromium.org> on 2013-02-06
Reviewed by Darin Fisher.

WebWidget::selectionBounds() returns the anchor and focus of the
selection. This matches the arguments to WebFrame::selectRange().
Add WebWidget::isSelectionAnchorFirst so that a caller can convert the
anchor/focus to start/end.

  • public/WebWidget.h:

(WebWidget):
(WebKit::WebWidget::isSelectionAnchorFirst):

  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::isSelectionAnchorFirst):
(WebKit):

  • src/WebViewImpl.h:
  • tests/WebViewTest.cpp:
Location:
trunk/Source/WebKit/chromium
Files:
5 edited

Legend:

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

    r142008 r142011  
     12013-02-06  Chris Hopman  <cjhopman@chromium.org>
     2
     3        [Chromium] WebWidget should expose a way to determine the start/end of the selection bounds
     4        https://bugs.webkit.org/show_bug.cgi?id=108667
     5
     6        Reviewed by Darin Fisher.
     7
     8        WebWidget::selectionBounds() returns the anchor and focus of the
     9        selection. This matches the arguments to WebFrame::selectRange().
     10        Add WebWidget::isSelectionAnchorFirst so that a caller can convert the
     11        anchor/focus to start/end.
     12
     13        * public/WebWidget.h:
     14        (WebWidget):
     15        (WebKit::WebWidget::isSelectionAnchorFirst):
     16        * src/WebViewImpl.cpp:
     17        (WebKit::WebViewImpl::isSelectionAnchorFirst):
     18        (WebKit):
     19        * src/WebViewImpl.h:
     20        * tests/WebViewTest.cpp:
     21
    1222013-02-06  Alec Flett  <alecflett@chromium.org>
    223
  • trunk/Source/WebKit/chromium/public/WebWidget.h

    r141428 r142011  
    199199    virtual bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const { return false; }
    200200
     201    // Returns true if the selection range is nonempty and its anchor is first
     202    // (i.e its anchor is its start).
     203    virtual bool isSelectionAnchorFirst() const { return false; }
     204
    201205    // Fetch the current selection range of this WebWidget. If there is no
    202206    // selection, it will output a 0-length range with the location at the
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r141657 r142011  
    24192419}
    24202420
     2421bool WebViewImpl::isSelectionAnchorFirst() const
     2422{
     2423    const Frame* frame = focusedWebCoreFrame();
     2424    if (!frame)
     2425        return false;
     2426    FrameSelection* selection = frame->selection();
     2427    if (!selection)
     2428        return false;
     2429    return selection->selection().isBaseFirst();
     2430}
     2431
    24212432bool WebViewImpl::setEditableSelectionOffsets(int start, int end)
    24222433{
  • trunk/Source/WebKit/chromium/src/WebViewImpl.h

    r141483 r142011  
    173173    virtual bool selectionBounds(WebRect& anchor, WebRect& focus) const;
    174174    virtual bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const;
     175    virtual bool isSelectionAnchorFirst() const;
    175176    virtual bool caretOrSelectionRange(size_t* location, size_t* length);
    176177    virtual void setTextDirection(WebTextDirection direction);
  • trunk/Source/WebKit/chromium/tests/WebViewTest.cpp

    r141540 r142011  
    457457}
    458458
     459TEST_F(WebViewTest, IsSelectionAnchorFirst)
     460{
     461    URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html"));
     462    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_populated.html");
     463    WebFrame* frame = webView->mainFrame();
     464
     465    webView->setInitialFocus(false);
     466    webView->setEditableSelectionOffsets(4, 10);
     467    EXPECT_TRUE(webView->isSelectionAnchorFirst());
     468    WebRect anchor;
     469    WebRect focus;
     470    webView->selectionBounds(anchor, focus);
     471    frame->selectRange(WebPoint(focus.x, focus.y), WebPoint(anchor.x, anchor.y));
     472    EXPECT_FALSE(webView->isSelectionAnchorFirst());
     473    webView->close();
     474}
     475
    459476TEST_F(WebViewTest, ResetScrollAndScaleState)
    460477{
Note: See TracChangeset for help on using the changeset viewer.