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

Side by Side Diff: Source/core/rendering/FloatingObjects.cpp

Issue 131223003: Track intruding and overhanging floats (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/FloatingObjects.h ('k') | Source/core/rendering/RenderBlockFlow.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 FloatingObject::FloatingObject(RenderBox* renderer) 45 FloatingObject::FloatingObject(RenderBox* renderer)
46 : m_renderer(renderer) 46 : m_renderer(renderer)
47 , m_originatingLine(0) 47 , m_originatingLine(0)
48 , m_paginationStrut(0) 48 , m_paginationStrut(0)
49 , m_shouldPaint(true) 49 , m_shouldPaint(true)
50 , m_isDescendant(false) 50 , m_isDescendant(false)
51 , m_isPlaced(false) 51 , m_isPlaced(false)
52 #ifndef NDEBUG 52 #ifndef NDEBUG
53 , m_isInPlacedTree(false) 53 , m_isInPlacedTree(false)
54 #endif 54 #endif
55 , m_isOverhangingOrIntruding(false)
55 { 56 {
56 EFloat type = renderer->style()->floating(); 57 EFloat type = renderer->style()->floating();
57 ASSERT(type != NoFloat); 58 ASSERT(type != NoFloat);
58 if (type == LeftFloat) 59 if (type == LeftFloat)
59 m_type = FloatLeft; 60 m_type = FloatLeft;
60 else if (type == RightFloat) 61 else if (type == RightFloat)
61 m_type = FloatRight; 62 m_type = FloatRight;
62 } 63 }
63 64
64 FloatingObject::FloatingObject(RenderBox* renderer, Type type, const LayoutRect& frameRect, bool shouldPaint, bool isDescendant) 65 FloatingObject::FloatingObject(RenderBox* renderer, Type type, const LayoutRect& frameRect, bool shouldPaint, bool isDescendant)
65 : m_renderer(renderer) 66 : m_renderer(renderer)
66 , m_originatingLine(0) 67 , m_originatingLine(0)
67 , m_frameRect(frameRect) 68 , m_frameRect(frameRect)
68 , m_paginationStrut(0) 69 , m_paginationStrut(0)
69 , m_type(type) 70 , m_type(type)
70 , m_shouldPaint(shouldPaint) 71 , m_shouldPaint(shouldPaint)
71 , m_isDescendant(isDescendant) 72 , m_isDescendant(isDescendant)
72 , m_isPlaced(true) 73 , m_isPlaced(true)
73 #ifndef NDEBUG 74 #ifndef NDEBUG
74 , m_isInPlacedTree(false) 75 , m_isInPlacedTree(false)
75 #endif 76 #endif
77 , m_isOverhangingOrIntruding(false)
76 { 78 {
77 } 79 }
78 80
79 PassOwnPtr<FloatingObject> FloatingObject::create(RenderBox* renderer) 81 PassOwnPtr<FloatingObject> FloatingObject::create(RenderBox* renderer)
80 { 82 {
81 OwnPtr<FloatingObject> newObj = adoptPtr(new FloatingObject(renderer)); 83 OwnPtr<FloatingObject> newObj = adoptPtr(new FloatingObject(renderer));
82 newObj->setShouldPaint(!renderer->hasSelfPaintingLayer()); // If a layer exi sts, the float will paint itself. Otherwise someone else will. 84 newObj->setShouldPaint(!renderer->hasSelfPaintingLayer()); // If a layer exi sts, the float will paint itself. Otherwise someone else will.
83 newObj->setIsDescendant(true); 85 newObj->setIsDescendant(true);
84 86
85 return newObj.release(); 87 return newObj.release();
86 } 88 }
87 89
88 PassOwnPtr<FloatingObject> FloatingObject::copyToNewContainer(LayoutSize offset, bool shouldPaint, bool isDescendant) const 90 PassOwnPtr<FloatingObject> FloatingObject::copyToNewContainer(LayoutSize offset, bool shouldPaint, bool isDescendant) const
89 { 91 {
90 return adoptPtr(new FloatingObject(renderer(), type(), LayoutRect(frameRect( ).location() - offset, frameRect().size()), shouldPaint, isDescendant)); 92 return adoptPtr(new FloatingObject(renderer(), type(), LayoutRect(frameRect( ).location() - offset, frameRect().size()), shouldPaint, isDescendant));
91 } 93 }
92 94
93 PassOwnPtr<FloatingObject> FloatingObject::unsafeClone() const 95 PassOwnPtr<FloatingObject> FloatingObject::unsafeClone() const
94 { 96 {
95 OwnPtr<FloatingObject> cloneObject = adoptPtr(new FloatingObject(renderer(), type(), m_frameRect, m_shouldPaint, m_isDescendant)); 97 OwnPtr<FloatingObject> cloneObject = adoptPtr(new FloatingObject(renderer(), type(), m_frameRect, m_shouldPaint, m_isDescendant));
96 cloneObject->m_originatingLine = m_originatingLine;
97 cloneObject->m_paginationStrut = m_paginationStrut; 98 cloneObject->m_paginationStrut = m_paginationStrut;
98 cloneObject->m_isPlaced = m_isPlaced; 99 cloneObject->m_isPlaced = m_isPlaced;
99 return cloneObject.release(); 100 return cloneObject.release();
100 } 101 }
101 102
102 template <FloatingObject::Type FloatTypeValue> 103 template <FloatingObject::Type FloatTypeValue>
103 class ComputeFloatOffsetAdapter { 104 class ComputeFloatOffsetAdapter {
104 public: 105 public:
105 typedef FloatingObjectInterval IntervalType; 106 typedef FloatingObjectInterval IntervalType;
106 107
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 , m_horizontalWritingMode(horizontalWritingMode) 166 , m_horizontalWritingMode(horizontalWritingMode)
166 , m_renderer(renderer) 167 , m_renderer(renderer)
167 , m_cachedHorizontalWritingMode(false) 168 , m_cachedHorizontalWritingMode(false)
168 { 169 {
169 } 170 }
170 171
171 void FloatingObjects::clear() 172 void FloatingObjects::clear()
172 { 173 {
173 deleteAllValues(m_set); 174 deleteAllValues(m_set);
174 m_set.clear(); 175 m_set.clear();
176 m_overhangingOrIntrudingSet.clear();
175 m_placedFloatsTree.clear(); 177 m_placedFloatsTree.clear();
176 m_leftObjectsCount = 0; 178 m_leftObjectsCount = 0;
177 m_rightObjectsCount = 0; 179 m_rightObjectsCount = 0;
178 markLowestFloatLogicalBottomCacheAsDirty(); 180 markLowestFloatLogicalBottomCacheAsDirty();
179 } 181 }
180 182
183 void FloatingObjects::clearOverhangingAndIntrudingFloats()
184 {
185 FloatingObjectSetIterator end = m_overhangingOrIntrudingSet.end();
186 for (FloatingObjectSetIterator it = m_overhangingOrIntrudingSet.begin(); it != end; ++it) {
187 FloatingObject* floatingObject = *it;
188 decreaseObjectsCount(floatingObject->type());
189 m_set.remove(floatingObject);
190 removePlacedObject(floatingObject);
191 ASSERT(!floatingObject->originatingLine());
192 delete floatingObject;
193 }
194 m_overhangingOrIntrudingSet.clear();
195 markLowestFloatLogicalBottomCacheAsDirty();
196 }
197
181 LayoutUnit FloatingObjects::lowestFloatLogicalBottom(FloatingObject::Type floatT ype) 198 LayoutUnit FloatingObjects::lowestFloatLogicalBottom(FloatingObject::Type floatT ype)
182 { 199 {
183 bool isInHorizontalWritingMode = m_horizontalWritingMode; 200 bool isInHorizontalWritingMode = m_horizontalWritingMode;
184 if (floatType != FloatingObject::FloatLeftRight) { 201 if (floatType != FloatingObject::FloatLeftRight) {
185 if (hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode, floatTy pe)) 202 if (hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode, floatTy pe))
186 return getCachedlowestFloatLogicalBottom(floatType); 203 return getCachedlowestFloatLogicalBottom(floatType);
187 } else { 204 } else {
188 if (hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode, Floatin gObject::FloatLeft) && hasLowestFloatLogicalBottomCached(isInHorizontalWritingMo de, FloatingObject::FloatRight)) { 205 if (hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode, Floatin gObject::FloatLeft) && hasLowestFloatLogicalBottomCached(isInHorizontalWritingMo de, FloatingObject::FloatRight)) {
189 return max(getCachedlowestFloatLogicalBottom(FloatingObject::FloatLe ft), 206 return max(getCachedlowestFloatLogicalBottom(FloatingObject::FloatLe ft),
190 getCachedlowestFloatLogicalBottom(FloatingObject::FloatRight)); 207 getCachedlowestFloatLogicalBottom(FloatingObject::FloatRight));
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 { 341 {
325 FloatingObject* newObject = floatingObject.leakPtr(); 342 FloatingObject* newObject = floatingObject.leakPtr();
326 increaseObjectsCount(newObject->type()); 343 increaseObjectsCount(newObject->type());
327 m_set.add(newObject); 344 m_set.add(newObject);
328 if (newObject->isPlaced()) 345 if (newObject->isPlaced())
329 addPlacedObject(newObject); 346 addPlacedObject(newObject);
330 markLowestFloatLogicalBottomCacheAsDirty(); 347 markLowestFloatLogicalBottomCacheAsDirty();
331 return newObject; 348 return newObject;
332 } 349 }
333 350
351 FloatingObject* FloatingObjects::addOverhangingOrIntrudingFloat(PassOwnPtr<Float ingObject> floatingObject)
352 {
353 ASSERT(floatingObject->isPlaced());
354
355 floatingObject->setIsOverhangingOrIntruding(true);
356
357 m_overhangingOrIntrudingSet.add(floatingObject.get());
358 return add(floatingObject);
359 }
360
334 void FloatingObjects::remove(FloatingObject* floatingObject) 361 void FloatingObjects::remove(FloatingObject* floatingObject)
335 { 362 {
336 decreaseObjectsCount(floatingObject->type()); 363 decreaseObjectsCount(floatingObject->type());
337 m_set.remove(floatingObject); 364 m_set.remove(floatingObject);
365 m_overhangingOrIntrudingSet.remove(floatingObject);
338 ASSERT(floatingObject->isPlaced() || !floatingObject->isInPlacedTree()); 366 ASSERT(floatingObject->isPlaced() || !floatingObject->isInPlacedTree());
339 if (floatingObject->isPlaced()) 367 if (floatingObject->isPlaced())
340 removePlacedObject(floatingObject); 368 removePlacedObject(floatingObject);
341 markLowestFloatLogicalBottomCacheAsDirty(); 369 markLowestFloatLogicalBottomCacheAsDirty();
342 ASSERT(!floatingObject->originatingLine()); 370 ASSERT(!floatingObject->originatingLine());
343 delete floatingObject; 371 delete floatingObject;
344 } 372 }
345 373
346 void FloatingObjects::computePlacedFloatsTree() 374 void FloatingObjects::computePlacedFloatsTree()
347 { 375 {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 } 524 }
497 525
498 String ValueToString<FloatingObject*>::string(const FloatingObject* floatingObje ct) 526 String ValueToString<FloatingObject*>::string(const FloatingObject* floatingObje ct)
499 { 527 {
500 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped MaxY()); 528 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped MaxY());
501 } 529 }
502 #endif 530 #endif
503 531
504 532
505 } // namespace WebCore 533 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/FloatingObjects.h ('k') | Source/core/rendering/RenderBlockFlow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698