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

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

Issue 1226833007: Add CaretBase::m_caretPainter, and compute caretBrowsing lazily. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 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
« no previous file with comments | « Source/core/editing/FrameSelection.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/FrameSelection.h" 8 #include "core/editing/FrameSelection.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/layout/LayoutFlexibleBox.h" 10 #include "core/layout/LayoutFlexibleBox.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 // If the caret's node's layout object's containing block is this block, and the paint action is PaintPhaseForeground, 225 // If the caret's node's layout object's containing block is this block, and the paint action is PaintPhaseForeground,
226 // then paint the caret. 226 // then paint the caret.
227 if (paintPhase == PaintPhaseForeground && hasCaret()) { 227 if (paintPhase == PaintPhaseForeground && hasCaret()) {
228 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBlock, DisplayItem::Caret, visualOverflowRectWithPaintOffset(m_layoutBlock, paintOffset )); 228 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBlock, DisplayItem::Caret, visualOverflowRectWithPaintOffset(m_layoutBlock, paintOffset ));
229 if (!recorder.canUseCachedDrawing()) 229 if (!recorder.canUseCachedDrawing())
230 paintCarets(paintInfo, paintOffset); 230 paintCarets(paintInfo, paintOffset);
231 } 231 }
232 } 232 }
233 233
234 static inline bool caretBrowsingEnabled(const Frame* frame) 234 static inline bool caretBrowsingEnabled(const LocalFrame* frame)
235 { 235 {
236 Settings* settings = frame->settings(); 236 Settings* settings = frame->settings();
237 return settings && settings->caretBrowsingEnabled(); 237 return settings && settings->caretBrowsingEnabled();
238 } 238 }
239 239
240 static inline bool hasCursorCaret(const FrameSelection& selection, const LayoutB lock* block, bool caretBrowsing) 240 static inline bool hasCursorCaret(const FrameSelection& selection, const LayoutB lock* block, const LocalFrame* frame)
241 { 241 {
242 return selection.caretLayoutObject() == block && (selection.hasEditableStyle () || caretBrowsing); 242 return selection.caretLayoutObject() == block && (selection.hasEditableStyle () || caretBrowsingEnabled(frame));
243 } 243 }
244 244
245 static inline bool hasDragCaret(const DragCaretController& dragCaretController, const LayoutBlock* block, bool caretBrowsing) 245 static inline bool hasDragCaret(const DragCaretController& dragCaretController, const LayoutBlock* block, const LocalFrame* frame)
246 { 246 {
247 return dragCaretController.caretLayoutObject() == block && (dragCaretControl ler.isContentEditable() || caretBrowsing); 247 return dragCaretController.caretLayoutObject() == block && (dragCaretControl ler.isContentEditable() || caretBrowsingEnabled(frame));
248 } 248 }
249 249
250 void BlockPainter::paintCarets(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) 250 void BlockPainter::paintCarets(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset)
251 { 251 {
252 bool caretBrowsing = caretBrowsingEnabled(m_layoutBlock.frame()); 252 LocalFrame* frame = m_layoutBlock.frame();
253 253
254 FrameSelection& selection = m_layoutBlock.frame()->selection(); 254 FrameSelection& selection = frame->selection();
255 if (hasCursorCaret(selection, &m_layoutBlock, caretBrowsing)) { 255 if (hasCursorCaret(selection, &m_layoutBlock, frame))
256 selection.paintCaret(paintInfo.context, paintOffset, LayoutRect(paintInf o.rect)); 256 selection.paintCaret(paintInfo.context, paintOffset, LayoutRect(paintInf o.rect));
257 }
258 257
259 DragCaretController& dragCaretController = m_layoutBlock.frame()->page()->dr agCaretController(); 258 DragCaretController& dragCaretController = frame->page()->dragCaretControlle r();
260 if (hasDragCaret(dragCaretController, &m_layoutBlock, caretBrowsing)) { 259 if (hasDragCaret(dragCaretController, &m_layoutBlock, frame))
261 dragCaretController.paintDragCaret(m_layoutBlock.frame(), paintInfo.cont ext, paintOffset, LayoutRect(paintInfo.rect)); 260 dragCaretController.paintDragCaret(frame, paintInfo.context, paintOffset , LayoutRect(paintInfo.rect));
262 }
263 } 261 }
264 262
265 LayoutRect BlockPainter::overflowRectForPaintRejection() const 263 LayoutRect BlockPainter::overflowRectForPaintRejection() const
266 { 264 {
267 LayoutRect overflowRect = m_layoutBlock.visualOverflowRect(); 265 LayoutRect overflowRect = m_layoutBlock.visualOverflowRect();
268 if (!m_layoutBlock.hasOverflowModel() || !m_layoutBlock.usesCompositedScroll ing()) 266 if (!m_layoutBlock.hasOverflowModel() || !m_layoutBlock.usesCompositedScroll ing())
269 return overflowRect; 267 return overflowRect;
270 268
271 overflowRect.unite(m_layoutBlock.layoutOverflowRect()); 269 overflowRect.unite(m_layoutBlock.layoutOverflowRect());
272 overflowRect.move(-m_layoutBlock.scrolledContentOffset()); 270 overflowRect.move(-m_layoutBlock.scrolledContentOffset());
273 return overflowRect; 271 return overflowRect;
274 } 272 }
275 273
276 bool BlockPainter::hasCaret() const 274 bool BlockPainter::hasCaret() const
277 { 275 {
278 bool caretBrowsing = caretBrowsingEnabled(m_layoutBlock.frame()); 276 LocalFrame* frame = m_layoutBlock.frame();
279 return hasCursorCaret(m_layoutBlock.frame()->selection(), &m_layoutBlock, ca retBrowsing) 277 return hasCursorCaret(frame->selection(), &m_layoutBlock, frame)
280 || hasDragCaret(m_layoutBlock.frame()->page()->dragCaretController(), &m _layoutBlock, caretBrowsing); 278 || hasDragCaret(frame->page()->dragCaretController(), &m_layoutBlock, fr ame);
281 } 279 }
282 280
283 void BlockPainter::paintContents(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 281 void BlockPainter::paintContents(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
284 { 282 {
285 // Avoid painting descendants of the root element when stylesheets haven't l oaded. This eliminates FOUC. 283 // Avoid painting descendants of the root element when stylesheets haven't l oaded. This eliminates FOUC.
286 // It's ok not to draw, because later on, when all the stylesheets do load, styleResolverChanged() on the Document 284 // It's ok not to draw, because later on, when all the stylesheets do load, styleResolverChanged() on the Document
287 // will do a full paint invalidation. 285 // will do a full paint invalidation.
288 if (m_layoutBlock.document().didLayoutWithPendingStylesheets() && !m_layoutB lock.isLayoutView()) 286 if (m_layoutBlock.document().didLayoutWithPendingStylesheets() && !m_layoutB lock.isLayoutView())
289 return; 287 return;
290 288
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 LayoutBlock* block = flow->containingBlock(); 344 LayoutBlock* block = flow->containingBlock();
347 for ( ; block && block != &m_layoutBlock; block = block->containingBlock ()) 345 for ( ; block && block != &m_layoutBlock; block = block->containingBlock ())
348 accumulatedPaintOffset.moveBy(block->location()); 346 accumulatedPaintOffset.moveBy(block->location());
349 ASSERT(block); 347 ASSERT(block);
350 InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset); 348 InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset);
351 } 349 }
352 } 350 }
353 351
354 352
355 } // namespace blink 353 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/FrameSelection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698