- Revision
- 240829
- Author
- megan_gard...@apple.com
- Date
- 2019-01-31 16:38:55 -0800 (Thu, 31 Jan 2019)
Log Message
Don't insert spaces at the beginning of a newline when using smart-copy-paste
https://bugs.webkit.org/show_bug.cgi?id=194070
Source/WebCore:
Reviewed by Tim Horton.
If our inserted content end is at the beginning of a paragraph, do not insert a space.
Also, if our inserted content beginning is at the end of a paragraph, do not insert a space.
Test: editing/pasteboard/mac/copy-smartpaste-first-line-in-textarea.html
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::addSpacesForSmartReplace):
LayoutTests:
Add test for smart copy paste around newlines.
Rebaseline a test that is dependant on a console log that changes lines.
Add additional helper functions to ui-helper.js.
Reviewed by Tim Horton.
* editing/pasteboard/mac/copy-smartpaste-first-line-in-textarea-expected.txt: Added.
* editing/pasteboard/mac/copy-smartpaste-first-line-in-textarea.html: Added.
* http/tests/security/anchor-download-block-crossorigin-expected.txt:
* platform/mac/TestExpectations:
* resources/ui-helper.js:
(window.UIHelper.doubleClickAt):
(window.UIHelper.doubleClickAtThenDragTo):
(window.UIHelper.async.selectWordByDoubleTapOrClick):
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (240828 => 240829)
--- trunk/LayoutTests/ChangeLog 2019-02-01 00:34:58 UTC (rev 240828)
+++ trunk/LayoutTests/ChangeLog 2019-02-01 00:38:55 UTC (rev 240829)
@@ -1,3 +1,23 @@
+2019-01-31 Megan Gardner <megan_gard...@apple.com>
+
+ Don't insert spaces at the beginning of a newline when using smart-copy-paste
+ https://bugs.webkit.org/show_bug.cgi?id=194070
+
+ Add test for smart copy paste around newlines.
+ Rebaseline a test that is dependant on a console log that changes lines.
+ Add additional helper functions to ui-helper.js.
+
+ Reviewed by Tim Horton.
+
+ * editing/pasteboard/mac/copy-smartpaste-first-line-in-textarea-expected.txt: Added.
+ * editing/pasteboard/mac/copy-smartpaste-first-line-in-textarea.html: Added.
+ * http/tests/security/anchor-download-block-crossorigin-expected.txt:
+ * platform/mac/TestExpectations:
+ * resources/ui-helper.js:
+ (window.UIHelper.doubleClickAt):
+ (window.UIHelper.doubleClickAtThenDragTo):
+ (window.UIHelper.async.selectWordByDoubleTapOrClick):
+
2019-01-31 Joseph Pecoraro <pecor...@apple.com>
Web Inspector: Timeline time range selection sometimes shows 0.000, should be just 0
Modified: trunk/LayoutTests/TestExpectations (240828 => 240829)
--- trunk/LayoutTests/TestExpectations 2019-02-01 00:34:58 UTC (rev 240828)
+++ trunk/LayoutTests/TestExpectations 2019-02-01 00:38:55 UTC (rev 240829)
@@ -52,6 +52,7 @@
system-preview [ Skip ]
editing/images [ Skip ]
pointerevents/ios [ Skip ]
+editing/pasteboard/mac [ Skip ]
# window.showModalDialog is only tested in DumpRenderTree on Mac.
editing/execCommand/show-modal-dialog-during-execCommand.html [ Skip ]
Added: trunk/LayoutTests/editing/pasteboard/mac/copy-smartpaste-first-line-in-textarea-expected.txt (0 => 240829)
--- trunk/LayoutTests/editing/pasteboard/mac/copy-smartpaste-first-line-in-textarea-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/mac/copy-smartpaste-first-line-in-textarea-expected.txt 2019-02-01 00:38:55 UTC (rev 240829)
@@ -0,0 +1,3 @@
+
+PASS selectFirstLineIncludingLineBreak(); copyPaste(); textarea.selectionEnd is offsetAfterLineBreak
+
Added: trunk/LayoutTests/editing/pasteboard/mac/copy-smartpaste-first-line-in-textarea.html (0 => 240829)
--- trunk/LayoutTests/editing/pasteboard/mac/copy-smartpaste-first-line-in-textarea.html (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/mac/copy-smartpaste-first-line-in-textarea.html 2019-02-01 00:38:55 UTC (rev 240829)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<body>
+<textarea id="test" cols=50 rows=10>first
+second</textarea>
+<script src=""
+<script src=""
+<script src=""
+<p id="console"></p>
+<script>
+
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+var textarea = document.querySelector('textarea');
+
+function selectFirstLineIncludingLineBreak() {
+ var element = document.getElementById("test");
+ const boundingRect = element.getBoundingClientRect();
+ const x = boundingRect.x + 5;
+ const y = boundingRect.y + 5;
+ UIHelper.doubleClickAtThenDragTo(x, y, x + boundingRect.width/2, y);
+}
+
+function copyPaste() {
+ document.execCommand('copy');
+ document.execCommand('paste');
+}
+
+var offsetAfterLineBreak = 6;
+shouldBe("selectFirstLineIncludingLineBreak(); copyPaste(); textarea.selectionEnd", "offsetAfterLineBreak");
+
+</script>
+</body>
+</html>
Modified: trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin-expected.txt (240828 => 240829)
--- trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin-expected.txt 2019-02-01 00:34:58 UTC (rev 240828)
+++ trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin-expected.txt 2019-02-01 00:38:55 UTC (rev 240829)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 88: The download attribute on anchor was ignored because its href URL has a different security origin.
+CONSOLE MESSAGE: line 107: The download attribute on anchor was ignored because its href URL has a different security origin.
Tests that the download attribute is ignored if the link is cross origin.
It should navigate the subframe instead of downloading the file.
Modified: trunk/LayoutTests/platform/mac/TestExpectations (240828 => 240829)
--- trunk/LayoutTests/platform/mac/TestExpectations 2019-02-01 00:34:58 UTC (rev 240828)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2019-02-01 00:38:55 UTC (rev 240829)
@@ -11,6 +11,7 @@
editing/mac [ Pass ]
fast/scrolling/latching [ Pass ]
media/mac [ Pass ]
+editing/pasteboard/mac [ Pass ]
fast/forms/search/search-padding-cancel-results-buttons.html [ Pass ]
fast/forms/search/search-results-hidden-crash.html [ Pass ]
Modified: trunk/LayoutTests/resources/ui-helper.js (240828 => 240829)
--- trunk/LayoutTests/resources/ui-helper.js 2019-02-01 00:34:58 UTC (rev 240828)
+++ trunk/LayoutTests/resources/ui-helper.js 2019-02-01 00:38:55 UTC (rev 240829)
@@ -10,6 +10,25 @@
return window.testRunner.isWebKit2;
}
+ static doubleClickAt(x, y)
+ {
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+
+ static doubleClickAtThenDragTo(x1, y1, x2, y2)
+ {
+ eventSender.mouseMoveTo(x1, y1);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(x2, y2);
+ eventSender.mouseUp();
+ }
+
static tapAt(x, y)
{
console.assert(this.isIOS());
@@ -104,6 +123,22 @@
return UIHelper.activateAt(x, y);
}
+ static async selectWordByDoubleTapOrClick(element, relativeX = 5, relativeY = 5)
+ {
+ const boundingRect = element.getBoundingClientRect();
+ const x = boundingRect.x + relativeX;
+ const y = boundingRect.y + relativeY;
+ if (this.isIOS()) {
+ await UIHelper.tapAt(x, y);
+ await UIHelper.doubleTapAt(x, y);
+ // This is only here to deal with async/sync copy/paste calls, so
+ // once <rdar://problem/16207002> is resolved, should be able to remove for faster tests.
+ await new Promise(resolve => testRunner.runUIScript("uiController.uiScriptComplete()", resolve));
+ } else {
+ await UIHelper.doubleClickAt(x, y);
+ }
+ }
+
static keyDown(key, modifiers=[])
{
if (!this.isWebKit2() || !this.isIOS()) {
Modified: trunk/Source/WebCore/ChangeLog (240828 => 240829)
--- trunk/Source/WebCore/ChangeLog 2019-02-01 00:34:58 UTC (rev 240828)
+++ trunk/Source/WebCore/ChangeLog 2019-02-01 00:38:55 UTC (rev 240829)
@@ -1,3 +1,18 @@
+2019-01-31 Megan Gardner <megan_gard...@apple.com>
+
+ Don't insert spaces at the beginning of a newline when using smart-copy-paste
+ https://bugs.webkit.org/show_bug.cgi?id=194070
+
+ Reviewed by Tim Horton.
+
+ If our inserted content end is at the beginning of a paragraph, do not insert a space.
+ Also, if our inserted content beginning is at the end of a paragraph, do not insert a space.
+
+ Test: editing/pasteboard/mac/copy-smartpaste-first-line-in-textarea.html
+
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::addSpacesForSmartReplace):
+
2019-01-31 Justin Fan <justin_...@apple.com>
[WebGPU] Build fix: disable MTLCopyAllDevices call on non-Mac platforms
Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (240828 => 240829)
--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2019-02-01 00:34:58 UTC (rev 240828)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2019-02-01 00:38:55 UTC (rev 240829)
@@ -1344,7 +1344,7 @@
endOffset = endUpstream.offsetInContainerNode();
}
- bool needsTrailingSpace = !isEndOfParagraph(endOfInsertedContent) && !isCharacterSmartReplaceExemptConsideringNonBreakingSpace(endOfInsertedContent.characterAfter(), false);
+ bool needsTrailingSpace = !isEndOfParagraph(endOfInsertedContent) && !isStartOfParagraph(endOfInsertedContent) && !isCharacterSmartReplaceExemptConsideringNonBreakingSpace(endOfInsertedContent.characterAfter(), false);
if (needsTrailingSpace && endNode) {
bool collapseWhiteSpace = !endNode->renderer() || endNode->renderer()->style().collapseWhiteSpace();
if (is<Text>(*endNode)) {
@@ -1368,7 +1368,7 @@
startOffset = startDownstream.offsetInContainerNode();
}
- bool needsLeadingSpace = !isStartOfParagraph(startOfInsertedContent) && !isCharacterSmartReplaceExemptConsideringNonBreakingSpace(startOfInsertedContent.previous().characterAfter(), true);
+ bool needsLeadingSpace = !isStartOfParagraph(startOfInsertedContent) && !isEndOfParagraph(startOfInsertedContent) && !isCharacterSmartReplaceExemptConsideringNonBreakingSpace(startOfInsertedContent.previous().characterAfter(), true);
if (needsLeadingSpace && startNode) {
bool collapseWhiteSpace = !startNode->renderer() || startNode->renderer()->style().collapseWhiteSpace();
if (is<Text>(*startNode)) {