<rdar://problem/9134330> Missing expansion before ideograph at the beginning or end...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 26 Mar 2011 00:46:26 +0000 (00:46 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 26 Mar 2011 00:46:26 +0000 (00:46 +0000)
commit3725da3593a1a23abef5006bbc7d6c47993d9868
treed9ed7779750b7aaacedb4b5c07129e01a700c2a3
parentf28ab68079a04d8cc22d4643012fc36cf589ef83
<rdar://problem/9134330> Missing expansion before ideograph at the beginning or end of a text run
https://bugs.webkit.org/show_bug.cgi?id=57106

Reviewed by Darin Adler.

Source/WebCore:

Test: fast/text/justify-ideograph-leading-expansion.html

* platform/graphics/TextRun.h:
Replaced TrailingExpansionBehavior enum with ExpansionBehavior flags.
(WebCore::TextRun::TextRun): Constructors now take an expansionBehavior parameter.
(WebCore::TextRun::allowsLeadingExpansion): Added this accessor.
(WebCore::TextRun::allowsTrailingExpansion): Changed to use the m_expansionBehavior member.
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::WidthIterator): Initialize m_isAfterExpansion from the TextRun, allowing
leading expansion when appropriate.
(WebCore::WidthIterator::advance): Moved the last-glyph-in-run check to only apply to expansion
after the glyph, not expansion before the glyph, since that is not trailing expansion. Added code
to handle expansion before the first glyph.
* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::ComplexTextController): Initialize m_afterExpansion from the
TextRun, allowing leading expansion when appropriate. Set m_runWidthSoFar to the leading expansion.
(WebCore::ComplexTextController::offsetForPosition): Account for leading expansion.
(WebCore::ComplexTextController::adjustGlyphsAndAdvances): Similar to WidthIterator::advance()
* platform/graphics/mac/ComplexTextController.h: Added m_leadingExpansion member variable.
* rendering/InlineBox.h:
(WebCore::InlineBox::InlineBox): Renamed m_hasSelectedChildren to m_hasSelectedChildrenOrCanHaveLeadingExpansion
to reflect the use of this bit by InlineTextBox.
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::selectionRect): Replaced calls to trailingExpansionBehavior() with expansionBehavior().
(WebCore::InlineTextBox::paint): Ditto.
(WebCore::InlineTextBox::paintSelection): Ditto.
(WebCore::InlineTextBox::paintCompositionBackground): Ditto.
(WebCore::InlineTextBox::paintSpellingOrGrammarMarker): Ditto.
(WebCore::InlineTextBox::paintTextMatchMarker): Ditto.
(WebCore::InlineTextBox::computeRectForReplacementMarker): Ditto.
(WebCore::InlineTextBox::offsetForPosition): Ditto.
(WebCore::InlineTextBox::positionForOffset): Ditto.
* rendering/InlineTextBox.h:
(WebCore::InlineTextBox::canHaveLeadingExpansion): Added this accessor.
(WebCore::InlineTextBox::setCanHaveLeadingExpansion): Ditto.
(WebCore::InlineTextBox::expansionBehavior): Replaced trailingExpansionBehavior() with this function,
which also considers canHaveLeadingExpansion().
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::computeInlineDirectionPositionsForLine): Call setCanHaveLeadingExpansion() on
text boxes that can have leading expansion. Avoid negative expansion.
* rendering/RootInlineBox.cpp:
* rendering/RootInlineBox.h:
(WebCore::RootInlineBox::hasSelectedChildren): Updated for renaming of the flag.
(WebCore::RootInlineBox::setHasSelectedChildren): Ditto.

LayoutTests:

* fast/text/justify-ideograph-leading-expansion.html: Added.
* platform/mac/fast/text/justify-ideograph-leading-expansion-expected.checksum: Added.
* platform/mac/fast/text/justify-ideograph-leading-expansion-expected.png: Added.
* platform/mac/fast/text/justify-ideograph-leading-expansion-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/justify-ideograph-leading-expansion.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/justify-ideograph-leading-expansion-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/justify-ideograph-leading-expansion-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/justify-ideograph-leading-expansion-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/TextRun.h
Source/WebCore/platform/graphics/WidthIterator.cpp
Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
Source/WebCore/platform/graphics/mac/ComplexTextController.h
Source/WebCore/rendering/InlineBox.h
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/InlineTextBox.h
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/RootInlineBox.cpp
Source/WebCore/rendering/RootInlineBox.h