Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
| 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| 11 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
| 12 * version 2 of the License, or (at your option) any later version. | 12 * version 2 of the License, or (at your option) any later version. |
| 13 * | 13 * |
| 14 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 * Library General Public License for more details. | 17 * Library General Public License for more details. |
| 18 * | 18 * |
| 19 * You should have received a copy of the GNU Library General Public License | 19 * You should have received a copy of the GNU Library General Public License |
| 20 * along with this library; see the file COPYING.LIB. If not, write to | 20 * along with this library; see the file COPYING.LIB. If not, write to |
| 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 * Boston, MA 02110-1301, USA. | 22 * Boston, MA 02110-1301, USA. |
| 23 * | 23 * |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/rendering/LayoutRepainter.h" | 27 #include "core/rendering/LayoutRepainter.h" |
| 28 | 28 |
| 29 #include "core/rendering/RenderBlockFlow.h" | |
| 30 #include "core/rendering/RenderBox.h" | |
| 29 #include "core/rendering/RenderObject.h" | 31 #include "core/rendering/RenderObject.h" |
| 30 | 32 |
| 31 namespace WebCore { | 33 namespace WebCore { |
| 32 | 34 |
| 33 LayoutRepainter::LayoutRepainter(RenderObject& object, bool checkForRepaint) | 35 LayoutRepainter::LayoutRepainter(RenderObject& object, bool checkForRepaint) |
| 34 : m_object(object) | 36 : m_object(object) |
| 35 , m_repaintContainer(0) | 37 , m_repaintContainer(0) |
| 36 , m_checkForRepaint(checkForRepaint) | 38 , m_checkForRepaint(checkForRepaint) |
| 39 , m_logicalWidth(-1) | |
|
eseidel
2014/02/24 21:45:45
My instinct would have been to preface these with
Julien - ping for review
2014/03/06 21:03:02
Good suggestion.
| |
| 40 , m_logicalHeight(-1) | |
|
eseidel
2014/02/24 21:45:45
I would use a const int kDidNotChange = -1; to mak
Julien - ping for review
2014/03/06 21:03:02
Done.
| |
| 41 , m_selfNeededLayout(object.selfNeedsLayout()) | |
| 37 { | 42 { |
| 38 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) | 43 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) |
| 39 return; | 44 return; |
| 40 | 45 |
| 41 if (m_checkForRepaint) { | 46 if (m_checkForRepaint) { |
| 42 m_repaintContainer = m_object.containerForRepaint(); | 47 m_repaintContainer = m_object.containerForRepaint(); |
| 43 m_oldBounds = m_object.clippedOverflowRectForRepaint(m_repaintContainer) ; | 48 m_oldBounds = m_object.clippedOverflowRectForRepaint(m_repaintContainer) ; |
| 44 m_oldOutlineBox = m_object.outlineBoundsForRepaint(m_repaintContainer); | 49 m_oldOutlineBox = m_object.outlineBoundsForRepaint(m_repaintContainer); |
| 50 if (m_object.isBox()) { | |
| 51 const RenderBox& box = *toRenderBox(&m_object); | |
| 52 m_logicalWidth = box.logicalWidth(); | |
| 53 m_logicalHeight = box.logicalHeight(); | |
| 54 } | |
| 45 } | 55 } |
| 46 } | 56 } |
| 47 | 57 |
| 48 bool LayoutRepainter::repaintAfterLayout() | 58 bool LayoutRepainter::repaintAfterLayout() |
| 49 { | 59 { |
| 50 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) | 60 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) |
| 51 return false; | 61 return false; |
| 52 | 62 |
| 53 return m_checkForRepaint ? m_object.repaintAfterLayoutIfNeeded(m_repaintCont ainer, m_object.selfNeedsLayout(), m_oldBounds, m_oldOutlineBox) : false; | 63 if (!m_checkForRepaint) |
| 64 return false; | |
| 65 | |
| 66 if (canSkipRepaint()) | |
| 67 return false; | |
| 68 | |
| 69 return m_object.repaintAfterLayoutIfNeeded(m_repaintContainer, m_object.self NeedsLayout(), m_oldBounds, m_oldOutlineBox); | |
| 70 } | |
| 71 | |
| 72 bool LayoutRepainter::canSkipRepaint() const | |
| 73 { | |
| 74 // If we needed layout, our content could have changed so we have to repaint . | |
| 75 if (m_selfNeededLayout) | |
| 76 return false; | |
| 77 | |
| 78 if (m_logicalWidth == -1) { | |
| 79 ASSERT(m_logicalHeight == -1); | |
| 80 return false; | |
| 81 } | |
| 82 | |
| 83 ASSERT(m_logicalWidth != -1); | |
| 84 ASSERT(m_logicalHeight != -1); | |
| 85 | |
| 86 // We don't repaint box containers that are not marked for self-layout and d idn't change size. | |
| 87 // This is valid because: | |
| 88 // - if their content changed, they would be marked for self-layout. | |
| 89 // - their descendant(s) that actually changed should repaint themselves cor rectly. | |
| 90 // FIXME: It should be possible to avoid repainting size changes but we have to be careful with | |
| 91 // some cases (e.g. gradient or repeated backgrounds). | |
| 92 const RenderBox& box = *toRenderBox(&m_object); | |
| 93 if (m_logicalWidth != box.logicalWidth() || m_logicalHeight != box.logicalHe ight()) | |
| 94 return false; | |
| 95 | |
| 96 if (!m_object.isRenderBlockFlow()) | |
| 97 return true; | |
| 98 | |
| 99 const RenderBlockFlow& block = *toRenderBlockFlow(&box); | |
| 100 // FIXME: We currently disable this optimization for floats as they need to be | |
| 101 // correctly repainted by their (not marked for self-layout) block-flow cont ainer. | |
| 102 return !block.containsFloats(); | |
|
eseidel
2014/02/24 21:45:45
I might have abstracted this into a nicely named h
Julien - ping for review
2014/03/06 21:03:02
Added hasChildrenNeedingRepaintFromContainingBlock
| |
| 54 } | 103 } |
| 55 | 104 |
| 56 } // namespace WebCore | 105 } // namespace WebCore |
| OLD | NEW |