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" | |
10 #include "core/layout/LayoutBlockFlow.h" | |
11 #include "core/layout/LayoutFlexibleBox.h" | 9 #include "core/layout/LayoutFlexibleBox.h" |
12 #include "core/layout/LayoutInline.h" | 10 #include "core/layout/LayoutInline.h" |
13 #include "core/layout/api/LineLayoutAPIShim.h" | 11 #include "core/layout/api/LineLayoutAPIShim.h" |
14 #include "core/layout/api/LineLayoutBox.h" | 12 #include "core/layout/api/LineLayoutBox.h" |
15 #include "core/page/Page.h" | 13 #include "core/page/Page.h" |
| 14 #include "core/paint/BlockFlowPainter.h" |
16 #include "core/paint/BoxClipper.h" | 15 #include "core/paint/BoxClipper.h" |
17 #include "core/paint/BoxPainter.h" | 16 #include "core/paint/BoxPainter.h" |
18 #include "core/paint/InlinePainter.h" | |
19 #include "core/paint/LayoutObjectDrawingRecorder.h" | 17 #include "core/paint/LayoutObjectDrawingRecorder.h" |
20 #include "core/paint/LineBoxListPainter.h" | |
21 #include "core/paint/ObjectPaintProperties.h" | 18 #include "core/paint/ObjectPaintProperties.h" |
22 #include "core/paint/PaintInfo.h" | 19 #include "core/paint/PaintInfo.h" |
23 #include "core/paint/PaintLayer.h" | 20 #include "core/paint/PaintLayer.h" |
24 #include "core/paint/ScopeRecorder.h" | |
25 #include "core/paint/ScrollRecorder.h" | 21 #include "core/paint/ScrollRecorder.h" |
26 #include "core/paint/ScrollableAreaPainter.h" | 22 #include "core/paint/ScrollableAreaPainter.h" |
27 #include "platform/graphics/paint/ClipRecorder.h" | 23 #include "platform/graphics/paint/ClipRecorder.h" |
28 #include "wtf/Optional.h" | 24 #include "wtf/Optional.h" |
29 | 25 |
30 namespace blink { | 26 namespace blink { |
31 | 27 |
32 void BlockPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOff
set) | 28 void BlockPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOff
set) |
33 { | 29 { |
34 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBlock.location(); | 30 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBlock.location(); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 scrollRecorder.emplace(paintInfo.context, m_layoutBlock, paintPh
ase, scrollOffset); | 170 scrollRecorder.emplace(paintInfo.context, m_layoutBlock, paintPh
ase, scrollOffset); |
175 scrolledPaintInfo.emplace(paintInfo); | 171 scrolledPaintInfo.emplace(paintInfo); |
176 AffineTransform transform; | 172 AffineTransform transform; |
177 transform.translate(-scrollOffset.width(), -scrollOffset.height(
)); | 173 transform.translate(-scrollOffset.width(), -scrollOffset.height(
)); |
178 scrolledPaintInfo->updateCullRect(transform); | 174 scrolledPaintInfo->updateCullRect(transform); |
179 } | 175 } |
180 } | 176 } |
181 | 177 |
182 const PaintInfo& contentsPaintInfo = scrolledPaintInfo ? *scrolledPaintI
nfo : paintInfo; | 178 const PaintInfo& contentsPaintInfo = scrolledPaintInfo ? *scrolledPaintI
nfo : paintInfo; |
183 | 179 |
184 paintContents(contentsPaintInfo, paintOffset); | 180 if (m_layoutBlock.isLayoutBlockFlow()) { |
185 | 181 BlockFlowPainter blockFlowPainter(toLayoutBlockFlow(m_layoutBlock)); |
186 if (paintPhase == PaintPhaseFloat || paintPhase == PaintPhaseSelection |
| paintPhase == PaintPhaseTextClip) | 182 blockFlowPainter.paintContents(contentsPaintInfo, paintOffset); |
187 m_layoutBlock.paintFloats(contentsPaintInfo, paintOffset); | 183 if (paintPhase == PaintPhaseFloat || paintPhase == PaintPhaseSelecti
on || paintPhase == PaintPhaseTextClip) |
| 184 blockFlowPainter.paintFloats(contentsPaintInfo, paintOffset); |
| 185 } else { |
| 186 paintContents(contentsPaintInfo, paintOffset); |
| 187 } |
188 } | 188 } |
189 | 189 |
190 if (shouldPaintSelfOutline(paintPhase)) | 190 if (shouldPaintSelfOutline(paintPhase)) |
191 ObjectPainter(m_layoutBlock).paintOutline(paintInfo, paintOffset); | 191 ObjectPainter(m_layoutBlock).paintOutline(paintInfo, paintOffset); |
192 | 192 |
193 // If the caret's node's layout object's containing block is this block, and
the paint action is PaintPhaseForeground, | 193 // If the caret's node's layout object's containing block is this block, and
the paint action is PaintPhaseForeground, |
194 // then paint the caret. | 194 // then paint the caret. |
195 if (paintPhase == PaintPhaseForeground && m_layoutBlock.hasCaret() && !Layou
tObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_layoutBl
ock, DisplayItem::Caret)) { | 195 if (paintPhase == PaintPhaseForeground && m_layoutBlock.hasCaret() && !Layou
tObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_layoutBl
ock, DisplayItem::Caret)) { |
196 LayoutRect bounds = m_layoutBlock.visualOverflowRect(); | 196 LayoutRect bounds = m_layoutBlock.visualOverflowRect(); |
197 bounds.moveBy(paintOffset); | 197 bounds.moveBy(paintOffset); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 overflowRect.unite(m_layoutBlock.layoutOverflowRect()); | 230 overflowRect.unite(m_layoutBlock.layoutOverflowRect()); |
231 overflowRect.move(-m_layoutBlock.scrolledContentOffset()); | 231 overflowRect.move(-m_layoutBlock.scrolledContentOffset()); |
232 } | 232 } |
233 m_layoutBlock.flipForWritingMode(overflowRect); | 233 m_layoutBlock.flipForWritingMode(overflowRect); |
234 overflowRect.moveBy(adjustedPaintOffset); | 234 overflowRect.moveBy(adjustedPaintOffset); |
235 return paintInfo.cullRect().intersectsCullRect(overflowRect); | 235 return paintInfo.cullRect().intersectsCullRect(overflowRect); |
236 } | 236 } |
237 | 237 |
238 void BlockPainter::paintContents(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) | 238 void BlockPainter::paintContents(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) |
239 { | 239 { |
240 // Avoid painting descendants of the root element when stylesheets haven't l
oaded. This eliminates FOUC. | 240 DCHECK(!m_layoutBlock.childrenInline()); |
241 // It's ok not to draw, because later on, when all the stylesheets do load,
styleResolverMayHaveChanged() | 241 PaintInfo paintInfoForDescendants = paintInfo.forDescendants(); |
242 // on Document will trigger a full paint invalidation. | 242 m_layoutBlock.paintChildren(paintInfoForDescendants, paintOffset); |
243 if (m_layoutBlock.document().didLayoutWithPendingStylesheets() && !m_layoutB
lock.isLayoutView()) | |
244 return; | |
245 | |
246 if (m_layoutBlock.childrenInline()) { | |
247 if (shouldPaintDescendantOutlines(paintInfo.phase)) | |
248 ObjectPainter(m_layoutBlock).paintInlineChildrenOutlines(paintInfo,
paintOffset); | |
249 else | |
250 LineBoxListPainter(m_layoutBlock.lineBoxes()).paint(m_layoutBlock, p
aintInfo, paintOffset); | |
251 } else { | |
252 PaintInfo paintInfoForDescendants = paintInfo.forDescendants(); | |
253 m_layoutBlock.paintChildren(paintInfoForDescendants, paintOffset); | |
254 } | |
255 } | 243 } |
256 | 244 |
257 } // namespace blink | 245 } // namespace blink |
OLD | NEW |