Chromium Code Reviews| 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/TablePainter.h" | 5 #include "core/paint/TablePainter.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutTable.h" | 7 #include "core/layout/LayoutTable.h" |
| 8 #include "core/layout/LayoutTableSection.h" | 8 #include "core/layout/LayoutTableSection.h" |
| 9 #include "core/layout/LayoutView.h" | |
| 9 #include "core/style/CollapsedBorderValue.h" | 10 #include "core/style/CollapsedBorderValue.h" |
| 10 #include "core/paint/BoxClipper.h" | 11 #include "core/paint/BoxClipper.h" |
| 11 #include "core/paint/BoxPainter.h" | 12 #include "core/paint/BoxPainter.h" |
| 12 #include "core/paint/LayoutObjectDrawingRecorder.h" | 13 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 13 #include "core/paint/ObjectPainter.h" | 14 #include "core/paint/ObjectPainter.h" |
| 14 #include "core/paint/PaintInfo.h" | 15 #include "core/paint/PaintInfo.h" |
| 15 #include "core/paint/ScopeRecorder.h" | 16 #include "core/paint/ScopeRecorder.h" |
| 16 #include "core/paint/TableSectionPainter.h" | 17 #include "core/paint/TableSectionPainter.h" |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 | 20 |
| 21 void TablePainter::paintRepeatingHeaderGroup(const PaintInfo& paintInfo, const L ayoutPoint& paintOffset, LayoutBox* child, const CollapsedBorderValue& currentBo rderValue, ItemToPaint itemToPaint) | |
|
Xianzhu
2016/05/31 02:11:33
Pass paintInfoForDescendants from caller, then you
Xianzhu
2016/06/01 19:19:39
s/LayoutBox* child/const LayoutTableSection& heade
| |
| 22 { | |
| 23 if (m_layoutTable.header() != child) | |
| 24 return; | |
| 25 if (child->getPaginationBreakability() == LayoutTableBoxComponent::AllowAnyB reaks) | |
|
Xianzhu
2016/05/31 02:11:33
Use LayoutBox::AllowAnyBreaks.
| |
| 26 return; | |
| 27 LayoutUnit printedPageLogicalHeight = child->view() ? child->view()->pageLog icalHeight() : LayoutUnit(); | |
| 28 LayoutUnit pageHeight = std::max(printedPageLogicalHeight, m_layoutTable.flo wThreadContainingBlock() ? m_layoutTable.pageLogicalHeightForOffset(LayoutUnit() ) : LayoutUnit()); | |
| 29 if (!pageHeight) | |
| 30 return; | |
| 31 | |
| 32 int pages = static_cast<int>(ceilf(m_layoutTable.logicalHeight() / pageHeigh t)); | |
| 33 LayoutPoint paginationOffset = paintOffset; | |
| 34 paginationOffset += LayoutPoint(0, pageHeight - m_layoutTable.pageLogicalOff set()); | |
| 35 for (int i = 1; i < pages; i++) { | |
| 36 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChild(child, paginationOffset); | |
| 37 if (itemToPaint == PaintCollapsedBorders) { | |
| 38 LayoutTableSection* section = toLayoutTableSection(child); | |
| 39 TableSectionPainter(*section).paintCollapsedBorders(paintInfo.forDes cendants(), childPoint, currentBorderValue); | |
|
Xianzhu
2016/06/01 19:19:39
Move the common code (LayoutTableSection* section
| |
| 40 } else { | |
| 41 child->paint(paintInfo.forDescendants(), childPoint); | |
| 42 } | |
| 43 paginationOffset += LayoutPoint(0, pageHeight); | |
| 44 } | |
|
Xianzhu
2016/05/31 02:11:34
We paint each page as a layer fragment in PaintLay
rhogan
2016/06/01 18:39:46
Right, but table headers don't have a layer - so t
Xianzhu
2016/06/01 19:19:39
I think this is the right place (and TableSectionP
| |
| 45 } | |
| 46 | |
| 20 void TablePainter::paintObject(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) | 47 void TablePainter::paintObject(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) |
| 21 { | 48 { |
| 22 PaintPhase paintPhase = paintInfo.phase; | 49 PaintPhase paintPhase = paintInfo.phase; |
| 23 | 50 |
| 24 if (shouldPaintSelfBlockBackground(paintPhase)) { | 51 if (shouldPaintSelfBlockBackground(paintPhase)) { |
| 25 paintBoxDecorationBackground(paintInfo, paintOffset); | 52 paintBoxDecorationBackground(paintInfo, paintOffset); |
| 26 if (paintPhase == PaintPhaseSelfBlockBackgroundOnly) | 53 if (paintPhase == PaintPhaseSelfBlockBackgroundOnly) |
| 27 return; | 54 return; |
| 28 } | 55 } |
| 29 | 56 |
| 30 if (paintPhase == PaintPhaseMask) { | 57 if (paintPhase == PaintPhaseMask) { |
| 31 paintMask(paintInfo, paintOffset); | 58 paintMask(paintInfo, paintOffset); |
| 32 return; | 59 return; |
| 33 } | 60 } |
| 34 | 61 |
| 35 if (paintPhase != PaintPhaseSelfOutlineOnly) { | 62 if (paintPhase != PaintPhaseSelfOutlineOnly) { |
| 36 PaintInfo paintInfoForDescendants = paintInfo.forDescendants(); | 63 PaintInfo paintInfoForDescendants = paintInfo.forDescendants(); |
| 37 | 64 |
| 38 for (LayoutObject* child = m_layoutTable.firstChild(); child; child = ch ild->nextSibling()) { | 65 for (LayoutObject* child = m_layoutTable.firstChild(); child; child = ch ild->nextSibling()) { |
| 39 if (child->isBox() && !toLayoutBox(child)->hasSelfPaintingLayer() && (child->isTableSection() || child->isTableCaption())) { | 66 if (child->isBox() && !toLayoutBox(child)->hasSelfPaintingLayer() && (child->isTableSection() || child->isTableCaption())) { |
| 40 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChil d(toLayoutBox(child), paintOffset); | 67 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChil d(toLayoutBox(child), paintOffset); |
| 41 child->paint(paintInfoForDescendants, childPoint); | 68 child->paint(paintInfoForDescendants, childPoint); |
| 69 paintRepeatingHeaderGroup(paintInfo, paintOffset, toLayoutBox(ch ild), CollapsedBorderValue(), PaintChild); | |
|
Xianzhu
2016/06/01 19:19:39
This should be in TableSectionPainter::paint(). Wi
| |
| 42 } | 70 } |
| 43 } | 71 } |
| 44 | 72 |
| 45 if (m_layoutTable.collapseBorders() && shouldPaintDescendantBlockBackgro unds(paintPhase) && m_layoutTable.style()->visibility() == VISIBLE) { | 73 if (m_layoutTable.collapseBorders() && shouldPaintDescendantBlockBackgro unds(paintPhase) && m_layoutTable.style()->visibility() == VISIBLE) { |
| 46 // Using our cached sorted styles, we then do individual passes, | 74 // Using our cached sorted styles, we then do individual passes, |
| 47 // painting each style of border from lowest precedence to highest p recedence. | 75 // painting each style of border from lowest precedence to highest p recedence. |
| 48 LayoutTable::CollapsedBorderValues collapsedBorders = m_layoutTable. collapsedBorders(); | 76 LayoutTable::CollapsedBorderValues collapsedBorders = m_layoutTable. collapsedBorders(); |
| 49 size_t count = collapsedBorders.size(); | 77 size_t count = collapsedBorders.size(); |
| 50 for (size_t i = 0; i < count; ++i) { | 78 for (size_t i = 0; i < count; ++i) { |
| 51 for (LayoutTableSection* section = m_layoutTable.bottomSection() ; section; section = m_layoutTable.sectionAbove(section)) { | 79 for (LayoutTableSection* section = m_layoutTable.bottomSection() ; section; section = m_layoutTable.sectionAbove(section)) { |
| 52 LayoutPoint childPoint = m_layoutTable.flipForWritingModeFor Child(section, paintOffset); | 80 LayoutPoint childPoint = m_layoutTable.flipForWritingModeFor Child(section, paintOffset); |
| 53 TableSectionPainter(*section).paintCollapsedBorders(paintInf oForDescendants, childPoint, collapsedBorders[i]); | 81 TableSectionPainter(*section).paintCollapsedBorders(paintInf oForDescendants, childPoint, collapsedBorders[i]); |
| 82 paintRepeatingHeaderGroup(paintInfo, paintOffset, section, c ollapsedBorders[i], PaintCollapsedBorders); | |
| 54 } | 83 } |
| 55 } | 84 } |
| 56 } | 85 } |
| 57 } | 86 } |
| 58 | 87 |
| 59 if (shouldPaintSelfOutline(paintPhase)) | 88 if (shouldPaintSelfOutline(paintPhase)) |
| 60 ObjectPainter(m_layoutTable).paintOutline(paintInfo, paintOffset); | 89 ObjectPainter(m_layoutTable).paintOutline(paintInfo, paintOffset); |
| 61 } | 90 } |
| 62 | 91 |
| 63 void TablePainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, cons t LayoutPoint& paintOffset) | 92 void TablePainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, cons t LayoutPoint& paintOffset) |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 79 return; | 108 return; |
| 80 | 109 |
| 81 LayoutRect rect(paintOffset, m_layoutTable.size()); | 110 LayoutRect rect(paintOffset, m_layoutTable.size()); |
| 82 m_layoutTable.subtractCaptionRect(rect); | 111 m_layoutTable.subtractCaptionRect(rect); |
| 83 | 112 |
| 84 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTable, paint Info.phase, rect); | 113 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTable, paint Info.phase, rect); |
| 85 BoxPainter(m_layoutTable).paintMaskImages(paintInfo, rect); | 114 BoxPainter(m_layoutTable).paintMaskImages(paintInfo, rect); |
| 86 } | 115 } |
| 87 | 116 |
| 88 } // namespace blink | 117 } // namespace blink |
| OLD | NEW |