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

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

Issue 1224933002: Combine outline and focus ring code paths (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix empty focus ring on Mac 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
« no previous file with comments | « Source/core/paint/BlockPainter.h ('k') | Source/core/paint/DeprecatedPaintLayerPainter.cpp » ('j') | 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/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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 if (paintPhase != PaintPhaseSelfOutline) 191 if (paintPhase != PaintPhaseSelfOutline)
192 paintContents(contentsPaintInfo, paintOffset); 192 paintContents(contentsPaintInfo, paintOffset);
193 193
194 if (paintPhase == PaintPhaseForeground && !paintInfo.isPrinting()) 194 if (paintPhase == PaintPhaseForeground && !paintInfo.isPrinting())
195 m_layoutBlock.paintSelection(contentsPaintInfo, paintOffset); // Fil l in gaps in selection on lines and between blocks. 195 m_layoutBlock.paintSelection(contentsPaintInfo, paintOffset); // Fil l in gaps in selection on lines and between blocks.
196 196
197 if (paintPhase == PaintPhaseFloat || paintPhase == PaintPhaseSelection | | paintPhase == PaintPhaseTextClip) 197 if (paintPhase == PaintPhaseFloat || paintPhase == PaintPhaseSelection | | paintPhase == PaintPhaseTextClip)
198 m_layoutBlock.paintFloats(contentsPaintInfo, paintOffset, paintPhase == PaintPhaseSelection || paintPhase == PaintPhaseTextClip); 198 m_layoutBlock.paintFloats(contentsPaintInfo, paintOffset, paintPhase == PaintPhaseSelection || paintPhase == PaintPhaseTextClip);
199 } 199 }
200 200
201 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) && m_layoutBlock.style()->hasOutline() && m_layoutBlock.style()->visibility() = = VISIBLE) { 201 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) && m_layoutBlock.style()->hasOutline() && m_layoutBlock.style()->visibility() = = VISIBLE)
202 // Don't paint focus ring for anonymous block continuation because the 202 ObjectPainter(m_layoutBlock).paintOutline(paintInfo, paintOffset);
203 // inline element having outline-style:auto paints the whole focus ring.
204 if (!m_layoutBlock.style()->outlineStyleIsAuto() || !m_layoutBlock.isAno nymousBlockContinuation())
205 ObjectPainter(m_layoutBlock).paintOutline(paintInfo, m_layoutBlock.v isualOverflowRect(), m_layoutBlock.size(), paintOffset);
206 }
207
208 if (paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseChildOutlines )
209 paintContinuationOutlines(paintInfo, paintOffset);
210 203
211 // If the caret's node's layout object's containing block is this block, and the paint action is PaintPhaseForeground, 204 // If the caret's node's layout object's containing block is this block, and the paint action is PaintPhaseForeground,
212 // then paint the caret. 205 // then paint the caret.
213 if (paintPhase == PaintPhaseForeground && hasCaret() && !LayoutObjectDrawing Recorder::useCachedDrawingIfPossible(*paintInfo.context, m_layoutBlock, DisplayI tem::Caret)) { 206 if (paintPhase == PaintPhaseForeground && hasCaret() && !LayoutObjectDrawing Recorder::useCachedDrawingIfPossible(*paintInfo.context, m_layoutBlock, DisplayI tem::Caret)) {
214 LayoutRect bounds = m_layoutBlock.visualOverflowRect(); 207 LayoutRect bounds = m_layoutBlock.visualOverflowRect();
215 bounds.moveBy(paintOffset); 208 bounds.moveBy(paintOffset);
216 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBlock, DisplayItem::Caret, bounds); 209 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBlock, DisplayItem::Caret, bounds);
217 paintCarets(paintInfo, paintOffset); 210 paintCarets(paintInfo, paintOffset);
218 } 211 }
219 } 212 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 260
268 void BlockPainter::paintContents(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 261 void BlockPainter::paintContents(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
269 { 262 {
270 // Avoid painting descendants of the root element when stylesheets haven't l oaded. This eliminates FOUC. 263 // Avoid painting descendants of the root element when stylesheets haven't l oaded. This eliminates FOUC.
271 // It's ok not to draw, because later on, when all the stylesheets do load, styleResolverChanged() on the Document 264 // It's ok not to draw, because later on, when all the stylesheets do load, styleResolverChanged() on the Document
272 // will do a full paint invalidation. 265 // will do a full paint invalidation.
273 if (m_layoutBlock.document().didLayoutWithPendingStylesheets() && !m_layoutB lock.isLayoutView()) 266 if (m_layoutBlock.document().didLayoutWithPendingStylesheets() && !m_layoutB lock.isLayoutView())
274 return; 267 return;
275 268
276 if (m_layoutBlock.childrenInline()) { 269 if (m_layoutBlock.childrenInline()) {
277 LineBoxListPainter(*m_layoutBlock.lineBoxes()).paint(&m_layoutBlock, pai ntInfo, paintOffset); 270 if (paintInfo.phase == PaintPhaseChildOutlines)
271 ObjectPainter(m_layoutBlock).paintInlineChildrenOutlines(paintInfo, paintOffset);
272 else
273 LineBoxListPainter(*m_layoutBlock.lineBoxes()).paint(&m_layoutBlock, paintInfo, paintOffset);
278 } else { 274 } else {
279 PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? Pai ntPhaseOutline : paintInfo.phase; 275 PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? Pai ntPhaseOutline : paintInfo.phase;
280 newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChi ldBlockBackground : newPhase; 276 newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChi ldBlockBackground : newPhase;
281 277
282 // We don't paint our own background, but we do let the kids paint their backgrounds. 278 // We don't paint our own background, but we do let the kids paint their backgrounds.
283 PaintInfo paintInfoForChild(paintInfo); 279 PaintInfo paintInfoForChild(paintInfo);
284 paintInfoForChild.phase = newPhase; 280 paintInfoForChild.phase = newPhase;
285 paintInfoForChild.updatePaintingRootForChildren(&m_layoutBlock); 281 paintInfoForChild.updatePaintingRootForChildren(&m_layoutBlock);
286 m_layoutBlock.paintChildren(paintInfoForChild, paintOffset); 282 m_layoutBlock.paintChildren(paintInfoForChild, paintOffset);
287 } 283 }
288 } 284 }
289 285
290 void BlockPainter::paintContinuationOutlines(const PaintInfo& info, const Layout Point& paintOffset)
291 {
292 LayoutInline* inlineCont = m_layoutBlock.inlineElementContinuation();
293 if (inlineCont && inlineCont->style()->hasOutline() && inlineCont->style()-> visibility() == VISIBLE) {
294 LayoutInline* inlineLayoutObject = toLayoutInline(inlineCont->node()->la youtObject());
295 LayoutBlock* cb = m_layoutBlock.containingBlock();
296
297 bool inlineEnclosedInSelfPaintingLayer = false;
298 for (LayoutBoxModelObject* box = inlineLayoutObject; box != cb; box = bo x->parent()->enclosingBoxModelObject()) {
299 if (box->hasSelfPaintingLayer()) {
300 inlineEnclosedInSelfPaintingLayer = true;
301 break;
302 }
303 }
304
305 // Do not add continuations for outline painting by our containing block if we are a relative positioned
306 // anonymous block (i.e. have our own layer), paint them straightaway in stead. This is because a block depends on layoutObjects in its continuation tabl e being
307 // in the same layer.
308 if (!inlineEnclosedInSelfPaintingLayer && !m_layoutBlock.hasLayer()) {
309 cb->addContinuationWithOutline(inlineLayoutObject);
310 } else if (!inlineLayoutObject->firstLineBox() || (!inlineEnclosedInSelf PaintingLayer && m_layoutBlock.hasLayer())) {
311 // The outline might be painted multiple times if multiple blocks ha ve the same inline element continuation, and the inline has a self-painting laye r.
312 ScopeRecorder scopeRecorder(*info.context);
313 InlinePainter(*inlineLayoutObject).paintOutline(info, paintOffset - m_layoutBlock.locationOffset() + inlineLayoutObject->containingBlock()->location ());
314 }
315 }
316
317 ContinuationOutlineTableMap* table = continuationOutlineTable();
318 if (table->isEmpty())
319 return;
320
321 OwnPtr<ListHashSet<LayoutInline*>> continuations = table->take(&m_layoutBloc k);
322 if (!continuations)
323 return;
324
325 LayoutPoint accumulatedPaintOffset = paintOffset;
326 // Paint each continuation outline.
327 ListHashSet<LayoutInline*>::iterator end = continuations->end();
328 for (ListHashSet<LayoutInline*>::iterator it = continuations->begin(); it != end; ++it) {
329 // Need to add in the coordinates of the intervening blocks.
330 LayoutInline* flow = *it;
331 LayoutBlock* block = flow->containingBlock();
332 for ( ; block && block != &m_layoutBlock; block = block->containingBlock ())
333 accumulatedPaintOffset.moveBy(block->location());
334 ASSERT(block);
335 InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset);
336 }
337 }
338
339
340 } // namespace blink 286 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/BlockPainter.h ('k') | Source/core/paint/DeprecatedPaintLayerPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698