Changeset 92626 in webkit
- Timestamp:
- Aug 8, 2011 1:13:48 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/PerformanceTests/ChangeLog
r92610 r92626 1 2011-08-08 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r92610. 4 http://trac.webkit.org/changeset/92610 5 https://bugs.webkit.org/show_bug.cgi?id=65868 6 7 Caused assertion failures when running fast/multicol tests 8 (Requested by andersca on #webkit). 9 10 * Layout/floats.html: 11 1 12 2011-08-08 Alexandru Chiculita <achicu@adobe.com> 2 13 -
trunk/PerformanceTests/Layout/floats.html
r92610 r92626 31 31 } 32 32 33 function createSet(width, height , nested)33 function createSet(width, height) 34 34 { 35 35 var container = createElement("div", document.body, "container"); … … 37 37 for (var x = 0; x < width; ++x) 38 38 createElement("div", container, "float", "float" + x + "_" + y); 39 40 var nestedContainer = container;41 for ( ; nested > 0; --nested)42 nestedContainer = createElement("div", nestedContainer, "nested", "nested" + x + "_" + nested);43 44 39 createElement("div", container, "float-end", "end" + x) 45 40 } … … 53 48 } 54 49 55 function test(width, height , nested)50 function test(width, height) 56 51 { 57 nested = nested || 0;58 59 52 document.getElementById("test_panel").style.display = "none"; 60 53 document.getElementById("framerate_panel").style.display = "block"; 61 54 62 createSet(width, height , nested);55 createSet(width, height); 63 56 var updates = 0; 64 57 var startTime = new Date(); … … 99 92 <button onclick="test(50, 100)">50 by 100</button> 100 93 <button onclick="test(100, 100)">100 by 100</button> 101 <p>Nested divs:</p>102 <button onclick="test(2, 100, 100)">2 by 100, 100 nested</button>103 <button onclick="test(20, 100, 100)">20 by 100, 100 nested</button>104 <button onclick="test(50, 100, 100)">50 by 100, 100 nested</button>105 <button onclick="test(100, 100, 100)">100 by 100, 100 nested</button>106 94 </div> 107 95 </body> -
trunk/Source/WebCore/ChangeLog
r92625 r92626 1 2011-08-08 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r92610. 4 http://trac.webkit.org/changeset/92610 5 https://bugs.webkit.org/show_bug.cgi?id=65868 6 7 Caused assertion failures when running fast/multicol tests 8 (Requested by andersca on #webkit). 9 10 * WebCore.xcodeproj/project.pbxproj: 11 * platform/PODIntervalTree.h: 12 (WebCore::PODIntervalTree::allOverlaps): 13 (WebCore::PODIntervalTree::searchForOverlapsFrom): 14 * platform/PODRedBlackTree.h: 15 (WebCore::PODRedBlackTree::add): 16 (WebCore::PODRedBlackTree::remove): 17 (WebCore::PODRedBlackTree::contains): 18 (WebCore::PODRedBlackTree::visitInorder): 19 (WebCore::PODRedBlackTree::size): 20 (WebCore::PODRedBlackTree::checkInvariants): 21 (WebCore::PODRedBlackTree::dump): 22 * rendering/RenderBlock.cpp: 23 (WebCore::RenderBlock::styleDidChange): 24 (WebCore::RenderBlock::addOverflowFromFloats): 25 (WebCore::RenderBlock::repaintOverhangingFloats): 26 (WebCore::RenderBlock::paintFloats): 27 (WebCore::RenderBlock::selectionGaps): 28 (WebCore::RenderBlock::insertFloatingObject): 29 (WebCore::RenderBlock::removeFloatingObject): 30 (WebCore::RenderBlock::removeFloatingObjectsBelow): 31 (WebCore::RenderBlock::positionNewFloats): 32 (WebCore::RenderBlock::logicalLeftOffsetForLine): 33 (WebCore::RenderBlock::logicalRightOffsetForLine): 34 (WebCore::RenderBlock::nextFloatLogicalBottomBelow): 35 (WebCore::RenderBlock::lowestFloatLogicalBottom): 36 (WebCore::RenderBlock::addPositionedFloats): 37 (WebCore::RenderBlock::clearFloats): 38 (WebCore::RenderBlock::addOverhangingFloats): 39 (WebCore::RenderBlock::hasOverhangingFloat): 40 (WebCore::RenderBlock::addIntrudingFloats): 41 (WebCore::RenderBlock::markSiblingsWithFloatsForLayout): 42 (WebCore::RenderBlock::hitTestFloats): 43 (WebCore::RenderBlock::adjustForBorderFit): 44 (WebCore::RenderBlock::FloatingObjects::clear): 45 * rendering/RenderBlock.h: 46 (WebCore::RenderBlock::FloatingObject::FloatingObject): 47 (WebCore::RenderBlock::FloatingObject::setX): 48 (WebCore::RenderBlock::FloatingObject::setY): 49 (WebCore::RenderBlock::FloatingObject::setWidth): 50 (WebCore::RenderBlock::FloatingObject::setHeight): 51 (WebCore::RenderBlock::FloatingObject::setFrameRect): 52 (WebCore::RenderBlock::FloatingObjects::FloatingObjects): 53 (WebCore::RenderBlock::FloatingObjects::set): 54 * rendering/RenderBlockLineLayout.cpp: 55 (WebCore::RenderBlock::layoutRunsAndFloatsInRange): 56 (WebCore::RenderBlock::linkToEndLineIfNeeded): 57 (WebCore::RenderBlock::matchedEndLine): 58 (WebCore::RenderBlock::positionNewFloatOnLine): 59 1 60 2011-08-08 Emil A Eklund <eae@chromium.org> 2 61 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r92610 r92626 1337 1337 508CCA4F13CF106B003151F3 /* RenderFlowThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 508CCA4D13CF106B003151F3 /* RenderFlowThread.h */; }; 1338 1338 508CCA5013CF106B003151F3 /* RenderFlowThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 508CCA4E13CF106B003151F3 /* RenderFlowThread.cpp */; }; 1339 5097C5A313EABA7E002DE4AF /* PODArena.h in Headers */ = {isa = PBXBuildFile; fileRef = 5097C59F13EABA7E002DE4AF /* PODArena.h */; settings = {ATTRIBUTES = (Private, ); }; };1340 5097C5A413EABA7E002DE4AF /* PODInterval.h in Headers */ = {isa = PBXBuildFile; fileRef = 5097C5A013EABA7E002DE4AF /* PODInterval.h */; settings = {ATTRIBUTES = (Private, ); }; };1341 5097C5A513EABA7E002DE4AF /* PODIntervalTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 5097C5A113EABA7E002DE4AF /* PODIntervalTree.h */; settings = {ATTRIBUTES = (Private, ); }; };1342 5097C5A613EABA7E002DE4AF /* PODRedBlackTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 5097C5A213EABA7E002DE4AF /* PODRedBlackTree.h */; settings = {ATTRIBUTES = (Private, ); }; };1343 1339 50E566D6139E38C500214433 /* CSSWrapShapes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 501BAAB11395114B00F7ACEB /* CSSWrapShapes.cpp */; }; 1344 1340 510184690B08602A004A825F /* CachedPage.h in Headers */ = {isa = PBXBuildFile; fileRef = 510184670B08602A004A825F /* CachedPage.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 7942 7938 508CCA4D13CF106B003151F3 /* RenderFlowThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderFlowThread.h; sourceTree = "<group>"; }; 7943 7939 508CCA4E13CF106B003151F3 /* RenderFlowThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFlowThread.cpp; sourceTree = "<group>"; }; 7944 5097C59F13EABA7E002DE4AF /* PODArena.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PODArena.h; sourceTree = "<group>"; };7945 5097C5A013EABA7E002DE4AF /* PODInterval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PODInterval.h; sourceTree = "<group>"; };7946 5097C5A113EABA7E002DE4AF /* PODIntervalTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PODIntervalTree.h; sourceTree = "<group>"; };7947 5097C5A213EABA7E002DE4AF /* PODRedBlackTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PODRedBlackTree.h; sourceTree = "<group>"; };7948 7940 510184670B08602A004A825F /* CachedPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedPage.h; sourceTree = "<group>"; }; 7949 7941 510184680B08602A004A825F /* CachedPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedPage.cpp; sourceTree = "<group>"; }; … … 19017 19009 isa = PBXGroup; 19018 19010 children = ( 19019 5097C59F13EABA7E002DE4AF /* PODArena.h */,19020 5097C5A013EABA7E002DE4AF /* PODInterval.h */,19021 5097C5A113EABA7E002DE4AF /* PODIntervalTree.h */,19022 5097C5A213EABA7E002DE4AF /* PODRedBlackTree.h */,19023 19011 49E912A40EFAC8E6009D0CAF /* animation */, 19024 19012 FD31604012B026A300C1A359 /* audio */, … … 23367 23355 977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */, 23368 23356 FD537353137B651800008DCE /* ZeroPole.h in Headers */, 23369 5097C5A313EABA7E002DE4AF /* PODArena.h in Headers */,23370 5097C5A413EABA7E002DE4AF /* PODInterval.h in Headers */,23371 5097C5A513EABA7E002DE4AF /* PODIntervalTree.h in Headers */,23372 5097C5A613EABA7E002DE4AF /* PODRedBlackTree.h in Headers */,23373 23357 ); 23374 23358 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/platform/PODIntervalTree.h
r92610 r92626 41 41 #endif 42 42 43 template <class T, class UserData = void*>44 class PODIntervalSearchAdapter {45 public:46 typedef PODInterval<T, UserData> IntervalType;47 48 PODIntervalSearchAdapter(Vector<IntervalType>& result, const T& lowValue, const T& highValue)49 : m_result(result)50 , m_lowValue(lowValue)51 , m_highValue(highValue)52 {53 }54 55 const T& lowValue() const { return m_lowValue; }56 const T& highValue() const { return m_highValue; }57 void collectIfNeeded(const IntervalType& data) const58 {59 if (data.overlaps(m_lowValue, m_highValue))60 m_result.append(data);61 }62 63 private:64 Vector<IntervalType>& m_result;65 T m_lowValue;66 T m_highValue;67 };68 69 43 // An interval tree, which is a form of augmented red-black tree. It 70 44 // supports efficient (O(lg n)) insertion, removal and querying of … … 77 51 // this tree. 78 52 typedef PODInterval<T, UserData> IntervalType; 79 typedef PODIntervalSearchAdapter<T, UserData> IntervalSearchAdapterType; 80 81 PODIntervalTree(UninitializedTreeEnum unitializedTree) 82 : PODRedBlackTree<IntervalType>(unitializedTree) 83 { 84 init(); 85 } 86 53 87 54 PODIntervalTree() 88 55 : PODRedBlackTree<IntervalType>() … … 114 81 // Explicit dereference of "this" required because of 115 82 // inheritance rules in template classes. 116 IntervalSearchAdapterType adapter(result, interval.low(), interval.high()); 117 searchForOverlapsFrom<IntervalSearchAdapterType>(this->root(), adapter); 118 } 119 120 template <class AdapterType> 121 void allOverlapsWithAdapter(AdapterType& adapter) const 122 { 123 // Explicit dereference of "this" required because of 124 // inheritance rules in template classes. 125 searchForOverlapsFrom<AdapterType>(this->root(), adapter); 83 searchForOverlapsFrom(this->root(), interval, result); 126 84 } 127 85 … … 155 113 // interval to the result vector. The intervals are sorted by 156 114 // increasing low endpoint. 157 template <class AdapterType> 158 void searchForOverlapsFrom(IntervalNode* node, AdapterType& adapter) const 115 void searchForOverlapsFrom(IntervalNode* node, const IntervalType& interval, Vector<IntervalType>& res) const 159 116 { 160 117 if (!node) … … 169 126 // This is phrased this way to avoid the need for operator 170 127 // <= on type T. 171 && !(left->data().maxHigh() < adapter.lowValue()))172 searchForOverlapsFrom <AdapterType>(left, adapter);128 && !(left->data().maxHigh() < interval.low())) 129 searchForOverlapsFrom(left, interval, res); 173 130 174 131 // Check for overlap with current node. 175 adapter.collectIfNeeded(node->data()); 132 if (node->data().overlaps(interval)) 133 res.append(node->data()); 176 134 177 135 // See whether we need to traverse the right subtree. 178 136 // This is phrased this way to avoid the need for operator <= 179 137 // on type T. 180 if (!( adapter.highValue() < node->data().low()))181 searchForOverlapsFrom <AdapterType>(node->right(), adapter);138 if (!(interval.high() < node->data().low())) 139 searchForOverlapsFrom(node->right(), interval, res); 182 140 } 183 141 -
trunk/Source/WebCore/platform/PODRedBlackTree.h
r92611 r92626 91 91 #endif 92 92 93 enum UninitializedTreeEnum {94 UninitializedTree95 };96 97 93 template<class T> 98 94 class PODRedBlackTree { … … 106 102 }; 107 103 108 // Constructs a new red-black tree without allocating an arena.109 // isInitialized will return false in this case. initIfNeeded can be used110 // to init the structure. This constructor is usefull for creating111 // lazy initialized tree.112 PODRedBlackTree(UninitializedTreeEnum)113 : m_root(0)114 , m_needsFullOrderingComparisons(false)115 #ifndef NDEBUG116 , m_verboseDebugging(false)117 #endif118 {119 }120 121 104 // Constructs a new red-black tree, allocating temporary objects 122 105 // from a newly constructed PODArena. … … 145 128 virtual ~PODRedBlackTree() { } 146 129 147 // Clearing will delete the contents of the tree. After this call148 // isInitialized will return false.149 void clear()150 {151 m_arena = 0;152 m_root = 0;153 }154 155 bool isInitialized() const156 {157 return m_arena;158 }159 160 void initIfNeeded()161 {162 if (!m_arena)163 m_arena = PODArena::create();164 }165 166 130 void add(const T& data) 167 131 { 168 ASSERT(isInitialized());169 132 Node* node = m_arena->allocateObject<Node, T>(data); 170 133 insertNode(node); … … 174 137 bool remove(const T& data) 175 138 { 176 ASSERT(isInitialized());177 139 Node* node = treeSearch(data); 178 140 if (node) { … … 183 145 } 184 146 185 bool contains(const T& data) const 186 { 187 ASSERT(isInitialized()); 188 return treeSearch(data); 189 } 147 bool contains(const T& data) const { return treeSearch(data); } 190 148 191 149 void visitInorder(Visitor* visitor) const 192 150 { 193 ASSERT(isInitialized());194 151 if (!m_root) 195 152 return; … … 199 156 int size() const 200 157 { 201 ASSERT(isInitialized());202 158 Counter counter; 203 159 visitInorder(&counter); … … 213 169 virtual bool checkInvariants() const 214 170 { 215 ASSERT(isInitialized());216 171 int blackCount; 217 172 return checkInvariantsFromNode(m_root, &blackCount); … … 223 178 void dump() const 224 179 { 225 if (m_arena) 226 dumpFromNode(m_root, 0); 180 dumpFromNode(m_root, 0); 227 181 } 228 182 -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r92610 r92626 275 275 if (diff == StyleDifferenceLayout && s_canPropagateFloatIntoSibling && !canPropagateFloatIntoSibling && hasOverhangingFloats()) { 276 276 RenderBlock* parentBlock = this; 277 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();277 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 278 278 FloatingObjectSetIterator end = floatingObjectSet.end(); 279 279 … … 1437 1437 return; 1438 1438 1439 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();1439 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 1440 1440 FloatingObjectSetIterator end = floatingObjectSet.end(); 1441 1441 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { … … 2295 2295 // in this block. Better yet would be to push extra state for the containers of other floats. 2296 2296 LayoutStateDisabler layoutStateDisabler(view()); 2297 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();2297 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2298 2298 FloatingObjectSetIterator end = floatingObjectSet.end(); 2299 2299 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { … … 2628 2628 return; 2629 2629 2630 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();2630 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2631 2631 FloatingObjectSetIterator end = floatingObjectSet.end(); 2632 2632 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { … … 2880 2880 clipOutPositionedObjects(paintInfo, IntPoint(cb->x(), cb->y()), cb->m_positionedObjects.get()); // FIXME: Not right for flipped writing modes. 2881 2881 if (m_floatingObjects) { 2882 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();2882 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2883 2883 FloatingObjectSetIterator end = floatingObjectSet.end(); 2884 2884 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { … … 3191 3191 // Create the list of special objects if we don't aleady have one 3192 3192 if (!m_floatingObjects) 3193 m_floatingObjects = adoptPtr(new FloatingObjects (isHorizontalWritingMode()));3193 m_floatingObjects = adoptPtr(new FloatingObjects); 3194 3194 else { 3195 3195 // Don't insert the object again if it's already in the list 3196 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();3196 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 3197 3197 FloatingObjectSetIterator it = floatingObjectSet.find<RenderBox*, FloatingObjectHashTranslator>(o); 3198 3198 if (it != floatingObjectSet.end()) … … 3225 3225 newObj->m_renderer = o; 3226 3226 3227 m_floatingObjects->add(newObj); 3227 m_floatingObjects->increaseObjectsCount(newObj->type()); 3228 m_floatingObjects->set().add(newObj); 3228 3229 3229 3230 return newObj; … … 3233 3234 { 3234 3235 if (m_floatingObjects) { 3235 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();3236 FloatingObjectSet Iterator it = floatingObjectSet.find<RenderBox*, FloatingObjectHashTranslator>(o);3236 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 3237 FloatingObjectSet::iterator it = floatingObjectSet.find<RenderBox*, FloatingObjectHashTranslator>(o); 3237 3238 if (it != floatingObjectSet.end()) { 3238 3239 FloatingObject* r = *it; … … 3259 3260 markLinesDirtyInBlockRange(0, logicalBottom); 3260 3261 } 3261 m_floatingObjects->remove(r); 3262 m_floatingObjects->decreaseObjectsCount(r->type()); 3263 floatingObjectSet.remove(it); 3262 3264 ASSERT(!r->m_originatingLine); 3263 3265 delete r; … … 3271 3273 return; 3272 3274 3273 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();3275 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 3274 3276 FloatingObject* curr = floatingObjectSet.last(); 3275 3277 while (curr != lastFloat && (!curr->isPlaced() || logicalTopForFloat(curr) >= logicalOffset)) { 3276 m_floatingObjects->remove(curr); 3278 m_floatingObjects->decreaseObjectsCount(curr->type()); 3279 floatingObjectSet.removeLast(); 3277 3280 ASSERT(!curr->m_originatingLine); 3278 3281 delete curr; … … 3286 3289 return false; 3287 3290 3288 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();3291 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 3289 3292 if (floatingObjectSet.isEmpty()) 3290 3293 return false; … … 3401 3404 setLogicalHeightForFloat(floatingObject, logicalHeightForChild(childBox) + marginBeforeForChild(childBox) + marginAfterForChild(childBox)); 3402 3405 3403 m_floatingObjects->addPlacedObject(floatingObject);3406 floatingObject->setIsPlaced(); 3404 3407 3405 3408 // If the child moved, we have to repaint it. … … 3503 3506 #endif 3504 3507 3505 template <RenderBlock::FloatingObject::Type FloatTypeValue> 3506 inline void RenderBlock::FloatIntervalSearchAdapter<FloatTypeValue>::collectIfNeeded(const IntervalType& interval) const 3507 { 3508 const FloatingObject* r = interval.data(); 3509 if (r->type() == FloatTypeValue && interval.low() <= m_value && m_value < interval.high()) { 3510 // All the objects returned from the tree should be already placed. 3511 ASSERT(r->isPlaced() && m_renderer->logicalTopForFloat(r) <= m_value && m_renderer->logicalBottomForFloat(r) > m_value); 3512 3513 if (FloatTypeValue == FloatingObject::FloatLeft 3514 && m_renderer->logicalRightForFloat(r) > m_offset) { 3515 m_offset = m_renderer->logicalRightForFloat(r); 3516 if (m_heightRemaining) 3517 *m_heightRemaining = m_renderer->logicalBottomForFloat(r) - m_value; 3518 } 3519 3520 if (FloatTypeValue == FloatingObject::FloatRight 3521 && m_renderer->logicalLeftForFloat(r) < m_offset) { 3522 m_offset = m_renderer->logicalLeftForFloat(r); 3523 if (m_heightRemaining) 3524 *m_heightRemaining = m_renderer->logicalBottomForFloat(r) - m_value; 3525 } 3526 } 3527 } 3528 3508 // FIXME: The logicalLeftOffsetForLine/logicalRightOffsetForLine functions are very slow if there are many floats 3509 // present. We need to add a structure to floating objects to represent "lines" of floats. Then instead of checking 3510 // each float individually, we'd just walk backwards through the "lines" and stop when we hit a line that is fully above 3511 // the vertical offset that we'd like to check. Computing the "lines" would be rather complicated, but could replace the left 3512 // objects and right objects count hack that is currently used here. 3529 3513 LayoutUnit RenderBlock::logicalLeftOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemaining) const 3530 3514 { … … 3534 3518 *heightRemaining = 1; 3535 3519 3536 FloatIntervalSearchAdapter<FloatingObject::FloatLeft> adapter(this, logicalTop, left, heightRemaining); 3537 m_floatingObjects->placedFloatsTree().allOverlapsWithAdapter(adapter); 3520 // We know the list is non-empty, since we have "left" objects to search for. 3521 // Therefore we can assume that begin != end, and that we can do at least one 3522 // decrement. 3523 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 3524 FloatingObjectSetIterator begin = floatingObjectSet.begin(); 3525 FloatingObjectSetIterator it = floatingObjectSet.end(); 3526 do { 3527 --it; 3528 FloatingObject* r = *it; 3529 if (r->isPlaced() && logicalTopForFloat(r) <= logicalTop && logicalBottomForFloat(r) > logicalTop 3530 && r->type() == FloatingObject::FloatLeft 3531 && logicalRightForFloat(r) > left) { 3532 left = max(left, logicalRightForFloat(r)); 3533 if (heightRemaining) 3534 *heightRemaining = logicalBottomForFloat(r) - logicalTop; 3535 } 3536 } while (it != begin); 3538 3537 } 3539 3538 … … 3555 3554 if (heightRemaining) 3556 3555 *heightRemaining = 1; 3557 3558 FloatIntervalSearchAdapter<FloatingObject::FloatRight> adapter(this, logicalTop, right, heightRemaining); 3559 m_floatingObjects->placedFloatsTree().allOverlapsWithAdapter(adapter); 3556 3557 // We know the list is non-empty, since we have "right" objects to search for. 3558 // Therefore we can assume that begin != end, and that we can do at least one 3559 // decrement. 3560 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 3561 FloatingObjectSetIterator begin = floatingObjectSet.begin(); 3562 FloatingObjectSetIterator it = floatingObjectSet.end(); 3563 do { 3564 --it; 3565 FloatingObject* r = *it; 3566 if (r->isPlaced() && logicalTopForFloat(r) <= logicalTop && logicalBottomForFloat(r) > logicalTop 3567 && r->type() == FloatingObject::FloatRight 3568 && logicalLeftForFloat(r) < right) { 3569 right = min(right, logicalLeftForFloat(r)); 3570 if (heightRemaining) 3571 *heightRemaining = logicalBottomForFloat(r) - logicalTop; 3572 } 3573 } while (it != begin); 3560 3574 } 3561 3575 … … 3582 3596 3583 3597 int bottom = INT_MAX; 3584 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();3598 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 3585 3599 FloatingObjectSetIterator end = floatingObjectSet.end(); 3586 3600 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { … … 3599 3613 return 0; 3600 3614 int lowestFloatBottom = 0; 3601 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();3615 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 3602 3616 FloatingObjectSetIterator end = floatingObjectSet.end(); 3603 3617 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { … … 3647 3661 setLogicalTopForFloat(floatingObject, logicalTopForChild(positionedObject) - marginBeforeForChild(positionedObject)); 3648 3662 setLogicalHeightForFloat(floatingObject, logicalHeightForChild(positionedObject) + marginBeforeForChild(positionedObject) + marginAfterForChild(positionedObject)); 3649 3650 m_floatingObjects->addPlacedObject(floatingObject); 3663 floatingObject->setIsPlaced(true); 3651 3664 3652 3665 m_hasPositionedFloats = true; … … 3656 3669 void RenderBlock::clearFloats(BlockLayoutPass layoutPass) 3657 3670 { 3658 if (m_floatingObjects)3659 m_floatingObjects->setHorizontalWritingMode(isHorizontalWritingMode());3660 3661 3671 // Clear our positioned floats boolean. 3662 3672 m_hasPositionedFloats = false; … … 3677 3687 3678 3688 if (m_floatingObjects) { 3679 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();3689 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 3680 3690 if (childrenInline()) { 3681 FloatingObjectSet Iterator end = floatingObjectSet.end();3682 for (FloatingObjectSet Iterator it = floatingObjectSet.begin(); it != end; ++it) {3691 FloatingObjectSet::iterator end = floatingObjectSet.end(); 3692 for (FloatingObjectSet::iterator it = floatingObjectSet.begin(); it != end; ++it) { 3683 3693 FloatingObject* f = *it; 3684 3694 floatMap.add(f->m_renderer, f); … … 3732 3742 int changeLogicalBottom = numeric_limits<int>::min(); 3733 3743 if (m_floatingObjects) { 3734 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();3744 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 3735 3745 FloatingObjectSetIterator end = floatingObjectSet.end(); 3736 3746 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { … … 3814 3824 // We create the floating object list lazily. 3815 3825 if (!m_floatingObjects) 3816 m_floatingObjects = adoptPtr(new FloatingObjects(isHorizontalWritingMode())); 3817 3818 m_floatingObjects->add(floatingObj); 3826 m_floatingObjects = adoptPtr(new FloatingObjects); 3827 3828 m_floatingObjects->increaseObjectsCount(floatingObj->type()); 3829 m_floatingObjects->set().add(floatingObj); 3819 3830 } 3820 3831 } else { … … 3843 3854 return false; 3844 3855 3845 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();3856 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 3846 3857 FloatingObjectSetIterator it = floatingObjectSet.find<RenderBox*, FloatingObjectHashTranslator>(renderer); 3847 3858 if (it == floatingObjectSet.end()) … … 3859 3870 logicalLeftOffset += (isHorizontalWritingMode() ? marginLeft() : marginTop()); 3860 3871 3861 constFloatingObjectSet& prevSet = prev->m_floatingObjects->set();3872 FloatingObjectSet& prevSet = prev->m_floatingObjects->set(); 3862 3873 FloatingObjectSetIterator prevEnd = prevSet.end(); 3863 3874 for (FloatingObjectSetIterator prevIt = prevSet.begin(); prevIt != prevEnd; ++prevIt) { … … 3887 3898 // We create the floating object list lazily. 3888 3899 if (!m_floatingObjects) 3889 m_floatingObjects = adoptPtr(new FloatingObjects(isHorizontalWritingMode())); 3890 m_floatingObjects->add(floatingObj); 3900 m_floatingObjects = adoptPtr(new FloatingObjects); 3901 m_floatingObjects->increaseObjectsCount(floatingObj->type()); 3902 m_floatingObjects->set().add(floatingObj); 3891 3903 } 3892 3904 } … … 3929 3941 void RenderBlock::markSiblingsWithFloatsForLayout() 3930 3942 { 3931 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();3943 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 3932 3944 FloatingObjectSetIterator end = floatingObjectSet.end(); 3933 3945 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { … … 4081 4093 } 4082 4094 4083 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();4095 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 4084 4096 FloatingObjectSetIterator begin = floatingObjectSet.begin(); 4085 4097 for (FloatingObjectSetIterator it = floatingObjectSet.end(); it != begin;) { … … 5688 5700 5689 5701 if (m_floatingObjects) { 5690 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();5702 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 5691 5703 FloatingObjectSetIterator end = floatingObjectSet.end(); 5692 5704 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { … … 6432 6444 { 6433 6445 m_set.clear(); 6434 m_placedFloatsTree.clear();6435 6446 m_leftObjectsCount = 0; 6436 6447 m_rightObjectsCount = 0; … … 6458 6469 } 6459 6470 6460 inline RenderBlock::FloatingObjectInterval RenderBlock::FloatingObjects::intervalForFloatingObject(FloatingObject* floatingObject)6461 {6462 if (m_horizontalWritingMode)6463 return RenderBlock::FloatingObjectInterval(floatingObject->y(), floatingObject->maxY(), floatingObject);6464 return RenderBlock::FloatingObjectInterval(floatingObject->x(), floatingObject->maxX(), floatingObject);6465 }6466 6467 void RenderBlock::FloatingObjects::addPlacedObject(FloatingObject* floatingObject)6468 {6469 ASSERT(!floatingObject->isInPlacedTree());6470 6471 floatingObject->setIsPlaced(true);6472 if (m_placedFloatsTree.isInitialized())6473 m_placedFloatsTree.add(intervalForFloatingObject(floatingObject));6474 6475 #ifndef NDEBUG6476 floatingObject->setIsInPlacedTree(true);6477 #endif6478 }6479 6480 void RenderBlock::FloatingObjects::removePlacedObject(FloatingObject* floatingObject)6481 {6482 ASSERT(floatingObject->isPlaced() && floatingObject->isInPlacedTree());6483 6484 if (m_placedFloatsTree.isInitialized()) {6485 bool removed = m_placedFloatsTree.remove(intervalForFloatingObject(floatingObject));6486 ASSERT_UNUSED(removed, removed);6487 }6488 6489 floatingObject->setIsPlaced(false);6490 #ifndef NDEBUG6491 floatingObject->setIsInPlacedTree(false);6492 #endif6493 }6494 6495 inline void RenderBlock::FloatingObjects::add(FloatingObject* floatingObject)6496 {6497 increaseObjectsCount(floatingObject->type());6498 m_set.add(floatingObject);6499 if (floatingObject->isPlaced())6500 addPlacedObject(floatingObject);6501 }6502 6503 inline void RenderBlock::FloatingObjects::remove(FloatingObject* floatingObject)6504 {6505 decreaseObjectsCount(floatingObject->type());6506 m_set.remove(floatingObject);6507 ASSERT(floatingObject->isPlaced() || !floatingObject->isInPlacedTree());6508 if (floatingObject->isPlaced())6509 removePlacedObject(floatingObject);6510 }6511 6512 void RenderBlock::FloatingObjects::computePlacedFloatsTree()6513 {6514 ASSERT(!m_placedFloatsTree.isInitialized());6515 if (m_set.isEmpty())6516 return;6517 m_placedFloatsTree.initIfNeeded();6518 FloatingObjectSetIterator it = m_set.begin();6519 FloatingObjectSetIterator end = m_set.end();6520 for (; it != end; ++it) {6521 FloatingObject* floatingObject = *it;6522 if (floatingObject->isPlaced())6523 m_placedFloatsTree.add(intervalForFloatingObject(floatingObject));6524 }6525 }6526 6527 6471 TextRun RenderBlock::constructTextRun(RenderObject* context, const Font& font, const UChar* characters, int length, RenderStyle* style, TextRun::ExpansionBehavior expansion, TextRunFlags flags) 6528 6472 { … … 6559 6503 } 6560 6504 6561 // These helpers are only used by the PODIntervalTree for debugging purposes.6562 String ValueToString<int>::string(const int value)6563 {6564 return String::number(value);6565 }6566 6567 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::FloatingObject* floatingObject)6568 {6569 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->x(), floatingObject->y(), floatingObject->maxX(), floatingObject->maxY());6570 }6571 6572 6505 #endif 6573 6506 -
trunk/Source/WebCore/rendering/RenderBlock.h
r92610 r92626 25 25 26 26 #include "GapRects.h" 27 #include "PODIntervalTree.h"28 27 #include "RenderBox.h" 29 28 #include "RenderLineBoxList.h" … … 69 68 public: 70 69 friend class LineLayoutState; 71 #ifndef NDEBUG72 // Used by the PODIntervalTree for debugging the FloatingObject.73 template <class> friend struct ValueToString;74 #endif75 76 70 RenderBlock(Node*); 77 71 virtual ~RenderBlock(); … … 429 423 , m_isDescendant(false) 430 424 , m_isPlaced(false) 431 #ifndef NDEBUG432 , m_isInPlacedTree(false)433 #endif434 425 { 435 426 ASSERT(type != NoFloat); … … 451 442 , m_isDescendant(false) 452 443 , m_isPlaced(true) 453 #ifndef NDEBUG454 , m_isInPlacedTree(false)455 #endif456 444 { 457 445 } … … 470 458 int height() const { return m_frameRect.height(); } 471 459 472 void setX(int x) { ASSERT(!isInPlacedTree());m_frameRect.setX(x); }473 void setY(int y) { ASSERT(!isInPlacedTree());m_frameRect.setY(y); }474 void setWidth(int width) { ASSERT(!isInPlacedTree());m_frameRect.setWidth(width); }475 void setHeight(int height) { ASSERT(!isInPlacedTree());m_frameRect.setHeight(height); }460 void setX(int x) { m_frameRect.setX(x); } 461 void setY(int y) { m_frameRect.setY(y); } 462 void setWidth(int width) { m_frameRect.setWidth(width); } 463 void setHeight(int height) { m_frameRect.setHeight(height); } 476 464 477 465 const IntRect& frameRect() const { ASSERT(isPlaced()); return m_frameRect; } 478 void setFrameRect(const IntRect& frameRect) { ASSERT(!isInPlacedTree()); m_frameRect = frameRect; } 479 480 #ifndef NDEBUG 481 bool isInPlacedTree() const { return m_isInPlacedTree; } 482 void setIsInPlacedTree(bool value) { m_isInPlacedTree = value; } 483 #endif 466 void setFrameRect(const IntRect& frameRect) { m_frameRect = frameRect; } 484 467 485 468 RenderBox* m_renderer; … … 491 474 bool m_isDescendant : 1; 492 475 bool m_isPlaced : 1; 493 #ifndef NDEBUG494 bool m_isInPlacedTree : 1;495 #endif496 476 }; 497 477 … … 820 800 typedef ListHashSet<FloatingObject*, 4, FloatingObjectHashFunctions> FloatingObjectSet; 821 801 typedef FloatingObjectSet::const_iterator FloatingObjectSetIterator; 822 typedef PODInterval<LayoutUnit, FloatingObject*> FloatingObjectInterval;823 typedef PODIntervalTree<LayoutUnit, FloatingObject*> FloatingObjectTree;824 825 template <FloatingObject::Type FloatTypeValue>826 class FloatIntervalSearchAdapter {827 public:828 typedef FloatingObjectInterval IntervalType;829 830 FloatIntervalSearchAdapter(const RenderBlock* renderer, LayoutUnit value, LayoutUnit& offset, LayoutUnit* heightRemaining)831 : m_renderer(renderer)832 , m_value(value)833 , m_offset(offset)834 , m_heightRemaining(heightRemaining)835 {836 }837 838 inline LayoutUnit lowValue() const { return m_value; }839 inline LayoutUnit highValue() const { return m_value; }840 void collectIfNeeded(const IntervalType&) const;841 842 private:843 const RenderBlock* m_renderer;844 LayoutUnit m_value;845 LayoutUnit& m_offset;846 LayoutUnit* m_heightRemaining;847 };848 849 802 class FloatingObjects { 850 803 public: 851 FloatingObjects(bool horizontalWritingMode) 852 : m_placedFloatsTree(UninitializedTree) 853 , m_leftObjectsCount(0) 804 FloatingObjects() 805 : m_leftObjectsCount(0) 854 806 , m_rightObjectsCount(0) 855 807 , m_positionedObjectsCount(0) 856 , m_horizontalWritingMode(horizontalWritingMode)857 808 { 858 809 } 859 810 860 811 void clear(); 861 void add(FloatingObject*); 862 void remove(FloatingObject*); 863 void addPlacedObject(FloatingObject*); 864 void removePlacedObject(FloatingObject*); 865 void setHorizontalWritingMode(bool b = true) { m_horizontalWritingMode = b; } 866 812 void increaseObjectsCount(FloatingObject::Type); 813 void decreaseObjectsCount(FloatingObject::Type); 867 814 bool hasLeftObjects() const { return m_leftObjectsCount > 0; } 868 815 bool hasRightObjects() const { return m_rightObjectsCount > 0; } 869 816 bool hasPositionedObjects() const { return m_positionedObjectsCount > 0; } 870 const FloatingObjectSet& set() const { return m_set; } 871 const FloatingObjectTree& placedFloatsTree() 872 { 873 computePlacedFloatsTreeIfNeeded(); 874 return m_placedFloatsTree; 875 } 817 FloatingObjectSet& set() { return m_set; } 818 876 819 private: 877 void computePlacedFloatsTree();878 inline void computePlacedFloatsTreeIfNeeded()879 {880 if (!m_placedFloatsTree.isInitialized())881 computePlacedFloatsTree();882 }883 void increaseObjectsCount(FloatingObject::Type);884 void decreaseObjectsCount(FloatingObject::Type);885 FloatingObjectInterval intervalForFloatingObject(FloatingObject*);886 887 820 FloatingObjectSet m_set; 888 FloatingObjectTree m_placedFloatsTree;889 821 unsigned m_leftObjectsCount; 890 822 unsigned m_rightObjectsCount; 891 823 unsigned m_positionedObjectsCount; 892 bool m_horizontalWritingMode;893 824 }; 894 825 OwnPtr<FloatingObjects> m_floatingObjects; … … 965 896 void toRenderBlock(const RenderBlock*); 966 897 967 #ifndef NDEBUG968 // These structures are used by PODIntervalTree for debugging purposes.969 template <> struct ValueToString<int> {970 static String string(const int value);971 };972 template<> struct ValueToString<RenderBlock::FloatingObject*> {973 static String string(const RenderBlock::FloatingObject*);974 };975 #endif976 977 898 } // namespace WebCore 978 899 -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r92610 r92626 1092 1092 1093 1093 if (m_floatingObjects && lastRootBox()) { 1094 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();1094 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 1095 1095 FloatingObjectSetIterator it = floatingObjectSet.begin(); 1096 1096 FloatingObjectSetIterator end = floatingObjectSet.end(); … … 1173 1173 } 1174 1174 1175 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();1175 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 1176 1176 FloatingObjectSetIterator it = floatingObjectSet.begin(); 1177 1177 FloatingObjectSetIterator end = floatingObjectSet.end(); … … 1492 1492 int logicalBottom = lastLine->blockLogicalHeight() + abs(delta); 1493 1493 1494 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();1494 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 1495 1495 FloatingObjectSetIterator end = floatingObjectSet.end(); 1496 1496 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { … … 1529 1529 int logicalBottom = lastLine->blockLogicalHeight() + abs(delta); 1530 1530 1531 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();1531 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 1532 1532 FloatingObjectSetIterator end = floatingObjectSet.end(); 1533 1533 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { … … 2551 2551 return true; 2552 2552 2553 constFloatingObjectSet& floatingObjectSet = m_floatingObjects->set();2553 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2554 2554 ASSERT(floatingObjectSet.last() == newFloat); 2555 2555 … … 2576 2576 toRenderBlock(o)->setChildNeedsLayout(true, false); 2577 2577 o->layoutIfNeeded(); 2578 m_floatingObjects->removePlacedObject(f);2579 2578 setLogicalTopForFloat(f, logicalTopForFloat(f) + f->m_paginationStrut); 2580 m_floatingObjects->addPlacedObject(f);2581 2579 } 2582 2580 }
Note: See TracChangeset
for help on using the changeset viewer.