Title: [252061] trunk/Tools
Revision
252061
Author
dba...@webkit.org
Date
2019-11-05 10:39:49 -0800 (Tue, 05 Nov 2019)

Log Message

TestWebKitAPI.WebKit.DocumentEditingContext is failing on iPad
https://bugs.webkit.org/show_bug.cgi?id=203828
<rdar://problem/55854631>

Reviewed by Myles Maxfield.

Specify both a font size and line height when using Ahem as per [1]. Otherwise, text may be
rendered inconsistently. Plus, disable text-autosizing and fix viewport to make test result
consistent on both iPhone and iPad.

[1] <https://web-platform-tests.org/writing-tests/ahem.html>

* TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:
(applyStyle): Remove unused style for <iframe>s and fix up parameter name to conform to style guide.
(applyAhemStyle): Set -webkit-text-size-adjust to 100% to disable auto-sizing. Fix viewport width
and initial scale to ensure the result is the same on both iPhone and iPad. Also remove unused style
for <iframe>s and renamed parameter name to conform to style guide.
(TEST):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (252060 => 252061)


--- trunk/Tools/ChangeLog	2019-11-05 18:25:38 UTC (rev 252060)
+++ trunk/Tools/ChangeLog	2019-11-05 18:39:49 UTC (rev 252061)
@@ -1,3 +1,24 @@
+2019-11-05  Daniel Bates  <daba...@apple.com>
+
+        TestWebKitAPI.WebKit.DocumentEditingContext is failing on iPad
+        https://bugs.webkit.org/show_bug.cgi?id=203828
+        <rdar://problem/55854631>
+
+        Reviewed by Myles Maxfield.
+
+        Specify both a font size and line height when using Ahem as per [1]. Otherwise, text may be
+        rendered inconsistently. Plus, disable text-autosizing and fix viewport to make test result
+        consistent on both iPhone and iPad. 
+
+        [1] <https://web-platform-tests.org/writing-tests/ahem.html>
+
+        * TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:
+        (applyStyle): Remove unused style for <iframe>s and fix up parameter name to conform to style guide.
+        (applyAhemStyle): Set -webkit-text-size-adjust to 100% to disable auto-sizing. Fix viewport width
+        and initial scale to ensure the result is the same on both iPhone and iPad. Also remove unused style
+        for <iframe>s and renamed parameter name to conform to style guide.
+        (TEST):
+
 2019-11-05  Sihui Liu  <sihui_...@apple.com>
 
         REGRESSION (r250754): web page using IDBIndex doesn't load occasionally

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm (252060 => 252061)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm	2019-11-05 18:25:38 UTC (rev 252060)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm	2019-11-05 18:39:49 UTC (rev 252061)
@@ -99,14 +99,16 @@
 
 @end
 
-static NSString *applyStyle(NSString *HTMLString)
+static NSString *applyStyle(NSString *htmlString)
 {
-    return [@"<style>body { margin: 0; } iframe { border: none; }</style><meta name='viewport' content='initial-scale=1'>" stringByAppendingString:HTMLString];
+    return [@"<style>body { margin: 0; } </style><meta name='viewport' content='initial-scale=1'>" stringByAppendingString:htmlString];
 }
 
-static NSString *applyAhemStyle(NSString *HTMLString)
+constexpr unsigned glyphWidth { 25 }; // pixels
+
+static NSString *applyAhemStyle(NSString *htmlString)
 {
-    return [@"<style>@font-face { font-family: customFont; src: url(Ahem.ttf); } body { margin: 0; font-family: customFont; } iframe { border: none; }</style><meta name='viewport' content='initial-scale=1'>" stringByAppendingString:HTMLString];
+    return [NSString stringWithFormat:@"<style>@font-face { font-family: Ahem; src: url(Ahem.ttf); } body { margin: 0; font: %upx/1 Ahem; -webkit-text-size-adjust: 100%%; }</style><meta name='viewport' content='width=980, initial-scale=1.0'>%@", glyphWidth, htmlString];
 }
 
 TEST(WebKit, DocumentEditingContext)
@@ -204,10 +206,10 @@
         return [@(a.CGRectValue.origin.x) compare:@(b.CGRectValue.origin.x)];
     }];
     EXPECT_EQ(4UL, rects.count);
-    EXPECT_EQ(CGRectMake(0, 0, 23, 24), rects[0].CGRectValue);
-    EXPECT_EQ(CGRectMake(23, 0, 23, 24), rects[1].CGRectValue);
-    EXPECT_EQ(CGRectMake(46, 0, 23, 24), rects[2].CGRectValue);
-    EXPECT_EQ(CGRectMake(69, 0, 23, 24), rects[3].CGRectValue);
+    EXPECT_EQ(CGRectMake(0, 0, glyphWidth, glyphWidth), rects[0].CGRectValue);
+    EXPECT_EQ(CGRectMake(glyphWidth, 0, glyphWidth, glyphWidth), rects[1].CGRectValue);
+    EXPECT_EQ(CGRectMake(2 * glyphWidth, 0, glyphWidth, glyphWidth), rects[2].CGRectValue);
+    EXPECT_EQ(CGRectMake(3 * glyphWidth, 0, glyphWidth, glyphWidth), rects[3].CGRectValue);
     rects = [context characterRectsForCharacterRange:NSMakeRange(5, 1)];
     EXPECT_EQ(0UL, rects.count);
 
@@ -215,10 +217,10 @@
     EXPECT_NSSTRING_EQ(" MMM", context.contextAfter);
     rects = [context characterRectsForCharacterRange:NSMakeRange(0, 1)];
     EXPECT_EQ(1UL, rects.count);
-    EXPECT_EQ(CGRectMake(0, 0, 23, 24), rects.firstObject.CGRectValue);
+    EXPECT_EQ(CGRectMake(0, 0, glyphWidth, glyphWidth), rects.firstObject.CGRectValue);
     rects = [context characterRectsForCharacterRange:NSMakeRange(6, 1)];
     EXPECT_EQ(1UL, rects.count);
-    EXPECT_EQ(CGRectMake(138, 0, 23, 24), rects.firstObject.CGRectValue);
+    EXPECT_EQ(CGRectMake(6 * glyphWidth, 0, glyphWidth, glyphWidth), rects.firstObject.CGRectValue);
 
     // Text Input Context
     [webView synchronouslyLoadHTMLString:applyStyle(@"<input type='text' style='width: 50px; height: 50px;' value='hello, world'>")];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to