Title: [128903] trunk/Source/WebKit/chromium
Revision
128903
Author
[email protected]
Date
2012-09-18 10:23:37 -0700 (Tue, 18 Sep 2012)

Log Message

[Chromium] Merge moveSelectionStart, moveSelectionEnd, and moveCaret into selectRange
https://bugs.webkit.org/show_bug.cgi?id=96508

Patch by Iain Merrick <[email protected]> on 2012-09-18
Reviewed by Ryosuke Niwa.

These methods had "start" and "end" parameters, but this is incorrect.
selectRange() actually takes base and extent (where the user actually
touched), and selectionBounds() returns anchor and focus (base and extent
expanded to account for the selection granularity).

This patch fixes the parameter names, and updates selectRange, its test
and its documentation to reflect the correct usage. It also removes
moveSelectionStart/moveSelectionEnd/moveCaret (which aren't being used
yet), and updates WebFrameTest to show how these can be implemented via
selectRange.

* public/WebFrame.h:
(WebFrame):
* public/WebWidget.h:
(WebWidget):
(WebKit::WebWidget::selectionBounds):
* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::selectRange):
* src/WebFrameImpl.h:
(WebFrameImpl):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::selectionBounds):
* src/WebViewImpl.h:
(WebViewImpl):
* tests/WebFrameTest.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (128902 => 128903)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-09-18 16:51:26 UTC (rev 128902)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-09-18 17:23:37 UTC (rev 128903)
@@ -1,3 +1,36 @@
+2012-09-18  Iain Merrick  <[email protected]>
+
+        [Chromium] Merge moveSelectionStart, moveSelectionEnd, and moveCaret into selectRange
+        https://bugs.webkit.org/show_bug.cgi?id=96508
+
+        Reviewed by Ryosuke Niwa.
+
+        These methods had "start" and "end" parameters, but this is incorrect.
+        selectRange() actually takes base and extent (where the user actually
+        touched), and selectionBounds() returns anchor and focus (base and extent
+        expanded to account for the selection granularity).
+
+        This patch fixes the parameter names, and updates selectRange, its test
+        and its documentation to reflect the correct usage. It also removes
+        moveSelectionStart/moveSelectionEnd/moveCaret (which aren't being used
+        yet), and updates WebFrameTest to show how these can be implemented via
+        selectRange.
+
+        * public/WebFrame.h:
+        (WebFrame):
+        * public/WebWidget.h:
+        (WebWidget):
+        (WebKit::WebWidget::selectionBounds):
+        * src/WebFrameImpl.cpp:
+        (WebKit::WebFrameImpl::selectRange):
+        * src/WebFrameImpl.h:
+        (WebFrameImpl):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::selectionBounds):
+        * src/WebViewImpl.h:
+        (WebViewImpl):
+        * tests/WebFrameTest.cpp:
+
 2012-09-18  Terry Anderson  <[email protected]>
 
         Roll chromium DEPS to r157342

Modified: trunk/Source/WebKit/chromium/public/WebFrame.h (128902 => 128903)


--- trunk/Source/WebKit/chromium/public/WebFrame.h	2012-09-18 16:51:26 UTC (rev 128902)
+++ trunk/Source/WebKit/chromium/public/WebFrame.h	2012-09-18 17:23:37 UTC (rev 128903)
@@ -472,30 +472,12 @@
     // there is ranged selection.
     virtual bool selectWordAroundCaret() = 0;
 
-    // DEPRECATED: Use moveSelectionStart / moveSelectionEnd / moveCaret
-    // This method is intended for touch-based UIs, but it's missing some
-    // functionality needed on Android, like preventing collapsed selections.
-    virtual void selectRange(const WebPoint& start, const WebPoint& end) = 0;
+    // Select a range of text, as if by drag-selecting from base to extent
+    // with character granularity.
+    virtual void selectRange(const WebPoint& base, const WebPoint& extent) = 0;
 
     virtual void selectRange(const WebRange&) = 0;
 
-    // The methods below are for adjusting the start and/or end of the current
-    // selection by direct manipulation on a touch-based UI. To enter selection
-    // mode in the first place, call selectRange() or send a fake mouse event.
-
-    // Moves the start of the current selection, keeping the end fixed.
-    // Returns true on success, false if there is no selection to modify.
-    virtual bool moveSelectionStart(const WebPoint&, bool allowCollapsedSelection) = 0;
-
-    // Moves the end of the current selection, keeping the start fixed.
-    // Returns true on success, false if there is no selection to modify.
-    virtual bool moveSelectionEnd(const WebPoint&, bool allowCollapsedSelection) = 0;
-
-    // Move both endpoints of the current selection to the given position.
-    // The caret will remain pinned inside the current editable region.
-    // Returns true on success, false if there is no selection or if we're not editing.
-    virtual bool moveCaret(const WebPoint&) = 0;
-
     // Printing ------------------------------------------------------------
 
     // Reformats the WebFrame for printing. WebPrintParams specifies the printable

Modified: trunk/Source/WebKit/chromium/public/WebWidget.h (128902 => 128903)


--- trunk/Source/WebKit/chromium/public/WebWidget.h	2012-09-18 16:51:26 UTC (rev 128902)
+++ trunk/Source/WebKit/chromium/public/WebWidget.h	2012-09-18 17:23:37 UTC (rev 128903)
@@ -194,9 +194,9 @@
     // FIXME: Remove this method. It's redundant with textInputInfo().
     virtual WebTextInputType textInputType() { return WebTextInputTypeNone; }
 
-    // Returns the start and end bounds of the current selection.
+    // Returns the anchor and focus bounds of the current selection.
     // If the selection range is empty, it returns the caret bounds.
-    virtual bool selectionBounds(WebRect& start, WebRect& end) const { return false; }
+    virtual bool selectionBounds(WebRect& anchor, WebRect& focus) const { return false; }
 
     // Returns the text direction at the start and end bounds of the current selection.
     // If the selection range is empty, it returns false.

Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp (128902 => 128903)


--- trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2012-09-18 16:51:26 UTC (rev 128902)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2012-09-18 17:23:37 UTC (rev 128903)
@@ -1466,71 +1466,15 @@
     return true;
 }
 
-void WebFrameImpl::selectRange(const WebPoint& start, const WebPoint& end)
+void WebFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent)
 {
-    if (start == end && moveCaret(start))
-        return;
-
-    if (moveSelectionStart(start, true) && moveSelectionEnd(end, true))
-        return;
-
-    // Failed to move endpoints, probably because there's no current selection.
-    // Just set the selection explicitly (but this won't handle editable boundaries correctly).
-    VisibleSelection newSelection(visiblePositionForWindowPoint(start), visiblePositionForWindowPoint(end));    
+    VisiblePosition basePos = visiblePositionForWindowPoint(base);
+    VisiblePosition extentPos = visiblePositionForWindowPoint(extent);
+    VisibleSelection newSelection = VisibleSelection(basePos, extentPos);
     if (frame()->selection()->shouldChangeSelection(newSelection))
         frame()->selection()->setSelection(newSelection, CharacterGranularity);
 }
 
-bool WebFrameImpl::moveSelectionStart(const WebPoint& point, bool allowCollapsedSelection)
-{
-    const VisibleSelection& selection = frame()->selection()->selection();
-    if (selection.isNone())
-        return false;
-
-    VisiblePosition start = visiblePositionForWindowPoint(point);
-    if (!allowCollapsedSelection) {
-        VisiblePosition maxStart = selection.visibleEnd().previous();
-        if (comparePositions(start, maxStart) > 0)
-            start = maxStart;
-    }
-
-    // start is moving, so base=end, extent=start
-    VisibleSelection newSelection = VisibleSelection(selection.visibleEnd(), start);
-    frame()->selection()->setNonDirectionalSelectionIfNeeded(newSelection, CharacterGranularity);
-    return true;
-}
-
-bool WebFrameImpl::moveSelectionEnd(const WebPoint& point, bool allowCollapsedSelection)
-{
-    const VisibleSelection& selection = frame()->selection()->selection();
-    if (selection.isNone())
-        return false;
-
-    VisiblePosition end = visiblePositionForWindowPoint(point);
-    if (!allowCollapsedSelection) {
-        VisiblePosition minEnd = selection.visibleStart().next();
-        if (comparePositions(end, minEnd) < 0)
-            end = minEnd;
-    }
-
-    // end is moving, so base=start, extent=end
-    VisibleSelection newSelection = VisibleSelection(selection.visibleStart(), end);
-    frame()->selection()->setNonDirectionalSelectionIfNeeded(newSelection, CharacterGranularity);
-    return true;
-}
-
-bool WebFrameImpl::moveCaret(const WebPoint& point)
-{
-    FrameSelection* frameSelection = frame()->selection();
-    if (frameSelection->isNone() || !frameSelection->isContentEditable())
-        return false;
-
-    VisiblePosition pos = visiblePositionForWindowPoint(point);
-    frameSelection->setExtent(pos, UserTriggered);
-    frameSelection->setBase(frameSelection->extent(), UserTriggered);
-    return true;
-}
-
 void WebFrameImpl::selectRange(const WebRange& webRange)
 {
     RefPtr<Range> range = static_cast<PassRefPtr<Range> >(webRange);

Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.h (128902 => 128903)


--- trunk/Source/WebKit/chromium/src/WebFrameImpl.h	2012-09-18 16:51:26 UTC (rev 128902)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.h	2012-09-18 17:23:37 UTC (rev 128903)
@@ -184,11 +184,8 @@
     virtual WebString selectionAsText() const;
     virtual WebString selectionAsMarkup() const;
     virtual bool selectWordAroundCaret();
-    virtual void selectRange(const WebPoint& start, const WebPoint& end);
+    virtual void selectRange(const WebPoint& base, const WebPoint& extent);
     virtual void selectRange(const WebRange&);
-    virtual bool moveSelectionStart(const WebPoint&, bool allowCollapsedSelection);
-    virtual bool moveSelectionEnd(const WebPoint&, bool allowCollapsedSelection);
-    virtual bool moveCaret(const WebPoint&);
     virtual int printBegin(const WebPrintParams&,
                            const WebNode& constrainToNode,
                            bool* useBrowserOverlays);

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (128902 => 128903)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-09-18 16:51:26 UTC (rev 128902)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-09-18 17:23:37 UTC (rev 128903)
@@ -2223,7 +2223,7 @@
     return WebTextInputTypeNone;
 }
 
-bool WebViewImpl::selectionBounds(WebRect& start, WebRect& end) const
+bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const
 {
     const Frame* frame = focusedWebCoreFrame();
     if (!frame)
@@ -2233,7 +2233,7 @@
         return false;
 
     if (selection->isCaret()) {
-        start = end = frame->view()->contentsToWindow(selection->absoluteCaretBounds());
+        anchor = focus = frame->view()->contentsToWindow(selection->absoluteCaretBounds());
         return true;
     }
 
@@ -2246,20 +2246,20 @@
                                       selectedRange->startOffset(),
                                       selectedRange->startContainer(),
                                       selectedRange->startOffset()));
-    start = frame->editor()->firstRectForRange(range.get());
+    anchor = frame->editor()->firstRectForRange(range.get());
 
     range = Range::create(selectedRange->endContainer()->document(),
                           selectedRange->endContainer(),
                           selectedRange->endOffset(),
                           selectedRange->endContainer(),
                           selectedRange->endOffset());
-    end = frame->editor()->firstRectForRange(range.get());
+    focus = frame->editor()->firstRectForRange(range.get());
 
-    start = frame->view()->contentsToWindow(start);
-    end = frame->view()->contentsToWindow(end);
+    anchor = frame->view()->contentsToWindow(anchor);
+    focus = frame->view()->contentsToWindow(focus);
 
     if (!frame->selection()->selection().isBaseFirst())
-        std::swap(start, end);
+        std::swap(anchor, focus);
     return true;
 }
 

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (128902 => 128903)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-09-18 16:51:26 UTC (rev 128902)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-09-18 17:23:37 UTC (rev 128903)
@@ -167,7 +167,7 @@
     virtual void extendSelectionAndDelete(int before, int after);
     virtual bool isSelectionEditable() const;
     virtual WebColor backgroundColor() const;
-    virtual bool selectionBounds(WebRect& start, WebRect& end) const;
+    virtual bool selectionBounds(WebRect& anchor, WebRect& focus) const;
     virtual bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const;
     virtual bool caretOrSelectionRange(size_t* location, size_t* length);
     virtual void setTextDirection(WebTextDirection direction);

Modified: trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp (128902 => 128903)


--- trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2012-09-18 16:51:26 UTC (rev 128902)
+++ trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2012-09-18 17:23:37 UTC (rev 128903)
@@ -1072,7 +1072,7 @@
     frame = webView->mainFrame();
     EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
     webView->selectionBounds(startWebRect, endWebRect);
-    frame->selectRange(WebPoint(0, 0), bottomRightMinusOne(endWebRect));
+    frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0));
     EXPECT_EQ("16-char header. This text is initially selected.", selectionAsString(frame));
     webView->close();
 
@@ -1086,176 +1086,100 @@
     webView->close();
 }
 
-TEST_F(WebFrameTest, MoveSelectionStart)
+TEST_F(WebFrameTest, SelectRangeCanMoveSelectionStart)
 {
     registerMockedHttpURLLoad("text_selection.html");
     WebView* webView = createWebViewForTextSelection(m_baseURL + "text_selection.html");
     WebFrame* frame = webView->mainFrame();
 
-    // moveSelectionStart() always returns false if there's no selection.
-    EXPECT_FALSE(frame->moveSelectionStart(topLeft(elementBounds(frame, "header_1")), false));
-    EXPECT_FALSE(frame->moveSelectionStart(topLeft(elementBounds(frame, "header_1")), true));
-
-    frame->executeScript(WebScriptSource("selectElement('header_1');"));
-    EXPECT_EQ("Header 1.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "header_2")), false));
-    EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame));
-
     // Select second span. We can move the start to include the first span.
     frame->executeScript(WebScriptSource("selectElement('header_2');"));
     EXPECT_EQ("Header 2.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "header_1")), false));
+    frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), topLeft(elementBounds(frame, "header_1")));
     EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame));
 
-    // If allowCollapsedSelection=false we can't move the selection start beyond the current end.
-    // We end up with a single character selected.
+    // We can move the start and end together.
     frame->executeScript(WebScriptSource("selectElement('header_1');"));
     EXPECT_EQ("Header 1.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionStart(bottomRightMinusOne(elementBounds(frame, "header_1")), false));
-    EXPECT_EQ(".", selectionAsString(frame));
-
-    // If allowCollapsedSelection=true we can move the start and end together.
-    frame->executeScript(WebScriptSource("selectElement('header_1');"));
-    EXPECT_EQ("Header 1.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionStart(bottomRightMinusOne(elementBounds(frame, "header_1")), true));
+    frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_1")), bottomRightMinusOne(elementBounds(frame, "header_1")));
     EXPECT_EQ("", selectionAsString(frame));
     // Selection is a caret, not empty.
     EXPECT_FALSE(frame->selectionRange().isNull());
-    EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "header_1")), true));
-    EXPECT_EQ("Header 1.", selectionAsString(frame));
 
-    // If allowCollapsedSelection=true we can move the start across the end.
+    // We can move the start across the end.
     frame->executeScript(WebScriptSource("selectElement('header_1');"));
     EXPECT_EQ("Header 1.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionStart(bottomRightMinusOne(elementBounds(frame, "header_2")), true));
+    frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_1")), bottomRightMinusOne(elementBounds(frame, "header_2")));
     EXPECT_EQ(" Header 2.", selectionAsString(frame));
 
     // Can't extend the selection part-way into an editable element.
     frame->executeScript(WebScriptSource("selectElement('footer_2');"));
     EXPECT_EQ("Footer 2.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "editable_2")), true));
+    frame->selectRange(bottomRightMinusOne(elementBounds(frame, "footer_2")), topLeft(elementBounds(frame, "editable_2")));
     EXPECT_EQ(" [ Footer 1. Footer 2.", selectionAsString(frame));
 
     // Can extend the selection completely across editable elements.
     frame->executeScript(WebScriptSource("selectElement('footer_2');"));
     EXPECT_EQ("Footer 2.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "header_2")), true));
+    frame->selectRange(bottomRightMinusOne(elementBounds(frame, "footer_2")), topLeft(elementBounds(frame, "header_2")));
     EXPECT_EQ("Header 2. ] [ Editable 1. Editable 2. ] [ Footer 1. Footer 2.", selectionAsString(frame));
 
     // If the selection is editable text, we can't extend it into non-editable text.
     frame->executeScript(WebScriptSource("selectElement('editable_2');"));
     EXPECT_EQ("Editable 2.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "header_2")), true));
+    frame->selectRange(bottomRightMinusOne(elementBounds(frame, "editable_2")), topLeft(elementBounds(frame, "header_2")));
     EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame));
 
     webView->close();
 }
 
-TEST_F(WebFrameTest, MoveSelectionEnd)
+TEST_F(WebFrameTest, SelectRangeCanMoveSelectionEnd)
 {
     registerMockedHttpURLLoad("text_selection.html");
     WebView* webView = createWebViewForTextSelection(m_baseURL + "text_selection.html");
     WebFrame* frame = webView->mainFrame();
 
-    // moveSelectionEnd() always returns false if there's no selection.
-    EXPECT_FALSE(frame->moveSelectionEnd(topLeft(elementBounds(frame, "header_1")), false));
-    EXPECT_FALSE(frame->moveSelectionEnd(topLeft(elementBounds(frame, "header_1")), true));
-
     // Select first span. We can move the end to include the second span.
     frame->executeScript(WebScriptSource("selectElement('header_1');"));
     EXPECT_EQ("Header 1.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "header_2")), false));
+    frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMinusOne(elementBounds(frame, "header_2")));
     EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame));
 
-    // If allowCollapsedSelection=false we can't move the selection end beyond the current start.
-    // We end up with a single character selected.
+    // We can move the start and end together.
     frame->executeScript(WebScriptSource("selectElement('header_2');"));
     EXPECT_EQ("Header 2.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionEnd(topLeft(elementBounds(frame, "header_2")), false));
-    EXPECT_EQ("H", selectionAsString(frame));
-
-    // If allowCollapsedSelection=true we can move the start and end together.
-    frame->executeScript(WebScriptSource("selectElement('header_2');"));
-    EXPECT_EQ("Header 2.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionEnd(topLeft(elementBounds(frame, "header_2")), true));
+    frame->selectRange(topLeft(elementBounds(frame, "header_2")), topLeft(elementBounds(frame, "header_2")));
     EXPECT_EQ("", selectionAsString(frame));
     // Selection is a caret, not empty.
     EXPECT_FALSE(frame->selectionRange().isNull());
-    EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "header_2")), true));
-    EXPECT_EQ("Header 2.", selectionAsString(frame));
 
-    // If allowCollapsedSelection=true we can move the end across the start.
+    // We can move the end across the start.
     frame->executeScript(WebScriptSource("selectElement('header_2');"));
     EXPECT_EQ("Header 2.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionEnd(topLeft(elementBounds(frame, "header_1")), true));
+    frame->selectRange(topLeft(elementBounds(frame, "header_2")), topLeft(elementBounds(frame, "header_1")));
     EXPECT_EQ("Header 1. ", selectionAsString(frame));
 
     // Can't extend the selection part-way into an editable element.
     frame->executeScript(WebScriptSource("selectElement('header_1');"));
     EXPECT_EQ("Header 1.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "editable_1")), true));
+    frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMinusOne(elementBounds(frame, "editable_1")));
     EXPECT_EQ("Header 1. Header 2. ] ", selectionAsString(frame));
 
     // Can extend the selection completely across editable elements.
     frame->executeScript(WebScriptSource("selectElement('header_1');"));
     EXPECT_EQ("Header 1.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "footer_1")), true));
+    frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMinusOne(elementBounds(frame, "footer_1")));
     EXPECT_EQ("Header 1. Header 2. ] [ Editable 1. Editable 2. ] [ Footer 1.", selectionAsString(frame));
 
     // If the selection is editable text, we can't extend it into non-editable text.
     frame->executeScript(WebScriptSource("selectElement('editable_1');"));
     EXPECT_EQ("Editable 1.", selectionAsString(frame));
-    EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "footer_1")), true));
+    frame->selectRange(topLeft(elementBounds(frame, "editable_1")), bottomRightMinusOne(elementBounds(frame, "footer_1")));
     EXPECT_EQ("Editable 1. Editable 2. ]", selectionAsString(frame));
 
     webView->close();
 }
 
-TEST_F(WebFrameTest, MoveCaret)
-{
-    registerMockedHttpURLLoad("text_selection.html");
-    WebView* webView = createWebViewForTextSelection(m_baseURL + "text_selection.html");
-    WebFrame* frame = webView->mainFrame();
-
-    // moveCaret() returns false if there's no selection, or if it isn't editable.
-    EXPECT_FALSE(frame->moveCaret(topLeft(elementBounds(frame, "editable"))));
-    frame->executeScript(WebScriptSource("selectElement('header_1');"));
-    EXPECT_EQ("Header 1.", selectionAsString(frame));
-    EXPECT_FALSE(frame->moveCaret(topLeft(elementBounds(frame, "editable"))));
-
-    // Select the editable text span. Now moveCaret() works.
-    frame->executeScript(WebScriptSource("selectElement('editable_1');"));
-    EXPECT_EQ("Editable 1.", selectionAsString(frame));
-
-    EXPECT_TRUE(frame->moveCaret(topLeft(elementBounds(frame, "editable_1"))));
-    EXPECT_EQ("", selectionAsString(frame));
-    EXPECT_FALSE(frame->selectionRange().isNull());
-    EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "editable_1")), false));
-    EXPECT_EQ("Editable 1.", selectionAsString(frame));
-
-    EXPECT_TRUE(frame->moveCaret(bottomRightMinusOne(elementBounds(frame, "editable_2"))));
-    EXPECT_EQ("", selectionAsString(frame));
-    EXPECT_FALSE(frame->selectionRange().isNull());
-    EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "editable_2")), false));
-    EXPECT_EQ("Editable 2.", selectionAsString(frame));
-
-    // Caret is pinned at the start of the editable region.
-    EXPECT_TRUE(frame->moveCaret(topLeft(elementBounds(frame, "header_1"))));
-    EXPECT_EQ("", selectionAsString(frame));
-    EXPECT_FALSE(frame->selectionRange().isNull());
-    EXPECT_TRUE(frame->moveSelectionEnd(bottomRightMinusOne(elementBounds(frame, "editable_1")), false));
-    EXPECT_EQ("[ Editable 1.", selectionAsString(frame));
-
-    // Caret is pinned at the end of the editable region.
-    EXPECT_TRUE(frame->moveCaret(bottomRightMinusOne(elementBounds(frame, "footer_2"))));
-    EXPECT_EQ("", selectionAsString(frame));
-    EXPECT_FALSE(frame->selectionRange().isNull());
-    EXPECT_TRUE(frame->moveSelectionStart(topLeft(elementBounds(frame, "editable_2")), false));
-    EXPECT_EQ("Editable 2. ]", selectionAsString(frame));
-
-    webView->close();
-}
-
 class DisambiguationPopupTestWebViewClient : public WebViewClient {
 public:
     virtual bool didTapMultipleTargets(const WebGestureEvent&, const WebVector<WebRect>& targetRects) OVERRIDE
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to