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

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

Issue 1145993002: Refactor root element background painting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase, adding back TestExpectation 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
« no previous file with comments | « Source/core/layout/LayoutObject.h ('k') | Source/core/layout/LayoutView.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) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 2284 matching lines...) Expand 10 before | Expand all | Expand 10 after
2295 bool LayoutObject::isRooted() const 2295 bool LayoutObject::isRooted() const
2296 { 2296 {
2297 const LayoutObject* object = this; 2297 const LayoutObject* object = this;
2298 while (object->parent() && !object->hasLayer()) 2298 while (object->parent() && !object->hasLayer())
2299 object = object->parent(); 2299 object = object->parent();
2300 if (object->hasLayer()) 2300 if (object->hasLayer())
2301 return toLayoutBoxModelObject(object)->layer()->root()->isRootLayer(); 2301 return toLayoutBoxModelObject(object)->layer()->root()->isRootLayer();
2302 return false; 2302 return false;
2303 } 2303 }
2304 2304
2305 LayoutObject* LayoutObject::layoutObjectForRootBackground()
2306 {
2307 ASSERT(isDocumentElement());
2308 if (!hasBackground() && isHTMLHtmlElement(node())) {
2309 // Locate the <body> element using the DOM. This is easier than trying
2310 // to crawl around a layout tree with potential :before/:after content a nd
2311 // anonymous blocks created by inline <body> tags etc. We can locate the <body>
2312 // layout object very easily via the DOM.
2313 HTMLElement* body = document().body();
2314 LayoutObject* bodyObject = isHTMLBodyElement(body) ? body->layoutObject( ) : 0;
2315 if (bodyObject)
2316 return bodyObject;
2317 }
2318
2319 return this;
2320 }
2321
2322 RespectImageOrientationEnum LayoutObject::shouldRespectImageOrientation() const 2305 RespectImageOrientationEnum LayoutObject::shouldRespectImageOrientation() const
2323 { 2306 {
2324 // Respect the image's orientation if it's being used as a full-page image o r it's 2307 // Respect the image's orientation if it's being used as a full-page image o r it's
2325 // an <img> and the setting to respect it everywhere is set. 2308 // an <img> and the setting to respect it everywhere is set.
2326 return document().isImageDocument() 2309 return document().isImageDocument()
2327 || (document().settings() && document().settings()->shouldRespectImageOr ientation() && isHTMLImageElement(node())) ? RespectImageOrientation : DoNotResp ectImageOrientation; 2310 || (document().settings() && document().settings()->shouldRespectImageOr ientation() && isHTMLImageElement(node())) ? RespectImageOrientation : DoNotResp ectImageOrientation;
2328 } 2311 }
2329 2312
2330 LayoutObject* LayoutObject::container(const LayoutBoxModelObject* paintInvalidat ionContainer, bool* paintInvalidationContainerSkipped) const 2313 LayoutObject* LayoutObject::container(const LayoutBoxModelObject* paintInvalidat ionContainer, bool* paintInvalidationContainerSkipped) const
2331 { 2314 {
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 { 3147 {
3165 // Only full invalidation reasons are allowed. 3148 // Only full invalidation reasons are allowed.
3166 ASSERT(isFullPaintInvalidationReason(reason)); 3149 ASSERT(isFullPaintInvalidationReason(reason));
3167 3150
3168 bool isUpgradingDelayedFullToFull = m_bitfields.fullPaintInvalidationReason( ) == PaintInvalidationDelayedFull && reason != PaintInvalidationDelayedFull; 3151 bool isUpgradingDelayedFullToFull = m_bitfields.fullPaintInvalidationReason( ) == PaintInvalidationDelayedFull && reason != PaintInvalidationDelayedFull;
3169 3152
3170 if (m_bitfields.fullPaintInvalidationReason() == PaintInvalidationNone || is UpgradingDelayedFullToFull) { 3153 if (m_bitfields.fullPaintInvalidationReason() == PaintInvalidationNone || is UpgradingDelayedFullToFull) {
3171 if (reason == PaintInvalidationFull) 3154 if (reason == PaintInvalidationFull)
3172 reason = documentLifecycleBasedPaintInvalidationReason(document().li fecycle()); 3155 reason = documentLifecycleBasedPaintInvalidationReason(document().li fecycle());
3173 m_bitfields.setFullPaintInvalidationReason(reason); 3156 m_bitfields.setFullPaintInvalidationReason(reason);
3174
3175 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && isBody()) {
3176 // The rootObject paints view's background. We need to invalidate it when
3177 // view's background changes because of change of body's style.
3178 // FIXME: The condition is broader than needed for simplicity.
3179 // Might remove this when fixing crbug.com/475115.
3180 if (LayoutObject* rootObject = document().documentElement()->layoutO bject())
3181 rootObject->setShouldDoFullPaintInvalidation();
3182 }
3183 } 3157 }
3184 3158
3185 if (!isUpgradingDelayedFullToFull) { 3159 if (!isUpgradingDelayedFullToFull) {
3186 ASSERT(document().lifecycle().state() != DocumentLifecycle::InPaintInval idation); 3160 ASSERT(document().lifecycle().state() != DocumentLifecycle::InPaintInval idation);
3187 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is called outside of FrameView::updateLayoutAndStyleForPainting(). 3161 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is called outside of FrameView::updateLayoutAndStyleForPainting().
3188 markContainerChainForPaintInvalidation(); 3162 markContainerChainForPaintInvalidation();
3189 } 3163 }
3190 } 3164 }
3191 3165
3192 void LayoutObject::setMayNeedPaintInvalidation() 3166 void LayoutObject::setMayNeedPaintInvalidation()
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3309 const blink::LayoutObject* root = object1; 3283 const blink::LayoutObject* root = object1;
3310 while (root->parent()) 3284 while (root->parent())
3311 root = root->parent(); 3285 root = root->parent();
3312 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3286 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3313 } else { 3287 } else {
3314 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); 3288 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n");
3315 } 3289 }
3316 } 3290 }
3317 3291
3318 #endif 3292 #endif
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutObject.h ('k') | Source/core/layout/LayoutView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698