<rdar://problem/8446709> Allow inter-ideograph justification for CJK
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jan 2011 01:39:27 +0000 (01:39 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jan 2011 01:39:27 +0000 (01:39 +0000)
commit3176a67c81fe8dcafa5ac9faf91133595701cef7
tree2280ba7db1cd98760f93a5aac5ce093f9d65a7bb
parent43a3e80072cc7d316df90224986d9507a97b5069
<rdar://problem/8446709> Allow inter-ideograph justification for CJK
https://bugs.webkit.org/show_bug.cgi?id=53184

Reviewed by Dave Hyatt.

Source/WebCore:

Tests: fast/text/justify-ideograph-complex.html
       fast/text/justify-ideograph-simple.html
       fast/text/justify-ideograph-vertical.html

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawTextInternal): Corrected the type of the third parameter
passed to the TextRun constructor and added the trailingExpansionBehavior parameter.
* platform/graphics/Font.cpp:
(WebCore::Font::expansionOpportunityCount): Added. Returns the number of expansion opportunities
for text justification. On entry, isAfterExpansion says whether an expansion opportunity exists
before the first character. On return, isAfterExpansion says whether an expansion opportunity
exists after the last character.
* platform/graphics/Font.h:
* platform/graphics/GlyphBuffer.h:
(WebCore::GlyphBuffer::expandLastAdvance): Added.
* platform/graphics/TextRun.h:
(WebCore::TextRun::TextRun): Added a TrailingExpansionBehavior parameter to the constructors.
Renamed padding to expansion.
(WebCore::TextRun::expansion): Renamed padding() to this.
(WebCore::TextRun::allowsTrailingExpansion): Added this accessor.
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::WidthIterator): Initialize m_isAfterExpansion. Use Font::expansionOpportunityCount()
and adjust the count if it includes a trailing expansion opportunity but the run disallows trailing
expansion.
(WebCore::WidthIterator::advance): Apply expansion before and after CJK ideographs.
(WebCore::WidthIterator::advanceOneCharacter): Changed to not clear the GlyphBuffer so that advance()
can expand the last advance if it is followed by a CJK ideograph.
* platform/graphics/WidthIterator.h: Renamed m_padding to m_expansion and m_padPerSpace
to m_expansionPerOpportunity.
* platform/graphics/chromium/FontChromiumWin.cpp:
(WebCore::Font::canExpandAroundIdeographsInComplexText): Added.
* platform/graphics/chromium/FontLinux.cpp:
(WebCore::Font::canExpandAroundIdeographsInComplexText): Added.
* platform/graphics/efl/FontEfl.cpp:
(WebCore::Font::canExpandAroundIdeographsInComplexText): Added.
* platform/graphics/gtk/FontGtk.cpp:
(WebCore::Font::canExpandAroundIdeographsInComplexText): Added.
* platform/graphics/haiku/FontHaiku.cpp:
(WebCore::Font::canExpandAroundIdeographsInComplexText): Added.
* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::ComplexTextController): Initialize m_isAfterExpansion. Use
Font::expansionOpportunityCount() and adjust the count if it includes a trailing expansion
opportunity but the run disallows trailing expansion.
(WebCore::ComplexTextController::adjustGlyphsAndAdvances): Moved the definition and initialization
of hasExtraSpacing outside the loop. Apply expansion before and after CJK ideographs.
* platform/graphics/mac/ComplexTextController.h: Renamed m_padding to m_expansion and m_padPerSpace
to m_expansionPerOpportunity.
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::canExpandAroundIdeographsInComplexText): Added.
* platform/graphics/qt/FontQt.cpp:
(WebCore::Font::canExpandAroundIdeographsInComplexText): Added.
* platform/graphics/win/FontWin.cpp:
(WebCore::Font::canExpandAroundIdeographsInComplexText): Added.
* platform/graphics/win/UniscribeController.cpp:
(WebCore::UniscribeController::UniscribeController): Updated for rename.
* platform/graphics/wince/FontWinCE.cpp:
(WebCore::Font::canExpandAroundIdeographsInComplexText): Added.
* platform/graphics/wx/FontWx.cpp:
(WebCore::Font::canExpandAroundIdeographsInComplexText): Added.
* rendering/EllipsisBox.cpp:
(WebCore::EllipsisBox::paint): Pass a TrailingExpansionBehavior to the TextRun constructor.
(WebCore::EllipsisBox::selectionRect): Ditto.
(WebCore::EllipsisBox::paintSelection): Ditto.
* rendering/InlineBox.h:
(WebCore::InlineBox::InlineBox): Renamed m_toAdd to m_expansion.
(WebCore::InlineBox::expansion): Renamed toAdd() to this.
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::selectionRect): Pass a TrailingExpansionBehavior to the TextRun constructor.
(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::setExpansion): Renamed setSpaceAdd() to this.
(WebCore::InlineTextBox::trailingExpansionBehavior): Added. Trailing expansion is allowed if this
is not the last leaf box on the line.
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::computeInlineDirectionPositionsForLine): Keep expansion opportunity counts
in a vector instead of computing them twice. Discard the trailing expansion opportunity in the
last text box.
* rendering/RenderFileUploadControl.cpp:
(WebCore::RenderFileUploadControl::paintObject): Pass a TrailingExpansionBehavior to the TextRun constructor.
(WebCore::RenderFileUploadControl::computePreferredLogicalWidths): Ditto.
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::updateFromElement): Ditto.
(WebCore::RenderListBox::paintItemForeground): Ditto. Also corrected the type of the second parameter.
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::getAvgCharWidth): Ditto.
(WebCore::RenderTextControl::paintPlaceholder): Ditto.
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::constructTextRun): Ditto.

Source/WebKit/chromium:

* src/WebTextRun.cpp:
(WebKit::WebTextRun::operator WebCore::TextRun): Added a TrailingExpansionBehavior parameter to the
RenderText constructor.

Source/WebKit2:

* WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp:
(WebKit::WebPopupMenu::setUpPlatformData): Added a TrailingExpansionBehavior parameter to the
RenderText constructor.

LayoutTests:

* fast/text/justify-ideograph-complex.html: Added.
* fast/text/justify-ideograph-simple.html: Added.
* fast/text/justify-ideograph-vertical.html: Added.
* platform/mac/fast/text/justify-ideograph-complex-expected.checksum: Added.
* platform/mac/fast/text/justify-ideograph-complex-expected.png: Added.
* platform/mac/fast/text/justify-ideograph-complex-expected.txt: Added.
* platform/mac/fast/text/justify-ideograph-simple-expected.checksum: Added.
* platform/mac/fast/text/justify-ideograph-simple-expected.png: Added.
* platform/mac/fast/text/justify-ideograph-simple-expected.txt: Added.
* platform/mac/fast/text/justify-ideograph-vertical-expected.checksum: Added.
* platform/mac/fast/text/justify-ideograph-vertical-expected.png: Added.
* platform/mac/fast/text/justify-ideograph-vertical-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@76743 268f45cc-cd09-0410-ab3c-d52691b4dbfc
50 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/justify-ideograph-complex.html [new file with mode: 0644]
LayoutTests/fast/text/justify-ideograph-simple.html [new file with mode: 0644]
LayoutTests/fast/text/justify-ideograph-vertical.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/justify-ideograph-complex-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/justify-ideograph-complex-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/justify-ideograph-complex-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/justify-ideograph-simple-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/justify-ideograph-simple-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/justify-ideograph-simple-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/justify-ideograph-vertical-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/justify-ideograph-vertical-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/justify-ideograph-vertical-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/platform/chromium/PopupMenuChromium.cpp
Source/WebCore/platform/graphics/Font.cpp
Source/WebCore/platform/graphics/Font.h
Source/WebCore/platform/graphics/GlyphBuffer.h
Source/WebCore/platform/graphics/TextRun.h
Source/WebCore/platform/graphics/WidthIterator.cpp
Source/WebCore/platform/graphics/WidthIterator.h
Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp
Source/WebCore/platform/graphics/chromium/FontLinux.cpp
Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp
Source/WebCore/platform/graphics/efl/FontEfl.cpp
Source/WebCore/platform/graphics/gtk/FontGtk.cpp
Source/WebCore/platform/graphics/haiku/FontHaiku.cpp
Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
Source/WebCore/platform/graphics/mac/ComplexTextController.h
Source/WebCore/platform/graphics/mac/FontMac.mm
Source/WebCore/platform/graphics/qt/FontQt.cpp
Source/WebCore/platform/graphics/win/FontWin.cpp
Source/WebCore/platform/graphics/win/UniscribeController.cpp
Source/WebCore/platform/graphics/wince/FontWinCE.cpp
Source/WebCore/platform/graphics/wx/FontWx.cpp
Source/WebCore/platform/win/PopupMenuWin.cpp
Source/WebCore/rendering/EllipsisBox.cpp
Source/WebCore/rendering/InlineBox.h
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/InlineTextBox.h
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/RenderFileUploadControl.cpp
Source/WebCore/rendering/RenderListBox.cpp
Source/WebCore/rendering/RenderTextControl.cpp
Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebTextRun.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp