Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: third_party/WebKit/Source/core/paint/BlockPainter.cpp

Issue 1562183002: ObjectPainter::paintAsStackingContext() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 void BlockPainter::paintChild(const LayoutBox& child, const PaintInfo& paintInfo , const LayoutPoint& paintOffset) 92 void BlockPainter::paintChild(const LayoutBox& child, const PaintInfo& paintInfo , const LayoutPoint& paintOffset)
93 { 93 {
94 LayoutPoint childPoint = m_layoutBlock.flipForWritingModeForChild(&child, pa intOffset); 94 LayoutPoint childPoint = m_layoutBlock.flipForWritingModeForChild(&child, pa intOffset);
95 if (!child.hasSelfPaintingLayer() && !child.isFloating() && !child.isColumnS panAll()) 95 if (!child.hasSelfPaintingLayer() && !child.isFloating() && !child.isColumnS panAll())
96 child.paint(paintInfo, childPoint); 96 child.paint(paintInfo, childPoint);
97 } 97 }
98 98
99 void BlockPainter::paintChildrenOfFlexibleBox(const LayoutFlexibleBox& layoutFle xibleBox, const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 99 void BlockPainter::paintChildrenOfFlexibleBox(const LayoutFlexibleBox& layoutFle xibleBox, const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
100 { 100 {
101 for (const LayoutBox* child = layoutFlexibleBox.orderIterator().first(); chi ld; child = layoutFlexibleBox.orderIterator().next()) 101 for (const LayoutBox* child = layoutFlexibleBox.orderIterator().first(); chi ld; child = layoutFlexibleBox.orderIterator().next())
102 BlockPainter(layoutFlexibleBox).paintChildAsInlineBlock(*child, paintInf o, paintOffset); 102 BlockPainter(layoutFlexibleBox).paintChildAsPseudoStackingContext(*child , paintInfo, paintOffset);
103 } 103 }
104 104
105 void BlockPainter::paintChildAsInlineBlock(const LayoutBox& child, const PaintIn fo& paintInfo, const LayoutPoint& paintOffset) 105 void BlockPainter::paintChildAsPseudoStackingContext(const LayoutBox& child, con st PaintInfo& paintInfo, const LayoutPoint& paintOffset)
106 { 106 {
107 LayoutPoint childPoint = m_layoutBlock.flipForWritingModeForChild(&child, pa intOffset); 107 LayoutPoint childPoint = m_layoutBlock.flipForWritingModeForChild(&child, pa intOffset);
108 if (!child.hasSelfPaintingLayer() && !child.isFloating()) 108 if (!child.hasSelfPaintingLayer() && !child.isFloating())
109 paintAsInlineBlock(child, paintInfo, childPoint); 109 ObjectPainter(child).paintAsPseudoStackingContext(paintInfo, childPoint) ;
110 } 110 }
111 111
112 void BlockPainter::paintInlineBox(const InlineBox& inlineBox, const PaintInfo& p aintInfo, const LayoutPoint& paintOffset) 112 void BlockPainter::paintInlineBox(const InlineBox& inlineBox, const PaintInfo& p aintInfo, const LayoutPoint& paintOffset)
113 { 113 {
114 if (!paintInfo.shouldPaintWithinRoot(&inlineBox.layoutObject()) || (paintInf o.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection)) 114 if (!paintInfo.shouldPaintWithinRoot(&inlineBox.layoutObject()) || (paintInf o.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection))
115 return; 115 return;
116 116
117 LayoutPoint childPoint = paintOffset; 117 LayoutPoint childPoint = paintOffset;
118 if (inlineBox.parent()->lineLayoutItem().style()->isFlippedBlocksWritingMode ()) // Faster than calling containingBlock(). 118 if (inlineBox.parent()->lineLayoutItem().style()->isFlippedBlocksWritingMode ()) // Faster than calling containingBlock().
119 childPoint = inlineBox.layoutObject().containingBlock()->flipForWritingM odeForChild(&toLayoutBox(inlineBox.layoutObject()), childPoint); 119 childPoint = inlineBox.layoutObject().containingBlock()->flipForWritingM odeForChild(&toLayoutBox(inlineBox.layoutObject()), childPoint);
120 120
121 paintAsInlineBlock(inlineBox.layoutObject(), paintInfo, childPoint); 121 ObjectPainter(inlineBox.layoutObject()).paintAsPseudoStackingContext(paintIn fo, childPoint);
122 }
123
124 void BlockPainter::paintAsInlineBlock(const LayoutObject& layoutObject, const Pa intInfo& paintInfo, const LayoutPoint& childPoint)
125 {
126 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase Selection)
127 return;
128
129 // Paint all phases atomically, as though the element established its own
130 // stacking context. (See Appendix E.2, section 7.2.1.4 on
131 // inline block/table/replaced elements in the CSS2.1 specification.)
132 // This is also used by other elements (e.g. flex items and grid items).
133 bool preservePhase = paintInfo.phase == PaintPhaseSelection || paintInfo.pha se == PaintPhaseTextClip;
134 PaintInfo info(paintInfo);
135 info.phase = preservePhase ? paintInfo.phase : PaintPhaseBlockBackground;
136 layoutObject.paint(info, childPoint);
137 if (!preservePhase) {
138 info.phase = PaintPhaseChildBlockBackgrounds;
139 layoutObject.paint(info, childPoint);
140 info.phase = PaintPhaseFloat;
141 layoutObject.paint(info, childPoint);
142 info.phase = PaintPhaseForeground;
143 layoutObject.paint(info, childPoint);
144 info.phase = PaintPhaseOutline;
145 layoutObject.paint(info, childPoint);
146 }
147 } 122 }
148 123
149 void BlockPainter::paintObject(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) 124 void BlockPainter::paintObject(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset)
150 { 125 {
151 if (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && m_layoutB lock.childrenInline() && !paintInfo.context.paintController().skippingCache()) { 126 if (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && m_layoutB lock.childrenInline() && !paintInfo.context.paintController().skippingCache()) {
152 if (m_layoutBlock.paintOffsetChanged(paintOffset)) { 127 if (m_layoutBlock.paintOffsetChanged(paintOffset)) {
153 LineBoxListPainter(m_layoutBlock.lineBoxes()).invalidateLineBoxPaint Offsets(paintInfo); 128 LineBoxListPainter(m_layoutBlock.lineBoxes()).invalidateLineBoxPaint Offsets(paintInfo);
154 paintInfo.context.paintController().invalidatePaintOffset(m_layoutBl ock); 129 paintInfo.context.paintController().invalidatePaintOffset(m_layoutBl ock);
155 } 130 }
156 // Set previousPaintOffset here in case that m_layoutBlock paints nothin g and no 131 // Set previousPaintOffset here in case that m_layoutBlock paints nothin g and no
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 176
202 const PaintInfo& contentsPaintInfo = scrolledPaintInfo ? *scrolledPaintI nfo : paintInfo; 177 const PaintInfo& contentsPaintInfo = scrolledPaintInfo ? *scrolledPaintI nfo : paintInfo;
203 178
204 if (paintPhase != PaintPhaseSelfOutline) 179 if (paintPhase != PaintPhaseSelfOutline)
205 paintContents(contentsPaintInfo, paintOffset); 180 paintContents(contentsPaintInfo, paintOffset);
206 181
207 if (paintPhase == PaintPhaseForeground && !paintInfo.isPrinting()) 182 if (paintPhase == PaintPhaseForeground && !paintInfo.isPrinting())
208 m_layoutBlock.paintSelection(contentsPaintInfo, paintOffset); // Fil l in gaps in selection on lines and between blocks. 183 m_layoutBlock.paintSelection(contentsPaintInfo, paintOffset); // Fil l in gaps in selection on lines and between blocks.
209 184
210 if (paintPhase == PaintPhaseFloat || paintPhase == PaintPhaseSelection | | paintPhase == PaintPhaseTextClip) 185 if (paintPhase == PaintPhaseFloat || paintPhase == PaintPhaseSelection | | paintPhase == PaintPhaseTextClip)
211 m_layoutBlock.paintFloats(contentsPaintInfo, paintOffset, paintPhase == PaintPhaseSelection || paintPhase == PaintPhaseTextClip); 186 m_layoutBlock.paintFloats(contentsPaintInfo, paintOffset);
212 } 187 }
213 188
214 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) && m_layoutBlock.style()->hasOutline() && m_layoutBlock.style()->visibility() = = VISIBLE) 189 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) && m_layoutBlock.style()->hasOutline() && m_layoutBlock.style()->visibility() = = VISIBLE)
215 ObjectPainter(m_layoutBlock).paintOutline(paintInfo, paintOffset); 190 ObjectPainter(m_layoutBlock).paintOutline(paintInfo, paintOffset);
216 191
217 // If the caret's node's layout object's containing block is this block, and the paint action is PaintPhaseForeground, 192 // If the caret's node's layout object's containing block is this block, and the paint action is PaintPhaseForeground,
218 // then paint the caret. 193 // then paint the caret.
219 if (paintPhase == PaintPhaseForeground && m_layoutBlock.hasCaret() && !Layou tObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_layoutBl ock, DisplayItem::Caret, paintOffset)) { 194 if (paintPhase == PaintPhaseForeground && m_layoutBlock.hasCaret() && !Layou tObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_layoutBl ock, DisplayItem::Caret, paintOffset)) {
220 LayoutRect bounds = m_layoutBlock.visualOverflowRect(); 195 LayoutRect bounds = m_layoutBlock.visualOverflowRect();
221 bounds.moveBy(paintOffset); 196 bounds.moveBy(paintOffset);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 241
267 // We don't paint our own background, but we do let the kids paint their backgrounds. 242 // We don't paint our own background, but we do let the kids paint their backgrounds.
268 PaintInfo paintInfoForChild(paintInfo); 243 PaintInfo paintInfoForChild(paintInfo);
269 paintInfoForChild.phase = newPhase; 244 paintInfoForChild.phase = newPhase;
270 paintInfoForChild.updatePaintingRootForChildren(&m_layoutBlock); 245 paintInfoForChild.updatePaintingRootForChildren(&m_layoutBlock);
271 m_layoutBlock.paintChildren(paintInfoForChild, paintOffset); 246 m_layoutBlock.paintChildren(paintInfoForChild, paintOffset);
272 } 247 }
273 } 248 }
274 249
275 } // namespace blink 250 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/BlockPainter.h ('k') | third_party/WebKit/Source/core/paint/GridPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698