Changeset 70172 in webkit


Ignore:
Timestamp:
Oct 20, 2010 1:51:40 PM (13 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=48001

Reviewed by Dan Bernstein.

Make boxes place themselves properly in the block direction. Get basic painting working for spans and add a test that
verifies that span painting and replaced element painting (like images) works correctly.

Added fast/blockflow/basic-vertical-line.html

WebCore:

  • rendering/InlineBox.cpp:

(WebCore::InlineBox::logicalHeight):

  • rendering/InlineFlowBox.cpp:

(WebCore::InlineFlowBox::placeBoxesInInlineDirection):
(WebCore::InlineFlowBox::adjustMaxAscentAndDescent):
(WebCore::verticalPositionForBox):
(WebCore::InlineFlowBox::computeLogicalBoxHeights):
(WebCore::InlineFlowBox::placeBoxesInBlockDirection):
(WebCore::InlineFlowBox::flipLinesInBlockDirection):
(WebCore::InlineFlowBox::paintBoxDecorations):
(WebCore::InlineFlowBox::paintMask):

  • rendering/InlineFlowBox.h:
  • rendering/style/RenderStyle.h:

(WebCore::InheritedFlags::isFlippedLinesWritingMode):

LayoutTests:

  • fast/blockflow/basic-vertical-line.html: Added.
  • platform/mac/fast/blockflow/basic-vertical-line-expected.checksum: Added.
  • platform/mac/fast/blockflow/basic-vertical-line-expected.png: Added.
  • platform/mac/fast/blockflow/basic-vertical-line-expected.txt: Added.
Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r70170 r70172  
     12010-10-20  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=48001
     6
     7        Make boxes place themselves properly in the block direction.  Get basic painting working for spans and add a test that
     8        verifies that span painting and replaced element painting (like images) works correctly.
     9       
     10        Added fast/blockflow/basic-vertical-line.html
     11
     12        * fast/blockflow/basic-vertical-line.html: Added.
     13        * platform/mac/fast/blockflow/basic-vertical-line-expected.checksum: Added.
     14        * platform/mac/fast/blockflow/basic-vertical-line-expected.png: Added.
     15        * platform/mac/fast/blockflow/basic-vertical-line-expected.txt: Added.
     16
    1172010-10-20  Beth Dakin  <bdakin@apple.com>
    218
  • trunk/WebCore/ChangeLog

    r70170 r70172  
     12010-10-20  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=48001
     6
     7        Make boxes place themselves properly in the block direction.  Get basic painting working for spans and add a test that
     8        verifies that span painting and replaced element painting (like images) works correctly.
     9       
     10        Added fast/blockflow/basic-vertical-line.html
     11
     12        * rendering/InlineBox.cpp:
     13        (WebCore::InlineBox::logicalHeight):
     14        * rendering/InlineFlowBox.cpp:
     15        (WebCore::InlineFlowBox::placeBoxesInInlineDirection):
     16        (WebCore::InlineFlowBox::adjustMaxAscentAndDescent):
     17        (WebCore::verticalPositionForBox):
     18        (WebCore::InlineFlowBox::computeLogicalBoxHeights):
     19        (WebCore::InlineFlowBox::placeBoxesInBlockDirection):
     20        (WebCore::InlineFlowBox::flipLinesInBlockDirection):
     21        (WebCore::InlineFlowBox::paintBoxDecorations):
     22        (WebCore::InlineFlowBox::paintMask):
     23        * rendering/InlineFlowBox.h:
     24        * rendering/style/RenderStyle.h:
     25        (WebCore::InheritedFlags::isFlippedLinesWritingMode):
     26
    1272010-10-20  Beth Dakin  <bdakin@apple.com>
    228
  • trunk/WebCore/rendering/InlineBox.cpp

    r68177 r70172  
    9696        return m_isText ? renderer()->style(m_firstLine)->font().height() : 0;
    9797    if (renderer()->isBox() && parent())
    98         return toRenderBox(m_renderer)->height();
     98        return m_isVertical ? toRenderBox(m_renderer)->width() : toRenderBox(m_renderer)->height();
    9999
    100100    ASSERT(isInlineFlowBox());
     
    103103    int result = font.height();
    104104    if (parent())
    105         result += flowObject->borderAndPaddingHeight();
     105        result += flowObject->borderAndPaddingLogicalHeight();
    106106    return result;
    107107}
  • trunk/WebCore/rendering/InlineFlowBox.cpp

    r70072 r70172  
    333333               
    334334                logicalLeft += logicalLeftMargin;
    335                 curr->setX(logicalLeft);
     335                curr->setLogicalLeft(logicalLeft);
    336336                       
    337337                RenderBox* box = toRenderBox(curr->renderer());
     
    368368        if (curr->renderer()->isPositioned())
    369369            continue; // Positioned placeholders don't affect calculations.
    370         if (curr->y() == PositionTop || curr->y() == PositionBottom) {
     370        if (curr->logicalTop() == PositionTop || curr->logicalTop() == PositionBottom) {
    371371            int lineHeight = curr->lineHeight();
    372             if (curr->y() == PositionTop) {
     372            if (curr->logicalTop() == PositionTop) {
    373373                if (maxAscent + maxDescent < lineHeight)
    374374                    maxDescent = lineHeight - maxAscent;
     
    391391{
    392392    if (curr->renderer()->isText())
    393         return curr->parent()->y();
     393        return curr->parent()->logicalTop();
    394394    if (curr->renderer()->isBox())
    395395        return toRenderBox(curr->renderer())->verticalPosition(firstLine);
     
    460460        }
    461461
    462         curr->setY(verticalPositionForBox(curr, m_firstLine));
    463         if (curr->y() == PositionTop) {
     462        curr->setLogicalTop(verticalPositionForBox(curr, m_firstLine));
     463        if (curr->logicalTop() == PositionTop) {
    464464            if (maxPositionTop < lineHeight)
    465465                maxPositionTop = lineHeight;
    466         } else if (curr->y() == PositionBottom) {
     466        } else if (curr->logicalTop() == PositionBottom) {
    467467            if (maxPositionBottom < lineHeight)
    468468                maxPositionBottom = lineHeight;
    469469        } else if ((!isInlineFlow || static_cast<InlineFlowBox*>(curr)->hasTextChildren()) || curr->boxModelObject()->hasInlineDirectionBordersOrPadding() || strictMode) {
    470             int ascent = baseline - curr->y();
     470            int ascent = baseline - curr->logicalTop();
    471471            int descent = lineHeight - ascent;
    472472            if (maxAscent < ascent)
     
    481481}
    482482
    483 void InlineFlowBox::placeBoxesInBlockDirection(int yPos, int maxHeight, int maxAscent, bool strictMode, int& selectionTop, int& selectionBottom)
     483void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAscent, bool strictMode, int& lineTop, int& lineBottom)
    484484{
    485485    if (isRootInlineBox())
    486         setY(yPos + maxAscent - baselinePosition()); // Place our root box.
     486        setLogicalTop(top + maxAscent - baselinePosition()); // Place our root box.
    487487
    488488    for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
     
    494494        bool isInlineFlow = curr->isInlineFlowBox();
    495495        if (isInlineFlow)
    496             static_cast<InlineFlowBox*>(curr)->placeBoxesInBlockDirection(yPos, maxHeight, maxAscent, strictMode, selectionTop, selectionBottom);
     496            static_cast<InlineFlowBox*>(curr)->placeBoxesInBlockDirection(top, maxHeight, maxAscent, strictMode, lineTop, lineBottom);
    497497
    498498        bool childAffectsTopBottomPos = true;
    499         if (curr->y() == PositionTop)
    500             curr->setY(yPos);
    501         else if (curr->y() == PositionBottom)
    502             curr->setY(yPos + maxHeight - curr->lineHeight());
     499        if (curr->logicalTop() == PositionTop)
     500            curr->setLogicalTop(top);
     501        else if (curr->logicalTop() == PositionBottom)
     502            curr->setLogicalTop(top + maxHeight - curr->lineHeight());
    503503        else {
    504504            if ((isInlineFlow && !static_cast<InlineFlowBox*>(curr)->hasTextChildren()) && !curr->boxModelObject()->hasInlineDirectionBordersOrPadding() && !strictMode)
    505505                childAffectsTopBottomPos = false;
    506506            int posAdjust = maxAscent - curr->baselinePosition();
    507             curr->setY(curr->y() + yPos + posAdjust);
     507            curr->setLogicalTop(curr->logicalTop() + top + posAdjust);
    508508        }
    509509       
    510         int newY = curr->y();
     510        int newLogicalTop = curr->logicalTop();
    511511        if (curr->isText() || curr->isInlineFlowBox()) {
    512512            const Font& font = curr->renderer()->style(m_firstLine)->font();
    513             newY += curr->baselinePosition() - font.ascent();
    514             if (curr->isInlineFlowBox())
    515                 newY -= curr->boxModelObject()->borderTop() + curr->boxModelObject()->paddingTop();
     513            newLogicalTop += curr->baselinePosition() - font.ascent();
     514            if (curr->isInlineFlowBox()) {
     515                RenderBoxModelObject* boxObject = toRenderBoxModelObject(curr->renderer());
     516                newLogicalTop -= boxObject->style(m_firstLine)->isHorizontalWritingMode() ? boxObject->borderTop() + boxObject->paddingTop() :
     517                                 boxObject->borderRight() + boxObject->paddingRight();
     518            }
    516519        } else if (!curr->renderer()->isBR()) {
    517520            RenderBox* box = toRenderBox(curr->renderer());
    518             newY += box->marginTop();
    519         }
    520 
    521         curr->setY(newY);
     521            newLogicalTop += box->style(m_firstLine)->isHorizontalWritingMode() ? box->marginTop() : box->marginRight();
     522        }
     523
     524        curr->setLogicalTop(newLogicalTop);
    522525
    523526        if (childAffectsTopBottomPos) {
    524527            int boxHeight = curr->logicalHeight();
    525             selectionTop = min(selectionTop, newY);
    526             selectionBottom = max(selectionBottom, newY + boxHeight);
     528            lineTop = min(lineTop, newLogicalTop);
     529            lineBottom = max(lineBottom, newLogicalTop + boxHeight);
    527530        }
    528531    }
     
    530533    if (isRootInlineBox()) {
    531534        const Font& font = renderer()->style(m_firstLine)->font();
    532         setY(y() + baselinePosition() - font.ascent());
     535        setLogicalTop(logicalTop() + baselinePosition() - font.ascent());
     536       
    533537        if (hasTextChildren() || strictMode) {
    534             selectionTop = min(selectionTop, y());
    535             selectionBottom = max(selectionBottom, y() + logicalHeight());
    536         }
     538            lineTop = min(lineTop, logicalTop());
     539            lineBottom = max(lineBottom, logicalTop() + logicalHeight());
     540        }
     541       
     542        if (renderer()->style()->isFlippedLinesWritingMode())
     543            flipLinesInBlockDirection(lineTop, lineBottom);
     544    }
     545}
     546
     547void InlineFlowBox::flipLinesInBlockDirection(int lineTop, int lineBottom)
     548{
     549    // Flip the box on the line such that the top is now relative to the lineBottom instead of the lineTop.
     550    setLogicalTop(lineBottom - (logicalTop() - lineTop) - logicalHeight());
     551   
     552    for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
     553        if (curr->renderer()->isPositioned())
     554            continue; // Positioned placeholders aren't affected here.
     555       
     556        if (curr->isInlineFlowBox())
     557            static_cast<InlineFlowBox*>(curr)->flipLinesInBlockDirection(lineTop, lineBottom);
     558        else
     559            curr->setLogicalTop(lineBottom - (curr->logicalTop() - lineTop) - curr->logicalHeight());
    537560    }
    538561}
     
    763786    int x = m_x;
    764787    int y = m_y;
    765     int w = logicalWidth();
    766     int h = logicalHeight();
     788    int w = m_isVertical ? logicalHeight() : logicalWidth();
     789    int h = m_isVertical ? logicalWidth() : logicalHeight();
    767790
    768791    // Constrain our background/border painting to the line top and bottom if necessary.
     
    770793    if (!hasTextChildren() && !noQuirksMode) {
    771794        RootInlineBox* rootBox = root();
    772         int bottom = min(rootBox->lineBottom(), y + h);
    773         y = max(rootBox->lineTop(), y);
    774         h = bottom - y;
     795        int& top = m_isVertical ? x : y;
     796        int& logicalHeight = m_isVertical ? w : h;
     797        int bottom = min(rootBox->lineBottom(), top + logicalHeight);
     798        top = max(rootBox->lineTop(), top);
     799        logicalHeight = bottom - top;
    775800    }
    776801   
     
    839864    int x = m_x;
    840865    int y = m_y;
    841     int w = logicalWidth();
    842     int h = logicalHeight();
     866    int w = m_isVertical ? logicalHeight() : logicalWidth();
     867    int h = m_isVertical ? logicalWidth() : logicalHeight();
    843868
    844869    // Constrain our background/border painting to the line top and bottom if necessary.
     
    846871    if (!hasTextChildren() && !noQuirksMode) {
    847872        RootInlineBox* rootBox = root();
    848         int bottom = min(rootBox->lineBottom(), y + h);
    849         y = max(rootBox->lineTop(), y);
    850         h = bottom - y;
     873        int& top = m_isVertical ? x : y;
     874        int& logicalHeight = m_isVertical ? w : h;
     875        int bottom = min(rootBox->lineBottom(), top + logicalHeight);
     876        top = max(rootBox->lineTop(), top);
     877        logicalHeight = bottom - top;
    851878    }
    852879   
  • trunk/WebCore/rendering/InlineFlowBox.h

    r69341 r70172  
    155155    int getFlowSpacingLogicalWidth();
    156156    bool onEndChain(RenderObject* endObject);
    157     int placeBoxesInInlineDirection(int x, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap&);
     157    int placeBoxesInInlineDirection(int logicalLeft, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap&);
    158158    void computeLogicalBoxHeights(int& maxPositionTop, int& maxPositionBottom,
    159159                                  int& maxAscent, int& maxDescent, bool strictMode, GlyphOverflowAndFallbackFontsMap&);
    160160    void adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent,
    161161                                   int maxPositionTop, int maxPositionBottom);
    162     void placeBoxesInBlockDirection(int y, int maxHeight, int maxAscent, bool strictMode, int& lineTop, int& lineBottom);
     162    void placeBoxesInBlockDirection(int logicalTop, int maxHeight, int maxAscent, bool strictMode, int& lineTop, int& lineBottom);
     163    void flipLinesInBlockDirection(int lineTop, int lineBottom);
    163164    void computeBlockDirectionOverflow(int lineTop, int lineBottom, bool strictMode, GlyphOverflowAndFallbackFontsMap&);
    164165
  • trunk/WebCore/rendering/style/RenderStyle.h

    r69341 r70172  
    752752    WritingMode writingMode() const { return static_cast<WritingMode>(inherited_flags.m_writingMode); }
    753753    bool isHorizontalWritingMode() const { return writingMode() == TopToBottomWritingMode || writingMode() == BottomToTopWritingMode; }
     754    bool isFlippedLinesWritingMode() const { return writingMode() == LeftToRightWritingMode || writingMode() == BottomToTopWritingMode; }
    754755
    755756    ESpeak speak() { return static_cast<ESpeak>(rareInheritedData->speak); }
Note: See TracChangeset for help on using the changeset viewer.