Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: third_party/WebKit/Source/core/layout/FloatingObjects.cpp

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

Powered by Google App Engine
This is Rietveld 408576698