Changeset 17677 in webkit
- Timestamp:
- Nov 8, 2006 7:55:58 PM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r17674 r17677 1 2006-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 1 166 2006-11-08 Darin Adler <darin@apple.com> 2 167 -
trunk/WebCore/rendering/RenderObject.cpp
r17667 r17677 28 28 #include "RenderObject.h" 29 29 30 #include "AXObjectCache.h" 30 #include "AXObjectCache.h" 31 31 #include "AffineTransform.h" 32 32 #include "CachedImage.h" … … 34 34 #include "CounterNode.h" 35 35 #include "CounterResetNode.h" 36 #include "TextResourceDecoder.h"37 36 #include "Document.h" 38 37 #include "Element.h" … … 44 43 #include "HTMLNames.h" 45 44 #include "HTMLOListElement.h" 46 #include "KURL.h"47 45 #include "HitTestRequest.h" 48 46 #include "HitTestResult.h" 47 #include "KURL.h" 49 48 #include "Page.h" 50 49 #include "Position.h" … … 61 60 #include "RenderView.h" 62 61 #include "Screen.h" 62 #include "TextResourceDecoder.h" 63 63 #include "TextStream.h" 64 64 #include "cssstyleselector.h" … … 73 73 74 74 #ifndef NDEBUG 75 static void *baseOfRenderObjectBeingDeleted;75 static void* baseOfRenderObjectBeingDeleted; 76 76 #endif 77 77 … … 93 93 { 94 94 ASSERT(baseOfRenderObjectBeingDeleted == ptr); 95 95 96 96 // Stash size where destroy can find it. 97 97 *(size_t *)ptr = sz; 98 98 } 99 99 100 RenderObject *RenderObject::createObject(Node* node,RenderStyle* style)101 { 102 RenderObject *o = 0;100 RenderObject* RenderObject::createObject(Node* node, RenderStyle* style) 101 { 102 RenderObject* o = 0; 103 103 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); 107 107 if (contentImage) { 108 108 contentImage->setStyle(style); … … 113 113 } 114 114 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; 161 160 } 162 161 return o; … … 164 163 165 164 #ifndef NDEBUG 166 struct RenderObjectCounter { 167 static int count; 168 ~RenderObjectCounter() { if (count != 0) fprintf(stderr, "LEAK: %d RenderObject\n", count); } 165 struct RenderObjectCounter { 166 static int count; 167 ~RenderObjectCounter() { if (count != 0) fprintf(stderr, "LEAK: %d RenderObject\n", count); } 169 168 }; 170 169 int RenderObjectCounter::count; … … 173 172 174 173 RenderObject::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) 201 197 { 202 198 #ifndef NDEBUG … … 212 208 } 213 209 214 bool RenderObject::isDescendantOf(const RenderObject *obj) const215 { 216 for (const RenderObject *r = this; r; r = r->m_parent)210 bool RenderObject::isDescendantOf(const RenderObject* obj) const 211 { 212 for (const RenderObject* r = this; r; r = r->m_parent) { 217 213 if (r == obj) 218 214 return true; 215 } 219 216 return false; 220 217 } … … 222 219 bool RenderObject::isRoot() const 223 220 { 224 return element() && element()->renderer() == this && 225 element()->document()->documentElement() == element(); 221 return element() && element()->renderer() == this && element()->document()->documentElement() == element(); 226 222 } 227 223 … … 256 252 } 257 253 258 void RenderObject::addChild(RenderObject* , RenderObject*)259 { 260 ASSERT (0);261 } 262 263 RenderObject* RenderObject::removeChildNode(RenderObject* 264 { 265 ASSERT (0);254 void RenderObject::addChild(RenderObject*, RenderObject*) 255 { 256 ASSERT_NOT_REACHED(); 257 } 258 259 RenderObject* RenderObject::removeChildNode(RenderObject*) 260 { 261 ASSERT_NOT_REACHED(); 266 262 return 0; 267 263 } 268 264 269 void RenderObject::removeChild(RenderObject* 270 { 271 ASSERT (0);265 void RenderObject::removeChild(RenderObject*) 266 { 267 ASSERT_NOT_REACHED(); 272 268 } 273 269 274 270 void RenderObject::appendChildNode(RenderObject*) 275 271 { 276 ASSERT (0);272 ASSERT_NOT_REACHED(); 277 273 } 278 274 279 275 void RenderObject::insertChildNode(RenderObject*, RenderObject*) 280 276 { 281 ASSERT (0);282 } 283 284 RenderObject *RenderObject::nextInPreOrder() const277 ASSERT_NOT_REACHED(); 278 } 279 280 RenderObject* RenderObject::nextInPreOrder() const 285 281 { 286 282 if (RenderObject* o = firstChild()) 287 283 return o; 288 284 289 285 return nextInPreOrderAfterChildren(); 290 286 } … … 300 296 o = o->nextSibling(); 301 297 } 298 302 299 return o; 303 300 } 304 301 305 RenderObject *RenderObject::previousInPreOrder() const302 RenderObject* RenderObject::previousInPreOrder() const 306 303 { 307 304 if (RenderObject* o = previousSibling()) { … … 324 321 bool RenderObject::isEditable() const 325 322 { 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 && 332 328 element() && element()->isContentEditable() && 333 ((isBlockFlow() && !firstChild()) || 334 isReplaced() || 335 isBR() || 329 ((isBlockFlow() && !firstChild()) || 330 isReplaced() || 331 isBR() || 336 332 (textRenderer && textRenderer->firstTextBox())); 337 333 } 338 334 339 RenderObject *RenderObject::nextEditable() const340 { 341 RenderObject *r = const_cast<RenderObject*>(this);342 RenderObject *n = firstChild();335 RenderObject* RenderObject::nextEditable() const 336 { 337 RenderObject* r = const_cast<RenderObject*>(this); 338 RenderObject* n = firstChild(); 343 339 if (n) { 344 while (n) { 345 r = n; 346 n = n->firstChild(); 340 while (n) { 341 r = n; 342 n = n->firstChild(); 347 343 } 348 344 if (r->isEditable()) 349 345 return r; 350 else 346 else 351 347 return r->nextEditable(); 352 348 } … … 354 350 if (n) { 355 351 r = n; 356 while (n) { 357 r = n; 358 n = n->firstChild(); 352 while (n) { 353 r = n; 354 n = n->firstChild(); 359 355 } 360 356 if (r->isEditable()) 361 357 return r; 362 else 358 else 363 359 return r->nextEditable(); 364 360 } … … 370 366 r = n; 371 367 n = r->firstChild(); 372 while (n) { 373 r = n; 374 n = n->firstChild(); 368 while (n) { 369 r = n; 370 n = n->firstChild(); 375 371 } 376 372 if (r->isEditable()) 377 373 return r; 378 else 374 else 379 375 return r->nextEditable(); 380 376 } 381 377 n = r->parent(); 382 378 } 379 383 380 return 0; 384 381 } 385 382 386 RenderObject *RenderObject::previousEditable() const387 { 388 RenderObject *r = const_cast<RenderObject*>(this);389 RenderObject *n = firstChild();383 RenderObject* RenderObject::previousEditable() const 384 { 385 RenderObject* r = const_cast<RenderObject*>(this); 386 RenderObject* n = firstChild(); 390 387 if (n) { 391 while (n) { 392 r = n; 393 n = n->lastChild(); 388 while (n) { 389 r = n; 390 n = n->lastChild(); 394 391 } 395 392 if (r->isEditable()) 396 393 return r; 397 else 394 else 398 395 return r->previousEditable(); 399 396 } … … 401 398 if (n) { 402 399 r = n; 403 while (n) { 404 r = n; 405 n = n->lastChild(); 400 while (n) { 401 r = n; 402 n = n->lastChild(); 406 403 } 407 404 if (r->isEditable()) 408 405 return r; 409 else 406 else 410 407 return r->previousEditable(); 411 } 408 } 412 409 n = r->parent(); 413 410 while (n) { … … 417 414 r = n; 418 415 n = r->lastChild(); 419 while (n) { 420 r = n; 421 n = n->lastChild(); 416 while (n) { 417 r = n; 418 n = n->lastChild(); 422 419 } 423 420 if (r->isEditable()) 424 421 return r; 425 else 422 else 426 423 return r->previousEditable(); 427 424 } 428 425 n = r->parent(); 429 426 } 427 430 428 return 0; 431 } 432 433 RenderObject *RenderObject::firstLeafChild() const434 { 435 RenderObject *r = firstChild();429 } 430 431 RenderObject* RenderObject::firstLeafChild() const 432 { 433 RenderObject* r = firstChild(); 436 434 while (r) { 437 RenderObject *n = 0;435 RenderObject* n = 0; 438 436 n = r->firstChild(); 439 437 if (!n) … … 444 442 } 445 443 446 RenderObject *RenderObject::lastLeafChild() const447 { 448 RenderObject *r = lastChild();444 RenderObject* RenderObject::lastLeafChild() const 445 { 446 RenderObject* r = lastChild(); 449 447 while (r) { 450 RenderObject *n = 0;448 RenderObject* n = 0; 451 449 n = r->lastChild(); 452 450 if (!n) … … 480 478 if (!parentLayer) 481 479 return; 482 480 483 481 RenderObject* object = newObject; 484 482 RenderLayer* beforeChild = 0; … … 490 488 if (!parentLayer) 491 489 return; 492 490 493 491 if (layer()) { 494 492 parentLayer->removeChild(layer()); … … 504 502 if (!newParent) 505 503 return; 506 504 507 505 if (layer()) { 508 506 if (oldParent) … … 522 520 if (!parentLayer) 523 521 return 0; 524 522 525 523 // Step 1: If our layer is a child of the desired parent, then return our layer. 526 524 RenderLayer* ourLayer = layer(); 527 525 if (ourLayer && ourLayer->parent() == parentLayer) 528 526 return ourLayer; 529 527 530 528 // Step 2: If we don't have a layer, or our layer is the desired parent, then descend 531 529 // into our siblings trying to find the next layer whose parent is the desired parent. … … 538 536 } 539 537 } 540 538 541 539 // Step 3: If our layer is the desired parent layer, then we're finished. We didn't 542 540 // find anything. 543 541 if (parentLayer == ourLayer) 544 542 return 0; 545 543 546 544 // Step 4: If |checkParent| is set, climb up to our parent and check its siblings that 547 545 // follow us to see if we can locate a layer. 548 546 if (checkParent && parent()) 549 547 return parent()->findNextLayer(parentLayer, this, true); 550 548 551 549 return 0; 552 550 } 553 551 554 552 RenderLayer* RenderObject::enclosingLayer() const 555 553 { 556 554 const RenderObject* curr = this; 557 555 while (curr) { 558 RenderLayer *layer = curr->layer();556 RenderLayer* layer = curr->layer(); 559 557 if (layer) 560 558 return layer; … … 575 573 576 574 void RenderObject::updateFirstLetter() 577 {} 575 { 576 } 578 577 579 578 int RenderObject::offsetLeft() const … … 613 612 return y; 614 613 } 615 614 616 615 RenderObject* RenderObject::offsetParent() const 617 616 { … … 619 618 if (isBody()) 620 619 return 0; 620 621 621 bool skipTables = isPositioned() || isRelPositioned(); 622 622 RenderObject* curr = parent(); 623 while (curr && (!curr->element() || 624 (!curr->isPositioned() && !curr->isRelPositioned() && 623 while (curr && (!curr->element() || 624 (!curr->isPositioned() && !curr->isRelPositioned() && 625 625 !(!style()->htmlHacks() && skipTables ? curr->isRoot() : curr->isBody())))) { 626 626 if (!skipTables && curr->element() && (curr->isTableCell() || curr->isTable())) … … 681 681 bool RenderObject::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier) 682 682 { 683 RenderLayer *l = layer();683 RenderLayer* l = layer(); 684 684 if (l && l->scroll(direction, granularity, multiplier)) 685 685 return true; 686 RenderBlock *b = containingBlock();686 RenderBlock* b = containingBlock(); 687 687 if (b && !b->isRenderView()) 688 688 return b->scroll(direction, granularity, multiplier); … … 703 703 bool RenderObject::hasStaticX() const 704 704 { 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(); 708 706 } 709 707 … … 717 715 } 718 716 719 void RenderObject::setNeedsLayout(bool b, bool markParents) 717 void RenderObject::setNeedsLayout(bool b, bool markParents) 720 718 { 721 719 bool alreadyNeededLayout = m_needsLayout; … … 724 722 if (!alreadyNeededLayout && markParents) 725 723 markContainingBlocksForLayout(); 726 } 727 else { 724 } else { 728 725 m_posChildNeedsLayout = false; 729 726 m_normalChildNeedsLayout = false; … … 738 735 if (!alreadyNeededLayout && markParents) 739 736 markContainingBlocksForLayout(); 740 } 741 else { 737 } else { 742 738 m_posChildNeedsLayout = false; 743 739 m_normalChildNeedsLayout = false; … … 747 743 void RenderObject::markContainingBlocksForLayout(bool scheduleRelayout) 748 744 { 749 RenderObject *o = container();750 RenderObject *last = this;745 RenderObject* o = container(); 746 RenderObject* last = this; 751 747 752 748 while (o) { … … 773 769 RenderBlock* RenderObject::containingBlock() const 774 770 { 775 if (isTableCell())776 return static_cast<const RenderTableCell 771 if (isTableCell()) 772 return static_cast<const RenderTableCell*>(this)->table(); 777 773 if (isRenderView()) 778 774 return (RenderBlock*)this; 779 775 780 RenderObject *o = parent();776 RenderObject* o = parent(); 781 777 if (!isText() && m_style->position() == FixedPosition) { 782 778 while ( o && !o->isRenderView() ) 783 779 o = o->parent(); 784 } 785 else if (!isText() && m_style->position() == AbsolutePosition) { 780 } else if (!isText() && m_style->position() == AbsolutePosition) { 786 781 while (o && (o->style()->position() == StaticPosition || (o->isInline() && !o->isReplaced())) && !o->isRenderView()) { 787 782 // For relpositioned inlines, we return the nearest enclosing block. We don't try … … 806 801 if (!o || !o->isRenderBlock()) 807 802 return 0; // Probably doesn't happen any more, but leave just in case. -dwh 808 803 809 804 return static_cast<RenderBlock*>(o); 810 805 } … … 812 807 int RenderObject::containingBlockWidth() const 813 808 { 814 // ###809 // FIXME ? 815 810 return containingBlock()->contentWidth(); 816 811 } … … 818 813 int RenderObject::containingBlockHeight() const 819 814 { 820 // ###815 // FIXME ? 821 816 return containingBlock()->contentHeight(); 822 817 } … … 827 822 if (!shouldPaintBackgroundOrBorder()) 828 823 return false; 829 824 830 825 // Ok, let's check the background first. 831 826 const BackgroundLayer* bgLayer = style()->backgroundLayers(); 827 828 // Nobody will use multiple background layers without wanting fancy positioning. 832 829 if (bgLayer->next()) 833 return true; // Nobody will use multiple background layers without wanting fancy positioning.834 830 return true; 831 835 832 // Make sure we have a valid background image. 836 833 CachedImage* bg = bgLayer->backgroundImage(); 837 834 bool shouldPaintBackgroundImage = bg && bg->canRender(); 838 835 839 836 // 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 845 843 // Background is ok. Let's check border. 846 844 if (style()->hasBorder()) { … … 848 846 CachedImage* borderImage = style()->borderImage().image(); 849 847 bool shouldPaintBorderImage = borderImage && borderImage->canRender(); 848 849 // If the image hasn't loaded, we're still using the normal border style. 850 850 if (shouldPaintBorderImage && borderImage->isLoaded()) 851 return true; // If the image hasn't loaded, we're still using the normal border style.851 return true; 852 852 } 853 853 … … 855 855 } 856 856 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)))857 void 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)) 862 862 style = SOLID; 863 863 864 864 if (!c.isValid()) { 865 865 if (style == INSET || style == OUTSET || style == RIDGE || style == GROOVE) … … 868 868 c = textColor; 869 869 } 870 870 871 871 switch (style) { 872 872 case BNONE: … … 874 874 return; 875 875 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)); 877 877 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 888 884 break; 889 885 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 895 891 int outerY = y; 896 892 int outerHeight = radius.height() * 2; … … 903 899 innerHeight += 2; 904 900 } 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); 909 905 break; 910 906 } … … 912 908 case RIDGE: { 913 909 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))) 916 912 c2 = c.dark(); 917 913 else { … … 920 916 } 921 917 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); 932 928 break; 933 929 } 934 930 case INSET: 935 if (s == BSTop || s == BSLeft)931 if (s == BSTop || s == BSLeft) 936 932 c = c.dark(); 937 933 case OUTSET: 938 if (style == OUTSET && (s == BSBottom || s == BSRight))934 if (style == OUTSET && (s == BSBottom || s == BSRight)) 939 935 c = c.dark(); 940 936 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); 944 940 break; 945 941 } 946 942 } 947 943 948 void RenderObject::drawBorder(GraphicsContext* p, int x1, int y1, int x2, int y2,944 void RenderObject::drawBorder(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2, 949 945 BorderSide s, Color c, const Color& textcolor, EBorderStyle style, 950 946 int adjbw1, int adjbw2) … … 962 958 } 963 959 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 } 987 1041 } 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: 996 1046 { 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; 1014 1055 } 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: 1017 1097 { 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; 1052 1105 } 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); 1087 1134 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 1139 bool RenderObject::paintBorderImage(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, const RenderStyle* style) 1155 1140 { 1156 1141 CachedImage* borderImage = style->borderImage().image(); 1157 1142 if (!borderImage->isLoaded()) 1158 1143 return true; // Never paint a border image incrementally, but don't paint the fallback borders either. 1159 1144 1160 1145 // If we have a border radius, the border image gets clipped to the rounded rect. 1161 1146 bool clipped = false; 1162 1147 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()); 1168 1152 clipped = true; 1169 1153 } … … 1174 1158 int topSlice = min(imageHeight, style->borderImage().m_slices.top.calcValue(borderImage->image()->height())); 1175 1159 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())); 1177 1161 int rightSlice = min(imageWidth, style->borderImage().m_slices.right.calcValue(borderImage->image()->width())); 1178 1162 1179 1163 EBorderImageRule hRule = style->borderImage().horizontalRule(); 1180 1164 EBorderImageRule vRule = style->borderImage().verticalRule(); 1181 1165 1182 1166 bool drawLeft = leftSlice > 0 && style->borderLeftWidth() > 0; 1183 1167 bool drawTop = topSlice > 0 && style->borderTopWidth() > 0; … … 1189 1173 if (drawLeft) { 1190 1174 // 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) 1193 1177 // The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice) 1194 1178 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) 1199 1183 // The rect to use from within the image is (0, imageHeight - bottomSlice, leftSlice, botomSlice) 1200 1184 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 1204 1188 // Paint the left edge. 1205 1189 // 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 1212 1196 if (drawRight) { 1213 1197 // 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) 1215 1199 // The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice) 1216 1200 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) 1221 1205 // The rect to use from within the image is (imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, botomSlice) 1222 1206 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 1226 1210 // 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); 1231 1215 } 1232 1216 1233 1217 // Paint the top edge. 1234 1218 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 1239 1223 // Paint the bottom edge. 1240 1224 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 1246 1230 // Paint the middle. 1247 1231 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); 1252 1236 1253 1237 // Clear the clip for the border radius. 1254 1238 if (clipped) 1255 p->restore();1239 graphicsContext->restore(); 1256 1240 1257 1241 return true; 1258 1242 } 1259 1243 1260 void RenderObject::paintBorder(GraphicsContext* p, int _tx, int _ty, int w, int h, const RenderStyle* style, bool begin, bool end) 1244 void RenderObject::paintBorder(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, 1245 const RenderStyle* style, bool begin, bool end) 1261 1246 { 1262 1247 CachedImage* borderImage = style->borderImage().image(); 1263 1248 bool shouldPaintBackgroundImage = borderImage && borderImage->canRender(); 1264 1249 if (shouldPaintBackgroundImage) 1265 shouldPaintBackgroundImage = paintBorderImage( p, _tx, _ty, w, h, style);1266 1250 shouldPaintBackgroundImage = paintBorderImage(graphicsContext, tx, ty, w, h, style); 1251 1267 1252 if (shouldPaintBackgroundImage) 1268 1253 return; … … 1277 1262 bool rt = style->borderRightIsTransparent(); 1278 1263 bool lt = style->borderLeftIsTransparent(); 1279 1264 1280 1265 EBorderStyle ts = style->borderTopStyle(); 1281 1266 EBorderStyle bs = style->borderBottomStyle(); … … 1302 1287 renderRadii = (requiredWidth <= w && requiredHeight <= h); 1303 1288 } 1304 1289 1305 1290 // Clip to the rounded rectangle. 1306 1291 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); 1309 1294 } 1310 1295 … … 1318 1303 if (renderTop) { 1319 1304 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)); 1323 1307 1324 1308 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; 1331 1314 if (renderRadii) { 1332 1315 x += topLeft.width(); 1333 1316 x2 -= topRight.width(); 1334 1317 } 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 1340 1322 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; 1344 1326 firstAngleStart = 90; 1345 1327 firstAngleSpan = upperLeftBorderStylesMatch ? 90 : 45; 1346 1328 1347 1329 // We make the arc double thick and let the clip rect take care of clipping the extra off. 1348 1330 // We're doing this because it doesn't seem possible to match the curve of the clip exactly 1349 1331 // with the arc-drawing function. 1350 1332 thickness = style->borderTopWidth() * 2; 1351 1333 1352 1334 if (upperRightBorderStylesMatch) { 1353 1335 secondAngleStart = 0; … … 1357 1339 secondAngleSpan = 45; 1358 1340 } 1359 1341 1360 1342 // The inner clip clips inside the arc. This is especially important for 1px borders. 1361 1343 bool applyLeftInnerClip = (style->borderLeftWidth() < topLeft.width()) … … 1363 1345 && (ts != DOUBLE || style->borderTopWidth() > 6); 1364 1346 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()); 1368 1350 } 1369 1351 1370 1352 // 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); 1373 1355 if (applyLeftInnerClip) 1374 p->restore();1375 1356 graphicsContext->restore(); 1357 1376 1358 bool applyRightInnerClip = (style->borderRightWidth() < topRight.width()) 1377 1359 && (style->borderTopWidth() < topRight.height()) 1378 1360 && (ts != DOUBLE || style->borderTopWidth() > 6); 1379 1361 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()); 1383 1365 } 1384 1366 1385 1367 // 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); 1388 1370 if (applyRightInnerClip) 1389 p->restore();1371 graphicsContext->restore(); 1390 1372 } 1391 1373 } … … 1393 1375 if (renderBottom) { 1394 1376 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)); 1398 1379 1399 1380 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; 1406 1386 if (renderRadii) { 1407 1387 x += bottomLeft.width(); … … 1409 1389 } 1410 1390 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 1415 1394 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; 1419 1398 secondAngleStart = 270; 1420 1399 secondAngleSpan = upperRightBorderStylesMatch ? 90 : 45; 1421 1400 thickness = style->borderBottomWidth() * 2; 1422 1401 1423 1402 if (upperLeftBorderStylesMatch) { 1424 1403 firstAngleStart = 180; … … 1426 1405 } else { 1427 1406 firstAngleStart = 225; 1428 firstAngleSpan = 1407 firstAngleSpan = 45; 1429 1408 } 1430 1409 1431 1410 bool applyLeftInnerClip = (style->borderLeftWidth() < bottomLeft.width()) 1432 1411 && (style->borderBottomWidth() < bottomLeft.height()) 1433 1412 && (bs != DOUBLE || style->borderBottomWidth() > 6); 1434 1413 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()); 1438 1417 } 1439 1418 1440 1419 // 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); 1443 1422 if (applyLeftInnerClip) 1444 p->restore();1445 1423 graphicsContext->restore(); 1424 1446 1425 bool applyRightInnerClip = (style->borderRightWidth() < bottomRight.width()) 1447 1426 && (style->borderBottomWidth() < bottomRight.height()) 1448 1427 && (bs != DOUBLE || style->borderBottomWidth() > 6); 1449 1428 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()); 1453 1432 } 1454 1433 1455 1434 // 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); 1458 1437 if (applyRightInnerClip) 1459 p->restore();1460 } 1461 } 1462 1438 graphicsContext->restore(); 1439 } 1440 } 1441 1463 1442 if (renderLeft) { 1464 1443 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)); 1468 1446 1469 1447 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; 1476 1453 if (renderRadii) { 1477 1454 y += topLeft.height(); 1478 1455 y2 -= bottomLeft.height(); 1479 1456 } 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()); 1484 1460 1485 1461 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; 1489 1465 firstAngleStart = 135; 1490 1466 secondAngleStart = 180; 1491 1467 firstAngleSpan = secondAngleSpan = 45; 1492 1468 thickness = style->borderLeftWidth() * 2; 1493 1469 1494 1470 bool applyTopInnerClip = (style->borderLeftWidth() < topLeft.width()) 1495 1471 && (style->borderTopWidth() < topLeft.height()) 1496 1472 && (ls != DOUBLE || style->borderLeftWidth() > 6); 1497 1473 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()); 1501 1477 } 1502 1478 1503 1479 // 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); 1506 1482 if (applyTopInnerClip) 1507 p->restore();1508 1483 graphicsContext->restore(); 1484 1509 1485 bool applyBottomInnerClip = (style->borderLeftWidth() < bottomLeft.width()) 1510 1486 && (style->borderBottomWidth() < bottomLeft.height()) 1511 1487 && (ls != DOUBLE || style->borderLeftWidth() > 6); 1512 1488 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()); 1516 1492 } 1517 1493 1518 1494 // 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); 1521 1497 if (applyBottomInnerClip) 1522 p->restore();1498 graphicsContext->restore(); 1523 1499 } 1524 1500 } … … 1526 1502 if (renderRight) { 1527 1503 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)); 1531 1507 1532 1508 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; 1539 1515 if (renderRadii) { 1540 1516 y += topRight.height(); … … 1542 1518 } 1543 1519 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()); 1547 1522 1548 1523 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; 1553 1528 secondAngleStart = 315; 1554 1529 firstAngleSpan = secondAngleSpan = 45; 1555 1530 thickness = style->borderRightWidth() * 2; 1556 1531 1557 1532 bool applyTopInnerClip = (style->borderRightWidth() < topRight.width()) 1558 1533 && (style->borderTopWidth() < topRight.height()) 1559 1534 && (rs != DOUBLE || style->borderRightWidth() > 6); 1560 1535 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()); 1564 1539 } 1565 1540 1566 1541 // 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); 1569 1544 if (applyTopInnerClip) 1570 p->restore();1571 1545 graphicsContext->restore(); 1546 1572 1547 bool applyBottomInnerClip = (style->borderRightWidth() < bottomRight.width()) 1573 1548 && (style->borderBottomWidth() < bottomRight.height()) 1574 1549 && (rs != DOUBLE || style->borderRightWidth() > 6); 1575 1550 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()); 1579 1554 } 1580 1555 1581 1556 // 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); 1584 1559 if (applyBottomInnerClip) 1585 p->restore();1586 } 1587 } 1588 1560 graphicsContext->restore(); 1561 } 1562 } 1563 1589 1564 if (renderRadii) 1590 p->restore(); // Undo the clip.1565 graphicsContext->restore(); 1591 1566 } 1592 1567 … … 1601 1576 // shape). 1602 1577 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, 1606 1581 tx - xPos() + continuation()->containingBlock()->xPos(), 1607 1582 ty - yPos() + continuation()->containingBlock()->yPos()); 1608 } 1609 else 1583 } else 1610 1584 rects.append(IntRect(tx, ty, width(), height() + borderTopExtra() + borderBottomExtra())); 1611 1585 } … … 1645 1619 } 1646 1620 1647 void RenderObject::addPDFURLRect(GraphicsContext* p, IntRect rect)1621 void RenderObject::addPDFURLRect(GraphicsContext* graphicsContext, IntRect rect) 1648 1622 { 1649 1623 Node* node = element(); 1650 1624 if (node) { 1651 if ( p) {1625 if (graphicsContext) { 1652 1626 if (rect.width() > 0 && rect.height() > 0) { 1653 1627 Element* element = static_cast<Element*>(node); … … 1655 1629 if (element->isLink()) 1656 1630 href = element->getAttribute(hrefAttr); 1657 1631 1658 1632 if (!href.isNull()) { 1659 1633 KURL link = element->document()->completeURL(href.deprecatedString()); 1660 1634 if (link.isValid()) 1661 p->setURLForRect(link, rect);1635 graphicsContext->setURLForRect(link, rect); 1662 1636 } 1663 1637 } … … 1667 1641 1668 1642 1669 void RenderObject::addFocusRingRects(GraphicsContext* p, int _tx, int _ty)1643 void RenderObject::addFocusRingRects(GraphicsContext* graphicsContext, int tx, int ty) 1670 1644 { 1671 1645 // For blocks inside inlines, we go ahead and include margins so that we run right up to the … … 1673 1647 // shape). 1674 1648 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 1657 void RenderObject::paintOutline(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, const RenderStyle* style) 1685 1658 { 1686 1659 if (!hasOutline()) 1687 1660 return; 1688 1661 1689 1662 int ow = style->outlineWidth(); 1690 1663 1691 1664 EBorderStyle os = style->outlineStyle(); 1692 1665 1693 1666 Color oc = style->outlineColor(); 1694 1667 if (!oc.isValid()) 1695 1668 oc = style->color(); 1696 1669 1697 1670 int offset = style->outlineOffset(); 1698 1671 1699 1672 if (style->outlineStyleIsAuto() || hasOutlineAnnotation()) { 1700 1673 if (!theme()->supportsFocusRing(style)) { 1701 1674 // 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); 1703 1676 if (style->outlineStyleIsAuto()) 1704 addFocusRingRects( p, _tx, _ty);1677 addFocusRingRects(graphicsContext, tx, ty); 1705 1678 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(); 1709 1682 } 1710 1683 } … … 1713 1686 return; 1714 1687 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); 1736 1704 } 1737 1705 … … 1744 1712 // Can't use view(), since we might be unrooted. 1745 1713 RenderObject* o = this; 1746 while ( o->parent() ) o = o->parent(); 1714 while (o->parent()) 1715 o = o->parent(); 1747 1716 if (!o->isRenderView()) 1748 1717 return; 1749 RenderView* c= static_cast<RenderView*>(o);1750 if ( c->printingMode())1718 RenderView* view = static_cast<RenderView*>(o); 1719 if (view->printingMode()) 1751 1720 return; // Don't repaint if we're printing. 1752 c->repaintViewRectangle(getAbsoluteRepaintRect(), immediate);1721 view->repaintViewRectangle(getAbsoluteRepaintRect(), immediate); 1753 1722 } 1754 1723 … … 1757 1726 // Can't use view(), since we might be unrooted. 1758 1727 RenderObject* o = this; 1759 while ( o->parent() ) o = o->parent(); 1728 while (o->parent()) 1729 o = o->parent(); 1760 1730 if (!o->isRenderView()) 1761 1731 return; 1762 RenderView* c= static_cast<RenderView*>(o);1763 if ( c->printingMode())1732 RenderView* view = static_cast<RenderView*>(o); 1733 if (view->printingMode()) 1764 1734 return; // Don't repaint if we're printing. 1765 1735 IntRect absRect(r); 1766 1736 computeAbsoluteRepaintRect(absRect); 1767 c->repaintViewRectangle(absRect, immediate);1737 view->repaintViewRectangle(absRect, immediate); 1768 1738 } 1769 1739 1770 1740 bool RenderObject::repaintAfterLayoutIfNeeded(const IntRect& oldBounds, const IntRect& oldFullBounds) 1771 1741 { 1772 RenderView* c= view();1773 if ( c->printingMode())1742 RenderView* v = view(); 1743 if (v->printingMode()) 1774 1744 return false; // Don't repaint if we're printing. 1775 1745 1776 1746 IntRect newBounds, newFullBounds; 1777 1747 getAbsoluteRepaintRectIncludingFloats(newBounds, newFullBounds); … … 1781 1751 bool fullRepaint = selfNeedsLayout() || newBounds.location() != oldBounds.location() || mustRepaintBackgroundOrBorder(); 1782 1752 if (fullRepaint) { 1783 c->repaintViewRectangle(oldFullBounds);1753 v->repaintViewRectangle(oldFullBounds); 1784 1754 if (newBounds != oldBounds) 1785 c->repaintViewRectangle(newFullBounds);1755 v->repaintViewRectangle(newFullBounds); 1786 1756 return true; 1787 1757 } 1788 1758 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 1790 1760 // two rectangles (but typically only one). 1791 1761 int ow = style() ? style()->outlineSize() : 0; 1792 1762 int width = abs(newBounds.width() - oldBounds.width()); 1793 1763 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, 1795 1765 newBounds.y(), 1796 1766 width + borderRight() + ow, … … 1798 1768 int height = abs(newBounds.height() - oldBounds.height()); 1799 1769 if (height) 1800 c->repaintViewRectangle(IntRect(newBounds.x(),1770 v->repaintViewRectangle(IntRect(newBounds.x(), 1801 1771 min(newBounds.bottom(), oldBounds.bottom()) - borderBottom() - ow, 1802 1772 max(newBounds.width(), oldBounds.width()), … … 1822 1792 if (!needsLayout() || isText()) 1823 1793 return; 1824 1794 1825 1795 bool blockWithInlineChildren = (isRenderBlock() && !isTable() && normalChildNeedsLayout() && childrenInline()); 1826 1796 if (selfNeedsLayout()) { … … 1843 1813 if (continuation() && !isInline()) 1844 1814 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()) { 1848 1818 if (!curr->isText()) 1849 1819 r.unite(curr->getAbsoluteRepaintRectWithOutline(ow)); 1820 } 1821 } 1850 1822 1851 1823 return r; … … 1881 1853 TextStream ts(&str); 1882 1854 ts << renderName() 1883 1855 << "(" << (style() ? style()->refCount() : 0) << ")" 1884 1856 << ": " << (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(); 1894 1875 if (element()) { 1895 1876 if (element()->active()) … … 1899 1880 if (element()->focused()) 1900 1881 ts << "focus "; 1901 ts << " <" << 1882 ts << " <" << element()->localName().deprecatedString() << ">"; 1902 1883 ts << " (" << xPos() << "," << yPos() << "," << width() << "," << height() << ")"; 1903 1884 if (isTableCell()) { 1904 const RenderTableCell* cell = static_cast<const RenderTableCell 1885 const RenderTableCell* cell = static_cast<const RenderTableCell*>(this); 1905 1886 ts << " [r=" << cell->row() << " c=" << cell->col() << " rs=" << cell->rowSpan() << " cs=" << cell->colSpan() << "]"; 1906 1887 } … … 1909 1890 } 1910 1891 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"; } 1892 void 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"; 1923 1914 *stream << endl; 1924 1915 1925 RenderObject *child = firstChild(); 1926 while( child != 0 ) 1927 { 1916 RenderObject* child = firstChild(); 1917 while (child) { 1928 1918 *stream << ind << child->renderName() << ": "; 1929 child->dump(stream, ind+" ");1919 child->dump(stream, ind + " "); 1930 1920 child = child->nextSibling(); 1931 1921 } … … 1938 1928 } 1939 1929 1940 #endif 1941 1942 static Node *selectStartNode(const RenderObject *object)1943 { 1944 Node *node = 0;1930 #endif // NDEBUG 1931 1932 static Node* selectStartNode(const RenderObject* object) 1933 { 1934 Node* node = 0; 1945 1935 bool forcedOn = false; 1946 1936 1947 for (const RenderObject *curr = object; curr; curr = curr->parent()) {1937 for (const RenderObject* curr = object; curr; curr = curr->parent()) { 1948 1938 if (curr->style()->userSelect() == SELECT_TEXT) 1949 1939 forcedOn = true; … … 1968 1958 bool RenderObject::shouldSelect() const 1969 1959 { 1970 if (Node *node = selectStartNode(this))1960 if (Node* node = selectStartNode(this)) 1971 1961 return EventTargetNodeCast(node)->dispatchHTMLEvent(selectstartEvent, true, true); 1972 1962 … … 2013 2003 const RenderObject* curr = this; 2014 2004 while (curr) { 2015 Node *elt = curr->element();2005 Node* elt = curr->element(); 2016 2006 if (elt && elt->nodeType() == Node::TEXT_NODE) { 2017 2007 // Since there's no way for the author to address the -webkit-user-drag style for a text node, … … 2020 2010 dhtmlWillDrag = false; 2021 2011 return curr->node(); 2022 } else if (curr->shouldSelect()) {2012 } else if (curr->shouldSelect()) 2023 2013 // In this case we have a click in the unselected portion of text. If this text is 2024 2014 // selectable, we want to start the selection process instead of looking for a parent 2025 2015 // to try to drag. 2026 2016 return 0; 2027 }2028 2017 } else { 2029 2018 EUserDrag dragMode = curr->style()->userDrag(); … … 2050 2039 RenderBlock* RenderObject::createAnonymousBlock() 2051 2040 { 2052 RenderStyle *newStyle = new (renderArena()) RenderStyle();2041 RenderStyle* newStyle = new (renderArena()) RenderStyle(); 2053 2042 newStyle->inheritFrom(m_style); 2054 2043 newStyle->setDisplay(BLOCK); 2055 2044 2056 RenderBlock *newBox = new (renderArena()) RenderBlock(document() /* anonymous box */);2045 RenderBlock* newBox = new (renderArena()) RenderBlock(document() /* anonymous box */); 2057 2046 newBox->setStyle(newStyle); 2058 2047 return newBox; … … 2071 2060 RenderInline* parentInline = static_cast<RenderInline*>(parent()); 2072 2061 RenderBlock* newBox = parentInline->createAnonymousBlock(); 2073 2062 2074 2063 RenderFlow* oldContinuation = parent()->continuation(); 2075 2064 parentInline->setContinuation(newBox); … … 2078 2067 parent()->removeChildNode(this); 2079 2068 parentInline->splitFlow(beforeChild, newBox, this, oldContinuation); 2080 } 2081 else if (parent()->isRenderBlock()) 2069 } else if (parent()->isRenderBlock()) 2082 2070 static_cast<RenderBlock*>(parent())->makeChildrenNonInline(); 2083 } 2084 else { 2071 } else { 2085 2072 // An anonymous block must be made to wrap this inline. 2086 2073 RenderBlock* box = createAnonymousBlock(); … … 2091 2078 } 2092 2079 2093 void RenderObject::setStyle(RenderStyle *style)2080 void RenderObject::setStyle(RenderStyle* style) 2094 2081 { 2095 2082 if (m_style == style) … … 2104 2091 #if PLATFORM(MAC) 2105 2092 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()) 2108 2095 document()->setDashboardRegionsDirty(true); 2109 2096 #endif 2110 2097 2111 2098 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()) { 2114 2101 layer()->stackingContext()->dirtyZOrderLists(); 2115 2102 if (m_style->hasAutoZIndex() != style->hasAutoZIndex() || 2116 m_style->visibility() != style->visibility())2103 m_style->visibility() != style->visibility()) 2117 2104 layer()->dirtyZOrderLists(); 2118 2105 } 2119 2106 // keep layer hierarchy visibility bits up to date if visibility changes 2120 2107 if (m_style->visibility() != style->visibility()) { 2121 RenderLayer* l = enclosingLayer(); 2108 RenderLayer* l = enclosingLayer(); 2122 2109 if (style->visibility() == VISIBLE && l) 2123 2110 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)) 2126 2113 l->dirtyVisibleContentStatus(); 2127 } 2114 } 2128 2115 } 2129 2116 … … 2133 2120 if (d == RenderStyle::RepaintLayer && !layer()) 2134 2121 d = RenderStyle::Repaint; 2135 2122 2136 2123 // The background of the root element or the body element could propagate up to 2137 2124 // the canvas. Just dirty the entire canvas when our style changes substantially. 2138 2125 if (d >= RenderStyle::Repaint && element() && 2139 (element()->hasTagName(htmlTag) || element()->hasTagName(bodyTag)))2126 (element()->hasTagName(htmlTag) || element()->hasTagName(bodyTag))) 2140 2127 view()->repaint(); 2141 2128 else if (m_parent && !isText()) { … … 2153 2140 // end up being destroyed. 2154 2141 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())) 2161 2148 layer()->repaintIncludingDescendants(); 2162 2149 … … 2168 2155 repaint(); 2169 2156 if (isRenderBlock()) { 2170 if (style->position() == StaticPosition) {2157 if (style->position() == StaticPosition) 2171 2158 // Clear our positioned objects list. Our absolutely positioned descendants will be 2172 2159 // inserted into our containing block's positioned objects list during layout. 2173 2160 removePositionedObjects(0); 2174 }else if (m_style->position() == StaticPosition) {2161 else if (m_style->position() == StaticPosition) { 2175 2162 // Remove our absolutely positioned descendants from their current containing block. 2176 2163 // They will be inserted into our positioned objects list during layout. … … 2178 2165 while (cb && (cb->style()->position() == StaticPosition || (cb->isInline() && !cb->isReplaced())) && !cb->isRoot() && !cb->isRenderView()) { 2179 2166 if (cb->style()->position() == RelativePosition && cb->isInline() && !cb->isReplaced()) { 2180 cb = 2167 cb = cb->containingBlock(); 2181 2168 break; 2182 2169 } … … 2187 2174 } 2188 2175 } 2189 2176 2190 2177 if (isFloating() && (m_style->floating() != style->floating())) 2191 2178 // For changes in float styles, we need to conceivably remove ourselves … … 2196 2183 // from the positioned objects list. 2197 2184 removeFromObjectLists(); 2198 2185 2199 2186 affectsParentBlock = m_style && isFloatingOrPositioned() && 2200 2187 (!style->isFloating() && style->position() != AbsolutePosition && style->position() != FixedPosition) 2201 2188 && parent() && (parent()->isBlockFlow() || parent()->isInlineFlow()); 2202 2189 2203 2190 // reset style flags 2204 2191 m_floating = false; … … 2222 2209 } 2223 2210 2224 RenderStyle *oldStyle = m_style;2211 RenderStyle* oldStyle = m_style; 2225 2212 m_style = style; 2226 2213 2227 2214 updateBackgroundImages(oldStyle); 2228 2215 2229 2216 if (m_style) 2230 2217 m_style->ref(); 2231 2218 2232 2219 if (oldStyle) 2233 2220 oldStyle->deref(renderArena()); … … 2237 2224 if (affectsParentBlock) 2238 2225 handleDynamicFloatPositionChange(); 2239 2226 2240 2227 // No need to ever schedule repaints from a style change of a text run, since 2241 2228 // we already did this for the parent of the text run. … … 2248 2235 } 2249 2236 2250 void RenderObject::setStyleInternal(RenderStyle* st )2251 { 2252 if (m_style == st )2237 void RenderObject::setStyleInternal(RenderStyle* style) 2238 { 2239 if (m_style == style) 2253 2240 return; 2254 2241 if (m_style) 2255 2242 m_style->deref(renderArena()); 2256 m_style = st ;2243 m_style = style; 2257 2244 if (m_style) 2258 2245 m_style->ref(); … … 2272 2259 currNew->backgroundImage()->ref(this); 2273 2260 } 2274 2261 2275 2262 CachedImage* oldBorderImage = oldStyle ? oldStyle->borderImage().image() : 0; 2276 2263 CachedImage* newBorderImage = m_style ? m_style->borderImage().image() : 0; … … 2288 2275 } 2289 2276 2290 bool RenderObject::absolutePosition(int &xPos, int &yPos, bool f)2277 bool RenderObject::absolutePosition(int& xPos, int& yPos, bool f) 2291 2278 { 2292 2279 RenderObject* o = parent(); … … 2295 2282 yPos += o->borderTopExtra(); 2296 2283 if (o->hasOverflowClip()) 2297 o->layer()->subtractScrollOffset(xPos, yPos); 2284 o->layer()->subtractScrollOffset(xPos, yPos); 2298 2285 return true; 2299 } 2300 else 2301 { 2286 } else { 2302 2287 xPos = yPos = 0; 2303 2288 return false; … … 2305 2290 } 2306 2291 2307 IntRect RenderObject::caretRect(int offset, EAffinity affinity, int *extraWidthToEndOfLine)2292 IntRect RenderObject::caretRect(int offset, EAffinity affinity, int* extraWidthToEndOfLine) 2308 2293 { 2309 2294 if (extraWidthToEndOfLine) … … 2320 2305 w = containingBlock()->contentWidth(); 2321 2306 w = padding.calcMinValue(w); 2322 if ( isTableCell() && padding.isAuto())2323 w = static_cast<const RenderTableCell 2307 if (isTableCell() && padding.isAuto()) 2308 w = static_cast<const RenderTableCell*>(this)->table()->cellPadding(); 2324 2309 return w; 2325 2310 } … … 2332 2317 w = containingBlock()->contentWidth(); 2333 2318 w = padding.calcMinValue(w); 2334 if ( isTableCell() && padding.isAuto())2335 w = static_cast<const RenderTableCell 2319 if (isTableCell() && padding.isAuto()) 2320 w = static_cast<const RenderTableCell*>(this)->table()->cellPadding(); 2336 2321 return w; 2337 2322 } … … 2344 2329 w = containingBlock()->contentWidth(); 2345 2330 w = padding.calcMinValue(w); 2346 if ( isTableCell() && padding.isAuto())2347 w = static_cast<const RenderTableCell 2331 if (isTableCell() && padding.isAuto()) 2332 w = static_cast<const RenderTableCell*>(this)->table()->cellPadding(); 2348 2333 return w; 2349 2334 } … … 2356 2341 w = containingBlock()->contentWidth(); 2357 2342 w = padding.calcMinValue(w); 2358 if ( isTableCell() && padding.isAuto())2359 w = static_cast<const RenderTableCell 2343 if (isTableCell() && padding.isAuto()) 2344 w = static_cast<const RenderTableCell*>(this)->table()->cellPadding(); 2360 2345 return w; 2361 2346 } … … 2365 2350 if (style()->collapseWhiteSpace()) 2366 2351 return 0; 2367 2352 2368 2353 return containingBlock()->tabWidth(true); 2369 2354 } … … 2379 2364 } 2380 2365 2381 RenderObject *RenderObject::container() const2366 RenderObject* RenderObject::container() const 2382 2367 { 2383 2368 // This method is extremely similar to containingBlock(), but with a few notable … … 2391 2376 // calcAbsoluteVertical have to use container(). 2392 2377 EPosition pos = m_style->position(); 2393 RenderObject *o = 0;2378 RenderObject* o = parent(); 2394 2379 if (!isText() && pos == FixedPosition) { 2395 2380 // container() can be called on an object that is not in the … … 2399 2384 // aren't we'll get the root of our little subtree (most likely 2400 2385 // 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) { 2405 2389 // Same goes here. We technically just want our containing block, but 2406 2390 // we may not have one if we're part of an uninstalled subtree. We'll 2407 2391 // climb as high as we can though. 2408 o = parent();2409 2392 while (o && o->style()->position() == StaticPosition && !o->isRenderView()) 2410 2393 o = o->parent(); 2411 2394 } 2412 else 2413 o = parent(); 2395 2414 2396 return o; 2415 2397 } … … 2427 2409 return st == SelectionStart || st == SelectionEnd || st == SelectionBoth; 2428 2410 } 2429 2430 2411 2431 2412 void RenderObject::removeFromObjectLists() … … 2440 2421 outermostBlock = p; 2441 2422 } 2442 2423 2443 2424 if (outermostBlock) 2444 2425 outermostBlock->markAllDescendantsWithFloatsForLayout(this); … … 2446 2427 2447 2428 if (isPositioned()) { 2448 RenderObject *p;2429 RenderObject* p; 2449 2430 for (p = parent(); p; p = p->parent()) { 2450 2431 if (p->isRenderBlock()) … … 2485 2466 } 2486 2467 } 2487 2468 2488 2469 document()->axObjectCache()->remove(this); 2489 2470 2490 2471 // By default no ref-counting. RenderWidget::destroy() doesn't call 2491 2472 // 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. 2493 2474 2494 2475 remove(); 2495 2476 2496 2477 arenaDelete(document()->renderArena(), this); 2497 2478 } 2498 2479 2499 void RenderObject::arenaDelete(RenderArena *arena, void *base)2480 void RenderObject::arenaDelete(RenderArena* arena, void* base) 2500 2481 { 2501 2482 if (m_style->backgroundImage()) … … 2503 2484 if (m_style) 2504 2485 m_style->deref(arena); 2505 2486 2506 2487 #ifndef NDEBUG 2507 void *savedBase = baseOfRenderObjectBeingDeleted;2488 void* savedBase = baseOfRenderObjectBeingDeleted; 2508 2489 baseOfRenderObjectBeingDeleted = base; 2509 2490 #endif … … 2512 2493 baseOfRenderObjectBeingDeleted = savedBase; 2513 2494 #endif 2514 2495 2515 2496 // Recover the size left there for us by operator delete and free the memory. 2516 arena->free(*(size_t 2497 arena->free(*(size_t*)base, base); 2517 2498 } 2518 2499 … … 2520 2501 { 2521 2502 return VisiblePosition(element(), caretMinOffset(), DOWNSTREAM); 2522 }2523 2524 bool RenderObject::isDragging() const2525 {2526 return m_isDragging;2527 2503 } 2528 2504 … … 2545 2521 // First test the foreground layer (lines and inlines). 2546 2522 inside = nodeAtPoint(request, result, x, y, tx, ty, HitTestForeground); 2547 2523 2548 2524 // Test floats next. 2549 2525 if (!inside) … … 2554 2530 inside = nodeAtPoint(request, result, x, y, tx, ty, HitTestChildBlockBackgrounds); 2555 2531 } 2556 2532 2557 2533 // See if the mouse is inside us but not any of our descendants 2558 2534 if (hitTestFilter != HitTestDescendants && !inside) 2559 2535 inside = nodeAtPoint(request, result, x, y, tx, ty, HitTestBlockBackground); 2560 2536 2561 2537 return inside; 2562 2538 } … … 2575 2551 // split. Go ahead and set our inner node accordingly. 2576 2552 node = continuation()->element(); 2577 2553 2578 2554 if (node) { 2579 2555 result.setInnerNode(node); … … 2583 2559 } 2584 2560 2585 bool RenderObject::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, 2586 int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction) 2561 bool RenderObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, int /*x*/, int /*y*/, int /*tx*/, int /*ty*/, HitTestAction) 2587 2562 { 2588 2563 return false; 2589 2564 } 2590 2565 2591 short RenderObject::verticalPositionHint( bool firstLine) const2566 short RenderObject::verticalPositionHint(bool firstLine) const 2592 2567 { 2593 2568 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) 2597 2572 m_verticalPosition = vpos; 2598 2573 } 2574 2599 2575 return vpos; 2600 2601 } 2602 2603 short RenderObject::getVerticalPosition( bool firstLine ) const 2576 } 2577 2578 short RenderObject::getVerticalPosition(bool firstLine) const 2604 2579 { 2605 2580 if (!isInline()) … … 2609 2584 int vpos = 0; 2610 2585 EVerticalAlign va = style()->verticalAlign(); 2611 if ( va == TOP ) {2586 if (va == TOP) 2612 2587 vpos = PositionTop; 2613 } else if ( va == BOTTOM ) {2588 else if (va == BOTTOM) 2614 2589 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 { 2618 2593 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; 2620 2595 // don't allow elements nested inside text-top to have a different valignment. 2621 if ( va == BASELINE)2596 if (va == BASELINE) 2622 2597 return vpos; 2623 2598 2624 const Font &f = parent()->font(firstLine);2599 const Font& f = parent()->font(firstLine); 2625 2600 int fontsize = f.pixelSize(); 2626 2601 2627 2602 if (va == SUB) 2628 vpos += fontsize /5 + 1;2603 vpos += fontsize / 5 + 1; 2629 2604 else if (va == SUPER) 2630 vpos -= fontsize /3 + 1;2605 vpos -= fontsize / 3 + 1; 2631 2606 else if (va == TEXT_TOP) 2632 2607 vpos += baselinePosition(firstLine) - f.ascent(); 2633 2608 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); 2635 2610 else if (va == TEXT_BOTTOM) { 2636 2611 vpos += f.descent(); 2637 2612 if (!isReplaced()) 2638 2613 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 2643 2618 return vpos; 2644 2619 } 2645 2620 2646 short RenderObject::lineHeight( bool firstLine, bool) const2621 short RenderObject::lineHeight(bool firstLine, bool /*isRootLineBox*/) const 2647 2622 { 2648 2623 RenderStyle* s = style(firstLine); 2649 2624 2650 2625 Length lh = s->lineHeight(); 2651 2626 … … 2670 2645 { 2671 2646 m_verticalPosition = PositionUndefined; 2672 RenderObject *child = firstChild();2673 while( child) {2647 RenderObject* child = firstChild(); 2648 while(child) { 2674 2649 child->invalidateVerticalPositions(); 2675 2650 child = child->nextSibling(); … … 2679 2654 void RenderObject::recalcMinMaxWidths() 2680 2655 { 2681 ASSERT( m_recalcMinMax ); 2682 2683 #ifdef DEBUG_LAYOUT 2684 kdDebug( 6040 ) << renderName() << " recalcMinMaxWidths() this=" << this <<endl; 2685 #endif 2656 ASSERT(m_recalcMinMax); 2686 2657 2687 2658 if (m_recalcMinMax) 2688 2659 updateFirstLetter(); 2689 2690 RenderObject *child = firstChild();2691 while ( child) {2660 2661 RenderObject* child = firstChild(); 2662 while (child) { 2692 2663 int cmin = 0; 2693 2664 int cmax = 0; 2694 2665 bool test = false; 2695 if ( ( m_minMaxKnown && child->m_recalcMinMax ) || !child->m_minMaxKnown) {2666 if ((m_minMaxKnown && child->m_recalcMinMax) || !child->m_minMaxKnown) { 2696 2667 cmin = child->minWidth(); 2697 2668 cmax = child->maxWidth(); 2698 2669 test = true; 2699 2670 } 2700 if ( child->m_recalcMinMax)2671 if (child->m_recalcMinMax) 2701 2672 child->recalcMinMaxWidths(); 2702 if ( !child->m_minMaxKnown)2673 if (!child->m_minMaxKnown) 2703 2674 child->calcMinMaxWidth(); 2704 if ( m_minMaxKnown && test && (cmin != child->minWidth() || cmax != child->maxWidth()))2675 if (m_minMaxKnown && test && (cmin != child->minWidth() || cmax != child->maxWidth())) 2705 2676 m_minMaxKnown = false; 2706 2677 child = child->nextSibling(); … … 2713 2684 m_minMaxKnown = false; 2714 2685 2715 if ( !m_minMaxKnown)2686 if (!m_minMaxKnown) 2716 2687 calcMinMaxWidth(); 2717 2688 m_recalcMinMax = false; … … 2720 2691 void RenderObject::scheduleRelayout() 2721 2692 { 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 } 2733 2703 2734 2704 void RenderObject::removeLeftoverAnonymousBoxes() … … 2751 2721 } 2752 2722 2753 void RenderObject::setInlineBoxWrapper(InlineBox* b)2723 void RenderObject::setInlineBoxWrapper(InlineBox*) 2754 2724 { 2755 2725 } … … 2759 2729 } 2760 2730 2761 RenderStyle* RenderObject::firstLineStyle() const 2762 { 2763 RenderStyle *s = m_style;2731 RenderStyle* RenderObject::firstLineStyle() const 2732 { 2733 RenderStyle* s = m_style; 2764 2734 const RenderObject* obj = isText() ? parent() : this; 2765 2735 if (obj->isBlockFlow()) { … … 2783 2753 if (!style()->hasPseudoStyle(pseudo)) 2784 2754 return 0; 2785 2755 2786 2756 if (!parentStyle) 2787 2757 parentStyle = style(); … … 2790 2760 if (result) 2791 2761 return result; 2792 2762 2793 2763 Node* node = element(); 2794 2764 if (isText()) … … 2796 2766 if (!node) 2797 2767 return 0; 2798 2768 2799 2769 if (pseudo == RenderStyle::FIRST_LINE_INHERITED) { 2800 2770 result = document()->styleSelector()->styleForElement(static_cast<Element*>(node), parentStyle, false); … … 2843 2813 if (decorations & LINE_THROUGH) 2844 2814 linethrough = curr->style()->color(); 2845 } 2815 } 2846 2816 } 2847 2817 … … 2853 2823 { 2854 2824 // Convert the style regions to absolute coordinates. 2855 if (style()->visibility() != VISIBLE) 2825 if (style()->visibility() != VISIBLE) 2856 2826 return; 2857 2827 2858 2828 const Vector<StyleDashboardRegion>& styleRegions = style()->dashboardRegions(); 2859 2829 unsigned i, count = styleRegions.size(); 2860 for (i = 0; i < count; i++) {2830 for (i = 0; i < count; i++) { 2861 2831 StyleDashboardRegion styleRegion = styleRegions[i]; 2862 2832 2863 2833 int w = width(); 2864 2834 int h = height(); 2865 2835 2866 2836 DashboardRegionValue region; 2867 2837 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()); 2873 2842 region.type = styleRegion.type; 2874 2843 … … 2884 2853 region.bounds.setX(x + styleRegion.offset.left.value()); 2885 2854 region.bounds.setY(y + styleRegion.offset.top.value()); 2886 2855 2887 2856 if (document()->frame()) { 2888 2857 float pageScaleFactor = document()->frame()->page()->chrome()->scaleFactor(); … … 2892 2861 } 2893 2862 } 2894 2863 2895 2864 regions.append(region); 2896 2865 } … … 2903 2872 if (isText()) 2904 2873 return; 2905 2874 2906 2875 addDashboardRegions(regions); 2907 2876 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) … … 2909 2878 } 2910 2879 2911 2912 2880 void RenderObject::collectBorders(DeprecatedValueList<CollapsedBorderValue>& borderStyles) 2913 2881 { … … 2918 2886 bool RenderObject::avoidsFloats() const 2919 2887 { 2920 return isReplaced() || hasOverflowClip() || isHR(); 2888 return isReplaced() || hasOverflowClip() || isHR(); 2921 2889 } 2922 2890 … … 2932 2900 2933 2901 CounterNode* RenderObject::findCounter(const String& counterName, bool willNeedLayout, 2934 bool usesSeparator, bool createIfNotFound)2902 bool usesSeparator, bool createIfNotFound) 2935 2903 { 2936 2904 if (!style()) … … 2939 2907 RenderObjectsToCounterNodeMaps* objectsMap = getRenderObjectsToCounterNodeMaps(); 2940 2908 CounterNode* newNode = 0; 2941 if (CounterNodeMap* counterNodesMap = objectsMap->get(this)) 2909 if (CounterNodeMap* counterNodesMap = objectsMap->get(this)) { 2942 2910 if (counterNodesMap) 2943 2911 newNode = counterNodesMap->get(counterName); 2944 2912 } 2913 2945 2914 if (newNode) 2946 2915 return newNode; … … 2964 2933 val = v.toInt(); 2965 2934 } 2966 } 2967 2935 } 2936 2968 2937 if (!newNode) { 2969 2938 newNode = new CounterNode(this); … … 2982 2951 newNode->setValue(0); 2983 2952 } 2984 } 2985 2953 } 2954 2986 2955 if (!newNode && !createIfNotFound) 2987 2956 return 0; … … 3004 2973 m_hasCounterNodeMap = true; 3005 2974 } 3006 2975 3007 2976 nodeMap->set(counterName, newNode); 3008 2977 … … 3017 2986 break; 3018 2987 } 3019 2988 3020 2989 CounterNode* last = current; 3021 2990 CounterNode* sibling = current; … … 3036 3005 n = n->previousSibling(); 3037 3006 } 3038 3007 3039 3008 if (sibling->isReset()) { 3040 3009 if (last != sibling) … … 3059 3028 UChar RenderObject::backslashAsCurrencySymbol() const 3060 3029 { 3061 if (Node *node = element()) 3062 if (TextResourceDecoder *decoder = node->document()->decoder())3030 if (Node *node = element()) { 3031 if (TextResourceDecoder* decoder = node->document()->decoder()) 3063 3032 return decoder->encoding().backslashAsCurrencySymbol(); 3033 } 3064 3034 return '\\'; 3065 3035 } 3066 3036 3067 void RenderObject::imageChanged(CachedImage *image)3037 void RenderObject::imageChanged(CachedImage* image) 3068 3038 { 3069 3039 // Repaint when the background image or border image finishes loading. … … 3074 3044 if (image && image->canRender() && parent()) { 3075 3045 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(); 3077 3048 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(); 3079 3051 } 3080 3052 } … … 3113 3085 } 3114 3086 3115 int RenderObject::previousOffset 3087 int RenderObject::previousOffset(int current) const 3116 3088 { 3117 3089 int previousOffset = current - 1; … … 3119 3091 } 3120 3092 3121 int RenderObject::nextOffset 3093 int RenderObject::nextOffset(int current) const 3122 3094 { 3123 3095 int nextOffset = current + 1; … … 3125 3097 } 3126 3098 3127 InlineBox *RenderObject::inlineBox(int offset, EAffinity affinity)3099 InlineBox* RenderObject::inlineBox(int offset, EAffinity affinity) 3128 3100 { 3129 3101 return inlineBoxWrapper(); … … 3141 3113 return AffineTransform(1, 0, 0, 1, xPos(), yPos()); 3142 3114 } 3143 3115 3144 3116 void RenderObject::setLocalTransform(const AffineTransform&) 3145 3117 { … … 3154 3126 } 3155 3127 3156 #endif 3157 3158 } 3128 #endif // SVG_SUPPORT 3129 3130 } // namespace WebCore 3159 3131 3160 3132 #ifndef NDEBUG -
trunk/WebCore/rendering/RenderObject.h
r17667 r17677 33 33 #include "ScrollBar.h" 34 34 #include "VisiblePosition.h" 35 #include <algorithm> 35 36 #include <wtf/HashMap.h> 36 37 … … 56 57 class FrameView; 57 58 class HTMLAreaElement; 59 class HitTestResult; 58 60 class InlineBox; 59 61 class InlineFlowBox; 60 class HitTestResult;61 62 class PlatformScrollbar; 62 63 class Position; … … 72 73 class TextStream; 73 74 class VisiblePosition; 74 75 75 struct HitTestRequest; 76 76 … … 108 108 }; 109 109 110 struct DashboardRegionValue 111 { 110 enum VerticalPositionHint { 111 PositionTop = -0x4000, 112 PositionBottom = 0x4000, 113 PositionUndefined = 0x3fff 114 }; 115 116 struct DashboardRegionValue { 117 bool operator==(const DashboardRegionValue& o) const 118 { 119 return type == o.type && bounds == o.bounds && label == o.label; 120 } 121 112 122 String label; 113 123 IntRect bounds; 114 124 IntRect clip; 115 125 int type; 116 117 bool operator==(const DashboardRegionValue& o) const118 {119 return type == o.type && bounds == o.bounds && label == o.label;120 }121 126 }; 122 127 … … 128 133 * Base Class for all rendering tree objects. 129 134 */ 130 class RenderObject : public CachedResourceClient 131 { 135 class RenderObject : public CachedResourceClient { 136 friend class RenderListItem; 137 friend class RenderContainer; 138 friend class RenderView; 132 139 public: 133 140 // Anonymous objects should pass the document as their node, and they will then automatically be 134 141 // marked as anonymous in the constructor. 135 RenderObject(Node* node);142 RenderObject(Node*); 136 143 virtual ~RenderObject(); 137 144 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; } 146 155 147 156 RenderObject* nextInPreOrder() const; … … 150 159 RenderObject* childAt(unsigned) const; 151 160 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 158 167 virtual RenderLayer* layer() const { return 0; } 159 168 RenderLayer* enclosingLayer() const; … … 161 170 void removeLayers(RenderLayer* parentLayer); 162 171 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); 165 173 virtual void positionChildLayers() { } 166 174 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); } 170 178 bool hasClip() { return isPositioned() && style()->hasClip(); } 171 172 virtual int getBaselineOfFirstLineBox() const { return -1; } 179 180 virtual int getBaselineOfFirstLineBox() const { return -1; } 173 181 virtual int getBaselineOfLastLineBox() const { return -1; } 182 174 183 virtual bool isEmpty() const { return firstChild() == 0; } 175 184 176 185 virtual bool isEdited() const { return false; } 177 virtual void setEdited(bool) { return; };178 186 virtual void setEdited(bool) { } 187 179 188 // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline 180 189 // children. 181 190 virtual RenderBlock* firstLineBlock() const; 182 191 virtual void updateFirstLetter(); 183 192 184 193 // Called when an object that was floating or positioned becomes a normal flow object 185 194 // again. We have to make sure the render tree updates as needed to accommodate the new … … 190 199 // style from this RenderObject. 191 200 RenderBlock* createAnonymousBlock(); 192 201 193 202 // Whether or not a positioned element requires normal flow x/y to be computed 194 203 // to determine its position. 195 204 bool hasStaticX() const; 196 205 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*/) { } 199 208 virtual int staticX() const { return 0; } 200 209 virtual int staticY() const { return 0; } 201 210 202 211 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 206 214 // RenderObject tree manipulation 207 215 ////////////////////////////////////////// 208 216 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*); 211 219 virtual bool createsAnonymousWrapper() const { return false; } 212 220 213 221 // 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*); 216 224 virtual void insertChildNode(RenderObject* child, RenderObject* before); 217 225 ////////////////////////////////////////// … … 220 228 ////////////////////////////////////////// 221 229 // 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; } 225 233 ////////////////////////////////////////// 226 234 private: … … 228 236 229 237 public: 230 virtual const char *renderName() const { return "RenderObject"; }231 238 #ifndef NDEBUG 232 239 DeprecatedString information() const; 233 virtual void dump(TextStream *stream, DeprecatedString ind = "") const;240 virtual void dump(TextStream*, DeprecatedString ind = "") const; 234 241 void showTreeForThis() const; 235 242 #endif 236 243 237 static RenderObject *createObject(Node* node, RenderStyle* style);244 static RenderObject* createObject(Node*, RenderStyle*); 238 245 239 246 // Overloaded new operator. Derived classes must override operator new 240 247 // 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(); 242 249 243 250 // 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 246 253 private: 247 254 // 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 250 257 public: 251 258 RenderArena* renderArena() const; 252 259 253 260 // some helper functions... 254 261 virtual bool isRenderBlock() const { return false; } … … 257 264 virtual bool isBlockFlow() const { return false; } 258 265 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;263 266 virtual bool isInlineContinuation() const; 264 265 267 virtual bool isListItem() const { return false; } 266 268 virtual bool isListMarker() const { return false; } 267 269 virtual bool isCounter() const { return false; } 268 270 virtual bool isRenderView() const { return false; } 269 bool isRoot() const;270 bool isBody() const;271 bool isHR() const;272 271 virtual bool isBR() const { return false; } 273 272 virtual bool isTableCell() const { return false; } … … 285 284 virtual bool isMenuList() const { return false; } 286 285 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 288 298 #ifdef SVG_SUPPORT 289 299 virtual bool isKCanvasContainer() const { return false; } … … 295 305 virtual AffineTransform absoluteTransform() const; 296 306 #endif 297 307 298 308 virtual bool isEditable() const; 299 309 300 bool isHTMLMarquee() const;301 302 310 bool isAnonymous() const { return m_isAnonymous; } 303 311 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 309 317 bool isFloating() const { return m_floating; } 310 318 bool isPositioned() const { return m_positioned; } // absolute or fixed positioning … … 314 322 bool isCompact() const { return style()->display() == COMPACT; } // compact object 315 323 bool isRunIn() const { return style()->display() == RUN_IN; } // run-in object 316 bool isDragging() const ;324 bool isDragging() const { return m_isDragging; } 317 325 bool isReplaced() const { return m_replaced; } // a "replaced" element (see CSS) 326 318 327 bool shouldPaintBackgroundOrBorder() const { return m_paintBackground; } 319 328 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; } 321 331 bool selfNeedsLayout() const { return m_needsLayout; } 322 332 bool posChildNeedsLayout() const { return m_posChildNeedsLayout; } 323 333 bool normalChildNeedsLayout() const { return m_normalChildNeedsLayout; } 334 324 335 bool minMaxKnown() const{ return m_minMaxKnown; } 325 336 bool recalcMinMax() const { return m_recalcMinMax; } 337 326 338 bool isSelectionBorder() const; 327 339 328 340 bool hasOverflowClip() const { return m_hasOverflowClip; } 329 341 330 342 bool hasAutoVerticalScrollbar() const { return hasOverflowClip() && (style()->overflowY() == OAUTO || style()->overflowY() == OOVERLAY); } 331 343 bool hasAutoHorizontalScrollbar() const { return hasOverflowClip() && (style()->overflowX() == OAUTO || style()->overflowX() == OOVERLAY); } … … 334 346 bool scrollsOverflowX() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || hasAutoHorizontalScrollbar()); } 335 347 bool scrollsOverflowY() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || hasAutoVerticalScrollbar()); } 336 348 337 349 bool includeVerticalScrollbarSize() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || style()->overflowY() == OAUTO); } 338 350 bool includeHorizontalScrollbarSize() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || style()->overflowX() == OAUTO); } 339 351 340 RenderStyle* getPseudoStyle(RenderStyle::PseudoId pseudo, RenderStyle* parentStyle = 0) const;341 352 RenderStyle* getPseudoStyle(RenderStyle::PseudoId, RenderStyle* parentStyle = 0) const; 353 342 354 void updateDragState(bool dragOn); 343 355 … … 349 361 void setNode(Node* node) { m_node = node; } 350 362 Node* node() const { return m_node; } 351 363 352 364 bool hasOutlineAnnotation() const; 353 365 bool hasOutline() const { return style()->hasOutline() || hasOutlineAnnotation(); } 354 366 355 367 /** 356 368 * returns the object containing this one. can be different from parent for 357 369 * positioned elements 358 370 */ 359 RenderObject *container() const;371 RenderObject* container() const; 360 372 RenderObject* hoverAncestor() const; 361 373 … … 364 376 void setNeedsLayout(bool b, bool markParents = true); 365 377 void setChildNeedsLayout(bool b, bool markParents = true); 366 void setMinMaxKnown(bool b=true) { 378 379 void setMinMaxKnown(bool b = true) 380 { 367 381 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 ) { 372 386 o->m_recalcMinMax = true; 373 387 root = o; … … 377 391 } 378 392 379 void setNeedsLayoutAndMinMaxRecalc() { 393 void setNeedsLayoutAndMinMaxRecalc() 394 { 380 395 setMinMaxKnown(false); 381 396 setNeedsLayout(true); 382 397 } 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; } 389 404 void setRenderText() { m_isText = true; } 390 void setReplaced(bool b =true) { m_replaced = b; }405 void setReplaced(bool b = true) { m_replaced = b; } 391 406 void setHasOverflowClip(bool b = true) { m_hasOverflowClip = b; } 392 407 393 408 void scheduleRelayout(); 394 409 395 410 void updateBackgroundImages(RenderStyle* oldStyle); 396 411 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 400 415 // For inline replaced elements, this function returns the inline box that owns us. Enables 401 416 // the replaced RenderObject to quickly determine what line it is contained on and to easily 402 417 // iterate over structures on the line. 403 418 virtual InlineBox* inlineBoxWrapper() const; 404 virtual void setInlineBoxWrapper(InlineBox* b);419 virtual void setInlineBoxWrapper(InlineBox*); 405 420 virtual void deleteLineBoxWrapper(); 406 421 407 virtual InlineBox *inlineBox(int offset=0, EAffinity affinity = UPSTREAM);408 422 virtual InlineBox* inlineBox(int offset = 0, EAffinity = UPSTREAM); 423 409 424 // 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; 411 426 // for the vertical-align property of inline elements 412 427 // 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; 414 429 // 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; 416 431 // width of tab character 417 432 int tabWidth() const; … … 422 437 */ 423 438 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) 425 441 : context(newContext) 426 442 , rect(newRect) … … 442 458 virtual void paint(PaintInfo&, int tx, int ty); 443 459 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*); 446 462 447 463 // RenderBox implements this. 448 464 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty) { } 449 465 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) { } 452 469 453 470 /* … … 475 492 * objects) 476 493 */ 477 virtual void calcWidth() { }494 virtual void calcWidth() { } 478 495 479 496 /* … … 494 511 // used for element state updates that can not be fixed with a 495 512 // repaint and do not need a relayout 496 virtual void updateFromElement() { };513 virtual void updateFromElement() { } 497 514 498 515 virtual int availableHeight() const { return 0; } 499 516 500 517 virtual void updateWidgetPosition(); 501 518 502 519 void addDashboardRegions(Vector<DashboardRegionValue>&); 503 520 void collectDashboardRegions(Vector<DashboardRegionValue>&); … … 506 523 // layout is complete. 507 524 struct RepaintInfo { 525 RepaintInfo(RenderObject* object, const IntRect& repaintRect) 526 : m_object(object) 527 , m_repaintRect(repaintRect) 528 { 529 } 530 508 531 RenderObject* m_object; 509 532 IntRect m_repaintRect; 510 511 RepaintInfo(RenderObject* o, const IntRect& r) :m_object(o), m_repaintRect(r) {}512 533 }; 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); 515 536 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); 516 537 void setInnerNode(HitTestResult&); … … 518 539 virtual VisiblePosition positionForCoordinates(int x, int y); 519 540 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 523 544 // 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*); 525 546 526 547 // Updates only the local style ptr of the object. Does not update the state of the object, 527 548 // 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*); 529 550 530 551 // returns the containing block level element for this element. 531 RenderBlock *containingBlock() const;552 RenderBlock* containingBlock() const; 532 553 533 554 // return just the width of the containing block … … 548 569 virtual int overrideWidth() const { return 0; } 549 570 virtual int overrideHeight() const { return 0; } 550 virtual void setOverrideSize(int s) {}571 virtual void setOverrideSize(int /*overrideSize*/) { } 551 572 552 573 // 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*/) { } 556 577 557 578 virtual int xPos() const { return 0; } … … 559 580 560 581 // 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 563 584 // This function is used to deal with the extra top space that can occur in table cells (called borderTopExtra). 564 585 // The children of the cell do not factor this space in, so we have to add it in. Any code that wants to 565 586 // 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 { 567 589 absolutePosition(xPos, yPos, fixed); 568 590 yPos += borderTopExtra(); … … 578 600 // of the block (e.g., a <div style="height:25px"> that has a 100px tall image inside 579 601 // 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) 589 611 // to return the remaining width on a given line (and the height of a single line). -dwh 590 612 virtual int offsetWidth() const { return width(); } 591 613 virtual int offsetHeight() const { return height() + borderTopExtra() + borderBottomExtra(); } 592 593 // IE ex xtensions. Also supported by Gecko. We override in render flow to get the614 615 // IE extensions. Also supported by Gecko. We override in render flow to get the 594 616 // left and top correct. -dwh 595 617 virtual int offsetLeft() const; … … 616 638 virtual void setScrollTop(int); 617 639 618 virtual bool scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier=1.0);640 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f); 619 641 virtual bool shouldAutoscroll() const; 620 642 virtual void autoscroll(); 621 virtual void stopAutoscroll() { };643 virtual void stopAutoscroll() { } 622 644 623 645 // The following seven functions are used to implement collapsing margins. … … 628 650 // methods. 629 651 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); } 634 654 virtual bool isTopMarginQuirk() const { return false; } 635 655 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()); } 660 659 661 660 virtual int marginTop() const { return 0; } … … 664 663 virtual int marginRight() const { return 0; } 665 664 666 // Virtual since table cells override 665 // Virtual since table cells override 667 666 virtual int paddingTop() const; 668 667 virtual int paddingBottom() const; 669 668 virtual int paddingLeft() const; 670 669 virtual int paddingRight() const; 671 670 672 671 virtual int borderTop() const { return style()->borderTopWidth(); } 673 672 virtual int borderBottom() const { return style()->borderBottomWidth(); } … … 681 680 virtual void absoluteRects(Vector<IntRect>&, int tx, int ty); 682 681 IntRect absoluteBoundingBoxRect(); 683 682 684 683 // the rect that will be painted if this object is passed as the paintingRoot 685 684 IntRect paintingRootRect(IntRect& topLevelRect); 686 685 687 void addPDFURLRect(GraphicsContext* p, IntRect rect);686 void addPDFURLRect(GraphicsContext*, IntRect); 688 687 689 688 virtual void addFocusRingRects(GraphicsContext*, int tx, int ty); … … 696 695 RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle() : style(); } 697 696 698 699 697 void getTextDecorationColors(int decorations, Color& underline, Color& overline, 700 Color& linethrough, bool quirksMode =false);698 Color& linethrough, bool quirksMode = false); 701 699 702 700 enum BorderSide { 703 BSTop, BSBottom, BSLeft, BSRight 701 BSTop, 702 BSBottom, 703 BSLeft, 704 BSRight 704 705 }; 706 705 707 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); 707 709 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*) { } 711 713 712 714 // Used by collapsed border tables. … … 718 720 719 721 // 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 722 724 // Repaint only if our old bounds and new bounds are different. 723 725 bool repaintAfterLayoutIfNeeded(const IntRect& oldBounds, const IntRect& oldFullBounds); … … 744 746 // Given a rect in the object's coordinate space, this method converts the rectangle to the view's 745 747 // coordinate space. 746 virtual void computeAbsoluteRepaintRect(IntRect& r, bool f=false);747 748 virtual void computeAbsoluteRepaintRect(IntRect&, bool fixed = false); 749 748 750 virtual unsigned int length() const { return 1; } 749 751 750 bool isFloatingOrPositioned() const { return (isFloating() || isPositioned()); } ;752 bool isFloatingOrPositioned() const { return (isFloating() || isPositioned()); } 751 753 virtual bool containsFloats() { return false; } 752 virtual bool containsFloat(RenderObject* o) { return false; }754 virtual bool containsFloat(RenderObject*) { return false; } 753 755 virtual bool hasOverhangingFloats() { return false; } 754 756 virtual bool expandsToEncloseOverhangingFloats() const { return isFloating() && style()->height().isAuto(); } … … 767 769 768 770 // 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; 770 772 771 773 enum SelectionState { … … 780 782 // descendants (as described above in the SelectionState enum declaration). 781 783 virtual SelectionState selectionState() const { return SelectionNone; } 782 784 783 785 // 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); } 785 787 786 788 // A single rectangle that encompasses all of the selected objects within this object. Used to determine the tightest 787 789 // possible bounding box for the selection. 788 790 virtual IntRect selectionRect() { return IntRect(); } 789 791 790 792 // Whether or not an object can be part of the leaf elements of the selection. 791 793 virtual bool canBeSelectionLeaf() const { return false; } … … 800 802 // since it fires the selectstart DOM event. 801 803 bool shouldSelect() const; 802 804 803 805 // Obtains the selection colors that should be used when painting a selection. 804 806 Color selectionBackgroundColor() const; … … 810 812 // This struct is used when the selection changes to cache the old and new state of the selection for each RenderObject. 811 813 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 } 815 826 816 827 RenderObject* object() const { return m_object; } 817 828 IntRect rect() const { return m_rect; } 818 829 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; 822 834 }; 823 835 … … 832 844 * useful for character range rect computations 833 845 */ 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() { } 841 853 void removeFromObjectLists(); 842 854 … … 847 859 virtual void destroy(); 848 860 849 const Font& font(bool firstLine) const { 850 return style(firstLine)->font(); 851 } 861 const Font& font(bool firstLine) const { return style(firstLine)->font(); } 852 862 853 863 // Virtual function helpers for CSS3 Flexible Box Layout … … 863 873 virtual unsigned caretMaxRenderedOffset() const; 864 874 865 virtual int previousOffset 866 virtual int nextOffset 875 virtual int previousOffset(int current) const; 876 virtual int nextOffset(int current) const; 867 877 868 878 virtual void imageChanged(CachedImage*); … … 893 903 894 904 virtual void removeLeftoverAnonymousBoxes(); 895 905 896 906 void arenaDelete(RenderArena*, void* objectBase); 897 907 … … 901 911 Node* m_node; 902 912 903 RenderObject *m_parent;904 RenderObject *m_previous;905 RenderObject *m_next;913 RenderObject* m_parent; 914 RenderObject* m_previous; 915 RenderObject* m_next; 906 916 907 917 mutable short m_verticalPosition; … … 924 934 bool m_replaced : 1; 925 935 bool m_isDragging : 1; 926 936 927 937 bool m_hasOverflowClip : 1; 928 938 929 939 bool m_hasCounterNodeMap : 1; 930 931 friend class RenderListItem;932 friend class RenderContainer;933 friend class RenderView;934 940 }; 935 941 936 937 enum VerticalPositionHint { 938 PositionTop = -0x4000, 939 PositionBottom = 0x4000, 940 PositionUndefined = 0x3fff 941 }; 942 943 } //namespace 942 } // namespace WebCore 944 943 945 944 #ifndef NDEBUG … … 948 947 #endif 949 948 950 951 #endif 949 #endif // RenderObject_h
Note: See TracChangeset
for help on using the changeset viewer.