Changeset 211836 in webkit
- Timestamp:
- Feb 7, 2017 1:37:44 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r211821 r211836 2170 2170 platform/graphics/BitmapImage.cpp 2171 2171 platform/graphics/Color.cpp 2172 platform/graphics/ComplexTextController.cpp 2172 2173 platform/graphics/CrossfadeGeneratedImage.cpp 2173 2174 platform/graphics/DisplayRefreshMonitorClient.cpp -
trunk/Source/WebCore/ChangeLog
r211835 r211836 1 2017-02-07 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Win] [GTK] [EFL] Compile (but don't use, yet) the platform-independent piece of ComplexTextController 4 https://bugs.webkit.org/show_bug.cgi?id=167927 5 6 Reviewed by Brent Fulgham. 7 8 This patch simply moves some functions around to enable the Win, GTK, and EFL ports to compile the 9 platform-independent pieces of ComplexTextController. Those parts of ComplexTextController have 10 some dependencies which were previously only available on the Cocoa ports; however, those 11 dependencies are easily created or moved from elsewhere. The next step is to populate the 12 ComplexTextController::collectComplexTextRunsForCharacters() function for DirectWrite and HarfBuzz. 13 Once that is done, UniscribeController and HarfBuzzShaper can be deleted. 14 15 Adds ComplexTextController TestWebKitAPI tests to the Win and GTK ports. 16 17 * CMakeLists.txt: Everyone can compile the platform-independent piece of ComplexTextController. 18 * PlatformEfl.cmake: Add the HarfBuzz-specific piece. 19 * PlatformGTK.cmake: Ditto. 20 * PlatformWin.cmake: Add the DirectWrite-specific piece. 21 * platform/graphics/ComplexTextController.cpp: 22 (WebCore::TextLayoutDeleter::operator()): ComplexTextController shouldn't be enabled yet for Win, 23 GTK, or EFL. 24 (WebCore::FontCascade::createLayout): Ditto. 25 (WebCore::FontCascade::width): Ditto. 26 (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Moved shared code to the shared 27 file. 28 * platform/graphics/Font.cpp: 29 (WebCore::Font::noSynthesizableFeaturesFont): Default implementation for other ports. 30 (WebCore::Font::variantCapsSupportsCharacterForSynthesis): Ditto. 31 * platform/graphics/FontCascade.cpp: 32 (WebCore::FontCascade::fontForCombiningCharacterSequence): Ditto. 33 (WebCore::FontCascade::drawEmphasisMarksForComplexText): Ditto. 34 (WebCore::FontCascade::createLayout): Deleted. Moved to ComplexTextController. 35 (WebCore::TextLayoutDeleter::operator()): Deleted. Ditto. 36 * platform/graphics/FontCascade.h: fontForCombiningCharacterSequence() should exist on all ports. 37 * platform/graphics/cairo/FontCairoHarfbuzzNG.cpp: 38 (WebCore::FontCascade::drawEmphasisMarksForComplexText): Deleted. Shared among all ports. 39 * platform/graphics/cocoa/FontCascadeCocoa.mm: 40 (WebCore::FontCascade::drawEmphasisMarksForComplexText): Deleted. Ditto. 41 * platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp: Added. 42 (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Empty implementation of 43 HarfBuzz-specific piece of ComplexTextController. 44 * platform/graphics/mac/ComplexTextControllerCoreText.mm: Moved constructors to shared file. 45 * platform/graphics/win/ComplexTextControllerDirectWrite.cpp: Added. 46 (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Empty implementation of 47 Direct Write-specific piece of ComplexTextController. 48 * platform/graphics/win/FontWin.cpp: 49 (WebCore::FontCascade::drawEmphasisMarksForComplexText): Deleted. Shared among all ports. 50 1 51 2017-02-07 Alex Christensen <achristensen@webkit.org> 2 52 -
trunk/Source/WebCore/PlatformEfl.cmake
r211027 r211836 139 139 platform/graphics/gstreamer/ImageGStreamerCairo.cpp 140 140 141 platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp 141 142 platform/graphics/harfbuzz/HarfBuzzFace.cpp 142 143 platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp -
trunk/Source/WebCore/PlatformGTK.cmake
r211631 r211836 120 120 platform/graphics/gstreamer/ImageGStreamerCairo.cpp 121 121 122 platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp 122 123 platform/graphics/harfbuzz/HarfBuzzFace.cpp 123 124 platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp -
trunk/Source/WebCore/PlatformWin.cmake
r211161 r211836 87 87 88 88 platform/graphics/win/ColorDirect2D.cpp 89 platform/graphics/win/ComplexTextControllerDirectWrite.cpp 89 90 platform/graphics/win/DIBPixelData.cpp 90 91 platform/graphics/win/FloatPointDirect2D.cpp -
trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp
r211776 r211836 93 93 void TextLayoutDeleter::operator()(TextLayout* layout) const 94 94 { 95 #if PLATFORM(COCOA) 95 96 delete layout; 97 #else 98 ASSERT_UNUSED(layout, !layout); 99 #endif 96 100 } 97 101 98 102 std::unique_ptr<TextLayout, TextLayoutDeleter> FontCascade::createLayout(RenderText& text, float xPos, bool collapseWhiteSpace) const 99 103 { 104 #if PLATFORM(COCOA) 100 105 if (!collapseWhiteSpace || !TextLayout::isNeeded(text, *this)) 101 106 return nullptr; 102 107 return std::unique_ptr<TextLayout, TextLayoutDeleter>(new TextLayout(text, *this, xPos)); 108 #else 109 UNUSED_PARAM(text); 110 UNUSED_PARAM(xPos); 111 UNUSED_PARAM(collapseWhiteSpace); 112 return nullptr; 113 #endif 103 114 } 104 115 105 116 float FontCascade::width(TextLayout& layout, unsigned from, unsigned len, HashSet<const Font*>* fallbackFonts) 106 117 { 118 #if PLATFORM(COCOA) 107 119 return layout.width(from, len, fallbackFonts); 120 #else 121 UNUSED_PARAM(layout); 122 UNUSED_PARAM(from); 123 UNUSED_PARAM(len); 124 UNUSED_PARAM(fallbackFonts); 125 ASSERT_NOT_REACHED(); 126 return 0; 127 #endif 108 128 } 109 129 … … 704 724 const FloatSize* advances = complexTextRun.baseAdvances(); 705 725 706 bool lastRun = runIndex + 1 == runCount;707 726 float spaceWidth = font.spaceWidth() - font.syntheticBoldOffset(); 708 727 const UChar* cp = complexTextRun.characters(); … … 721 740 } 722 741 UChar ch = *(cp + characterIndex); 723 bool lastGlyph = lastRun && i + 1 == glyphCount;724 UChar nextCh;725 if (lastGlyph)726 nextCh = ' ';727 else if (i + 1 < glyphCount)728 nextCh = *(cp + complexTextRun.indexAt(i + 1));729 else730 nextCh = *(m_complexTextRuns[runIndex + 1]->characters() + m_complexTextRuns[runIndex + 1]->indexAt(0));731 742 732 743 bool treatAsSpace = FontCascade::treatAsSpace(ch); … … 831 842 } 832 843 844 // Missing glyphs run constructor. Core Text will not generate a run of missing glyphs, instead falling back on 845 // glyphs from LastResort. We want to use the primary font's missing glyph in order to match the fast text code path. 846 ComplexTextController::ComplexTextRun::ComplexTextRun(const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr) 847 : m_font(font) 848 , m_characters(characters) 849 , m_stringLength(stringLength) 850 , m_indexBegin(indexBegin) 851 , m_indexEnd(indexEnd) 852 , m_stringLocation(stringLocation) 853 , m_isLTR(ltr) 854 { 855 auto runLengthInCodeUnits = m_indexEnd - m_indexBegin; 856 m_coreTextIndices.reserveInitialCapacity(runLengthInCodeUnits); 857 unsigned r = m_indexBegin; 858 while (r < m_indexEnd) { 859 m_coreTextIndices.uncheckedAppend(r); 860 UChar32 character; 861 U16_NEXT(m_characters, r, m_stringLength, character); 862 } 863 m_glyphCount = m_coreTextIndices.size(); 864 if (!ltr) { 865 for (unsigned r = 0, end = m_glyphCount - 1; r < m_glyphCount / 2; ++r, --end) 866 std::swap(m_coreTextIndices[r], m_coreTextIndices[end]); 867 } 868 869 // Synthesize a run of missing glyphs. 870 m_glyphs.fill(0, m_glyphCount); 871 m_baseAdvances.fill(FloatSize(m_font.widthForGlyph(0), 0), m_glyphCount); 872 } 873 874 ComplexTextController::ComplexTextRun::ComplexTextRun(const Vector<FloatSize>& advances, const Vector<FloatPoint>& origins, const Vector<Glyph>& glyphs, const Vector<unsigned>& stringIndices, FloatSize initialAdvance, const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr) 875 : m_baseAdvances(advances) 876 , m_glyphOrigins(origins) 877 , m_glyphs(glyphs) 878 , m_coreTextIndices(stringIndices) 879 , m_initialAdvance(initialAdvance) 880 , m_font(font) 881 , m_characters(characters) 882 , m_stringLength(stringLength) 883 , m_indexBegin(indexBegin) 884 , m_indexEnd(indexEnd) 885 , m_glyphCount(glyphs.size()) 886 , m_stringLocation(stringLocation) 887 , m_isLTR(ltr) 888 { 889 } 890 833 891 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/ComplexTextController.h
r211776 r211836 196 196 Vector<unsigned, 16> m_glyphCountFromStartToIndex; 197 197 198 #if PLATFORM(COCOA) 198 199 Vector<RetainPtr<CTLineRef>> m_coreTextLines; 200 #endif 199 201 200 202 Vector<String> m_stringsFor8BitRuns; -
trunk/Source/WebCore/platform/graphics/Font.cpp
r206830 r211836 293 293 } 294 294 295 const Font& Font::noSynthesizableFeaturesFont() const 296 { 295 297 #if PLATFORM(COCOA) 296 const Font& Font::noSynthesizableFeaturesFont() const297 {298 298 if (!m_derivedFontData) 299 299 m_derivedFontData = std::make_unique<DerivedFonts>(isCustomFont()); … … 302 302 ASSERT(m_derivedFontData->noSynthesizableFeatures != this); 303 303 return *m_derivedFontData->noSynthesizableFeatures; 304 } 305 #endif 304 #else 305 return *this; 306 #endif 307 } 306 308 307 309 const Font* Font::emphasisMarkFont(const FontDescription& fontDescription) const … … 506 508 } 507 509 510 #if !PLATFORM(COCOA) 511 bool Font::variantCapsSupportsCharacterForSynthesis(FontVariantCaps, UChar32) const 512 { 513 return false; 514 } 515 #endif 516 508 517 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/FontCascade.cpp
r211738 r211836 431 431 return m_fonts->glyphDataForCharacter(c, m_fontDescription, variant); 432 432 } 433 434 #if !PLATFORM(COCOA)435 436 std::unique_ptr<TextLayout, TextLayoutDeleter> FontCascade::createLayout(RenderText&, float, bool) const437 {438 return nullptr;439 }440 441 void TextLayoutDeleter::operator()(TextLayout*) const442 {443 }444 445 float FontCascade::width(TextLayout&, unsigned, unsigned, HashSet<const Font*>*)446 {447 ASSERT_NOT_REACHED();448 return 0;449 }450 451 #endif452 433 453 434 static const char* fontFamiliesWithInvalidCharWidth[] = { … … 1469 1450 } 1470 1451 1471 1472 } 1452 #if !PLATFORM(COCOA) 1453 // FIXME: Unify this with the macOS and iOS implementation. 1454 const Font* FontCascade::fontForCombiningCharacterSequence(const UChar* characters, size_t length) const 1455 { 1456 UChar32 baseCharacter; 1457 size_t baseCharacterLength = 0; 1458 U16_NEXT(characters, baseCharacterLength, length, baseCharacter); 1459 GlyphData baseCharacterGlyphData = glyphDataForCharacter(baseCharacter, false, NormalVariant); 1460 1461 if (!baseCharacterGlyphData.glyph) 1462 return nullptr; 1463 return baseCharacterGlyphData.font; 1464 } 1465 #endif 1466 1467 void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const 1468 { 1469 GlyphBuffer glyphBuffer; 1470 float initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis); 1471 1472 if (glyphBuffer.isEmpty()) 1473 return; 1474 1475 drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y())); 1476 } 1477 1478 } -
trunk/Source/WebCore/platform/graphics/FontCascade.h
r211738 r211836 185 185 const FontRanges& fallbackRangesAt(unsigned) const; 186 186 GlyphData glyphDataForCharacter(UChar32, bool mirror, FontVariant = AutoVariant) const; 187 188 #if PLATFORM(COCOA) 187 189 188 const Font* fontForCombiningCharacterSequence(const UChar*, size_t length) const; 190 #endif191 189 192 190 static bool isCJKIdeograph(UChar32); -
trunk/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp
r204400 r211836 53 53 } 54 54 55 void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, unsigned /* from */, unsigned /* to */) const56 {57 notImplemented();58 }59 60 55 bool FontCascade::canReturnFallbackFontsForComplexText() 61 56 { -
trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm
r211667 r211836 532 532 } 533 533 534 void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const535 {536 GlyphBuffer glyphBuffer;537 float initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis);538 539 if (glyphBuffer.isEmpty())540 return;541 542 drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));543 }544 545 534 float FontCascade::floatWidthForComplexText(const TextRun& run, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow) const 546 535 { … … 561 550 } 562 551 552 // FIXME: Use this on all ports. 563 553 const Font* FontCascade::fontForCombiningCharacterSequence(const UChar* characters, size_t length) const 564 554 { -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
r211765 r211836 24 24 25 25 #include "config.h" 26 27 26 #include "ComplexTextController.h" 28 27 … … 164 163 m_baseAdvances.uncheckedAppend(baseAdvances[i]); 165 164 } 166 }167 168 // Missing glyphs run constructor. Core Text will not generate a run of missing glyphs, instead falling back on169 // glyphs from LastResort. We want to use the primary font's missing glyph in order to match the fast text code path.170 ComplexTextController::ComplexTextRun::ComplexTextRun(const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr)171 : m_font(font)172 , m_characters(characters)173 , m_stringLength(stringLength)174 , m_indexBegin(indexBegin)175 , m_indexEnd(indexEnd)176 , m_stringLocation(stringLocation)177 , m_isLTR(ltr)178 {179 auto runLengthInCodeUnits = m_indexEnd - m_indexBegin;180 m_coreTextIndices.reserveInitialCapacity(runLengthInCodeUnits);181 unsigned r = m_indexBegin;182 while (r < m_indexEnd) {183 m_coreTextIndices.uncheckedAppend(r);184 UChar32 character;185 U16_NEXT(m_characters, r, m_stringLength, character);186 }187 m_glyphCount = m_coreTextIndices.size();188 if (!ltr) {189 for (unsigned r = 0, end = m_glyphCount - 1; r < m_glyphCount / 2; ++r, --end)190 std::swap(m_coreTextIndices[r], m_coreTextIndices[end]);191 }192 193 // Synthesize a run of missing glyphs.194 m_glyphs.fill(0, m_glyphCount);195 m_baseAdvances.fill(FloatSize(m_font.widthForGlyph(0), 0), m_glyphCount);196 }197 198 199 ComplexTextController::ComplexTextRun::ComplexTextRun(const Vector<FloatSize>& advances, const Vector<FloatPoint>& origins, const Vector<Glyph>& glyphs, const Vector<unsigned>& stringIndices, FloatSize initialAdvance, const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr)200 : m_baseAdvances(advances)201 , m_glyphOrigins(origins)202 , m_glyphs(glyphs)203 , m_coreTextIndices(stringIndices)204 , m_initialAdvance(initialAdvance)205 , m_font(font)206 , m_characters(characters)207 , m_stringLength(stringLength)208 , m_indexBegin(indexBegin)209 , m_indexEnd(indexEnd)210 , m_glyphCount(glyphs.size())211 , m_stringLocation(stringLocation)212 , m_isLTR(ltr)213 {214 165 } 215 166 -
trunk/Source/WebCore/platform/graphics/win/FontWin.cpp
r206597 r211836 92 92 } 93 93 94 void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const95 {96 GlyphBuffer glyphBuffer;97 float initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis);98 99 if (glyphBuffer.isEmpty())100 return;101 102 drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));103 }104 105 94 float FontCascade::floatWidthForComplexText(const TextRun& run, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow) const 106 95 { -
trunk/Tools/ChangeLog
r211833 r211836 1 2017-02-07 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Win] [GTK] [EFL] Compile (but don't use, yet) the platform-independent piece of ComplexTextController 4 https://bugs.webkit.org/show_bug.cgi?id=167927 5 6 Reviewed by Brent Fulgham. 7 8 Enable ComplexTextController API tests on the Win and GTK ports. 9 10 * TestWebKitAPI/PlatformGTK.cmake: 11 * TestWebKitAPI/PlatformWin.cmake: 12 1 13 2017-02-07 Jonathan Bedard <jbedard@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/PlatformGTK.cmake
r210320 r211836 132 132 ${TESTWEBKITAPI_DIR}/TestsController.cpp 133 133 ${TESTWEBKITAPI_DIR}/Tests/WebCore/CSSParser.cpp 134 ${TESTWEBKITAPI_DIR}/Tests/WebCore/ComplexTextController.cpp 134 135 ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileSystem.cpp 135 136 ${TESTWEBKITAPI_DIR}/Tests/WebCore/GridPosition.cpp -
trunk/Tools/TestWebKitAPI/PlatformWin.cmake
r211207 r211836 47 47 ${TESTWEBKITAPI_DIR}/Tests/WebCore/AffineTransform.cpp 48 48 ${TESTWEBKITAPI_DIR}/Tests/WebCore/CalculationValue.cpp 49 ${TESTWEBKITAPI_DIR}/Tests/WebCore/ComplexTextController.cpp 49 50 ${TESTWEBKITAPI_DIR}/Tests/WebCore/CSSParser.cpp 50 51 ${TESTWEBKITAPI_DIR}/Tests/WebCore/FloatRect.cpp -
trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp
r211765 r211836 75 75 ComplexTextController controller(font, textRun, runs); 76 76 77 CGFloat totalWidth = 0;77 float totalWidth = 0; 78 78 for (size_t i = 1; i < advances.size(); ++i) 79 79 totalWidth += advances[i].width(); … … 124 124 ComplexTextController controller(font, textRun, runs); 125 125 126 CGFloat totalWidth = 0;126 float totalWidth = 0; 127 127 for (size_t i = 1; i < advances.size(); ++i) 128 128 totalWidth += advances[i].width(); … … 259 259 ComplexTextController controller(font, textRun, runs); 260 260 261 CGFloat totalWidth = 14.0397830018083 + 12.0 + 43.8119349005425;261 float totalWidth = 14.0397830018083 + 12.0 + 43.8119349005425; 262 262 EXPECT_NEAR(controller.totalWidth(), totalWidth, 0.0001); 263 263 GlyphBuffer glyphBuffer; … … 299 299 ComplexTextController controller(font, textRun, runs); 300 300 301 CGFloat totalWidth = 100 + 24;301 float totalWidth = 100 + 24; 302 302 EXPECT_NEAR(controller.totalWidth(), totalWidth, 0.0001); 303 303 GlyphBuffer glyphBuffer;
Note: See TracChangeset
for help on using the changeset viewer.