Changeset 162791 in webkit


Ignore:
Timestamp:
Jan 25, 2014 5:27:28 PM (10 years ago)
Author:
Alan Bujtas
Message:

Subpixel layout: RenderInline is not centered when child RenderTextControl's innerTextRenderer needs bias centering.
https://bugs.webkit.org/show_bug.cgi?id=125659

Source/WebCore:

Reviewed by Andreas Kling

layoutMod(logicalHeightDiff, 2) fails to bias round when subpixel layout is enabled. It sets
the denominator value to 2, which returns incorrect modulo result.
(subpixel off: 3px % 2 = 1 vs subpixel on: (3px * 64) -> 192 % 2 = 0)

Covered by existing tests.

  • platform/LayoutUnit.h:
  • rendering/RenderSearchField.cpp:

(WebCore::RenderSearchField::centerContainerIfNeeded):

  • rendering/RenderTextControlSingleLine.cpp:

(WebCore::RenderTextControlSingleLine::centerRenderer):
(WebCore::RenderTextControlSingleLine::layout):

  • rendering/RenderTextControlSingleLine.h:

LayoutTests:

Reviewed by Andreas Kling.

layoutMod(logicalHeightDiff, 2) fails to bias round when subpixel layout is enabled. It sets
the denominator value to 2, which returns incorrect modulo result.
(subpixel off: 3px % 2 = 1 vs subpixel on: (3px * 64) -> 192 % 2 = 0)

Covered by existing tests.

  • platform/mac/fast/block/float/032-expected.txt:
  • platform/mac/fast/forms/search-vertical-alignment-expected.png:
  • platform/mac/fast/forms/search-vertical-alignment-expected.txt:
  • platform/mac-mountainlion/fast/forms/search-vertical-alignment-expected.txt:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r162763 r162791  
     12014-01-25  Zalan Bujtas  <zalan@apple.com>
     2
     3        Subpixel layout: RenderInline is not centered when child RenderTextControl's innerTextRenderer needs bias centering.
     4        https://bugs.webkit.org/show_bug.cgi?id=125659
     5
     6        Reviewed by Andreas Kling.
     7
     8        layoutMod(logicalHeightDiff, 2) fails to bias round when subpixel layout is enabled. It sets
     9        the denominator value to 2, which returns incorrect modulo result.
     10        (subpixel off: 3px % 2 = 1 vs subpixel on: (3px * 64) -> 192 % 2 = 0)
     11
     12        Covered by existing tests.
     13
     14        * platform/mac/fast/block/float/032-expected.txt:
     15        * platform/mac/fast/forms/search-vertical-alignment-expected.png:
     16        * platform/mac/fast/forms/search-vertical-alignment-expected.txt:
     17        * platform/mac-mountainlion/fast/forms/search-vertical-alignment-expected.txt:
     18
    1192014-01-25  Antti Koivisto  <antti@apple.com>
    220
  • trunk/LayoutTests/platform/mac-mountainlion/fast/forms/search-vertical-alignment-expected.txt

    r161906 r162791  
    2323      RenderBlock {P} at (0,113) size 784x18
    2424        RenderTextControl {INPUT} at (2,2) size 153x16 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
    25           RenderFlexibleBox {DIV} at (3,1) size 147x14
     25          RenderFlexibleBox {DIV} at (3,1) size 147x13
    2626            RenderBlock {DIV} at (0,1) size 17x11
    2727            RenderBlock {DIV} at (17,0) size 117x13
     
    4949    RenderText {#text} at (0,0) size 24x13
    5050      text run at (0,0) width 24: "Text"
    51 layer at (30,125) size 117x13
     51layer at (30,124) size 117x13
    5252  RenderBlock {DIV} at (0,0) size 117x13
    5353    RenderText {#text} at (0,0) size 24x13
    5454      text run at (0,0) width 24: "Text"
    55 layer at (174,125) size 117x13
    56   RenderBlock {DIV} at (3,1) size 117x14
     55layer at (174,124) size 117x13
     56  RenderBlock {DIV} at (3,1) size 117x13
    5757    RenderText {#text} at (0,0) size 24x13
    5858      text run at (0,0) width 24: "Text"
  • trunk/LayoutTests/platform/mac/fast/block/float/032-expected.txt

    r161884 r162791  
    4747        RenderText {#text} at (0,0) size 0x0
    4848layer at (216,572) size 100x13
    49   RenderBlock {DIV} at (3,46) size 100x14
     49  RenderBlock {DIV} at (3,47) size 100x13
    5050layer at (316,700) size 100x13
    51   RenderBlock {DIV} at (3,46) size 100x14
     51  RenderBlock {DIV} at (3,47) size 100x13
    5252layer at (66,828) size 100x13
    53   RenderBlock {DIV} at (3,46) size 100x14
     53  RenderBlock {DIV} at (3,47) size 100x13
    5454layer at (66,956) size 100x13
    55   RenderBlock {DIV} at (3,46) size 100x14
     55  RenderBlock {DIV} at (3,47) size 100x13
  • trunk/LayoutTests/platform/mac/fast/forms/search-vertical-alignment-expected.txt

    r161884 r162791  
    2323      RenderBlock {P} at (0,113) size 784x18
    2424        RenderTextControl {INPUT} at (2,2) size 176x16 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
    25           RenderFlexibleBox {DIV} at (3,1) size 170x14
     25          RenderFlexibleBox {DIV} at (3,1) size 170x13
    2626            RenderBlock {DIV} at (0,1) size 17x11
    2727            RenderBlock {DIV} at (17,0) size 140x13
     
    4949    RenderText {#text} at (0,0) size 24x13
    5050      text run at (0,0) width 24: "Text"
    51 layer at (30,125) size 139x13
     51layer at (30,124) size 139x13
    5252  RenderBlock {DIV} at (0,0) size 140x13
    5353    RenderText {#text} at (0,0) size 24x13
    5454      text run at (0,0) width 24: "Text"
    55 layer at (196,125) size 139x13
    56   RenderBlock {DIV} at (3,1) size 140x14
     55layer at (196,124) size 139x13
     56  RenderBlock {DIV} at (3,1) size 140x13
    5757    RenderText {#text} at (0,0) size 24x13
    5858      text run at (0,0) width 24: "Text"
  • trunk/Source/WebCore/ChangeLog

    r162789 r162791  
     12014-01-25  Zalan Bujtas  <zalan@apple.com>
     2
     3        Subpixel layout: RenderInline is not centered when child RenderTextControl's innerTextRenderer needs bias centering.
     4        https://bugs.webkit.org/show_bug.cgi?id=125659
     5
     6        Reviewed by Andreas Kling
     7
     8        layoutMod(logicalHeightDiff, 2) fails to bias round when subpixel layout is enabled. It sets
     9        the denominator value to 2, which returns incorrect modulo result.
     10        (subpixel off: 3px % 2 = 1 vs subpixel on: (3px * 64) -> 192 % 2 = 0)
     11
     12        Covered by existing tests.
     13
     14        * platform/LayoutUnit.h:
     15        * rendering/RenderSearchField.cpp:
     16        (WebCore::RenderSearchField::centerContainerIfNeeded):
     17        * rendering/RenderTextControlSingleLine.cpp:
     18        (WebCore::RenderTextControlSingleLine::centerRenderer):
     19        (WebCore::RenderTextControlSingleLine::layout):
     20        * rendering/RenderTextControlSingleLine.h:
     21
    1222014-01-25  Sam Weinig  <sam@webkit.org>
    223
  • trunk/Source/WebCore/platform/LayoutUnit.h

    r162732 r162791  
    959959}
    960960
    961 inline LayoutUnit layoutMod(const LayoutUnit& numerator, const LayoutUnit& denominator)
    962 {
    963     return numerator % denominator;
    964 }
    965 
    966961inline bool isIntegerValue(const LayoutUnit value)
    967962{
  • trunk/Source/WebCore/rendering/RenderSearchField.cpp

    r160236 r162791  
    374374    // A quirk for find-in-page box on Safari Windows.
    375375    // http://webkit.org/b/63157
    376     LayoutUnit logicalHeightDiff = containerRenderer->logicalHeight() - contentLogicalHeight();
    377     containerRenderer->setLogicalTop(containerRenderer->logicalTop() - (logicalHeightDiff / 2 + layoutMod(logicalHeightDiff, 2)));
    378 }
    379 
    380 }
     376    centerRenderer(*containerRenderer);
     377}
     378
     379}
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp

    r160599 r162791  
    9494}
    9595
     96void RenderTextControlSingleLine::centerRenderer(RenderBox& renderer) const
     97{
     98    LayoutUnit logicalHeightDiff = renderer.logicalHeight() - contentLogicalHeight();
     99    float center = logicalHeightDiff / 2;
     100    renderer.setLogicalTop(renderer.logicalTop() - LayoutUnit(round(center)));
     101}
     102
    96103static void setNeedsLayoutOnAncestors(RenderObject* start, RenderObject* ancestor)
    97104{
     
    171178
    172179    // Center the child block in the block progression direction (vertical centering for horizontal text fields).
    173     if (!container && innerTextRenderer && innerTextRenderer->height() != contentLogicalHeight()) {
    174         LayoutUnit logicalHeightDiff = innerTextRenderer->logicalHeight() - contentLogicalHeight();
    175         innerTextRenderer->setLogicalTop(innerTextRenderer->logicalTop() - (logicalHeightDiff / 2 + layoutMod(logicalHeightDiff, 2)));
    176     } else
     180    if (!container && innerTextRenderer && innerTextRenderer->height() != contentLogicalHeight())
     181        centerRenderer(*innerTextRenderer);
     182    else
    177183        centerContainerIfNeeded(containerRenderer);
    178184
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h

    r162198 r162791  
    4444    virtual void centerContainerIfNeeded(RenderBox*) const { }
    4545    virtual LayoutUnit computeLogicalHeightLimit() const;
     46    void centerRenderer(RenderBox& renderer) const;
    4647    HTMLElement* containerElement() const;
    4748    HTMLElement* innerBlockElement() const;
Note: See TracChangeset for help on using the changeset viewer.