summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/RenderView.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
commit635860845790a19bf50bbc51ba8fb66a96dde068 (patch)
treeef6ad9ff73a5b57f65249d4232a202fa77e6a140 /WebCore/rendering/RenderView.cpp
parent8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff)
downloadexternal_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2
auto import from //depot/cupcake/@136594
Diffstat (limited to 'WebCore/rendering/RenderView.cpp')
-rw-r--r--WebCore/rendering/RenderView.cpp144
1 files changed, 94 insertions, 50 deletions
diff --git a/WebCore/rendering/RenderView.cpp b/WebCore/rendering/RenderView.cpp
index a447bc8..7ce4998 100644
--- a/WebCore/rendering/RenderView.cpp
+++ b/WebCore/rendering/RenderView.cpp
@@ -1,8 +1,6 @@
-/**
- * This file is part of the HTML widget for KDE.
- *
+/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -25,6 +23,7 @@
#include "Document.h"
#include "Element.h"
+#include "FloatQuad.h"
#include "Frame.h"
#include "FrameView.h"
#include "GraphicsContext.h"
@@ -54,10 +53,7 @@ RenderView::RenderView(Node* node, FrameView* view)
// init RenderObject attributes
setInline(false);
-
- // try to contrain the width to the views width
- m_width = 0;
- m_height = 0;
+
m_minPrefWidth = 0;
m_maxPrefWidth = 0;
@@ -77,20 +73,20 @@ RenderView::~RenderView()
void RenderView::calcHeight()
{
if (!printing() && m_frameView)
- m_height = viewHeight();
+ setHeight(viewHeight());
}
void RenderView::calcWidth()
{
if (!printing() && m_frameView)
- m_width = viewWidth();
+ setWidth(viewWidth());
#ifdef ANDROID_LAYOUT
const Settings * settings = document()->settings();
ASSERT(settings);
if (settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen)
m_visibleWidth = m_frameView->screenWidth();
- if (settings->useWideViewport() && settings->viewportWidth() == -1 && m_width < minPrefWidth())
- m_width = m_minPrefWidth;
+ if (settings->useWideViewport() && settings->viewportWidth() == -1 && width() < minPrefWidth())
+ setWidth(m_minPrefWidth);
#endif
m_marginLeft = 0;
m_marginRight = 0;
@@ -108,10 +104,10 @@ void RenderView::calcPrefWidths()
void RenderView::layout()
{
if (printing())
- m_minPrefWidth = m_maxPrefWidth = m_width;
+ m_minPrefWidth = m_maxPrefWidth = width();
// Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account.
- bool relayoutChildren = !printing() && (!m_frameView || m_width != viewWidth() || m_height != viewHeight());
+ bool relayoutChildren = !printing() && (!m_frameView || width() != viewWidth() || height() != viewHeight());
if (relayoutChildren) {
setChildNeedsLayout(true, false);
for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
@@ -130,8 +126,8 @@ void RenderView::layout()
RenderBlock::layout();
// Ensure that docWidth() >= width() and docHeight() >= height().
- setOverflowWidth(m_width);
- setOverflowHeight(m_height);
+ setOverflowWidth(width());
+ setOverflowHeight(height());
setOverflowWidth(docWidth());
setOverflowHeight(docHeight());
@@ -143,20 +139,39 @@ void RenderView::layout()
setNeedsLayout(false);
}
-bool RenderView::absolutePosition(int& xPos, int& yPos, bool fixed) const
+FloatPoint RenderView::localToAbsolute(FloatPoint localPoint, bool fixed, bool) const
+{
+ // This disables the css position:fixed to the Browser window. Instead
+ // the fixed element will be always fixed to the top page.
+#ifndef ANDROID_DISABLE_POSITION_FIXED
+ if (fixed && m_frameView)
+ localPoint += m_frameView->scrollOffset();
+#endif
+ return localPoint;
+}
+
+FloatPoint RenderView::absoluteToLocal(FloatPoint containerPoint, bool fixed, bool) const
{
- if (fixed && m_frameView) {
-#ifdef ANDROID_DISABLE_POSITION_FIXED
- // This disables the css position:fixed to the Browser window. Instead
- // the fixed element will be always fixed to the top page.
- xPos = yPos = 0;
-#else
- xPos = m_frameView->scrollX();
- yPos = m_frameView->scrollY();
+ // This disables the css position:fixed to the Browser window. Instead
+ // the fixed element will be always fixed to the top page.
+#ifndef ANDROID_DISABLE_POSITION_FIXED
+ if (fixed && m_frameView)
+ containerPoint -= m_frameView->scrollOffset();
#endif
- } else
- xPos = yPos = 0;
- return true;
+ return containerPoint;
+}
+
+FloatQuad RenderView::localToContainerQuad(const FloatQuad& localQuad, RenderBox* repaintContainer, bool fixed) const
+{
+ // If a container was specified, and was not 0 or the RenderView,
+ // then we should have found it by now.
+ ASSERT_UNUSED(repaintContainer, !repaintContainer || repaintContainer == this);
+
+ FloatQuad quad = localQuad;
+ if (fixed && m_frameView)
+ quad += m_frameView->scrollOffset();
+
+ return quad;
}
void RenderView::paint(PaintInfo& paintInfo, int tx, int ty)
@@ -172,7 +187,12 @@ void RenderView::paint(PaintInfo& paintInfo, int tx, int ty)
paintObject(paintInfo, tx, ty);
}
-void RenderView::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
+static inline bool rendererObscuresBackground(RenderObject* object)
+{
+ return object && object->style()->visibility() == VISIBLE && object->style()->opacity() == 1 && !object->style()->hasTransform();
+}
+
+void RenderView::paintBoxDecorations(PaintInfo& paintInfo, int, int)
{
// Check to see if we are enclosed by a layer that requires complex painting rules. If so, we cannot blit
// when scrolling, and we need to use slow repaints. Examples of layers that require this are transparent layers,
@@ -188,10 +208,12 @@ void RenderView::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
}
}
- if (elt || (firstChild() && firstChild()->style()->visibility() == VISIBLE) || !view())
+ // If painting will entirely fill the view, no need to fill the background.
+ if (elt || rendererObscuresBackground(firstChild()) || !view())
return;
- // This code typically only executes if the root element's visibility has been set to hidden.
+ // This code typically only executes if the root element's visibility has been set to hidden,
+ // or there is a transform on the <html>.
// Only fill with the base background color (typically white) if we're the root document,
// since iframes/frames with no background in the child document should show the parent's background.
if (view()->isTransparent()) // FIXME: This needs to be dynamic. We should be able to go back to blitting if we ever stop being transparent.
@@ -221,7 +243,7 @@ void RenderView::repaintViewRectangle(const IntRect& ur, bool immediate)
Element* elt = document()->ownerElement();
if (!elt)
m_frameView->repaintContentRectangle(ur, immediate);
- else if (RenderObject* obj = elt->renderer()) {
+ else if (RenderBox* obj = elt->renderBox()) {
IntRect vr = viewRect();
IntRect r = intersection(ur, vr);
@@ -236,8 +258,12 @@ void RenderView::repaintViewRectangle(const IntRect& ur, bool immediate)
}
}
-void RenderView::computeAbsoluteRepaintRect(IntRect& rect, bool fixed)
+void RenderView::computeRectForRepaint(IntRect& rect, RenderBox* repaintContainer, bool fixed)
{
+ // If a container was specified, and was not 0 or the RenderView,
+ // then we should have found it by now.
+ ASSERT_UNUSED(repaintContainer, !repaintContainer || repaintContainer == this);
+
if (printing())
return;
@@ -254,7 +280,12 @@ void RenderView::absoluteRects(Vector<IntRect>& rects, int tx, int ty, bool)
rects.append(IntRect(tx, ty, m_layer->width(), m_layer->height()));
}
-RenderObject* rendererAfterPosition(RenderObject* object, unsigned offset)
+void RenderView::absoluteQuads(Vector<FloatQuad>& quads, bool)
+{
+ quads.append(FloatRect(0, 0, m_layer->width(), m_layer->height()));
+}
+
+static RenderObject* rendererAfterPosition(RenderObject* object, unsigned offset)
{
if (!object)
return 0;
@@ -263,7 +294,17 @@ RenderObject* rendererAfterPosition(RenderObject* object, unsigned offset)
return child ? child : object->nextInPreOrderAfterChildren();
}
-IntRect RenderView::selectionRect(bool clipToVisibleContent) const
+IntRect RenderView::selectionRect(bool clipToVisibleContent)
+{
+ // The virtual selectionRect() should never be called on the RenderView.
+ // We assert because there used to be ambiguity between
+ // RenderView::selectionRect(bool) and
+ // virtual RenderObject::selectionRect(bool) const
+ ASSERT_NOT_REACHED();
+ return RenderBlock::selectionRect(clipToVisibleContent);
+}
+
+IntRect RenderView::selectionBounds(bool clipToVisibleContent) const
{
document()->updateRendering();
@@ -495,7 +536,7 @@ void RenderView::removeWidget(RenderObject* o)
IntRect RenderView::viewRect() const
{
if (printing())
- return IntRect(0, 0, m_width, m_height);
+ return IntRect(0, 0, width(), height());
if (m_frameView)
return m_frameView->visibleContentRect();
return IntRect();
@@ -503,7 +544,7 @@ IntRect RenderView::viewRect() const
int RenderView::docHeight() const
{
- int h = m_height;
+ int h = height();
int lowestPos = lowestPosition();
if (lowestPos > h)
h = lowestPos;
@@ -512,7 +553,7 @@ int RenderView::docHeight() const
// Instead of this dh computation we should keep the result
// when we call RenderBlock::layout.
int dh = 0;
- for (RenderObject* c = firstChild(); c; c = c->nextSibling())
+ for (RenderBox* c = firstChildBox(); c; c = c->nextSiblingBox())
dh += c->height() + c->marginTop() + c->marginBottom();
if (dh > h)
@@ -523,12 +564,12 @@ int RenderView::docHeight() const
int RenderView::docWidth() const
{
- int w = m_width;
+ int w = width();
int rightmostPos = rightmostPosition();
if (rightmostPos > w)
w = rightmostPos;
-
- for (RenderObject *c = firstChild(); c; c = c->nextSibling()) {
+
+ for (RenderBox* c = firstChildBox(); c; c = c->nextSiblingBox()) {
int dw = c->width() + c->marginLeft() + c->marginRight();
if (dw > w)
w = dw;
@@ -540,22 +581,26 @@ int RenderView::docWidth() const
int RenderView::viewHeight() const
{
int height = 0;
- if (!printing() && m_frameView)
- height = m_frameView->visibleHeight();
+ if (!printing() && m_frameView) {
+ height = m_frameView->layoutHeight();
+ height = m_frameView->useFixedLayout() ? ceilf(style()->effectiveZoom() * float(height)) : height;
+ }
return height;
}
int RenderView::viewWidth() const
{
int width = 0;
- if (!printing() && m_frameView)
- width = m_frameView->visibleWidth();
+ if (!printing() && m_frameView) {
+ width = m_frameView->layoutWidth();
+ width = m_frameView->useFixedLayout() ? ceilf(style()->effectiveZoom() * float(width)) : width;
+ }
return width;
}
// The idea here is to take into account what object is moving the pagination point, and
// thus choose the best place to chop it.
-void RenderView::setBestTruncatedAt(int y, RenderObject* forRenderer, bool forcedBreak)
+void RenderView::setBestTruncatedAt(int y, RenderBox* forRenderer, bool forcedBreak)
{
// Nobody else can set a page break once we have a forced break.
if (m_forcedPageBreak)
@@ -569,16 +614,15 @@ void RenderView::setBestTruncatedAt(int y, RenderObject* forRenderer, bool force
}
// prefer the widest object who tries to move the pagination point
- int width = forRenderer->width();
- if (width > m_truncatorWidth) {
- m_truncatorWidth = width;
+ if (forRenderer->width() > m_truncatorWidth) {
+ m_truncatorWidth = forRenderer->width();
m_bestTruncatedAt = y;
}
}
void RenderView::pushLayoutState(RenderObject* root)
{
- ASSERT(!m_frameView->needsFullRepaint());
+ ASSERT(!doingFullRepaint());
ASSERT(m_layoutStateDisableCount == 0);
ASSERT(m_layoutState == 0);