Chromium Code Reviews| 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 |
| 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" | |
| 30 | 31 |
| 31 #include <algorithm> | 32 #include <algorithm> |
| 32 | 33 |
| 33 using namespace WTF; | 34 using namespace WTF; |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 37 struct SameSizeAsFloatingObject { | 38 struct SameSizeAsFloatingObject { |
| 38 void* pointers[2]; | 39 void* pointers[2]; |
| 39 LayoutRect rect; | 40 LayoutRect rect; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 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(LayoutBox* layoutObject, Type type, const LayoutR ect& frameRect, bool shouldPaint, bool isDescendant, bool isLowestNonOverhanging FloatInChild) | 65 FloatingObject::FloatingObject(LayoutBox* layoutObject, Type type, const LayoutR ect& frameRect, bool shouldPaint, bool isDescendant, bool isLowestNonOverhanging FloatInChild) |
| 65 : m_layoutObject(layoutObject) | 66 : m_layoutObject(layoutObject) |
| 66 , m_originatingLine(nullptr) | 67 , m_originatingLine(nullptr) |
| 67 , m_frameRect(frameRect) | 68 , m_frameRect(frameRect) |
| 68 , m_type(type) | 69 , m_type(type) |
| 69 , m_shouldPaint(shouldPaint) | |
| 70 , m_isDescendant(isDescendant) | 70 , m_isDescendant(isDescendant) |
| 71 , m_isPlaced(true) | 71 , m_isPlaced(true) |
| 72 , m_isLowestNonOverhangingFloatInChild(isLowestNonOverhangingFloatInChild) | 72 , m_isLowestNonOverhangingFloatInChild(isLowestNonOverhangingFloatInChild) |
| 73 #if ENABLE(ASSERT) | 73 #if ENABLE(ASSERT) |
| 74 , m_isInPlacedTree(false) | 74 , m_isInPlacedTree(false) |
| 75 #endif | 75 #endif |
| 76 { | 76 { |
| 77 m_shouldPaint = shouldPaint || shouldPaintForCompositedLayoutPart(); | |
| 78 } | |
| 79 | |
| 80 bool FloatingObject::shouldPaintForCompositedLayoutPart() | |
| 81 { | |
| 82 // HACK: only non-self-painting floats should paint. However, due to the fun damental compositing bug, some LayoutPart objects | |
| 83 // may become self-painting due to being composited. This leads to a chicken -egg issue because layout may not depend on compositing. | |
| 84 // 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 // a LayoutPart start painting as soon as it stops being composited, without having to re-layout the float. | |
| 86 // This hack can be removed after SPv2. | |
| 87 return m_layoutObject->layer() && m_layoutObject->layer()->isSelfPaintingOnl yBecauseIsCompositedPart(); | |
| 77 } | 88 } |
| 78 | 89 |
| 79 PassOwnPtr<FloatingObject> FloatingObject::create(LayoutBox* layoutObject) | 90 PassOwnPtr<FloatingObject> FloatingObject::create(LayoutBox* layoutObject) |
| 80 { | 91 { |
| 81 OwnPtr<FloatingObject> newObj = adoptPtr(new FloatingObject(layoutObject)); | 92 OwnPtr<FloatingObject> newObj = adoptPtr(new FloatingObject(layoutObject)); |
| 82 newObj->setShouldPaint(!layoutObject->hasSelfPaintingLayer()); // If a layer exists, the float will paint itself. Otherwise someone else will. | 93 |
| 94 // If a layer exists, the float will paint itself. Otherwise someone else wi ll. | |
| 95 newObj->setShouldPaint(!layoutObject->hasSelfPaintingLayer() || newObj->sho uldPaintForCompositedLayoutPart()); | |
|
Xianzhu
2016/05/26 18:29:54
Nit: Remove extra space before '||'.
chrishtr
2016/05/26 18:49:29
Done.
| |
| 96 | |
| 83 newObj->setIsDescendant(true); | 97 newObj->setIsDescendant(true); |
| 84 | 98 |
| 85 return newObj; | 99 return newObj; |
| 86 } | 100 } |
| 87 | 101 |
| 102 bool FloatingObject::shouldPaint() const | |
| 103 { | |
| 104 return m_shouldPaint && !m_layoutObject->hasSelfPaintingLayer(); | |
| 105 } | |
| 106 | |
| 88 PassOwnPtr<FloatingObject> FloatingObject::copyToNewContainer(LayoutSize offset, bool shouldPaint, bool isDescendant) const | 107 PassOwnPtr<FloatingObject> FloatingObject::copyToNewContainer(LayoutSize offset, bool shouldPaint, bool isDescendant) const |
| 89 { | 108 { |
| 90 return adoptPtr(new FloatingObject(layoutObject(), getType(), LayoutRect(fra meRect().location() - offset, frameRect().size()), shouldPaint, isDescendant, is LowestNonOverhangingFloatInChild())); | 109 return adoptPtr(new FloatingObject(layoutObject(), getType(), LayoutRect(fra meRect().location() - offset, frameRect().size()), shouldPaint, isDescendant, is LowestNonOverhangingFloatInChild())); |
| 91 } | 110 } |
| 92 | 111 |
| 93 PassOwnPtr<FloatingObject> FloatingObject::unsafeClone() const | 112 PassOwnPtr<FloatingObject> FloatingObject::unsafeClone() const |
| 94 { | 113 { |
| 95 OwnPtr<FloatingObject> cloneObject = adoptPtr(new FloatingObject(layoutObjec t(), getType(), m_frameRect, m_shouldPaint, m_isDescendant, false)); | 114 OwnPtr<FloatingObject> cloneObject = adoptPtr(new FloatingObject(layoutObjec t(), getType(), m_frameRect, m_shouldPaint, m_isDescendant, false)); |
| 96 cloneObject->m_isPlaced = m_isPlaced; | 115 cloneObject->m_isPlaced = m_isPlaced; |
| 97 return cloneObject; | 116 return cloneObject; |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 } | 637 } |
| 619 | 638 |
| 620 String ValueToString<FloatingObject*>::toString(const FloatingObject* floatingOb ject) | 639 String ValueToString<FloatingObject*>::toString(const FloatingObject* floatingOb ject) |
| 621 { | 640 { |
| 622 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()); | 641 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()); |
| 623 } | 642 } |
| 624 #endif | 643 #endif |
| 625 | 644 |
| 626 | 645 |
| 627 } // namespace blink | 646 } // namespace blink |
| OLD | NEW |