Changeset 211294 in webkit
- Timestamp:
- Jan 27, 2017 12:28:11 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r211292 r211294 1 2017-01-27 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Prepare ComplexTextController for unit testing 4 https://bugs.webkit.org/show_bug.cgi?id=167493 5 6 Reviewed by Dean Jackson. 7 8 ComplexTextController has three phases: 9 1. Interrogate Core Text about some text 10 2. Compute layout advances and paint advances from the information retrieved from 11 Core Text 12 3. Iterate through the layout advances or paint advances. 13 14 This patch tests phases 2 and 3 by chopping ComplexTextController between 15 phases 1 and 2, and injecting foreign metrics from a unit test. These metrics 16 have been gathered from real-world uses; however, a layout test is not appropriate 17 because the fonts which produced these metrics are not licensed appropriately. 18 The tests can enforce the correct behavior by using ComplexTextController's 19 public API. 20 21 This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=166013. 22 However, the fix for that bug is quite large, so I've split out this smaller piece 23 to ease the reviewing burden. The tests I've added are disabled for now (because 24 they fail), but will be enabled by the fix to that bug. 25 26 No new tests because there is no behavior change. 27 28 * WebCore.xcodeproj/project.pbxproj: 29 * platform/graphics/FontCascade.h: 30 * platform/graphics/FontDescription.h: 31 * platform/graphics/mac/ComplexTextController.cpp: 32 (WebCore::ComplexTextController::ComplexTextController): 33 (WebCore::ComplexTextController::finishConstruction): 34 * platform/graphics/mac/ComplexTextController.h: 35 (WebCore::ComplexTextController::ComplexTextRun::createForTesting): 36 * platform/graphics/mac/ComplexTextControllerCoreText.mm: 37 (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): 38 1 39 2017-01-27 Zalan Bujtas <zalan@apple.com> 2 40 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r211283 r211294 1453 1453 37BAAE581980D1DD005DFE71 /* ProtectionSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 37BAAE571980D1DD005DFE71 /* ProtectionSpace.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1454 1454 37C236101097EE7700EF9F72 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C2360E1097EE7700EF9F72 /* ComplexTextController.cpp */; }; 1455 37C236111097EE7700EF9F72 /* ComplexTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C2360F1097EE7700EF9F72 /* ComplexTextController.h */; };1455 37C236111097EE7700EF9F72 /* ComplexTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C2360F1097EE7700EF9F72 /* ComplexTextController.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1456 1456 37C238221098C84200EF9F72 /* ComplexTextControllerCoreText.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.mm */; }; 1457 1457 37D456FD1A9A50D8003330A1 /* LocalizableStrings.pm in Copy Scripts */ = {isa = PBXBuildFile; fileRef = 37D456FB1A9A50B6003330A1 /* LocalizableStrings.pm */; }; -
trunk/Source/WebCore/platform/graphics/FontCascade.h
r208985 r211294 115 115 public: 116 116 WEBCORE_EXPORT FontCascade(); 117 WEBCORE_EXPORT FontCascade(const FontCascadeDescription&, float letterSpacing , float wordSpacing);117 WEBCORE_EXPORT FontCascade(const FontCascadeDescription&, float letterSpacing = 0, float wordSpacing = 0); 118 118 // This constructor is only used if the platform wants to start with a native font. 119 119 WEBCORE_EXPORT FontCascade(const FontPlatformData&, FontSmoothingMode = AutoSmoothing); … … 130 130 float size() const { return fontDescription().computedSize(); } 131 131 132 void update(RefPtr<FontSelector>&&) const;132 WEBCORE_EXPORT void update(RefPtr<FontSelector>&&) const; 133 133 134 134 enum CustomFontNotReadyAction { DoNotPaintIfFontNotReady, UseFallbackIfFontNotReady }; -
trunk/Source/WebCore/platform/graphics/FontDescription.h
r209875 r211294 198 198 class FontCascadeDescription : public FontDescription { 199 199 public: 200 FontCascadeDescription();200 WEBCORE_EXPORT FontCascadeDescription(); 201 201 202 202 bool operator==(const FontCascadeDescription&) const; -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
r209907 r211294 129 129 130 130 collectComplexTextRuns(); 131 132 finishConstruction(); 133 } 134 135 ComplexTextController::ComplexTextController(const FontCascade& font, const TextRun& run, Vector<Ref<ComplexTextRun>>& runs) 136 : m_font(font) 137 , m_run(run) 138 , m_end(run.length()) 139 { 140 for (auto& run : runs) 141 m_complexTextRuns.append(run.ptr()); 142 143 finishConstruction(); 144 } 145 146 void ComplexTextController::finishConstruction() 147 { 131 148 adjustGlyphsAndAdvances(); 132 149 -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h
r206466 r211294 59 59 ComplexTextController(const FontCascade&, const TextRun&, bool mayUseNaturalWritingDirection = false, HashSet<const Font*>* fallbackFonts = 0, bool forTextEmphasis = false); 60 60 61 class ComplexTextRun; 62 WEBCORE_EXPORT ComplexTextController(const FontCascade&, const TextRun&, Vector<Ref<ComplexTextRun>>&); 63 61 64 // Advance and emit glyphs up to the specified character. 62 void advance(unsigned to, GlyphBuffer* = nullptr, GlyphIterationStyle = IncludePartialGlyphs, HashSet<const Font*>* fallbackFonts = nullptr);65 WEBCORE_EXPORT void advance(unsigned to, GlyphBuffer* = nullptr, GlyphIterationStyle = IncludePartialGlyphs, HashSet<const Font*>* fallbackFonts = nullptr); 63 66 64 67 // Compute the character offset for a given x coordinate. … … 76 79 77 80 float leadingExpansion() const { return m_leadingExpansion; } 78 79 private: 81 80 82 class ComplexTextRun : public RefCounted<ComplexTextRun> { 81 83 public: … … 88 90 { 89 91 return adoptRef(*new ComplexTextRun(font, characters, stringLocation, stringLength, ltr)); 92 } 93 94 static Ref<ComplexTextRun> createForTesting(Vector<CGSize> advances, Vector<CGPoint> origins, Vector<CGGlyph> glyphs, Vector<CFIndex> stringIndices, CGSize initialAdvance, const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange, bool ltr) 95 { 96 return adoptRef(*new ComplexTextRun(advances, origins, glyphs, stringIndices, initialAdvance, font, characters, stringLocation, stringLength, runRange, ltr)); 90 97 } 91 98 … … 121 128 ComplexTextRun(CTRunRef, const Font&, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange); 122 129 ComplexTextRun(const Font&, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr); 130 WEBCORE_EXPORT ComplexTextRun(Vector<CGSize> advances, Vector<CGPoint> origins, Vector<CGGlyph> glyphs, Vector<CFIndex> stringIndices, CGSize initialAdvance, const Font&, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange, bool ltr); 123 131 124 132 Vector<CGSize, 64> m_baseAdvancesVector; … … 139 147 unsigned m_stringLocation; 140 148 bool m_isLTR; 141 bool m_isMonotonic ;149 bool m_isMonotonic { true }; 142 150 }; 151 private: 152 void finishConstruction(); 143 153 144 154 static unsigned stringBegin(const ComplexTextRun& run) { return run.stringLocation() + run.indexBegin(); } -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
r206466 r211294 112 112 , m_characters(characters) 113 113 , m_stringLength(stringLength) 114 , m_coreTextIndices(CTRunGetStringIndicesPtr(ctRun)) 115 , m_glyphs(CTRunGetGlyphsPtr(ctRun)) 114 116 , m_indexBegin(runRange.location) 115 117 , m_indexEnd(runRange.location + runRange.length) 118 , m_glyphCount(CTRunGetGlyphCount(ctRun)) 116 119 , m_stringLocation(stringLocation) 117 120 , m_isLTR(!(CTRunGetStatus(ctRun) & kCTRunStatusRightToLeft)) 118 , m_isMonotonic(true) 119 { 120 m_glyphCount = CTRunGetGlyphCount(ctRun); 121 m_coreTextIndices = CTRunGetStringIndicesPtr(ctRun); 121 { 122 122 if (!m_coreTextIndices) { 123 123 m_coreTextIndicesVector.grow(m_glyphCount); … … 126 126 } 127 127 128 m_glyphs = CTRunGetGlyphsPtr(ctRun);129 128 if (!m_glyphs) { 130 129 m_glyphsVector.grow(m_glyphCount); … … 162 161 , m_stringLocation(stringLocation) 163 162 , m_isLTR(ltr) 164 , m_isMonotonic(true)165 163 { 166 164 m_coreTextIndicesVector.reserveInitialCapacity(m_stringLength); … … 183 181 m_baseAdvancesVector.fill(CGSizeMake(m_font.widthForGlyph(0), 0), m_glyphCount); 184 182 m_baseAdvances = m_baseAdvancesVector.data(); 183 } 184 185 186 ComplexTextController::ComplexTextRun::ComplexTextRun(Vector<CGSize> advances, Vector<CGPoint> origins, Vector<CGGlyph> glyphs, Vector<CFIndex> stringIndices, CGSize initialAdvance, const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange, bool ltr) 187 : m_baseAdvancesVector(advances) 188 , m_glyphOrigins(origins) 189 , m_glyphsVector(glyphs) 190 , m_coreTextIndicesVector(stringIndices) 191 , m_initialAdvance(initialAdvance) 192 , m_font(font) 193 , m_characters(characters) 194 , m_stringLength(stringLength) 195 , m_coreTextIndices(m_coreTextIndicesVector.data()) 196 , m_glyphs(m_glyphsVector.data()) 197 , m_baseAdvances(m_baseAdvancesVector.data()) 198 , m_indexBegin(runRange.location) 199 , m_indexEnd(runRange.location + runRange.length) 200 , m_glyphCount(glyphs.size()) 201 , m_stringLocation(stringLocation) 202 , m_isLTR(ltr) 203 { 185 204 } 186 205 -
trunk/Tools/ChangeLog
r211254 r211294 1 2017-01-27 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Prepare ComplexTextController for unit testing 4 https://bugs.webkit.org/show_bug.cgi?id=167493 5 6 Reviewed by Dean Jackson. 7 8 Create four unit tests. 9 10 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 11 * TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp: Added. 12 (TestWebKitAPI::ComplexTextControllerTest::SetUp): 13 (TestWebKitAPI::TEST_F): 14 1 15 2017-01-26 Chris Dumez <cdumez@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r211240 r211294 46 46 1C2B81861C89259D00A5529F /* webfont.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81841C8924A200A5529F /* webfont.html */; }; 47 47 1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81851C89252300A5529F /* Ahem.ttf */; }; 48 1C9EB8411E380DA1005C6442 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */; }; 48 49 1F83571B1D3FFB2300E3967B /* WKBackForwardList.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F83571A1D3FFB0E00E3967B /* WKBackForwardList.mm */; }; 49 50 26DF5A6315A2A27E003689C2 /* CancelLoadFromResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 26DF5A6115A2A22B003689C2 /* CancelLoadFromResourceLoadDelegate.html */; }; … … 824 825 1C2B81841C8924A200A5529F /* webfont.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = webfont.html; sourceTree = "<group>"; }; 825 826 1C2B81851C89252300A5529F /* Ahem.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Ahem.ttf; sourceTree = "<group>"; }; 827 1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextController.cpp; sourceTree = "<group>"; }; 826 828 1CB9BC371A67482300FE5678 /* WeakPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WeakPtr.cpp; sourceTree = "<group>"; }; 827 829 1CF0D3781BBF2F3D00B4EF54 /* WKRetainPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKRetainPtr.cpp; sourceTree = "<group>"; }; … … 1605 1607 5C6E65411D5CEF8500F7862E /* URLParser.cpp */, 1606 1608 9C64DC311D76198A004B598E /* YouTubePluginReplacement.cpp */, 1609 1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */, 1607 1610 ); 1608 1611 path = WebCore; … … 2703 2706 5C6E65441D5CEFD400F7862E /* URLParser.cpp in Sources */, 2704 2707 7CCE7F271A411AF600447C4C /* UserContentController.mm in Sources */, 2708 1C9EB8411E380DA1005C6442 /* ComplexTextController.cpp in Sources */, 2705 2709 7CCE7F2D1A411B1000447C4C /* UserContentTest.mm in Sources */, 2706 2710 7C882E0A1C80C764006BF731 /* UserContentWorld.mm in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.