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/BlockPainter.h" | 5 #include "core/paint/BlockPainter.h" |
6 | 6 |
7 #include "core/editing/DragCaretController.h" | 7 #include "core/editing/DragCaretController.h" |
8 #include "core/editing/FrameSelection.h" | 8 #include "core/editing/FrameSelection.h" |
9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
10 #include "core/layout/LayoutBlockFlow.h" | 10 #include "core/layout/LayoutBlockFlow.h" |
11 #include "core/layout/LayoutFlexibleBox.h" | 11 #include "core/layout/LayoutFlexibleBox.h" |
12 #include "core/layout/LayoutInline.h" | 12 #include "core/layout/LayoutInline.h" |
13 #include "core/layout/LayoutView.h" | |
13 #include "core/layout/api/LineLayoutBox.h" | 14 #include "core/layout/api/LineLayoutBox.h" |
14 #include "core/page/Page.h" | 15 #include "core/page/Page.h" |
15 #include "core/paint/BoxClipper.h" | 16 #include "core/paint/BoxClipper.h" |
16 #include "core/paint/BoxPainter.h" | 17 #include "core/paint/BoxPainter.h" |
17 #include "core/paint/InlinePainter.h" | 18 #include "core/paint/InlinePainter.h" |
18 #include "core/paint/LayoutObjectDrawingRecorder.h" | 19 #include "core/paint/LayoutObjectDrawingRecorder.h" |
19 #include "core/paint/LineBoxListPainter.h" | 20 #include "core/paint/LineBoxListPainter.h" |
20 #include "core/paint/PaintInfo.h" | 21 #include "core/paint/PaintInfo.h" |
21 #include "core/paint/PaintLayer.h" | 22 #include "core/paint/PaintLayer.h" |
22 #include "core/paint/ScopeRecorder.h" | 23 #include "core/paint/ScopeRecorder.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 } else if (originalPhase == PaintPhaseChildBlockBackground) { | 63 } else if (originalPhase == PaintPhaseChildBlockBackground) { |
63 localPaintInfo.phase = originalPhase; | 64 localPaintInfo.phase = originalPhase; |
64 } | 65 } |
65 | 66 |
66 // Our scrollbar widgets paint exactly when we tell them to, so that they wo rk properly with | 67 // Our scrollbar widgets paint exactly when we tell them to, so that they wo rk properly with |
67 // z-index. We paint after we painted the background/border, so that the scr ollbars will | 68 // z-index. We paint after we painted the background/border, so that the scr ollbars will |
68 // sit above the background/border. | 69 // sit above the background/border. |
69 paintOverflowControlsIfNeeded(localPaintInfo, adjustedPaintOffset); | 70 paintOverflowControlsIfNeeded(localPaintInfo, adjustedPaintOffset); |
70 } | 71 } |
71 | 72 |
73 void BlockPainter::paintFixedPositionObjectsOnAllPages(const PaintInfo& localPai ntInfo, const LayoutPoint& paintOffset) | |
74 { | |
75 // For paged media, boxes with fixed positions are repeated on every page. | |
mstensho (USE GERRIT)
2016/01/11 19:54:51
I think this approach is wrong. This would be in t
rhogan
2016/01/14 12:10:44
OK I don't have enough of a clue about painting to
Xianzhu
2016/02/24 19:22:51
I also think the current patch is incorrect about
rhogan
2016/02/25 20:33:04
When I do that it doesn't paint at all.
--- a/th
| |
76 if (!m_layoutBlock.parent() || !m_layoutBlock.parent()->isLayoutView()) | |
77 return; | |
78 | |
79 LayoutView* view = toLayoutView(m_layoutBlock.parent()); | |
80 if (!view->pageLogicalHeight()) | |
81 return; | |
82 | |
83 TrackedLayoutBoxListHashSet* positionedDescendants = view->positionedObjects (); | |
84 if (!positionedDescendants) | |
85 return; | |
86 int pages = m_layoutBlock.logicalHeight() / view->pageLogicalHeight(); | |
87 for (auto* positionedObject : *positionedDescendants) { | |
88 if (positionedObject->style()->position() != FixedPosition) | |
89 continue; | |
90 LayoutPoint adjustedPaintOffset = paintOffset + toLayoutBlock(positioned Object)->location(); | |
91 for (int i = 0; i < pages; i++) { | |
92 adjustedPaintOffset += LayoutPoint(0, view->pageLogicalHeight()); | |
93 toLayoutBlock(positionedObject)->paintObject(localPaintInfo, adjuste dPaintOffset); | |
94 } | |
95 } | |
96 } | |
97 | |
72 void BlockPainter::paintOverflowControlsIfNeeded(const PaintInfo& paintInfo, con st LayoutPoint& paintOffset) | 98 void BlockPainter::paintOverflowControlsIfNeeded(const PaintInfo& paintInfo, con st LayoutPoint& paintOffset) |
73 { | 99 { |
74 PaintPhase phase = paintInfo.phase; | 100 PaintPhase phase = paintInfo.phase; |
75 if (m_layoutBlock.hasOverflowClip() && m_layoutBlock.style()->visibility() = = VISIBLE && (phase == PaintPhaseBlockBackground || phase == PaintPhaseChildBloc kBackground) && paintInfo.shouldPaintWithinRoot(&m_layoutBlock) && !paintInfo.pa intRootBackgroundOnly()) { | 101 if (m_layoutBlock.hasOverflowClip() && m_layoutBlock.style()->visibility() = = VISIBLE && (phase == PaintPhaseBlockBackground || phase == PaintPhaseChildBloc kBackground) && paintInfo.shouldPaintWithinRoot(&m_layoutBlock) && !paintInfo.pa intRootBackgroundOnly()) { |
76 Optional<ClipRecorder> clipRecorder; | 102 Optional<ClipRecorder> clipRecorder; |
77 if (!m_layoutBlock.layer()->isSelfPaintingLayer()) { | 103 if (!m_layoutBlock.layer()->isSelfPaintingLayer()) { |
78 LayoutRect clipRect = m_layoutBlock.borderBoxRect(); | 104 LayoutRect clipRect = m_layoutBlock.borderBoxRect(); |
79 clipRect.moveBy(paintOffset); | 105 clipRect.moveBy(paintOffset); |
80 clipRecorder.emplace(paintInfo.context, m_layoutBlock, DisplayItem:: ClipScrollbarsToBoxBounds, clipRect); | 106 clipRecorder.emplace(paintInfo.context, m_layoutBlock, DisplayItem:: ClipScrollbarsToBoxBounds, clipRect); |
81 } | 107 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 } else { | 289 } else { |
264 PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? Pai ntPhaseOutline : paintInfo.phase; | 290 PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? Pai ntPhaseOutline : paintInfo.phase; |
265 newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChi ldBlockBackground : newPhase; | 291 newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChi ldBlockBackground : newPhase; |
266 | 292 |
267 // We don't paint our own background, but we do let the kids paint their backgrounds. | 293 // We don't paint our own background, but we do let the kids paint their backgrounds. |
268 PaintInfo paintInfoForChild(paintInfo); | 294 PaintInfo paintInfoForChild(paintInfo); |
269 paintInfoForChild.phase = newPhase; | 295 paintInfoForChild.phase = newPhase; |
270 paintInfoForChild.updatePaintingRootForChildren(&m_layoutBlock); | 296 paintInfoForChild.updatePaintingRootForChildren(&m_layoutBlock); |
271 m_layoutBlock.paintChildren(paintInfoForChild, paintOffset); | 297 m_layoutBlock.paintChildren(paintInfoForChild, paintOffset); |
272 } | 298 } |
299 paintFixedPositionObjectsOnAllPages(paintInfo, paintOffset); | |
273 } | 300 } |
274 | 301 |
275 } // namespace blink | 302 } // namespace blink |
OLD | NEW |