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

Side by Side Diff: sky/engine/core/rendering/RenderBlock.cpp

Issue 891573002: Removed a bunch of unneeded paint phase checks. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 return; 463 return;
464 } 464 }
465 465
466 // There are some cases where not all clipped visual overflow is accounted f or. 466 // There are some cases where not all clipped visual overflow is accounted f or.
467 // FIXME: reduce the number of such cases. 467 // FIXME: reduce the number of such cases.
468 ContentsClipBehavior contentsClipBehavior = ForceContentsClip; 468 ContentsClipBehavior contentsClipBehavior = ForceContentsClip;
469 if (hasOverflowClip() && !(shouldPaintSelectionGaps() && phase == PaintPhase Foreground) && !hasCaret()) 469 if (hasOverflowClip() && !(shouldPaintSelectionGaps() && phase == PaintPhase Foreground) && !hasCaret())
470 contentsClipBehavior = SkipContentsClipIfPossible; 470 contentsClipBehavior = SkipContentsClipIfPossible;
471 471
472 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset, contentsC lipBehavior); 472 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset, contentsC lipBehavior);
473 { 473 paintObject(paintInfo, adjustedPaintOffset);
474 paintObject(paintInfo, adjustedPaintOffset);
475 }
476 if (pushedClip) 474 if (pushedClip)
477 popContentsClip(paintInfo, phase, adjustedPaintOffset); 475 popContentsClip(paintInfo, phase, adjustedPaintOffset);
478 } 476 }
479 477
480 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) 478 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
481 { 479 {
482 // FIXME(sky): Can we remove paintContents and just keep paintChildren? 480 // FIXME(sky): Can we remove paintContents and just keep paintChildren?
483 paintChildren(paintInfo, paintOffset); 481 paintChildren(paintInfo, paintOffset);
484 } 482 }
485 483
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 } 531 }
534 532
535 DragCaretController& dragCaretController = frame()->page()->dragCaretControl ler(); 533 DragCaretController& dragCaretController = frame()->page()->dragCaretControl ler();
536 if (hasDragCaret(dragCaretController, this)) { 534 if (hasDragCaret(dragCaretController, this)) {
537 dragCaretController.paintDragCaret(frame(), paintInfo.context, paintOffs et, paintInfo.rect); 535 dragCaretController.paintDragCaret(frame(), paintInfo.context, paintOffs et, paintInfo.rect);
538 } 536 }
539 } 537 }
540 538
541 void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs et) 539 void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs et)
542 { 540 {
543 PaintPhase paintPhase = paintInfo.phase; 541 if (paintInfo.phase == PaintPhaseMask) {
544
545 if (paintPhase == PaintPhaseForeground) {
546 if (hasBoxDecorationBackground())
547 paintBoxDecorationBackground(paintInfo, paintOffset);
548 }
549
550 if (paintPhase == PaintPhaseMask) {
551 paintMask(paintInfo, paintOffset); 542 paintMask(paintInfo, paintOffset);
552 return; 543 return;
553 } 544 }
554 545
546 if (hasBoxDecorationBackground())
547 paintBoxDecorationBackground(paintInfo, paintOffset);
548
555 paintContents(paintInfo, paintOffset); 549 paintContents(paintInfo, paintOffset);
556 paintSelection(paintInfo, paintOffset); // Fill in gaps in selection on line s and between blocks. 550 paintSelection(paintInfo, paintOffset); // Fill in gaps in selection on line s and between blocks.
557 551
558 if (paintPhase == PaintPhaseForeground) { 552 if (style()->hasOutline() && !style()->outlineStyleIsAuto())
559 if (style()->hasOutline() && !style()->outlineStyleIsAuto()) 553 paintOutline(paintInfo, LayoutRect(paintOffset, size()));
560 paintOutline(paintInfo, LayoutRect(paintOffset, size()));
561 554
562 // If the caret's node's render object's containing block is this block, and the paint action is PaintPhaseForeground, 555 paintCarets(paintInfo, paintOffset);
563 // then paint the caret.
564 paintCarets(paintInfo, paintOffset);
565 }
566 } 556 }
567 557
568 bool RenderBlock::shouldPaintSelectionGaps() const 558 bool RenderBlock::shouldPaintSelectionGaps() const
569 { 559 {
570 return selectionState() != SelectionNone && isSelectionRoot(); 560 return selectionState() != SelectionNone && isSelectionRoot();
571 } 561 }
572 562
573 bool RenderBlock::isSelectionRoot() const 563 bool RenderBlock::isSelectionRoot() const
574 { 564 {
575 ASSERT(node() || isAnonymous()); 565 ASSERT(node() || isAnonymous());
576 566
577 if (isDocumentElement() || hasOverflowClip() 567 if (isDocumentElement() || hasOverflowClip()
578 || isPositioned() 568 || isPositioned()
579 || isInlineBlock() 569 || isInlineBlock()
580 || hasTransform() || hasMask() 570 || hasTransform() || hasMask()
581 || isFlexItem()) 571 || isFlexItem())
582 return true; 572 return true;
583 573
584 if (view() && view()->selectionStart()) { 574 if (view() && view()->selectionStart()) {
585 Node* startElement = view()->selectionStart()->node(); 575 Node* startElement = view()->selectionStart()->node();
586 if (startElement && startElement->rootEditableElement() == node()) 576 if (startElement && startElement->rootEditableElement() == node())
587 return true; 577 return true;
588 } 578 }
589 579
590 return false; 580 return false;
591 } 581 }
592 582
593 void RenderBlock::paintSelection(PaintInfo& paintInfo, const LayoutPoint& paintO ffset) 583 void RenderBlock::paintSelection(PaintInfo& paintInfo, const LayoutPoint& paintO ffset)
594 { 584 {
595 if (shouldPaintSelectionGaps() && paintInfo.phase == PaintPhaseForeground) { 585 if (shouldPaintSelectionGaps()) {
ojan 2015/01/30 01:25:59 The caller already does this check.
596 LayoutUnit lastTop = 0; 586 LayoutUnit lastTop = 0;
597 LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop); 587 LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop);
598 LayoutUnit lastRight = logicalRightSelectionOffset(this, lastTop); 588 LayoutUnit lastRight = logicalRightSelectionOffset(this, lastTop);
599 GraphicsContextStateSaver stateSaver(*paintInfo.context); 589 GraphicsContextStateSaver stateSaver(*paintInfo.context);
600 590
601 // TODO(ojan): In sky, we don't use the return value, but we 591 // TODO(ojan): In sky, we don't use the return value, but we
602 // need this in order to actually paint selection gaps. 592 // need this in order to actually paint selection gaps.
603 // We should rename it appropriately. 593 // We should rename it appropriately.
604 selectionGaps(this, paintOffset, LayoutSize(), lastTop, lastLeft, lastRi ght, &paintInfo); 594 selectionGaps(this, paintOffset, LayoutSize(), lastTop, lastLeft, lastRi ght, &paintInfo);
605 } 595 }
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 1800 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
1811 { 1801 {
1812 showRenderObject(); 1802 showRenderObject();
1813 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 1803 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
1814 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 1804 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
1815 } 1805 }
1816 1806
1817 #endif 1807 #endif
1818 1808
1819 } // namespace blink 1809 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698