summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderLayer.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-24 16:36:50 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-24 16:36:50 +0100
commitad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (patch)
treeb34b0daceb7c8e7fdde4b4ec43650ab7caadb0a9 /Source/WebCore/rendering/RenderLayer.cpp
parent03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (diff)
downloadqtwebkit-ad0d549d4cc13433f77c1ac8f0ab379c83d93f28.tar.gz
Imported WebKit commit bb52bf3c0119e8a128cd93afe5572413a8617de9 (http://svn.webkit.org/repository/webkit/trunk@108790)
Diffstat (limited to 'Source/WebCore/rendering/RenderLayer.cpp')
-rw-r--r--Source/WebCore/rendering/RenderLayer.cpp125
1 files changed, 69 insertions, 56 deletions
diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp
index ee6e8beea..a5b028b65 100644
--- a/Source/WebCore/rendering/RenderLayer.cpp
+++ b/Source/WebCore/rendering/RenderLayer.cpp
@@ -77,6 +77,7 @@
#include "Page.h"
#include "PlatformMouseEvent.h"
#include "RenderArena.h"
+#include "RenderFlowThread.h"
#include "RenderInline.h"
#include "RenderMarquee.h"
#include "RenderReplica.h"
@@ -357,7 +358,7 @@ void RenderLayer::updateLayerPositions(LayoutPoint* offsetFromRoot, UpdateLayerP
// as canUseConvertToLayerCoords may be true for an ancestor layer.
convertToLayerCoords(root(), offset);
}
- positionOverflowControls(toSize(offset));
+ positionOverflowControls(toSize(roundedIntPoint(offset)));
updateVisibilityStatus();
@@ -375,8 +376,8 @@ void RenderLayer::updateLayerPositions(LayoutPoint* offsetFromRoot, UpdateLayerP
ASSERT(!view->layoutStateEnabled());
RenderBoxModelObject* repaintContainer = renderer()->containerForRepaint();
- IntRect oldRepaintRect = m_repaintRect;
- IntRect oldOutlineBox = m_outlineBox;
+ LayoutRect oldRepaintRect = m_repaintRect;
+ LayoutRect oldOutlineBox = m_outlineBox;
computeRepaintRects(offsetFromRoot);
// FIXME: Should ASSERT that value calculated for m_outlineBox using the cached offset is the same
// as the value not using the cached offset, but we can't due to https://bugs.webkit.org/show_bug.cgi?id=37048
@@ -433,7 +434,7 @@ LayoutRect RenderLayer::repaintRectIncludingDescendants() const
return repaintRect;
}
-void RenderLayer::computeRepaintRects(IntPoint* offsetFromRoot)
+void RenderLayer::computeRepaintRects(LayoutPoint* offsetFromRoot)
{
ASSERT(!m_visibleContentStatusDirty);
@@ -453,8 +454,9 @@ void RenderLayer::clearRepaintRects()
void RenderLayer::updateLayerPositionsAfterScroll(UpdateLayerPositionsAfterScrollFlags flags)
{
- ASSERT(!m_visibleDescendantStatusDirty);
- ASSERT(!m_visibleContentStatusDirty);
+ // FIXME: This shouldn't be needed, but there are some corner cases where
+ // these flags are still dirty. Update so that the check below is valid.
+ updateVisibilityStatus();
// If we have no visible content and no visible descendants, there is no point recomputing
// our rectangles as they will be empty. If our visibility changes, we are expected to
@@ -1191,22 +1193,16 @@ void RenderLayer::removeOnlyThisLayer()
// Dirty the clip rects.
clearClipRectsIncludingDescendants();
- // Remove us from the parent.
- RenderLayer* parent = m_parent;
RenderLayer* nextSib = nextSibling();
bool hasLayerOffset;
const LayoutPoint offsetFromRootBeforeMove = computeOffsetFromRoot(hasLayerOffset);
- parent->removeChild(this);
-
- if (reflection())
- removeChild(reflectionLayer());
// Now walk our kids and reattach them to our parent.
RenderLayer* current = m_first;
while (current) {
RenderLayer* next = current->nextSibling();
removeChild(current);
- parent->addChild(current, nextSib);
+ m_parent->addChild(current, nextSib);
current->setRepaintStatus(NeedsFullRepaint);
LayoutPoint offsetFromRoot = offsetFromRootBeforeMove;
// updateLayerPositions depends on hasLayer() already being false for proper layout.
@@ -1215,6 +1211,11 @@ void RenderLayer::removeOnlyThisLayer()
current = next;
}
+ // Remove us from the parent.
+ if (reflection())
+ removeChild(reflectionLayer());
+ m_parent->removeChild(this);
+
m_renderer->destroyLayer();
}
@@ -1237,8 +1238,21 @@ void RenderLayer::insertOnlyThisLayer()
clearClipRectsIncludingDescendants();
}
-void
-RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint& location) const
+void RenderLayer::convertToPixelSnappedLayerCoords(const RenderLayer* ancestorLayer, IntPoint& roundedLocation) const
+{
+ LayoutPoint location = roundedLocation;
+ convertToLayerCoords(ancestorLayer, location);
+ roundedLocation = roundedIntPoint(location);
+}
+
+void RenderLayer::convertToPixelSnappedLayerCoords(const RenderLayer* ancestorLayer, IntRect& roundedRect) const
+{
+ LayoutRect rect = roundedRect;
+ convertToLayerCoords(ancestorLayer, rect);
+ roundedRect = pixelSnappedIntRect(rect);
+}
+
+void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint& location) const
{
if (ancestorLayer == this)
return;
@@ -1325,8 +1339,7 @@ RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint&
location += toSize(m_topLeft);
}
-void
-RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutRect& rect) const
+void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutRect& rect) const
{
LayoutPoint delta;
convertToLayerCoords(ancestorLayer, delta);
@@ -1578,7 +1591,7 @@ void RenderLayer::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignm
LayoutRect viewRect = frameView->visibleContentRect();
LayoutRect r = getRectToExpose(viewRect, rect, alignX, alignY);
- frameView->setScrollPosition(r.location());
+ frameView->setScrollPosition(roundedIntPoint(r.location()));
// This is the outermost view of a web page, so after scrolling this view we
// scroll its container by calling Page::scrollRectIntoView.
@@ -1587,7 +1600,7 @@ void RenderLayer::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignm
// The canAutoscroll function in EventHandler also knows about this.
if (Frame* frame = frameView->frame()) {
if (Page* page = frame->page())
- page->chrome()->scrollRectIntoView(rect);
+ page->chrome()->scrollRectIntoView(pixelSnappedIntRect(rect));
}
}
}
@@ -1725,29 +1738,29 @@ void RenderLayer::resize(const PlatformMouseEvent& evt, const LayoutSize& oldOff
LayoutSize difference = (currentSize + newOffset - adjustedOldOffset).expandedTo(minimumSize) - currentSize;
ASSERT(element->isStyledElement());
- StylePropertySet* styleDeclaration = static_cast<StyledElement*>(element)->ensureInlineStyleDecl();
+ StyledElement* styledElement = static_cast<StyledElement*>(element);
bool isBoxSizingBorder = renderer->style()->boxSizing() == BORDER_BOX;
if (resize != RESIZE_VERTICAL && difference.width()) {
if (element->isFormControlElement()) {
// Make implicit margins from the theme explicit (see <http://bugs.webkit.org/show_bug.cgi?id=9547>).
- styleDeclaration->setProperty(CSSPropertyMarginLeft, String::number(renderer->marginLeft() / zoomFactor) + "px", false);
- styleDeclaration->setProperty(CSSPropertyMarginRight, String::number(renderer->marginRight() / zoomFactor) + "px", false);
+ styledElement->setInlineStyleProperty(CSSPropertyMarginLeft, String::number(renderer->marginLeft() / zoomFactor) + "px", false);
+ styledElement->setInlineStyleProperty(CSSPropertyMarginRight, String::number(renderer->marginRight() / zoomFactor) + "px", false);
}
- LayoutUnit baseWidth = renderer->width() - (isBoxSizingBorder ? 0 : renderer->borderAndPaddingWidth());
+ LayoutUnit baseWidth = renderer->width() - (isBoxSizingBorder ? zeroLayoutUnit : renderer->borderAndPaddingWidth());
baseWidth = baseWidth / zoomFactor;
- styleDeclaration->setProperty(CSSPropertyWidth, String::number(baseWidth + difference.width()) + "px", false);
+ styledElement->setInlineStyleProperty(CSSPropertyWidth, String::number(baseWidth + difference.width()) + "px", false);
}
if (resize != RESIZE_HORIZONTAL && difference.height()) {
if (element->isFormControlElement()) {
// Make implicit margins from the theme explicit (see <http://bugs.webkit.org/show_bug.cgi?id=9547>).
- styleDeclaration->setProperty(CSSPropertyMarginTop, String::number(renderer->marginTop() / zoomFactor) + "px", false);
- styleDeclaration->setProperty(CSSPropertyMarginBottom, String::number(renderer->marginBottom() / zoomFactor) + "px", false);
+ styledElement->setInlineStyleProperty(CSSPropertyMarginTop, String::number(renderer->marginTop() / zoomFactor) + "px", false);
+ styledElement->setInlineStyleProperty(CSSPropertyMarginBottom, String::number(renderer->marginBottom() / zoomFactor) + "px", false);
}
- LayoutUnit baseHeight = renderer->height() - (isBoxSizingBorder ? 0 : renderer->borderAndPaddingHeight());
+ LayoutUnit baseHeight = renderer->height() - (isBoxSizingBorder ? zeroLayoutUnit : renderer->borderAndPaddingHeight());
baseHeight = baseHeight / zoomFactor;
- styleDeclaration->setProperty(CSSPropertyHeight, String::number(baseHeight + difference.height()) + "px", false);
+ styledElement->setInlineStyleProperty(CSSPropertyHeight, String::number(baseHeight + difference.height()) + "px", false);
}
document->updateLayout();
@@ -1788,7 +1801,7 @@ IntPoint RenderLayer::minimumScrollPosition() const
IntPoint RenderLayer::maximumScrollPosition() const
{
// FIXME: m_scrollSize may not be up-to-date if m_scrollDimensionsDirty is true.
- return scrollOrigin() + m_scrollSize - visibleContentRect(true).size();
+ return scrollOrigin() + roundedIntSize(m_scrollSize) - visibleContentRect(true).size();
}
IntRect RenderLayer::visibleContentRect(bool includeScrollbars) const
@@ -1850,7 +1863,7 @@ IntRect RenderLayer::scrollCornerRect() const
bool hasVerticalBar = verticalScrollbar();
bool hasResizer = renderer()->style()->resize() != RESIZE_NONE;
if ((hasHorizontalBar && hasVerticalBar) || (hasResizer && (hasHorizontalBar || hasVerticalBar)))
- return cornerRect(this, renderBox()->borderBoxRect());
+ return cornerRect(this, pixelSnappedIntRect(renderBox()->borderBoxRect()));
return IntRect();
}
@@ -1869,7 +1882,7 @@ IntRect RenderLayer::scrollCornerAndResizerRect() const
return IntRect();
IntRect scrollCornerAndResizer = scrollCornerRect();
if (scrollCornerAndResizer.isEmpty())
- scrollCornerAndResizer = resizerCornerRect(this, box->borderBoxRect());
+ scrollCornerAndResizer = resizerCornerRect(this, pixelSnappedIntRect(box->borderBoxRect()));
return scrollCornerAndResizer;
}
@@ -2131,12 +2144,12 @@ int RenderLayer::horizontalScrollbarHeight(OverlayScrollbarSizeRelevancy relevan
return m_hBar->height();
}
-LayoutSize RenderLayer::offsetFromResizeCorner(const LayoutPoint& absolutePoint) const
+IntSize RenderLayer::offsetFromResizeCorner(const IntPoint& absolutePoint) const
{
// Currently the resize corner is always the bottom right corner
// FIXME: This assumes the location is 0, 0. Is this guaranteed to always be the case?
- LayoutPoint bottomRight = toPoint(size());
- LayoutPoint localPoint = absoluteToContents(absolutePoint);
+ IntPoint bottomRight = toPoint(size());
+ IntPoint localPoint = roundedIntPoint(absoluteToContents(absolutePoint));
return localPoint - bottomRight;
}
@@ -2145,7 +2158,7 @@ bool RenderLayer::hasOverflowControls() const
return m_hBar || m_vBar || m_scrollCorner || renderer()->style()->resize() != RESIZE_NONE;
}
-void RenderLayer::positionOverflowControls(const LayoutSize& offsetFromLayer)
+void RenderLayer::positionOverflowControls(const IntSize& offsetFromLayer)
{
if (!m_hBar && !m_vBar && (!renderer()->hasOverflowClip() || renderer()->style()->resize() == RESIZE_NONE))
return;
@@ -2154,7 +2167,7 @@ void RenderLayer::positionOverflowControls(const LayoutSize& offsetFromLayer)
if (!box)
return;
- const IntRect borderBox = box->borderBoxRect();
+ const IntRect borderBox = pixelSnappedIntRect(box->borderBoxRect());
const IntRect& scrollCorner = scrollCornerRect();
IntRect absBounds(borderBox.location() + offsetFromLayer, borderBox.size());
if (m_vBar)
@@ -2397,7 +2410,7 @@ void RenderLayer::updateScrollInfoAfterLayout()
updateOverflowStatus(horizontalOverflow, verticalOverflow);
}
-void RenderLayer::paintOverflowControls(GraphicsContext* context, const LayoutPoint& paintOffset, const LayoutRect& damageRect, bool paintingOverlayControls)
+void RenderLayer::paintOverflowControls(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect, bool paintingOverlayControls)
{
// Don't do anything if we have no overflow.
if (!renderer()->hasOverflowClip())
@@ -2421,7 +2434,7 @@ void RenderLayer::paintOverflowControls(GraphicsContext* context, const LayoutPo
if (paintingOverlayControls && !hasOverlayScrollbars())
return;
- LayoutPoint adjustedPaintOffset = paintOffset;
+ IntPoint adjustedPaintOffset = paintOffset;
if (paintingOverlayControls)
adjustedPaintOffset = m_cachedOverlayScrollbarOffset;
@@ -2457,12 +2470,12 @@ void RenderLayer::paintOverflowControls(GraphicsContext* context, const LayoutPo
paintResizer(context, adjustedPaintOffset, damageRect);
}
-void RenderLayer::paintScrollCorner(GraphicsContext* context, const LayoutPoint& paintOffset, const LayoutRect& damageRect)
+void RenderLayer::paintScrollCorner(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect)
{
RenderBox* box = renderBox();
ASSERT(box);
- LayoutRect absRect = scrollCornerRect();
+ IntRect absRect = scrollCornerRect();
absRect.moveBy(paintOffset);
if (!absRect.intersects(damageRect))
return;
@@ -2483,7 +2496,7 @@ void RenderLayer::paintScrollCorner(GraphicsContext* context, const LayoutPoint&
context->fillRect(absRect, Color::white, box->style()->colorSpace());
}
-void RenderLayer::drawPlatformResizerImage(GraphicsContext* context, LayoutRect resizerCornerRect)
+void RenderLayer::drawPlatformResizerImage(GraphicsContext* context, IntRect resizerCornerRect)
{
float deviceScaleFactor = WebCore::deviceScaleFactor(renderer()->frame());
@@ -2504,7 +2517,7 @@ void RenderLayer::drawPlatformResizerImage(GraphicsContext* context, LayoutRect
context->drawImage(resizeCornerImage.get(), renderer()->style()->colorSpace(), imageRect);
}
-void RenderLayer::paintResizer(GraphicsContext* context, const LayoutPoint& paintOffset, const LayoutRect& damageRect)
+void RenderLayer::paintResizer(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect)
{
if (renderer()->style()->resize() == RESIZE_NONE)
return;
@@ -2512,7 +2525,7 @@ void RenderLayer::paintResizer(GraphicsContext* context, const LayoutPoint& pain
RenderBox* box = renderBox();
ASSERT(box);
- LayoutRect absRect = resizerCornerRect(this, box->borderBoxRect());
+ IntRect absRect = resizerCornerRect(this, pixelSnappedIntRect(box->borderBoxRect()));
absRect.moveBy(paintOffset);
if (!absRect.intersects(damageRect))
return;
@@ -2534,8 +2547,8 @@ void RenderLayer::paintResizer(GraphicsContext* context, const LayoutPoint& pain
if (!hasOverlayScrollbars() && (m_vBar || m_hBar)) {
GraphicsContextStateSaver stateSaver(*context);
context->clip(absRect);
- LayoutRect largerCorner = absRect;
- largerCorner.setSize(LayoutSize(largerCorner.width() + 1, largerCorner.height() + 1));
+ IntRect largerCorner = absRect;
+ largerCorner.setSize(IntSize(largerCorner.width() + 1, largerCorner.height() + 1));
context->setStrokeColor(Color(makeRGB(217, 217, 217)), ColorSpaceDeviceRGB);
context->setStrokeThickness(1.0f);
context->setFillColor(Color::transparent, ColorSpaceDeviceRGB);
@@ -2543,7 +2556,7 @@ void RenderLayer::paintResizer(GraphicsContext* context, const LayoutPoint& pain
}
}
-bool RenderLayer::isPointInResizeControl(const LayoutPoint& absolutePoint) const
+bool RenderLayer::isPointInResizeControl(const IntPoint& absolutePoint) const
{
if (!renderer()->hasOverflowClip() || renderer()->style()->resize() == RESIZE_NONE)
return false;
@@ -2551,13 +2564,13 @@ bool RenderLayer::isPointInResizeControl(const LayoutPoint& absolutePoint) const
RenderBox* box = renderBox();
ASSERT(box);
- LayoutPoint localPoint = absoluteToContents(absolutePoint);
+ IntPoint localPoint = roundedIntPoint(absoluteToContents(absolutePoint));
- LayoutRect localBounds(0, 0, box->width(), box->height());
+ IntRect localBounds(0, 0, box->pixelSnappedWidth(), box->pixelSnappedHeight());
return resizerCornerRect(this, localBounds).contains(localPoint);
}
-bool RenderLayer::hitTestOverflowControls(HitTestResult& result, const LayoutPoint& localPoint)
+bool RenderLayer::hitTestOverflowControls(HitTestResult& result, const IntPoint& localPoint)
{
if (!m_hBar && !m_vBar && (!renderer()->hasOverflowClip() || renderer()->style()->resize() == RESIZE_NONE))
return false;
@@ -2567,7 +2580,7 @@ bool RenderLayer::hitTestOverflowControls(HitTestResult& result, const LayoutPoi
IntRect resizeControlRect;
if (renderer()->style()->resize() != RESIZE_NONE) {
- resizeControlRect = resizerCornerRect(this, box->borderBoxRect());
+ resizeControlRect = resizerCornerRect(this, pixelSnappedIntRect(box->borderBoxRect()));
if (resizeControlRect.contains(localPoint))
return true;
}
@@ -2645,7 +2658,7 @@ void RenderLayer::clipToRect(RenderLayer* rootLayer, GraphicsContext* context, c
if (clipRect.rect() == paintDirtyRect)
return;
context->save();
- context->clip(clipRect.rect());
+ context->clip(pixelSnappedIntRect(clipRect.rect()));
if (!clipRect.hasRadius())
return;
@@ -2946,7 +2959,7 @@ void RenderLayer::paintLayerContents(RenderLayer* rootLayer, GraphicsContext* co
if (isPaintingOverlayScrollbars) {
clipToRect(rootLayer, context, paintDirtyRect, damageRect);
- paintOverflowControls(context, paintOffset, damageRect.rect(), true);
+ paintOverflowControls(context, roundedIntPoint(paintOffset), pixelSnappedIntRect(damageRect.rect()), true);
restoreClip(context, paintDirtyRect, damageRect);
}
@@ -3110,9 +3123,9 @@ bool RenderLayer::hitTest(const HitTestRequest& request, HitTestResult& result)
{
renderer()->document()->updateLayout();
- LayoutRect hitTestArea = renderer()->view()->documentRect();
+ IntRect hitTestArea = renderer()->isRenderFlowThread() ? toRenderFlowThread(renderer())->borderBoxRect() : renderer()->view()->documentRect();
if (!request.ignoreClipping())
- hitTestArea.intersect(frameVisibleRect(renderer()));
+ hitTestArea.intersect(pixelSnappedIntRect(frameVisibleRect(renderer())));
RenderLayer* insideLayer = hitTestLayer(this, 0, request, result, hitTestArea, result.point(), false);
if (!insideLayer) {
@@ -3747,7 +3760,7 @@ void RenderLayer::calculateRects(const RenderLayer* rootLayer, RenderRegion* reg
backgroundRect.intersect(layerBoundsWithVisualOverflow);
} else {
// Shift the bounds to be for our region only.
- LayoutRect bounds = renderBox()->borderBoxRectInRegion(region);
+ LayoutRect bounds = pixelSnappedIntRect(renderBox()->borderBoxRectInRegion(region));
bounds.moveBy(offset);
backgroundRect.intersect(bounds);
}
@@ -4269,7 +4282,7 @@ void RenderLayer::setBackingNeedsRepaintInRect(const LayoutRect& r)
if (view)
view->repaintViewRectangle(absRect);
} else
- backing()->setContentsNeedDisplayInRect(r);
+ backing()->setContentsNeedDisplayInRect(pixelSnappedIntRect(r));
}
// Since we're only painting non-composited layers, we know that they all share the same repaintContainer.