diff options
Diffstat (limited to 'WebCore/rendering/RenderBox.cpp')
-rw-r--r-- | WebCore/rendering/RenderBox.cpp | 71 |
1 files changed, 43 insertions, 28 deletions
diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp index fc617c4..41e2cd5 100644 --- a/WebCore/rendering/RenderBox.cpp +++ b/WebCore/rendering/RenderBox.cpp @@ -297,15 +297,13 @@ void RenderBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle // If our zoom factor changes and we have a defined scrollLeft/Top, we need to adjust that value into the // new zoomed coordinate space. if (hasOverflowClip() && oldStyle && style() && oldStyle->effectiveZoom() != style()->effectiveZoom()) { - int left = scrollLeft(); - if (left) { + if (int left = layer()->scrollXOffset()) { left = (left / oldStyle->effectiveZoom()) * style()->effectiveZoom(); - setScrollLeft(left); + layer()->scrollToXOffset(left); } - int top = scrollTop(); - if (top) { + if (int top = layer()->scrollYOffset()) { top = (top / oldStyle->effectiveZoom()) * style()->effectiveZoom(); - setScrollTop(top); + layer()->scrollToYOffset(top); } } @@ -387,7 +385,7 @@ void RenderBox::layout() return; } - LayoutStateMaintainer statePusher(view(), this, IntSize(x(), y())); + LayoutStateMaintainer statePusher(view(), this, IntSize(x(), y()), style()->isFlippedBlocksWritingMode()); while (child) { child->layoutIfNeeded(); ASSERT(!child->needsLayout()); @@ -1183,7 +1181,7 @@ void RenderBox::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed |= isFixedPos; IntSize containerOffset = offsetFromContainer(o, roundedIntPoint(transformState.mappedPoint())); - + bool preserve3D = useTransforms && (o->style()->preserves3D() || style()->preserves3D()); if (useTransforms && shouldUseTransformFromContainer(o)) { TransformationMatrix t; @@ -1243,9 +1241,11 @@ IntSize RenderBox::offsetFromContainer(RenderObject* o, const IntPoint& point) c offset += relativePositionOffset(); if (!isInline() || isReplaced()) { - if (style()->position() != AbsolutePosition && style()->position() != FixedPosition) + if (style()->position() != AbsolutePosition && style()->position() != FixedPosition) { o->adjustForColumns(offset, IntPoint(point.x() + x(), point.y() + y())); - offset.expand(x(), y()); + offset += locationOffsetIncludingFlipping(); + } else + offset += locationOffset(); } if (o->hasOverflowClip()) @@ -1338,12 +1338,21 @@ IntRect RenderBox::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintCo r.inflate(v->maximalOutlineSize()); } } + computeRectForRepaint(repaintContainer, r); return r; } void RenderBox::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& rect, bool fixed) { + // The rect we compute at each step is shifted by our x/y offset in the parent container's coordinate space. + // Only when we cross a writing mode boundary will we have to possibly flipForWritingMode (to convert into a more appropriate + // offset corner for the enclosing container). This allows for a fully RL or BT document to repaint + // properly even during layout, since the rect remains flipped all the way until the end. + // + // RenderView::computeRectForRepaint then converts the rect to physical coordinates. We also convert to + // physical when we hit a repaintContainer boundary. Therefore the final rect returned is always in the + // physical coordinate space of the repaintContainer. if (RenderView* v = view()) { // LayoutState is only valid for root-relative repainting if (v->layoutStateEnabled() && !repaintContainer) { @@ -1366,14 +1375,19 @@ void RenderBox::computeRectForRepaint(RenderBoxModelObject* repaintContainer, In if (hasReflection()) rect.unite(reflectedRect(rect)); - if (repaintContainer == this) + if (repaintContainer == this) { + if (repaintContainer->style()->isFlippedBlocksWritingMode()) + flipForWritingMode(rect); return; + } bool containerSkipped; RenderObject* o = container(repaintContainer, &containerSkipped); if (!o) return; + if (isWritingModeRoot() && !isPositioned()) + flipForWritingMode(rect); IntPoint topLeft = rect.location(); topLeft.move(x(), y()); @@ -1433,10 +1447,7 @@ void RenderBox::computeRectForRepaint(RenderBoxModelObject* repaintContainer, In rect.move(-containerOffset); return; } - - if (o->isBox()) - toRenderBox(o)->flipForWritingMode(rect); - + o->computeRectForRepaint(repaintContainer, rect, fixed); } @@ -3164,7 +3175,7 @@ bool RenderBox::shrinkToAvoidFloats() const bool RenderBox::avoidsFloats() const { - return isReplaced() || hasOverflowClip() || isHR() || isWritingModeRoot(); + return isReplaced() || hasOverflowClip() || isHR() || isLegend() || isWritingModeRoot(); } void RenderBox::addShadowOverflow() @@ -3249,10 +3260,14 @@ int RenderBox::lineHeight(bool /*firstLine*/, LineDirectionMode direction, LineP return 0; } -int RenderBox::baselinePosition(bool /*firstLine*/, LineDirectionMode direction, LinePositionMode /*linePositionMode*/) const +int RenderBox::baselinePosition(FontBaseline baselineType, bool /*firstLine*/, LineDirectionMode direction, LinePositionMode /*linePositionMode*/) const { - if (isReplaced()) - return direction == HorizontalLine ? m_marginTop + height() + m_marginBottom : m_marginRight + width() + m_marginLeft; + if (isReplaced()) { + int result = direction == HorizontalLine ? m_marginTop + height() + m_marginBottom : m_marginRight + width() + m_marginLeft; + if (baselineType == AlphabeticBaseline) + return result; + return result - result / 2; + } return 0; } @@ -3272,7 +3287,7 @@ void RenderBox::blockDirectionOverflow(bool isLineHorizontal, int& logicalTopLay } } -IntPoint RenderBox::flipForWritingMode(RenderBox* child, const IntPoint& point, FlippingAdjustment adjustment) +IntPoint RenderBox::flipForWritingMode(const RenderBox* child, const IntPoint& point, FlippingAdjustment adjustment) const { if (!style()->isFlippedBlocksWritingMode()) return point; @@ -3284,7 +3299,7 @@ IntPoint RenderBox::flipForWritingMode(RenderBox* child, const IntPoint& point, return IntPoint(point.x() + width() - child->width() - child->x() - (adjustment == ParentToChildFlippingAdjustment ? child->x() : 0), point.y()); } -void RenderBox::flipForWritingMode(IntRect& rect) +void RenderBox::flipForWritingMode(IntRect& rect) const { if (!style()->isFlippedBlocksWritingMode()) return; @@ -3295,35 +3310,35 @@ void RenderBox::flipForWritingMode(IntRect& rect) rect.setX(width() - rect.right()); } -int RenderBox::flipForWritingMode(int position) +int RenderBox::flipForWritingMode(int position) const { if (!style()->isFlippedBlocksWritingMode()) return position; return logicalHeight() - position; } -IntPoint RenderBox::flipForWritingMode(const IntPoint& position) +IntPoint RenderBox::flipForWritingMode(const IntPoint& position) const { if (!style()->isFlippedBlocksWritingMode()) return position; return style()->isHorizontalWritingMode() ? IntPoint(position.x(), height() - position.y()) : IntPoint(width() - position.x(), position.y()); } -IntSize RenderBox::flipForWritingMode(const IntSize& offset) +IntSize RenderBox::flipForWritingMode(const IntSize& offset) const { if (!style()->isFlippedBlocksWritingMode()) return offset; return style()->isHorizontalWritingMode() ? IntSize(offset.width(), height() - offset.height()) : IntSize(width() - offset.width(), offset.height()); } -IntSize RenderBox::locationOffsetIncludingFlipping() +IntSize RenderBox::locationOffsetIncludingFlipping() const { if (!parent() || !parent()->isBox()) return locationOffset(); - RenderBox* parent = parentBox(); - IntPoint localPoint = parent->flipForWritingMode(this, location(), ChildToParentFlippingAdjustment); - return IntSize(localPoint.x(), localPoint.y()); + IntRect rect(frameRect()); + parentBox()->flipForWritingMode(rect); + return IntSize(rect.x(), rect.y()); } } // namespace WebCore |