diff options
Diffstat (limited to 'WebCore/rendering/InlineFlowBox.cpp')
-rw-r--r-- | WebCore/rendering/InlineFlowBox.cpp | 97 |
1 files changed, 54 insertions, 43 deletions
diff --git a/WebCore/rendering/InlineFlowBox.cpp b/WebCore/rendering/InlineFlowBox.cpp index d165231..8525673 100644 --- a/WebCore/rendering/InlineFlowBox.cpp +++ b/WebCore/rendering/InlineFlowBox.cpp @@ -80,7 +80,7 @@ void InlineFlowBox::addToLine(InlineBox* child) m_lastChild = child; } child->setFirstLineStyleBit(m_firstLine); - child->setIsVertical(m_isVertical); + child->setIsHorizontal(isHorizontal()); if (child->isText()) m_hasTextChildren = true; @@ -328,22 +328,22 @@ int InlineFlowBox::placeBoxesInInlineDirection(int logicalLeft, bool& needsWordS } else if (!curr->renderer()->isListMarker() || toRenderListMarker(curr->renderer())->isInside()) { // The box can have a different writing-mode than the overall line, so this is a bit complicated. // Just get all the physical margin and overflow values by hand based off |isVertical|. - int logicalLeftMargin = !isVertical() ? curr->boxModelObject()->marginLeft() : curr->boxModelObject()->marginTop(); - int logicalRightMargin = !isVertical() ? curr->boxModelObject()->marginRight() : curr->boxModelObject()->marginBottom(); + int logicalLeftMargin = isHorizontal() ? curr->boxModelObject()->marginLeft() : curr->boxModelObject()->marginTop(); + int logicalRightMargin = isHorizontal() ? curr->boxModelObject()->marginRight() : curr->boxModelObject()->marginBottom(); logicalLeft += logicalLeftMargin; curr->setLogicalLeft(logicalLeft); RenderBox* box = toRenderBox(curr->renderer()); - int childOverflowLogicalLeft = box->hasOverflowClip() ? 0 : (!isVertical() ? box->leftLayoutOverflow() : box->topLayoutOverflow()); - int childOverflowLogicalRight = box->hasOverflowClip() ? curr->logicalWidth() : (!isVertical() ? box->rightLayoutOverflow() : box->bottomLayoutOverflow()); + int childOverflowLogicalLeft = box->hasOverflowClip() ? 0 : (isHorizontal() ? box->leftLayoutOverflow() : box->topLayoutOverflow()); + int childOverflowLogicalRight = box->hasOverflowClip() ? curr->logicalWidth() : (isHorizontal() ? box->rightLayoutOverflow() : box->bottomLayoutOverflow()); logicalLeftLayoutOverflow = min(logicalLeft + childOverflowLogicalLeft, logicalLeftLayoutOverflow); logicalRightLayoutOverflow = max(logicalLeft + childOverflowLogicalRight, logicalRightLayoutOverflow); - logicalLeftVisualOverflow = min(logicalLeft + (!isVertical() ? box->leftVisualOverflow() : box->topVisualOverflow()), logicalLeftVisualOverflow); - logicalRightVisualOverflow = max(logicalLeft + (!isVertical() ? box->rightVisualOverflow() : box->bottomVisualOverflow()), logicalRightVisualOverflow); + logicalLeftVisualOverflow = min(logicalLeft + (isHorizontal() ? box->leftVisualOverflow() : box->topVisualOverflow()), logicalLeftVisualOverflow); + logicalRightVisualOverflow = max(logicalLeft + (isHorizontal() ? box->rightVisualOverflow() : box->bottomVisualOverflow()), logicalRightVisualOverflow); logicalLeft += curr->logicalWidth() + logicalRightMargin; } @@ -480,7 +480,7 @@ void InlineFlowBox::computeLogicalBoxHeights(int& maxPositionTop, int& maxPositi } } -void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAscent, bool strictMode, int& lineTop, int& lineBottom) +void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAscent, bool strictMode, int& lineTop, int& lineBottom, bool& setLineTop) { if (isRootInlineBox()) setLogicalTop(top + maxAscent - baselinePosition()); // Place our root box. @@ -493,7 +493,7 @@ void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAs // line-height). bool isInlineFlow = curr->isInlineFlowBox(); if (isInlineFlow) - static_cast<InlineFlowBox*>(curr)->placeBoxesInBlockDirection(top, maxHeight, maxAscent, strictMode, lineTop, lineBottom); + static_cast<InlineFlowBox*>(curr)->placeBoxesInBlockDirection(top, maxHeight, maxAscent, strictMode, lineTop, lineBottom, setLineTop); bool childAffectsTopBottomPos = true; if (curr->logicalTop() == PositionTop) @@ -525,7 +525,11 @@ void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAs if (childAffectsTopBottomPos) { int boxHeight = curr->logicalHeight(); - lineTop = min(lineTop, newLogicalTop); + if (!setLineTop) { + setLineTop = true; + lineTop = newLogicalTop; + } else + lineTop = min(lineTop, newLogicalTop); lineBottom = max(lineBottom, newLogicalTop + boxHeight); } } @@ -535,7 +539,11 @@ void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAs setLogicalTop(logicalTop() + baselinePosition() - font.ascent()); if (hasTextChildren() || strictMode) { - lineTop = min(lineTop, logicalTop()); + if (!setLineTop) { + setLineTop = true; + lineTop = logicalTop(); + } else + lineTop = min(lineTop, logicalTop()); lineBottom = max(lineBottom, logicalTop() + logicalHeight()); } @@ -633,7 +641,7 @@ void InlineFlowBox::computeBlockDirectionOverflow(int lineTop, int lineBottom, b int childBottomVisualOverflow; RenderBox* box = toRenderBox(curr->renderer()); - box->blockDirectionOverflow(isVertical(), childTopLayoutOverflow, childBottomLayoutOverflow, + box->blockDirectionOverflow(isHorizontal(), childTopLayoutOverflow, childBottomLayoutOverflow, childTopVisualOverflow, childBottomVisualOverflow); if (box->hasOverflowClip()) { @@ -654,6 +662,7 @@ void InlineFlowBox::computeBlockDirectionOverflow(int lineTop, int lineBottom, b bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty) { IntRect overflowRect(visibleOverflowRect()); + flipForWritingMode(overflowRect); overflowRect.move(tx, ty); if (!overflowRect.intersects(result.rectForPoint(x, y))) return false; @@ -667,9 +676,11 @@ bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re } // Now check ourselves. - IntRect rect(tx + m_x, ty + m_y, width(), height()); + IntPoint boxOrigin = locationIncludingFlipping(); + boxOrigin.move(tx, ty); + IntRect rect(boxOrigin, IntSize(width(), height())); if (visibleToHitTesting() && rect.intersects(result.rectForPoint(x, y))) { - renderer()->updateHitTestResult(result, IntPoint(x - tx, y - ty)); // Don't add in m_x or m_y here, we want coords in the containing block's space. + renderer()->updateHitTestResult(result, flipForWritingMode(IntPoint(x - tx, y - ty))); // Don't add in m_x or m_y here, we want coords in the containing block's space. if (!result.addNodeToRectBasedTestResult(renderer()->node(), x, y, rect)) return true; } @@ -681,7 +692,7 @@ void InlineFlowBox::paint(PaintInfo& paintInfo, int tx, int ty) { IntRect overflowRect(visibleOverflowRect()); overflowRect.inflate(renderer()->maximalOutlineSize(paintInfo.phase)); - adjustForFlippedBlocksWritingMode(overflowRect); + flipForWritingMode(overflowRect); overflowRect.move(tx, ty); if (!paintInfo.rect.intersects(overflowRect)) @@ -769,10 +780,10 @@ void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, c int totalLogicalWidth = logicalOffsetOnLine; for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) totalLogicalWidth += curr->logicalWidth(); - int stripX = tx - (isVertical() ? 0 : logicalOffsetOnLine); - int stripY = ty - (isVertical() ? logicalOffsetOnLine : 0); - int stripWidth = isVertical() ? width() : totalLogicalWidth; - int stripHeight = isVertical() ? totalLogicalWidth : height(); + int stripX = tx - (isHorizontal() ? logicalOffsetOnLine : 0); + int stripY = ty - (isHorizontal() ? 0 : logicalOffsetOnLine); + int stripWidth = isHorizontal() ? totalLogicalWidth : width(); + int stripHeight = isHorizontal() ? height() : totalLogicalWidth; paintInfo.context->save(); paintInfo.context->clip(IntRect(tx, ty, width(), height())); boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, stripX, stripY, stripWidth, stripHeight, this, op); @@ -798,25 +809,25 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty) int x = m_x; int y = m_y; - int w = m_isVertical ? logicalHeight() : logicalWidth(); - int h = m_isVertical ? logicalWidth() : logicalHeight(); + int w = width(); + int h = height(); // Constrain our background/border painting to the line top and bottom if necessary. bool noQuirksMode = renderer()->document()->inNoQuirksMode(); if (!hasTextChildren() && !noQuirksMode) { RootInlineBox* rootBox = root(); - int& top = m_isVertical ? x : y; - int& logicalHeight = m_isVertical ? w : h; + int& top = isHorizontal() ? y : x; + int& logicalHeight = isHorizontal() ? h : w; int bottom = min(rootBox->lineBottom(), top + logicalHeight); top = max(rootBox->lineTop(), top); logicalHeight = bottom - top; } // Move x/y to our coordinates. - IntPoint localPoint(x, y); - adjustForFlippedBlocksWritingMode(localPoint); - tx += localPoint.x(); - ty += localPoint.y(); + IntRect localRect(x, y, w, h); + flipForWritingMode(localRect); + tx += localRect.x(); + ty += localRect.y(); GraphicsContext* context = paintInfo.context; @@ -861,10 +872,10 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty) int totalLogicalWidth = logicalOffsetOnLine; for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) totalLogicalWidth += curr->logicalWidth(); - int stripX = tx - (isVertical() ? 0 : logicalOffsetOnLine); - int stripY = ty - (isVertical() ? logicalOffsetOnLine : 0); - int stripWidth = isVertical() ? w : totalLogicalWidth; - int stripHeight = isVertical() ? totalLogicalWidth : h; + int stripX = tx - (isHorizontal() ? logicalOffsetOnLine : 0); + int stripY = ty - (isHorizontal() ? 0 : logicalOffsetOnLine); + int stripWidth = isHorizontal() ? totalLogicalWidth : w; + int stripHeight = isHorizontal() ? h : totalLogicalWidth; context->save(); context->clip(IntRect(tx, ty, w, h)); boxModelObject()->paintBorder(context, stripX, stripY, stripWidth, stripHeight, renderer()->style()); @@ -881,25 +892,25 @@ void InlineFlowBox::paintMask(PaintInfo& paintInfo, int tx, int ty) int x = m_x; int y = m_y; - int w = m_isVertical ? logicalHeight() : logicalWidth(); - int h = m_isVertical ? logicalWidth() : logicalHeight(); + int w = width(); + int h = height(); // Constrain our background/border painting to the line top and bottom if necessary. bool noQuirksMode = renderer()->document()->inNoQuirksMode(); if (!hasTextChildren() && !noQuirksMode) { RootInlineBox* rootBox = root(); - int& top = m_isVertical ? x : y; - int& logicalHeight = m_isVertical ? w : h; + int& top = isHorizontal() ? y : x; + int& logicalHeight = isHorizontal() ? h : w; int bottom = min(rootBox->lineBottom(), top + logicalHeight); top = max(rootBox->lineTop(), top); logicalHeight = bottom - top; } // Move x/y to our coordinates. - IntPoint localPoint(x, y); - adjustForFlippedBlocksWritingMode(localPoint); - tx += localPoint.x(); - ty += localPoint.y(); + IntRect localRect(x, y, w, h); + flipForWritingMode(localRect); + tx += localRect.x(); + ty += localRect.y(); const NinePieceImage& maskNinePieceImage = renderer()->style()->maskBoxImage(); StyleImage* maskBoxImage = renderer()->style()->maskBoxImage().image(); @@ -939,10 +950,10 @@ void InlineFlowBox::paintMask(PaintInfo& paintInfo, int tx, int ty) int totalLogicalWidth = logicalOffsetOnLine; for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) totalLogicalWidth += curr->logicalWidth(); - int stripX = tx - (isVertical() ? 0 : logicalOffsetOnLine); - int stripY = ty - (isVertical() ? logicalOffsetOnLine : 0); - int stripWidth = isVertical() ? w : totalLogicalWidth; - int stripHeight = isVertical() ? totalLogicalWidth : h; + int stripX = tx - (isHorizontal() ? logicalOffsetOnLine : 0); + int stripY = ty - (isHorizontal() ? 0 : logicalOffsetOnLine); + int stripWidth = isHorizontal() ? totalLogicalWidth : w; + int stripHeight = isHorizontal() ? h : totalLogicalWidth; paintInfo.context->save(); paintInfo.context->clip(IntRect(tx, ty, w, h)); boxModelObject()->paintNinePieceImage(paintInfo.context, stripX, stripY, stripWidth, stripHeight, renderer()->style(), maskNinePieceImage, compositeOp); |