This source file includes following definitions.
- m_isValid
- pageLogicalWidth
- pageLogicalHeight
- logicalHeightOfAllFlowThreadContent
- flowThreadPortionOverflowRect
- overflowRectForFlowThreadPortion
- pageLogicalTopForOffset
- isFirstRegion
- isLastRegion
- layoutBlock
- repaintFlowThreadContent
- repaintFlowThreadContentRectangle
- attachRegion
- detachRegion
- logicalTopOfFlowThreadContentRect
- logicalBottomOfFlowThreadContentRect
- insertedIntoTree
- willBeRemovedFromTree
- computeIntrinsicLogicalWidths
#include "config.h"
#include "core/rendering/RenderRegion.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/rendering/FlowThreadController.h"
#include "core/rendering/HitTestLocation.h"
#include "core/rendering/PaintInfo.h"
#include "core/rendering/RenderFlowThread.h"
#include "core/rendering/RenderView.h"
using namespace std;
namespace WebCore {
RenderRegion::RenderRegion(Element* element, RenderFlowThread* flowThread)
: RenderBlockFlow(element)
, m_flowThread(flowThread)
, m_isValid(false)
{
}
LayoutUnit RenderRegion::pageLogicalWidth() const
{
ASSERT(m_flowThread);
return m_flowThread->isHorizontalWritingMode() ? contentWidth() : contentHeight();
}
LayoutUnit RenderRegion::pageLogicalHeight() const
{
ASSERT(m_flowThread);
return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWidth();
}
LayoutUnit RenderRegion::logicalHeightOfAllFlowThreadContent() const
{
ASSERT(m_flowThread);
return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWidth();
}
LayoutRect RenderRegion::flowThreadPortionOverflowRect() const
{
return overflowRectForFlowThreadPortion(flowThreadPortionRect(), isFirstRegion(), isLastRegion());
}
LayoutRect RenderRegion::overflowRectForFlowThreadPortion(const LayoutRect& flowThreadPortionRect, bool isFirstPortion, bool isLastPortion) const
{
ASSERT(isValid());
if (hasOverflowClip())
return flowThreadPortionRect;
LayoutRect flowThreadOverflow = m_flowThread->visualOverflowRect();
LayoutRect clipRect;
if (m_flowThread->isHorizontalWritingMode()) {
LayoutUnit minY = isFirstPortion ? flowThreadOverflow.y() : flowThreadPortionRect.y();
LayoutUnit maxY = isLastPortion ? max(flowThreadPortionRect.maxY(), flowThreadOverflow.maxY()) : flowThreadPortionRect.maxY();
LayoutUnit minX = min(flowThreadPortionRect.x(), flowThreadOverflow.x());
LayoutUnit maxX = max(flowThreadPortionRect.maxX(), flowThreadOverflow.maxX());
clipRect = LayoutRect(minX, minY, maxX - minX, maxY - minY);
} else {
LayoutUnit minX = isFirstPortion ? flowThreadOverflow.x() : flowThreadPortionRect.x();
LayoutUnit maxX = isLastPortion ? max(flowThreadPortionRect.maxX(), flowThreadOverflow.maxX()) : flowThreadPortionRect.maxX();
LayoutUnit minY = min(flowThreadPortionRect.y(), (flowThreadOverflow.y()));
LayoutUnit maxY = max(flowThreadPortionRect.y(), (flowThreadOverflow.maxY()));
clipRect = LayoutRect(minX, minY, maxX - minX, maxY - minY);
}
return clipRect;
}
LayoutUnit RenderRegion::pageLogicalTopForOffset(LayoutUnit ) const
{
return flowThread()->isHorizontalWritingMode() ? flowThreadPortionRect().y() : flowThreadPortionRect().x();
}
bool RenderRegion::isFirstRegion() const
{
ASSERT(isValid());
return m_flowThread->firstRegion() == this;
}
bool RenderRegion::isLastRegion() const
{
ASSERT(isValid());
return m_flowThread->lastRegion() == this;
}
void RenderRegion::layoutBlock(bool relayoutChildren)
{
RenderBlockFlow::layoutBlock(relayoutChildren);
}
void RenderRegion::repaintFlowThreadContent(const LayoutRect& repaintRect) const
{
repaintFlowThreadContentRectangle(repaintRect, flowThreadPortionRect(), flowThreadPortionOverflowRect(), contentBoxRect().location());
}
void RenderRegion::repaintFlowThreadContentRectangle(const LayoutRect& repaintRect, const LayoutRect& flowThreadPortionRect, const LayoutRect& flowThreadPortionOverflowRect, const LayoutPoint& regionLocation) const
{
ASSERT(isValid());
LayoutRect flippedFlowThreadPortionRect(flowThreadPortionRect);
LayoutRect flippedFlowThreadPortionOverflowRect(flowThreadPortionOverflowRect);
flowThread()->flipForWritingMode(flippedFlowThreadPortionRect);
flowThread()->flipForWritingMode(flippedFlowThreadPortionOverflowRect);
LayoutRect clippedRect(repaintRect);
clippedRect.intersect(flippedFlowThreadPortionOverflowRect);
if (clippedRect.isEmpty())
return;
clippedRect.setLocation(regionLocation + (clippedRect.location() - flippedFlowThreadPortionRect.location()));
flipForWritingMode(clippedRect);
repaintRectangle(clippedRect);
}
void RenderRegion::attachRegion()
{
if (documentBeingDestroyed())
return;
setIsValid(false);
if (!m_flowThread)
return;
m_flowThread->addRegionToThread(this);
}
void RenderRegion::detachRegion()
{
if (m_flowThread) {
m_flowThread->removeRegionFromThread(this);
m_flowThread = 0;
}
}
LayoutUnit RenderRegion::logicalTopOfFlowThreadContentRect(const LayoutRect& rect) const
{
ASSERT(isValid());
return flowThread()->isHorizontalWritingMode() ? rect.y() : rect.x();
}
LayoutUnit RenderRegion::logicalBottomOfFlowThreadContentRect(const LayoutRect& rect) const
{
ASSERT(isValid());
return flowThread()->isHorizontalWritingMode() ? rect.maxY() : rect.maxX();
}
void RenderRegion::insertedIntoTree()
{
RenderBlockFlow::insertedIntoTree();
attachRegion();
}
void RenderRegion::willBeRemovedFromTree()
{
RenderBlockFlow::willBeRemovedFromTree();
detachRegion();
}
void RenderRegion::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
{
if (!isValid()) {
RenderBlockFlow::computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth);
return;
}
minLogicalWidth = m_flowThread->minPreferredLogicalWidth();
maxLogicalWidth = m_flowThread->maxPreferredLogicalWidth();
}
}