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)
commit16a6c40d91d476118969439bfbff4a0eac0b0887
tree155309118ab4e0ff4e1afbdf36d16a3b19655f07
parent4e21cd87cb6dcd3990836b122558ba81e608c8dc
Initial advance of text runs should be taken into account
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