Diff
Modified: trunk/Source/WebCore/ChangeLog (266687 => 266688)
--- trunk/Source/WebCore/ChangeLog 2020-09-07 00:20:01 UTC (rev 266687)
+++ trunk/Source/WebCore/ChangeLog 2020-09-07 00:52:52 UTC (rev 266688)
@@ -1,3 +1,81 @@
+2020-09-06 Myles C. Maxfield <[email protected]>
+
+ Make GlyphBufferAdvance and GlyphBufferOrigin more robust
+ https://bugs.webkit.org/show_bug.cgi?id=215143
+
+ Reviewed by Zalan Bujtas.
+
+ GlyphBuffer contains vectors of advances and origins, which are conceptually
+ FloatSizes and FloatPoints. However, we need to pass these arrays into CTFontShapeGlyphs()
+ or CTFontTransformGlyphsWithLanguage(), which expects these vectors to use platform types.
+ Rather than converting in/out of platform types around the call site, we can simply use
+ the platform types throughout. Indeed, that's what we're doing today.
+
+ However, the mechanism we use today to make this platform-independent is to make a struct
+ which inherits from the platform types. Then, we static_cast the array of the struct to
+ an array of the base type. This is brittle, because it relies on the assumption that the
+ struct doesn't have any members added to it, which would change the stride of the array
+ and feed garbage into the shaping function.
+
+ Instead, a better design is to typedef the native type, and have all interactions with the
+ types go through standalone functions which deal with the native type. That way, we can't
+ accidentally change the size of the array elements.
+
+ No new tests because there is no behavior change.
+
+ * Headers.cmake:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/ComplexTextController.cpp:
+ (WebCore::ComplexTextController::advance):
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::FontCascade::widthForSimpleText const):
+ (WebCore::FontCascade::layoutComplexText const):
+ (WebCore::FontCascade::drawGlyphBuffer const):
+ (WebCore::FontCascade::drawEmphasisMarks const):
+ (WebCore::GlyphToPathTranslator::extents):
+ (WebCore::GlyphToPathTranslator::advance):
+ * platform/graphics/GlyphBuffer.h:
+ (WebCore::GlyphBuffer::add):
+ (WebCore::GlyphBuffer::makeHole):
+ (WebCore::GlyphBuffer::expandLastAdvance):
+ (WebCore::GlyphBuffer::flatten):
+ (WebCore::GlyphBufferAdvance::GlyphBufferAdvance): Deleted.
+ (WebCore::GlyphBufferAdvance::operator FloatSize): Deleted.
+ (WebCore::GlyphBufferAdvance::setWidth): Deleted.
+ (WebCore::GlyphBufferAdvance::setHeight): Deleted.
+ (WebCore::GlyphBufferAdvance::width const): Deleted.
+ (WebCore::GlyphBufferAdvance::height const): Deleted.
+ (WebCore::GlyphBufferAdvance::encode const): Deleted.
+ (WebCore::GlyphBufferAdvance::decode): Deleted.
+ (WebCore::GlyphBufferOrigin::GlyphBufferOrigin): Deleted.
+ (WebCore::GlyphBufferOrigin::operator FloatPoint): Deleted.
+ (WebCore::GlyphBufferOrigin::setX): Deleted.
+ (WebCore::GlyphBufferOrigin::setY): Deleted.
+ (WebCore::GlyphBufferOrigin::x const): Deleted.
+ (WebCore::GlyphBufferOrigin::y const): Deleted.
+ (WebCore::GlyphBufferOrigin::encode const): Deleted.
+ (WebCore::GlyphBufferOrigin::decode): Deleted.
+ (WebCore::toFloatSize): Deleted.
+ * platform/graphics/GlyphBufferMembers.h: Added.
+ (WebCore::createGlyphBufferAdvance):
+ (WebCore::floatSizeFromGlyphBufferAdvance):
+ (WebCore::setGlyphBufferAdvanceWidth):
+ (WebCore::setGlyphBufferAdvanceHeight):
+ (WebCore::glyphBufferAdvanceWidth):
+ (WebCore::glyphBufferAdvanceHeight):
+ (WebCore::createGlyphBufferOrigin):
+ (WebCore::floatPointFromGlyphBufferOrigin):
+ (WebCore::setGlyphBufferOriginX):
+ (WebCore::setGlyphBufferOriginY):
+ (WebCore::glyphBufferOriginX):
+ (WebCore::glyphBufferOriginY):
+ * platform/graphics/WidthIterator.cpp:
+ (WebCore::WidthIterator::applyFontTransforms):
+ (WebCore::WidthIterator::advanceInternal):
+ (WebCore::WidthIterator::advanceOneCharacter):
+ * platform/graphics/displaylists/DisplayListItems.cpp:
+ (WebCore::DisplayList::DrawGlyphs::computeBounds):
+
2020-09-06 Sam Weinig <[email protected]>
[WebIDL] Add mode to preprocess-idls.pl to validate fast regex based scanner with the normal IDL parser
Modified: trunk/Source/WebCore/Headers.cmake (266687 => 266688)
--- trunk/Source/WebCore/Headers.cmake 2020-09-07 00:20:01 UTC (rev 266687)
+++ trunk/Source/WebCore/Headers.cmake 2020-09-07 00:52:52 UTC (rev 266688)
@@ -1127,6 +1127,7 @@
platform/graphics/GeometryUtilities.h
platform/graphics/Glyph.h
platform/graphics/GlyphBuffer.h
+ platform/graphics/GlyphBufferMembers.h
platform/graphics/GlyphMetricsMap.h
platform/graphics/GlyphPage.h
platform/graphics/Gradient.h
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (266687 => 266688)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-09-07 00:20:01 UTC (rev 266687)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-09-07 00:52:52 UTC (rev 266688)
@@ -613,6 +613,7 @@
1C24EEA51C729CE40080F8FC /* FontFaceSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C24EEA31C729CE40080F8FC /* FontFaceSet.h */; };
1C24EEA91C72A7B40080F8FC /* JSFontFaceSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C24EEA71C72A7B40080F8FC /* JSFontFaceSet.h */; };
1C43DE6B22AB4B8A001527D9 /* LocalCurrentTraitCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C43DE6822AB4B8A001527D9 /* LocalCurrentTraitCollection.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 1C4D0DD324D9F10D003D7498 /* GlyphBufferMembers.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4D0DD124D9F0DB003D7498 /* GlyphBufferMembers.h */; settings = {ATTRIBUTES = (Private, ); }; };
1C6626111C6E7CA600AB527C /* FontFace.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C66260F1C6E7CA600AB527C /* FontFace.h */; };
1C73A7132185757E004CCEA5 /* TextUnderlineOffset.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB6B4FB217B83940093B9CD /* TextUnderlineOffset.h */; settings = {ATTRIBUTES = (Private, ); }; };
1C73A71521857587004CCEA5 /* TextDecorationThickness.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB6B4F8217B83930093B9CD /* TextDecorationThickness.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -6633,6 +6634,7 @@
1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontCacheCoreText.cpp; sourceTree = "<group>"; };
1C43DE6822AB4B8A001527D9 /* LocalCurrentTraitCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalCurrentTraitCollection.h; sourceTree = "<group>"; };
1C43DE6A22AB4B8A001527D9 /* LocalCurrentTraitCollection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalCurrentTraitCollection.mm; sourceTree = "<group>"; };
+ 1C4D0DD124D9F0DB003D7498 /* GlyphBufferMembers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlyphBufferMembers.h; sourceTree = "<group>"; };
1C50C49522C84F2400A6E4BE /* WHLSLStandardLibraryFunctionMap.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLStandardLibraryFunctionMap.cpp; sourceTree = "<group>"; };
1C59B0182238687900853805 /* WHLSLScopedSetAdder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLScopedSetAdder.h; sourceTree = "<group>"; };
1C66260E1C6E7CA600AB527C /* FontFace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFace.cpp; sourceTree = "<group>"; };
@@ -25914,6 +25916,7 @@
0FB6252D18DE1B1500A07C05 /* GeometryUtilities.h */,
086BBD0E136039C2008B15D8 /* Glyph.h */,
B2C3DA5B0D006CD600EF6F26 /* GlyphBuffer.h */,
+ 1C4D0DD124D9F0DB003D7498 /* GlyphBufferMembers.h */,
C5D4AA78116BAFB60069CA93 /* GlyphMetricsMap.h */,
0873B86A136064EA00A522C2 /* GlyphPage.h */,
BC53C6070DA56C570021EB5D /* Gradient.cpp */,
@@ -31316,6 +31319,7 @@
46B95197207D634000A7D2DD /* GlobalWindowIdentifier.h in Headers */,
086BBD0F136039C2008B15D8 /* Glyph.h in Headers */,
B2C3DA6C0D006CD600EF6F26 /* GlyphBuffer.h in Headers */,
+ 1C4D0DD324D9F10D003D7498 /* GlyphBufferMembers.h in Headers */,
C5D4AA7A116BAFB60069CA93 /* GlyphMetricsMap.h in Headers */,
0873B86B136064EA00A522C2 /* GlyphPage.h in Headers */,
311518FC1E78C15F00EC514A /* GPUBasedCanvasRenderingContext.h in Headers */,
Modified: trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp (266687 => 266688)
--- trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp 2020-09-07 00:20:01 UTC (rev 266687)
+++ trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp 2020-09-07 00:52:52 UTC (rev 266688)
@@ -584,7 +584,7 @@
// When leftmostGlyph is 0, it represents the first glyph to draw, taking into
// account the text direction.
if (!indexOfLeftmostGlyphInCurrentRun && glyphBuffer)
- glyphBuffer->setInitialAdvance(GlyphBufferAdvance(complexTextRun.initialAdvance().width(), complexTextRun.initialAdvance().height()));
+ glyphBuffer->setInitialAdvance(makeGlyphBufferAdvance(complexTextRun.initialAdvance()));
while (m_glyphInCurrentRun < glyphCount) {
unsigned glyphStartOffset = complexTextRun.indexAt(glyphIndexIntoCurrentRun);
@@ -604,23 +604,23 @@
if (glyphBuffer && !m_characterInCurrentGlyph) {
auto currentGlyphOrigin = glyphOrigin(glyphIndexIntoComplexTextController);
- GlyphBufferAdvance paintAdvance(adjustedBaseAdvance);
+ GlyphBufferAdvance paintAdvance = makeGlyphBufferAdvance(adjustedBaseAdvance);
if (!glyphIndexIntoCurrentRun) {
// The first layout advance of every run includes the "initial layout advance." However, here, we need
// paint advances, so subtract it out before transforming the layout advance into a paint advance.
- paintAdvance.setWidth(paintAdvance.width() - (complexTextRun.initialAdvance().width() - currentGlyphOrigin.x()));
- paintAdvance.setHeight(paintAdvance.height() - (complexTextRun.initialAdvance().height() - currentGlyphOrigin.y()));
+ setWidth(paintAdvance, width(paintAdvance) - (complexTextRun.initialAdvance().width() - currentGlyphOrigin.x()));
+ setHeight(paintAdvance, height(paintAdvance) - (complexTextRun.initialAdvance().height() - currentGlyphOrigin.y()));
}
- paintAdvance.setWidth(paintAdvance.width() + glyphOrigin(glyphIndexIntoComplexTextController + 1).x() - currentGlyphOrigin.x());
- paintAdvance.setHeight(paintAdvance.height() + glyphOrigin(glyphIndexIntoComplexTextController + 1).y() - currentGlyphOrigin.y());
+ setWidth(paintAdvance, width(paintAdvance) + glyphOrigin(glyphIndexIntoComplexTextController + 1).x() - currentGlyphOrigin.x());
+ setHeight(paintAdvance, height(paintAdvance) + glyphOrigin(glyphIndexIntoComplexTextController + 1).y() - currentGlyphOrigin.y());
if (glyphIndexIntoCurrentRun == glyphCount - 1 && currentRunIndex + 1 < runCount) {
// Our paint advance points to the end of the run. However, the next run may have an
// initial advance, and our paint advance needs to point to the location of the next
// glyph. So, we need to add in the next run's initial advance.
- paintAdvance.setWidth(paintAdvance.width() - glyphOrigin(glyphIndexIntoComplexTextController + 1).x() + m_complexTextRuns[currentRunIndex + 1]->initialAdvance().width());
- paintAdvance.setHeight(paintAdvance.height() - glyphOrigin(glyphIndexIntoComplexTextController + 1).y() + m_complexTextRuns[currentRunIndex + 1]->initialAdvance().height());
+ setWidth(paintAdvance, width(paintAdvance) - glyphOrigin(glyphIndexIntoComplexTextController + 1).x() + m_complexTextRuns[currentRunIndex + 1]->initialAdvance().width());
+ setHeight(paintAdvance, height(paintAdvance) - glyphOrigin(glyphIndexIntoComplexTextController + 1).y() + m_complexTextRuns[currentRunIndex + 1]->initialAdvance().height());
}
- paintAdvance.setHeight(-paintAdvance.height()); // Increasing y points down
+ setHeight(paintAdvance, -height(paintAdvance)); // Increasing y points down
glyphBuffer->add(m_adjustedGlyphs[glyphIndexIntoComplexTextController], complexTextRun.font(), paintAdvance, complexTextRun.indexAt(m_glyphInCurrentRun));
}
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (266687 => 266688)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-09-07 00:20:01 UTC (rev 266687)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-09-07 00:52:52 UTC (rev 266688)
@@ -302,7 +302,7 @@
if (glyphBuffer.isEmpty())
return FloatSize();
- FloatPoint startPoint = point + FloatSize(glyphBuffer.initialAdvance());
+ FloatPoint startPoint = point + WebCore::size(glyphBuffer.initialAdvance());
drawGlyphBuffer(context, glyphBuffer, startPoint, customFontNotReadyAction);
return startPoint - point;
}
@@ -320,7 +320,7 @@
if (glyphBuffer.isEmpty())
return;
- FloatPoint startPoint = point + FloatSize(glyphBuffer.initialAdvance());
+ FloatPoint startPoint = point + WebCore::size(glyphBuffer.initialAdvance());
drawEmphasisMarks(context, glyphBuffer, mark, startPoint);
}
@@ -345,7 +345,7 @@
return makeUnique<DisplayList::Recorder>(displayListContext, *displayList, context.state(), FloatRect(), AffineTransform());
});
- FloatPoint startPoint = toFloatPoint(FloatSize(glyphBuffer.initialAdvance()));
+ FloatPoint startPoint = toFloatPoint(WebCore::size(glyphBuffer.initialAdvance()));
drawGlyphBuffer(recordingContext, glyphBuffer, startPoint, customFontNotReadyAction);
return displayList;
}
@@ -451,7 +451,7 @@
// Same glyph widths but different floating point arithmetic can produce different run width.
float runWidthDifferenceWithTransformApplied = -runWidth;
for (size_t i = 0; i < glyphBuffer.size(); ++i)
- runWidthDifferenceWithTransformApplied += glyphBuffer.advanceAt(i).width();
+ runWidthDifferenceWithTransformApplied += WebCore::width(glyphBuffer.advanceAt(i));
runWidth += runWidthDifferenceWithTransformApplied;
if (cacheEntry)
@@ -1401,7 +1401,7 @@
if (!glyphBuffer.isEmpty()) {
// The initial advance is supposed to point directly to the first glyph's paint position.
// See the ascii-art diagram in ComplexTextController.h.
- glyphBuffer.expandInitialAdvance(GlyphBufferAdvance(glyphBuffer.originAt(0).x(), glyphBuffer.originAt(0).y()));
+ glyphBuffer.expandInitialAdvance(makeGlyphBufferAdvance(x(glyphBuffer.originAt(0)), y(glyphBuffer.originAt(0))));
}
// The glyph buffer is currently in logical order,
@@ -1429,18 +1429,18 @@
// the sum of the layout advances.
FloatSize initialAdvance = controller.totalAdvance();
for (unsigned i = 0; i < dummyGlyphBuffer.size(); ++i)
- initialAdvance -= toFloatSize(dummyGlyphBuffer.advanceAt(i));
+ initialAdvance -= WebCore::size(dummyGlyphBuffer.advanceAt(i));
for (unsigned i = 0; i < glyphBuffer.size(); ++i)
- initialAdvance -= toFloatSize(glyphBuffer.advanceAt(i));
+ initialAdvance -= WebCore::size(glyphBuffer.advanceAt(i));
// FIXME: Shouldn't we subtract the other initial advance?
glyphBuffer.reverse(0, glyphBuffer.size());
- glyphBuffer.setInitialAdvance(initialAdvance);
+ glyphBuffer.setInitialAdvance(makeGlyphBufferAdvance(initialAdvance));
} else {
- FloatSize initialAdvance = toFloatSize(dummyGlyphBuffer.initialAdvance());
+ FloatSize initialAdvance = WebCore::size(dummyGlyphBuffer.initialAdvance());
for (unsigned i = 0; i < dummyGlyphBuffer.size(); ++i)
- initialAdvance += toFloatSize(dummyGlyphBuffer.advanceAt(i));
+ initialAdvance += WebCore::size(dummyGlyphBuffer.advanceAt(i));
// FIXME: Shouldn't we add the other initial advance?
- glyphBuffer.setInitialAdvance(initialAdvance);
+ glyphBuffer.setInitialAdvance(makeGlyphBufferAdvance(initialAdvance));
}
return glyphBuffer;
@@ -1459,8 +1459,8 @@
ASSERT(glyphBuffer.isFlattened());
const Font* fontData = &glyphBuffer.fontAt(0);
FloatPoint startPoint = point;
- float nextX = startPoint.x() + glyphBuffer.advanceAt(0).width();
- float nextY = startPoint.y() + glyphBuffer.advanceAt(0).height();
+ float nextX = startPoint.x() + WebCore::width(glyphBuffer.advanceAt(0));
+ float nextY = startPoint.y() + height(glyphBuffer.advanceAt(0));
unsigned lastFrom = 0;
unsigned nextGlyph = 1;
while (nextGlyph < glyphBuffer.size()) {
@@ -1475,8 +1475,8 @@
startPoint.setX(nextX);
startPoint.setY(nextY);
}
- nextX += glyphBuffer.advanceAt(nextGlyph).width();
- nextY += glyphBuffer.advanceAt(nextGlyph).height();
+ nextX += WebCore::width(glyphBuffer.advanceAt(nextGlyph));
+ nextY += height(glyphBuffer.advanceAt(nextGlyph));
nextGlyph++;
}
@@ -1521,7 +1521,7 @@
GlyphBuffer markBuffer;
for (unsigned i = 0; i + 1 < glyphBuffer.size(); ++i) {
float middleOfNextGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, i + 1);
- float advance = glyphBuffer.advanceAt(i).width() - middleOfLastGlyph + middleOfNextGlyph;
+ float advance = WebCore::width(glyphBuffer.advanceAt(i)) - middleOfLastGlyph + middleOfNextGlyph;
markBuffer.add(glyphBuffer.glyphAt(i) ? markGlyph : spaceGlyph, *markFontData, advance);
middleOfLastGlyph = middleOfNextGlyph;
}
@@ -1766,7 +1766,7 @@
{
auto beginning = m_translation.mapPoint(FloatPoint(0, 0));
auto advance = m_glyphBuffer.advanceAt(m_index);
- auto end = m_translation.mapSize(FloatSize(advance.width(), advance.height()));
+ auto end = m_translation.mapSize(size(advance));
return std::make_pair(beginning.x(), beginning.x() + end.width());
}
@@ -1778,7 +1778,7 @@
void GlyphToPathTranslator::advance()
{
GlyphBufferAdvance advance = m_glyphBuffer.advanceAt(m_index);
- m_translation.translate(FloatSize(advance.width(), advance.height()));
+ m_translation.translate(size(advance));
++m_index;
if (m_index < m_glyphBuffer.size())
m_fontData = &m_glyphBuffer.fontAt(m_index);
@@ -1794,7 +1794,7 @@
if (!glyphBuffer.size())
return DashArray();
- FloatPoint origin = textOrigin + FloatSize(glyphBuffer.initialAdvance());
+ FloatPoint origin = textOrigin + WebCore::size(glyphBuffer.initialAdvance());
GlyphToPathTranslator translator(run, glyphBuffer, origin);
DashArray result;
for (unsigned index = 0; translator.containsMorePaths(); ++index, translator.advance()) {
Modified: trunk/Source/WebCore/platform/graphics/GlyphBuffer.h (266687 => 266688)
--- trunk/Source/WebCore/platform/graphics/GlyphBuffer.h 2020-09-07 00:20:01 UTC (rev 266687)
+++ trunk/Source/WebCore/platform/graphics/GlyphBuffer.h 2020-09-07 00:52:52 UTC (rev 266688)
@@ -32,141 +32,15 @@
#include "FloatPoint.h"
#include "FloatSize.h"
#include "Glyph.h"
+#include "GlyphBufferMembers.h"
#include <climits>
#include <limits>
#include <wtf/Vector.h>
-#if USE(CG)
-#include <CoreGraphics/CGGeometry.h>
-#endif
-
namespace WebCore {
class Font;
-#if USE(WINGDI)
-typedef wchar_t GlyphBufferGlyph;
-#else
-typedef Glyph GlyphBufferGlyph;
-#endif
-
-// CG uses CGSize instead of FloatSize so that the result of advances()
-// can be passed directly to CGContextShowGlyphsWithAdvances in FontMac.mm
-#if USE(CG)
-
-struct GlyphBufferAdvance : CGSize {
-public:
- GlyphBufferAdvance()
- : CGSize(CGSizeZero)
- {
- }
- GlyphBufferAdvance(FloatSize size)
- : CGSize(size)
- {
- }
- GlyphBufferAdvance(float width, float height)
- : CGSize(CGSizeMake(width, height))
- {
- }
-
- template<class Encoder> void encode(Encoder&) const;
- template<class Decoder> static Optional<GlyphBufferAdvance> decode(Decoder&);
-
- operator FloatSize() { return { static_cast<float>(this->CGSize::width), static_cast<float>(this->CGSize::height) }; }
-
- void setWidth(float width) { this->CGSize::width = width; }
- void setHeight(float height) { this->CGSize::height = height; }
- float width() const { return this->CGSize::width; }
- float height() const { return this->CGSize::height; }
-};
-
-template<class Encoder>
-void GlyphBufferAdvance::encode(Encoder& encoder) const
-{
- encoder << width();
- encoder << height();
-}
-
-template<class Decoder>
-Optional<GlyphBufferAdvance> GlyphBufferAdvance::decode(Decoder& decoder)
-{
- Optional<float> width;
- decoder >> width;
- if (!width)
- return WTF::nullopt;
-
- Optional<float> height;
- decoder >> height;
- if (!height)
- return WTF::nullopt;
-
- return GlyphBufferAdvance(*width, *height);
-}
-
-struct GlyphBufferOrigin : CGPoint {
-public:
- GlyphBufferOrigin()
- : CGPoint(CGPointZero)
- {
- }
- GlyphBufferOrigin(FloatPoint point)
- : CGPoint(point)
- {
- }
- GlyphBufferOrigin(float x, float y)
- : CGPoint(CGPointMake(x, y))
- {
- }
-
- template<class Encoder> void encode(Encoder&) const;
- template<class Decoder> static Optional<GlyphBufferOrigin> decode(Decoder&);
-
- operator FloatPoint() { return { static_cast<float>(this->CGPoint::x), static_cast<float>(this->CGPoint::y) }; }
-
- void setX(float x) { this->CGPoint::x = x; }
- void setY(float y) { this->CGPoint::y = y; }
- float x() const { return this->CGPoint::x; }
- float y() const { return this->CGPoint::y; }
-};
-
-template<class Encoder>
-void GlyphBufferOrigin::encode(Encoder& encoder) const
-{
- encoder << x();
- encoder << y();
-}
-
-template<class Decoder>
-Optional<GlyphBufferOrigin> GlyphBufferOrigin::decode(Decoder& decoder)
-{
- Optional<float> x;
- decoder >> x;
- if (!x)
- return WTF::nullopt;
-
- Optional<float> y;
- decoder >> y;
- if (!y)
- return WTF::nullopt;
-
- return GlyphBufferOrigin(*x, *y);
-}
-
-using GlyphBufferStringOffset = CFIndex;
-
-#else
-
-using GlyphBufferAdvance = FloatSize;
-using GlyphBufferOrigin = FloatPoint;
-using GlyphBufferStringOffset = unsigned;
-
-#endif // #if USE(CG)
-
-inline FloatSize toFloatSize(const GlyphBufferAdvance& a)
-{
- return FloatSize(a.width(), a.height());
-}
-
class GlyphBuffer {
public:
bool isEmpty() const { return m_fonts.isEmpty(); }
@@ -204,19 +78,17 @@
void setInitialAdvance(GlyphBufferAdvance initialAdvance) { m_initialAdvance = initialAdvance; }
const GlyphBufferAdvance& initialAdvance() const { return m_initialAdvance; }
- void expandInitialAdvance(float width) { m_initialAdvance.setWidth(m_initialAdvance.width() + width); }
+ void expandInitialAdvance(float width) { setWidth(m_initialAdvance, WebCore::width(m_initialAdvance) + width); }
void expandInitialAdvance(GlyphBufferAdvance additionalAdvance)
{
- m_initialAdvance.setWidth(m_initialAdvance.width() + additionalAdvance.width());
- m_initialAdvance.setHeight(m_initialAdvance.height() + additionalAdvance.height());
+ setWidth(m_initialAdvance, width(m_initialAdvance) + width(additionalAdvance));
+ setHeight(m_initialAdvance, height(m_initialAdvance) + height(additionalAdvance));
}
static constexpr GlyphBufferStringOffset noOffset = std::numeric_limits<GlyphBufferStringOffset>::max();
void add(Glyph glyph, const Font& font, float width, GlyphBufferStringOffset offsetInString = noOffset)
{
- GlyphBufferAdvance advance;
- advance.setWidth(width);
- advance.setHeight(0);
+ GlyphBufferAdvance advance = makeGlyphBufferAdvance(width, 0);
add(glyph, font, advance, offsetInString);
}
@@ -225,7 +97,7 @@
m_fonts.append(&font);
m_glyphs.append(glyph);
m_advances.append(advance);
- m_origins.append(GlyphBufferOrigin());
+ m_origins.append(makeGlyphBufferOrigin());
m_offsetsInString.append(offsetInString);
}
@@ -243,9 +115,9 @@
ASSERT(location <= size());
m_fonts.insertVector(location, Vector<const Font*>(length, font));
- m_glyphs.insertVector(location, Vector<GlyphBufferGlyph>(length, 0xFFFF));
- m_advances.insertVector(location, Vector<GlyphBufferAdvance>(length, GlyphBufferAdvance(0, 0)));
- m_origins.insertVector(location, Vector<GlyphBufferOrigin>(length, GlyphBufferOrigin()));
+ m_glyphs.insertVector(location, Vector<GlyphBufferGlyph>(length, std::numeric_limits<GlyphBufferGlyph>::max()));
+ m_advances.insertVector(location, Vector<GlyphBufferAdvance>(length, makeGlyphBufferAdvance()));
+ m_origins.insertVector(location, Vector<GlyphBufferOrigin>(length, makeGlyphBufferOrigin()));
m_offsetsInString.insertVector(location, Vector<GlyphBufferStringOffset>(length, 0));
}
@@ -259,7 +131,7 @@
{
ASSERT(!isEmpty());
GlyphBufferAdvance& lastAdvance = m_advances.last();
- lastAdvance.setWidth(lastAdvance.width() + width);
+ setWidth(lastAdvance, WebCore::width(lastAdvance) + width);
}
void expandAdvance(unsigned index, float width)
@@ -266,7 +138,7 @@
{
ASSERT(index < size());
auto& lastAdvance = m_advances[index];
- lastAdvance.setWidth(lastAdvance.width() + width);
+ setWidth(lastAdvance, WebCore::width(lastAdvance) + width);
}
void expandLastAdvance(GlyphBufferAdvance expansion)
@@ -273,8 +145,8 @@
{
ASSERT(!isEmpty());
GlyphBufferAdvance& lastAdvance = m_advances.last();
- lastAdvance.setWidth(lastAdvance.width() + expansion.width());
- lastAdvance.setHeight(lastAdvance.height() + expansion.height());
+ setWidth(lastAdvance, width(lastAdvance) + width(expansion));
+ setHeight(lastAdvance, height(lastAdvance) + height(expansion));
}
void shrink(unsigned truncationPoint)
@@ -295,11 +167,11 @@
void flatten()
{
for (unsigned i = 0; i < size(); ++i) {
- m_advances[i] = GlyphBufferAdvance(
- -m_origins[i].x() + m_advances[i].width() + (i + 1 < size() ? m_origins[i + 1].x() : 0),
- -m_origins[i].y() + m_advances[i].height() + (i + 1 < size() ? m_origins[i + 1].y() : 0)
+ m_advances[i] = makeGlyphBufferAdvance(
+ -x(m_origins[i]) + width(m_advances[i]) + (i + 1 < size() ? x(m_origins[i + 1]) : 0),
+ -y(m_origins[i]) + height(m_advances[i]) + (i + 1 < size() ? y(m_origins[i + 1]) : 0)
);
- m_origins[i] = GlyphBufferOrigin();
+ m_origins[i] = makeGlyphBufferOrigin();
}
}
@@ -306,7 +178,7 @@
bool isFlattened() const
{
for (unsigned i = 0; i < size(); ++i) {
- if (m_origins[i] != GlyphBufferOrigin())
+ if (m_origins[i] != makeGlyphBufferOrigin())
return false;
}
return true;
@@ -341,7 +213,7 @@
Vector<GlyphBufferAdvance, 1024> m_advances;
Vector<GlyphBufferOrigin, 1024> m_origins;
Vector<GlyphBufferStringOffset, 1024> m_offsetsInString;
- GlyphBufferAdvance m_initialAdvance;
+ GlyphBufferAdvance m_initialAdvance { makeGlyphBufferAdvance() };
};
}
Added: trunk/Source/WebCore/platform/graphics/GlyphBufferMembers.h (0 => 266688)
--- trunk/Source/WebCore/platform/graphics/GlyphBufferMembers.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/GlyphBufferMembers.h 2020-09-07 00:52:52 UTC (rev 266688)
@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2008 Torch Mobile Inc.
+ *
+ * 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.
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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 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.
+ */
+
+#pragma once
+
+#include "FloatSize.h"
+#include "Glyph.h"
+#include <wtf/Vector.h>
+
+#if USE(CG)
+#include <CoreGraphics/CGFont.h>
+#include <CoreGraphics/CGGeometry.h>
+#endif
+
+namespace WebCore {
+
+// The CG ports use the CG types directly, so an array of these types can be fed directly into CTFontShapeGlyphs().
+#if USE(CG)
+using GlyphBufferGlyph = CGGlyph;
+using GlyphBufferAdvance = CGSize;
+using GlyphBufferOrigin = CGPoint;
+using GlyphBufferStringOffset = CFIndex;
+#elif USE(WINGDI)
+using GlyphBufferGlyph = wchar_t;
+using GlyphBufferAdvance = FloatSize;
+using GlyphBufferOrigin = FloatPoint;
+using GlyphBufferStringOffset = unsigned;
+#else
+using GlyphBufferGlyph = Glyph;
+using GlyphBufferAdvance = FloatSize;
+using GlyphBufferOrigin = FloatPoint;
+using GlyphBufferStringOffset = unsigned;
+#endif
+
+inline GlyphBufferAdvance makeGlyphBufferAdvance(const FloatSize&);
+inline GlyphBufferAdvance makeGlyphBufferAdvance(float = 0, float = 0);
+inline FloatSize size(const GlyphBufferAdvance&);
+inline void setWidth(GlyphBufferAdvance&, float);
+inline void setHeight(GlyphBufferAdvance&, float);
+inline float width(const GlyphBufferAdvance&);
+inline float height(const GlyphBufferAdvance&);
+inline GlyphBufferOrigin makeGlyphBufferOrigin(const FloatPoint&);
+inline GlyphBufferOrigin makeGlyphBufferOrigin(float = 0, float = 0);
+inline FloatPoint point(const GlyphBufferOrigin&);
+inline void setX(GlyphBufferOrigin&, float);
+inline void setY(GlyphBufferOrigin&, float);
+inline float x(const GlyphBufferOrigin&);
+inline float y(const GlyphBufferOrigin&);
+
+#if USE(CG)
+
+inline GlyphBufferAdvance makeGlyphBufferAdvance(const FloatSize& size)
+{
+ return CGSizeMake(size.width(), size.height());
+}
+
+inline GlyphBufferAdvance makeGlyphBufferAdvance(float width, float height)
+{
+ return CGSizeMake(width, height);
+}
+
+inline FloatSize size(const GlyphBufferAdvance& advance)
+{
+ return FloatSize(advance.width, advance.height);
+}
+
+inline void setWidth(GlyphBufferAdvance& advance, float width)
+{
+ advance.width = width;
+}
+
+inline void setHeight(GlyphBufferAdvance& advance, float height)
+{
+ advance.height = height;
+}
+
+inline float width(const GlyphBufferAdvance& advance)
+{
+ return advance.width;
+}
+
+inline float height(const GlyphBufferAdvance& advance)
+{
+ return advance.height;
+}
+
+inline GlyphBufferOrigin makeGlyphBufferOrigin(const FloatPoint& point)
+{
+ return CGPointMake(point.x(), point.y());
+}
+
+inline GlyphBufferOrigin makeGlyphBufferOrigin(float x, float y)
+{
+ return CGPointMake(x, y);
+}
+
+inline FloatPoint point(const GlyphBufferOrigin& origin)
+{
+ return FloatPoint(origin.x, origin.y);
+}
+
+inline void setX(GlyphBufferOrigin& origin, float x)
+{
+ origin.x = x;
+}
+
+inline void setY(GlyphBufferOrigin& origin, float y)
+{
+ origin.y = y;
+}
+
+inline float x(const GlyphBufferOrigin& origin)
+{
+ return origin.x;
+}
+
+inline float y(const GlyphBufferOrigin& origin)
+{
+ return origin.y;
+}
+
+#else
+
+inline GlyphBufferAdvance makeGlyphBufferAdvance(const FloatSize& size)
+{
+ return size;
+}
+
+inline GlyphBufferAdvance makeGlyphBufferAdvance(float width, float height)
+{
+ return FloatSize(width, height);
+}
+
+inline FloatSize size(const GlyphBufferAdvance& advance)
+{
+ return advance;
+}
+
+inline void setWidth(GlyphBufferAdvance& advance, float width)
+{
+ advance.setWidth(width);
+}
+
+inline void setHeight(GlyphBufferAdvance& advance, float height)
+{
+ advance.setHeight(height);
+}
+
+inline float width(const GlyphBufferAdvance& advance)
+{
+ return advance.width();
+}
+
+inline float height(const GlyphBufferAdvance& advance)
+{
+ return advance.height();
+}
+
+inline GlyphBufferOrigin makeGlyphBufferOrigin(const FloatPoint& point)
+{
+ return point;
+}
+
+inline GlyphBufferOrigin makeGlyphBufferOrigin(float x, float y)
+{
+ return FloatPoint(x, y);
+}
+
+inline FloatPoint point(const GlyphBufferOrigin& origin)
+{
+ return origin;
+}
+
+inline void setX(GlyphBufferOrigin& origin, float x)
+{
+ origin.setX(x);
+}
+
+inline void setY(GlyphBufferOrigin& origin, float y)
+{
+ origin.setY(y);
+}
+
+inline float x(const GlyphBufferOrigin& origin)
+{
+ return origin.x();
+}
+
+inline float y(const GlyphBufferOrigin& origin)
+{
+ return origin.y();
+}
+
+#endif // #if USE(CG)
+
+}
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (266687 => 266688)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-09-07 00:20:01 UTC (rev 266687)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-09-07 00:52:52 UTC (rev 266688)
@@ -101,7 +101,7 @@
GlyphBufferAdvance* advances = glyphBuffer.advances(0);
float beforeWidth = 0;
for (unsigned i = lastGlyphCount; i < glyphBufferSize; ++i)
- beforeWidth += advances[i].width();
+ beforeWidth += width(advances[i]);
ASSERT(lastGlyphCount <= glyphBufferSize);
@@ -110,8 +110,8 @@
GlyphBufferOrigin* origins = glyphBuffer.origins(0);
for (unsigned i = lastGlyphCount; i < glyphBufferSize; ++i) {
- advances[i].setHeight(-advances[i].height());
- origins[i].setY(-origins[i].y());
+ setHeight(advances[i], -height(advances[i]));
+ setY(origins[i], -y(origins[i]));
}
for (unsigned i = lastGlyphCount; i < glyphBufferSize; ++i) {
@@ -123,14 +123,14 @@
continue;
const auto& originalAdvances = *iterator;
if (i && !originalAdvances.characterIsSpace)
- glyphBuffer.advances(i - 1)->setWidth(originalAdvances.advanceBeforeCharacter);
- glyphBuffer.advances(i)->setWidth(originalAdvances.advanceAtCharacter);
+ setWidth(*glyphBuffer.advances(i - 1), originalAdvances.advanceBeforeCharacter);
+ setWidth(*glyphBuffer.advances(i), originalAdvances.advanceAtCharacter);
}
charactersTreatedAsSpace.clear();
float afterWidth = 0;
for (unsigned i = lastGlyphCount; i < glyphBufferSize; ++i)
- afterWidth += advances[i].width();
+ afterWidth += width(advances[i]);
return afterWidth - beforeWidth;
}
@@ -248,7 +248,7 @@
charactersTreatedAsSpace.constructAndAppend(
currentCharacterIndex,
character == ' ',
- glyphBuffer.size() ? glyphBuffer.advanceAt(glyphBuffer.size() - 1).width() : 0,
+ glyphBuffer.size() ? WebCore::width(glyphBuffer.advanceAt(glyphBuffer.size() - 1)) : 0,
width);
}
@@ -291,7 +291,7 @@
if (character == tabCharacter && m_run.allowTabs()) {
auto& font = glyphBuffer.fontAt(trailingGlyphIndex);
auto newWidth = m_font.tabWidth(font, m_run.tabSize(), position);
- auto currentWidth = glyphBuffer.advanceAt(trailingGlyphIndex).width();
+ auto currentWidth = width(glyphBuffer.advanceAt(trailingGlyphIndex));
rightAdditionalWidth += newWidth - currentWidth;
}
@@ -301,7 +301,7 @@
// This is a heuristic to determine if the character is non-visible. Non-visible characters don't get letter-spacing.
float baseWidth = 0;
for (unsigned i = leadingGlyphIndex; i <= trailingGlyphIndex; ++i)
- baseWidth += glyphBuffer.advanceAt(i).width();
+ baseWidth += width(glyphBuffer.advanceAt(i));
if (baseWidth)
rightAdditionalWidth += m_font.letterSpacing();
@@ -388,7 +388,7 @@
Vector<float> advanceWidths(m_run.length(), 0);
for (unsigned i = glyphBufferStartIndex; i < glyphBuffer.size(); ++i) {
auto stringOffset = glyphBuffer.stringOffsetAt(i);
- advanceWidths[stringOffset] += glyphBuffer.advanceAt(i).width();
+ advanceWidths[stringOffset] += width(glyphBuffer.advanceAt(i));
auto& glyphIndexRange = characterIndexToGlyphIndexRange[stringOffset];
if (glyphIndexRange)
glyphIndexRange->trailingGlyphIndex = i;
@@ -406,7 +406,7 @@
if (character == tabCharacter)
continue;
- auto currentAdvance = glyphBuffer.advanceAt(i).width();
+ auto currentAdvance = width(glyphBuffer.advanceAt(i));
auto newAdvance = currentAdvance * m_run.horizontalGlyphStretch();
glyphBuffer.expandAdvance(i, newAdvance - currentAdvance);
}
@@ -493,7 +493,7 @@
advance(m_currentCharacterIndex + 1, glyphBuffer);
float w = 0;
for (unsigned i = oldSize; i < glyphBuffer.size(); ++i)
- w += glyphBuffer.advanceAt(i).width();
+ w += WebCore::width(glyphBuffer.advanceAt(i));
width = w;
return glyphBuffer.size() > oldSize;
}
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (266687 => 266688)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm 2020-09-07 00:20:01 UTC (rev 266687)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm 2020-09-07 00:52:52 UTC (rev 266688)
@@ -288,18 +288,18 @@
float shadowTextX = point.x() + shadowOffset.width();
// If shadows are ignoring transforms, then we haven't applied the Y coordinate flip yet, so down is negative.
float shadowTextY = point.y() + shadowOffset.height() * (context.shadowsIgnoreTransforms() ? -1 : 1);
- showGlyphsWithAdvances(FloatPoint(shadowTextX, shadowTextY), font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
+ showGlyphsWithAdvances(FloatPoint(shadowTextX, shadowTextY), font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
if (syntheticBoldOffset)
- showGlyphsWithAdvances(FloatPoint(shadowTextX + syntheticBoldOffset, shadowTextY), font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
+ showGlyphsWithAdvances(FloatPoint(shadowTextX + syntheticBoldOffset, shadowTextY), font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
context.setFillColor(fillColor);
}
if (useLetterpressEffect)
- showLetterpressedGlyphsWithAdvances(point, font, context, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
+ showLetterpressedGlyphsWithAdvances(point, font, context, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
else
- showGlyphsWithAdvances(point, font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
+ showGlyphsWithAdvances(point, font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
if (syntheticBoldOffset)
- showGlyphsWithAdvances(FloatPoint(point.x() + syntheticBoldOffset, point.y()), font, cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
+ showGlyphsWithAdvances(FloatPoint(point.x() + syntheticBoldOffset, point.y()), font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
if (hasSimpleShadow)
context.setShadow(shadowOffset, shadowBlur, shadowColor);
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (266687 => 266688)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2020-09-07 00:20:01 UTC (rev 266687)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2020-09-07 00:52:52 UTC (rev 266688)
@@ -563,10 +563,10 @@
size_t numGlyphs = m_glyphs.size();
for (size_t i = 0; i < numGlyphs; ++i) {
GlyphBufferAdvance advance = m_advances[i];
- FloatRect glyphRect = FloatRect(current.x(), current.y() - ascent, advance.width(), ascent + descent);
+ FloatRect glyphRect = FloatRect(current.x(), current.y() - ascent, width(advance), ascent + descent);
m_bounds.unite(glyphRect);
- current.move(advance.width(), advance.height());
+ current.move(width(advance), height(advance));
}
}
Modified: trunk/Tools/ChangeLog (266687 => 266688)
--- trunk/Tools/ChangeLog 2020-09-07 00:20:01 UTC (rev 266687)
+++ trunk/Tools/ChangeLog 2020-09-07 00:52:52 UTC (rev 266688)
@@ -1,3 +1,13 @@
+2020-09-06 Myles C. Maxfield <[email protected]>
+
+ Make GlyphBufferAdvance and GlyphBufferOrigin more robust
+ https://bugs.webkit.org/show_bug.cgi?id=215143
+
+ Reviewed by Zalan Bujtas.
+
+ * TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp:
+ (TestWebKitAPI::TEST_F):
+
2020-09-06 Sam Weinig <[email protected]>
[WebIDL] Add mode to preprocess-idls.pl to validate fast regex based scanner with the normal IDL parser
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp (266687 => 266688)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp 2020-09-07 00:20:01 UTC (rev 266687)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp 2020-09-07 00:52:52 UTC (rev 266688)
@@ -80,15 +80,15 @@
EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width(), 0.0001);
controller.advance(6, &glyphBuffer);
EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + totalWidth, 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().width(), 0, 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 0, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.initialAdvance()), 0, 0.0001);
+ EXPECT_NEAR(height(glyphBuffer.initialAdvance()), 0, 0.0001);
EXPECT_EQ(glyphBuffer.size(), 6U);
- EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(5).width(), spaceWidth + initialAdvance.width(), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(0)), width(advances[4]), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(1)), width(advances[3]), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(2)), width(advances[2]), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(3)), width(advances[1]), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(4)), -width(initialAdvance), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(5)), spaceWidth + width(initialAdvance), 0.0001);
}
TEST_F(ComplexTextControllerTest, InitialAdvanceInRTL)
@@ -124,15 +124,15 @@
EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width(), 0.0001);
controller.advance(5, &glyphBuffer);
EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height(), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.initialAdvance()), initialAdvance.width(), 0.0001);
+ EXPECT_NEAR(height(glyphBuffer.initialAdvance()), initialAdvance.height(), 0.0001);
EXPECT_EQ(glyphBuffer.size(), 5U);
- EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(4).height(), initialAdvance.height(), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(0)), advances[4].width(), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(1)), advances[3].width(), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(2)), advances[2].width(), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(3)), advances[1].width(), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(4)), -initialAdvance.width(), 0.0001);
+ EXPECT_NEAR(height(glyphBuffer.advanceAt(4)), initialAdvance.height(), 0.0001);
}
TEST_F(ComplexTextControllerTest, InitialAdvanceWithLeftRunInLTR)
@@ -170,12 +170,12 @@
EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + advances[0].width() + initialAdvance.width(), 0.0001);
controller.advance(3, &glyphBuffer);
EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + 76.347656 + initialAdvance.width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().width(), 0, 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 0, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.initialAdvance()), 0, 0.0001);
+ EXPECT_NEAR(height(glyphBuffer.initialAdvance()), 0, 0.0001);
EXPECT_EQ(glyphBuffer.size(), 3U);
- EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), spaceWidth + initialAdvance.width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 53.066406, 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), 23.281250, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(0)), spaceWidth + initialAdvance.width(), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(1)), 53.066406, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(2)), 23.281250, 0.0001);
}
TEST_F(ComplexTextControllerTest, InitialAdvanceInLTR)
@@ -208,11 +208,11 @@
EXPECT_NEAR(controller.runWidthSoFar(), advances[0].width() + initialAdvance.width(), 0.0001);
controller.advance(2, &glyphBuffer);
EXPECT_NEAR(controller.runWidthSoFar(), 76.347656 + initialAdvance.width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height(), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.initialAdvance()), initialAdvance.width(), 0.0001);
+ EXPECT_NEAR(height(glyphBuffer.initialAdvance()), initialAdvance.height(), 0.0001);
EXPECT_EQ(glyphBuffer.size(), 2U);
- EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), 53.066406, 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 23.281250, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(0)), 53.066406, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(1)), 23.281250, 0.0001);
}
TEST_F(ComplexTextControllerTest, InitialAdvanceInRTLNoOrigins)
@@ -251,14 +251,14 @@
EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001);
controller.advance(4, &glyphBuffer);
EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width(), 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height(), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.initialAdvance()), initialAdvance.width(), 0.0001);
+ EXPECT_NEAR(height(glyphBuffer.initialAdvance()), initialAdvance.height(), 0.0001);
EXPECT_EQ(glyphBuffer.size(), 4U);
- EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), 43.8119349005425, 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 12.0, 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), 14.0397830018083, 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), -4.33996383363472, 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(3).height(), 12.368896925859, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(0)), 43.8119349005425, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(1)), 12.0, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(2)), 14.0397830018083, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(3)), -4.33996383363472, 0.0001);
+ EXPECT_NEAR(height(glyphBuffer.advanceAt(3)), 12.368896925859, 0.0001);
}
TEST_F(ComplexTextControllerTest, LeftExpansion)
@@ -285,10 +285,10 @@
EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
controller.advance(1, &glyphBuffer);
EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().width(), 100, 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 0, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.initialAdvance()), 100, 0.0001);
+ EXPECT_NEAR(height(glyphBuffer.initialAdvance()), 0, 0.0001);
EXPECT_EQ(glyphBuffer.size(), 1U);
- EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), 24, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(0)), 24, 0.0001);
}
TEST_F(ComplexTextControllerTest, VerticalAdvances)
@@ -322,17 +322,17 @@
EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
controller.advance(4, &glyphBuffer);
EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().width(), 0, 0.0001);
- EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 16, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.initialAdvance()), 0, 0.0001);
+ EXPECT_NEAR(height(glyphBuffer.initialAdvance()), 16, 0.0001);
EXPECT_EQ(glyphBuffer.size(), 4U);
- EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), 0, 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(0).height(), 4 - 1 -8, 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 0, 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(1).height(), 8 - 2 - 512, 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), 0, 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(2).height(), 128 - 32 - 256, 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), 0, 0.0001);
- EXPECT_NEAR(glyphBuffer.advanceAt(3).height(), 256 - 64, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(0)), 0, 0.0001);
+ EXPECT_NEAR(height(glyphBuffer.advanceAt(0)), 4 - 1 -8, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(1)), 0, 0.0001);
+ EXPECT_NEAR(height(glyphBuffer.advanceAt(1)), 8 - 2 - 512, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(2)), 0, 0.0001);
+ EXPECT_NEAR(height(glyphBuffer.advanceAt(2)), 128 - 32 - 256, 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(3)), 0, 0.0001);
+ EXPECT_NEAR(height(glyphBuffer.advanceAt(3)), 256 - 64, 0.0001);
}
TEST_F(ComplexTextControllerTest, TotalWidthWithJustification)
@@ -361,7 +361,12 @@
EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
controller.advance(5, &glyphBuffer);
EXPECT_EQ(glyphBuffer.size(), 5U);
- EXPECT_NEAR(glyphBuffer.advanceAt(0).width() + glyphBuffer.advanceAt(1).width() + glyphBuffer.advanceAt(2).width() + glyphBuffer.advanceAt(3).width() + glyphBuffer.advanceAt(4).width(), controller.totalAdvance().width(), 0.0001);
+ EXPECT_NEAR(width(glyphBuffer.advanceAt(0))
+ + width(glyphBuffer.advanceAt(1))
+ + width(glyphBuffer.advanceAt(2))
+ + width(glyphBuffer.advanceAt(3))
+ + width(glyphBuffer.advanceAt(4))
+ , controller.totalAdvance().width(), 0.0001);
}
}