Diff
Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (249988 => 249989)
--- branches/safari-608-branch/Source/WebCore/ChangeLog 2019-09-17 22:29:17 UTC (rev 249988)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog 2019-09-17 22:29:20 UTC (rev 249989)
@@ -1,5 +1,49 @@
2019-09-17 Kocsen Chung <[email protected]>
+ Cherry-pick r249701. rdar://problem/55291696
+
+ Tap and hold on Facebook sometimes creates a tall empty selection.
+ https://bugs.webkit.org/show_bug.cgi?id=201618
+ rdar://53630145
+
+ Reviewed by Megan Gardner.
+
+ Source/WebCore:
+
+ API Test: SelectionTests.ByWordAtEndOfDocument
+
+ * editing/VisibleUnits.cpp:
+ (WebCore::wordRangeFromPosition):
+ Remove special case code for the possibility of an empty paragraph and at the end
+ of the document. This is no longer needed and was causing a large selection to be
+ created on Facebook due to large areas of non-selectable content on the page.
+
+ Tools:
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/ios/SelectionByWord.mm: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249701 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-09-09 Timothy Hatcher <[email protected]>
+
+ Tap and hold on Facebook sometimes creates a tall empty selection.
+ https://bugs.webkit.org/show_bug.cgi?id=201618
+ rdar://53630145
+
+ Reviewed by Megan Gardner.
+
+ API Test: SelectionTests.ByWordAtEndOfDocument
+
+ * editing/VisibleUnits.cpp:
+ (WebCore::wordRangeFromPosition):
+ Remove special case code for the possibility of an empty paragraph and at the end
+ of the document. This is no longer needed and was causing a large selection to be
+ created on Facebook due to large areas of non-selectable content on the page.
+
+2019-09-17 Kocsen Chung <[email protected]>
+
Cherry-pick r249511. rdar://problem/55291693
Cancelled transitions on Google image search leave content with opacity 0 sometimes
Modified: branches/safari-608-branch/Source/WebCore/editing/VisibleUnits.cpp (249988 => 249989)
--- branches/safari-608-branch/Source/WebCore/editing/VisibleUnits.cpp 2019-09-17 22:29:17 UTC (rev 249988)
+++ branches/safari-608-branch/Source/WebCore/editing/VisibleUnits.cpp 2019-09-17 22:29:20 UTC (rev 249989)
@@ -1969,6 +1969,7 @@
// We could be at the start of a word, try forward.
range = enclosingTextUnitOfGranularity(position, WordGranularity, DirectionForward);
}
+
if (range)
return range;
@@ -1977,18 +1978,6 @@
currentPosition = positionOfNextBoundaryOfGranularity(currentPosition, WordGranularity, DirectionBackward);
} while (currentPosition.isNotNull() && !atBoundaryOfGranularity(currentPosition, WordGranularity, DirectionBackward));
- // If the position is an empty paragraph and at the end of the document
- // the word iterator could not pass the paragraph boundary, therefore iterating to
- // the previous line is required.
- if (currentPosition.isNull() && isEndOfDocument(position)) {
- VisiblePosition previousLinePosition = positionOfNextBoundaryOfGranularity(position, LineGranularity, DirectionBackward);
- if (previousLinePosition.isNotNull()) {
- currentPosition = positionOfNextBoundaryOfGranularity(previousLinePosition, WordGranularity, DirectionBackward);
- if (currentPosition.isNull())
- currentPosition = previousLinePosition;
- }
- }
-
if (currentPosition.isNull())
currentPosition = positionOfNextBoundaryOfGranularity(position, WordGranularity, DirectionForward);
@@ -1996,6 +1985,7 @@
range = Range::create(position.deepEquivalent().deprecatedNode()->document(), currentPosition, position);
ASSERT(range);
}
+
return range;
}
Modified: branches/safari-608-branch/Tools/ChangeLog (249988 => 249989)
--- branches/safari-608-branch/Tools/ChangeLog 2019-09-17 22:29:17 UTC (rev 249988)
+++ branches/safari-608-branch/Tools/ChangeLog 2019-09-17 22:29:20 UTC (rev 249989)
@@ -1,3 +1,42 @@
+2019-09-17 Kocsen Chung <[email protected]>
+
+ Cherry-pick r249701. rdar://problem/55291696
+
+ Tap and hold on Facebook sometimes creates a tall empty selection.
+ https://bugs.webkit.org/show_bug.cgi?id=201618
+ rdar://53630145
+
+ Reviewed by Megan Gardner.
+
+ Source/WebCore:
+
+ API Test: SelectionTests.ByWordAtEndOfDocument
+
+ * editing/VisibleUnits.cpp:
+ (WebCore::wordRangeFromPosition):
+ Remove special case code for the possibility of an empty paragraph and at the end
+ of the document. This is no longer needed and was causing a large selection to be
+ created on Facebook due to large areas of non-selectable content on the page.
+
+ Tools:
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/ios/SelectionByWord.mm: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249701 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-09-09 Timothy Hatcher <[email protected]>
+
+ Tap and hold on Facebook sometimes creates a tall empty selection.
+ https://bugs.webkit.org/show_bug.cgi?id=201618
+ rdar://53630145
+
+ Reviewed by Megan Gardner.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/ios/SelectionByWord.mm: Added.
+
2019-09-09 Ryosuke Niwa <[email protected]>
REGRESSION (iOS 13): Bulleted list copied from Notes to Mail results in Times New Roman
Modified: branches/safari-608-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (249988 => 249989)
--- branches/safari-608-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-09-17 22:29:17 UTC (rev 249988)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-09-17 22:29:20 UTC (rev 249989)
@@ -89,6 +89,7 @@
1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81851C89252300A5529F /* Ahem.ttf */; };
1C734B5320788C4800F430EA /* SystemColors.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C734B5220788C4800F430EA /* SystemColors.mm */; };
1C7FEB20207C0F2E00D23278 /* BackgroundColor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C7FEB1F207C0F2D00D23278 /* BackgroundColor.mm */; };
+ 1C90420C2326E03C00BEF91E /* SelectionByWord.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C90420B2326E03C00BEF91E /* SelectionByWord.mm */; };
1C9EB8411E380DA1005C6442 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */; };
1CACADA1230620AE0007D54C /* WKWebViewOpaque.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CACADA0230620AD0007D54C /* WKWebViewOpaque.mm */; };
1CAD1F861E5CE7DA00AF2C2C /* FontCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD1F851E5CE7DA00AF2C2C /* FontCache.cpp */; };
@@ -1497,6 +1498,7 @@
1C2B81851C89252300A5529F /* Ahem.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Ahem.ttf; sourceTree = "<group>"; };
1C734B5220788C4800F430EA /* SystemColors.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemColors.mm; sourceTree = "<group>"; };
1C7FEB1F207C0F2D00D23278 /* BackgroundColor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BackgroundColor.mm; sourceTree = "<group>"; };
+ 1C90420B2326E03C00BEF91E /* SelectionByWord.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SelectionByWord.mm; sourceTree = "<group>"; };
1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextController.cpp; sourceTree = "<group>"; };
1CACADA0230620AD0007D54C /* WKWebViewOpaque.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewOpaque.mm; sourceTree = "<group>"; };
1CAD1F851E5CE7DA00AF2C2C /* FontCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontCache.cpp; sourceTree = "<group>"; };
@@ -3033,6 +3035,7 @@
F464AF9120BB66EA007F9B18 /* RenderingProgressTests.mm */,
F4C8797E2059D8D3009CD00B /* ScrollViewInsetTests.mm */,
0FF1134D22D68679009A81DA /* ScrollViewScrollabilityTests.mm */,
+ 1C90420B2326E03C00BEF91E /* SelectionByWord.mm */,
9B4B5EA422DEBE19001E3D5A /* SelectionModifyByParagraphBoundary.mm */,
CE6E819F20A6935F00E2C80F /* SetTimeoutFunction.mm */,
4433A395208044130091ED57 /* SynchronousTimeoutTests.mm */,
@@ -4607,6 +4610,7 @@
F4C8797F2059D8D3009CD00B /* ScrollViewInsetTests.mm in Sources */,
0FF1134E22D68679009A81DA /* ScrollViewScrollabilityTests.mm in Sources */,
CE06DF9B1E1851F200E570C9 /* SecurityOrigin.cpp in Sources */,
+ 1C90420C2326E03C00BEF91E /* SelectionByWord.mm in Sources */,
9B4B5EA522DEBE19001E3D5A /* SelectionModifyByParagraphBoundary.mm in Sources */,
5769C50B1D9B0002000847FB /* SerializedCryptoKeyWrap.mm in Sources */,
51EB12941FDF052500A5A1BD /* ServiceWorkerBasic.mm in Sources */,
Added: branches/safari-608-branch/Tools/TestWebKitAPI/Tests/ios/SelectionByWord.mm (0 => 249989)
--- branches/safari-608-branch/Tools/TestWebKitAPI/Tests/ios/SelectionByWord.mm (rev 0)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/Tests/ios/SelectionByWord.mm 2019-09-17 22:29:20 UTC (rev 249989)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if PLATFORM(IOS_FAMILY)
+
+#import "PlatformUtilities.h"
+#import "TestInputDelegate.h"
+#import "TestWKWebView.h"
+#import "UIKitSPI.h"
+
+@interface WKContentView (Private)
+- (void)selectWordForReplacement;
+@end
+
+TEST(SelectionTests, ByWordAtEndOfDocument)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] init]);
+
+ [webView synchronouslyLoadHTMLString:@"<body><p>Paragraph One</p><p style='-webkit-user-select: none'>Paragraph Two</p><p>Paragraph Three</p><p></p></body>"];
+
+ [webView stringByEvaluatingJavaScript:@"getSelection().setPosition(document.body.lastChild, 0)"];
+
+ EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"getSelection().isCollapsed"].boolValue);
+
+ // This method triggers the wordRangeFromPosition() code to be tested.
+ [[webView wkContentView] selectWordForReplacement];
+
+ EXPECT_FALSE([webView stringByEvaluatingJavaScript:@"getSelection().isCollapsed"].boolValue);
+ EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"getSelection().anchorNode.nodeValue"], "Paragraph Three");
+ EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"getSelection().anchorOffset"], "10");
+ EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"getSelection().focusNode.nodeValue"], "Paragraph Three");
+ EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"getSelection().focusOffset"], "15");
+
+ EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"getSelection().toString()"], "Three");
+}
+
+#endif // PLATFORM(IOS_FAMILY)