Changeset 86041 in webkit


Ignore:
Timestamp:
May 8, 2011 8:29:42 PM (13 years ago)
Author:
rniwa@webkit.org
Message:

2011-05-08 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Kent Tamura.

selectstart event does not fire when selection is made via select all
https://bugs.webkit.org/show_bug.cgi?id=60376

Added tests to ensure selectstart event is fired when a user selects all contents
and script can prevent such selection change in selectstart's event handler.

  • fast/events/selectstart-on-selectall-expected.txt: Added.
  • fast/events/selectstart-on-selectall.html: Added.
  • fast/events/selectstart-prevent-selectall-expected.txt: Added.
  • fast/events/selectstart-prevent-selectall.html: Added.

2011-05-08 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Kent Tamura.

selectstart event does not fire when selection is made via select all
https://bugs.webkit.org/show_bug.cgi?id=60376

Fire selectstart event when a user selects all contents (i.e. document.execCommand('SelectAll')) in
document, editable region, or text control.

Tests: editing/selection/selectstart-on-selectall.html

editing/selection/selectstart-prevent-selectall.html

  • dom/Node.h: Removed canSelectAll and selectAll as they are left over from WMLSelectElement.
  • editing/FrameSelection.cpp: (WebCore::FrameSelection::selectAll): Dispatch selectstart event on selectStartTarget, which is input element or textarea element when the current selection is inside a shadow DOM, and the root editable element if it's inside a non-shadow editable region, and the body element otherwise.
  • html/HTMLSelectElement.h: Made canSelectAll and selectAll public since they are no longer declared in Node.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r86035 r86041  
     12011-05-08  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        selectstart event does not fire when selection is made via select all
     6        https://bugs.webkit.org/show_bug.cgi?id=60376
     7
     8        Added tests to ensure selectstart event is fired when a user selects all contents
     9        and script can prevent such selection change in selectstart's event handler.
     10
     11        * fast/events/selectstart-on-selectall-expected.txt: Added.
     12        * fast/events/selectstart-on-selectall.html: Added.
     13        * fast/events/selectstart-prevent-selectall-expected.txt: Added.
     14        * fast/events/selectstart-prevent-selectall.html: Added.
     15
    1162011-05-08  Abhishek Arya  <inferno@chromium.org>
    217
  • trunk/Source/WebCore/ChangeLog

    r86040 r86041  
     12011-05-08  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        selectstart event does not fire when selection is made via select all
     6        https://bugs.webkit.org/show_bug.cgi?id=60376
     7
     8        Fire selectstart event when a user selects all contents (i.e. document.execCommand('SelectAll')) in
     9        document, editable region, or text control.
     10
     11        Tests: editing/selection/selectstart-on-selectall.html
     12               editing/selection/selectstart-prevent-selectall.html
     13
     14        * dom/Node.h: Removed canSelectAll and selectAll as they are left over from WMLSelectElement.
     15        * editing/FrameSelection.cpp:
     16        (WebCore::FrameSelection::selectAll): Dispatch selectstart event on selectStartTarget, which is
     17        input element or textarea element when the current selection is inside a shadow DOM, and the root
     18        editable element if it's inside a non-shadow editable region, and the body element otherwise.
     19        * html/HTMLSelectElement.h: Made canSelectAll and selectAll public since they are no longer
     20        declared in Node.
     21
    1222011-05-08  Luke Macpherson   <macpherson@chromium.org>
    223
  • trunk/Source/WebCore/dom/Node.h

    r85998 r86041  
    416416    // css-transform:capitalize breaking up precomposed characters and ligatures.
    417417    virtual int maxCharacterOffset() const;
    418    
    419     // FIXME: We should try to find a better location for these methods.
    420     virtual bool canSelectAll() const { return false; }
    421     virtual void selectAll() { }
    422418
    423419    // Whether or not a selection can be started in this object
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r86039 r86041  
    4444#include "HTMLFrameElementBase.h"
    4545#include "HTMLInputElement.h"
     46#include "HTMLSelectElement.h"
    4647#include "HTMLNames.h"
    4748#include "HitTestRequest.h"
     
    14531454{
    14541455    Document* document = m_frame->document();
    1455    
    1456     if (document->focusedNode() && document->focusedNode()->canSelectAll()) {
    1457         document->focusedNode()->selectAll();
    1458         return;
    1459     }
    1460    
     1456
     1457    if (document->focusedNode() && document->focusedNode()->hasTagName(selectTag)) {
     1458        HTMLSelectElement* selectElement = static_cast<HTMLSelectElement*>(document->focusedNode());
     1459        if (selectElement->canSelectAll()) {
     1460            selectElement->selectAll();
     1461            return;
     1462        }
     1463    }
     1464
    14611465    Node* root = 0;
    1462     if (isContentEditable())
     1466    Node* selectStartTarget = 0;
     1467    if (isContentEditable()) {
    14631468        root = highestEditableRoot(m_selection.start());
    1464     else {
     1469        if (Node* shadowRoot = shadowTreeRootNode())
     1470            selectStartTarget = shadowRoot->shadowHost();
     1471        else
     1472            selectStartTarget = root;
     1473    } else {
    14651474        root = shadowTreeRootNode();
    1466         if (!root)
     1475        if (root)
     1476            selectStartTarget = root->shadowHost();
     1477        else {
    14671478            root = document->documentElement();
     1479            selectStartTarget = document->body();
     1480        }
    14681481    }
    14691482    if (!root)
    14701483        return;
     1484
     1485    if (selectStartTarget && !selectStartTarget->dispatchEvent(Event::create(eventNames().selectstartEvent, true, true)))
     1486        return;
     1487
    14711488    VisibleSelection newSelection(VisibleSelection::selectionFromContentsOfNode(root));
     1489
    14721490    if (shouldChangeSelection(newSelection))
    14731491        setSelection(newSelection);
     1492
    14741493    selectFrameElementInParentIfFullySelected();
    14751494    notifyRendererOfSelectionChange(true);
  • trunk/Source/WebCore/html/HTMLSelectElement.h

    r82925 r86041  
    8989    virtual void updateValidity() { setNeedsValidityCheck(); }
    9090
     91    virtual bool canSelectAll() const;
     92    virtual void selectAll();
     93
    9194protected:
    9295    HTMLSelectElement(const QualifiedName&, Document*, HTMLFormElement*);
     
    97100    virtual bool isKeyboardFocusable(KeyboardEvent*) const;
    98101    virtual bool isMouseFocusable() const;
    99     virtual bool canSelectAll() const;
    100     virtual void selectAll();
    101102
    102103    virtual void recalcStyle(StyleChange);
Note: See TracChangeset for help on using the changeset viewer.