2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
26 #include "RenderObject.h"
28 #include "AXObjectCache.h"
29 #include "CSSStyleSelector.h"
30 #include "FloatQuad.h"
31 #include "FrameView.h"
32 #include "GraphicsContext.h"
33 #include "HTMLNames.h"
34 #include "HitTestResult.h"
36 #include "RenderArena.h"
37 #include "RenderCounter.h"
38 #include "RenderFlexibleBox.h"
39 #include "RenderImageGeneratedContent.h"
40 #include "RenderInline.h"
41 #include "RenderListItem.h"
42 #include "RenderTableCell.h"
43 #include "RenderTableCol.h"
44 #include "RenderTableRow.h"
45 #include "RenderTheme.h"
46 #include "RenderView.h"
49 #include <wtf/RefCountedLeakCounter.h>
59 using namespace HTMLNames;
62 static void* baseOfRenderObjectBeingDeleted;
65 bool RenderObject::s_affectsParentBlock = false;
67 void* RenderObject::operator new(size_t sz, RenderArena* renderArena) throw()
69 return renderArena->allocate(sz);
72 void RenderObject::operator delete(void* ptr, size_t sz)
74 ASSERT(baseOfRenderObjectBeingDeleted == ptr);
76 // Stash size where destroy can find it.
80 RenderObject* RenderObject::createObject(Node* node, RenderStyle* style)
82 Document* doc = node->document();
83 RenderArena* arena = doc->renderArena();
85 // Minimal support for content properties replacing an entire element.
86 // Works only if we have exactly one piece of content and it's a URL.
87 // Otherwise acts as if we didn't support this feature.
88 const ContentData* contentData = style->contentData();
89 if (contentData && !contentData->m_next && contentData->m_type == CONTENT_OBJECT && doc != node) {
90 RenderImageGeneratedContent* image = new (arena) RenderImageGeneratedContent(node);
91 image->setStyle(style);
92 if (StyleImage* styleImage = contentData->m_content.m_image)
93 image->setStyleImage(styleImage);
99 switch (style->display()) {
103 o = new (arena) RenderInline(node);
106 o = new (arena) RenderBlock(node);
109 o = new (arena) RenderBlock(node);
112 o = new (arena) RenderListItem(node);
116 o = new (arena) RenderBlock(node);
120 o = new (arena) RenderTable(node);
122 case TABLE_ROW_GROUP:
123 case TABLE_HEADER_GROUP:
124 case TABLE_FOOTER_GROUP:
125 o = new (arena) RenderTableSection(node);
128 o = new (arena) RenderTableRow(node);
130 case TABLE_COLUMN_GROUP:
132 o = new (arena) RenderTableCol(node);
135 o = new (arena) RenderTableCell(node);
138 o = new (arena) RenderBlock(node);
142 o = new (arena) RenderFlexibleBox(node);
150 static WTF::RefCountedLeakCounter renderObjectCounter("RenderObject");
153 RenderObject::RenderObject(Node* node)
154 : CachedResourceClient()
161 , m_hasAXObject(false)
162 , m_setNeedsLayoutForbidden(false)
164 , m_verticalPosition(PositionUndefined)
165 , m_needsLayout(false)
166 , m_needsPositionedMovementLayout(false)
167 , m_normalChildNeedsLayout(false)
168 , m_posChildNeedsLayout(false)
169 , m_prefWidthsDirty(false)
171 , m_positioned(false)
172 , m_relPositioned(false)
173 , m_paintBackground(false)
174 , m_isAnonymous(node == node->document())
179 , m_isDragging(false)
181 , m_hasOverflowClip(false)
182 , m_hasTransform(false)
183 , m_hasReflection(false)
184 , m_hasOverrideSize(false)
185 , m_hasCounterNodeMap(false)
186 , m_everHadLayout(false)
187 , m_childrenInline(false)
188 , m_topMarginQuirk(false)
189 , m_bottomMarginQuirk(false)
190 , m_hasMarkupTruncation(false)
191 , m_selectionState(SelectionNone)
192 , m_hasColumns(false)
193 , m_cellWidthChanged(false)
196 renderObjectCounter.increment();
200 RenderObject::~RenderObject()
202 ASSERT(!node() || documentBeingDestroyed() || !document()->frame()->view() || document()->frame()->view()->layoutRoot() != this);
204 ASSERT(!m_hasAXObject);
205 renderObjectCounter.decrement();
209 bool RenderObject::isDescendantOf(const RenderObject* obj) const
211 for (const RenderObject* r = this; r; r = r->m_parent) {
218 bool RenderObject::isBody() const
220 return node()->hasTagName(bodyTag);
223 bool RenderObject::isHR() const
225 return element() && element()->hasTagName(hrTag);
228 bool RenderObject::isHTMLMarquee() const
230 return element() && element()->renderer() == this && element()->hasTagName(marqueeTag);
234 static void updateListMarkerNumbers(RenderObject* child)
236 for (RenderObject* r = child; r; r = r->nextSibling())
238 static_cast<RenderListItem*>(r)->updateValue();
241 void RenderObject::addChild(RenderObject* newChild, RenderObject* beforeChild)
243 RenderObjectChildList* children = virtualChildren();
248 bool needsTable = false;
250 if (newChild->isListItem())
251 updateListMarkerNumbers(beforeChild ? beforeChild : children->lastChild());
252 else if (newChild->isTableCol() && newChild->style()->display() == TABLE_COLUMN_GROUP)
253 needsTable = !isTable();
254 else if (newChild->isRenderBlock() && newChild->style()->display() == TABLE_CAPTION)
255 needsTable = !isTable();
256 else if (newChild->isTableSection())
257 needsTable = !isTable();
258 else if (newChild->isTableRow())
259 needsTable = !isTableSection();
260 else if (newChild->isTableCell()) {
261 needsTable = !isTableRow();
262 // I'm not 100% sure this is the best way to fix this, but without this
263 // change we recurse infinitely when trying to render the CSS2 test page:
264 // http://www.bath.ac.uk/%7Epy8ieh/internet/eviltests/htmlbodyheadrendering2.html.
265 // See Radar 2925291.
266 if (needsTable && isTableCell() && !children->firstChild() && !newChild->isTableCell())
272 RenderObject* afterChild = beforeChild ? beforeChild->previousSibling() : children->lastChild();
273 if (afterChild && afterChild->isAnonymous() && afterChild->isTable())
274 table = static_cast<RenderTable*>(afterChild);
276 table = new (renderArena()) RenderTable(document() /* is anonymous */);
277 RefPtr<RenderStyle> newStyle = RenderStyle::create();
278 newStyle->inheritFrom(style());
279 newStyle->setDisplay(TABLE);
280 table->setStyle(newStyle.release());
281 addChild(table, beforeChild);
283 table->addChild(newChild);
286 children->insertChildNode(this, newChild, beforeChild);
289 if (newChild->isText() && newChild->style()->textTransform() == CAPITALIZE) {
290 RefPtr<StringImpl> textToTransform = toRenderText(newChild)->originalText();
292 toRenderText(newChild)->setText(textToTransform.release(), true);
296 void RenderObject::removeChild(RenderObject* oldChild)
298 RenderObjectChildList* children = virtualChildren();
303 // We do this here instead of in removeChildNode, since the only extremely low-level uses of remove/appendChildNode
304 // cannot affect the positioned object list, and the floating object list is irrelevant (since the list gets cleared on
306 if (oldChild->isFloatingOrPositioned())
307 toRenderBox(oldChild)->removeFloatingOrPositionedChildFromBlockLists();
309 children->removeChildNode(this, oldChild);
312 RenderObject* RenderObject::nextInPreOrder() const
314 if (RenderObject* o = firstChild())
317 return nextInPreOrderAfterChildren();
320 RenderObject* RenderObject::nextInPreOrderAfterChildren() const
323 if (!(o = nextSibling())) {
325 while (o && !o->nextSibling())
328 o = o->nextSibling();
334 RenderObject* RenderObject::nextInPreOrder(RenderObject* stayWithin) const
336 if (RenderObject* o = firstChild())
339 return nextInPreOrderAfterChildren(stayWithin);
342 RenderObject* RenderObject::nextInPreOrderAfterChildren(RenderObject* stayWithin) const
344 if (this == stayWithin)
348 if (!(o = nextSibling())) {
350 while (o && !o->nextSibling()) {
356 o = o->nextSibling();
362 RenderObject* RenderObject::previousInPreOrder() const
364 if (RenderObject* o = previousSibling()) {
365 while (o->lastChild())
373 RenderObject* RenderObject::childAt(unsigned index) const
375 RenderObject* child = firstChild();
376 for (unsigned i = 0; child && i < index; i++)
377 child = child->nextSibling();
381 bool RenderObject::isEditable() const
383 RenderText* textRenderer = 0;
385 textRenderer = toRenderText(const_cast<RenderObject*>(this));
387 return style()->visibility() == VISIBLE &&
388 element() && element()->isContentEditable() &&
389 ((isBlockFlow() && !firstChild()) ||
392 (textRenderer && textRenderer->firstTextBox()));
395 RenderObject* RenderObject::firstLeafChild() const
397 RenderObject* r = firstChild();
408 RenderObject* RenderObject::lastLeafChild() const
410 RenderObject* r = lastChild();
421 static void addLayers(RenderObject* obj, RenderLayer* parentLayer, RenderObject*& newObject,
422 RenderLayer*& beforeChild)
424 if (obj->hasLayer()) {
425 if (!beforeChild && newObject) {
426 // We need to figure out the layer that follows newObject. We only do
427 // this the first time we find a child layer, and then we update the
428 // pointer values for newObject and beforeChild used by everyone else.
429 beforeChild = newObject->parent()->findNextLayer(parentLayer, newObject);
432 parentLayer->addChild(toRenderBox(obj)->layer(), beforeChild);
436 for (RenderObject* curr = obj->firstChild(); curr; curr = curr->nextSibling())
437 addLayers(curr, parentLayer, newObject, beforeChild);
440 void RenderObject::addLayers(RenderLayer* parentLayer, RenderObject* newObject)
445 RenderObject* object = newObject;
446 RenderLayer* beforeChild = 0;
447 WebCore::addLayers(this, parentLayer, object, beforeChild);
450 void RenderObject::removeLayers(RenderLayer* parentLayer)
456 parentLayer->removeChild(toRenderBox(this)->layer());
460 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
461 curr->removeLayers(parentLayer);
464 void RenderObject::moveLayers(RenderLayer* oldParent, RenderLayer* newParent)
470 RenderLayer* layer = toRenderBox(this)->layer();
472 oldParent->removeChild(layer);
473 newParent->addChild(layer);
477 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
478 curr->moveLayers(oldParent, newParent);
481 RenderLayer* RenderObject::findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint,
484 // Error check the parent layer passed in. If it's null, we can't find anything.
488 // Step 1: If our layer is a child of the desired parent, then return our layer.
489 RenderLayer* ourLayer = hasLayer() ? toRenderBox(this)->layer() : 0;
490 if (ourLayer && ourLayer->parent() == parentLayer)
493 // Step 2: If we don't have a layer, or our layer is the desired parent, then descend
494 // into our siblings trying to find the next layer whose parent is the desired parent.
495 if (!ourLayer || ourLayer == parentLayer) {
496 for (RenderObject* curr = startPoint ? startPoint->nextSibling() : firstChild();
497 curr; curr = curr->nextSibling()) {
498 RenderLayer* nextLayer = curr->findNextLayer(parentLayer, 0, false);
504 // Step 3: If our layer is the desired parent layer, then we're finished. We didn't
506 if (parentLayer == ourLayer)
509 // Step 4: If |checkParent| is set, climb up to our parent and check its siblings that
510 // follow us to see if we can locate a layer.
511 if (checkParent && parent())
512 return parent()->findNextLayer(parentLayer, this, true);
517 RenderLayer* RenderObject::enclosingLayer() const
519 const RenderObject* curr = this;
521 RenderLayer* layer = curr->hasLayer() ? toRenderBox(curr)->layer() : 0;
524 curr = curr->parent();
529 #if USE(ACCELERATED_COMPOSITING)
530 RenderLayer* RenderObject::enclosingCompositingLayer() const
532 const RenderObject* curr = this;
534 RenderLayer* layer = curr->hasLayer() ? toRenderBox(curr)->layer() : 0;
535 if (layer && layer->isComposited())
537 curr = curr->parent();
543 RenderBox* RenderObject::enclosingBox() const
545 RenderObject* curr = const_cast<RenderObject*>(this);
548 return toRenderBox(curr);
549 curr = curr->parent();
552 ASSERT_NOT_REACHED();
556 RenderBlock* RenderObject::firstLineBlock() const
561 void RenderObject::setPrefWidthsDirty(bool b, bool markParents)
563 bool alreadyDirty = m_prefWidthsDirty;
564 m_prefWidthsDirty = b;
565 if (b && !alreadyDirty && markParents && (isText() || (style()->position() != FixedPosition && style()->position() != AbsolutePosition)))
566 invalidateContainerPrefWidths();
569 void RenderObject::invalidateContainerPrefWidths()
571 // In order to avoid pathological behavior when inlines are deeply nested, we do include them
572 // in the chain that we mark dirty (even though they're kind of irrelevant).
573 RenderObject* o = isTableCell() ? containingBlock() : container();
574 while (o && !o->m_prefWidthsDirty) {
575 o->m_prefWidthsDirty = true;
576 if (o->style()->position() == FixedPosition || o->style()->position() == AbsolutePosition)
577 // A positioned object has no effect on the min/max width of its containing block ever.
578 // We can optimize this case and not go up any further.
580 o = o->isTableCell() ? o->containingBlock() : o->container();
584 void RenderObject::setLayerNeedsFullRepaint()
586 toRenderBox(this)->layer()->setNeedsFullRepaint(true);
589 RenderBlock* RenderObject::containingBlock() const
592 const RenderTableCell* cell = static_cast<const RenderTableCell*>(this);
593 if (parent() && cell->section())
594 return cell->table();
599 return const_cast<RenderView*>(toRenderView(this));
601 RenderObject* o = parent();
602 if (!isText() && m_style->position() == FixedPosition) {
603 while (o && !o->isRenderView() && !(o->hasTransform() && o->isRenderBlock()))
605 } else if (!isText() && m_style->position() == AbsolutePosition) {
606 while (o && (o->style()->position() == StaticPosition || (o->isInline() && !o->isReplaced())) && !o->isRenderView() && !(o->hasTransform() && o->isRenderBlock())) {
607 // For relpositioned inlines, we return the nearest enclosing block. We don't try
608 // to return the inline itself. This allows us to avoid having a positioned objects
609 // list in all RenderInlines and lets us return a strongly-typed RenderBlock* result
610 // from this method. The container() method can actually be used to obtain the
612 if (o->style()->position() == RelativePosition && o->isInline() && !o->isReplaced())
613 return o->containingBlock();
617 while (o && ((o->isInline() && !o->isReplaced()) || o->isTableRow() || o->isTableSection()
618 || o->isTableCol() || o->isFrameSet() || o->isMedia()
620 || o->isSVGContainer() || o->isSVGRoot()
626 if (!o || !o->isRenderBlock())
627 return 0; // Probably doesn't happen any more, but leave just in case. -dwh
629 return toRenderBlock(o);
632 int RenderObject::containingBlockWidth() const
634 return containingBlock()->availableWidth();
637 int RenderObject::containingBlockHeight() const
639 return containingBlock()->contentHeight();
642 static bool mustRepaintFillLayers(const RenderObject* renderer, const FillLayer* layer)
644 // Nobody will use multiple layers without wanting fancy positioning.
648 // Make sure we have a valid image.
649 StyleImage* img = layer->image();
650 bool shouldPaintBackgroundImage = img && img->canRender(renderer->style()->effectiveZoom());
652 // These are always percents or auto.
653 if (shouldPaintBackgroundImage &&
654 (!layer->xPosition().isZero() || !layer->yPosition().isZero() ||
655 layer->size().width().isPercent() || layer->size().height().isPercent()))
656 // The image will shift unpredictably if the size changes.
662 bool RenderObject::mustRepaintBackgroundOrBorder() const
664 if (hasMask() && mustRepaintFillLayers(this, style()->maskLayers()))
667 // If we don't have a background/border/mask, then nothing to do.
668 if (!hasBoxDecorations())
671 if (mustRepaintFillLayers(this, style()->backgroundLayers()))
674 // Our fill layers are ok. Let's check border.
675 if (style()->hasBorder()) {
676 // Border images are not ok.
677 StyleImage* borderImage = style()->borderImage().image();
678 bool shouldPaintBorderImage = borderImage && borderImage->canRender(style()->effectiveZoom());
680 // If the image hasn't loaded, we're still using the normal border style.
681 if (shouldPaintBorderImage && borderImage->isLoaded())
688 void RenderObject::drawBorderArc(GraphicsContext* graphicsContext, int x, int y, float thickness, IntSize radius,
689 int angleStart, int angleSpan, BorderSide s, Color c, const Color& textColor,
690 EBorderStyle style, bool firstCorner)
692 if ((style == DOUBLE && thickness / 2 < 3) || ((style == RIDGE || style == GROOVE) && thickness / 2 < 2))
696 if (style == INSET || style == OUTSET || style == RIDGE || style == GROOVE)
697 c.setRGB(238, 238, 238);
708 graphicsContext->setStrokeColor(c);
709 graphicsContext->setStrokeStyle(style == DOTTED ? DottedStroke : DashedStroke);
710 graphicsContext->setStrokeThickness(thickness);
711 graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), angleStart, angleSpan);
714 float third = thickness / 3.0f;
715 float innerThird = (thickness + 1.0f) / 6.0f;
716 int shiftForInner = static_cast<int>(innerThird * 2.5f);
719 int outerHeight = radius.height() * 2;
720 int innerX = x + shiftForInner;
721 int innerY = y + shiftForInner;
722 int innerWidth = (radius.width() - shiftForInner) * 2;
723 int innerHeight = (radius.height() - shiftForInner) * 2;
724 if (innerThird > 1 && (s == BSTop || (firstCorner && (s == BSLeft || s == BSRight)))) {
729 graphicsContext->setStrokeStyle(SolidStroke);
730 graphicsContext->setStrokeColor(c);
731 graphicsContext->setStrokeThickness(third);
732 graphicsContext->strokeArc(IntRect(x, outerY, radius.width() * 2, outerHeight), angleStart, angleSpan);
733 graphicsContext->setStrokeThickness(innerThird > 2 ? innerThird - 1 : innerThird);
734 graphicsContext->strokeArc(IntRect(innerX, innerY, innerWidth, innerHeight), angleStart, angleSpan);
740 if ((style == RIDGE && (s == BSTop || s == BSLeft)) ||
741 (style == GROOVE && (s == BSBottom || s == BSRight)))
748 graphicsContext->setStrokeStyle(SolidStroke);
749 graphicsContext->setStrokeColor(c);
750 graphicsContext->setStrokeThickness(thickness);
751 graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), angleStart, angleSpan);
753 float halfThickness = (thickness + 1.0f) / 4.0f;
754 int shiftForInner = static_cast<int>(halfThickness * 1.5f);
755 graphicsContext->setStrokeColor(c2);
756 graphicsContext->setStrokeThickness(halfThickness > 2 ? halfThickness - 1 : halfThickness);
757 graphicsContext->strokeArc(IntRect(x + shiftForInner, y + shiftForInner, (radius.width() - shiftForInner) * 2,
758 (radius.height() - shiftForInner) * 2), angleStart, angleSpan);
762 if (s == BSTop || s == BSLeft)
765 if (style == OUTSET && (s == BSBottom || s == BSRight))
768 graphicsContext->setStrokeStyle(SolidStroke);
769 graphicsContext->setStrokeColor(c);
770 graphicsContext->setStrokeThickness(thickness);
771 graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), angleStart, angleSpan);
776 void RenderObject::drawBorder(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2,
777 BorderSide s, Color c, const Color& textcolor, EBorderStyle style,
778 int adjbw1, int adjbw2)
780 int width = (s == BSTop || s == BSBottom ? y2 - y1 : x2 - x1);
782 if (style == DOUBLE && width < 3)
786 if (style == INSET || style == OUTSET || style == RIDGE || style == GROOVE)
787 c.setRGB(238, 238, 238);
798 graphicsContext->setStrokeColor(c);
799 graphicsContext->setStrokeThickness(width);
800 graphicsContext->setStrokeStyle(style == DASHED ? DashedStroke : DottedStroke);
806 graphicsContext->drawLine(IntPoint(x1, (y1 + y2) / 2), IntPoint(x2, (y1 + y2) / 2));
810 graphicsContext->drawLine(IntPoint((x1 + x2) / 2, y1), IntPoint((x1 + x2) / 2, y2));
815 int third = (width + 1) / 3;
817 if (adjbw1 == 0 && adjbw2 == 0) {
818 graphicsContext->setStrokeStyle(NoStroke);
819 graphicsContext->setFillColor(c);
823 graphicsContext->drawRect(IntRect(x1, y1, x2 - x1, third));
824 graphicsContext->drawRect(IntRect(x1, y2 - third, x2 - x1, third));
827 graphicsContext->drawRect(IntRect(x1, y1 + 1, third, y2 - y1 - 1));
828 graphicsContext->drawRect(IntRect(x2 - third, y1 + 1, third, y2 - y1 - 1));
831 graphicsContext->drawRect(IntRect(x1, y1 + 1, third, y2 - y1 - 1));
832 graphicsContext->drawRect(IntRect(x2 - third, y1 + 1, third, y2 - y1 - 1));
836 int adjbw1bigthird = ((adjbw1 > 0) ? adjbw1 + 1 : adjbw1 - 1) / 3;
837 int adjbw2bigthird = ((adjbw2 > 0) ? adjbw2 + 1 : adjbw2 - 1) / 3;
841 drawBorder(graphicsContext, x1 + max((-adjbw1 * 2 + 1) / 3, 0),
842 y1, x2 - max((-adjbw2 * 2 + 1) / 3, 0), y1 + third,
843 s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
844 drawBorder(graphicsContext, x1 + max((adjbw1 * 2 + 1) / 3, 0),
845 y2 - third, x2 - max((adjbw2 * 2 + 1) / 3, 0), y2,
846 s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
849 drawBorder(graphicsContext, x1, y1 + max((-adjbw1 * 2 + 1) / 3, 0),
850 x1 + third, y2 - max((-adjbw2 * 2 + 1) / 3, 0),
851 s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
852 drawBorder(graphicsContext, x2 - third, y1 + max((adjbw1 * 2 + 1) / 3, 0),
853 x2, y2 - max((adjbw2 * 2 + 1) / 3, 0),
854 s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
857 drawBorder(graphicsContext, x1 + max((adjbw1 * 2 + 1) / 3, 0),
858 y1, x2 - max((adjbw2 * 2 + 1) / 3, 0), y1 + third,
859 s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
860 drawBorder(graphicsContext, x1 + max((-adjbw1 * 2 + 1) / 3, 0),
861 y2 - third, x2 - max((-adjbw2 * 2 + 1) / 3, 0), y2,
862 s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
865 drawBorder(graphicsContext, x1, y1 + max((adjbw1 * 2 + 1) / 3, 0),
866 x1 + third, y2 - max(( adjbw2 * 2 + 1) / 3, 0),
867 s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
868 drawBorder(graphicsContext, x2 - third, y1 + max((-adjbw1 * 2 + 1) / 3, 0),
869 x2, y2 - max((-adjbw2 * 2 + 1) / 3, 0),
870 s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
883 if (style == GROOVE) {
891 int adjbw1bighalf = ((adjbw1 > 0) ? adjbw1 + 1 : adjbw1 - 1) / 2;
892 int adjbw2bighalf = ((adjbw2 > 0) ? adjbw2 + 1 : adjbw2 - 1) / 2;
896 drawBorder(graphicsContext, x1 + max(-adjbw1, 0) / 2, y1, x2 - max(-adjbw2, 0) / 2, (y1 + y2 + 1) / 2,
897 s, c, textcolor, s1, adjbw1bighalf, adjbw2bighalf);
898 drawBorder(graphicsContext, x1 + max(adjbw1 + 1, 0) / 2, (y1 + y2 + 1) / 2, x2 - max(adjbw2 + 1, 0) / 2, y2,
899 s, c, textcolor, s2, adjbw1 / 2, adjbw2 / 2);
902 drawBorder(graphicsContext, x1, y1 + max(-adjbw1, 0) / 2, (x1 + x2 + 1) / 2, y2 - max(-adjbw2, 0) / 2,
903 s, c, textcolor, s1, adjbw1bighalf, adjbw2bighalf);
904 drawBorder(graphicsContext, (x1 + x2 + 1) / 2, y1 + max(adjbw1 + 1, 0) / 2, x2, y2 - max(adjbw2 + 1, 0) / 2,
905 s, c, textcolor, s2, adjbw1 / 2, adjbw2 / 2);
908 drawBorder(graphicsContext, x1 + max(adjbw1, 0) / 2, y1, x2 - max(adjbw2, 0) / 2, (y1 + y2 + 1) / 2,
909 s, c, textcolor, s2, adjbw1bighalf, adjbw2bighalf);
910 drawBorder(graphicsContext, x1 + max(-adjbw1 + 1, 0) / 2, (y1 + y2 + 1) / 2, x2 - max(-adjbw2 + 1, 0) / 2, y2,
911 s, c, textcolor, s1, adjbw1/2, adjbw2/2);
914 drawBorder(graphicsContext, x1, y1 + max(adjbw1, 0) / 2, (x1 + x2 + 1) / 2, y2 - max(adjbw2, 0) / 2,
915 s, c, textcolor, s2, adjbw1bighalf, adjbw2bighalf);
916 drawBorder(graphicsContext, (x1 + x2 + 1) / 2, y1 + max(-adjbw1 + 1, 0) / 2, x2, y2 - max(-adjbw2 + 1, 0) / 2,
917 s, c, textcolor, s1, adjbw1/2, adjbw2/2);
923 if (s == BSTop || s == BSLeft)
927 if (style == OUTSET && (s == BSBottom || s == BSRight))
931 graphicsContext->setStrokeStyle(NoStroke);
932 graphicsContext->setFillColor(c);
935 if (!adjbw1 && !adjbw2) {
936 graphicsContext->drawRect(IntRect(x1, y1, x2 - x1, y2 - y1));
942 quad[0] = FloatPoint(x1 + max(-adjbw1, 0), y1);
943 quad[1] = FloatPoint(x1 + max(adjbw1, 0), y2);
944 quad[2] = FloatPoint(x2 - max(adjbw2, 0), y2);
945 quad[3] = FloatPoint(x2 - max(-adjbw2, 0), y1);
948 quad[0] = FloatPoint(x1 + max(adjbw1, 0), y1);
949 quad[1] = FloatPoint(x1 + max(-adjbw1, 0), y2);
950 quad[2] = FloatPoint(x2 - max(-adjbw2, 0), y2);
951 quad[3] = FloatPoint(x2 - max(adjbw2, 0), y1);
954 quad[0] = FloatPoint(x1, y1 + max(-adjbw1, 0));
955 quad[1] = FloatPoint(x1, y2 - max(-adjbw2, 0));
956 quad[2] = FloatPoint(x2, y2 - max(adjbw2, 0));
957 quad[3] = FloatPoint(x2, y1 + max(adjbw1, 0));
960 quad[0] = FloatPoint(x1, y1 + max(adjbw1, 0));
961 quad[1] = FloatPoint(x1, y2 - max(adjbw2, 0));
962 quad[2] = FloatPoint(x2, y2 - max(-adjbw2, 0));
963 quad[3] = FloatPoint(x2, y1 + max(-adjbw1, 0));
966 graphicsContext->drawConvexPolygon(4, quad);
972 bool RenderObject::paintNinePieceImage(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, const RenderStyle* style,
973 const NinePieceImage& ninePieceImage, CompositeOperator op)
975 StyleImage* styleImage = ninePieceImage.image();
976 if (!styleImage || !styleImage->canRender(style->effectiveZoom()))
979 if (!styleImage->isLoaded())
980 return true; // Never paint a nine-piece image incrementally, but don't paint the fallback borders either.
982 // If we have a border radius, the image gets clipped to the rounded rect.
983 bool clipped = false;
984 if (style->hasBorderRadius()) {
985 IntRect clipRect(tx, ty, w, h);
986 graphicsContext->save();
987 graphicsContext->addRoundedRectClip(clipRect, style->borderTopLeftRadius(), style->borderTopRightRadius(),
988 style->borderBottomLeftRadius(), style->borderBottomRightRadius());
992 // FIXME: border-image is broken with full page zooming when tiling has to happen, since the tiling function
993 // doesn't have any understanding of the zoom that is in effect on the tile.
994 styleImage->setImageContainerSize(IntSize(w, h));
995 IntSize imageSize = styleImage->imageSize(this, 1.0f);
996 int imageWidth = imageSize.width();
997 int imageHeight = imageSize.height();
999 int topSlice = min(imageHeight, ninePieceImage.m_slices.top().calcValue(imageHeight));
1000 int bottomSlice = min(imageHeight, ninePieceImage.m_slices.bottom().calcValue(imageHeight));
1001 int leftSlice = min(imageWidth, ninePieceImage.m_slices.left().calcValue(imageWidth));
1002 int rightSlice = min(imageWidth, ninePieceImage.m_slices.right().calcValue(imageWidth));
1004 ENinePieceImageRule hRule = ninePieceImage.horizontalRule();
1005 ENinePieceImageRule vRule = ninePieceImage.verticalRule();
1007 bool fitToBorder = style->borderImage() == ninePieceImage;
1009 int leftWidth = fitToBorder ? style->borderLeftWidth() : leftSlice;
1010 int topWidth = fitToBorder ? style->borderTopWidth() : topSlice;
1011 int rightWidth = fitToBorder ? style->borderRightWidth() : rightSlice;
1012 int bottomWidth = fitToBorder ? style->borderBottomWidth() : bottomSlice;
1014 bool drawLeft = leftSlice > 0 && leftWidth > 0;
1015 bool drawTop = topSlice > 0 && topWidth > 0;
1016 bool drawRight = rightSlice > 0 && rightWidth > 0;
1017 bool drawBottom = bottomSlice > 0 && bottomWidth > 0;
1018 bool drawMiddle = (imageWidth - leftSlice - rightSlice) > 0 && (w - leftWidth - rightWidth) > 0 &&
1019 (imageHeight - topSlice - bottomSlice) > 0 && (h - topWidth - bottomWidth) > 0;
1021 Image* image = styleImage->image(this, imageSize);
1024 // Paint the top and bottom left corners.
1026 // The top left corner rect is (tx, ty, leftWidth, topWidth)
1027 // The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice)
1029 graphicsContext->drawImage(image, IntRect(tx, ty, leftWidth, topWidth),
1030 IntRect(0, 0, leftSlice, topSlice), op);
1032 // The bottom left corner rect is (tx, ty + h - bottomWidth, leftWidth, bottomWidth)
1033 // The rect to use from within the image is (0, imageHeight - bottomSlice, leftSlice, botomSlice)
1035 graphicsContext->drawImage(image, IntRect(tx, ty + h - bottomWidth, leftWidth, bottomWidth),
1036 IntRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice), op);
1038 // Paint the left edge.
1039 // Have to scale and tile into the border rect.
1040 graphicsContext->drawTiledImage(image, IntRect(tx, ty + topWidth, leftWidth,
1041 h - topWidth - bottomWidth),
1042 IntRect(0, topSlice, leftSlice, imageHeight - topSlice - bottomSlice),
1043 Image::StretchTile, (Image::TileRule)vRule, op);
1047 // Paint the top and bottom right corners
1048 // The top right corner rect is (tx + w - rightWidth, ty, rightWidth, topWidth)
1049 // The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice)
1051 graphicsContext->drawImage(image, IntRect(tx + w - rightWidth, ty, rightWidth, topWidth),
1052 IntRect(imageWidth - rightSlice, 0, rightSlice, topSlice), op);
1054 // The bottom right corner rect is (tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth)
1055 // The rect to use from within the image is (imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice)
1057 graphicsContext->drawImage(image, IntRect(tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth),
1058 IntRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice), op);
1060 // Paint the right edge.
1061 graphicsContext->drawTiledImage(image, IntRect(tx + w - rightWidth, ty + topWidth, rightWidth,
1062 h - topWidth - bottomWidth),
1063 IntRect(imageWidth - rightSlice, topSlice, rightSlice, imageHeight - topSlice - bottomSlice),
1064 Image::StretchTile, (Image::TileRule)vRule, op);
1067 // Paint the top edge.
1069 graphicsContext->drawTiledImage(image, IntRect(tx + leftWidth, ty, w - leftWidth - rightWidth, topWidth),
1070 IntRect(leftSlice, 0, imageWidth - rightSlice - leftSlice, topSlice),
1071 (Image::TileRule)hRule, Image::StretchTile, op);
1073 // Paint the bottom edge.
1075 graphicsContext->drawTiledImage(image, IntRect(tx + leftWidth, ty + h - bottomWidth,
1076 w - leftWidth - rightWidth, bottomWidth),
1077 IntRect(leftSlice, imageHeight - bottomSlice, imageWidth - rightSlice - leftSlice, bottomSlice),
1078 (Image::TileRule)hRule, Image::StretchTile, op);
1080 // Paint the middle.
1082 graphicsContext->drawTiledImage(image, IntRect(tx + leftWidth, ty + topWidth, w - leftWidth - rightWidth,
1083 h - topWidth - bottomWidth),
1084 IntRect(leftSlice, topSlice, imageWidth - rightSlice - leftSlice, imageHeight - topSlice - bottomSlice),
1085 (Image::TileRule)hRule, (Image::TileRule)vRule, op);
1087 // Clear the clip for the border radius.
1089 graphicsContext->restore();
1094 void RenderObject::paintBorder(GraphicsContext* graphicsContext, int tx, int ty, int w, int h,
1095 const RenderStyle* style, bool begin, bool end)
1097 if (paintNinePieceImage(graphicsContext, tx, ty, w, h, style, style->borderImage()))
1100 const Color& tc = style->borderTopColor();
1101 const Color& bc = style->borderBottomColor();
1102 const Color& lc = style->borderLeftColor();
1103 const Color& rc = style->borderRightColor();
1105 bool tt = style->borderTopIsTransparent();
1106 bool bt = style->borderBottomIsTransparent();
1107 bool rt = style->borderRightIsTransparent();
1108 bool lt = style->borderLeftIsTransparent();
1110 EBorderStyle ts = style->borderTopStyle();
1111 EBorderStyle bs = style->borderBottomStyle();
1112 EBorderStyle ls = style->borderLeftStyle();
1113 EBorderStyle rs = style->borderRightStyle();
1115 bool renderTop = ts > BHIDDEN && !tt;
1116 bool renderLeft = ls > BHIDDEN && begin && !lt;
1117 bool renderRight = rs > BHIDDEN && end && !rt;
1118 bool renderBottom = bs > BHIDDEN && !bt;
1120 // Need sufficient width and height to contain border radius curves. Sanity check our border radii
1121 // and our width/height values to make sure the curves can all fit. If not, then we won't paint
1122 // any border radii.
1123 bool renderRadii = false;
1124 IntSize topLeft = style->borderTopLeftRadius();
1125 IntSize topRight = style->borderTopRightRadius();
1126 IntSize bottomLeft = style->borderBottomLeftRadius();
1127 IntSize bottomRight = style->borderBottomRightRadius();
1129 if (style->hasBorderRadius() &&
1130 static_cast<unsigned>(w) >= static_cast<unsigned>(topLeft.width()) + static_cast<unsigned>(topRight.width()) &&
1131 static_cast<unsigned>(w) >= static_cast<unsigned>(bottomLeft.width()) + static_cast<unsigned>(bottomRight.width()) &&
1132 static_cast<unsigned>(h) >= static_cast<unsigned>(topLeft.height()) + static_cast<unsigned>(bottomLeft.height()) &&
1133 static_cast<unsigned>(h) >= static_cast<unsigned>(topRight.height()) + static_cast<unsigned>(bottomRight.height()))
1136 // Clip to the rounded rectangle.
1138 graphicsContext->save();
1139 graphicsContext->addRoundedRectClip(IntRect(tx, ty, w, h), topLeft, topRight, bottomLeft, bottomRight);
1142 int firstAngleStart, secondAngleStart, firstAngleSpan, secondAngleSpan;
1144 bool upperLeftBorderStylesMatch = renderLeft && (ts == ls) && (tc == lc);
1145 bool upperRightBorderStylesMatch = renderRight && (ts == rs) && (tc == rc) && (ts != OUTSET) && (ts != RIDGE) && (ts != INSET) && (ts != GROOVE);
1146 bool lowerLeftBorderStylesMatch = renderLeft && (bs == ls) && (bc == lc) && (bs != OUTSET) && (bs != RIDGE) && (bs != INSET) && (bs != GROOVE);
1147 bool lowerRightBorderStylesMatch = renderRight && (bs == rs) && (bc == rc);
1150 bool ignore_left = (renderRadii && topLeft.width() > 0) ||
1151 (tc == lc && tt == lt && ts >= OUTSET &&
1152 (ls == DOTTED || ls == DASHED || ls == SOLID || ls == OUTSET));
1154 bool ignore_right = (renderRadii && topRight.width() > 0) ||
1155 (tc == rc && tt == rt && ts >= OUTSET &&
1156 (rs == DOTTED || rs == DASHED || rs == SOLID || rs == INSET));
1161 x += topLeft.width();
1162 x2 -= topRight.width();
1165 drawBorder(graphicsContext, x, ty, x2, ty + style->borderTopWidth(), BSTop, tc, style->color(), ts,
1166 ignore_left ? 0 : style->borderLeftWidth(), ignore_right ? 0 : style->borderRightWidth());
1171 // We make the arc double thick and let the clip rect take care of clipping the extra off.
1172 // We're doing this because it doesn't seem possible to match the curve of the clip exactly
1173 // with the arc-drawing function.
1174 thickness = style->borderTopWidth() * 2;
1176 if (topLeft.width()) {
1178 // The inner clip clips inside the arc. This is especially important for 1px borders.
1179 bool applyLeftInnerClip = (style->borderLeftWidth() < topLeft.width())
1180 && (style->borderTopWidth() < topLeft.height())
1181 && (ts != DOUBLE || style->borderTopWidth() > 6);
1182 if (applyLeftInnerClip) {
1183 graphicsContext->save();
1184 graphicsContext->addInnerRoundedRectClip(IntRect(leftX, leftY, topLeft.width() * 2, topLeft.height() * 2),
1185 style->borderTopWidth());
1188 firstAngleStart = 90;
1189 firstAngleSpan = upperLeftBorderStylesMatch ? 90 : 45;
1191 // Draw upper left arc
1192 drawBorderArc(graphicsContext, leftX, leftY, thickness, topLeft, firstAngleStart, firstAngleSpan,
1193 BSTop, tc, style->color(), ts, true);
1194 if (applyLeftInnerClip)
1195 graphicsContext->restore();
1198 if (topRight.width()) {
1199 int rightX = tx + w - topRight.width() * 2;
1200 bool applyRightInnerClip = (style->borderRightWidth() < topRight.width())
1201 && (style->borderTopWidth() < topRight.height())
1202 && (ts != DOUBLE || style->borderTopWidth() > 6);
1203 if (applyRightInnerClip) {
1204 graphicsContext->save();
1205 graphicsContext->addInnerRoundedRectClip(IntRect(rightX, leftY, topRight.width() * 2, topRight.height() * 2),
1206 style->borderTopWidth());
1209 if (upperRightBorderStylesMatch) {
1210 secondAngleStart = 0;
1211 secondAngleSpan = 90;
1213 secondAngleStart = 45;
1214 secondAngleSpan = 45;
1217 // Draw upper right arc
1218 drawBorderArc(graphicsContext, rightX, leftY, thickness, topRight, secondAngleStart, secondAngleSpan,
1219 BSTop, tc, style->color(), ts, false);
1220 if (applyRightInnerClip)
1221 graphicsContext->restore();
1227 bool ignore_left = (renderRadii && bottomLeft.width() > 0) ||
1228 (bc == lc && bt == lt && bs >= OUTSET &&
1229 (ls == DOTTED || ls == DASHED || ls == SOLID || ls == OUTSET));
1231 bool ignore_right = (renderRadii && bottomRight.width() > 0) ||
1232 (bc == rc && bt == rt && bs >= OUTSET &&
1233 (rs == DOTTED || rs == DASHED || rs == SOLID || rs == INSET));
1238 x += bottomLeft.width();
1239 x2 -= bottomRight.width();
1242 drawBorder(graphicsContext, x, ty + h - style->borderBottomWidth(), x2, ty + h, BSBottom, bc, style->color(), bs,
1243 ignore_left ? 0 : style->borderLeftWidth(), ignore_right ? 0 : style->borderRightWidth());
1246 thickness = style->borderBottomWidth() * 2;
1248 if (bottomLeft.width()) {
1250 int leftY = ty + h - bottomLeft.height() * 2;
1251 bool applyLeftInnerClip = (style->borderLeftWidth() < bottomLeft.width())
1252 && (style->borderBottomWidth() < bottomLeft.height())
1253 && (bs != DOUBLE || style->borderBottomWidth() > 6);
1254 if (applyLeftInnerClip) {
1255 graphicsContext->save();
1256 graphicsContext->addInnerRoundedRectClip(IntRect(leftX, leftY, bottomLeft.width() * 2, bottomLeft.height() * 2),
1257 style->borderBottomWidth());
1260 if (lowerLeftBorderStylesMatch) {
1261 firstAngleStart = 180;
1262 firstAngleSpan = 90;
1264 firstAngleStart = 225;
1265 firstAngleSpan = 45;
1268 // Draw lower left arc
1269 drawBorderArc(graphicsContext, leftX, leftY, thickness, bottomLeft, firstAngleStart, firstAngleSpan,
1270 BSBottom, bc, style->color(), bs, true);
1271 if (applyLeftInnerClip)
1272 graphicsContext->restore();
1275 if (bottomRight.width()) {
1276 int rightY = ty + h - bottomRight.height() * 2;
1277 int rightX = tx + w - bottomRight.width() * 2;
1278 bool applyRightInnerClip = (style->borderRightWidth() < bottomRight.width())
1279 && (style->borderBottomWidth() < bottomRight.height())
1280 && (bs != DOUBLE || style->borderBottomWidth() > 6);
1281 if (applyRightInnerClip) {
1282 graphicsContext->save();
1283 graphicsContext->addInnerRoundedRectClip(IntRect(rightX, rightY, bottomRight.width() * 2, bottomRight.height() * 2),
1284 style->borderBottomWidth());
1287 secondAngleStart = 270;
1288 secondAngleSpan = lowerRightBorderStylesMatch ? 90 : 45;
1290 // Draw lower right arc
1291 drawBorderArc(graphicsContext, rightX, rightY, thickness, bottomRight, secondAngleStart, secondAngleSpan,
1292 BSBottom, bc, style->color(), bs, false);
1293 if (applyRightInnerClip)
1294 graphicsContext->restore();
1300 bool ignore_top = (renderRadii && topLeft.height() > 0) ||
1301 (tc == lc && tt == lt && ls >= OUTSET &&
1302 (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET));
1304 bool ignore_bottom = (renderRadii && bottomLeft.height() > 0) ||
1305 (bc == lc && bt == lt && ls >= OUTSET &&
1306 (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET));
1311 y += topLeft.height();
1312 y2 -= bottomLeft.height();
1315 drawBorder(graphicsContext, tx, y, tx + style->borderLeftWidth(), y2, BSLeft, lc, style->color(), ls,
1316 ignore_top ? 0 : style->borderTopWidth(), ignore_bottom ? 0 : style->borderBottomWidth());
1318 if (renderRadii && (!upperLeftBorderStylesMatch || !lowerLeftBorderStylesMatch)) {
1320 thickness = style->borderLeftWidth() * 2;
1322 if (!upperLeftBorderStylesMatch && topLeft.width()) {
1324 bool applyTopInnerClip = (style->borderLeftWidth() < topLeft.width())
1325 && (style->borderTopWidth() < topLeft.height())
1326 && (ls != DOUBLE || style->borderLeftWidth() > 6);
1327 if (applyTopInnerClip) {
1328 graphicsContext->save();
1329 graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, topLeft.width() * 2, topLeft.height() * 2),
1330 style->borderLeftWidth());
1333 firstAngleStart = 135;
1334 firstAngleSpan = 45;
1336 // Draw top left arc
1337 drawBorderArc(graphicsContext, topX, topY, thickness, topLeft, firstAngleStart, firstAngleSpan,
1338 BSLeft, lc, style->color(), ls, true);
1339 if (applyTopInnerClip)
1340 graphicsContext->restore();
1343 if (!lowerLeftBorderStylesMatch && bottomLeft.width()) {
1344 int bottomY = ty + h - bottomLeft.height() * 2;
1345 bool applyBottomInnerClip = (style->borderLeftWidth() < bottomLeft.width())
1346 && (style->borderBottomWidth() < bottomLeft.height())
1347 && (ls != DOUBLE || style->borderLeftWidth() > 6);
1348 if (applyBottomInnerClip) {
1349 graphicsContext->save();
1350 graphicsContext->addInnerRoundedRectClip(IntRect(topX, bottomY, bottomLeft.width() * 2, bottomLeft.height() * 2),
1351 style->borderLeftWidth());
1354 secondAngleStart = 180;
1355 secondAngleSpan = 45;
1357 // Draw bottom left arc
1358 drawBorderArc(graphicsContext, topX, bottomY, thickness, bottomLeft, secondAngleStart, secondAngleSpan,
1359 BSLeft, lc, style->color(), ls, false);
1360 if (applyBottomInnerClip)
1361 graphicsContext->restore();
1367 bool ignore_top = (renderRadii && topRight.height() > 0) ||
1368 ((tc == rc) && (tt == rt) &&
1369 (rs >= DOTTED || rs == INSET) &&
1370 (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET));
1372 bool ignore_bottom = (renderRadii && bottomRight.height() > 0) ||
1373 ((bc == rc) && (bt == rt) &&
1374 (rs >= DOTTED || rs == INSET) &&
1375 (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET));
1380 y += topRight.height();
1381 y2 -= bottomRight.height();
1384 drawBorder(graphicsContext, tx + w - style->borderRightWidth(), y, tx + w, y2, BSRight, rc, style->color(), rs,
1385 ignore_top ? 0 : style->borderTopWidth(), ignore_bottom ? 0 : style->borderBottomWidth());
1387 if (renderRadii && (!upperRightBorderStylesMatch || !lowerRightBorderStylesMatch)) {
1388 thickness = style->borderRightWidth() * 2;
1390 if (!upperRightBorderStylesMatch && topRight.width()) {
1391 int topX = tx + w - topRight.width() * 2;
1393 bool applyTopInnerClip = (style->borderRightWidth() < topRight.width())
1394 && (style->borderTopWidth() < topRight.height())
1395 && (rs != DOUBLE || style->borderRightWidth() > 6);
1396 if (applyTopInnerClip) {
1397 graphicsContext->save();
1398 graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, topRight.width() * 2, topRight.height() * 2),
1399 style->borderRightWidth());
1402 firstAngleStart = 0;
1403 firstAngleSpan = 45;
1405 // Draw top right arc
1406 drawBorderArc(graphicsContext, topX, topY, thickness, topRight, firstAngleStart, firstAngleSpan,
1407 BSRight, rc, style->color(), rs, true);
1408 if (applyTopInnerClip)
1409 graphicsContext->restore();
1412 if (!lowerRightBorderStylesMatch && bottomRight.width()) {
1413 int bottomX = tx + w - bottomRight.width() * 2;
1414 int bottomY = ty + h - bottomRight.height() * 2;
1415 bool applyBottomInnerClip = (style->borderRightWidth() < bottomRight.width())
1416 && (style->borderBottomWidth() < bottomRight.height())
1417 && (rs != DOUBLE || style->borderRightWidth() > 6);
1418 if (applyBottomInnerClip) {
1419 graphicsContext->save();
1420 graphicsContext->addInnerRoundedRectClip(IntRect(bottomX, bottomY, bottomRight.width() * 2, bottomRight.height() * 2),
1421 style->borderRightWidth());
1424 secondAngleStart = 315;
1425 secondAngleSpan = 45;
1427 // Draw bottom right arc
1428 drawBorderArc(graphicsContext, bottomX, bottomY, thickness, bottomRight, secondAngleStart, secondAngleSpan,
1429 BSRight, rc, style->color(), rs, false);
1430 if (applyBottomInnerClip)
1431 graphicsContext->restore();
1437 graphicsContext->restore();
1440 void RenderObject::paintBoxShadow(GraphicsContext* context, int tx, int ty, int w, int h, const RenderStyle* s, bool begin, bool end)
1442 // FIXME: Deal with border-image. Would be great to use border-image as a mask.
1444 IntRect rect(tx, ty, w, h);
1445 bool hasBorderRadius = s->hasBorderRadius();
1446 bool hasOpaqueBackground = s->backgroundColor().isValid() && s->backgroundColor().alpha() == 255;
1447 for (ShadowData* shadow = s->boxShadow(); shadow; shadow = shadow->next) {
1450 IntSize shadowOffset(shadow->x, shadow->y);
1451 int shadowBlur = shadow->blur;
1452 IntRect fillRect(rect);
1454 if (hasBorderRadius) {
1455 IntRect shadowRect(rect);
1456 shadowRect.inflate(shadowBlur);
1457 shadowRect.move(shadowOffset);
1458 context->clip(shadowRect);
1460 // Move the fill just outside the clip, adding 1 pixel separation so that the fill does not
1461 // bleed in (due to antialiasing) if the context is transformed.
1462 IntSize extraOffset(w + max(0, shadowOffset.width()) + shadowBlur + 1, 0);
1463 shadowOffset -= extraOffset;
1464 fillRect.move(extraOffset);
1467 context->setShadow(shadowOffset, shadowBlur, shadow->color);
1468 if (hasBorderRadius) {
1469 IntSize topLeft = begin ? s->borderTopLeftRadius() : IntSize();
1470 IntSize topRight = end ? s->borderTopRightRadius() : IntSize();
1471 IntSize bottomLeft = begin ? s->borderBottomLeftRadius() : IntSize();
1472 IntSize bottomRight = end ? s->borderBottomRightRadius() : IntSize();
1473 if (!hasOpaqueBackground)
1474 context->clipOutRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
1475 context->fillRoundedRect(fillRect, topLeft, topRight, bottomLeft, bottomRight, Color::black);
1477 if (!hasOpaqueBackground)
1478 context->clipOut(rect);
1479 context->fillRect(fillRect, Color::black);
1485 void RenderObject::addPDFURLRect(GraphicsContext* context, const IntRect& rect)
1489 Node* node = element();
1490 if (!node || !node->isLink() || !node->isElementNode())
1492 const AtomicString& href = static_cast<Element*>(node)->getAttribute(hrefAttr);
1495 context->setURLForRect(node->document()->completeURL(href), rect);
1498 void RenderObject::paintOutline(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, const RenderStyle* style)
1503 int ow = style->outlineWidth();
1504 EBorderStyle os = style->outlineStyle();
1506 Color oc = style->outlineColor();
1508 oc = style->color();
1510 int offset = style->outlineOffset();
1512 if (style->outlineStyleIsAuto() || hasOutlineAnnotation()) {
1513 if (!theme()->supportsFocusRing(style)) {
1514 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring.
1515 graphicsContext->initFocusRing(ow, offset);
1516 addFocusRingRects(graphicsContext, tx, ty);
1517 if (style->outlineStyleIsAuto())
1518 graphicsContext->drawFocusRing(oc);
1520 addPDFURLRect(graphicsContext, graphicsContext->focusRingBoundingRect());
1521 graphicsContext->clearFocusRing();
1525 if (style->outlineStyleIsAuto() || style->outlineStyle() == BNONE)
1536 drawBorder(graphicsContext, tx - ow, ty - ow, tx, ty + h + ow,
1537 BSLeft, Color(oc), style->color(), os, ow, ow);
1539 drawBorder(graphicsContext, tx - ow, ty - ow, tx + w + ow, ty,
1540 BSTop, Color(oc), style->color(), os, ow, ow);
1542 drawBorder(graphicsContext, tx + w, ty - ow, tx + w + ow, ty + h + ow,
1543 BSRight, Color(oc), style->color(), os, ow, ow);
1545 drawBorder(graphicsContext, tx - ow, ty + h, tx + w + ow, ty + h + ow,
1546 BSBottom, Color(oc), style->color(), os, ow, ow);
1550 void RenderObject::absoluteRectsForRange(Vector<IntRect>& rects, unsigned start, unsigned end, bool)
1552 if (!virtualChildren()->firstChild()) {
1553 if ((isInline() || isAnonymousBlock())) {
1554 FloatPoint absPos = localToAbsolute(FloatPoint());
1555 absoluteRects(rects, absPos.x(), absPos.y());
1560 unsigned offset = start;
1561 for (RenderObject* child = childAt(start); child && offset < end; child = child->nextSibling(), ++offset) {
1562 if (child->isText() || child->isInline() || child->isAnonymousBlock()) {
1563 FloatPoint absPos = child->localToAbsolute(FloatPoint());
1564 child->absoluteRects(rects, absPos.x(), absPos.y());
1569 void RenderObject::absoluteQuadsForRange(Vector<FloatQuad>& quads, unsigned start, unsigned end, bool)
1571 if (!virtualChildren()->firstChild()) {
1572 if (isInline() || isAnonymousBlock())
1573 absoluteQuads(quads);
1577 unsigned offset = start;
1578 for (RenderObject* child = childAt(start); child && offset < end; child = child->nextSibling(), ++offset) {
1579 if (child->isText() || child->isInline() || child->isAnonymousBlock())
1580 child->absoluteQuads(quads);
1584 IntRect RenderObject::absoluteBoundingBoxRect(bool useTransforms)
1586 if (useTransforms) {
1587 Vector<FloatQuad> quads;
1588 absoluteQuads(quads);
1590 size_t n = quads.size();
1594 IntRect result = quads[0].enclosingBoundingBox();
1595 for (size_t i = 1; i < n; ++i)
1596 result.unite(quads[i].enclosingBoundingBox());
1600 FloatPoint absPos = localToAbsolute();
1601 Vector<IntRect> rects;
1602 absoluteRects(rects, absPos.x(), absPos.y());
1604 size_t n = rects.size();
1608 IntRect result = rects[0];
1609 for (size_t i = 1; i < n; ++i)
1610 result.unite(rects[i]);
1614 void RenderObject::addAbsoluteRectForLayer(IntRect& result)
1617 result.unite(absoluteBoundingBoxRect());
1618 for (RenderObject* current = firstChild(); current; current = current->nextSibling())
1619 current->addAbsoluteRectForLayer(result);
1622 IntRect RenderObject::paintingRootRect(IntRect& topLevelRect)
1624 IntRect result = absoluteBoundingBoxRect();
1625 topLevelRect = result;
1626 for (RenderObject* current = firstChild(); current; current = current->nextSibling())
1627 current->addAbsoluteRectForLayer(result);
1631 void RenderObject::paint(PaintInfo& /*paintInfo*/, int /*tx*/, int /*ty*/)
1635 RenderBoxModelObject* RenderObject::containerForRepaint() const
1637 #if USE(ACCELERATED_COMPOSITING)
1638 if (RenderView* v = view()) {
1639 if (v->usesCompositing()) {
1640 RenderLayer* compLayer = enclosingCompositingLayer();
1641 return compLayer ? compLayer->renderer() : 0;
1645 // Do root-relative repaint.
1649 void RenderObject::repaintUsingContainer(RenderBoxModelObject* repaintContainer, const IntRect& r, bool immediate)
1651 if (!repaintContainer || repaintContainer->isRenderView()) {
1652 RenderView* v = repaintContainer ? toRenderView(repaintContainer) : view();
1653 v->repaintViewRectangle(r, immediate);
1655 #if USE(ACCELERATED_COMPOSITING)
1656 RenderView* v = view();
1657 if (v->usesCompositing()) {
1658 ASSERT(repaintContainer->hasLayer() && repaintContainer->layer()->isComposited());
1659 repaintContainer->layer()->setBackingNeedsRepaintInRect(r);
1662 ASSERT_NOT_REACHED();
1667 void RenderObject::repaint(bool immediate)
1669 // Can't use view(), since we might be unrooted.
1670 RenderObject* o = this;
1673 if (!o->isRenderView())
1676 RenderView* view = toRenderView(o);
1677 if (view->printing())
1678 return; // Don't repaint if we're printing.
1680 RenderBoxModelObject* repaintContainer = containerForRepaint();
1681 repaintUsingContainer(repaintContainer ? repaintContainer : view, clippedOverflowRectForRepaint(repaintContainer), immediate);
1684 void RenderObject::repaintRectangle(const IntRect& r, bool immediate)
1686 // Can't use view(), since we might be unrooted.
1687 RenderObject* o = this;
1690 if (!o->isRenderView())
1693 RenderView* view = toRenderView(o);
1694 if (view->printing())
1695 return; // Don't repaint if we're printing.
1697 IntRect dirtyRect(r);
1699 // FIXME: layoutDelta needs to be applied in parts before/after transforms and
1700 // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308
1701 dirtyRect.move(view->layoutDelta());
1703 RenderBoxModelObject* repaintContainer = containerForRepaint();
1704 computeRectForRepaint(repaintContainer, dirtyRect);
1705 repaintUsingContainer(repaintContainer ? repaintContainer : view, dirtyRect, immediate);
1708 bool RenderObject::repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintContainer, const IntRect& oldBounds, const IntRect& oldOutlineBox)
1710 RenderView* v = view();
1712 return false; // Don't repaint if we're printing.
1714 IntRect newBounds = clippedOverflowRectForRepaint(repaintContainer);
1715 IntRect newOutlineBox;
1717 bool fullRepaint = selfNeedsLayout();
1718 // Presumably a background or a border exists if border-fit:lines was specified.
1719 if (!fullRepaint && style()->borderFit() == BorderFitLines)
1722 newOutlineBox = outlineBoundsForRepaint(repaintContainer);
1723 if (newOutlineBox.location() != oldOutlineBox.location() || (mustRepaintBackgroundOrBorder() && (newBounds != oldBounds || newOutlineBox != oldOutlineBox)))
1727 if (!repaintContainer)
1728 repaintContainer = v;
1731 repaintUsingContainer(repaintContainer, oldBounds);
1732 if (newBounds != oldBounds)
1733 repaintUsingContainer(repaintContainer, newBounds);
1737 if (newBounds == oldBounds && newOutlineBox == oldOutlineBox)
1740 int deltaLeft = newBounds.x() - oldBounds.x();
1742 repaintUsingContainer(repaintContainer, IntRect(oldBounds.x(), oldBounds.y(), deltaLeft, oldBounds.height()));
1743 else if (deltaLeft < 0)
1744 repaintUsingContainer(repaintContainer, IntRect(newBounds.x(), newBounds.y(), -deltaLeft, newBounds.height()));
1746 int deltaRight = newBounds.right() - oldBounds.right();
1748 repaintUsingContainer(repaintContainer, IntRect(oldBounds.right(), newBounds.y(), deltaRight, newBounds.height()));
1749 else if (deltaRight < 0)
1750 repaintUsingContainer(repaintContainer, IntRect(newBounds.right(), oldBounds.y(), -deltaRight, oldBounds.height()));
1752 int deltaTop = newBounds.y() - oldBounds.y();
1754 repaintUsingContainer(repaintContainer, IntRect(oldBounds.x(), oldBounds.y(), oldBounds.width(), deltaTop));
1755 else if (deltaTop < 0)
1756 repaintUsingContainer(repaintContainer, IntRect(newBounds.x(), newBounds.y(), newBounds.width(), -deltaTop));
1758 int deltaBottom = newBounds.bottom() - oldBounds.bottom();
1759 if (deltaBottom > 0)
1760 repaintUsingContainer(repaintContainer, IntRect(newBounds.x(), oldBounds.bottom(), newBounds.width(), deltaBottom));
1761 else if (deltaBottom < 0)
1762 repaintUsingContainer(repaintContainer, IntRect(oldBounds.x(), newBounds.bottom(), oldBounds.width(), -deltaBottom));
1764 if (newOutlineBox == oldOutlineBox)
1767 // We didn't move, but we did change size. Invalidate the delta, which will consist of possibly
1768 // two rectangles (but typically only one).
1769 RenderStyle* outlineStyle = outlineStyleForRepaint();
1770 int ow = outlineStyle->outlineSize();
1771 ShadowData* boxShadow = style()->boxShadow();
1772 int width = abs(newOutlineBox.width() - oldOutlineBox.width());
1774 int shadowRight = 0;
1775 for (ShadowData* shadow = boxShadow; shadow; shadow = shadow->next)
1776 shadowRight = max(shadow->x + shadow->blur, shadowRight);
1778 int borderRight = isBox() ? toRenderBox(this)->borderRight() : 0;
1779 int borderWidth = max(-outlineStyle->outlineOffset(), max(borderRight, max(style()->borderTopRightRadius().width(), style()->borderBottomRightRadius().width()))) + max(ow, shadowRight);
1780 IntRect rightRect(newOutlineBox.x() + min(newOutlineBox.width(), oldOutlineBox.width()) - borderWidth,
1782 width + borderWidth,
1783 max(newOutlineBox.height(), oldOutlineBox.height()));
1784 int right = min(newBounds.right(), oldBounds.right());
1785 if (rightRect.x() < right) {
1786 rightRect.setWidth(min(rightRect.width(), right - rightRect.x()));
1787 repaintUsingContainer(repaintContainer, rightRect);
1790 int height = abs(newOutlineBox.height() - oldOutlineBox.height());
1792 int shadowBottom = 0;
1793 for (ShadowData* shadow = boxShadow; shadow; shadow = shadow->next)
1794 shadowBottom = max(shadow->y + shadow->blur, shadowBottom);
1796 int borderBottom = isBox() ? toRenderBox(this)->borderBottom() : 0;
1797 int borderHeight = max(-outlineStyle->outlineOffset(), max(borderBottom, max(style()->borderBottomLeftRadius().height(), style()->borderBottomRightRadius().height()))) + max(ow, shadowBottom);
1798 IntRect bottomRect(newOutlineBox.x(),
1799 min(newOutlineBox.bottom(), oldOutlineBox.bottom()) - borderHeight,
1800 max(newOutlineBox.width(), oldOutlineBox.width()),
1801 height + borderHeight);
1802 int bottom = min(newBounds.bottom(), oldBounds.bottom());
1803 if (bottomRect.y() < bottom) {
1804 bottomRect.setHeight(min(bottomRect.height(), bottom - bottomRect.y()));
1805 repaintUsingContainer(repaintContainer, bottomRect);
1811 void RenderObject::repaintDuringLayoutIfMoved(const IntRect&)
1815 void RenderObject::repaintOverhangingFloats(bool)
1819 bool RenderObject::checkForRepaintDuringLayout() const
1821 // FIXME: <https://bugs.webkit.org/show_bug.cgi?id=20885> It is probably safe to also require
1822 // m_everHadLayout. Currently, only RenderBlock::layoutBlock() adds this condition. See also
1823 // <https://bugs.webkit.org/show_bug.cgi?id=15129>.
1824 return !document()->view()->needsFullRepaint() && !hasLayer();
1827 IntRect RenderObject::rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, int outlineWidth)
1829 IntRect r(clippedOverflowRectForRepaint(repaintContainer));
1830 r.inflate(outlineWidth);
1834 IntRect RenderObject::clippedOverflowRectForRepaint(RenderBoxModelObject*)
1836 ASSERT_NOT_REACHED();
1840 void RenderObject::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& rect, bool fixed)
1842 if (repaintContainer == this)
1845 if (RenderObject* o = parent()) {
1846 if (o->isBlockFlow()) {
1847 RenderBlock* cb = toRenderBlock(o);
1848 if (cb->hasColumns())
1849 cb->adjustRectForColumns(rect);
1852 if (o->hasOverflowClip()) {
1853 // o->height() is inaccurate if we're in the middle of a layout of |o|, so use the
1854 // layer's size instead. Even if the layer's size is wrong, the layer itself will repaint
1855 // anyway if its size does change.
1856 RenderBox* boxParent = toRenderBox(o);
1858 IntRect boxRect(0, 0, boxParent->layer()->width(), boxParent->layer()->height());
1861 boxParent->layer()->subtractScrolledContentOffset(x, y); // For overflow:auto/scroll/hidden.
1862 IntRect repaintRect(x, y, rect.width(), rect.height());
1863 rect = intersection(repaintRect, boxRect);
1868 o->computeRectForRepaint(repaintContainer, rect, fixed);
1872 void RenderObject::dirtyLinesFromChangedChild(RenderObject*)
1878 void RenderObject::showTreeForThis() const
1881 element()->showTreeForThis();
1886 Color RenderObject::selectionBackgroundColor() const
1889 if (style()->userSelect() != SELECT_NONE) {
1890 RenderStyle* pseudoStyle = getCachedPseudoStyle(SELECTION);
1891 if (pseudoStyle && pseudoStyle->backgroundColor().isValid())
1892 color = pseudoStyle->backgroundColor().blendWithWhite();
1894 color = document()->frame()->selection()->isFocusedAndActive() ?
1895 theme()->activeSelectionBackgroundColor() :
1896 theme()->inactiveSelectionBackgroundColor();
1902 Color RenderObject::selectionForegroundColor() const
1905 if (style()->userSelect() == SELECT_NONE)
1908 if (RenderStyle* pseudoStyle = getCachedPseudoStyle(SELECTION)) {
1909 color = pseudoStyle->textFillColor();
1910 if (!color.isValid())
1911 color = pseudoStyle->color();
1913 color = document()->frame()->selection()->isFocusedAndActive() ?
1914 theme()->activeSelectionForegroundColor() :
1915 theme()->inactiveSelectionForegroundColor();
1920 Node* RenderObject::draggableNode(bool dhtmlOK, bool uaOK, int x, int y, bool& dhtmlWillDrag) const
1922 if (!dhtmlOK && !uaOK)
1925 for (const RenderObject* curr = this; curr; curr = curr->parent()) {
1926 Node* elt = curr->element();
1927 if (elt && elt->nodeType() == Node::TEXT_NODE) {
1928 // Since there's no way for the author to address the -webkit-user-drag style for a text node,
1929 // we use our own judgement.
1930 if (uaOK && view()->frameView()->frame()->eventHandler()->shouldDragAutoNode(curr->node(), IntPoint(x, y))) {
1931 dhtmlWillDrag = false;
1932 return curr->node();
1934 if (elt->canStartSelection())
1935 // In this case we have a click in the unselected portion of text. If this text is
1936 // selectable, we want to start the selection process instead of looking for a parent
1940 EUserDrag dragMode = curr->style()->userDrag();
1941 if (dhtmlOK && dragMode == DRAG_ELEMENT) {
1942 dhtmlWillDrag = true;
1943 return curr->node();
1945 if (uaOK && dragMode == DRAG_AUTO
1946 && view()->frameView()->frame()->eventHandler()->shouldDragAutoNode(curr->node(), IntPoint(x, y))) {
1947 dhtmlWillDrag = false;
1948 return curr->node();
1955 void RenderObject::selectionStartEnd(int& spos, int& epos) const
1957 view()->selectionStartEnd(spos, epos);
1960 RenderBlock* RenderObject::createAnonymousBlock()
1962 RefPtr<RenderStyle> newStyle = RenderStyle::create();
1963 newStyle->inheritFrom(m_style.get());
1964 newStyle->setDisplay(BLOCK);
1966 RenderBlock* newBox = new (renderArena()) RenderBlock(document() /* anonymous box */);
1967 newBox->setStyle(newStyle.release());
1971 void RenderObject::handleDynamicFloatPositionChange()
1973 // We have gone from not affecting the inline status of the parent flow to suddenly
1974 // having an impact. See if there is a mismatch between the parent flow's
1975 // childrenInline() state and our state.
1976 setInline(style()->isDisplayInlineType());
1977 if (isInline() != parent()->childrenInline()) {
1979 toRenderBox(parent())->childBecameNonInline(this);
1981 // An anonymous block must be made to wrap this inline.
1982 RenderBlock* block = createAnonymousBlock();
1983 RenderObjectChildList* childlist = parent()->virtualChildren();
1984 childlist->insertChildNode(parent(), block, this);
1985 block->children()->appendChildNode(block, childlist->removeChildNode(parent(), this));
1990 void RenderObject::setAnimatableStyle(PassRefPtr<RenderStyle> style)
1992 if (!isText() && style)
1993 setStyle(animation()->updateAnimations(this, style.get()));
1998 void RenderObject::setStyle(PassRefPtr<RenderStyle> style)
2000 if (m_style == style)
2003 StyleDifference diff = StyleDifferenceEqual;
2005 diff = m_style->diff(style.get());
2007 // If we have no layer(), just treat a RepaintLayer hint as a normal Repaint.
2008 if (diff == StyleDifferenceRepaintLayer && !hasLayer())
2009 diff = StyleDifferenceRepaint;
2011 styleWillChange(diff, style.get());
2013 RefPtr<RenderStyle> oldStyle = m_style.release();
2016 updateFillImages(oldStyle ? oldStyle->backgroundLayers() : 0, m_style ? m_style->backgroundLayers() : 0);
2017 updateFillImages(oldStyle ? oldStyle->maskLayers() : 0, m_style ? m_style->maskLayers() : 0);
2019 updateImage(oldStyle ? oldStyle->borderImage().image() : 0, m_style ? m_style->borderImage().image() : 0);
2020 updateImage(oldStyle ? oldStyle->maskBoxImage().image() : 0, m_style ? m_style->maskBoxImage().image() : 0);
2022 // We need to ensure that view->maximalOutlineSize() is valid for any repaints that happen
2023 // during styleDidChange (it's used by clippedOverflowRectForRepaint()).
2024 if (m_style->outlineWidth() > 0 && m_style->outlineSize() > maximalOutlineSize(PaintPhaseOutline))
2025 toRenderView(document()->renderer())->setMaximalOutlineSize(m_style->outlineSize());
2027 styleDidChange(diff, oldStyle.get());
2030 void RenderObject::setStyleInternal(PassRefPtr<RenderStyle> style)
2035 void RenderObject::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
2038 // If our z-index changes value or our visibility changes,
2039 // we need to dirty our stacking context's z-order list.
2041 #if ENABLE(DASHBOARD_SUPPORT)
2042 if (m_style->visibility() != newStyle->visibility() ||
2043 m_style->zIndex() != newStyle->zIndex() ||
2044 m_style->hasAutoZIndex() != newStyle->hasAutoZIndex())
2045 document()->setDashboardRegionsDirty(true);
2048 // Keep layer hierarchy visibility bits up to date if visibility changes.
2049 if (m_style->visibility() != newStyle->visibility()) {
2050 if (RenderLayer* l = enclosingLayer()) {
2051 if (newStyle->visibility() == VISIBLE)
2052 l->setHasVisibleContent(true);
2053 else if (l->hasVisibleContent() && (this == l->renderer() || l->renderer()->style()->visibility() != VISIBLE)) {
2054 l->dirtyVisibleContentStatus();
2055 if (diff > StyleDifferenceRepaintLayer)
2062 if (m_parent && (diff == StyleDifferenceRepaint || newStyle->outlineSize() < m_style->outlineSize()))
2064 if (isFloating() && (m_style->floating() != newStyle->floating()))
2065 // For changes in float styles, we need to conceivably remove ourselves
2066 // from the floating objects list.
2067 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists();
2068 else if (isPositioned() && (newStyle->position() != AbsolutePosition && newStyle->position() != FixedPosition))
2069 // For changes in positioning styles, we need to conceivably remove ourselves
2070 // from the positioned objects list.
2071 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists();
2073 s_affectsParentBlock = isFloatingOrPositioned() &&
2074 (!newStyle->isFloating() && newStyle->position() != AbsolutePosition && newStyle->position() != FixedPosition)
2075 && parent() && (parent()->isBlockFlow() || parent()->isRenderInline());
2077 // reset style flags
2078 if (diff == StyleDifferenceLayout || diff == StyleDifferenceLayoutPositionedMovementOnly) {
2080 m_positioned = false;
2081 m_relPositioned = false;
2083 m_paintBackground = false;
2084 m_hasOverflowClip = false;
2085 m_hasTransform = false;
2086 m_hasReflection = false;
2088 s_affectsParentBlock = false;
2090 if (view()->frameView()) {
2091 // FIXME: A better solution would be to only invalidate the fixed regions when scrolling. It's overkill to
2092 // prevent the entire view from blitting on a scroll.
2093 bool newStyleSlowScroll = newStyle && (newStyle->position() == FixedPosition || newStyle->hasFixedBackgroundImage());
2094 bool oldStyleSlowScroll = m_style && (m_style->position() == FixedPosition || m_style->hasFixedBackgroundImage());
2095 if (oldStyleSlowScroll != newStyleSlowScroll) {
2096 if (oldStyleSlowScroll)
2097 view()->frameView()->removeSlowRepaintObject();
2098 if (newStyleSlowScroll)
2099 view()->frameView()->addSlowRepaintObject();
2104 void RenderObject::styleDidChange(StyleDifference diff, const RenderStyle*)
2106 if (s_affectsParentBlock)
2107 handleDynamicFloatPositionChange();
2112 if (diff == StyleDifferenceLayout)
2113 setNeedsLayoutAndPrefWidthsRecalc();
2114 else if (diff == StyleDifferenceLayoutPositionedMovementOnly)
2115 setNeedsPositionedMovementLayout();
2116 else if (diff == StyleDifferenceRepaintLayer || diff == StyleDifferenceRepaint)
2117 // Do a repaint with the new style now, e.g., for example if we go from
2118 // not having an outline to having an outline.
2122 void RenderObject::updateFillImages(const FillLayer* oldLayers, const FillLayer* newLayers)
2124 // FIXME: This will be slow when a large number of images is used. Fix by using a dict.
2125 for (const FillLayer* currOld = oldLayers; currOld; currOld = currOld->next()) {
2126 if (currOld->image() && (!newLayers || !newLayers->containsImage(currOld->image())))
2127 currOld->image()->removeClient(this);
2129 for (const FillLayer* currNew = newLayers; currNew; currNew = currNew->next()) {
2130 if (currNew->image() && (!oldLayers || !oldLayers->containsImage(currNew->image())))
2131 currNew->image()->addClient(this);
2135 void RenderObject::updateImage(StyleImage* oldImage, StyleImage* newImage)
2137 if (oldImage != newImage) {
2139 oldImage->removeClient(this);
2141 newImage->addClient(this);
2145 IntRect RenderObject::viewRect() const
2147 return view()->viewRect();
2150 FloatPoint RenderObject::localToAbsolute(FloatPoint localPoint, bool fixed, bool useTransforms) const
2152 RenderObject* o = parent();
2154 if (o->hasOverflowClip())
2155 localPoint -= toRenderBox(o)->layer()->scrolledContentOffset();
2156 return o->localToAbsolute(localPoint, fixed, useTransforms);
2159 return FloatPoint();
2162 FloatPoint RenderObject::absoluteToLocal(FloatPoint containerPoint, bool fixed, bool useTransforms) const
2164 RenderObject* o = parent();
2166 FloatPoint localPoint = o->absoluteToLocal(containerPoint, fixed, useTransforms);
2167 if (o->hasOverflowClip())
2168 localPoint += toRenderBox(o)->layer()->scrolledContentOffset();
2171 return FloatPoint();
2174 FloatQuad RenderObject::localToContainerQuad(const FloatQuad& localQuad, RenderBoxModelObject* repaintContainer, bool fixed) const
2176 if (repaintContainer == this)
2179 RenderObject* o = parent();
2181 FloatQuad quad = localQuad;
2182 if (o->hasOverflowClip())
2183 quad -= toRenderBox(o)->layer()->scrolledContentOffset();
2184 return o->localToContainerQuad(quad, repaintContainer, fixed);
2190 IntSize RenderObject::offsetFromContainer(RenderObject* o) const
2192 ASSERT(o == container());
2195 if (o->hasOverflowClip())
2196 offset -= toRenderBox(o)->layer()->scrolledContentOffset();
2201 IntRect RenderObject::localCaretRect(InlineBox*, int, int* extraWidthToEndOfLine)
2203 if (extraWidthToEndOfLine)
2204 *extraWidthToEndOfLine = 0;
2209 RenderView* RenderObject::view() const
2211 return toRenderView(document()->renderer());
2214 bool RenderObject::hasOutlineAnnotation() const
2216 return element() && element()->isLink() && document()->printing();
2219 RenderObject* RenderObject::container() const
2221 // This method is extremely similar to containingBlock(), but with a few notable
2223 // (1) It can be used on orphaned subtrees, i.e., it can be called safely even when
2224 // the object is not part of the primary document subtree yet.
2225 // (2) For normal flow elements, it just returns the parent.
2226 // (3) For absolute positioned elements, it will return a relative positioned inline.
2227 // containingBlock() simply skips relpositioned inlines and lets an enclosing block handle
2228 // the layout of the positioned object. This does mean that calcAbsoluteHorizontal and
2229 // calcAbsoluteVertical have to use container().
2230 RenderObject* o = parent();
2235 EPosition pos = m_style->position();
2236 if (pos == FixedPosition) {
2237 // container() can be called on an object that is not in the
2238 // tree yet. We don't call view() since it will assert if it
2239 // can't get back to the canvas. Instead we just walk as high up
2240 // as we can. If we're in the tree, we'll get the root. If we
2241 // aren't we'll get the root of our little subtree (most likely
2242 // we'll just return 0).
2243 // FIXME: The definition of view() has changed to not crawl up the render tree. It might
2244 // be safe now to use it.
2245 while (o && o->parent() && !(o->hasTransform() && o->isRenderBlock()))
2247 } else if (pos == AbsolutePosition) {
2248 // Same goes here. We technically just want our containing block, but
2249 // we may not have one if we're part of an uninstalled subtree. We'll
2250 // climb as high as we can though.
2251 while (o && o->style()->position() == StaticPosition && !o->isRenderView() && !(o->hasTransform() && o->isRenderBlock()))
2258 bool RenderObject::isSelectionBorder() const
2260 SelectionState st = selectionState();
2261 return st == SelectionStart || st == SelectionEnd || st == SelectionBoth;
2264 void RenderObject::destroy()
2266 // Destroy any leftover anonymous children.
2267 RenderObjectChildList* children = virtualChildren();
2269 children->destroyLeftoverChildren();
2271 // If this renderer is being autoscrolled, stop the autoscroll timer
2272 if (document()->frame() && document()->frame()->eventHandler()->autoscrollRenderer() == this)
2273 document()->frame()->eventHandler()->stopAutoscrollTimer(true);
2275 if (m_hasCounterNodeMap)
2276 RenderCounter::destroyCounterNodes(this);
2278 if (AXObjectCache::accessibilityEnabled()) {
2279 document()->axObjectCache()->childrenChanged(this->parent());
2280 document()->axObjectCache()->remove(this);
2282 animation()->cancelAnimations(this);
2284 // By default no ref-counting. RenderWidget::destroy() doesn't call
2285 // this function because it needs to do ref-counting. If anything
2286 // in this function changes, be sure to fix RenderWidget::destroy() as well.
2290 // FIXME: Would like to do this in RenderBox, but the timing is so complicated that this can't easily
2291 // be moved into RenderBox::destroy.
2292 RenderArena* arena = renderArena();
2294 toRenderBox(this)->layer()->destroy(arena);
2295 arenaDelete(arena, this);
2298 void RenderObject::arenaDelete(RenderArena* arena, void* base)
2301 for (const FillLayer* bgLayer = m_style->backgroundLayers(); bgLayer; bgLayer = bgLayer->next()) {
2302 if (StyleImage* backgroundImage = bgLayer->image())
2303 backgroundImage->removeClient(this);
2306 for (const FillLayer* maskLayer = m_style->maskLayers(); maskLayer; maskLayer = maskLayer->next()) {
2307 if (StyleImage* maskImage = maskLayer->image())
2308 maskImage->removeClient(this);
2311 if (StyleImage* borderImage = m_style->borderImage().image())
2312 borderImage->removeClient(this);
2314 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image())
2315 maskBoxImage->removeClient(this);
2319 void* savedBase = baseOfRenderObjectBeingDeleted;
2320 baseOfRenderObjectBeingDeleted = base;
2324 baseOfRenderObjectBeingDeleted = savedBase;
2327 // Recover the size left there for us by operator delete and free the memory.
2328 arena->free(*(size_t*)base, base);
2331 VisiblePosition RenderObject::positionForCoordinates(int, int)
2333 return VisiblePosition(element(), caretMinOffset(), DOWNSTREAM);
2336 VisiblePosition RenderObject::positionForPoint(const IntPoint& point)
2338 return positionForCoordinates(point.x(), point.y());
2341 void RenderObject::updateDragState(bool dragOn)
2343 bool valueChanged = (dragOn != m_isDragging);
2344 m_isDragging = dragOn;
2345 if (valueChanged && style()->affectedByDragRules())
2346 element()->setChanged();
2347 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
2348 curr->updateDragState(dragOn);
2351 bool RenderObject::hitTest(const HitTestRequest& request, HitTestResult& result, const IntPoint& point, int tx, int ty, HitTestFilter hitTestFilter)
2353 bool inside = false;
2354 if (hitTestFilter != HitTestSelf) {
2355 // First test the foreground layer (lines and inlines).
2356 inside = nodeAtPoint(request, result, point.x(), point.y(), tx, ty, HitTestForeground);
2358 // Test floats next.
2360 inside = nodeAtPoint(request, result, point.x(), point.y(), tx, ty, HitTestFloat);
2362 // Finally test to see if the mouse is in the background (within a child block's background).
2364 inside = nodeAtPoint(request, result, point.x(), point.y(), tx, ty, HitTestChildBlockBackgrounds);
2367 // See if the mouse is inside us but not any of our descendants
2368 if (hitTestFilter != HitTestDescendants && !inside)
2369 inside = nodeAtPoint(request, result, point.x(), point.y(), tx, ty, HitTestBlockBackground);
2374 void RenderObject::updateHitTestResult(HitTestResult& result, const IntPoint& point)
2376 if (result.innerNode())
2379 Node* node = element();
2381 result.setInnerNode(node);
2382 if (!result.innerNonSharedNode())
2383 result.setInnerNonSharedNode(node);
2384 result.setLocalPoint(point);
2388 bool RenderObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, int /*x*/, int /*y*/, int /*tx*/, int /*ty*/, HitTestAction)
2393 int RenderObject::verticalPositionHint(bool firstLine) const
2395 if (firstLine) // We're only really a first-line style if the document actually uses first-line rules.
2396 firstLine = document()->usesFirstLineRules();
2397 int vpos = m_verticalPosition;
2398 if (m_verticalPosition == PositionUndefined || firstLine) {
2399 vpos = getVerticalPosition(firstLine);
2401 m_verticalPosition = vpos;
2407 int RenderObject::getVerticalPosition(bool firstLine) const
2412 // This method determines the vertical position for inline elements.
2414 EVerticalAlign va = style()->verticalAlign();
2417 else if (va == BOTTOM)
2418 vpos = PositionBottom;
2420 bool checkParent = parent()->isInline() && !parent()->isInlineBlockOrInlineTable() && parent()->style()->verticalAlign() != TOP && parent()->style()->verticalAlign() != BOTTOM;
2421 vpos = checkParent ? parent()->verticalPositionHint(firstLine) : 0;
2422 // don't allow elements nested inside text-top to have a different valignment.
2426 const Font& f = parent()->style(firstLine)->font();
2427 int fontsize = f.pixelSize();
2430 vpos += fontsize / 5 + 1;
2431 else if (va == SUPER)
2432 vpos -= fontsize / 3 + 1;
2433 else if (va == TEXT_TOP)
2434 vpos += baselinePosition(firstLine) - f.ascent();
2435 else if (va == MIDDLE)
2436 vpos += -static_cast<int>(f.xHeight() / 2) - lineHeight(firstLine) / 2 + baselinePosition(firstLine);
2437 else if (va == TEXT_BOTTOM) {
2438 vpos += f.descent();
2440 vpos -= style(firstLine)->font().descent();
2441 } else if (va == BASELINE_MIDDLE)
2442 vpos += -lineHeight(firstLine) / 2 + baselinePosition(firstLine);
2443 else if (va == LENGTH)
2444 vpos -= style()->verticalAlignLength().calcValue(lineHeight(firstLine));
2450 int RenderObject::lineHeight(bool firstLine, bool /*isRootLineBox*/) const
2452 return style(firstLine)->computedLineHeight();
2455 int RenderObject::baselinePosition(bool firstLine, bool isRootLineBox) const
2457 const Font& f = style(firstLine)->font();
2458 return f.ascent() + (lineHeight(firstLine, isRootLineBox) - f.height()) / 2;
2461 void RenderObject::scheduleRelayout()
2463 if (isRenderView()) {
2464 FrameView* view = toRenderView(this)->frameView();
2466 view->scheduleRelayout();
2467 } else if (parent()) {
2468 FrameView* v = view() ? view()->frameView() : 0;
2470 v->scheduleRelayoutOfSubtree(this);
2474 void RenderObject::layout()
2476 ASSERT(needsLayout());
2477 RenderObject* child = firstChild();
2479 child->layoutIfNeeded();
2480 ASSERT(!child->needsLayout());
2481 child = child->nextSibling();
2483 setNeedsLayout(false);
2486 InlineBox* RenderObject::createInlineBox(bool, bool unusedIsRootLineBox, bool)
2488 ASSERT_UNUSED(unusedIsRootLineBox, !unusedIsRootLineBox);
2489 return new (renderArena()) InlineBox(this);
2492 void RenderObject::dirtyLineBoxes(bool, bool)
2496 InlineBox* RenderObject::inlineBoxWrapper() const
2501 void RenderObject::setInlineBoxWrapper(InlineBox*)
2505 void RenderObject::deleteLineBoxWrapper()
2509 RenderStyle* RenderObject::firstLineStyleSlowCase() const
2511 ASSERT(document()->usesFirstLineRules());
2513 RenderStyle* style = m_style.get();
2514 const RenderObject* renderer = isText() ? parent() : this;
2515 if (renderer->isBlockFlow()) {
2516 if (RenderBlock* firstLineBlock = renderer->firstLineBlock())
2517 style = firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style);
2518 } else if (!renderer->isAnonymous() && renderer->isRenderInline()) {
2519 RenderStyle* parentStyle = renderer->parent()->firstLineStyle();
2520 if (parentStyle != renderer->parent()->style()) {
2521 // A first-line style is in effect. Cache a first-line style for ourselves.
2522 style->setHasPseudoStyle(FIRST_LINE_INHERITED);
2523 style = renderer->getCachedPseudoStyle(FIRST_LINE_INHERITED, parentStyle);
2530 RenderStyle* RenderObject::getCachedPseudoStyle(PseudoId pseudo, RenderStyle* parentStyle) const
2532 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo))
2535 RenderStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo);
2539 RefPtr<RenderStyle> result = getUncachedPseudoStyle(pseudo, parentStyle);
2541 return style()->addCachedPseudoStyle(result.release());
2545 PassRefPtr<RenderStyle> RenderObject::getUncachedPseudoStyle(PseudoId pseudo, RenderStyle* parentStyle) const
2547 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo))
2551 parentStyle = style();
2553 Node* node = element();
2554 while (node && !node->isElementNode())
2555 node = node->parentNode();
2559 RefPtr<RenderStyle> result;
2560 if (pseudo == FIRST_LINE_INHERITED) {
2561 result = document()->styleSelector()->styleForElement(static_cast<Element*>(node), parentStyle, false);
2562 result->setStyleType(FIRST_LINE_INHERITED);
2564 result = document()->styleSelector()->pseudoStyleForElement(pseudo, static_cast<Element*>(node), parentStyle);
2565 return result.release();
2568 static Color decorationColor(RenderStyle* style)
2571 if (style->textStrokeWidth() > 0) {
2572 // Prefer stroke color if possible but not if it's fully transparent.
2573 result = style->textStrokeColor();
2574 if (!result.isValid())
2575 result = style->color();
2580 result = style->textFillColor();
2581 if (!result.isValid())
2582 result = style->color();
2586 void RenderObject::getTextDecorationColors(int decorations, Color& underline, Color& overline,
2587 Color& linethrough, bool quirksMode)
2589 RenderObject* curr = this;
2591 int currDecs = curr->style()->textDecoration();
2593 if (currDecs & UNDERLINE) {
2594 decorations &= ~UNDERLINE;
2595 underline = decorationColor(curr->style());
2597 if (currDecs & OVERLINE) {
2598 decorations &= ~OVERLINE;
2599 overline = decorationColor(curr->style());
2601 if (currDecs & LINE_THROUGH) {
2602 decorations &= ~LINE_THROUGH;
2603 linethrough = decorationColor(curr->style());
2606 curr = curr->parent();
2607 if (curr && curr->isRenderBlock() && toRenderBlock(curr)->inlineContinuation())
2608 curr = toRenderBlock(curr)->inlineContinuation();
2609 } while (curr && decorations && (!quirksMode || !curr->element() ||
2610 (!curr->element()->hasTagName(aTag) && !curr->element()->hasTagName(fontTag))));
2612 // If we bailed out, use the element we bailed out at (typically a <font> or <a> element).
2613 if (decorations && curr) {
2614 if (decorations & UNDERLINE)
2615 underline = decorationColor(curr->style());
2616 if (decorations & OVERLINE)
2617 overline = decorationColor(curr->style());
2618 if (decorations & LINE_THROUGH)
2619 linethrough = decorationColor(curr->style());
2623 void RenderObject::updateWidgetPosition()
2627 #if ENABLE(DASHBOARD_SUPPORT)
2628 void RenderObject::addDashboardRegions(Vector<DashboardRegionValue>& regions)
2630 // Convert the style regions to absolute coordinates.
2631 if (style()->visibility() != VISIBLE || !isBox())
2634 RenderBox* box = toRenderBox(this);
2636 const Vector<StyleDashboardRegion>& styleRegions = style()->dashboardRegions();
2637 unsigned i, count = styleRegions.size();
2638 for (i = 0; i < count; i++) {
2639 StyleDashboardRegion styleRegion = styleRegions[i];
2641 int w = box->width();
2642 int h = box->height();
2644 DashboardRegionValue region;
2645 region.label = styleRegion.label;
2646 region.bounds = IntRect(styleRegion.offset.left().value(),
2647 styleRegion.offset.top().value(),
2648 w - styleRegion.offset.left().value() - styleRegion.offset.right().value(),
2649 h - styleRegion.offset.top().value() - styleRegion.offset.bottom().value());
2650 region.type = styleRegion.type;
2652 region.clip = region.bounds;
2653 computeAbsoluteRepaintRect(region.clip);
2654 if (region.clip.height() < 0) {
2655 region.clip.setHeight(0);
2656 region.clip.setWidth(0);
2659 FloatPoint absPos = localToAbsolute();
2660 region.bounds.setX(absPos.x() + styleRegion.offset.left().value());
2661 region.bounds.setY(absPos.y() + styleRegion.offset.top().value());
2663 if (document()->frame()) {
2664 float pageScaleFactor = document()->frame()->page()->chrome()->scaleFactor();
2665 if (pageScaleFactor != 1.0f) {
2666 region.bounds.scale(pageScaleFactor);
2667 region.clip.scale(pageScaleFactor);
2671 regions.append(region);
2675 void RenderObject::collectDashboardRegions(Vector<DashboardRegionValue>& regions)
2677 // RenderTexts don't have their own style, they just use their parent's style,
2678 // so we don't want to include them.
2682 addDashboardRegions(regions);
2683 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
2684 curr->collectDashboardRegions(regions);
2688 bool RenderObject::avoidsFloats() const
2690 return isReplaced() || hasOverflowClip() || isHR();
2693 bool RenderObject::shrinkToAvoidFloats() const
2695 // FIXME: Technically we should be able to shrink replaced elements on a line, but this is difficult to accomplish, since this
2696 // involves doing a relayout during findNextLineBreak and somehow overriding the containingBlockWidth method to return the
2697 // current remaining width on a line.
2698 if (isInline() && !isHTMLMarquee() || !avoidsFloats())
2701 // All auto-width objects that avoid floats should always use lineWidth.
2702 return style()->width().isAuto();
2705 bool RenderObject::willRenderImage(CachedImage*)
2707 // Without visibility we won't render (and therefore don't care about animation).
2708 if (style()->visibility() != VISIBLE)
2711 // If we're not in a window (i.e., we're dormant from being put in the b/f cache or in a background tab)
2712 // then we don't want to render either.
2713 return !document()->inPageCache() && !document()->view()->isOffscreen();
2716 int RenderObject::maximalOutlineSize(PaintPhase p) const
2718 if (p != PaintPhaseOutline && p != PaintPhaseSelfOutline && p != PaintPhaseChildOutlines)
2720 return toRenderView(document()->renderer())->maximalOutlineSize();
2723 int RenderObject::caretMinOffset() const
2728 int RenderObject::caretMaxOffset() const
2731 return element() ? max(1U, element()->childNodeCount()) : 1;
2737 unsigned RenderObject::caretMaxRenderedOffset() const
2742 int RenderObject::previousOffset(int current) const
2747 int RenderObject::nextOffset(int current) const
2752 void RenderObject::adjustRectForOutlineAndShadow(IntRect& rect) const
2754 int outlineSize = outlineStyleForRepaint()->outlineSize();
2755 if (ShadowData* boxShadow = style()->boxShadow()) {
2757 int shadowRight = 0;
2759 int shadowBottom = 0;
2762 shadowLeft = min(boxShadow->x - boxShadow->blur - outlineSize, shadowLeft);
2763 shadowRight = max(boxShadow->x + boxShadow->blur + outlineSize, shadowRight);
2764 shadowTop = min(boxShadow->y - boxShadow->blur - outlineSize, shadowTop);
2765 shadowBottom = max(boxShadow->y + boxShadow->blur + outlineSize, shadowBottom);
2767 boxShadow = boxShadow->next;
2768 } while (boxShadow);
2770 rect.move(shadowLeft, shadowTop);
2771 rect.setWidth(rect.width() - shadowLeft + shadowRight);
2772 rect.setHeight(rect.height() - shadowTop + shadowBottom);
2774 rect.inflate(outlineSize);
2777 AnimationController* RenderObject::animation() const
2779 return document()->frame()->animation();
2782 void RenderObject::imageChanged(CachedImage* image, const IntRect* rect)
2784 imageChanged(static_cast<WrappedImagePtr>(image), rect);
2789 FloatRect RenderObject::relativeBBox(bool) const
2794 TransformationMatrix RenderObject::localTransform() const
2796 return TransformationMatrix();
2799 TransformationMatrix RenderObject::absoluteTransform() const
2802 return localTransform() * parent()->absoluteTransform();
2803 return localTransform();
2806 #endif // ENABLE(SVG)
2808 } // namespace WebCore
2812 void showTree(const WebCore::RenderObject* ro)
2815 ro->showTreeForThis();