This source file includes following definitions.
- m_renderCounterCount
- hitTest
- hitTest
- computeLogicalHeight
- updateLogicalWidth
- availableLogicalHeight
- isChildAllowed
- canCenterDialog
- positionDialog
- positionDialogs
- layoutContent
- checkLayoutState
- layout
- mapLocalToContainer
- pushMappingToContainer
- mapAbsoluteToLocalPoint
- computeSelfHitTestRects
- paint
- rendererObscuresBackground
- rootFillsViewportBackground
- paintBoxDecorations
- shouldRepaint
- repaintViewRectangle
- repaintViewAndCompositedLayers
- computeRectForRepaint
- absoluteRects
- absoluteQuads
- rendererAfterPosition
- selectionBounds
- repaintSelection
- getNextOrPrevRenderObjectBasedOnDirection
- setSelection
- getSelection
- clearSelection
- selectionStartEnd
- shouldUsePrintingLayout
- viewRect
- unscaledDocumentRect
- rootBackgroundIsEntirelyFixed
- backgroundRect
- documentRect
- viewHeight
- viewWidth
- viewLogicalHeight
- zoomFactor
- pushLayoutState
- shouldDisableLayoutStateForSubtree
- updateHitTestResult
- usesCompositing
- compositor
- setIsInWindow
- flowThreadController
- pushLayoutStateForCurrentFlowThread
- popLayoutStateForCurrentFlowThread
- intervalArena
- backgroundIsKnownToBeOpaqueInRect
- layoutViewportWidth
- layoutViewportHeight
#include "config.h"
#include "core/rendering/RenderView.h"
#include "RuntimeEnabledFeatures.h"
#include "core/dom/Document.h"
#include "core/dom/Element.h"
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLDialogElement.h"
#include "core/html/HTMLFrameOwnerElement.h"
#include "core/html/HTMLIFrameElement.h"
#include "core/page/Page.h"
#include "core/rendering/ColumnInfo.h"
#include "core/rendering/FlowThreadController.h"
#include "core/rendering/GraphicsContextAnnotator.h"
#include "core/rendering/HitTestResult.h"
#include "core/rendering/LayoutRectRecorder.h"
#include "core/rendering/RenderFlowThread.h"
#include "core/rendering/RenderGeometryMap.h"
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderSelectionInfo.h"
#include "core/rendering/compositing/CompositedLayerMapping.h"
#include "core/rendering/compositing/RenderLayerCompositor.h"
#include "core/svg/SVGDocumentExtensions.h"
#include "platform/geometry/FloatQuad.h"
#include "platform/geometry/TransformState.h"
#include "platform/graphics/GraphicsContext.h"
namespace WebCore {
RenderView::RenderView(Document* document)
: RenderBlockFlow(document)
, m_frameView(document->view())
, m_selectionStart(0)
, m_selectionEnd(0)
, m_selectionStartPos(-1)
, m_selectionEndPos(-1)
, m_pageLogicalHeight(0)
, m_pageLogicalHeightChanged(false)
, m_layoutState(0)
, m_layoutStateDisableCount(0)
, m_renderQuoteHead(0)
, m_renderCounterCount(0)
{
setInline(false);
m_minPreferredLogicalWidth = 0;
m_maxPreferredLogicalWidth = 0;
setPreferredLogicalWidthsDirty(MarkOnlyThis);
setPositionState(AbsolutePosition);
}
RenderView::~RenderView()
{
}
bool RenderView::hitTest(const HitTestRequest& request, HitTestResult& result)
{
return hitTest(request, result.hitTestLocation(), result);
}
bool RenderView::hitTest(const HitTestRequest& request, const HitTestLocation& location, HitTestResult& result)
{
frameView()->updateLayoutAndStyleIfNeededRecursive();
return layer()->hitTest(request, location, result);
}
void RenderView::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit, LogicalExtentComputedValues& computedValues) const
{
computedValues.m_extent = (!shouldUsePrintingLayout() && m_frameView) ? LayoutUnit(viewLogicalHeight()) : logicalHeight;
}
void RenderView::updateLogicalWidth()
{
if (!shouldUsePrintingLayout() && m_frameView)
setLogicalWidth(viewLogicalWidth());
}
LayoutUnit RenderView::availableLogicalHeight(AvailableLogicalHeightType heightType) const
{
if (hasColumns())
return columnInfo()->columnHeight();
return RenderBlockFlow::availableLogicalHeight(heightType);
}
bool RenderView::isChildAllowed(RenderObject* child, RenderStyle*) const
{
return child->isBox();
}
static bool canCenterDialog(const RenderStyle* style)
{
return style->position() == AbsolutePosition && style->hasAutoTopAndBottom();
}
void RenderView::positionDialog(RenderBox* box)
{
HTMLDialogElement* dialog = toHTMLDialogElement(box->node());
if (dialog->centeringMode() == HTMLDialogElement::NotCentered)
return;
if (dialog->centeringMode() == HTMLDialogElement::Centered) {
if (canCenterDialog(box->style()))
box->setY(dialog->centeredPosition());
return;
}
ASSERT(dialog->centeringMode() == HTMLDialogElement::NeedsCentering);
if (!canCenterDialog(box->style())) {
dialog->setNotCentered();
return;
}
FrameView* frameView = document().view();
int scrollTop = frameView->scrollOffset().height();
int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height();
LayoutUnit top = scrollTop;
if (box->height() < visibleHeight)
top += (visibleHeight - box->height()) / 2;
box->setY(top);
dialog->setCentered(top);
}
void RenderView::positionDialogs()
{
TrackedRendererListHashSet* positionedDescendants = positionedObjects();
if (!positionedDescendants)
return;
TrackedRendererListHashSet::iterator end = positionedDescendants->end();
for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin(); it != end; ++it) {
RenderBox* box = *it;
if (isHTMLDialogElement(box->node()))
positionDialog(box);
}
}
void RenderView::layoutContent()
{
ASSERT(needsLayout());
LayoutRectRecorder recorder(*this);
RenderBlockFlow::layout();
if (RuntimeEnabledFeatures::dialogElementEnabled())
positionDialogs();
#ifndef NDEBUG
checkLayoutState();
#endif
}
#ifndef NDEBUG
void RenderView::checkLayoutState()
{
if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) {
ASSERT(layoutDeltaMatches(LayoutSize()));
}
ASSERT(!m_layoutStateDisableCount);
ASSERT(!m_layoutState->next());
}
#endif
void RenderView::layout()
{
if (!document().paginated())
setPageLogicalHeight(0);
if (shouldUsePrintingLayout())
m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth();
SubtreeLayoutScope layoutScope(this);
bool relayoutChildren = !shouldUsePrintingLayout() && (!m_frameView || width() != viewWidth() || height() != viewHeight());
if (relayoutChildren) {
layoutScope.setChildNeedsLayout(this);
for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
if (child->isSVGRoot())
continue;
if ((child->isBox() && toRenderBox(child)->hasRelativeLogicalHeight())
|| child->style()->logicalHeight().isPercent()
|| child->style()->logicalMinHeight().isPercent()
|| child->style()->logicalMaxHeight().isPercent())
layoutScope.setChildNeedsLayout(child);
}
if (document().svgExtensions())
document().accessSVGExtensions().invalidateSVGRootsWithRelativeLengthDescendents(&layoutScope);
}
ASSERT(!m_layoutState);
if (!needsLayout())
return;
RootLayoutStateScope rootLayoutStateScope(*this);
m_pageLogicalHeightChanged = false;
layoutContent();
#ifndef NDEBUG
checkLayoutState();
#endif
clearNeedsLayout();
}
void RenderView::mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFixed) const
{
ASSERT_UNUSED(wasFixed, !wasFixed || *wasFixed == static_cast<bool>(mode & IsFixed));
if (!repaintContainer && mode & UseTransforms && shouldUseTransformFromContainer(0)) {
TransformationMatrix t;
getTransformFromContainer(0, LayoutSize(), t);
transformState.applyTransform(t);
}
if (mode & IsFixed && m_frameView)
transformState.move(m_frameView->scrollOffsetForFixedPosition());
if (repaintContainer == this)
return;
if (mode & TraverseDocumentBoundaries) {
if (RenderObject* parentDocRenderer = frame()->ownerRenderer()) {
transformState.move(-frame()->view()->scrollOffset());
if (parentDocRenderer->isBox())
transformState.move(toLayoutSize(toRenderBox(parentDocRenderer)->contentBoxRect().location()));
parentDocRenderer->mapLocalToContainer(repaintContainer, transformState, mode, wasFixed);
return;
}
}
ASSERT_ARG(repaintContainer, !repaintContainer);
}
const RenderObject* RenderView::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const
{
LayoutSize offsetForFixedPosition;
LayoutSize offset;
RenderObject* container = 0;
if (m_frameView)
offsetForFixedPosition = m_frameView->scrollOffsetForFixedPosition();
if (geometryMap.mapCoordinatesFlags() & TraverseDocumentBoundaries) {
if (RenderPart* parentDocRenderer = frame()->ownerRenderer()) {
offset = -m_frameView->scrollOffset();
offset += toLayoutSize(parentDocRenderer->contentBoxRect().location());
container = parentDocRenderer;
}
}
ASSERT_ARG(ancestorToStopAt, !ancestorToStopAt || ancestorToStopAt == this || container);
if ((!ancestorToStopAt || container) && shouldUseTransformFromContainer(container)) {
TransformationMatrix t;
getTransformFromContainer(container, LayoutSize(), t);
geometryMap.push(this, t, false, false, false, true, offsetForFixedPosition);
} else {
geometryMap.push(this, offset, false, false, false, false, offsetForFixedPosition);
}
return container;
}
void RenderView::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformState& transformState) const
{
if (mode & IsFixed && m_frameView)
transformState.move(m_frameView->scrollOffsetForFixedPosition());
if (mode & UseTransforms && shouldUseTransformFromContainer(0)) {
TransformationMatrix t;
getTransformFromContainer(0, LayoutSize(), t);
transformState.applyTransform(t);
}
}
void RenderView::computeSelfHitTestRects(Vector<LayoutRect>& rects, const LayoutPoint&) const
{
rects.append(LayoutRect(LayoutPoint::zero(), frameView()->contentsSize()));
}
void RenderView::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
ASSERT(!needsLayout());
ASSERT(LayoutPoint(IntPoint(paintOffset.x(), paintOffset.y())) == paintOffset);
ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this);
if (m_frameView && style()->isOverflowPaged())
paintInfo.context->fillRect(paintInfo.rect, m_frameView->baseBackgroundColor());
paintObject(paintInfo, paintOffset);
}
static inline bool rendererObscuresBackground(RenderBox* rootBox)
{
ASSERT(rootBox);
RenderStyle* style = rootBox->style();
if (style->visibility() != VISIBLE
|| style->opacity() != 1
|| style->hasFilter()
|| style->hasTransform())
return false;
if (rootBox->compositingState() == PaintsIntoOwnBacking)
return false;
const RenderObject* rootRenderer = rootBox->rendererForRootBackground();
if (rootRenderer->style()->backgroundClip() == TextFillBox)
return false;
return true;
}
bool RenderView::rootFillsViewportBackground(RenderBox* rootBox) const
{
ASSERT(rootBox);
if (!rootBox->isSVG())
return true;
return rootBox->frameRect().contains(frameRect());
}
void RenderView::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&)
{
Element* elt;
for (elt = document().ownerElement(); view() && elt && elt->renderer(); elt = elt->document().ownerElement()) {
RenderLayer* layer = elt->renderer()->enclosingLayer();
if (layer->cannotBlitToWindow()) {
frameView()->setCannotBlitToWindow();
break;
}
if (layer->enclosingCompositingLayerForRepaint()) {
frameView()->setCannotBlitToWindow();
break;
}
}
if (document().ownerElement() || !view())
return;
if (paintInfo.skipRootBackground())
return;
bool shouldPaintBackground = true;
Node* documentElement = document().documentElement();
if (RenderBox* rootBox = documentElement ? toRenderBox(documentElement->renderer()) : 0)
shouldPaintBackground = !rootFillsViewportBackground(rootBox) || !rendererObscuresBackground(rootBox);
if (!shouldPaintBackground)
return;
if (frameView()->isTransparent())
frameView()->setCannotBlitToWindow();
else {
Color baseColor = frameView()->baseBackgroundColor();
if (baseColor.alpha()) {
CompositeOperator previousOperator = paintInfo.context->compositeOperation();
paintInfo.context->setCompositeOperation(CompositeCopy);
paintInfo.context->fillRect(paintInfo.rect, baseColor);
paintInfo.context->setCompositeOperation(previousOperator);
} else {
paintInfo.context->clearRect(paintInfo.rect);
}
}
}
bool RenderView::shouldRepaint(const LayoutRect& rect) const
{
if (document().printing())
return false;
return m_frameView && !rect.isEmpty();
}
void RenderView::repaintViewRectangle(const LayoutRect& ur) const
{
if (!shouldRepaint(ur))
return;
Element* elt = document().ownerElement();
if (!elt)
m_frameView->repaintContentRectangle(pixelSnappedIntRect(ur));
else if (RenderBox* obj = elt->renderBox()) {
LayoutRect vr = viewRect();
LayoutRect r = intersection(ur, vr);
r.moveBy(-vr.location());
r.moveBy(obj->contentBoxRect().location());
obj->repaintRectangle(r);
}
}
void RenderView::repaintViewAndCompositedLayers()
{
repaint();
DisableCompositingQueryAsserts disabler;
if (compositor()->inCompositingMode())
compositor()->repaintCompositedLayers();
}
void RenderView::computeRectForRepaint(const RenderLayerModelObject* repaintContainer, LayoutRect& rect, bool fixed) const
{
ASSERT_ARG(repaintContainer, !repaintContainer || repaintContainer == this);
if (document().printing())
return;
if (style()->isFlippedBlocksWritingMode()) {
if (style()->isHorizontalWritingMode())
rect.setY(viewHeight() - rect.maxY());
else
rect.setX(viewWidth() - rect.maxX());
}
if (fixed && m_frameView) {
rect.move(m_frameView->scrollOffsetForFixedPosition());
if (!m_frameView->pendingScrollDelta().isZero()) {
rect.move(-m_frameView->pendingScrollDelta());
}
}
if (!repaintContainer && layer() && layer()->transform())
rect = layer()->transform()->mapRect(rect);
}
void RenderView::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const
{
rects.append(pixelSnappedIntRect(accumulatedOffset, layer()->size()));
}
void RenderView::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const
{
if (wasFixed)
*wasFixed = false;
quads.append(FloatRect(FloatPoint(), layer()->size()));
}
static RenderObject* rendererAfterPosition(RenderObject* object, unsigned offset)
{
if (!object)
return 0;
RenderObject* child = object->childAt(offset);
return child ? child : object->nextInPreOrderAfterChildren();
}
IntRect RenderView::selectionBounds(bool clipToVisibleContent) const
{
typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectionMap;
SelectionMap selectedObjects;
RenderObject* os = m_selectionStart;
RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos);
while (os && os != stop) {
if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selectionEnd) && os->selectionState() != SelectionNone) {
selectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, clipToVisibleContent)));
RenderBlock* cb = os->containingBlock();
while (cb && !cb->isRenderView()) {
OwnPtr<RenderSelectionInfo>& blockInfo = selectedObjects.add(cb, nullptr).storedValue->value;
if (blockInfo)
break;
blockInfo = adoptPtr(new RenderSelectionInfo(cb, clipToVisibleContent));
cb = cb->containingBlock();
}
}
os = os->nextInPreOrder();
}
LayoutRect selRect;
SelectionMap::iterator end = selectedObjects.end();
for (SelectionMap::iterator i = selectedObjects.begin(); i != end; ++i) {
RenderSelectionInfo* info = i->value.get();
LayoutRect currRect = info->rect();
if (RenderLayerModelObject* repaintContainer = info->repaintContainer()) {
FloatQuad absQuad = repaintContainer->localToAbsoluteQuad(FloatRect(currRect));
currRect = absQuad.enclosingBoundingBox();
}
selRect.unite(currRect);
}
return pixelSnappedIntRect(selRect);
}
void RenderView::repaintSelection() const
{
HashSet<RenderBlock*> processedBlocks;
RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos);
for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrder()) {
if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectionEnd)
continue;
if (o->selectionState() == SelectionNone)
continue;
RenderSelectionInfo(o, true).repaint();
for (RenderBlock* block = o->containingBlock(); block && !block->isRenderView(); block = block->containingBlock()) {
if (!processedBlocks.add(block).isNewEntry)
break;
RenderSelectionInfo(block, true).repaint();
}
}
}
static inline RenderObject* getNextOrPrevRenderObjectBasedOnDirection(const RenderObject* o, const RenderObject* stop, bool& continueExploring, bool& exploringBackwards)
{
RenderObject* next;
if (exploringBackwards) {
next = o->previousInPreOrder();
continueExploring = next && !(next)->isRenderView();
} else {
next = o->nextInPreOrder();
continueExploring = next && next != stop;
exploringBackwards = !next && (next != stop);
if (exploringBackwards) {
next = stop->previousInPreOrder();
continueExploring = next && !next->isRenderView();
}
}
return next;
}
void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* end, int endPos, SelectionRepaintMode blockRepaintMode)
{
if ((start && !end) || (end && !start))
return;
if (m_selectionStart == start && m_selectionStartPos == startPos &&
m_selectionEnd == end && m_selectionEndPos == endPos)
return;
int oldStartPos = m_selectionStartPos;
int oldEndPos = m_selectionEndPos;
typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectedObjectMap;
SelectedObjectMap oldSelectedObjects;
SelectedObjectMap newSelectedObjects;
typedef HashMap<RenderBlock*, OwnPtr<RenderBlockSelectionInfo> > SelectedBlockMap;
SelectedBlockMap oldSelectedBlocks;
SelectedBlockMap newSelectedBlocks;
RenderObject* os = m_selectionStart;
RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos);
bool exploringBackwards = false;
bool continueExploring = os && (os != stop);
while (continueExploring) {
if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selectionEnd) && os->selectionState() != SelectionNone) {
oldSelectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, true)));
if (blockRepaintMode == RepaintNewXOROld) {
RenderBlock* cb = os->containingBlock();
while (cb && !cb->isRenderView()) {
OwnPtr<RenderBlockSelectionInfo>& blockInfo = oldSelectedBlocks.add(cb, nullptr).storedValue->value;
if (blockInfo)
break;
blockInfo = adoptPtr(new RenderBlockSelectionInfo(cb));
cb = cb->containingBlock();
}
}
}
os = getNextOrPrevRenderObjectBasedOnDirection(os, stop, continueExploring, exploringBackwards);
}
SelectedObjectMap::iterator oldObjectsEnd = oldSelectedObjects.end();
for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObjectsEnd; ++i)
i->key->setSelectionStateIfNeeded(SelectionNone);
m_selectionStart = start;
m_selectionStartPos = startPos;
m_selectionEnd = end;
m_selectionEndPos = endPos;
if (start && start == end)
start->setSelectionStateIfNeeded(SelectionBoth);
else {
if (start)
start->setSelectionStateIfNeeded(SelectionStart);
if (end)
end->setSelectionStateIfNeeded(SelectionEnd);
}
RenderObject* o = start;
stop = rendererAfterPosition(end, endPos);
while (o && o != stop) {
if (o != start && o != end && o->canBeSelectionLeaf())
o->setSelectionStateIfNeeded(SelectionInside);
o = o->nextInPreOrder();
}
if (blockRepaintMode != RepaintNothing)
layer()->clearBlockSelectionGapsBounds();
o = start;
exploringBackwards = false;
continueExploring = o && (o != stop);
while (continueExploring) {
if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionState() != SelectionNone) {
newSelectedObjects.set(o, adoptPtr(new RenderSelectionInfo(o, true)));
RenderBlock* cb = o->containingBlock();
while (cb && !cb->isRenderView()) {
OwnPtr<RenderBlockSelectionInfo>& blockInfo = newSelectedBlocks.add(cb, nullptr).storedValue->value;
if (blockInfo)
break;
blockInfo = adoptPtr(new RenderBlockSelectionInfo(cb));
cb = cb->containingBlock();
}
}
o = getNextOrPrevRenderObjectBasedOnDirection(o, stop, continueExploring, exploringBackwards);
}
if (!m_frameView || blockRepaintMode == RepaintNothing)
return;
for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObjectsEnd; ++i) {
RenderObject* obj = i->key;
RenderSelectionInfo* newInfo = newSelectedObjects.get(obj);
RenderSelectionInfo* oldInfo = i->value.get();
if (!newInfo || oldInfo->rect() != newInfo->rect() || oldInfo->state() != newInfo->state() ||
(m_selectionStart == obj && oldStartPos != m_selectionStartPos) ||
(m_selectionEnd == obj && oldEndPos != m_selectionEndPos)) {
oldInfo->repaint();
if (newInfo) {
newInfo->repaint();
newSelectedObjects.remove(obj);
}
}
}
SelectedObjectMap::iterator newObjectsEnd = newSelectedObjects.end();
for (SelectedObjectMap::iterator i = newSelectedObjects.begin(); i != newObjectsEnd; ++i)
i->value->repaint();
SelectedBlockMap::iterator oldBlocksEnd = oldSelectedBlocks.end();
for (SelectedBlockMap::iterator i = oldSelectedBlocks.begin(); i != oldBlocksEnd; ++i) {
RenderBlock* block = i->key;
RenderBlockSelectionInfo* newInfo = newSelectedBlocks.get(block);
RenderBlockSelectionInfo* oldInfo = i->value.get();
if (!newInfo || oldInfo->rects() != newInfo->rects() || oldInfo->state() != newInfo->state()) {
oldInfo->repaint();
if (newInfo) {
newInfo->repaint();
newSelectedBlocks.remove(block);
}
}
}
SelectedBlockMap::iterator newBlocksEnd = newSelectedBlocks.end();
for (SelectedBlockMap::iterator i = newSelectedBlocks.begin(); i != newBlocksEnd; ++i)
i->value->repaint();
}
void RenderView::getSelection(RenderObject*& startRenderer, int& startOffset, RenderObject*& endRenderer, int& endOffset) const
{
startRenderer = m_selectionStart;
startOffset = m_selectionStartPos;
endRenderer = m_selectionEnd;
endOffset = m_selectionEndPos;
}
void RenderView::clearSelection()
{
layer()->repaintBlockSelectionGaps();
setSelection(0, -1, 0, -1, RepaintNewMinusOld);
}
void RenderView::selectionStartEnd(int& startPos, int& endPos) const
{
startPos = m_selectionStartPos;
endPos = m_selectionEndPos;
}
bool RenderView::shouldUsePrintingLayout() const
{
if (!document().printing() || !m_frameView)
return false;
return m_frameView->frame().shouldUsePrintingLayout();
}
LayoutRect RenderView::viewRect() const
{
if (shouldUsePrintingLayout())
return LayoutRect(LayoutPoint(), size());
if (m_frameView)
return m_frameView->visibleContentRect();
return LayoutRect();
}
IntRect RenderView::unscaledDocumentRect() const
{
LayoutRect overflowRect(layoutOverflowRect());
flipForWritingMode(overflowRect);
return pixelSnappedIntRect(overflowRect);
}
bool RenderView::rootBackgroundIsEntirelyFixed() const
{
RenderObject* rootObject = document().documentElement() ? document().documentElement()->renderer() : 0;
if (!rootObject)
return false;
RenderObject* rootRenderer = rootObject->rendererForRootBackground();
return rootRenderer->hasEntirelyFixedBackground();
}
LayoutRect RenderView::backgroundRect(RenderBox* backgroundRenderer) const
{
if (!hasColumns())
return unscaledDocumentRect();
ColumnInfo* columnInfo = this->columnInfo();
LayoutRect backgroundRect(0, 0, columnInfo->desiredColumnWidth(), columnInfo->columnHeight() * columnInfo->columnCount());
if (!isHorizontalWritingMode())
backgroundRect = backgroundRect.transposedRect();
backgroundRenderer->flipForWritingMode(backgroundRect);
return backgroundRect;
}
IntRect RenderView::documentRect() const
{
FloatRect overflowRect(unscaledDocumentRect());
if (hasTransform())
overflowRect = layer()->currentTransform().mapRect(overflowRect);
return IntRect(overflowRect);
}
int RenderView::viewHeight(IncludeScrollbarsInRect scrollbarInclusion) const
{
int height = 0;
if (!shouldUsePrintingLayout() && m_frameView)
height = m_frameView->layoutSize(scrollbarInclusion).height();
return height;
}
int RenderView::viewWidth(IncludeScrollbarsInRect scrollbarInclusion) const
{
int width = 0;
if (!shouldUsePrintingLayout() && m_frameView)
width = m_frameView->layoutSize(scrollbarInclusion).width();
return width;
}
int RenderView::viewLogicalHeight() const
{
return style()->isHorizontalWritingMode() ? viewHeight(ExcludeScrollbars) : viewWidth(ExcludeScrollbars);
}
float RenderView::zoomFactor() const
{
return m_frameView->frame().pageZoomFactor();
}
void RenderView::pushLayoutState(RenderObject& root)
{
ASSERT(m_layoutStateDisableCount == 0);
ASSERT(m_layoutState == 0);
pushLayoutStateForCurrentFlowThread(root);
m_layoutState = new LayoutState(root);
}
bool RenderView::shouldDisableLayoutStateForSubtree(RenderObject& renderer) const
{
RenderObject* o = &renderer;
while (o) {
if (o->shouldDisableLayoutState())
return true;
o = o->container();
}
return false;
}
void RenderView::updateHitTestResult(HitTestResult& result, const LayoutPoint& point)
{
if (result.innerNode())
return;
Node* node = document().documentElement();
if (node) {
result.setInnerNode(node);
if (!result.innerNonSharedNode())
result.setInnerNonSharedNode(node);
LayoutPoint adjustedPoint = point;
offsetForContents(adjustedPoint);
result.setLocalPoint(adjustedPoint);
}
}
bool RenderView::usesCompositing() const
{
return m_compositor && m_compositor->inCompositingMode();
}
RenderLayerCompositor* RenderView::compositor()
{
if (!m_compositor)
m_compositor = adoptPtr(new RenderLayerCompositor(*this));
return m_compositor.get();
}
void RenderView::setIsInWindow(bool isInWindow)
{
if (m_compositor)
m_compositor->setIsInWindow(isInWindow);
}
FlowThreadController* RenderView::flowThreadController()
{
if (!m_flowThreadController)
m_flowThreadController = FlowThreadController::create();
return m_flowThreadController.get();
}
void RenderView::pushLayoutStateForCurrentFlowThread(const RenderObject& object)
{
if (!m_flowThreadController)
return;
RenderFlowThread* currentFlowThread = m_flowThreadController->currentRenderFlowThread();
if (!currentFlowThread)
return;
currentFlowThread->pushFlowThreadLayoutState(object);
}
void RenderView::popLayoutStateForCurrentFlowThread()
{
if (!m_flowThreadController)
return;
RenderFlowThread* currentFlowThread = m_flowThreadController->currentRenderFlowThread();
if (!currentFlowThread)
return;
currentFlowThread->popFlowThreadLayoutState();
}
IntervalArena* RenderView::intervalArena()
{
if (!m_intervalArena)
m_intervalArena = IntervalArena::create();
return m_intervalArena.get();
}
bool RenderView::backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const
{
if (!m_frameView || !m_frameView->isMainFrame())
return false;
return m_frameView->hasOpaqueBackground();
}
double RenderView::layoutViewportWidth() const
{
float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1;
return viewWidth(IncludeScrollbars) / scale;
}
double RenderView::layoutViewportHeight() const
{
float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1;
return viewHeight(IncludeScrollbars) / scale;
}
}