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

Side by Side Diff: Source/core/layout/LayoutBoxModelObject.cpp

Issue 1145993002: Refactor root element background painting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: revert to patchset 10 Created 5 years, 6 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
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
11 * License as published by the Free Software Foundation; either 11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version. 12 * version 2 of the License, or (at your option) any later version.
13 * 13 *
14 * This library is distributed in the hope that it will be useful, 14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details. 17 * Library General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU Library General Public License 19 * You should have received a copy of the GNU Library General Public License
20 * along with this library; see the file COPYING.LIB. If not, write to 20 * along with this library; see the file COPYING.LIB. If not, write to
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA. 22 * Boston, MA 02110-1301, USA.
23 * 23 *
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/layout/LayoutBoxModelObject.h" 27 #include "core/layout/LayoutBoxModelObject.h"
28 28
29 #include "core/dom/NodeComputedStyle.h"
29 #include "core/layout/ImageQualityController.h" 30 #include "core/layout/ImageQualityController.h"
30 #include "core/layout/LayoutBlock.h" 31 #include "core/layout/LayoutBlock.h"
31 #include "core/layout/LayoutFlowThread.h" 32 #include "core/layout/LayoutFlowThread.h"
32 #include "core/layout/LayoutGeometryMap.h" 33 #include "core/layout/LayoutGeometryMap.h"
33 #include "core/layout/LayoutInline.h" 34 #include "core/layout/LayoutInline.h"
34 #include "core/layout/LayoutObject.h" 35 #include "core/layout/LayoutObject.h"
35 #include "core/layout/LayoutTextFragment.h" 36 #include "core/layout/LayoutTextFragment.h"
36 #include "core/layout/LayoutView.h" 37 #include "core/layout/LayoutView.h"
37 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h" 38 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h"
38 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" 39 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // gets the same layout after changing position property, although no 243 // gets the same layout after changing position property, although no
243 // re-raster (rect-based invalidation) is needed, display items should 244 // re-raster (rect-based invalidation) is needed, display items should
244 // still update their paint offset. 245 // still update their paint offset.
245 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && oldStyle) { 246 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && oldStyle) {
246 bool newStyleIsFixedPosition = style()->position() == FixedPosition; 247 bool newStyleIsFixedPosition = style()->position() == FixedPosition;
247 bool oldStyleIsFixedPosition = oldStyle->position() == FixedPosition; 248 bool oldStyleIsFixedPosition = oldStyle->position() == FixedPosition;
248 if (newStyleIsFixedPosition != oldStyleIsFixedPosition) 249 if (newStyleIsFixedPosition != oldStyleIsFixedPosition)
249 invalidateDisplayItemClientForNonCompositingDescendants(); 250 invalidateDisplayItemClientForNonCompositingDescendants();
250 } 251 }
251 252
253 if (isDocumentElement() && isHTMLHtmlElement(node())) {
254 // Refers to backgroundStolenForBeingBody().
chrishtr 2015/06/05 23:54:18 Is this code to handle when backgroundStolenForBei
trchen 2015/06/06 05:30:02 Acknowledged.
255 bool newStyleHasBackground = style()->hasBackground();
256 bool oldStyleHasBackground = oldStyle && oldStyle->hasBackground();
257 if (newStyleHasBackground != oldStyleHasBackground) {
258 Element* body = document().body();
259 LayoutObject* bodyLayout = isHTMLBodyElement(body) ? body->layoutObj ect() : nullptr;
260 if (bodyLayout) {
261 const ComputedStyle* bodyStyle = bodyLayout->style();
262 if (bodyStyle && bodyStyle->hasBackground())
263 bodyLayout->setShouldDoFullPaintInvalidation();
264 }
265 }
266 }
267
252 if (FrameView *frameView = view()->frameView()) { 268 if (FrameView *frameView = view()->frameView()) {
253 bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosit ion(); 269 bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosit ion();
254 bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportCo nstrainedPosition(); 270 bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportCo nstrainedPosition();
255 if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) { 271 if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) {
256 if (newStyleIsViewportConstained && layer()) 272 if (newStyleIsViewportConstained && layer())
257 frameView->addViewportConstrainedObject(this); 273 frameView->addViewportConstrainedObject(this);
258 else 274 else
259 frameView->removeViewportConstrainedObject(this); 275 frameView->removeViewportConstrainedObject(this);
260 } 276 }
261 } 277 }
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 return false; 718 return false;
703 } 719 }
704 720
705 if (!hasOneNormalBoxShadow) 721 if (!hasOneNormalBoxShadow)
706 return false; 722 return false;
707 723
708 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); 724 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
709 if (backgroundColor.hasAlpha()) 725 if (backgroundColor.hasAlpha())
710 return false; 726 return false;
711 727
728 // TODO(trchen): Mask layers are painted with the same code path as backgrou nd layers.
729 // We shouldn't paint shadow to the mask by accident.
730 if (style()->maskImage())
chrishtr 2015/06/05 23:54:18 This seems a little random. Is it fixing a particu
trchen 2015/06/06 05:30:02 Nope. Just feel dangerous when I see this. I can s
731 return false;
732
712 const FillLayer* lastBackgroundLayer = &style()->backgroundLayers(); 733 const FillLayer* lastBackgroundLayer = &style()->backgroundLayers();
713 for (const FillLayer* next = lastBackgroundLayer->next(); next; next = lastB ackgroundLayer->next()) 734 for (const FillLayer* next = lastBackgroundLayer->next(); next; next = lastB ackgroundLayer->next())
714 lastBackgroundLayer = next; 735 lastBackgroundLayer = next;
715 736
716 if (lastBackgroundLayer->clip() != BorderFillBox) 737 if (lastBackgroundLayer->clip() != BorderFillBox)
717 return false; 738 return false;
718 739
719 if (lastBackgroundLayer->image() && style()->hasBorderRadius()) 740 if (lastBackgroundLayer->image() && style()->hasBorderRadius())
720 return false; 741 return false;
721 742
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 953
933 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 954 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
934 for (LayoutObject* child = startChild; child && child != endChild; ) { 955 for (LayoutObject* child = startChild; child && child != endChild; ) {
935 // Save our next sibling as moveChildTo will clear it. 956 // Save our next sibling as moveChildTo will clear it.
936 LayoutObject* nextSibling = child->nextSibling(); 957 LayoutObject* nextSibling = child->nextSibling();
937 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 958 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
938 child = nextSibling; 959 child = nextSibling;
939 } 960 }
940 } 961 }
941 962
963 bool LayoutBoxModelObject::backgroundStolenForBeingBody() const
964 {
965 // http://www.w3.org/TR/css3-background/#body-background
966 // If the root element is <html> with no background, and a <body> child elem ent exists,
967 // the root element steals the first <body> child element's background.
968 if (!isBody())
969 return false;
970
971 Element* rootElement = document().documentElement();
972 if (!isHTMLHtmlElement(rootElement) || rootElement->ensureComputedStyle()->h asBackground())
973 return false;
974
975 if (node() != document().body())
976 return false;
977
978 return true;
979 }
980
942 } // namespace blink 981 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698