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

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: fix DocumentLifecycle error 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) 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 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 bool LayoutObject::isRooted() const 2293 bool LayoutObject::isRooted() const
2294 { 2294 {
2295 const LayoutObject* object = this; 2295 const LayoutObject* object = this;
2296 while (object->parent() && !object->hasLayer()) 2296 while (object->parent() && !object->hasLayer())
2297 object = object->parent(); 2297 object = object->parent();
2298 if (object->hasLayer()) 2298 if (object->hasLayer())
2299 return toLayoutBoxModelObject(object)->layer()->root()->isRootLayer(); 2299 return toLayoutBoxModelObject(object)->layer()->root()->isRootLayer();
2300 return false; 2300 return false;
2301 } 2301 }
2302 2302
2303 LayoutObject* LayoutObject::layoutObjectForRootBackground()
2304 {
2305 ASSERT(isDocumentElement());
2306 if (!hasBackground() && isHTMLHtmlElement(node())) {
2307 // Locate the <body> element using the DOM. This is easier than trying
2308 // to crawl around a layout tree with potential :before/:after content a nd
2309 // anonymous blocks created by inline <body> tags etc. We can locate the <body>
2310 // layout object very easily via the DOM.
2311 HTMLElement* body = document().body();
2312 LayoutObject* bodyObject = isHTMLBodyElement(body) ? body->layoutObject( ) : 0;
2313 if (bodyObject)
2314 return bodyObject;
2315 }
2316
2317 return this;
2318 }
2319
2320 RespectImageOrientationEnum LayoutObject::shouldRespectImageOrientation() const 2303 RespectImageOrientationEnum LayoutObject::shouldRespectImageOrientation() const
2321 { 2304 {
2322 // Respect the image's orientation if it's being used as a full-page image o r it's 2305 // Respect the image's orientation if it's being used as a full-page image o r it's
2323 // an <img> and the setting to respect it everywhere is set. 2306 // an <img> and the setting to respect it everywhere is set.
2324 return document().isImageDocument() 2307 return document().isImageDocument()
2325 || (document().settings() && document().settings()->shouldRespectImageOr ientation() && isHTMLImageElement(node())) ? RespectImageOrientation : DoNotResp ectImageOrientation; 2308 || (document().settings() && document().settings()->shouldRespectImageOr ientation() && isHTMLImageElement(node())) ? RespectImageOrientation : DoNotResp ectImageOrientation;
2326 } 2309 }
2327 2310
2328 LayoutObject* LayoutObject::container(const LayoutBoxModelObject* paintInvalidat ionContainer, bool* paintInvalidationContainerSkipped) const 2311 LayoutObject* LayoutObject::container(const LayoutBoxModelObject* paintInvalidat ionContainer, bool* paintInvalidationContainerSkipped) const
2329 { 2312 {
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
3162 { 3145 {
3163 // Only full invalidation reasons are allowed. 3146 // Only full invalidation reasons are allowed.
3164 ASSERT(isFullPaintInvalidationReason(reason)); 3147 ASSERT(isFullPaintInvalidationReason(reason));
3165 3148
3166 bool isUpgradingDelayedFullToFull = m_bitfields.fullPaintInvalidationReason( ) == PaintInvalidationDelayedFull && reason != PaintInvalidationDelayedFull; 3149 bool isUpgradingDelayedFullToFull = m_bitfields.fullPaintInvalidationReason( ) == PaintInvalidationDelayedFull && reason != PaintInvalidationDelayedFull;
3167 3150
3168 if (m_bitfields.fullPaintInvalidationReason() == PaintInvalidationNone || is UpgradingDelayedFullToFull) { 3151 if (m_bitfields.fullPaintInvalidationReason() == PaintInvalidationNone || is UpgradingDelayedFullToFull) {
3169 if (reason == PaintInvalidationFull) 3152 if (reason == PaintInvalidationFull)
3170 reason = documentLifecycleBasedPaintInvalidationReason(document().li fecycle()); 3153 reason = documentLifecycleBasedPaintInvalidationReason(document().li fecycle());
3171 m_bitfields.setFullPaintInvalidationReason(reason); 3154 m_bitfields.setFullPaintInvalidationReason(reason);
3172
3173 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && isBody()) {
3174 // The rootObject paints view's background. We need to invalidate it when
3175 // view's background changes because of change of body's style.
3176 // FIXME: The condition is broader than needed for simplicity.
3177 // Might remove this when fixing crbug.com/475115.
3178 if (LayoutObject* rootObject = document().documentElement()->layoutO bject())
3179 rootObject->setShouldDoFullPaintInvalidation();
3180 }
3181 } 3155 }
3182 3156
3183 if (!isUpgradingDelayedFullToFull) { 3157 if (!isUpgradingDelayedFullToFull) {
3184 ASSERT(document().lifecycle().state() != DocumentLifecycle::InPaintInval idation); 3158 ASSERT(document().lifecycle().state() != DocumentLifecycle::InPaintInval idation);
3185 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is called outside of FrameView::updateLayoutAndStyleForPainting(). 3159 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is called outside of FrameView::updateLayoutAndStyleForPainting().
3186 markContainerChainForPaintInvalidation(); 3160 markContainerChainForPaintInvalidation();
3187 } 3161 }
3188 } 3162 }
3189 3163
3190 void LayoutObject::setMayNeedPaintInvalidation() 3164 void LayoutObject::setMayNeedPaintInvalidation()
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
3291 const blink::LayoutObject* root = object1; 3265 const blink::LayoutObject* root = object1;
3292 while (root->parent()) 3266 while (root->parent())
3293 root = root->parent(); 3267 root = root->parent();
3294 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3268 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3295 } else { 3269 } else {
3296 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); 3270 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n");
3297 } 3271 }
3298 } 3272 }
3299 3273
3300 #endif 3274 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698