[Win] [GTK] [EFL] Compile (but don't use, yet) the platform-independent piece of...
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Feb 2017 21:37:44 +0000 (21:37 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Feb 2017 21:37:44 +0000 (21:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167927

Reviewed by Brent Fulgham.

Source/WebCore:

This patch simply moves some functions around to enable the Win, GTK, and EFL ports to compile the
platform-independent pieces of ComplexTextController. Those parts of ComplexTextController have
some dependencies which were previously only available on the Cocoa ports; however, those
dependencies are easily created or moved from elsewhere. The next step is to populate the
ComplexTextController::collectComplexTextRunsForCharacters() function for DirectWrite and HarfBuzz.
Once that is done, UniscribeController and HarfBuzzShaper can be deleted.

Adds ComplexTextController TestWebKitAPI tests to the Win and GTK ports.

* CMakeLists.txt: Everyone can compile the platform-independent piece of ComplexTextController.
* PlatformEfl.cmake: Add the HarfBuzz-specific piece.
* PlatformGTK.cmake: Ditto.
* PlatformWin.cmake: Add the DirectWrite-specific piece.
* platform/graphics/ComplexTextController.cpp:
(WebCore::TextLayoutDeleter::operator()): ComplexTextController shouldn't be enabled yet for Win,
GTK, or EFL.
(WebCore::FontCascade::createLayout): Ditto.
(WebCore::FontCascade::width): Ditto.
(WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Moved shared code to the shared
file.
* platform/graphics/Font.cpp:
(WebCore::Font::noSynthesizableFeaturesFont): Default implementation for other ports.
(WebCore::Font::variantCapsSupportsCharacterForSynthesis): Ditto.
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::fontForCombiningCharacterSequence): Ditto.
(WebCore::FontCascade::drawEmphasisMarksForComplexText): Ditto.
(WebCore::FontCascade::createLayout): Deleted. Moved to ComplexTextController.
(WebCore::TextLayoutDeleter::operator()): Deleted. Ditto.
* platform/graphics/FontCascade.h: fontForCombiningCharacterSequence() should exist on all ports.
* platform/graphics/cairo/FontCairoHarfbuzzNG.cpp:
(WebCore::FontCascade::drawEmphasisMarksForComplexText): Deleted. Shared among all ports.
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::FontCascade::drawEmphasisMarksForComplexText): Deleted. Ditto.
* platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp: Added.
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Empty implementation of
HarfBuzz-specific piece of ComplexTextController.
* platform/graphics/mac/ComplexTextControllerCoreText.mm: Moved constructors to shared file.
* platform/graphics/win/ComplexTextControllerDirectWrite.cpp: Added.
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Empty implementation of
Direct Write-specific piece of ComplexTextController.
* platform/graphics/win/FontWin.cpp:
(WebCore::FontCascade::drawEmphasisMarksForComplexText): Deleted. Shared among all ports.

Tools:

Enable ComplexTextController API tests on the Win and GTK ports.

* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/PlatformWin.cmake:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211836 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/PlatformEfl.cmake
Source/WebCore/PlatformGTK.cmake
Source/WebCore/PlatformWin.cmake
Source/WebCore/platform/graphics/ComplexTextController.cpp
Source/WebCore/platform/graphics/ComplexTextController.h
Source/WebCore/platform/graphics/Font.cpp
Source/WebCore/platform/graphics/FontCascade.cpp
Source/WebCore/platform/graphics/FontCascade.h
Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp
Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm
Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
Source/WebCore/platform/graphics/win/ComplexTextControllerDirectWrite.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/win/FontWin.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/PlatformGTK.cmake
Tools/TestWebKitAPI/PlatformWin.cmake
Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp

index b1ec9e5..836b0d9 100644 (file)
@@ -2169,6 +2169,7 @@ set(WebCore_SOURCES
 
     platform/graphics/BitmapImage.cpp
     platform/graphics/Color.cpp
+    platform/graphics/ComplexTextController.cpp
     platform/graphics/CrossfadeGeneratedImage.cpp
     platform/graphics/DisplayRefreshMonitorClient.cpp
     platform/graphics/ExtendedColor.cpp
index 0c8e28b..284559c 100644 (file)
@@ -1,3 +1,53 @@
+2017-02-07  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [Win] [GTK] [EFL] Compile (but don't use, yet) the platform-independent piece of ComplexTextController
+        https://bugs.webkit.org/show_bug.cgi?id=167927
+
+        Reviewed by Brent Fulgham.
+
+        This patch simply moves some functions around to enable the Win, GTK, and EFL ports to compile the
+        platform-independent pieces of ComplexTextController. Those parts of ComplexTextController have
+        some dependencies which were previously only available on the Cocoa ports; however, those
+        dependencies are easily created or moved from elsewhere. The next step is to populate the
+        ComplexTextController::collectComplexTextRunsForCharacters() function for DirectWrite and HarfBuzz.
+        Once that is done, UniscribeController and HarfBuzzShaper can be deleted.
+
+        Adds ComplexTextController TestWebKitAPI tests to the Win and GTK ports.
+
+        * CMakeLists.txt: Everyone can compile the platform-independent piece of ComplexTextController.
+        * PlatformEfl.cmake: Add the HarfBuzz-specific piece.
+        * PlatformGTK.cmake: Ditto.
+        * PlatformWin.cmake: Add the DirectWrite-specific piece.
+        * platform/graphics/ComplexTextController.cpp:
+        (WebCore::TextLayoutDeleter::operator()): ComplexTextController shouldn't be enabled yet for Win,
+        GTK, or EFL.
+        (WebCore::FontCascade::createLayout): Ditto.
+        (WebCore::FontCascade::width): Ditto.
+        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Moved shared code to the shared
+        file.
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::noSynthesizableFeaturesFont): Default implementation for other ports.
+        (WebCore::Font::variantCapsSupportsCharacterForSynthesis): Ditto.
+        * platform/graphics/FontCascade.cpp:
+        (WebCore::FontCascade::fontForCombiningCharacterSequence): Ditto.
+        (WebCore::FontCascade::drawEmphasisMarksForComplexText): Ditto.
+        (WebCore::FontCascade::createLayout): Deleted. Moved to ComplexTextController.
+        (WebCore::TextLayoutDeleter::operator()): Deleted. Ditto.
+        * platform/graphics/FontCascade.h: fontForCombiningCharacterSequence() should exist on all ports.
+        * platform/graphics/cairo/FontCairoHarfbuzzNG.cpp:
+        (WebCore::FontCascade::drawEmphasisMarksForComplexText): Deleted. Shared among all ports.
+        * platform/graphics/cocoa/FontCascadeCocoa.mm:
+        (WebCore::FontCascade::drawEmphasisMarksForComplexText): Deleted. Ditto.
+        * platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp: Added.
+        (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Empty implementation of
+        HarfBuzz-specific piece of ComplexTextController.
+        * platform/graphics/mac/ComplexTextControllerCoreText.mm: Moved constructors to shared file.
+        * platform/graphics/win/ComplexTextControllerDirectWrite.cpp: Added.
+        (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Empty implementation of
+        Direct Write-specific piece of ComplexTextController.
+        * platform/graphics/win/FontWin.cpp:
+        (WebCore::FontCascade::drawEmphasisMarksForComplexText): Deleted. Shared among all ports.
+
 2017-02-07  Alex Christensen  <achristensen@webkit.org>
 
         Revert r166597
index 1f0e103..50ab723 100644 (file)
@@ -138,6 +138,7 @@ list(APPEND WebCore_SOURCES
 
     platform/graphics/gstreamer/ImageGStreamerCairo.cpp
 
+    platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp
     platform/graphics/harfbuzz/HarfBuzzFace.cpp
     platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp
     platform/graphics/harfbuzz/HarfBuzzShaper.cpp
index c0bcd2a..a7ceeb8 100644 (file)
@@ -119,6 +119,7 @@ list(APPEND WebCore_SOURCES
 
     platform/graphics/gstreamer/ImageGStreamerCairo.cpp
 
+    platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp
     platform/graphics/harfbuzz/HarfBuzzFace.cpp
     platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp
     platform/graphics/harfbuzz/HarfBuzzShaper.cpp
index fd48cc1..3b5b40b 100644 (file)
@@ -86,6 +86,7 @@ list(APPEND WebCore_SOURCES
     platform/graphics/opentype/OpenTypeUtilities.cpp
 
     platform/graphics/win/ColorDirect2D.cpp
+    platform/graphics/win/ComplexTextControllerDirectWrite.cpp
     platform/graphics/win/DIBPixelData.cpp
     platform/graphics/win/FloatPointDirect2D.cpp
     platform/graphics/win/FloatRectDirect2D.cpp
index dd9f3ca..9870a7e 100644 (file)
@@ -92,19 +92,39 @@ private:
 
 void TextLayoutDeleter::operator()(TextLayout* layout) const
 {
+#if PLATFORM(COCOA)
     delete layout;
+#else
+    ASSERT_UNUSED(layout, !layout);
+#endif
 }
 
 std::unique_ptr<TextLayout, TextLayoutDeleter> FontCascade::createLayout(RenderText& text, float xPos, bool collapseWhiteSpace) const
 {
+#if PLATFORM(COCOA)
     if (!collapseWhiteSpace || !TextLayout::isNeeded(text, *this))
         return nullptr;
     return std::unique_ptr<TextLayout, TextLayoutDeleter>(new TextLayout(text, *this, xPos));
+#else
+    UNUSED_PARAM(text);
+    UNUSED_PARAM(xPos);
+    UNUSED_PARAM(collapseWhiteSpace);
+    return nullptr;
+#endif
 }
 
 float FontCascade::width(TextLayout& layout, unsigned from, unsigned len, HashSet<const Font*>* fallbackFonts)
 {
+#if PLATFORM(COCOA)
     return layout.width(from, len, fallbackFonts);
+#else
+    UNUSED_PARAM(layout);
+    UNUSED_PARAM(from);
+    UNUSED_PARAM(len);
+    UNUSED_PARAM(fallbackFonts);
+    ASSERT_NOT_REACHED();
+    return 0;
+#endif
 }
 
 void ComplexTextController::computeExpansionOpportunity()
@@ -703,7 +723,6 @@ void ComplexTextController::adjustGlyphsAndAdvances()
         const CGGlyph* glyphs = complexTextRun.glyphs();
         const FloatSize* advances = complexTextRun.baseAdvances();
 
-        bool lastRun = runIndex + 1 == runCount;
         float spaceWidth = font.spaceWidth() - font.syntheticBoldOffset();
         const UChar* cp = complexTextRun.characters();
         FloatPoint glyphOrigin;
@@ -720,14 +739,6 @@ void ComplexTextController::adjustGlyphsAndAdvances()
                     isMonotonic = false;
             }
             UChar ch = *(cp + characterIndex);
-            bool lastGlyph = lastRun && i + 1 == glyphCount;
-            UChar nextCh;
-            if (lastGlyph)
-                nextCh = ' ';
-            else if (i + 1 < glyphCount)
-                nextCh = *(cp + complexTextRun.indexAt(i + 1));
-            else
-                nextCh = *(m_complexTextRuns[runIndex + 1]->characters() + m_complexTextRuns[runIndex + 1]->indexAt(0));
 
             bool treatAsSpace = FontCascade::treatAsSpace(ch);
             CGGlyph glyph = treatAsSpace ? font.spaceGlyph() : glyphs[i];
@@ -830,4 +841,51 @@ void ComplexTextController::adjustGlyphsAndAdvances()
     m_totalWidth += widthSinceLastCommit;
 }
 
+// Missing glyphs run constructor. Core Text will not generate a run of missing glyphs, instead falling back on
+// glyphs from LastResort. We want to use the primary font's missing glyph in order to match the fast text code path.
+ComplexTextController::ComplexTextRun::ComplexTextRun(const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr)
+    : m_font(font)
+    , m_characters(characters)
+    , m_stringLength(stringLength)
+    , m_indexBegin(indexBegin)
+    , m_indexEnd(indexEnd)
+    , m_stringLocation(stringLocation)
+    , m_isLTR(ltr)
+{
+    auto runLengthInCodeUnits = m_indexEnd - m_indexBegin;
+    m_coreTextIndices.reserveInitialCapacity(runLengthInCodeUnits);
+    unsigned r = m_indexBegin;
+    while (r < m_indexEnd) {
+        m_coreTextIndices.uncheckedAppend(r);
+        UChar32 character;
+        U16_NEXT(m_characters, r, m_stringLength, character);
+    }
+    m_glyphCount = m_coreTextIndices.size();
+    if (!ltr) {
+        for (unsigned r = 0, end = m_glyphCount - 1; r < m_glyphCount / 2; ++r, --end)
+            std::swap(m_coreTextIndices[r], m_coreTextIndices[end]);
+    }
+
+    // Synthesize a run of missing glyphs.
+    m_glyphs.fill(0, m_glyphCount);
+    m_baseAdvances.fill(FloatSize(m_font.widthForGlyph(0), 0), m_glyphCount);
+}
+
+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)
+    : m_baseAdvances(advances)
+    , m_glyphOrigins(origins)
+    , m_glyphs(glyphs)
+    , m_coreTextIndices(stringIndices)
+    , m_initialAdvance(initialAdvance)
+    , m_font(font)
+    , m_characters(characters)
+    , m_stringLength(stringLength)
+    , m_indexBegin(indexBegin)
+    , m_indexEnd(indexEnd)
+    , m_glyphCount(glyphs.size())
+    , m_stringLocation(stringLocation)
+    , m_isLTR(ltr)
+{
+}
+
 } // namespace WebCore
index 09aba55..169d891 100644 (file)
@@ -195,7 +195,9 @@ private:
     Vector<unsigned, 16> m_runIndices;
     Vector<unsigned, 16> m_glyphCountFromStartToIndex;
 
+#if PLATFORM(COCOA)
     Vector<RetainPtr<CTLineRef>> m_coreTextLines;
+#endif
 
     Vector<String> m_stringsFor8BitRuns;
 
index c9ac4dd..ac8fa39 100644 (file)
@@ -292,17 +292,19 @@ const Font* Font::smallCapsFont(const FontDescription& fontDescription) const
     return m_derivedFontData->smallCaps.get();
 }
 
-#if PLATFORM(COCOA)
 const Font& Font::noSynthesizableFeaturesFont() const
 {
+#if PLATFORM(COCOA)
     if (!m_derivedFontData)
         m_derivedFontData = std::make_unique<DerivedFonts>(isCustomFont());
     if (!m_derivedFontData->noSynthesizableFeatures)
         m_derivedFontData->noSynthesizableFeatures = createFontWithoutSynthesizableFeatures();
     ASSERT(m_derivedFontData->noSynthesizableFeatures != this);
     return *m_derivedFontData->noSynthesizableFeatures;
-}
+#else
+    return *this;
 #endif
+}
 
 const Font* Font::emphasisMarkFont(const FontDescription& fontDescription) const
 {
@@ -505,4 +507,11 @@ void Font::removeFromSystemFallbackCache()
     }
 }
 
+#if !PLATFORM(COCOA)
+bool Font::variantCapsSupportsCharacterForSynthesis(FontVariantCaps, UChar32) const
+{
+    return false;
+}
+#endif
+
 } // namespace WebCore
index 6ac86f8..f7bfdfa 100644 (file)
@@ -431,25 +431,6 @@ GlyphData FontCascade::glyphDataForCharacter(UChar32 c, bool mirror, FontVariant
     return m_fonts->glyphDataForCharacter(c, m_fontDescription, variant);
 }
 
-#if !PLATFORM(COCOA)
-
-std::unique_ptr<TextLayout, TextLayoutDeleter> FontCascade::createLayout(RenderText&, float, bool) const
-{
-    return nullptr;
-}
-
-void TextLayoutDeleter::operator()(TextLayout*) const
-{
-}
-
-float FontCascade::width(TextLayout&, unsigned, unsigned, HashSet<const Font*>*)
-{
-    ASSERT_NOT_REACHED();
-    return 0;
-}
-
-#endif
-
 static const char* fontFamiliesWithInvalidCharWidth[] = {
     "American Typewriter",
     "Arial Hebrew",
@@ -1468,5 +1449,30 @@ int FontCascade::offsetForPositionForSimpleText(const TextRun& run, float x, boo
     return offset;
 }
 
+#if !PLATFORM(COCOA)
+// FIXME: Unify this with the macOS and iOS implementation.
+const Font* FontCascade::fontForCombiningCharacterSequence(const UChar* characters, size_t length) const
+{
+    UChar32 baseCharacter;
+    size_t baseCharacterLength = 0;
+    U16_NEXT(characters, baseCharacterLength, length, baseCharacter);
+    GlyphData baseCharacterGlyphData = glyphDataForCharacter(baseCharacter, false, NormalVariant);
+
+    if (!baseCharacterGlyphData.glyph)
+        return nullptr;
+    return baseCharacterGlyphData.font;
+}
+#endif
+
+void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const
+{
+    GlyphBuffer glyphBuffer;
+    float initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis);
+
+    if (glyphBuffer.isEmpty())
+        return;
+
+    drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
+}
 
 }
index bc7a118..92d8786 100644 (file)
@@ -184,10 +184,8 @@ public:
     const Font& primaryFont() const;
     const FontRanges& fallbackRangesAt(unsigned) const;
     GlyphData glyphDataForCharacter(UChar32, bool mirror, FontVariant = AutoVariant) const;
-    
-#if PLATFORM(COCOA)
+
     const Font* fontForCombiningCharacterSequence(const UChar*, size_t length) const;
-#endif
 
     static bool isCJKIdeograph(UChar32);
     static bool isCJKIdeographOrSymbol(UChar32);
index 08bae38..cc37d7d 100644 (file)
@@ -52,11 +52,6 @@ float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsign
     return 0;
 }
 
-void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, unsigned /* from */, unsigned /* to */) const
-{
-    notImplemented();
-}
-
 bool FontCascade::canReturnFallbackFontsForComplexText()
 {
     return false;
index acab113..834f714 100644 (file)
@@ -531,17 +531,6 @@ float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsign
     return initialAdvance;
 }
 
-void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const
-{
-    GlyphBuffer glyphBuffer;
-    float initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis);
-
-    if (glyphBuffer.isEmpty())
-        return;
-
-    drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
-}
-
 float FontCascade::floatWidthForComplexText(const TextRun& run, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
 {
     ComplexTextController controller(*this, run, true, fallbackFonts);
@@ -560,6 +549,7 @@ int FontCascade::offsetForPositionForComplexText(const TextRun& run, float x, bo
     return controller.offsetForPosition(x, includePartialGlyphs);
 }
 
+// FIXME: Use this on all ports.
 const Font* FontCascade::fontForCombiningCharacterSequence(const UChar* characters, size_t length) const
 {
     UChar32 baseCharacter;
diff --git a/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp b/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp
new file mode 100644 (file)
index 0000000..e97f9c2
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+* Copyright (C) 2017 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"
+#include "ComplexTextController.h"
+
+namespace WebCore {
+
+void ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned, unsigned, const Font*)
+{
+    // FIXME: Implement this.
+    ASSERT_NOT_REACHED();
+}
+
+}
index 24bf27e..e959d28 100644 (file)
@@ -23,7 +23,6 @@
  */
 
 #include "config.h"
-
 #include "ComplexTextController.h"
 
 #include "CoreTextSPI.h"
@@ -165,54 +164,6 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const Font
     }
 }
 
-// Missing glyphs run constructor. Core Text will not generate a run of missing glyphs, instead falling back on
-// glyphs from LastResort. We want to use the primary font's missing glyph in order to match the fast text code path.
-ComplexTextController::ComplexTextRun::ComplexTextRun(const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr)
-    : m_font(font)
-    , m_characters(characters)
-    , m_stringLength(stringLength)
-    , m_indexBegin(indexBegin)
-    , m_indexEnd(indexEnd)
-    , m_stringLocation(stringLocation)
-    , m_isLTR(ltr)
-{
-    auto runLengthInCodeUnits = m_indexEnd - m_indexBegin;
-    m_coreTextIndices.reserveInitialCapacity(runLengthInCodeUnits);
-    unsigned r = m_indexBegin;
-    while (r < m_indexEnd) {
-        m_coreTextIndices.uncheckedAppend(r);
-        UChar32 character;
-        U16_NEXT(m_characters, r, m_stringLength, character);
-    }
-    m_glyphCount = m_coreTextIndices.size();
-    if (!ltr) {
-        for (unsigned r = 0, end = m_glyphCount - 1; r < m_glyphCount / 2; ++r, --end)
-            std::swap(m_coreTextIndices[r], m_coreTextIndices[end]);
-    }
-
-    // Synthesize a run of missing glyphs.
-    m_glyphs.fill(0, m_glyphCount);
-    m_baseAdvances.fill(FloatSize(m_font.widthForGlyph(0), 0), m_glyphCount);
-}
-
-
-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)
-    : m_baseAdvances(advances)
-    , m_glyphOrigins(origins)
-    , m_glyphs(glyphs)
-    , m_coreTextIndices(stringIndices)
-    , m_initialAdvance(initialAdvance)
-    , m_font(font)
-    , m_characters(characters)
-    , m_stringLength(stringLength)
-    , m_indexBegin(indexBegin)
-    , m_indexEnd(indexEnd)
-    , m_glyphCount(glyphs.size())
-    , m_stringLocation(stringLocation)
-    , m_isLTR(ltr)
-{
-}
-
 struct ProviderInfo {
     const UChar* cp;
     unsigned length;
diff --git a/Source/WebCore/platform/graphics/win/ComplexTextControllerDirectWrite.cpp b/Source/WebCore/platform/graphics/win/ComplexTextControllerDirectWrite.cpp
new file mode 100644 (file)
index 0000000..e97f9c2
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+* Copyright (C) 2017 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"
+#include "ComplexTextController.h"
+
+namespace WebCore {
+
+void ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned, unsigned, const Font*)
+{
+    // FIXME: Implement this.
+    ASSERT_NOT_REACHED();
+}
+
+}
index 21d32ed..120e501 100644 (file)
@@ -91,17 +91,6 @@ float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsign
     return beforeWidth;
 }
 
-void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const
-{
-    GlyphBuffer glyphBuffer;
-    float initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis);
-
-    if (glyphBuffer.isEmpty())
-        return;
-
-    drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
-}
-
 float FontCascade::floatWidthForComplexText(const TextRun& run, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
 {
     UniscribeController controller(this, run, fallbackFonts);
index 2272a74..6b3f28c 100644 (file)
@@ -1,3 +1,15 @@
+2017-02-07  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [Win] [GTK] [EFL] Compile (but don't use, yet) the platform-independent piece of ComplexTextController
+        https://bugs.webkit.org/show_bug.cgi?id=167927
+
+        Reviewed by Brent Fulgham.
+
+        Enable ComplexTextController API tests on the Win and GTK ports.
+
+        * TestWebKitAPI/PlatformGTK.cmake:
+        * TestWebKitAPI/PlatformWin.cmake:
+
 2017-02-07  Jonathan Bedard  <jbedard@apple.com>
 
         File index appended to previous file in svn-create-patch with SVN 1.9
index cff9676..ffc72f2 100644 (file)
@@ -131,6 +131,7 @@ add_executable(TestWebCore
     ${test_main_SOURCES}
     ${TESTWEBKITAPI_DIR}/TestsController.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/CSSParser.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebCore/ComplexTextController.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileSystem.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/GridPosition.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/HTMLParserIdioms.cpp
index 194ca8f..7b1019c 100644 (file)
@@ -46,6 +46,7 @@ set(TestWebCoreLib_SOURCES
     ${TESTWEBKITAPI_DIR}/TestsController.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/AffineTransform.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/CalculationValue.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebCore/ComplexTextController.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/CSSParser.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/FloatRect.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebCore/FloatPoint.cpp
index c6b7ddc..1871a46 100644 (file)
@@ -74,7 +74,7 @@ TEST_F(ComplexTextControllerTest, InitialAdvanceWithLeftRunInRTL)
     runs.append(WTFMove(run2));
     ComplexTextController controller(font, textRun, runs);
 
-    CGFloat totalWidth = 0;
+    float totalWidth = 0;
     for (size_t i = 1; i < advances.size(); ++i)
         totalWidth += advances[i].width();
     EXPECT_NEAR(controller.totalWidth(), spaceWidth + totalWidth, 0.0001);
@@ -123,7 +123,7 @@ TEST_F(ComplexTextControllerTest, InitialAdvanceInRTL)
     runs.append(WTFMove(run));
     ComplexTextController controller(font, textRun, runs);
 
-    CGFloat totalWidth = 0;
+    float totalWidth = 0;
     for (size_t i = 1; i < advances.size(); ++i)
         totalWidth += advances[i].width();
     EXPECT_NEAR(controller.totalWidth(), totalWidth, 0.0001);
@@ -258,7 +258,7 @@ TEST_F(ComplexTextControllerTest, InitialAdvanceInRTLNoOrigins)
     runs.append(WTFMove(run3));
     ComplexTextController controller(font, textRun, runs);
 
-    CGFloat totalWidth = 14.0397830018083 + 12.0 + 43.8119349005425;
+    float totalWidth = 14.0397830018083 + 12.0 + 43.8119349005425;
     EXPECT_NEAR(controller.totalWidth(), totalWidth, 0.0001);
     GlyphBuffer glyphBuffer;
     EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
@@ -298,7 +298,7 @@ TEST_F(ComplexTextControllerTest, LeadingExpansion)
     runs.append(WTFMove(run));
     ComplexTextController controller(font, textRun, runs);
 
-    CGFloat totalWidth = 100 + 24;
+    float totalWidth = 100 + 24;
     EXPECT_NEAR(controller.totalWidth(), totalWidth, 0.0001);
     GlyphBuffer glyphBuffer;
     EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);