LayoutTests:
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Dec 2006 07:18:26 +0000 (07:18 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Dec 2006 07:18:26 +0000 (07:18 +0000)
        Reviewed by Anders.

        Test for <rdar://problem/3824247> Select All works even if -khtml-user-select:none; style is set

        * editing/selection/select-all-user-select-none-expected.txt: Added.
        * editing/selection/select-all-user-select-none.html: Added.

WebCore:

        Reviewed by Anders.

        - Fix for <rdar://problem/3824247> Select All works even if -khtml-user-select:none; style is set

        Also made user-select:none work on new list boxes, and cleaned up the list box defaultEventHandler.

        Test: editing/selection/select-all-user-select-none.html

        * editing/SelectionController.cpp: (WebCore::SelectionController::selectAll): Make sure canSelect is true on the root renderer.
        * html/HTMLSelectElement.cpp:
        (WebCore::HTMLSelectElement::canSelectAll): Check canSelect here.
        (WebCore::HTMLSelectElement::selectAll): Added nil check for renderer.
        (WebCore::HTMLSelectElement::defaultEventHandler): Return early if the event has been handled.
        (WebCore::HTMLSelectElement::listBoxDefaultEventHandler): Check canSelect here.
        * html/HTMLSelectElement.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@18338 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/selection/select-all-user-select-none-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-all-user-select-none.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/SelectionController.cpp
WebCore/html/HTMLSelectElement.cpp
WebCore/html/HTMLSelectElement.h

index e3eb205..06f5dbd 100644 (file)
@@ -1,3 +1,12 @@
+2006-12-19  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Anders.
+
+        Test for <rdar://problem/3824247> Select All works even if -khtml-user-select:none; style is set
+
+        * editing/selection/select-all-user-select-none-expected.txt: Added.
+        * editing/selection/select-all-user-select-none.html: Added.
+
 2006-12-19  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Adele.
diff --git a/LayoutTests/editing/selection/select-all-user-select-none-expected.txt b/LayoutTests/editing/selection/select-all-user-select-none-expected.txt
new file mode 100644 (file)
index 0000000..40531aa
--- /dev/null
@@ -0,0 +1 @@
+Test Passed
diff --git a/LayoutTests/editing/selection/select-all-user-select-none.html b/LayoutTests/editing/selection/select-all-user-select-none.html
new file mode 100644 (file)
index 0000000..c05c518
--- /dev/null
@@ -0,0 +1,21 @@
+<html>
+    <head>
+        <style>
+        html {
+            -webkit-user-select: none;
+        }
+        </style>
+        <script>
+            function test() {
+                if (window.layoutTestController)
+                    layoutTestController.dumpAsText();
+                document.execCommand('SelectAll');
+                if (window.getSelection().toString() == "")
+                    document.body.innerHTML = "Test Passed";
+            }
+        </script>
+    </head>
+    <body onload="test()">
+    Test Failed (this should not be selected)
+    </body>
+</html>
index bfdfcbd..78744bd 100644 (file)
@@ -1,3 +1,21 @@
+2006-12-19  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Anders.
+
+        - Fix for <rdar://problem/3824247> Select All works even if -khtml-user-select:none; style is set
+
+        Also made user-select:none work on new list boxes, and cleaned up the list box defaultEventHandler.
+
+        Test: editing/selection/select-all-user-select-none.html
+
+        * editing/SelectionController.cpp: (WebCore::SelectionController::selectAll): Make sure canSelect is true on the root renderer.
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::canSelectAll): Check canSelect here.
+        (WebCore::HTMLSelectElement::selectAll): Added nil check for renderer.
+        (WebCore::HTMLSelectElement::defaultEventHandler): Return early if the event has been handled.
+        (WebCore::HTMLSelectElement::listBoxDefaultEventHandler): Check canSelect here.
+        * html/HTMLSelectElement.h:
+
 2006-12-19  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Adele.
index 877b3af..1c1b54b 100644 (file)
@@ -1091,6 +1091,8 @@ void SelectionController::selectAll()
     }
     
     Node* root = isContentEditable() ? highestEditableRoot(m_sel.start()) : document->documentElement();
+    if (!root->renderer() || !root->renderer()->canSelect())
+        return;
     Selection newSelection(Selection::selectionFromContentsOfNode(root));
     if (m_frame->shouldChangeSelection(newSelection))
         setSelection(newSelection);
index 8414c99..7bbb189 100644 (file)
@@ -355,10 +355,15 @@ bool HTMLSelectElement::isMouseFocusable() const
     return HTMLGenericFormElement::isMouseFocusable();
 }
 
+bool HTMLSelectElement::canSelectAll() const
+{
+    return !usesMenuList() && renderer() && renderer()->canSelect(); 
+}
+
 void HTMLSelectElement::selectAll()
 {
     ASSERT(!usesMenuList());
-    if (!multiple())
+    if (!renderer() || !multiple())
         return;
     
     m_activeSelectionState = true;
@@ -551,6 +556,9 @@ void HTMLSelectElement::defaultEventHandler(Event* evt)
         menuListDefaultEventHandler(evt);
     else 
         listBoxDefaultEventHandler(evt);
+    
+    if (evt->defaultHandled())
+        return;
 
     if (!evt->defaultHandled() && evt->type() == keypressEvent && evt->isKeyboardEvent()) {
         KeyboardEvent* keyboardEvent = static_cast<KeyboardEvent*>(evt);
@@ -559,6 +567,7 @@ void HTMLSelectElement::defaultEventHandler(Event* evt)
             && isprint(static_cast<KeyboardEvent*>(evt)->charCode())) {
             typeAheadFind(static_cast<KeyboardEvent*>(evt));
             evt->setDefaultHandled();
+            return;
         }
     }
 
@@ -629,7 +638,7 @@ void HTMLSelectElement::menuListDefaultEventHandler(Event* evt)
 
 void HTMLSelectElement::listBoxDefaultEventHandler(Event* evt)
 {
-    if (!renderer())
+    if (!renderer() || !renderer()->canSelect())
         return;
 
     if (evt->type() == mousedownEvent) {
@@ -682,6 +691,7 @@ void HTMLSelectElement::listBoxDefaultEventHandler(Event* evt)
             setActiveSelectionEndIndex(listIndex);
             updateListBoxSelection(!multiSelect);
             renderer()->repaint();
+            evt->setDefaultHandled();
         }
     } else if (evt->type() == mouseupEvent && document()->frame()->eventHandler()->autoscrollRenderer() != renderer())
         // This makes sure we fire onChange for a single click.  For drag selection, onChange will fire when the autoscroll timer stops.
@@ -720,11 +730,10 @@ void HTMLSelectElement::listBoxDefaultEventHandler(Event* evt)
             }
 
             static_cast<RenderListBox*>(renderer())->scrollToRevealElementAtListIndex(endIndex);
-            evt->setDefaultHandled();
             updateListBoxSelection(deselectOthers);
-            renderer()->repaint();
-            
+            renderer()->repaint();            
             listBoxOnChange();
+            evt->setDefaultHandled();
         }
     }
 }
index e8aeb46..f31512d 100644 (file)
@@ -51,7 +51,7 @@ public:
     
     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
     virtual bool isMouseFocusable() const;
-    virtual bool canSelectAll() const { return !usesMenuList(); }
+    virtual bool canSelectAll() const;
     virtual void selectAll();
 
     virtual void recalcStyle(StyleChange);