Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1246)

Unified Diff: third_party/WebKit/WebCore/rendering/RenderBox.cpp

Issue 21184: WebKit merge 40722:40785 (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/WebCore/rendering/RenderBox.cpp
===================================================================
--- third_party/WebKit/WebCore/rendering/RenderBox.cpp (revision 9391)
+++ third_party/WebKit/WebCore/rendering/RenderBox.cpp (working copy)
@@ -276,86 +276,6 @@
setNeedsLayout(false);
}
-int RenderBox::offsetLeft() const
-{
- RenderBox* offsetPar = offsetParent();
- if (!offsetPar)
- return 0;
- int xPos = x() - offsetPar->borderLeft();
- if (!isPositioned()) {
- if (isRelPositioned())
- xPos += relativePositionOffsetX();
- RenderObject* curr = parent();
- while (curr && curr != offsetPar) {
- // FIXME: What are we supposed to do inside SVG content?
- if (curr->isBox() && !curr->isTableRow())
- xPos += toRenderBox(curr)->x();
- curr = curr->parent();
- }
- if (offsetPar->isBody() && !offsetPar->isRelPositioned() && !offsetPar->isPositioned())
- xPos += offsetPar->x();
- }
- return xPos;
-}
-
-int RenderBox::offsetTop() const
-{
- RenderBox* offsetPar = offsetParent();
- if (!offsetPar)
- return 0;
- int yPos = y() - offsetPar->borderTop();
- if (!isPositioned()) {
- if (isRelPositioned())
- yPos += relativePositionOffsetY();
- RenderObject* curr = parent();
- while (curr && curr != offsetPar) {
- // FIXME: What are we supposed to do inside SVG content?
- if (curr->isBox() && !curr->isTableRow())
- yPos += toRenderBox(curr)->y();
- curr = curr->parent();
- }
- if (offsetPar->isBody() && !offsetPar->isRelPositioned() && !offsetPar->isPositioned())
- yPos += offsetPar->y();
- }
- return yPos;
-}
-
-RenderBox* RenderBox::offsetParent() const
-{
- // FIXME: It feels like this function could almost be written using containing blocks.
- if (isBody())
- return 0;
-
- bool skipTables = isPositioned() || isRelPositioned();
- float currZoom = style()->effectiveZoom();
- RenderObject* curr = parent();
- while (curr && (!curr->element() ||
- (!curr->isPositioned() && !curr->isRelPositioned() && !curr->isBody()))) {
- Node* element = curr->element();
- if (!skipTables && element) {
- bool isTableElement = element->hasTagName(tableTag) ||
- element->hasTagName(tdTag) ||
- element->hasTagName(thTag);
-
-#if ENABLE(WML)
- if (!isTableElement && element->isWMLElement())
- isTableElement = element->hasTagName(WMLNames::tableTag) ||
- element->hasTagName(WMLNames::tdTag);
-#endif
-
- if (isTableElement)
- break;
- }
-
- float newZoom = curr->style()->effectiveZoom();
- if (currZoom != newZoom)
- break;
- currZoom = newZoom;
- curr = curr->parent();
- }
- return curr && curr->isBox() ? toRenderBox(curr) : 0;
-}
-
// More IE extensions. clientWidth and clientHeight represent the interior of an object
// excluding border and scrollbar.
int RenderBox::clientWidth() const
@@ -408,42 +328,6 @@
layer()->scrollToYOffset(newTop);
}
-int RenderBox::paddingTop(bool) const
-{
- int w = 0;
- Length padding = style()->paddingTop();
- if (padding.isPercent())
- w = containingBlock()->availableWidth();
- return padding.calcMinValue(w);
-}
-
-int RenderBox::paddingBottom(bool) const
-{
- int w = 0;
- Length padding = style()->paddingBottom();
- if (padding.isPercent())
- w = containingBlock()->availableWidth();
- return padding.calcMinValue(w);
-}
-
-int RenderBox::paddingLeft(bool) const
-{
- int w = 0;
- Length padding = style()->paddingLeft();
- if (padding.isPercent())
- w = containingBlock()->availableWidth();
- return padding.calcMinValue(w);
-}
-
-int RenderBox::paddingRight(bool) const
-{
- int w = 0;
- Length padding = style()->paddingRight();
- if (padding.isPercent())
- w = containingBlock()->availableWidth();
- return padding.calcMinValue(w);
-}
-
void RenderBox::absoluteRects(Vector<IntRect>& rects, int tx, int ty, bool)
{
rects.append(IntRect(tx, ty, width(), height()));
@@ -881,60 +765,20 @@
paintFillLayerExtended(paintInfo, c, fillLayer, clipY, clipH, tx, ty, width, height, 0, op);
}
-IntSize RenderBox::calculateBackgroundSize(const FillLayer* bgLayer, int scaledWidth, int scaledHeight) const
-{
- StyleImage* bg = bgLayer->image();
- bg->setImageContainerSize(IntSize(scaledWidth, scaledHeight)); // Use the box established by background-origin.
-
- if (bgLayer->isSizeSet()) {
- int w = scaledWidth;
- int h = scaledHeight;
- Length bgWidth = bgLayer->size().width();
- Length bgHeight = bgLayer->size().height();
-
- if (bgWidth.isFixed())
- w = bgWidth.value();
- else if (bgWidth.isPercent())
- w = bgWidth.calcValue(scaledWidth);
-
- if (bgHeight.isFixed())
- h = bgHeight.value();
- else if (bgHeight.isPercent())
- h = bgHeight.calcValue(scaledHeight);
-
- // If one of the values is auto we have to use the appropriate
- // scale to maintain our aspect ratio.
- if (bgWidth.isAuto() && !bgHeight.isAuto())
- w = bg->imageSize(this, style()->effectiveZoom()).width() * h / bg->imageSize(this, style()->effectiveZoom()).height();
- else if (!bgWidth.isAuto() && bgHeight.isAuto())
- h = bg->imageSize(this, style()->effectiveZoom()).height() * w / bg->imageSize(this, style()->effectiveZoom()).width();
- else if (bgWidth.isAuto() && bgHeight.isAuto()) {
- // If both width and height are auto, we just want to use the image's
- // intrinsic size.
- w = bg->imageSize(this, style()->effectiveZoom()).width();
- h = bg->imageSize(this, style()->effectiveZoom()).height();
- }
-
- return IntSize(max(1, w), max(1, h));
- } else
- return bg->imageSize(this, style()->effectiveZoom());
-}
-
void RenderBox::imageChanged(WrappedImagePtr image, const IntRect*)
{
if (!parent())
return;
- if (isRenderInline() || style()->borderImage().image() && style()->borderImage().image()->data() == image ||
+ if (style()->borderImage().image() && style()->borderImage().image()->data() == image ||
style()->maskBoxImage().image() && style()->maskBoxImage().image()->data() == image) {
repaint();
return;
}
bool didFullRepaint = repaintLayerRectsForImage(image, style()->backgroundLayers(), true);
- if (!didFullRepaint) {
+ if (!didFullRepaint)
repaintLayerRectsForImage(image, style()->maskLayers(), false);
- }
}
bool RenderBox::repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer* layers, bool drawingBackground)
@@ -983,256 +827,6 @@
return false;
}
-void RenderBox::calculateBackgroundImageGeometry(const FillLayer* bgLayer, int tx, int ty, int w, int h, IntRect& destRect, IntPoint& phase, IntSize& tileSize)
-{
- int pw;
- int ph;
- int left = 0;
- int right = 0;
- int top = 0;
- int bottom = 0;
- int cx;
- int cy;
- int rw = 0;
- int rh = 0;
-
- // CSS2 chapter 14.2.1
-
- if (bgLayer->attachment()) {
- // Scroll
- if (bgLayer->origin() != BorderFillBox) {
- left = borderLeft();
- right = borderRight();
- top = borderTop();
- bottom = borderBottom();
- if (bgLayer->origin() == ContentFillBox) {
- left += paddingLeft();
- right += paddingRight();
- top += paddingTop();
- bottom += paddingBottom();
- }
- }
-
- // The background of the box generated by the root element covers the entire canvas including
- // its margins. Since those were added in already, we have to factor them out when computing the
- // box used by background-origin/size/position.
- if (isRoot()) {
- rw = width() - left - right;
- rh = height() - top - bottom;
- left += marginLeft();
- right += marginRight();
- top += marginTop();
- bottom += marginBottom();
- }
- cx = tx;
- cy = ty;
- pw = w - left - right;
- ph = h - top - bottom;
- } else {
- // Fixed
- IntRect vr = viewRect();
- cx = vr.x();
- cy = vr.y();
- pw = vr.width();
- ph = vr.height();
- }
-
- int sx = 0;
- int sy = 0;
- int cw;
- int ch;
-
- IntSize scaledImageSize;
- if (isRoot() && bgLayer->attachment())
- scaledImageSize = calculateBackgroundSize(bgLayer, rw, rh);
- else
- scaledImageSize = calculateBackgroundSize(bgLayer, pw, ph);
-
- int scaledImageWidth = scaledImageSize.width();
- int scaledImageHeight = scaledImageSize.height();
-
- EFillRepeat backgroundRepeat = bgLayer->repeat();
-
- int xPosition;
- if (isRoot() && bgLayer->attachment())
- xPosition = bgLayer->xPosition().calcMinValue(rw - scaledImageWidth, true);
- else
- xPosition = bgLayer->xPosition().calcMinValue(pw - scaledImageWidth, true);
- if (backgroundRepeat == RepeatFill || backgroundRepeat == RepeatXFill) {
- cw = pw + left + right;
- sx = scaledImageWidth ? scaledImageWidth - (xPosition + left) % scaledImageWidth : 0;
- } else {
- cx += max(xPosition + left, 0);
- sx = -min(xPosition + left, 0);
- cw = scaledImageWidth + min(xPosition + left, 0);
- }
-
- int yPosition;
- if (isRoot() && bgLayer->attachment())
- yPosition = bgLayer->yPosition().calcMinValue(rh - scaledImageHeight, true);
- else
- yPosition = bgLayer->yPosition().calcMinValue(ph - scaledImageHeight, true);
- if (backgroundRepeat == RepeatFill || backgroundRepeat == RepeatYFill) {
- ch = ph + top + bottom;
- sy = scaledImageHeight ? scaledImageHeight - (yPosition + top) % scaledImageHeight : 0;
- } else {
- cy += max(yPosition + top, 0);
- sy = -min(yPosition + top, 0);
- ch = scaledImageHeight + min(yPosition + top, 0);
- }
-
- if (!bgLayer->attachment()) {
- sx += max(tx - cx, 0);
- sy += max(ty - cy, 0);
- }
-
- destRect = IntRect(cx, cy, cw, ch);
- destRect.intersect(IntRect(tx, ty, w, h));
- phase = IntPoint(sx, sy);
- tileSize = IntSize(scaledImageWidth, scaledImageHeight);
-}
-
-void RenderBox::paintFillLayerExtended(const PaintInfo& paintInfo, const Color& c, const FillLayer* bgLayer, int clipY, int clipH,
- int tx, int ty, int w, int h, InlineFlowBox* box, CompositeOperator op)
-{
- GraphicsContext* context = paintInfo.context;
- bool includeLeftEdge = box ? box->includeLeftEdge() : true;
- bool includeRightEdge = box ? box->includeRightEdge() : true;
- int bLeft = includeLeftEdge ? borderLeft() : 0;
- int bRight = includeRightEdge ? borderRight() : 0;
- int pLeft = includeLeftEdge ? paddingLeft() : 0;
- int pRight = includeRightEdge ? paddingRight() : 0;
-
- bool clippedToBorderRadius = false;
- if (style()->hasBorderRadius() && (includeLeftEdge || includeRightEdge)) {
- context->save();
- context->addRoundedRectClip(IntRect(tx, ty, w, h),
- includeLeftEdge ? style()->borderTopLeftRadius() : IntSize(),
- includeRightEdge ? style()->borderTopRightRadius() : IntSize(),
- includeLeftEdge ? style()->borderBottomLeftRadius() : IntSize(),
- includeRightEdge ? style()->borderBottomRightRadius() : IntSize());
- clippedToBorderRadius = true;
- }
-
- if (bgLayer->clip() == PaddingFillBox || bgLayer->clip() == ContentFillBox) {
- // Clip to the padding or content boxes as necessary.
- bool includePadding = bgLayer->clip() == ContentFillBox;
- int x = tx + bLeft + (includePadding ? pLeft : 0);
- int y = ty + borderTop() + (includePadding ? paddingTop() : 0);
- int width = w - bLeft - bRight - (includePadding ? pLeft + pRight : 0);
- int height = h - borderTop() - borderBottom() - (includePadding ? paddingTop() + paddingBottom() : 0);
- context->save();
- context->clip(IntRect(x, y, width, height));
- } else if (bgLayer->clip() == TextFillBox) {
- // We have to draw our text into a mask that can then be used to clip background drawing.
- // First figure out how big the mask has to be. It should be no bigger than what we need
- // to actually render, so we should intersect the dirty rect with the border box of the background.
- IntRect maskRect(tx, ty, w, h);
- maskRect.intersect(paintInfo.rect);
-
- // Now create the mask.
- auto_ptr<ImageBuffer> maskImage = ImageBuffer::create(maskRect.size(), false);
- if (!maskImage.get())
- return;
-
- GraphicsContext* maskImageContext = maskImage->context();
- maskImageContext->translate(-maskRect.x(), -maskRect.y());
-
- // Now add the text to the clip. We do this by painting using a special paint phase that signals to
- // InlineTextBoxes that they should just add their contents to the clip.
- PaintInfo info(maskImageContext, maskRect, PaintPhaseTextClip, true, 0, 0);
- if (box)
- box->paint(info, tx - box->xPos(), ty - box->yPos());
- else
- paint(info, tx, ty);
-
- // The mask has been created. Now we just need to clip to it.
- context->save();
- context->clipToImageBuffer(maskRect, maskImage.get());
- }
-
- StyleImage* bg = bgLayer->image();
- bool shouldPaintBackgroundImage = bg && bg->canRender(style()->effectiveZoom());
- Color bgColor = c;
-
- // When this style flag is set, change existing background colors and images to a solid white background.
- // If there's no bg color or image, leave it untouched to avoid affecting transparency.
- // We don't try to avoid loading the background images, because this style flag is only set
- // when printing, and at that point we've already loaded the background images anyway. (To avoid
- // loading the background images we'd have to do this check when applying styles rather than
- // while rendering.)
- if (style()->forceBackgroundsToWhite()) {
- // Note that we can't reuse this variable below because the bgColor might be changed
- bool shouldPaintBackgroundColor = !bgLayer->next() && bgColor.isValid() && bgColor.alpha() > 0;
- if (shouldPaintBackgroundImage || shouldPaintBackgroundColor) {
- bgColor = Color::white;
- shouldPaintBackgroundImage = false;
- }
- }
-
- // Only fill with a base color (e.g., white) if we're the root document, since iframes/frames with
- // no background in the child document should show the parent's background.
- bool isTransparent = false;
- if (!bgLayer->next() && isRoot() && !(bgColor.isValid() && bgColor.alpha() > 0) && view()->frameView()) {
- Node* elt = document()->ownerElement();
- if (elt) {
- if (!elt->hasTagName(frameTag)) {
- // Locate the <body> element using the DOM. This is easier than trying
- // to crawl around a render tree with potential :before/:after content and
- // anonymous blocks created by inline <body> tags etc. We can locate the <body>
- // render object very easily via the DOM.
- HTMLElement* body = document()->body();
- isTransparent = !body || !body->hasLocalName(framesetTag); // Can't scroll a frameset document anyway.
- }
- } else
- isTransparent = view()->frameView()->isTransparent();
-
- // FIXME: This needs to be dynamic. We should be able to go back to blitting if we ever stop being transparent.
- if (isTransparent)
- view()->frameView()->setUseSlowRepaints(); // The parent must show behind the child.
- }
-
- // Paint the color first underneath all images.
- if (!bgLayer->next()) {
- IntRect rect(tx, clipY, w, clipH);
- // If we have an alpha and we are painting the root element, go ahead and blend with the base background color.
- if (isRoot() && (!bgColor.isValid() || bgColor.alpha() < 0xFF) && !isTransparent) {
- Color baseColor = view()->frameView()->baseBackgroundColor();
- if (baseColor.alpha() > 0) {
- context->save();
- context->setCompositeOperation(CompositeCopy);
- context->fillRect(rect, baseColor);
- context->restore();
- } else
- context->clearRect(rect);
- }
-
- if (bgColor.isValid() && bgColor.alpha() > 0)
- context->fillRect(rect, bgColor);
- }
-
- // no progressive loading of the background image
- if (shouldPaintBackgroundImage) {
- IntRect destRect;
- IntPoint phase;
- IntSize tileSize;
-
- calculateBackgroundImageGeometry(bgLayer, tx, ty, w, h, destRect, phase, tileSize);
- if (!destRect.isEmpty()) {
- CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer->composite() : op;
- context->drawTiledImage(bg->image(this, tileSize), destRect, phase, tileSize, compositeOp);
- }
- }
-
- if (bgLayer->clip() != BorderFillBox)
- // Undo the background clip
- context->restore();
-
- if (clippedToBorderRadius)
- // Undo the border radius clip
- context->restore();
-}
-
#if PLATFORM(MAC)
void RenderBox::paintCustomHighlight(int tx, int ty, const AtomicString& type, bool behindText)
@@ -1962,7 +1556,7 @@
case Fixed:
return calcContentBoxWidth(width.value());
case Percent: {
- const int cw = isPositioned() ? containingBlockWidthForPositioned(container()) : containingBlockWidth();
+ const int cw = isPositioned() ? containingBlockWidthForPositioned(toRenderBoxModelObject(container())) : containingBlockWidth();
if (cw > 0)
return calcContentBoxWidth(width.calcMinValue(cw));
}
@@ -2004,7 +1598,7 @@
return calcContentBoxHeight(height.calcValue(newHeight));
}
- int availableHeight = isPositioned() ? containingBlockHeightForPositioned(cb) : toRenderBox(cb)->availableHeight();
+ int availableHeight = isPositioned() ? containingBlockHeightForPositioned(toRenderBoxModelObject(cb)) : toRenderBox(cb)->availableHeight();
// It is necessary to use the border-box to match WinIE's broken
// box model. This is essential for sizing inside
@@ -2074,48 +1668,46 @@
m_marginBottom = style()->marginBottom().calcMinValue(cw);
}
-int RenderBox::containingBlockWidthForPositioned(const RenderObject* containingBlock) const
+int RenderBox::containingBlockWidthForPositioned(const RenderBoxModelObject* containingBlock) const
{
- if (containingBlock->isRenderInline()) {
- ASSERT(containingBlock->isRelPositioned());
+ if (containingBlock->isBox()) {
+ const RenderBox* containingBlockBox = toRenderBox(containingBlock);
+ return containingBlockBox->width() - containingBlockBox->borderLeft() - containingBlockBox->borderRight() - containingBlockBox->verticalScrollbarWidth();
+ }
+
+ ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned());
- const RenderInline* flow = toRenderInline(containingBlock);
- InlineFlowBox* first = flow->firstLineBox();
- InlineFlowBox* last = flow->lastLineBox();
+ const RenderInline* flow = toRenderInline(containingBlock);
+ InlineFlowBox* first = flow->firstLineBox();
+ InlineFlowBox* last = flow->lastLineBox();
- // If the containing block is empty, return a width of 0.
- if (!first || !last)
- return 0;
+ // If the containing block is empty, return a width of 0.
+ if (!first || !last)
+ return 0;
- int fromLeft;
- int fromRight;
- if (containingBlock->style()->direction() == LTR) {
- fromLeft = first->xPos() + first->borderLeft();
- fromRight = last->xPos() + last->width() - last->borderRight();
- } else {
- fromRight = first->xPos() + first->width() - first->borderRight();
- fromLeft = last->xPos() + last->borderLeft();
- }
-
- return max(0, (fromRight - fromLeft));
+ int fromLeft;
+ int fromRight;
+ if (containingBlock->style()->direction() == LTR) {
+ fromLeft = first->xPos() + first->borderLeft();
+ fromRight = last->xPos() + last->width() - last->borderRight();
+ } else {
+ fromRight = first->xPos() + first->width() - first->borderRight();
+ fromLeft = last->xPos() + last->borderLeft();
}
- const RenderBox* containingBlockBox = toRenderBox(containingBlock);
- return containingBlockBox->width() - containingBlockBox->borderLeft() - containingBlockBox->borderRight() - containingBlockBox->verticalScrollbarWidth();
+ return max(0, (fromRight - fromLeft));
}
-int RenderBox::containingBlockHeightForPositioned(const RenderObject* containingBlock) const
-{
- const RenderBox* containingBlockBox = toRenderBox(containingBlock);
-
- int heightResult;
- if (containingBlock->isRenderInline()) {
+int RenderBox::containingBlockHeightForPositioned(const RenderBoxModelObject* containingBlock) const
+{
+ int heightResult = 0;
+ if (containingBlock->isBox())
+ heightResult = toRenderBox(containingBlock)->height();
+ else if (containingBlock->isRenderInline()) {
ASSERT(containingBlock->isRelPositioned());
heightResult = toRenderInline(containingBlock)->linesBoundingBox().height();
- } else
- heightResult = containingBlockBox->height();
-
- return heightResult - containingBlockBox->borderTop() - containingBlockBox->borderBottom();
+ }
+ return heightResult - containingBlock->borderTop() - containingBlock->borderBottom();
}
void RenderBox::calcAbsoluteHorizontal()
@@ -2152,7 +1744,7 @@
// We don't use containingBlock(), since we may be positioned by an enclosing
// relative positioned inline.
- const RenderBox* containerBlock = toRenderBox(container());
+ const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(container());
const int containerWidth = containingBlockWidthForPositioned(containerBlock);
@@ -2196,15 +1788,21 @@
if (containerDirection == LTR) {
// 'staticX' should already have been set through layout of the parent.
int staticPosition = layer()->staticX() - containerBlock->borderLeft();
- for (RenderBox* po = parentBox(); po && po != containerBlock; po = po->parentBox())
- staticPosition += po->x();
+ for (RenderObject* po = parent(); po && po != containerBlock; po = po->parent()) {
+ if (po->isBox())
+ staticPosition += toRenderBox(po)->x();
+ }
left.setValue(Fixed, staticPosition);
} else {
- RenderBox* po = parentBox();
+ RenderObject* po = parent();
// 'staticX' should already have been set through layout of the parent.
- int staticPosition = layer()->staticX() + containerWidth + containerBlock->borderRight() - po->width();
- for (; po && po != containerBlock; po = po->parentBox())
- staticPosition -= po->x();
+ int staticPosition = layer()->staticX() + containerWidth + containerBlock->borderRight();
+ if (po->isBox())
+ staticPosition -= toRenderBox(po)->width();
+ for (; po && po != containerBlock; po = po->parent()) {
+ if (po->isBox())
+ staticPosition -= toRenderBox(po)->x();
+ }
right.setValue(Fixed, staticPosition);
}
}
@@ -2272,7 +1870,7 @@
setWidth(width() + bordersPlusPadding);
}
-void RenderBox::calcAbsoluteHorizontalValues(Length width, const RenderBox* containerBlock, TextDirection containerDirection,
+void RenderBox::calcAbsoluteHorizontalValues(Length width, const RenderBoxModelObject* containerBlock, TextDirection containerDirection,
const int containerWidth, const int bordersPlusPadding,
const Length left, const Length right, const Length marginLeft, const Length marginRight,
int& widthValue, int& marginLeftValue, int& marginRightValue, int& xPos)
@@ -2459,7 +2057,7 @@
// We don't use containingBlock(), since we may be positioned by an enclosing relpositioned inline.
- const RenderBox* containerBlock = toRenderBox(container());
+ const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(container());
const int containerHeight = containingBlockHeightForPositioned(containerBlock);
@@ -2491,9 +2089,9 @@
if (top.isAuto() && bottom.isAuto()) {
// staticY should already have been set through layout of the parent()
int staticTop = layer()->staticY() - containerBlock->borderTop();
- for (RenderBox* po = parentBox(); po && po != containerBlock; po = po->parentBox()) {
- if (!po->isTableRow())
- staticTop += po->y();
+ for (RenderObject* po = parent(); po && po != containerBlock; po = po->parent()) {
+ if (po->isBox() && !po->isTableRow())
+ staticTop += toRenderBox(po)->y();
}
top.setValue(Fixed, staticTop);
}
@@ -2553,7 +2151,7 @@
setHeight(h + bordersPlusPadding);
}
-void RenderBox::calcAbsoluteVerticalValues(Length h, const RenderBox* containerBlock,
+void RenderBox::calcAbsoluteVerticalValues(Length h, const RenderBoxModelObject* containerBlock,
const int containerHeight, const int bordersPlusPadding,
const Length top, const Length bottom, const Length marginTop, const Length marginBottom,
int& heightValue, int& marginTopValue, int& marginBottomValue, int& yPos)
@@ -2682,7 +2280,7 @@
// We don't use containingBlock(), since we may be positioned by an enclosing
// relative positioned inline.
- const RenderBox* containerBlock = toRenderBox(container());
+ const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(container());
const int containerWidth = containingBlockWidthForPositioned(containerBlock);
@@ -2718,15 +2316,21 @@
if (containerDirection == LTR) {
// 'staticX' should already have been set through layout of the parent.
int staticPosition = layer()->staticX() - containerBlock->borderLeft();
- for (RenderBox* po = parentBox(); po && po != containerBlock; po = po->parentBox())
- staticPosition += po->x();
+ for (RenderObject* po = parent(); po && po != containerBlock; po = po->parent()) {
+ if (po->isBox())
+ staticPosition += toRenderBox(po)->x();
+ }
left.setValue(Fixed, staticPosition);
} else {
- RenderBox* po = parentBox();
+ RenderObject* po = parent();
// 'staticX' should already have been set through layout of the parent.
- int staticPosition = layer()->staticX() + containerWidth + containerBlock->borderRight() - po->width();
- for (; po && po != containerBlock; po = po->parentBox())
- staticPosition -= po->x();
+ int staticPosition = layer()->staticX() + containerWidth + toRenderBoxModelObject(containerBlock)->borderRight();
+ if (po->isBox())
+ po -= toRenderBox(po)->width();
+ for ( ; po && po != containerBlock; po = po->parent()) {
+ if (po->isBox())
+ staticPosition += toRenderBox(po)->x();
+ }
right.setValue(Fixed, staticPosition);
}
}
@@ -2855,7 +2459,7 @@
// the numbers correspond to numbers in spec)
// We don't use containingBlock(), since we may be positioned by an enclosing relpositioned inline.
- const RenderBox* containerBlock = toRenderBox(container());
+ const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(container());
const int containerHeight = containingBlockHeightForPositioned(containerBlock);
@@ -2884,9 +2488,9 @@
if (top.isAuto() && bottom.isAuto()) {
// staticY should already have been set through layout of the parent().
int staticTop = layer()->staticY() - containerBlock->borderTop();
- for (RenderBox* po = parentBox(); po && po != containerBlock; po = po->parentBox()) {
- if (!po->isTableRow())
- staticTop += po->y();
+ for (RenderObject* po = parent(); po && po != containerBlock; po = po->parent()) {
+ if (po->isBox() && !po->isTableRow())
+ staticTop += toRenderBox(po)->y();
}
top.setValue(Fixed, staticTop);
}
@@ -3092,9 +2696,9 @@
RenderBox* renderer = toRenderBox(renderObject);
- int top = borderTop() + paddingTop() + (isTableRow() ? 0 : renderer->y());
+ int top = renderer->borderTop() + renderer->paddingTop() + (isTableRow() ? 0 : renderer->y());
int bottom = top + renderer->contentHeight();
- int left = borderLeft() + paddingLeft() + (isTableRow() ? 0 : renderer->x());
+ int left = renderer->borderLeft() + renderer->paddingLeft() + (isTableRow() ? 0 : renderer->x());
int right = left + renderer->contentWidth();
if (xPos <= right && xPos >= left && yPos <= top && yPos >= bottom) {
« no previous file with comments | « third_party/WebKit/WebCore/rendering/RenderBox.h ('k') | third_party/WebKit/WebCore/rendering/RenderBoxModelObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698