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

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: fix under invalidation (override LayoutView::visualOverflowRect), revise LayoutBoxModelObject::styl… 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"
30 #include "core/html/HTMLBodyElement.h"
29 #include "core/layout/ImageQualityController.h" 31 #include "core/layout/ImageQualityController.h"
30 #include "core/layout/LayoutBlock.h" 32 #include "core/layout/LayoutBlock.h"
31 #include "core/layout/LayoutFlowThread.h" 33 #include "core/layout/LayoutFlowThread.h"
32 #include "core/layout/LayoutGeometryMap.h" 34 #include "core/layout/LayoutGeometryMap.h"
33 #include "core/layout/LayoutInline.h" 35 #include "core/layout/LayoutInline.h"
34 #include "core/layout/LayoutObject.h" 36 #include "core/layout/LayoutObject.h"
35 #include "core/layout/LayoutTextFragment.h" 37 #include "core/layout/LayoutTextFragment.h"
36 #include "core/layout/LayoutView.h" 38 #include "core/layout/LayoutView.h"
37 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h" 39 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h"
38 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" 40 #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 244 // gets the same layout after changing position property, although no
243 // re-raster (rect-based invalidation) is needed, display items should 245 // re-raster (rect-based invalidation) is needed, display items should
244 // still update their paint offset. 246 // still update their paint offset.
245 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && oldStyle) { 247 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && oldStyle) {
246 bool newStyleIsFixedPosition = style()->position() == FixedPosition; 248 bool newStyleIsFixedPosition = style()->position() == FixedPosition;
247 bool oldStyleIsFixedPosition = oldStyle->position() == FixedPosition; 249 bool oldStyleIsFixedPosition = oldStyle->position() == FixedPosition;
248 if (newStyleIsFixedPosition != oldStyleIsFixedPosition) 250 if (newStyleIsFixedPosition != oldStyleIsFixedPosition)
249 invalidateDisplayItemClientForNonCompositingDescendants(); 251 invalidateDisplayItemClientForNonCompositingDescendants();
250 } 252 }
251 253
254 if (isDocumentElement()) {
chrishtr 2015/06/08 20:30:58 Please add a comment.
trchen 2015/06/08 22:46:55 Done.
255 HTMLBodyElement* body = document().firstBodyElement();
256 LayoutObject* bodyLayout = body ? body->layoutObject() : nullptr;
257 if (bodyLayout && bodyLayout->isBoxModelObject()) {
258 bool newStoleBodyBackground = toLayoutBoxModelObject(bodyLayout)->ba ckgroundStolenForBeingBody(style());
259 bool oldStoleBodyBackground = oldStyle && toLayoutBoxModelObject(bod yLayout)->backgroundStolenForBeingBody(oldStyle);
260 if (newStoleBodyBackground != oldStoleBodyBackground
261 && bodyLayout->style() && bodyLayout->style()->hasBackground()) {
262 bodyLayout->setShouldDoFullPaintInvalidation();
263 }
264 }
265 }
266
252 if (FrameView *frameView = view()->frameView()) { 267 if (FrameView *frameView = view()->frameView()) {
253 bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosit ion(); 268 bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosit ion();
254 bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportCo nstrainedPosition(); 269 bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportCo nstrainedPosition();
255 if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) { 270 if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) {
256 if (newStyleIsViewportConstained && layer()) 271 if (newStyleIsViewportConstained && layer())
257 frameView->addViewportConstrainedObject(this); 272 frameView->addViewportConstrainedObject(this);
258 else 273 else
259 frameView->removeViewportConstrainedObject(this); 274 frameView->removeViewportConstrainedObject(this);
260 } 275 }
261 } 276 }
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 947
933 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 948 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
934 for (LayoutObject* child = startChild; child && child != endChild; ) { 949 for (LayoutObject* child = startChild; child && child != endChild; ) {
935 // Save our next sibling as moveChildTo will clear it. 950 // Save our next sibling as moveChildTo will clear it.
936 LayoutObject* nextSibling = child->nextSibling(); 951 LayoutObject* nextSibling = child->nextSibling();
937 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 952 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
938 child = nextSibling; 953 child = nextSibling;
939 } 954 }
940 } 955 }
941 956
957 bool LayoutBoxModelObject::backgroundStolenForBeingBody(const ComputedStyle* roo tElementStyle) const
958 {
959 // http://www.w3.org/TR/css3-background/#body-background
960 // If the root element is <html> with no background, and a <body> child elem ent exists,
961 // the root element steals the first <body> child element's background.
962 if (!isBody())
963 return false;
964
965 Element* rootElement = document().documentElement();
966 if (!isHTMLHtmlElement(rootElement))
967 return false;
968
969 if (!rootElementStyle)
970 rootElementStyle = rootElement->ensureComputedStyle();
971 if (rootElementStyle->hasBackground())
972 return false;
973
974 if (node() != document().firstBodyElement())
975 return false;
976
977 return true;
978 }
979
942 } // namespace blink 980 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698