Add an option to enable legacy rounding hacks
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Jun 2011 06:49:12 +0000 (06:49 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Jun 2011 06:49:12 +0000 (06:49 +0000)
commita4b3444871537dd289f768d8fb3f77c7da2ddcc6
treedbce91b8352831994755527a0b84ebb5d71edeaa
parent88e0aebfa18c0d736a1045e512aee8def1be33c0
Add an option to enable legacy rounding hacks
https://bugs.webkit.org/show_bug.cgi?id=63363

Reviewed by Anders Carlsson.

Source/WebCore:

Restored most of text rounding hacks which were removed in r78846, with a global flag to control
whether rounding hacks are allowed, which defaults to false.

Test: platform/mac/fast/text/rounding-hacks.html

* CMakeLists.txt: Added TextRun.cpp.
* GNUmakefile.list.am: Ditto.
* WebCore.exp.in: Export new TextRun function and global and updated StringTruncator functions.
* WebCore.gypi: Added TextRun.cpp.
* WebCore.pro: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawTextInternal): Disable rounding hacks in the one place
they used to be disabled.
* platform/graphics/Font.cpp: Re-added the rounding character table.
* platform/graphics/Font.h:
(WebCore::Font::isRoundingHackCharacter): Re-added.
* platform/graphics/FontFastPath.cpp:
(WebCore::Font::getGlyphsAndAdvancesForSimpleText): Account for final rounding width.
* platform/graphics/SimpleFontData.cpp:
(WebCore::SimpleFontData::platformGlyphInit): Initialize m_adjustedSpaceWidth.
* platform/graphics/SimpleFontData.h:
(WebCore::SimpleFontData::adjustedSpaceWidth): Re-added.
* platform/graphics/StringTruncator.cpp:
(WebCore::stringWidth): Re-added disableRoundingHacks parameter.
(WebCore::truncateString): Ditto.
(WebCore::StringTruncator::centerTruncate): Added EnableRoundingHacksOrNot parameter.
(WebCore::StringTruncator::rightTruncate): Ditto.
(WebCore::StringTruncator::width): Ditto.
* platform/graphics/StringTruncator.h:
* platform/graphics/TextRun.cpp: Added.
(WebCore::TextRun::setAllowsRoundingHacks): Added.
* platform/graphics/TextRun.h:
(WebCore::TextRun::TextRun): Added RoundingHacks parameter to the constructors, used to initialize
the m_applyRunRounding and m_applyWordRounding member variables, subject to rounding hacks being allowed.
(WebCore::TextRun::applyRunRounding): Re-added this accessor.
(WebCore::TextRun::applyWordRounding): Ditto.
(WebCore::TextRun::disableRoundingHacks): Re-added.
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::WidthIterator): Re-added code to apply rounding hacks.
(WebCore::WidthIterator::advance): Ditto.
* platform/graphics/WidthIterator.h:
* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ceilCGFloat): Re-added.
(WebCore::ComplexTextController::ComplexTextController): Re-added code to apply rounding hacks.
(WebCore::ComplexTextController::advance): Ditto.
(WebCore::ComplexTextController::adjustGlyphsAndAdvances): Ditto.
* platform/graphics/mac/ComplexTextController.h:
(WebCore::ComplexTextController::finalRoundingWidth): Re-added this accessor.
* platform/graphics/mac/FontComplexTextMac.cpp:
(WebCore::Font::getGlyphsAndAdvancesForComplexText): Accound for final rounding width.
* platform/graphics/qt/SimpleFontDataQt.cpp:
(WebCore::SimpleFontData::platformGlyphInit): Initialize m_adjustedSpaceWidth.
* platform/gtk/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::fileListNameForWidth): Enabled rounding hacks in the string truncator.
* platform/mac/DragImageMac.mm:
(WebCore::widthWithFont): Disable rounding hacks when measuring.
(WebCore::drawAtPoint): Disable rounding hacks when drawing.
* platform/win/DragImageWin.cpp:
(WebCore::createDragImageForLink): Enable rounding hacks in the string truncator.
* platform/win/WebCoreTextRenderer.cpp:
(WebCore::WebCoreTextFloatWidth): Ditto.
* rendering/RenderFileUploadControl.cpp:
(WebCore::RenderFileUploadControl::paintObject): Disable rounding hacks.
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::updateFromElement): Ditto.
(WebCore::RenderListBox::paintItemForeground): Ditto.
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::getAvgCharWidth): Ditto.
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::fileListNameForWidth): Enabled rounding hacks in the string truncator.
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::fileListNameForWidth): Ditto.
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::constructTextRun): Disabled rounding hacks.
* rendering/svg/SVGTextMetrics.cpp:
(WebCore::constructTextRun): Ditto.

Source/WebKit/mac:

* Misc/WebKitNSStringExtras.mm:
(-[NSString _web_drawAtPoint:font:textColor:allowingFontSmoothing:]):
Disabled rounding hacks.
(-[NSString _web_widthWithFont:]): Ditto.
* WebView/WebView.mm:
(+[WebView _setAllowsRoundingHacks:]): Added this setter.
* WebView/WebViewPrivate.h:

Source/WebKit/win:

* WebKitGraphics.cpp:
(CenterTruncateStringToWidth): Enabled rounding hacks in the string truncator.
(RightTruncateStringToWidth): Ditto.

Tools:

Added layoutTestController.allowRoundingHacks() and implemented it
on OS X.

* DumpRenderTree/LayoutTestController.cpp:
(allowRoundingHacksCallback):
(LayoutTestController::staticFunctions):
* DumpRenderTree/LayoutTestController.h:
* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::allowRoundingHacks):
* DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
(LayoutTestController::allowRoundingHacks):
* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebViewToConsistentStateBeforeTesting):
* DumpRenderTree/mac/LayoutTestControllerMac.mm:
(LayoutTestController::allowRoundingHacks):
* DumpRenderTree/qt/LayoutTestControllerQt.cpp:
(LayoutTestController::allowRoundingHacks):
* DumpRenderTree/win/LayoutTestControllerWin.cpp:
(LayoutTestController::allowRoundingHacks):
* DumpRenderTree/wx/LayoutTestControllerWx.cpp:
(LayoutTestController::allowRoundingHacks):

LayoutTests:

* platform/mac/fast/text/rounding-hacks.html: Added.
* platform/mac/platform/mac/fast/text/rounding-hacks-expected.png: Added.
* platform/mac/platform/mac/fast/text/rounding-hacks-expected.txt: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@89733 268f45cc-cd09-0410-ab3c-d52691b4dbfc
55 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/fast/text/rounding-hacks.html [new file with mode: 0644]
LayoutTests/platform/mac/platform/mac/fast/text/rounding-hacks-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/platform/mac/fast/text/rounding-hacks-expected.txt [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/platform/graphics/Font.cpp
Source/WebCore/platform/graphics/Font.h
Source/WebCore/platform/graphics/FontFastPath.cpp
Source/WebCore/platform/graphics/SimpleFontData.cpp
Source/WebCore/platform/graphics/SimpleFontData.h
Source/WebCore/platform/graphics/StringTruncator.cpp
Source/WebCore/platform/graphics/StringTruncator.h
Source/WebCore/platform/graphics/TextRun.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/TextRun.h
Source/WebCore/platform/graphics/WidthIterator.cpp
Source/WebCore/platform/graphics/WidthIterator.h
Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
Source/WebCore/platform/graphics/mac/ComplexTextController.h
Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp
Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
Source/WebCore/platform/gtk/RenderThemeGtk.cpp
Source/WebCore/platform/mac/DragImageMac.mm
Source/WebCore/platform/win/DragImageWin.cpp
Source/WebCore/platform/win/WebCoreTextRenderer.cpp
Source/WebCore/rendering/RenderFileUploadControl.cpp
Source/WebCore/rendering/RenderListBox.cpp
Source/WebCore/rendering/RenderTextControl.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
Source/WebCore/rendering/svg/SVGTextMetrics.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Misc/WebKitNSStringExtras.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/mac/WebView/WebViewPrivate.h
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebKitGraphics.cpp
Tools/ChangeLog
Tools/DumpRenderTree/LayoutTestController.cpp
Tools/DumpRenderTree/LayoutTestController.h
Tools/DumpRenderTree/chromium/LayoutTestController.cpp
Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm
Tools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp
Tools/DumpRenderTree/wx/LayoutTestControllerWx.cpp