| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/paint/TableCellPainter.h" | 5 #include "core/paint/TableCellPainter.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutTableCell.h" | 7 #include "core/layout/LayoutTableCell.h" |
| 8 #include "core/paint/BlockPainter.h" | 8 #include "core/paint/BlockPainter.h" |
| 9 #include "core/paint/BoxPainter.h" | 9 #include "core/paint/BoxPainter.h" |
| 10 #include "core/paint/LayoutObjectDrawingRecorder.h" | 10 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 void TableCellPainter::PaintContainerBackgroundBehindCell( | 179 void TableCellPainter::PaintContainerBackgroundBehindCell( |
| 180 const PaintInfo& paint_info, | 180 const PaintInfo& paint_info, |
| 181 const LayoutPoint& paint_offset, | 181 const LayoutPoint& paint_offset, |
| 182 const LayoutObject& background_object) { | 182 const LayoutObject& background_object) { |
| 183 DCHECK(background_object != layout_table_cell_); | 183 DCHECK(background_object != layout_table_cell_); |
| 184 | 184 |
| 185 if (layout_table_cell_.Style()->Visibility() != EVisibility::kVisible) | 185 if (layout_table_cell_.Style()->Visibility() != EVisibility::kVisible) |
| 186 return; | 186 return; |
| 187 | 187 |
| 188 LayoutTable* table = layout_table_cell_.Table(); | 188 LayoutTable* table = layout_table_cell_.Table(); |
| 189 if (!table->CollapseBorders() && | 189 if (!table->ShouldCollapseBorders() && |
| 190 layout_table_cell_.Style()->EmptyCells() == EEmptyCells::kHide && | 190 layout_table_cell_.Style()->EmptyCells() == EEmptyCells::kHide && |
| 191 !layout_table_cell_.FirstChild()) | 191 !layout_table_cell_.FirstChild()) |
| 192 return; | 192 return; |
| 193 | 193 |
| 194 LayoutRect paint_rect = PaintRectNotIncludingVisualOverflow( | 194 LayoutRect paint_rect = PaintRectNotIncludingVisualOverflow( |
| 195 paint_offset + layout_table_cell_.Location()); | 195 paint_offset + layout_table_cell_.Location()); |
| 196 PaintBackground(paint_info, paint_rect, background_object); | 196 PaintBackground(paint_info, paint_rect, background_object); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void TableCellPainter::PaintBackground(const PaintInfo& paint_info, | 199 void TableCellPainter::PaintBackground(const PaintInfo& paint_info, |
| 200 const LayoutRect& paint_rect, | 200 const LayoutRect& paint_rect, |
| 201 const LayoutObject& background_object) { | 201 const LayoutObject& background_object) { |
| 202 if (layout_table_cell_.BackgroundStolenForBeingBody()) | 202 if (layout_table_cell_.BackgroundStolenForBeingBody()) |
| 203 return; | 203 return; |
| 204 | 204 |
| 205 Color c = background_object.ResolveColor(CSSPropertyBackgroundColor); | 205 Color c = background_object.ResolveColor(CSSPropertyBackgroundColor); |
| 206 const FillLayer& bg_layer = background_object.StyleRef().BackgroundLayers(); | 206 const FillLayer& bg_layer = background_object.StyleRef().BackgroundLayers(); |
| 207 if (bg_layer.HasImage() || c.Alpha()) { | 207 if (bg_layer.HasImage() || c.Alpha()) { |
| 208 // We have to clip here because the background would paint | 208 // We have to clip here because the background would paint |
| 209 // on top of the borders otherwise. This only matters for cells and rows. | 209 // on top of the borders otherwise. This only matters for cells and rows. |
| 210 bool should_clip = background_object.HasLayer() && | 210 bool should_clip = background_object.HasLayer() && |
| 211 (background_object == layout_table_cell_ || | 211 (background_object == layout_table_cell_ || |
| 212 background_object == layout_table_cell_.Parent()) && | 212 background_object == layout_table_cell_.Parent()) && |
| 213 layout_table_cell_.Table()->CollapseBorders(); | 213 layout_table_cell_.Table()->ShouldCollapseBorders(); |
| 214 GraphicsContextStateSaver state_saver(paint_info.context, should_clip); | 214 GraphicsContextStateSaver state_saver(paint_info.context, should_clip); |
| 215 if (should_clip) { | 215 if (should_clip) { |
| 216 LayoutRect clip_rect(paint_rect.Location(), layout_table_cell_.Size()); | 216 LayoutRect clip_rect(paint_rect.Location(), layout_table_cell_.Size()); |
| 217 clip_rect.Expand(layout_table_cell_.BorderInsets()); | 217 clip_rect.Expand(layout_table_cell_.BorderInsets()); |
| 218 paint_info.context.Clip(PixelSnappedIntRect(clip_rect)); | 218 paint_info.context.Clip(PixelSnappedIntRect(clip_rect)); |
| 219 } | 219 } |
| 220 BoxPainter(layout_table_cell_) | 220 BoxPainter(layout_table_cell_) |
| 221 .PaintFillLayers(paint_info, c, bg_layer, paint_rect, | 221 .PaintFillLayers(paint_info, c, bg_layer, paint_rect, |
| 222 kBackgroundBleedNone, SkBlendMode::kSrcOver, | 222 kBackgroundBleedNone, SkBlendMode::kSrcOver, |
| 223 &background_object); | 223 &background_object); |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 | 226 |
| 227 void TableCellPainter::PaintBoxDecorationBackground( | 227 void TableCellPainter::PaintBoxDecorationBackground( |
| 228 const PaintInfo& paint_info, | 228 const PaintInfo& paint_info, |
| 229 const LayoutPoint& paint_offset) { | 229 const LayoutPoint& paint_offset) { |
| 230 LayoutTable* table = layout_table_cell_.Table(); | 230 LayoutTable* table = layout_table_cell_.Table(); |
| 231 const ComputedStyle& style = layout_table_cell_.StyleRef(); | 231 const ComputedStyle& style = layout_table_cell_.StyleRef(); |
| 232 if (!table->CollapseBorders() && style.EmptyCells() == EEmptyCells::kHide && | 232 if (!table->ShouldCollapseBorders() && |
| 233 style.EmptyCells() == EEmptyCells::kHide && |
| 233 !layout_table_cell_.FirstChild()) | 234 !layout_table_cell_.FirstChild()) |
| 234 return; | 235 return; |
| 235 | 236 |
| 236 bool needs_to_paint_border = | 237 bool needs_to_paint_border = |
| 237 style.HasBorderDecoration() && !table->CollapseBorders(); | 238 style.HasBorderDecoration() && !table->ShouldCollapseBorders(); |
| 238 if (!style.HasBackground() && !style.BoxShadow() && !needs_to_paint_border) | 239 if (!style.HasBackground() && !style.BoxShadow() && !needs_to_paint_border) |
| 239 return; | 240 return; |
| 240 | 241 |
| 241 if (LayoutObjectDrawingRecorder::UseCachedDrawingIfPossible( | 242 if (LayoutObjectDrawingRecorder::UseCachedDrawingIfPossible( |
| 242 paint_info.context, layout_table_cell_, | 243 paint_info.context, layout_table_cell_, |
| 243 DisplayItem::kBoxDecorationBackground)) | 244 DisplayItem::kBoxDecorationBackground)) |
| 244 return; | 245 return; |
| 245 | 246 |
| 246 LayoutRect visual_overflow_rect = layout_table_cell_.VisualOverflowRect(); | 247 LayoutRect visual_overflow_rect = layout_table_cell_.VisualOverflowRect(); |
| 247 visual_overflow_rect.MoveBy(paint_offset); | 248 visual_overflow_rect.MoveBy(paint_offset); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 265 BoxPainter::PaintBorder(layout_table_cell_, paint_info, paint_rect, style); | 266 BoxPainter::PaintBorder(layout_table_cell_, paint_info, paint_rect, style); |
| 266 } | 267 } |
| 267 | 268 |
| 268 void TableCellPainter::PaintMask(const PaintInfo& paint_info, | 269 void TableCellPainter::PaintMask(const PaintInfo& paint_info, |
| 269 const LayoutPoint& paint_offset) { | 270 const LayoutPoint& paint_offset) { |
| 270 if (layout_table_cell_.Style()->Visibility() != EVisibility::kVisible || | 271 if (layout_table_cell_.Style()->Visibility() != EVisibility::kVisible || |
| 271 paint_info.phase != kPaintPhaseMask) | 272 paint_info.phase != kPaintPhaseMask) |
| 272 return; | 273 return; |
| 273 | 274 |
| 274 LayoutTable* table_elt = layout_table_cell_.Table(); | 275 LayoutTable* table_elt = layout_table_cell_.Table(); |
| 275 if (!table_elt->CollapseBorders() && | 276 if (!table_elt->ShouldCollapseBorders() && |
| 276 layout_table_cell_.Style()->EmptyCells() == EEmptyCells::kHide && | 277 layout_table_cell_.Style()->EmptyCells() == EEmptyCells::kHide && |
| 277 !layout_table_cell_.FirstChild()) | 278 !layout_table_cell_.FirstChild()) |
| 278 return; | 279 return; |
| 279 | 280 |
| 280 if (LayoutObjectDrawingRecorder::UseCachedDrawingIfPossible( | 281 if (LayoutObjectDrawingRecorder::UseCachedDrawingIfPossible( |
| 281 paint_info.context, layout_table_cell_, paint_info.phase)) | 282 paint_info.context, layout_table_cell_, paint_info.phase)) |
| 282 return; | 283 return; |
| 283 | 284 |
| 284 LayoutRect paint_rect = PaintRectNotIncludingVisualOverflow(paint_offset); | 285 LayoutRect paint_rect = PaintRectNotIncludingVisualOverflow(paint_offset); |
| 285 LayoutObjectDrawingRecorder recorder(paint_info.context, layout_table_cell_, | 286 LayoutObjectDrawingRecorder recorder(paint_info.context, layout_table_cell_, |
| 286 paint_info.phase, paint_rect); | 287 paint_info.phase, paint_rect); |
| 287 BoxPainter(layout_table_cell_).PaintMaskImages(paint_info, paint_rect); | 288 BoxPainter(layout_table_cell_).PaintMaskImages(paint_info, paint_rect); |
| 288 } | 289 } |
| 289 | 290 |
| 290 LayoutRect TableCellPainter::PaintRectNotIncludingVisualOverflow( | 291 LayoutRect TableCellPainter::PaintRectNotIncludingVisualOverflow( |
| 291 const LayoutPoint& paint_offset) { | 292 const LayoutPoint& paint_offset) { |
| 292 return LayoutRect(paint_offset, | 293 return LayoutRect(paint_offset, |
| 293 LayoutSize(layout_table_cell_.PixelSnappedSize())); | 294 LayoutSize(layout_table_cell_.PixelSnappedSize())); |
| 294 } | 295 } |
| 295 | 296 |
| 296 } // namespace blink | 297 } // namespace blink |
| OLD | NEW |