Changeset 71251 in webkit


Ignore:
Timestamp:
Nov 3, 2010 11:03:55 AM (13 years ago)
Author:
mitz@apple.com
Message:

Make collapsed borders in tables work with different block flows
https://bugs.webkit.org/show_bug.cgi?id=46191

Reviewed by Dave Hyatt.

No new tests since tables don’t support different block flows yet.

This change still doesn’t support cells whose block flow differs from the table’s.

  • rendering/AutoTableLayout.cpp:

(WebCore::AutoTableLayout::recalcColumn): Updated for the renaming of styleOrColWidth().
(WebCore::AutoTableLayout::calcEffectiveWidth): Ditto.

  • rendering/FixedTableLayout.cpp:

(WebCore::FixedTableLayout::calcWidthArray): Ditto.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::computePreferredLogicalWidths): Ditto.

  • rendering/RenderTableCell.cpp:

(WebCore::RenderTableCell::styleOrColLogicalWidth): Renamed styleOrColWidth() to this and
changed to use logical widths.
(WebCore::RenderTableCell::computePreferredLogicalWidths): Updated for the above rename.
(WebCore::RenderTableCell::updateLogicalWidth): Renamed updateWidth() to this and changed
to set the logical width.
(WebCore::RenderTableCell::collapsedStartBorder): Changed collapsedLeftBorder() into this.
Note that “start” here will refer to the table’s block flow, not the cell’s, once we allow
the two to differ.
(WebCore::RenderTableCell::collapsedEndBorder): Similar.
(WebCore::RenderTableCell::collapsedBeforeBorder): Similar.
(WebCore::RenderTableCell::collapsedAfterBorder): Similar.
(WebCore::RenderTableCell::collapsedLeftBorder): Resolves “left” to a logical side using
the table’s block flow.
(WebCore::RenderTableCell::collapsedRightBorder): Similar.
(WebCore::RenderTableCell::collapsedTopBorder): Similar.
(WebCore::RenderTableCell::collapsedBottomBorder): Similar.
(WebCore::RenderTableCell::borderStart): Use borderHalfStart().
(WebCore::RenderTableCell::borderEnd): Similar.
(WebCore::RenderTableCell::borderBefore): Similar.
(WebCore::RenderTableCell::borderAfter): Similar.
(WebCore::RenderTableCell::borderHalfLeft): Resolves “left” to a logical side using the
table’s block flow.
(WebCore::RenderTableCell::borderHalfRight): Similar.
(WebCore::RenderTableCell::borderHalfTop): Similar.
(WebCore::RenderTableCell::borderHalfBottom): Similar.
(WebCore::RenderTableCell::borderHalfStart): Added. Uses collapsedStartBorder(). Splits odd
widths based on physical side.
(WebCore::RenderTableCell::borderHalfEnd): Similar.
(WebCore::RenderTableCell::borderHalfBefore): Similar.
(WebCore::RenderTableCell::borderHalfAfter): Similar.
(WebCore::RenderTableCell::collectBorderStyles): Use logical methods.
(WebCore::RenderTableCell::paintCollapsedBorder): Updated.

  • rendering/RenderTableCell.h:
  • rendering/RenderTableSection.cpp:

(WebCore::RenderTableSection::setCellWidths): Updated for the renaming of updateWidth().

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::borderBefore): Added.
(WebCore::RenderStyle::borderAfter): Added.
(WebCore::RenderStyle::borderStart): Added.
(WebCore::RenderStyle::borderEnd): Adeed.

  • rendering/style/RenderStyle.h:
Location:
trunk/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r71250 r71251  
     12010-11-03  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        Make collapsed borders in tables work with different block flows
     6        https://bugs.webkit.org/show_bug.cgi?id=46191
     7
     8        No new tests since tables don’t support different block flows yet.
     9
     10        This change still doesn’t support cells whose block flow differs from the table’s.
     11
     12        * rendering/AutoTableLayout.cpp:
     13        (WebCore::AutoTableLayout::recalcColumn): Updated for the renaming of styleOrColWidth().
     14        (WebCore::AutoTableLayout::calcEffectiveWidth): Ditto.
     15        * rendering/FixedTableLayout.cpp:
     16        (WebCore::FixedTableLayout::calcWidthArray): Ditto.
     17        * rendering/RenderBlock.cpp:
     18        (WebCore::RenderBlock::computePreferredLogicalWidths): Ditto.
     19        * rendering/RenderTableCell.cpp:
     20        (WebCore::RenderTableCell::styleOrColLogicalWidth): Renamed styleOrColWidth() to this and
     21        changed to use logical widths.
     22        (WebCore::RenderTableCell::computePreferredLogicalWidths): Updated for the above rename.
     23        (WebCore::RenderTableCell::updateLogicalWidth): Renamed updateWidth() to this and changed
     24        to set the logical width.
     25        (WebCore::RenderTableCell::collapsedStartBorder): Changed collapsedLeftBorder() into this.
     26        Note that “start” here will refer to the table’s block flow, not the cell’s, once we allow
     27        the two to differ.
     28        (WebCore::RenderTableCell::collapsedEndBorder): Similar.
     29        (WebCore::RenderTableCell::collapsedBeforeBorder): Similar.
     30        (WebCore::RenderTableCell::collapsedAfterBorder): Similar.
     31        (WebCore::RenderTableCell::collapsedLeftBorder): Resolves “left” to a logical side using
     32        the table’s block flow.
     33        (WebCore::RenderTableCell::collapsedRightBorder): Similar.
     34        (WebCore::RenderTableCell::collapsedTopBorder): Similar.
     35        (WebCore::RenderTableCell::collapsedBottomBorder): Similar.
     36        (WebCore::RenderTableCell::borderStart): Use borderHalfStart().
     37        (WebCore::RenderTableCell::borderEnd): Similar.
     38        (WebCore::RenderTableCell::borderBefore): Similar.
     39        (WebCore::RenderTableCell::borderAfter): Similar.
     40        (WebCore::RenderTableCell::borderHalfLeft): Resolves “left” to a logical side using the
     41        table’s block flow.
     42        (WebCore::RenderTableCell::borderHalfRight): Similar.
     43        (WebCore::RenderTableCell::borderHalfTop): Similar.
     44        (WebCore::RenderTableCell::borderHalfBottom): Similar.
     45        (WebCore::RenderTableCell::borderHalfStart): Added. Uses collapsedStartBorder(). Splits odd
     46        widths based on physical side.
     47        (WebCore::RenderTableCell::borderHalfEnd): Similar.
     48        (WebCore::RenderTableCell::borderHalfBefore): Similar.
     49        (WebCore::RenderTableCell::borderHalfAfter): Similar.
     50        (WebCore::RenderTableCell::collectBorderStyles): Use logical methods.
     51        (WebCore::RenderTableCell::paintCollapsedBorder): Updated.
     52        * rendering/RenderTableCell.h:
     53        * rendering/RenderTableSection.cpp:
     54        (WebCore::RenderTableSection::setCellWidths): Updated for the renaming of updateWidth().
     55        * rendering/style/RenderStyle.cpp:
     56        (WebCore::RenderStyle::borderBefore): Added.
     57        (WebCore::RenderStyle::borderAfter): Added.
     58        (WebCore::RenderStyle::borderStart): Added.
     59        (WebCore::RenderStyle::borderEnd): Adeed.
     60        * rendering/style/RenderStyle.h:
     61
    1622010-11-03  Dimitri Glazkov  <dglazkov@chromium.org>
    263
  • trunk/WebCore/rendering/AutoTableLayout.cpp

    r71138 r71251  
    8686                    }
    8787
    88                     Length w = cell->styleOrColWidth();
     88                    Length w = cell->styleOrColLogicalWidth();
    8989                    // FIXME: What is this arbitrary value?
    9090                    if (w.rawValue() > 32760)
     
    309309        int span = cell->colSpan();
    310310
    311         Length w = cell->styleOrColWidth();
     311        Length w = cell->styleOrColLogicalWidth();
    312312        if (!w.isRelative() && w.isZero())
    313313            w = Length(); // make it Auto
  • trunk/WebCore/rendering/FixedTableLayout.cpp

    r68276 r71251  
    159159                    cell->computePreferredLogicalWidths();
    160160
    161                 Length w = cell->styleOrColWidth();
     161                Length w = cell->styleOrColLogicalWidth();
    162162                int span = cell->colSpan();
    163163                int effWidth = 0;
  • trunk/WebCore/rendering/RenderBlock.cpp

    r71246 r71251  
    47134713
    47144714        if (isTableCell()) {
    4715             Length w = toRenderTableCell(this)->styleOrColWidth();
     4715            Length w = toRenderTableCell(this)->styleOrColLogicalWidth();
    47164716            if (w.isFixed() && w.value() > 0)
    47174717                m_maxPreferredLogicalWidth = max(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(w.value()));
  • trunk/WebCore/rendering/RenderTableCell.cpp

    r70072 r71251  
    8181}
    8282
    83 Length RenderTableCell::styleOrColWidth() const
    84 {
    85     Length w = style()->width();
     83Length RenderTableCell::styleOrColLogicalWidth() const
     84{
     85    Length w = style()->logicalWidth();
    8686    if (!w.isAuto())
    8787        return w;
    8888
    89     RenderTableCol* tableCol = table()->colElement(col());
    90 
    91     if (tableCol) {
     89    if (RenderTableCol* tableCol = table()->colElement(col())) {
    9290        int colSpanCount = colSpan();
    9391
    9492        Length colWidthSum = Length(0, Fixed);
    9593        for (int i = 1; i <= colSpanCount; i++) {
    96             Length colWidth = tableCol->style()->width();
     94            Length colWidth = tableCol->style()->logicalWidth();
    9795
    9896            // Percentage value should be returned only for colSpan == 1.
     
    116114        // See Bugzilla bug 8126 for details.
    117115        if (colWidthSum.isFixed() && colWidthSum.value() > 0)
    118             colWidthSum = Length(max(0, colWidthSum.value() - borderAndPaddingWidth()), Fixed);
     116            colWidthSum = Length(max(0, colWidthSum.value() - borderAndPaddingLogicalWidth()), Fixed);
    119117        return colWidthSum;
    120118    }
     
    133131    if (node() && style()->autoWrap()) {
    134132        // See if nowrap was set.
    135         Length w = styleOrColWidth();
     133        Length w = styleOrColLogicalWidth();
    136134        String nowrap = static_cast<Element*>(node())->getAttribute(nowrapAttr);
    137135        if (!nowrap.isNull() && w.isFixed())
     
    149147}
    150148
    151 void RenderTableCell::updateWidth(int w)
    152 {
    153     if (w != width()) {
    154         setWidth(w);
    155         setCellWidthChanged(true);
    156     }
     149void RenderTableCell::updateLogicalWidth(int w)
     150{
     151    if (w == logicalWidth())
     152        return;
     153
     154    setLogicalWidth(w);
     155    setCellWidthChanged(true);
    157156}
    158157
     
    385384}
    386385
    387 CollapsedBorderValue RenderTableCell::collapsedLeftBorder(bool rtl) const
    388 {
    389     RenderTable* tableElt = table();
    390     bool leftmostColumn;
    391     if (!rtl)
    392         leftmostColumn = col() == 0;
    393     else {
    394         int effCol = tableElt->colToEffCol(col() + colSpan() - 1);
    395         leftmostColumn = effCol == tableElt->numEffCols() - 1;
    396     }
    397    
    398     // For border left, we need to check, in order of precedence:
    399     // (1) Our left border.
    400     int left = CSSPropertyBorderLeftColor;
    401     int right = CSSPropertyBorderRightColor;
    402     CollapsedBorderValue result(&style()->borderLeft(), style()->visitedDependentColor(left), BCELL);
    403    
    404     // (2) The right border of the cell to the left.
    405     RenderTableCell* prevCell = rtl ? tableElt->cellAfter(this) : tableElt->cellBefore(this);
    406     if (prevCell) {
    407         CollapsedBorderValue prevCellBorder = CollapsedBorderValue(&prevCell->style()->borderRight(), prevCell->style()->visitedDependentColor(right), BCELL);
    408         result = rtl ? chooseBorder(result, prevCellBorder) : chooseBorder(prevCellBorder, result);
    409         if (!result.exists())
    410             return result;
    411     } else if (leftmostColumn) {
    412         // (3) Our row's left border.
    413         result = chooseBorder(result, CollapsedBorderValue(&parent()->style()->borderLeft(), parent()->style()->visitedDependentColor(left), BROW));
     386CollapsedBorderValue RenderTableCell::collapsedStartBorder() const
     387{
     388    RenderTable* table = this->table();
     389    bool isStartColumn = col() == 0;
     390
     391    // For the start border, we need to check, in order of precedence:
     392    // (1) Our start border.
     393    int start = CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderStartColor, table->style()->direction(), table->style()->writingMode());
     394    int end = CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderEndColor, table->style()->direction(), table->style()->writingMode());
     395    CollapsedBorderValue result(&style()->borderStart(), style()->visitedDependentColor(start), BCELL);
     396
     397    // (2) The end border of the preceding cell.
     398    if (RenderTableCell* prevCell = table->cellBefore(this)) {
     399        CollapsedBorderValue prevCellBorder = CollapsedBorderValue(&prevCell->style()->borderEnd(), prevCell->style()->visitedDependentColor(end), BCELL);
     400        result = chooseBorder(prevCellBorder, result);
     401        if (!result.exists())
     402            return result;
     403    } else if (isStartColumn) {
     404        // (3) Our row's start border.
     405        result = chooseBorder(result, CollapsedBorderValue(&parent()->style()->borderStart(), parent()->style()->visitedDependentColor(start), BROW));
    414406        if (!result.exists())
    415407            return result;
    416408       
    417         // (4) Our row group's left border.
    418         result = chooseBorder(result, CollapsedBorderValue(&section()->style()->borderLeft(), section()->style()->visitedDependentColor(left), BROWGROUP));
    419         if (!result.exists())
    420             return result;
    421     }
    422    
    423     // (5) Our column and column group's left borders.
     409        // (4) Our row group's start border.
     410        result = chooseBorder(result, CollapsedBorderValue(&section()->style()->borderStart(), section()->style()->visitedDependentColor(start), BROWGROUP));
     411        if (!result.exists())
     412            return result;
     413    }
     414   
     415    // (5) Our column and column group's start borders.
    424416    bool startColEdge;
    425417    bool endColEdge;
    426     RenderTableCol* colElt = tableElt->colElement(col() + (rtl ? colSpan() - 1 : 0), &startColEdge, &endColEdge);
    427     if (colElt && (!rtl ? startColEdge : endColEdge)) {
    428         result = chooseBorder(result, CollapsedBorderValue(&colElt->style()->borderLeft(), colElt->style()->visitedDependentColor(left), BCOL));
    429         if (!result.exists())
    430             return result;
    431         if (colElt->parent()->isTableCol() && (!rtl ? !colElt->previousSibling() : !colElt->nextSibling())) {
    432             result = chooseBorder(result, CollapsedBorderValue(&colElt->parent()->style()->borderLeft(), colElt->parent()->style()->visitedDependentColor(left), BCOLGROUP));
     418    RenderTableCol* colElt = table->colElement(col(), &startColEdge, &endColEdge);
     419    if (colElt && startColEdge) {
     420        result = chooseBorder(result, CollapsedBorderValue(&colElt->style()->borderStart(), colElt->style()->visitedDependentColor(start), BCOL));
     421        if (!result.exists())
     422            return result;
     423        if (colElt->parent()->isTableCol() && !colElt->previousSibling()) {
     424            result = chooseBorder(result, CollapsedBorderValue(&colElt->parent()->style()->borderStart(), colElt->parent()->style()->visitedDependentColor(start), BCOLGROUP));
    433425            if (!result.exists())
    434426                return result;
     
    436428    }
    437429   
    438     // (6) The right border of the column to the left.
    439     if (!leftmostColumn) {
    440         colElt = tableElt->colElement(col() + (rtl ? colSpan() : -1), &startColEdge, &endColEdge);
    441         if (colElt && (!rtl ? endColEdge : startColEdge)) {
    442             CollapsedBorderValue rightBorder = CollapsedBorderValue(&colElt->style()->borderRight(), colElt->style()->visitedDependentColor(right), BCOL);
    443             result = rtl ? chooseBorder(result, rightBorder) : chooseBorder(rightBorder, result);
     430    // (6) The end border of the preceding column.
     431    if (!isStartColumn) {
     432        colElt = table->colElement(col() -1, &startColEdge, &endColEdge);
     433        if (colElt && endColEdge) {
     434            CollapsedBorderValue endBorder = CollapsedBorderValue(&colElt->style()->borderEnd(), colElt->style()->visitedDependentColor(end), BCOL);
     435            result = chooseBorder(endBorder, result);
    444436            if (!result.exists())
    445437                return result;
    446438        }
    447439    } else {
    448         // (7) The table's left border.
    449         result = chooseBorder(result, CollapsedBorderValue(&tableElt->style()->borderLeft(), tableElt->style()->visitedDependentColor(left), BTABLE));
     440        // (7) The table's start border.
     441        result = chooseBorder(result, CollapsedBorderValue(&table->style()->borderStart(), table->style()->visitedDependentColor(start), BTABLE));
    450442        if (!result.exists())
    451443            return result;
     
    455447}
    456448
    457 CollapsedBorderValue RenderTableCell::collapsedRightBorder(bool rtl) const
    458 {
    459     RenderTable* tableElt = table();
    460     bool rightmostColumn;
    461     if (rtl)
    462         rightmostColumn = col() == 0;
    463     else {
    464         int effCol = tableElt->colToEffCol(col() + colSpan() - 1);
    465         rightmostColumn = effCol == tableElt->numEffCols() - 1;
    466     }
    467    
    468     // For border right, we need to check, in order of precedence:
    469     // (1) Our right border.
    470     int left = CSSPropertyBorderLeftColor;
    471     int right = CSSPropertyBorderRightColor;
    472     CollapsedBorderValue result = CollapsedBorderValue(&style()->borderRight(), style()->visitedDependentColor(right), BCELL);
    473    
    474     // (2) The left border of the cell to the right.
    475     if (!rightmostColumn) {
    476         RenderTableCell* nextCell = rtl ? tableElt->cellBefore(this) : tableElt->cellAfter(this);
     449CollapsedBorderValue RenderTableCell::collapsedEndBorder() const
     450{
     451    RenderTable* table = this->table();
     452    bool isEndColumn = table->colToEffCol(col() + colSpan() - 1) == table->numEffCols() - 1;
     453
     454    // For end border, we need to check, in order of precedence:
     455    // (1) Our end border.
     456    int start = CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderStartColor, table->style()->direction(), table->style()->writingMode());
     457    int end = CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderEndColor, table->style()->direction(), table->style()->writingMode());
     458    CollapsedBorderValue result = CollapsedBorderValue(&style()->borderEnd(), style()->visitedDependentColor(end), BCELL);
     459   
     460    // (2) The start border of the following cell.
     461    if (!isEndColumn) {
     462        RenderTableCell* nextCell = table->cellAfter(this);
    477463        if (nextCell && nextCell->style()) {
    478             CollapsedBorderValue leftBorder = CollapsedBorderValue(&nextCell->style()->borderLeft(), nextCell->style()->visitedDependentColor(left), BCELL);
    479             result = rtl ? chooseBorder(leftBorder, result) : chooseBorder(result, leftBorder);
     464            CollapsedBorderValue startBorder = CollapsedBorderValue(&nextCell->style()->borderStart(), nextCell->style()->visitedDependentColor(start), BCELL);
     465            result = chooseBorder(result, startBorder);
    480466            if (!result.exists())
    481467                return result;
    482468        }
    483469    } else {
    484         // (3) Our row's right border.
    485         result = chooseBorder(result, CollapsedBorderValue(&parent()->style()->borderRight(), parent()->style()->visitedDependentColor(right), BROW));
     470        // (3) Our row's end border.
     471        result = chooseBorder(result, CollapsedBorderValue(&parent()->style()->borderEnd(), parent()->style()->visitedDependentColor(end), BROW));
    486472        if (!result.exists())
    487473            return result;
    488474       
    489         // (4) Our row group's right border.
    490         result = chooseBorder(result, CollapsedBorderValue(&section()->style()->borderRight(), section()->style()->visitedDependentColor(right), BROWGROUP));
    491         if (!result.exists())
    492             return result;
    493     }
    494    
    495     // (5) Our column and column group's right borders.
     475        // (4) Our row group's end border.
     476        result = chooseBorder(result, CollapsedBorderValue(&section()->style()->borderEnd(), section()->style()->visitedDependentColor(end), BROWGROUP));
     477        if (!result.exists())
     478            return result;
     479    }
     480   
     481    // (5) Our column and column group's end borders.
    496482    bool startColEdge;
    497483    bool endColEdge;
    498     RenderTableCol* colElt = tableElt->colElement(col() + (rtl ? 0 : colSpan() - 1), &startColEdge, &endColEdge);
    499     if (colElt && (!rtl ? endColEdge : startColEdge)) {
    500         result = chooseBorder(result, CollapsedBorderValue(&colElt->style()->borderRight(), colElt->style()->visitedDependentColor(right), BCOL));
    501         if (!result.exists())
    502             return result;
    503         if (colElt->parent()->isTableCol() && (!rtl ? !colElt->nextSibling() : !colElt->previousSibling())) {
    504             result = chooseBorder(result, CollapsedBorderValue(&colElt->parent()->style()->borderRight(), colElt->parent()->style()->visitedDependentColor(right), BCOLGROUP));
     484    RenderTableCol* colElt = table->colElement(col() + colSpan() - 1, &startColEdge, &endColEdge);
     485    if (colElt && endColEdge) {
     486        result = chooseBorder(result, CollapsedBorderValue(&colElt->style()->borderEnd(), colElt->style()->visitedDependentColor(end), BCOL));
     487        if (!result.exists())
     488            return result;
     489        if (colElt->parent()->isTableCol() && !colElt->nextSibling()) {
     490            result = chooseBorder(result, CollapsedBorderValue(&colElt->parent()->style()->borderEnd(), colElt->parent()->style()->visitedDependentColor(end), BCOLGROUP));
    505491            if (!result.exists())
    506492                return result;
     
    508494    }
    509495   
    510     // (6) The left border of the column to the right.
    511     if (!rightmostColumn) {
    512         colElt = tableElt->colElement(col() + (rtl ? -1 : colSpan()), &startColEdge, &endColEdge);
    513         if (colElt && (!rtl ? startColEdge : endColEdge)) {
    514             CollapsedBorderValue leftBorder = CollapsedBorderValue(&colElt->style()->borderLeft(), colElt->style()->visitedDependentColor(left), BCOL);
    515             result = rtl ? chooseBorder(leftBorder, result) : chooseBorder(result, leftBorder);
     496    // (6) The start border of the next column.
     497    if (!isEndColumn) {
     498        colElt = table->colElement(col() + colSpan(), &startColEdge, &endColEdge);
     499        if (colElt && startColEdge) {
     500            CollapsedBorderValue startBorder = CollapsedBorderValue(&colElt->style()->borderStart(), colElt->style()->visitedDependentColor(start), BCOL);
     501            result = chooseBorder(result, startBorder);
    516502            if (!result.exists())
    517503                return result;
    518504        }
    519505    } else {
    520         // (7) The table's right border.
    521         result = chooseBorder(result, CollapsedBorderValue(&tableElt->style()->borderRight(), tableElt->style()->visitedDependentColor(right), BTABLE));
     506        // (7) The table's end border.
     507        result = chooseBorder(result, CollapsedBorderValue(&table->style()->borderEnd(), table->style()->visitedDependentColor(end), BTABLE));
    522508        if (!result.exists())
    523509            return result;
     
    527513}
    528514
    529 CollapsedBorderValue RenderTableCell::collapsedTopBorder() const
    530 {
    531     // For border top, we need to check, in order of precedence:
    532     // (1) Our top border.
    533     int top = CSSPropertyBorderTopColor;
    534     int bottom = CSSPropertyBorderBottomColor;
    535     CollapsedBorderValue result = CollapsedBorderValue(&style()->borderTop(), style()->visitedDependentColor(top), BCELL);
    536    
    537     RenderTableCell* prevCell = table()->cellAbove(this);
     515CollapsedBorderValue RenderTableCell::collapsedBeforeBorder() const
     516{
     517    RenderTable* table = this->table();
     518
     519    // For before border, we need to check, in order of precedence:
     520    // (1) Our before border.
     521    int before = CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderBeforeColor, table->style()->direction(), table->style()->writingMode());
     522    int after = CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderAfterColor, table->style()->direction(), table->style()->writingMode());
     523    CollapsedBorderValue result = CollapsedBorderValue(&style()->borderBefore(), style()->visitedDependentColor(before), BCELL);
     524   
     525    RenderTableCell* prevCell = table->cellAbove(this);
    538526    if (prevCell) {
    539         // (2) A previous cell's bottom border.
    540         result = chooseBorder(CollapsedBorderValue(&prevCell->style()->borderBottom(), prevCell->style()->visitedDependentColor(bottom), BCELL), result);
    541         if (!result.exists()) 
    542             return result;
    543     }
    544    
    545     // (3) Our row's top border.
    546     result = chooseBorder(result, CollapsedBorderValue(&parent()->style()->borderTop(), parent()->style()->visitedDependentColor(top), BROW));
     527        // (2) A before cell's after border.
     528        result = chooseBorder(CollapsedBorderValue(&prevCell->style()->borderAfter(), prevCell->style()->visitedDependentColor(after), BCELL), result);
     529        if (!result.exists())
     530            return result;
     531    }
     532   
     533    // (3) Our row's before border.
     534    result = chooseBorder(result, CollapsedBorderValue(&parent()->style()->borderBefore(), parent()->style()->visitedDependentColor(before), BROW));
    547535    if (!result.exists())
    548536        return result;
    549537   
    550     // (4) The previous row's bottom border.
     538    // (4) The previous row's after border.
    551539    if (prevCell) {
    552540        RenderObject* prevRow = 0;
     
    557545   
    558546        if (prevRow) {
    559             result = chooseBorder(CollapsedBorderValue(&prevRow->style()->borderBottom(), prevRow->style()->visitedDependentColor(bottom), BROW), result);
     547            result = chooseBorder(CollapsedBorderValue(&prevRow->style()->borderAfter(), prevRow->style()->visitedDependentColor(after), BROW), result);
    560548            if (!result.exists())
    561549                return result;
     
    566554    RenderTableSection* currSection = section();
    567555    if (!row()) {
    568         // (5) Our row group's top border.
    569         result = chooseBorder(result, CollapsedBorderValue(&currSection->style()->borderTop(), currSection->style()->visitedDependentColor(top), BROWGROUP));
     556        // (5) Our row group's before border.
     557        result = chooseBorder(result, CollapsedBorderValue(&currSection->style()->borderBefore(), currSection->style()->visitedDependentColor(before), BROWGROUP));
    570558        if (!result.exists())
    571559            return result;
    572560       
    573         // (6) Previous row group's bottom border.
    574         currSection = table()->sectionAbove(currSection);
     561        // (6) Previous row group's after border.
     562        currSection = table->sectionAbove(currSection);
    575563        if (currSection) {
    576             result = chooseBorder(CollapsedBorderValue(&currSection->style()->borderBottom(), currSection->style()->visitedDependentColor(bottom), BROWGROUP), result);
     564            result = chooseBorder(CollapsedBorderValue(&currSection->style()->borderAfter(), currSection->style()->visitedDependentColor(after), BROWGROUP), result);
    577565            if (!result.exists())
    578566                return result;
     
    581569   
    582570    if (!currSection) {
    583         // (8) Our column and column group's top borders.
    584         RenderTableCol* colElt = table()->colElement(col());
     571        // (8) Our column and column group's before borders.
     572        RenderTableCol* colElt = table->colElement(col());
    585573        if (colElt) {
    586             result = chooseBorder(result, CollapsedBorderValue(&colElt->style()->borderTop(), colElt->style()->visitedDependentColor(top), BCOL));
     574            result = chooseBorder(result, CollapsedBorderValue(&colElt->style()->borderBefore(), colElt->style()->visitedDependentColor(before), BCOL));
    587575            if (!result.exists())
    588576                return result;
    589577            if (colElt->parent()->isTableCol()) {
    590                 result = chooseBorder(result, CollapsedBorderValue(&colElt->parent()->style()->borderTop(), colElt->parent()->style()->visitedDependentColor(top), BCOLGROUP));
     578                result = chooseBorder(result, CollapsedBorderValue(&colElt->parent()->style()->borderBefore(), colElt->parent()->style()->visitedDependentColor(before), BCOLGROUP));
    591579                if (!result.exists())
    592580                    return result;
     
    594582        }
    595583       
    596         // (9) The table's top border.
    597         RenderTable* enclosingTable = table();
    598         result = chooseBorder(result, CollapsedBorderValue(&enclosingTable->style()->borderTop(), enclosingTable->style()->visitedDependentColor(top), BTABLE));
     584        // (9) The table's before border.
     585        result = chooseBorder(result, CollapsedBorderValue(&table->style()->borderBefore(), table->style()->visitedDependentColor(before), BTABLE));
    599586        if (!result.exists())
    600587            return result;
     
    604591}
    605592
    606 CollapsedBorderValue RenderTableCell::collapsedBottomBorder() const
    607 {
    608     // For border top, we need to check, in order of precedence:
    609     // (1) Our bottom border.
    610     int top = CSSPropertyBorderTopColor;
    611     int bottom = CSSPropertyBorderBottomColor;
    612     CollapsedBorderValue result = CollapsedBorderValue(&style()->borderBottom(), style()->visitedDependentColor(bottom), BCELL);
    613    
    614     RenderTableCell* nextCell = table()->cellBelow(this);
     593CollapsedBorderValue RenderTableCell::collapsedAfterBorder() const
     594{
     595    RenderTable* table = this->table();
     596
     597    // For after border, we need to check, in order of precedence:
     598    // (1) Our after border.
     599    int before = CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderBeforeColor, table->style()->direction(), table->style()->writingMode());
     600    int after = CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderAfterColor, table->style()->direction(), table->style()->writingMode());
     601    CollapsedBorderValue result = CollapsedBorderValue(&style()->borderAfter(), style()->visitedDependentColor(after), BCELL);
     602   
     603    RenderTableCell* nextCell = table->cellBelow(this);
    615604    if (nextCell) {
    616         // (2) A following cell's top border.
    617         result = chooseBorder(result, CollapsedBorderValue(&nextCell->style()->borderTop(), nextCell->style()->visitedDependentColor(top), BCELL));
    618         if (!result.exists())
    619             return result;
    620     }
    621    
    622     // (3) Our row's bottom border. (FIXME: Deal with rowspan!)
    623     result = chooseBorder(result, CollapsedBorderValue(&parent()->style()->borderBottom(), parent()->style()->visitedDependentColor(bottom), BROW));
     605        // (2) An after cell's before border.
     606        result = chooseBorder(result, CollapsedBorderValue(&nextCell->style()->borderBefore(), nextCell->style()->visitedDependentColor(before), BCELL));
     607        if (!result.exists())
     608            return result;
     609    }
     610   
     611    // (3) Our row's after border. (FIXME: Deal with rowspan!)
     612    result = chooseBorder(result, CollapsedBorderValue(&parent()->style()->borderAfter(), parent()->style()->visitedDependentColor(after), BROW));
    624613    if (!result.exists())
    625614        return result;
    626615   
    627     // (4) The next row's top border.
     616    // (4) The next row's before border.
    628617    if (nextCell) {
    629         result = chooseBorder(result, CollapsedBorderValue(&nextCell->parent()->style()->borderTop(), nextCell->parent()->style()->visitedDependentColor(top), BROW));
     618        result = chooseBorder(result, CollapsedBorderValue(&nextCell->parent()->style()->borderBefore(), nextCell->parent()->style()->visitedDependentColor(before), BROW));
    630619        if (!result.exists())
    631620            return result;
     
    635624    RenderTableSection* currSection = section();
    636625    if (row() + rowSpan() >= currSection->numRows()) {
    637         // (5) Our row group's bottom border.
    638         result = chooseBorder(result, CollapsedBorderValue(&currSection->style()->borderBottom(), currSection->style()->visitedDependentColor(bottom), BROWGROUP));
     626        // (5) Our row group's after border.
     627        result = chooseBorder(result, CollapsedBorderValue(&currSection->style()->borderAfter(), currSection->style()->visitedDependentColor(after), BROWGROUP));
    639628        if (!result.exists())
    640629            return result;
    641630       
    642         // (6) Following row group's top border.
    643         currSection = table()->sectionBelow(currSection);
     631        // (6) Following row group's before border.
     632        currSection = table->sectionBelow(currSection);
    644633        if (currSection) {
    645             result = chooseBorder(result, CollapsedBorderValue(&currSection->style()->borderTop(), currSection->style()->visitedDependentColor(top), BROWGROUP));
     634            result = chooseBorder(result, CollapsedBorderValue(&currSection->style()->borderBefore(), currSection->style()->visitedDependentColor(before), BROWGROUP));
    646635            if (!result.exists())
    647636                return result;
     
    650639   
    651640    if (!currSection) {
    652         // (8) Our column and column group's bottom borders.
    653         RenderTableCol* colElt = table()->colElement(col());
     641        // (8) Our column and column group's after borders.
     642        RenderTableCol* colElt = table->colElement(col());
    654643        if (colElt) {
    655             result = chooseBorder(result, CollapsedBorderValue(&colElt->style()->borderBottom(), colElt->style()->visitedDependentColor(bottom), BCOL));
     644            result = chooseBorder(result, CollapsedBorderValue(&colElt->style()->borderAfter(), colElt->style()->visitedDependentColor(after), BCOL));
    656645            if (!result.exists()) return result;
    657646            if (colElt->parent()->isTableCol()) {
    658                 result = chooseBorder(result, CollapsedBorderValue(&colElt->parent()->style()->borderBottom(), colElt->parent()->style()->visitedDependentColor(bottom), BCOLGROUP));
     647                result = chooseBorder(result, CollapsedBorderValue(&colElt->parent()->style()->borderAfter(), colElt->parent()->style()->visitedDependentColor(after), BCOLGROUP));
    659648                if (!result.exists())
    660649                    return result;
     
    662651        }
    663652       
    664         // (9) The table's bottom border.
    665         RenderTable* enclosingTable = table();
    666         result = chooseBorder(result, CollapsedBorderValue(&enclosingTable->style()->borderBottom(), enclosingTable->style()->visitedDependentColor(bottom), BTABLE));
     653        // (9) The table's after border.
     654        result = chooseBorder(result, CollapsedBorderValue(&table->style()->borderAfter(), table->style()->visitedDependentColor(after), BTABLE));
    667655        if (!result.exists())
    668656            return result;
     
    670658   
    671659    return result;   
     660}
     661
     662CollapsedBorderValue RenderTableCell::collapsedLeftBorder() const
     663{
     664    RenderStyle* tableStyle = table()->style();
     665    if (tableStyle->isHorizontalWritingMode())
     666        return tableStyle->isLeftToRightDirection() ? collapsedStartBorder() : collapsedEndBorder();
     667    return tableStyle->isFlippedBlocksWritingMode() ? collapsedAfterBorder() : collapsedBeforeBorder();
     668}
     669
     670CollapsedBorderValue RenderTableCell::collapsedRightBorder() const
     671{
     672    RenderStyle* tableStyle = table()->style();
     673    if (tableStyle->isHorizontalWritingMode())
     674        return tableStyle->isLeftToRightDirection() ? collapsedEndBorder() : collapsedStartBorder();
     675    return tableStyle->isFlippedBlocksWritingMode() ? collapsedBeforeBorder() : collapsedAfterBorder();
     676}
     677
     678CollapsedBorderValue RenderTableCell::collapsedTopBorder() const
     679{
     680    RenderStyle* tableStyle = table()->style();
     681    if (tableStyle->isHorizontalWritingMode())
     682        return tableStyle->isFlippedBlocksWritingMode() ? collapsedAfterBorder() : collapsedBeforeBorder();
     683    return tableStyle->isLeftToRightDirection() ? collapsedStartBorder() : collapsedEndBorder();
     684}
     685
     686CollapsedBorderValue RenderTableCell::collapsedBottomBorder() const
     687{
     688    RenderStyle* tableStyle = table()->style();
     689    if (tableStyle->isHorizontalWritingMode())
     690        return tableStyle->isFlippedBlocksWritingMode() ? collapsedBeforeBorder() : collapsedAfterBorder();
     691    return tableStyle->isLeftToRightDirection() ? collapsedEndBorder() : collapsedStartBorder();
    672692}
    673693
     
    696716int RenderTableCell::borderStart() const
    697717{
    698     return table()->collapseBorders() ? borderHalfLeft(false) : RenderBlock::borderStart();
     718    return table()->collapseBorders() ? borderHalfStart(false) : RenderBlock::borderStart();
    699719}
    700720
    701721int RenderTableCell::borderEnd() const
    702722{
    703     return table()->collapseBorders() ? borderHalfRight(false) : RenderBlock::borderEnd();
     723    return table()->collapseBorders() ? borderHalfEnd(false) : RenderBlock::borderEnd();
    704724}
    705725
    706726int RenderTableCell::borderBefore() const
    707727{
    708     return table()->collapseBorders() ? borderHalfTop(false) : RenderBlock::borderBefore();
     728    return table()->collapseBorders() ? borderHalfBefore(false) : RenderBlock::borderBefore();
    709729}
    710730
    711731int RenderTableCell::borderAfter() const
    712732{
    713     return table()->collapseBorders() ? borderHalfBottom(false) : RenderBlock::borderAfter();
     733    return table()->collapseBorders() ? borderHalfAfter(false) : RenderBlock::borderAfter();
    714734}
    715735
    716736int RenderTableCell::borderHalfLeft(bool outer) const
    717737{
    718     CollapsedBorderValue border = collapsedLeftBorder(!table()->style()->isLeftToRightDirection());
     738    RenderStyle* tableStyle = table()->style();
     739    if (tableStyle->isHorizontalWritingMode())
     740        return tableStyle->isLeftToRightDirection() ? borderHalfStart(outer) : borderHalfEnd(outer);
     741    return tableStyle->isFlippedBlocksWritingMode() ? borderHalfAfter(outer) : borderHalfBefore(outer);
     742}
     743
     744int RenderTableCell::borderHalfRight(bool outer) const
     745{
     746    RenderStyle* tableStyle = table()->style();
     747    if (tableStyle->isHorizontalWritingMode())
     748        return tableStyle->isLeftToRightDirection() ? borderHalfEnd(outer) : borderHalfStart(outer);
     749    return tableStyle->isFlippedBlocksWritingMode() ? borderHalfBefore(outer) : borderHalfAfter(outer);
     750}
     751
     752int RenderTableCell::borderHalfTop(bool outer) const
     753{
     754    RenderStyle* tableStyle = table()->style();
     755    if (tableStyle->isHorizontalWritingMode())
     756        return tableStyle->isFlippedBlocksWritingMode() ? borderHalfAfter(outer) : borderHalfBefore(outer);
     757    return tableStyle->isLeftToRightDirection() ? borderHalfStart(outer) : borderHalfEnd(outer);
     758}
     759
     760int RenderTableCell::borderHalfBottom(bool outer) const
     761{
     762    RenderStyle* tableStyle = table()->style();
     763    if (tableStyle->isHorizontalWritingMode())
     764        return tableStyle->isFlippedBlocksWritingMode() ? borderHalfBefore(outer) : borderHalfAfter(outer);
     765    return tableStyle->isLeftToRightDirection() ? borderHalfEnd(outer) : borderHalfStart(outer);
     766}
     767
     768int RenderTableCell::borderHalfStart(bool outer) const
     769{
     770    CollapsedBorderValue border = collapsedStartBorder();
    719771    if (border.exists())
    720         return (border.width() + (outer ? 0 : 1)) / 2; // Give the extra pixel to top and left.
     772        return (border.width() + ((table()->style()->isLeftToRightDirection() ^ outer) ? 1 : 0)) / 2; // Give the extra pixel to top and left.
    721773    return 0;
    722774}
    723775   
    724 int RenderTableCell::borderHalfRight(bool outer) const
    725 {
    726     CollapsedBorderValue border = collapsedRightBorder(!table()->style()->isLeftToRightDirection());
     776int RenderTableCell::borderHalfEnd(bool outer) const
     777{
     778    CollapsedBorderValue border = collapsedEndBorder();
    727779    if (border.exists())
    728         return (border.width() + (outer ? 1 : 0)) / 2;
     780        return (border.width() + ((table()->style()->isLeftToRightDirection() ^ outer) ? 0 : 1)) / 2;
    729781    return 0;
    730782}
    731783
    732 int RenderTableCell::borderHalfTop(bool outer) const
    733 {
    734     CollapsedBorderValue border = collapsedTopBorder();
     784int RenderTableCell::borderHalfBefore(bool outer) const
     785{
     786    CollapsedBorderValue border = collapsedBeforeBorder();
    735787    if (border.exists())
    736         return (border.width() + (outer ? 0 : 1)) / 2; // Give the extra pixel to top and left.
     788        return (border.width() + ((table()->style()->isFlippedBlocksWritingMode() ^ outer) ? 0 : 1)) / 2; // Give the extra pixel to top and left.
    737789    return 0;
    738790}
    739791
    740 int RenderTableCell::borderHalfBottom(bool outer) const
    741 {
    742     CollapsedBorderValue border = collapsedBottomBorder();
     792int RenderTableCell::borderHalfAfter(bool outer) const
     793{
     794    CollapsedBorderValue border = collapsedAfterBorder();
    743795    if (border.exists())
    744         return (border.width() + (outer ? 1 : 0)) / 2;
     796        return (border.width() + ((table()->style()->isFlippedBlocksWritingMode() ^ outer) ? 1 : 0)) / 2;
    745797    return 0;
    746798}
     
    836888void RenderTableCell::collectBorderStyles(CollapsedBorderStyles& borderStyles) const
    837889{
    838     bool rtl = !table()->style()->isLeftToRightDirection();
    839     addBorderStyle(borderStyles, collapsedLeftBorder(rtl));
    840     addBorderStyle(borderStyles, collapsedRightBorder(rtl));
    841     addBorderStyle(borderStyles, collapsedTopBorder());
    842     addBorderStyle(borderStyles, collapsedBottomBorder());
     890    addBorderStyle(borderStyles, collapsedStartBorder());
     891    addBorderStyle(borderStyles, collapsedEndBorder());
     892    addBorderStyle(borderStyles, collapsedBeforeBorder());
     893    addBorderStyle(borderStyles, collapsedAfterBorder());
    843894}
    844895
     
    863914        return;
    864915   
    865     bool rtl = !table()->style()->isLeftToRightDirection();
    866     CollapsedBorderValue leftVal = collapsedLeftBorder(rtl);
    867     CollapsedBorderValue rightVal = collapsedRightBorder(rtl);
     916    CollapsedBorderValue leftVal = collapsedLeftBorder();
     917    CollapsedBorderValue rightVal = collapsedRightBorder();
    868918    CollapsedBorderValue topVal = collapsedTopBorder();
    869919    CollapsedBorderValue bottomVal = collapsedBottomBorder();
  • trunk/WebCore/rendering/RenderTableCell.h

    r70072 r71251  
    5252    RenderTable* table() const { return toRenderTable(parent()->parent()->parent()); }
    5353
    54     Length styleOrColWidth() const;
     54    Length styleOrColLogicalWidth() const;
    5555
    5656    virtual void computePreferredLogicalWidths();
    5757
    58     void updateWidth(int);
     58    void updateLogicalWidth(int);
    5959
    6060    virtual int borderLeft() const;
     
    7272    int borderHalfBottom(bool outer) const;
    7373
    74     CollapsedBorderValue collapsedLeftBorder(bool rtl) const;
    75     CollapsedBorderValue collapsedRightBorder(bool rtl) const;
     74    int borderHalfStart(bool outer) const;
     75    int borderHalfEnd(bool outer) const;
     76    int borderHalfBefore(bool outer) const;
     77    int borderHalfAfter(bool outer) const;
     78
     79    CollapsedBorderValue collapsedStartBorder() const;
     80    CollapsedBorderValue collapsedEndBorder() const;
     81    CollapsedBorderValue collapsedBeforeBorder() const;
     82    CollapsedBorderValue collapsedAfterBorder() const;
     83
     84    CollapsedBorderValue collapsedLeftBorder() const;
     85    CollapsedBorderValue collapsedRightBorder() const;
    7686    CollapsedBorderValue collapsedTopBorder() const;
    7787    CollapsedBorderValue collapsedBottomBorder() const;
  • trunk/WebCore/rendering/RenderTableSection.cpp

    r70170 r71251  
    282282                    cell->repaint();
    283283                }
    284                 cell->updateWidth(w);
     284                cell->updateLogicalWidth(w);
    285285            }
    286286        }
  • trunk/WebCore/rendering/style/RenderStyle.cpp

    r71218 r71251  
    11491149}
    11501150
     1151const BorderValue& RenderStyle::borderBefore() const
     1152{
     1153    switch (writingMode()) {
     1154    case TopToBottomWritingMode:
     1155        return borderTop();
     1156    case BottomToTopWritingMode:
     1157        return borderBottom();
     1158    case LeftToRightWritingMode:
     1159        return borderLeft();
     1160    case RightToLeftWritingMode:
     1161        return borderRight();
     1162    }
     1163    ASSERT_NOT_REACHED();
     1164    return borderTop();
     1165}
     1166
     1167const BorderValue& RenderStyle::borderAfter() const
     1168{
     1169    switch (writingMode()) {
     1170    case TopToBottomWritingMode:
     1171        return borderBottom();
     1172    case BottomToTopWritingMode:
     1173        return borderTop();
     1174    case LeftToRightWritingMode:
     1175        return borderRight();
     1176    case RightToLeftWritingMode:
     1177        return borderLeft();
     1178    }
     1179    ASSERT_NOT_REACHED();
     1180    return borderBottom();
     1181}
     1182
     1183const BorderValue& RenderStyle::borderStart() const
     1184{
     1185    if (isHorizontalWritingMode())
     1186        return isLeftToRightDirection() ? borderLeft() : borderRight();
     1187    return isLeftToRightDirection() ? borderTop() : borderBottom();
     1188}
     1189
     1190const BorderValue& RenderStyle::borderEnd() const
     1191{
     1192    if (isHorizontalWritingMode())
     1193        return isLeftToRightDirection() ? borderRight() : borderLeft();
     1194    return isLeftToRightDirection() ? borderBottom() : borderTop();
     1195}
     1196
    11511197unsigned short RenderStyle::borderBeforeWidth() const
    11521198{
  • trunk/WebCore/rendering/style/RenderStyle.h

    r71218 r71251  
    404404    const BorderValue& borderTop() const { return surround->border.top(); }
    405405    const BorderValue& borderBottom() const { return surround->border.bottom(); }
     406
     407    const BorderValue& borderBefore() const;
     408    const BorderValue& borderAfter() const;
     409    const BorderValue& borderStart() const;
     410    const BorderValue& borderEnd() const;
    406411
    407412    const NinePieceImage& borderImage() const { return surround->border.image(); }
Note: See TracChangeset for help on using the changeset viewer.