| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 virtual ~ComputeFloatOffsetAdapter() { } | 114 virtual ~ComputeFloatOffsetAdapter() { } |
| 115 | 115 |
| 116 int lowValue() const { return m_lineTop; } | 116 int lowValue() const { return m_lineTop; } |
| 117 int highValue() const { return m_lineBottom; } | 117 int highValue() const { return m_lineBottom; } |
| 118 void collectIfNeeded(const IntervalType&); | 118 void collectIfNeeded(const IntervalType&); |
| 119 | 119 |
| 120 LayoutUnit offset() const { return m_offset; } | 120 LayoutUnit offset() const { return m_offset; } |
| 121 | 121 |
| 122 protected: | 122 protected: |
| 123 virtual bool updateOffsetIfNeeded(const FloatingObject*) = 0; | 123 virtual bool updateOffsetIfNeeded(const FloatingObject&) = 0; |
| 124 | 124 |
| 125 const RenderBlockFlow* m_renderer; | 125 const RenderBlockFlow* m_renderer; |
| 126 int m_lineTop; | 126 int m_lineTop; |
| 127 int m_lineBottom; | 127 int m_lineBottom; |
| 128 LayoutUnit m_offset; | 128 LayoutUnit m_offset; |
| 129 const FloatingObject* m_outermostFloat; | 129 const FloatingObject* m_outermostFloat; |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 template <FloatingObject::Type FloatTypeValue> | 132 template <FloatingObject::Type FloatTypeValue> |
| 133 class ComputeFloatOffsetForFloatLayoutAdapter : public ComputeFloatOffsetAdapter
<FloatTypeValue> { | 133 class ComputeFloatOffsetForFloatLayoutAdapter : public ComputeFloatOffsetAdapter
<FloatTypeValue> { |
| 134 public: | 134 public: |
| 135 ComputeFloatOffsetForFloatLayoutAdapter(const RenderBlockFlow* renderer, Lay
outUnit lineTop, LayoutUnit lineBottom, LayoutUnit offset) | 135 ComputeFloatOffsetForFloatLayoutAdapter(const RenderBlockFlow* renderer, Lay
outUnit lineTop, LayoutUnit lineBottom, LayoutUnit offset) |
| 136 : ComputeFloatOffsetAdapter<FloatTypeValue>(renderer, lineTop, lineBotto
m, offset) | 136 : ComputeFloatOffsetAdapter<FloatTypeValue>(renderer, lineTop, lineBotto
m, offset) |
| 137 { | 137 { |
| 138 } | 138 } |
| 139 | 139 |
| 140 virtual ~ComputeFloatOffsetForFloatLayoutAdapter() { } | 140 virtual ~ComputeFloatOffsetForFloatLayoutAdapter() { } |
| 141 | 141 |
| 142 LayoutUnit heightRemaining() const; | 142 LayoutUnit heightRemaining() const; |
| 143 | 143 |
| 144 protected: | 144 protected: |
| 145 virtual bool updateOffsetIfNeeded(const FloatingObject*) OVERRIDE FINAL; | 145 virtual bool updateOffsetIfNeeded(const FloatingObject&) OVERRIDE FINAL; |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 template <FloatingObject::Type FloatTypeValue> | 148 template <FloatingObject::Type FloatTypeValue> |
| 149 class ComputeFloatOffsetForLineLayoutAdapter : public ComputeFloatOffsetAdapter<
FloatTypeValue> { | 149 class ComputeFloatOffsetForLineLayoutAdapter : public ComputeFloatOffsetAdapter<
FloatTypeValue> { |
| 150 public: | 150 public: |
| 151 ComputeFloatOffsetForLineLayoutAdapter(const RenderBlockFlow* renderer, Layo
utUnit lineTop, LayoutUnit lineBottom, LayoutUnit offset) | 151 ComputeFloatOffsetForLineLayoutAdapter(const RenderBlockFlow* renderer, Layo
utUnit lineTop, LayoutUnit lineBottom, LayoutUnit offset) |
| 152 : ComputeFloatOffsetAdapter<FloatTypeValue>(renderer, lineTop, lineBotto
m, offset) | 152 : ComputeFloatOffsetAdapter<FloatTypeValue>(renderer, lineTop, lineBotto
m, offset) |
| 153 { | 153 { |
| 154 } | 154 } |
| 155 | 155 |
| 156 virtual ~ComputeFloatOffsetForLineLayoutAdapter() { } | 156 virtual ~ComputeFloatOffsetForLineLayoutAdapter() { } |
| 157 | 157 |
| 158 protected: | 158 protected: |
| 159 virtual bool updateOffsetIfNeeded(const FloatingObject*) OVERRIDE FINAL; | 159 virtual bool updateOffsetIfNeeded(const FloatingObject&) OVERRIDE FINAL; |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 | 162 |
| 163 FloatingObjects::~FloatingObjects() | 163 FloatingObjects::~FloatingObjects() |
| 164 { | 164 { |
| 165 } | 165 } |
| 166 void FloatingObjects::clearLineBoxTreePointers() | 166 void FloatingObjects::clearLineBoxTreePointers() |
| 167 { | 167 { |
| 168 // Clear references to originating lines, since the lines are being deleted | 168 // Clear references to originating lines, since the lines are being deleted |
| 169 FloatingObjectSetIterator end = m_set.end(); | 169 FloatingObjectSetIterator end = m_set.end(); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 return true; | 429 return true; |
| 430 | 430 |
| 431 // The bottom of the object overlaps the float | 431 // The bottom of the object overlaps the float |
| 432 if (objectBottom > objectTop && objectBottom > floatTop && objectBottom <= f
loatBottom) | 432 if (objectBottom > objectTop && objectBottom > floatTop && objectBottom <= f
loatBottom) |
| 433 return true; | 433 return true; |
| 434 | 434 |
| 435 return false; | 435 return false; |
| 436 } | 436 } |
| 437 | 437 |
| 438 template<> | 438 template<> |
| 439 inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft>::
updateOffsetIfNeeded(const FloatingObject* floatingObject) | 439 inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft>::
updateOffsetIfNeeded(const FloatingObject& floatingObject) |
| 440 { | 440 { |
| 441 LayoutUnit logicalRight = m_renderer->logicalRightForFloat(floatingObject); | 441 LayoutUnit logicalRight = m_renderer->logicalRightForFloat(&floatingObject); |
| 442 if (logicalRight > m_offset) { | 442 if (logicalRight > m_offset) { |
| 443 m_offset = logicalRight; | 443 m_offset = logicalRight; |
| 444 return true; | 444 return true; |
| 445 } | 445 } |
| 446 return false; | 446 return false; |
| 447 } | 447 } |
| 448 | 448 |
| 449 template<> | 449 template<> |
| 450 inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatRight>:
:updateOffsetIfNeeded(const FloatingObject* floatingObject) | 450 inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatRight>:
:updateOffsetIfNeeded(const FloatingObject& floatingObject) |
| 451 { | 451 { |
| 452 LayoutUnit logicalLeft = m_renderer->logicalLeftForFloat(floatingObject); | 452 LayoutUnit logicalLeft = m_renderer->logicalLeftForFloat(&floatingObject); |
| 453 if (logicalLeft < m_offset) { | 453 if (logicalLeft < m_offset) { |
| 454 m_offset = logicalLeft; | 454 m_offset = logicalLeft; |
| 455 return true; | 455 return true; |
| 456 } | 456 } |
| 457 return false; | 457 return false; |
| 458 } | 458 } |
| 459 | 459 |
| 460 template <FloatingObject::Type FloatTypeValue> | 460 template <FloatingObject::Type FloatTypeValue> |
| 461 LayoutUnit ComputeFloatOffsetForFloatLayoutAdapter<FloatTypeValue>::heightRemain
ing() const | 461 LayoutUnit ComputeFloatOffsetForFloatLayoutAdapter<FloatTypeValue>::heightRemain
ing() const |
| 462 { | 462 { |
| 463 return this->m_outermostFloat ? this->m_renderer->logicalBottomForFloat(this
->m_outermostFloat) - this->m_lineTop : LayoutUnit(1); | 463 return this->m_outermostFloat ? this->m_renderer->logicalBottomForFloat(this
->m_outermostFloat) - this->m_lineTop : LayoutUnit(1); |
| 464 } | 464 } |
| 465 | 465 |
| 466 template <FloatingObject::Type FloatTypeValue> | 466 template <FloatingObject::Type FloatTypeValue> |
| 467 inline void ComputeFloatOffsetAdapter<FloatTypeValue>::collectIfNeeded(const Int
ervalType& interval) | 467 inline void ComputeFloatOffsetAdapter<FloatTypeValue>::collectIfNeeded(const Int
ervalType& interval) |
| 468 { | 468 { |
| 469 const FloatingObject* floatingObject = interval.data(); | 469 const FloatingObject* floatingObject = interval.data(); |
| 470 if (floatingObject->type() != FloatTypeValue || !rangesIntersect(interval.lo
w(), interval.high(), m_lineTop, m_lineBottom)) | 470 if (floatingObject->type() != FloatTypeValue || !rangesIntersect(interval.lo
w(), interval.high(), m_lineTop, m_lineBottom)) |
| 471 return; | 471 return; |
| 472 | 472 |
| 473 // Make sure the float hasn't changed since it was added to the placed float
s tree. | 473 // Make sure the float hasn't changed since it was added to the placed float
s tree. |
| 474 ASSERT(floatingObject->isPlaced()); | 474 ASSERT(floatingObject->isPlaced()); |
| 475 ASSERT(interval.low() == m_renderer->pixelSnappedLogicalTopForFloat(floating
Object)); | 475 ASSERT(interval.low() == m_renderer->pixelSnappedLogicalTopForFloat(floating
Object)); |
| 476 ASSERT(interval.high() == m_renderer->pixelSnappedLogicalBottomForFloat(floa
tingObject)); | 476 ASSERT(interval.high() == m_renderer->pixelSnappedLogicalBottomForFloat(floa
tingObject)); |
| 477 | 477 |
| 478 bool floatIsNewExtreme = updateOffsetIfNeeded(floatingObject); | 478 bool floatIsNewExtreme = updateOffsetIfNeeded(*floatingObject); |
| 479 if (floatIsNewExtreme) | 479 if (floatIsNewExtreme) |
| 480 m_outermostFloat = floatingObject; | 480 m_outermostFloat = floatingObject; |
| 481 } | 481 } |
| 482 | 482 |
| 483 static inline ShapeOutsideInfo* shapeInfoForFloat(const FloatingObject& floating
Object, const RenderBlockFlow& containingBlock, LayoutUnit lineTop, LayoutUnit l
ineBottom) | 483 template<> |
| 484 inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>::u
pdateOffsetIfNeeded(const FloatingObject& floatingObject) |
| 484 { | 485 { |
| 486 LayoutUnit logicalRight = m_renderer->logicalRightForFloat(&floatingObject); |
| 485 if (ShapeOutsideInfo* shapeOutside = floatingObject.renderer()->shapeOutside
Info()) { | 487 if (ShapeOutsideInfo* shapeOutside = floatingObject.renderer()->shapeOutside
Info()) { |
| 486 shapeOutside->updateDeltasForContainingBlockLine(containingBlock, floati
ngObject, lineTop, lineBottom - lineTop); | 488 ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainin
gBlockLine(*m_renderer, floatingObject, m_lineTop, m_lineBottom - m_lineTop); |
| 487 return shapeOutside; | 489 if (!shapeDeltas.lineOverlapsShape()) |
| 488 } | |
| 489 | |
| 490 return 0; | |
| 491 } | |
| 492 | |
| 493 template<> | |
| 494 inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>::u
pdateOffsetIfNeeded(const FloatingObject* floatingObject) | |
| 495 { | |
| 496 ASSERT(floatingObject); | |
| 497 LayoutUnit logicalRight = m_renderer->logicalRightForFloat(floatingObject); | |
| 498 if (ShapeOutsideInfo* shapeOutside = shapeInfoForFloat(*floatingObject, *m_r
enderer, m_lineTop, m_lineBottom)) { | |
| 499 if (!shapeOutside->lineOverlapsShape()) | |
| 500 return false; | 490 return false; |
| 501 | 491 |
| 502 logicalRight += shapeOutside->rightMarginBoxDelta(); | 492 logicalRight += shapeDeltas.rightMarginBoxDelta(); |
| 503 } | 493 } |
| 504 if (logicalRight > m_offset) { | 494 if (logicalRight > m_offset) { |
| 505 m_offset = logicalRight; | 495 m_offset = logicalRight; |
| 506 return true; | 496 return true; |
| 507 } | 497 } |
| 508 | 498 |
| 509 return false; | 499 return false; |
| 510 } | 500 } |
| 511 | 501 |
| 512 template<> | 502 template<> |
| 513 inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatRight>::
updateOffsetIfNeeded(const FloatingObject* floatingObject) | 503 inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatRight>::
updateOffsetIfNeeded(const FloatingObject& floatingObject) |
| 514 { | 504 { |
| 515 ASSERT(floatingObject); | 505 LayoutUnit logicalLeft = m_renderer->logicalLeftForFloat(&floatingObject); |
| 516 LayoutUnit logicalLeft = m_renderer->logicalLeftForFloat(floatingObject); | 506 if (ShapeOutsideInfo* shapeOutside = floatingObject.renderer()->shapeOutside
Info()) { |
| 517 if (ShapeOutsideInfo* shapeOutside = shapeInfoForFloat(*floatingObject, *m_r
enderer, m_lineTop, m_lineBottom)) { | 507 ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainin
gBlockLine(*m_renderer, floatingObject, m_lineTop, m_lineBottom - m_lineTop); |
| 518 if (!shapeOutside->lineOverlapsShape()) | 508 if (!shapeDeltas.lineOverlapsShape()) |
| 519 return false; | 509 return false; |
| 520 | 510 |
| 521 logicalLeft += shapeOutside->leftMarginBoxDelta(); | 511 logicalLeft += shapeDeltas.leftMarginBoxDelta(); |
| 522 } | 512 } |
| 523 if (logicalLeft < m_offset) { | 513 if (logicalLeft < m_offset) { |
| 524 m_offset = logicalLeft; | 514 m_offset = logicalLeft; |
| 525 return true; | 515 return true; |
| 526 } | 516 } |
| 527 | 517 |
| 528 return false; | 518 return false; |
| 529 } | 519 } |
| 530 | 520 |
| 531 #ifndef NDEBUG | 521 #ifndef NDEBUG |
| 532 // These helpers are only used by the PODIntervalTree for debugging purposes. | 522 // These helpers are only used by the PODIntervalTree for debugging purposes. |
| 533 String ValueToString<int>::string(const int value) | 523 String ValueToString<int>::string(const int value) |
| 534 { | 524 { |
| 535 return String::number(value); | 525 return String::number(value); |
| 536 } | 526 } |
| 537 | 527 |
| 538 String ValueToString<FloatingObject*>::string(const FloatingObject* floatingObje
ct) | 528 String ValueToString<FloatingObject*>::string(const FloatingObject* floatingObje
ct) |
| 539 { | 529 { |
| 540 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr
ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating
Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped
MaxY()); | 530 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr
ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating
Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped
MaxY()); |
| 541 } | 531 } |
| 542 #endif | 532 #endif |
| 543 | 533 |
| 544 | 534 |
| 545 } // namespace blink | 535 } // namespace blink |
| OLD | NEW |