Changeset 62816 in webkit
- Timestamp:
- Jul 8, 2010 12:25:36 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r62810 r62816 1 2010-07-07 Ojan Vafai <ojan@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Regression: Selection anchor + focus swap when arrow keys after setBaseAndExtent 6 https://bugs.webkit.org/show_bug.cgi?id=32605 7 8 * editing/selection/5195166-1.html: 9 * editing/selection/extend-forward-after-set-base-and-extent-expected.txt: Added. 10 * editing/selection/extend-forward-after-set-base-and-extent.html: Added. 11 * platform/mac/editing/selection/5195166-1-expected.txt: 12 1 13 2010-07-05 Gavin Barraclough <barraclough@apple.com> 2 14 -
trunk/LayoutTests/editing/selection/5195166-1.html
r56567 r62816 1 1 <p>This tests for a bug where extending a selection created with the mouse would blow it away before extending it.</p> 2 <div id="div" contenteditable="true">There should besix characters selected in this sentence on Mac and four characters selected on Win/Linux.</div>2 <div id="div" contenteditable="true">There <span id="select" style="color:green">should be</span> six characters selected in this sentence on Mac and four characters selected on Win/Linux.</div> 3 3 <ul id="console"></ul> 4 4 <script> 5 function log(str) { 5 function log(str) 6 { 6 7 console = document.getElementById("console"); 7 8 li = document.createElement("li"); … … 10 11 li.appendChild(text); 11 12 } 12 if (window.layoutTestController) {13 layoutTestController.dumpAsText()14 13 15 var text = document.getElementById("div").firstChild; 16 var selection = window.getSelection(); 14 function runTest(platform, expectedText) 15 { 16 layoutTestController.setEditingBehavior(platform); 17 17 18 // FIXME: m_lastChangeWasHorizontalExtension isn't cleared in several places 19 // where it should be, when opening a new document for example. 20 selection.setPosition(text, 0); 21 selection.modify("move", "forward", "character"); 22 23 selection.setBaseAndExtent(text, 3 + 5, text, 3); 18 var target = document.getElementById('select'); 19 var startX = target.offsetLeft + target.offsetWidth; 20 var y = target.offsetTop + target.offsetHeight / 2; 21 var endX = target.offsetLeft; 22 23 // Select all the green text using the mouse. 24 // Use a word-granularity selection to avoid eventSender bug. 25 // Using just a single-click would not act is if the initial 26 // mouseDown was at (endX, y), resulting in a collapsed selection. 27 eventSender.mouseMoveTo(startX, y); 28 eventSender.mouseDown(); 29 eventSender.mouseUp(); 30 eventSender.mouseDown(); 31 eventSender.mouseMoveTo(endX, y); 32 eventSender.mouseUp(); 24 33 // Extending this 5 character selection will select 6 characters on mac, 25 34 // but shrink the selection on win/linux. 26 35 layoutTestController.execCommand("MoveForwardAndModifySelection"); 27 36 // Extending it in this way flips the anchor and the focus on Mac. 28 var onMacPlatform = navigator.userAgent.search(/\bMac OS X\b/) != -1; 29 if (onMacPlatform && selection.focusOffset - selection.anchorOffset == 6 || 30 !onMacPlatform && selection.anchorOffset - selection.focusOffset == 4) 37 var selectedText = window.getSelection().toString(); 38 if (selectedText != expectedText) 39 log("Failure: Selected text was \"" + selectedText + "\" and should be \"" + expectedText + "\""); 40 else 31 41 log("Success"); 32 else 33 log("Failure: Selection isn't the right size. anchorOffset=" + selection.anchorOffset + 34 " focusOffset=" + selection.focusOffset + " onMacPlatform: " + onMacPlatform); 35 } else 36 log ("Failure: This test cannot be run manually.") 42 } 43 44 if (window.layoutTestController) { 45 layoutTestController.dumpAsText() 46 runTest('mac', 'should be s'); 47 runTest('win', 'hould be '); 48 } else { 49 log("Failure: To test manually, select the green text " + 50 "starting at the end via double-click (i.e. word granularity), then shift+right-arrow. " + 51 "On Win/Linux you should see 'hould be ' selected. On Mac, you should see 'should be s' selected." + 52 "There's currently a bug that selects the space " + 53 "after 'should be' during the initial selection (https://bugs.webkit.org/show_bug.cgi?id=36256). " + 54 "Once that's fixed, it the final selected text should be 'should be ' on Mac and 'hould be' on Win/Linux.") 55 } 37 56 </script> -
trunk/LayoutTests/platform/mac/editing/selection/5195166-1-expected.txt
r56567 r62816 3 3 There should be six characters selected in this sentence on Mac and four characters selected on Win/Linux. 4 4 Success 5 Success -
trunk/WebCore/ChangeLog
r62815 r62816 1 2010-07-07 Ojan Vafai <ojan@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Regression: Selection anchor + focus swap when arrow keys after setBaseAndExtent 6 https://bugs.webkit.org/show_bug.cgi?id=32605 7 8 Only have selections be non-directional when they are set via the mouse. 9 Otherwise, all selections are directional. 10 11 Test: editing/selection/extend-forward-after-set-base-and-extent.html 12 13 * WebCore.base.exp: 14 * editing/SelectionController.cpp: 15 (WebCore::SelectionController::setSelection): 16 * editing/SelectionController.h: 17 (WebCore::SelectionController::setSelection): 18 * page/EventHandler.cpp: 19 (WebCore::EventHandler::selectClosestWordFromMouseEvent): 20 (WebCore::EventHandler::selectClosestWordOrLinkFromMouseEvent): 21 (WebCore::EventHandler::handleMousePressEventTripleClick): 22 (WebCore::EventHandler::handleMousePressEventSingleClick): 23 (WebCore::EventHandler::updateSelectionForMouseDrag): 24 1 25 2010-07-08 Antonio Gomes <tonikitoo@webkit.org> 2 26 -
trunk/WebCore/WebCore.exp.in
r62809 r62816 404 404 __ZN7WebCore19InspectorController34inspectorStartsAttachedSettingNameEv 405 405 __ZN7WebCore19SelectionController10setFocusedEb 406 __ZN7WebCore19SelectionController12setSelectionERKNS_16VisibleSelectionEbbbNS0_19CursorAlignOnScrollENS_15TextGranularityE 406 __ZN7WebCore19SelectionController12setSelectionERKNS_16VisibleSelectionEbbbNS0_19CursorAlignOnScrollENS_15TextGranularityENS_20DirectionalityPolicyE 407 407 __ZN7WebCore19SelectionController16setSelectedRangeEPNS_5RangeENS_9EAffinityEb 408 408 __ZN7WebCore19SelectionController5clearEv -
trunk/WebCore/editing/SelectionController.cpp
r62693 r62816 108 108 } 109 109 110 void SelectionController::setSelection(const VisibleSelection& s, bool closeTyping, bool clearTypingStyle, bool userTriggered, CursorAlignOnScroll align, TextGranularity granularity )110 void SelectionController::setSelection(const VisibleSelection& s, bool closeTyping, bool clearTypingStyle, bool userTriggered, CursorAlignOnScroll align, TextGranularity granularity, DirectionalityPolicy directionalityPolicy) 111 111 { 112 112 m_granularity = granularity; 113 113 114 setIsDirectional( false);114 setIsDirectional(directionalityPolicy == MakeDirectionalSelection); 115 115 116 116 if (m_isDragCaretController) { -
trunk/WebCore/editing/SelectionController.h
r60463 r62816 42 42 class VisiblePosition; 43 43 44 enum DirectionalityPolicy { MakeNonDirectionalSelection, MakeDirectionalSelection }; 45 44 46 class SelectionController : public Noncopyable { 45 47 public: … … 63 65 64 66 const VisibleSelection& selection() const { return m_selection; } 65 void setSelection(const VisibleSelection&, bool closeTyping = true, bool clearTypingStyle = true, bool userTriggered = false, CursorAlignOnScroll = AlignCursorOnScrollIfNeeded, TextGranularity = CharacterGranularity );66 void setSelection(const VisibleSelection& selection, TextGranularity granularity ) { setSelection(selection, true, true, false, AlignCursorOnScrollIfNeeded, granularity); }67 void setSelection(const VisibleSelection&, bool closeTyping = true, bool clearTypingStyle = true, bool userTriggered = false, CursorAlignOnScroll = AlignCursorOnScrollIfNeeded, TextGranularity = CharacterGranularity, DirectionalityPolicy = MakeDirectionalSelection); 68 void setSelection(const VisibleSelection& selection, TextGranularity granularity, DirectionalityPolicy directionality = MakeDirectionalSelection) { setSelection(selection, true, true, false, AlignCursorOnScrollIfNeeded, granularity, directionality); } 67 69 bool setSelectedRange(Range*, EAffinity, bool closeTyping); 68 70 void selectAll(); -
trunk/WebCore/page/EventHandler.cpp
r62780 r62816 260 260 261 261 if (m_frame->shouldChangeSelection(newSelection)) 262 m_frame->selection()->setSelection(newSelection, granularity );262 m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); 263 263 } 264 264 } … … 285 285 286 286 if (m_frame->shouldChangeSelection(newSelection)) 287 m_frame->selection()->setSelection(newSelection, granularity );287 m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); 288 288 } 289 289 } … … 330 330 331 331 if (m_frame->shouldChangeSelection(newSelection)) 332 m_frame->selection()->setSelection(newSelection, granularity );332 m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); 333 333 334 334 return true; … … 397 397 398 398 if (m_frame->shouldChangeSelection(newSelection)) 399 m_frame->selection()->setSelection(newSelection, granularity );399 m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); 400 400 401 401 return true; … … 634 634 if (m_frame->shouldChangeSelection(newSelection)) { 635 635 m_frame->selection()->setIsDirectional(false); 636 m_frame->selection()->setSelection(newSelection, m_frame->selectionGranularity() );636 m_frame->selection()->setSelection(newSelection, m_frame->selectionGranularity(), MakeNonDirectionalSelection); 637 637 } 638 638 }
Note: See TracChangeset
for help on using the changeset viewer.