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)
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

index 7154817..c6a5245 100644 (file)
@@ -1,3 +1,14 @@
+2011-06-24  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        Add an option to enable legacy rounding hacks
+        https://bugs.webkit.org/show_bug.cgi?id=63363
+
+        * 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.
+
 2011-06-24  Nikolas Zimmermann  <nzimmermann@rim.com>
 
         Reviewed by Rob Buis.
diff --git a/LayoutTests/platform/mac/fast/text/rounding-hacks.html b/LayoutTests/platform/mac/fast/text/rounding-hacks.html
new file mode 100644 (file)
index 0000000..251aaf8
--- /dev/null
@@ -0,0 +1,21 @@
+<script>
+    if (window.layoutTestController)
+        layoutTestController.allowRoundingHacks();
+</script>
+<div style="font-family: 'lucida grande'; font-size: 22px;">
+    Lorem ipsum dolor sit amet,  consectetur adipiscing elit. Praesent
+    ullamcorper accumsan hendrerit. Phasellus  bibendum fringilla
+    sollicitudin. Donec blandit rutrum neque eget euismod.  Nullam nec
+    felis turpis, vitae tempor enim. Aenean venenatis blandit dui
+    vel ultrices. Donec porta nunc ut nibh  adipiscing id suscipit
+</div>
+<div style="font-family: 'lucida grande'; font-size: 18px;">
+    dolor facilisis. Vestibulum vitae enim vitae dolor  sollicitudin
+    imperdiet sit amet ac tortor. Quisque egestas adipiscing volutpat.
+    Proin eu nibh eros, quis luctus urna. Sed tincidunt iaculis  tempor.
+    Vestibulum dapibus lorem sit amet libero
+    pharetra at sodales nisi pulvinar. Morbi eu risus lectus,  id scelerisque
+    neque. Aenean eget mauris nulla. Nunc egestas elit nec lorem fermentum
+    mattis. Sed adipiscing metus nec diam congue at ornare sapien faucibus.
+    Vestibulum varius tempor quam sed malesuada.  Sed vitae quam nulla.
+</div>
diff --git a/LayoutTests/platform/mac/platform/mac/fast/text/rounding-hacks-expected.png b/LayoutTests/platform/mac/platform/mac/fast/text/rounding-hacks-expected.png
new file mode 100644 (file)
index 0000000..a4ed282
Binary files /dev/null and b/LayoutTests/platform/mac/platform/mac/fast/text/rounding-hacks-expected.png differ
diff --git a/LayoutTests/platform/mac/platform/mac/fast/text/rounding-hacks-expected.txt b/LayoutTests/platform/mac/platform/mac/fast/text/rounding-hacks-expected.txt
new file mode 100644 (file)
index 0000000..40a44d3
--- /dev/null
@@ -0,0 +1,38 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x130
+        RenderText {#text} at (0,0) size 777x130
+          text run at (0,0) width 313: "Lorem ipsum dolor sit amet, "
+          text run at (313,0) width 387: "consectetur adipiscing elit. Praesent"
+          text run at (0,26) width 468: "ullamcorper accumsan hendrerit. Phasellus "
+          text run at (468,26) width 199: "bibendum fringilla"
+          text run at (0,52) width 604: "sollicitudin. Donec blandit rutrum neque eget euismod. "
+          text run at (604,52) width 128: "Nullam nec "
+          text run at (732,52) width 45: "felis"
+          text run at (0,78) width 606: "turpis, vitae tempor enim. Aenean venenatis blandit dui "
+          text run at (606,78) width 124: "vel ultrices."
+          text run at (0,104) width 283: "Donec porta nunc ut nibh "
+          text run at (283,104) width 227: "adipiscing id suscipit"
+      RenderBlock {DIV} at (0,130) size 784x147
+        RenderText {#text} at (0,0) size 766x147
+          text run at (0,0) width 434: "dolor facilisis. Vestibulum vitae enim vitae dolor "
+          text run at (434,0) width 102: "sollicitudin "
+          text run at (536,0) width 189: "imperdiet sit amet ac"
+          text run at (0,21) width 394: "tortor. Quisque egestas adipiscing volutpat. "
+          text run at (394,21) width 360: "Proin eu nibh eros, quis luctus urna. Sed"
+          text run at (0,42) width 146: "tincidunt iaculis "
+          text run at (146,42) width 76: "tempor. "
+          text run at (222,42) width 373: "Vestibulum dapibus lorem sit amet libero "
+          text run at (595,42) width 169: "pharetra at sodales"
+          text run at (0,63) width 318: "nisi pulvinar. Morbi eu risus lectus, "
+          text run at (318,63) width 127: "id scelerisque "
+          text run at (445,63) width 297: "neque. Aenean eget mauris nulla."
+          text run at (0,84) width 355: "Nunc egestas elit nec lorem fermentum "
+          text run at (355,84) width 411: "mattis. Sed adipiscing metus nec diam congue"
+          text run at (0,105) width 235: "at ornare sapien faucibus. "
+          text run at (235,105) width 433: "Vestibulum varius tempor quam sed malesuada. "
+          text run at (668,105) width 80: "Sed vitae"
+          text run at (0,126) width 105: "quam nulla."
index 1e8205b..a45e29f 100644 (file)
@@ -1087,6 +1087,7 @@ SET(WebCore_SOURCES
     platform/graphics/SimpleFontData.cpp
     platform/graphics/StringTruncator.cpp
     platform/graphics/SurrogatePairAwareTextIterator.cpp
+    platform/graphics/TextRun.cpp
     platform/graphics/WidthIterator.cpp
 
     platform/graphics/filters/DistantLightSource.cpp
index e9501de..600ede0 100644 (file)
@@ -1,3 +1,89 @@
+2011-06-24  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        Add an option to enable legacy rounding hacks
+        https://bugs.webkit.org/show_bug.cgi?id=63363
+
+        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.
+
 2011-06-24  Nikolas Zimmermann  <nzimmermann@rim.com>
 
         Reviewed by Rob Buis.
index 377dacd..f1e05a4 100644 (file)
@@ -2561,6 +2561,7 @@ webcore_sources += \
        Source/WebCore/platform/graphics/SVGGlyph.cpp \
        Source/WebCore/platform/graphics/SVGGlyph.h \
        Source/WebCore/platform/graphics/TextRenderingMode.h \
+       Source/WebCore/platform/graphics/TextRun.cpp \
        Source/WebCore/platform/graphics/TextRun.h \
        Source/WebCore/platform/graphics/transforms/AffineTransform.cpp \
        Source/WebCore/platform/graphics/transforms/AffineTransform.h \
index f7008eb..91ed84d 100644 (file)
@@ -429,9 +429,9 @@ __ZN7WebCore15ResourceRequest21httpPipeliningEnabledEv
 __ZN7WebCore15ResourceRequest24setHTTPPipeliningEnabledEb
 __ZN7WebCore15ScrollAlignment17alignCenterAlwaysE
 __ZN7WebCore15ScrollAlignment19alignToEdgeIfNeededE
-__ZN7WebCore15StringTruncator13rightTruncateERKN3WTF6StringEfRKNS_4FontE
-__ZN7WebCore15StringTruncator14centerTruncateERKN3WTF6StringEfRKNS_4FontE
-__ZN7WebCore15StringTruncator5widthERKN3WTF6StringERKNS_4FontE
+__ZN7WebCore15StringTruncator13rightTruncateERKN3WTF6StringEfRKNS_4FontENS0_24EnableRoundingHacksOrNotE
+__ZN7WebCore15StringTruncator14centerTruncateERKN3WTF6StringEfRKNS_4FontENS0_24EnableRoundingHacksOrNotE
+__ZN7WebCore15StringTruncator5widthERKN3WTF6StringERKNS_4FontENS0_24EnableRoundingHacksOrNotE
 __ZN7WebCore15VisiblePositionC1ERKNS_8PositionENS_9EAffinityE
 __ZN7WebCore15defaultLanguageEv
 __ZN7WebCore15localizedStringEPKc
@@ -826,6 +826,8 @@ __ZN7WebCore7IntRect5uniteERKS0_
 __ZN7WebCore7IntRect9intersectERKS0_
 __ZN7WebCore7IntRectC1ERKNS_9FloatRectE
 __ZN7WebCore7IntSizeC1ERK7_NSSize
+__ZN7WebCore7TextRun21s_allowsRoundingHacksE
+__ZN7WebCore7TextRun22setAllowsRoundingHacksEb
 __ZN7WebCore7cookiesEPKNS_8DocumentERKNS_4KURLE
 __ZN7WebCore7nsColorERKNS_5ColorE
 __ZN7WebCore8Document11createRangeEv
index 0589b4b..f918730 100644 (file)
             'platform/graphics/StrokeStyleApplier.h',
             'platform/graphics/SurrogatePairAwareTextIterator.cpp',
             'platform/graphics/SurrogatePairAwareTextIterator.h',
+            'platform/graphics/TextRun.cpp',
             'platform/graphics/Tile.h',
             'platform/graphics/TiledBackingStore.cpp',
             'platform/graphics/TiledBackingStore.h',
index 1283f91..c2c7059 100644 (file)
@@ -1007,6 +1007,7 @@ SOURCES += \
     platform/graphics/SVGGlyph.cpp \
     platform/graphics/SimpleFontData.cpp \
     platform/graphics/StringTruncator.cpp \
+    platform/graphics/TextRun.cpp \
     platform/graphics/TiledBackingStore.cpp \
     platform/graphics/transforms/AffineTransform.cpp \
     platform/graphics/transforms/TransformationMatrix.cpp \
index f08bb42..f02b1ba 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\platform\graphics\TextRun.cpp"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\platform\graphics\TextRun.h"
                                        >
                                </File>
index d888dc6..5f45aa6 100644 (file)
                3744570F0DB05FA500AE0992 /* SVGGlyphMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 3744570E0DB05FA500AE0992 /* SVGGlyphMap.h */; };
                375CD232119D43C800A2A859 /* Hyphenation.h in Headers */ = {isa = PBXBuildFile; fileRef = 375CD231119D43C800A2A859 /* Hyphenation.h */; };
                375CD23B119D44EA00A2A859 /* HyphenationMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 375CD239119D44EA00A2A859 /* HyphenationMac.mm */; };
+               376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 376DCCE013B4F966002EBEFC /* TextRun.cpp */; };
                3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                377C4CDF1014E9F600B9AE42 /* PlaceholderDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 377C4CDD1014E9F600B9AE42 /* PlaceholderDocument.h */; };
                377C4CE01014E9F600B9AE42 /* PlaceholderDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 377C4CDE1014E9F600B9AE42 /* PlaceholderDocument.cpp */; };
                37569E0213AF172C00CDBA8E /* SharedBufferChunkReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedBufferChunkReader.h; sourceTree = "<group>"; };
                375CD231119D43C800A2A859 /* Hyphenation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Hyphenation.h; sourceTree = "<group>"; };
                375CD239119D44EA00A2A859 /* HyphenationMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HyphenationMac.mm; sourceTree = "<group>"; };
+               376DCCE013B4F966002EBEFC /* TextRun.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextRun.cpp; sourceTree = "<group>"; };
                3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverlapTestRequestClient.h; sourceTree = "<group>"; };
                377C4CDD1014E9F600B9AE42 /* PlaceholderDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaceholderDocument.h; sourceTree = "<group>"; };
                377C4CDE1014E9F600B9AE42 /* PlaceholderDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlaceholderDocument.cpp; sourceTree = "<group>"; };
                                087E0AF513606D0B00FA4BA8 /* SVGGlyph.h */,
                                930FC6891072B9280045293E /* TextRenderingMode.h */,
                                A824B4640E2EF2EA0081A7B7 /* TextRun.h */,
+                               376DCCE013B4F966002EBEFC /* TextRun.cpp */,
                                37C28A6710F659CC008C7813 /* TypesettingFeatures.h */,
                                E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */,
                                939B02EC0EA2DBC400C54570 /* WidthIterator.cpp */,
                                43A625F913B3304000AC94B8 /* SVGAnimatedColor.cpp in Sources */,
                                43A6266713B3D11000AC94B8 /* SVGAnimatedString.cpp in Sources */,
                                087558C513B4A57D00F49307 /* SurrogatePairAwareTextIterator.cpp in Sources */,
+                               376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index cc08d07..f423778 100644 (file)
@@ -1925,7 +1925,7 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
 
     unsigned length = text.length();
     const UChar* string = text.characters();
-    TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, direction, override);
+    TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, direction, override, TextRun::NoRounding);
 
     // Draw the item text at the correct point.
     FloatPoint location(x, y);
index 3b5595d..4b47cfd 100644 (file)
@@ -42,6 +42,17 @@ using namespace Unicode;
 
 namespace WebCore {
 
+const uint8_t Font::s_roundingHackCharacterTable[256] = {
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*\t*/, 1 /*\n*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    1 /*space*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*-*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*?*/,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    1 /*no-break space*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
 Font::CodePath Font::s_codePath = Auto;
 
 // ============================================================================================
index 8d83125..bf9a994 100644 (file)
@@ -194,6 +194,12 @@ public:
     static CodePath codePath();
     static CodePath s_codePath;
 
+    static const uint8_t s_roundingHackCharacterTable[256];
+    static bool isRoundingHackCharacter(UChar32 c)
+    {
+        return !(c & ~0xFF) && s_roundingHackCharacterTable[c];
+    }
+
     FontSelector* fontSelector() const;
     static bool treatAsSpace(UChar c) { return c == ' ' || c == '\t' || c == '\n' || c == noBreakSpace; }
     static bool treatAsZeroWidthSpace(UChar c) { return treatAsZeroWidthSpaceInComplexScript(c) || c == 0x200c || c == 0x200d; }
index efc330c..7cf265c 100644 (file)
@@ -337,8 +337,9 @@ float Font::getGlyphsAndAdvancesForSimpleText(const TextRun& run, int from, int
     float afterWidth = it.m_runWidthSoFar;
 
     if (run.rtl()) {
+        float finalRoundingWidth = it.m_finalRoundingWidth;
         it.advance(run.length());
-        initialAdvance = it.m_runWidthSoFar - afterWidth;
+        initialAdvance = finalRoundingWidth + it.m_runWidthSoFar - afterWidth;
     } else
         initialAdvance = beforeWidth;
 
index 28e9ae1..4537ab9 100644 (file)
@@ -98,6 +98,7 @@ void SimpleFontData::platformGlyphInit()
         LOG_ERROR("Failed to get glyph page zero.");
         m_spaceGlyph = 0;
         m_spaceWidth = 0;
+        m_adjustedSpaceWidth = 0;
         determinePitch();
         m_zeroWidthSpaceGlyph = 0;
         m_missingGlyphData.fontData = this;
@@ -114,6 +115,7 @@ void SimpleFontData::platformGlyphInit()
     float width = widthForGlyph(m_spaceGlyph);
     m_spaceWidth = width;
     determinePitch();
+    m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width);
 
     // Force the glyph for ZERO WIDTH SPACE to have zero width, unless it is shared with SPACE.
     // Helvetica is an example of a non-zero width ZERO WIDTH SPACE glyph.
index 9b11e49..17dcad9 100644 (file)
@@ -134,6 +134,7 @@ public:
     float platformWidthForGlyph(Glyph) const;
 
     float spaceWidth() const { return m_spaceWidth; }
+    float adjustedSpaceWidth() const { return m_adjustedSpaceWidth; }
     void setSpaceWidth(float spaceWidth) { m_spaceWidth = spaceWidth; }
 
 #if USE(CG) || USE(CAIRO) || PLATFORM(WX) || USE(SKIA_ON_MAC_CHROME)
@@ -243,6 +244,7 @@ private:
     
     Glyph m_spaceGlyph;
     float m_spaceWidth;
+    float m_adjustedSpaceWidth;
 
     Glyph m_zeroWidthSpaceGlyph;
 
index fa8f211..1ea0460 100644 (file)
@@ -92,20 +92,22 @@ static unsigned rightTruncateToBuffer(const String& string, unsigned length, uns
     return truncatedLength;
 }
 
-static float stringWidth(const Font& renderer, const UChar* characters, unsigned length)
+static float stringWidth(const Font& renderer, const UChar* characters, unsigned length, bool disableRoundingHacks)
 {
     TextRun run(characters, length);
+    if (disableRoundingHacks)
+        run.disableRoundingHacks();
     return renderer.width(run);
 }
 
-static String truncateString(const String& string, float maxWidth, const Font& font, TruncationFunction truncateToBuffer)
+static String truncateString(const String& string, float maxWidth, const Font& font, TruncationFunction truncateToBuffer, bool disableRoundingHacks)
 {
     if (string.isEmpty())
         return string;
     
     ASSERT(maxWidth >= 0);
     
-    float currentEllipsisWidth = stringWidth(font, &horizontalEllipsis, 1);
+    float currentEllipsisWidth = stringWidth(font, &horizontalEllipsis, 1, disableRoundingHacks);
     
     UChar stringBuffer[STRING_BUFFER_SIZE];
     unsigned truncatedLength;
@@ -121,7 +123,7 @@ static String truncateString(const String& string, float maxWidth, const Font& f
         truncatedLength = length;
     }
 
-    float width = stringWidth(font, stringBuffer, truncatedLength);
+    float width = stringWidth(font, stringBuffer, truncatedLength, disableRoundingHacks);
     if (width <= maxWidth)
         return string;
 
@@ -157,7 +159,7 @@ static String truncateString(const String& string, float maxWidth, const Font& f
         
         truncatedLength = truncateToBuffer(string, length, keepCount, stringBuffer);
 
-        width = stringWidth(font, stringBuffer, truncatedLength);
+        width = stringWidth(font, stringBuffer, truncatedLength, disableRoundingHacks);
         if (width <= maxWidth) {
             keepCountForLargestKnownToFit = keepCount;
             widthForLargestKnownToFit = width;
@@ -179,19 +181,19 @@ static String truncateString(const String& string, float maxWidth, const Font& f
     return String(stringBuffer, truncatedLength);
 }
 
-String StringTruncator::centerTruncate(const String& string, float maxWidth, const Font& font)
+String StringTruncator::centerTruncate(const String& string, float maxWidth, const Font& font, EnableRoundingHacksOrNot enableRoundingHacks)
 {
-    return truncateString(string, maxWidth, font, centerTruncateToBuffer);
+    return truncateString(string, maxWidth, font, centerTruncateToBuffer, !enableRoundingHacks);
 }
 
-String StringTruncator::rightTruncate(const String& string, float maxWidth, const Font& font)
+String StringTruncator::rightTruncate(const String& string, float maxWidth, const Font& font, EnableRoundingHacksOrNot enableRoundingHacks)
 {
-    return truncateString(string, maxWidth, font, rightTruncateToBuffer);
+    return truncateString(string, maxWidth, font, rightTruncateToBuffer, !enableRoundingHacks);
 }
 
-float StringTruncator::width(const String& string, const Font& font)
+float StringTruncator::width(const String& string, const Font& font, EnableRoundingHacksOrNot enableRoundingHacks)
 {
-    return stringWidth(font, string.characters(), string.length());
+    return stringWidth(font, string.characters(), string.length(), !enableRoundingHacks);
 }
 
 } // namespace WebCore
index 89dc9ef..1499c10 100644 (file)
@@ -37,9 +37,11 @@ namespace WebCore {
     
     class StringTruncator {
     public:
-        static String centerTruncate(const String&, float maxWidth, const Font&);
-        static String rightTruncate(const String&, float maxWidth, const Font&);
-        static float width(const String&, const Font&);
+        enum EnableRoundingHacksOrNot { DisableRoundingHacks, EnableRoundingHacks };
+
+        static String centerTruncate(const String&, float maxWidth, const Font&, EnableRoundingHacksOrNot = DisableRoundingHacks);
+        static String rightTruncate(const String&, float maxWidth, const Font&, EnableRoundingHacksOrNot = DisableRoundingHacks);
+        static float width(const String&, const Font&, EnableRoundingHacksOrNot = DisableRoundingHacks);
     };
     
 } // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/TextRun.cpp b/Source/WebCore/platform/graphics/TextRun.cpp
new file mode 100644 (file)
index 0000000..7f79936
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TextRun.h"
+
+namespace WebCore {
+
+bool TextRun::s_allowsRoundingHacks = false;
+
+void TextRun::setAllowsRoundingHacks(bool allowsRoundingHacks)
+{
+    s_allowsRoundingHacks = allowsRoundingHacks;
+}
+
+}
index e4d8fab..79cb25d 100644 (file)
@@ -50,7 +50,15 @@ public:
 
     typedef unsigned ExpansionBehavior;
 
-    TextRun(const UChar* c, int len, bool allowTabs = false, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false)
+    enum RoundingHackFlags {
+        NoRounding = 0,
+        RunRounding = 1 << 0,
+        WordRounding = 1 << 1,
+    };
+
+    typedef unsigned RoundingHacks;
+
+    TextRun(const UChar* c, int len, bool allowTabs = false, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, RoundingHacks roundingHacks = RunRounding | WordRounding)
         : m_characters(c)
         , m_charactersLength(len)
         , m_len(len)
@@ -63,11 +71,13 @@ public:
         , m_allowTabs(allowTabs)
         , m_direction(direction)
         , m_directionalOverride(directionalOverride)
+        , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHacks)
+        , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRoundingHacks)
         , m_disableSpacing(false)
     {
     }
 
-    TextRun(const String& s, bool allowTabs = false, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false)
+    TextRun(const String& s, bool allowTabs = false, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, RoundingHacks roundingHacks = RunRounding | WordRounding)
         : m_characters(s.characters())
         , m_charactersLength(s.length())
         , m_len(s.length())
@@ -80,6 +90,8 @@ public:
         , m_allowTabs(allowTabs)
         , m_direction(direction)
         , m_directionalOverride(directionalOverride)
+        , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHacks)
+        , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRoundingHacks)
         , m_disableSpacing(false)
     {
     }
@@ -110,9 +122,12 @@ public:
     bool rtl() const { return m_direction == RTL; }
     bool ltr() const { return m_direction == LTR; }
     bool directionalOverride() const { return m_directionalOverride; }
+    bool applyRunRounding() const { return m_applyRunRounding; }
+    bool applyWordRounding() const { return m_applyWordRounding; }
     bool spacingDisabled() const { return m_disableSpacing; }
 
     void disableSpacing() { m_disableSpacing = true; }
+    void disableRoundingHacks() { m_applyRunRounding = m_applyWordRounding = false; }
     void setDirection(TextDirection direction) { m_direction = direction; }
     void setDirectionalOverride(bool override) { m_directionalOverride = override; }
 
@@ -130,7 +145,11 @@ public:
     RenderingContext* renderingContext() const { return m_renderingContext.get(); }
     void setRenderingContext(PassRefPtr<RenderingContext> context) { m_renderingContext = context; }
 
+    static void setAllowsRoundingHacks(bool);
+
 private:
+    static bool s_allowsRoundingHacks;
+
     const UChar* m_characters;
     int m_charactersLength; // Marks the end of the m_characters buffer. Default equals to m_len.
     int m_len;
@@ -147,6 +166,8 @@ private:
     bool m_allowTabs;
     TextDirection m_direction;
     bool m_directionalOverride; // Was this direction set by an override character.
+    bool m_applyRunRounding;
+    bool m_applyWordRounding;
     bool m_disableSpacing;
     RefPtr<RenderingContext> m_renderingContext;
 };
index bb015e3..b67b4b2 100644 (file)
@@ -41,6 +41,7 @@ WidthIterator::WidthIterator(const Font* font, const TextRun& run, HashSet<const
     , m_currentCharacter(0)
     , m_runWidthSoFar(0)
     , m_isAfterExpansion(!run.allowsLeadingExpansion())
+    , m_finalRoundingWidth(0)
     , m_fallbackFonts(fallbackFonts)
     , m_accountForGlyphBounds(accountForGlyphBounds)
     , m_maxGlyphBoundingBoxY(numeric_limits<float>::min())
@@ -93,6 +94,11 @@ unsigned WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
     bool rtl = m_run.rtl();
     bool hasExtraSpacing = (m_font->letterSpacing() || m_font->wordSpacing() || m_expansion) && !m_run.spacingDisabled();
 
+    float widthSinceLastRounding = m_runWidthSoFar;
+    m_runWidthSoFar = floorf(m_runWidthSoFar);
+    widthSinceLastRounding -= m_runWidthSoFar;
+
+    float lastRoundingWidth = m_finalRoundingWidth;
     FloatRect bounds;
 
     const SimpleFontData* primaryFont = m_font->primaryFont();
@@ -113,7 +119,7 @@ unsigned WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
         float width;
         if (character == '\t' && m_run.allowTabs()) {
             float tabWidth = m_font->tabWidth(*fontData);
-            width = tabWidth - fmodf(m_run.xPos() + m_runWidthSoFar, tabWidth);
+            width = tabWidth - fmodf(m_run.xPos() + m_runWidthSoFar + widthSinceLastRounding, tabWidth);
         } else {
             width = fontData->widthForGlyph(glyph);
 
@@ -121,6 +127,13 @@ unsigned WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
             // SVG uses horizontalGlyphStretch(), when textLength is used to stretch/squeeze text.
             width *= m_run.horizontalGlyphStretch();
 #endif
+
+            // We special case spaces in two ways when applying word rounding.
+            // First, we round spaces to an adjusted width in all fonts.
+            // Second, in fixed-pitch fonts we ensure that all characters that
+            // match the width of the space character have the same width as the space character.
+            if (m_run.applyWordRounding() && width == fontData->spaceWidth() && (fontData->pitch() == FixedPitch || glyph == fontData->spaceGlyph()))
+                width = fontData->adjustedSpaceWidth();
         }
 
         if (fontData != lastFontData && width) {
@@ -187,10 +200,39 @@ unsigned WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
 
         // Advance past the character we just dealt with.
         textIterator.advance(advanceLength);
-        m_runWidthSoFar += width;
+
+        float oldWidth = width; 
+
+        // Force characters that are used to determine word boundaries for the rounding hack
+        // to be integer width, so following words will start on an integer boundary.
+        if (m_run.applyWordRounding() && Font::isRoundingHackCharacter(character)) {
+            width = ceilf(width);
+
+            // Since widthSinceLastRounding can lose precision if we include measurements for
+            // preceding whitespace, we bypass it here.
+            m_runWidthSoFar += width;
+
+            // Since this is a rounding hack character, we should have reset this sum on the previous
+            // iteration.
+            ASSERT(!widthSinceLastRounding);
+        } else {
+            // Check to see if the next character is a "rounding hack character", if so, adjust
+            // width so that the total run width will be on an integer boundary.
+            if ((m_run.applyWordRounding() && textIterator.currentCharacter() < m_run.length() && Font::isRoundingHackCharacter(*(textIterator.characters())))
+                    || (m_run.applyRunRounding() && textIterator.currentCharacter() >= m_run.length())) {
+                float totalWidth = widthSinceLastRounding + width;
+                widthSinceLastRounding = ceilf(totalWidth);
+                width += widthSinceLastRounding - totalWidth;
+                m_runWidthSoFar += widthSinceLastRounding;
+                widthSinceLastRounding = 0;
+            } else
+                widthSinceLastRounding += width;
+        }
 
         if (glyphBuffer)
-            glyphBuffer->add(glyph, fontData, width);
+            glyphBuffer->add(glyph, fontData, (rtl ? oldWidth + lastRoundingWidth : width));
+
+        lastRoundingWidth = width - oldWidth;
 
         if (m_accountForGlyphBounds) {
             m_maxGlyphBoundingBoxY = max(m_maxGlyphBoundingBoxY, bounds.maxY());
@@ -201,6 +243,8 @@ unsigned WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
 
     unsigned consumedCharacters = textIterator.currentCharacter() - m_currentCharacter;
     m_currentCharacter = textIterator.currentCharacter();
+    m_runWidthSoFar += widthSinceLastRounding;
+    m_finalRoundingWidth = lastRoundingWidth;
     return consumedCharacters;
 }
 
index 43124c4..60b9374 100644 (file)
@@ -64,6 +64,7 @@ struct WidthIterator {
     float m_expansion;
     float m_expansionPerOpportunity;
     bool m_isAfterExpansion;
+    float m_finalRoundingWidth;
 
 #if ENABLE(SVG_FONTS)
     String m_lastGlyphName;
index 0ed7460..33b2dbe 100644 (file)
@@ -49,6 +49,13 @@ static inline CGFloat roundCGFloat(CGFloat f)
     return static_cast<CGFloat>(round(f));
 }
 
+static inline CGFloat ceilCGFloat(CGFloat f)
+{
+    if (sizeof(CGFloat) == sizeof(float))
+        return ceilf(static_cast<float>(f));
+    return static_cast<CGFloat>(ceil(f));
+}
+
 ComplexTextController::ComplexTextController(const Font* font, const TextRun& run, bool mayUseNaturalWritingDirection, HashSet<const SimpleFontData*>* fallbackFonts, bool forTextEmphasis)
     : m_font(*font)
     , m_run(run)
@@ -62,6 +69,7 @@ ComplexTextController::ComplexTextController(const Font* font, const TextRun& ru
     , m_currentRun(0)
     , m_glyphInCurrentRun(0)
     , m_characterInCurrentGlyph(0)
+    , m_finalRoundingWidth(0)
     , m_expansion(run.expansion())
     , m_leadingExpansion(0)
     , m_afterExpansion(!run.allowsLeadingExpansion())
@@ -70,6 +78,7 @@ ComplexTextController::ComplexTextController(const Font* font, const TextRun& ru
     , m_maxGlyphBoundingBoxX(numeric_limits<float>::min())
     , m_minGlyphBoundingBoxY(numeric_limits<float>::max())
     , m_maxGlyphBoundingBoxY(numeric_limits<float>::min())
+    , m_lastRoundingGlyph(0)
 {
     if (!m_expansion)
         m_expansionPerOpportunity = 0;
@@ -400,6 +409,8 @@ void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer)
         m_currentRun++;
         m_glyphInCurrentRun = 0;
     }
+    if (!ltr && m_numGlyphsSoFar == m_adjustedAdvances.size())
+        m_runWidthSoFar += m_finalRoundingWidth;
 }
 
 void ComplexTextController::adjustGlyphsAndAdvances()
@@ -417,6 +428,7 @@ void ComplexTextController::adjustGlyphsAndAdvances()
 
         bool lastRun = r + 1 == runCount;
         bool roundsAdvances = !m_font.isPrinterFont() && fontData->platformData().roundsGlyphAdvances();
+        CGFloat roundedSpaceWidth = roundCGFloat(fontData->spaceWidth());
         const UChar* cp = complexTextRun.characters();
         CGPoint glyphOrigin = CGPointZero;
         CFIndex lastCharacterIndex = m_run.ltr() ? numeric_limits<CFIndex>::min() : numeric_limits<CFIndex>::max();
@@ -459,6 +471,14 @@ void ComplexTextController::adjustGlyphsAndAdvances()
 
             advance.width += fontData->syntheticBoldOffset();
 
+            // We special case spaces in two ways when applying word rounding. 
+            // First, we round spaces to an adjusted width in all fonts. 
+            // Second, in fixed-pitch fonts we ensure that all glyphs that 
+            // match the width of the space glyph have the same width as the space glyph. 
+            if (m_run.applyWordRounding() && roundedAdvanceWidth == roundedSpaceWidth && (fontData->pitch() == FixedPitch || glyph == fontData->spaceGlyph()))
+                advance.width = fontData->adjustedSpaceWidth();
+
             if (hasExtraSpacing) {
                 // If we're a glyph with an advance, go ahead and add in letter-spacing.
                 // That way we weed out zero width lurkers.  This behavior matches the fast text code path.
@@ -493,7 +513,32 @@ void ComplexTextController::adjustGlyphsAndAdvances()
                     m_afterExpansion = false;
             }
 
-            widthSinceLastCommit += advance.width;
+            // Apply rounding hacks if needed.
+            // We adjust the width of the last character of a "word" to ensure an integer width. 
+            // Force characters that are used to determine word boundaries for the rounding hack 
+            // to be integer width, so the following words will start on an integer boundary. 
+            if (m_run.applyWordRounding() && Font::isRoundingHackCharacter(ch)) 
+                advance.width = ceilCGFloat(advance.width); 
+
+            // Check to see if the next character is a "rounding hack character", if so, adjust the 
+            // width so that the total run width will be on an integer boundary. 
+            if ((m_run.applyWordRounding() && !lastGlyph && Font::isRoundingHackCharacter(nextCh)) || (m_run.applyRunRounding() && lastGlyph)) { 
+                CGFloat totalWidth = widthSinceLastCommit + advance.width; 
+                widthSinceLastCommit = ceilCGFloat(totalWidth); 
+                CGFloat extraWidth = widthSinceLastCommit - totalWidth; 
+                if (m_run.ltr()) 
+                    advance.width += extraWidth; 
+                else { 
+                    if (m_lastRoundingGlyph) 
+                        m_adjustedAdvances[m_lastRoundingGlyph - 1].width += extraWidth; 
+                    else 
+                        m_finalRoundingWidth = extraWidth; 
+                    m_lastRoundingGlyph = m_adjustedAdvances.size() + 1; 
+                } 
+                m_totalWidth += widthSinceLastCommit; 
+                widthSinceLastCommit = 0; 
+            } else 
+                widthSinceLastCommit += advance.width; 
 
             // FIXME: Combining marks should receive a text emphasis mark if they are combine with a space.
             if (m_forTextEmphasis && (!Font::canReceiveTextEmphasis(ch) || (U_GET_GC_MASK(ch) & U_GC_M_MASK)))
index e33aed8..12be561 100644 (file)
@@ -72,6 +72,8 @@ public:
 
     float totalWidth() const { return m_totalWidth; }
 
+    float finalRoundingWidth() const { return m_finalRoundingWidth; }
+
     float minGlyphBoundingBoxX() const { return m_minGlyphBoundingBoxX; }
     float maxGlyphBoundingBoxX() const { return m_maxGlyphBoundingBoxX; }
     float minGlyphBoundingBoxY() const { return m_minGlyphBoundingBoxY; }
@@ -183,6 +185,7 @@ private:
     size_t m_currentRun;
     unsigned m_glyphInCurrentRun;
     unsigned m_characterInCurrentGlyph;
+    float m_finalRoundingWidth;
     float m_expansion;
     float m_expansionPerOpportunity;
     float m_leadingExpansion;
@@ -194,6 +197,8 @@ private:
     float m_maxGlyphBoundingBoxX;
     float m_minGlyphBoundingBoxY;
     float m_maxGlyphBoundingBoxY;
+
+    unsigned m_lastRoundingGlyph;
 };
 
 } // namespace WebCore
index 5a7dd08..65f7e76 100644 (file)
@@ -71,7 +71,7 @@ float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int
     float afterWidth = controller.runWidthSoFar();
 
     if (run.rtl()) {
-        initialAdvance = controller.totalWidth() - afterWidth;
+        initialAdvance = controller.totalWidth() + controller.finalRoundingWidth() - afterWidth;
         for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
             glyphBuffer.swap(i, end);
     } else
index 59e73f7..e95b8c5 100644 (file)
@@ -113,6 +113,7 @@ void SimpleFontData::platformGlyphInit()
     if (!m_platformData.size())
         return;
     m_spaceGlyph = 0;
+    m_adjustedSpaceWidth = m_spaceWidth;
     determinePitch();
     m_missingGlyphData.fontData = this;
     m_missingGlyphData.glyph = 0;
index 61b4496..8867098 100644 (file)
@@ -705,9 +705,9 @@ String RenderThemeGtk::fileListNameForWidth(const Vector<String>& filenames, con
         gchar* systemBasename = g_path_get_basename(systemFilename.data());
         stringByAdoptingFileSystemRepresentation(systemBasename, string);
     } else if (filenames.size() > 1)
-        return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font);
+        return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font, StringTruncator::EnableRoundingHacks);
 
-    return StringTruncator::centerTruncate(string, width, font);
+    return StringTruncator::centerTruncate(string, width, font, StringTruncator::EnableRoundingHacks);
 }
 
 }
index b393c9d..d57648f 100644 (file)
@@ -161,6 +161,7 @@ static float widthWithFont(NSString *string, NSFont *font)
 
         Font webCoreFont(FontPlatformData(font, [font pointSize]), ![[NSGraphicsContext currentContext] isDrawingToScreen]);
         TextRun run(buffer.data(), length);
+        run.disableRoundingHacks();
         return webCoreFont.width(run);
     }
     
@@ -201,6 +202,7 @@ static void drawAtPoint(NSString *string, NSPoint point, NSFont *font, NSColor *
             
         Font webCoreFont(FontPlatformData(font, [font pointSize]), ![nsContext isDrawingToScreen], Antialiased);
         TextRun run(buffer.data(), length);
+        run.disableRoundingHacks();
 
         CGFloat red;
         CGFloat green;
index 3b913ec..f858b07 100644 (file)
@@ -212,13 +212,13 @@ DragImageRef createDragImageForLink(KURL& url, const String& inLabel, Frame* fra
     static const Color bottomColor(255, 255, 255, 127); // original alpha = 0.5
     if (drawURLString) {
         if (clipURLString)
-            urlString = StringTruncator::rightTruncate(urlString, imageSize.width() - (DragLabelBorderX * 2.0f), *urlFont);
+            urlString = StringTruncator::rightTruncate(urlString, imageSize.width() - (DragLabelBorderX * 2.0f), *urlFont, StringTruncator::EnableRoundingHacks);
         IntPoint textPos(DragLabelBorderX, imageSize.height() - (LabelBorderYOffset + urlFont->fontMetrics().descent()));
         WebCoreDrawDoubledTextAtPoint(context, urlString, textPos, *urlFont, topColor, bottomColor);
     }
     
     if (clipLabelString)
-        label = StringTruncator::rightTruncate(label, imageSize.width() - (DragLabelBorderX * 2.0f), *labelFont);
+        label = StringTruncator::rightTruncate(label, imageSize.width() - (DragLabelBorderX * 2.0f), *labelFont, StringTruncator::EnableRoundingHacks);
 
     IntPoint textPos(DragLabelBorderX, DragLabelBorderY + labelFont->pixelSize());
     WebCoreDrawDoubledTextAtPoint(context, label, textPos, *labelFont, topColor, bottomColor);
index 22c609b..650a15d 100644 (file)
@@ -106,7 +106,7 @@ float WebCoreTextFloatWidth(const String& text, const Font& font)
 {
     FontCachePurgePreventer fontCachePurgePreventer;
 
-    return StringTruncator::width(text, font);
+    return StringTruncator::width(text, font, StringTruncator::EnableRoundingHacks);
 }
 
 void WebCoreSetShouldUseFontSmoothing(bool smooth)
index f3b26f6..ebc3334 100644 (file)
@@ -96,6 +96,7 @@ void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const IntPoint&
         const String& displayedFilename = fileTextValue();
         const Font& font = style()->font();
         TextRun textRun = constructTextRun(this, font, displayedFilename, style(), TextRun::AllowTrailingExpansion, RespectDirection | RespectDirectionOverride);
+        textRun.disableRoundingHacks();
 
         // Determine where the filename should be placed
         int contentLeft = paintOffset.x() + borderLeft() + paddingLeft();
index 5621967..ccc98ec 100644 (file)
@@ -122,7 +122,9 @@ void RenderListBox::updateFromElement()
 
             if (!text.isEmpty()) {
                 // FIXME: Why is this always LTR? Can't text direction affect the width?
-                float textWidth = itemFont.width(constructTextRun(this, itemFont, text, style(), TextRun::AllowTrailingExpansion));
+                TextRun textRun = constructTextRun(this, itemFont, text, style(), TextRun::AllowTrailingExpansion);
+                textRun.disableRoundingHacks();
+                float textWidth = itemFont.width(textRun);
                 width = max(width, textWidth);
             }
         }
@@ -395,7 +397,7 @@ void RenderListBox::paintItemForeground(PaintInfo& paintInfo, const IntPoint& pa
 
     unsigned length = itemText.length();
     const UChar* string = itemText.characters();
-    TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, itemStyle->direction(), itemStyle->unicodeBidi() == Override);
+    TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, itemStyle->direction(), itemStyle->unicodeBidi() == Override, TextRun::NoRounding);
     Font itemFont = style()->font();
     IntRect r = itemBoundingBoxRect(paintOffset, listIndex);
     r.move(itemOffsetForAlignment(textRun, itemStyle, itemFont, r));
index 9c618bf..5d29200 100644 (file)
@@ -530,7 +530,9 @@ float RenderTextControl::getAvgCharWidth(AtomicString family)
 
     const UChar ch = '0';
     const Font& font = style()->font();
-    return font.width(constructTextRun(this, font, String(&ch, 1), style(), TextRun::AllowTrailingExpansion));
+    TextRun textRun = constructTextRun(this, font, String(&ch, 1), style(), TextRun::AllowTrailingExpansion);
+    textRun.disableRoundingHacks();
+    return font.width(textRun);
 }
 
 float RenderTextControl::scaleEmToUnits(int x) const
index 2c3ef4c..d239032 100644 (file)
@@ -1105,10 +1105,9 @@ String RenderTheme::fileListNameForWidth(const Vector<String>& filenames, const
     else if (filenames.size() == 1)
         string = pathGetFileName(filenames[0]);
     else
-        return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font);
+        return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font, StringTruncator::EnableRoundingHacks);
 
-    return StringTruncator::centerTruncate(string, width, font);
+    return StringTruncator::centerTruncate(string, width, font, StringTruncator::EnableRoundingHacks);
 }
 
-
 } // namespace WebCore
index 0672163..444bb5e 100644 (file)
@@ -2062,9 +2062,9 @@ String RenderThemeMac::fileListNameForWidth(const Vector<String>& filenames, con
     else if (filenames.size() == 1)
         strToTruncate = [[NSFileManager defaultManager] displayNameAtPath:(filenames[0])];
     else
-        return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font);
+        return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font, StringTruncator::EnableRoundingHacks);
 
-    return StringTruncator::centerTruncate(strToTruncate, width, font);
+    return StringTruncator::centerTruncate(strToTruncate, width, font, StringTruncator::EnableRoundingHacks);
 }
 
 } // namespace WebCore
index f9f26b4..abf9b6b 100644 (file)
@@ -430,6 +430,8 @@ TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFrag
     if (textRunNeedsRenderingContext(style->font()))
         run.setRenderingContext(SVGTextRunRenderingContext::create(text));
 
+    run.disableRoundingHacks();
+
     // We handle letter & word spacing ourselves.
     run.disableSpacing();
 
index cb1a9b4..2eeb482 100644 (file)
@@ -87,6 +87,8 @@ static TextRun constructTextRun(RenderSVGInlineText* text, const UChar* characte
     if (textRunNeedsRenderingContext(style->font()))
         run.setRenderingContext(SVGTextRunRenderingContext::create(text));
 
+    run.disableRoundingHacks();
+
     // We handle letter & word spacing ourselves.
     run.disableSpacing();
 
index fd174ea..fd9bdf3 100644 (file)
@@ -1,3 +1,18 @@
+2011-06-24  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        Add an option to enable legacy rounding hacks
+        https://bugs.webkit.org/show_bug.cgi?id=63363
+
+        * 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:
+
 2011-06-24  Dominic Cooney  <dominicc@chromium.org>
 
         Reviewed by Dimitri Glazkov.
index 527e2e6..2ba333f 100644 (file)
@@ -94,6 +94,7 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
 
         Font webCoreFont(FontPlatformData(font, [font pointSize]), ![nsContext isDrawingToScreen], fontSmoothingIsAllowed ? AutoSmoothing : Antialiased);
         TextRun run(buffer.data(), length);
+        run.disableRoundingHacks();
 
         CGFloat red;
         CGFloat green;
@@ -141,6 +142,7 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
 
         Font webCoreFont(FontPlatformData(font, [font pointSize]), ![[NSGraphicsContext currentContext] isDrawingToScreen]);
         TextRun run(buffer.data(), length);
+        run.disableRoundingHacks();
         return webCoreFont.width(run);
     }
 
index 70a7575..9ee55cc 100644 (file)
@@ -1066,6 +1066,11 @@ static NSMutableSet *knownPluginMIMETypes()
     Font::setCodePath(f ? Font::Complex : Font::Auto);
 }
 
++ (void)_setAllowsRoundingHacks:(BOOL)allowsRoundingHacks
+{
+    TextRun::setAllowsRoundingHacks(allowsRoundingHacks);
+}
+
 + (BOOL)canCloseAllWebViews
 {
     return DOMWindow::dispatchAllPendingBeforeUnloadEvents();
index a9d2b96..3735264 100644 (file)
@@ -341,6 +341,8 @@ Could be worth adding to the API.
 // This is the old name of the above method. Needed for Safari versions that call it.
 + (void)_setAlwaysUseATSU:(BOOL)f;
 
++ (void)_setAllowsRoundingHacks:(BOOL)allowsRoundingHacks;
+
 - (NSCachedURLResponse *)_cachedResponseForURL:(NSURL *)URL;
 
 #if ENABLE_DASHBOARD_SUPPORT
index c44d59b..10c4c02 100644 (file)
@@ -1,3 +1,14 @@
+2011-06-24  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        Add an option to enable legacy rounding hacks
+        https://bugs.webkit.org/show_bug.cgi?id=63363
+
+        * WebKitGraphics.cpp:
+        (CenterTruncateStringToWidth): Enabled rounding hacks in the string truncator.
+        (RightTruncateStringToWidth): Ditto.
+
 2011-06-24  Yuta Kitamura  <yutak@chromium.org>
 
         Reviewed by Adam Barth.
index f58ca76..382cbe3 100644 (file)
@@ -150,7 +150,7 @@ unsigned CenterTruncateStringToWidth(LPCTSTR text, int length, const WebFontDesc
 
     FontCachePurgePreventer fontCachePurgePreventer;
 
-    String result = StringTruncator::centerTruncate(String(text, length), width, makeFont(description));
+    String result = StringTruncator::centerTruncate(String(text, length), width, makeFont(description), StringTruncator::EnableRoundingHacks);
     memcpy(buffer, result.characters(), result.length() * sizeof(UChar));
     buffer[result.length()] = '\0';
     return result.length();
@@ -162,7 +162,7 @@ unsigned RightTruncateStringToWidth(LPCTSTR text, int length, const WebFontDescr
 
     FontCachePurgePreventer fontCachePurgePreventer;
 
-    String result = StringTruncator::rightTruncate(String(text, length), width, makeFont(description));
+    String result = StringTruncator::rightTruncate(String(text, length), width, makeFont(description), StringTruncator::EnableRoundingHacks);
     memcpy(buffer, result.characters(), result.length() * sizeof(UChar));
     buffer[result.length()] = '\0';
     return result.length();
index 4b1945a..567cadb 100644 (file)
@@ -1,3 +1,32 @@
+2011-06-24  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        Add an option to enable legacy rounding hacks
+        https://bugs.webkit.org/show_bug.cgi?id=63363
+
+        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):
+
 2011-06-24  Adam Roben  <aroben@apple.com>
 
         Include the directory containing the failing tests in titles of bugs filed from TestFailures
index f819c82..df6f351 100644 (file)
@@ -2124,6 +2124,14 @@ static JSValueRef setSerializeHTTPLoadsCallback(JSContextRef context, JSObjectRe
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef allowRoundingHacksCallback(JSContextRef context, JSObjectRef thisObject, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+
+    controller->allowRoundingHacks();
+    return JSValueMakeUndefined(context);
+}
+
 // Static Values
 
 static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
@@ -2396,6 +2404,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
         { "originsWithLocalStorage", originsWithLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setShouldPaintBrokenImage", setShouldPaintBrokenImageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setTextDirection", setTextDirectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "allowRoundingHacks", allowRoundingHacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { 0, 0, 0 }
     };
 
index 284e72c..df75bea 100644 (file)
@@ -302,6 +302,7 @@ public:
     void closeWebInspector();
     void evaluateInWebInspector(long callId, JSStringRef script);
     void evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script);
+    void allowRoundingHacks();
 
     void setPOSIXLocale(JSStringRef locale);
 
index 6957ee0..b108716 100644 (file)
@@ -1854,3 +1854,7 @@ void LayoutTestController::setEncodedAudioData(const CppArgumentList& arguments,
     m_encodedAudioData = arguments[0].toString();
     setShouldDumpAsAudio(true);
 }
+
+void LayoutTestController::allowRoundingHacks()
+{
+}
index ba8522b..98cc1dd 100644 (file)
@@ -977,3 +977,7 @@ void LayoutTestController::setTextDirection(JSStringRef direction)
 {
     // FIXME: Implement.
 }
+
+void LayoutTestController::allowRoundingHacks()
+{
+}
index bd959f7..c40d8b9 100644 (file)
@@ -1059,6 +1059,7 @@ static void resetWebViewToConsistentStateBeforeTesting()
 
     [WebView _setUsesTestModeFocusRingColor:YES];
     [WebView _resetOriginAccessWhitelists];
+    [WebView _setAllowsRoundingHacks:NO];
 
     [[MockGeolocationProvider shared] stopTimer];
     
index 230a140..244e71d 100644 (file)
@@ -914,6 +914,11 @@ void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObj
     [mainFrame _stringByEvaluatingJavaScriptFromString:scriptNS withGlobalObject:globalObject inScriptWorld:world];
 }
 
+void LayoutTestController::allowRoundingHacks()
+{
+    [WebView _setAllowsRoundingHacks:YES];
+}
+
 @interface APITestDelegate : NSObject
 {
     bool* m_condition;
index f606b28..09b74f4 100644 (file)
@@ -949,5 +949,9 @@ void LayoutTestController::setTextDirection(const QString& directionName)
         m_drt->webPage()->triggerAction(QWebPage::SetTextDirectionLeftToRight);
 }
 
+void LayoutTestController::allowRoundingHacks()
+{
+}
+
 const unsigned LayoutTestController::maxViewWidth = 800;
 const unsigned LayoutTestController::maxViewHeight = 600;
index 232a45d..d8de2b9 100644 (file)
@@ -1526,3 +1526,7 @@ void LayoutTestController::setTextDirection(JSStringRef direction)
 {
     // FIXME: Implement.
 }
+
+void LayoutTestController::allowRoundingHacks()
+{
+}
index 4349fdc..6300cc5 100644 (file)
@@ -635,3 +635,7 @@ void LayoutTestController::setTextDirection(JSStringRef direction)
 {
     // FIXME: Implement.
 }
+
+void LayoutTestController::allowRoundingHacks()
+{
+}