Changeset 56319 in webkit


Ignore:
Timestamp:
Mar 21, 2010 3:19:27 PM (14 years ago)
Author:
ddkilzer@apple.com
Message:

<http://webkit.org/b/14858> <col> width ignored when not tied to a single cell

Patch by Dmitry Gorbik <socket.h@gmail.com> on 2010-03-21
Reviewed by David Kilzer.

Fixed width calculation for cells with span when <col> is defined.

WebCore:

Test: fast/table/col-width-span-expand.html

  • rendering/RenderTableCell.cpp:

(WebCore::RenderTableCell::styleOrColWidth): Added the calculation of cell width
in case of <col> defined and span > 1.

LayoutTests:

  • fast/table/col-width-span-expand-expected.txt: Added.
  • fast/table/col-width-span-expand.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r56316 r56319  
     12010-03-21  Dmitry Gorbik  <socket.h@gmail.com>
     2
     3        <http://webkit.org/b/14858> <col> width ignored when not tied to a single cell
     4
     5        Reviewed by David Kilzer.
     6
     7        Fixed width calculation for cells with span when <col> is defined.
     8
     9        * fast/table/col-width-span-expand-expected.txt: Added.
     10        * fast/table/col-width-span-expand.html: Added.
     11
    1122010-03-20  Martin Robinson  <mrobinson@webkit.org>
    213
  • trunk/WebCore/ChangeLog

    r56311 r56319  
     12010-03-21  Dmitry Gorbik  <socket.h@gmail.com>
     2
     3        <http://webkit.org/b/14858> <col> width ignored when not tied to a single cell
     4
     5        Reviewed by David Kilzer.
     6
     7        Fixed width calculation for cells with span when <col> is defined.
     8
     9        Test: fast/table/col-width-span-expand.html
     10
     11        * rendering/RenderTableCell.cpp:
     12        (WebCore::RenderTableCell::styleOrColWidth): Added the calculation of cell width
     13        in case of <col> defined and span > 1.
     14
    1152010-03-20  Antonio Gomes  <tonikitoo@webkit.org>
    216
  • trunk/WebCore/rendering/RenderTable.cpp

    r54311 r56319  
    582582}
    583583
     584RenderTableCol* RenderTable::nextColElement(RenderTableCol* current) const
     585{
     586    RenderObject* next = current->firstChild();
     587    if (!next)
     588        next = current->nextSibling();
     589    if (!next && current->parent()->isTableCol())
     590        next = current->parent()->nextSibling();
     591
     592    while (next) {
     593        if (next->isTableCol())
     594            return toRenderTableCol(next);
     595        if (next != m_caption)
     596            return 0;
     597        next = next->nextSibling();
     598    }
     599   
     600    return 0;
     601}
     602
    584603RenderTableCol* RenderTable::colElement(int col, bool* startEdge, bool* endEdge) const
    585604{
     
    590609
    591610    while (child) {
    592         if (child->isTableCol()) {
    593             RenderTableCol* colElem = toRenderTableCol(child);
    594             int span = colElem->span();
    595             if (!colElem->firstChild()) {
    596                 int startCol = cCol;
    597                 int endCol = cCol + span - 1;
    598                 cCol += span;
    599                 if (cCol > col) {
    600                     if (startEdge)
    601                         *startEdge = startCol == col;
    602                     if (endEdge)
    603                         *endEdge = endCol == col;
    604                     return colElem;
    605                 }
     611        if (child->isTableCol())
     612            break;
     613        if (child != m_caption)
     614            return 0;
     615        child = child->nextSibling();
     616    }
     617    if (!child)
     618        return 0;
     619
     620    RenderTableCol* colElem = toRenderTableCol(child);
     621    while (colElem) {
     622        int span = colElem->span();
     623        if (!colElem->firstChild()) {
     624            int startCol = cCol;
     625            int endCol = cCol + span - 1;
     626            cCol += span;
     627            if (cCol > col) {
     628                if (startEdge)
     629                    *startEdge = startCol == col;
     630                if (endEdge)
     631                    *endEdge = endCol == col;
     632                return colElem;
    606633            }
    607 
    608             RenderObject* next = child->firstChild();
    609             if (!next)
    610                 next = child->nextSibling();
    611             if (!next && child->parent()->isTableCol())
    612                 next = child->parent()->nextSibling();
    613             child = next;
    614         } else if (child == m_caption)
    615             child = child->nextSibling();
    616         else
    617             break;
     634        }
     635        colElem = nextColElement(colElem);
    618636    }
    619637
  • trunk/WebCore/rendering/RenderTable.h

    r46647 r56319  
    114114
    115115    RenderTableCol* colElement(int col, bool* startEdge = 0, bool* endEdge = 0) const;
     116    RenderTableCol* nextColElement(RenderTableCol* current) const;
    116117
    117118    bool needsSectionRecalc() const { return m_needsSectionRecalc; }
  • trunk/WebCore/rendering/RenderTableCell.cpp

    r54784 r56319  
    8484{
    8585    Length w = style()->width();
    86     if (colSpan() > 1 || !w.isAuto())
     86    if (!w.isAuto())
    8787        return w;
     88
    8889    RenderTableCol* tableCol = table()->colElement(col());
     90
    8991    if (tableCol) {
    90         w = tableCol->style()->width();
    91        
     92        int colSpanCount = colSpan();
     93
     94        Length colWidthSum = Length(0, Fixed);
     95        for (int i = 1; i <= colSpanCount; i++) {
     96            Length colWidth = tableCol->style()->width();
     97
     98            // Percentage value should be returned only for colSpan == 1.
     99            // Otherwise we return original width for the cell.
     100            if (!colWidth.isFixed()) {
     101                if (colSpanCount > 1)
     102                    return w;
     103                return colWidth;
     104            }
     105
     106            colWidthSum = Length(colWidthSum.value() + colWidth.value(), Fixed);
     107
     108            tableCol = table()->nextColElement(tableCol);
     109            // If no next <col> tag found for the span we just return what we have for now.
     110            if (!tableCol)
     111                break;
     112        }
     113
    92114        // Column widths specified on <col> apply to the border box of the cell.
    93115        // Percentages don't need to be handled since they're always treated this way (even when specified on the cells).
    94116        // See Bugzilla bug 8126 for details.
    95         if (w.isFixed() && w.value() > 0)
    96             w = Length(max(0, w.value() - borderLeft() - borderRight() - paddingLeft() - paddingRight()), Fixed);
    97     }
     117        if (colWidthSum.isFixed() && colWidthSum.value() > 0)
     118            colWidthSum = Length(max(0, colWidthSum.value() - borderLeft() - borderRight() - paddingLeft() - paddingRight()), Fixed);
     119        return colWidthSum;
     120    }
     121
    98122    return w;
    99123}
Note: See TracChangeset for help on using the changeset viewer.