OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 imageResources.append(styleImage->cachedImage()); | 190 imageResources.append(styleImage->cachedImage()); |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 static void appendLayers(Vector<ImageResource*>& images, const FillLayer& styleL
ayer) | 194 static void appendLayers(Vector<ImageResource*>& images, const FillLayer& styleL
ayer) |
195 { | 195 { |
196 for (const FillLayer* layer = &styleLayer; layer; layer = layer->next()) | 196 for (const FillLayer* layer = &styleLayer; layer; layer = layer->next()) |
197 appendImageIfNotNull(images, layer->image()); | 197 appendImageIfNotNull(images, layer->image()); |
198 } | 198 } |
199 | 199 |
200 static void appendImagesFromStyle(Vector<ImageResource*>& images, RenderStyle& b
lockStyle) | 200 static void appendImagesFromStyle(Vector<ImageResource*>& images, const RenderSt
yle& blockStyle) |
201 { | 201 { |
202 appendLayers(images, blockStyle.backgroundLayers()); | 202 appendLayers(images, blockStyle.backgroundLayers()); |
203 appendLayers(images, blockStyle.maskLayers()); | 203 appendLayers(images, blockStyle.maskLayers()); |
204 | 204 |
205 const ContentData* contentData = blockStyle.contentData(); | 205 const ContentData* contentData = blockStyle.contentData(); |
206 if (contentData && contentData->isImage()) | 206 if (contentData && contentData->isImage()) |
207 appendImageIfNotNull(images, toImageContentData(contentData)->image()); | 207 appendImageIfNotNull(images, toImageContentData(contentData)->image()); |
208 if (blockStyle.boxReflect()) | 208 if (blockStyle.boxReflect()) |
209 appendImageIfNotNull(images, blockStyle.boxReflect()->mask().image()); | 209 appendImageIfNotNull(images, blockStyle.boxReflect()->mask().image()); |
210 appendImageIfNotNull(images, blockStyle.listStyleImage()); | 210 appendImageIfNotNull(images, blockStyle.listStyleImage()); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 gDelayedUpdateScrollInfoSet->remove(this); | 286 gDelayedUpdateScrollInfoSet->remove(this); |
287 | 287 |
288 if (TextAutosizer* textAutosizer = document().textAutosizer()) | 288 if (TextAutosizer* textAutosizer = document().textAutosizer()) |
289 textAutosizer->destroy(this); | 289 textAutosizer->destroy(this); |
290 | 290 |
291 RenderBox::willBeDestroyed(); | 291 RenderBox::willBeDestroyed(); |
292 } | 292 } |
293 | 293 |
294 void RenderBlock::styleWillChange(StyleDifference diff, const RenderStyle& newSt
yle) | 294 void RenderBlock::styleWillChange(StyleDifference diff, const RenderStyle& newSt
yle) |
295 { | 295 { |
296 RenderStyle* oldStyle = style(); | 296 const RenderStyle* oldStyle = style(); |
297 | 297 |
298 setReplaced(newStyle.isDisplayInlineType()); | 298 setReplaced(newStyle.isDisplayInlineType()); |
299 | 299 |
300 if (oldStyle && parent()) { | 300 if (oldStyle && parent()) { |
301 bool oldStyleIsContainer = oldStyle->position() != StaticPosition || old
Style->hasTransformRelatedProperty(); | 301 bool oldStyleIsContainer = oldStyle->position() != StaticPosition || old
Style->hasTransformRelatedProperty(); |
302 bool newStyleIsContainer = newStyle.position() != StaticPosition || newS
tyle.hasTransformRelatedProperty(); | 302 bool newStyleIsContainer = newStyle.position() != StaticPosition || newS
tyle.hasTransformRelatedProperty(); |
303 | 303 |
304 if (oldStyleIsContainer && !newStyleIsContainer) { | 304 if (oldStyleIsContainer && !newStyleIsContainer) { |
305 // Clear our positioned objects list. Our absolutely positioned desc
endants will be | 305 // Clear our positioned objects list. Our absolutely positioned desc
endants will be |
306 // inserted into our containing block's positioned objects list duri
ng layout. | 306 // inserted into our containing block's positioned objects list duri
ng layout. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 || oldStyle->paddingBottom() != newStyle->paddingBottom(); | 339 || oldStyle->paddingBottom() != newStyle->paddingBottom(); |
340 } | 340 } |
341 | 341 |
342 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty
le) | 342 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty
le) |
343 { | 343 { |
344 RenderBox::styleDidChange(diff, oldStyle); | 344 RenderBox::styleDidChange(diff, oldStyle); |
345 | 345 |
346 if (isFloatingOrOutOfFlowPositioned() && oldStyle && !oldStyle->isFloating()
&& !oldStyle->hasOutOfFlowPosition() && parent() && parent()->isRenderBlockFlow
()) | 346 if (isFloatingOrOutOfFlowPositioned() && oldStyle && !oldStyle->isFloating()
&& !oldStyle->hasOutOfFlowPosition() && parent() && parent()->isRenderBlockFlow
()) |
347 toRenderBlock(parent())->removeAnonymousWrappersIfRequired(); | 347 toRenderBlock(parent())->removeAnonymousWrappersIfRequired(); |
348 | 348 |
349 RenderStyle* newStyle = style(); | 349 RenderStyle* newStyle = deprecatedMutableStyle(); |
350 | 350 |
351 if (!isAnonymousBlock()) { | 351 if (!isAnonymousBlock()) { |
352 // Ensure that all of our continuation blocks pick up the new style. | 352 // Ensure that all of our continuation blocks pick up the new style. |
353 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC
ont = currCont->blockElementContinuation()) { | 353 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC
ont = currCont->blockElementContinuation()) { |
354 RenderBoxModelObject* nextCont = currCont->continuation(); | 354 RenderBoxModelObject* nextCont = currCont->continuation(); |
355 currCont->setContinuation(0); | 355 currCont->setContinuation(0); |
356 currCont->setStyle(newStyle); | 356 currCont->setStyle(newStyle); |
357 currCont->setContinuation(nextCont); | 357 currCont->setContinuation(nextCont); |
358 } | 358 } |
359 } | 359 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 RenderBlock* RenderBlock::clone() const | 584 RenderBlock* RenderBlock::clone() const |
585 { | 585 { |
586 RenderBlock* cloneBlock; | 586 RenderBlock* cloneBlock; |
587 if (isAnonymousBlock()) { | 587 if (isAnonymousBlock()) { |
588 cloneBlock = createAnonymousBlock(); | 588 cloneBlock = createAnonymousBlock(); |
589 cloneBlock->setChildrenInline(childrenInline()); | 589 cloneBlock->setChildrenInline(childrenInline()); |
590 } | 590 } |
591 else { | 591 else { |
592 RenderObject* cloneRenderer = toElement(node())->createRenderer(style())
; | 592 RenderObject* cloneRenderer = toElement(node())->createRenderer(style())
; |
593 cloneBlock = toRenderBlock(cloneRenderer); | 593 cloneBlock = toRenderBlock(cloneRenderer); |
594 cloneBlock->setStyle(style()); | 594 cloneBlock->setStyle(deprecatedMutableStyle()); |
595 | 595 |
596 // This takes care of setting the right value of childrenInline in case | 596 // This takes care of setting the right value of childrenInline in case |
597 // generated content is added to cloneBlock and 'this' does not have | 597 // generated content is added to cloneBlock and 'this' does not have |
598 // generated content added yet. | 598 // generated content added yet. |
599 cloneBlock->setChildrenInline(cloneBlock->firstChild() ? cloneBlock->fir
stChild()->isInline() : childrenInline()); | 599 cloneBlock->setChildrenInline(cloneBlock->firstChild() ? cloneBlock->fir
stChild()->isInline() : childrenInline()); |
600 } | 600 } |
601 cloneBlock->setFlowThreadState(flowThreadState()); | 601 cloneBlock->setFlowThreadState(flowThreadState()); |
602 return cloneBlock; | 602 return cloneBlock; |
603 } | 603 } |
604 | 604 |
(...skipping 2370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2975 | 2975 |
2976 void RenderBlock::computePreferredLogicalWidths() | 2976 void RenderBlock::computePreferredLogicalWidths() |
2977 { | 2977 { |
2978 ASSERT(preferredLogicalWidthsDirty()); | 2978 ASSERT(preferredLogicalWidthsDirty()); |
2979 | 2979 |
2980 m_minPreferredLogicalWidth = 0; | 2980 m_minPreferredLogicalWidth = 0; |
2981 m_maxPreferredLogicalWidth = 0; | 2981 m_maxPreferredLogicalWidth = 0; |
2982 | 2982 |
2983 // FIXME: The isFixed() calls here should probably be checking for isSpecifi
ed since you | 2983 // FIXME: The isFixed() calls here should probably be checking for isSpecifi
ed since you |
2984 // should be able to use percentage, calc or viewport relative values for wi
dth. | 2984 // should be able to use percentage, calc or viewport relative values for wi
dth. |
2985 RenderStyle* styleToUse = style(); | 2985 const RenderStyle* styleToUse = style(); |
2986 if (!isTableCell() && styleToUse->logicalWidth().isFixed() && styleToUse->lo
gicalWidth().value() >= 0 | 2986 if (!isTableCell() && styleToUse->logicalWidth().isFixed() && styleToUse->lo
gicalWidth().value() >= 0 |
2987 && !(isDeprecatedFlexItem() && !styleToUse->logicalWidth().intValue())) | 2987 && !(isDeprecatedFlexItem() && !styleToUse->logicalWidth().intValue())) |
2988 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentB
oxLogicalWidthForBoxSizing(styleToUse->logicalWidth().value()); | 2988 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentB
oxLogicalWidthForBoxSizing(styleToUse->logicalWidth().value()); |
2989 else | 2989 else |
2990 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferred
LogicalWidth); | 2990 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferred
LogicalWidth); |
2991 | 2991 |
2992 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth()
.value() > 0) { | 2992 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth()
.value() > 0) { |
2993 m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); | 2993 m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); |
2994 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); | 2994 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); |
2995 } | 2995 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3032 // intrinsic width, instead of pretending that it's 1. The only way to d
o that is by | 3032 // intrinsic width, instead of pretending that it's 1. The only way to d
o that is by |
3033 // performing a layout pass, but this is not an appropriate time or plac
e for layout. The | 3033 // performing a layout pass, but this is not an appropriate time or plac
e for layout. The |
3034 // good news is that if height is unconstrained and there are no explici
t breaks, the | 3034 // good news is that if height is unconstrained and there are no explici
t breaks, the |
3035 // resolved column-count really should be 1. | 3035 // resolved column-count really should be 1. |
3036 maxLogicalWidth = std::max(maxLogicalWidth, columnWidth) * columnCount +
gapExtra; | 3036 maxLogicalWidth = std::max(maxLogicalWidth, columnWidth) * columnCount +
gapExtra; |
3037 } | 3037 } |
3038 } | 3038 } |
3039 | 3039 |
3040 void RenderBlock::computeBlockPreferredLogicalWidths(LayoutUnit& minLogicalWidth
, LayoutUnit& maxLogicalWidth) const | 3040 void RenderBlock::computeBlockPreferredLogicalWidths(LayoutUnit& minLogicalWidth
, LayoutUnit& maxLogicalWidth) const |
3041 { | 3041 { |
3042 RenderStyle* styleToUse = style(); | 3042 const RenderStyle* styleToUse = style(); |
3043 bool nowrap = styleToUse->whiteSpace() == NOWRAP; | 3043 bool nowrap = styleToUse->whiteSpace() == NOWRAP; |
3044 | 3044 |
3045 RenderObject* child = firstChild(); | 3045 RenderObject* child = firstChild(); |
3046 RenderBlock* containingBlock = this->containingBlock(); | 3046 RenderBlock* containingBlock = this->containingBlock(); |
3047 LayoutUnit floatLeftWidth = 0, floatRightWidth = 0; | 3047 LayoutUnit floatLeftWidth = 0, floatRightWidth = 0; |
3048 while (child) { | 3048 while (child) { |
3049 // Positioned children don't affect the min/max width. Spanners only aff
ect the min/max | 3049 // Positioned children don't affect the min/max width. Spanners only aff
ect the min/max |
3050 // width of the multicol container, not the flow thread. | 3050 // width of the multicol container, not the flow thread. |
3051 if (child->isOutOfFlowPositioned() || child->isColumnSpanAll()) { | 3051 if (child->isOutOfFlowPositioned() || child->isColumnSpanAll()) { |
3052 child = child->nextSibling(); | 3052 child = child->nextSibling(); |
3053 continue; | 3053 continue; |
3054 } | 3054 } |
3055 | 3055 |
3056 RefPtr<RenderStyle> childStyle = child->style(); | 3056 const RenderStyle* childStyle = child->style(); |
3057 if (child->isFloating() || (child->isBox() && toRenderBox(child)->avoids
Floats())) { | 3057 if (child->isFloating() || (child->isBox() && toRenderBox(child)->avoids
Floats())) { |
3058 LayoutUnit floatTotalWidth = floatLeftWidth + floatRightWidth; | 3058 LayoutUnit floatTotalWidth = floatLeftWidth + floatRightWidth; |
3059 if (childStyle->clear() & CLEFT) { | 3059 if (childStyle->clear() & CLEFT) { |
3060 maxLogicalWidth = std::max(floatTotalWidth, maxLogicalWidth); | 3060 maxLogicalWidth = std::max(floatTotalWidth, maxLogicalWidth); |
3061 floatLeftWidth = 0; | 3061 floatLeftWidth = 0; |
3062 } | 3062 } |
3063 if (childStyle->clear() & CRIGHT) { | 3063 if (childStyle->clear() & CRIGHT) { |
3064 maxLogicalWidth = std::max(floatTotalWidth, maxLogicalWidth); | 3064 maxLogicalWidth = std::max(floatTotalWidth, maxLogicalWidth); |
3065 floatRightWidth = 0; | 3065 floatRightWidth = 0; |
3066 } | 3066 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3153 | 3153 |
3154 LayoutUnit RenderBlock::lineHeight(bool firstLine, LineDirectionMode direction,
LinePositionMode linePositionMode) const | 3154 LayoutUnit RenderBlock::lineHeight(bool firstLine, LineDirectionMode direction,
LinePositionMode linePositionMode) const |
3155 { | 3155 { |
3156 // Inline blocks are replaced elements. Otherwise, just pass off to | 3156 // Inline blocks are replaced elements. Otherwise, just pass off to |
3157 // the base class. If we're being queried as though we're the root line | 3157 // the base class. If we're being queried as though we're the root line |
3158 // box, then the fact that we're an inline-block is irrelevant, and we behav
e | 3158 // box, then the fact that we're an inline-block is irrelevant, and we behav
e |
3159 // just like a block. | 3159 // just like a block. |
3160 if (isReplaced() && linePositionMode == PositionOnContainingLine) | 3160 if (isReplaced() && linePositionMode == PositionOnContainingLine) |
3161 return RenderBox::lineHeight(firstLine, direction, linePositionMode); | 3161 return RenderBox::lineHeight(firstLine, direction, linePositionMode); |
3162 | 3162 |
3163 RenderStyle* s = style(firstLine && document().styleEngine()->usesFirstLineR
ules()); | 3163 const RenderStyle* s = style(firstLine && document().styleEngine()->usesFirs
tLineRules()); |
3164 return s->computedLineHeight(); | 3164 return s->computedLineHeight(); |
3165 } | 3165 } |
3166 | 3166 |
3167 int RenderBlock::beforeMarginInLineDirection(LineDirectionMode direction) const | 3167 int RenderBlock::beforeMarginInLineDirection(LineDirectionMode direction) const |
3168 { | 3168 { |
3169 return direction == HorizontalLine ? marginTop() : marginRight(); | 3169 return direction == HorizontalLine ? marginTop() : marginRight(); |
3170 } | 3170 } |
3171 | 3171 |
3172 int RenderBlock::baselinePosition(FontBaseline baselineType, bool firstLine, Lin
eDirectionMode direction, LinePositionMode linePositionMode) const | 3172 int RenderBlock::baselinePosition(FontBaseline baselineType, bool firstLine, Lin
eDirectionMode direction, LinePositionMode linePositionMode) const |
3173 { | 3173 { |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3781 | 3781 |
3782 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
parent->style(), newDisplay); | 3782 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
parent->style(), newDisplay); |
3783 parent->updateAnonymousChildStyle(newBox, newStyle.get()); | 3783 parent->updateAnonymousChildStyle(newBox, newStyle.get()); |
3784 newBox->setStyle(newStyle.release()); | 3784 newBox->setStyle(newStyle.release()); |
3785 return newBox; | 3785 return newBox; |
3786 } | 3786 } |
3787 | 3787 |
3788 RenderBlockFlow* RenderBlock::createAnonymousColumnsWithParentRenderer(const Ren
derObject* parent) | 3788 RenderBlockFlow* RenderBlock::createAnonymousColumnsWithParentRenderer(const Ren
derObject* parent) |
3789 { | 3789 { |
3790 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
parent->style(), BLOCK); | 3790 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
parent->style(), BLOCK); |
3791 newStyle->inheritColumnPropertiesFrom(parent->style()); | 3791 newStyle->inheritColumnPropertiesFrom(*parent->style()); |
3792 | 3792 |
3793 RenderBlockFlow* newBox = RenderBlockFlow::createAnonymous(&parent->document
()); | 3793 RenderBlockFlow* newBox = RenderBlockFlow::createAnonymous(&parent->document
()); |
3794 parent->updateAnonymousChildStyle(newBox, newStyle.get()); | 3794 parent->updateAnonymousChildStyle(newBox, newStyle.get()); |
3795 newBox->setStyle(newStyle.release()); | 3795 newBox->setStyle(newStyle.release()); |
3796 return newBox; | 3796 return newBox; |
3797 } | 3797 } |
3798 | 3798 |
3799 RenderBlockFlow* RenderBlock::createAnonymousColumnSpanWithParentRenderer(const
RenderObject* parent) | 3799 RenderBlockFlow* RenderBlock::createAnonymousColumnSpanWithParentRenderer(const
RenderObject* parent) |
3800 { | 3800 { |
3801 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
parent->style(), BLOCK); | 3801 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
parent->style(), BLOCK); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3947 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const | 3947 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const |
3948 { | 3948 { |
3949 showRenderObject(); | 3949 showRenderObject(); |
3950 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 3950 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
3951 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 3951 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
3952 } | 3952 } |
3953 | 3953 |
3954 #endif | 3954 #endif |
3955 | 3955 |
3956 } // namespace blink | 3956 } // namespace blink |
OLD | NEW |