summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/RenderReplaced.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
commit1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch)
tree4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/rendering/RenderReplaced.cpp
parent9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff)
downloadexternal_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/rendering/RenderReplaced.cpp')
-rw-r--r--WebCore/rendering/RenderReplaced.cpp81
1 files changed, 49 insertions, 32 deletions
diff --git a/WebCore/rendering/RenderReplaced.cpp b/WebCore/rendering/RenderReplaced.cpp
index 32d6332..52267d5 100644
--- a/WebCore/rendering/RenderReplaced.cpp
+++ b/WebCore/rendering/RenderReplaced.cpp
@@ -34,9 +34,12 @@ namespace WebCore {
typedef WTF::HashMap<const RenderReplaced*, IntRect> OverflowRectMap;
static OverflowRectMap* gOverflowRectMap = 0;
+const int cDefaultWidth = 300;
+const int cDefaultHeight = 150;
+
RenderReplaced::RenderReplaced(Node* node)
: RenderBox(node)
- , m_intrinsicSize(300, 150)
+ , m_intrinsicSize(cDefaultWidth, cDefaultHeight)
, m_selectionState(SelectionNone)
, m_hasOverflow(false)
{
@@ -57,7 +60,17 @@ RenderReplaced::~RenderReplaced()
if (m_hasOverflow)
gOverflowRectMap->remove(this);
}
-
+
+void RenderReplaced::styleDidChange(RenderStyle::Diff diff, const RenderStyle* oldStyle)
+{
+ RenderBox::styleDidChange(diff, oldStyle);
+
+ bool hadStyle = (oldStyle != 0);
+ float oldZoom = hadStyle ? oldStyle->effectiveZoom() : RenderStyle::initialZoom();
+ if (hadStyle && style() && style()->effectiveZoom() != oldZoom)
+ intrinsicSizeChanged();
+}
+
void RenderReplaced::layout()
{
ASSERT(needsLayout());
@@ -81,7 +94,15 @@ void RenderReplaced::layout()
setNeedsLayout(false);
}
-
+
+void RenderReplaced::intrinsicSizeChanged()
+{
+ int scaledWidth = static_cast<int>(cDefaultWidth * style()->effectiveZoom());
+ int scaledHeight = static_cast<int>(cDefaultHeight * style()->effectiveZoom());
+ m_intrinsicSize = IntSize(scaledWidth, scaledHeight);
+ setNeedsLayoutAndPrefWidthsRecalc();
+}
+
void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty)
{
if (!shouldPaint(paintInfo, tx, ty))
@@ -93,7 +114,12 @@ void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty)
if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection))
paintBoxDecorations(paintInfo, tx, ty);
- if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth() && style()->visibility() == VISIBLE)
+ if (paintInfo.phase == PaintPhaseMask) {
+ paintMask(paintInfo, tx, ty);
+ return;
+ }
+
+ if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth())
paintOutline(paintInfo.context, tx, ty, width(), height(), style());
if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection)
@@ -118,7 +144,7 @@ void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty)
bool RenderReplaced::shouldPaint(PaintInfo& paintInfo, int& tx, int& ty)
{
if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseOutline && paintInfo.phase != PaintPhaseSelfOutline
- && paintInfo.phase != PaintPhaseSelection)
+ && paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseMask)
return false;
if (!shouldPaintWithinRoot(paintInfo))
@@ -154,7 +180,12 @@ void RenderReplaced::calcPrefWidths()
{
ASSERT(prefWidthsDirty());
- int width = calcReplacedWidth() + paddingLeft() + paddingRight() + borderLeft() + borderRight();
+ int paddingAndBorders = paddingLeft() + paddingRight() + borderLeft() + borderRight();
+ int width = calcReplacedWidth(false) + paddingAndBorders;
+
+ if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength)
+ width = min(width, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? paddingAndBorders : 0));
+
if (style()->width().isPercent() || (style()->width().isAuto() && style()->height().isPercent())) {
m_minPrefWidth = 0;
m_maxPrefWidth = width;
@@ -164,30 +195,16 @@ void RenderReplaced::calcPrefWidths()
setPrefWidthsDirty(false);
}
-short RenderReplaced::lineHeight(bool, bool) const
+int RenderReplaced::lineHeight(bool, bool) const
{
return height() + marginTop() + marginBottom();
}
-short RenderReplaced::baselinePosition(bool, bool) const
+int RenderReplaced::baselinePosition(bool, bool) const
{
return height() + marginTop() + marginBottom();
}
-int RenderReplaced::caretMinOffset() const
-{
- return 0;
-}
-
-// Returns 1 since a replaced element can have the caret positioned
-// at its beginning (0), or at its end (1).
-// NOTE: Yet, "select" elements can have any number of "option" elements
-// as children, so this "0 or 1" idea does not really hold up.
-int RenderReplaced::caretMaxOffset() const
-{
- return 1;
-}
-
unsigned RenderReplaced::caretMaxRenderedOffset() const
{
return 1;
@@ -296,21 +313,21 @@ void RenderReplaced::setIntrinsicSize(const IntSize& size)
void RenderReplaced::adjustOverflowForBoxShadow()
{
- if (ShadowData* boxShadow = style()->boxShadow()) {
- if (!gOverflowRectMap)
- gOverflowRectMap = new OverflowRectMap();
-
+ IntRect overflow;
+ for (ShadowData* boxShadow = style()->boxShadow(); boxShadow; boxShadow = boxShadow->next) {
IntRect shadow = borderBox();
shadow.move(boxShadow->x, boxShadow->y);
shadow.inflate(boxShadow->blur);
- shadow.unite(borderBox());
-
- gOverflowRectMap->set(this, shadow);
- m_hasOverflow = true;
- return;
+ overflow.unite(shadow);
}
- if (m_hasOverflow) {
+ if (!overflow.isEmpty()) {
+ if (!gOverflowRectMap)
+ gOverflowRectMap = new OverflowRectMap();
+ overflow.unite(borderBox());
+ gOverflowRectMap->set(this, overflow);
+ m_hasOverflow = true;
+ } else if (m_hasOverflow) {
gOverflowRectMap->remove(this);
m_hasOverflow = false;
}