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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/TableCellPainter.h" | 6 #include "core/paint/TableCellPainter.h" |
7 | 7 |
8 #include "core/layout/LayoutTableCell.h" | 8 #include "core/layout/LayoutTableCell.h" |
9 #include "core/paint/BlockPainter.h" | 9 #include "core/paint/BlockPainter.h" |
10 #include "core/paint/BoxPainter.h" | 10 #include "core/paint/BoxPainter.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 LayoutRect paintRect = paintBounds(paintOffset, backgroundObject != &m_layou
tTableCell ? AddOffsetFromParent : DoNotAddOffsetFromParent); | 160 LayoutRect paintRect = paintBounds(paintOffset, backgroundObject != &m_layou
tTableCell ? AddOffsetFromParent : DoNotAddOffsetFromParent); |
161 | 161 |
162 if (bgLayer.hasImage() || c.alpha()) { | 162 if (bgLayer.hasImage() || c.alpha()) { |
163 // We have to clip here because the background would paint | 163 // We have to clip here because the background would paint |
164 // on top of the borders otherwise. This only matters for cells and row
s. | 164 // on top of the borders otherwise. This only matters for cells and row
s. |
165 bool shouldClip = backgroundObject->hasLayer() && (backgroundObject == &
m_layoutTableCell || backgroundObject == m_layoutTableCell.parent()) && tableElt
->collapseBorders(); | 165 bool shouldClip = backgroundObject->hasLayer() && (backgroundObject == &
m_layoutTableCell || backgroundObject == m_layoutTableCell.parent()) && tableElt
->collapseBorders(); |
166 GraphicsContextStateSaver stateSaver(*paintInfo.context, shouldClip); | 166 GraphicsContextStateSaver stateSaver(*paintInfo.context, shouldClip); |
167 if (shouldClip) { | 167 if (shouldClip) { |
168 LayoutRect clipRect(paintRect.location(), m_layoutTableCell.size()); | 168 LayoutRect clipRect(paintRect.location(), m_layoutTableCell.size()); |
169 clipRect.expand(m_layoutTableCell.borderInsets()); | 169 clipRect.expand(m_layoutTableCell.borderInsets()); |
170 paintInfo.context->clip(clipRect); | 170 // TODO(chrishtr): should this be pixel-snapped? |
| 171 paintInfo.context->clip(FloatRect(clipRect)); |
171 } | 172 } |
172 BoxPainter(m_layoutTableCell).paintFillLayers(paintInfo, c, bgLayer, pai
ntRect, BackgroundBleedNone, SkXfermode::kSrcOver_Mode, backgroundObject); | 173 BoxPainter(m_layoutTableCell).paintFillLayers(paintInfo, c, bgLayer, pai
ntRect, BackgroundBleedNone, SkXfermode::kSrcOver_Mode, backgroundObject); |
173 } | 174 } |
174 } | 175 } |
175 | 176 |
176 void TableCellPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo,
const LayoutPoint& paintOffset) | 177 void TableCellPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo,
const LayoutPoint& paintOffset) |
177 { | 178 { |
178 if (!paintInfo.shouldPaintWithinRoot(&m_layoutTableCell)) | 179 if (!paintInfo.shouldPaintWithinRoot(&m_layoutTableCell)) |
179 return; | 180 return; |
180 | 181 |
181 LayoutTable* table = m_layoutTableCell.table(); | 182 LayoutTable* table = m_layoutTableCell.table(); |
182 if (!table->collapseBorders() && m_layoutTableCell.style()->emptyCells() ==
HIDE && !m_layoutTableCell.firstChild()) | 183 if (!table->collapseBorders() && m_layoutTableCell.style()->emptyCells() ==
HIDE && !m_layoutTableCell.firstChild()) |
183 return; | 184 return; |
184 | 185 |
185 bool needsToPaintBorder = m_layoutTableCell.styleRef().hasBorderDecoration()
&& !table->collapseBorders(); | 186 bool needsToPaintBorder = m_layoutTableCell.styleRef().hasBorderDecoration()
&& !table->collapseBorders(); |
186 if (!m_layoutTableCell.hasBackground() && !m_layoutTableCell.styleRef().boxS
hadow() && !needsToPaintBorder) | 187 if (!m_layoutTableCell.hasBackground() && !m_layoutTableCell.styleRef().boxS
hadow() && !needsToPaintBorder) |
187 return; | 188 return; |
188 | 189 |
189 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutTableCell, DisplayItem::BoxDecorationBackground)) | 190 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutTableCell, DisplayItem::BoxDecorationBackground)) |
190 return; | 191 return; |
191 | 192 |
192 LayoutRect visualOverflowRect = m_layoutTableCell.visualOverflowRect(); | 193 LayoutRect visualOverflowRect = m_layoutTableCell.visualOverflowRect(); |
193 visualOverflowRect.moveBy(paintOffset); | 194 visualOverflowRect.moveBy(paintOffset); |
| 195 // TODO(chrishtr): the pixel-snapping here is likely incorrect. |
194 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell,
DisplayItem::BoxDecorationBackground, pixelSnappedIntRect(visualOverflowRect)); | 196 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell,
DisplayItem::BoxDecorationBackground, pixelSnappedIntRect(visualOverflowRect)); |
195 | 197 |
196 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent); | 198 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent); |
197 | 199 |
198 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(
), Normal); | 200 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(
), Normal); |
199 | 201 |
200 // Paint our cell background. | 202 // Paint our cell background. |
201 paintBackgroundsBehindCell(paintInfo, paintOffset, &m_layoutTableCell); | 203 paintBackgroundsBehindCell(paintInfo, paintOffset, &m_layoutTableCell); |
202 | 204 |
203 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(
), Inset); | 205 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(
), Inset); |
(...skipping 24 matching lines...) Expand all Loading... |
228 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo
undOffsetBehavior paintBoundOffsetBehavior) | 230 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo
undOffsetBehavior paintBoundOffsetBehavior) |
229 { | 231 { |
230 LayoutPoint adjustedPaintOffset = paintOffset; | 232 LayoutPoint adjustedPaintOffset = paintOffset; |
231 if (paintBoundOffsetBehavior == AddOffsetFromParent) | 233 if (paintBoundOffsetBehavior == AddOffsetFromParent) |
232 adjustedPaintOffset.moveBy(m_layoutTableCell.location()); | 234 adjustedPaintOffset.moveBy(m_layoutTableCell.location()); |
233 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna
ppedSize())); | 235 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna
ppedSize())); |
234 } | 236 } |
235 | 237 |
236 } // namespace blink | 238 } // namespace blink |
237 | 239 |
OLD | NEW |