Initial advance of text runs should be taken into account
authorgraouts@apple.com <graouts@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Apr 2013 09:50:15 +0000 (09:50 +0000)
committergraouts@apple.com <graouts@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Apr 2013 09:50:15 +0000 (09:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=114949

Reviewed by Darin Adler.

Source/WebCore:

Keep track of complex text runs' initial advance by adding a new
member to GlyphBuffer and adding the initial advance of any non-first
text run to the advance of the last glyph added for the previous text run.
Additionally, we now correctly handle advance values in the y-axis.

Test: fast/text/complex-initial-advance.html

* WebCore.exp.in:
Add support for new WebKitSystemInterface API.
* platform/graphics/FontFastPath.cpp:
(WebCore::Font::drawGlyphBuffer):
Take into account the buffer's initial advance in the y-axis to adjust
the point at which to draw the buffers. Additionally, keep track of advances
on the y-axis as well as the x-axis (which we already were doing) as we iterate
through glyphs and adjust the start point.
(WebCore::Font::drawEmphasisMarks):
Adopt change of GlyphBuffer::advanceAt() return type.
* platform/graphics/GlyphBuffer.h:
Removing the WINCE-specific GlyphBufferAdvance struct since heights are now necessary.
(WebCore::GlyphBufferAdvance::GlyphBufferAdvance):
New default constructor for GlyphBufferAdvance to support the m_initialAdvance member.
(WebCore::GlyphBuffer::setInitialAdvance):
(WebCore::GlyphBuffer::initialAdvance):
New APIs to get and set the initial advance for a glyph buffer.
(WebCore::GlyphBuffer::advanceAt):
Return a GlyphBufferAdvance rather than a float which used to be only
the glyph buffer's x-axis advance. This is necessary to handle deltas
on the y-axis as well (see WebCore::Font::drawGlyphBuffer).
* platform/graphics/GlyphBuffer.h:
(GlyphBuffer):
(WebCore::GlyphBuffer::setInitialAdvance):
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::advanceInternal):
(WebCore::WidthIterator::advanceOneCharacter):
Adopt change of GlyphBuffer::advanceAt() return type.
* platform/graphics/cairo/FontCairo.cpp:
(WebCore::Font::drawGlyphs):
Adopt change of GlyphBuffer::advanceAt() return type.
* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::advance):
When processing the first text run, set that run's initial advance as
the glyph buffer's initial advance.
(WebCore::ComplexTextController::adjustGlyphsAndAdvances):
Represent the initial advance for a text run by adjusting the advance
of the last glyph of the previous text run in the glyph buffer.
* platform/graphics/mac/ComplexTextController.h:
(WebCore::ComplexTextController::ComplexTextRun::initialAdvance):
(ComplexTextRun):
New API to read the inital advance of a complex text run.
* platform/graphics/mac/ComplexTextControllerCoreText.mm:
(WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
Obtain the text run's initial advance via the new wkCTRunGetInitialAdvance
WebKitSystemInterface API.
* platform/graphics/qt/FontQt.cpp:
(WebCore::Font::drawGlyphs):
Adopt change of GlyphBuffer::advanceAt() return type.
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:
Add support for the new wkCTRunGetInitialAdvance WebKitSystemInterface API.
* platform/wx/wxcode/cairo/non-kerned-drawing.cpp:
(WebCore::drawTextWithSpacing):
Adopt change of GlyphBuffer::advanceAt() return type.
* rendering/svg/SVGTextRunRenderingContext.cpp:
(WebCore::SVGTextRunRenderingContext::drawSVGGlyphs):
Adopt change of GlyphBuffer::advanceAt() return type.

Source/WebKit/mac:

Adding support for new method CTRunGetInitialAdvance in WebKitSystemInterface.

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

Source/WebKit2:

Adding support for new method CTRunGetInitialAdvance in WebKitSystemInterface.

* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

WebKitLibraries:

* WebKitSystemInterface.h:
* libWebKitSystemInterfaceLion.a:
* libWebKitSystemInterfaceMountainLion.a:

LayoutTests:

* fast/text/complex-initial-advance-expected.html: Added.
* fast/text/complex-initial-advance.html: Added.

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

25 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/complex-initial-advance-expected.html [new file with mode: 0644]
LayoutTests/fast/text/complex-initial-advance.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/graphics/FontFastPath.cpp
Source/WebCore/platform/graphics/GlyphBuffer.h
Source/WebCore/platform/graphics/WidthIterator.cpp
Source/WebCore/platform/graphics/cairo/FontCairo.cpp
Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
Source/WebCore/platform/graphics/mac/ComplexTextController.h
Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
Source/WebCore/platform/graphics/qt/FontQt.cpp
Source/WebCore/platform/mac/WebCoreSystemInterface.h
Source/WebCore/platform/mac/WebCoreSystemInterface.mm
Source/WebCore/platform/wx/wxcode/cairo/non-kerned-drawing.cpp
Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLion.a
WebKitLibraries/libWebKitSystemInterfaceMountainLion.a

index 8b177c8..e4fc340 100644 (file)
@@ -1,3 +1,13 @@
+2013-04-23  Antoine Quint  <graouts@apple.com>
+
+        Initial advance of text runs should be taken into account
+        https://bugs.webkit.org/show_bug.cgi?id=114949
+
+        Reviewed by Darin Adler.
+
+        * fast/text/complex-initial-advance-expected.html: Added.
+        * fast/text/complex-initial-advance.html: Added.
+
 2013-04-23  Zan Dobersek  <zdobersek@igalia.com>
 
         Unreviewed GTK gardening.
diff --git a/LayoutTests/fast/text/complex-initial-advance-expected.html b/LayoutTests/fast/text/complex-initial-advance-expected.html
new file mode 100644 (file)
index 0000000..38b2cc9
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body style="font-family: Geeza Pro">
+<span>مليئ حياةٍ مليئ</span>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/text/complex-initial-advance.html b/LayoutTests/fast/text/complex-initial-advance.html
new file mode 100644 (file)
index 0000000..da03f3e
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body style="font-family: Geeza Pro">
+<span>مليئ</span><span> </span><span>حياةٍ</span><span> </span><span>مليئ</span>
+</body>
+</html>
\ No newline at end of file
index d975a7c..fc29236 100644 (file)
@@ -1,3 +1,76 @@
+2013-04-23  Antoine Quint  <graouts@apple.com>
+
+        Initial advance of text runs should be taken into account
+        https://bugs.webkit.org/show_bug.cgi?id=114949
+
+        Reviewed by Darin Adler.
+
+        Keep track of complex text runs' initial advance by adding a new
+        member to GlyphBuffer and adding the initial advance of any non-first
+        text run to the advance of the last glyph added for the previous text run.
+        Additionally, we now correctly handle advance values in the y-axis.
+
+        Test: fast/text/complex-initial-advance.html
+
+        * WebCore.exp.in:
+        Add support for new WebKitSystemInterface API.
+        * platform/graphics/FontFastPath.cpp:
+        (WebCore::Font::drawGlyphBuffer):
+        Take into account the buffer's initial advance in the y-axis to adjust
+        the point at which to draw the buffers. Additionally, keep track of advances
+        on the y-axis as well as the x-axis (which we already were doing) as we iterate
+        through glyphs and adjust the start point.
+        (WebCore::Font::drawEmphasisMarks):
+        Adopt change of GlyphBuffer::advanceAt() return type.
+        * platform/graphics/GlyphBuffer.h:
+        Removing the WINCE-specific GlyphBufferAdvance struct since heights are now necessary.
+        (WebCore::GlyphBufferAdvance::GlyphBufferAdvance):
+        New default constructor for GlyphBufferAdvance to support the m_initialAdvance member.
+        (WebCore::GlyphBuffer::setInitialAdvance):
+        (WebCore::GlyphBuffer::initialAdvance):
+        New APIs to get and set the initial advance for a glyph buffer.
+        (WebCore::GlyphBuffer::advanceAt):
+        Return a GlyphBufferAdvance rather than a float which used to be only
+        the glyph buffer's x-axis advance. This is necessary to handle deltas
+        on the y-axis as well (see WebCore::Font::drawGlyphBuffer).
+        * platform/graphics/GlyphBuffer.h:
+        (GlyphBuffer):
+        (WebCore::GlyphBuffer::setInitialAdvance):
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::WidthIterator::advanceInternal):
+        (WebCore::WidthIterator::advanceOneCharacter):
+        Adopt change of GlyphBuffer::advanceAt() return type.
+        * platform/graphics/cairo/FontCairo.cpp:
+        (WebCore::Font::drawGlyphs):
+        Adopt change of GlyphBuffer::advanceAt() return type.
+        * platform/graphics/mac/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::advance):
+        When processing the first text run, set that run's initial advance as
+        the glyph buffer's initial advance.
+        (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
+        Represent the initial advance for a text run by adjusting the advance
+        of the last glyph of the previous text run in the glyph buffer.
+        * platform/graphics/mac/ComplexTextController.h:
+        (WebCore::ComplexTextController::ComplexTextRun::initialAdvance):
+        (ComplexTextRun):
+        New API to read the inital advance of a complex text run.
+        * platform/graphics/mac/ComplexTextControllerCoreText.mm:
+        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
+        Obtain the text run's initial advance via the new wkCTRunGetInitialAdvance
+        WebKitSystemInterface API.
+        * platform/graphics/qt/FontQt.cpp:
+        (WebCore::Font::drawGlyphs):
+        Adopt change of GlyphBuffer::advanceAt() return type.
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+        Add support for the new wkCTRunGetInitialAdvance WebKitSystemInterface API.
+        * platform/wx/wxcode/cairo/non-kerned-drawing.cpp:
+        (WebCore::drawTextWithSpacing):
+        Adopt change of GlyphBuffer::advanceAt() return type.
+        * rendering/svg/SVGTextRunRenderingContext.cpp:
+        (WebCore::SVGTextRunRenderingContext::drawSVGGlyphs):
+        Adopt change of GlyphBuffer::advanceAt() return type.
+
 2013-04-23  Noam Rosenthal  <noam@webkit.org>
 
         [Texmap] Don't paint to an intermediate surface when the result is going to be clipped out completely.
index eed7967..9382d18 100644 (file)
@@ -1650,6 +1650,7 @@ _wkCopyRequestWithStorageSession
 _wkCreateCTLineWithUniCharProvider
 _wkCreateCustomCFReadStream
 _wkCreatePrivateStorageSession
+_wkCTRunGetInitialAdvance
 _wkDeleteAllHTTPCookies
 _wkDeleteHTTPCookie
 _wkGetCFURLResponseHTTPResponse
index e4019f0..f89f4a9 100644 (file)
@@ -477,8 +477,9 @@ void Font::drawGlyphBuffer(GraphicsContext* context, const TextRun& run, const G
     // Draw each contiguous run of glyphs that use the same font data.
     const SimpleFontData* fontData = glyphBuffer.fontDataAt(0);
     FloatSize offset = glyphBuffer.offsetAt(0);
-    FloatPoint startPoint(point);
-    float nextX = startPoint.x() + glyphBuffer.advanceAt(0);
+    FloatPoint startPoint(point.x(), point.y() - glyphBuffer.initialAdvance().height());
+    float nextX = startPoint.x() + glyphBuffer.advanceAt(0).width();
+    float nextY = startPoint.y() + glyphBuffer.advanceAt(0).height();
     int lastFrom = 0;
     int nextGlyph = 1;
 #if ENABLE(SVG_FONTS)
@@ -500,8 +501,10 @@ void Font::drawGlyphBuffer(GraphicsContext* context, const TextRun& run, const G
             fontData = nextFontData;
             offset = nextOffset;
             startPoint.setX(nextX);
+            startPoint.setY(nextY);
         }
-        nextX += glyphBuffer.advanceAt(nextGlyph);
+        nextX += glyphBuffer.advanceAt(nextGlyph).width();
+        nextY += glyphBuffer.advanceAt(nextGlyph).height();
         nextGlyph++;
     }
 
@@ -550,7 +553,7 @@ void Font::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const
     GlyphBuffer markBuffer;
     for (int i = 0; i + 1 < glyphBuffer.size(); ++i) {
         float middleOfNextGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, i + 1);
-        float advance = glyphBuffer.advanceAt(i) - middleOfLastGlyph + middleOfNextGlyph;
+        float advance = glyphBuffer.advanceAt(i).width() - middleOfLastGlyph + middleOfNextGlyph;
         markBuffer.add(glyphBuffer.glyphAt(i) ? markGlyph : spaceGlyph, markFontData, advance);
         middleOfLastGlyph = middleOfNextGlyph;
     }
index 882f2a0..81f3b4c 100644 (file)
@@ -67,6 +67,7 @@ typedef Glyph GlyphBufferGlyph;
 #if USE(CG) || (OS(DARWIN) && PLATFORM(WX))
 struct GlyphBufferAdvance : CGSize {
 public:
+    GlyphBufferAdvance() : CGSize(CGSizeZero) { }
     GlyphBufferAdvance(CGSize size) : CGSize(size)
     {
     }
@@ -75,25 +76,10 @@ public:
     CGFloat width() const { return this->CGSize::width; }
     CGFloat height() const { return this->CGSize::height; }
 };
-#elif OS(WINCE)
-// There is no cross-platform code that uses the height of GlyphBufferAdvance,
-// so we can save memory space on embedded devices by storing only the width
-struct GlyphBufferAdvance {
-public:
-    GlyphBufferAdvance(float width)
-        : advance(width)
-    {
-    }
-
-    void setWidth(float width) { advance = width; }
-    float width() const { return advance; }
-
-private:
-    float advance;
-};
 #elif PLATFORM(QT)
 struct GlyphBufferAdvance : public QPointF {
 public:
+    GlyphBufferAdvance() : QPointF() { }
     GlyphBufferAdvance(const QPointF& advance)
         : QPointF(advance)
     {
@@ -128,6 +114,9 @@ public:
     const GlyphBufferAdvance* advances(int from) const { return m_advances.data() + from; }
 
     const SimpleFontData* fontDataAt(int index) const { return m_fontData[index]; }
+
+    void setInitialAdvance(GlyphBufferAdvance initialAdvance) { m_initialAdvance = initialAdvance; }
+    const GlyphBufferAdvance& initialAdvance() const { return m_initialAdvance; }
     
     Glyph glyphAt(int index) const
     {
@@ -138,9 +127,9 @@ public:
 #endif
     }
 
-    float advanceAt(int index) const
+    GlyphBufferAdvance advanceAt(int index) const
     {
-        return m_advances[index].width();
+        return m_advances[index];
     }
 
     FloatSize offsetAt(int index) const
@@ -168,8 +157,6 @@ public:
 #if USE(CG) || (OS(DARWIN) && PLATFORM(WX))
         CGSize advance = { width, 0 };
         m_advances.append(advance);
-#elif OS(WINCE)
-        m_advances.append(width);
 #elif PLATFORM(QT)
         m_advances.append(QPointF(width, 0));
 #else
@@ -240,6 +227,7 @@ private:
     Vector<const SimpleFontData*, 2048> m_fontData;
     Vector<GlyphBufferGlyph, 2048> m_glyphs;
     Vector<GlyphBufferAdvance, 2048> m_advances;
+    GlyphBufferAdvance m_initialAdvance;
 #if PLATFORM(WIN)
     Vector<FloatSize, 2048> m_offsets;
 #endif
index f5beb91..b66e2d1 100644 (file)
@@ -254,7 +254,7 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph
 
         if (shouldApplyFontTransforms() && glyphBuffer && Font::treatAsSpace(character))
             charactersTreatedAsSpace.append(make_pair(glyphBuffer->size(),
-                OriginalAdvancesForCharacterTreatedAsSpace(character == ' ', glyphBuffer->size() ? glyphBuffer->advanceAt(glyphBuffer->size() - 1) : 0, width)));
+                OriginalAdvancesForCharacterTreatedAsSpace(character == ' ', glyphBuffer->size() ? glyphBuffer->advanceAt(glyphBuffer->size() - 1).width() : 0, width)));
 
         if (m_accountForGlyphBounds) {
             bounds = fontData->boundsForGlyph(glyph);
@@ -343,7 +343,7 @@ bool WidthIterator::advanceOneCharacter(float& width, GlyphBuffer& glyphBuffer)
     advance(m_currentCharacter + 1, &glyphBuffer);
     float w = 0;
     for (int i = oldSize; i < glyphBuffer.size(); ++i)
-        w += glyphBuffer.advanceAt(i);
+        w += glyphBuffer.advanceAt(i).width();
     width = w;
     return glyphBuffer.size() > oldSize;
 }
index 9123ccc..a09e555 100644 (file)
@@ -105,7 +105,7 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons
     for (int i = 0; i < numGlyphs; i++) {
         glyphs[i].x = offset;
         glyphs[i].y = point.y();
-        offset += glyphBuffer.advanceAt(from + i);
+        offset += glyphBuffer.advanceAt(from + i).width();
     }
 
     PlatformContextCairo* platformContext = context->platformContext();
index 2814e1f..01beded 100644 (file)
@@ -500,6 +500,9 @@ void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer, G
         if (fallbackFonts && complexTextRun.fontData() != m_font.primaryFont())
             fallbackFonts->add(complexTextRun.fontData());
 
+        if (glyphBuffer && glyphBuffer->isEmpty())
+            glyphBuffer->setInitialAdvance(complexTextRun.initialAdvance());
+
         while (m_glyphInCurrentRun < glyphCount) {
             unsigned glyphStartOffset = complexTextRun.indexAt(g);
             unsigned glyphEndOffset;
@@ -565,6 +568,15 @@ void ComplexTextController::adjustGlyphsAndAdvances()
         unsigned glyphCount = complexTextRun.glyphCount();
         const SimpleFontData* fontData = complexTextRun.fontData();
 
+        // Represent the initial advance for a text run by adjusting the advance
+        // of the last glyph of the previous text run in the glyph buffer.
+        if (r && m_adjustedAdvances.size()) {
+            CGSize previousAdvance = m_adjustedAdvances.last();
+            previousAdvance.width += complexTextRun.initialAdvance().width;
+            previousAdvance.height -= complexTextRun.initialAdvance().height;
+            m_adjustedAdvances[m_adjustedAdvances.size() - 1] = previousAdvance;
+        }
+
         if (!complexTextRun.isLTR())
             m_isLTROnly = false;
 
index e58f66f..3c69f89 100644 (file)
@@ -94,6 +94,7 @@ private:
         CFIndex indexEnd() const { return m_indexEnd; }
         CFIndex endOffsetAt(size_t i) const { ASSERT(!m_isMonotonic); return m_glyphEndOffsets[i]; }
         const CGGlyph* glyphs() const { return m_glyphs; }
+        CGSize initialAdvance() const { return m_initialAdvance; }
         const CGSize* advances() const { return m_advances; }
         bool isLTR() const { return m_isLTR; }
         bool isMonotonic() const { return m_isMonotonic; }
@@ -115,6 +116,7 @@ private:
         Vector<CFIndex, 64> m_glyphEndOffsets;
         Vector<CGGlyph, 64> m_glyphsVector;
         const CGGlyph* m_glyphs;
+        CGSize m_initialAdvance;
         Vector<CGSize, 64> m_advancesVector;
         const CGSize* m_advances;
         bool m_isLTR;
index 6b731ef..47d0f81 100644 (file)
@@ -94,6 +94,7 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const Simp
     , m_stringLength(stringLength)
     , m_indexBegin(runRange.location)
     , m_indexEnd(runRange.location + runRange.length)
+    , m_initialAdvance(wkCTRunGetInitialAdvance(ctRun))    
     , m_isLTR(!(CTRunGetStatus(ctRun) & kCTRunStatusRightToLeft))
     , m_isMonotonic(true)
 {
@@ -129,6 +130,7 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(const SimpleFontData* font
     , m_stringLength(stringLength)
     , m_indexBegin(0)
     , m_indexEnd(stringLength)
+    , m_initialAdvance(CGSizeZero)
     , m_isLTR(ltr)
     , m_isMonotonic(true)
 {
index b46b78b..a2f22d8 100644 (file)
@@ -296,7 +296,7 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* fontData,
 
     for (int i = 0; i < numGlyphs; ++i) {
         Glyph glyph = glyphBuffer.glyphAt(from + i);
-        float advance = glyphBuffer.advanceAt(from + i);
+        float advance = glyphBuffer.advanceAt(from + i).width();
         if (!glyph)
             continue;
         glyphIndexes.append(glyph);
index cab8c94..b23b0ac 100644 (file)
@@ -50,6 +50,7 @@ typedef struct _CFURLResponse *CFURLResponseRef;
 typedef const struct _CFURLRequest *CFURLRequestRef;
 typedef const struct __CTFont * CTFontRef;
 typedef const struct __CTLine * CTLineRef;
+typedef const struct __CTRun * CTRunRef;
 typedef const struct __CTTypesetter * CTTypesetterRef;
 typedef const struct __AXUIElement *AXUIElementRef;
 typedef struct _NSRange NSRange;
@@ -253,6 +254,8 @@ extern bool (*wkCTFontTransformGlyphs)(CTFontRef font, CGGlyph glyphs[], CGSize
 
 extern CTTypesetterRef (*wkCreateCTTypesetterWithUniCharProviderAndOptions)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*, CFDictionaryRef options);
 
+extern CGSize (*wkCTRunGetInitialAdvance)(CTRunRef);
+
 #if PLATFORM(MAC) && USE(CA)
 extern CGContextRef (*wkIOSurfaceContextCreate)(IOSurfaceRef surface, unsigned width, unsigned height, CGColorSpaceRef colorSpace);
 extern CGImageRef (*wkIOSurfaceContextCreateImage)(CGContextRef context);
index 081798e..8698db2 100644 (file)
@@ -143,6 +143,8 @@ CTLineRef (*wkCreateCTLineWithUniCharProvider)(const UniChar* (*provide)(CFIndex
 bool (*wkCTFontTransformGlyphs)(CTFontRef font, CGGlyph glyphs[], CGSize advances[], CFIndex count, wkCTFontTransformOptions options);
 #endif
 
+CGSize (*wkCTRunGetInitialAdvance)(CTRunRef);
+
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
 CTTypesetterRef (*wkCreateCTTypesetterWithUniCharProviderAndOptions)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*, CFDictionaryRef options);
 
index 46ddc6e..ccf9047 100644 (file)
@@ -228,7 +228,7 @@ void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData*
 #endif
         glyphs[i].x = offset;
         glyphs[i].y = point.y();
-        offset += glyphBuffer.advanceAt(from + i);
+        offset += glyphBuffer.advanceAt(from + i).width();
     }
 
     cairo_set_source_rgba(cr, color.Red()/255.0, color.Green()/255.0, color.Blue()/255.0, color.Alpha()/255.0);
@@ -252,7 +252,7 @@ void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData*
     wxString text = wxEmptyString;
     for (unsigned i = 0; i < numGlyphs; i++) {
         text = text.Append((wxChar)glyphs[i]);
-        offset += glyphBuffer.advanceAt(from + i);
+        offset += glyphBuffer.advanceAt(from + i).width();
     }
     
     // the y point is actually the bottom point of the text, turn it into the top
index b41086b..21b3753 100644 (file)
@@ -126,7 +126,7 @@ void SVGTextRunRenderingContext::drawSVGGlyphs(GraphicsContext* context, const T
         if (!glyph)
             continue;
 
-        float advance = glyphBuffer.advanceAt(from + i);
+        float advance = glyphBuffer.advanceAt(from + i).width();
         SVGGlyph svgGlyph = fontElement->svgGlyphForGlyph(glyph);
         ASSERT(!svgGlyph.isPartOfLigature);
         ASSERT(svgGlyph.tableEntry == glyph);
index 8f19c30..a22f51e 100644 (file)
@@ -1,3 +1,15 @@
+2013-04-23  Antoine Quint  <graouts@apple.com>
+
+        Initial advance of text runs should be taken into account
+        https://bugs.webkit.org/show_bug.cgi?id=114949
+
+        Reviewed by Darin Adler.
+
+        Adding support for new method CTRunGetInitialAdvance in WebKitSystemInterface.
+
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2013-04-22  Benjamin Poulain  <benjamin@webkit.org>
 
         Remove the memory instrumentation code
index 2ff5131..7cdc987 100644 (file)
@@ -137,6 +137,7 @@ void InitWebCoreSystemInterface(void)
     INIT(IOSurfaceContextCreate);
     INIT(IOSurfaceContextCreateImage);
     INIT(CreateCTTypesetterWithUniCharProviderAndOptions);
+    INIT(CTRunGetInitialAdvance);
     INIT(RecommendedScrollerStyle);
     INIT(ExecutableWasLinkedOnOrBeforeSnowLeopard);
     INIT(SetCrashReportApplicationSpecificInformation);
index f4561e3..95816f2 100644 (file)
@@ -1,3 +1,15 @@
+2013-04-23  Antoine Quint  <graouts@apple.com>
+
+        Initial advance of text runs should be taken into account
+        https://bugs.webkit.org/show_bug.cgi?id=114949
+
+        Reviewed by Darin Adler.
+
+        Adding support for new method CTRunGetInitialAdvance in WebKitSystemInterface.
+
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2013-04-23  Noam Rosenthal  <noam@webkit.org>
 
         [Coordinated Graphics] Remove the lockAnimations code path
index 7c51acd..f04491e 100644 (file)
@@ -125,6 +125,7 @@ void InitWebCoreSystemInterface(void)
         INIT(IOSurfaceContextCreate);
         INIT(IOSurfaceContextCreateImage);
         INIT(CreateCTTypesetterWithUniCharProviderAndOptions);
+        INIT(CTRunGetInitialAdvance);
         INIT(RecommendedScrollerStyle);
         INIT(ExecutableWasLinkedOnOrBeforeSnowLeopard);
         INIT(CopyDefaultSearchProviderDisplayName);
index 7d72d2b..8902f34 100644 (file)
@@ -1,3 +1,14 @@
+2013-04-23  Antoine Quint  <graouts@apple.com>
+
+        Initial advance of text runs should be taken into account
+        https://bugs.webkit.org/show_bug.cgi?id=114949
+
+        Reviewed by Darin Adler.
+
+        * WebKitSystemInterface.h:
+        * libWebKitSystemInterfaceLion.a:
+        * libWebKitSystemInterfaceMountainLion.a:
+
 2013-04-12  Jeffrey Pfau  <jpfau@apple.com>
 
         Query directly for cache partition names
index 7d9b9f5..d5dec34 100644 (file)
@@ -163,6 +163,8 @@ bool WKCTFontTransformGlyphs(CTFontRef font, CGGlyph glyphs[], CGSize advances[]
 
 CTTypesetterRef WKCreateCTTypesetterWithUniCharProviderAndOptions(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*, CFDictionaryRef options);
 
+CGSize WKCTRunGetInitialAdvance(CTRunRef);
+
 CGContextRef WKIOSurfaceContextCreate(IOSurfaceRef, unsigned width, unsigned height, CGColorSpaceRef);
 CGImageRef WKIOSurfaceContextCreateImage(CGContextRef context);
 
index a7c61c3..6dfd50a 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLion.a and b/WebKitLibraries/libWebKitSystemInterfaceLion.a differ
index 7f3e753..7e4e2f2 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceMountainLion.a and b/WebKitLibraries/libWebKitSystemInterfaceMountainLion.a differ