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

Side by Side Diff: Source/core/rendering/RenderReplaced.cpp

Issue 251783004: Don't paint below image's baseline unless it is selected. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 7 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 | « LayoutTests/virtual/deferred/fast/images/do-not-paint-below-image-baseline-expected.txt ('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 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org) 3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. 5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 if (root.block().style()->isHorizontalWritingMode()) 568 if (root.block().style()->isHorizontalWritingMode())
569 return LayoutRect(0, newLogicalTop, width(), root.selectionHeight()); 569 return LayoutRect(0, newLogicalTop, width(), root.selectionHeight());
570 return LayoutRect(newLogicalTop, 0, root.selectionHeight(), height()); 570 return LayoutRect(newLogicalTop, 0, root.selectionHeight(), height());
571 } 571 }
572 572
573 void RenderReplaced::setSelectionState(SelectionState state) 573 void RenderReplaced::setSelectionState(SelectionState state)
574 { 574 {
575 // The selection state for our containing block hierarchy is updated by the base class call. 575 // The selection state for our containing block hierarchy is updated by the base class call.
576 RenderBox::setSelectionState(state); 576 RenderBox::setSelectionState(state);
577 577
578 if (inlineBoxWrapper() && canUpdateSelectionOnRootLineBoxes()) 578 if (!inlineBoxWrapper())
579 return;
580
581 // We only include the space below the baseline in our layer's cached repain t rect if the
582 // image is selected. Since the selection state has changed update the rect.
583 if (hasLayer())
584 layer()->repainter().computeRepaintRects(containerForRepaint());
Julien - ping for review 2014/05/16 12:41:46 Whenever RenderLayer needs to recompute its repain
rhogan 2014/05/16 21:05:47 The RAL call to setPreviousRepaintRectangle happen
Julien - ping for review 2014/05/19 09:31:36 Good point, you don't need to call it twice indeed
585
586 if (canUpdateSelectionOnRootLineBoxes())
579 inlineBoxWrapper()->root().setHasSelectedChildren(isSelected()); 587 inlineBoxWrapper()->root().setHasSelectedChildren(isSelected());
580 } 588 }
581 589
582 bool RenderReplaced::isSelected() const 590 bool RenderReplaced::isSelected() const
583 { 591 {
584 SelectionState s = selectionState(); 592 SelectionState s = selectionState();
585 if (s == SelectionNone) 593 if (s == SelectionNone)
586 return false; 594 return false;
587 if (s == SelectionInside) 595 if (s == SelectionInside)
588 return true; 596 return true;
589 597
590 int selectionStart, selectionEnd; 598 int selectionStart, selectionEnd;
591 selectionStartEnd(selectionStart, selectionEnd); 599 selectionStartEnd(selectionStart, selectionEnd);
592 if (s == SelectionStart) 600 if (s == SelectionStart)
593 return selectionStart == 0; 601 return selectionStart == 0;
594 602
595 int end = node()->hasChildren() ? node()->countChildren() : 1; 603 int end = node()->hasChildren() ? node()->countChildren() : 1;
596 if (s == SelectionEnd) 604 if (s == SelectionEnd)
597 return selectionEnd == end; 605 return selectionEnd == end;
598 if (s == SelectionBoth) 606 if (s == SelectionBoth)
599 return selectionStart == 0 && selectionEnd == end; 607 return selectionStart == 0 && selectionEnd == end;
600 608
601 ASSERT(0); 609 ASSERT(0);
602 return false; 610 return false;
603 } 611 }
604
605 LayoutRect RenderReplaced::clippedOverflowRectForRepaint(const RenderLayerModelO bject* repaintContainer) const 612 LayoutRect RenderReplaced::clippedOverflowRectForRepaint(const RenderLayerModelO bject* repaintContainer) const
606 { 613 {
607 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent ()) 614 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent ())
608 return LayoutRect(); 615 return LayoutRect();
609 616
610 // The selectionRect can project outside of the overflowRect, so take their union 617 // The selectionRect can project outside of the overflowRect, so take their union
611 // for repainting to avoid selection painting glitches. 618 // for repainting to avoid selection painting glitches.
612 LayoutRect r = unionRect(localSelectionRect(false), visualOverflowRect()); 619 LayoutRect r = isSelected() ? localSelectionRect() : visualOverflowRect();
613 620
614 RenderView* v = view(); 621 RenderView* v = view();
615 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled() && v) { 622 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled() && v) {
616 // FIXME: layoutDelta needs to be applied in parts before/after transfor ms and 623 // FIXME: layoutDelta needs to be applied in parts before/after transfor ms and
617 // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308 624 // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308
618 r.move(v->layoutDelta()); 625 r.move(v->layoutDelta());
619 } 626 }
620 627
621 computeRectForRepaint(repaintContainer, r); 628 computeRectForRepaint(repaintContainer, r);
622 return r; 629 return r;
623 } 630 }
624 631
625 } 632 }
OLDNEW
« no previous file with comments | « LayoutTests/virtual/deferred/fast/images/do-not-paint-below-image-baseline-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698