OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/layout/LayoutTableBoxComponent.h" | 5 #include "core/layout/LayoutTableBoxComponent.h" |
6 | 6 |
7 #include "core/layout/LayoutTable.h" | 7 #include "core/layout/LayoutTable.h" |
8 #include "core/paint/ObjectPaintInvalidator.h" | 8 #include "core/paint/ObjectPaintInvalidator.h" |
9 #include "core/style/ComputedStyle.h" | 9 #include "core/style/ComputedStyle.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 void LayoutTableBoxComponent::InvalidateCollapsedBordersOnStyleChange( | 13 void LayoutTableBoxComponent::InvalidateCollapsedBordersOnStyleChange( |
14 const LayoutObject& table_part, | 14 const LayoutObject& table_part, |
15 LayoutTable& table, | 15 LayoutTable& table, |
16 const StyleDifference& diff, | 16 const StyleDifference& diff, |
17 const ComputedStyle& old_style) { | 17 const ComputedStyle& old_style) { |
18 if (!table.CollapseBorders()) | 18 if (!table.ShouldCollapseBorders()) |
19 return; | 19 return; |
20 if (old_style.Border() != table_part.StyleRef().Border() || | 20 if (old_style.Border() != table_part.StyleRef().Border() || |
21 (diff.TextDecorationOrColorChanged() && | 21 (diff.TextDecorationOrColorChanged() && |
22 table_part.StyleRef().HasBorderColorReferencingCurrentColor())) | 22 table_part.StyleRef().HasBorderColorReferencingCurrentColor())) |
23 table.InvalidateCollapsedBorders(); | 23 table.InvalidateCollapsedBorders(); |
24 } | 24 } |
25 | 25 |
26 bool LayoutTableBoxComponent::DoCellsHaveDirtyWidth( | 26 bool LayoutTableBoxComponent::DoCellsHaveDirtyWidth( |
27 const LayoutObject& table_part, | 27 const LayoutObject& table_part, |
28 const LayoutTable& table, | 28 const LayoutTable& table, |
29 const StyleDifference& diff, | 29 const StyleDifference& diff, |
30 const ComputedStyle& old_style) { | 30 const ComputedStyle& old_style) { |
31 // ComputedStyle::diffNeedsFullLayoutAndPaintInvalidation sets needsFullLayout | 31 // ComputedStyle::diffNeedsFullLayoutAndPaintInvalidation sets needsFullLayout |
32 // when border sizes change: checking diff.needsFullLayout() is an | 32 // when border sizes change: checking diff.needsFullLayout() is an |
33 // optimization, not required for correctness. | 33 // optimization, not required for correctness. |
34 // TODO(dgrogan): Remove tablePart.needsLayout()? Perhaps it was an old | 34 // TODO(dgrogan): Remove tablePart.needsLayout()? Perhaps it was an old |
35 // optimization but now it seems that diff.needsFullLayout() implies | 35 // optimization but now it seems that diff.needsFullLayout() implies |
36 // tablePart.needsLayout(). | 36 // tablePart.needsLayout(). |
37 return diff.NeedsFullLayout() && table_part.NeedsLayout() && | 37 return diff.NeedsFullLayout() && table_part.NeedsLayout() && |
38 table.CollapseBorders() && | 38 table.ShouldCollapseBorders() && |
39 !old_style.Border().SizeEquals(table_part.Style()->Border()); | 39 !old_style.Border().SizeEquals(table_part.Style()->Border()); |
40 } | 40 } |
41 | 41 |
42 void LayoutTableBoxComponent::MutableForPainting::UpdatePaintResult( | 42 void LayoutTableBoxComponent::MutableForPainting::UpdatePaintResult( |
43 PaintResult paint_result, | 43 PaintResult paint_result, |
44 const CullRect& paint_rect) { | 44 const CullRect& paint_rect) { |
45 DCHECK_EQ(layout_object_.GetDocument().Lifecycle().GetState(), | 45 DCHECK_EQ(layout_object_.GetDocument().Lifecycle().GetState(), |
46 DocumentLifecycle::LifecycleState::kInPaint); | 46 DocumentLifecycle::LifecycleState::kInPaint); |
47 | 47 |
48 // A table row or section may paint large background display item which | 48 // A table row or section may paint large background display item which |
49 // contains paint operations of the background in each contained cell. | 49 // contains paint operations of the background in each contained cell. |
50 // The display item can be clipped by the paint rect to avoid painting | 50 // The display item can be clipped by the paint rect to avoid painting |
51 // on areas not interested. If we didn't fully paint and paint rect changes, | 51 // on areas not interested. If we didn't fully paint and paint rect changes, |
52 // we need to invalidate the display item (using setDisplayItemUncached() | 52 // we need to invalidate the display item (using setDisplayItemUncached() |
53 // because we are already in painting.) | 53 // because we are already in painting.) |
54 auto& box = static_cast<LayoutTableBoxComponent&>(layout_object_); | 54 auto& box = static_cast<LayoutTableBoxComponent&>(layout_object_); |
55 if (box.last_paint_result_ != kFullyPainted && | 55 if (box.last_paint_result_ != kFullyPainted && |
56 box.last_paint_rect_ != paint_rect) | 56 box.last_paint_rect_ != paint_rect) |
57 layout_object_.SetDisplayItemsUncached(); | 57 layout_object_.SetDisplayItemsUncached(); |
58 | 58 |
59 box.last_paint_result_ = paint_result; | 59 box.last_paint_result_ = paint_result; |
60 box.last_paint_rect_ = paint_rect; | 60 box.last_paint_rect_ = paint_rect; |
61 } | 61 } |
62 | 62 |
63 } // namespace blink | 63 } // namespace blink |
OLD | NEW |