Changeset 89733 in webkit


Ignore:
Timestamp:
Jun 24, 2011 11:49:12 PM (13 years ago)
Author:
mitz@apple.com
Message:

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.
Location:
trunk
Files:
4 added
51 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r89732 r89733  
     12011-06-24  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Add an option to enable legacy rounding hacks
     6        https://bugs.webkit.org/show_bug.cgi?id=63363
     7
     8        * platform/mac/fast/text/rounding-hacks.html: Added.
     9        * platform/mac/platform/mac/fast/text/rounding-hacks-expected.png: Added.
     10        * platform/mac/platform/mac/fast/text/rounding-hacks-expected.txt: Added.
     11
    1122011-06-24  Nikolas Zimmermann  <nzimmermann@rim.com>
    213
  • trunk/Source/WebCore/CMakeLists.txt

    r89731 r89733  
    10881088    platform/graphics/StringTruncator.cpp
    10891089    platform/graphics/SurrogatePairAwareTextIterator.cpp
     1090    platform/graphics/TextRun.cpp
    10901091    platform/graphics/WidthIterator.cpp
    10911092
  • trunk/Source/WebCore/ChangeLog

    r89732 r89733  
     12011-06-24  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Add an option to enable legacy rounding hacks
     6        https://bugs.webkit.org/show_bug.cgi?id=63363
     7
     8        Restored most of text rounding hacks which were removed in r78846, with a global flag to control
     9        whether rounding hacks are allowed, which defaults to false.
     10
     11        Test: platform/mac/fast/text/rounding-hacks.html
     12
     13        * CMakeLists.txt: Added TextRun.cpp.
     14        * GNUmakefile.list.am: Ditto.
     15        * WebCore.exp.in: Export new TextRun function and global and updated StringTruncator functions.
     16        * WebCore.gypi: Added TextRun.cpp.
     17        * WebCore.pro: Ditto.
     18        * WebCore.vcproj/WebCore.vcproj: Ditto.
     19        * WebCore.xcodeproj/project.pbxproj: Ditto.
     20        * html/canvas/CanvasRenderingContext2D.cpp:
     21        (WebCore::CanvasRenderingContext2D::drawTextInternal): Disable rounding hacks in the one place
     22        they used to be disabled.
     23        * platform/graphics/Font.cpp: Re-added the rounding character table.
     24        * platform/graphics/Font.h:
     25        (WebCore::Font::isRoundingHackCharacter): Re-added.
     26        * platform/graphics/FontFastPath.cpp:
     27        (WebCore::Font::getGlyphsAndAdvancesForSimpleText): Account for final rounding width.
     28        * platform/graphics/SimpleFontData.cpp:
     29        (WebCore::SimpleFontData::platformGlyphInit): Initialize m_adjustedSpaceWidth.
     30        * platform/graphics/SimpleFontData.h:
     31        (WebCore::SimpleFontData::adjustedSpaceWidth): Re-added.
     32        * platform/graphics/StringTruncator.cpp:
     33        (WebCore::stringWidth): Re-added disableRoundingHacks parameter.
     34        (WebCore::truncateString): Ditto.
     35        (WebCore::StringTruncator::centerTruncate): Added EnableRoundingHacksOrNot parameter.
     36        (WebCore::StringTruncator::rightTruncate): Ditto.
     37        (WebCore::StringTruncator::width): Ditto.
     38        * platform/graphics/StringTruncator.h:
     39        * platform/graphics/TextRun.cpp: Added.
     40        (WebCore::TextRun::setAllowsRoundingHacks): Added.
     41        * platform/graphics/TextRun.h:
     42        (WebCore::TextRun::TextRun): Added RoundingHacks parameter to the constructors, used to initialize
     43        the m_applyRunRounding and m_applyWordRounding member variables, subject to rounding hacks being allowed.
     44        (WebCore::TextRun::applyRunRounding): Re-added this accessor.
     45        (WebCore::TextRun::applyWordRounding): Ditto.
     46        (WebCore::TextRun::disableRoundingHacks): Re-added.
     47        * platform/graphics/WidthIterator.cpp:
     48        (WebCore::WidthIterator::WidthIterator): Re-added code to apply rounding hacks.
     49        (WebCore::WidthIterator::advance): Ditto.
     50        * platform/graphics/WidthIterator.h:
     51        * platform/graphics/mac/ComplexTextController.cpp:
     52        (WebCore::ceilCGFloat): Re-added.
     53        (WebCore::ComplexTextController::ComplexTextController): Re-added code to apply rounding hacks.
     54        (WebCore::ComplexTextController::advance): Ditto.
     55        (WebCore::ComplexTextController::adjustGlyphsAndAdvances): Ditto.
     56        * platform/graphics/mac/ComplexTextController.h:
     57        (WebCore::ComplexTextController::finalRoundingWidth): Re-added this accessor.
     58        * platform/graphics/mac/FontComplexTextMac.cpp:
     59        (WebCore::Font::getGlyphsAndAdvancesForComplexText): Accound for final rounding width.
     60        * platform/graphics/qt/SimpleFontDataQt.cpp:
     61        (WebCore::SimpleFontData::platformGlyphInit): Initialize m_adjustedSpaceWidth.
     62        * platform/gtk/RenderThemeGtk.cpp:
     63        (WebCore::RenderThemeGtk::fileListNameForWidth): Enabled rounding hacks in the string truncator.
     64        * platform/mac/DragImageMac.mm:
     65        (WebCore::widthWithFont): Disable rounding hacks when measuring.
     66        (WebCore::drawAtPoint): Disable rounding hacks when drawing.
     67        * platform/win/DragImageWin.cpp:
     68        (WebCore::createDragImageForLink): Enable rounding hacks in the string truncator.
     69        * platform/win/WebCoreTextRenderer.cpp:
     70        (WebCore::WebCoreTextFloatWidth): Ditto.
     71        * rendering/RenderFileUploadControl.cpp:
     72        (WebCore::RenderFileUploadControl::paintObject): Disable rounding hacks.
     73        * rendering/RenderListBox.cpp:
     74        (WebCore::RenderListBox::updateFromElement): Ditto.
     75        (WebCore::RenderListBox::paintItemForeground): Ditto.
     76        * rendering/RenderTextControl.cpp:
     77        (WebCore::RenderTextControl::getAvgCharWidth): Ditto.
     78        * rendering/RenderTheme.cpp:
     79        (WebCore::RenderTheme::fileListNameForWidth): Enabled rounding hacks in the string truncator.
     80        * rendering/RenderThemeMac.mm:
     81        (WebCore::RenderThemeMac::fileListNameForWidth): Ditto.
     82        * rendering/svg/SVGInlineTextBox.cpp:
     83        (WebCore::SVGInlineTextBox::constructTextRun): Disabled rounding hacks.
     84        * rendering/svg/SVGTextMetrics.cpp:
     85        (WebCore::constructTextRun): Ditto.
     86
    1872011-06-24  Nikolas Zimmermann  <nzimmermann@rim.com>
    288
  • trunk/Source/WebCore/GNUmakefile.list.am

    r89711 r89733  
    25622562        Source/WebCore/platform/graphics/SVGGlyph.h \
    25632563        Source/WebCore/platform/graphics/TextRenderingMode.h \
     2564        Source/WebCore/platform/graphics/TextRun.cpp \
    25642565        Source/WebCore/platform/graphics/TextRun.h \
    25652566        Source/WebCore/platform/graphics/transforms/AffineTransform.cpp \
  • trunk/Source/WebCore/WebCore.exp.in

    r89682 r89733  
    430430__ZN7WebCore15ScrollAlignment17alignCenterAlwaysE
    431431__ZN7WebCore15ScrollAlignment19alignToEdgeIfNeededE
    432 __ZN7WebCore15StringTruncator13rightTruncateERKN3WTF6StringEfRKNS_4FontE
    433 __ZN7WebCore15StringTruncator14centerTruncateERKN3WTF6StringEfRKNS_4FontE
    434 __ZN7WebCore15StringTruncator5widthERKN3WTF6StringERKNS_4FontE
     432__ZN7WebCore15StringTruncator13rightTruncateERKN3WTF6StringEfRKNS_4FontENS0_24EnableRoundingHacksOrNotE
     433__ZN7WebCore15StringTruncator14centerTruncateERKN3WTF6StringEfRKNS_4FontENS0_24EnableRoundingHacksOrNotE
     434__ZN7WebCore15StringTruncator5widthERKN3WTF6StringERKNS_4FontENS0_24EnableRoundingHacksOrNotE
    435435__ZN7WebCore15VisiblePositionC1ERKNS_8PositionENS_9EAffinityE
    436436__ZN7WebCore15defaultLanguageEv
     
    827827__ZN7WebCore7IntRectC1ERKNS_9FloatRectE
    828828__ZN7WebCore7IntSizeC1ERK7_NSSize
     829__ZN7WebCore7TextRun21s_allowsRoundingHacksE
     830__ZN7WebCore7TextRun22setAllowsRoundingHacksEb
    829831__ZN7WebCore7cookiesEPKNS_8DocumentERKNS_4KURLE
    830832__ZN7WebCore7nsColorERKNS_5ColorE
  • trunk/Source/WebCore/WebCore.gypi

    r89711 r89733  
    39853985            'platform/graphics/SurrogatePairAwareTextIterator.cpp',
    39863986            'platform/graphics/SurrogatePairAwareTextIterator.h',
     3987            'platform/graphics/TextRun.cpp',
    39873988            'platform/graphics/Tile.h',
    39883989            'platform/graphics/TiledBackingStore.cpp',
  • trunk/Source/WebCore/WebCore.pro

    r89711 r89733  
    10081008    platform/graphics/SimpleFontData.cpp \
    10091009    platform/graphics/StringTruncator.cpp \
     1010    platform/graphics/TextRun.cpp \
    10101011    platform/graphics/TiledBackingStore.cpp \
    10111012    platform/graphics/transforms/AffineTransform.cpp \
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r89690 r89733  
    2769027690                                </File>
    2769127691                                <File
     27692                                        RelativePath="..\platform\graphics\TextRun.cpp"
     27693                                        >
     27694                                </File>
     27695                                <File
    2769227696                                        RelativePath="..\platform\graphics\TextRun.h"
    2769327697                                        >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r89711 r89733  
    809809                375CD232119D43C800A2A859 /* Hyphenation.h in Headers */ = {isa = PBXBuildFile; fileRef = 375CD231119D43C800A2A859 /* Hyphenation.h */; };
    810810                375CD23B119D44EA00A2A859 /* HyphenationMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 375CD239119D44EA00A2A859 /* HyphenationMac.mm */; };
     811                376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 376DCCE013B4F966002EBEFC /* TextRun.cpp */; };
    811812                3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    812813                377C4CDF1014E9F600B9AE42 /* PlaceholderDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 377C4CDD1014E9F600B9AE42 /* PlaceholderDocument.h */; };
     
    72597260                375CD231119D43C800A2A859 /* Hyphenation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Hyphenation.h; sourceTree = "<group>"; };
    72607261                375CD239119D44EA00A2A859 /* HyphenationMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HyphenationMac.mm; sourceTree = "<group>"; };
     7262                376DCCE013B4F966002EBEFC /* TextRun.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextRun.cpp; sourceTree = "<group>"; };
    72617263                3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverlapTestRequestClient.h; sourceTree = "<group>"; };
    72627264                377C4CDD1014E9F600B9AE42 /* PlaceholderDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaceholderDocument.h; sourceTree = "<group>"; };
     
    1804518047                                930FC6891072B9280045293E /* TextRenderingMode.h */,
    1804618048                                A824B4640E2EF2EA0081A7B7 /* TextRun.h */,
     18049                                376DCCE013B4F966002EBEFC /* TextRun.cpp */,
    1804718050                                37C28A6710F659CC008C7813 /* TypesettingFeatures.h */,
    1804818051                                E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */,
     
    2581625819                                43A6266713B3D11000AC94B8 /* SVGAnimatedString.cpp in Sources */,
    2581725820                                087558C513B4A57D00F49307 /* SurrogatePairAwareTextIterator.cpp in Sources */,
     25821                                376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */,
    2581825822                        );
    2581925823                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r89283 r89733  
    19261926    unsigned length = text.length();
    19271927    const UChar* string = text.characters();
    1928     TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, direction, override);
     1928    TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, direction, override, TextRun::NoRounding);
    19291929
    19301930    // Draw the item text at the correct point.
  • trunk/Source/WebCore/platform/graphics/Font.cpp

    r89732 r89733  
    4242
    4343namespace WebCore {
     44
     45const uint8_t Font::s_roundingHackCharacterTable[256] = {
     46    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,
     47    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 /*?*/,
     48    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,
     49    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,
     50    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,
     51    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,
     52    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,
     53    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
     54};
    4455
    4556Font::CodePath Font::s_codePath = Auto;
  • trunk/Source/WebCore/platform/graphics/Font.h

    r89732 r89733  
    195195    static CodePath s_codePath;
    196196
     197    static const uint8_t s_roundingHackCharacterTable[256];
     198    static bool isRoundingHackCharacter(UChar32 c)
     199    {
     200        return !(c & ~0xFF) && s_roundingHackCharacterTable[c];
     201    }
     202
    197203    FontSelector* fontSelector() const;
    198204    static bool treatAsSpace(UChar c) { return c == ' ' || c == '\t' || c == '\n' || c == noBreakSpace; }
  • trunk/Source/WebCore/platform/graphics/FontFastPath.cpp

    r89732 r89733  
    338338
    339339    if (run.rtl()) {
     340        float finalRoundingWidth = it.m_finalRoundingWidth;
    340341        it.advance(run.length());
    341         initialAdvance = it.m_runWidthSoFar - afterWidth;
     342        initialAdvance = finalRoundingWidth + it.m_runWidthSoFar - afterWidth;
    342343    } else
    343344        initialAdvance = beforeWidth;
  • trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp

    r89732 r89733  
    9999        m_spaceGlyph = 0;
    100100        m_spaceWidth = 0;
     101        m_adjustedSpaceWidth = 0;
    101102        determinePitch();
    102103        m_zeroWidthSpaceGlyph = 0;
     
    115116    m_spaceWidth = width;
    116117    determinePitch();
     118    m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width);
    117119
    118120    // Force the glyph for ZERO WIDTH SPACE to have zero width, unless it is shared with SPACE.
  • trunk/Source/WebCore/platform/graphics/SimpleFontData.h

    r89732 r89733  
    135135
    136136    float spaceWidth() const { return m_spaceWidth; }
     137    float adjustedSpaceWidth() const { return m_adjustedSpaceWidth; }
    137138    void setSpaceWidth(float spaceWidth) { m_spaceWidth = spaceWidth; }
    138139
     
    244245    Glyph m_spaceGlyph;
    245246    float m_spaceWidth;
     247    float m_adjustedSpaceWidth;
    246248
    247249    Glyph m_zeroWidthSpaceGlyph;
  • trunk/Source/WebCore/platform/graphics/StringTruncator.cpp

    r78846 r89733  
    9393}
    9494
    95 static float stringWidth(const Font& renderer, const UChar* characters, unsigned length)
     95static float stringWidth(const Font& renderer, const UChar* characters, unsigned length, bool disableRoundingHacks)
    9696{
    9797    TextRun run(characters, length);
     98    if (disableRoundingHacks)
     99        run.disableRoundingHacks();
    98100    return renderer.width(run);
    99101}
    100102
    101 static String truncateString(const String& string, float maxWidth, const Font& font, TruncationFunction truncateToBuffer)
     103static String truncateString(const String& string, float maxWidth, const Font& font, TruncationFunction truncateToBuffer, bool disableRoundingHacks)
    102104{
    103105    if (string.isEmpty())
     
    106108    ASSERT(maxWidth >= 0);
    107109   
    108     float currentEllipsisWidth = stringWidth(font, &horizontalEllipsis, 1);
     110    float currentEllipsisWidth = stringWidth(font, &horizontalEllipsis, 1, disableRoundingHacks);
    109111   
    110112    UChar stringBuffer[STRING_BUFFER_SIZE];
     
    122124    }
    123125
    124     float width = stringWidth(font, stringBuffer, truncatedLength);
     126    float width = stringWidth(font, stringBuffer, truncatedLength, disableRoundingHacks);
    125127    if (width <= maxWidth)
    126128        return string;
     
    158160        truncatedLength = truncateToBuffer(string, length, keepCount, stringBuffer);
    159161
    160         width = stringWidth(font, stringBuffer, truncatedLength);
     162        width = stringWidth(font, stringBuffer, truncatedLength, disableRoundingHacks);
    161163        if (width <= maxWidth) {
    162164            keepCountForLargestKnownToFit = keepCount;
     
    180182}
    181183
    182 String StringTruncator::centerTruncate(const String& string, float maxWidth, const Font& font)
     184String StringTruncator::centerTruncate(const String& string, float maxWidth, const Font& font, EnableRoundingHacksOrNot enableRoundingHacks)
    183185{
    184     return truncateString(string, maxWidth, font, centerTruncateToBuffer);
     186    return truncateString(string, maxWidth, font, centerTruncateToBuffer, !enableRoundingHacks);
    185187}
    186188
    187 String StringTruncator::rightTruncate(const String& string, float maxWidth, const Font& font)
     189String StringTruncator::rightTruncate(const String& string, float maxWidth, const Font& font, EnableRoundingHacksOrNot enableRoundingHacks)
    188190{
    189     return truncateString(string, maxWidth, font, rightTruncateToBuffer);
     191    return truncateString(string, maxWidth, font, rightTruncateToBuffer, !enableRoundingHacks);
    190192}
    191193
    192 float StringTruncator::width(const String& string, const Font& font)
     194float StringTruncator::width(const String& string, const Font& font, EnableRoundingHacksOrNot enableRoundingHacks)
    193195{
    194     return stringWidth(font, string.characters(), string.length());
     196    return stringWidth(font, string.characters(), string.length(), !enableRoundingHacks);
    195197}
    196198
  • trunk/Source/WebCore/platform/graphics/StringTruncator.h

    r78846 r89733  
    3838    class StringTruncator {
    3939    public:
    40         static String centerTruncate(const String&, float maxWidth, const Font&);
    41         static String rightTruncate(const String&, float maxWidth, const Font&);
    42         static float width(const String&, const Font&);
     40        enum EnableRoundingHacksOrNot { DisableRoundingHacks, EnableRoundingHacks };
     41
     42        static String centerTruncate(const String&, float maxWidth, const Font&, EnableRoundingHacksOrNot = DisableRoundingHacks);
     43        static String rightTruncate(const String&, float maxWidth, const Font&, EnableRoundingHacksOrNot = DisableRoundingHacks);
     44        static float width(const String&, const Font&, EnableRoundingHacksOrNot = DisableRoundingHacks);
    4345    };
    4446   
  • trunk/Source/WebCore/platform/graphics/TextRun.h

    r89732 r89733  
    5151    typedef unsigned ExpansionBehavior;
    5252
    53     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)
     53    enum RoundingHackFlags {
     54        NoRounding = 0,
     55        RunRounding = 1 << 0,
     56        WordRounding = 1 << 1,
     57    };
     58
     59    typedef unsigned RoundingHacks;
     60
     61    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)
    5462        : m_characters(c)
    5563        , m_charactersLength(len)
     
    6472        , m_direction(direction)
    6573        , m_directionalOverride(directionalOverride)
     74        , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHacks)
     75        , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRoundingHacks)
    6676        , m_disableSpacing(false)
    6777    {
    6878    }
    6979
    70     TextRun(const String& s, bool allowTabs = false, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false)
     80    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)
    7181        : m_characters(s.characters())
    7282        , m_charactersLength(s.length())
     
    8191        , m_direction(direction)
    8292        , m_directionalOverride(directionalOverride)
     93        , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHacks)
     94        , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRoundingHacks)
    8395        , m_disableSpacing(false)
    8496    {
     
    111123    bool ltr() const { return m_direction == LTR; }
    112124    bool directionalOverride() const { return m_directionalOverride; }
     125    bool applyRunRounding() const { return m_applyRunRounding; }
     126    bool applyWordRounding() const { return m_applyWordRounding; }
    113127    bool spacingDisabled() const { return m_disableSpacing; }
    114128
    115129    void disableSpacing() { m_disableSpacing = true; }
     130    void disableRoundingHacks() { m_applyRunRounding = m_applyWordRounding = false; }
    116131    void setDirection(TextDirection direction) { m_direction = direction; }
    117132    void setDirectionalOverride(bool override) { m_directionalOverride = override; }
     
    131146    void setRenderingContext(PassRefPtr<RenderingContext> context) { m_renderingContext = context; }
    132147
     148    static void setAllowsRoundingHacks(bool);
     149
    133150private:
     151    static bool s_allowsRoundingHacks;
     152
    134153    const UChar* m_characters;
    135154    int m_charactersLength; // Marks the end of the m_characters buffer. Default equals to m_len.
     
    148167    TextDirection m_direction;
    149168    bool m_directionalOverride; // Was this direction set by an override character.
     169    bool m_applyRunRounding;
     170    bool m_applyWordRounding;
    150171    bool m_disableSpacing;
    151172    RefPtr<RenderingContext> m_renderingContext;
  • trunk/Source/WebCore/platform/graphics/WidthIterator.cpp

    r89732 r89733  
    4242    , m_runWidthSoFar(0)
    4343    , m_isAfterExpansion(!run.allowsLeadingExpansion())
     44    , m_finalRoundingWidth(0)
    4445    , m_fallbackFonts(fallbackFonts)
    4546    , m_accountForGlyphBounds(accountForGlyphBounds)
     
    9495    bool hasExtraSpacing = (m_font->letterSpacing() || m_font->wordSpacing() || m_expansion) && !m_run.spacingDisabled();
    9596
     97    float widthSinceLastRounding = m_runWidthSoFar;
     98    m_runWidthSoFar = floorf(m_runWidthSoFar);
     99    widthSinceLastRounding -= m_runWidthSoFar;
     100
     101    float lastRoundingWidth = m_finalRoundingWidth;
    96102    FloatRect bounds;
    97103
     
    114120        if (character == '\t' && m_run.allowTabs()) {
    115121            float tabWidth = m_font->tabWidth(*fontData);
    116             width = tabWidth - fmodf(m_run.xPos() + m_runWidthSoFar, tabWidth);
     122            width = tabWidth - fmodf(m_run.xPos() + m_runWidthSoFar + widthSinceLastRounding, tabWidth);
    117123        } else {
    118124            width = fontData->widthForGlyph(glyph);
     
    122128            width *= m_run.horizontalGlyphStretch();
    123129#endif
     130
     131            // We special case spaces in two ways when applying word rounding.
     132            // First, we round spaces to an adjusted width in all fonts.
     133            // Second, in fixed-pitch fonts we ensure that all characters that
     134            // match the width of the space character have the same width as the space character.
     135            if (m_run.applyWordRounding() && width == fontData->spaceWidth() && (fontData->pitch() == FixedPitch || glyph == fontData->spaceGlyph()))
     136                width = fontData->adjustedSpaceWidth();
    124137        }
    125138
     
    188201        // Advance past the character we just dealt with.
    189202        textIterator.advance(advanceLength);
    190         m_runWidthSoFar += width;
     203
     204        float oldWidth = width;
     205
     206        // Force characters that are used to determine word boundaries for the rounding hack
     207        // to be integer width, so following words will start on an integer boundary.
     208        if (m_run.applyWordRounding() && Font::isRoundingHackCharacter(character)) {
     209            width = ceilf(width);
     210
     211            // Since widthSinceLastRounding can lose precision if we include measurements for
     212            // preceding whitespace, we bypass it here.
     213            m_runWidthSoFar += width;
     214
     215            // Since this is a rounding hack character, we should have reset this sum on the previous
     216            // iteration.
     217            ASSERT(!widthSinceLastRounding);
     218        } else {
     219            // Check to see if the next character is a "rounding hack character", if so, adjust
     220            // width so that the total run width will be on an integer boundary.
     221            if ((m_run.applyWordRounding() && textIterator.currentCharacter() < m_run.length() && Font::isRoundingHackCharacter(*(textIterator.characters())))
     222                    || (m_run.applyRunRounding() && textIterator.currentCharacter() >= m_run.length())) {
     223                float totalWidth = widthSinceLastRounding + width;
     224                widthSinceLastRounding = ceilf(totalWidth);
     225                width += widthSinceLastRounding - totalWidth;
     226                m_runWidthSoFar += widthSinceLastRounding;
     227                widthSinceLastRounding = 0;
     228            } else
     229                widthSinceLastRounding += width;
     230        }
    191231
    192232        if (glyphBuffer)
    193             glyphBuffer->add(glyph, fontData, width);
     233            glyphBuffer->add(glyph, fontData, (rtl ? oldWidth + lastRoundingWidth : width));
     234
     235        lastRoundingWidth = width - oldWidth;
    194236
    195237        if (m_accountForGlyphBounds) {
     
    202244    unsigned consumedCharacters = textIterator.currentCharacter() - m_currentCharacter;
    203245    m_currentCharacter = textIterator.currentCharacter();
     246    m_runWidthSoFar += widthSinceLastRounding;
     247    m_finalRoundingWidth = lastRoundingWidth;
    204248    return consumedCharacters;
    205249}
  • trunk/Source/WebCore/platform/graphics/WidthIterator.h

    r89732 r89733  
    6565    float m_expansionPerOpportunity;
    6666    bool m_isAfterExpansion;
     67    float m_finalRoundingWidth;
    6768
    6869#if ENABLE(SVG_FONTS)
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp

    r88478 r89733  
    5050}
    5151
     52static inline CGFloat ceilCGFloat(CGFloat f)
     53{
     54    if (sizeof(CGFloat) == sizeof(float))
     55        return ceilf(static_cast<float>(f));
     56    return static_cast<CGFloat>(ceil(f));
     57}
     58
    5259ComplexTextController::ComplexTextController(const Font* font, const TextRun& run, bool mayUseNaturalWritingDirection, HashSet<const SimpleFontData*>* fallbackFonts, bool forTextEmphasis)
    5360    : m_font(*font)
     
    6370    , m_glyphInCurrentRun(0)
    6471    , m_characterInCurrentGlyph(0)
     72    , m_finalRoundingWidth(0)
    6573    , m_expansion(run.expansion())
    6674    , m_leadingExpansion(0)
     
    7179    , m_minGlyphBoundingBoxY(numeric_limits<float>::max())
    7280    , m_maxGlyphBoundingBoxY(numeric_limits<float>::min())
     81    , m_lastRoundingGlyph(0)
    7382{
    7483    if (!m_expansion)
     
    401410        m_glyphInCurrentRun = 0;
    402411    }
     412    if (!ltr && m_numGlyphsSoFar == m_adjustedAdvances.size())
     413        m_runWidthSoFar += m_finalRoundingWidth;
    403414}
    404415
     
    418429        bool lastRun = r + 1 == runCount;
    419430        bool roundsAdvances = !m_font.isPrinterFont() && fontData->platformData().roundsGlyphAdvances();
     431        CGFloat roundedSpaceWidth = roundCGFloat(fontData->spaceWidth());
    420432        const UChar* cp = complexTextRun.characters();
    421433        CGPoint glyphOrigin = CGPointZero;
     
    459471
    460472            advance.width += fontData->syntheticBoldOffset();
     473
     474 
     475            // We special case spaces in two ways when applying word rounding.
     476            // First, we round spaces to an adjusted width in all fonts.
     477            // Second, in fixed-pitch fonts we ensure that all glyphs that
     478            // match the width of the space glyph have the same width as the space glyph.
     479            if (m_run.applyWordRounding() && roundedAdvanceWidth == roundedSpaceWidth && (fontData->pitch() == FixedPitch || glyph == fontData->spaceGlyph()))
     480                advance.width = fontData->adjustedSpaceWidth();
    461481
    462482            if (hasExtraSpacing) {
     
    494514            }
    495515
    496             widthSinceLastCommit += advance.width;
     516            // Apply rounding hacks if needed.
     517            // We adjust the width of the last character of a "word" to ensure an integer width.
     518            // Force characters that are used to determine word boundaries for the rounding hack
     519            // to be integer width, so the following words will start on an integer boundary.
     520            if (m_run.applyWordRounding() && Font::isRoundingHackCharacter(ch))
     521                advance.width = ceilCGFloat(advance.width);
     522
     523            // Check to see if the next character is a "rounding hack character", if so, adjust the
     524            // width so that the total run width will be on an integer boundary.
     525            if ((m_run.applyWordRounding() && !lastGlyph && Font::isRoundingHackCharacter(nextCh)) || (m_run.applyRunRounding() && lastGlyph)) {
     526                CGFloat totalWidth = widthSinceLastCommit + advance.width;
     527                widthSinceLastCommit = ceilCGFloat(totalWidth);
     528                CGFloat extraWidth = widthSinceLastCommit - totalWidth;
     529                if (m_run.ltr())
     530                    advance.width += extraWidth;
     531                else {
     532                    if (m_lastRoundingGlyph)
     533                        m_adjustedAdvances[m_lastRoundingGlyph - 1].width += extraWidth;
     534                    else
     535                        m_finalRoundingWidth = extraWidth;
     536                    m_lastRoundingGlyph = m_adjustedAdvances.size() + 1;
     537                }
     538                m_totalWidth += widthSinceLastCommit;
     539                widthSinceLastCommit = 0;
     540            } else
     541                widthSinceLastCommit += advance.width;
    497542
    498543            // FIXME: Combining marks should receive a text emphasis mark if they are combine with a space.
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h

    r85507 r89733  
    7373    float totalWidth() const { return m_totalWidth; }
    7474
     75    float finalRoundingWidth() const { return m_finalRoundingWidth; }
     76
    7577    float minGlyphBoundingBoxX() const { return m_minGlyphBoundingBoxX; }
    7678    float maxGlyphBoundingBoxX() const { return m_maxGlyphBoundingBoxX; }
     
    184186    unsigned m_glyphInCurrentRun;
    185187    unsigned m_characterInCurrentGlyph;
     188    float m_finalRoundingWidth;
    186189    float m_expansion;
    187190    float m_expansionPerOpportunity;
     
    195198    float m_minGlyphBoundingBoxY;
    196199    float m_maxGlyphBoundingBoxY;
     200
     201    unsigned m_lastRoundingGlyph;
    197202};
    198203
  • trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp

    r88613 r89733  
    7272
    7373    if (run.rtl()) {
    74         initialAdvance = controller.totalWidth() - afterWidth;
     74        initialAdvance = controller.totalWidth() + controller.finalRoundingWidth() - afterWidth;
    7575        for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
    7676            glyphBuffer.swap(i, end);
  • trunk/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp

    r86401 r89733  
    114114        return;
    115115    m_spaceGlyph = 0;
     116    m_adjustedSpaceWidth = m_spaceWidth;
    116117    determinePitch();
    117118    m_missingGlyphData.fontData = this;
  • trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp

    r89039 r89733  
    706706        stringByAdoptingFileSystemRepresentation(systemBasename, string);
    707707    } else if (filenames.size() > 1)
    708         return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font);
    709 
    710     return StringTruncator::centerTruncate(string, width, font);
    711 }
    712 
    713 }
     708        return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font, StringTruncator::EnableRoundingHacks);
     709
     710    return StringTruncator::centerTruncate(string, width, font, StringTruncator::EnableRoundingHacks);
     711}
     712
     713}
  • trunk/Source/WebCore/platform/mac/DragImageMac.mm

    r88691 r89733  
    162162        Font webCoreFont(FontPlatformData(font, [font pointSize]), ![[NSGraphicsContext currentContext] isDrawingToScreen]);
    163163        TextRun run(buffer.data(), length);
     164        run.disableRoundingHacks();
    164165        return webCoreFont.width(run);
    165166    }
     
    202203        Font webCoreFont(FontPlatformData(font, [font pointSize]), ![nsContext isDrawingToScreen], Antialiased);
    203204        TextRun run(buffer.data(), length);
     205        run.disableRoundingHacks();
    204206
    205207        CGFloat red;
  • trunk/Source/WebCore/platform/win/DragImageWin.cpp

    r89425 r89733  
    213213    if (drawURLString) {
    214214        if (clipURLString)
    215             urlString = StringTruncator::rightTruncate(urlString, imageSize.width() - (DragLabelBorderX * 2.0f), *urlFont);
     215            urlString = StringTruncator::rightTruncate(urlString, imageSize.width() - (DragLabelBorderX * 2.0f), *urlFont, StringTruncator::EnableRoundingHacks);
    216216        IntPoint textPos(DragLabelBorderX, imageSize.height() - (LabelBorderYOffset + urlFont->fontMetrics().descent()));
    217217        WebCoreDrawDoubledTextAtPoint(context, urlString, textPos, *urlFont, topColor, bottomColor);
     
    219219   
    220220    if (clipLabelString)
    221         label = StringTruncator::rightTruncate(label, imageSize.width() - (DragLabelBorderX * 2.0f), *labelFont);
     221        label = StringTruncator::rightTruncate(label, imageSize.width() - (DragLabelBorderX * 2.0f), *labelFont, StringTruncator::EnableRoundingHacks);
    222222
    223223    IntPoint textPos(DragLabelBorderX, DragLabelBorderY + labelFont->pixelSize());
  • trunk/Source/WebCore/platform/win/WebCoreTextRenderer.cpp

    r89425 r89733  
    107107    FontCachePurgePreventer fontCachePurgePreventer;
    108108
    109     return StringTruncator::width(text, font);
     109    return StringTruncator::width(text, font, StringTruncator::EnableRoundingHacks);
    110110}
    111111
  • trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp

    r89535 r89733  
    9797        const Font& font = style()->font();
    9898        TextRun textRun = constructTextRun(this, font, displayedFilename, style(), TextRun::AllowTrailingExpansion, RespectDirection | RespectDirectionOverride);
     99        textRun.disableRoundingHacks();
    99100
    100101        // Determine where the filename should be placed
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r88982 r89733  
    123123            if (!text.isEmpty()) {
    124124                // FIXME: Why is this always LTR? Can't text direction affect the width?
    125                 float textWidth = itemFont.width(constructTextRun(this, itemFont, text, style(), TextRun::AllowTrailingExpansion));
     125                TextRun textRun = constructTextRun(this, itemFont, text, style(), TextRun::AllowTrailingExpansion);
     126                textRun.disableRoundingHacks();
     127                float textWidth = itemFont.width(textRun);
    126128                width = max(width, textWidth);
    127129            }
     
    396398    unsigned length = itemText.length();
    397399    const UChar* string = itemText.characters();
    398     TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, itemStyle->direction(), itemStyle->unicodeBidi() == Override);
     400    TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, itemStyle->direction(), itemStyle->unicodeBidi() == Override, TextRun::NoRounding);
    399401    Font itemFont = style()->font();
    400402    IntRect r = itemBoundingBoxRect(paintOffset, listIndex);
  • trunk/Source/WebCore/rendering/RenderTextControl.cpp

    r89505 r89733  
    531531    const UChar ch = '0';
    532532    const Font& font = style()->font();
    533     return font.width(constructTextRun(this, font, String(&ch, 1), style(), TextRun::AllowTrailingExpansion));
     533    TextRun textRun = constructTextRun(this, font, String(&ch, 1), style(), TextRun::AllowTrailingExpansion);
     534    textRun.disableRoundingHacks();
     535    return font.width(textRun);
    534536}
    535537
  • trunk/Source/WebCore/rendering/RenderTheme.cpp

    r89039 r89733  
    11061106        string = pathGetFileName(filenames[0]);
    11071107    else
    1108         return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font);
    1109 
    1110     return StringTruncator::centerTruncate(string, width, font);
    1111 }
    1112 
     1108        return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font, StringTruncator::EnableRoundingHacks);
     1109
     1110    return StringTruncator::centerTruncate(string, width, font, StringTruncator::EnableRoundingHacks);
     1111}
    11131112
    11141113} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderThemeMac.mm

    r89048 r89733  
    20632063        strToTruncate = [[NSFileManager defaultManager] displayNameAtPath:(filenames[0])];
    20642064    else
    2065         return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font);
    2066 
    2067     return StringTruncator::centerTruncate(strToTruncate, width, font);
     2065        return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font, StringTruncator::EnableRoundingHacks);
     2066
     2067    return StringTruncator::centerTruncate(strToTruncate, width, font, StringTruncator::EnableRoundingHacks);
    20682068}
    20692069
  • trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp

    r89710 r89733  
    431431        run.setRenderingContext(SVGTextRunRenderingContext::create(text));
    432432
     433    run.disableRoundingHacks();
     434
    433435    // We handle letter & word spacing ourselves.
    434436    run.disableSpacing();
  • trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp

    r89732 r89733  
    8888        run.setRenderingContext(SVGTextRunRenderingContext::create(text));
    8989
     90    run.disableRoundingHacks();
     91
    9092    // We handle letter & word spacing ourselves.
    9193    run.disableSpacing();
  • trunk/Source/WebKit/mac/ChangeLog

    r89682 r89733  
     12011-06-24  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Add an option to enable legacy rounding hacks
     6        https://bugs.webkit.org/show_bug.cgi?id=63363
     7
     8        * Misc/WebKitNSStringExtras.mm:
     9        (-[NSString _web_drawAtPoint:font:textColor:allowingFontSmoothing:]):
     10        Disabled rounding hacks.
     11        (-[NSString _web_widthWithFont:]): Ditto.
     12        * WebView/WebView.mm:
     13        (+[WebView _setAllowsRoundingHacks:]): Added this setter.
     14        * WebView/WebViewPrivate.h:
     15
    1162011-06-24  Dominic Cooney  <dominicc@chromium.org>
    217
  • trunk/Source/WebKit/mac/Misc/WebKitNSStringExtras.mm

    r88260 r89733  
    9595        Font webCoreFont(FontPlatformData(font, [font pointSize]), ![nsContext isDrawingToScreen], fontSmoothingIsAllowed ? AutoSmoothing : Antialiased);
    9696        TextRun run(buffer.data(), length);
     97        run.disableRoundingHacks();
    9798
    9899        CGFloat red;
     
    142143        Font webCoreFont(FontPlatformData(font, [font pointSize]), ![[NSGraphicsContext currentContext] isDrawingToScreen]);
    143144        TextRun run(buffer.data(), length);
     145        run.disableRoundingHacks();
    144146        return webCoreFont.width(run);
    145147    }
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r89669 r89733  
    10671067}
    10681068
     1069+ (void)_setAllowsRoundingHacks:(BOOL)allowsRoundingHacks
     1070{
     1071    TextRun::setAllowsRoundingHacks(allowsRoundingHacks);
     1072}
     1073
    10691074+ (BOOL)canCloseAllWebViews
    10701075{
  • trunk/Source/WebKit/mac/WebView/WebViewPrivate.h

    r87962 r89733  
    342342+ (void)_setAlwaysUseATSU:(BOOL)f;
    343343
     344+ (void)_setAllowsRoundingHacks:(BOOL)allowsRoundingHacks;
     345
    344346- (NSCachedURLResponse *)_cachedResponseForURL:(NSURL *)URL;
    345347
  • trunk/Source/WebKit/win/ChangeLog

    r89669 r89733  
     12011-06-24  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Add an option to enable legacy rounding hacks
     6        https://bugs.webkit.org/show_bug.cgi?id=63363
     7
     8        * WebKitGraphics.cpp:
     9        (CenterTruncateStringToWidth): Enabled rounding hacks in the string truncator.
     10        (RightTruncateStringToWidth): Ditto.
     11
    1122011-06-24  Yuta Kitamura  <yutak@chromium.org>
    213
  • trunk/Source/WebKit/win/WebKitGraphics.cpp

    r88260 r89733  
    151151    FontCachePurgePreventer fontCachePurgePreventer;
    152152
    153     String result = StringTruncator::centerTruncate(String(text, length), width, makeFont(description));
     153    String result = StringTruncator::centerTruncate(String(text, length), width, makeFont(description), StringTruncator::EnableRoundingHacks);
    154154    memcpy(buffer, result.characters(), result.length() * sizeof(UChar));
    155155    buffer[result.length()] = '\0';
     
    163163    FontCachePurgePreventer fontCachePurgePreventer;
    164164
    165     String result = StringTruncator::rightTruncate(String(text, length), width, makeFont(description));
     165    String result = StringTruncator::rightTruncate(String(text, length), width, makeFont(description), StringTruncator::EnableRoundingHacks);
    166166    memcpy(buffer, result.characters(), result.length() * sizeof(UChar));
    167167    buffer[result.length()] = '\0';
  • trunk/Tools/ChangeLog

    r89702 r89733  
     12011-06-24  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Add an option to enable legacy rounding hacks
     6        https://bugs.webkit.org/show_bug.cgi?id=63363
     7
     8        Added layoutTestController.allowRoundingHacks() and implemented it
     9        on OS X.
     10
     11        * DumpRenderTree/LayoutTestController.cpp:
     12        (allowRoundingHacksCallback):
     13        (LayoutTestController::staticFunctions):
     14        * DumpRenderTree/LayoutTestController.h:
     15        * DumpRenderTree/chromium/LayoutTestController.cpp:
     16        (LayoutTestController::allowRoundingHacks):
     17        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
     18        (LayoutTestController::allowRoundingHacks):
     19        * DumpRenderTree/mac/DumpRenderTree.mm:
     20        (resetWebViewToConsistentStateBeforeTesting):
     21        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
     22        (LayoutTestController::allowRoundingHacks):
     23        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
     24        (LayoutTestController::allowRoundingHacks):
     25        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
     26        (LayoutTestController::allowRoundingHacks):
     27        * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
     28        (LayoutTestController::allowRoundingHacks):
     29
    1302011-06-24  Adam Roben  <aroben@apple.com>
    231
  • trunk/Tools/DumpRenderTree/LayoutTestController.cpp

    r89682 r89733  
    21222122
    21232123    LayoutTestController::setSerializeHTTPLoads(serialize);
     2124    return JSValueMakeUndefined(context);
     2125}
     2126
     2127static JSValueRef allowRoundingHacksCallback(JSContextRef context, JSObjectRef thisObject, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     2128{
     2129    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
     2130
     2131    controller->allowRoundingHacks();
    21242132    return JSValueMakeUndefined(context);
    21252133}
     
    23972405        { "setShouldPaintBrokenImage", setShouldPaintBrokenImageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    23982406        { "setTextDirection", setTextDirectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     2407        { "allowRoundingHacks", allowRoundingHacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    23992408        { 0, 0, 0 }
    24002409    };
  • trunk/Tools/DumpRenderTree/LayoutTestController.h

    r89682 r89733  
    303303    void evaluateInWebInspector(long callId, JSStringRef script);
    304304    void evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script);
     305    void allowRoundingHacks();
    305306
    306307    void setPOSIXLocale(JSStringRef locale);
  • trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp

    r89682 r89733  
    18551855    setShouldDumpAsAudio(true);
    18561856}
     1857
     1858void LayoutTestController::allowRoundingHacks()
     1859{
     1860}
  • trunk/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp

    r89682 r89733  
    978978    // FIXME: Implement.
    979979}
     980
     981void LayoutTestController::allowRoundingHacks()
     982{
     983}
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r85083 r89733  
    10601060    [WebView _setUsesTestModeFocusRingColor:YES];
    10611061    [WebView _resetOriginAccessWhitelists];
     1062    [WebView _setAllowsRoundingHacks:NO];
    10621063
    10631064    [[MockGeolocationProvider shared] stopTimer];
  • trunk/Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm

    r89682 r89733  
    915915}
    916916
     917void LayoutTestController::allowRoundingHacks()
     918{
     919    [WebView _setAllowsRoundingHacks:YES];
     920}
     921
    917922@interface APITestDelegate : NSObject
    918923{
  • trunk/Tools/DumpRenderTree/qt/LayoutTestControllerQt.cpp

    r89682 r89733  
    950950}
    951951
     952void LayoutTestController::allowRoundingHacks()
     953{
     954}
     955
    952956const unsigned LayoutTestController::maxViewWidth = 800;
    953957const unsigned LayoutTestController::maxViewHeight = 600;
  • trunk/Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp

    r89682 r89733  
    15271527    // FIXME: Implement.
    15281528}
     1529
     1530void LayoutTestController::allowRoundingHacks()
     1531{
     1532}
  • trunk/Tools/DumpRenderTree/wx/LayoutTestControllerWx.cpp

    r89682 r89733  
    636636    // FIXME: Implement.
    637637}
     638
     639void LayoutTestController::allowRoundingHacks()
     640{
     641}
Note: See TracChangeset for help on using the changeset viewer.