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 11 matching lines...) Expand all Loading... |
22 */ | 22 */ |
23 | 23 |
24 #include "core/layout/FloatingObjects.h" | 24 #include "core/layout/FloatingObjects.h" |
25 | 25 |
26 #include "core/layout/LayoutBlockFlow.h" | 26 #include "core/layout/LayoutBlockFlow.h" |
27 #include "core/layout/LayoutBox.h" | 27 #include "core/layout/LayoutBox.h" |
28 #include "core/layout/LayoutView.h" | 28 #include "core/layout/LayoutView.h" |
29 #include "core/layout/shapes/ShapeOutsideInfo.h" | 29 #include "core/layout/shapes/ShapeOutsideInfo.h" |
30 #include "core/paint/PaintLayer.h" | 30 #include "core/paint/PaintLayer.h" |
31 #include "platform/RuntimeEnabledFeatures.h" | 31 #include "platform/RuntimeEnabledFeatures.h" |
32 #include "wtf/PtrUtil.h" | 32 |
33 #include <algorithm> | 33 #include <algorithm> |
34 #include <memory> | |
35 | 34 |
36 using namespace WTF; | 35 using namespace WTF; |
37 | 36 |
38 namespace blink { | 37 namespace blink { |
39 | 38 |
40 struct SameSizeAsFloatingObject { | 39 struct SameSizeAsFloatingObject { |
41 void* pointers[2]; | 40 void* pointers[2]; |
42 LayoutRect rect; | 41 LayoutRect rect; |
43 uint32_t bitfields : 8; | 42 uint32_t bitfields : 8; |
44 }; | 43 }; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 bool FloatingObject::shouldPaintForCompositedLayoutPart() | 81 bool FloatingObject::shouldPaintForCompositedLayoutPart() |
83 { | 82 { |
84 // HACK: only non-self-painting floats should paint. However, due to the fun
damental compositing bug, some LayoutPart objects | 83 // HACK: only non-self-painting floats should paint. However, due to the fun
damental compositing bug, some LayoutPart objects |
85 // may become self-painting due to being composited. This leads to a chicken
-egg issue because layout may not depend on compositing. | 84 // may become self-painting due to being composited. This leads to a chicken
-egg issue because layout may not depend on compositing. |
86 // If this is the case, set shouldPaint() to true even if the layer is techn
ically self-painting. This lets the float which contains | 85 // If this is the case, set shouldPaint() to true even if the layer is techn
ically self-painting. This lets the float which contains |
87 // a LayoutPart start painting as soon as it stops being composited, without
having to re-layout the float. | 86 // a LayoutPart start painting as soon as it stops being composited, without
having to re-layout the float. |
88 // This hack can be removed after SPv2. | 87 // This hack can be removed after SPv2. |
89 return m_layoutObject->layer() && m_layoutObject->layer()->isSelfPaintingOnl
yBecauseIsCompositedPart() && !RuntimeEnabledFeatures::slimmingPaintV2Enabled(); | 88 return m_layoutObject->layer() && m_layoutObject->layer()->isSelfPaintingOnl
yBecauseIsCompositedPart() && !RuntimeEnabledFeatures::slimmingPaintV2Enabled(); |
90 } | 89 } |
91 | 90 |
92 std::unique_ptr<FloatingObject> FloatingObject::create(LayoutBox* layoutObject) | 91 PassOwnPtr<FloatingObject> FloatingObject::create(LayoutBox* layoutObject) |
93 { | 92 { |
94 std::unique_ptr<FloatingObject> newObj = wrapUnique(new FloatingObject(layou
tObject)); | 93 OwnPtr<FloatingObject> newObj = adoptPtr(new FloatingObject(layoutObject)); |
95 | 94 |
96 // If a layer exists, the float will paint itself. Otherwise someone else wi
ll. | 95 // If a layer exists, the float will paint itself. Otherwise someone else wi
ll. |
97 newObj->setShouldPaint(!layoutObject->hasSelfPaintingLayer() || newObj->shou
ldPaintForCompositedLayoutPart()); | 96 newObj->setShouldPaint(!layoutObject->hasSelfPaintingLayer() || newObj->shou
ldPaintForCompositedLayoutPart()); |
98 | 97 |
99 newObj->setIsDescendant(true); | 98 newObj->setIsDescendant(true); |
100 | 99 |
101 return newObj; | 100 return newObj; |
102 } | 101 } |
103 | 102 |
104 bool FloatingObject::shouldPaint() const | 103 bool FloatingObject::shouldPaint() const |
105 { | 104 { |
106 return m_shouldPaint && !m_layoutObject->hasSelfPaintingLayer(); | 105 return m_shouldPaint && !m_layoutObject->hasSelfPaintingLayer(); |
107 } | 106 } |
108 | 107 |
109 std::unique_ptr<FloatingObject> FloatingObject::copyToNewContainer(LayoutSize of
fset, bool shouldPaint, bool isDescendant) const | 108 PassOwnPtr<FloatingObject> FloatingObject::copyToNewContainer(LayoutSize offset,
bool shouldPaint, bool isDescendant) const |
110 { | 109 { |
111 return wrapUnique(new FloatingObject(layoutObject(), getType(), LayoutRect(f
rameRect().location() - offset, frameRect().size()), shouldPaint, isDescendant,
isLowestNonOverhangingFloatInChild())); | 110 return adoptPtr(new FloatingObject(layoutObject(), getType(), LayoutRect(fra
meRect().location() - offset, frameRect().size()), shouldPaint, isDescendant, is
LowestNonOverhangingFloatInChild())); |
112 } | 111 } |
113 | 112 |
114 std::unique_ptr<FloatingObject> FloatingObject::unsafeClone() const | 113 PassOwnPtr<FloatingObject> FloatingObject::unsafeClone() const |
115 { | 114 { |
116 std::unique_ptr<FloatingObject> cloneObject = wrapUnique(new FloatingObject(
layoutObject(), getType(), m_frameRect, m_shouldPaint, m_isDescendant, false)); | 115 OwnPtr<FloatingObject> cloneObject = adoptPtr(new FloatingObject(layoutObjec
t(), getType(), m_frameRect, m_shouldPaint, m_isDescendant, false)); |
117 cloneObject->m_isPlaced = m_isPlaced; | 116 cloneObject->m_isPlaced = m_isPlaced; |
118 return cloneObject; | 117 return cloneObject; |
119 } | 118 } |
120 | 119 |
121 template <FloatingObject::Type FloatTypeValue> | 120 template <FloatingObject::Type FloatTypeValue> |
122 class ComputeFloatOffsetAdapter { | 121 class ComputeFloatOffsetAdapter { |
123 public: | 122 public: |
124 typedef FloatingObjectInterval IntervalType; | 123 typedef FloatingObjectInterval IntervalType; |
125 | 124 |
126 ComputeFloatOffsetAdapter(const LayoutBlockFlow* layoutObject, LayoutUnit li
neTop, LayoutUnit lineBottom, LayoutUnit offset) | 125 ComputeFloatOffsetAdapter(const LayoutBlockFlow* layoutObject, LayoutUnit li
neTop, LayoutUnit lineBottom, LayoutUnit offset) |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 | 399 |
401 void FloatingObjects::markLowestFloatLogicalBottomCacheAsDirty() | 400 void FloatingObjects::markLowestFloatLogicalBottomCacheAsDirty() |
402 { | 401 { |
403 for (size_t i = 0; i < sizeof(m_lowestFloatBottomCache) / sizeof(FloatBottom
CachedValue); ++i) | 402 for (size_t i = 0; i < sizeof(m_lowestFloatBottomCache) / sizeof(FloatBottom
CachedValue); ++i) |
404 m_lowestFloatBottomCache[i].dirty = true; | 403 m_lowestFloatBottomCache[i].dirty = true; |
405 } | 404 } |
406 | 405 |
407 void FloatingObjects::moveAllToFloatInfoMap(LayoutBoxToFloatInfoMap& map) | 406 void FloatingObjects::moveAllToFloatInfoMap(LayoutBoxToFloatInfoMap& map) |
408 { | 407 { |
409 while (!m_set.isEmpty()) { | 408 while (!m_set.isEmpty()) { |
410 std::unique_ptr<FloatingObject> floatingObject = m_set.takeFirst(); | 409 OwnPtr<FloatingObject> floatingObject = m_set.takeFirst(); |
411 LayoutBox* layoutObject = floatingObject->layoutObject(); | 410 LayoutBox* layoutObject = floatingObject->layoutObject(); |
412 map.add(layoutObject, std::move(floatingObject)); | 411 map.add(layoutObject, std::move(floatingObject)); |
413 } | 412 } |
414 clear(); | 413 clear(); |
415 } | 414 } |
416 | 415 |
417 inline void FloatingObjects::increaseObjectsCount(FloatingObject::Type type) | 416 inline void FloatingObjects::increaseObjectsCount(FloatingObject::Type type) |
418 { | 417 { |
419 if (type == FloatingObject::FloatLeft) | 418 if (type == FloatingObject::FloatLeft) |
420 m_leftObjectsCount++; | 419 m_leftObjectsCount++; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 ASSERT_UNUSED(removed, removed); | 459 ASSERT_UNUSED(removed, removed); |
461 } | 460 } |
462 | 461 |
463 floatingObject.setIsPlaced(false); | 462 floatingObject.setIsPlaced(false); |
464 #if ENABLE(ASSERT) | 463 #if ENABLE(ASSERT) |
465 floatingObject.setIsInPlacedTree(false); | 464 floatingObject.setIsInPlacedTree(false); |
466 #endif | 465 #endif |
467 markLowestFloatLogicalBottomCacheAsDirty(); | 466 markLowestFloatLogicalBottomCacheAsDirty(); |
468 } | 467 } |
469 | 468 |
470 FloatingObject* FloatingObjects::add(std::unique_ptr<FloatingObject> floatingObj
ect) | 469 FloatingObject* FloatingObjects::add(PassOwnPtr<FloatingObject> floatingObject) |
471 { | 470 { |
472 FloatingObject* newObject = floatingObject.release(); | 471 FloatingObject* newObject = floatingObject.leakPtr(); |
473 increaseObjectsCount(newObject->getType()); | 472 increaseObjectsCount(newObject->getType()); |
474 m_set.add(wrapUnique(newObject)); | 473 m_set.add(adoptPtr(newObject)); |
475 if (newObject->isPlaced()) | 474 if (newObject->isPlaced()) |
476 addPlacedObject(*newObject); | 475 addPlacedObject(*newObject); |
477 markLowestFloatLogicalBottomCacheAsDirty(); | 476 markLowestFloatLogicalBottomCacheAsDirty(); |
478 return newObject; | 477 return newObject; |
479 } | 478 } |
480 | 479 |
481 void FloatingObjects::remove(FloatingObject* toBeRemoved) | 480 void FloatingObjects::remove(FloatingObject* toBeRemoved) |
482 { | 481 { |
483 decreaseObjectsCount(toBeRemoved->getType()); | 482 decreaseObjectsCount(toBeRemoved->getType()); |
484 std::unique_ptr<FloatingObject> floatingObject = m_set.take(toBeRemoved); | 483 OwnPtr<FloatingObject> floatingObject = m_set.take(toBeRemoved); |
485 ASSERT(floatingObject->isPlaced() || !floatingObject->isInPlacedTree()); | 484 ASSERT(floatingObject->isPlaced() || !floatingObject->isInPlacedTree()); |
486 if (floatingObject->isPlaced()) | 485 if (floatingObject->isPlaced()) |
487 removePlacedObject(*floatingObject); | 486 removePlacedObject(*floatingObject); |
488 markLowestFloatLogicalBottomCacheAsDirty(); | 487 markLowestFloatLogicalBottomCacheAsDirty(); |
489 ASSERT(!floatingObject->originatingLine()); | 488 ASSERT(!floatingObject->originatingLine()); |
490 } | 489 } |
491 | 490 |
492 void FloatingObjects::computePlacedFloatsTree() | 491 void FloatingObjects::computePlacedFloatsTree() |
493 { | 492 { |
494 ASSERT(!m_placedFloatsTree.isInitialized()); | 493 ASSERT(!m_placedFloatsTree.isInitialized()); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 } | 638 } |
640 | 639 |
641 String ValueToString<FloatingObject*>::toString(const FloatingObject* floatingOb
ject) | 640 String ValueToString<FloatingObject*>::toString(const FloatingObject* floatingOb
ject) |
642 { | 641 { |
643 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()); | 642 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()); |
644 } | 643 } |
645 #endif | 644 #endif |
646 | 645 |
647 | 646 |
648 } // namespace blink | 647 } // namespace blink |
OLD | NEW |