| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 const LayoutTableCell::CollapsedBorderValues* values = m_layoutTableCell.col
lapsedBorderValues(); | 68 const LayoutTableCell::CollapsedBorderValues* values = m_layoutTableCell.col
lapsedBorderValues(); |
| 69 if (!values) | 69 if (!values) |
| 70 return; | 70 return; |
| 71 | 71 |
| 72 const ComputedStyle& styleForCellFlow = m_layoutTableCell.styleForCellFlow()
; | 72 const ComputedStyle& styleForCellFlow = m_layoutTableCell.styleForCellFlow()
; |
| 73 const CollapsedBorderValue& leftBorderValue = collapsedLeftBorder(styleForCe
llFlow, *values); | 73 const CollapsedBorderValue& leftBorderValue = collapsedLeftBorder(styleForCe
llFlow, *values); |
| 74 const CollapsedBorderValue& rightBorderValue = collapsedRightBorder(styleFor
CellFlow, *values); | 74 const CollapsedBorderValue& rightBorderValue = collapsedRightBorder(styleFor
CellFlow, *values); |
| 75 const CollapsedBorderValue& topBorderValue = collapsedTopBorder(styleForCell
Flow, *values); | 75 const CollapsedBorderValue& topBorderValue = collapsedTopBorder(styleForCell
Flow, *values); |
| 76 const CollapsedBorderValue& bottomBorderValue = collapsedBottomBorder(styleF
orCellFlow, *values); | 76 const CollapsedBorderValue& bottomBorderValue = collapsedBottomBorder(styleF
orCellFlow, *values); |
| 77 | 77 |
| 78 int displayItemType = DisplayItem::TableCollapsedBorderBase; | 78 int displayItemType = DisplayItem::kTableCollapsedBorderBase; |
| 79 if (topBorderValue.shouldPaint(currentBorderValue)) | 79 if (topBorderValue.shouldPaint(currentBorderValue)) |
| 80 displayItemType |= DisplayItem::TableCollapsedBorderTop; | 80 displayItemType |= DisplayItem::TableCollapsedBorderTop; |
| 81 if (bottomBorderValue.shouldPaint(currentBorderValue)) | 81 if (bottomBorderValue.shouldPaint(currentBorderValue)) |
| 82 displayItemType |= DisplayItem::TableCollapsedBorderBottom; | 82 displayItemType |= DisplayItem::TableCollapsedBorderBottom; |
| 83 if (leftBorderValue.shouldPaint(currentBorderValue)) | 83 if (leftBorderValue.shouldPaint(currentBorderValue)) |
| 84 displayItemType |= DisplayItem::TableCollapsedBorderLeft; | 84 displayItemType |= DisplayItem::TableCollapsedBorderLeft; |
| 85 if (rightBorderValue.shouldPaint(currentBorderValue)) | 85 if (rightBorderValue.shouldPaint(currentBorderValue)) |
| 86 displayItemType |= DisplayItem::TableCollapsedBorderRight; | 86 displayItemType |= DisplayItem::TableCollapsedBorderRight; |
| 87 if (displayItemType == DisplayItem::TableCollapsedBorderBase) | 87 if (displayItemType == DisplayItem::kTableCollapsedBorderBase) |
| 88 return; | 88 return; |
| 89 | 89 |
| 90 int topWidth = topBorderValue.width(); | 90 int topWidth = topBorderValue.width(); |
| 91 int bottomWidth = bottomBorderValue.width(); | 91 int bottomWidth = bottomBorderValue.width(); |
| 92 int leftWidth = leftBorderValue.width(); | 92 int leftWidth = leftBorderValue.width(); |
| 93 int rightWidth = rightBorderValue.width(); | 93 int rightWidth = rightBorderValue.width(); |
| 94 | 94 |
| 95 // Adjust our x/y/width/height so that we paint the collapsed borders at the
correct location. | 95 // Adjust our x/y/width/height so that we paint the collapsed borders at the
correct location. |
| 96 LayoutRect paintRect = paintRectNotIncludingVisualOverflow(adjustedPaintOffs
et); | 96 LayoutRect paintRect = paintRectNotIncludingVisualOverflow(adjustedPaintOffs
et); |
| 97 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2, | 97 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 void TableCellPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo,
const LayoutPoint& paintOffset) | 173 void TableCellPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo,
const LayoutPoint& paintOffset) |
| 174 { | 174 { |
| 175 LayoutTable* table = m_layoutTableCell.table(); | 175 LayoutTable* table = m_layoutTableCell.table(); |
| 176 if (!table->collapseBorders() && m_layoutTableCell.style()->emptyCells() ==
EmptyCellsHide && !m_layoutTableCell.firstChild()) | 176 if (!table->collapseBorders() && m_layoutTableCell.style()->emptyCells() ==
EmptyCellsHide && !m_layoutTableCell.firstChild()) |
| 177 return; | 177 return; |
| 178 | 178 |
| 179 bool needsToPaintBorder = m_layoutTableCell.styleRef().hasBorderDecoration()
&& !table->collapseBorders(); | 179 bool needsToPaintBorder = m_layoutTableCell.styleRef().hasBorderDecoration()
&& !table->collapseBorders(); |
| 180 if (!m_layoutTableCell.styleRef().hasBackground() && !m_layoutTableCell.styl
eRef().boxShadow() && !needsToPaintBorder) | 180 if (!m_layoutTableCell.styleRef().hasBackground() && !m_layoutTableCell.styl
eRef().boxShadow() && !needsToPaintBorder) |
| 181 return; | 181 return; |
| 182 | 182 |
| 183 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutTableCell, DisplayItem::BoxDecorationBackground)) | 183 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutTableCell, DisplayItem::kBoxDecorationBackground)) |
| 184 return; | 184 return; |
| 185 | 185 |
| 186 LayoutRect visualOverflowRect = m_layoutTableCell.visualOverflowRect(); | 186 LayoutRect visualOverflowRect = m_layoutTableCell.visualOverflowRect(); |
| 187 visualOverflowRect.moveBy(paintOffset); | 187 visualOverflowRect.moveBy(paintOffset); |
| 188 // TODO(chrishtr): the pixel-snapping here is likely incorrect. | 188 // TODO(chrishtr): the pixel-snapping here is likely incorrect. |
| 189 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableCell, D
isplayItem::BoxDecorationBackground, pixelSnappedIntRect(visualOverflowRect)); | 189 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableCell, D
isplayItem::kBoxDecorationBackground, pixelSnappedIntRect(visualOverflowRect)); |
| 190 | 190 |
| 191 LayoutRect paintRect = paintRectNotIncludingVisualOverflow(paintOffset); | 191 LayoutRect paintRect = paintRectNotIncludingVisualOverflow(paintOffset); |
| 192 | 192 |
| 193 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(
), Normal); | 193 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(
), Normal); |
| 194 paintBackground(paintInfo, paintRect, m_layoutTableCell); | 194 paintBackground(paintInfo, paintRect, m_layoutTableCell); |
| 195 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(
), Inset); | 195 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(
), Inset); |
| 196 | 196 |
| 197 if (!needsToPaintBorder) | 197 if (!needsToPaintBorder) |
| 198 return; | 198 return; |
| 199 | 199 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 217 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect); | 217 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect); |
| 218 } | 218 } |
| 219 | 219 |
| 220 LayoutRect TableCellPainter::paintRectNotIncludingVisualOverflow(const LayoutPoi
nt& paintOffset) | 220 LayoutRect TableCellPainter::paintRectNotIncludingVisualOverflow(const LayoutPoi
nt& paintOffset) |
| 221 { | 221 { |
| 222 return LayoutRect(paintOffset, LayoutSize(m_layoutTableCell.pixelSnappedSize
())); | 222 return LayoutRect(paintOffset, LayoutSize(m_layoutTableCell.pixelSnappedSize
())); |
| 223 } | 223 } |
| 224 | 224 |
| 225 } // namespace blink | 225 } // namespace blink |
| 226 | 226 |
| OLD | NEW |