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

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

Issue 23483051: Blend background with existing content (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix test in android Created 7 years 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
« no previous file with comments | « Source/core/page/Settings.in ('k') | Source/web/WebSettingsImpl.h » ('j') | 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 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 // Paint the color first underneath all images, culled if background image o ccludes it. 695 // Paint the color first underneath all images, culled if background image o ccludes it.
696 // FIXME: In the bgLayer->hasFiniteBounds() case, we could improve the culli ng test 696 // FIXME: In the bgLayer->hasFiniteBounds() case, we could improve the culli ng test
697 // by verifying whether the background image covers the entire layout rect. 697 // by verifying whether the background image covers the entire layout rect.
698 if (!bgLayer->next()) { 698 if (!bgLayer->next()) {
699 IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect)); 699 IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect));
700 bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppli edToBackground(bleedAvoidance, box); 700 bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppli edToBackground(bleedAvoidance, box);
701 if (boxShadowShouldBeAppliedToBackground || !shouldPaintBackgroundImage || !bgLayer->hasOpaqueImage(this) || !bgLayer->hasRepeatXY()) { 701 if (boxShadowShouldBeAppliedToBackground || !shouldPaintBackgroundImage || !bgLayer->hasOpaqueImage(this) || !bgLayer->hasRepeatXY()) {
702 if (!boxShadowShouldBeAppliedToBackground) 702 if (!boxShadowShouldBeAppliedToBackground)
703 backgroundRect.intersect(paintInfo.rect); 703 backgroundRect.intersect(paintInfo.rect);
704 704
705 // If we have an alpha and we are painting the root element, go ahea d and blend with the base background color.
706 Color baseColor;
707 bool shouldClearBackground = false;
708 if (isOpaqueRoot) {
709 baseColor = view()->frameView()->baseBackgroundColor();
710 if (!baseColor.alpha())
711 shouldClearBackground = true;
712 }
713
714 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShould BeAppliedToBackground); 705 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShould BeAppliedToBackground);
715 if (boxShadowShouldBeAppliedToBackground) 706 if (boxShadowShouldBeAppliedToBackground)
716 applyBoxShadowForBackground(context, this); 707 applyBoxShadowForBackground(context, this);
717 708
718 if (baseColor.alpha()) { 709 if (isOpaqueRoot) {
719 if (bgColor.alpha()) 710 // If we have an alpha and we are painting the root element, go ahead and blend with the base background color.
720 baseColor = baseColor.blend(bgColor); 711 Color baseColor = view()->frameView()->baseBackgroundColor();
712 bool shouldClearDocumentBackground = document().settings() && do cument().settings()->shouldClearDocumentBackground();
713 CompositeOperator operation = shouldClearDocumentBackground ? Co mpositeCopy : context->compositeOperation();
721 714
722 context->fillRect(backgroundRect, baseColor, CompositeCopy); 715 if (baseColor.alpha()) {
716 if (bgColor.alpha())
717 baseColor = baseColor.blend(bgColor);
718 context->fillRect(backgroundRect, baseColor, operation);
719 } else if (bgColor.alpha()) {
720 context->fillRect(backgroundRect, bgColor, operation);
721 } else if (shouldClearDocumentBackground) {
722 context->clearRect(backgroundRect);
723 }
723 } else if (bgColor.alpha()) { 724 } else if (bgColor.alpha()) {
724 CompositeOperator operation = shouldClearBackground ? CompositeC opy : context->compositeOperation(); 725 context->fillRect(backgroundRect, bgColor, context->compositeOpe ration());
725 context->fillRect(backgroundRect, bgColor, operation); 726 }
726 } else if (shouldClearBackground)
727 context->clearRect(backgroundRect);
728 } 727 }
729 } 728 }
730 729
731 // no progressive loading of the background image 730 // no progressive loading of the background image
732 if (shouldPaintBackgroundImage) { 731 if (shouldPaintBackgroundImage) {
733 BackgroundImageGeometry geometry; 732 BackgroundImageGeometry geometry;
734 calculateBackgroundImageGeometry(bgLayer, scrolledPaintRect, geometry, b ackgroundObject); 733 calculateBackgroundImageGeometry(bgLayer, scrolledPaintRect, geometry, b ackgroundObject);
735 geometry.clip(paintInfo.rect); 734 geometry.clip(paintInfo.rect);
736 if (!geometry.destRect().isEmpty()) { 735 if (!geometry.destRect().isEmpty()) {
737 CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer- >composite() : op; 736 CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer- >composite() : op;
(...skipping 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after
2811 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2810 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2812 for (RenderObject* child = startChild; child && child != endChild; ) { 2811 for (RenderObject* child = startChild; child && child != endChild; ) {
2813 // Save our next sibling as moveChildTo will clear it. 2812 // Save our next sibling as moveChildTo will clear it.
2814 RenderObject* nextSibling = child->nextSibling(); 2813 RenderObject* nextSibling = child->nextSibling();
2815 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2814 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2816 child = nextSibling; 2815 child = nextSibling;
2817 } 2816 }
2818 } 2817 }
2819 2818
2820 } // namespace WebCore 2819 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/Settings.in ('k') | Source/web/WebSettingsImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698