summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderRegion.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-09-10 19:10:20 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-09-10 19:10:20 +0200
commit284837daa07b29d6a63a748544a90b1f5842ac5c (patch)
treeecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/WebCore/rendering/RenderRegion.cpp
parent2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff)
downloadqtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/WebCore/rendering/RenderRegion.cpp')
-rw-r--r--Source/WebCore/rendering/RenderRegion.cpp95
1 files changed, 71 insertions, 24 deletions
diff --git a/Source/WebCore/rendering/RenderRegion.cpp b/Source/WebCore/rendering/RenderRegion.cpp
index dbdbe83f7..80c848bf4 100644
--- a/Source/WebCore/rendering/RenderRegion.cpp
+++ b/Source/WebCore/rendering/RenderRegion.cpp
@@ -52,25 +52,35 @@ RenderRegion::RenderRegion(Node* node, RenderFlowThread* flowThread)
{
}
-LayoutUnit RenderRegion::logicalWidthForFlowThreadContent() const
+LayoutUnit RenderRegion::pageLogicalWidth() const
{
return m_flowThread->isHorizontalWritingMode() ? contentWidth() : contentHeight();
}
-LayoutUnit RenderRegion::logicalHeightForFlowThreadContent() const
+LayoutUnit RenderRegion::pageLogicalHeight() const
{
return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWidth();
}
-LayoutRect RenderRegion::regionOversetRect() const
+LayoutUnit RenderRegion::logicalHeightOfAllFlowThreadContent() const
+{
+ return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWidth();
+}
+
+LayoutRect RenderRegion::flowThreadPortionOverflowRect() const
+{
+ return overflowRectForFlowThreadPortion(flowThreadPortionRect(), isFirstRegion(), isLastRegion());
+}
+
+LayoutRect RenderRegion::overflowRectForFlowThreadPortion(LayoutRect flowThreadPortionRect, bool isFirstPortion, bool isLastPortion) const
{
// FIXME: Would like to just use hasOverflowClip() but we aren't a block yet. When RenderRegion is eliminated and
// folded into RenderBlock, switch to hasOverflowClip().
bool clipX = style()->overflowX() != OVISIBLE;
bool clipY = style()->overflowY() != OVISIBLE;
- bool isLastRegionWithRegionOverflowBreak = (isLastRegion() && (style()->regionOverflow() == BreakRegionOverflow));
+ bool isLastRegionWithRegionOverflowBreak = (isLastPortion && (style()->regionOverflow() == BreakRegionOverflow));
if ((clipX && clipY) || !isValid() || !m_flowThread || isLastRegionWithRegionOverflowBreak)
- return regionRect();
+ return flowThreadPortionRect;
LayoutRect flowThreadOverflow = m_flowThread->visualOverflowRect();
@@ -78,22 +88,27 @@ LayoutRect RenderRegion::regionOversetRect() const
LayoutUnit outlineSize = maximalOutlineSize(PaintPhaseOutline);
LayoutRect clipRect;
if (m_flowThread->isHorizontalWritingMode()) {
- LayoutUnit minY = isFirstRegion() ? (flowThreadOverflow.y() - outlineSize) : regionRect().y();
- LayoutUnit maxY = isLastRegion() ? max(regionRect().maxY(), flowThreadOverflow.maxY()) + outlineSize : regionRect().maxY();
- LayoutUnit minX = clipX ? regionRect().x() : (flowThreadOverflow.x() - outlineSize);
- LayoutUnit maxX = clipX ? regionRect().maxX() : (flowThreadOverflow.maxX() + outlineSize);
+ LayoutUnit minY = isFirstPortion ? (flowThreadOverflow.y() - outlineSize) : flowThreadPortionRect.y();
+ LayoutUnit maxY = isLastPortion ? max(flowThreadPortionRect.maxY(), flowThreadOverflow.maxY()) + outlineSize : flowThreadPortionRect.maxY();
+ LayoutUnit minX = clipX ? flowThreadPortionRect.x() : (flowThreadOverflow.x() - outlineSize);
+ LayoutUnit maxX = clipX ? flowThreadPortionRect.maxX() : (flowThreadOverflow.maxX() + outlineSize);
clipRect = LayoutRect(minX, minY, maxX - minX, maxY - minY);
} else {
- LayoutUnit minX = isFirstRegion() ? (flowThreadOverflow.x() - outlineSize) : regionRect().x();
- LayoutUnit maxX = isLastRegion() ? max(regionRect().maxX(), flowThreadOverflow.maxX()) + outlineSize : regionRect().maxX();
- LayoutUnit minY = clipY ? regionRect().y() : (flowThreadOverflow.y() - outlineSize);
- LayoutUnit maxY = clipY ? regionRect().maxY() : (flowThreadOverflow.maxY() + outlineSize);
+ LayoutUnit minX = isFirstPortion ? (flowThreadOverflow.x() - outlineSize) : flowThreadPortionRect.x();
+ LayoutUnit maxX = isLastPortion ? max(flowThreadPortionRect.maxX(), flowThreadOverflow.maxX()) + outlineSize : flowThreadPortionRect.maxX();
+ LayoutUnit minY = clipY ? flowThreadPortionRect.y() : (flowThreadOverflow.y() - outlineSize);
+ LayoutUnit maxY = clipY ? flowThreadPortionRect.maxY() : (flowThreadOverflow.maxY() + outlineSize);
clipRect = LayoutRect(minX, minY, maxX - minX, maxY - minY);
}
return clipRect;
}
+LayoutUnit RenderRegion::pageLogicalTopForOffset(LayoutUnit /* offset */) const
+{
+ return flowThread()->isHorizontalWritingMode() ? flowThreadPortionRect().y() : flowThreadPortionRect().x();
+}
+
bool RenderRegion::isFirstRegion() const
{
ASSERT(isValid() && m_flowThread);
@@ -113,12 +128,12 @@ void RenderRegion::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintO
return;
setRegionObjectsRegionStyle();
- m_flowThread->paintIntoRegion(paintInfo, this, LayoutPoint(paintOffset.x() + borderLeft() + paddingLeft(), paintOffset.y() + borderTop() + paddingTop()));
+ m_flowThread->paintFlowThreadPortionInRegion(paintInfo, this, flowThreadPortionRect(), flowThreadPortionOverflowRect(), LayoutPoint(paintOffset.x() + borderLeft() + paddingLeft(), paintOffset.y() + borderTop() + paddingTop()));
restoreRegionObjectsOriginalStyle();
}
// Hit Testing
-bool RenderRegion::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
+bool RenderRegion::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
{
if (!isValid())
return false;
@@ -127,14 +142,15 @@ bool RenderRegion::nodeAtPoint(const HitTestRequest& request, HitTestResult& res
// Check our bounds next. For this purpose always assume that we can only be hit in the
// foreground phase (which is true for replaced elements like images).
- LayoutRect boundsRect = borderBoxRectInRegion(pointInContainer.region());
+ // FIXME: Once we support overflow, we need to intersect with that and not with the bounds rect.
+ LayoutRect boundsRect = borderBoxRectInRegion(locationInContainer.region());
boundsRect.moveBy(adjustedLocation);
- if (visibleToHitTesting() && action == HitTestForeground && pointInContainer.intersects(boundsRect)) {
+ if (visibleToHitTesting() && action == HitTestForeground && locationInContainer.intersects(boundsRect)) {
// Check the contents of the RenderFlowThread.
- if (m_flowThread && m_flowThread->hitTestRegion(this, request, result, pointInContainer, LayoutPoint(adjustedLocation.x() + borderLeft() + paddingLeft(), adjustedLocation.y() + borderTop() + paddingTop())))
+ if (m_flowThread && m_flowThread->hitTestFlowThreadPortionInRegion(this, flowThreadPortionRect(), flowThreadPortionOverflowRect(), request, result, locationInContainer, LayoutPoint(adjustedLocation.x() + borderLeft() + paddingLeft(), adjustedLocation.y() + borderTop() + paddingTop())))
return true;
- updateHitTestResult(result, pointInContainer.point() - toLayoutSize(adjustedLocation));
- if (!result.addNodeToRectBasedTestResult(node(), pointInContainer, boundsRect))
+ updateHitTestResult(result, locationInContainer.point() - toLayoutSize(adjustedLocation));
+ if (!result.addNodeToRectBasedTestResult(generatingNode(), request, locationInContainer, boundsRect))
return true;
}
@@ -145,6 +161,8 @@ void RenderRegion::checkRegionStyle()
{
ASSERT(m_flowThread);
bool customRegionStyle = false;
+
+ // FIXME: Region styling doesn't work for pseudo elements.
if (node()) {
Element* regionElement = static_cast<Element*>(node());
customRegionStyle = view()->document()->styleResolver()->checkRegionStyle(regionElement);
@@ -172,10 +190,10 @@ void RenderRegion::layout()
{
RenderReplaced::layout();
if (m_flowThread && isValid()) {
- LayoutRect oldRegionRect(regionRect());
+ LayoutRect oldRegionRect(flowThreadPortionRect());
if (!isHorizontalWritingMode())
oldRegionRect = oldRegionRect.transposedRect();
- if (oldRegionRect.width() != logicalWidthForFlowThreadContent() || oldRegionRect.height() != logicalHeightForFlowThreadContent())
+ if (oldRegionRect.width() != pageLogicalWidth() || oldRegionRect.height() != pageLogicalHeight())
m_flowThread->invalidateRegions();
}
@@ -191,6 +209,34 @@ void RenderRegion::layout()
// We'll need to expand RenderBoxRegionInfo to also hold left and right overflow values.
}
+void RenderRegion::repaintFlowThreadContent(const LayoutRect& repaintRect, bool immediate) const
+{
+ repaintFlowThreadContentRectangle(repaintRect, immediate, flowThreadPortionRect(), flowThreadPortionOverflowRect(), contentBoxRect().location());
+}
+
+void RenderRegion::repaintFlowThreadContentRectangle(const LayoutRect& repaintRect, bool immediate, const LayoutRect& flowThreadPortionRect, const LayoutRect& flowThreadPortionOverflowRect, const LayoutPoint& regionLocation) const
+{
+ // We only have to issue a repaint in this region if the region rect intersects the repaint rect.
+ LayoutRect flippedFlowThreadPortionRect(flowThreadPortionRect);
+ LayoutRect flippedFlowThreadPortionOverflowRect(flowThreadPortionOverflowRect);
+ flowThread()->flipForWritingMode(flippedFlowThreadPortionRect); // Put the region rects into physical coordinates.
+ flowThread()->flipForWritingMode(flippedFlowThreadPortionOverflowRect);
+
+ LayoutRect clippedRect(repaintRect);
+ clippedRect.intersect(flippedFlowThreadPortionOverflowRect);
+ if (clippedRect.isEmpty())
+ return;
+
+ // Put the region rect into the region's physical coordinate space.
+ clippedRect.setLocation(regionLocation + (clippedRect.location() - flippedFlowThreadPortionRect.location()));
+
+ // Now switch to the region's writing mode coordinate space and let it repaint itself.
+ flipForWritingMode(clippedRect);
+
+ // Issue the repaint.
+ repaintRectangle(clippedRect, immediate);
+}
+
void RenderRegion::installFlowThread()
{
ASSERT(view());
@@ -287,8 +333,8 @@ LayoutUnit RenderRegion::offsetFromLogicalTopOfFirstPage() const
if (!m_isValid || !m_flowThread)
return 0;
if (m_flowThread->isHorizontalWritingMode())
- return regionRect().y();
- return regionRect().x();
+ return flowThreadPortionRect().y();
+ return flowThreadPortionRect().x();
}
void RenderRegion::setRegionObjectsRegionStyle()
@@ -383,6 +429,7 @@ PassRefPtr<RenderStyle> RenderRegion::computeStyleInRegion(const RenderObject* o
ASSERT(!object->isAnonymous());
ASSERT(object->node() && object->node()->isElementNode());
+ // FIXME: Region styling fails for pseudo-elements because the renderers don't have a node.
Element* element = toElement(object->node());
RefPtr<RenderStyle> renderObjectRegionStyle = object->view()->document()->styleResolver()->styleForElement(element, 0, DisallowStyleSharing, MatchAllRules, this);