summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/RenderObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/rendering/RenderObject.cpp')
-rw-r--r--WebCore/rendering/RenderObject.cpp160
1 files changed, 63 insertions, 97 deletions
diff --git a/WebCore/rendering/RenderObject.cpp b/WebCore/rendering/RenderObject.cpp
index e70de96..d63997a 100644
--- a/WebCore/rendering/RenderObject.cpp
+++ b/WebCore/rendering/RenderObject.cpp
@@ -119,12 +119,12 @@ RenderObject* RenderObject::createObject(Node* node, RenderStyle* style)
if (node->hasTagName(rubyTag)) {
if (style->display() == INLINE)
return new (arena) RenderRubyAsInline(node);
- else
+ else if (style->display() == BLOCK)
return new (arena) RenderRubyAsBlock(node);
}
// treat <rt> as ruby text ONLY if it still has its default treatment of block
if (node->hasTagName(rtTag) && style->display() == BLOCK)
- return new (arena) RenderRubyText(node);
+ return new (arena) RenderRubyText(node);
#endif
switch (style->display()) {
@@ -260,14 +260,6 @@ bool RenderObject::isHTMLMarquee() const
return node() && node()->renderer() == this && node()->hasTagName(marqueeTag);
}
-static void updateListMarkerNumbers(RenderObject* child)
-{
- for (RenderObject* sibling = child; sibling; sibling = sibling->nextSibling()) {
- if (sibling->isListItem())
- toRenderListItem(sibling)->updateValue();
- }
-}
-
void RenderObject::addChild(RenderObject* newChild, RenderObject* beforeChild)
{
RenderObjectChildList* children = virtualChildren();
@@ -277,9 +269,7 @@ void RenderObject::addChild(RenderObject* newChild, RenderObject* beforeChild)
bool needsTable = false;
- if (newChild->isListItem())
- updateListMarkerNumbers(beforeChild ? beforeChild : children->lastChild());
- else if (newChild->isTableCol() && newChild->style()->display() == TABLE_COLUMN_GROUP)
+ if (newChild->isTableCol() && newChild->style()->display() == TABLE_COLUMN_GROUP)
needsTable = !isTable();
else if (newChild->isRenderBlock() && newChild->style()->display() == TABLE_CAPTION)
needsTable = !isTable();
@@ -701,7 +691,7 @@ bool RenderObject::mustRepaintBackgroundOrBorder() const
}
void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2,
- BoxSide s, Color c, const Color& textcolor, EBorderStyle style,
+ BoxSide s, Color c, EBorderStyle style,
int adjbw1, int adjbw2)
{
int width = (s == BSTop || s == BSBottom ? y2 - y1 : x2 - x1);
@@ -709,13 +699,6 @@ void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
if (style == DOUBLE && width < 3)
style = SOLID;
- if (!c.isValid()) {
- if (style == INSET || style == OUTSET || style == RIDGE || style == GROOVE)
- c.setRGB(238, 238, 238);
- else
- c = textcolor;
- }
-
switch (style) {
case BNONE:
case BHIDDEN:
@@ -767,34 +750,34 @@ void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
case BSTop:
drawLineForBoxSide(graphicsContext, x1 + max((-adjbw1 * 2 + 1) / 3, 0),
y1, x2 - max((-adjbw2 * 2 + 1) / 3, 0), y1 + third,
- s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
+ s, c, SOLID, adjbw1bigthird, adjbw2bigthird);
drawLineForBoxSide(graphicsContext, x1 + max((adjbw1 * 2 + 1) / 3, 0),
y2 - third, x2 - max((adjbw2 * 2 + 1) / 3, 0), y2,
- s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
+ s, c, SOLID, adjbw1bigthird, adjbw2bigthird);
break;
case BSLeft:
drawLineForBoxSide(graphicsContext, x1, y1 + max((-adjbw1 * 2 + 1) / 3, 0),
x1 + third, y2 - max((-adjbw2 * 2 + 1) / 3, 0),
- s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
+ s, c, SOLID, adjbw1bigthird, adjbw2bigthird);
drawLineForBoxSide(graphicsContext, x2 - third, y1 + max((adjbw1 * 2 + 1) / 3, 0),
x2, y2 - max((adjbw2 * 2 + 1) / 3, 0),
- s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
+ s, c, SOLID, adjbw1bigthird, adjbw2bigthird);
break;
case BSBottom:
drawLineForBoxSide(graphicsContext, x1 + max((adjbw1 * 2 + 1) / 3, 0),
y1, x2 - max((adjbw2 * 2 + 1) / 3, 0), y1 + third,
- s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
+ s, c, SOLID, adjbw1bigthird, adjbw2bigthird);
drawLineForBoxSide(graphicsContext, x1 + max((-adjbw1 * 2 + 1) / 3, 0),
y2 - third, x2 - max((-adjbw2 * 2 + 1) / 3, 0), y2,
- s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
+ s, c, SOLID, adjbw1bigthird, adjbw2bigthird);
break;
case BSRight:
drawLineForBoxSide(graphicsContext, x1, y1 + max((adjbw1 * 2 + 1) / 3, 0),
x1 + third, y2 - max((adjbw2 * 2 + 1) / 3, 0),
- s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
+ s, c, SOLID, adjbw1bigthird, adjbw2bigthird);
drawLineForBoxSide(graphicsContext, x2 - third, y1 + max((-adjbw1 * 2 + 1) / 3, 0),
x2, y2 - max((-adjbw2 * 2 + 1) / 3, 0),
- s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
+ s, c, SOLID, adjbw1bigthird, adjbw2bigthird);
break;
default:
break;
@@ -821,27 +804,27 @@ void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
switch (s) {
case BSTop:
drawLineForBoxSide(graphicsContext, x1 + max(-adjbw1, 0) / 2, y1, x2 - max(-adjbw2, 0) / 2, (y1 + y2 + 1) / 2,
- s, c, textcolor, s1, adjbw1bighalf, adjbw2bighalf);
+ s, c, s1, adjbw1bighalf, adjbw2bighalf);
drawLineForBoxSide(graphicsContext, x1 + max(adjbw1 + 1, 0) / 2, (y1 + y2 + 1) / 2, x2 - max(adjbw2 + 1, 0) / 2, y2,
- s, c, textcolor, s2, adjbw1 / 2, adjbw2 / 2);
+ s, c, s2, adjbw1 / 2, adjbw2 / 2);
break;
case BSLeft:
drawLineForBoxSide(graphicsContext, x1, y1 + max(-adjbw1, 0) / 2, (x1 + x2 + 1) / 2, y2 - max(-adjbw2, 0) / 2,
- s, c, textcolor, s1, adjbw1bighalf, adjbw2bighalf);
+ s, c, s1, adjbw1bighalf, adjbw2bighalf);
drawLineForBoxSide(graphicsContext, (x1 + x2 + 1) / 2, y1 + max(adjbw1 + 1, 0) / 2, x2, y2 - max(adjbw2 + 1, 0) / 2,
- s, c, textcolor, s2, adjbw1 / 2, adjbw2 / 2);
+ s, c, s2, adjbw1 / 2, adjbw2 / 2);
break;
case BSBottom:
drawLineForBoxSide(graphicsContext, x1 + max(adjbw1, 0) / 2, y1, x2 - max(adjbw2, 0) / 2, (y1 + y2 + 1) / 2,
- s, c, textcolor, s2, adjbw1bighalf, adjbw2bighalf);
+ s, c, s2, adjbw1bighalf, adjbw2bighalf);
drawLineForBoxSide(graphicsContext, x1 + max(-adjbw1 + 1, 0) / 2, (y1 + y2 + 1) / 2, x2 - max(-adjbw2 + 1, 0) / 2, y2,
- s, c, textcolor, s1, adjbw1/2, adjbw2/2);
+ s, c, s1, adjbw1 / 2, adjbw2 / 2);
break;
case BSRight:
drawLineForBoxSide(graphicsContext, x1, y1 + max(adjbw1, 0) / 2, (x1 + x2 + 1) / 2, y2 - max(adjbw2, 0) / 2,
- s, c, textcolor, s2, adjbw1bighalf, adjbw2bighalf);
+ s, c, s2, adjbw1bighalf, adjbw2bighalf);
drawLineForBoxSide(graphicsContext, (x1 + x2 + 1) / 2, y1 + max(-adjbw1 + 1, 0) / 2, x2, y2 - max(-adjbw2 + 1, 0) / 2,
- s, c, textcolor, s1, adjbw1/2, adjbw2/2);
+ s, c, s1, adjbw1 / 2, adjbw2 / 2);
break;
}
break;
@@ -897,19 +880,12 @@ void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
}
void RenderObject::drawArcForBoxSide(GraphicsContext* graphicsContext, int x, int y, float thickness, IntSize radius,
- int angleStart, int angleSpan, BoxSide s, Color c, const Color& textColor,
+ int angleStart, int angleSpan, BoxSide s, Color c,
EBorderStyle style, bool firstCorner)
{
if ((style == DOUBLE && thickness / 2 < 3) || ((style == RIDGE || style == GROOVE) && thickness / 2 < 2))
style = SOLID;
- if (!c.isValid()) {
- if (style == INSET || style == OUTSET || style == RIDGE || style == GROOVE)
- c.setRGB(238, 238, 238);
- else
- c = textColor;
- }
-
switch (style) {
case BNONE:
case BHIDDEN:
@@ -997,33 +973,32 @@ void RenderObject::addPDFURLRect(GraphicsContext* context, const IntRect& rect)
context->setURLForRect(n->document()->completeURL(href), rect);
}
-void RenderObject::paintOutline(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, const RenderStyle* style)
+void RenderObject::paintOutline(GraphicsContext* graphicsContext, int tx, int ty, int w, int h)
{
if (!hasOutline())
return;
- int ow = style->outlineWidth();
- EBorderStyle os = style->outlineStyle();
+ RenderStyle* styleToUse = style();
+ int ow = styleToUse->outlineWidth();
+ EBorderStyle os = styleToUse->outlineStyle();
- Color oc = style->outlineColor();
- if (!oc.isValid())
- oc = style->color();
+ Color oc = styleToUse->visitedDependentColor(CSSPropertyOutlineColor);
- int offset = style->outlineOffset();
+ int offset = styleToUse->outlineOffset();
- if (style->outlineStyleIsAuto() || hasOutlineAnnotation()) {
- if (!theme()->supportsFocusRing(style)) {
+ if (styleToUse->outlineStyleIsAuto() || hasOutlineAnnotation()) {
+ if (!theme()->supportsFocusRing(styleToUse)) {
// Only paint the focus ring by hand if the theme isn't able to draw the focus ring.
Vector<IntRect> focusRingRects;
addFocusRingRects(focusRingRects, tx, ty);
- if (style->outlineStyleIsAuto())
+ if (styleToUse->outlineStyleIsAuto())
graphicsContext->drawFocusRing(focusRingRects, ow, offset, oc);
else
addPDFURLRect(graphicsContext, unionRect(focusRingRects));
}
}
- if (style->outlineStyleIsAuto() || style->outlineStyle() == BNONE)
+ if (styleToUse->outlineStyleIsAuto() || styleToUse->outlineStyle() == BNONE)
return;
tx -= offset;
@@ -1034,17 +1009,10 @@ void RenderObject::paintOutline(GraphicsContext* graphicsContext, int tx, int ty
if (h < 0 || w < 0)
return;
- drawLineForBoxSide(graphicsContext, tx - ow, ty - ow, tx, ty + h + ow,
- BSLeft, Color(oc), style->color(), os, ow, ow);
-
- drawLineForBoxSide(graphicsContext, tx - ow, ty - ow, tx + w + ow, ty,
- BSTop, Color(oc), style->color(), os, ow, ow);
-
- drawLineForBoxSide(graphicsContext, tx + w, ty - ow, tx + w + ow, ty + h + ow,
- BSRight, Color(oc), style->color(), os, ow, ow);
-
- drawLineForBoxSide(graphicsContext, tx - ow, ty + h, tx + w + ow, ty + h + ow,
- BSBottom, Color(oc), style->color(), os, ow, ow);
+ drawLineForBoxSide(graphicsContext, tx - ow, ty - ow, tx, ty + h + ow, BSLeft, oc, os, ow, ow);
+ drawLineForBoxSide(graphicsContext, tx - ow, ty - ow, tx + w + ow, ty, BSTop, oc, os, ow, ow);
+ drawLineForBoxSide(graphicsContext, tx + w, ty - ow, tx + w + ow, ty + h + ow, BSRight, oc, os, ow, ow);
+ drawLineForBoxSide(graphicsContext, tx - ow, ty + h, tx + w + ow, ty + h + ow, BSBottom, oc, os, ow, ow);
}
IntRect RenderObject::absoluteBoundingBoxRect(bool useTransforms)
@@ -1182,13 +1150,14 @@ void RenderObject::repaintRectangle(const IntRect& r, bool immediate)
repaintUsingContainer(repaintContainer ? repaintContainer : view, dirtyRect, immediate);
}
-bool RenderObject::repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintContainer, const IntRect& oldBounds, const IntRect& oldOutlineBox)
+bool RenderObject::repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintContainer, const IntRect& oldBounds, const IntRect& oldOutlineBox, const IntRect* newBoundsPtr, const IntRect* newOutlineBoxRectPtr)
{
RenderView* v = view();
if (v->printing())
return false; // Don't repaint if we're printing.
- IntRect newBounds = clippedOverflowRectForRepaint(repaintContainer);
+ ASSERT(!newBoundsPtr || *newBoundsPtr == clippedOverflowRectForRepaint(repaintContainer));
+ IntRect newBounds = newBoundsPtr ? *newBoundsPtr : clippedOverflowRectForRepaint(repaintContainer);
IntRect newOutlineBox;
bool fullRepaint = selfNeedsLayout();
@@ -1196,7 +1165,8 @@ bool RenderObject::repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintConta
if (!fullRepaint && style()->borderFit() == BorderFitLines)
fullRepaint = true;
if (!fullRepaint) {
- newOutlineBox = outlineBoundsForRepaint(repaintContainer);
+ ASSERT(!newOutlineBoxRectPtr || *newOutlineBoxRectPtr == outlineBoundsForRepaint(repaintContainer));
+ newOutlineBox = newOutlineBoxRectPtr ? *newOutlineBoxRectPtr : outlineBoundsForRepaint(repaintContainer);
if (newOutlineBox.location() != oldOutlineBox.location() || (mustRepaintBackgroundOrBorder() && (newBounds != oldBounds || newOutlineBox != oldOutlineBox)))
fullRepaint = true;
}
@@ -1331,11 +1301,10 @@ void RenderObject::computeRectForRepaint(RenderBoxModelObject* repaintContainer,
// anyway if its size does change.
RenderBox* boxParent = toRenderBox(o);
+ IntRect repaintRect(rect);
+ repaintRect.move(-boxParent->layer()->scrolledContentOffset()); // For overflow:auto/scroll/hidden.
+
IntRect boxRect(0, 0, boxParent->layer()->width(), boxParent->layer()->height());
- int x = rect.x();
- int y = rect.y();
- boxParent->layer()->subtractScrolledContentOffset(x, y); // For overflow:auto/scroll/hidden.
- IntRect repaintRect(x, y, rect.width(), rect.height());
rect = intersection(repaintRect, boxRect);
if (rect.isEmpty())
return;
@@ -1667,9 +1636,10 @@ void RenderObject::styleWillChange(StyleDifference diff, const RenderStyle* newS
#endif
bool newStyleSlowScroll = newStyle && (newStyle->position() == FixedPosition
- || (!shouldBlitOnFixedBackgroundImage && newStyle->hasFixedBackgroundImage()));
+ || (!shouldBlitOnFixedBackgroundImage && newStyle->hasFixedBackgroundImage()));
bool oldStyleSlowScroll = m_style && (m_style->position() == FixedPosition
- || (!shouldBlitOnFixedBackgroundImage && m_style->hasFixedBackgroundImage()));
+ || (!shouldBlitOnFixedBackgroundImage && m_style->hasFixedBackgroundImage()));
+
if (oldStyleSlowScroll != newStyleSlowScroll) {
if (oldStyleSlowScroll)
view()->frameView()->removeSlowRepaintObject();
@@ -2210,21 +2180,17 @@ PassRefPtr<RenderStyle> RenderObject::getUncachedPseudoStyle(PseudoId pseudo, Re
return result.release();
}
-static Color decorationColor(RenderStyle* style)
+static Color decorationColor(RenderObject* renderer)
{
Color result;
- if (style->textStrokeWidth() > 0) {
+ if (renderer->style()->textStrokeWidth() > 0) {
// Prefer stroke color if possible but not if it's fully transparent.
- result = style->textStrokeColor();
- if (!result.isValid())
- result = style->color();
+ result = renderer->style()->visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
if (result.alpha())
return result;
}
- result = style->textFillColor();
- if (!result.isValid())
- result = style->color();
+ result = renderer->style()->visitedDependentColor(CSSPropertyWebkitTextFillColor);
return result;
}
@@ -2237,15 +2203,15 @@ void RenderObject::getTextDecorationColors(int decorations, Color& underline, Co
if (currDecs) {
if (currDecs & UNDERLINE) {
decorations &= ~UNDERLINE;
- underline = decorationColor(curr->style());
+ underline = decorationColor(curr);
}
if (currDecs & OVERLINE) {
decorations &= ~OVERLINE;
- overline = decorationColor(curr->style());
+ overline = decorationColor(curr);
}
if (currDecs & LINE_THROUGH) {
decorations &= ~LINE_THROUGH;
- linethrough = decorationColor(curr->style());
+ linethrough = decorationColor(curr);
}
}
curr = curr->parent();
@@ -2257,11 +2223,11 @@ void RenderObject::getTextDecorationColors(int decorations, Color& underline, Co
// If we bailed out, use the element we bailed out at (typically a <font> or <a> element).
if (decorations && curr) {
if (decorations & UNDERLINE)
- underline = decorationColor(curr->style());
+ underline = decorationColor(curr);
if (decorations & OVERLINE)
- overline = decorationColor(curr->style());
+ overline = decorationColor(curr);
if (decorations & LINE_THROUGH)
- linethrough = decorationColor(curr->style());
+ linethrough = decorationColor(curr);
}
}
@@ -2381,21 +2347,21 @@ int RenderObject::nextOffset(int current) const
void RenderObject::adjustRectForOutlineAndShadow(IntRect& rect) const
{
int outlineSize = outlineStyleForRepaint()->outlineSize();
- if (ShadowData* boxShadow = style()->boxShadow()) {
+ if (const ShadowData* boxShadow = style()->boxShadow()) {
int shadowLeft = 0;
int shadowRight = 0;
int shadowTop = 0;
int shadowBottom = 0;
do {
- if (boxShadow->style == Normal) {
- shadowLeft = min(boxShadow->x - boxShadow->blur - boxShadow->spread - outlineSize, shadowLeft);
- shadowRight = max(boxShadow->x + boxShadow->blur + boxShadow->spread + outlineSize, shadowRight);
- shadowTop = min(boxShadow->y - boxShadow->blur - boxShadow->spread - outlineSize, shadowTop);
- shadowBottom = max(boxShadow->y + boxShadow->blur + boxShadow->spread + outlineSize, shadowBottom);
+ if (boxShadow->style() == Normal) {
+ shadowLeft = min(boxShadow->x() - boxShadow->blur() - boxShadow->spread() - outlineSize, shadowLeft);
+ shadowRight = max(boxShadow->x() + boxShadow->blur() + boxShadow->spread() + outlineSize, shadowRight);
+ shadowTop = min(boxShadow->y() - boxShadow->blur() - boxShadow->spread() - outlineSize, shadowTop);
+ shadowBottom = max(boxShadow->y() + boxShadow->blur() + boxShadow->spread() + outlineSize, shadowBottom);
}
- boxShadow = boxShadow->next;
+ boxShadow = boxShadow->next();
} while (boxShadow);
rect.move(shadowLeft, shadowTop);