Diff
Modified: trunk/ChangeLog (208127 => 208128)
--- trunk/ChangeLog 2016-10-30 15:56:26 UTC (rev 208127)
+++ trunk/ChangeLog 2016-10-30 16:18:57 UTC (rev 208128)
@@ -1,3 +1,12 @@
+2016-10-30 Frederic Wang <[email protected]>
+
+ Use HarfBuzz ot-math API to parse the OpenType MATH table
+ https://bugs.webkit.org/show_bug.cgi?id=162671
+
+ Reviewed by Michael Catanzaro.
+
+ * Source/cmake/OptionsGTK.cmake: Enable internal OpenType MATH parsing for HarfBuzz < 1.3.3.
+
2016-10-30 Hyowon Kim <[email protected]>
[GTK] Build break by missing geoclue-2.0.
Modified: trunk/LayoutTests/ChangeLog (208127 => 208128)
--- trunk/LayoutTests/ChangeLog 2016-10-30 15:56:26 UTC (rev 208127)
+++ trunk/LayoutTests/ChangeLog 2016-10-30 16:18:57 UTC (rev 208128)
@@ -1,3 +1,15 @@
+2016-10-30 Frederic Wang <[email protected]>
+
+ Use HarfBuzz ot-math API to parse the OpenType MATH table
+ https://bugs.webkit.org/show_bug.cgi?id=162671
+
+ Reviewed by Michael Catanzaro.
+
+ Rebaseline one test for large operators due to small rendering changes.
+
+ * platform/gtk/mathml/opentype/opentype-stretchy-expected.png:
+ * platform/gtk/mathml/opentype/opentype-stretchy-expected.txt:
+
2016-10-30 Gyuyoung Kim <[email protected]>
[EFL] Remove duplicated media/media-source tests in TestExpectations
Modified: trunk/LayoutTests/platform/gtk/mathml/opentype/opentype-stretchy-expected.png
(Binary files differ)
Modified: trunk/LayoutTests/platform/gtk/mathml/opentype/opentype-stretchy-expected.txt (208127 => 208128)
--- trunk/LayoutTests/platform/gtk/mathml/opentype/opentype-stretchy-expected.txt 2016-10-30 15:56:26 UTC (rev 208127)
+++ trunk/LayoutTests/platform/gtk/mathml/opentype/opentype-stretchy-expected.txt 2016-10-30 16:18:57 UTC (rev 208128)
@@ -1,8 +1,8 @@
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
-layer at (0,0) size 800x347
- RenderBlock {HTML} at (0,0) size 800x347
- RenderBody {BODY} at (8,16) size 784x315
+layer at (0,0) size 800x336
+ RenderBlock {HTML} at (0,0) size 800x336
+ RenderBody {BODY} at (8,16) size 784x304
RenderBlock {P} at (0,0) size 784x34
RenderMathMLMath {math} at (0,20) size 26x11
RenderMathMLRow {mrow} at (0,0) size 26x11
@@ -35,10 +35,10 @@
RenderText {#text} at (0,-3) size 2x0
text run at (0,-3) width 2: "\x{219F}"
RenderText {#text} at (0,0) size 0x0
- RenderBlock {P} at (0,219) size 784x96
- RenderMathMLMath {math} at (0,0) size 94x93
- RenderMathMLRow {mrow} at (0,0) size 94x93
- RenderMathMLOperator {mo} at (0,0) size 94x93
+ RenderBlock {P} at (0,219) size 784x85
+ RenderMathMLMath {math} at (0,0) size 84x82
+ RenderMathMLRow {mrow} at (0,0) size 84x82
+ RenderMathMLOperator {mo} at (0,0) size 84x82
RenderBlock (anonymous) at (0,0) size 10x12
RenderText {#text} at (0,6) size 10x0
text run at (0,6) width 10: "\x{2A1B}"
Modified: trunk/Source/WTF/ChangeLog (208127 => 208128)
--- trunk/Source/WTF/ChangeLog 2016-10-30 15:56:26 UTC (rev 208127)
+++ trunk/Source/WTF/ChangeLog 2016-10-30 16:18:57 UTC (rev 208128)
@@ -1,3 +1,12 @@
+2016-10-30 Frederic Wang <[email protected]>
+
+ Use HarfBuzz ot-math API to parse the OpenType MATH table
+ https://bugs.webkit.org/show_bug.cgi?id=162671
+
+ Reviewed by Michael Catanzaro.
+
+ * wtf/Platform.h: By default, do not enable internal OpenType MATH parsing on GTK.
+
2016-10-25 Mark Lam <[email protected]>
String.prototype.replace() should throw an OutOfMemoryError when using too much memory.
Modified: trunk/Source/WTF/wtf/Platform.h (208127 => 208128)
--- trunk/Source/WTF/wtf/Platform.h 2016-10-30 15:56:26 UTC (rev 208127)
+++ trunk/Source/WTF/wtf/Platform.h 2016-10-30 16:18:57 UTC (rev 208128)
@@ -1140,7 +1140,7 @@
#define HAVE_NS_ACTIVITY 1
#endif
-#if (OS(DARWIN) && USE(CG)) || USE(FREETYPE) || (PLATFORM(WIN) && (USE(CG) || USE(CAIRO)))
+#if (OS(DARWIN) && USE(CG)) || (USE(FREETYPE) && !PLATFORM(GTK)) || (PLATFORM(WIN) && (USE(CG) || USE(CAIRO)))
#undef ENABLE_OPENTYPE_MATH
#define ENABLE_OPENTYPE_MATH 1
#endif
Modified: trunk/Source/WebCore/ChangeLog (208127 => 208128)
--- trunk/Source/WebCore/ChangeLog 2016-10-30 15:56:26 UTC (rev 208127)
+++ trunk/Source/WebCore/ChangeLog 2016-10-30 16:18:57 UTC (rev 208128)
@@ -1,3 +1,18 @@
+2016-10-30 Frederic Wang <[email protected]>
+
+ Use HarfBuzz ot-math API to parse the OpenType MATH table
+ https://bugs.webkit.org/show_bug.cgi?id=162671
+
+ Reviewed by Michael Catanzaro.
+
+ No new tests, already covered by existing tests.
+
+ * platform/graphics/opentype/OpenTypeMathData.cpp: Add alternative implementation relying on
+ HarfBuzz's new OpenType MATH API.
+ * platform/graphics/opentype/OpenTypeMathData.h: Ditto.
+ (WebCore::OpenTypeMathData::hasMathData):
+ (WebCore::OpenTypeMathData::HbFontDeleter::operator()):
+
2016-10-29 Dave Hyatt <[email protected]>
[CSS Parser] Support unprefixed image-sets
Modified: trunk/Source/WebCore/platform/graphics/opentype/OpenTypeMathData.cpp (208127 => 208128)
--- trunk/Source/WebCore/platform/graphics/opentype/OpenTypeMathData.cpp 2016-10-30 15:56:26 UTC (rev 208127)
+++ trunk/Source/WebCore/platform/graphics/opentype/OpenTypeMathData.cpp 2016-10-30 16:18:57 UTC (rev 208128)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 Frederic Wang ([email protected]). All rights reserved.
+ * Copyright (C) 2016 Igalia S.L. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -253,6 +254,15 @@
const OpenType::MathVariants* mathVariants = math->mathVariants(*m_mathBuffer);
if (!mathVariants)
m_mathBuffer = nullptr;
+#elif USE(HARFBUZZ)
+OpenTypeMathData::OpenTypeMathData(const FontPlatformData& font)
+{
+ HarfBuzzFace* face = font.harfBuzzFace();
+ if (face) {
+ m_mathFont.reset(face->createFont());
+ if (!hb_ot_math_has_data(hb_font_get_face(m_mathFont.get())))
+ m_mathFont.release();
+ }
#else
OpenTypeMathData::OpenTypeMathData(const FontPlatformData&)
{
@@ -287,6 +297,14 @@
return value / 100.0;
return value * font.sizePerUnit();
+#elif USE(HARFBUZZ)
+float OpenTypeMathData::getMathConstant(const Font&, MathConstant constant) const
+{
+ hb_position_t value = hb_ot_math_get_constant(m_mathFont.get(), static_cast<hb_ot_math_constant_t>(constant));
+ if (constant == ScriptPercentScaleDown || constant == ScriptScriptPercentScaleDown || constant == RadicalDegreeBottomRaisePercent)
+ return value / 100.0;
+
+ return value / 65536.0;
#else
float OpenTypeMathData::getMathConstant(const Font&, MathConstant) const
{
@@ -309,6 +327,10 @@
return 0;
return mathItalicsCorrectionInfo->getItalicCorrection(*m_mathBuffer, glyph) * font.sizePerUnit();
+#elif USE(HARFBUZZ)
+float OpenTypeMathData::getItalicCorrection(const Font&, Glyph glyph) const
+{
+ return hb_ot_math_get_glyph_italics_correction(m_mathFont.get(), glyph) / 65536.0;
#else
float OpenTypeMathData::getItalicCorrection(const Font&, Glyph) const
{
@@ -333,6 +355,39 @@
mathGlyphConstruction->getSizeVariants(*m_mathBuffer, sizeVariants);
mathGlyphConstruction->getAssemblyParts(*m_mathBuffer, assemblyParts);
+#elif USE(HARFBUZZ)
+void OpenTypeMathData::getMathVariants(Glyph glyph, bool isVertical, Vector<Glyph>& sizeVariants, Vector<AssemblyPart>& assemblyParts) const
+{
+ hb_direction_t direction = isVertical ? HB_DIRECTION_BTT : HB_DIRECTION_LTR;
+
+ sizeVariants.clear();
+ hb_ot_math_glyph_variant_t variants[10];
+ unsigned variantsSize = WTF_ARRAY_LENGTH(variants);
+ unsigned count;
+ unsigned offset = 0;
+ do {
+ count = variantsSize;
+ hb_ot_math_get_glyph_variants(m_mathFont.get(), glyph, direction, offset, &count, variants);
+ offset += count;
+ for (unsigned i = 0; i < count; i++)
+ sizeVariants.append(variants[i].glyph);
+ } while (count == variantsSize);
+
+ assemblyParts.clear();
+ hb_ot_math_glyph_part_t parts[10];
+ unsigned partsSize = WTF_ARRAY_LENGTH(parts);
+ offset = 0;
+ do {
+ count = partsSize;
+ hb_ot_math_get_glyph_assembly(m_mathFont.get(), glyph, direction, offset, &count, parts, nullptr);
+ offset += count;
+ for (unsigned i = 0; i < count; i++) {
+ AssemblyPart assemblyPart;
+ assemblyPart.glyph = parts[i].glyph;
+ assemblyPart.isExtender = parts[i].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER;
+ assemblyParts.append(assemblyPart);
+ }
+ } while (count == partsSize);
#else
void OpenTypeMathData::getMathVariants(Glyph, bool, Vector<Glyph>&, Vector<AssemblyPart>&) const
{
Modified: trunk/Source/WebCore/platform/graphics/opentype/OpenTypeMathData.h (208127 => 208128)
--- trunk/Source/WebCore/platform/graphics/opentype/OpenTypeMathData.h 2016-10-30 15:56:26 UTC (rev 208127)
+++ trunk/Source/WebCore/platform/graphics/opentype/OpenTypeMathData.h 2016-10-30 16:18:57 UTC (rev 208128)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 Frederic Wang ([email protected]). All rights reserved.
+ * Copyright (C) 2016 Igalia S.L. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,8 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef OpenTypeMathData_h
-#define OpenTypeMathData_h
+#pragma once
#include "Glyph.h"
#include <wtf/PassRefPtr.h>
@@ -31,6 +31,10 @@
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
+#if !ENABLE(OPENTYPE_MATH) && USE(HARFBUZZ)
+#include <hb-ot.h>
+#endif
+
namespace WebCore {
class FontPlatformData;
@@ -45,7 +49,13 @@
}
~OpenTypeMathData();
+#if ENABLE(OPENTYPE_MATH)
bool hasMathData() const { return m_mathBuffer; }
+#elif USE(HARFBUZZ)
+ bool hasMathData() const { return m_mathFont.get(); }
+#else
+ bool hasMathData() const { return false; }
+#endif
// These constants are defined in the MATH table.
// The implementation of OpenTypeMathData::getMathConstant assumes that they correspond to the indices of the MathContant table.
@@ -119,9 +129,18 @@
private:
explicit OpenTypeMathData(const FontPlatformData&);
+
+#if ENABLE(OPENTYPE_MATH)
RefPtr<SharedBuffer> m_mathBuffer;
+#elif USE(HARFBUZZ)
+ struct HbFontDeleter {
+ void operator()(hb_font_t* font)
+ {
+ hb_font_destroy(font);
+ }
+ };
+ std::unique_ptr<hb_font_t, HbFontDeleter> m_mathFont;
+#endif
};
} // namespace WebCore
-
-#endif // OpenTypeMathData_h
Modified: trunk/Source/cmake/OptionsGTK.cmake (208127 => 208128)
--- trunk/Source/cmake/OptionsGTK.cmake 2016-10-30 15:56:26 UTC (rev 208127)
+++ trunk/Source/cmake/OptionsGTK.cmake 2016-10-30 16:18:57 UTC (rev 208128)
@@ -57,6 +57,12 @@
set(USE_WOFF2 ON)
+# For old versions of HarfBuzz that do not expose an API for the OpenType MATH
+# table, we enable our own code to parse that table.
+if ("${PC_HARFBUZZ_VERSION}" VERSION_LESS "1.3.3")
+ add_definitions(-DENABLE_OPENTYPE_MATH=1)
+endif ()
+
# Set the default value for ENABLE_GLES2 automatically.
# We are not enabling or disabling automatically a feature here, because
# the feature is by default always on (ENABLE_OPENGL=ON).