[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andreas.kling at nokia.com andreas.kling at nokia.com
Wed Dec 22 12:54:17 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a11b16c130197617bd833832f10b709ea331b7bf
Author: andreas.kling at nokia.com <andreas.kling at nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Sep 1 10:23:22 2010 +0000

    2010-09-01  Andreas Kling  <andreas.kling at nokia.com>
    
            Reviewed by Darin Adler.
    
            DOM Selection: collapseToStart() and collapseToEnd() should throw INVALID_STATE_ERR if there's no selection
            https://bugs.webkit.org/show_bug.cgi?id=44598
    
            Spec links:
            http://www.whatwg.org/specs/web-apps/current-work/#dom-selection-collapsetostart
            http://www.whatwg.org/specs/web-apps/current-work/#dom-selection-collapsetoend
    
            Test: fast/dom/Selection/collapseToX-empty-selection.html
    
            * page/DOMSelection.cpp:
            (WebCore::DOMSelection::collapseToEnd):
            (WebCore::DOMSelection::collapseToStart):
            * page/DOMSelection.h:
            * page/DOMSelection.idl:
    2010-09-01  Andreas Kling  <andreas.kling at nokia.com>
    
            Reviewed by Darin Adler.
    
            DOM Selection: collapseToStart() and collapseToEnd() should throw INVALID_STATE_ERR if there's no selection
            https://bugs.webkit.org/show_bug.cgi?id=44598
    
            Spec links:
            http://www.whatwg.org/specs/web-apps/current-work/#dom-selection-collapsetostart
            http://www.whatwg.org/specs/web-apps/current-work/#dom-selection-collapsetoend
    
            * fast/dom/Selection/collapseToX-empty-selection-expected.txt: Added.
            * fast/dom/Selection/collapseToX-empty-selection.html: Added.
            * fast/dom/Selection/script-tests/collapseToX-empty-selection.js: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66590 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 0795312..cbad964 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
+2010-09-01  Andreas Kling  <andreas.kling at nokia.com>
+
+        Reviewed by Darin Adler.
+
+        DOM Selection: collapseToStart() and collapseToEnd() should throw INVALID_STATE_ERR if there's no selection
+        https://bugs.webkit.org/show_bug.cgi?id=44598
+
+        Spec links:
+        http://www.whatwg.org/specs/web-apps/current-work/#dom-selection-collapsetostart
+        http://www.whatwg.org/specs/web-apps/current-work/#dom-selection-collapsetoend
+
+        * fast/dom/Selection/collapseToX-empty-selection-expected.txt: Added.
+        * fast/dom/Selection/collapseToX-empty-selection.html: Added.
+        * fast/dom/Selection/script-tests/collapseToX-empty-selection.js: Added.
+
 2010-09-01  Alejandro G. Castro  <alex at igalia.com>
 
         Unreviewed, updating expected results for r66581.
diff --git a/LayoutTests/fast/dom/Selection/collapseToX-empty-selection-expected.txt b/LayoutTests/fast/dom/Selection/collapseToX-empty-selection-expected.txt
new file mode 100644
index 0000000..1a77f93
--- /dev/null
+++ b/LayoutTests/fast/dom/Selection/collapseToX-empty-selection-expected.txt
@@ -0,0 +1,13 @@
+Test that collapseToStart() and collapseToEnd() throw INVALID_STATE_ERR if no selection is made.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS sel.collapseToStart() threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
+PASS sel.collapseToEnd() threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
+PASS sel.collapseToStart() is undefined
+PASS sel.collapseToEnd() is undefined
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Selection/collapseToX-empty-selection.html b/LayoutTests/fast/dom/Selection/collapseToX-empty-selection.html
new file mode 100644
index 0000000..5463fff
--- /dev/null
+++ b/LayoutTests/fast/dom/Selection/collapseToX-empty-selection.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/collapseToX-empty-selection.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/Selection/script-tests/collapseToX-empty-selection.js b/LayoutTests/fast/dom/Selection/script-tests/collapseToX-empty-selection.js
new file mode 100644
index 0000000..c1fd73c
--- /dev/null
+++ b/LayoutTests/fast/dom/Selection/script-tests/collapseToX-empty-selection.js
@@ -0,0 +1,17 @@
+description("Test that collapseToStart() and collapseToEnd() throw INVALID_STATE_ERR if no selection is made.");
+
+var sel = window.getSelection();
+var textNode = document.createTextNode("abcdef");
+document.body.appendChild(textNode);
+
+shouldThrow("sel.collapseToStart()", "'Error: INVALID_STATE_ERR: DOM Exception 11'");
+shouldThrow("sel.collapseToEnd()", "'Error: INVALID_STATE_ERR: DOM Exception 11'");
+
+sel.selectAllChildren(textNode);
+
+shouldBe("sel.collapseToStart()", "undefined");
+shouldBe("sel.collapseToEnd()", "undefined");
+
+document.body.removeChild(textNode);
+
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 27816e1..211b7ba 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-09-01  Andreas Kling  <andreas.kling at nokia.com>
+
+        Reviewed by Darin Adler.
+
+        DOM Selection: collapseToStart() and collapseToEnd() should throw INVALID_STATE_ERR if there's no selection
+        https://bugs.webkit.org/show_bug.cgi?id=44598
+
+        Spec links:
+        http://www.whatwg.org/specs/web-apps/current-work/#dom-selection-collapsetostart
+        http://www.whatwg.org/specs/web-apps/current-work/#dom-selection-collapsetoend
+
+        Test: fast/dom/Selection/collapseToX-empty-selection.html
+
+        * page/DOMSelection.cpp:
+        (WebCore::DOMSelection::collapseToEnd):
+        (WebCore::DOMSelection::collapseToStart):
+        * page/DOMSelection.h:
+        * page/DOMSelection.idl:
+
 2010-09-01  Kinuko Yasuda  <kinuko at chromium.org>
 
         Unreviewed; another build fix.
diff --git a/WebCore/page/DOMSelection.cpp b/WebCore/page/DOMSelection.cpp
index 106dd13..6c25103 100644
--- a/WebCore/page/DOMSelection.cpp
+++ b/WebCore/page/DOMSelection.cpp
@@ -214,21 +214,33 @@ void DOMSelection::collapse(Node* node, int offset, ExceptionCode& ec)
     m_frame->selection()->moveTo(VisiblePosition(node, offset, DOWNSTREAM));
 }
 
-void DOMSelection::collapseToEnd()
+void DOMSelection::collapseToEnd(ExceptionCode& ec)
 {
     if (!m_frame)
         return;
 
     const VisibleSelection& selection = m_frame->selection()->selection();
+
+    if (selection.isNone()) {
+        ec = INVALID_STATE_ERR;
+        return;
+    }
+
     m_frame->selection()->moveTo(VisiblePosition(selection.end(), DOWNSTREAM));
 }
 
-void DOMSelection::collapseToStart()
+void DOMSelection::collapseToStart(ExceptionCode& ec)
 {
     if (!m_frame)
         return;
 
     const VisibleSelection& selection = m_frame->selection()->selection();
+
+    if (selection.isNone()) {
+        ec = INVALID_STATE_ERR;
+        return;
+    }
+
     m_frame->selection()->moveTo(VisiblePosition(selection.start(), DOWNSTREAM));
 }
 
diff --git a/WebCore/page/DOMSelection.h b/WebCore/page/DOMSelection.h
index b0421c7..b5fd197 100644
--- a/WebCore/page/DOMSelection.h
+++ b/WebCore/page/DOMSelection.h
@@ -74,8 +74,8 @@ namespace WebCore {
         bool isCollapsed() const;
         int rangeCount() const;
         void collapse(Node*, int offset, ExceptionCode&);
-        void collapseToEnd();
-        void collapseToStart();
+        void collapseToEnd(ExceptionCode&);
+        void collapseToStart(ExceptionCode&);
         void extend(Node*, int offset, ExceptionCode&);
         PassRefPtr<Range> getRangeAt(int, ExceptionCode&);
         void removeAllRanges();
diff --git a/WebCore/page/DOMSelection.idl b/WebCore/page/DOMSelection.idl
index 4d0c942..ee82823 100644
--- a/WebCore/page/DOMSelection.idl
+++ b/WebCore/page/DOMSelection.idl
@@ -42,8 +42,10 @@ module window {
 
         void collapse(in Node node, in long index)
             raises(DOMException);
-        void collapseToEnd();
-        void collapseToStart();
+        void collapseToEnd()
+            raises(DOMException);
+        void collapseToStart()
+            raises(DOMException);
 
         void deleteFromDocument();
         boolean containsNode(in Node node, in boolean allowPartial);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list