Index: third_party/WebKit/WebCore/rendering/RenderLayer.cpp |
=================================================================== |
--- third_party/WebKit/WebCore/rendering/RenderLayer.cpp (revision 9383) |
+++ third_party/WebKit/WebCore/rendering/RenderLayer.cpp (working copy) |
@@ -126,7 +126,7 @@ |
renderArena->free(*(size_t *)this, this); |
} |
-RenderLayer::RenderLayer(RenderBoxModelObject* renderer) |
+RenderLayer::RenderLayer(RenderBox* renderer) |
: m_renderer(renderer) |
, m_parent(0) |
, m_previous(0) |
@@ -228,14 +228,6 @@ |
} |
#endif // USE(ACCELERATED_COMPOSITING) |
-void RenderLayer::setStaticY(int staticY) |
-{ |
- if (m_staticY == staticY) |
- return; |
- m_staticY = staticY; |
- renderer()->setChildNeedsLayout(true, false); |
-} |
- |
void RenderLayer::updateLayerPositions(bool doFullRepaint, bool checkForRepaint) |
{ |
if (doFullRepaint) { |
@@ -270,7 +262,7 @@ |
// from updateScrollInfoAfterLayout(). |
ASSERT(!view->layoutStateEnabled()); |
- RenderBoxModelObject* repaintContainer = renderer()->containerForRepaint(); |
+ RenderBox* repaintContainer = renderer()->containerForRepaint(); |
IntRect newRect = renderer()->clippedOverflowRectForRepaint(repaintContainer); |
IntRect newOutlineBox = renderer()->outlineBoundsForRepaint(repaintContainer); |
if (checkForRepaint) { |
@@ -324,10 +316,8 @@ |
} |
if (hasTransform) { |
- RenderBox* box = renderBox(); |
- ASSERT(box); |
m_transform->reset(); |
- box->style()->applyTransform(*m_transform, box->borderBoxRect().size()); |
+ renderer()->style()->applyTransform(*m_transform, renderer()->borderBoxRect().size()); |
} |
} |
@@ -338,7 +328,7 @@ |
m_visibleContentStatusDirty = false; |
m_hasVisibleContent = b; |
if (m_hasVisibleContent) { |
- RenderBoxModelObject* repaintContainer = renderer()->containerForRepaint(); |
+ RenderBox* repaintContainer = renderer()->containerForRepaint(); |
m_repaintRect = renderer()->clippedOverflowRectForRepaint(repaintContainer); |
m_outlineBox = renderer()->outlineBoundsForRepaint(repaintContainer); |
if (!isOverflowOnly()) |
@@ -428,30 +418,26 @@ |
// Clear our cached clip rect information. |
clearClipRects(); |
- RenderBox* rendererBox = renderBox(); |
- |
- int x = rendererBox ? rendererBox->x() : 0; |
- int y = rendererBox ? rendererBox->y() : 0; |
+ int x = renderer()->x(); |
+ int y = renderer()->y(); |
if (!renderer()->isPositioned() && renderer()->parent()) { |
// We must adjust our position by walking up the render tree looking for the |
// nearest enclosing object with a layer. |
- RenderObject* curr = renderer()->parent(); |
+ RenderBox* curr = renderer()->parentBox(); |
while (curr && !curr->hasLayer()) { |
- if (curr->isBox() && !curr->isTableRow()) { |
+ if (!curr->isTableRow()) { |
// Rows and cells share the same coordinate space (that of the section). |
// Omit them when computing our xpos/ypos. |
- RenderBox* currBox = toRenderBox(curr); |
- x += currBox->x(); |
- y += currBox->y(); |
+ x += curr->x(); |
+ y += curr->y(); |
} |
- curr = curr->parent(); |
+ curr = curr->parentBox(); |
} |
- if (curr->isBox() && curr->isTableRow()) { |
+ if (curr->isTableRow()) { |
// Put ourselves into the row coordinate space. |
- RenderBox* currBox = toRenderBox(curr); |
- x -= currBox->x(); |
- y -= currBox->y(); |
+ x -= curr->x(); |
+ y -= curr->y(); |
} |
} |
@@ -470,7 +456,7 @@ |
positionedParent->subtractScrolledContentOffset(x, y); |
if (renderer()->isPositioned() && positionedParent->renderer()->isRelPositioned() && positionedParent->renderer()->isRenderInline()) { |
- IntSize offset = toRenderInline(positionedParent->renderer())->relativePositionedInlineOffset(toRenderBox(renderer())); |
+ IntSize offset = toRenderInline(positionedParent->renderer())->relativePositionedInlineOffset(renderer()); |
x += offset.width(); |
y += offset.height(); |
} |
@@ -486,15 +472,15 @@ |
IntRect lineBox = inlineFlow->linesBoundingBox(); |
setWidth(lineBox.width()); |
setHeight(lineBox.height()); |
- } else if (RenderBox* box = renderBox()) { |
- setWidth(box->width()); |
- setHeight(box->height()); |
+ } else { |
+ setWidth(renderer()->width()); |
+ setHeight(renderer()->height()); |
- if (!box->hasOverflowClip()) { |
- if (box->overflowWidth() > box->width()) |
- setWidth(box->overflowWidth()); |
- if (box->overflowHeight() > box->height()) |
- setHeight(box->overflowHeight()); |
+ if (!renderer()->hasOverflowClip()) { |
+ if (renderer()->overflowWidth() > renderer()->width()) |
+ setWidth(renderer()->overflowWidth()); |
+ if (renderer()->overflowHeight() > renderer()->height()) |
+ setHeight(renderer()->overflowHeight()); |
} |
} |
} |
@@ -878,18 +864,14 @@ |
void RenderLayer::scrollToOffset(int x, int y, bool updateScrollbars, bool repaint) |
{ |
- RenderBox* box = renderBox(); |
- if (!box) |
- return; |
- |
- if (box->style()->overflowX() != OMARQUEE) { |
+ if (renderer()->style()->overflowX() != OMARQUEE) { |
if (x < 0) x = 0; |
if (y < 0) y = 0; |
// Call the scrollWidth/Height functions so that the dimensions will be computed if they need |
// to be (for overflow:hidden blocks). |
- int maxX = scrollWidth() - box->clientWidth(); |
- int maxY = scrollHeight() - box->clientHeight(); |
+ int maxX = scrollWidth() - renderer()->clientWidth(); |
+ int maxY = scrollHeight() - renderer()->clientHeight(); |
if (x > maxX) x = maxX; |
if (y > maxY) y = maxY; |
@@ -948,7 +930,7 @@ |
// Schedule the scroll DOM event. |
if (view) { |
if (FrameView* frameView = view->frameView()) |
- frameView->scheduleEvent(Event::create(eventNames().scrollEvent, false, false), renderer()->element()); |
+ frameView->scheduleEvent(Event::create(eventNames().scrollEvent, false, false), EventTargetNodeCast(renderer()->element())); |
} |
} |
@@ -973,12 +955,10 @@ |
if (renderer()->hasOverflowClip() && !restrictedByLineClamp) { |
// Don't scroll to reveal an overflow layer that is restricted by the -webkit-line-clamp property. |
// This will prevent us from revealing text hidden by the slider in Safari RSS. |
- RenderBox* box = renderBox(); |
- ASSERT(box); |
- FloatPoint absPos = box->localToAbsolute(); |
- absPos.move(box->borderLeft(), box->borderTop()); |
+ FloatPoint absPos = renderer()->localToAbsolute(); |
+ absPos.move(renderer()->borderLeft(), renderer()->borderTop()); |
- IntRect layerBounds = IntRect(absPos.x() + scrollXOffset(), absPos.y() + scrollYOffset(), box->clientWidth(), box->clientHeight()); |
+ IntRect layerBounds = IntRect(absPos.x() + scrollXOffset(), absPos.y() + scrollYOffset(), renderer()->clientWidth(), renderer()->clientHeight()); |
IntRect exposeRect = IntRect(rect.x() + scrollXOffset(), rect.y() + scrollYOffset(), rect.width(), rect.height()); |
IntRect r = getRectToExpose(layerBounds, exposeRect, alignX, alignY); |
@@ -997,7 +977,7 @@ |
newRect.setX(rect.x() - diffX); |
newRect.setY(rect.y() - diffY); |
} |
- } else if (!parentLayer && renderer()->isBox() && renderBox()->canBeProgramaticallyScrolled(scrollToAnchor)) { |
+ } else if (!parentLayer && renderer()->canBeProgramaticallyScrolled(scrollToAnchor)) { |
if (frameView) { |
if (renderer()->document() && renderer()->document()->ownerElement() && renderer()->document()->ownerElement()->renderer()) { |
IntRect viewRect = frameView->visibleContentRect(); |
@@ -1257,7 +1237,6 @@ |
static IntRect resizerCornerRect(const RenderLayer* layer, const IntRect& bounds) |
{ |
- ASSERT(layer->renderer()->isBox()); |
if (layer->renderer()->style()->resize() == RESIZE_NONE) |
return IntRect(); |
return cornerRect(layer, bounds); |
@@ -1265,19 +1244,16 @@ |
bool RenderLayer::scrollbarCornerPresent() const |
{ |
- ASSERT(renderer()->isBox()); |
- return !scrollCornerRect(this, renderBox()->borderBoxRect()).isEmpty(); |
+ return !scrollCornerRect(this, renderer()->borderBoxRect()).isEmpty(); |
} |
void RenderLayer::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect) |
{ |
IntRect scrollRect = rect; |
- RenderBox* box = renderBox(); |
- ASSERT(box); |
if (scrollbar == m_vBar.get()) |
- scrollRect.move(box->width() - box->borderRight() - box->width(), box->borderTop()); |
+ scrollRect.move(renderer()->width() - renderer()->borderRight() - scrollbar->width(), renderer()->borderTop()); |
else |
- scrollRect.move(box->borderLeft(), box->height() - box->borderBottom() - scrollbar->height()); |
+ scrollRect.move(renderer()->borderLeft(), renderer()->height() - renderer()->borderBottom() - scrollbar->height()); |
renderer()->repaintRectangle(scrollRect); |
} |
@@ -1376,23 +1352,19 @@ |
if (!m_hBar && !m_vBar && (!renderer()->hasOverflowClip() || renderer()->style()->resize() == RESIZE_NONE)) |
return; |
- RenderBox* box = renderBox(); |
- if (!box) |
- return; |
- |
- IntRect borderBox = box->borderBoxRect(); |
+ IntRect borderBox = renderer()->borderBoxRect(); |
IntRect scrollCorner(scrollCornerRect(this, borderBox)); |
IntRect absBounds(borderBox.x() + tx, borderBox.y() + ty, borderBox.width(), borderBox.height()); |
if (m_vBar) |
- m_vBar->setFrameRect(IntRect(absBounds.right() - box->borderRight() - m_vBar->width(), |
- absBounds.y() + box->borderTop(), |
+ m_vBar->setFrameRect(IntRect(absBounds.right() - renderer()->borderRight() - m_vBar->width(), |
+ absBounds.y() + renderer()->borderTop(), |
m_vBar->width(), |
- absBounds.height() - (box->borderTop() + box->borderBottom()) - scrollCorner.height())); |
+ absBounds.height() - (renderer()->borderTop() + renderer()->borderBottom()) - scrollCorner.height())); |
if (m_hBar) |
- m_hBar->setFrameRect(IntRect(absBounds.x() + box->borderLeft(), |
- absBounds.bottom() - box->borderBottom() - m_hBar->height(), |
- absBounds.width() - (box->borderLeft() + box->borderRight()) - scrollCorner.width(), |
+ m_hBar->setFrameRect(IntRect(absBounds.x() + renderer()->borderLeft(), |
+ absBounds.bottom() - renderer()->borderBottom() - m_hBar->height(), |
+ absBounds.width() - (renderer()->borderLeft() + renderer()->borderRight()) - scrollCorner.width(), |
m_hBar->height())); |
if (m_scrollCorner) |
@@ -1417,22 +1389,19 @@ |
void RenderLayer::computeScrollDimensions(bool* needHBar, bool* needVBar) |
{ |
- RenderBox* box = renderBox(); |
- ASSERT(box); |
- |
m_scrollDimensionsDirty = false; |
bool ltr = renderer()->style()->direction() == LTR; |
- int clientWidth = box->clientWidth(); |
- int clientHeight = box->clientHeight(); |
+ int clientWidth = renderer()->clientWidth(); |
+ int clientHeight = renderer()->clientHeight(); |
- m_scrollLeftOverflow = ltr ? 0 : min(0, box->leftmostPosition(true, false) - box->borderLeft()); |
+ m_scrollLeftOverflow = ltr ? 0 : min(0, renderer()->leftmostPosition(true, false) - renderer()->borderLeft()); |
int rightPos = ltr ? |
- box->rightmostPosition(true, false) - box->borderLeft() : |
+ renderer()->rightmostPosition(true, false) - renderer()->borderLeft() : |
clientWidth - m_scrollLeftOverflow; |
- int bottomPos = renderer()->lowestPosition(true, false) - box->borderTop(); |
+ int bottomPos = renderer()->lowestPosition(true, false) - renderer()->borderTop(); |
m_scrollWidth = max(rightPos, clientWidth); |
m_scrollHeight = max(bottomPos, clientHeight); |
@@ -1464,7 +1433,7 @@ |
if (FrameView* frameView = renderer()->document()->view()) { |
frameView->scheduleEvent(OverflowEvent::create(horizontalOverflowChanged, horizontalOverflow, verticalOverflowChanged, verticalOverflow), |
- renderer()->element()); |
+ EventTargetNodeCast(renderer()->element())); |
} |
} |
} |
@@ -1472,20 +1441,16 @@ |
void |
RenderLayer::updateScrollInfoAfterLayout() |
{ |
- RenderBox* box = renderBox(); |
- if (!box) |
- return; |
- |
m_scrollDimensionsDirty = true; |
bool horizontalOverflow, verticalOverflow; |
computeScrollDimensions(&horizontalOverflow, &verticalOverflow); |
- if (box->style()->overflowX() != OMARQUEE) { |
+ if (renderer()->style()->overflowX() != OMARQUEE) { |
// Layout may cause us to be in an invalid scroll position. In this case we need |
// to pull our scroll offsets back to the max (or push them up to the min). |
- int newX = max(0, min(scrollXOffset(), scrollWidth() - box->clientWidth())); |
- int newY = max(0, min(m_scrollY, scrollHeight() - box->clientHeight())); |
+ int newX = max(0, min(scrollXOffset(), scrollWidth() - renderer()->clientWidth())); |
+ int newY = max(0, min(m_scrollY, scrollHeight() - renderer()->clientHeight())); |
if (newX != scrollXOffset() || newY != m_scrollY) { |
RenderView* view = renderer()->view(); |
ASSERT(view); |
@@ -1517,12 +1482,12 @@ |
setHasVerticalScrollbar(false); |
// overflow:auto may need to lay out again if scrollbars got added/removed. |
- bool scrollbarsChanged = (box->hasAutoHorizontalScrollbar() && haveHorizontalBar != horizontalOverflow) || |
- (box->hasAutoVerticalScrollbar() && haveVerticalBar != verticalOverflow); |
+ bool scrollbarsChanged = (renderer()->hasAutoHorizontalScrollbar() && haveHorizontalBar != horizontalOverflow) || |
+ (renderer()->hasAutoVerticalScrollbar() && haveVerticalBar != verticalOverflow); |
if (scrollbarsChanged) { |
- if (box->hasAutoHorizontalScrollbar()) |
+ if (renderer()->hasAutoHorizontalScrollbar()) |
setHasHorizontalScrollbar(horizontalOverflow); |
- if (box->hasAutoVerticalScrollbar()) |
+ if (renderer()->hasAutoVerticalScrollbar()) |
setHasVerticalScrollbar(verticalOverflow); |
#if ENABLE(DASHBOARD_SUPPORT) |
@@ -1548,14 +1513,14 @@ |
} |
// If overflow:scroll is turned into overflow:auto a bar might still be disabled (Bug 11985). |
- if (m_hBar && box->hasAutoHorizontalScrollbar()) |
+ if (m_hBar && renderer()->hasAutoHorizontalScrollbar()) |
m_hBar->setEnabled(true); |
- if (m_vBar && box->hasAutoVerticalScrollbar()) |
+ if (m_vBar && renderer()->hasAutoVerticalScrollbar()) |
m_vBar->setEnabled(true); |
// Set up the range (and page step/line step). |
if (m_hBar) { |
- int clientWidth = box->clientWidth(); |
+ int clientWidth = renderer()->clientWidth(); |
int pageStep = (clientWidth - cAmountToKeepWhenPaging); |
if (pageStep < 0) pageStep = clientWidth; |
m_hBar->setSteps(cScrollbarPixelsPerLineStep, pageStep); |
@@ -1563,7 +1528,7 @@ |
m_hBar->setValue(scrollXOffset()); |
} |
if (m_vBar) { |
- int clientHeight = box->clientHeight(); |
+ int clientHeight = renderer()->clientHeight(); |
int pageStep = (clientHeight - cAmountToKeepWhenPaging); |
if (pageStep < 0) pageStep = clientHeight; |
m_vBar->setSteps(cScrollbarPixelsPerLineStep, pageStep); |
@@ -1601,10 +1566,7 @@ |
void RenderLayer::paintScrollCorner(GraphicsContext* context, int tx, int ty, const IntRect& damageRect) |
{ |
- RenderBox* box = renderBox(); |
- ASSERT(box); |
- |
- IntRect cornerRect = scrollCornerRect(this, box->borderBoxRect()); |
+ IntRect cornerRect = scrollCornerRect(this, renderer()->borderBoxRect()); |
IntRect absRect = IntRect(cornerRect.x() + tx, cornerRect.y() + ty, cornerRect.width(), cornerRect.height()); |
if (!absRect.intersects(damageRect)) |
return; |
@@ -1627,10 +1589,7 @@ |
if (renderer()->style()->resize() == RESIZE_NONE) |
return; |
- RenderBox* box = renderBox(); |
- ASSERT(box); |
- |
- IntRect cornerRect = resizerCornerRect(this, box->borderBoxRect()); |
+ IntRect cornerRect = resizerCornerRect(this, renderer()->borderBoxRect()); |
IntRect absRect = IntRect(cornerRect.x() + tx, cornerRect.y() + ty, cornerRect.width(), cornerRect.height()); |
if (!absRect.intersects(damageRect)) |
return; |
@@ -1669,12 +1628,9 @@ |
if (!renderer()->hasOverflowClip() || renderer()->style()->resize() == RESIZE_NONE) |
return false; |
- RenderBox* box = renderBox(); |
- ASSERT(box); |
- |
IntPoint localPoint = absoluteToContents(absolutePoint); |
- IntRect localBounds(0, 0, box->width(), box->height()); |
+ IntRect localBounds(0, 0, renderer()->width(), renderer()->height()); |
return resizerCornerRect(this, localBounds).contains(localPoint); |
} |
@@ -1683,13 +1639,10 @@ |
if (!m_hBar && !m_vBar && (!renderer()->hasOverflowClip() || renderer()->style()->resize() == RESIZE_NONE)) |
return false; |
- RenderBox* box = renderBox(); |
- ASSERT(box); |
- |
int x = 0; |
int y = 0; |
convertToLayerCoords(root(), x, y); |
- IntRect absBounds(x, y, box->width(), box->height()); |
+ IntRect absBounds(x, y, renderer()->width(), renderer()->height()); |
IntRect resizeControlRect; |
if (renderer()->style()->resize() != RESIZE_NONE) { |
@@ -1701,10 +1654,7 @@ |
int resizeControlSize = max(resizeControlRect.height(), 0); |
if (m_vBar) { |
- IntRect vBarRect(absBounds.right() - box->borderRight() - m_vBar->width(), |
- absBounds.y() + box->borderTop(), |
- m_vBar->width(), |
- absBounds.height() - (box->borderTop() + box->borderBottom()) - (m_hBar ? m_hBar->height() : resizeControlSize)); |
+ IntRect vBarRect(absBounds.right() - renderer()->borderRight() - m_vBar->width(), absBounds.y() + renderer()->borderTop(), m_vBar->width(), absBounds.height() - (renderer()->borderTop() + renderer()->borderBottom()) - (m_hBar ? m_hBar->height() : resizeControlSize)); |
if (vBarRect.contains(result.point())) { |
result.setScrollbar(m_vBar.get()); |
return true; |
@@ -1713,10 +1663,7 @@ |
resizeControlSize = max(resizeControlRect.width(), 0); |
if (m_hBar) { |
- IntRect hBarRect(absBounds.x() + box->borderLeft(), |
- absBounds.bottom() - box->borderBottom() - m_hBar->height(), |
- absBounds.width() - (box->borderLeft() + box->borderRight()) - (m_vBar ? m_vBar->width() : resizeControlSize), |
- m_hBar->height()); |
+ IntRect hBarRect(absBounds.x() + renderer()->borderLeft(), absBounds.bottom() - renderer()->borderBottom() - m_hBar->height(), absBounds.width() - (renderer()->borderLeft() + renderer()->borderRight()) - (m_vBar ? m_vBar->width() : resizeControlSize), m_hBar->height()); |
if (hBarRect.contains(result.point())) { |
result.setScrollbar(m_hBar.get()); |
return true; |
@@ -1856,8 +1803,8 @@ |
calculateRects(rootLayer, paintDirtyRect, layerBounds, damageRect, clipRectToApply, outlineRect, temporaryClipRects); |
int x = layerBounds.x(); |
int y = layerBounds.y(); |
- int tx = x - renderBoxX(); |
- int ty = y - renderBoxY(); |
+ int tx = x - renderer()->x(); |
+ int ty = y - renderer()->y(); |
// Ensure our lists are up-to-date. |
updateLayerListsIfNeeded(); |
@@ -2079,8 +2026,8 @@ |
// Next we want to see if the mouse pos is inside the child RenderObjects of the layer. |
if (fgRect.contains(hitTestPoint) && |
renderer()->hitTest(request, result, hitTestPoint, |
- layerBounds.x() - renderBoxX(), |
- layerBounds.y() - renderBoxY(), |
+ layerBounds.x() - renderer()->x(), |
+ layerBounds.y() - renderer()->y(), |
HitTestDescendants)) { |
// For positioned generated content, we might still not have a |
// node by the time we get to the layer level, since none of |
@@ -2109,8 +2056,8 @@ |
// Next we want to see if the mouse is inside this layer but not any of its children. |
if (bgRect.contains(hitTestPoint) && |
renderer()->hitTest(request, result, hitTestPoint, |
- layerBounds.x() - renderBoxX(), |
- layerBounds.y() - renderBoxY(), |
+ layerBounds.x() - renderer()->x(), |
+ layerBounds.y() - renderer()->y(), |
HitTestSelf)) { |
if (!result.innerNode() || !result.innerNonSharedNode()) { |
Node* e = enclosingElement(); |
@@ -2348,27 +2295,25 @@ |
int left = firstBox->xPos(); |
for (InlineRunBox* curr = firstBox->nextLineBox(); curr; curr = curr->nextLineBox()) |
left = min(left, curr->xPos()); |
- result = IntRect(left, top, width(), bottom - top); |
+ result = IntRect(left, (top - renderer()->y()), width(), bottom - top); |
} else if (renderer()->isTableRow()) { |
// Our bounding box is just the union of all of our cells' border/overflow rects. |
for (RenderObject* child = renderer()->firstChild(); child; child = child->nextSibling()) { |
if (child->isTableCell()) { |
IntRect bbox = toRenderBox(child)->borderBoxRect(); |
result.unite(bbox); |
- IntRect overflowRect = renderBox()->overflowRect(false); |
+ IntRect overflowRect = renderer()->overflowRect(false); |
if (bbox != overflowRect) |
result.unite(overflowRect); |
} |
} |
} else { |
- RenderBox* box = renderBox(); |
- ASSERT(box); |
- if (box->hasMask()) |
- result = box->maskClipRect(); |
+ if (renderer()->hasMask()) |
+ result = renderer()->maskClipRect(); |
else { |
- IntRect bbox = box->borderBoxRect(); |
+ IntRect bbox = renderer()->borderBoxRect(); |
result = bbox; |
- IntRect overflowRect = box->overflowRect(false); |
+ IntRect overflowRect = renderer()->overflowRect(false); |
if (bbox != overflowRect) |
result.unite(overflowRect); |
} |