| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 { | 83 { |
| 84 OwnPtr<FloatingObject> newObj = adoptPtr(new FloatingObject(layoutObject)); | 84 OwnPtr<FloatingObject> newObj = adoptPtr(new FloatingObject(layoutObject)); |
| 85 newObj->setShouldPaint(!layoutObject->hasSelfPaintingLayer()); // If a layer
exists, the float will paint itself. Otherwise someone else will. | 85 newObj->setShouldPaint(!layoutObject->hasSelfPaintingLayer()); // If a layer
exists, the float will paint itself. Otherwise someone else will. |
| 86 newObj->setIsDescendant(true); | 86 newObj->setIsDescendant(true); |
| 87 | 87 |
| 88 return newObj.release(); | 88 return newObj.release(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 PassOwnPtr<FloatingObject> FloatingObject::copyToNewContainer(LayoutSize offset,
bool shouldPaint, bool isDescendant) const | 91 PassOwnPtr<FloatingObject> FloatingObject::copyToNewContainer(LayoutSize offset,
bool shouldPaint, bool isDescendant) const |
| 92 { | 92 { |
| 93 return adoptPtr(new FloatingObject(layoutObject(), type(), LayoutRect(frameR
ect().location() - offset, frameRect().size()), shouldPaint, isDescendant, isLow
estNonOverhangingFloatInChild())); | 93 return adoptPtr(new FloatingObject(layoutObject(), getType(), LayoutRect(fra
meRect().location() - offset, frameRect().size()), shouldPaint, isDescendant, is
LowestNonOverhangingFloatInChild())); |
| 94 } | 94 } |
| 95 | 95 |
| 96 PassOwnPtr<FloatingObject> FloatingObject::unsafeClone() const | 96 PassOwnPtr<FloatingObject> FloatingObject::unsafeClone() const |
| 97 { | 97 { |
| 98 OwnPtr<FloatingObject> cloneObject = adoptPtr(new FloatingObject(layoutObjec
t(), type(), m_frameRect, m_shouldPaint, m_isDescendant, false)); | 98 OwnPtr<FloatingObject> cloneObject = adoptPtr(new FloatingObject(layoutObjec
t(), getType(), m_frameRect, m_shouldPaint, m_isDescendant, false)); |
| 99 cloneObject->m_paginationStrut = m_paginationStrut; | 99 cloneObject->m_paginationStrut = m_paginationStrut; |
| 100 cloneObject->m_isPlaced = m_isPlaced; | 100 cloneObject->m_isPlaced = m_isPlaced; |
| 101 return cloneObject.release(); | 101 return cloneObject.release(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 template <FloatingObject::Type FloatTypeValue> | 104 template <FloatingObject::Type FloatTypeValue> |
| 105 class ComputeFloatOffsetAdapter { | 105 class ComputeFloatOffsetAdapter { |
| 106 public: | 106 public: |
| 107 typedef FloatingObjectInterval IntervalType; | 107 typedef FloatingObjectInterval IntervalType; |
| 108 | 108 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 } | 251 } |
| 252 | 252 |
| 253 FloatingObjects::~FloatingObjects() | 253 FloatingObjects::~FloatingObjects() |
| 254 { | 254 { |
| 255 } | 255 } |
| 256 void FloatingObjects::clearLineBoxTreePointers() | 256 void FloatingObjects::clearLineBoxTreePointers() |
| 257 { | 257 { |
| 258 // Clear references to originating lines, since the lines are being deleted | 258 // Clear references to originating lines, since the lines are being deleted |
| 259 FloatingObjectSetIterator end = m_set.end(); | 259 FloatingObjectSetIterator end = m_set.end(); |
| 260 for (FloatingObjectSetIterator it = m_set.begin(); it != end; ++it) { | 260 for (FloatingObjectSetIterator it = m_set.begin(); it != end; ++it) { |
| 261 ASSERT(!((*it)->originatingLine()) || (*it)->originatingLine()->lineLayo
utItem().isEqual(m_layoutObject)); | 261 ASSERT(!((*it)->originatingLine()) || (*it)->originatingLine()->getLineL
ayoutItem().isEqual(m_layoutObject)); |
| 262 (*it)->setOriginatingLine(nullptr); | 262 (*it)->setOriginatingLine(nullptr); |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 | 265 |
| 266 FloatingObjects::FloatingObjects(const LayoutBlockFlow* layoutObject, bool horiz
ontalWritingMode) | 266 FloatingObjects::FloatingObjects(const LayoutBlockFlow* layoutObject, bool horiz
ontalWritingMode) |
| 267 : m_placedFloatsTree(UninitializedTree) | 267 : m_placedFloatsTree(UninitializedTree) |
| 268 , m_leftObjectsCount(0) | 268 , m_leftObjectsCount(0) |
| 269 , m_rightObjectsCount(0) | 269 , m_rightObjectsCount(0) |
| 270 , m_horizontalWritingMode(horizontalWritingMode) | 270 , m_horizontalWritingMode(horizontalWritingMode) |
| 271 , m_layoutObject(layoutObject) | 271 , m_layoutObject(layoutObject) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 299 const FloatingObjectSet& floatingObjectSet = set(); | 299 const FloatingObjectSet& floatingObjectSet = set(); |
| 300 FloatingObjectSetIterator end = floatingObjectSet.end(); | 300 FloatingObjectSetIterator end = floatingObjectSet.end(); |
| 301 if (floatType == FloatingObject::FloatLeftRight) { | 301 if (floatType == FloatingObject::FloatLeftRight) { |
| 302 FloatingObject* lowestFloatingObjectLeft = nullptr; | 302 FloatingObject* lowestFloatingObjectLeft = nullptr; |
| 303 FloatingObject* lowestFloatingObjectRight = nullptr; | 303 FloatingObject* lowestFloatingObjectRight = nullptr; |
| 304 LayoutUnit lowestFloatBottomLeft; | 304 LayoutUnit lowestFloatBottomLeft; |
| 305 LayoutUnit lowestFloatBottomRight; | 305 LayoutUnit lowestFloatBottomRight; |
| 306 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end
; ++it) { | 306 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end
; ++it) { |
| 307 FloatingObject& floatingObject = *it->get(); | 307 FloatingObject& floatingObject = *it->get(); |
| 308 if (floatingObject.isPlaced()) { | 308 if (floatingObject.isPlaced()) { |
| 309 FloatingObject::Type curType = floatingObject.type(); | 309 FloatingObject::Type curType = floatingObject.getType(); |
| 310 LayoutUnit curFloatLogicalBottom = m_layoutObject->logicalBottom
ForFloat(floatingObject); | 310 LayoutUnit curFloatLogicalBottom = m_layoutObject->logicalBottom
ForFloat(floatingObject); |
| 311 if (curType & FloatingObject::FloatLeft && curFloatLogicalBottom
> lowestFloatBottomLeft) { | 311 if (curType & FloatingObject::FloatLeft && curFloatLogicalBottom
> lowestFloatBottomLeft) { |
| 312 lowestFloatBottomLeft = curFloatLogicalBottom; | 312 lowestFloatBottomLeft = curFloatLogicalBottom; |
| 313 lowestFloatingObjectLeft = &floatingObject; | 313 lowestFloatingObjectLeft = &floatingObject; |
| 314 } | 314 } |
| 315 if (curType & FloatingObject::FloatRight && curFloatLogicalBotto
m > lowestFloatBottomRight) { | 315 if (curType & FloatingObject::FloatRight && curFloatLogicalBotto
m > lowestFloatBottomRight) { |
| 316 lowestFloatBottomRight = curFloatLogicalBottom; | 316 lowestFloatBottomRight = curFloatLogicalBottom; |
| 317 lowestFloatingObjectRight = &floatingObject; | 317 lowestFloatingObjectRight = &floatingObject; |
| 318 } | 318 } |
| 319 } | 319 } |
| 320 } | 320 } |
| 321 lowestFloatBottom = std::max(lowestFloatBottomLeft, lowestFloatBottomRig
ht); | 321 lowestFloatBottom = std::max(lowestFloatBottomLeft, lowestFloatBottomRig
ht); |
| 322 setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, FloatingObj
ect::FloatLeft, lowestFloatingObjectLeft); | 322 setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, FloatingObj
ect::FloatLeft, lowestFloatingObjectLeft); |
| 323 setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, FloatingObj
ect::FloatRight, lowestFloatingObjectRight); | 323 setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, FloatingObj
ect::FloatRight, lowestFloatingObjectRight); |
| 324 } else { | 324 } else { |
| 325 FloatingObject* lowestFloatingObject = nullptr; | 325 FloatingObject* lowestFloatingObject = nullptr; |
| 326 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end
; ++it) { | 326 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end
; ++it) { |
| 327 FloatingObject& floatingObject = *it->get(); | 327 FloatingObject& floatingObject = *it->get(); |
| 328 if (floatingObject.isPlaced() && floatingObject.type() == floatType)
{ | 328 if (floatingObject.isPlaced() && floatingObject.getType() == floatTy
pe) { |
| 329 if (m_layoutObject->logicalBottomForFloat(floatingObject) > lowe
stFloatBottom) { | 329 if (m_layoutObject->logicalBottomForFloat(floatingObject) > lowe
stFloatBottom) { |
| 330 lowestFloatingObject = &floatingObject; | 330 lowestFloatingObject = &floatingObject; |
| 331 lowestFloatBottom = m_layoutObject->logicalBottomForFloat(fl
oatingObject); | 331 lowestFloatBottom = m_layoutObject->logicalBottomForFloat(fl
oatingObject); |
| 332 } | 332 } |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, floatType,
lowestFloatingObject); | 335 setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, floatType,
lowestFloatingObject); |
| 336 } | 336 } |
| 337 | 337 |
| 338 return lowestFloatBottom; | 338 return lowestFloatBottom; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 floatingObject.setIsPlaced(false); | 446 floatingObject.setIsPlaced(false); |
| 447 #if ENABLE(ASSERT) | 447 #if ENABLE(ASSERT) |
| 448 floatingObject.setIsInPlacedTree(false); | 448 floatingObject.setIsInPlacedTree(false); |
| 449 #endif | 449 #endif |
| 450 markLowestFloatLogicalBottomCacheAsDirty(); | 450 markLowestFloatLogicalBottomCacheAsDirty(); |
| 451 } | 451 } |
| 452 | 452 |
| 453 FloatingObject* FloatingObjects::add(PassOwnPtr<FloatingObject> floatingObject) | 453 FloatingObject* FloatingObjects::add(PassOwnPtr<FloatingObject> floatingObject) |
| 454 { | 454 { |
| 455 FloatingObject* newObject = floatingObject.leakPtr(); | 455 FloatingObject* newObject = floatingObject.leakPtr(); |
| 456 increaseObjectsCount(newObject->type()); | 456 increaseObjectsCount(newObject->getType()); |
| 457 m_set.add(adoptPtr(newObject)); | 457 m_set.add(adoptPtr(newObject)); |
| 458 if (newObject->isPlaced()) | 458 if (newObject->isPlaced()) |
| 459 addPlacedObject(*newObject); | 459 addPlacedObject(*newObject); |
| 460 markLowestFloatLogicalBottomCacheAsDirty(); | 460 markLowestFloatLogicalBottomCacheAsDirty(); |
| 461 return newObject; | 461 return newObject; |
| 462 } | 462 } |
| 463 | 463 |
| 464 void FloatingObjects::remove(FloatingObject* toBeRemoved) | 464 void FloatingObjects::remove(FloatingObject* toBeRemoved) |
| 465 { | 465 { |
| 466 decreaseObjectsCount(toBeRemoved->type()); | 466 decreaseObjectsCount(toBeRemoved->getType()); |
| 467 OwnPtr<FloatingObject> floatingObject = m_set.take(toBeRemoved); | 467 OwnPtr<FloatingObject> floatingObject = m_set.take(toBeRemoved); |
| 468 ASSERT(floatingObject->isPlaced() || !floatingObject->isInPlacedTree()); | 468 ASSERT(floatingObject->isPlaced() || !floatingObject->isInPlacedTree()); |
| 469 if (floatingObject->isPlaced()) | 469 if (floatingObject->isPlaced()) |
| 470 removePlacedObject(*floatingObject); | 470 removePlacedObject(*floatingObject); |
| 471 markLowestFloatLogicalBottomCacheAsDirty(); | 471 markLowestFloatLogicalBottomCacheAsDirty(); |
| 472 ASSERT(!floatingObject->originatingLine()); | 472 ASSERT(!floatingObject->originatingLine()); |
| 473 } | 473 } |
| 474 | 474 |
| 475 void FloatingObjects::computePlacedFloatsTree() | 475 void FloatingObjects::computePlacedFloatsTree() |
| 476 { | 476 { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 template <FloatingObject::Type FloatTypeValue> | 556 template <FloatingObject::Type FloatTypeValue> |
| 557 LayoutUnit ComputeFloatOffsetForFloatLayoutAdapter<FloatTypeValue>::heightRemain
ing() const | 557 LayoutUnit ComputeFloatOffsetForFloatLayoutAdapter<FloatTypeValue>::heightRemain
ing() const |
| 558 { | 558 { |
| 559 return this->m_outermostFloat ? this->m_layoutObject->logicalBottomForFloat(
*this->m_outermostFloat) - this->m_lineTop : LayoutUnit(1); | 559 return this->m_outermostFloat ? this->m_layoutObject->logicalBottomForFloat(
*this->m_outermostFloat) - this->m_lineTop : LayoutUnit(1); |
| 560 } | 560 } |
| 561 | 561 |
| 562 template <FloatingObject::Type FloatTypeValue> | 562 template <FloatingObject::Type FloatTypeValue> |
| 563 inline void ComputeFloatOffsetAdapter<FloatTypeValue>::collectIfNeeded(const Int
ervalType& interval) | 563 inline void ComputeFloatOffsetAdapter<FloatTypeValue>::collectIfNeeded(const Int
ervalType& interval) |
| 564 { | 564 { |
| 565 const FloatingObject& floatingObject = *(interval.data()); | 565 const FloatingObject& floatingObject = *(interval.data()); |
| 566 if (floatingObject.type() != FloatTypeValue || !rangesIntersect(interval.low
(), interval.high(), m_lineTop, m_lineBottom)) | 566 if (floatingObject.getType() != FloatTypeValue || !rangesIntersect(interval.
low(), interval.high(), m_lineTop, m_lineBottom)) |
| 567 return; | 567 return; |
| 568 | 568 |
| 569 // Make sure the float hasn't changed since it was added to the placed float
s tree. | 569 // Make sure the float hasn't changed since it was added to the placed float
s tree. |
| 570 ASSERT(floatingObject.isPlaced()); | 570 ASSERT(floatingObject.isPlaced()); |
| 571 ASSERT(interval.low() == m_layoutObject->logicalTopForFloat(floatingObject))
; | 571 ASSERT(interval.low() == m_layoutObject->logicalTopForFloat(floatingObject))
; |
| 572 ASSERT(interval.high() == m_layoutObject->logicalBottomForFloat(floatingObje
ct)); | 572 ASSERT(interval.high() == m_layoutObject->logicalBottomForFloat(floatingObje
ct)); |
| 573 | 573 |
| 574 bool floatIsNewExtreme = updateOffsetIfNeeded(floatingObject); | 574 bool floatIsNewExtreme = updateOffsetIfNeeded(floatingObject); |
| 575 if (floatIsNewExtreme) | 575 if (floatIsNewExtreme) |
| 576 m_outermostFloat = &floatingObject; | 576 m_outermostFloat = &floatingObject; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 } | 622 } |
| 623 | 623 |
| 624 String ValueToString<FloatingObject*>::toString(const FloatingObject* floatingOb
ject) | 624 String ValueToString<FloatingObject*>::toString(const FloatingObject* floatingOb
ject) |
| 625 { | 625 { |
| 626 return String::format("%p (%gx%g %gx%g)", floatingObject, floatingObject->fr
ameRect().x().toFloat(), floatingObject->frameRect().y().toFloat(), floatingObje
ct->frameRect().maxX().toFloat(), floatingObject->frameRect().maxY().toFloat()); | 626 return String::format("%p (%gx%g %gx%g)", floatingObject, floatingObject->fr
ameRect().x().toFloat(), floatingObject->frameRect().y().toFloat(), floatingObje
ct->frameRect().maxX().toFloat(), floatingObject->frameRect().maxY().toFloat()); |
| 627 } | 627 } |
| 628 #endif | 628 #endif |
| 629 | 629 |
| 630 | 630 |
| 631 } // namespace blink | 631 } // namespace blink |
| OLD | NEW |