Changeset 86041 in webkit
- Timestamp:
- May 8, 2011 8:29:42 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r86035 r86041 1 2011-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 1 16 2011-05-08 Abhishek Arya <inferno@chromium.org> 2 17 -
trunk/Source/WebCore/ChangeLog
r86040 r86041 1 2011-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 1 22 2011-05-08 Luke Macpherson <macpherson@chromium.org> 2 23 -
trunk/Source/WebCore/dom/Node.h
r85998 r86041 416 416 // css-transform:capitalize breaking up precomposed characters and ligatures. 417 417 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() { }422 418 423 419 // Whether or not a selection can be started in this object -
trunk/Source/WebCore/editing/FrameSelection.cpp
r86039 r86041 44 44 #include "HTMLFrameElementBase.h" 45 45 #include "HTMLInputElement.h" 46 #include "HTMLSelectElement.h" 46 47 #include "HTMLNames.h" 47 48 #include "HitTestRequest.h" … … 1453 1454 { 1454 1455 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 1461 1465 Node* root = 0; 1462 if (isContentEditable()) 1466 Node* selectStartTarget = 0; 1467 if (isContentEditable()) { 1463 1468 root = highestEditableRoot(m_selection.start()); 1464 else { 1469 if (Node* shadowRoot = shadowTreeRootNode()) 1470 selectStartTarget = shadowRoot->shadowHost(); 1471 else 1472 selectStartTarget = root; 1473 } else { 1465 1474 root = shadowTreeRootNode(); 1466 if (!root) 1475 if (root) 1476 selectStartTarget = root->shadowHost(); 1477 else { 1467 1478 root = document->documentElement(); 1479 selectStartTarget = document->body(); 1480 } 1468 1481 } 1469 1482 if (!root) 1470 1483 return; 1484 1485 if (selectStartTarget && !selectStartTarget->dispatchEvent(Event::create(eventNames().selectstartEvent, true, true))) 1486 return; 1487 1471 1488 VisibleSelection newSelection(VisibleSelection::selectionFromContentsOfNode(root)); 1489 1472 1490 if (shouldChangeSelection(newSelection)) 1473 1491 setSelection(newSelection); 1492 1474 1493 selectFrameElementInParentIfFullySelected(); 1475 1494 notifyRendererOfSelectionChange(true); -
trunk/Source/WebCore/html/HTMLSelectElement.h
r82925 r86041 89 89 virtual void updateValidity() { setNeedsValidityCheck(); } 90 90 91 virtual bool canSelectAll() const; 92 virtual void selectAll(); 93 91 94 protected: 92 95 HTMLSelectElement(const QualifiedName&, Document*, HTMLFormElement*); … … 97 100 virtual bool isKeyboardFocusable(KeyboardEvent*) const; 98 101 virtual bool isMouseFocusable() const; 99 virtual bool canSelectAll() const;100 virtual void selectAll();101 102 102 103 virtual void recalcStyle(StyleChange);
Note: See TracChangeset
for help on using the changeset viewer.