summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/RenderReplaced.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-10-08 17:19:54 +0100
committerSteve Block <steveblock@google.com>2009-10-20 00:41:58 +0100
commit231d4e3152a9c27a73b6ac7badbe6be673aa3ddf (patch)
treea6c7e2d6cd7bfa7011cc39abbb436142d7a4a7c8 /WebCore/rendering/RenderReplaced.cpp
parente196732677050bd463301566a68a643b6d14b907 (diff)
downloadexternal_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.zip
external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.gz
external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.bz2
Merge webkit.org at R49305 : Automatic merge by git.
Change-Id: I8968561bc1bfd72b8923b7118d3728579c6dbcc7
Diffstat (limited to 'WebCore/rendering/RenderReplaced.cpp')
-rw-r--r--WebCore/rendering/RenderReplaced.cpp127
1 files changed, 28 insertions, 99 deletions
diff --git a/WebCore/rendering/RenderReplaced.cpp b/WebCore/rendering/RenderReplaced.cpp
index 692a66e..27d2e72 100644
--- a/WebCore/rendering/RenderReplaced.cpp
+++ b/WebCore/rendering/RenderReplaced.cpp
@@ -34,9 +34,6 @@ using namespace std;
namespace WebCore {
-typedef WTF::HashMap<const RenderReplaced*, IntRect> OverflowRectMap;
-static OverflowRectMap* gOverflowRectMap = 0;
-
const int cDefaultWidth = 300;
const int cDefaultHeight = 150;
@@ -56,8 +53,6 @@ RenderReplaced::RenderReplaced(Node* node, const IntSize& intrinsicSize)
RenderReplaced::~RenderReplaced()
{
- if (replacedHasOverflow())
- gOverflowRectMap->remove(this);
}
void RenderReplaced::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
@@ -66,7 +61,7 @@ void RenderReplaced::styleDidChange(StyleDifference diff, const RenderStyle* old
bool hadStyle = (oldStyle != 0);
float oldZoom = hadStyle ? oldStyle->effectiveZoom() : RenderStyle::initialZoom();
- if (hadStyle && style() && style()->effectiveZoom() != oldZoom)
+ if (style() && style()->effectiveZoom() != oldZoom)
intrinsicSizeChanged();
}
@@ -77,10 +72,12 @@ void RenderReplaced::layout()
LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
setHeight(minimumReplacedHeight());
-
+
calcWidth();
calcHeight();
- adjustOverflowForBoxShadowAndReflect();
+
+ m_overflow.clear();
+ addShadowOverflow();
repainter.repaintAfterLayout();
@@ -127,21 +124,29 @@ void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty)
drawSelectionTint = false;
}
+ bool completelyClippedOut = false;
if (style()->hasBorderRadius()) {
- // Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
- paintInfo.context->save();
-
- IntSize topLeft, topRight, bottomLeft, bottomRight;
IntRect borderRect = IntRect(tx, ty, width(), height());
- style()->getBorderRadiiForRect(borderRect, topLeft, topRight, bottomLeft, bottomRight);
- paintInfo.context->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
+ if (borderRect.isEmpty())
+ completelyClippedOut = true;
+ else {
+ // Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
+ paintInfo.context->save();
+
+ IntSize topLeft, topRight, bottomLeft, bottomRight;
+ style()->getBorderRadiiForRect(borderRect, topLeft, topRight, bottomLeft, bottomRight);
+
+ paintInfo.context->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
+ }
}
- paintReplaced(paintInfo, tx, ty);
+ if (!completelyClippedOut) {
+ paintReplaced(paintInfo, tx, ty);
- if (style()->hasBorderRadius())
- paintInfo.context->restore();
+ if (style()->hasBorderRadius())
+ paintInfo.context->restore();
+ }
// The selection tint never gets clipped by border-radius rounding, since we want it to run right up to the edges of
// surrounding content.
@@ -169,8 +174,8 @@ bool RenderReplaced::shouldPaint(PaintInfo& paintInfo, int& tx, int& ty)
int currentTY = ty + y();
// Early exit if the element touches the edges.
- int top = currentTY + overflowTop();
- int bottom = currentTY + overflowHeight();
+ int top = currentTY + topVisibleOverflow();
+ int bottom = currentTY + bottomVisibleOverflow();
if (isSelected() && m_inlineBoxWrapper) {
int selTop = ty + m_inlineBoxWrapper->root()->selectionTop();
int selBottom = ty + selTop + m_inlineBoxWrapper->root()->selectionHeight();
@@ -179,7 +184,7 @@ bool RenderReplaced::shouldPaint(PaintInfo& paintInfo, int& tx, int& ty)
}
int os = 2 * maximalOutlineSize(paintInfo.phase);
- if (currentTX + overflowLeft() >= paintInfo.rect.right() + os || currentTX + overflowWidth() <= paintInfo.rect.x() - os)
+ if (currentTX + leftVisibleOverflow() >= paintInfo.rect.right() + os || currentTX + rightVisibleOverflow() <= paintInfo.rect.x() - os)
return false;
if (top >= paintInfo.rect.bottom() + os || bottom <= paintInfo.rect.y() - os)
return false;
@@ -231,8 +236,8 @@ VisiblePosition RenderReplaced::positionForPoint(const IntPoint& point)
RootInlineBox* root = box->root();
- int top = root->topOverflow();
- int bottom = root->nextRootBox() ? root->nextRootBox()->topOverflow() : root->bottomOverflow();
+ int top = root->lineTop();
+ int bottom = root->nextRootBox() ? root->nextRootBox()->lineTop() : root->lineBottom();
if (point.y() + y() < top)
return createVisiblePosition(caretMinOffset(), DOWNSTREAM); // coordinates are above
@@ -327,82 +332,6 @@ void RenderReplaced::setIntrinsicSize(const IntSize& size)
m_intrinsicSize = size;
}
-void RenderReplaced::adjustOverflowForBoxShadowAndReflect()
-{
- IntRect overflow;
- for (ShadowData* boxShadow = style()->boxShadow(); boxShadow; boxShadow = boxShadow->next) {
- if (boxShadow->style == Inset)
- continue;
- IntRect shadow = borderBoxRect();
- shadow.move(boxShadow->x, boxShadow->y);
- shadow.inflate(boxShadow->blur + boxShadow->spread);
- overflow.unite(shadow);
- }
-
- // Now that we have an overflow rect including shadow, let's make sure that
- // the reflection (which can also include the shadow) is also included.
- if (hasReflection()) {
- if (overflow.isEmpty())
- overflow = borderBoxRect();
- overflow.unite(reflectedRect(overflow));
- }
-
- if (!overflow.isEmpty()) {
- if (!gOverflowRectMap)
- gOverflowRectMap = new OverflowRectMap();
- overflow.unite(borderBoxRect());
- gOverflowRectMap->set(this, overflow);
- setReplacedHasOverflow(true);
- } else if (replacedHasOverflow()) {
- gOverflowRectMap->remove(this);
- setReplacedHasOverflow(false);
- }
-}
-
-int RenderReplaced::overflowHeight(bool) const
-{
- if (replacedHasOverflow()) {
- IntRect *r = &gOverflowRectMap->find(this)->second;
- return r->height() + r->y();
- }
-
- return height();
-}
-
-int RenderReplaced::overflowWidth(bool) const
-{
- if (replacedHasOverflow()) {
- IntRect *r = &gOverflowRectMap->find(this)->second;
- return r->width() + r->x();
- }
-
- return width();
-}
-
-int RenderReplaced::overflowLeft(bool) const
-{
- if (replacedHasOverflow())
- return gOverflowRectMap->get(this).x();
-
- return 0;
-}
-
-int RenderReplaced::overflowTop(bool) const
-{
- if (replacedHasOverflow())
- return gOverflowRectMap->get(this).y();
-
- return 0;
-}
-
-IntRect RenderReplaced::overflowRect(bool) const
-{
- if (replacedHasOverflow())
- return gOverflowRectMap->find(this)->second;
-
- return borderBoxRect();
-}
-
IntRect RenderReplaced::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer)
{
if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent())
@@ -410,7 +339,7 @@ IntRect RenderReplaced::clippedOverflowRectForRepaint(RenderBoxModelObject* repa
// The selectionRect can project outside of the overflowRect, so take their union
// for repainting to avoid selection painting glitches.
- IntRect r = unionRect(localSelectionRect(false), overflowRect(false));
+ IntRect r = unionRect(localSelectionRect(false), visibleOverflowRect());
RenderView* v = view();
if (v) {