Changeset 17677 in webkit


Ignore:
Timestamp:
Nov 8, 2006 7:55:58 PM (17 years ago)
Author:
weinig
Message:

Reviewed by Mitz.

Fix for http://bugs.webkit.org/show_bug.cgi?id=11506
Cleanup RenderObject

  • rendering/RenderObject.cpp: (WebCore::RenderObject::operator delete): (WebCore::RenderObject::createObject): (WebCore::RenderObjectCounter::~RenderObjectCounter): (WebCore::RenderObject::RenderObject): (WebCore::RenderObject::isDescendantOf): (WebCore::RenderObject::isRoot): (WebCore::RenderObject::addChild): (WebCore::RenderObject::removeChildNode): (WebCore::RenderObject::removeChild): (WebCore::RenderObject::appendChildNode): (WebCore::RenderObject::insertChildNode): (WebCore::RenderObject::nextInPreOrder): (WebCore::RenderObject::nextInPreOrderAfterChildren): (WebCore::RenderObject::previousInPreOrder): (WebCore::RenderObject::isEditable): (WebCore::RenderObject::nextEditable): (WebCore::RenderObject::previousEditable): (WebCore::RenderObject::firstLeafChild): (WebCore::RenderObject::lastLeafChild): (WebCore::RenderObject::addLayers): (WebCore::RenderObject::removeLayers): (WebCore::RenderObject::moveLayers): (WebCore::RenderObject::findNextLayer): (WebCore::RenderObject::enclosingLayer): (WebCore::RenderObject::updateFirstLetter): (WebCore::RenderObject::offsetParent): (WebCore::RenderObject::scroll): (WebCore::RenderObject::hasStaticX): (WebCore::RenderObject::setNeedsLayout): (WebCore::RenderObject::setChildNeedsLayout): (WebCore::RenderObject::markContainingBlocksForLayout): (WebCore::RenderObject::containingBlock): (WebCore::RenderObject::containingBlockWidth): (WebCore::RenderObject::containingBlockHeight): (WebCore::RenderObject::mustRepaintBackgroundOrBorder): (WebCore::RenderObject::drawBorderArc): (WebCore::RenderObject::drawBorder): (WebCore::RenderObject::paintBorderImage): (WebCore::RenderObject::paintBorder): (WebCore::RenderObject::absoluteRects): (WebCore::RenderObject::addPDFURLRect): (WebCore::RenderObject::addFocusRingRects): (WebCore::RenderObject::paintOutline): (WebCore::RenderObject::repaint): (WebCore::RenderObject::repaintRectangle): (WebCore::RenderObject::repaintAfterLayoutIfNeeded): (WebCore::RenderObject::repaintObjectsBeforeLayout): (WebCore::RenderObject::getAbsoluteRepaintRectWithOutline): (WebCore::RenderObject::information): (WebCore::RenderObject::dump): (WebCore::selectStartNode): (WebCore::RenderObject::shouldSelect): (WebCore::RenderObject::draggableNode): (WebCore::RenderObject::createAnonymousBlock): (WebCore::RenderObject::handleDynamicFloatPositionChange): (WebCore::RenderObject::setStyle): (WebCore::RenderObject::setStyleInternal): (WebCore::RenderObject::updateBackgroundImages): (WebCore::RenderObject::absolutePosition): (WebCore::RenderObject::caretRect): (WebCore::RenderObject::paddingTop): (WebCore::RenderObject::paddingBottom): (WebCore::RenderObject::paddingLeft): (WebCore::RenderObject::paddingRight): (WebCore::RenderObject::tabWidth): (WebCore::RenderObject::container): (WebCore::RenderObject::removeFromObjectLists): (WebCore::RenderObject::destroy): (WebCore::RenderObject::arenaDelete): (WebCore::RenderObject::hitTest): (WebCore::RenderObject::setInnerNode): (WebCore::RenderObject::nodeAtPoint): (WebCore::RenderObject::verticalPositionHint): (WebCore::RenderObject::getVerticalPosition): (WebCore::RenderObject::lineHeight): (WebCore::RenderObject::invalidateVerticalPositions): (WebCore::RenderObject::recalcMinMaxWidths): (WebCore::RenderObject::scheduleRelayout): (WebCore::RenderObject::setInlineBoxWrapper): (WebCore::RenderObject::firstLineStyle): (WebCore::RenderObject::getPseudoStyle): (WebCore::RenderObject::getTextDecorationColors): (WebCore::RenderObject::addDashboardRegions): (WebCore::RenderObject::collectDashboardRegions): (WebCore::RenderObject::avoidsFloats): (WebCore::RenderObject::findCounter): (WebCore::RenderObject::backslashAsCurrencySymbol): (WebCore::RenderObject::imageChanged): (WebCore::RenderObject::previousOffset): (WebCore::RenderObject::nextOffset): (WebCore::RenderObject::inlineBox):
  • rendering/RenderObject.h: (WebCore::): (WebCore::RenderObject::renderName): (WebCore::RenderObject::parent): (WebCore::RenderObject::previousSibling): (WebCore::RenderObject::nextSibling): (WebCore::RenderObject::firstChild): (WebCore::RenderObject::lastChild): (WebCore::RenderObject::getOverflowClipRect): (WebCore::RenderObject::getClipRect): (WebCore::RenderObject::getBaselineOfFirstLineBox): (WebCore::RenderObject::setEdited): (WebCore::RenderObject::setStaticX): (WebCore::RenderObject::setStaticY): (WebCore::RenderObject::setPreviousSibling): (WebCore::RenderObject::setNextSibling): (WebCore::RenderObject::setParent): (WebCore::RenderObject::isInlineBlockOrInlineTable): (WebCore::RenderObject::isRenderView): (WebCore::RenderObject::childrenInline): (WebCore::RenderObject::setChildrenInline): (WebCore::RenderObject::isAnonymousBlock): (WebCore::RenderObject::isDragging): (WebCore::RenderObject::needsLayout): (WebCore::RenderObject::setMinMaxKnown): (WebCore::RenderObject::setNeedsLayoutAndMinMaxRecalc): (WebCore::RenderObject::setPositioned): (WebCore::RenderObject::setRelPositioned): (WebCore::RenderObject::setFloating): (WebCore::RenderObject::setInline): (WebCore::RenderObject::setShouldPaintBackgroundOrBorder): (WebCore::RenderObject::setReplaced): (WebCore::RenderObject::PaintInfo::PaintInfo): (WebCore::RenderObject::paintBackgroundExtended): (WebCore::RenderObject::calcWidth): (WebCore::RenderObject::updateFromElement): (WebCore::RenderObject::RepaintInfo::RepaintInfo): (WebCore::RenderObject::setOverrideSize): (WebCore::RenderObject::setPos): (WebCore::RenderObject::setWidth): (WebCore::RenderObject::setHeight): (WebCore::RenderObject::absolutePositionForContent): (WebCore::RenderObject::overflowHeight): (WebCore::RenderObject::overflowWidth): (WebCore::RenderObject::setOverflowHeight): (WebCore::RenderObject::setOverflowWidth): (WebCore::RenderObject::overflowLeft): (WebCore::RenderObject::overflowTop): (WebCore::RenderObject::overflowRect): (WebCore::RenderObject::stopAutoscroll): (WebCore::RenderObject::collapsedMarginTop): (WebCore::RenderObject::collapsedMarginBottom): (WebCore::RenderObject::maxTopMargin): (WebCore::RenderObject::maxBottomMargin): (WebCore::RenderObject::): (WebCore::RenderObject::setTable): (WebCore::RenderObject::isFloatingOrPositioned): (WebCore::RenderObject::containsFloat): (WebCore::RenderObject::setSelectionState): (WebCore::RenderObject::SelectionInfo::SelectionInfo): (WebCore::RenderObject::lowestPosition): (WebCore::RenderObject::rightmostPosition): (WebCore::RenderObject::leftmostPosition): (WebCore::RenderObject::calcVerticalMargins): (WebCore::RenderObject::font):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r17674 r17677  
     12006-11-08  Sam Weinig  <sam.weinig@gmail.com>
     2
     3        Reviewed by Mitz.
     4
     5        Fix for http://bugs.webkit.org/show_bug.cgi?id=11506
     6        Cleanup RenderObject
     7
     8        * rendering/RenderObject.cpp:
     9        (WebCore::RenderObject::operator delete):
     10        (WebCore::RenderObject::createObject):
     11        (WebCore::RenderObjectCounter::~RenderObjectCounter):
     12        (WebCore::RenderObject::RenderObject):
     13        (WebCore::RenderObject::isDescendantOf):
     14        (WebCore::RenderObject::isRoot):
     15        (WebCore::RenderObject::addChild):
     16        (WebCore::RenderObject::removeChildNode):
     17        (WebCore::RenderObject::removeChild):
     18        (WebCore::RenderObject::appendChildNode):
     19        (WebCore::RenderObject::insertChildNode):
     20        (WebCore::RenderObject::nextInPreOrder):
     21        (WebCore::RenderObject::nextInPreOrderAfterChildren):
     22        (WebCore::RenderObject::previousInPreOrder):
     23        (WebCore::RenderObject::isEditable):
     24        (WebCore::RenderObject::nextEditable):
     25        (WebCore::RenderObject::previousEditable):
     26        (WebCore::RenderObject::firstLeafChild):
     27        (WebCore::RenderObject::lastLeafChild):
     28        (WebCore::RenderObject::addLayers):
     29        (WebCore::RenderObject::removeLayers):
     30        (WebCore::RenderObject::moveLayers):
     31        (WebCore::RenderObject::findNextLayer):
     32        (WebCore::RenderObject::enclosingLayer):
     33        (WebCore::RenderObject::updateFirstLetter):
     34        (WebCore::RenderObject::offsetParent):
     35        (WebCore::RenderObject::scroll):
     36        (WebCore::RenderObject::hasStaticX):
     37        (WebCore::RenderObject::setNeedsLayout):
     38        (WebCore::RenderObject::setChildNeedsLayout):
     39        (WebCore::RenderObject::markContainingBlocksForLayout):
     40        (WebCore::RenderObject::containingBlock):
     41        (WebCore::RenderObject::containingBlockWidth):
     42        (WebCore::RenderObject::containingBlockHeight):
     43        (WebCore::RenderObject::mustRepaintBackgroundOrBorder):
     44        (WebCore::RenderObject::drawBorderArc):
     45        (WebCore::RenderObject::drawBorder):
     46        (WebCore::RenderObject::paintBorderImage):
     47        (WebCore::RenderObject::paintBorder):
     48        (WebCore::RenderObject::absoluteRects):
     49        (WebCore::RenderObject::addPDFURLRect):
     50        (WebCore::RenderObject::addFocusRingRects):
     51        (WebCore::RenderObject::paintOutline):
     52        (WebCore::RenderObject::repaint):
     53        (WebCore::RenderObject::repaintRectangle):
     54        (WebCore::RenderObject::repaintAfterLayoutIfNeeded):
     55        (WebCore::RenderObject::repaintObjectsBeforeLayout):
     56        (WebCore::RenderObject::getAbsoluteRepaintRectWithOutline):
     57        (WebCore::RenderObject::information):
     58        (WebCore::RenderObject::dump):
     59        (WebCore::selectStartNode):
     60        (WebCore::RenderObject::shouldSelect):
     61        (WebCore::RenderObject::draggableNode):
     62        (WebCore::RenderObject::createAnonymousBlock):
     63        (WebCore::RenderObject::handleDynamicFloatPositionChange):
     64        (WebCore::RenderObject::setStyle):
     65        (WebCore::RenderObject::setStyleInternal):
     66        (WebCore::RenderObject::updateBackgroundImages):
     67        (WebCore::RenderObject::absolutePosition):
     68        (WebCore::RenderObject::caretRect):
     69        (WebCore::RenderObject::paddingTop):
     70        (WebCore::RenderObject::paddingBottom):
     71        (WebCore::RenderObject::paddingLeft):
     72        (WebCore::RenderObject::paddingRight):
     73        (WebCore::RenderObject::tabWidth):
     74        (WebCore::RenderObject::container):
     75        (WebCore::RenderObject::removeFromObjectLists):
     76        (WebCore::RenderObject::destroy):
     77        (WebCore::RenderObject::arenaDelete):
     78        (WebCore::RenderObject::hitTest):
     79        (WebCore::RenderObject::setInnerNode):
     80        (WebCore::RenderObject::nodeAtPoint):
     81        (WebCore::RenderObject::verticalPositionHint):
     82        (WebCore::RenderObject::getVerticalPosition):
     83        (WebCore::RenderObject::lineHeight):
     84        (WebCore::RenderObject::invalidateVerticalPositions):
     85        (WebCore::RenderObject::recalcMinMaxWidths):
     86        (WebCore::RenderObject::scheduleRelayout):
     87        (WebCore::RenderObject::setInlineBoxWrapper):
     88        (WebCore::RenderObject::firstLineStyle):
     89        (WebCore::RenderObject::getPseudoStyle):
     90        (WebCore::RenderObject::getTextDecorationColors):
     91        (WebCore::RenderObject::addDashboardRegions):
     92        (WebCore::RenderObject::collectDashboardRegions):
     93        (WebCore::RenderObject::avoidsFloats):
     94        (WebCore::RenderObject::findCounter):
     95        (WebCore::RenderObject::backslashAsCurrencySymbol):
     96        (WebCore::RenderObject::imageChanged):
     97        (WebCore::RenderObject::previousOffset):
     98        (WebCore::RenderObject::nextOffset):
     99        (WebCore::RenderObject::inlineBox):
     100        * rendering/RenderObject.h:
     101        (WebCore::):
     102        (WebCore::RenderObject::renderName):
     103        (WebCore::RenderObject::parent):
     104        (WebCore::RenderObject::previousSibling):
     105        (WebCore::RenderObject::nextSibling):
     106        (WebCore::RenderObject::firstChild):
     107        (WebCore::RenderObject::lastChild):
     108        (WebCore::RenderObject::getOverflowClipRect):
     109        (WebCore::RenderObject::getClipRect):
     110        (WebCore::RenderObject::getBaselineOfFirstLineBox):
     111        (WebCore::RenderObject::setEdited):
     112        (WebCore::RenderObject::setStaticX):
     113        (WebCore::RenderObject::setStaticY):
     114        (WebCore::RenderObject::setPreviousSibling):
     115        (WebCore::RenderObject::setNextSibling):
     116        (WebCore::RenderObject::setParent):
     117        (WebCore::RenderObject::isInlineBlockOrInlineTable):
     118        (WebCore::RenderObject::isRenderView):
     119        (WebCore::RenderObject::childrenInline):
     120        (WebCore::RenderObject::setChildrenInline):
     121        (WebCore::RenderObject::isAnonymousBlock):
     122        (WebCore::RenderObject::isDragging):
     123        (WebCore::RenderObject::needsLayout):
     124        (WebCore::RenderObject::setMinMaxKnown):
     125        (WebCore::RenderObject::setNeedsLayoutAndMinMaxRecalc):
     126        (WebCore::RenderObject::setPositioned):
     127        (WebCore::RenderObject::setRelPositioned):
     128        (WebCore::RenderObject::setFloating):
     129        (WebCore::RenderObject::setInline):
     130        (WebCore::RenderObject::setShouldPaintBackgroundOrBorder):
     131        (WebCore::RenderObject::setReplaced):
     132        (WebCore::RenderObject::PaintInfo::PaintInfo):
     133        (WebCore::RenderObject::paintBackgroundExtended):
     134        (WebCore::RenderObject::calcWidth):
     135        (WebCore::RenderObject::updateFromElement):
     136        (WebCore::RenderObject::RepaintInfo::RepaintInfo):
     137        (WebCore::RenderObject::setOverrideSize):
     138        (WebCore::RenderObject::setPos):
     139        (WebCore::RenderObject::setWidth):
     140        (WebCore::RenderObject::setHeight):
     141        (WebCore::RenderObject::absolutePositionForContent):
     142        (WebCore::RenderObject::overflowHeight):
     143        (WebCore::RenderObject::overflowWidth):
     144        (WebCore::RenderObject::setOverflowHeight):
     145        (WebCore::RenderObject::setOverflowWidth):
     146        (WebCore::RenderObject::overflowLeft):
     147        (WebCore::RenderObject::overflowTop):
     148        (WebCore::RenderObject::overflowRect):
     149        (WebCore::RenderObject::stopAutoscroll):
     150        (WebCore::RenderObject::collapsedMarginTop):
     151        (WebCore::RenderObject::collapsedMarginBottom):
     152        (WebCore::RenderObject::maxTopMargin):
     153        (WebCore::RenderObject::maxBottomMargin):
     154        (WebCore::RenderObject::):
     155        (WebCore::RenderObject::setTable):
     156        (WebCore::RenderObject::isFloatingOrPositioned):
     157        (WebCore::RenderObject::containsFloat):
     158        (WebCore::RenderObject::setSelectionState):
     159        (WebCore::RenderObject::SelectionInfo::SelectionInfo):
     160        (WebCore::RenderObject::lowestPosition):
     161        (WebCore::RenderObject::rightmostPosition):
     162        (WebCore::RenderObject::leftmostPosition):
     163        (WebCore::RenderObject::calcVerticalMargins):
     164        (WebCore::RenderObject::font):
     165
    11662006-11-08  Darin Adler  <darin@apple.com>
    2167
  • trunk/WebCore/rendering/RenderObject.cpp

    r17667 r17677  
    2828#include "RenderObject.h"
    2929
    30 #include "AXObjectCache.h" 
     30#include "AXObjectCache.h"
    3131#include "AffineTransform.h"
    3232#include "CachedImage.h"
     
    3434#include "CounterNode.h"
    3535#include "CounterResetNode.h"
    36 #include "TextResourceDecoder.h"
    3736#include "Document.h"
    3837#include "Element.h"
     
    4443#include "HTMLNames.h"
    4544#include "HTMLOListElement.h"
    46 #include "KURL.h"
    4745#include "HitTestRequest.h"
    4846#include "HitTestResult.h"
     47#include "KURL.h"
    4948#include "Page.h"
    5049#include "Position.h"
     
    6160#include "RenderView.h"
    6261#include "Screen.h"
     62#include "TextResourceDecoder.h"
    6363#include "TextStream.h"
    6464#include "cssstyleselector.h"
     
    7373
    7474#ifndef NDEBUG
    75 static void *baseOfRenderObjectBeingDeleted;
     75static void* baseOfRenderObjectBeingDeleted;
    7676#endif
    7777
     
    9393{
    9494    ASSERT(baseOfRenderObjectBeingDeleted == ptr);
    95    
     95
    9696    // Stash size where destroy can find it.
    9797    *(size_t *)ptr = sz;
    9898}
    9999
    100 RenderObject *RenderObject::createObject(Node* node, RenderStyle* style)
    101 {
    102     RenderObject *o = 0;
     100RenderObject* RenderObject::createObject(Node* node, RenderStyle* style)
     101{
     102    RenderObject* o = 0;
    103103    RenderArena* arena = node->document()->renderArena();
    104    
    105     if (ContentData *contentData = style->contentData()) {
    106         RenderImage *contentImage = new (arena) RenderImage(node);
     104
     105    if (ContentData* contentData = style->contentData()) {
     106        RenderImage* contentImage = new (arena) RenderImage(node);
    107107        if (contentImage) {
    108108            contentImage->setStyle(style);
     
    113113    }
    114114
    115     switch(style->display())
    116     {
    117     case NONE:
    118         break;
    119     case INLINE:
    120         o = new (arena) RenderInline(node);
    121         break;
    122     case BLOCK:
    123         o = new (arena) RenderBlock(node);
    124         break;
    125     case INLINE_BLOCK:
    126         o = new (arena) RenderBlock(node);
    127         break;
    128     case LIST_ITEM:
    129         o = new (arena) RenderListItem(node);
    130         break;
    131     case RUN_IN:
    132     case COMPACT:
    133         o = new (arena) RenderBlock(node);
    134         break;
    135     case TABLE:
    136     case INLINE_TABLE:
    137         o = new (arena) RenderTable(node);
    138         break;
    139     case TABLE_ROW_GROUP:
    140     case TABLE_HEADER_GROUP:
    141     case TABLE_FOOTER_GROUP:
    142         o = new (arena) RenderTableSection(node);
    143         break;
    144     case TABLE_ROW:
    145         o = new (arena) RenderTableRow(node);
    146         break;
    147     case TABLE_COLUMN_GROUP:
    148     case TABLE_COLUMN:
    149         o = new (arena) RenderTableCol(node);
    150         break;
    151     case TABLE_CELL:
    152         o = new (arena) RenderTableCell(node);
    153         break;
    154     case TABLE_CAPTION:
    155         o = new (arena) RenderBlock(node);
    156         break;
    157     case BOX:
    158     case INLINE_BOX:
    159         o = new (arena) RenderFlexibleBox(node);
    160         break;
     115    switch (style->display()) {
     116        case NONE:
     117            break;
     118        case INLINE:
     119            o = new (arena) RenderInline(node);
     120            break;
     121        case BLOCK:
     122            o = new (arena) RenderBlock(node);
     123            break;
     124        case INLINE_BLOCK:
     125            o = new (arena) RenderBlock(node);
     126            break;
     127        case LIST_ITEM:
     128            o = new (arena) RenderListItem(node);
     129            break;
     130        case RUN_IN:
     131        case COMPACT:
     132            o = new (arena) RenderBlock(node);
     133            break;
     134        case TABLE:
     135        case INLINE_TABLE:
     136            o = new (arena) RenderTable(node);
     137            break;
     138        case TABLE_ROW_GROUP:
     139        case TABLE_HEADER_GROUP:
     140        case TABLE_FOOTER_GROUP:
     141            o = new (arena) RenderTableSection(node);
     142            break;
     143        case TABLE_ROW:
     144            o = new (arena) RenderTableRow(node);
     145            break;
     146        case TABLE_COLUMN_GROUP:
     147        case TABLE_COLUMN:
     148            o = new (arena) RenderTableCol(node);
     149            break;
     150        case TABLE_CELL:
     151            o = new (arena) RenderTableCell(node);
     152            break;
     153        case TABLE_CAPTION:
     154            o = new (arena) RenderBlock(node);
     155            break;
     156        case BOX:
     157        case INLINE_BOX:
     158            o = new (arena) RenderFlexibleBox(node);
     159            break;
    161160    }
    162161    return o;
     
    164163
    165164#ifndef NDEBUG
    166 struct RenderObjectCounter { 
    167     static int count; 
    168     ~RenderObjectCounter() { if (count != 0) fprintf(stderr, "LEAK: %d RenderObject\n", count); } 
     165struct RenderObjectCounter {
     166    static int count;
     167    ~RenderObjectCounter() { if (count != 0) fprintf(stderr, "LEAK: %d RenderObject\n", count); }
    169168};
    170169int RenderObjectCounter::count;
     
    173172
    174173RenderObject::RenderObject(Node* node)
    175     : CachedResourceClient(),
    176 m_style( 0 ),
    177 m_node( node ),
    178 m_parent( 0 ),
    179 m_previous( 0 ),
    180 m_next( 0 ),
    181 m_verticalPosition( PositionUndefined ),
    182 m_needsLayout( false ),
    183 m_normalChildNeedsLayout( false ),
    184 m_posChildNeedsLayout( false ),
    185 m_minMaxKnown( false ),
    186 m_floating( false ),
    187 
    188 m_positioned( false ),
    189 m_relPositioned( false ),
    190 m_paintBackground( false ),
    191 
    192 m_isAnonymous( node == node->document() ),
    193 m_recalcMinMax( false ),
    194 m_isText( false ),
    195 m_inline( true ),
    196 
    197 m_replaced( false ),
    198 m_isDragging( false ),
    199 m_hasOverflowClip(false),
    200 m_hasCounterNodeMap(false)
     174    : CachedResourceClient()
     175    , m_style(0)
     176    , m_node(node)
     177    , m_parent(0)
     178    , m_previous(0)
     179    , m_next(0)
     180    , m_verticalPosition(PositionUndefined)
     181    , m_needsLayout(false)
     182    , m_normalChildNeedsLayout(false)
     183    , m_posChildNeedsLayout(false)
     184    , m_minMaxKnown(false)
     185    , m_floating(false)
     186    , m_positioned(false)
     187    , m_relPositioned(false)
     188    , m_paintBackground(false)
     189    , m_isAnonymous(node == node->document())
     190    , m_recalcMinMax(false)
     191    , m_isText(false)
     192    , m_inline(true)
     193    , m_replaced(false)
     194    , m_isDragging(false)
     195    , m_hasOverflowClip(false)
     196    , m_hasCounterNodeMap(false)
    201197{
    202198#ifndef NDEBUG
     
    212208}
    213209
    214 bool RenderObject::isDescendantOf(const RenderObject *obj) const
    215 {
    216     for (const RenderObject *r = this; r; r = r->m_parent)
     210bool RenderObject::isDescendantOf(const RenderObject* obj) const
     211{
     212    for (const RenderObject* r = this; r; r = r->m_parent) {
    217213        if (r == obj)
    218214            return true;
     215    }
    219216    return false;
    220217}
     
    222219bool RenderObject::isRoot() const
    223220{
    224     return element() && element()->renderer() == this &&
    225            element()->document()->documentElement() == element();
     221    return element() && element()->renderer() == this && element()->document()->documentElement() == element();
    226222}
    227223
     
    256252}
    257253
    258 void RenderObject::addChild(RenderObject* , RenderObject *)
    259 {
    260     ASSERT(0);
    261 }
    262 
    263 RenderObject* RenderObject::removeChildNode(RenderObject* )
    264 {
    265     ASSERT(0);
     254void RenderObject::addChild(RenderObject*, RenderObject*)
     255{
     256    ASSERT_NOT_REACHED();
     257}
     258
     259RenderObject* RenderObject::removeChildNode(RenderObject*)
     260{
     261    ASSERT_NOT_REACHED();
    266262    return 0;
    267263}
    268264
    269 void RenderObject::removeChild(RenderObject* )
    270 {
    271     ASSERT(0);
     265void RenderObject::removeChild(RenderObject*)
     266{
     267    ASSERT_NOT_REACHED();
    272268}
    273269
    274270void RenderObject::appendChildNode(RenderObject*)
    275271{
    276     ASSERT(0);
     272    ASSERT_NOT_REACHED();
    277273}
    278274
    279275void RenderObject::insertChildNode(RenderObject*, RenderObject*)
    280276{
    281     ASSERT(0);
    282 }
    283 
    284 RenderObject *RenderObject::nextInPreOrder() const
     277    ASSERT_NOT_REACHED();
     278}
     279
     280RenderObject* RenderObject::nextInPreOrder() const
    285281{
    286282    if (RenderObject* o = firstChild())
    287283        return o;
    288        
     284
    289285    return nextInPreOrderAfterChildren();
    290286}
     
    300296            o = o->nextSibling();
    301297    }
     298
    302299    return o;
    303300}
    304301
    305 RenderObject *RenderObject::previousInPreOrder() const
     302RenderObject* RenderObject::previousInPreOrder() const
    306303{
    307304    if (RenderObject* o = previousSibling()) {
     
    324321bool RenderObject::isEditable() const
    325322{
    326     RenderText *textRenderer = 0;
    327     if (isText()) {
    328         textRenderer = static_cast<RenderText *>(const_cast<RenderObject *>(this));
    329     }
    330 
    331     return style()->visibility() == VISIBLE &&
     323    RenderText* textRenderer = 0;
     324    if (isText())
     325        textRenderer = static_cast<RenderText*>(const_cast<RenderObject*>(this));
     326
     327    return style()->visibility() == VISIBLE &&
    332328        element() && element()->isContentEditable() &&
    333         ((isBlockFlow() && !firstChild()) || 
    334         isReplaced() || 
    335         isBR() || 
     329        ((isBlockFlow() && !firstChild()) ||
     330        isReplaced() ||
     331        isBR() ||
    336332        (textRenderer && textRenderer->firstTextBox()));
    337333}
    338334
    339 RenderObject *RenderObject::nextEditable() const
    340 {
    341     RenderObject *r = const_cast<RenderObject *>(this);
    342     RenderObject *n = firstChild();
     335RenderObject* RenderObject::nextEditable() const
     336{
     337    RenderObject* r = const_cast<RenderObject*>(this);
     338    RenderObject* n = firstChild();
    343339    if (n) {
    344         while (n) { 
    345             r = n; 
    346             n = n->firstChild(); 
     340        while (n) {
     341            r = n;
     342            n = n->firstChild();
    347343        }
    348344        if (r->isEditable())
    349345            return r;
    350         else 
     346        else
    351347            return r->nextEditable();
    352348    }
     
    354350    if (n) {
    355351        r = n;
    356         while (n) { 
    357             r = n; 
    358             n = n->firstChild(); 
     352        while (n) {
     353            r = n;
     354            n = n->firstChild();
    359355        }
    360356        if (r->isEditable())
    361357            return r;
    362         else 
     358        else
    363359            return r->nextEditable();
    364360    }
     
    370366            r = n;
    371367            n = r->firstChild();
    372             while (n) { 
    373                 r = n; 
    374                 n = n->firstChild(); 
     368            while (n) {
     369                r = n;
     370                n = n->firstChild();
    375371            }
    376372            if (r->isEditable())
    377373                return r;
    378             else 
     374            else
    379375                return r->nextEditable();
    380376        }
    381377        n = r->parent();
    382378    }
     379
    383380    return 0;
    384381}
    385382
    386 RenderObject *RenderObject::previousEditable() const
    387 {
    388     RenderObject *r = const_cast<RenderObject *>(this);
    389     RenderObject *n = firstChild();
     383RenderObject* RenderObject::previousEditable() const
     384{
     385    RenderObject* r = const_cast<RenderObject*>(this);
     386    RenderObject* n = firstChild();
    390387    if (n) {
    391         while (n) { 
    392             r = n; 
    393             n = n->lastChild(); 
     388        while (n) {
     389            r = n;
     390            n = n->lastChild();
    394391        }
    395392        if (r->isEditable())
    396393            return r;
    397         else 
     394        else
    398395            return r->previousEditable();
    399396    }
     
    401398    if (n) {
    402399        r = n;
    403         while (n) { 
    404             r = n; 
    405             n = n->lastChild(); 
     400        while (n) {
     401            r = n;
     402            n = n->lastChild();
    406403        }
    407404        if (r->isEditable())
    408405            return r;
    409         else 
     406        else
    410407            return r->previousEditable();
    411     }   
     408    }
    412409    n = r->parent();
    413410    while (n) {
     
    417414            r = n;
    418415            n = r->lastChild();
    419             while (n) { 
    420                 r = n; 
    421                 n = n->lastChild(); 
     416            while (n) {
     417                r = n;
     418                n = n->lastChild();
    422419            }
    423420            if (r->isEditable())
    424421                return r;
    425             else 
     422            else
    426423                return r->previousEditable();
    427424        }
    428425        n = r->parent();
    429426    }
     427
    430428    return 0;
    431 } 
    432 
    433 RenderObject *RenderObject::firstLeafChild() const
    434 {
    435     RenderObject *r = firstChild();
     429}
     430
     431RenderObject* RenderObject::firstLeafChild() const
     432{
     433    RenderObject* r = firstChild();
    436434    while (r) {
    437         RenderObject *n = 0;
     435        RenderObject* n = 0;
    438436        n = r->firstChild();
    439437        if (!n)
     
    444442}
    445443
    446 RenderObject *RenderObject::lastLeafChild() const
    447 {
    448     RenderObject *r = lastChild();
     444RenderObject* RenderObject::lastLeafChild() const
     445{
     446    RenderObject* r = lastChild();
    449447    while (r) {
    450         RenderObject *n = 0;
     448        RenderObject* n = 0;
    451449        n = r->lastChild();
    452450        if (!n)
     
    480478    if (!parentLayer)
    481479        return;
    482    
     480
    483481    RenderObject* object = newObject;
    484482    RenderLayer* beforeChild = 0;
     
    490488    if (!parentLayer)
    491489        return;
    492    
     490
    493491    if (layer()) {
    494492        parentLayer->removeChild(layer());
     
    504502    if (!newParent)
    505503        return;
    506    
     504
    507505    if (layer()) {
    508506        if (oldParent)
     
    522520    if (!parentLayer)
    523521        return 0;
    524    
     522
    525523    // Step 1: If our layer is a child of the desired parent, then return our layer.
    526524    RenderLayer* ourLayer = layer();
    527525    if (ourLayer && ourLayer->parent() == parentLayer)
    528526        return ourLayer;
    529    
     527
    530528    // Step 2: If we don't have a layer, or our layer is the desired parent, then descend
    531529    // into our siblings trying to find the next layer whose parent is the desired parent.
     
    538536        }
    539537    }
    540    
     538
    541539    // Step 3: If our layer is the desired parent layer, then we're finished.  We didn't
    542540    // find anything.
    543541    if (parentLayer == ourLayer)
    544542        return 0;
    545    
     543
    546544    // Step 4: If |checkParent| is set, climb up to our parent and check its siblings that
    547545    // follow us to see if we can locate a layer.
    548546    if (checkParent && parent())
    549547        return parent()->findNextLayer(parentLayer, this, true);
    550    
     548
    551549    return 0;
    552550}
    553    
     551
    554552RenderLayer* RenderObject::enclosingLayer() const
    555553{
    556554    const RenderObject* curr = this;
    557555    while (curr) {
    558         RenderLayer *layer = curr->layer();
     556        RenderLayer* layer = curr->layer();
    559557        if (layer)
    560558            return layer;
     
    575573
    576574void RenderObject::updateFirstLetter()
    577 {}
     575{
     576}
    578577
    579578int RenderObject::offsetLeft() const
     
    613612    return y;
    614613}
    615    
     614
    616615RenderObject* RenderObject::offsetParent() const
    617616{
     
    619618    if (isBody())
    620619        return 0;
     620
    621621    bool skipTables = isPositioned() || isRelPositioned();
    622622    RenderObject* curr = parent();
    623     while (curr && (!curr->element() || 
    624                     (!curr->isPositioned() && !curr->isRelPositioned() && 
     623    while (curr && (!curr->element() ||
     624                    (!curr->isPositioned() && !curr->isRelPositioned() &&
    625625                        !(!style()->htmlHacks() && skipTables ? curr->isRoot() : curr->isBody())))) {
    626626        if (!skipTables && curr->element() && (curr->isTableCell() || curr->isTable()))
     
    681681bool RenderObject::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
    682682{
    683     RenderLayer *l = layer();
     683    RenderLayer* l = layer();
    684684    if (l && l->scroll(direction, granularity, multiplier))
    685685        return true;
    686     RenderBlock *b = containingBlock();
     686    RenderBlock* b = containingBlock();
    687687    if (b && !b->isRenderView())
    688688        return b->scroll(direction, granularity, multiplier);
     
    703703bool RenderObject::hasStaticX() const
    704704{
    705     return (style()->left().isAuto() && style()->right().isAuto()) ||
    706             style()->left().isStatic() ||
    707             style()->right().isStatic();
     705    return (style()->left().isAuto() && style()->right().isAuto()) || style()->left().isStatic() || style()->right().isStatic();
    708706}
    709707
     
    717715}
    718716
    719 void RenderObject::setNeedsLayout(bool b, bool markParents) 
     717void RenderObject::setNeedsLayout(bool b, bool markParents)
    720718{
    721719    bool alreadyNeededLayout = m_needsLayout;
     
    724722        if (!alreadyNeededLayout && markParents)
    725723            markContainingBlocksForLayout();
    726     }
    727     else {
     724    } else {
    728725        m_posChildNeedsLayout = false;
    729726        m_normalChildNeedsLayout = false;
     
    738735        if (!alreadyNeededLayout && markParents)
    739736            markContainingBlocksForLayout();
    740     }
    741     else {
     737    } else {
    742738        m_posChildNeedsLayout = false;
    743739        m_normalChildNeedsLayout = false;
     
    747743void RenderObject::markContainingBlocksForLayout(bool scheduleRelayout)
    748744{
    749     RenderObject *o = container();
    750     RenderObject *last = this;
     745    RenderObject* o = container();
     746    RenderObject* last = this;
    751747
    752748    while (o) {
     
    773769RenderBlock* RenderObject::containingBlock() const
    774770{
    775     if(isTableCell())
    776         return static_cast<const RenderTableCell *>(this)->table();
     771    if (isTableCell())
     772        return static_cast<const RenderTableCell*>(this)->table();
    777773    if (isRenderView())
    778774        return (RenderBlock*)this;
    779775
    780     RenderObject *o = parent();
     776    RenderObject* o = parent();
    781777    if (!isText() && m_style->position() == FixedPosition) {
    782778        while ( o && !o->isRenderView() )
    783779            o = o->parent();
    784     }
    785     else if (!isText() && m_style->position() == AbsolutePosition) {
     780    } else if (!isText() && m_style->position() == AbsolutePosition) {
    786781        while (o && (o->style()->position() == StaticPosition || (o->isInline() && !o->isReplaced())) && !o->isRenderView()) {
    787782            // For relpositioned inlines, we return the nearest enclosing block.  We don't try
     
    806801    if (!o || !o->isRenderBlock())
    807802        return 0; // Probably doesn't happen any more, but leave just in case. -dwh
    808    
     803
    809804    return static_cast<RenderBlock*>(o);
    810805}
     
    812807int RenderObject::containingBlockWidth() const
    813808{
    814     // ###
     809    // FIXME ?
    815810    return containingBlock()->contentWidth();
    816811}
     
    818813int RenderObject::containingBlockHeight() const
    819814{
    820     // ###
     815    // FIXME ?
    821816    return containingBlock()->contentHeight();
    822817}
     
    827822    if (!shouldPaintBackgroundOrBorder())
    828823        return false;
    829    
     824
    830825    // Ok, let's check the background first.
    831826    const BackgroundLayer* bgLayer = style()->backgroundLayers();
     827
     828    // Nobody will use multiple background layers without wanting fancy positioning.
    832829    if (bgLayer->next())
    833         return true; // Nobody will use multiple background layers without wanting fancy positioning.
    834    
     830        return true;
     831
    835832    // Make sure we have a valid background image.
    836833    CachedImage* bg = bgLayer->backgroundImage();
    837834    bool shouldPaintBackgroundImage = bg && bg->canRender();
    838    
     835
    839836    // These are always percents or auto.
    840     if (shouldPaintBackgroundImage &&
    841         (bgLayer->backgroundXPosition().value() != 0 || bgLayer->backgroundYPosition().value() != 0
    842         || bgLayer->backgroundSize().width.isPercent() || bgLayer->backgroundSize().height.isPercent()))
    843         return true; // The background image will shift unpredictably if the size changes.
    844        
     837    if (shouldPaintBackgroundImage &&
     838            (bgLayer->backgroundXPosition().value() != 0 || bgLayer->backgroundYPosition().value() != 0 ||
     839             bgLayer->backgroundSize().width.isPercent() || bgLayer->backgroundSize().height.isPercent()))
     840        // The background image will shift unpredictably if the size changes.
     841        return true;
     842
    845843    // Background is ok.  Let's check border.
    846844    if (style()->hasBorder()) {
     
    848846        CachedImage* borderImage = style()->borderImage().image();
    849847        bool shouldPaintBorderImage = borderImage && borderImage->canRender();
     848
     849        // If the image hasn't loaded, we're still using the normal border style.
    850850        if (shouldPaintBorderImage && borderImage->isLoaded())
    851             return true; // If the image hasn't loaded, we're still using the normal border style.
     851            return true;
    852852    }
    853853
     
    855855}
    856856
    857 void RenderObject::drawBorderArc(GraphicsContext* p, int x, int y, float thickness, IntSize radius, int angleStart,
    858     int angleSpan, BorderSide s, Color c, const Color& textColor, EBorderStyle style, bool firstCorner)
    859 {
    860     if ((style == DOUBLE && ((thickness / 2) < 3)) ||
    861         ((style == RIDGE || style == GROOVE) && ((thickness / 2) < 2)))
     857void RenderObject::drawBorderArc(GraphicsContext* graphicsContext, int x, int y, float thickness, IntSize radius,
     858                                 int angleStart, int angleSpan, BorderSide s, Color c, const Color& textColor,
     859                                 EBorderStyle style, bool firstCorner)
     860{
     861    if ((style == DOUBLE && thickness / 2 < 3) || ((style == RIDGE || style == GROOVE) && thickness / 2 < 2))
    862862        style = SOLID;
    863    
     863
    864864    if (!c.isValid()) {
    865865        if (style == INSET || style == OUTSET || style == RIDGE || style == GROOVE)
     
    868868            c = textColor;
    869869    }
    870    
     870
    871871    switch (style) {
    872872        case BNONE:
     
    874874            return;
    875875        case DOTTED:
    876             p->setPen(Pen(c, thickness == 1 ? 0 : (int)thickness, Pen::DotLine));
     876            graphicsContext->setPen(Pen(c, thickness == 1 ? 0 : static_cast<int>(thickness), Pen::DotLine));
    877877        case DASHED:
    878             if(style == DASHED)
    879                 p->setPen(Pen(c, thickness == 1 ? 0 : (int)thickness, Pen::DashLine));
    880            
    881             if (thickness > 0) {
    882                 if (s == BSBottom || s == BSTop)
    883                     p->drawArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), thickness, angleStart, angleSpan);
    884                 else //We are drawing a left or right border
    885                     p->drawArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), thickness, angleStart, angleSpan);
    886             }
    887            
     878            if (style == DASHED)
     879                graphicsContext->setPen(Pen(c, thickness == 1 ? 0 : static_cast<int>(thickness), Pen::DashLine));
     880
     881            if (thickness > 0)
     882                graphicsContext->drawArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), thickness, angleStart, angleSpan);
     883
    888884            break;
    889885        case DOUBLE: {
    890             float third = thickness / 3;
    891             float innerThird = (thickness + 1) / 6;
    892             int shiftForInner = (int)(innerThird * 2.5);
    893             p->setPen(Pen::NoPen);
    894            
     886            float third = thickness / 3.0f;
     887            float innerThird = (thickness + 1.0f) / 6.0f;
     888            int shiftForInner = static_cast<int>(innerThird * 2.5f);
     889            graphicsContext->setPen(Pen::NoPen);
     890
    895891            int outerY = y;
    896892            int outerHeight = radius.height() * 2;
     
    903899                innerHeight += 2;
    904900            }
    905            
    906             p->drawArc(IntRect(x, outerY, radius.width() * 2, outerHeight), third, angleStart, angleSpan);
    907             p->drawArc(IntRect(innerX, innerY, innerWidth, innerHeight), (innerThird > 2) ? innerThird - 1 : innerThird,
    908                 angleStart, angleSpan);
     901
     902            graphicsContext->drawArc(IntRect(x, outerY, radius.width() * 2, outerHeight), third, angleStart, angleSpan);
     903            graphicsContext->drawArc(IntRect(innerX, innerY, innerWidth, innerHeight), (innerThird > 2) ? innerThird - 1 : innerThird,
     904                                     angleStart, angleSpan);
    909905            break;
    910906        }
     
    912908        case RIDGE: {
    913909            Color c2;
    914             if ((style == RIDGE && (s == BSTop || s == BSLeft)) || 
    915                 (style == GROOVE && (s == BSBottom || s == BSRight)))
     910            if ((style == RIDGE && (s == BSTop || s == BSLeft)) ||
     911                    (style == GROOVE && (s == BSBottom || s == BSRight)))
    916912                c2 = c.dark();
    917913            else {
     
    920916            }
    921917
    922             p->setPen(Pen::NoPen);
    923             p->setFillColor(c.rgb());
    924             p->drawArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), thickness, angleStart, angleSpan);
    925            
    926             float halfThickness = (thickness + 1) / 4;
    927             int shiftForInner = (int)(halfThickness * 1.5);
    928             p->setFillColor(c2.rgb());
    929             p->drawArc(IntRect(x + shiftForInner, y + shiftForInner, (radius.width() - shiftForInner) * 2,
    930                 (radius.height() - shiftForInner) * 2), (halfThickness > 2) ? halfThickness - 1 : halfThickness,
    931                 angleStart, angleSpan);
     918            graphicsContext->setPen(Pen::NoPen);
     919            graphicsContext->setFillColor(c);
     920            graphicsContext->drawArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), thickness, angleStart, angleSpan);
     921
     922            float halfThickness = (thickness + 1.0f) / 4.0f;
     923            int shiftForInner = static_cast<int>(halfThickness * 1.5f);
     924            graphicsContext->setFillColor(c2);
     925            graphicsContext->drawArc(IntRect(x + shiftForInner, y + shiftForInner, (radius.width() - shiftForInner) * 2,
     926                                     (radius.height() - shiftForInner) * 2), (halfThickness > 2) ? halfThickness - 1 : halfThickness,
     927                                     angleStart, angleSpan);
    932928            break;
    933929        }
    934930        case INSET:
    935             if(s == BSTop || s == BSLeft)
     931            if (s == BSTop || s == BSLeft)
    936932                c = c.dark();
    937933        case OUTSET:
    938             if(style == OUTSET && (s == BSBottom || s == BSRight))
     934            if (style == OUTSET && (s == BSBottom || s == BSRight))
    939935                c = c.dark();
    940936        case SOLID:
    941             p->setPen(Pen::NoPen);
    942             p->setFillColor(c.rgb());
    943             p->drawArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), thickness, angleStart, angleSpan);
     937            graphicsContext->setPen(Pen::NoPen);
     938            graphicsContext->setFillColor(c);
     939            graphicsContext->drawArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), thickness, angleStart, angleSpan);
    944940            break;
    945941    }
    946942}
    947943
    948 void RenderObject::drawBorder(GraphicsContext* p, int x1, int y1, int x2, int y2,
     944void RenderObject::drawBorder(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2,
    949945                              BorderSide s, Color c, const Color& textcolor, EBorderStyle style,
    950946                              int adjbw1, int adjbw2)
     
    962958    }
    963959
    964     switch(style)
    965     {
    966     case BNONE:
    967     case BHIDDEN:
    968         return;
    969     case DOTTED:
    970         p->setPen(Pen(c, width == 1 ? 0 : width, Pen::DotLine));
    971         /* nobreak; */
    972     case DASHED:
    973         if(style == DASHED)
    974             p->setPen(Pen(c, width == 1 ? 0 : width, Pen::DashLine));
    975 
    976         if (width > 0)
    977             switch(s)
    978             {
    979             case BSBottom:
    980             case BSTop:
    981                 p->drawLine(IntPoint(x1, (y1+y2)/2), IntPoint(x2, (y1+y2)/2));
    982                 break;
    983             case BSRight:
    984             case BSLeft:
    985                 p->drawLine(IntPoint((x1+x2)/2, y1), IntPoint((x1+x2)/2, y2));
    986                 break;
     960    switch (style) {
     961        case BNONE:
     962        case BHIDDEN:
     963            return;
     964        case DOTTED:
     965        case DASHED:
     966            graphicsContext->setPen(Pen(c, width == 1 ? 0 : width, style == DASHED ? Pen::DashLine : Pen::DotLine));
     967
     968            if (width > 0)
     969                switch (s) {
     970                    case BSBottom:
     971                    case BSTop:
     972                        graphicsContext->drawLine(IntPoint(x1, (y1 + y2) / 2), IntPoint(x2, (y1 + y2) / 2));
     973                        break;
     974                    case BSRight:
     975                    case BSLeft:
     976                        graphicsContext->drawLine(IntPoint((x1 + x2) / 2, y1), IntPoint((x1 + x2) / 2, y2));
     977                        break;
     978                }
     979            break;
     980        case DOUBLE: {
     981            int third = (width + 1) / 3;
     982
     983            if (adjbw1 == 0 && adjbw2 == 0) {
     984                graphicsContext->setPen(Pen::NoPen);
     985                graphicsContext->setFillColor(c);
     986                switch (s) {
     987                    case BSTop:
     988                    case BSBottom:
     989                        graphicsContext->drawRect(IntRect(x1, y1, x2 - x1, third));
     990                        graphicsContext->drawRect(IntRect(x1, y2 - third, x2 - x1, third));
     991                        break;
     992                    case BSLeft:
     993                        graphicsContext->drawRect(IntRect(x1, y1 + 1, third, y2 - y1 - 1));
     994                        graphicsContext->drawRect(IntRect(x2 - third, y1 + 1, third, y2 - y1 - 1));
     995                        break;
     996                    case BSRight:
     997                        graphicsContext->drawRect(IntRect(x1, y1 + 1, third, y2 - y1 - 1));
     998                        graphicsContext->drawRect(IntRect(x2 - third, y1 + 1, third, y2 - y1 - 1));
     999                        break;
     1000                }
     1001            } else {
     1002                int adjbw1bigthird = ((adjbw1 > 0) ? adjbw1 + 1 : adjbw1 - 1) / 3;
     1003                int adjbw2bigthird = ((adjbw2 > 0) ? adjbw2 + 1 : adjbw2 - 1) / 3;
     1004
     1005                switch (s) {
     1006                    case BSTop:
     1007                        drawBorder(graphicsContext, x1 + max((-adjbw1 * 2 + 1) / 3, 0),
     1008                                   y1, x2 - max((-adjbw2 * 2 + 1) / 3, 0), y1 + third,
     1009                                   s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
     1010                        drawBorder(graphicsContext, x1 + max((adjbw1 * 2 + 1) / 3, 0),
     1011                                   y2 - third, x2 - max((adjbw2 * 2 + 1) / 3, 0), y2,
     1012                                   s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
     1013                        break;
     1014                    case BSLeft:
     1015                        drawBorder(graphicsContext, x1, y1 + max((-adjbw1 * 2 + 1) / 3, 0),
     1016                                   x1 + third, y2 - max((-adjbw2 * 2 + 1) / 3, 0),
     1017                                   s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
     1018                        drawBorder(graphicsContext, x2 - third, y1 + max((adjbw1 * 2 + 1) / 3, 0),
     1019                                   x2, y2 - max((adjbw2 * 2 + 1) / 3, 0),
     1020                                   s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
     1021                        break;
     1022                    case BSBottom:
     1023                        drawBorder(graphicsContext, x1 + max((adjbw1 * 2 + 1) / 3, 0),
     1024                                   y1, x2 - max((adjbw2 * 2 + 1) / 3, 0), y1 + third,
     1025                                   s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
     1026                        drawBorder(graphicsContext, x1 + max((-adjbw1 * 2 + 1) / 3, 0),
     1027                                   y2 - third, x2 - max((-adjbw2 * 2 + 1) / 3, 0), y2,
     1028                                   s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
     1029                        break;
     1030                    case BSRight:
     1031                        drawBorder(graphicsContext, x1, y1 + max((adjbw1 * 2 + 1) / 3, 0),
     1032                                   x1 + third, y2 - max(( adjbw2 * 2 + 1) / 3, 0),
     1033                                   s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
     1034                        drawBorder(graphicsContext, x2 - third, y1 + max((-adjbw1 * 2 + 1) / 3, 0),
     1035                                   x2, y2 - max((-adjbw2 * 2 + 1) / 3, 0),
     1036                                   s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
     1037                        break;
     1038                    default:
     1039                        break;
     1040                }
    9871041            }
    988                
    989         break;
    990 
    991     case DOUBLE:
    992     {
    993         int third = (width+1)/3;
    994 
    995         if (adjbw1 == 0 && adjbw2 == 0)
     1042            break;
     1043        }
     1044        case RIDGE:
     1045        case GROOVE:
    9961046        {
    997             p->setPen(Pen::NoPen);
    998             p->setFillColor(c.rgb());
    999             switch(s)
    1000             {
    1001             case BSTop:
    1002             case BSBottom:
    1003                 p->drawRect(IntRect(x1, y1      , x2-x1, third));
    1004                 p->drawRect(IntRect(x1, y2-third, x2-x1, third));
    1005                 break;
    1006             case BSLeft:
    1007                 p->drawRect(IntRect(x1      , y1+1, third, y2-y1-1));
    1008                 p->drawRect(IntRect(x2-third, y1+1, third, y2-y1-1));
    1009                 break;
    1010             case BSRight:
    1011                 p->drawRect(IntRect(x1      , y1+1, third, y2-y1-1));
    1012                 p->drawRect(IntRect(x2-third, y1+1, third, y2-y1-1));
    1013                 break;
     1047            EBorderStyle s1;
     1048            EBorderStyle s2;
     1049            if (style == GROOVE) {
     1050                s1 = INSET;
     1051                s2 = OUTSET;
     1052            } else {
     1053                s1 = OUTSET;
     1054                s2 = INSET;
    10141055            }
    1015         }
    1016         else
     1056
     1057            int adjbw1bighalf = ((adjbw1 > 0) ? adjbw1 + 1 : adjbw1 - 1) / 2;
     1058            int adjbw2bighalf = ((adjbw2 > 0) ? adjbw2 + 1 : adjbw2 - 1) / 2;
     1059
     1060            switch (s) {
     1061                case BSTop:
     1062                    drawBorder(graphicsContext, x1 + max(-adjbw1, 0) / 2, y1, x2 - max(-adjbw2, 0) / 2, (y1 + y2 + 1) / 2,
     1063                               s, c, textcolor, s1, adjbw1bighalf, adjbw2bighalf);
     1064                    drawBorder(graphicsContext, x1 + max(adjbw1 + 1, 0) / 2, (y1 + y2 + 1) / 2, x2 - max(adjbw2 + 1, 0) / 2, y2,
     1065                               s, c, textcolor, s2, adjbw1 / 2, adjbw2 / 2);
     1066                    break;
     1067                case BSLeft:
     1068                    drawBorder(graphicsContext, x1, y1 + max(-adjbw1, 0) / 2, (x1 + x2 + 1) / 2, y2 - max(-adjbw2, 0) / 2,
     1069                               s, c, textcolor, s1, adjbw1bighalf, adjbw2bighalf);
     1070                    drawBorder(graphicsContext, (x1 + x2 + 1) / 2, y1 + max(adjbw1 + 1, 0) / 2, x2, y2 - max(adjbw2 + 1, 0) / 2,
     1071                               s, c, textcolor, s2, adjbw1 / 2, adjbw2 / 2);
     1072                    break;
     1073                case BSBottom:
     1074                    drawBorder(graphicsContext, x1 + max(adjbw1, 0) / 2, y1, x2 - max(adjbw2, 0) / 2, (y1 + y2 + 1) / 2,
     1075                               s, c, textcolor, s2, adjbw1bighalf, adjbw2bighalf);
     1076                    drawBorder(graphicsContext, x1 + max(-adjbw1 + 1, 0) / 2, (y1 + y2 + 1) / 2, x2 - max(-adjbw2 + 1, 0) / 2, y2,
     1077                               s, c, textcolor, s1, adjbw1/2, adjbw2/2);
     1078                    break;
     1079                case BSRight:
     1080                    drawBorder(graphicsContext, x1, y1 + max(adjbw1, 0) / 2, (x1 + x2 + 1) / 2, y2 - max(adjbw2, 0) / 2,
     1081                               s, c, textcolor, s2, adjbw1bighalf, adjbw2bighalf);
     1082                    drawBorder(graphicsContext, (x1 + x2 + 1) / 2, y1 + max(-adjbw1 + 1, 0) / 2, x2, y2 - max(-adjbw2 + 1, 0) / 2,
     1083                               s, c, textcolor, s1, adjbw1/2, adjbw2/2);
     1084                    break;
     1085            }
     1086            break;
     1087        }
     1088        case INSET:
     1089            if (s == BSTop || s == BSLeft)
     1090                c = c.dark();
     1091            // fall through
     1092        case OUTSET:
     1093            if (style == OUTSET && (s == BSBottom || s == BSRight))
     1094                c = c.dark();
     1095            // fall through
     1096        case SOLID:
    10171097        {
    1018             int adjbw1bigthird;
    1019             if (adjbw1>0)
    1020                 adjbw1bigthird = adjbw1+1;
    1021             else
    1022                 adjbw1bigthird = adjbw1 - 1;
    1023             adjbw1bigthird /= 3;
    1024 
    1025             int adjbw2bigthird;
    1026             if (adjbw2>0)
    1027                 adjbw2bigthird = adjbw2 + 1;
    1028             else
    1029                 adjbw2bigthird = adjbw2 - 1;
    1030             adjbw2bigthird /= 3;
    1031 
    1032           switch(s)
    1033             {
    1034             case BSTop:
    1035               drawBorder(p, x1+max((-adjbw1*2+1)/3,0), y1        , x2-max((-adjbw2*2+1)/3,0), y1 + third, s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
    1036               drawBorder(p, x1+max(( adjbw1*2+1)/3,0), y2 - third, x2-max(( adjbw2*2+1)/3,0), y2        , s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
    1037               break;
    1038             case BSLeft:
    1039               drawBorder(p, x1        , y1+max((-adjbw1*2+1)/3,0), x1+third, y2-max((-adjbw2*2+1)/3,0), s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
    1040               drawBorder(p, x2 - third, y1+max(( adjbw1*2+1)/3,0), x2      , y2-max(( adjbw2*2+1)/3,0), s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
    1041               break;
    1042             case BSBottom:
    1043               drawBorder(p, x1+max(( adjbw1*2+1)/3,0), y1      , x2-max(( adjbw2*2+1)/3,0), y1+third, s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
    1044               drawBorder(p, x1+max((-adjbw1*2+1)/3,0), y2-third, x2-max((-adjbw2*2+1)/3,0), y2      , s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
    1045               break;
    1046             case BSRight:
    1047             drawBorder(p, x1      , y1+max(( adjbw1*2+1)/3,0), x1+third, y2-max(( adjbw2*2+1)/3,0), s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
    1048             drawBorder(p, x2-third, y1+max((-adjbw1*2+1)/3,0), x2      , y2-max((-adjbw2*2+1)/3,0), s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird);
    1049               break;
    1050             default:
    1051               break;
     1098            graphicsContext->setPen(Pen::NoPen);
     1099            graphicsContext->setFillColor(c);
     1100            ASSERT(x2 >= x1);
     1101            ASSERT(y2 >= y1);
     1102            if (!adjbw1 && !adjbw2) {
     1103                graphicsContext->drawRect(IntRect(x1, y1, x2 - x1, y2 - y1));
     1104                return;
    10521105            }
    1053         }
    1054         break;
    1055     }
    1056     case RIDGE:
    1057     case GROOVE:
    1058     {
    1059         EBorderStyle s1;
    1060         EBorderStyle s2;
    1061         if (style==GROOVE)
    1062         {
    1063             s1 = INSET;
    1064             s2 = OUTSET;
    1065         }
    1066         else
    1067         {
    1068             s1 = OUTSET;
    1069             s2 = INSET;
    1070         }
    1071 
    1072         int adjbw1bighalf;
    1073         int adjbw2bighalf;
    1074         if (adjbw1>0) adjbw1bighalf=adjbw1+1;
    1075         else adjbw1bighalf=adjbw1-1;
    1076         adjbw1bighalf/=2;
    1077 
    1078         if (adjbw2>0) adjbw2bighalf=adjbw2+1;
    1079         else adjbw2bighalf=adjbw2-1;
    1080         adjbw2bighalf/=2;
    1081 
    1082         switch (s)
    1083         {
    1084         case BSTop:
    1085             drawBorder(p, x1+max(-adjbw1  ,0)/2,  y1        , x2-max(-adjbw2,0)/2, (y1+y2+1)/2, s, c, textcolor, s1, adjbw1bighalf, adjbw2bighalf);
    1086             drawBorder(p, x1+max( adjbw1+1,0)/2, (y1+y2+1)/2, x2-max( adjbw2+1,0)/2,  y2        , s, c, textcolor, s2, adjbw1/2, adjbw2/2);
     1106            FloatPoint quad[4];
     1107            switch (s) {
     1108                case BSTop:
     1109                    quad[0] = FloatPoint(x1 + max(-adjbw1, 0), y1);
     1110                    quad[1] = FloatPoint(x1 + max(adjbw1, 0), y2);
     1111                    quad[2] = FloatPoint(x2 - max(adjbw2, 0), y2);
     1112                    quad[3] = FloatPoint(x2 - max(-adjbw2, 0), y1);
     1113                    break;
     1114                case BSBottom:
     1115                    quad[0] = FloatPoint(x1 + max(adjbw1, 0), y1);
     1116                    quad[1] = FloatPoint(x1 + max(-adjbw1, 0), y2);
     1117                    quad[2] = FloatPoint(x2 - max(-adjbw2, 0), y2);
     1118                    quad[3] = FloatPoint(x2 - max(adjbw2, 0), y1);
     1119                    break;
     1120                case BSLeft:
     1121                    quad[0] = FloatPoint(x1, y1 + max(-adjbw1, 0));
     1122                    quad[1] = FloatPoint(x1, y2 - max(-adjbw2, 0));
     1123                    quad[2] = FloatPoint(x2, y2 - max(adjbw2, 0));
     1124                    quad[3] = FloatPoint(x2, y1 + max(adjbw1, 0));
     1125                    break;
     1126                case BSRight:
     1127                    quad[0] = FloatPoint(x1, y1 + max(adjbw1, 0));
     1128                    quad[1] = FloatPoint(x1, y2 - max(adjbw2, 0));
     1129                    quad[2] = FloatPoint(x2, y2 - max(-adjbw2, 0));
     1130                    quad[3] = FloatPoint(x2, y1 + max(-adjbw1, 0));
     1131                    break;
     1132            }
     1133            graphicsContext->drawConvexPolygon(4, quad);
    10871134            break;
    1088         case BSLeft:
    1089             drawBorder(p,  x1        , y1+max(-adjbw1  ,0)/2, (x1+x2+1)/2, y2-max(-adjbw2,0)/2, s, c, textcolor, s1, adjbw1bighalf, adjbw2bighalf);
    1090             drawBorder(p, (x1+x2+1)/2, y1+max( adjbw1+1,0)/2,  x2        , y2-max( adjbw2+1,0)/2, s, c, textcolor, s2, adjbw1/2, adjbw2/2);
    1091             break;
    1092         case BSBottom:
    1093             drawBorder(p, x1+max( adjbw1  ,0)/2,  y1        , x2-max( adjbw2,0)/2, (y1+y2+1)/2, s, c, textcolor, s2,  adjbw1bighalf, adjbw2bighalf);
    1094             drawBorder(p, x1+max(-adjbw1+1,0)/2, (y1+y2+1)/2, x2-max(-adjbw2+1,0)/2,  y2        , s, c, textcolor, s1, adjbw1/2, adjbw2/2);
    1095             break;
    1096         case BSRight:
    1097             drawBorder(p,  x1        , y1+max( adjbw1  ,0)/2, (x1+x2+1)/2, y2-max( adjbw2,0)/2, s, c, textcolor, s2, adjbw1bighalf, adjbw2bighalf);
    1098             drawBorder(p, (x1+x2+1)/2, y1+max(-adjbw1+1,0)/2,  x2        , y2-max(-adjbw2+1,0)/2, s, c, textcolor, s1, adjbw1/2, adjbw2/2);
    1099             break;
    1100         }
    1101         break;
    1102     }
    1103     case INSET:
    1104         if (s == BSTop || s == BSLeft)
    1105             c = c.dark();
    1106         /* nobreak; */
    1107     case OUTSET:
    1108         if (style == OUTSET && (s == BSBottom || s == BSRight))
    1109             c = c.dark();
    1110         /* nobreak; */
    1111     case SOLID:
    1112     {
    1113         p->setPen(Pen::NoPen);
    1114         p->setFillColor(c);
    1115         ASSERT(x2 >= x1);
    1116         ASSERT(y2 >= y1);
    1117         if (!adjbw1 && !adjbw2) {
    1118             p->drawRect(IntRect(x1, y1, x2 - x1, y2 - y1));
    1119             return;
    1120         }
    1121         FloatPoint quad[4];
    1122         switch (s) {
    1123             case BSTop:
    1124                 quad[0] = FloatPoint(x1 + max(-adjbw1, 0), y1);
    1125                 quad[1] = FloatPoint(x1 + max( adjbw1, 0), y2);
    1126                 quad[2] = FloatPoint(x2 - max( adjbw2, 0), y2);
    1127                 quad[3] = FloatPoint(x2 - max(-adjbw2, 0), y1);
    1128                 break;
    1129             case BSBottom:
    1130                 quad[0] = FloatPoint(x1 + max( adjbw1, 0), y1);
    1131                 quad[1] = FloatPoint(x1 + max(-adjbw1, 0), y2);
    1132                 quad[2] = FloatPoint(x2 - max(-adjbw2, 0), y2);
    1133                 quad[3] = FloatPoint(x2 - max( adjbw2, 0), y1);
    1134                 break;
    1135             case BSLeft:
    1136                 quad[0] = FloatPoint(x1, y1 + max(-adjbw1, 0));
    1137                 quad[1] = FloatPoint(x1, y2 - max(-adjbw2, 0));
    1138                 quad[2] = FloatPoint(x2, y2 - max( adjbw2, 0));
    1139                 quad[3] = FloatPoint(x2, y1 + max( adjbw1, 0));
    1140                 break;
    1141             case BSRight:
    1142                 quad[0] = FloatPoint(x1, y1 + max( adjbw1, 0));
    1143                 quad[1] = FloatPoint(x1, y2 - max( adjbw2, 0));
    1144                 quad[2] = FloatPoint(x2, y2 - max(-adjbw2, 0));
    1145                 quad[3] = FloatPoint(x2, y1 + max(-adjbw1, 0));
    1146                 break;
    1147         }
    1148         p->drawConvexPolygon(4, quad);
    1149         break;
    1150     }
    1151     }
    1152 }
    1153 
    1154 bool RenderObject::paintBorderImage(GraphicsContext* p, int _tx, int _ty, int w, int h, const RenderStyle* style)
     1135        }
     1136    }
     1137}
     1138
     1139bool RenderObject::paintBorderImage(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, const RenderStyle* style)
    11551140{
    11561141    CachedImage* borderImage = style->borderImage().image();
    11571142    if (!borderImage->isLoaded())
    11581143        return true; // Never paint a border image incrementally, but don't paint the fallback borders either.
    1159    
     1144
    11601145    // If we have a border radius, the border image gets clipped to the rounded rect.
    11611146    bool clipped = false;
    11621147    if (style->hasBorderRadius()) {
    1163         IntRect clipRect(_tx, _ty, w, h);
    1164         p->save();
    1165         p->addRoundedRectClip(clipRect,
    1166             style->borderTopLeftRadius(), style->borderTopRightRadius(),
    1167             style->borderBottomLeftRadius(), style->borderBottomRightRadius());
     1148        IntRect clipRect(tx, ty, w, h);
     1149        graphicsContext->save();
     1150        graphicsContext->addRoundedRectClip(clipRect, style->borderTopLeftRadius(), style->borderTopRightRadius(),
     1151                                            style->borderBottomLeftRadius(), style->borderBottomRightRadius());
    11681152        clipped = true;
    11691153    }
     
    11741158    int topSlice = min(imageHeight, style->borderImage().m_slices.top.calcValue(borderImage->image()->height()));
    11751159    int bottomSlice = min(imageHeight, style->borderImage().m_slices.bottom.calcValue(borderImage->image()->height()));
    1176     int leftSlice = min(imageWidth, style->borderImage().m_slices.left.calcValue(borderImage->image()->width()));   
     1160    int leftSlice = min(imageWidth, style->borderImage().m_slices.left.calcValue(borderImage->image()->width()));
    11771161    int rightSlice = min(imageWidth, style->borderImage().m_slices.right.calcValue(borderImage->image()->width()));
    11781162
    11791163    EBorderImageRule hRule = style->borderImage().horizontalRule();
    11801164    EBorderImageRule vRule = style->borderImage().verticalRule();
    1181    
     1165
    11821166    bool drawLeft = leftSlice > 0 && style->borderLeftWidth() > 0;
    11831167    bool drawTop = topSlice > 0 && style->borderTopWidth() > 0;
     
    11891173    if (drawLeft) {
    11901174        // Paint the top and bottom left corners.
    1191        
    1192         // The top left corner rect is (_tx, _ty, leftWidth, topWidth)
     1175
     1176        // The top left corner rect is (tx, ty, leftWidth, topWidth)
    11931177        // The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice)
    11941178        if (drawTop)
    1195             p->drawImage(borderImage->image(), IntRect(_tx, _ty, style->borderLeftWidth(), style->borderTopWidth()),
    1196                          IntRect(0, 0, leftSlice, topSlice));
    1197        
    1198         // The bottom left corner rect is (_tx, _ty + h - bottomWidth, leftWidth, bottomWidth)
     1179            graphicsContext->drawImage(borderImage->image(), IntRect(tx, ty, style->borderLeftWidth(), style->borderTopWidth()),
     1180                                       IntRect(0, 0, leftSlice, topSlice));
     1181
     1182        // The bottom left corner rect is (tx, ty + h - bottomWidth, leftWidth, bottomWidth)
    11991183        // The rect to use from within the image is (0, imageHeight - bottomSlice, leftSlice, botomSlice)
    12001184        if (drawBottom)
    1201             p->drawImage(borderImage->image(), IntRect(_tx, _ty + h - style->borderBottomWidth(), style->borderLeftWidth(), style->borderBottomWidth()),
    1202                          IntRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice));
    1203                      
     1185            graphicsContext->drawImage(borderImage->image(), IntRect(tx, ty + h - style->borderBottomWidth(), style->borderLeftWidth(), style->borderBottomWidth()),
     1186                                       IntRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice));
     1187
    12041188        // Paint the left edge.
    12051189        // Have to scale and tile into the border rect.
    1206         p->drawTiledImage(borderImage->image(), IntRect(_tx, _ty + style->borderTopWidth(), style->borderLeftWidth(),
    1207                                     h - style->borderTopWidth() - style->borderBottomWidth()),
    1208                                     IntRect(0, topSlice, leftSlice, imageHeight - topSlice - bottomSlice),
    1209                                     Image::StretchTile, (Image::TileRule)vRule);
    1210     }
    1211    
     1190        graphicsContext->drawTiledImage(borderImage->image(), IntRect(tx, ty + style->borderTopWidth(), style->borderLeftWidth(),
     1191                                        h - style->borderTopWidth() - style->borderBottomWidth()),
     1192                                        IntRect(0, topSlice, leftSlice, imageHeight - topSlice - bottomSlice),
     1193                                        Image::StretchTile, (Image::TileRule)vRule);
     1194    }
     1195
    12121196    if (drawRight) {
    12131197        // Paint the top and bottom right corners
    1214         // The top right corner rect is (_tx + w - rightWidth, _ty, rightWidth, topWidth)
     1198        // The top right corner rect is (tx + w - rightWidth, ty, rightWidth, topWidth)
    12151199        // The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice)
    12161200        if (drawTop)
    1217             p->drawImage(borderImage->image(), IntRect(_tx + w - style->borderRightWidth(), _ty, style->borderRightWidth(), style->borderTopWidth()),
    1218                          IntRect(imageWidth - rightSlice, 0, rightSlice, topSlice));
    1219        
    1220         // The bottom right corner rect is (_tx + w - rightWidth, _ty + h - bottomWidth, rightWidth, bottomWidth)
     1201            graphicsContext->drawImage(borderImage->image(), IntRect(tx + w - style->borderRightWidth(), ty, style->borderRightWidth(), style->borderTopWidth()),
     1202                                       IntRect(imageWidth - rightSlice, 0, rightSlice, topSlice));
     1203
     1204        // The bottom right corner rect is (tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth)
    12211205        // The rect to use from within the image is (imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, botomSlice)
    12221206        if (drawBottom)
    1223             p->drawImage(borderImage->image(), IntRect(_tx + w - style->borderRightWidth(), _ty + h - style->borderBottomWidth(), style->borderRightWidth(), style->borderBottomWidth()),
    1224                          IntRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice));
    1225                      
     1207            graphicsContext->drawImage(borderImage->image(), IntRect(tx + w - style->borderRightWidth(), ty + h - style->borderBottomWidth(), style->borderRightWidth(), style->borderBottomWidth()),
     1208                                       IntRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice));
     1209
    12261210        // Paint the right edge.
    1227         p->drawTiledImage(borderImage->image(), IntRect(_tx + w - style->borderRightWidth(), _ty + style->borderTopWidth(), style->borderRightWidth(),
    1228                           h - style->borderTopWidth() - style->borderBottomWidth()),
    1229                           IntRect(imageWidth - rightSlice, topSlice, rightSlice, imageHeight - topSlice - bottomSlice),
    1230                           Image::StretchTile, (Image::TileRule)vRule);
     1211        graphicsContext->drawTiledImage(borderImage->image(), IntRect(tx + w - style->borderRightWidth(), ty + style->borderTopWidth(), style->borderRightWidth(),
     1212                                        h - style->borderTopWidth() - style->borderBottomWidth()),
     1213                                        IntRect(imageWidth - rightSlice, topSlice, rightSlice, imageHeight - topSlice - bottomSlice),
     1214                                        Image::StretchTile, (Image::TileRule)vRule);
    12311215    }
    12321216
    12331217    // Paint the top edge.
    12341218    if (drawTop)
    1235         p->drawTiledImage(borderImage->image(), IntRect(_tx + style->borderLeftWidth(), _ty, w - style->borderLeftWidth() - style->borderRightWidth(), style->borderTopWidth()),
    1236                           IntRect(leftSlice, 0, imageWidth - rightSlice - leftSlice, topSlice),
    1237                           (Image::TileRule)hRule, Image::StretchTile);
    1238    
     1219        graphicsContext->drawTiledImage(borderImage->image(), IntRect(tx + style->borderLeftWidth(), ty, w - style->borderLeftWidth() - style->borderRightWidth(), style->borderTopWidth()),
     1220                                        IntRect(leftSlice, 0, imageWidth - rightSlice - leftSlice, topSlice),
     1221                                        (Image::TileRule)hRule, Image::StretchTile);
     1222
    12391223    // Paint the bottom edge.
    12401224    if (drawBottom)
    1241         p->drawTiledImage(borderImage->image(), IntRect(_tx + style->borderLeftWidth(), _ty + h - style->borderBottomWidth(),
    1242                           w - style->borderLeftWidth() - style->borderRightWidth(), style->borderBottomWidth()),
    1243                           IntRect(leftSlice, imageHeight - bottomSlice, imageWidth - rightSlice - leftSlice, bottomSlice),
    1244                           (Image::TileRule)hRule, Image::StretchTile);
    1245    
     1225        graphicsContext->drawTiledImage(borderImage->image(), IntRect(tx + style->borderLeftWidth(), ty + h - style->borderBottomWidth(),
     1226                                        w - style->borderLeftWidth() - style->borderRightWidth(), style->borderBottomWidth()),
     1227                                        IntRect(leftSlice, imageHeight - bottomSlice, imageWidth - rightSlice - leftSlice, bottomSlice),
     1228                                        (Image::TileRule)hRule, Image::StretchTile);
     1229
    12461230    // Paint the middle.
    12471231    if (drawMiddle)
    1248         p->drawTiledImage(borderImage->image(), IntRect(_tx + style->borderLeftWidth(), _ty + style->borderTopWidth(), w - style->borderLeftWidth() - style->borderRightWidth(),
    1249                           h - style->borderTopWidth() - style->borderBottomWidth()),
    1250                           IntRect(leftSlice, topSlice, imageWidth - rightSlice - leftSlice, imageHeight - topSlice - bottomSlice),
    1251                           (Image::TileRule)hRule, (Image::TileRule)vRule);
     1232        graphicsContext->drawTiledImage(borderImage->image(), IntRect(tx + style->borderLeftWidth(), ty + style->borderTopWidth(), w - style->borderLeftWidth() - style->borderRightWidth(),
     1233                                        h - style->borderTopWidth() - style->borderBottomWidth()),
     1234                                        IntRect(leftSlice, topSlice, imageWidth - rightSlice - leftSlice, imageHeight - topSlice - bottomSlice),
     1235                                        (Image::TileRule)hRule, (Image::TileRule)vRule);
    12521236
    12531237    // Clear the clip for the border radius.
    12541238    if (clipped)
    1255         p->restore();
     1239        graphicsContext->restore();
    12561240
    12571241    return true;
    12581242}
    12591243
    1260 void RenderObject::paintBorder(GraphicsContext* p, int _tx, int _ty, int w, int h, const RenderStyle* style, bool begin, bool end)
     1244void RenderObject::paintBorder(GraphicsContext* graphicsContext, int tx, int ty, int w, int h,
     1245                               const RenderStyle* style, bool begin, bool end)
    12611246{
    12621247    CachedImage* borderImage = style->borderImage().image();
    12631248    bool shouldPaintBackgroundImage = borderImage && borderImage->canRender();
    12641249    if (shouldPaintBackgroundImage)
    1265         shouldPaintBackgroundImage = paintBorderImage(p, _tx, _ty, w, h, style);
    1266    
     1250        shouldPaintBackgroundImage = paintBorderImage(graphicsContext, tx, ty, w, h, style);
     1251
    12671252    if (shouldPaintBackgroundImage)
    12681253        return;
     
    12771262    bool rt = style->borderRightIsTransparent();
    12781263    bool lt = style->borderLeftIsTransparent();
    1279    
     1264
    12801265    EBorderStyle ts = style->borderTopStyle();
    12811266    EBorderStyle bs = style->borderBottomStyle();
     
    13021287        renderRadii = (requiredWidth <= w && requiredHeight <= h);
    13031288    }
    1304    
     1289
    13051290    // Clip to the rounded rectangle.
    13061291    if (renderRadii) {
    1307         p->save();
    1308         p->addRoundedRectClip(IntRect(_tx, _ty, w, h), topLeft, topRight, bottomLeft, bottomRight);
     1292        graphicsContext->save();
     1293        graphicsContext->addRoundedRectClip(IntRect(tx, ty, w, h), topLeft, topRight, bottomLeft, bottomRight);
    13091294    }
    13101295
     
    13181303    if (renderTop) {
    13191304        bool ignore_left = (renderRadii && topLeft.width() > 0) ||
    1320             ((tc == lc) && (tt == lt) &&
    1321             (ts >= OUTSET) &&
    1322             (ls == DOTTED || ls == DASHED || ls == SOLID || ls == OUTSET));
     1305            (tc == lc && tt == lt && ts >= OUTSET &&
     1306             (ls == DOTTED || ls == DASHED || ls == SOLID || ls == OUTSET));
    13231307
    13241308        bool ignore_right = (renderRadii && topRight.width() > 0) ||
    1325             ((tc == rc) && (tt == rt) &&
    1326             (ts >= OUTSET) &&
    1327             (rs == DOTTED || rs == DASHED || rs == SOLID || rs == INSET));
    1328        
    1329         int x = _tx;
    1330         int x2 = _tx + w;
     1309            (tc == rc && tt == rt && ts >= OUTSET &&
     1310             (rs == DOTTED || rs == DASHED || rs == SOLID || rs == INSET));
     1311
     1312        int x = tx;
     1313        int x2 = tx + w;
    13311314        if (renderRadii) {
    13321315            x += topLeft.width();
    13331316            x2 -= topRight.width();
    13341317        }
    1335        
    1336         drawBorder(p, x, _ty, x2, _ty +  style->borderTopWidth(), BSTop, tc, style->color(), ts,
    1337                    ignore_left ? 0 : style->borderLeftWidth(),
    1338                    ignore_right? 0 : style->borderRightWidth());
    1339        
     1318
     1319        drawBorder(graphicsContext, x, ty, x2, ty + style->borderTopWidth(), BSTop, tc, style->color(), ts,
     1320                   ignore_left ? 0 : style->borderLeftWidth(), ignore_right ? 0 : style->borderRightWidth());
     1321
    13401322        if (renderRadii) {
    1341             int leftX = _tx;
    1342             int leftY = _ty;
    1343             int rightX = _tx + w - topRight.width() * 2;
     1323            int leftX = tx;
     1324            int leftY = ty;
     1325            int rightX = tx + w - topRight.width() * 2;
    13441326            firstAngleStart = 90;
    13451327            firstAngleSpan = upperLeftBorderStylesMatch ? 90 : 45;
    1346            
     1328
    13471329            // We make the arc double thick and let the clip rect take care of clipping the extra off.
    13481330            // We're doing this because it doesn't seem possible to match the curve of the clip exactly
    13491331            // with the arc-drawing function.
    13501332            thickness = style->borderTopWidth() * 2;
    1351            
     1333
    13521334            if (upperRightBorderStylesMatch) {
    13531335                secondAngleStart = 0;
     
    13571339                secondAngleSpan = 45;
    13581340            }
    1359            
     1341
    13601342            // The inner clip clips inside the arc. This is especially important for 1px borders.
    13611343            bool applyLeftInnerClip = (style->borderLeftWidth() < topLeft.width())
     
    13631345                && (ts != DOUBLE || style->borderTopWidth() > 6);
    13641346            if (applyLeftInnerClip) {
    1365                 p->save();
    1366                 p->addInnerRoundedRectClip(IntRect(leftX, leftY, topLeft.width() * 2, topLeft.height() * 2),
    1367                     style->borderTopWidth());
     1347                graphicsContext->save();
     1348                graphicsContext->addInnerRoundedRectClip(IntRect(leftX, leftY, topLeft.width() * 2, topLeft.height() * 2),
     1349                                                         style->borderTopWidth());
    13681350            }
    1369            
     1351
    13701352            // Draw upper left arc
    1371             drawBorderArc(p, leftX, leftY, thickness, topLeft, firstAngleStart, firstAngleSpan,
    1372                 BSTop, tc, style->color(), ts, true);
     1353            drawBorderArc(graphicsContext, leftX, leftY, thickness, topLeft, firstAngleStart, firstAngleSpan,
     1354                          BSTop, tc, style->color(), ts, true);
    13731355            if (applyLeftInnerClip)
    1374                 p->restore();
    1375            
     1356                graphicsContext->restore();
     1357
    13761358            bool applyRightInnerClip = (style->borderRightWidth() < topRight.width())
    13771359                && (style->borderTopWidth() < topRight.height())
    13781360                && (ts != DOUBLE || style->borderTopWidth() > 6);
    13791361            if (applyRightInnerClip) {
    1380                 p->save();
    1381                 p->addInnerRoundedRectClip(IntRect(rightX, leftY, topRight.width() * 2, topRight.height() * 2),
    1382                     style->borderTopWidth());
     1362                graphicsContext->save();
     1363                graphicsContext->addInnerRoundedRectClip(IntRect(rightX, leftY, topRight.width() * 2, topRight.height() * 2),
     1364                                                         style->borderTopWidth());
    13831365            }
    1384            
     1366
    13851367            // Draw upper right arc
    1386             drawBorderArc(p, rightX, leftY, thickness, topRight, secondAngleStart, secondAngleSpan,
    1387                 BSTop, tc, style->color(), ts, false);
     1368            drawBorderArc(graphicsContext, rightX, leftY, thickness, topRight, secondAngleStart, secondAngleSpan,
     1369                          BSTop, tc, style->color(), ts, false);
    13881370            if (applyRightInnerClip)
    1389                 p->restore();
     1371                graphicsContext->restore();
    13901372        }
    13911373    }
     
    13931375    if (renderBottom) {
    13941376        bool ignore_left = (renderRadii && bottomLeft.width() > 0) ||
    1395         ((bc == lc) && (bt == lt) &&
    1396         (bs >= OUTSET) &&
    1397         (ls == DOTTED || ls == DASHED || ls == SOLID || ls == OUTSET));
     1377            (bc == lc && bt == lt && bs >= OUTSET &&
     1378             (ls == DOTTED || ls == DASHED || ls == SOLID || ls == OUTSET));
    13981379
    13991380        bool ignore_right = (renderRadii && bottomRight.width() > 0) ||
    1400             ((bc == rc) && (bt == rt) &&
    1401             (bs >= OUTSET) &&
    1402             (rs == DOTTED || rs == DASHED || rs == SOLID || rs == INSET));
    1403        
    1404         int x = _tx;
    1405         int x2 = _tx + w;
     1381            (bc == rc && bt == rt && bs >= OUTSET &&
     1382             (rs == DOTTED || rs == DASHED || rs == SOLID || rs == INSET));
     1383
     1384        int x = tx;
     1385        int x2 = tx + w;
    14061386        if (renderRadii) {
    14071387            x += bottomLeft.width();
     
    14091389        }
    14101390
    1411         drawBorder(p, x, _ty + h - style->borderBottomWidth(), x2, _ty + h, BSBottom, bc, style->color(), bs,
    1412                    ignore_left ? 0 :style->borderLeftWidth(),
    1413                    ignore_right? 0 :style->borderRightWidth());
    1414        
     1391        drawBorder(graphicsContext, x, ty + h - style->borderBottomWidth(), x2, ty + h, BSBottom, bc, style->color(), bs,
     1392                   ignore_left ? 0 : style->borderLeftWidth(), ignore_right ? 0 : style->borderRightWidth());
     1393
    14151394        if (renderRadii) {
    1416             int leftX = _tx;
    1417             int leftY = _ty + h - bottomLeft.height() * 2;
    1418             int rightX = _tx + w - bottomRight.width() * 2;
     1395            int leftX = tx;
     1396            int leftY = ty + h - bottomLeft.height() * 2;
     1397            int rightX = tx + w - bottomRight.width() * 2;
    14191398            secondAngleStart = 270;
    14201399            secondAngleSpan = upperRightBorderStylesMatch ? 90 : 45;
    14211400            thickness = style->borderBottomWidth() * 2;
    1422            
     1401
    14231402            if (upperLeftBorderStylesMatch) {
    14241403                firstAngleStart = 180;
     
    14261405            } else {
    14271406                firstAngleStart = 225;
    1428                 firstAngleSpan =  45;
     1407                firstAngleSpan = 45;
    14291408            }
    1430            
     1409
    14311410            bool applyLeftInnerClip = (style->borderLeftWidth() < bottomLeft.width())
    14321411                && (style->borderBottomWidth() < bottomLeft.height())
    14331412                && (bs != DOUBLE || style->borderBottomWidth() > 6);
    14341413            if (applyLeftInnerClip) {
    1435                 p->save();
    1436                 p->addInnerRoundedRectClip(IntRect(leftX, leftY, bottomLeft.width() * 2, bottomLeft.height() * 2),
    1437                     style->borderBottomWidth());
     1414                graphicsContext->save();
     1415                graphicsContext->addInnerRoundedRectClip(IntRect(leftX, leftY, bottomLeft.width() * 2, bottomLeft.height() * 2),
     1416                                                         style->borderBottomWidth());
    14381417            }
    1439            
     1418
    14401419            // Draw lower left arc
    1441             drawBorderArc(p, leftX, leftY, thickness, bottomLeft, firstAngleStart, firstAngleSpan,
    1442                 BSBottom, bc, style->color(), bs, true);
     1420            drawBorderArc(graphicsContext, leftX, leftY, thickness, bottomLeft, firstAngleStart, firstAngleSpan,
     1421                          BSBottom, bc, style->color(), bs, true);
    14431422            if (applyLeftInnerClip)
    1444                 p->restore();
    1445                
     1423                graphicsContext->restore();
     1424
    14461425            bool applyRightInnerClip = (style->borderRightWidth() < bottomRight.width())
    14471426                && (style->borderBottomWidth() < bottomRight.height())
    14481427                && (bs != DOUBLE || style->borderBottomWidth() > 6);
    14491428            if (applyRightInnerClip) {
    1450                 p->save();
    1451                 p->addInnerRoundedRectClip(IntRect(rightX, leftY, bottomRight.width() * 2, bottomRight.height() * 2),
    1452                     style->borderBottomWidth());
     1429                graphicsContext->save();
     1430                graphicsContext->addInnerRoundedRectClip(IntRect(rightX, leftY, bottomRight.width() * 2, bottomRight.height() * 2),
     1431                                                         style->borderBottomWidth());
    14531432            }
    1454            
     1433
    14551434            // Draw lower right arc
    1456             drawBorderArc(p, rightX, leftY, thickness, bottomRight, secondAngleStart, secondAngleSpan,
    1457                 BSBottom, bc, style->color(), bs, false);
     1435            drawBorderArc(graphicsContext, rightX, leftY, thickness, bottomRight, secondAngleStart, secondAngleSpan,
     1436                          BSBottom, bc, style->color(), bs, false);
    14581437            if (applyRightInnerClip)
    1459                 p->restore();
    1460         }
    1461     }
    1462    
     1438                graphicsContext->restore();
     1439        }
     1440    }
     1441
    14631442    if (renderLeft) {
    14641443        bool ignore_top = (renderRadii && topLeft.height() > 0) ||
    1465           ((tc == lc) && (tt == lt) &&
    1466           (ls >= OUTSET) &&
    1467           (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET));
     1444            (tc == lc && tt == lt && ls >= OUTSET &&
     1445             (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET));
    14681446
    14691447        bool ignore_bottom = (renderRadii && bottomLeft.height() > 0) ||
    1470           ((bc == lc) && (bt == lt) &&
    1471           (ls >= OUTSET) &&
    1472           (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET));
    1473 
    1474         int y = _ty;
    1475         int y2 = _ty + h;
     1448            (bc == lc && bt == lt && ls >= OUTSET &&
     1449             (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET));
     1450
     1451        int y = ty;
     1452        int y2 = ty + h;
    14761453        if (renderRadii) {
    14771454            y += topLeft.height();
    14781455            y2 -= bottomLeft.height();
    14791456        }
    1480        
    1481         drawBorder(p, _tx, y, _tx + style->borderLeftWidth(), y2, BSLeft, lc, style->color(), ls,
    1482                    ignore_top?0:style->borderTopWidth(),
    1483                    ignore_bottom?0:style->borderBottomWidth());
     1457
     1458        drawBorder(graphicsContext, tx, y, tx + style->borderLeftWidth(), y2, BSLeft, lc, style->color(), ls,
     1459                   ignore_top ? 0 : style->borderTopWidth(), ignore_bottom ? 0 : style->borderBottomWidth());
    14841460
    14851461        if (renderRadii && (!upperLeftBorderStylesMatch || !lowerLeftBorderStylesMatch)) {
    1486             int topX = _tx;
    1487             int topY = _ty;
    1488             int bottomY = _ty + h - bottomLeft.height() * 2;
     1462            int topX = tx;
     1463            int topY = ty;
     1464            int bottomY = ty + h - bottomLeft.height() * 2;
    14891465            firstAngleStart = 135;
    14901466            secondAngleStart = 180;
    14911467            firstAngleSpan = secondAngleSpan = 45;
    14921468            thickness = style->borderLeftWidth() * 2;
    1493            
     1469
    14941470            bool applyTopInnerClip = (style->borderLeftWidth() < topLeft.width())
    14951471                && (style->borderTopWidth() < topLeft.height())
    14961472                && (ls != DOUBLE || style->borderLeftWidth() > 6);
    14971473            if (applyTopInnerClip) {
    1498                 p->save();
    1499                 p->addInnerRoundedRectClip(IntRect(topX, topY, topLeft.width() * 2, topLeft.height() * 2),
    1500                     style->borderLeftWidth());
     1474                graphicsContext->save();
     1475                graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, topLeft.width() * 2, topLeft.height() * 2),
     1476                                                         style->borderLeftWidth());
    15011477            }
    1502            
     1478
    15031479            // Draw top left arc
    1504             drawBorderArc(p, topX, topY, thickness, topLeft, firstAngleStart, firstAngleSpan,
    1505                 BSLeft, lc, style->color(), ls, true);
     1480            drawBorderArc(graphicsContext, topX, topY, thickness, topLeft, firstAngleStart, firstAngleSpan,
     1481                          BSLeft, lc, style->color(), ls, true);
    15061482            if (applyTopInnerClip)
    1507                 p->restore();
    1508            
     1483                graphicsContext->restore();
     1484
    15091485            bool applyBottomInnerClip = (style->borderLeftWidth() < bottomLeft.width())
    15101486                && (style->borderBottomWidth() < bottomLeft.height())
    15111487                && (ls != DOUBLE || style->borderLeftWidth() > 6);
    15121488            if (applyBottomInnerClip) {
    1513                 p->save();
    1514                 p->addInnerRoundedRectClip(IntRect(topX, bottomY, bottomLeft.width() * 2, bottomLeft.height() * 2),
    1515                     style->borderLeftWidth());
     1489                graphicsContext->save();
     1490                graphicsContext->addInnerRoundedRectClip(IntRect(topX, bottomY, bottomLeft.width() * 2, bottomLeft.height() * 2),
     1491                                                         style->borderLeftWidth());
    15161492            }
    1517            
     1493
    15181494            // Draw bottom left arc
    1519             drawBorderArc(p, topX, bottomY, thickness, bottomLeft, secondAngleStart, secondAngleSpan,
    1520                 BSLeft, lc, style->color(), ls, false);
     1495            drawBorderArc(graphicsContext, topX, bottomY, thickness, bottomLeft, secondAngleStart, secondAngleSpan,
     1496                          BSLeft, lc, style->color(), ls, false);
    15211497            if (applyBottomInnerClip)
    1522                 p->restore();
     1498                graphicsContext->restore();
    15231499        }
    15241500    }
     
    15261502    if (renderRight) {
    15271503        bool ignore_top = (renderRadii && topRight.height() > 0) ||
    1528           ((tc == rc) && (tt == rt) &&
    1529           (rs >= DOTTED || rs == INSET) &&
    1530           (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET));
     1504            ((tc == rc) && (tt == rt) &&
     1505            (rs >= DOTTED || rs == INSET) &&
     1506            (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET));
    15311507
    15321508        bool ignore_bottom = (renderRadii && bottomRight.height() > 0) ||
    1533           ((bc == rc) && (bt == rt) &&
    1534           (rs >= DOTTED || rs == INSET) &&
    1535           (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET));
    1536 
    1537         int y = _ty;
    1538         int y2 = _ty + h;
     1509            ((bc == rc) && (bt == rt) &&
     1510            (rs >= DOTTED || rs == INSET) &&
     1511            (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET));
     1512
     1513        int y = ty;
     1514        int y2 = ty + h;
    15391515        if (renderRadii) {
    15401516            y += topRight.height();
     
    15421518        }
    15431519
    1544         drawBorder(p, _tx + w - style->borderRightWidth(), y, _tx + w, y2, BSRight, rc, style->color(), rs,
    1545                    ignore_top?0:style->borderTopWidth(),
    1546                    ignore_bottom?0:style->borderBottomWidth());
     1520        drawBorder(graphicsContext, tx + w - style->borderRightWidth(), y, tx + w, y2, BSRight, rc, style->color(), rs,
     1521                   ignore_top ? 0 : style->borderTopWidth(), ignore_bottom ? 0 : style->borderBottomWidth());
    15471522
    15481523        if (renderRadii && (!upperRightBorderStylesMatch || !lowerRightBorderStylesMatch)) {
    1549             int topX = _tx + w - topRight.width() * 2;
    1550             int topY = _ty;
    1551             int bottomY = _ty + h - bottomRight.height() * 2;
    1552             firstAngleStart = 0; 
     1524            int topX = tx + w - topRight.width() * 2;
     1525            int topY = ty;
     1526            int bottomY = ty + h - bottomRight.height() * 2;
     1527            firstAngleStart = 0;
    15531528            secondAngleStart = 315;
    15541529            firstAngleSpan = secondAngleSpan = 45;
    15551530            thickness = style->borderRightWidth() * 2;
    1556            
     1531
    15571532            bool applyTopInnerClip = (style->borderRightWidth() < topRight.width())
    15581533                && (style->borderTopWidth() < topRight.height())
    15591534                && (rs != DOUBLE || style->borderRightWidth() > 6);
    15601535            if (applyTopInnerClip) {
    1561                 p->save();
    1562                 p->addInnerRoundedRectClip(IntRect(topX, topY, topRight.width() * 2, topRight.height() * 2),
    1563                     style->borderRightWidth());
     1536                graphicsContext->save();
     1537                graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, topRight.width() * 2, topRight.height() * 2),
     1538                                                         style->borderRightWidth());
    15641539            }
    1565            
     1540
    15661541            // Draw top right arc
    1567             drawBorderArc(p, topX, topY, thickness, topRight, firstAngleStart, firstAngleSpan,
    1568                 BSRight, rc, style->color(), rs, true);
     1542            drawBorderArc(graphicsContext, topX, topY, thickness, topRight, firstAngleStart, firstAngleSpan,
     1543                          BSRight, rc, style->color(), rs, true);
    15691544            if (applyTopInnerClip)
    1570                 p->restore();
    1571            
     1545                graphicsContext->restore();
     1546
    15721547            bool applyBottomInnerClip = (style->borderRightWidth() < bottomRight.width())
    15731548                && (style->borderBottomWidth() < bottomRight.height())
    15741549                && (rs != DOUBLE || style->borderRightWidth() > 6);
    15751550            if (applyBottomInnerClip) {
    1576                 p->save();
    1577                 p->addInnerRoundedRectClip(IntRect(topX, bottomY, bottomRight.width() * 2, bottomRight.height() * 2),
    1578                     style->borderRightWidth());
     1551                graphicsContext->save();
     1552                graphicsContext->addInnerRoundedRectClip(IntRect(topX, bottomY, bottomRight.width() * 2, bottomRight.height() * 2),
     1553                                                         style->borderRightWidth());
    15791554            }
    1580            
     1555
    15811556            // Draw bottom right arc
    1582             drawBorderArc(p, topX, bottomY, thickness, bottomRight, secondAngleStart, secondAngleSpan,
    1583                 BSRight, rc, style->color(), rs, false);
     1557            drawBorderArc(graphicsContext, topX, bottomY, thickness, bottomRight, secondAngleStart, secondAngleSpan,
     1558                          BSRight, rc, style->color(), rs, false);
    15841559            if (applyBottomInnerClip)
    1585                 p->restore();
    1586         }
    1587     }
    1588    
     1560                graphicsContext->restore();
     1561        }
     1562    }
     1563
    15891564    if (renderRadii)
    1590         p->restore(); // Undo the clip.
     1565        graphicsContext->restore();
    15911566}
    15921567
     
    16011576    // shape).
    16021577    if (continuation()) {
    1603         rects.append(IntRect(tx, ty - collapsedMarginTop(), 
    1604                            width(), height()+collapsedMarginTop()+collapsedMarginBottom()));
    1605         continuation()->absoluteRects(rects, 
     1578        rects.append(IntRect(tx, ty - collapsedMarginTop(),
     1579                             width(), height() + collapsedMarginTop() + collapsedMarginBottom()));
     1580        continuation()->absoluteRects(rects,
    16061581                                      tx - xPos() + continuation()->containingBlock()->xPos(),
    16071582                                      ty - yPos() + continuation()->containingBlock()->yPos());
    1608     }
    1609     else
     1583    } else
    16101584        rects.append(IntRect(tx, ty, width(), height() + borderTopExtra() + borderBottomExtra()));
    16111585}
     
    16451619}
    16461620
    1647 void RenderObject::addPDFURLRect(GraphicsContext* p, IntRect rect)
     1621void RenderObject::addPDFURLRect(GraphicsContext* graphicsContext, IntRect rect)
    16481622{
    16491623    Node* node = element();
    16501624    if (node) {
    1651         if (p) {
     1625        if (graphicsContext) {
    16521626            if (rect.width() > 0 && rect.height() > 0) {
    16531627                Element* element = static_cast<Element*>(node);
     
    16551629                if (element->isLink())
    16561630                    href = element->getAttribute(hrefAttr);
    1657                    
     1631
    16581632                if (!href.isNull()) {
    16591633                    KURL link = element->document()->completeURL(href.deprecatedString());
    16601634                    if (link.isValid())
    1661                         p->setURLForRect(link, rect);
     1635                        graphicsContext->setURLForRect(link, rect);
    16621636                }
    16631637            }
     
    16671641
    16681642
    1669 void RenderObject::addFocusRingRects(GraphicsContext* p, int _tx, int _ty)
     1643void RenderObject::addFocusRingRects(GraphicsContext* graphicsContext, int tx, int ty)
    16701644{
    16711645    // For blocks inside inlines, we go ahead and include margins so that we run right up to the
     
    16731647    // shape).
    16741648    if (continuation()) {
    1675         p->addFocusRingRect(IntRect(_tx, _ty - collapsedMarginTop(), width(), height()+collapsedMarginTop()+collapsedMarginBottom()));
    1676         continuation()->addFocusRingRects(p,
    1677                                           _tx - xPos() + continuation()->containingBlock()->xPos(),
    1678                                           _ty - yPos() + continuation()->containingBlock()->yPos());
    1679     }
    1680     else
    1681         p->addFocusRingRect(IntRect(_tx, _ty, width(), height()));
    1682 }
    1683 
    1684 void RenderObject::paintOutline(GraphicsContext* p, int _tx, int _ty, int w, int h, const RenderStyle* style)
     1649        graphicsContext->addFocusRingRect(IntRect(tx, ty - collapsedMarginTop(), width(), height() + collapsedMarginTop() + collapsedMarginBottom()));
     1650        continuation()->addFocusRingRects(graphicsContext,
     1651                                          tx - xPos() + continuation()->containingBlock()->xPos(),
     1652                                          ty - yPos() + continuation()->containingBlock()->yPos());
     1653    } else
     1654        graphicsContext->addFocusRingRect(IntRect(tx, ty, width(), height()));
     1655}
     1656
     1657void RenderObject::paintOutline(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, const RenderStyle* style)
    16851658{
    16861659    if (!hasOutline())
    16871660        return;
    1688    
     1661
    16891662    int ow = style->outlineWidth();
    16901663
    16911664    EBorderStyle os = style->outlineStyle();
    1692    
     1665
    16931666    Color oc = style->outlineColor();
    16941667    if (!oc.isValid())
    16951668        oc = style->color();
    1696    
     1669
    16971670    int offset = style->outlineOffset();
    1698    
     1671
    16991672    if (style->outlineStyleIsAuto() || hasOutlineAnnotation()) {
    17001673        if (!theme()->supportsFocusRing(style)) {
    17011674            // Only paint the focus ring by hand if the theme isn't able to draw the focus ring.
    1702             p->initFocusRing(ow, offset);
     1675            graphicsContext->initFocusRing(ow, offset);
    17031676            if (style->outlineStyleIsAuto())
    1704                 addFocusRingRects(p, _tx, _ty);
     1677                addFocusRingRects(graphicsContext, tx, ty);
    17051678            else
    1706                 addPDFURLRect(p, p->focusRingBoundingRect());
    1707             p->drawFocusRing(oc);
    1708             p->clearFocusRing();
     1679                addPDFURLRect(graphicsContext, graphicsContext->focusRingBoundingRect());
     1680            graphicsContext->drawFocusRing(oc);
     1681            graphicsContext->clearFocusRing();
    17091682        }
    17101683    }
     
    17131686        return;
    17141687
    1715     _tx -= offset;
    1716     _ty -= offset;
    1717     w += 2*offset;
    1718     h += 2*offset;
    1719    
    1720     drawBorder(p, _tx-ow, _ty-ow, _tx, _ty+h+ow, BSLeft,
    1721                Color(oc), style->color(),
    1722                os, ow, ow);
    1723 
    1724     drawBorder(p, _tx-ow, _ty-ow, _tx+w+ow, _ty, BSTop,
    1725                Color(oc), style->color(),
    1726                os, ow, ow);
    1727 
    1728     drawBorder(p, _tx+w, _ty-ow, _tx+w+ow, _ty+h+ow, BSRight,
    1729                Color(oc), style->color(),
    1730                os, ow, ow);
    1731 
    1732     drawBorder(p, _tx-ow, _ty+h, _tx+w+ow, _ty+h+ow, BSBottom,
    1733                Color(oc), style->color(),
    1734                os, ow, ow);
    1735 
     1688    tx -= offset;
     1689    ty -= offset;
     1690    w += 2 * offset;
     1691    h += 2 * offset;
     1692
     1693    drawBorder(graphicsContext, tx - ow, ty - ow, tx, ty + h + ow,
     1694               BSLeft, Color(oc), style->color(), os, ow, ow);
     1695
     1696    drawBorder(graphicsContext, tx - ow, ty - ow, tx + w + ow, ty,
     1697               BSTop, Color(oc), style->color(), os, ow, ow);
     1698
     1699    drawBorder(graphicsContext, tx + w, ty - ow, tx + w + ow, ty + h + ow,
     1700               BSRight, Color(oc), style->color(), os, ow, ow);
     1701
     1702    drawBorder(graphicsContext, tx - ow, ty + h, tx + w + ow, ty + h + ow,
     1703               BSBottom, Color(oc), style->color(), os, ow, ow);
    17361704}
    17371705
     
    17441712    // Can't use view(), since we might be unrooted.
    17451713    RenderObject* o = this;
    1746     while ( o->parent() ) o = o->parent();
     1714    while (o->parent())
     1715        o = o->parent();
    17471716    if (!o->isRenderView())
    17481717        return;
    1749     RenderView* c = static_cast<RenderView*>(o);
    1750     if (c->printingMode())
     1718    RenderView* view = static_cast<RenderView*>(o);
     1719    if (view->printingMode())
    17511720        return; // Don't repaint if we're printing.
    1752     c->repaintViewRectangle(getAbsoluteRepaintRect(), immediate);   
     1721    view->repaintViewRectangle(getAbsoluteRepaintRect(), immediate);
    17531722}
    17541723
     
    17571726    // Can't use view(), since we might be unrooted.
    17581727    RenderObject* o = this;
    1759     while ( o->parent() ) o = o->parent();
     1728    while (o->parent())
     1729        o = o->parent();
    17601730    if (!o->isRenderView())
    17611731        return;
    1762     RenderView* c = static_cast<RenderView*>(o);
    1763     if (c->printingMode())
     1732    RenderView* view = static_cast<RenderView*>(o);
     1733    if (view->printingMode())
    17641734        return; // Don't repaint if we're printing.
    17651735    IntRect absRect(r);
    17661736    computeAbsoluteRepaintRect(absRect);
    1767     c->repaintViewRectangle(absRect, immediate);
     1737    view->repaintViewRectangle(absRect, immediate);
    17681738}
    17691739
    17701740bool RenderObject::repaintAfterLayoutIfNeeded(const IntRect& oldBounds, const IntRect& oldFullBounds)
    17711741{
    1772     RenderView* c = view();
    1773     if (c->printingMode())
     1742    RenderView* v = view();
     1743    if (v->printingMode())
    17741744        return false; // Don't repaint if we're printing.
    1775            
     1745
    17761746    IntRect newBounds, newFullBounds;
    17771747    getAbsoluteRepaintRectIncludingFloats(newBounds, newFullBounds);
     
    17811751    bool fullRepaint = selfNeedsLayout() || newBounds.location() != oldBounds.location() || mustRepaintBackgroundOrBorder();
    17821752    if (fullRepaint) {
    1783         c->repaintViewRectangle(oldFullBounds);
     1753        v->repaintViewRectangle(oldFullBounds);
    17841754        if (newBounds != oldBounds)
    1785             c->repaintViewRectangle(newFullBounds);
     1755            v->repaintViewRectangle(newFullBounds);
    17861756        return true;
    17871757    }
    17881758
    1789     // We didn't move, but we did change size.  Invalidate the delta, which will consist of possibly 
     1759    // We didn't move, but we did change size.  Invalidate the delta, which will consist of possibly
    17901760    // two rectangles (but typically only one).
    17911761    int ow = style() ? style()->outlineSize() : 0;
    17921762    int width = abs(newBounds.width() - oldBounds.width());
    17931763    if (width)
    1794         c->repaintViewRectangle(IntRect(min(newBounds.x() + newBounds.width(), oldBounds.x() + oldBounds.width()) - borderRight() - ow,
     1764        v->repaintViewRectangle(IntRect(min(newBounds.x() + newBounds.width(), oldBounds.x() + oldBounds.width()) - borderRight() - ow,
    17951765            newBounds.y(),
    17961766            width + borderRight() + ow,
     
    17981768    int height = abs(newBounds.height() - oldBounds.height());
    17991769    if (height)
    1800         c->repaintViewRectangle(IntRect(newBounds.x(),
     1770        v->repaintViewRectangle(IntRect(newBounds.x(),
    18011771            min(newBounds.bottom(), oldBounds.bottom()) - borderBottom() - ow,
    18021772            max(newBounds.width(), oldBounds.width()),
     
    18221792    if (!needsLayout() || isText())
    18231793        return;
    1824    
     1794
    18251795    bool blockWithInlineChildren = (isRenderBlock() && !isTable() && normalChildNeedsLayout() && childrenInline());
    18261796    if (selfNeedsLayout()) {
     
    18431813    if (continuation() && !isInline())
    18441814        r.inflateY(collapsedMarginTop());
    1845    
    1846     if (isInlineFlow())
    1847         for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
     1815
     1816    if (isInlineFlow()) {
     1817        for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {
    18481818            if (!curr->isText())
    18491819                r.unite(curr->getAbsoluteRepaintRectWithOutline(ow));
     1820        }
     1821    }
    18501822
    18511823    return r;
     
    18811853    TextStream ts(&str);
    18821854    ts << renderName()
    1883         << "(" << (style() ? style()->refCount() : 0) << ")"
     1855       << "(" << (style() ? style()->refCount() : 0) << ")"
    18841856       << ": " << (void*)this << "  ";
    1885     if (isInline()) ts << "il ";
    1886     if (childrenInline()) ts << "ci ";
    1887     if (isFloating()) ts << "fl ";
    1888     if (isAnonymous()) ts << "an ";
    1889     if (isRelPositioned()) ts << "rp ";
    1890     if (isPositioned()) ts << "ps ";
    1891     if (needsLayout()) ts << "nl ";
    1892     if (m_recalcMinMax) ts << "rmm ";
    1893     if (style() && style()->zIndex()) ts << "zI: " << style()->zIndex();
     1857    if (isInline())
     1858        ts << "il ";
     1859    if (childrenInline())
     1860        ts << "ci ";
     1861    if (isFloating())
     1862        ts << "fl ";
     1863    if (isAnonymous())
     1864        ts << "an ";
     1865    if (isRelPositioned())
     1866        ts << "rp ";
     1867    if (isPositioned())
     1868        ts << "ps ";
     1869    if (needsLayout())
     1870        ts << "nl ";
     1871    if (m_recalcMinMax)
     1872        ts << "rmm ";
     1873    if (style() && style()->zIndex())
     1874        ts << "zI: " << style()->zIndex();
    18941875    if (element()) {
    18951876        if (element()->active())
     
    18991880        if (element()->focused())
    19001881            ts << "focus ";
    1901         ts << " <" <<  element()->localName().deprecatedString() << ">";
     1882        ts << " <" << element()->localName().deprecatedString() << ">";
    19021883        ts << " (" << xPos() << "," << yPos() << "," << width() << "," << height() << ")";
    19031884        if (isTableCell()) {
    1904             const RenderTableCell* cell = static_cast<const RenderTableCell *>(this);
     1885            const RenderTableCell* cell = static_cast<const RenderTableCell*>(this);
    19051886            ts << " [r=" << cell->row() << " c=" << cell->col() << " rs=" << cell->rowSpan() << " cs=" << cell->colSpan() << "]";
    19061887        }
     
    19091890}
    19101891
    1911 void RenderObject::dump(TextStream *stream, DeprecatedString ind) const
    1912 {
    1913     if (isAnonymous()) { *stream << " anonymous"; }
    1914     if (isFloating()) { *stream << " floating"; }
    1915     if (isPositioned()) { *stream << " positioned"; }
    1916     if (isRelPositioned()) { *stream << " relPositioned"; }
    1917     if (isText()) { *stream << " text"; }
    1918     if (isInline()) { *stream << " inline"; }
    1919     if (isReplaced()) { *stream << " replaced"; }
    1920     if (shouldPaintBackgroundOrBorder()) { *stream << " paintBackground"; }
    1921     if (needsLayout()) { *stream << " needsLayout"; }
    1922     if (minMaxKnown()) { *stream << " minMaxKnown"; }
     1892void RenderObject::dump(TextStream* stream, DeprecatedString ind) const
     1893{
     1894    if (isAnonymous())
     1895        *stream << " anonymous";
     1896    if (isFloating())
     1897        *stream << " floating";
     1898    if (isPositioned())
     1899        *stream << " positioned";
     1900    if (isRelPositioned())
     1901        *stream << " relPositioned";
     1902    if (isText())
     1903        *stream << " text";
     1904    if (isInline())
     1905        *stream << " inline";
     1906    if (isReplaced())
     1907        *stream << " replaced";
     1908    if (shouldPaintBackgroundOrBorder())
     1909        *stream << " paintBackground";
     1910    if (needsLayout())
     1911        *stream << " needsLayout";
     1912    if (minMaxKnown())
     1913        *stream << " minMaxKnown";
    19231914    *stream << endl;
    19241915
    1925     RenderObject *child = firstChild();
    1926     while( child != 0 )
    1927     {
     1916    RenderObject* child = firstChild();
     1917    while (child) {
    19281918        *stream << ind << child->renderName() << ": ";
    1929         child->dump(stream,ind+"  ");
     1919        child->dump(stream, ind + "  ");
    19301920        child = child->nextSibling();
    19311921    }
     
    19381928}
    19391929
    1940 #endif
    1941 
    1942 static Node *selectStartNode(const RenderObject *object)
    1943 {
    1944     Node *node = 0;
     1930#endif // NDEBUG
     1931
     1932static Node* selectStartNode(const RenderObject* object)
     1933{
     1934    Node* node = 0;
    19451935    bool forcedOn = false;
    19461936
    1947     for (const RenderObject *curr = object; curr; curr = curr->parent()) {
     1937    for (const RenderObject* curr = object; curr; curr = curr->parent()) {
    19481938        if (curr->style()->userSelect() == SELECT_TEXT)
    19491939            forcedOn = true;
     
    19681958bool RenderObject::shouldSelect() const
    19691959{
    1970     if (Node *node = selectStartNode(this))
     1960    if (Node* node = selectStartNode(this))
    19711961        return EventTargetNodeCast(node)->dispatchHTMLEvent(selectstartEvent, true, true);
    19721962
     
    20132003    const RenderObject* curr = this;
    20142004    while (curr) {
    2015         Node *elt = curr->element();
     2005        Node* elt = curr->element();
    20162006        if (elt && elt->nodeType() == Node::TEXT_NODE) {
    20172007            // Since there's no way for the author to address the -webkit-user-drag style for a text node,
     
    20202010                dhtmlWillDrag = false;
    20212011                return curr->node();
    2022             } else if (curr->shouldSelect()) {
     2012            } else if (curr->shouldSelect())
    20232013                // In this case we have a click in the unselected portion of text.  If this text is
    20242014                // selectable, we want to start the selection process instead of looking for a parent
    20252015                // to try to drag.
    20262016                return 0;
    2027             }
    20282017        } else {
    20292018            EUserDrag dragMode = curr->style()->userDrag();
     
    20502039RenderBlock* RenderObject::createAnonymousBlock()
    20512040{
    2052     RenderStyle *newStyle = new (renderArena()) RenderStyle();
     2041    RenderStyle* newStyle = new (renderArena()) RenderStyle();
    20532042    newStyle->inheritFrom(m_style);
    20542043    newStyle->setDisplay(BLOCK);
    20552044
    2056     RenderBlock *newBox = new (renderArena()) RenderBlock(document() /* anonymous box */);
     2045    RenderBlock* newBox = new (renderArena()) RenderBlock(document() /* anonymous box */);
    20572046    newBox->setStyle(newStyle);
    20582047    return newBox;
     
    20712060                RenderInline* parentInline = static_cast<RenderInline*>(parent());
    20722061                RenderBlock* newBox = parentInline->createAnonymousBlock();
    2073                
     2062
    20742063                RenderFlow* oldContinuation = parent()->continuation();
    20752064                parentInline->setContinuation(newBox);
     
    20782067                parent()->removeChildNode(this);
    20792068                parentInline->splitFlow(beforeChild, newBox, this, oldContinuation);
    2080             }
    2081             else if (parent()->isRenderBlock())
     2069            } else if (parent()->isRenderBlock())
    20822070                static_cast<RenderBlock*>(parent())->makeChildrenNonInline();
    2083         }
    2084         else {
     2071        } else {
    20852072            // An anonymous block must be made to wrap this inline.
    20862073            RenderBlock* box = createAnonymousBlock();
     
    20912078}
    20922079
    2093 void RenderObject::setStyle(RenderStyle *style)
     2080void RenderObject::setStyle(RenderStyle* style)
    20942081{
    20952082    if (m_style == style)
     
    21042091#if PLATFORM(MAC)
    21052092            if (m_style->visibility() != style->visibility() ||
    2106                 m_style->zIndex() != style->zIndex() ||
    2107                 m_style->hasAutoZIndex() != style->hasAutoZIndex())
     2093                    m_style->zIndex() != style->zIndex() ||
     2094                    m_style->hasAutoZIndex() != style->hasAutoZIndex())
    21082095                document()->setDashboardRegionsDirty(true);
    21092096#endif
    21102097
    21112098            if ((m_style->hasAutoZIndex() != style->hasAutoZIndex() ||
    2112                  m_style->zIndex() != style->zIndex() ||
    2113                  m_style->visibility() != style->visibility()) && layer()) {
     2099                    m_style->zIndex() != style->zIndex() ||
     2100                    m_style->visibility() != style->visibility()) && layer()) {
    21142101                layer()->stackingContext()->dirtyZOrderLists();
    21152102                if (m_style->hasAutoZIndex() != style->hasAutoZIndex() ||
    2116                     m_style->visibility() != style->visibility())
     2103                        m_style->visibility() != style->visibility())
    21172104                    layer()->dirtyZOrderLists();
    21182105            }
    21192106            // keep layer hierarchy visibility bits up to date if visibility changes
    21202107            if (m_style->visibility() != style->visibility()) {
    2121                 RenderLayer* l = enclosingLayer(); 
     2108                RenderLayer* l = enclosingLayer();
    21222109                if (style->visibility() == VISIBLE && l)
    21232110                    l->setHasVisibleContent(true);
    2124                 else if (l && l->hasVisibleContent() && 
    2125                     (this == l->renderer() || l->renderer()->style()->visibility() != VISIBLE))
     2111                else if (l && l->hasVisibleContent() &&
     2112                            (this == l->renderer() || l->renderer()->style()->visibility() != VISIBLE))
    21262113                    l->dirtyVisibleContentStatus();
    2127             }           
     2114            }
    21282115        }
    21292116
     
    21332120        if (d == RenderStyle::RepaintLayer && !layer())
    21342121            d = RenderStyle::Repaint;
    2135        
     2122
    21362123        // The background of the root element or the body element could propagate up to
    21372124        // the canvas.  Just dirty the entire canvas when our style changes substantially.
    21382125        if (d >= RenderStyle::Repaint && element() &&
    2139             (element()->hasTagName(htmlTag) || element()->hasTagName(bodyTag)))
     2126                (element()->hasTagName(htmlTag) || element()->hasTagName(bodyTag)))
    21402127            view()->repaint();
    21412128        else if (m_parent && !isText()) {
     
    21532140        // end up being destroyed.
    21542141        if (d == RenderStyle::Layout && layer() &&
    2155             (m_style->position() != style->position() ||
    2156              m_style->zIndex() != style->zIndex() ||
    2157              m_style->hasAutoZIndex() != style->hasAutoZIndex() ||
    2158              !(m_style->clip() == style->clip()) ||
    2159              m_style->hasClip() != style->hasClip() ||
    2160              m_style->opacity() != style->opacity()))
     2142                (m_style->position() != style->position() ||
     2143                 m_style->zIndex() != style->zIndex() ||
     2144                 m_style->hasAutoZIndex() != style->hasAutoZIndex() ||
     2145                 !(m_style->clip() == style->clip()) ||
     2146                 m_style->hasClip() != style->hasClip() ||
     2147                 m_style->opacity() != style->opacity()))
    21612148            layer()->repaintIncludingDescendants();
    21622149
     
    21682155                repaint();
    21692156            if (isRenderBlock()) {
    2170                 if (style->position() == StaticPosition) {
     2157                if (style->position() == StaticPosition)
    21712158                    // Clear our positioned objects list. Our absolutely positioned descendants will be
    21722159                    // inserted into our containing block's positioned objects list during layout.
    21732160                    removePositionedObjects(0);
    2174                 } else if (m_style->position() == StaticPosition) {
     2161                else if (m_style->position() == StaticPosition) {
    21752162                    // Remove our absolutely positioned descendants from their current containing block.
    21762163                    // They will be inserted into our positioned objects list during layout.
     
    21782165                    while (cb && (cb->style()->position() == StaticPosition || (cb->isInline() && !cb->isReplaced())) && !cb->isRoot() && !cb->isRenderView()) {
    21792166                        if (cb->style()->position() == RelativePosition && cb->isInline() && !cb->isReplaced()) {
    2180                             cb =  cb->containingBlock();
     2167                            cb = cb->containingBlock();
    21812168                            break;
    21822169                        }
     
    21872174            }
    21882175        }
    2189        
     2176
    21902177        if (isFloating() && (m_style->floating() != style->floating()))
    21912178            // For changes in float styles, we need to conceivably remove ourselves
     
    21962183            // from the positioned objects list.
    21972184            removeFromObjectLists();
    2198        
     2185
    21992186        affectsParentBlock = m_style && isFloatingOrPositioned() &&
    22002187            (!style->isFloating() && style->position() != AbsolutePosition && style->position() != FixedPosition)
    22012188            && parent() && (parent()->isBlockFlow() || parent()->isInlineFlow());
    2202        
     2189
    22032190        // reset style flags
    22042191        m_floating = false;
     
    22222209    }
    22232210
    2224     RenderStyle *oldStyle = m_style;
     2211    RenderStyle* oldStyle = m_style;
    22252212    m_style = style;
    22262213
    22272214    updateBackgroundImages(oldStyle);
    2228    
     2215
    22292216    if (m_style)
    22302217        m_style->ref();
    2231    
     2218
    22322219    if (oldStyle)
    22332220        oldStyle->deref(renderArena());
     
    22372224    if (affectsParentBlock)
    22382225        handleDynamicFloatPositionChange();
    2239    
     2226
    22402227    // No need to ever schedule repaints from a style change of a text run, since
    22412228    // we already did this for the parent of the text run.
     
    22482235}
    22492236
    2250 void RenderObject::setStyleInternal(RenderStyle* st)
    2251 {
    2252     if (m_style == st)
     2237void RenderObject::setStyleInternal(RenderStyle* style)
     2238{
     2239    if (m_style == style)
    22532240        return;
    22542241    if (m_style)
    22552242        m_style->deref(renderArena());
    2256     m_style = st;
     2243    m_style = style;
    22572244    if (m_style)
    22582245        m_style->ref();
     
    22722259            currNew->backgroundImage()->ref(this);
    22732260    }
    2274    
     2261
    22752262    CachedImage* oldBorderImage = oldStyle ? oldStyle->borderImage().image() : 0;
    22762263    CachedImage* newBorderImage = m_style ? m_style->borderImage().image() : 0;
     
    22882275}
    22892276
    2290 bool RenderObject::absolutePosition(int &xPos, int &yPos, bool f)
     2277bool RenderObject::absolutePosition(int& xPos, int& yPos, bool f)
    22912278{
    22922279    RenderObject* o = parent();
     
    22952282        yPos += o->borderTopExtra();
    22962283        if (o->hasOverflowClip())
    2297             o->layer()->subtractScrollOffset(xPos, yPos); 
     2284            o->layer()->subtractScrollOffset(xPos, yPos);
    22982285        return true;
    2299     }
    2300     else
    2301     {
     2286    } else {
    23022287        xPos = yPos = 0;
    23032288        return false;
     
    23052290}
    23062291
    2307 IntRect RenderObject::caretRect(int offset, EAffinity affinity, int *extraWidthToEndOfLine)
     2292IntRect RenderObject::caretRect(int offset, EAffinity affinity, int* extraWidthToEndOfLine)
    23082293{
    23092294   if (extraWidthToEndOfLine)
     
    23202305        w = containingBlock()->contentWidth();
    23212306    w = padding.calcMinValue(w);
    2322     if ( isTableCell() && padding.isAuto() )
    2323         w = static_cast<const RenderTableCell *>(this)->table()->cellPadding();
     2307    if (isTableCell() && padding.isAuto())
     2308        w = static_cast<const RenderTableCell*>(this)->table()->cellPadding();
    23242309    return w;
    23252310}
     
    23322317        w = containingBlock()->contentWidth();
    23332318    w = padding.calcMinValue(w);
    2334     if ( isTableCell() && padding.isAuto() )
    2335         w = static_cast<const RenderTableCell *>(this)->table()->cellPadding();
     2319    if (isTableCell() && padding.isAuto())
     2320        w = static_cast<const RenderTableCell*>(this)->table()->cellPadding();
    23362321    return w;
    23372322}
     
    23442329        w = containingBlock()->contentWidth();
    23452330    w = padding.calcMinValue(w);
    2346     if ( isTableCell() && padding.isAuto() )
    2347         w = static_cast<const RenderTableCell *>(this)->table()->cellPadding();
     2331    if (isTableCell() && padding.isAuto())
     2332        w = static_cast<const RenderTableCell*>(this)->table()->cellPadding();
    23482333    return w;
    23492334}
     
    23562341        w = containingBlock()->contentWidth();
    23572342    w = padding.calcMinValue(w);
    2358     if ( isTableCell() && padding.isAuto() )
    2359         w = static_cast<const RenderTableCell *>(this)->table()->cellPadding();
     2343    if (isTableCell() && padding.isAuto())
     2344        w = static_cast<const RenderTableCell*>(this)->table()->cellPadding();
    23602345    return w;
    23612346}
     
    23652350    if (style()->collapseWhiteSpace())
    23662351        return 0;
    2367        
     2352
    23682353    return containingBlock()->tabWidth(true);
    23692354}
     
    23792364}
    23802365
    2381 RenderObject *RenderObject::container() const
     2366RenderObject* RenderObject::container() const
    23822367{
    23832368    // This method is extremely similar to containingBlock(), but with a few notable
     
    23912376    // calcAbsoluteVertical have to use container().
    23922377    EPosition pos = m_style->position();
    2393     RenderObject *o = 0;
     2378    RenderObject* o = parent();
    23942379    if (!isText() && pos == FixedPosition) {
    23952380        // container() can be called on an object that is not in the
     
    23992384        // aren't we'll get the root of our little subtree (most likely
    24002385        // we'll just return 0).
    2401         o = parent();
    2402         while (o && o->parent()) o = o->parent();
    2403     }
    2404     else if (!isText() && pos == AbsolutePosition) {
     2386        while (o && o->parent())
     2387            o = o->parent();
     2388    } else if (!isText() && pos == AbsolutePosition) {
    24052389        // Same goes here.  We technically just want our containing block, but
    24062390        // we may not have one if we're part of an uninstalled subtree.  We'll
    24072391        // climb as high as we can though.
    2408         o = parent();
    24092392        while (o && o->style()->position() == StaticPosition && !o->isRenderView())
    24102393            o = o->parent();
    24112394    }
    2412     else
    2413         o = parent();
     2395
    24142396    return o;
    24152397}
     
    24272409    return st == SelectionStart || st == SelectionEnd || st == SelectionBoth;
    24282410}
    2429 
    24302411
    24312412void RenderObject::removeFromObjectLists()
     
    24402421                outermostBlock = p;
    24412422        }
    2442        
     2423
    24432424        if (outermostBlock)
    24442425            outermostBlock->markAllDescendantsWithFloatsForLayout(this);
     
    24462427
    24472428    if (isPositioned()) {
    2448         RenderObject *p;
     2429        RenderObject* p;
    24492430        for (p = parent(); p; p = p->parent()) {
    24502431            if (p->isRenderBlock())
     
    24852466        }
    24862467    }
    2487    
     2468
    24882469    document()->axObjectCache()->remove(this);
    24892470
    24902471    // By default no ref-counting. RenderWidget::destroy() doesn't call
    24912472    // this function because it needs to do ref-counting. If anything
    2492     // in this function changes, be sure to fix RenderWidget::destroy() as well. 
     2473    // in this function changes, be sure to fix RenderWidget::destroy() as well.
    24932474
    24942475    remove();
    2495    
     2476
    24962477    arenaDelete(document()->renderArena(), this);
    24972478}
    24982479
    2499 void RenderObject::arenaDelete(RenderArena *arena, void *base)
     2480void RenderObject::arenaDelete(RenderArena* arena, void* base)
    25002481{
    25012482    if (m_style->backgroundImage())
     
    25032484    if (m_style)
    25042485        m_style->deref(arena);
    2505    
     2486
    25062487#ifndef NDEBUG
    2507     void *savedBase = baseOfRenderObjectBeingDeleted;
     2488    void* savedBase = baseOfRenderObjectBeingDeleted;
    25082489    baseOfRenderObjectBeingDeleted = base;
    25092490#endif
     
    25122493    baseOfRenderObjectBeingDeleted = savedBase;
    25132494#endif
    2514    
     2495
    25152496    // Recover the size left there for us by operator delete and free the memory.
    2516     arena->free(*(size_t *)base, base);
     2497    arena->free(*(size_t*)base, base);
    25172498}
    25182499
     
    25202501{
    25212502    return VisiblePosition(element(), caretMinOffset(), DOWNSTREAM);
    2522 }
    2523 
    2524 bool RenderObject::isDragging() const
    2525 {
    2526     return m_isDragging;
    25272503}
    25282504
     
    25452521        // First test the foreground layer (lines and inlines).
    25462522        inside = nodeAtPoint(request, result, x, y, tx, ty, HitTestForeground);
    2547        
     2523
    25482524        // Test floats next.
    25492525        if (!inside)
     
    25542530            inside = nodeAtPoint(request, result, x, y, tx, ty, HitTestChildBlockBackgrounds);
    25552531    }
    2556    
     2532
    25572533    // See if the mouse is inside us but not any of our descendants
    25582534    if (hitTestFilter != HitTestDescendants && !inside)
    25592535        inside = nodeAtPoint(request, result, x, y, tx, ty, HitTestBlockBackground);
    2560        
     2536
    25612537    return inside;
    25622538}
     
    25752551        // split.  Go ahead and set our inner node accordingly.
    25762552        node = continuation()->element();
    2577          
     2553
    25782554    if (node) {
    25792555        result.setInnerNode(node);
     
    25832559}
    25842560
    2585 bool RenderObject::nodeAtPoint(const HitTestRequest& request, HitTestResult& result,
    2586                                 int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction)
     2561bool RenderObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, int /*x*/, int /*y*/, int /*tx*/, int /*ty*/, HitTestAction)
    25872562{
    25882563    return false;
    25892564}
    25902565
    2591 short RenderObject::verticalPositionHint( bool firstLine ) const
     2566short RenderObject::verticalPositionHint(bool firstLine) const
    25922567{
    25932568    short vpos = m_verticalPosition;
    2594     if ( m_verticalPosition == PositionUndefined || firstLine ) {
    2595         vpos = getVerticalPosition( firstLine );
    2596         if ( !firstLine )
     2569    if (m_verticalPosition == PositionUndefined || firstLine) {
     2570        vpos = getVerticalPosition(firstLine);
     2571        if (!firstLine)
    25972572            m_verticalPosition = vpos;
    25982573    }
     2574
    25992575    return vpos;
    2600 
    2601 }
    2602 
    2603 short RenderObject::getVerticalPosition( bool firstLine ) const
     2576}
     2577
     2578short RenderObject::getVerticalPosition(bool firstLine) const
    26042579{
    26052580    if (!isInline())
     
    26092584    int vpos = 0;
    26102585    EVerticalAlign va = style()->verticalAlign();
    2611     if ( va == TOP ) {
     2586    if (va == TOP)
    26122587        vpos = PositionTop;
    2613     } else if ( va == BOTTOM ) {
     2588    else if (va == BOTTOM)
    26142589        vpos = PositionBottom;
    2615     } else if ( va == LENGTH ) {
    2616         vpos = -style()->verticalAlignLength().calcValue( lineHeight( firstLine ) );
    2617     } else {
     2590    else if (va == LENGTH)
     2591        vpos = -style()->verticalAlignLength().calcValue(lineHeight(firstLine));
     2592    else {
    26182593        bool checkParent = parent()->isInline() && !parent()->isInlineBlockOrInlineTable() && parent()->style()->verticalAlign() != TOP && parent()->style()->verticalAlign() != BOTTOM;
    2619         vpos = checkParent ? parent()->verticalPositionHint( firstLine ) : 0;
     2594        vpos = checkParent ? parent()->verticalPositionHint(firstLine) : 0;
    26202595        // don't allow elements nested inside text-top to have a different valignment.
    2621         if ( va == BASELINE )
     2596        if (va == BASELINE)
    26222597            return vpos;
    26232598
    2624         const Font &f = parent()->font(firstLine);
     2599        const Font& f = parent()->font(firstLine);
    26252600        int fontsize = f.pixelSize();
    2626    
     2601
    26272602        if (va == SUB)
    2628             vpos += fontsize/5 + 1;
     2603            vpos += fontsize / 5 + 1;
    26292604        else if (va == SUPER)
    2630             vpos -= fontsize/3 + 1;
     2605            vpos -= fontsize / 3 + 1;
    26312606        else if (va == TEXT_TOP)
    26322607            vpos += baselinePosition(firstLine) - f.ascent();
    26332608        else if (va == MIDDLE)
    2634             vpos += - (int)(f.xHeight()/2) - lineHeight( firstLine )/2 + baselinePosition( firstLine );
     2609            vpos += -static_cast<int>(f.xHeight() / 2) - lineHeight(firstLine) / 2 + baselinePosition(firstLine);
    26352610        else if (va == TEXT_BOTTOM) {
    26362611            vpos += f.descent();
    26372612            if (!isReplaced())
    26382613                vpos -= font(firstLine).descent();
    2639         } else if ( va == BASELINE_MIDDLE )
    2640             vpos += - lineHeight( firstLine )/2 + baselinePosition( firstLine );
    2641     }
    2642    
     2614        } else if (va == BASELINE_MIDDLE)
     2615            vpos += -lineHeight(firstLine) / 2 + baselinePosition(firstLine);
     2616    }
     2617
    26432618    return vpos;
    26442619}
    26452620
    2646 short RenderObject::lineHeight( bool firstLine, bool ) const
     2621short RenderObject::lineHeight(bool firstLine, bool /*isRootLineBox*/) const
    26472622{
    26482623    RenderStyle* s = style(firstLine);
    2649    
     2624
    26502625    Length lh = s->lineHeight();
    26512626
     
    26702645{
    26712646    m_verticalPosition = PositionUndefined;
    2672     RenderObject *child = firstChild();
    2673     while( child ) {
     2647    RenderObject* child = firstChild();
     2648    while(child) {
    26742649        child->invalidateVerticalPositions();
    26752650        child = child->nextSibling();
     
    26792654void RenderObject::recalcMinMaxWidths()
    26802655{
    2681     ASSERT( m_recalcMinMax );
    2682 
    2683 #ifdef DEBUG_LAYOUT
    2684     kdDebug( 6040 ) << renderName() << " recalcMinMaxWidths() this=" << this <<endl;
    2685 #endif
     2656    ASSERT(m_recalcMinMax);
    26862657
    26872658    if (m_recalcMinMax)
    26882659        updateFirstLetter();
    2689    
    2690     RenderObject *child = firstChild();
    2691     while( child ) {
     2660
     2661    RenderObject* child = firstChild();
     2662    while (child) {
    26922663        int cmin = 0;
    26932664        int cmax = 0;
    26942665        bool test = false;
    2695         if ( ( m_minMaxKnown && child->m_recalcMinMax ) || !child->m_minMaxKnown ) {
     2666        if ((m_minMaxKnown && child->m_recalcMinMax) || !child->m_minMaxKnown) {
    26962667            cmin = child->minWidth();
    26972668            cmax = child->maxWidth();
    26982669            test = true;
    26992670        }
    2700         if ( child->m_recalcMinMax )
     2671        if (child->m_recalcMinMax)
    27012672            child->recalcMinMaxWidths();
    2702         if ( !child->m_minMaxKnown )
     2673        if (!child->m_minMaxKnown)
    27032674            child->calcMinMaxWidth();
    2704         if ( m_minMaxKnown && test && (cmin != child->minWidth() || cmax != child->maxWidth()) )
     2675        if (m_minMaxKnown && test && (cmin != child->minWidth() || cmax != child->maxWidth()))
    27052676            m_minMaxKnown = false;
    27062677        child = child->nextSibling();
     
    27132684        m_minMaxKnown = false;
    27142685
    2715     if ( !m_minMaxKnown )
     2686    if (!m_minMaxKnown)
    27162687        calcMinMaxWidth();
    27172688    m_recalcMinMax = false;
     
    27202691void RenderObject::scheduleRelayout()
    27212692{
    2722      if (isRenderView()) {
    2723          FrameView* view = static_cast<RenderView*>(this)->frameView();
    2724          if (view)
    2725              view->scheduleRelayout();
    2726      } else {
    2727          FrameView* v = view() ? view()->frameView() : 0;
    2728          if (v)
    2729              v->scheduleRelayoutOfSubtree(node());
    2730      }
    2731 }
    2732 
     2693    if (isRenderView()) {
     2694        FrameView* view = static_cast<RenderView*>(this)->frameView();
     2695        if (view)
     2696            view->scheduleRelayout();
     2697    } else {
     2698        FrameView* v = view() ? view()->frameView() : 0;
     2699        if (v)
     2700            v->scheduleRelayoutOfSubtree(node());
     2701    }
     2702}
    27332703
    27342704void RenderObject::removeLeftoverAnonymousBoxes()
     
    27512721}
    27522722
    2753 void RenderObject::setInlineBoxWrapper(InlineBox* b)
     2723void RenderObject::setInlineBoxWrapper(InlineBox*)
    27542724{
    27552725}
     
    27592729}
    27602730
    2761 RenderStyle* RenderObject::firstLineStyle() const 
    2762 {
    2763     RenderStyle *s = m_style;
     2731RenderStyle* RenderObject::firstLineStyle() const
     2732{
     2733    RenderStyle* s = m_style;
    27642734    const RenderObject* obj = isText() ? parent() : this;
    27652735    if (obj->isBlockFlow()) {
     
    27832753    if (!style()->hasPseudoStyle(pseudo))
    27842754        return 0;
    2785    
     2755
    27862756    if (!parentStyle)
    27872757        parentStyle = style();
     
    27902760    if (result)
    27912761        return result;
    2792    
     2762
    27932763    Node* node = element();
    27942764    if (isText())
     
    27962766    if (!node)
    27972767        return 0;
    2798    
     2768
    27992769    if (pseudo == RenderStyle::FIRST_LINE_INHERITED) {
    28002770        result = document()->styleSelector()->styleForElement(static_cast<Element*>(node), parentStyle, false);
     
    28432813        if (decorations & LINE_THROUGH)
    28442814            linethrough = curr->style()->color();
    2845     }       
     2815    }
    28462816}
    28472817
     
    28532823{
    28542824    // Convert the style regions to absolute coordinates.
    2855     if (style()->visibility() != VISIBLE) 
     2825    if (style()->visibility() != VISIBLE)
    28562826        return;
    28572827
    28582828    const Vector<StyleDashboardRegion>& styleRegions = style()->dashboardRegions();
    28592829    unsigned i, count = styleRegions.size();
    2860     for (i = 0; i < count; i++){
     2830    for (i = 0; i < count; i++) {
    28612831        StyleDashboardRegion styleRegion = styleRegions[i];
    2862        
     2832
    28632833        int w = width();
    28642834        int h = height();
    2865        
     2835
    28662836        DashboardRegionValue region;
    28672837        region.label = styleRegion.label;
    2868         region.bounds = IntRect (
    2869             styleRegion.offset.left.value(),
    2870             styleRegion.offset.top.value(),
    2871             w - styleRegion.offset.left.value() - styleRegion.offset.right.value(),
    2872             h - styleRegion.offset.top.value() - styleRegion.offset.bottom.value());
     2838        region.bounds = IntRect(styleRegion.offset.left.value(),
     2839                                styleRegion.offset.top.value(),
     2840                                w - styleRegion.offset.left.value() - styleRegion.offset.right.value(),
     2841                                h - styleRegion.offset.top.value() - styleRegion.offset.bottom.value());
    28732842        region.type = styleRegion.type;
    28742843
     
    28842853        region.bounds.setX(x + styleRegion.offset.left.value());
    28852854        region.bounds.setY(y + styleRegion.offset.top.value());
    2886        
     2855
    28872856        if (document()->frame()) {
    28882857            float pageScaleFactor = document()->frame()->page()->chrome()->scaleFactor();
     
    28922861            }
    28932862        }
    2894        
     2863
    28952864        regions.append(region);
    28962865    }
     
    29032872    if (isText())
    29042873        return;
    2905        
     2874
    29062875    addDashboardRegions(regions);
    29072876    for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
     
    29092878}
    29102879
    2911 
    29122880void RenderObject::collectBorders(DeprecatedValueList<CollapsedBorderValue>& borderStyles)
    29132881{
     
    29182886bool RenderObject::avoidsFloats() const
    29192887{
    2920     return isReplaced() || hasOverflowClip() || isHR(); 
     2888    return isReplaced() || hasOverflowClip() || isHR();
    29212889}
    29222890
     
    29322900
    29332901CounterNode* RenderObject::findCounter(const String& counterName, bool willNeedLayout,
    2934     bool usesSeparator, bool createIfNotFound)
     2902                                       bool usesSeparator, bool createIfNotFound)
    29352903{
    29362904    if (!style())
     
    29392907    RenderObjectsToCounterNodeMaps* objectsMap = getRenderObjectsToCounterNodeMaps();
    29402908    CounterNode* newNode = 0;
    2941     if (CounterNodeMap* counterNodesMap = objectsMap->get(this))
     2909    if (CounterNodeMap* counterNodesMap = objectsMap->get(this)) {
    29422910        if (counterNodesMap)
    29432911            newNode = counterNodesMap->get(counterName);
    2944        
     2912    }
     2913
    29452914    if (newNode)
    29462915        return newNode;
     
    29642933                    val = v.toInt();
    29652934                }
    2966             } 
    2967            
     2935            }
     2936
    29682937            if (!newNode) {
    29692938                newNode = new CounterNode(this);
     
    29822951            newNode->setValue(0);
    29832952        }
    2984     } 
    2985    
     2953    }
     2954
    29862955    if (!newNode && !createIfNotFound)
    29872956        return 0;
     
    30042973        m_hasCounterNodeMap = true;
    30052974    }
    3006    
     2975
    30072976    nodeMap->set(counterName, newNode);
    30082977
     
    30172986                break;
    30182987        }
    3019        
     2988
    30202989        CounterNode* last = current;
    30212990        CounterNode* sibling = current;
     
    30363005                n = n->previousSibling();
    30373006            }
    3038            
     3007
    30393008            if (sibling->isReset()) {
    30403009                if (last != sibling)
     
    30593028UChar RenderObject::backslashAsCurrencySymbol() const
    30603029{
    3061     if (Node *node = element())
    3062         if (TextResourceDecoder *decoder = node->document()->decoder())
     3030    if (Node *node = element()) {
     3031        if (TextResourceDecoder* decoder = node->document()->decoder())
    30633032            return decoder->encoding().backslashAsCurrencySymbol();
     3033    }
    30643034    return '\\';
    30653035}
    30663036
    3067 void RenderObject::imageChanged(CachedImage *image)
     3037void RenderObject::imageChanged(CachedImage* image)
    30683038{
    30693039    // Repaint when the background image or border image finishes loading.
     
    30743044    if (image && image->canRender() && parent()) {
    30753045        if (view() && element() && (element()->hasTagName(htmlTag) || element()->hasTagName(bodyTag)))
    3076             view()->repaint();    // repaint the entire canvas since the background gets propagated up
     3046            // repaint the entire canvas since the background gets propagated up
     3047            view()->repaint();
    30773048        else
    3078             repaint();              // repaint object, which is a box or a container with boxes inside it
     3049            // repaint object, which is a box or a container with boxes inside it
     3050            repaint();
    30793051    }
    30803052}
     
    31133085}
    31143086
    3115 int RenderObject::previousOffset (int current) const
     3087int RenderObject::previousOffset(int current) const
    31163088{
    31173089    int previousOffset = current - 1;
     
    31193091}
    31203092
    3121 int RenderObject::nextOffset (int current) const
     3093int RenderObject::nextOffset(int current) const
    31223094{
    31233095    int nextOffset = current + 1;
     
    31253097}
    31263098
    3127 InlineBox *RenderObject::inlineBox(int offset, EAffinity affinity)
     3099InlineBox* RenderObject::inlineBox(int offset, EAffinity affinity)
    31283100{
    31293101    return inlineBoxWrapper();
     
    31413113    return AffineTransform(1, 0, 0, 1, xPos(), yPos());
    31423114}
    3143  
     3115
    31443116void RenderObject::setLocalTransform(const AffineTransform&)
    31453117{
     
    31543126}
    31553127
    3156 #endif
    3157 
    3158 }
     3128#endif // SVG_SUPPORT
     3129
     3130} // namespace WebCore
    31593131
    31603132#ifndef NDEBUG
  • trunk/WebCore/rendering/RenderObject.h

    r17667 r17677  
    3333#include "ScrollBar.h"
    3434#include "VisiblePosition.h"
     35#include <algorithm>
    3536#include <wtf/HashMap.h>
    3637
     
    5657class FrameView;
    5758class HTMLAreaElement;
     59class HitTestResult;
    5860class InlineBox;
    5961class InlineFlowBox;
    60 class HitTestResult;
    6162class PlatformScrollbar;
    6263class Position;
     
    7273class TextStream;
    7374class VisiblePosition;
    74 
    7575struct HitTestRequest;
    7676
     
    108108};
    109109
    110 struct DashboardRegionValue
    111 {
     110enum VerticalPositionHint {
     111    PositionTop = -0x4000,
     112    PositionBottom = 0x4000,
     113    PositionUndefined = 0x3fff
     114};
     115
     116struct DashboardRegionValue {
     117    bool operator==(const DashboardRegionValue& o) const
     118    {
     119        return type == o.type && bounds == o.bounds && label == o.label;
     120    }
     121
    112122    String label;
    113123    IntRect bounds;
    114124    IntRect clip;
    115125    int type;
    116 
    117     bool operator==(const DashboardRegionValue& o) const
    118     {
    119         return type == o.type && bounds == o.bounds && label == o.label;
    120     }
    121126};
    122127
     
    128133 * Base Class for all rendering tree objects.
    129134 */
    130 class RenderObject : public CachedResourceClient
    131 {
     135class RenderObject : public CachedResourceClient {
     136    friend class RenderListItem;
     137    friend class RenderContainer;
     138    friend class RenderView;
    132139public:
    133140    // Anonymous objects should pass the document as their node, and they will then automatically be
    134141    // marked as anonymous in the constructor.
    135     RenderObject(Node* node);
     142    RenderObject(Node*);
    136143    virtual ~RenderObject();
    137144
    138     RenderObject *parent() const { return m_parent; }
    139     bool isDescendantOf(const RenderObject *obj) const;
    140 
    141     RenderObject *previousSibling() const { return m_previous; }
    142     RenderObject *nextSibling() const { return m_next; }
    143 
    144     virtual RenderObject *firstChild() const { return 0; }
    145     virtual RenderObject *lastChild() const { return 0; }
     145    virtual const char* renderName() const { return "RenderObject"; }
     146
     147    RenderObject* parent() const { return m_parent; }
     148    bool isDescendantOf(const RenderObject*) const;
     149
     150    RenderObject* previousSibling() const { return m_previous; }
     151    RenderObject* nextSibling() const { return m_next; }
     152
     153    virtual RenderObject* firstChild() const { return 0; }
     154    virtual RenderObject* lastChild() const { return 0; }
    146155
    147156    RenderObject* nextInPreOrder() const;
     
    150159    RenderObject* childAt(unsigned) const;
    151160
    152     RenderObject *nextEditable() const;
    153     RenderObject *previousEditable() const;
    154 
    155     RenderObject *firstLeafChild() const;
    156     RenderObject *lastLeafChild() const;
    157    
     161    RenderObject* nextEditable() const;
     162    RenderObject* previousEditable() const;
     163
     164    RenderObject* firstLeafChild() const;
     165    RenderObject* lastLeafChild() const;
     166
    158167    virtual RenderLayer* layer() const { return 0; }
    159168    RenderLayer* enclosingLayer() const;
     
    161170    void removeLayers(RenderLayer* parentLayer);
    162171    void moveLayers(RenderLayer* oldParent, RenderLayer* newParent);
    163     RenderLayer* findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint,
    164                                bool checkParent=true);
     172    RenderLayer* findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint, bool checkParent = true);
    165173    virtual void positionChildLayers() { }
    166174    virtual bool requiresLayer();
    167    
    168     virtual IntRect getOverflowClipRect(int tx, int ty) { return IntRect(0,0,0,0); }
    169     virtual IntRect getClipRect(int tx, int ty) { return IntRect(0,0,0,0); }
     175
     176    virtual IntRect getOverflowClipRect(int /*tx*/, int /*ty*/) { return IntRect(0, 0, 0, 0); }
     177    virtual IntRect getClipRect(int /*tx*/, int /*ty*/) { return IntRect(0, 0, 0, 0); }
    170178    bool hasClip() { return isPositioned() &&  style()->hasClip(); }
    171    
    172     virtual int getBaselineOfFirstLineBox() const { return -1; } 
     179
     180    virtual int getBaselineOfFirstLineBox() const { return -1; }
    173181    virtual int getBaselineOfLastLineBox() const { return -1; }
     182
    174183    virtual bool isEmpty() const { return firstChild() == 0; }
    175        
     184
    176185    virtual bool isEdited() const { return false; }
    177     virtual void setEdited(bool) { return; };
    178    
     186    virtual void setEdited(bool) { }
     187
    179188    // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
    180189    // children.
    181190    virtual RenderBlock* firstLineBlock() const;
    182191    virtual void updateFirstLetter();
    183    
     192
    184193    // Called when an object that was floating or positioned becomes a normal flow object
    185194    // again.  We have to make sure the render tree updates as needed to accommodate the new
     
    190199    // style from this RenderObject.
    191200    RenderBlock* createAnonymousBlock();
    192    
     201
    193202    // Whether or not a positioned element requires normal flow x/y to be computed
    194203    // to determine its position.
    195204    bool hasStaticX() const;
    196205    bool hasStaticY() const;
    197     virtual void setStaticX(int staticX) {};
    198     virtual void setStaticY(int staticY) {};
     206    virtual void setStaticX(int /*staticX*/) { }
     207    virtual void setStaticY(int /*staticY*/) { }
    199208    virtual int staticX() const { return 0; }
    200209    virtual int staticY() const { return 0; }
    201    
     210
    202211    CounterNode* findCounter(const String& counterName, bool willNeedLayout = false,
    203         bool usesSeparator = false, bool createIfNotFound = true);
    204 
    205 public:
     212                             bool usesSeparator = false, bool createIfNotFound = true);
     213
    206214    // RenderObject tree manipulation
    207215    //////////////////////////////////////////
    208216    virtual bool canHaveChildren() const;
    209     virtual void addChild(RenderObject *newChild, RenderObject *beforeChild = 0);
    210     virtual void removeChild(RenderObject *oldChild);
     217    virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
     218    virtual void removeChild(RenderObject*);
    211219    virtual bool createsAnonymousWrapper() const { return false; }
    212220
    213221    // raw tree manipulation
    214     virtual RenderObject* removeChildNode(RenderObject* child);
    215     virtual void appendChildNode(RenderObject* child);
     222    virtual RenderObject* removeChildNode(RenderObject*);
     223    virtual void appendChildNode(RenderObject*);
    216224    virtual void insertChildNode(RenderObject* child, RenderObject* before);
    217225    //////////////////////////////////////////
     
    220228    //////////////////////////////////////////
    221229    // Helper functions. Dangerous to use!
    222     void setPreviousSibling(RenderObject *previous) { m_previous = previous; }
    223     void setNextSibling(RenderObject *next) { m_next = next; }
    224     void setParent(RenderObject *parent) { m_parent = parent; }
     230    void setPreviousSibling(RenderObject* previous) { m_previous = previous; }
     231    void setNextSibling(RenderObject* next) { m_next = next; }
     232    void setParent(RenderObject* parent) { m_parent = parent; }
    225233    //////////////////////////////////////////
    226234private:
     
    228236
    229237public:
    230     virtual const char *renderName() const { return "RenderObject"; }
    231238#ifndef NDEBUG
    232239    DeprecatedString information() const;
    233     virtual void dump(TextStream *stream, DeprecatedString ind = "") const;
     240    virtual void dump(TextStream*, DeprecatedString ind = "") const;
    234241    void showTreeForThis() const;
    235242#endif
    236243
    237     static RenderObject *createObject(Node* node, RenderStyle* style);
     244    static RenderObject* createObject(Node*, RenderStyle*);
    238245
    239246    // Overloaded new operator.  Derived classes must override operator new
    240247    // in order to allocate out of the RenderArena.
    241     void* operator new(size_t sz, RenderArena* renderArena) throw();   
     248    void* operator new(size_t, RenderArena*) throw();
    242249
    243250    // Overridden to prevent the normal delete from being called.
    244     void operator delete(void* ptr, size_t sz);
    245        
     251    void operator delete(void*, size_t);
     252
    246253private:
    247254    // The normal operator new is disallowed on all render objects.
    248     void* operator new(size_t sz) throw();
    249    
     255    void* operator new(size_t) throw();
     256
    250257public:
    251258    RenderArena* renderArena() const;
    252    
     259
    253260    // some helper functions...
    254261    virtual bool isRenderBlock() const { return false; }
     
    257264    virtual bool isBlockFlow() const { return false; }
    258265    virtual bool isInlineBlockOrInlineTable() const { return false; }
    259     virtual bool childrenInline() const { return false; }
    260     virtual void setChildrenInline(bool b) { };
    261 
    262     virtual RenderFlow* continuation() const;
    263266    virtual bool isInlineContinuation() const;
    264    
    265267    virtual bool isListItem() const { return false; }
    266268    virtual bool isListMarker() const { return false; }
    267269    virtual bool isCounter() const { return false; }
    268270    virtual bool isRenderView() const { return false; }
    269     bool isRoot() const;
    270     bool isBody() const;
    271     bool isHR() const;
    272271    virtual bool isBR() const { return false; }
    273272    virtual bool isTableCell() const { return false; }
     
    285284    virtual bool isMenuList() const { return false; }
    286285    virtual bool isListBox() const { return false; }
    287    
     286
     287    bool isRoot() const;
     288    bool isBody() const;
     289    bool isHR() const;
     290
     291    bool isHTMLMarquee() const;
     292
     293    virtual bool childrenInline() const { return false; }
     294    virtual void setChildrenInline(bool) { }
     295
     296    virtual RenderFlow* continuation() const;
     297
    288298#ifdef SVG_SUPPORT
    289299    virtual bool isKCanvasContainer() const { return false; }
     
    295305    virtual AffineTransform absoluteTransform() const;
    296306#endif
    297    
     307
    298308    virtual bool isEditable() const;
    299309
    300     bool isHTMLMarquee() const;
    301    
    302310    bool isAnonymous() const { return m_isAnonymous; }
    303311    void setIsAnonymous(bool b) { m_isAnonymous = b; }
    304     bool isAnonymousBlock() const { return m_isAnonymous &&
    305                                            style()->display() == BLOCK &&
    306                                            style()->styleType() == RenderStyle::NOPSEUDO &&
    307                                            !isListMarker(); }
    308    
     312    bool isAnonymousBlock() const
     313    {
     314        return m_isAnonymous && style()->display() == BLOCK && style()->styleType() == RenderStyle::NOPSEUDO && !isListMarker();
     315    }
     316
    309317    bool isFloating() const { return m_floating; }
    310318    bool isPositioned() const { return m_positioned; } // absolute or fixed positioning
     
    314322    bool isCompact() const { return style()->display() == COMPACT; } // compact object
    315323    bool isRunIn() const { return style()->display() == RUN_IN; } // run-in object
    316     bool isDragging() const;
     324    bool isDragging() const { return m_isDragging; }
    317325    bool isReplaced() const { return m_replaced; } // a "replaced" element (see CSS)
     326
    318327    bool shouldPaintBackgroundOrBorder() const { return m_paintBackground; }
    319328    bool mustRepaintBackgroundOrBorder() const;
    320     bool needsLayout() const   { return m_needsLayout || m_normalChildNeedsLayout || m_posChildNeedsLayout; }
     329
     330    bool needsLayout() const { return m_needsLayout || m_normalChildNeedsLayout || m_posChildNeedsLayout; }
    321331    bool selfNeedsLayout() const { return m_needsLayout; }
    322332    bool posChildNeedsLayout() const { return m_posChildNeedsLayout; }
    323333    bool normalChildNeedsLayout() const { return m_normalChildNeedsLayout; }
     334
    324335    bool minMaxKnown() const{ return m_minMaxKnown; }
    325336    bool recalcMinMax() const { return m_recalcMinMax; }
     337
    326338    bool isSelectionBorder() const;
    327    
     339
    328340    bool hasOverflowClip() const { return m_hasOverflowClip; }
    329    
     341
    330342    bool hasAutoVerticalScrollbar() const { return hasOverflowClip() && (style()->overflowY() == OAUTO || style()->overflowY() == OOVERLAY); }
    331343    bool hasAutoHorizontalScrollbar() const { return hasOverflowClip() && (style()->overflowX() == OAUTO || style()->overflowX() == OOVERLAY); }
     
    334346    bool scrollsOverflowX() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || hasAutoHorizontalScrollbar()); }
    335347    bool scrollsOverflowY() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || hasAutoVerticalScrollbar()); }
    336    
     348
    337349    bool includeVerticalScrollbarSize() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || style()->overflowY() == OAUTO); }
    338350    bool includeHorizontalScrollbarSize() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || style()->overflowX() == OAUTO); }
    339351
    340     RenderStyle* getPseudoStyle(RenderStyle::PseudoId pseudo, RenderStyle* parentStyle = 0) const;
    341    
     352    RenderStyle* getPseudoStyle(RenderStyle::PseudoId, RenderStyle* parentStyle = 0) const;
     353
    342354    void updateDragState(bool dragOn);
    343355
     
    349361    void setNode(Node* node) { m_node = node; }
    350362    Node* node() const { return m_node; }
    351    
     363
    352364    bool hasOutlineAnnotation() const;
    353365    bool hasOutline() const { return style()->hasOutline() || hasOutlineAnnotation(); }
    354    
     366
    355367   /**
    356368     * returns the object containing this one. can be different from parent for
    357369     * positioned elements
    358370     */
    359     RenderObject *container() const;
     371    RenderObject* container() const;
    360372    RenderObject* hoverAncestor() const;
    361373
     
    364376    void setNeedsLayout(bool b, bool markParents = true);
    365377    void setChildNeedsLayout(bool b, bool markParents = true);
    366     void setMinMaxKnown(bool b=true) {
     378
     379    void setMinMaxKnown(bool b = true)
     380    {
    367381        m_minMaxKnown = b;
    368         if ( !b ) {
    369             RenderObject *o = this;
    370             RenderObject *root = this;
    371             while( o ) { // ### && !o->m_recalcMinMax ) {
     382        if (!b) {
     383            RenderObject* o = this;
     384            RenderObject* root = this;
     385            while(o) { // FIXME: && !o->m_recalcMinMax ) {
    372386                o->m_recalcMinMax = true;
    373387                root = o;
     
    377391    }
    378392
    379     void setNeedsLayoutAndMinMaxRecalc() {
     393    void setNeedsLayoutAndMinMaxRecalc()
     394    {
    380395        setMinMaxKnown(false);
    381396        setNeedsLayout(true);
    382397    }
    383    
    384     void setPositioned(bool b=true)  { m_positioned = b;  }
    385     void setRelPositioned(bool b=true) { m_relPositioned = b; }
    386     void setFloating(bool b=true) { m_floating = b; }
    387     void setInline(bool b=true) { m_inline = b; }
    388     void setShouldPaintBackgroundOrBorder(bool b=true) { m_paintBackground = b; }
     398
     399    void setPositioned(bool b = true)  { m_positioned = b;  }
     400    void setRelPositioned(bool b = true) { m_relPositioned = b; }
     401    void setFloating(bool b = true) { m_floating = b; }
     402    void setInline(bool b = true) { m_inline = b; }
     403    void setShouldPaintBackgroundOrBorder(bool b = true) { m_paintBackground = b; }
    389404    void setRenderText() { m_isText = true; }
    390     void setReplaced(bool b=true) { m_replaced = b; }
     405    void setReplaced(bool b = true) { m_replaced = b; }
    391406    void setHasOverflowClip(bool b = true) { m_hasOverflowClip = b; }
    392407
    393408    void scheduleRelayout();
    394    
     409
    395410    void updateBackgroundImages(RenderStyle* oldStyle);
    396411
    397     virtual InlineBox* createInlineBox(bool makePlaceHolderBox, bool isRootLineBox, bool isOnlyRun=false);
    398     virtual void dirtyLineBoxes(bool fullLayout, bool isRootLineBox=false);
    399    
     412    virtual InlineBox* createInlineBox(bool makePlaceHolderBox, bool isRootLineBox, bool isOnlyRun = false);
     413    virtual void dirtyLineBoxes(bool fullLayout, bool isRootLineBox = false);
     414
    400415    // For inline replaced elements, this function returns the inline box that owns us.  Enables
    401416    // the replaced RenderObject to quickly determine what line it is contained on and to easily
    402417    // iterate over structures on the line.
    403418    virtual InlineBox* inlineBoxWrapper() const;
    404     virtual void setInlineBoxWrapper(InlineBox* b);
     419    virtual void setInlineBoxWrapper(InlineBox*);
    405420    virtual void deleteLineBoxWrapper();
    406421
    407     virtual InlineBox *inlineBox(int offset=0, EAffinity affinity = UPSTREAM);
    408    
     422    virtual InlineBox* inlineBox(int offset = 0, EAffinity = UPSTREAM);
     423
    409424    // for discussion of lineHeight see CSS2 spec
    410     virtual short lineHeight( bool firstLine, bool isRootLineBox=false ) const;
     425    virtual short lineHeight(bool firstLine, bool isRootLineBox = false) const;
    411426    // for the vertical-align property of inline elements
    412427    // the difference between this objects baseline position and the lines baseline position.
    413     virtual short verticalPositionHint( bool firstLine ) const;
     428    virtual short verticalPositionHint(bool firstLine) const;
    414429    // the offset of baseline from the top of the object.
    415     virtual short baselinePosition( bool firstLine, bool isRootLineBox=false ) const;
     430    virtual short baselinePosition(bool firstLine, bool isRootLineBox = false) const;
    416431    // width of tab character
    417432    int tabWidth() const;
     
    422437     */
    423438    struct PaintInfo {
    424         PaintInfo(GraphicsContext* newContext, const IntRect& newRect, PaintPhase newPhase, bool newForceWhiteText, RenderObject* newPaintingRoot, RenderFlowSequencedSet* newOutlineObjects)
     439        PaintInfo(GraphicsContext* newContext, const IntRect& newRect, PaintPhase newPhase, bool newForceWhiteText,
     440                  RenderObject* newPaintingRoot, RenderFlowSequencedSet* newOutlineObjects)
    425441            : context(newContext)
    426442            , rect(newRect)
     
    442458    virtual void paint(PaintInfo&, int tx, int ty);
    443459    void paintBorder(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, bool begin = true, bool end = true);
    444     bool paintBorderImage(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle* style);
    445     void paintOutline(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle* style);
     460    bool paintBorderImage(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*);
     461    void paintOutline(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*);
    446462
    447463    // RenderBox implements this.
    448464    virtual void paintBoxDecorations(PaintInfo&, int tx, int ty) { }
    449465
    450     virtual void paintBackgroundExtended(GraphicsContext*, const Color&, const BackgroundLayer*, int clipy, int cliph,
    451         int tx, int ty, int w, int height, int bleft, int bright, int pleft, int pright) {}
     466    virtual void paintBackgroundExtended(GraphicsContext*, const Color&, const BackgroundLayer*,
     467                                         int clipy, int cliph, int tx, int ty, int width, int height,
     468                                         int bleft, int bright, int pleft, int pright) { }
    452469
    453470    /*
     
    475492     * objects)
    476493     */
    477     virtual void calcWidth() {}
     494    virtual void calcWidth() { }
    478495
    479496    /*
     
    494511    // used for element state updates that can not be fixed with a
    495512    // repaint and do not need a relayout
    496     virtual void updateFromElement() {};
     513    virtual void updateFromElement() { }
    497514
    498515    virtual int availableHeight() const { return 0; }
    499516
    500517    virtual void updateWidgetPosition();
    501    
     518
    502519    void addDashboardRegions(Vector<DashboardRegionValue>&);
    503520    void collectDashboardRegions(Vector<DashboardRegionValue>&);
     
    506523    // layout is complete.
    507524    struct RepaintInfo {
     525        RepaintInfo(RenderObject* object, const IntRect& repaintRect)
     526            : m_object(object)
     527            , m_repaintRect(repaintRect)
     528        {
     529        }
     530
    508531        RenderObject* m_object;
    509532        IntRect m_repaintRect;
    510    
    511         RepaintInfo(RenderObject* o, const IntRect& r) :m_object(o), m_repaintRect(r) {}
    512533    };
    513    
    514     bool hitTest(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestFilter hitTestFilter = HitTestAll);
     534
     535    bool hitTest(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestFilter = HitTestAll);
    515536    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
    516537    void setInnerNode(HitTestResult&);
     
    518539    virtual VisiblePosition positionForCoordinates(int x, int y);
    519540    VisiblePosition positionForPoint(const IntPoint& point) { return positionForCoordinates(point.x(), point.y()); }
    520    
    521     virtual void dirtyLinesFromChangedChild(RenderObject* child);
    522    
     541
     542    virtual void dirtyLinesFromChangedChild(RenderObject*);
     543
    523544    // Set the style of the object and update the state of the object accordingly.
    524     virtual void setStyle(RenderStyle* style);
     545    virtual void setStyle(RenderStyle*);
    525546
    526547    // Updates only the local style ptr of the object.  Does not update the state of the object,
    527548    // and so only should be called when the style is known not to have changed (or from setStyle).
    528     void setStyleInternal(RenderStyle* style);
     549    void setStyleInternal(RenderStyle*);
    529550
    530551    // returns the containing block level element for this element.
    531     RenderBlock *containingBlock() const;
     552    RenderBlock* containingBlock() const;
    532553
    533554    // return just the width of the containing block
     
    548569    virtual int overrideWidth() const { return 0; }
    549570    virtual int overrideHeight() const { return 0; }
    550     virtual void setOverrideSize(int s) {}
     571    virtual void setOverrideSize(int /*overrideSize*/) { }
    551572
    552573    // relative to parent node
    553     virtual void setPos( int /*xPos*/, int /*yPos*/ ) { }
    554     virtual void setWidth( int /*width*/ ) { }
    555     virtual void setHeight( int /*height*/ ) { }
     574    virtual void setPos(int /*xPos*/, int /*yPos*/) { }
     575    virtual void setWidth(int /*width*/) { }
     576    virtual void setHeight(int /*height*/) { }
    556577
    557578    virtual int xPos() const { return 0; }
     
    559580
    560581    // calculate client position of box
    561     virtual bool absolutePosition(int &/*xPos*/, int &/*yPos*/, bool fixed = false);
    562    
     582    virtual bool absolutePosition(int& /*xPos*/, int& /*yPos*/, bool /*fixed*/ = false);
     583
    563584    // This function is used to deal with the extra top space that can occur in table cells (called borderTopExtra).
    564585    // The children of the cell do not factor this space in, so we have to add it in.  Any code that wants to
    565586    // accurately deal with the contents of a cell must call this function instad of absolutePosition.
    566     void absolutePositionForContent(int& xPos, int& yPos, bool fixed = false) {
     587    void absolutePositionForContent(int& xPos, int& yPos, bool fixed = false)
     588    {
    567589        absolutePosition(xPos, yPos, fixed);
    568590        yPos += borderTopExtra();
     
    578600    // of the block (e.g., a <div style="height:25px"> that has a 100px tall image inside
    579601    // it would have an overflow height of borderTop() + paddingTop() + 100px.
    580     virtual int overflowHeight(bool includeInterior=true) const { return height(); }
    581     virtual int overflowWidth(bool includeInterior=true) const { return width(); }
    582     virtual void setOverflowHeight(int) {}
    583     virtual void setOverflowWidth(int) {}
    584     virtual int overflowLeft(bool includeInterior=true) const { return 0; }
    585     virtual int overflowTop(bool includeInterior=true) const { return 0; }
    586     virtual IntRect overflowRect(bool includeInterior=true) const { return borderBox(); }
    587 
    588     // IE extensions. Used to calculate offsetWidth/Height.  Overridden by inlines (RenderFlow) 
     602    virtual int overflowHeight(bool /*includeInterior*/ = true) const { return height(); }
     603    virtual int overflowWidth(bool /*includeInterior*/ = true) const { return width(); }
     604    virtual void setOverflowHeight(int) { }
     605    virtual void setOverflowWidth(int) { }
     606    virtual int overflowLeft(bool /*includeInterior*/ = true) const { return 0; }
     607    virtual int overflowTop(bool /*includeInterior*/ = true) const { return 0; }
     608    virtual IntRect overflowRect(bool /*includeInterior*/ = true) const { return borderBox(); }
     609
     610    // IE extensions. Used to calculate offsetWidth/Height.  Overridden by inlines (RenderFlow)
    589611    // to return the remaining width on a given line (and the height of a single line). -dwh
    590612    virtual int offsetWidth() const { return width(); }
    591613    virtual int offsetHeight() const { return height() + borderTopExtra() + borderBottomExtra(); }
    592    
    593     // IE exxtensions.  Also supported by Gecko.  We override in render flow to get the
     614
     615    // IE extensions.  Also supported by Gecko.  We override in render flow to get the
    594616    // left and top correct. -dwh
    595617    virtual int offsetLeft() const;
     
    616638    virtual void setScrollTop(int);
    617639
    618     virtual bool scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier=1.0);
     640    virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f);
    619641    virtual bool shouldAutoscroll() const;
    620642    virtual void autoscroll();
    621     virtual void stopAutoscroll() {};
     643    virtual void stopAutoscroll() { }
    622644
    623645    // The following seven functions are used to implement collapsing margins.
     
    628650    // methods.
    629651    virtual bool isSelfCollapsingBlock() const { return false; }
    630     virtual int collapsedMarginTop() const
    631         { return maxTopMargin(true)-maxTopMargin(false); }
    632     virtual int collapsedMarginBottom() const
    633         { return maxBottomMargin(true)-maxBottomMargin(false); }
     652    virtual int collapsedMarginTop() const { return maxTopMargin(true) - maxTopMargin(false); }
     653    virtual int collapsedMarginBottom() const { return maxBottomMargin(true) - maxBottomMargin(false); }
    634654    virtual bool isTopMarginQuirk() const { return false; }
    635655    virtual bool isBottomMarginQuirk() const { return false; }
    636     virtual int maxTopMargin(bool positive) const {
    637         if (positive)
    638             if (marginTop() > 0)
    639                 return marginTop();
    640             else
    641                 return 0;
    642         else
    643             if (marginTop() < 0)
    644                 return 0 - marginTop();
    645             else
    646                 return 0;
    647     }
    648     virtual int maxBottomMargin(bool positive) const {
    649         if (positive)
    650             if (marginBottom() > 0)
    651                 return marginBottom();
    652             else
    653                 return 0;
    654         else
    655             if (marginBottom() < 0)
    656                 return 0 - marginBottom();
    657             else
    658                 return 0;
    659     }
     656
     657    virtual int maxTopMargin(bool positive) const { return positive ? std::max(0, marginTop()) : -std::min(0, marginTop()); }
     658    virtual int maxBottomMargin(bool positive) const { return positive ? std::max(0, marginBottom()) : -std::min(0, marginBottom()); }
    660659
    661660    virtual int marginTop() const { return 0; }
     
    664663    virtual int marginRight() const { return 0; }
    665664
    666     // Virtual since table cells override 
     665    // Virtual since table cells override
    667666    virtual int paddingTop() const;
    668667    virtual int paddingBottom() const;
    669668    virtual int paddingLeft() const;
    670669    virtual int paddingRight() const;
    671    
     670
    672671    virtual int borderTop() const { return style()->borderTopWidth(); }
    673672    virtual int borderBottom() const { return style()->borderBottomWidth(); }
     
    681680    virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
    682681    IntRect absoluteBoundingBoxRect();
    683    
     682
    684683    // the rect that will be painted if this object is passed as the paintingRoot
    685684    IntRect paintingRootRect(IntRect& topLevelRect);
    686685
    687     void addPDFURLRect(GraphicsContext* p, IntRect rect);
     686    void addPDFURLRect(GraphicsContext*, IntRect);
    688687
    689688    virtual void addFocusRingRects(GraphicsContext*, int tx, int ty);
     
    696695    RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle() : style(); }
    697696
    698 
    699697    void getTextDecorationColors(int decorations, Color& underline, Color& overline,
    700                                  Color& linethrough, bool quirksMode=false);
     698                                 Color& linethrough, bool quirksMode = false);
    701699
    702700    enum BorderSide {
    703         BSTop, BSBottom, BSLeft, BSRight
     701        BSTop,
     702        BSBottom,
     703        BSLeft,
     704        BSRight
    704705    };
     706
    705707    void drawBorderArc(GraphicsContext*, int x, int y, float thickness, IntSize radius, int angleStart,
    706         int angleSpan, BorderSide, Color, const Color& textcolor, EBorderStyle, bool firstCorner);
     708                       int angleSpan, BorderSide, Color, const Color& textcolor, EBorderStyle, bool firstCorner);
    707709    void drawBorder(GraphicsContext*, int x1, int y1, int x2, int y2, BorderSide,
    708         Color, const Color& textcolor, EBorderStyle, int adjbw1, int adjbw2);
    709 
    710     virtual void setTable(RenderTable*) {};
     710                    Color, const Color& textcolor, EBorderStyle, int adjbw1, int adjbw2);
     711
     712    virtual void setTable(RenderTable*) { }
    711713
    712714    // Used by collapsed border tables.
     
    718720
    719721    // Repaint a specific subrectangle within a given object.  The rect |r| is in the object's coordinate space.
    720     void repaintRectangle(const IntRect& r, bool immediate = false);
    721    
     722    void repaintRectangle(const IntRect&, bool immediate = false);
     723
    722724    // Repaint only if our old bounds and new bounds are different.
    723725    bool repaintAfterLayoutIfNeeded(const IntRect& oldBounds, const IntRect& oldFullBounds);
     
    744746    // Given a rect in the object's coordinate space, this method converts the rectangle to the view's
    745747    // coordinate space.
    746     virtual void computeAbsoluteRepaintRect(IntRect& r, bool f=false);
    747    
     748    virtual void computeAbsoluteRepaintRect(IntRect&, bool fixed = false);
     749
    748750    virtual unsigned int length() const { return 1; }
    749751
    750     bool isFloatingOrPositioned() const { return (isFloating() || isPositioned()); };
     752    bool isFloatingOrPositioned() const { return (isFloating() || isPositioned()); }
    751753    virtual bool containsFloats() { return false; }
    752     virtual bool containsFloat(RenderObject* o) { return false; }
     754    virtual bool containsFloat(RenderObject*) { return false; }
    753755    virtual bool hasOverhangingFloats() { return false; }
    754756    virtual bool expandsToEncloseOverhangingFloats() const { return isFloating() && style()->height().isAuto(); }
     
    767769
    768770    // Applied as a "slop" to dirty rect checks during the outline painting phase's dirty-rect checks.
    769     int maximalOutlineSize(PaintPhase p) const;
     771    int maximalOutlineSize(PaintPhase) const;
    770772
    771773    enum SelectionState {
     
    780782    // descendants (as described above in the SelectionState enum declaration).
    781783    virtual SelectionState selectionState() const { return SelectionNone; }
    782    
     784
    783785    // Sets the selection state for an object.
    784     virtual void setSelectionState(SelectionState s) { if (parent()) parent()->setSelectionState(s); }
     786    virtual void setSelectionState(SelectionState state) { if (parent()) parent()->setSelectionState(state); }
    785787
    786788    // A single rectangle that encompasses all of the selected objects within this object.  Used to determine the tightest
    787789    // possible bounding box for the selection.
    788790    virtual IntRect selectionRect() { return IntRect(); }
    789    
     791
    790792    // Whether or not an object can be part of the leaf elements of the selection.
    791793    virtual bool canBeSelectionLeaf() const { return false; }
     
    800802    // since it fires the selectstart DOM event.
    801803    bool shouldSelect() const;
    802    
     804
    803805    // Obtains the selection colors that should be used when painting a selection.
    804806    Color selectionBackgroundColor() const;
     
    810812    // This struct is used when the selection changes to cache the old and new state of the selection for each RenderObject.
    811813    struct SelectionInfo {
    812         RenderObject* m_object;
    813         IntRect m_rect;
    814         RenderObject::SelectionState m_state;
     814        SelectionInfo()
     815            : m_object(0)
     816            , m_state(SelectionNone)
     817        {
     818        }
     819
     820        SelectionInfo(RenderObject* o)
     821            : m_object(o)
     822            , m_rect(o->selectionRect())
     823            , m_state(o->selectionState())
     824        {
     825        }
    815826
    816827        RenderObject* object() const { return m_object; }
    817828        IntRect rect() const { return m_rect; }
    818829        SelectionState state() const { return m_state; }
    819        
    820         SelectionInfo() { m_object = 0; m_state = SelectionNone; }
    821         SelectionInfo(RenderObject* o) :m_object(o), m_rect(o->selectionRect()), m_state(o->selectionState()) {}
     830
     831        RenderObject* m_object;
     832        IntRect m_rect;
     833        SelectionState m_state;
    822834    };
    823835
     
    832844     * useful for character range rect computations
    833845     */
    834     virtual IntRect caretRect(int offset, EAffinity affinity = UPSTREAM, int *extraWidthToEndOfLine = 0);
    835 
    836     virtual int lowestPosition(bool includeOverflowInterior=true, bool includeSelf=true) const { return 0; }
    837     virtual int rightmostPosition(bool includeOverflowInterior=true, bool includeSelf=true) const { return 0; }
    838     virtual int leftmostPosition(bool includeOverflowInterior=true, bool includeSelf=true) const { return 0; }
    839    
    840     virtual void calcVerticalMargins() {}
     846    virtual IntRect caretRect(int offset, EAffinity = UPSTREAM, int* extraWidthToEndOfLine = 0);
     847
     848    virtual int lowestPosition(bool /*includeOverflowInterior*/ = true, bool /*includeSelf*/ = true) const { return 0; }
     849    virtual int rightmostPosition(bool /*includeOverflowInterior*/ = true, bool /*includeSelf*/ = true) const { return 0; }
     850    virtual int leftmostPosition(bool /*includeOverflowInterior*/ = true, bool /*includeSelf*/ = true) const { return 0; }
     851
     852    virtual void calcVerticalMargins() { }
    841853    void removeFromObjectLists();
    842854
     
    847859    virtual void destroy();
    848860
    849     const Font& font(bool firstLine) const {
    850         return style(firstLine)->font();
    851     }
     861    const Font& font(bool firstLine) const { return style(firstLine)->font(); }
    852862
    853863    // Virtual function helpers for CSS3 Flexible Box Layout
     
    863873    virtual unsigned caretMaxRenderedOffset() const;
    864874
    865     virtual int previousOffset (int current) const;
    866     virtual int nextOffset (int current) const;
     875    virtual int previousOffset(int current) const;
     876    virtual int nextOffset(int current) const;
    867877
    868878    virtual void imageChanged(CachedImage*);
     
    893903
    894904    virtual void removeLeftoverAnonymousBoxes();
    895    
     905
    896906    void arenaDelete(RenderArena*, void* objectBase);
    897907
     
    901911    Node* m_node;
    902912
    903     RenderObject *m_parent;
    904     RenderObject *m_previous;
    905     RenderObject *m_next;
     913    RenderObject* m_parent;
     914    RenderObject* m_previous;
     915    RenderObject* m_next;
    906916
    907917    mutable short m_verticalPosition;
     
    924934    bool m_replaced                  : 1;
    925935    bool m_isDragging                : 1;
    926    
     936
    927937    bool m_hasOverflowClip           : 1;
    928    
     938
    929939    bool m_hasCounterNodeMap         : 1;
    930 
    931     friend class RenderListItem;
    932     friend class RenderContainer;
    933     friend class RenderView;
    934940};
    935941
    936 
    937 enum VerticalPositionHint {
    938     PositionTop = -0x4000,
    939     PositionBottom = 0x4000,
    940     PositionUndefined = 0x3fff
    941 };
    942 
    943 } //namespace
     942} // namespace WebCore
    944943
    945944#ifndef NDEBUG
     
    948947#endif
    949948
    950 
    951 #endif
     949#endif // RenderObject_h
Note: See TracChangeset for help on using the changeset viewer.