Changeset 171882 in webkit


Ignore:
Timestamp:
Jul 31, 2014 12:50:45 PM (10 years ago)
Author:
abucur@adobe.com
Message:

REGRESSION: Search highlight is broken in RTL multicolumn content
https://bugs.webkit.org/show_bug.cgi?id=135452

Reviewed by Simon Fraser.

Source/WebCore:
The offsets for elements inside RTL multi-column elements are incorrectly computed because
the columns don't calculate their left position according to the writing direction.

The patch extracts the column position computation in two helper functions (for top and left)
so they can be used when needed in different parts of the code. In our case, the |columnLogicalLeft|
function should be used inside |columnTranslationForOffset|.

Test: fast/multicol/content-bounding-box-rtl.html

  • rendering/RenderMultiColumnSet.cpp:

(WebCore::RenderMultiColumnSet::columnLogicalLeft): Return the logical left of a column relative to the set.
(WebCore::RenderMultiColumnSet::columnLogicalTop): Return the logical top of a column relative to the set.
(WebCore::RenderMultiColumnSet::columnRectAt): Split the code between columnLogicalLeft and columnLogicalTop.
(WebCore::RenderMultiColumnSet::collectLayerFragments): Make code clearer by adding a new line.
(WebCore::RenderMultiColumnSet::columnTranslationForOffset): Use columnLogicalLeft instead of duplicating logic.

  • rendering/RenderMultiColumnSet.h:

LayoutTests:
A test that verifies the bounding boxes for content inside a RTL multi-column element are correctly computed:

  • for static elements
  • for relative positioned elements
  • for absolutely positioned elements
  • fast/multicol/content-bounding-box-rtl-expected.txt: Added.
  • fast/multicol/content-bounding-box-rtl.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r171865 r171882  
     12014-07-31  Andrei Bucur  <abucur@adobe.com>
     2
     3        REGRESSION: Search highlight is broken in RTL multicolumn content
     4        https://bugs.webkit.org/show_bug.cgi?id=135452
     5
     6        Reviewed by Simon Fraser.
     7
     8        A test that verifies the bounding boxes for content inside a RTL multi-column element are correctly computed:
     9        - for static elements
     10        - for relative positioned elements
     11        - for absolutely positioned elements
     12
     13        * fast/multicol/content-bounding-box-rtl-expected.txt: Added.
     14        * fast/multicol/content-bounding-box-rtl.html: Added.
     15
    1162014-07-31  Bear Travis  <betravis@adobe.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r171871 r171882  
     12014-07-31  Andrei Bucur  <abucur@adobe.com>
     2
     3        REGRESSION: Search highlight is broken in RTL multicolumn content
     4        https://bugs.webkit.org/show_bug.cgi?id=135452
     5
     6        Reviewed by Simon Fraser.
     7
     8        The offsets for elements inside RTL multi-column elements are incorrectly computed because
     9        the columns don't calculate their left position according to the writing direction.
     10
     11        The patch extracts the column position computation in two helper functions (for top and left)
     12        so they can be used when needed in different parts of the code. In our case, the |columnLogicalLeft|
     13        function should be used inside |columnTranslationForOffset|.
     14
     15        Test: fast/multicol/content-bounding-box-rtl.html
     16
     17        * rendering/RenderMultiColumnSet.cpp:
     18        (WebCore::RenderMultiColumnSet::columnLogicalLeft): Return the logical left of a column relative to the set.
     19        (WebCore::RenderMultiColumnSet::columnLogicalTop): Return the logical top of a column relative to the set.
     20        (WebCore::RenderMultiColumnSet::columnRectAt): Split the code between columnLogicalLeft and columnLogicalTop.
     21        (WebCore::RenderMultiColumnSet::collectLayerFragments): Make code clearer by adding a new line.
     22        (WebCore::RenderMultiColumnSet::columnTranslationForOffset): Use columnLogicalLeft instead of duplicating logic.
     23        * rendering/RenderMultiColumnSet.h:
     24
    1252014-07-31  Martin Hodovan  <mhodovan.u-szeged@partner.samsung.com>
    226
  • trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp

    r170774 r171882  
    445445}
    446446
    447 LayoutRect RenderMultiColumnSet::columnRectAt(unsigned index) const
     447LayoutUnit RenderMultiColumnSet::columnLogicalLeft(unsigned index) const
    448448{
    449449    LayoutUnit colLogicalWidth = computedColumnWidth();
    450     LayoutUnit colLogicalHeight = computedColumnHeight();
    451     LayoutUnit colLogicalTop = borderAndPaddingBefore();
    452450    LayoutUnit colLogicalLeft = borderAndPaddingLogicalLeft();
    453451    LayoutUnit colGap = columnGap();
    454    
     452
    455453    bool progressionReversed = multiColumnFlowThread()->progressionIsReversed();
    456454    bool progressionInline = multiColumnFlowThread()->progressionIsInline();
    457    
     455
    458456    if (progressionInline) {
    459457        if (style().isLeftToRightDirection() ^ progressionReversed)
     
    461459        else
    462460            colLogicalLeft += contentLogicalWidth() - colLogicalWidth - index * (colLogicalWidth + colGap);
    463     } else {
     461    }
     462
     463    return colLogicalLeft;
     464}
     465
     466LayoutUnit RenderMultiColumnSet::columnLogicalTop(unsigned index) const
     467{
     468    LayoutUnit colLogicalHeight = computedColumnHeight();
     469    LayoutUnit colLogicalTop = borderAndPaddingBefore();
     470    LayoutUnit colGap = columnGap();
     471
     472    bool progressionReversed = multiColumnFlowThread()->progressionIsReversed();
     473    bool progressionInline = multiColumnFlowThread()->progressionIsInline();
     474
     475    if (!progressionInline) {
    464476        if (!progressionReversed)
    465477            colLogicalTop += index * (colLogicalHeight + colGap);
     
    467479            colLogicalTop += contentLogicalHeight() - colLogicalHeight - index * (colLogicalHeight + colGap);
    468480    }
    469    
     481
     482    return colLogicalTop;
     483}
     484
     485LayoutRect RenderMultiColumnSet::columnRectAt(unsigned index) const
     486{
     487    LayoutUnit colLogicalWidth = computedColumnWidth();
     488    LayoutUnit colLogicalHeight = computedColumnHeight();
     489
    470490    if (isHorizontalWritingMode())
    471         return LayoutRect(colLogicalLeft, colLogicalTop, colLogicalWidth, colLogicalHeight);
    472     return LayoutRect(colLogicalTop, colLogicalLeft, colLogicalHeight, colLogicalWidth);
     491        return LayoutRect(columnLogicalLeft(index), columnLogicalTop(index), colLogicalWidth, colLogicalHeight);
     492    return LayoutRect(columnLogicalTop(index), columnLogicalLeft(index), colLogicalHeight, colLogicalWidth);
    473493}
    474494
     
    767787        }
    768788        translationOffset.setWidth(inlineOffset);
     789
    769790        LayoutUnit blockOffset = initialBlockOffset + logicalTop() - flowThread()->logicalTop() + (isHorizontalWritingMode() ? -flowThreadPortion.y() : -flowThreadPortion.x());
    770791        if (!progressionIsInline) {
     
    808829   
    809830    LayoutUnit colGap = columnGap();
    810     LayoutUnit colLogicalWidth = computedColumnWidth();
    811831   
    812832    LayoutRect flowThreadPortion = flowThreadPortionRectAt(startColumn);
     
    818838    LayoutUnit initialBlockOffset = initialBlockOffsetForPainting();
    819839   
    820     LayoutUnit inlineOffset = progressionIsInline ? startColumn * (colLogicalWidth + colGap) : LayoutUnit();
    821    
    822     bool leftToRight = style().isLeftToRightDirection() ^ progressionReversed;
    823     if (!leftToRight) {
    824         inlineOffset = -inlineOffset;
    825         if (progressionReversed)
    826             inlineOffset += contentLogicalWidth() - colLogicalWidth;
    827     }
    828     translationOffset.setX(inlineOffset);
     840    translationOffset.setX(columnLogicalLeft(startColumn));
     841
    829842    LayoutUnit blockOffset = initialBlockOffset - (isHorizontalWritingMode() ? flowThreadPortion.y() : flowThreadPortion.x());
    830843    if (!progressionIsInline) {
  • trunk/Source/WebCore/rendering/RenderMultiColumnSet.h

    r168113 r171882  
    161161    LayoutUnit columnGap() const;
    162162
     163    LayoutUnit columnLogicalLeft(unsigned) const;
     164    LayoutUnit columnLogicalTop(unsigned) const;
     165
    163166    LayoutRect flowThreadPortionRectAt(unsigned index) const;
    164167    LayoutRect flowThreadPortionOverflowRect(const LayoutRect& flowThreadPortion, unsigned index, unsigned colCount, LayoutUnit colGap);
Note: See TracChangeset for help on using the changeset viewer.