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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 using namespace std; | 65 using namespace std; |
66 using namespace WTF; | 66 using namespace WTF; |
67 using namespace Unicode; | 67 using namespace Unicode; |
68 | 68 |
69 namespace WebCore { | 69 namespace WebCore { |
70 | 70 |
71 using namespace HTMLNames; | 71 using namespace HTMLNames; |
72 | 72 |
73 struct SameSizeAsRenderBlock : public RenderBox { | 73 struct SameSizeAsRenderBlock : public RenderBox { |
74 void* pointers[3]; | 74 void* pointers[2]; |
75 RenderObjectChildList children; | 75 RenderObjectChildList children; |
76 RenderLineBoxList lineBoxes; | 76 RenderLineBoxList lineBoxes; |
77 uint32_t bitfields; | 77 uint32_t bitfields; |
78 }; | 78 }; |
79 | 79 |
80 COMPILE_ASSERT(sizeof(RenderBlock) == sizeof(SameSizeAsRenderBlock), RenderBlock
_should_stay_small); | 80 COMPILE_ASSERT(sizeof(RenderBlock) == sizeof(SameSizeAsRenderBlock), RenderBlock
_should_stay_small); |
81 | 81 |
82 struct SameSizeAsFloatingObject { | 82 struct SameSizeAsFloatingObject { |
83 void* pointers[2]; | 83 void* pointers[2]; |
84 LayoutRect rect; | 84 LayoutRect rect; |
85 int paginationStrut; | 85 int paginationStrut; |
86 uint32_t bitfields : 8; | 86 uint32_t bitfields : 8; |
87 }; | 87 }; |
88 | 88 |
89 COMPILE_ASSERT(sizeof(RenderBlock::MarginValues) == sizeof(LayoutUnit[4]), Margi
nValues_should_stay_small); | 89 COMPILE_ASSERT(sizeof(RenderBlock::MarginValues) == sizeof(LayoutUnit[4]), Margi
nValues_should_stay_small); |
90 | 90 |
91 struct SameSizeAsMarginInfo { | 91 struct SameSizeAsMarginInfo { |
92 uint32_t bitfields : 16; | 92 uint32_t bitfields : 16; |
93 LayoutUnit margins[2]; | 93 LayoutUnit margins[2]; |
94 }; | 94 }; |
95 | 95 |
96 typedef WTF::HashMap<const RenderBox*, ColumnInfo*> ColumnInfoMap; | 96 typedef WTF::HashMap<const RenderBox*, ColumnInfo*> ColumnInfoMap; |
97 static ColumnInfoMap* gColumnInfoMap = 0; | 97 static ColumnInfoMap* gColumnInfoMap = 0; |
98 | 98 |
99 typedef WTF::HashMap<const RenderBlock*, HashSet<RenderBox*>*> PercentHeightDesc
endantsMap; | 99 static TrackedDescendantsMap* gPositionedDescendantsMap = 0; |
100 static PercentHeightDescendantsMap* gPercentHeightDescendantsMap = 0; | 100 static TrackedDescendantsMap* gPercentHeightDescendantsMap = 0; |
101 | 101 |
102 typedef WTF::HashMap<const RenderBox*, HashSet<RenderBlock*>*> PercentHeightCont
ainerMap; | 102 static TrackedContainerMap* gPositionedContainerMap = 0; |
103 static PercentHeightContainerMap* gPercentHeightContainerMap = 0; | 103 static TrackedContainerMap* gPercentHeightContainerMap = 0; |
104 | 104 |
105 typedef WTF::HashMap<RenderBlock*, ListHashSet<RenderInline*>*> ContinuationOutl
ineTableMap; | 105 typedef WTF::HashMap<RenderBlock*, ListHashSet<RenderInline*>*> ContinuationOutl
ineTableMap; |
106 | 106 |
107 typedef WTF::HashSet<RenderBlock*> DelayedUpdateScrollInfoSet; | 107 typedef WTF::HashSet<RenderBlock*> DelayedUpdateScrollInfoSet; |
108 static int gDelayUpdateScrollInfo = 0; | 108 static int gDelayUpdateScrollInfo = 0; |
109 static DelayedUpdateScrollInfoSet* gDelayedUpdateScrollInfoSet = 0; | 109 static DelayedUpdateScrollInfoSet* gDelayedUpdateScrollInfoSet = 0; |
110 | 110 |
111 bool RenderBlock::s_canPropagateFloatIntoSibling = false; | 111 bool RenderBlock::s_canPropagateFloatIntoSibling = false; |
112 | 112 |
113 // This class helps dispatching the 'overflow' event on layout change. overflow
can be set on RenderBoxes, yet the existing code | 113 // This class helps dispatching the 'overflow' event on layout change. overflow
can be set on RenderBoxes, yet the existing code |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 : RenderBox(node) | 189 : RenderBox(node) |
190 , m_lineHeight(-1) | 190 , m_lineHeight(-1) |
191 , m_beingDestroyed(false) | 191 , m_beingDestroyed(false) |
192 , m_hasMarkupTruncation(false) | 192 , m_hasMarkupTruncation(false) |
193 { | 193 { |
194 setChildrenInline(true); | 194 setChildrenInline(true); |
195 COMPILE_ASSERT(sizeof(RenderBlock::FloatingObject) == sizeof(SameSizeAsFloat
ingObject), FloatingObject_should_stay_small); | 195 COMPILE_ASSERT(sizeof(RenderBlock::FloatingObject) == sizeof(SameSizeAsFloat
ingObject), FloatingObject_should_stay_small); |
196 COMPILE_ASSERT(sizeof(RenderBlock::MarginInfo) == sizeof(SameSizeAsMarginInf
o), MarginInfo_should_stay_small); | 196 COMPILE_ASSERT(sizeof(RenderBlock::MarginInfo) == sizeof(SameSizeAsMarginInf
o), MarginInfo_should_stay_small); |
197 } | 197 } |
198 | 198 |
| 199 static void removeBlockFromDescendantAndContainerMaps(RenderBlock* block, Tracke
dDescendantsMap*& descendantMap, TrackedContainerMap*& containerMap) |
| 200 { |
| 201 if (TrackedRendererListHashSet* descendantSet = descendantMap->take(block))
{ |
| 202 TrackedRendererListHashSet::iterator end = descendantSet->end(); |
| 203 for (TrackedRendererListHashSet::iterator descendant = descendantSet->be
gin(); descendant != end; ++descendant) { |
| 204 HashSet<RenderBlock*>* containerSet = containerMap->get(*descendant)
; |
| 205 ASSERT(containerSet); |
| 206 if (!containerSet) |
| 207 continue; |
| 208 ASSERT(containerSet->contains(block)); |
| 209 containerSet->remove(block); |
| 210 if (containerSet->isEmpty()) { |
| 211 containerMap->remove(*descendant); |
| 212 delete containerSet; |
| 213 } |
| 214 } |
| 215 delete descendantSet; |
| 216 } |
| 217 } |
| 218 |
199 RenderBlock::~RenderBlock() | 219 RenderBlock::~RenderBlock() |
200 { | 220 { |
201 if (m_floatingObjects) | 221 if (m_floatingObjects) |
202 deleteAllValues(m_floatingObjects->set()); | 222 deleteAllValues(m_floatingObjects->set()); |
203 | 223 |
204 if (hasColumns()) | 224 if (hasColumns()) |
205 delete gColumnInfoMap->take(this); | 225 delete gColumnInfoMap->take(this); |
206 | 226 |
207 if (gPercentHeightDescendantsMap) { | 227 if (gPercentHeightDescendantsMap) |
208 if (HashSet<RenderBox*>* descendantSet = gPercentHeightDescendantsMap->t
ake(this)) { | 228 removeBlockFromDescendantAndContainerMaps(this, gPercentHeightDescendant
sMap, gPercentHeightContainerMap); |
209 HashSet<RenderBox*>::iterator end = descendantSet->end(); | 229 if (gPositionedDescendantsMap) |
210 for (HashSet<RenderBox*>::iterator descendant = descendantSet->begin
(); descendant != end; ++descendant) { | 230 removeBlockFromDescendantAndContainerMaps(this, gPositionedDescendantsMa
p, gPositionedContainerMap); |
211 HashSet<RenderBlock*>* containerSet = gPercentHeightContainerMap
->get(*descendant); | |
212 ASSERT(containerSet); | |
213 if (!containerSet) | |
214 continue; | |
215 ASSERT(containerSet->contains(this)); | |
216 containerSet->remove(this); | |
217 if (containerSet->isEmpty()) { | |
218 gPercentHeightContainerMap->remove(*descendant); | |
219 delete containerSet; | |
220 } | |
221 } | |
222 delete descendantSet; | |
223 } | |
224 } | |
225 } | 231 } |
226 | 232 |
227 void RenderBlock::willBeDestroyed() | 233 void RenderBlock::willBeDestroyed() |
228 { | 234 { |
229 // Mark as being destroyed to avoid trouble with merges in removeChild(). | 235 // Mark as being destroyed to avoid trouble with merges in removeChild(). |
230 m_beingDestroyed = true; | 236 m_beingDestroyed = true; |
231 | 237 |
232 // Make sure to destroy anonymous children first while they are still connec
ted to the rest of the tree, so that they will | 238 // Make sure to destroy anonymous children first while they are still connec
ted to the rest of the tree, so that they will |
233 // properly dirty line boxes that they are removed from. Effects that do :be
fore/:after only on hover could crash otherwise. | 239 // properly dirty line boxes that they are removed from. Effects that do :be
fore/:after only on hover could crash otherwise. |
234 children()->destroyLeftoverChildren(); | 240 children()->destroyLeftoverChildren(); |
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1647 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { | 1653 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { |
1648 FloatingObject* r = *it; | 1654 FloatingObject* r = *it; |
1649 if (r->isDescendant()) | 1655 if (r->isDescendant()) |
1650 addOverflowFromChild(r->m_renderer, IntSize(xPositionForFloatIncludi
ngMargin(r), yPositionForFloatIncludingMargin(r))); | 1656 addOverflowFromChild(r->m_renderer, IntSize(xPositionForFloatIncludi
ngMargin(r), yPositionForFloatIncludingMargin(r))); |
1651 } | 1657 } |
1652 return; | 1658 return; |
1653 } | 1659 } |
1654 | 1660 |
1655 void RenderBlock::addOverflowFromPositionedObjects() | 1661 void RenderBlock::addOverflowFromPositionedObjects() |
1656 { | 1662 { |
1657 if (!m_positionedObjects) | 1663 TrackedRendererListHashSet* positionedDescendants = positionedObjects(); |
| 1664 if (!positionedDescendants) |
1658 return; | 1665 return; |
1659 | 1666 |
1660 RenderBox* positionedObject; | 1667 RenderBox* positionedObject; |
1661 Iterator end = m_positionedObjects->end(); | 1668 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); |
1662 for (Iterator it = m_positionedObjects->begin(); it != end; ++it) { | 1669 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin(
); it != end; ++it) { |
1663 positionedObject = *it; | 1670 positionedObject = *it; |
1664 | 1671 |
1665 // Fixed positioned elements don't contribute to layout overflow, since
they don't scroll with the content. | 1672 // Fixed positioned elements don't contribute to layout overflow, since
they don't scroll with the content. |
1666 if (positionedObject->style()->position() != FixedPosition) { | 1673 if (positionedObject->style()->position() != FixedPosition) { |
1667 int x = positionedObject->x(); | 1674 LayoutUnit x = positionedObject->x(); |
1668 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 1675 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
1669 x -= verticalScrollbarWidth(); | 1676 x -= verticalScrollbarWidth(); |
1670 addOverflowFromChild(positionedObject, IntSize(x, positionedObject->
y())); | 1677 addOverflowFromChild(positionedObject, LayoutSize(x, positionedObjec
t->y())); |
1671 } | 1678 } |
1672 } | 1679 } |
1673 } | 1680 } |
1674 | 1681 |
1675 void RenderBlock::addVisualOverflowFromTheme() | 1682 void RenderBlock::addVisualOverflowFromTheme() |
1676 { | 1683 { |
1677 if (!style()->hasAppearance()) | 1684 if (!style()->hasAppearance()) |
1678 return; | 1685 return; |
1679 | 1686 |
1680 IntRect inflatedRect = pixelSnappedBorderBoxRect(); | 1687 IntRect inflatedRect = pixelSnappedBorderBoxRect(); |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2267 } else { | 2274 } else { |
2268 if (applyDelta == ApplyLayoutDelta) | 2275 if (applyDelta == ApplyLayoutDelta) |
2269 view()->addLayoutDelta(LayoutSize(child->x() - logicalTop, 0)); | 2276 view()->addLayoutDelta(LayoutSize(child->x() - logicalTop, 0)); |
2270 child->setX(logicalTop); | 2277 child->setX(logicalTop); |
2271 } | 2278 } |
2272 } | 2279 } |
2273 | 2280 |
2274 void RenderBlock::layoutBlockChildren(bool relayoutChildren, LayoutUnit& maxFloa
tLogicalBottom) | 2281 void RenderBlock::layoutBlockChildren(bool relayoutChildren, LayoutUnit& maxFloa
tLogicalBottom) |
2275 { | 2282 { |
2276 if (gPercentHeightDescendantsMap) { | 2283 if (gPercentHeightDescendantsMap) { |
2277 if (HashSet<RenderBox*>* descendants = gPercentHeightDescendantsMap->get
(this)) { | 2284 if (TrackedRendererListHashSet* descendants = gPercentHeightDescendantsM
ap->get(this)) { |
2278 HashSet<RenderBox*>::iterator end = descendants->end(); | 2285 TrackedRendererListHashSet::iterator end = descendants->end(); |
2279 for (HashSet<RenderBox*>::iterator it = descendants->begin(); it !=
end; ++it) { | 2286 for (TrackedRendererListHashSet::iterator it = descendants->begin();
it != end; ++it) { |
2280 RenderBox* box = *it; | 2287 RenderBox* box = *it; |
2281 while (box != this) { | 2288 while (box != this) { |
2282 if (box->normalChildNeedsLayout()) | 2289 if (box->normalChildNeedsLayout()) |
2283 break; | 2290 break; |
2284 box->setChildNeedsLayout(true, MarkOnlyThis); | 2291 box->setChildNeedsLayout(true, MarkOnlyThis); |
2285 box = box->containingBlock(); | 2292 box = box->containingBlock(); |
2286 ASSERT(box); | 2293 ASSERT(box); |
2287 if (!box) | 2294 if (!box) |
2288 break; | 2295 break; |
2289 } | 2296 } |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2548 updateLayerTransform(); | 2555 updateLayerTransform(); |
2549 | 2556 |
2550 updateScrollInfoAfterLayout(); | 2557 updateScrollInfoAfterLayout(); |
2551 | 2558 |
2552 setNeedsLayout(false); | 2559 setNeedsLayout(false); |
2553 return true; | 2560 return true; |
2554 } | 2561 } |
2555 | 2562 |
2556 void RenderBlock::layoutPositionedObjects(bool relayoutChildren) | 2563 void RenderBlock::layoutPositionedObjects(bool relayoutChildren) |
2557 { | 2564 { |
2558 if (!m_positionedObjects) | 2565 TrackedRendererListHashSet* positionedDescendants = positionedObjects(); |
| 2566 if (!positionedDescendants) |
2559 return; | 2567 return; |
2560 | 2568 |
2561 if (hasColumns()) | 2569 if (hasColumns()) |
2562 view()->layoutState()->clearPaginationInformation(); // Positioned objec
ts are not part of the column flow, so they don't paginate with the columns. | 2570 view()->layoutState()->clearPaginationInformation(); // Positioned objec
ts are not part of the column flow, so they don't paginate with the columns. |
2563 | 2571 |
2564 RenderBox* r; | 2572 RenderBox* r; |
2565 Iterator end = m_positionedObjects->end(); | 2573 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); |
2566 for (Iterator it = m_positionedObjects->begin(); it != end; ++it) { | 2574 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin(
); it != end; ++it) { |
2567 r = *it; | 2575 r = *it; |
2568 // When a non-positioned block element moves, it may have positioned chi
ldren that are implicitly positioned relative to the | 2576 // When a non-positioned block element moves, it may have positioned chi
ldren that are implicitly positioned relative to the |
2569 // non-positioned block. Rather than trying to detect all of these move
ment cases, we just always lay out positioned | 2577 // non-positioned block. Rather than trying to detect all of these move
ment cases, we just always lay out positioned |
2570 // objects that are positioned implicitly like this. Such objects are r
are, and so in typical DHTML menu usage (where everything is | 2578 // objects that are positioned implicitly like this. Such objects are r
are, and so in typical DHTML menu usage (where everything is |
2571 // positioned explicitly) this should not incur a performance penalty. | 2579 // positioned explicitly) this should not incur a performance penalty. |
2572 if (relayoutChildren || (r->style()->hasStaticBlockPosition(isHorizontal
WritingMode()) && r->parent() != this)) | 2580 if (relayoutChildren || (r->style()->hasStaticBlockPosition(isHorizontal
WritingMode()) && r->parent() != this)) |
2573 r->setChildNeedsLayout(true, MarkOnlyThis); | 2581 r->setChildNeedsLayout(true, MarkOnlyThis); |
2574 | 2582 |
2575 // If relayoutChildren is set and the child has percentage padding or an
embedded content box, we also need to invalidate the childs pref widths. | 2583 // If relayoutChildren is set and the child has percentage padding or an
embedded content box, we also need to invalidate the childs pref widths. |
2576 if (relayoutChildren && r->needsPreferredWidthsRecalculation()) | 2584 if (relayoutChildren && r->needsPreferredWidthsRecalculation()) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2612 r->layoutIfNeeded(); | 2620 r->layoutIfNeeded(); |
2613 } | 2621 } |
2614 } | 2622 } |
2615 | 2623 |
2616 if (hasColumns()) | 2624 if (hasColumns()) |
2617 view()->layoutState()->m_columnInfo = columnInfo(); // FIXME: Kind of gr
oss. We just put this back into the layout state so that pop() will work. | 2625 view()->layoutState()->m_columnInfo = columnInfo(); // FIXME: Kind of gr
oss. We just put this back into the layout state so that pop() will work. |
2618 } | 2626 } |
2619 | 2627 |
2620 void RenderBlock::markPositionedObjectsForLayout() | 2628 void RenderBlock::markPositionedObjectsForLayout() |
2621 { | 2629 { |
2622 if (m_positionedObjects) { | 2630 TrackedRendererListHashSet* positionedDescendants = positionedObjects(); |
| 2631 if (positionedDescendants) { |
2623 RenderBox* r; | 2632 RenderBox* r; |
2624 Iterator end = m_positionedObjects->end(); | 2633 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); |
2625 for (Iterator it = m_positionedObjects->begin(); it != end; ++it) { | 2634 for (TrackedRendererListHashSet::iterator it = positionedDescendants->be
gin(); it != end; ++it) { |
2626 r = *it; | 2635 r = *it; |
2627 r->setChildNeedsLayout(true); | 2636 r->setChildNeedsLayout(true); |
2628 } | 2637 } |
2629 } | 2638 } |
2630 } | 2639 } |
2631 | 2640 |
2632 void RenderBlock::markForPaginationRelayoutIfNeeded() | 2641 void RenderBlock::markForPaginationRelayoutIfNeeded() |
2633 { | 2642 { |
2634 ASSERT(!needsLayout()); | 2643 ASSERT(!needsLayout()); |
2635 if (needsLayout()) | 2644 if (needsLayout()) |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3237 gapRectsBounds = localToContainerQuad(FloatRect(localBounds)
, layer->renderer()).enclosingBoundingBox(); | 3246 gapRectsBounds = localToContainerQuad(FloatRect(localBounds)
, layer->renderer()).enclosingBoundingBox(); |
3238 if (layer->renderer()->hasOverflowClip()) | 3247 if (layer->renderer()->hasOverflowClip()) |
3239 gapRectsBounds.move(layer->renderBox()->scrolledContentO
ffset()); | 3248 gapRectsBounds.move(layer->renderBox()->scrolledContentO
ffset()); |
3240 } | 3249 } |
3241 layer->addBlockSelectionGapsBounds(gapRectsBounds); | 3250 layer->addBlockSelectionGapsBounds(gapRectsBounds); |
3242 } | 3251 } |
3243 } | 3252 } |
3244 } | 3253 } |
3245 } | 3254 } |
3246 | 3255 |
3247 static void clipOutPositionedObjects(const PaintInfo* paintInfo, const LayoutPoi
nt& offset, RenderBlock::PositionedObjectsListHashSet* positionedObjects) | 3256 static void clipOutPositionedObjects(const PaintInfo* paintInfo, const LayoutPoi
nt& offset, TrackedRendererListHashSet* positionedObjects) |
3248 { | 3257 { |
3249 if (!positionedObjects) | 3258 if (!positionedObjects) |
3250 return; | 3259 return; |
3251 | 3260 |
3252 RenderBlock::PositionedObjectsListHashSet::const_iterator end = positionedOb
jects->end(); | 3261 TrackedRendererListHashSet::const_iterator end = positionedObjects->end(); |
3253 for (RenderBlock::PositionedObjectsListHashSet::const_iterator it = position
edObjects->begin(); it != end; ++it) { | 3262 for (TrackedRendererListHashSet::const_iterator it = positionedObjects->begi
n(); it != end; ++it) { |
3254 RenderBox* r = *it; | 3263 RenderBox* r = *it; |
3255 paintInfo->context->clipOut(IntRect(offset.x() + r->x(), offset.y() + r-
>y(), r->width(), r->height())); | 3264 paintInfo->context->clipOut(IntRect(offset.x() + r->x(), offset.y() + r-
>y(), r->width(), r->height())); |
3256 } | 3265 } |
3257 } | 3266 } |
3258 | 3267 |
3259 static LayoutUnit blockDirectionOffset(RenderBlock* rootBlock, const LayoutSize&
offsetFromRootBlock) | 3268 static LayoutUnit blockDirectionOffset(RenderBlock* rootBlock, const LayoutSize&
offsetFromRootBlock) |
3260 { | 3269 { |
3261 return rootBlock->isHorizontalWritingMode() ? offsetFromRootBlock.height() :
offsetFromRootBlock.width(); | 3270 return rootBlock->isHorizontalWritingMode() ? offsetFromRootBlock.height() :
offsetFromRootBlock.width(); |
3262 } | 3271 } |
3263 | 3272 |
(...skipping 17 matching lines...) Expand all Loading... |
3281 GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const LayoutPoint& r
ootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | 3290 GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const LayoutPoint& r
ootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, |
3282 LayoutUnit& lastLogicalTop, LayoutUnit& last
LogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo) | 3291 LayoutUnit& lastLogicalTop, LayoutUnit& last
LogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo) |
3283 { | 3292 { |
3284 // IMPORTANT: Callers of this method that intend for painting to happen need
to do a save/restore. | 3293 // IMPORTANT: Callers of this method that intend for painting to happen need
to do a save/restore. |
3285 // Clip out floating and positioned objects when painting selection gaps. | 3294 // Clip out floating and positioned objects when painting selection gaps. |
3286 if (paintInfo) { | 3295 if (paintInfo) { |
3287 // Note that we don't clip out overflow for positioned objects. We just
stick to the border box. | 3296 // Note that we don't clip out overflow for positioned objects. We just
stick to the border box. |
3288 LayoutRect flippedBlockRect(offsetFromRootBlock.width(), offsetFromRootB
lock.height(), width(), height()); | 3297 LayoutRect flippedBlockRect(offsetFromRootBlock.width(), offsetFromRootB
lock.height(), width(), height()); |
3289 rootBlock->flipForWritingMode(flippedBlockRect); | 3298 rootBlock->flipForWritingMode(flippedBlockRect); |
3290 flippedBlockRect.moveBy(rootBlockPhysicalPosition); | 3299 flippedBlockRect.moveBy(rootBlockPhysicalPosition); |
3291 clipOutPositionedObjects(paintInfo, flippedBlockRect.location(), m_posit
ionedObjects.get()); | 3300 clipOutPositionedObjects(paintInfo, flippedBlockRect.location(), positio
nedObjects()); |
3292 if (isBody() || isRoot()) // The <body> must make sure to examine its co
ntainingBlock's positioned objects. | 3301 if (isBody() || isRoot()) // The <body> must make sure to examine its co
ntainingBlock's positioned objects. |
3293 for (RenderBlock* cb = containingBlock(); cb && !cb->isRenderView();
cb = cb->containingBlock()) | 3302 for (RenderBlock* cb = containingBlock(); cb && !cb->isRenderView();
cb = cb->containingBlock()) |
3294 clipOutPositionedObjects(paintInfo, LayoutPoint(cb->x(), cb->y()
), cb->m_positionedObjects.get()); // FIXME: Not right for flipped writing modes
. | 3303 clipOutPositionedObjects(paintInfo, LayoutPoint(cb->x(), cb->y()
), cb->positionedObjects()); // FIXME: Not right for flipped writing modes. |
3295 if (m_floatingObjects) { | 3304 if (m_floatingObjects) { |
3296 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(
); | 3305 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(
); |
3297 FloatingObjectSetIterator end = floatingObjectSet.end(); | 3306 FloatingObjectSetIterator end = floatingObjectSet.end(); |
3298 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it !=
end; ++it) { | 3307 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it !=
end; ++it) { |
3299 FloatingObject* r = *it; | 3308 FloatingObject* r = *it; |
3300 LayoutRect floatBox(offsetFromRootBlock.width() + xPositionForFl
oatIncludingMargin(r), | 3309 LayoutRect floatBox(offsetFromRootBlock.width() + xPositionForFl
oatIncludingMargin(r), |
3301 offsetFromRootBlock.height() + yPositionForF
loatIncludingMargin(r), | 3310 offsetFromRootBlock.height() + yPositionForF
loatIncludingMargin(r), |
3302 r->m_renderer->width(), r->m_renderer->heigh
t()); | 3311 r->m_renderer->width(), r->m_renderer->heigh
t()); |
3303 rootBlock->flipForWritingMode(floatBox); | 3312 rootBlock->flipForWritingMode(floatBox); |
3304 floatBox.move(rootBlockPhysicalPosition.x(), rootBlockPhysicalPo
sition.y()); | 3313 floatBox.move(rootBlockPhysicalPosition.x(), rootBlockPhysicalPo
sition.y()); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3575 | 3584 |
3576 RenderObject* child = beforeBlock->lastChild(); | 3585 RenderObject* child = beforeBlock->lastChild(); |
3577 while (child && child->isRenderBlock()) { | 3586 while (child && child->isRenderBlock()) { |
3578 beforeBlock = toRenderBlock(child); | 3587 beforeBlock = toRenderBlock(child); |
3579 offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop
()); | 3588 offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop
()); |
3580 child = beforeBlock->lastChild(); | 3589 child = beforeBlock->lastChild(); |
3581 } | 3590 } |
3582 return beforeBlock; | 3591 return beforeBlock; |
3583 } | 3592 } |
3584 | 3593 |
| 3594 void RenderBlock::insertIntoTrackedRendererMaps(RenderBox* descendant, TrackedDe
scendantsMap*& descendantsMap, TrackedContainerMap*& containerMap) |
| 3595 { |
| 3596 if (!descendantsMap) { |
| 3597 descendantsMap = new TrackedDescendantsMap; |
| 3598 containerMap = new TrackedContainerMap; |
| 3599 } |
| 3600 |
| 3601 TrackedRendererListHashSet* descendantSet = descendantsMap->get(this); |
| 3602 if (!descendantSet) { |
| 3603 descendantSet = new TrackedRendererListHashSet; |
| 3604 descendantsMap->set(this, descendantSet); |
| 3605 } |
| 3606 bool added = descendantSet->add(descendant).isNewEntry; |
| 3607 if (!added) { |
| 3608 ASSERT(containerMap->get(descendant)); |
| 3609 ASSERT(containerMap->get(descendant)->contains(this)); |
| 3610 return; |
| 3611 } |
| 3612 |
| 3613 HashSet<RenderBlock*>* containerSet = containerMap->get(descendant); |
| 3614 if (!containerSet) { |
| 3615 containerSet = new HashSet<RenderBlock*>; |
| 3616 containerMap->set(descendant, containerSet); |
| 3617 } |
| 3618 ASSERT(!containerSet->contains(this)); |
| 3619 containerSet->add(this); |
| 3620 } |
| 3621 |
| 3622 void RenderBlock::removeFromTrackedRendererMaps(RenderBox* descendant, TrackedDe
scendantsMap*& descendantsMap, TrackedContainerMap*& containerMap) |
| 3623 { |
| 3624 if (!descendantsMap) |
| 3625 return; |
| 3626 |
| 3627 HashSet<RenderBlock*>* containerSet = containerMap->take(descendant); |
| 3628 if (!containerSet) |
| 3629 return; |
| 3630 |
| 3631 HashSet<RenderBlock*>::iterator end = containerSet->end(); |
| 3632 for (HashSet<RenderBlock*>::iterator it = containerSet->begin(); it != end;
++it) { |
| 3633 RenderBlock* container = *it; |
| 3634 ASSERT(descendant->isDescendantOf(container)); |
| 3635 TrackedRendererListHashSet* descendantSet = descendantsMap->get(containe
r); |
| 3636 ASSERT(descendantSet); |
| 3637 if (!descendantSet) |
| 3638 continue; |
| 3639 ASSERT(descendantSet->contains(descendant)); |
| 3640 descendantSet->remove(descendant); |
| 3641 if (descendantSet->isEmpty()) { |
| 3642 descendantsMap->remove(container); |
| 3643 delete descendantSet; |
| 3644 } |
| 3645 } |
| 3646 |
| 3647 delete containerSet; |
| 3648 } |
| 3649 |
| 3650 TrackedRendererListHashSet* RenderBlock::positionedObjects() const |
| 3651 { |
| 3652 if (gPositionedDescendantsMap) |
| 3653 return gPositionedDescendantsMap->get(this); |
| 3654 return 0; |
| 3655 } |
| 3656 |
3585 void RenderBlock::insertPositionedObject(RenderBox* o) | 3657 void RenderBlock::insertPositionedObject(RenderBox* o) |
3586 { | 3658 { |
3587 ASSERT(!isAnonymousBlock()); | 3659 ASSERT(!isAnonymousBlock()); |
3588 | 3660 |
3589 if (o->isRenderFlowThread()) | 3661 if (o->isRenderFlowThread()) |
3590 return; | 3662 return; |
3591 | 3663 |
3592 // Create the list of special objects if we don't aleady have one | 3664 insertIntoTrackedRendererMaps(o, gPositionedDescendantsMap, gPositionedConta
inerMap); |
3593 if (!m_positionedObjects) | |
3594 m_positionedObjects = adoptPtr(new PositionedObjectsListHashSet); | |
3595 | |
3596 m_positionedObjects->add(o); | |
3597 } | 3665 } |
3598 | 3666 |
3599 void RenderBlock::removePositionedObject(RenderBox* o) | 3667 void RenderBlock::removePositionedObject(RenderBox* o) |
3600 { | 3668 { |
3601 if (m_positionedObjects) | 3669 removeFromTrackedRendererMaps(o, gPositionedDescendantsMap, gPositionedConta
inerMap); |
3602 m_positionedObjects->remove(o); | |
3603 } | 3670 } |
3604 | 3671 |
3605 void RenderBlock::removePositionedObjects(RenderBlock* o) | 3672 void RenderBlock::removePositionedObjects(RenderBlock* o) |
3606 { | 3673 { |
3607 if (!m_positionedObjects) | 3674 TrackedRendererListHashSet* positionedDescendants = positionedObjects(); |
| 3675 if (!positionedDescendants) |
3608 return; | 3676 return; |
3609 | 3677 |
3610 RenderBox* r; | 3678 RenderBox* r; |
3611 | 3679 |
3612 Iterator end = m_positionedObjects->end(); | 3680 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); |
3613 | 3681 |
3614 Vector<RenderBox*, 16> deadObjects; | 3682 Vector<RenderBox*, 16> deadObjects; |
3615 | 3683 |
3616 for (Iterator it = m_positionedObjects->begin(); it != end; ++it) { | 3684 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin(
); it != end; ++it) { |
3617 r = *it; | 3685 r = *it; |
3618 if (!o || r->isDescendantOf(o)) { | 3686 if (!o || r->isDescendantOf(o)) { |
3619 if (o) | 3687 if (o) |
3620 r->setChildNeedsLayout(true, MarkOnlyThis); | 3688 r->setChildNeedsLayout(true, MarkOnlyThis); |
3621 | 3689 |
3622 // It is parent blocks job to add positioned child to positioned obj
ects list of its containing block | 3690 // It is parent blocks job to add positioned child to positioned obj
ects list of its containing block |
3623 // Parent layout needs to be invalidated to ensure this happens. | 3691 // Parent layout needs to be invalidated to ensure this happens. |
3624 RenderObject* p = r->parent(); | 3692 RenderObject* p = r->parent(); |
3625 while (p && !p->isRenderBlock()) | 3693 while (p && !p->isRenderBlock()) |
3626 p = p->parent(); | 3694 p = p->parent(); |
3627 if (p) | 3695 if (p) |
3628 p->setChildNeedsLayout(true); | 3696 p->setChildNeedsLayout(true); |
3629 | 3697 |
3630 deadObjects.append(r); | 3698 deadObjects.append(r); |
3631 } | 3699 } |
3632 } | 3700 } |
3633 | 3701 |
3634 for (unsigned i = 0; i < deadObjects.size(); i++) | 3702 for (unsigned i = 0; i < deadObjects.size(); i++) |
3635 m_positionedObjects->remove(deadObjects.at(i)); | 3703 removePositionedObject(deadObjects.at(i)); |
3636 } | 3704 } |
3637 | 3705 |
3638 RenderBlock::FloatingObject* RenderBlock::insertFloatingObject(RenderBox* o) | 3706 RenderBlock::FloatingObject* RenderBlock::insertFloatingObject(RenderBox* o) |
3639 { | 3707 { |
3640 ASSERT(o->isFloating()); | 3708 ASSERT(o->isFloating()); |
3641 | 3709 |
3642 // Create the list of special objects if we don't aleady have one | 3710 // Create the list of special objects if we don't aleady have one |
3643 if (!m_floatingObjects) | 3711 if (!m_floatingObjects) |
3644 m_floatingObjects = adoptPtr(new FloatingObjects(this, isHorizontalWriti
ngMode())); | 3712 m_floatingObjects = adoptPtr(new FloatingObjects(this, isHorizontalWriti
ngMode())); |
3645 else { | 3713 else { |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3903 newY = lowestFloatLogicalBottom(); | 3971 newY = lowestFloatLogicalBottom(); |
3904 default: | 3972 default: |
3905 break; | 3973 break; |
3906 } | 3974 } |
3907 if (height() < newY) | 3975 if (height() < newY) |
3908 setLogicalHeight(newY); | 3976 setLogicalHeight(newY); |
3909 } | 3977 } |
3910 | 3978 |
3911 void RenderBlock::addPercentHeightDescendant(RenderBox* descendant) | 3979 void RenderBlock::addPercentHeightDescendant(RenderBox* descendant) |
3912 { | 3980 { |
3913 if (!gPercentHeightDescendantsMap) { | 3981 insertIntoTrackedRendererMaps(descendant, gPercentHeightDescendantsMap, gPer
centHeightContainerMap); |
3914 gPercentHeightDescendantsMap = new PercentHeightDescendantsMap; | |
3915 gPercentHeightContainerMap = new PercentHeightContainerMap; | |
3916 } | |
3917 | |
3918 HashSet<RenderBox*>* descendantSet = gPercentHeightDescendantsMap->get(this)
; | |
3919 if (!descendantSet) { | |
3920 descendantSet = new HashSet<RenderBox*>; | |
3921 gPercentHeightDescendantsMap->set(this, descendantSet); | |
3922 } | |
3923 bool added = descendantSet->add(descendant).isNewEntry; | |
3924 if (!added) { | |
3925 ASSERT(gPercentHeightContainerMap->get(descendant)); | |
3926 ASSERT(gPercentHeightContainerMap->get(descendant)->contains(this)); | |
3927 return; | |
3928 } | |
3929 | |
3930 HashSet<RenderBlock*>* containerSet = gPercentHeightContainerMap->get(descen
dant); | |
3931 if (!containerSet) { | |
3932 containerSet = new HashSet<RenderBlock*>; | |
3933 gPercentHeightContainerMap->set(descendant, containerSet); | |
3934 } | |
3935 ASSERT(!containerSet->contains(this)); | |
3936 containerSet->add(this); | |
3937 } | 3982 } |
3938 | 3983 |
3939 void RenderBlock::removePercentHeightDescendant(RenderBox* descendant) | 3984 void RenderBlock::removePercentHeightDescendant(RenderBox* descendant) |
3940 { | 3985 { |
3941 if (!gPercentHeightContainerMap) | 3986 removeFromTrackedRendererMaps(descendant, gPercentHeightDescendantsMap, gPer
centHeightContainerMap); |
3942 return; | |
3943 | |
3944 HashSet<RenderBlock*>* containerSet = gPercentHeightContainerMap->take(desce
ndant); | |
3945 if (!containerSet) | |
3946 return; | |
3947 | |
3948 HashSet<RenderBlock*>::iterator end = containerSet->end(); | |
3949 for (HashSet<RenderBlock*>::iterator it = containerSet->begin(); it != end;
++it) { | |
3950 RenderBlock* container = *it; | |
3951 HashSet<RenderBox*>* descendantSet = gPercentHeightDescendantsMap->get(c
ontainer); | |
3952 ASSERT(descendantSet); | |
3953 if (!descendantSet) | |
3954 continue; | |
3955 ASSERT(descendantSet->contains(descendant)); | |
3956 descendantSet->remove(descendant); | |
3957 if (descendantSet->isEmpty()) { | |
3958 gPercentHeightDescendantsMap->remove(container); | |
3959 delete descendantSet; | |
3960 } | |
3961 } | |
3962 | |
3963 delete containerSet; | |
3964 } | 3987 } |
3965 | 3988 |
3966 HashSet<RenderBox*>* RenderBlock::percentHeightDescendants() const | 3989 TrackedRendererListHashSet* RenderBlock::percentHeightDescendants() const |
3967 { | 3990 { |
3968 return gPercentHeightDescendantsMap ? gPercentHeightDescendantsMap->get(this
) : 0; | 3991 return gPercentHeightDescendantsMap ? gPercentHeightDescendantsMap->get(this
) : 0; |
3969 } | 3992 } |
3970 | 3993 |
3971 bool RenderBlock::hasPercentHeightContainerMap() | 3994 bool RenderBlock::hasPercentHeightContainerMap() |
3972 { | 3995 { |
3973 return gPercentHeightContainerMap; | 3996 return gPercentHeightContainerMap; |
3974 } | 3997 } |
3975 | 3998 |
3976 bool RenderBlock::hasPercentHeightDescendant(RenderBox* descendant) | 3999 bool RenderBlock::hasPercentHeightDescendant(RenderBox* descendant) |
(...skipping 3440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7417 newStyle->setColumnSpan(ColumnSpanAll); | 7440 newStyle->setColumnSpan(ColumnSpanAll); |
7418 | 7441 |
7419 RenderBlock* newBox = new (parent->renderArena()) RenderBlock(parent->docume
nt() /* anonymous box */); | 7442 RenderBlock* newBox = new (parent->renderArena()) RenderBlock(parent->docume
nt() /* anonymous box */); |
7420 newBox->setStyle(newStyle.release()); | 7443 newBox->setStyle(newStyle.release()); |
7421 return newBox; | 7444 return newBox; |
7422 } | 7445 } |
7423 | 7446 |
7424 #ifndef NDEBUG | 7447 #ifndef NDEBUG |
7425 void RenderBlock::checkPositionedObjectsNeedLayout() | 7448 void RenderBlock::checkPositionedObjectsNeedLayout() |
7426 { | 7449 { |
7427 if (PositionedObjectsListHashSet* positionedObjects = this->positionedObject
s()) { | 7450 if (!gPositionedDescendantsMap) |
7428 PositionedObjectsListHashSet::const_iterator end = positionedObjects->en
d(); | 7451 return; |
7429 for (PositionedObjectsListHashSet::const_iterator it = positionedObjects
->begin(); it != end; ++it) { | 7452 |
| 7453 if (TrackedRendererListHashSet* positionedDescendantSet = positionedObjects(
)) { |
| 7454 TrackedRendererListHashSet::const_iterator end = positionedDescendantSet
->end(); |
| 7455 for (TrackedRendererListHashSet::const_iterator it = positionedDescendan
tSet->begin(); it != end; ++it) { |
7430 RenderBox* currBox = *it; | 7456 RenderBox* currBox = *it; |
7431 ASSERT(!currBox->needsLayout()); | 7457 ASSERT(!currBox->needsLayout()); |
7432 } | 7458 } |
7433 } | 7459 } |
7434 } | 7460 } |
7435 | 7461 |
7436 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const | 7462 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const |
7437 { | 7463 { |
7438 showRenderObject(); | 7464 showRenderObject(); |
7439 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 7465 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
7440 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 7466 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
7441 } | 7467 } |
7442 | 7468 |
7443 // These helpers are only used by the PODIntervalTree for debugging purposes. | 7469 // These helpers are only used by the PODIntervalTree for debugging purposes. |
7444 String ValueToString<int>::string(const int value) | 7470 String ValueToString<int>::string(const int value) |
7445 { | 7471 { |
7446 return String::number(value); | 7472 return String::number(value); |
7447 } | 7473 } |
7448 | 7474 |
7449 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl
oatingObject* floatingObject) | 7475 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl
oatingObject* floatingObject) |
7450 { | 7476 { |
7451 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr
ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating
Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped
MaxY()); | 7477 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr
ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating
Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped
MaxY()); |
7452 } | 7478 } |
7453 | 7479 |
7454 #endif | 7480 #endif |
7455 | 7481 |
7456 } // namespace WebCore | 7482 } // namespace WebCore |
OLD | NEW |