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

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

Issue 2164813002: Revert "Add a hack to set shouldPaint to true for force-composited iframes." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details. 16 * Library General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Library General Public License 18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to 19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
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"
31 #include "platform/RuntimeEnabledFeatures.h"
32 #include "wtf/PtrUtil.h" 30 #include "wtf/PtrUtil.h"
31
33 #include <algorithm> 32 #include <algorithm>
34 #include <memory> 33 #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 };
45 44
46 static_assert(sizeof(FloatingObject) == sizeof(SameSizeAsFloatingObject), "Float ingObject should stay small"); 45 static_assert(sizeof(FloatingObject) == sizeof(SameSizeAsFloatingObject), "Float ingObject should stay small");
47 46
48 FloatingObject::FloatingObject(LayoutBox* layoutObject) 47 FloatingObject::FloatingObject(LayoutBox* layoutObject)
49 : m_layoutObject(layoutObject) 48 : m_layoutObject(layoutObject)
50 , m_originatingLine(nullptr) 49 , m_originatingLine(nullptr)
50 // TODO(wkorman): Do we need to change this to take param as it used to?
51 , m_shouldPaint(true) 51 , m_shouldPaint(true)
52 , m_isDescendant(false) 52 , m_isDescendant(false)
53 , m_isPlaced(false) 53 , m_isPlaced(false)
54 , m_isLowestNonOverhangingFloatInChild(false) 54 , m_isLowestNonOverhangingFloatInChild(false)
55 #if ENABLE(ASSERT) 55 #if ENABLE(ASSERT)
56 , m_isInPlacedTree(false) 56 , m_isInPlacedTree(false)
57 #endif 57 #endif
58 { 58 {
59 EFloat type = layoutObject->style()->floating(); 59 EFloat type = layoutObject->style()->floating();
60 ASSERT(type != NoFloat); 60 ASSERT(type != NoFloat);
61 if (type == LeftFloat) 61 if (type == LeftFloat)
62 m_type = FloatLeft; 62 m_type = FloatLeft;
63 else if (type == RightFloat) 63 else if (type == RightFloat)
64 m_type = FloatRight; 64 m_type = FloatRight;
65 } 65 }
66 66
67 FloatingObject::FloatingObject(LayoutBox* layoutObject, Type type, const LayoutR ect& frameRect, bool shouldPaint, bool isDescendant, bool isLowestNonOverhanging FloatInChild, bool performingUnsafeClone) 67 FloatingObject::FloatingObject(LayoutBox* layoutObject, Type type, const LayoutR ect& frameRect, bool shouldPaint, bool isDescendant, bool isLowestNonOverhanging FloatInChild, bool performingUnsafeClone)
68 : m_layoutObject(layoutObject) 68 : m_layoutObject(layoutObject)
69 , m_originatingLine(nullptr) 69 , m_originatingLine(nullptr)
70 , m_frameRect(frameRect) 70 , m_frameRect(frameRect)
71 , m_type(type) 71 , m_type(type)
72 , m_shouldPaint(shouldPaint)
72 , m_isDescendant(isDescendant) 73 , m_isDescendant(isDescendant)
73 , m_isPlaced(true) 74 , m_isPlaced(true)
74 , m_isLowestNonOverhangingFloatInChild(isLowestNonOverhangingFloatInChild) 75 , m_isLowestNonOverhangingFloatInChild(isLowestNonOverhangingFloatInChild)
75 #if ENABLE(ASSERT) 76 #if ENABLE(ASSERT)
76 , m_isInPlacedTree(false) 77 , m_isInPlacedTree(false)
77 #endif 78 #endif
78 { 79 {
79 m_shouldPaint = shouldPaint;
80 // TODO(chrishtr): Avoid the following hack when performing an unsafe clone.
81 // This avoids a use-after-free bug due to the fact that we sometimes fail t o remove
82 // floats from their container when detaching (crbug.com/619380). This is ac tually a bug in the
83 // floats detach machinery, which needs to be fixed, in which case this work around can be removed.
84 // In any case, it should be safe because moving floats from one owner to an other should cause layout,
85 // which will in turn update the m_shouldPaint property.
86 if (!performingUnsafeClone)
87 m_shouldPaint = m_shouldPaint || shouldPaintForCompositedLayoutPart();
88 }
89
90 bool FloatingObject::shouldPaintForCompositedLayoutPart()
91 {
92 // HACK: only non-self-painting floats should paint. However, due to the fun damental compositing bug, some LayoutPart objects
93 // may become self-painting due to being composited. This leads to a chicken -egg issue because layout may not depend on compositing.
94 // If this is the case, set shouldPaint() to true even if the layer is techn ically self-painting. This lets the float which contains
95 // a LayoutPart start painting as soon as it stops being composited, without having to re-layout the float.
96 // This hack can be removed after SPv2.
97 return m_layoutObject->layer() && m_layoutObject->layer()->isSelfPaintingOnl yBecauseIsCompositedPart() && !RuntimeEnabledFeatures::slimmingPaintV2Enabled();
98 } 80 }
99 81
100 std::unique_ptr<FloatingObject> FloatingObject::create(LayoutBox* layoutObject) 82 std::unique_ptr<FloatingObject> FloatingObject::create(LayoutBox* layoutObject)
101 { 83 {
102 std::unique_ptr<FloatingObject> newObj = wrapUnique(new FloatingObject(layou tObject)); 84 std::unique_ptr<FloatingObject> newObj = wrapUnique(new FloatingObject(layou tObject));
103 85
104 // If a layer exists, the float will paint itself. Otherwise someone else wi ll. 86 // If a layer exists, the float will paint itself. Otherwise someone else wi ll.
105 newObj->setShouldPaint(!layoutObject->hasSelfPaintingLayer() || newObj->shou ldPaintForCompositedLayoutPart()); 87 newObj->setShouldPaint(!layoutObject->hasSelfPaintingLayer());
106 88
107 newObj->setIsDescendant(true); 89 newObj->setIsDescendant(true);
108 90
109 return newObj; 91 return newObj;
110 } 92 }
111 93
112 bool FloatingObject::shouldPaint() const
113 {
114 return m_shouldPaint && !m_layoutObject->hasSelfPaintingLayer();
115 }
116
117 std::unique_ptr<FloatingObject> FloatingObject::copyToNewContainer(LayoutSize of fset, bool shouldPaint, bool isDescendant) const 94 std::unique_ptr<FloatingObject> FloatingObject::copyToNewContainer(LayoutSize of fset, bool shouldPaint, bool isDescendant) const
118 { 95 {
119 return wrapUnique(new FloatingObject(layoutObject(), getType(), LayoutRect(f rameRect().location() - offset, frameRect().size()), shouldPaint, isDescendant, isLowestNonOverhangingFloatInChild())); 96 return wrapUnique(new FloatingObject(layoutObject(), getType(), LayoutRect(f rameRect().location() - offset, frameRect().size()), shouldPaint, isDescendant, isLowestNonOverhangingFloatInChild()));
120 } 97 }
121 98
122 std::unique_ptr<FloatingObject> FloatingObject::unsafeClone() const 99 std::unique_ptr<FloatingObject> FloatingObject::unsafeClone() const
123 { 100 {
124 std::unique_ptr<FloatingObject> cloneObject = wrapUnique(new FloatingObject( layoutObject(), getType(), m_frameRect, m_shouldPaint, m_isDescendant, false, tr ue)); 101 std::unique_ptr<FloatingObject> cloneObject = wrapUnique(new FloatingObject( layoutObject(), getType(), m_frameRect, m_shouldPaint, m_isDescendant, false, tr ue));
125 cloneObject->m_isPlaced = m_isPlaced; 102 cloneObject->m_isPlaced = m_isPlaced;
126 return cloneObject; 103 return cloneObject;
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 } 624 }
648 625
649 String ValueToString<FloatingObject*>::toString(const FloatingObject* floatingOb ject) 626 String ValueToString<FloatingObject*>::toString(const FloatingObject* floatingOb ject)
650 { 627 {
651 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()); 628 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());
652 } 629 }
653 #endif 630 #endif
654 631
655 632
656 } // namespace blink 633 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/FloatingObjects.h ('k') | third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698