Changeset 56567 in webkit
- Timestamp:
- Mar 25, 2010 1:21:45 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 8 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r56562 r56567 1 2010-03-25 Ojan Vafai <ojan@chromium.org> 2 3 Reviewed by David Levin. 4 5 mouse-based selections are always directional on Window/Linux 6 https://bugs.webkit.org/show_bug.cgi?id=25195 7 8 The tests are modified to expect different things for Win/Linux vs. Mac. 9 10 * editing/selection/5195166-1.html: 11 * editing/selection/extend-after-mouse-selection.html: 12 * editing/selection/extend-selection-after-double-click-expected.txt: 13 * editing/selection/extend-selection-after-double-click.html: 14 * platform/chromium-linux/editing/selection/5195166-1-expected.checksum: Removed. 15 * platform/chromium-linux/editing/selection/5195166-1-expected.png: Removed. 16 * platform/chromium-win/editing/selection/5195166-1-expected.checksum: Removed. 17 * platform/chromium-win/editing/selection/5195166-1-expected.png: Removed. 18 * platform/chromium-win/editing/selection/5195166-1-expected.txt: Removed. 19 * platform/mac/editing/selection/5195166-1-expected.checksum: Removed. 20 * platform/mac/editing/selection/5195166-1-expected.png: Removed. 21 * platform/mac/editing/selection/5195166-1-expected.txt: 22 * platform/qt/editing/selection/5195166-1-expected.txt: Removed. 23 * platform/win/editing/selection/extend-after-mouse-selection-expected.txt: 24 1 25 2010-03-25 Simon Fraser <simon.fraser@apple.com> 2 26 -
trunk/LayoutTests/editing/selection/5195166-1.html
r29149 r56567 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 be five characters selected in this sentence.</div>2 <div id="div" contenteditable="true">There should be 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> … … 11 11 } 12 12 if (window.layoutTestController) { 13 layoutTestController.dumpAsText() 14 13 15 var text = document.getElementById("div").firstChild; 14 16 var selection = window.getSelection(); … … 20 22 21 23 selection.setBaseAndExtent(text, 3 + 5, text, 3); 22 // Extending this 5 character selection will select 6 characters. 24 // Extending this 5 character selection will select 6 characters on mac, 25 // but shrink the selection on win/linux. 23 26 layoutTestController.execCommand("MoveForwardAndModifySelection"); 24 // Extending it in this way flips the base and the extent. 25 if (selection.extentOffset - selection.baseOffset != 6) 26 log("Failure: Selection isn't the right size."); 27 // 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) 31 log("Success"); 27 32 else 28 log ("Success"); 33 log("Failure: Selection isn't the right size. anchorOffset=" + selection.anchorOffset + 34 " focusOffset=" + selection.focusOffset + " onMacPlatform: " + onMacPlatform); 29 35 } else 30 36 log ("Failure: This test cannot be run manually.") -
trunk/LayoutTests/editing/selection/extend-after-mouse-selection.html
r54980 r56567 1 <html> 1 <html> 2 2 <head> 3 3 4 4 <style> 5 .editing { 6 border: 2px solid red; 7 font-size: 24px; 5 .editing { 6 border: 2px solid red; 7 font-size: 24px; 8 8 } 9 9 </style> … … 25 25 // character granularity (i.e. that it just doesn't work). 26 26 eventSender.mouseDown(); 27 eventSender.mouseUp(); 27 eventSender.mouseUp(); 28 28 eventSender.mouseDown(); 29 29 eventSender.mouseMoveTo(endTarget.offsetLeft, endTarget.offsetTop + 10); 30 eventSender.mouseUp(); 30 eventSender.mouseUp(); 31 31 32 32 assertSelectionAt(startTarget.firstChild, 0, endTarget.firstChild, 2); … … 34 34 extendSelectionBackwardByCharacterCommand(); 35 35 36 // The first character-granularity selection after a mouse-selection resets the anchor/focus. 37 // FIXME: On Win/Linux the anchor/focus should be fixed after the mouse-selection. 38 assertSelectionAt(endTarget.firstChild, 2, startTarget.previousSibling, 1); 36 37 // On Win/Linux the anchor is be fixed after the mouse-selection and never changes. 38 // On Mac, the first character-granularity selection after a mouse-selection resets the anchor/focus. 39 if (onMacPlatform) 40 assertSelectionAt(endTarget.firstChild, 2, startTarget.previousSibling, 1); 41 else 42 assertSelectionAt(startTarget.firstChild, 0, endTarget.firstChild, 1); 39 43 40 44 extendSelectionForwardByCharacterCommand(); 41 assertSelectionAt(endTarget.firstChild, 2, startTarget.firstChild, 0); 42 45 if (onMacPlatform) 46 assertSelectionAt(endTarget.firstChild, 2, startTarget.firstChild, 0); 47 else 48 assertSelectionAt(startTarget.firstChild, 0, endTarget.firstChild, 2); 49 43 50 extendSelectionForwardByLineBoundaryCommand(); 44 51 45 52 if (onMacPlatform) { 46 53 // FIXME: This encodes what TextEdit does. Currently WebKit does the wrong thing. 47 54 // The selection should go from the beginning of startTarget to the end of the line that endTarget is on. 48 55 assertSelectionAt(endTarget.nextSibling, 1, startTarget.firstChild, 0); 49 } else { 50 // Seleciton goes from the end of "ef" to the first BR element in the contentEditable region. 51 assertSelectionAt(endTarget.firstChild, 2, document.getElementById('test'), 3); 52 } 53 56 } else 57 assertSelectionAt(startTarget.firstChild, 0, endTarget.nextSibling, 1); 58 54 59 extendSelectionBackwardByLineBoundaryCommand(); 55 60 … … 59 64 assertSelectionAt(endTarget.nextSibling, 1, startTarget.previousSibling, 0); 60 65 } else 61 assertSelectionAt( endTarget.firstChild, 2, startTarget.previousSibling, 0);66 assertSelectionAt(startTarget.firstChild, 0, document.getElementById('test'), 4); 62 67 } 63 68 64 69 </script> 65 70 66 <title>Editing Test</title> 67 </head> 71 <title>Editing Test</title> 72 </head> 68 73 <body> 69 74 <div contenteditable id="root" class="editing"> -
trunk/LayoutTests/editing/selection/extend-selection-after-double-click-expected.txt
r45945 r56567 1 1 This tests modifying a selection created with a double click with shift arrow key. 2 2 3 This test does not run interactively. It uses the event sender to do mouse clicks. To run it manually, double click on the blue "g", then press shift-left-arrow twice. Then repeat those steps again. The selection should include the words "a paragraph" .3 This test does not run interactively. It uses the event sender to do mouse clicks. To run it manually, double click on the blue "g", then press shift-left-arrow twice. Then repeat those steps again. The selection should include the words "a paragraph" on mac and "paragra" on win/linux.. 4 4 5 5 This is a paragraph. 6 6 7 SUCCESS : The selection was extended to the left of the word.7 SUCCESS -
trunk/LayoutTests/editing/selection/extend-selection-after-double-click.html
r45945 r56567 35 35 var result; 36 36 var selectedText = getSelection().toString(); 37 if (selectedText == "a paragraph") 38 result = "SUCCESS: The selection was extended to the left of the word."; 37 var onMacPlatform = navigator.userAgent.search(/\bMac OS X\b/) != -1; 38 var expectedText = onMacPlatform ? "a paragraph" : "paragra"; 39 if (selectedText == expectedText) 40 result = "SUCCESS"; 39 41 else 40 result = "FAILURE: The selected text is \"" + selectedText + "\" .";42 result = "FAILURE: The selected text is \"" + selectedText + "\" and should be \"" + expectedText + "\"."; 41 43 document.getElementById("result").firstChild.data = result; 42 44 } … … 50 52 To run it manually, double click on the blue "g", then press shift-left-arrow twice. 51 53 Then repeat those steps again. 52 The selection should include the words "a paragraph" .54 The selection should include the words "a paragraph" on mac and "paragra" on win/linux.. 53 55 </p> 54 56 <p>This is a para<span style="color:blue" id="start">g</span>raph.</p> -
trunk/LayoutTests/platform/mac/editing/selection/5195166-1-expected.txt
r43215 r56567 1 layer at (0,0) size 800x600 2 RenderView at (0,0) size 800x600 3 layer at (0,0) size 800x600 4 RenderBlock {HTML} at (0,0) size 800x600 5 RenderBody {BODY} at (8,8) size 784x576 6 RenderBlock {P} at (0,0) size 784x18 7 RenderText {#text} at (0,0) size 704x18 8 text run at (0,0) width 704: "This tests for a bug where extending a selection created with the mouse would blow it away before extending it." 9 RenderBlock {DIV} at (0,34) size 784x18 10 RenderText {#text} at (0,0) size 355x18 11 text run at (0,0) width 355: "There should be five characters selected in this sentence." 12 RenderBlock {UL} at (0,68) size 784x18 13 RenderListItem {LI} at (40,0) size 744x18 14 RenderListMarker at (-17,0) size 7x18: bullet 15 RenderText {#text} at (0,0) size 50x18 16 text run at (0,0) width 50: "Success" 17 selection start: position 3 of child 0 {#text} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document 18 selection end: position 9 of child 0 {#text} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document 1 This tests for a bug where extending a selection created with the mouse would blow it away before extending it. 2 3 There should be six characters selected in this sentence on Mac and four characters selected on Win/Linux. 4 Success -
trunk/LayoutTests/platform/win/editing/selection/extend-after-mouse-selection-expected.txt
r54980 r56567 3 3 ghi 4 4 PASS Selection is [anchorNode: [object Text](bc) anchorOffset: 0 focusNode: [object Text](ef) focusOffset: 2 isCollapsed: false] 5 PASS Selection is [anchorNode: [object Text]( ef) anchorOffset: 2 focusNode: [object Text](a) focusOffset: 1 isCollapsed: false]6 PASS Selection is [anchorNode: [object Text]( ef) anchorOffset: 2 focusNode: [object Text](bc) focusOffset: 0isCollapsed: false]7 PASS Selection is [anchorNode: [object Text]( ef) anchorOffset: 2 focusNode: [object HTMLElement](null) focusOffset: 3isCollapsed: false]8 PASS Selection is [anchorNode: [object Text]( ef) anchorOffset: 2 focusNode: [object Text](a ) focusOffset: 0isCollapsed: false]5 PASS Selection is [anchorNode: [object Text](bc) anchorOffset: 0 focusNode: [object Text](ef) focusOffset: 1 isCollapsed: false] 6 PASS Selection is [anchorNode: [object Text](bc) anchorOffset: 0 focusNode: [object Text](ef) focusOffset: 2 isCollapsed: false] 7 PASS Selection is [anchorNode: [object Text](bc) anchorOffset: 0 focusNode: [object Text]( ) focusOffset: 1 isCollapsed: false] 8 PASS Selection is [anchorNode: [object Text](bc) anchorOffset: 0 focusNode: [object HTMLElement](null) focusOffset: 4 isCollapsed: false] 9 9 PASS successfullyParsed is true 10 10 -
trunk/WebCore/ChangeLog
r56565 r56567 1 2010-03-25 Ojan Vafai <ojan@chromium.org> 2 3 Reviewed by David Levin. 4 5 mouse-based selections are always directional on Windows/Linux 6 https://bugs.webkit.org/show_bug.cgi?id=25195 7 8 Change m_lastChangeWasHorizontalExtension to m_isDirectional 9 and make m_isDirectional always be true for Windows/Linux. 10 11 * editing/SelectionController.cpp: 12 (WebCore::SelectionController::SelectionController): 13 (WebCore::SelectionController::setSelection): 14 (WebCore::SelectionController::setIsDirectional): 15 (WebCore::SelectionController::willBeModified): 16 When double-clicking, the base/extent will be in the middle 17 of the selection instead of the start/end of it. Changed to 18 maintain that modifications after double-click still move the 19 start/end of the selection, not the base/extent. 20 (WebCore::SelectionController::modify): 21 * editing/SelectionController.h: 22 * page/EventHandler.cpp: 23 (WebCore::EventHandler::handleMousePressEventSingleClick): 24 (WebCore::EventHandler::updateSelectionForMouseDrag): 25 1 26 2010-03-25 Simon Fraser <simon.fraser@apple.com> 2 27 -
trunk/WebCore/editing/SelectionController.cpp
r56175 r56567 71 71 , m_needsLayout(true) 72 72 , m_absCaretBoundsDirty(true) 73 , m_lastChangeWasHorizontalExtension(false)74 73 , m_isDragCaretController(isDragCaretController) 75 74 , m_isCaretBlinkingSuspended(false) … … 78 77 , m_caretPaint(true) 79 78 { 79 setIsDirectional(false); 80 80 } 81 81 … … 110 110 m_granularity = granularity; 111 111 112 m_lastChangeWasHorizontalExtension = false;112 setIsDirectional(false); 113 113 114 114 if (m_isDragCaretController) { … … 233 233 setSelection(VisibleSelection(), false, false); 234 234 } 235 236 void SelectionController::setIsDirectional(bool isDirectional) 237 { 238 Settings* settings = m_frame ? m_frame->settings() : 0; 239 m_isDirectional = !settings || (settings->editingBehavior() == EditingMacBehavior && isDirectional); 240 } 235 241 236 242 void SelectionController::willBeModified(EAlteration alter, EDirection direction) 237 243 { 238 244 if (alter != EXTEND) 239 return;240 if (m_lastChangeWasHorizontalExtension)241 245 return; 242 246 243 247 Position start = m_selection.start(); 244 248 Position end = m_selection.end(); 245 // FIXME: This is probably not correct for right and left when the direction is RTL. 246 switch (direction) { 249 250 if (m_isDirectional) { 251 // Make base and extent match start and end so we extend the user-visible selection. 252 // This only matters for cases where base and extend point to different positions than 253 // start and end (e.g. after a double-click to select a word). 254 if (m_selection.isBaseFirst()) { 255 m_selection.setBase(start); 256 m_selection.setExtent(end); 257 } else { 258 m_selection.setBase(end); 259 m_selection.setExtent(start); 260 } 261 } else { 262 // FIXME: This is probably not correct for right and left when the direction is RTL. 263 switch (direction) { 247 264 case RIGHT: 248 265 case FORWARD: … … 255 272 m_selection.setExtent(start); 256 273 break; 274 } 257 275 } 258 276 } … … 598 616 SelectionController trialSelectionController; 599 617 trialSelectionController.setSelection(m_selection); 600 trialSelectionController.set LastChangeWasHorizontalExtension(m_lastChangeWasHorizontalExtension);618 trialSelectionController.setIsDirectional(m_isDirectional); 601 619 trialSelectionController.modify(alter, dir, granularity, false); 602 620 … … 663 681 setNeedsLayout(); 664 682 665 m_lastChangeWasHorizontalExtension = alter == EXTEND;683 setIsDirectional(alter == EXTEND); 666 684 667 685 return true; … … 686 704 SelectionController trialSelectionController; 687 705 trialSelectionController.setSelection(m_selection); 688 trialSelectionController.set LastChangeWasHorizontalExtension(m_lastChangeWasHorizontalExtension);706 trialSelectionController.setIsDirectional(m_isDirectional); 689 707 trialSelectionController.modify(alter, verticalDistance, false); 690 708 … … 756 774 m_granularity = CharacterGranularity; 757 775 758 m_lastChangeWasHorizontalExtension = alter == EXTEND;776 setIsDirectional(alter == EXTEND); 759 777 760 778 return true; -
trunk/WebCore/editing/SelectionController.h
r56175 r56567 98 98 void setNeedsLayout(bool flag = true); 99 99 100 void set LastChangeWasHorizontalExtension(bool b) { m_lastChangeWasHorizontalExtension = b; }100 void setIsDirectional(bool); 101 101 void willBeModified(EAlteration, EDirection); 102 102 … … 190 190 bool m_needsLayout; // true if m_caretRect and m_absCaretBounds need to be calculated 191 191 bool m_absCaretBoundsDirty; 192 bool m_ lastChangeWasHorizontalExtension;192 bool m_isDirectional; 193 193 bool m_isDragCaretController; 194 194 bool m_isCaretBlinkingSuspended; -
trunk/WebCore/page/EventHandler.cpp
r56327 r56567 357 357 358 358 if (extendSelection && newSelection.isCaretOrRange()) { 359 m_frame->selection()->set LastChangeWasHorizontalExtension(false);359 m_frame->selection()->setIsDirectional(false); 360 360 361 361 // See <rdar://problem/3668157> REGRESSION (Mail): shift-click deselects when selection … … 592 592 593 593 if (m_frame->shouldChangeSelection(newSelection)) { 594 m_frame->selection()->set LastChangeWasHorizontalExtension(false);594 m_frame->selection()->setIsDirectional(false); 595 595 m_frame->selection()->setSelection(newSelection, m_frame->selectionGranularity()); 596 596 }
Note: See TracChangeset
for help on using the changeset viewer.