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

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

Issue 1312493007: Fix table cell background caching issue about interest rect (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 #include "core/paint/BlockPainter.h" 6 #include "core/paint/BlockPainter.h"
7 7
8 #include "core/editing/DragCaretController.h" 8 #include "core/editing/DragCaretController.h"
9 #include "core/editing/FrameSelection.h" 9 #include "core/editing/FrameSelection.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
(...skipping 11 matching lines...) Expand all
22 #include "core/paint/ScopeRecorder.h" 22 #include "core/paint/ScopeRecorder.h"
23 #include "core/paint/ScrollRecorder.h" 23 #include "core/paint/ScrollRecorder.h"
24 #include "core/paint/ScrollableAreaPainter.h" 24 #include "core/paint/ScrollableAreaPainter.h"
25 #include "platform/graphics/paint/ClipRecorder.h" 25 #include "platform/graphics/paint/ClipRecorder.h"
26 #include "wtf/Optional.h" 26 #include "wtf/Optional.h"
27 27
28 namespace blink { 28 namespace blink {
29 29
30 void BlockPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOff set) 30 void BlockPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOff set)
31 { 31 {
32 PaintInfo localPaintInfo(paintInfo); 32 if (!isVisibleInPaintRect(paintInfo, paintOffset))
33 return;
33 34
34 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBlock.location(); 35 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBlock.location();
35 36 PaintInfo localPaintInfo(paintInfo);
36 PaintPhase originalPhase = localPaintInfo.phase; 37 PaintPhase originalPhase = localPaintInfo.phase;
37 38
38 // Check if we need to do anything at all.
39 LayoutRect overflowBox = overflowRectForPaintRejection();
40 m_layoutBlock.flipForWritingMode(overflowBox);
41 overflowBox.moveBy(adjustedPaintOffset);
42 if (!overflowBox.intersects(LayoutRect(localPaintInfo.rect)))
43 return;
44
45 // There are some cases where not all clipped visual overflow is accounted f or. 39 // There are some cases where not all clipped visual overflow is accounted f or.
46 // FIXME: reduce the number of such cases. 40 // FIXME: reduce the number of such cases.
47 ContentsClipBehavior contentsClipBehavior = ForceContentsClip; 41 ContentsClipBehavior contentsClipBehavior = ForceContentsClip;
48 if (m_layoutBlock.hasOverflowClip() && !m_layoutBlock.hasControlClip() && !( m_layoutBlock.shouldPaintSelectionGaps() && originalPhase == PaintPhaseForegroun d) && !hasCaret()) 42 if (m_layoutBlock.hasOverflowClip() && !m_layoutBlock.hasControlClip() && !( m_layoutBlock.shouldPaintSelectionGaps() && originalPhase == PaintPhaseForegroun d) && !hasCaret())
49 contentsClipBehavior = SkipContentsClipIfPossible; 43 contentsClipBehavior = SkipContentsClipIfPossible;
50 44
51 if (localPaintInfo.phase == PaintPhaseOutline) { 45 if (localPaintInfo.phase == PaintPhaseOutline) {
52 localPaintInfo.phase = PaintPhaseChildOutlines; 46 localPaintInfo.phase = PaintPhaseChildOutlines;
53 } else if (localPaintInfo.phase == PaintPhaseChildBlockBackground) { 47 } else if (localPaintInfo.phase == PaintPhaseChildBlockBackground) {
54 localPaintInfo.phase = PaintPhaseBlockBackground; 48 localPaintInfo.phase = PaintPhaseBlockBackground;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 227
234 FrameSelection& selection = frame->selection(); 228 FrameSelection& selection = frame->selection();
235 if (hasCursorCaret(selection, &m_layoutBlock, frame)) 229 if (hasCursorCaret(selection, &m_layoutBlock, frame))
236 selection.paintCaret(paintInfo.context, paintOffset, LayoutRect(paintInf o.rect)); 230 selection.paintCaret(paintInfo.context, paintOffset, LayoutRect(paintInf o.rect));
237 231
238 DragCaretController& dragCaretController = frame->page()->dragCaretControlle r(); 232 DragCaretController& dragCaretController = frame->page()->dragCaretControlle r();
239 if (hasDragCaret(dragCaretController, &m_layoutBlock, frame)) 233 if (hasDragCaret(dragCaretController, &m_layoutBlock, frame))
240 dragCaretController.paintDragCaret(frame, paintInfo.context, paintOffset , LayoutRect(paintInfo.rect)); 234 dragCaretController.paintDragCaret(frame, paintInfo.context, paintOffset , LayoutRect(paintInfo.rect));
241 } 235 }
242 236
243 LayoutRect BlockPainter::overflowRectForPaintRejection() const 237 bool BlockPainter::isVisibleInPaintRect(const PaintInfo& paintInfo, const Layout Point& paintOffset) const
244 { 238 {
245 LayoutRect overflowRect = m_layoutBlock.visualOverflowRect(); 239 LayoutRect overflowRect = m_layoutBlock.visualOverflowRect();
246 if (!m_layoutBlock.hasOverflowModel() || !m_layoutBlock.usesCompositedScroll ing()) 240 if (m_layoutBlock.hasOverflowModel() && m_layoutBlock.usesCompositedScrollin g()) {
247 return overflowRect; 241 overflowRect.unite(m_layoutBlock.layoutOverflowRect());
248 242 overflowRect.move(-m_layoutBlock.scrolledContentOffset());
249 overflowRect.unite(m_layoutBlock.layoutOverflowRect()); 243 }
250 overflowRect.move(-m_layoutBlock.scrolledContentOffset()); 244 m_layoutBlock.flipForWritingMode(overflowRect);
251 return overflowRect; 245 overflowRect.moveBy(paintOffset + m_layoutBlock.location());
246 return (overflowRect.intersects(LayoutRect(paintInfo.rect)));
252 } 247 }
253 248
254 bool BlockPainter::hasCaret() const 249 bool BlockPainter::hasCaret() const
255 { 250 {
256 LocalFrame* frame = m_layoutBlock.frame(); 251 LocalFrame* frame = m_layoutBlock.frame();
257 return hasCursorCaret(frame->selection(), &m_layoutBlock, frame) 252 return hasCursorCaret(frame->selection(), &m_layoutBlock, frame)
258 || hasDragCaret(frame->page()->dragCaretController(), &m_layoutBlock, fr ame); 253 || hasDragCaret(frame->page()->dragCaretController(), &m_layoutBlock, fr ame);
259 } 254 }
260 255
261 void BlockPainter::paintContents(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 256 void BlockPainter::paintContents(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
(...skipping 15 matching lines...) Expand all
277 272
278 // We don't paint our own background, but we do let the kids paint their backgrounds. 273 // We don't paint our own background, but we do let the kids paint their backgrounds.
279 PaintInfo paintInfoForChild(paintInfo); 274 PaintInfo paintInfoForChild(paintInfo);
280 paintInfoForChild.phase = newPhase; 275 paintInfoForChild.phase = newPhase;
281 paintInfoForChild.updatePaintingRootForChildren(&m_layoutBlock); 276 paintInfoForChild.updatePaintingRootForChildren(&m_layoutBlock);
282 m_layoutBlock.paintChildren(paintInfoForChild, paintOffset); 277 m_layoutBlock.paintChildren(paintInfoForChild, paintOffset);
283 } 278 }
284 } 279 }
285 280
286 } // namespace blink 281 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698