diff options
author | Ben Murdoch <benm@google.com> | 2009-08-11 17:01:47 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2009-08-11 18:21:02 +0100 |
commit | 0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 (patch) | |
tree | 2943df35f62d885c89d01063cc528dd73b480fea /WebCore/rendering/RenderObject.cpp | |
parent | 7e7a70bfa49a1122b2597a1e6367d89eb4035eca (diff) | |
download | external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.zip external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.gz external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.bz2 |
Merge in WebKit r47029.
Diffstat (limited to 'WebCore/rendering/RenderObject.cpp')
-rw-r--r-- | WebCore/rendering/RenderObject.cpp | 95 |
1 files changed, 65 insertions, 30 deletions
diff --git a/WebCore/rendering/RenderObject.cpp b/WebCore/rendering/RenderObject.cpp index 2aba22a..5137338 100644 --- a/WebCore/rendering/RenderObject.cpp +++ b/WebCore/rendering/RenderObject.cpp @@ -217,6 +217,13 @@ RenderObject::~RenderObject() #endif } +RenderTheme* RenderObject::theme() const +{ + ASSERT(document()->page()); + + return document()->page()->theme(); +} + bool RenderObject::isDescendantOf(const RenderObject* obj) const { for (const RenderObject* r = this; r; r = r->m_parent) { @@ -243,9 +250,10 @@ bool RenderObject::isHTMLMarquee() const static void updateListMarkerNumbers(RenderObject* child) { - for (RenderObject* r = child; r; r = r->nextSibling()) - if (r->isListItem()) - static_cast<RenderListItem*>(r)->updateValue(); + for (RenderObject* sibling = child; sibling; sibling = sibling->nextSibling()) { + if (sibling->isListItem()) + toRenderListItem(sibling)->updateValue(); + } } void RenderObject::addChild(RenderObject* newChild, RenderObject* beforeChild) @@ -281,7 +289,7 @@ void RenderObject::addChild(RenderObject* newChild, RenderObject* beforeChild) RenderTable* table; RenderObject* afterChild = beforeChild ? beforeChild->previousSibling() : children->lastChild(); if (afterChild && afterChild->isAnonymous() && afterChild->isTable()) - table = static_cast<RenderTable*>(afterChild); + table = toRenderTable(afterChild); else { table = new (renderArena()) RenderTable(document() /* is anonymous */); RefPtr<RenderStyle> newStyle = RenderStyle::create(); @@ -591,7 +599,7 @@ void RenderObject::setLayerNeedsFullRepaint() RenderBlock* RenderObject::containingBlock() const { if (isTableCell()) { - const RenderTableCell* cell = static_cast<const RenderTableCell*>(this); + const RenderTableCell* cell = toRenderTableCell(this); if (parent() && cell->section()) return cell->table(); return 0; @@ -639,13 +647,16 @@ static bool mustRepaintFillLayers(const RenderObject* renderer, const FillLayer* // Make sure we have a valid image. StyleImage* img = layer->image(); - bool shouldPaintBackgroundImage = img && img->canRender(renderer->style()->effectiveZoom()); + if (!img || !img->canRender(renderer->style()->effectiveZoom())) + return false; - // These are always percents or auto. - if (shouldPaintBackgroundImage && - (!layer->xPosition().isZero() || !layer->yPosition().isZero() || - layer->size().width().isPercent() || layer->size().height().isPercent())) - // The image will shift unpredictably if the size changes. + if (!layer->xPosition().isZero() || !layer->yPosition().isZero()) + return true; + + if (layer->isSizeSet()) { + if (layer->size().width().isPercent() || layer->size().height().isPercent()) + return true; + } else if (img->usesImageContainerSize()) return true; return false; @@ -767,7 +778,7 @@ void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1, break; case BSRight: drawLineForBoxSide(graphicsContext, x1, y1 + max((adjbw1 * 2 + 1) / 3, 0), - x1 + third, y2 - max(( adjbw2 * 2 + 1) / 3, 0), + x1 + third, y2 - max((adjbw2 * 2 + 1) / 3, 0), s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird); drawLineForBoxSide(graphicsContext, x2 - third, y1 + max((-adjbw1 * 2 + 1) / 3, 0), x2, y2 - max((-adjbw2 * 2 + 1) / 3, 0), @@ -1206,12 +1217,11 @@ bool RenderObject::repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintConta // two rectangles (but typically only one). RenderStyle* outlineStyle = outlineStyleForRepaint(); int ow = outlineStyle->outlineSize(); - ShadowData* boxShadow = style()->boxShadow(); int width = abs(newOutlineBox.width() - oldOutlineBox.width()); if (width) { - int shadowRight = 0; - for (ShadowData* shadow = boxShadow; shadow; shadow = shadow->next) - shadowRight = max(shadow->x + shadow->blur, shadowRight); + int shadowLeft; + int shadowRight; + style()->getBoxShadowHorizontalExtent(shadowLeft, shadowRight); int borderRight = isBox() ? toRenderBox(this)->borderRight() : 0; int borderWidth = max(-outlineStyle->outlineOffset(), max(borderRight, max(style()->borderTopRightRadius().width(), style()->borderBottomRightRadius().width()))) + max(ow, shadowRight); @@ -1227,9 +1237,9 @@ bool RenderObject::repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintConta } int height = abs(newOutlineBox.height() - oldOutlineBox.height()); if (height) { - int shadowBottom = 0; - for (ShadowData* shadow = boxShadow; shadow; shadow = shadow->next) - shadowBottom = max(shadow->y + shadow->blur, shadowBottom); + int shadowTop; + int shadowBottom; + style()->getBoxShadowVerticalExtent(shadowTop, shadowBottom); int borderBottom = isBox() ? toRenderBox(this)->borderBottom() : 0; int borderHeight = max(-outlineStyle->outlineOffset(), max(borderBottom, max(style()->borderBottomLeftRadius().height(), style()->borderBottomRightRadius().height()))) + max(ow, shadowBottom); @@ -1692,7 +1702,7 @@ void RenderObject::getTransformFromContainer(const RenderObject* containerObject transform.multLeft(layer->currentTransform()); #if ENABLE(3D_RENDERING) - if (containerObject && containerObject->style()->hasPerspective()) { + if (containerObject && containerObject->hasLayer() && containerObject->style()->hasPerspective()) { // Perpsective on the container affects us, so we have to factor it in here. ASSERT(containerObject->hasLayer()); FloatPoint perspectiveOrigin = toRenderBox(containerObject)->layer()->perspectiveOrigin(); @@ -1731,8 +1741,8 @@ IntSize RenderObject::offsetFromContainer(RenderObject* o) const IntRect RenderObject::localCaretRect(InlineBox*, int, int* extraWidthToEndOfLine) { - if (extraWidthToEndOfLine) - *extraWidthToEndOfLine = 0; + if (extraWidthToEndOfLine) + *extraWidthToEndOfLine = 0; return IntRect(); } @@ -1815,7 +1825,7 @@ void RenderObject::destroy() children->destroyLeftoverChildren(); // If this renderer is being autoscrolled, stop the autoscroll timer - if (document()->frame() && document()->frame()->eventHandler()->autoscrollRenderer() == this) + if (document()->frame()->eventHandler()->autoscrollRenderer() == this) document()->frame()->eventHandler()->stopAutoscrollTimer(true); if (m_hasCounterNodeMap) @@ -1973,6 +1983,27 @@ void RenderObject::layout() setNeedsLayout(false); } +PassRefPtr<RenderStyle> RenderObject::uncachedFirstLineStyle(RenderStyle* style) const +{ + if (!document()->usesFirstLineRules()) + return 0; + + ASSERT(!isText()); + + RefPtr<RenderStyle> result; + + if (isBlockFlow()) { + if (RenderBlock* firstLineBlock = this->firstLineBlock()) + result = firstLineBlock->getUncachedPseudoStyle(FIRST_LINE, style, firstLineBlock == this ? style : 0); + } else if (!isAnonymous() && isRenderInline()) { + RenderStyle* parentStyle = parent()->firstLineStyle(); + if (parentStyle != parent()->style()) + result = getUncachedPseudoStyle(FIRST_LINE_INHERITED, parentStyle, style); + } + + return result.release(); +} + RenderStyle* RenderObject::firstLineStyleSlowCase() const { ASSERT(document()->usesFirstLineRules()); @@ -2009,13 +2040,15 @@ RenderStyle* RenderObject::getCachedPseudoStyle(PseudoId pseudo, RenderStyle* pa return 0; } -PassRefPtr<RenderStyle> RenderObject::getUncachedPseudoStyle(PseudoId pseudo, RenderStyle* parentStyle) const +PassRefPtr<RenderStyle> RenderObject::getUncachedPseudoStyle(PseudoId pseudo, RenderStyle* parentStyle, RenderStyle* ownStyle) const { - if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo)) + if (pseudo < FIRST_INTERNAL_PSEUDOID && !ownStyle && !style()->hasPseudoStyle(pseudo)) return 0; - if (!parentStyle) + if (!parentStyle) { + ASSERT(!ownStyle); parentStyle = style(); + } Node* n = node(); while (n && !n->isElementNode()) @@ -2210,10 +2243,12 @@ void RenderObject::adjustRectForOutlineAndShadow(IntRect& rect) const int shadowBottom = 0; do { - shadowLeft = min(boxShadow->x - boxShadow->blur - outlineSize, shadowLeft); - shadowRight = max(boxShadow->x + boxShadow->blur + outlineSize, shadowRight); - shadowTop = min(boxShadow->y - boxShadow->blur - outlineSize, shadowTop); - shadowBottom = max(boxShadow->y + boxShadow->blur + 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; } while (boxShadow); |