| 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. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
| 6 * All rights reserved. | 6 * All rights reserved. |
| 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 241 } |
| 242 | 242 |
| 243 inline void FindNextFloatLogicalBottomAdapter::collectIfNeeded( | 243 inline void FindNextFloatLogicalBottomAdapter::collectIfNeeded( |
| 244 const IntervalType& interval) { | 244 const IntervalType& interval) { |
| 245 const FloatingObject& floatingObject = *(interval.data()); | 245 const FloatingObject& floatingObject = *(interval.data()); |
| 246 if (!rangesIntersect(interval.low(), interval.high(), m_belowLogicalHeight, | 246 if (!rangesIntersect(interval.low(), interval.high(), m_belowLogicalHeight, |
| 247 m_aboveLogicalHeight)) | 247 m_aboveLogicalHeight)) |
| 248 return; | 248 return; |
| 249 | 249 |
| 250 // All the objects returned from the tree should be already placed. | 250 // All the objects returned from the tree should be already placed. |
| 251 ASSERT(floatingObject.isPlaced()); | 251 DCHECK(floatingObject.isPlaced()); |
| 252 ASSERT(rangesIntersect(m_layoutObject.logicalTopForFloat(floatingObject), | 252 DCHECK(rangesIntersect(m_layoutObject.logicalTopForFloat(floatingObject), |
| 253 m_layoutObject.logicalBottomForFloat(floatingObject), | 253 m_layoutObject.logicalBottomForFloat(floatingObject), |
| 254 m_belowLogicalHeight, m_aboveLogicalHeight)); | 254 m_belowLogicalHeight, m_aboveLogicalHeight)); |
| 255 | 255 |
| 256 LayoutUnit floatBottom = m_layoutObject.logicalBottomForFloat(floatingObject); | 256 LayoutUnit floatBottom = m_layoutObject.logicalBottomForFloat(floatingObject); |
| 257 | 257 |
| 258 if (ShapeOutsideInfo* shapeOutside = | 258 if (ShapeOutsideInfo* shapeOutside = |
| 259 floatingObject.layoutObject()->shapeOutsideInfo()) { | 259 floatingObject.layoutObject()->shapeOutsideInfo()) { |
| 260 LayoutUnit shapeBottom = | 260 LayoutUnit shapeBottom = |
| 261 m_layoutObject.logicalTopForFloat(floatingObject) + | 261 m_layoutObject.logicalTopForFloat(floatingObject) + |
| 262 m_layoutObject.marginBeforeForChild(*floatingObject.layoutObject()) + | 262 m_layoutObject.marginBeforeForChild(*floatingObject.layoutObject()) + |
| (...skipping 29 matching lines...) Expand all Loading... |
| 292 placedFloatsTree().allOverlapsWithAdapter(adapter); | 292 placedFloatsTree().allOverlapsWithAdapter(adapter); |
| 293 | 293 |
| 294 return adapter.nextLogicalBottom(); | 294 return adapter.nextLogicalBottom(); |
| 295 } | 295 } |
| 296 | 296 |
| 297 FloatingObjects::~FloatingObjects() {} | 297 FloatingObjects::~FloatingObjects() {} |
| 298 void FloatingObjects::clearLineBoxTreePointers() { | 298 void FloatingObjects::clearLineBoxTreePointers() { |
| 299 // Clear references to originating lines, since the lines are being deleted | 299 // Clear references to originating lines, since the lines are being deleted |
| 300 FloatingObjectSetIterator end = m_set.end(); | 300 FloatingObjectSetIterator end = m_set.end(); |
| 301 for (FloatingObjectSetIterator it = m_set.begin(); it != end; ++it) { | 301 for (FloatingObjectSetIterator it = m_set.begin(); it != end; ++it) { |
| 302 ASSERT( | 302 DCHECK( |
| 303 !((*it)->originatingLine()) || | 303 !((*it)->originatingLine()) || |
| 304 (*it)->originatingLine()->getLineLayoutItem().isEqual(m_layoutObject)); | 304 (*it)->originatingLine()->getLineLayoutItem().isEqual(m_layoutObject)); |
| 305 (*it)->setOriginatingLine(nullptr); | 305 (*it)->setOriginatingLine(nullptr); |
| 306 } | 306 } |
| 307 } | 307 } |
| 308 | 308 |
| 309 FloatingObjects::FloatingObjects(const LayoutBlockFlow* layoutObject, | 309 FloatingObjects::FloatingObjects(const LayoutBlockFlow* layoutObject, |
| 310 bool horizontalWritingMode) | 310 bool horizontalWritingMode) |
| 311 : m_placedFloatsTree(UninitializedTree), | 311 : m_placedFloatsTree(UninitializedTree), |
| 312 m_leftObjectsCount(0), | 312 m_leftObjectsCount(0), |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 lowestFloatingObject); | 392 lowestFloatingObject); |
| 393 } | 393 } |
| 394 | 394 |
| 395 return lowestFloatBottom; | 395 return lowestFloatBottom; |
| 396 } | 396 } |
| 397 | 397 |
| 398 bool FloatingObjects::hasLowestFloatLogicalBottomCached( | 398 bool FloatingObjects::hasLowestFloatLogicalBottomCached( |
| 399 bool isHorizontal, | 399 bool isHorizontal, |
| 400 FloatingObject::Type type) const { | 400 FloatingObject::Type type) const { |
| 401 int floatIndex = static_cast<int>(type) - 1; | 401 int floatIndex = static_cast<int>(type) - 1; |
| 402 ASSERT(floatIndex < static_cast<int>(sizeof(m_lowestFloatBottomCache) / | 402 DCHECK_LT(floatIndex, static_cast<int>(sizeof(m_lowestFloatBottomCache) / |
| 403 sizeof(FloatBottomCachedValue))); | 403 sizeof(FloatBottomCachedValue))); |
| 404 ASSERT(floatIndex >= 0); | 404 DCHECK_GE(floatIndex, 0); |
| 405 return (m_cachedHorizontalWritingMode == isHorizontal && | 405 return (m_cachedHorizontalWritingMode == isHorizontal && |
| 406 !m_lowestFloatBottomCache[floatIndex].dirty); | 406 !m_lowestFloatBottomCache[floatIndex].dirty); |
| 407 } | 407 } |
| 408 | 408 |
| 409 LayoutUnit FloatingObjects::getCachedlowestFloatLogicalBottom( | 409 LayoutUnit FloatingObjects::getCachedlowestFloatLogicalBottom( |
| 410 FloatingObject::Type type) const { | 410 FloatingObject::Type type) const { |
| 411 int floatIndex = static_cast<int>(type) - 1; | 411 int floatIndex = static_cast<int>(type) - 1; |
| 412 ASSERT(floatIndex < static_cast<int>(sizeof(m_lowestFloatBottomCache) / | 412 DCHECK_LT(floatIndex, static_cast<int>(sizeof(m_lowestFloatBottomCache) / |
| 413 sizeof(FloatBottomCachedValue))); | 413 sizeof(FloatBottomCachedValue))); |
| 414 ASSERT(floatIndex >= 0); | 414 DCHECK_GE(floatIndex, 0); |
| 415 if (!m_lowestFloatBottomCache[floatIndex].floatingObject) | 415 if (!m_lowestFloatBottomCache[floatIndex].floatingObject) |
| 416 return LayoutUnit(); | 416 return LayoutUnit(); |
| 417 return m_layoutObject->logicalBottomForFloat( | 417 return m_layoutObject->logicalBottomForFloat( |
| 418 *m_lowestFloatBottomCache[floatIndex].floatingObject); | 418 *m_lowestFloatBottomCache[floatIndex].floatingObject); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void FloatingObjects::setCachedLowestFloatLogicalBottom( | 421 void FloatingObjects::setCachedLowestFloatLogicalBottom( |
| 422 bool isHorizontal, | 422 bool isHorizontal, |
| 423 FloatingObject::Type type, | 423 FloatingObject::Type type, |
| 424 FloatingObject* floatingObject) { | 424 FloatingObject* floatingObject) { |
| 425 int floatIndex = static_cast<int>(type) - 1; | 425 int floatIndex = static_cast<int>(type) - 1; |
| 426 ASSERT(floatIndex < static_cast<int>(sizeof(m_lowestFloatBottomCache) / | 426 DCHECK_LT(floatIndex, static_cast<int>(sizeof(m_lowestFloatBottomCache) / |
| 427 sizeof(FloatBottomCachedValue))); | 427 sizeof(FloatBottomCachedValue))); |
| 428 ASSERT(floatIndex >= 0); | 428 DCHECK_GE(floatIndex, 0); |
| 429 m_cachedHorizontalWritingMode = isHorizontal; | 429 m_cachedHorizontalWritingMode = isHorizontal; |
| 430 m_lowestFloatBottomCache[floatIndex].floatingObject = floatingObject; | 430 m_lowestFloatBottomCache[floatIndex].floatingObject = floatingObject; |
| 431 m_lowestFloatBottomCache[floatIndex].dirty = false; | 431 m_lowestFloatBottomCache[floatIndex].dirty = false; |
| 432 } | 432 } |
| 433 | 433 |
| 434 FloatingObject* FloatingObjects::lowestFloatingObject() const { | 434 FloatingObject* FloatingObjects::lowestFloatingObject() const { |
| 435 bool isInHorizontalWritingMode = m_horizontalWritingMode; | 435 bool isInHorizontalWritingMode = m_horizontalWritingMode; |
| 436 if (!hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode, | 436 if (!hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode, |
| 437 FloatingObject::FloatLeft) && | 437 FloatingObject::FloatLeft) && |
| 438 !hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode, | 438 !hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 if (m_horizontalWritingMode) | 490 if (m_horizontalWritingMode) |
| 491 return FloatingObjectInterval(floatingObject.frameRect().y(), | 491 return FloatingObjectInterval(floatingObject.frameRect().y(), |
| 492 floatingObject.frameRect().maxY(), | 492 floatingObject.frameRect().maxY(), |
| 493 &floatingObject); | 493 &floatingObject); |
| 494 return FloatingObjectInterval(floatingObject.frameRect().x(), | 494 return FloatingObjectInterval(floatingObject.frameRect().x(), |
| 495 floatingObject.frameRect().maxX(), | 495 floatingObject.frameRect().maxX(), |
| 496 &floatingObject); | 496 &floatingObject); |
| 497 } | 497 } |
| 498 | 498 |
| 499 void FloatingObjects::addPlacedObject(FloatingObject& floatingObject) { | 499 void FloatingObjects::addPlacedObject(FloatingObject& floatingObject) { |
| 500 ASSERT(!floatingObject.isInPlacedTree()); | 500 DCHECK(!floatingObject.isInPlacedTree()); |
| 501 | 501 |
| 502 floatingObject.setIsPlaced(true); | 502 floatingObject.setIsPlaced(true); |
| 503 if (m_placedFloatsTree.isInitialized()) | 503 if (m_placedFloatsTree.isInitialized()) |
| 504 m_placedFloatsTree.add(intervalForFloatingObject(floatingObject)); | 504 m_placedFloatsTree.add(intervalForFloatingObject(floatingObject)); |
| 505 | 505 |
| 506 #if DCHECK_IS_ON() | 506 #if DCHECK_IS_ON() |
| 507 floatingObject.setIsInPlacedTree(true); | 507 floatingObject.setIsInPlacedTree(true); |
| 508 #endif | 508 #endif |
| 509 markLowestFloatLogicalBottomCacheAsDirty(); | 509 markLowestFloatLogicalBottomCacheAsDirty(); |
| 510 } | 510 } |
| 511 | 511 |
| 512 void FloatingObjects::removePlacedObject(FloatingObject& floatingObject) { | 512 void FloatingObjects::removePlacedObject(FloatingObject& floatingObject) { |
| 513 ASSERT(floatingObject.isPlaced() && floatingObject.isInPlacedTree()); | 513 DCHECK(floatingObject.isPlaced()); |
| 514 DCHECK(floatingObject.isInPlacedTree()); |
| 514 | 515 |
| 515 if (m_placedFloatsTree.isInitialized()) { | 516 if (m_placedFloatsTree.isInitialized()) { |
| 516 bool removed = | 517 bool removed = |
| 517 m_placedFloatsTree.remove(intervalForFloatingObject(floatingObject)); | 518 m_placedFloatsTree.remove(intervalForFloatingObject(floatingObject)); |
| 518 DCHECK(removed); | 519 DCHECK(removed); |
| 519 } | 520 } |
| 520 | 521 |
| 521 floatingObject.setIsPlaced(false); | 522 floatingObject.setIsPlaced(false); |
| 522 #if DCHECK_IS_ON() | 523 #if DCHECK_IS_ON() |
| 523 floatingObject.setIsInPlacedTree(false); | 524 floatingObject.setIsInPlacedTree(false); |
| 524 #endif | 525 #endif |
| 525 markLowestFloatLogicalBottomCacheAsDirty(); | 526 markLowestFloatLogicalBottomCacheAsDirty(); |
| 526 } | 527 } |
| 527 | 528 |
| 528 FloatingObject* FloatingObjects::add( | 529 FloatingObject* FloatingObjects::add( |
| 529 std::unique_ptr<FloatingObject> floatingObject) { | 530 std::unique_ptr<FloatingObject> floatingObject) { |
| 530 FloatingObject* newObject = floatingObject.release(); | 531 FloatingObject* newObject = floatingObject.release(); |
| 531 increaseObjectsCount(newObject->getType()); | 532 increaseObjectsCount(newObject->getType()); |
| 532 m_set.insert(WTF::wrapUnique(newObject)); | 533 m_set.insert(WTF::wrapUnique(newObject)); |
| 533 if (newObject->isPlaced()) | 534 if (newObject->isPlaced()) |
| 534 addPlacedObject(*newObject); | 535 addPlacedObject(*newObject); |
| 535 markLowestFloatLogicalBottomCacheAsDirty(); | 536 markLowestFloatLogicalBottomCacheAsDirty(); |
| 536 return newObject; | 537 return newObject; |
| 537 } | 538 } |
| 538 | 539 |
| 539 void FloatingObjects::remove(FloatingObject* toBeRemoved) { | 540 void FloatingObjects::remove(FloatingObject* toBeRemoved) { |
| 540 decreaseObjectsCount(toBeRemoved->getType()); | 541 decreaseObjectsCount(toBeRemoved->getType()); |
| 541 std::unique_ptr<FloatingObject> floatingObject = m_set.take(toBeRemoved); | 542 std::unique_ptr<FloatingObject> floatingObject = m_set.take(toBeRemoved); |
| 542 ASSERT(floatingObject->isPlaced() || !floatingObject->isInPlacedTree()); | 543 DCHECK(floatingObject->isPlaced() || !floatingObject->isInPlacedTree()); |
| 543 if (floatingObject->isPlaced()) | 544 if (floatingObject->isPlaced()) |
| 544 removePlacedObject(*floatingObject); | 545 removePlacedObject(*floatingObject); |
| 545 markLowestFloatLogicalBottomCacheAsDirty(); | 546 markLowestFloatLogicalBottomCacheAsDirty(); |
| 546 ASSERT(!floatingObject->originatingLine()); | 547 DCHECK(!floatingObject->originatingLine()); |
| 547 } | 548 } |
| 548 | 549 |
| 549 void FloatingObjects::computePlacedFloatsTree() { | 550 void FloatingObjects::computePlacedFloatsTree() { |
| 550 ASSERT(!m_placedFloatsTree.isInitialized()); | 551 DCHECK(!m_placedFloatsTree.isInitialized()); |
| 551 if (m_set.isEmpty()) | 552 if (m_set.isEmpty()) |
| 552 return; | 553 return; |
| 553 m_placedFloatsTree.initIfNeeded(m_layoutObject->view()->intervalArena()); | 554 m_placedFloatsTree.initIfNeeded(m_layoutObject->view()->intervalArena()); |
| 554 FloatingObjectSetIterator it = m_set.begin(); | 555 FloatingObjectSetIterator it = m_set.begin(); |
| 555 FloatingObjectSetIterator end = m_set.end(); | 556 FloatingObjectSetIterator end = m_set.end(); |
| 556 for (; it != end; ++it) { | 557 for (; it != end; ++it) { |
| 557 FloatingObject& floatingObject = *it->get(); | 558 FloatingObject& floatingObject = *it->get(); |
| 558 if (floatingObject.isPlaced()) | 559 if (floatingObject.isPlaced()) |
| 559 m_placedFloatsTree.add(intervalForFloatingObject(floatingObject)); | 560 m_placedFloatsTree.add(intervalForFloatingObject(floatingObject)); |
| 560 } | 561 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 ComputeFloatOffsetAdapter<FloatTypeValue>::collectIfNeeded( | 651 ComputeFloatOffsetAdapter<FloatTypeValue>::collectIfNeeded( |
| 651 const IntervalType& interval) { | 652 const IntervalType& interval) { |
| 652 const FloatingObject& floatingObject = *(interval.data()); | 653 const FloatingObject& floatingObject = *(interval.data()); |
| 653 if (floatingObject.getType() != FloatTypeValue || | 654 if (floatingObject.getType() != FloatTypeValue || |
| 654 !rangesIntersect(interval.low(), interval.high(), m_lineTop, | 655 !rangesIntersect(interval.low(), interval.high(), m_lineTop, |
| 655 m_lineBottom)) | 656 m_lineBottom)) |
| 656 return; | 657 return; |
| 657 | 658 |
| 658 // Make sure the float hasn't changed since it was added to the placed floats | 659 // Make sure the float hasn't changed since it was added to the placed floats |
| 659 // tree. | 660 // tree. |
| 660 ASSERT(floatingObject.isPlaced()); | 661 DCHECK(floatingObject.isPlaced()); |
| 661 ASSERT(interval.low() == m_layoutObject->logicalTopForFloat(floatingObject)); | 662 DCHECK_EQ(interval.low(), m_layoutObject->logicalTopForFloat(floatingObject)); |
| 662 ASSERT(interval.high() == | 663 DCHECK_EQ(interval.high(), |
| 663 m_layoutObject->logicalBottomForFloat(floatingObject)); | 664 m_layoutObject->logicalBottomForFloat(floatingObject)); |
| 664 | 665 |
| 665 bool floatIsNewExtreme = updateOffsetIfNeeded(floatingObject); | 666 bool floatIsNewExtreme = updateOffsetIfNeeded(floatingObject); |
| 666 if (floatIsNewExtreme) | 667 if (floatIsNewExtreme) |
| 667 m_outermostFloat = &floatingObject; | 668 m_outermostFloat = &floatingObject; |
| 668 } | 669 } |
| 669 | 670 |
| 670 template <> | 671 template <> |
| 671 inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>:: | 672 inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>:: |
| 672 updateOffsetIfNeeded(const FloatingObject& floatingObject) { | 673 updateOffsetIfNeeded(const FloatingObject& floatingObject) { |
| 673 LayoutUnit logicalRight = | 674 LayoutUnit logicalRight = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 const FloatingObject* floatingObject) { | 725 const FloatingObject* floatingObject) { |
| 725 return String::format("%p (%gx%g %gx%g)", floatingObject, | 726 return String::format("%p (%gx%g %gx%g)", floatingObject, |
| 726 floatingObject->frameRect().x().toFloat(), | 727 floatingObject->frameRect().x().toFloat(), |
| 727 floatingObject->frameRect().y().toFloat(), | 728 floatingObject->frameRect().y().toFloat(), |
| 728 floatingObject->frameRect().maxX().toFloat(), | 729 floatingObject->frameRect().maxX().toFloat(), |
| 729 floatingObject->frameRect().maxY().toFloat()); | 730 floatingObject->frameRect().maxY().toFloat()); |
| 730 } | 731 } |
| 731 #endif | 732 #endif |
| 732 | 733 |
| 733 } // namespace blink | 734 } // namespace blink |
| OLD | NEW |