WebKit Bugzilla
Attachment 370359 Details for
Bug 198010
: [Mac] Add API test to make sure the system font is drawn just like in native code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for committing
bug-198010-20190521171018.patch (text/plain), 10.07 KB, created by
Myles C. Maxfield
on 2019-05-21 17:10:19 PDT
(
hide
)
Description:
Patch for committing
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2019-05-21 17:10:19 PDT
Size:
10.07 KB
patch
obsolete
>Subversion Revision: 245598 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 81eabc75e282715dfd8c4ee93533903066283a7f..72bd0a1e00922b1f3e5fe70a97a5007c6818e981 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,17 @@ >+2019-05-21 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [Mac] Add API test to make sure the system font is drawn just like in native code >+ https://bugs.webkit.org/show_bug.cgi?id=198010 >+ >+ Reviewed by Daniel Bates. >+ >+ We can compare the width of using font-family:system-ui to a CTLine. >+ >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WebKitCocoa/TextWidth.html: Added. >+ * TestWebKitAPI/Tests/WebKitCocoa/TextWidth.mm: Added. >+ (TEST): >+ > 2019-05-21 Carlos Garcia Campos <cgarcia@igalia.com> > > Unreviewed. Fix the build with HAVE(ACCESSIBILITY) disabled >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 1a6a0851d031deec7194a1b29e68f9cee89ad7ed..fd132521e8d1c07e4613c395f6131e516c19f65b 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -758,6 +758,8 @@ > C0ADBE9612FCA79B00D2C129 /* simple-form.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C0ADBE8412FCA6B600D2C129 /* simple-form.html */; }; > C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */; }; > C0C5D3C61459912900A802A6 /* GetBackingScaleFactor_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */; }; >+ C22FA32B228F8708009D7988 /* TextWidth.mm in Sources */ = {isa = PBXBuildFile; fileRef = C22FA32A228F8708009D7988 /* TextWidth.mm */; }; >+ C22FA32D228F8AEB009D7988 /* TextWidth.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C22FA32C228F877A009D7988 /* TextWidth.html */; }; > C25CCA061E51380B0026CB8A /* LineBreaking.mm in Sources */ = {isa = PBXBuildFile; fileRef = C25CCA051E51380B0026CB8A /* LineBreaking.mm */; }; > C25CCA0B1E5140C10026CB8A /* LineBreaking.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C25CCA0A1E513F490026CB8A /* LineBreaking.html */; }; > C25CCA0D1E5141840026CB8A /* AllAhem.svg in Copy Resources */ = {isa = PBXBuildFile; fileRef = C25CCA0C1E5140E50026CB8A /* AllAhem.svg */; }; >@@ -1317,6 +1319,7 @@ > F4CD74C620FDACFA00DE3794 /* text-with-async-script.html in Copy Resources */, > F44C7A0520FAAE3C0014478C /* text-with-deferred-script.html in Copy Resources */, > F41AB9AA1EF4696B0083FA08 /* textarea-to-input.html in Copy Resources */, >+ C22FA32D228F8AEB009D7988 /* TextWidth.html in Copy Resources */, > F4451C761EB8FD890020C5DA /* two-paragraph-contenteditable.html in Copy Resources */, > C540F784152E5A9A00A40C8C /* verboseMarkup.html in Copy Resources */, > CD57779D211CE91F001B371E /* video-with-audio-and-web-audio.html in Copy Resources */, >@@ -2110,6 +2113,8 @@ > C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor.mm; sourceTree = "<group>"; }; > C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor_Bundle.mm; sourceTree = "<group>"; }; > C1D8EE212028E8E3008EB141 /* WebProcessTerminate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessTerminate.mm; sourceTree = "<group>"; }; >+ C22FA32A228F8708009D7988 /* TextWidth.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TextWidth.mm; sourceTree = "<group>"; }; >+ C22FA32C228F877A009D7988 /* TextWidth.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = TextWidth.html; sourceTree = "<group>"; }; > C25CCA051E51380B0026CB8A /* LineBreaking.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = LineBreaking.mm; path = ../WebCore/LineBreaking.mm; sourceTree = "<group>"; }; > C25CCA0A1E513F490026CB8A /* LineBreaking.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = LineBreaking.html; sourceTree = "<group>"; }; > C25CCA0C1E5140E50026CB8A /* AllAhem.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AllAhem.svg; sourceTree = "<group>"; }; >@@ -2700,6 +2705,7 @@ > 5774AA6721FBBF7800AF2A1B /* TestLoadOptimizer.mm */, > F4CD74C720FDB49600DE3794 /* TestURLSchemeHandler.h */, > F4CD74C820FDB49600DE3794 /* TestURLSchemeHandler.mm */, >+ C22FA32A228F8708009D7988 /* TextWidth.mm */, > 5CB40B4D1F4B98BE007DC7B9 /* UIDelegate.mm */, > 7CC3E1FA197E234100BE6252 /* UserContentController.mm */, > 7C882E031C80C624006BF731 /* UserContentWorld.mm */, >@@ -3095,6 +3101,7 @@ > F4CD74C520FDACF500DE3794 /* text-with-async-script.html */, > F44C7A0420FAAE320014478C /* text-with-deferred-script.html */, > F41AB9951EF4692C0083FA08 /* textarea-to-input.html */, >+ C22FA32C228F877A009D7988 /* TextWidth.html */, > F4451C751EB8FD7C0020C5DA /* two-paragraph-contenteditable.html */, > CD57779B211CE6CE001B371E /* video-with-audio-and-web-audio.html */, > CD577798211CDE8F001B371E /* web-audio-only.html */, >@@ -4405,6 +4412,7 @@ > F45033F5206BEC95009351CE /* TextAutosizingBoost.mm in Sources */, > 93E6193B1F931B3A00AF245E /* TextCodec.cpp in Sources */, > CE3524F91B1441C40028A7C5 /* TextFieldDidBeginAndEndEditing.cpp in Sources */, >+ C22FA32B228F8708009D7988 /* TextWidth.mm in Sources */, > 7CCE7EDD1A411A9200447C4C /* TimeRanges.cpp in Sources */, > 7CCE7ED31A411A7E00447C4C /* TypingStyleCrash.mm in Sources */, > 57152B7821DD4E8D000C37CA /* U2fCommandConstructorTest.cpp in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextWidth.html b/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextWidth.html >new file mode 100644 >index 0000000000000000000000000000000000000000..eaf800a0ba4fcf3efb9d652a67d63b4715e72306 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextWidth.html >@@ -0,0 +1,23 @@ >+<!DOCTYPE html> >+<html lang="en-US"> >+<head> >+<style> >+body { >+ width: 99999999px; >+} >+#test1 { >+ font: 24px "system-ui"; >+} >+</style> >+<script> >+function runTest1() { >+ return document.getElementById("test1").offsetWidth; >+} >+</script> >+</head> >+<body> >+<p> >+<span id="test1">This is a test string</span> >+</p> >+</body> >+</html> >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextWidth.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextWidth.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..29ece72396fa37f39c40652b72624d76f94c3d08 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextWidth.mm >@@ -0,0 +1,60 @@ >+/* >+ * 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" >+ >+#import "TestNavigationDelegate.h" >+#import "Utilities.h" >+#import <CoreText/CoreText.h> >+#import <wtf/RetainPtr.h> >+#import <wtf/text/WTFString.h> >+ >+TEST(WebKit, TextWidth) >+{ >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); >+ >+ [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"TextWidth" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]]; >+ [webView _test_waitForDidFinishNavigation]; >+ >+ __block bool didEvaluateJavaScript = false; >+ __block float webKitWidth; >+ [webView evaluateJavaScript:@"runTest1()" completionHandler:^(id value, NSError *error) { >+ webKitWidth = [(NSNumber *)value floatValue]; >+ didEvaluateJavaScript = true; >+ }]; >+ TestWebKitAPI::Util::run(&didEvaluateJavaScript); >+ >+ auto font = adoptCF(CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, 24, static_cast<CFStringRef>(@"en-US"))); >+ // Use CFAttributedString so we don't have to deal with NSFont / UIFont and have this code be platform-dependent. >+ CFTypeRef keys[] = { kCTFontAttributeName }; >+ CFTypeRef values[] = { font.get() }; >+ auto attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); >+ auto attributedString = adoptCF(CFAttributedStringCreate(kCFAllocatorDefault, CFSTR("This is a test string"), attributes.get())); >+ auto line = adoptCF(CTLineCreateWithAttributedString(static_cast<CFAttributedStringRef>(attributedString))); >+ double coreTextWidth = CTLineGetTypographicBounds(line.get(), nullptr, nullptr, nullptr); >+ >+ EXPECT_NEAR(webKitWidth, coreTextWidth, 3); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198010
:
370174
|
370359
|
370414
|
370438