Changeset 21093 in webkit
- Timestamp:
- Apr 25, 2007, 12:10:24 PM (18 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r21092 r21093 1 2007-04-25 David Hyatt <hyatt@apple.com> 2 3 Rearchitect calcPrefWidths. The calculation is now done lazily only when minPrefWidth 4 or maxPrefWidth are asked for. The result of the calculation is cached. 5 6 The new invalidation scheme for pref width invalidation follows the 7 containing block hierarchy and knows to halt at positioned objects, since 8 they cannot influence the size of their containers. 9 10 Reviewed by darin 11 12 * css/cssstyleselector.cpp: 13 (WebCore::CSSStyleSelector::init): 14 (WebCore::CSSStyleSelector::initForStyleResolve): 15 * page/FrameView.cpp: 16 (WebCore::FrameView::layout): 17 * rendering/RenderApplet.cpp: 18 (WebCore::RenderApplet::layout): 19 * rendering/RenderBlock.cpp: 20 (WebCore::RenderBlock::makeChildrenNonInline): 21 (WebCore::RenderBlock::removeChild): 22 (WebCore::RenderBlock::layout): 23 (WebCore::RenderBlock::layoutBlock): 24 (WebCore::RenderBlock::calcPrefWidths): 25 (WebCore::InlineMinMaxIterator::endOfInline): 26 (WebCore::shouldGrowTableCellForImage): 27 (WebCore::RenderBlock::calcInlinePrefWidths): 28 (WebCore::RenderBlock::calcBlockPrefWidths): 29 * rendering/RenderBlock.h: 30 * rendering/RenderBox.cpp: 31 (WebCore::RenderBox::setStyle): 32 (WebCore::RenderBox::minPrefWidth): 33 (WebCore::RenderBox::maxPrefWidth): 34 (WebCore::RenderBox::calcWidth): 35 (WebCore::RenderBox::calcWidthUsing): 36 (WebCore::RenderBox::calcAbsoluteHorizontal): 37 (WebCore::RenderBox::calcAbsoluteHorizontalValues): 38 * rendering/RenderBox.h: 39 * rendering/RenderContainer.cpp: 40 (WebCore::RenderContainer::removeChildNode): 41 (WebCore::RenderContainer::appendChildNode): 42 (WebCore::RenderContainer::insertChildNode): 43 (WebCore::RenderContainer::layout): 44 * rendering/RenderContainer.h: 45 (WebCore::RenderContainer::moveChildNode): 46 * rendering/RenderCounter.cpp: 47 (WebCore::RenderCounter::dirtyLineBoxes): 48 (WebCore::RenderCounter::calcPrefWidths): 49 * rendering/RenderCounter.h: 50 * rendering/RenderFileUploadControl.cpp: 51 (WebCore::RenderFileUploadControl::calcPrefWidths): 52 * rendering/RenderFlexibleBox.cpp: 53 (WebCore::RenderFlexibleBox::calcHorizontalPrefWidths): 54 (WebCore::RenderFlexibleBox::calcVerticalPrefWidths): 55 (WebCore::RenderFlexibleBox::calcPrefWidths): 56 (WebCore::RenderFlexibleBox::layoutBlock): 57 * rendering/RenderForeignObject.cpp: 58 (WebCore::RenderForeignObject::layout): 59 * rendering/RenderFrameSet.cpp: 60 (WebCore::RenderFrameSet::layout): 61 * rendering/RenderHTMLCanvas.cpp: 62 (WebCore::RenderHTMLCanvas::layout): 63 * rendering/RenderImage.cpp: 64 (WebCore::RenderImage::layout): 65 * rendering/RenderInline.cpp: 66 * rendering/RenderInline.h: 67 * rendering/RenderListBox.cpp: 68 (WebCore::RenderListBox::updateFromElement): 69 (WebCore::RenderListBox::calcPrefWidths): 70 * rendering/RenderListItem.cpp: 71 (WebCore::firstNonMarkerChild): 72 (WebCore::RenderListItem::updateMarkerLocation): 73 (WebCore::RenderListItem::calcPrefWidths): 74 (WebCore::RenderListItem::layout): 75 * rendering/RenderListMarker.cpp: 76 (WebCore::RenderListMarker::layout): 77 (WebCore::RenderListMarker::calcPrefWidths): 78 (WebCore::RenderListMarker::updateMargins): 79 * rendering/RenderListMarker.h: 80 * rendering/RenderObject.cpp: 81 (WebCore::RenderObject::RenderObject): 82 (WebCore::RenderObject::removeChildNode): 83 (WebCore::RenderObject::moveChildNode): 84 (WebCore::RenderObject::appendChildNode): 85 (WebCore::RenderObject::insertChildNode): 86 (WebCore::RenderObject::setPrefWidthsDirty): 87 (WebCore::RenderObject::invalidateContainingBlockPrefWidths): 88 (WebCore::RenderObject::information): 89 (WebCore::RenderObject::setStyle): 90 * rendering/RenderObject.h: 91 (WebCore::RenderObject::layer): 92 (WebCore::RenderObject::hasLayer): 93 (WebCore::RenderObject::prefWidthsDirty): 94 (WebCore::RenderObject::setNeedsLayoutAndPrefWidthsRecalc): 95 (WebCore::RenderObject::setHasLayer): 96 * rendering/RenderPartObject.cpp: 97 (WebCore::RenderPartObject::layout): 98 * rendering/RenderSVGContainer.cpp: 99 (WebCore::RenderSVGContainer::layout): 100 * rendering/RenderSVGContainer.h: 101 * rendering/RenderSVGHiddenContainer.cpp: 102 * rendering/RenderSVGHiddenContainer.h: 103 * rendering/RenderSVGText.cpp: 104 (WebCore::RenderSVGText::layout): 105 * rendering/RenderTable.cpp: 106 (WebCore::RenderTable::calcWidth): 107 (WebCore::RenderTable::layout): 108 (WebCore::RenderTable::removeChildNode): 109 * rendering/RenderTable.h: 110 * rendering/RenderTableRow.cpp: 111 (WebCore::RenderTableRow::layout): 112 * rendering/RenderTableSection.cpp: 113 (WebCore::RenderTableSection::removeChildNode): 114 * rendering/RenderTableSection.h: 115 * rendering/RenderText.cpp: 116 (WebCore::RenderText::trimmedPrefWidths): 117 (WebCore::isSpaceAccordingToStyle): 118 (WebCore::RenderText::minPrefWidth): 119 (WebCore::RenderText::maxPrefWidth): 120 (WebCore::RenderText::calcPrefWidths): 121 (WebCore::RenderText::width): 122 * rendering/RenderText.h: 123 * rendering/RenderView.cpp: 124 (WebCore::RenderView::RenderView): 125 (WebCore::RenderView::calcPrefWidths): 126 (WebCore::RenderView::layout): 127 * rendering/RenderWidget.cpp: 128 (WebCore::RenderWidget::layout): 129 1 130 2007-04-25 Steve Falkenburg <sfalken@apple.com> 2 131 … … 494 623 <rdar://problem/4966982> 64-bit: In a unordered list, TYPE=DISC and TYPE=CIRCLE attribute values are ignored 495 624 496 We need to draw our full-circle arcs counter-clockwise, since a clockwise arc from 0 to 2 πis no arc at all!625 We need to draw our full-circle arcs counter-clockwise, since a clockwise arc from 0 to 2Ï is no arc at all! 497 626 This only worked on 32-bit due to a rounding error in CoreGraphics, causing it to draw a full circle anyway. 498 627 -
trunk/WebCore/css/cssstyleselector.cpp
r21061 r21093 302 302 element = 0; 303 303 settings = 0; 304 m_matchedRules.clear();305 304 m_matchedDecls.clear(); 306 305 m_ruleList = 0; … … 565 564 style = 0; 566 565 567 m_matchedRules.clear();568 566 m_matchedDecls.clear(); 569 567 -
trunk/WebCore/page/FrameView.cpp
r20964 r21093 411 411 } 412 412 413 if (subtree) {414 if (root->recalcMinMax())415 root->recalcMinMaxWidths();416 }417 413 pauseScheduledEvents(); 418 414 root->layout(); -
trunk/WebCore/rendering/RenderApplet.cpp
r21079 r21093 96 96 { 97 97 ASSERT(needsLayout()); 98 ASSERT(!prefWidthsDirty());99 98 100 99 calcWidth(); -
trunk/WebCore/rendering/RenderBlock.cpp
r21082 r21093 326 326 RenderObject* no = o; 327 327 o = no->nextSibling(); 328 box-> appendChildNode(removeChildNode(no));329 } 330 box-> appendChildNode(removeChildNode(inlineRunEnd));328 box->moveChildNode(no); 329 } 330 box->moveChildNode(inlineRunEnd); 331 331 } 332 332 … … 356 356 RenderObject* no = o; 357 357 o = no->nextSibling(); 358 prev->appendChildNode(next->removeChildNode(no)); 359 no->setNeedsLayoutAndPrefWidthsRecalc(); 358 prev->moveChildNode(no); 360 359 } 361 360 … … 381 380 RenderObject* no = o; 382 381 o = no->nextSibling(); 383 appendChildNode(anonBlock->removeChildNode(no)); 384 no->setNeedsLayoutAndPrefWidthsRecalc(); 382 moveChildNode(no); 385 383 } 386 384 … … 465 463 void RenderBlock::layout() 466 464 { 465 // Update our first letter info now. 466 updateFirstLetter(); 467 467 468 // Table cells call layoutBlock directly, so don't add any logic here. Put code into 468 469 // layoutBlock(). … … 482 483 { 483 484 ASSERT(needsLayout()); 484 ASSERT(!prefWidthsDirty());485 485 486 486 if (isInline() && !isInlineBlockOrInlineTable()) // Inline <form>s inside various table elements can … … 3252 3252 ASSERT(prefWidthsDirty()); 3253 3253 3254 updateFirstLetter(); 3255 3254 3256 if (!isTableCell() && style()->width().isFixed() && style()->width().value() > 0) 3255 3257 m_minPrefWidth = m_maxPrefWidth = calcContentBoxWidth(style()->width().value()); … … 3274 3276 3275 3277 if (isTableCell()) { 3276 Length w = static_cast< RenderTableCell*>(this)->styleOrColWidth();3278 Length w = static_cast<const RenderTableCell*>(this)->styleOrColWidth(); 3277 3279 if (w.isFixed() && w.value() > 0) 3278 3280 m_maxPrefWidth = max(m_minPrefWidth, calcContentBoxWidth(w.value())); … … 3313 3315 bool endOfInline; 3314 3316 3315 InlineMinMaxIterator(RenderObject* p, RenderObject* o,bool end = false)3316 :parent(p), current( o), endOfInline(end) {}3317 InlineMinMaxIterator(RenderObject* p, bool end = false) 3318 :parent(p), current(p), endOfInline(end) {} 3317 3319 3318 3320 RenderObject* next(); … … 3404 3406 // very specific cirucumstances. Not supporting the quirk has caused us to 3405 3407 // mis-render some real sites. (See Bugzilla 10517.) 3406 static bool shouldGrowTableCellForImage( RenderBlock* containingBlock, RenderObject* image,RenderObject* adjacentLeaf)3408 static bool shouldGrowTableCellForImage(const RenderBlock* containingBlock, const RenderObject* image, const RenderObject* adjacentLeaf) 3407 3409 { 3408 3410 if (!containingBlock->style()->htmlHacks()) … … 3439 3441 autoWrap = oldAutoWrap = style()->autoWrap(); 3440 3442 3441 InlineMinMaxIterator childIterator(this , this);3443 InlineMinMaxIterator childIterator(this); 3442 3444 bool addedTextIndent = false; // Only gets added in once. 3443 3445 RenderObject* prevFloat = 0; 3444 3446 RenderObject* previousLeaf = 0; 3445 while (RenderObject* child = childIterator.next()) 3446 { 3447 while (RenderObject* child = childIterator.next()) { 3447 3448 InlineMinMaxIterator leafIterator = childIterator; 3448 3449 RenderObject* nextLeaf = leafIterator.next(); … … 3510 3511 Length leftMargin = cstyle->marginLeft(); 3511 3512 Length rightMargin = cstyle->marginRight(); 3512 bool useCalculatedWidths = child->isListMarker(); 3513 if (leftMargin.isPercent() || rightMargin.isPercent() || useCalculatedWidths) 3514 child->calcWidth(); 3515 if (useCalculatedWidths || leftMargin.isPercent()) 3516 margins += child->marginLeft(); 3517 else if (leftMargin.isFixed()) 3513 if (leftMargin.isFixed()) 3518 3514 margins += leftMargin.value(); 3519 if (useCalculatedWidths || rightMargin.isPercent()) 3520 margins += child->marginRight(); 3521 else if (rightMargin.isFixed()) 3515 if (rightMargin.isFixed()) 3522 3516 margins += rightMargin.value(); 3523 3517 childMin += margins; … … 3710 3704 } 3711 3705 3706 // A margin basically has three types: fixed, percentage, and auto (variable). 3707 // Auto and percentage margins simply become 0 when computing min/max width. 3708 // Fixed margins can be added in as is. 3712 3709 Length ml = child->style()->marginLeft(); 3713 3710 Length mr = child->style()->marginRight(); 3714 3715 // Call calcWidth on the child to ensure that our margins are3716 // up to date. This method can be called before the child has actually3717 // calculated its margins (which are computed inside calcWidth).3718 if (ml.isPercent() || mr.isPercent())3719 calcWidth();3720 3721 // A margin basically has three types: fixed, percentage, and auto (variable).3722 // Auto margins simply become 0 when computing min/max width.3723 // Fixed margins can be added in as is.3724 // Percentage margins are computed as a percentage of the width we calculated in3725 // the calcWidth call above. In this case we use the actual cached margin values on3726 // the RenderObject itself.3727 3711 int margin = 0, marginLeft = 0, marginRight = 0; 3728 3712 if (ml.isFixed()) 3729 3713 marginLeft += ml.value(); 3730 else if (ml.isPercent())3731 marginLeft += child->marginLeft();3732 3714 if (mr.isFixed()) 3733 3715 marginRight += mr.value(); 3734 else if (mr.isPercent())3735 marginRight += child->marginRight();3736 3716 margin = marginLeft + marginRight; 3737 3717 -
trunk/WebCore/rendering/RenderBox.cpp
r21079 r21093 117 117 setChildNeedsLayout(true); 118 118 m_layer = new (renderArena()) RenderLayer(this); 119 setHasLayer(true); 119 120 m_layer->insertOnlyThisLayer(); 120 121 if (parent() && !needsLayout() && containingBlock()) … … 125 126 RenderLayer* layer = m_layer; 126 127 m_layer = 0; 128 setHasLayer(false); 127 129 layer->removeOnlyThisLayer(); 128 130 if (wasFloating && isFloating()) … … 165 167 if (layer) 166 168 layer->destroy(arena); 169 } 170 171 int RenderBox::minPrefWidth() const 172 { 173 if (prefWidthsDirty()) 174 const_cast<RenderBox*>(this)->calcPrefWidths(); 175 176 return m_minPrefWidth; 177 } 178 179 int RenderBox::maxPrefWidth() const 180 { 181 if (prefWidthsDirty()) 182 const_cast<RenderBox*>(this)->calcPrefWidths(); 183 184 return m_maxPrefWidth; 167 185 } 168 186 … … 1058 1076 m_marginRight = marginRight.calcMinValue(containerWidth); 1059 1077 if (treatAsReplaced) 1060 m_width = max(width.value() + borderLeft() + borderRight() + paddingLeft() + paddingRight(), m _minPrefWidth);1078 m_width = max(width.value() + borderLeft() + borderRight() + paddingLeft() + paddingRight(), minPrefWidth()); 1061 1079 1062 1080 return; … … 1087 1105 } 1088 1106 1089 if ( m_width < m_minPrefWidth &&stretchesToMinIntrinsicWidth()) {1090 m_width = m _minPrefWidth;1107 if (stretchesToMinIntrinsicWidth()) { 1108 m_width = max(m_width, minPrefWidth()); 1091 1109 width = Length(m_width, Fixed); 1092 1110 } … … 1129 1147 1130 1148 if (sizesToIntrinsicWidth(widthType)) { 1131 width = max(width, m _minPrefWidth);1132 width = min(width, m _maxPrefWidth);1149 width = max(width, minPrefWidth()); 1150 width = min(width, maxPrefWidth()); 1133 1151 } 1134 1152 } else … … 1665 1683 } 1666 1684 1667 if ( m_width < m_minPrefWidth - bordersPlusPadding && stretchesToMinIntrinsicWidth())1668 calcAbsoluteHorizontalValues(Length(m _minPrefWidth- bordersPlusPadding, Fixed), containerBlock, containerDirection,1685 if (stretchesToMinIntrinsicWidth() && m_width < minPrefWidth() - bordersPlusPadding) 1686 calcAbsoluteHorizontalValues(Length(minPrefWidth() - bordersPlusPadding, Fixed), containerBlock, containerDirection, 1669 1687 containerWidth, bordersPlusPadding, 1670 1688 left, right, marginLeft, marginRight, … … 1799 1817 1800 1818 // FIXME: would it be better to have shrink-to-fit in one step? 1801 int preferredWidth = m _maxPrefWidth- bordersPlusPadding;1802 int preferredMinWidth = m _minPrefWidth- bordersPlusPadding;1819 int preferredWidth = maxPrefWidth() - bordersPlusPadding; 1820 int preferredMinWidth = minPrefWidth() - bordersPlusPadding; 1803 1821 int availableWidth = availableSpace - rightValue; 1804 1822 widthValue = min(max(preferredMinWidth, availableWidth), preferredWidth); … … 1809 1827 1810 1828 // FIXME: would it be better to have shrink-to-fit in one step? 1811 int preferredWidth = m _maxPrefWidth- bordersPlusPadding;1812 int preferredMinWidth = m _minPrefWidth- bordersPlusPadding;1829 int preferredWidth = maxPrefWidth() - bordersPlusPadding; 1830 int preferredMinWidth = minPrefWidth() - bordersPlusPadding; 1813 1831 int availableWidth = availableSpace - leftValue; 1814 1832 widthValue = min(max(preferredMinWidth, availableWidth), preferredWidth); -
trunk/WebCore/rendering/RenderBox.h
r21079 r21093 43 43 virtual void destroy(); 44 44 45 virtual int minPrefWidth() const { return m_minPrefWidth; }46 virtual int maxPrefWidth() const { return m_maxPrefWidth; }45 virtual int minPrefWidth() const; 46 virtual int maxPrefWidth() const; 47 47 48 48 virtual int overrideSize() const; … … 183 183 void calcAbsoluteHorizontalReplaced(); 184 184 185 // This function calculates the minimum and maximum preferred widths for an object. 186 // These values are used in shrink-to-fit layout systems. 187 // These include tables, positioned objects, floats and flexible boxes. 188 virtual void calcPrefWidths() = 0; 189 185 190 protected: 186 191 // The width/height of the contents + borders + padding. -
trunk/WebCore/rendering/RenderContainer.cpp
r21082 r21093 157 157 } 158 158 159 RenderObject* RenderContainer::removeChildNode(RenderObject* oldChild )159 RenderObject* RenderContainer::removeChildNode(RenderObject* oldChild, bool fullRemove) 160 160 { 161 161 ASSERT(oldChild->parent() == this); … … 164 164 // that a positioned child got yanked). We also repaint, so that the area exposed when the child 165 165 // disappears gets repainted properly. 166 if (!documentBeingDestroyed() ) {166 if (!documentBeingDestroyed() && fullRemove) { 167 167 oldChild->setNeedsLayoutAndPrefWidthsRecalc(); 168 168 oldChild->repaint(); … … 172 172 oldChild->deleteLineBoxWrapper(); 173 173 174 if (!documentBeingDestroyed() ) {174 if (!documentBeingDestroyed() && fullRemove) { 175 175 // if we remove visible child from an invisible parent, we don't know the layer visibility any more 176 176 RenderLayer* layer = 0; … … 376 376 377 377 378 void RenderContainer::appendChildNode(RenderObject* newChild )378 void RenderContainer::appendChildNode(RenderObject* newChild, bool fullAppend) 379 379 { 380 380 ASSERT(newChild->parent() == 0); … … 392 392 m_lastChild = newChild; 393 393 394 // Keep our layer hierarchy updated. Optimize for the common case where we don't have any children 395 // and don't have a layer attached to ourselves. 396 RenderLayer* layer = 0; 397 if (newChild->firstChild() || newChild->hasLayer()) { 398 layer = enclosingLayer(); 399 newChild->addLayers(layer, newChild); 400 } 401 402 // if the new child is visible but this object was not, tell the layer it has some visible content 403 // that needs to be drawn and layer visibility optimization can't be used 404 if (style()->visibility() != VISIBLE && newChild->style()->visibility() == VISIBLE && !newChild->hasLayer()) { 405 if (!layer) 394 if (fullAppend) { 395 // Keep our layer hierarchy updated. Optimize for the common case where we don't have any children 396 // and don't have a layer attached to ourselves. 397 RenderLayer* layer = 0; 398 if (newChild->firstChild() || newChild->hasLayer()) { 406 399 layer = enclosingLayer(); 407 if (layer) 408 layer->setHasVisibleContent(true); 409 } 410 400 newChild->addLayers(layer, newChild); 401 } 402 403 // if the new child is visible but this object was not, tell the layer it has some visible content 404 // that needs to be drawn and layer visibility optimization can't be used 405 if (style()->visibility() != VISIBLE && newChild->style()->visibility() == VISIBLE && !newChild->hasLayer()) { 406 if (!layer) 407 layer = enclosingLayer(); 408 if (layer) 409 layer->setHasVisibleContent(true); 410 } 411 412 if (!newChild->isFloatingOrPositioned() && childrenInline()) 413 dirtyLinesFromChangedChild(newChild); 414 } 415 411 416 newChild->setNeedsLayoutAndPrefWidthsRecalc(); // Goes up the containing block hierarchy. 412 417 if (!normalChildNeedsLayout()) 413 418 setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child. 414 419 415 if (!newChild->isFloatingOrPositioned() && childrenInline())416 dirtyLinesFromChangedChild(newChild);417 418 420 if (AXObjectCache::accessibilityEnabled()) 419 421 document()->axObjectCache()->childrenChanged(this); 420 422 } 421 423 422 void RenderContainer::insertChildNode(RenderObject* child, RenderObject* beforeChild )424 void RenderContainer::insertChildNode(RenderObject* child, RenderObject* beforeChild, bool fullInsert) 423 425 { 424 426 if (!beforeChild) { … … 445 447 child->setParent(this); 446 448 447 // Keep our layer hierarchy updated. Optimize for the common case where we don't have any children 448 // and don't have a layer attached to ourselves. 449 RenderLayer* layer = 0; 450 if (child->firstChild() || child->hasLayer()) { 451 layer = enclosingLayer(); 452 child->addLayers(layer, child); 453 } 454 455 // if the new child is visible but this object was not, tell the layer it has some visible content 456 // that needs to be drawn and layer visibility optimization can't be used 457 if (style()->visibility() != VISIBLE && child->style()->visibility() == VISIBLE && !child->hasLayer()) { 458 if (!layer) 449 if (fullInsert) { 450 // Keep our layer hierarchy updated. Optimize for the common case where we don't have any children 451 // and don't have a layer attached to ourselves. 452 RenderLayer* layer = 0; 453 if (child->firstChild() || child->hasLayer()) { 459 454 layer = enclosingLayer(); 460 if (layer) 461 layer->setHasVisibleContent(true); 455 child->addLayers(layer, child); 456 } 457 458 // if the new child is visible but this object was not, tell the layer it has some visible content 459 // that needs to be drawn and layer visibility optimization can't be used 460 if (style()->visibility() != VISIBLE && child->style()->visibility() == VISIBLE && !child->hasLayer()) { 461 if (!layer) 462 layer = enclosingLayer(); 463 if (layer) 464 layer->setHasVisibleContent(true); 465 } 466 467 468 if (!child->isFloating() && childrenInline()) 469 dirtyLinesFromChangedChild(child); 462 470 } 463 471 … … 466 474 setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child. 467 475 468 if (!child->isFloating() && childrenInline())469 dirtyLinesFromChangedChild(child);470 471 476 if (AXObjectCache::accessibilityEnabled()) 472 477 document()->axObjectCache()->childrenChanged(this); … … 476 481 { 477 482 ASSERT(needsLayout()); 478 ASSERT(!prefWidthsDirty());479 483 480 484 RenderObject* child = m_firstChild; -
trunk/WebCore/rendering/RenderContainer.h
r21079 r21093 42 42 void destroyLeftoverChildren(); 43 43 44 virtual RenderObject* removeChildNode(RenderObject*); 45 virtual void appendChildNode(RenderObject*); 46 virtual void insertChildNode(RenderObject* child, RenderObject* before); 47 44 virtual RenderObject* removeChildNode(RenderObject*, bool fullRemove = true); 45 virtual void appendChildNode(RenderObject*, bool fullAppend = true); 46 virtual void insertChildNode(RenderObject* child, RenderObject* before, bool fullInsert = true); 47 48 // Designed for speed. Don't waste time doing a bunch of work like layer updating and repainting when we know that our 49 // change in parentage is not going to affect anything. 50 virtual void moveChildNode(RenderObject* child) { appendChildNode(child->parent()->removeChildNode(child, false), false); } 51 48 52 virtual void layout(); 49 53 virtual void calcPrefWidths() { setPrefWidthsDirty(false); } -
trunk/WebCore/rendering/RenderCounter.cpp
r21079 r21093 245 245 } 246 246 247 void RenderCounter::calcPrefWidths() 247 void RenderCounter::dirtyLineBoxes(bool fullLayout, bool dummy) 248 { 249 if (prefWidthsDirty()) 250 calcPrefWidths(0); 251 RenderText::dirtyLineBoxes(fullLayout, dummy); 252 } 253 254 void RenderCounter::calcPrefWidths(int lead) 248 255 { 249 256 setTextInternal(originalText()); 250 RenderText::calcPrefWidths( );257 RenderText::calcPrefWidths(lead); 251 258 } 252 259 -
trunk/WebCore/rendering/RenderCounter.h
r21079 r21093 36 36 virtual bool isRenderCounter() const; 37 37 virtual PassRefPtr<StringImpl> originalText() const; 38 virtual void calcPrefWidths(); 38 39 virtual void dirtyLineBoxes(bool, bool); 40 virtual void calcPrefWidths(int leadWidth); 39 41 40 42 static void destroyCounterNodes(RenderObject*); -
trunk/WebCore/rendering/RenderFileUploadControl.cpp
r21079 r21093 232 232 void RenderFileUploadControl::calcPrefWidths() 233 233 { 234 ASSERT(prefWidthsDirty()); 235 234 236 m_minPrefWidth = 0; 235 237 m_maxPrefWidth = 0; -
trunk/WebCore/rendering/RenderFlexibleBox.cpp
r21082 r21093 120 120 } 121 121 122 int margin=0;123 // auto margins don't affect minwidth124 122 // A margin basically has three types: fixed, percentage, and auto (variable). 123 // Auto and percentage margins simply become 0 when computing min/max width. 124 // Fixed margins can be added in as is. 125 125 Length ml = child->style()->marginLeft(); 126 126 Length mr = child->style()->marginRight(); 127 128 // Call calcWidth on the child to ensure that our margins are 129 // up to date. This method can be called before the child has actually 130 // calculated its margins (which are computed inside calcWidth). 131 child->calcWidth(); 132 133 if (!ml.isAuto() && !mr.isAuto()) { 134 if (!child->style()->width().isAuto()) { 135 if (child->style()->direction()==LTR) 136 margin = child->marginLeft(); 137 else 138 margin = child->marginRight(); 139 } else 140 margin = child->marginLeft()+child->marginRight(); 141 } else if (!ml.isAuto()) 142 margin = child->marginLeft(); 143 else if (!mr.isAuto()) 144 margin = child->marginRight(); 145 146 margin = max(margin, 0); 127 int margin = 0, marginLeft = 0, marginRight = 0; 128 if (ml.isFixed()) 129 marginLeft += ml.value(); 130 if (mr.isFixed()) 131 marginRight += mr.value(); 132 margin = marginLeft + marginRight; 147 133 148 134 m_minPrefWidth += child->minPrefWidth() + margin; … … 164 150 } 165 151 152 // A margin basically has three types: fixed, percentage, and auto (variable). 153 // Auto/percentage margins simply become 0 when computing min/max width. 154 // Fixed margins can be added in as is. 166 155 Length ml = child->style()->marginLeft(); 167 156 Length mr = child->style()->marginRight(); 168 169 // Call calcWidth on the child to ensure that our margins are170 // up to date. This method can be called before the child has actually171 // calculated its margins (which are computed inside calcWidth).172 if (ml.isPercent() || mr.isPercent())173 calcWidth();174 175 // A margin basically has three types: fixed, percentage, and auto (variable).176 // Auto margins simply become 0 when computing min/max width.177 // Fixed margins can be added in as is.178 // Percentage margins are computed as a percentage of the width we calculated in179 // the calcWidth call above. In this case we use the actual cached margin values on180 // the RenderObject itself.181 157 int margin = 0; 182 158 if (ml.isFixed()) 183 159 margin += ml.value(); 184 else if (ml.isPercent())185 margin += child->marginLeft();186 187 160 if (mr.isFixed()) 188 161 margin += mr.value(); 189 else if (mr.isAuto())190 margin += child->marginRight();191 192 margin = max(margin, 0);193 162 194 163 int w = child->minPrefWidth() + margin; … … 206 175 ASSERT(prefWidthsDirty()); 207 176 208 m_minPrefWidth = 0;209 m_maxPrefWidth = 0;210 211 if (hasMultipleLines() || isVertical())212 calcVerticalPrefWidths();213 else214 calcHorizontalPrefWidths();215 216 m_maxPrefWidth = max(m_maxPrefWidth, m_minPrefWidth);217 218 177 if (style()->width().isFixed() && style()->width().value() > 0) 219 178 m_minPrefWidth = m_maxPrefWidth = calcContentBoxWidth(style()->width().value()); 220 179 else { 180 m_minPrefWidth = m_maxPrefWidth = 0; 181 182 if (hasMultipleLines() || isVertical()) 183 calcVerticalPrefWidths(); 184 else 185 calcHorizontalPrefWidths(); 186 187 m_maxPrefWidth = max(m_minPrefWidth, m_maxPrefWidth); 188 } 189 221 190 if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) { 222 191 m_maxPrefWidth = max(m_maxPrefWidth, calcContentBoxWidth(style()->minWidth().value())); … … 239 208 { 240 209 ASSERT(needsLayout()); 241 ASSERT(!prefWidthsDirty());242 210 243 211 if (!relayoutChildren && posChildNeedsLayout() && !normalChildNeedsLayout() && !selfNeedsLayout()) { -
trunk/WebCore/rendering/RenderForeignObject.cpp
r21079 r21093 86 86 { 87 87 ASSERT(needsLayout()); 88 ASSERT(!prefWidthsDirty());89 88 90 89 IntRect oldBounds; -
trunk/WebCore/rendering/RenderFrameSet.cpp
r21079 r21093 454 454 { 455 455 ASSERT(needsLayout()); 456 ASSERT(!prefWidthsDirty());457 456 458 457 if (!parent()->isFrameSet()) { -
trunk/WebCore/rendering/RenderHTMLCanvas.cpp
r21079 r21093 80 80 { 81 81 ASSERT(needsLayout()); 82 ASSERT(!prefWidthsDirty());83 82 84 83 IntRect oldBounds; -
trunk/WebCore/rendering/RenderImage.cpp
r21079 r21093 304 304 { 305 305 ASSERT(needsLayout()); 306 ASSERT(!prefWidthsDirty());307 306 308 307 IntRect oldBounds; -
trunk/WebCore/rendering/RenderInline.cpp
r21079 r21093 293 293 } 294 294 295 void RenderInline::calcPrefWidths()296 {297 ASSERT(prefWidthsDirty());298 299 // Irrelevant, since some enclosing block will actually measure us and our children.300 m_minPrefWidth = 0;301 m_maxPrefWidth = 0;302 303 setPrefWidthsDirty(false);304 }305 306 295 bool RenderInline::requiresLayer() 307 296 { -
trunk/WebCore/rendering/RenderInline.h
r21079 r21093 59 59 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); 60 60 61 virtual void calcPrefWidths();62 63 61 // overrides RenderObject 64 62 virtual bool requiresLayer(); -
trunk/WebCore/rendering/RenderListBox.cpp
r21079 r21093 119 119 m_optionsWidth = static_cast<int>(ceilf(width)); 120 120 m_optionsChanged = false; 121 122 if (!m_vBar && Scrollbar::hasPlatformScrollbars()) 123 if (FrameView* view = node()->document()->view()) { 124 RefPtr<PlatformScrollbar> widget = new PlatformScrollbar(this, VerticalScrollbar, SmallScrollbar); 125 view->addChild(widget.get()); 126 m_vBar = widget.release(); 127 } 128 121 129 setNeedsLayoutAndPrefWidthsRecalc(); 122 130 } … … 154 162 void RenderListBox::calcPrefWidths() 155 163 { 156 if (!m_vBar && Scrollbar::hasPlatformScrollbars()) 157 if (FrameView* view = node()->document()->view()) { 158 RefPtr<PlatformScrollbar> widget = new PlatformScrollbar(this, VerticalScrollbar, SmallScrollbar); 159 view->addChild(widget.get()); 160 m_vBar = widget.release(); 161 } 162 163 if (m_optionsChanged) 164 updateFromElement(); 164 ASSERT(!m_optionsChanged); 165 165 166 166 m_minPrefWidth = 0; -
trunk/WebCore/rendering/RenderListItem.cpp
r21079 r21093 175 175 } 176 176 177 static RenderObject* firstNonMarkerChild(RenderObject* parent) 178 { 179 RenderObject* result = parent->firstChild(); 180 while (result && result->isListMarker()) 181 result = result->nextSibling(); 182 return result; 183 } 184 177 185 void RenderListItem::updateMarkerLocation() 178 186 { … … 193 201 194 202 if (markerPar != lineBoxParent || m_marker->prefWidthsDirty()) { 203 updateFirstLetter(); 195 204 m_marker->remove(); 196 205 if (!lineBoxParent) 197 206 lineBoxParent = this; 198 lineBoxParent->addChild(m_marker, lineBoxParent->firstChild());207 lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent)); 199 208 if (m_marker->prefWidthsDirty()) 200 209 m_marker->calcPrefWidths(); 201 recalcMinMaxWidths();202 210 } 203 211 } … … 206 214 void RenderListItem::calcPrefWidths() 207 215 { 208 // Make sure our marker is in the correct location. 216 ASSERT(prefWidthsDirty()); 217 209 218 updateMarkerLocation(); 210 if (prefWidthsDirty()) 211 219 220 RenderBlock::calcPrefWidths(); 212 221 } 213 222 214 223 void RenderListItem::layout() 215 224 { 216 ASSERT(needsLayout()); 217 ASSERT(!prefWidthsDirty()); 218 225 ASSERT(needsLayout()); 226 219 227 updateMarkerLocation(); 220 228 RenderBlock::layout(); -
trunk/WebCore/rendering/RenderListMarker.cpp
r21079 r21093 627 627 { 628 628 ASSERT(needsLayout()); 629 if (prefWidthsDirty()) 630 calcPrefWidths(); 629 ASSERT(!prefWidthsDirty()); 630 631 if (isImage()) { 632 m_width = m_image->image()->width(); 633 m_height = m_image->image()->height(); 634 } else { 635 m_width = minPrefWidth(); 636 m_height = style()->font().height(); 637 } 638 639 m_marginLeft = m_marginRight = 0; 640 641 Length leftMargin = style()->marginLeft(); 642 Length rightMargin = style()->marginRight(); 643 if (leftMargin.isFixed()) 644 m_marginLeft = leftMargin.value(); 645 if (rightMargin.isFixed()) 646 m_marginRight = rightMargin.value(); 647 631 648 setNeedsLayout(false); 632 649 } … … 651 668 652 669 if (isImage()) { 653 m_width = m_image->image()->width(); 654 m_height = m_image->image()->height(); 655 m_minPrefWidth = m_maxPrefWidth = m_width; 670 m_minPrefWidth = m_maxPrefWidth = m_image->image()->width(); 656 671 setPrefWidthsDirty(false); 672 updateMargins(); 657 673 return; 658 674 } … … 700 716 } 701 717 702 m_width = width;703 718 m_minPrefWidth = width; 704 719 m_maxPrefWidth = width; 705 720 706 // FIXME: A little strange to set the height in calcPrefWidths.707 m_height = font.height();708 709 721 setPrefWidthsDirty(false); 710 } 711 712 void RenderListMarker::calcWidth() 713 { 714 // m_width is set in calcPrefWidths() 722 723 updateMargins(); 724 } 725 726 void RenderListMarker::updateMargins() 727 { 715 728 const Font& font = style()->font(); 729 730 int marginLeft = 0; 731 int marginRight = 0; 716 732 717 733 if (isInside()) { 718 734 if (isImage()) { 719 if (style()->direction() == LTR) { 720 m_marginLeft = 0; 721 m_marginRight = cMarkerPadding; 722 } else { 723 m_marginLeft = cMarkerPadding; 724 m_marginRight = 0; 725 } 735 if (style()->direction() == LTR) 736 marginRight = cMarkerPadding; 737 else 738 marginLeft = cMarkerPadding; 726 739 } else switch (style()->listStyleType()) { 727 740 case DISC: … … 729 742 case SQUARE: 730 743 if (style()->direction() == LTR) { 731 m _marginLeft = -1;732 m _marginRight = font.ascent() - m_width+ 1;744 marginLeft = -1; 745 marginRight = font.ascent() - minPrefWidth() + 1; 733 746 } else { 734 m _marginLeft = font.ascent() - m_width+ 1;735 m _marginRight = -1;747 marginLeft = font.ascent() - minPrefWidth() + 1; 748 marginRight = -1; 736 749 } 737 750 break; 738 751 default: 739 m_marginLeft = 0; 740 m_marginRight = 0; 752 break; 741 753 } 742 754 } else { 743 755 if (style()->direction() == LTR) { 744 756 if (isImage()) 745 m _marginLeft = -m_width- cMarkerPadding;757 marginLeft = -minPrefWidth() - cMarkerPadding; 746 758 else { 747 759 int offset = font.ascent() * 2 / 3; … … 750 762 case CIRCLE: 751 763 case SQUARE: 752 m _marginLeft = -offset - cMarkerPadding - 1;764 marginLeft = -offset - cMarkerPadding - 1; 753 765 break; 754 766 case LNONE: 755 m_marginLeft = 0;756 767 break; 757 768 default: 758 m _marginLeft = m_text.isEmpty() ? 0 : -m_width- offset / 2;769 marginLeft = m_text.isEmpty() ? 0 : -minPrefWidth() - offset / 2; 759 770 } 760 771 } 761 772 } else { 762 773 if (isImage()) 763 m _marginLeft = cMarkerPadding;774 marginLeft = cMarkerPadding; 764 775 else { 765 776 int offset = font.ascent() * 2 / 3; … … 768 779 case CIRCLE: 769 780 case SQUARE: 770 m _marginLeft = offset + cMarkerPadding + 1 - m_width;781 marginLeft = offset + cMarkerPadding + 1 - minPrefWidth(); 771 782 break; 772 783 case LNONE: 773 m_marginLeft = 0;774 784 break; 775 785 default: 776 m _marginLeft = m_text.isEmpty() ? 0 : offset / 2;786 marginLeft = m_text.isEmpty() ? 0 : offset / 2; 777 787 } 778 788 } 779 789 } 780 m_marginRight = -m_marginLeft - m_width; 781 } 790 marginRight = -marginLeft - minPrefWidth(); 791 } 792 793 style()->setMarginLeft(Length(marginLeft, Fixed)); 794 style()->setMarginRight(Length(marginRight, Fixed)); 782 795 } 783 796 -
trunk/WebCore/rendering/RenderListMarker.h
r21079 r21093 52 52 virtual void imageChanged(CachedImage*); 53 53 54 virtual void calcWidth();55 56 54 virtual InlineBox* createInlineBox(bool, bool, bool); 57 55 … … 70 68 virtual bool canBeSelectionLeaf() const { return true; } 71 69 70 void updateMargins(); 71 72 72 private: 73 73 IntRect getRelativeMarkerRect(); 74 74 75 String m_text;76 75 CachedImage* m_image; 77 76 RenderListItem* m_listItem; -
trunk/WebCore/rendering/RenderObject.cpp
r21082 r21093 177 177 , m_normalChildNeedsLayout(false) 178 178 , m_posChildNeedsLayout(false) 179 , m_prefWidthsDirty( true)179 , m_prefWidthsDirty(false) 180 180 , m_floating(false) 181 181 , m_positioned(false) … … 183 183 , m_paintBackground(false) 184 184 , m_isAnonymous(node == node->document()) 185 , m_recalcMinMax(false)186 185 , m_isText(false) 187 186 , m_inline(true) 188 187 , m_replaced(false) 189 188 , m_isDragging(false) 189 , m_hasLayer(false) 190 190 , m_hasOverflowClip(false) 191 191 , m_hasOverrideSize(false) … … 253 253 } 254 254 255 RenderObject* RenderObject::removeChildNode(RenderObject* )255 RenderObject* RenderObject::removeChildNode(RenderObject*, bool) 256 256 { 257 257 ASSERT_NOT_REACHED(); … … 264 264 } 265 265 266 void RenderObject:: appendChildNode(RenderObject*)266 void RenderObject::moveChildNode(RenderObject*) 267 267 { 268 268 ASSERT_NOT_REACHED(); 269 269 } 270 270 271 void RenderObject::insertChildNode(RenderObject*, RenderObject*) 271 void RenderObject::appendChildNode(RenderObject*, bool) 272 { 273 ASSERT_NOT_REACHED(); 274 } 275 276 void RenderObject::insertChildNode(RenderObject*, RenderObject*, bool) 272 277 { 273 278 ASSERT_NOT_REACHED(); … … 498 503 { 499 504 return 0; 500 }501 502 void RenderObject::updateFirstLetter()503 {504 505 } 505 506 … … 653 654 void RenderObject::markAllDescendantsWithFloatsForLayout(RenderObject*) 654 655 { 656 } 657 658 void RenderObject::setPrefWidthsDirty(bool b, bool markParents) 659 { 660 bool alreadyDirty = m_prefWidthsDirty; 661 m_prefWidthsDirty = b; 662 if (b && !alreadyDirty && markParents && (style()->position() != FixedPosition && style()->position() != AbsolutePosition)) 663 invalidateContainingBlockPrefWidths(); 664 } 665 666 void RenderObject::invalidateContainingBlockPrefWidths() 667 { 668 RenderObject* o = containingBlock(); 669 while (o && !o->m_prefWidthsDirty) { 670 o->m_prefWidthsDirty = true; 671 if (o->style()->position() == FixedPosition || o->style()->position() == AbsolutePosition) 672 // A positioned object has no effect on the min/max width of its containing block ever. 673 // We can optimize this case and not go up any further. 674 break; 675 o = o->containingBlock(); 676 } 655 677 } 656 678 … … 1918 1940 if (needsLayout()) 1919 1941 ts << "nl "; 1920 if (m_recalcMinMax)1921 ts << "rmm ";1922 1942 if (style() && style()->zIndex()) 1923 1943 ts << "zI: " << style()->zIndex(); … … 2707 2727 } 2708 2728 2709 void RenderObject::recalcMinMaxWidths()2710 {2711 ASSERT(m_recalcMinMax);2712 2713 m_recalcMinMax = false;2714 updateFirstLetter();2715 2716 RenderObject* child = firstChild();2717 while (child) {2718 int cmin = 0;2719 int cmax = 0;2720 bool test = false;2721 if ((!m_prefWidthsDirty && child->m_recalcMinMax) || child->m_prefWidthsDirty) {2722 cmin = child->minPrefWidth();2723 cmax = child->maxPrefWidth();2724 test = true;2725 }2726 if (child->m_recalcMinMax)2727 child->recalcMinMaxWidths();2728 if (child->m_prefWidthsDirty)2729 child->calcPrefWidths();2730 if (!m_prefWidthsDirty && test && (cmin != child->minPrefWidth() || cmax != child->maxPrefWidth()))2731 m_prefWidthsDirty = true;2732 child = child->nextSibling();2733 }2734 2735 // we need to recalculate, if the contains inline children, as the change could have2736 // happened somewhere deep inside the child tree. Also do this for blocks or tables that2737 // are inline (i.e., inline-block and inline-table).2738 if ((!isInline() || isInlineBlockOrInlineTable()) && childrenInline())2739 m_prefWidthsDirty = true;2740 2741 if (m_prefWidthsDirty)2742 calcPrefWidths();2743 }2744 2745 2729 void RenderObject::scheduleRelayout() 2746 2730 { -
trunk/WebCore/rendering/RenderObject.h
r21079 r21093 154 154 155 155 virtual RenderLayer* layer() const { return 0; } 156 bool hasLayer() const { return !!layer(); }157 156 RenderLayer* enclosingLayer() const; 158 157 void addLayers(RenderLayer* parentLayer, RenderObject* newObject); … … 178 177 // children. 179 178 virtual RenderBlock* firstLineBlock() const; 180 virtual void updateFirstLetter();181 179 182 180 // Called when an object that was floating or positioned becomes a normal flow object … … 207 205 208 206 // raw tree manipulation 209 virtual RenderObject* removeChildNode(RenderObject*); 210 virtual void appendChildNode(RenderObject*); 211 virtual void insertChildNode(RenderObject* child, RenderObject* before); 207 virtual RenderObject* removeChildNode(RenderObject*, bool fullRemove = true); 208 virtual void appendChildNode(RenderObject*, bool fullAppend = true); 209 virtual void insertChildNode(RenderObject* child, RenderObject* before, bool fullInsert = true); 210 // Designed for speed. Don't waste time doing a bunch of work like layer updating and repainting when we know that our 211 // change in parentage is not going to affect anything. 212 virtual void moveChildNode(RenderObject*); 212 213 ////////////////////////////////////////// 213 214 … … 311 312 bool isDragging() const { return m_isDragging; } 312 313 bool isReplaced() const { return m_replaced; } // a "replaced" element (see CSS) 313 314 315 bool hasLayer() const { return m_hasLayer; } 316 314 317 bool hasBoxDecorations() const { return m_paintBackground; } 315 318 bool mustRepaintBackgroundOrBorder() const; … … 321 324 322 325 bool prefWidthsDirty() const { return m_prefWidthsDirty; } 323 bool recalcMinMax() const { return m_recalcMinMax; }324 326 325 327 bool isSelectionBorder() const; … … 370 372 void setChildNeedsLayout(bool b, bool markParents = true); 371 373 372 void setPrefWidthsDirty(bool b) 373 { 374 m_prefWidthsDirty = b; 375 if (b) { 376 RenderObject* o = this; 377 RenderObject* root = this; 378 while(o) { // FIXME: && !o->m_recalcMinMax ) { 379 o->m_recalcMinMax = true; 380 root = o; 381 o = o->m_parent; 382 } 383 } 384 } 385 374 void setPrefWidthsDirty(bool, bool markParents = true); 375 void invalidateContainingBlockPrefWidths(); 376 386 377 void setNeedsLayoutAndPrefWidthsRecalc() 387 378 { 379 setNeedsLayout(true); 388 380 setPrefWidthsDirty(true); 389 setNeedsLayout(true);390 381 } 391 382 … … 398 389 void setReplaced(bool b = true) { m_replaced = b; } 399 390 void setHasOverflowClip(bool b = true) { m_hasOverflowClip = b; } 391 void setHasLayer(bool b = true) { m_hasLayer = b; } 400 392 401 393 void scheduleRelayout(); … … 460 452 bool includeLeftEdge = true, bool includeRightEdge = true) { } 461 453 462 /* 463 * This function calculates the minimum & maximum width that the object 464 * can be set to. 465 * 466 * when the Element calls setPrefWidthsDirty(false), calcPrefWidths() will 467 * be no longer called. 468 * 469 * when a element has a fixed size, m_minPrefWidth and m_maxPrefWidth should be 470 * set to the same value. This has the special meaning that m_width, 471 * contains the actual value. 472 * 473 * assumes calcPrefWidths has already been called for all children. 474 */ 475 virtual void calcPrefWidths() { } 476 477 /* 478 * Does the min max width recalculations after changes. 479 */ 480 void recalcMinMaxWidths(); 481 454 482 455 /* 483 456 * Calculates the actual width of the object (only for non inline … … 923 896 924 897 bool m_isAnonymous : 1; 925 bool m_recalcMinMax : 1;926 898 bool m_isText : 1; 927 899 bool m_inline : 1; … … 929 901 bool m_isDragging : 1; 930 902 903 bool m_hasLayer : 1; 931 904 bool m_hasOverflowClip : 1; 932 905 -
trunk/WebCore/rendering/RenderPartObject.cpp
r21079 r21093 246 246 { 247 247 ASSERT(needsLayout()); 248 ASSERT(!prefWidthsDirty());249 248 250 249 calcWidth(); -
trunk/WebCore/rendering/RenderSVGContainer.cpp
r21087 r21093 86 86 } 87 87 88 void RenderSVGContainer::calcPrefWidths()89 {90 ASSERT(prefWidthsDirty());91 m_minPrefWidth = m_maxPrefWidth = 0;92 setPrefWidthsDirty(false);93 }94 95 88 void RenderSVGContainer::layout() 96 89 { 97 90 ASSERT(needsLayout()); 98 ASSERT(!prefWidthsDirty());99 91 100 92 calcViewport(); -
trunk/WebCore/rendering/RenderSVGContainer.h
r21079 r21093 64 64 virtual short baselinePosition(bool b, bool isRootLineBox = false) const; 65 65 66 virtual void calcPrefWidths();67 66 virtual void layout(); 68 67 virtual void paint(PaintInfo&, int parentX, int parentY); -
trunk/WebCore/rendering/RenderSVGHiddenContainer.cpp
r21079 r21093 55 55 } 56 56 57 void RenderSVGHiddenContainer::calcPrefWidths()58 {59 ASSERT(prefWidthsDirty());60 m_minPrefWidth = m_maxPrefWidth = 0;61 setPrefWidthsDirty(false);62 }63 64 57 void RenderSVGHiddenContainer::layout() 65 58 { -
trunk/WebCore/rendering/RenderSVGHiddenContainer.h
r21079 r21093 47 47 virtual short baselinePosition(bool b, bool isRootLineBox = false) const; 48 48 49 virtual void calcPrefWidths();50 49 virtual void layout(); 51 50 virtual void paint(PaintInfo&, int parentX, int parentY); -
trunk/WebCore/rendering/RenderSVGText.cpp
r21079 r21093 59 59 { 60 60 ASSERT(needsLayout()); 61 ASSERT(!prefWidthsDirty());62 61 63 62 IntRect oldBounds; -
trunk/WebCore/rendering/RenderTable.cpp
r21082 r21093 234 234 // Percent or fixed table 235 235 m_width = style()->width().calcMinValue(availableWidth); 236 m_width = max(m _minPrefWidth, m_width);236 m_width = max(minPrefWidth(), m_width); 237 237 } else { 238 238 // An auto width table should shrink to fit within the line width if necessary in order to … … 251 251 252 252 // Ensure we aren't bigger than our max width or smaller than our min width. 253 m_width = min(availContentWidth, m _maxPrefWidth);253 m_width = min(availContentWidth, maxPrefWidth()); 254 254 } 255 255 256 m_width = max(m_width, m _minPrefWidth);256 m_width = max(m_width, minPrefWidth()); 257 257 258 258 // Finally, with our true width determined, compute our margins for real. … … 265 265 { 266 266 ASSERT(needsLayout()); 267 ASSERT(!prefWidthsDirty());268 ASSERT(!m_needsSectionRecalc);269 267 270 268 if (posChildNeedsLayout() && !normalChildNeedsLayout() && !selfNeedsLayout()) { … … 275 273 } 276 274 275 recalcSectionsIfNeeded(); 276 277 277 IntRect oldBounds; 278 278 IntRect oldOutlineBox; … … 686 686 } 687 687 688 RenderObject* RenderTable::removeChildNode(RenderObject* child )688 RenderObject* RenderTable::removeChildNode(RenderObject* child, bool fullRemove) 689 689 { 690 690 setNeedsSectionRecalc(); 691 return RenderContainer::removeChildNode(child );691 return RenderContainer::removeChildNode(child, fullRemove); 692 692 } 693 693 -
trunk/WebCore/rendering/RenderTable.h
r21079 r21093 166 166 void setNeedsSectionRecalc() { m_needsSectionRecalc = true; } 167 167 168 virtual RenderObject* removeChildNode(RenderObject* );168 virtual RenderObject* removeChildNode(RenderObject*, bool fullRemove = true); 169 169 170 170 RenderTableSection* sectionAbove(const RenderTableSection*, bool skipEmptySections = false) const; -
trunk/WebCore/rendering/RenderTableRow.cpp
r21082 r21093 113 113 { 114 114 ASSERT(needsLayout()); 115 ASSERT(!prefWidthsDirty());116 115 117 116 for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { -
trunk/WebCore/rendering/RenderTableSection.cpp
r21082 r21093 1005 1005 } 1006 1006 1007 RenderObject* RenderTableSection::removeChildNode(RenderObject* child )1007 RenderObject* RenderTableSection::removeChildNode(RenderObject* child, bool fullRemove) 1008 1008 { 1009 1009 setNeedsCellRecalc(); 1010 return RenderContainer::removeChildNode(child );1010 return RenderContainer::removeChildNode(child, fullRemove); 1011 1011 } 1012 1012 -
trunk/WebCore/rendering/RenderTableSection.h
r19696 r21093 122 122 int getBaseline(int row) { return m_grid[row].baseLine; } 123 123 124 virtual RenderObject* removeChildNode(RenderObject* );124 virtual RenderObject* removeChildNode(RenderObject*, bool fullRemove = true); 125 125 126 126 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); -
trunk/WebCore/rendering/RenderText.cpp
r21079 r21093 436 436 } 437 437 438 if (m_hasTab )439 calcPrefWidths Internal(leadWidth);438 if (m_hasTab || prefWidthsDirty()) 439 calcPrefWidths(leadWidth); 440 440 441 441 minW = m_minWidth; … … 495 495 } 496 496 497 void RenderText::calcPrefWidths()498 {499 // Use 0 for the leadWidth. If the text contains a variable width tab, the real width500 // will get measured when trimmedMinMaxWidth calls again with the real leadWidth.501 ASSERT(prefWidthsDirty());502 calcPrefWidthsInternal(0);503 }504 505 497 inline bool isSpaceAccordingToStyle(UChar c, RenderStyle* style) 506 498 { … … 508 500 } 509 501 510 void RenderText::calcPrefWidthsInternal(int leadWidth) 511 { 502 int RenderText::minPrefWidth() const 503 { 504 if (prefWidthsDirty()) 505 const_cast<RenderText*>(this)->calcPrefWidths(0); 506 507 return m_minWidth; 508 } 509 510 int RenderText::maxPrefWidth() const 511 { 512 if (prefWidthsDirty()) 513 const_cast<RenderText*>(this)->calcPrefWidths(0); 514 515 return m_maxWidth; 516 } 517 518 void RenderText::calcPrefWidths(int leadWidth) 519 { 520 ASSERT(m_hasTab || prefWidthsDirty()); 521 512 522 m_minWidth = 0; 513 523 m_beginMinWidth = 0; … … 992 1002 if (&f == &style()->font()) { 993 1003 if (!style()->preserveNewline() && !from && len == textLength()) 994 w = m _maxWidth;1004 w = maxPrefWidth(); 995 1005 else 996 1006 w = widthFromCache(f, from, len, xPos); -
trunk/WebCore/rendering/RenderText.h
r21079 r21093 76 76 virtual short lineHeight(bool firstLine, bool isRootLineBox = false) const; 77 77 78 virtual void calcPrefWidths(); 79 virtual int minPrefWidth() const { return m_minWidth; } 80 virtual int maxPrefWidth() const { return m_maxWidth; } 78 virtual int minPrefWidth() const; 79 virtual int maxPrefWidth() const; 81 80 82 81 void trimmedPrefWidths(int leadWidth, … … 130 129 protected: 131 130 void setTextInternal(PassRefPtr<StringImpl>); 131 virtual void calcPrefWidths(int leadWidth); 132 132 133 133 private: … … 139 139 void deleteTextBoxes(); 140 140 bool containsOnlyWhitespace(unsigned from, unsigned len) const; 141 void calcPrefWidthsInternal(int leadWidth);142 143 141 int widthFromCache(const Font&, int start, int len, int xPos) const; 144 142 bool isAllASCII() const { return m_isAllASCII; } -
trunk/WebCore/rendering/RenderView.cpp
r21079 r21093 55 55 m_maxPrefWidth = 0; 56 56 57 setPrefWidthsDirty(true );57 setPrefWidthsDirty(true, false); 58 58 59 59 setPositioned(true); // to 0,0 :) … … 61 61 // Create a new root layer for our layer hierarchy. 62 62 m_layer = new (node->document()->renderArena()) RenderLayer(this); 63 setHasLayer(true); 63 64 } 64 65 … … 88 89 89 90 m_maxPrefWidth = m_minPrefWidth; 90 91 setPrefWidthsDirty(false);92 91 } 93 92 … … 95 94 { 96 95 if (printing()) 97 m_minPrefWidth = m_ width;96 m_minPrefWidth = m_maxPrefWidth = m_width; 98 97 99 98 bool relayoutChildren = !printing() && (!m_frameView || m_width != m_frameView->visibleWidth() || m_height != m_frameView->visibleHeight()); 100 99 if (relayoutChildren) 101 100 setChildNeedsLayout(true, false); 102 103 if (recalcMinMax())104 recalcMinMaxWidths();105 101 106 102 if (needsLayout()) -
trunk/WebCore/rendering/RenderWidget.cpp
r21079 r21093 151 151 { 152 152 ASSERT(needsLayout()); 153 ASSERT(!prefWidthsDirty());154 153 155 154 setNeedsLayout(false);
Note:
See TracChangeset
for help on using the changeset viewer.