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

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

Issue 1240443003: Fix slow repaint object registration (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 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 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 if (LayoutBlock* container = containingBlock()) 1829 if (LayoutBlock* container = containingBlock())
1830 container->setNeedsOverflowRecalcAfterStyleChange(); 1830 container->setNeedsOverflowRecalcAfterStyleChange();
1831 } 1831 }
1832 1832
1833 if (updatedDiff.needsPaintInvalidationLayer()) 1833 if (updatedDiff.needsPaintInvalidationLayer())
1834 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); 1834 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants();
1835 else if (diff.needsPaintInvalidationObject() || updatedDiff.needsPaintInvali dationObject()) 1835 else if (diff.needsPaintInvalidationObject() || updatedDiff.needsPaintInvali dationObject())
1836 setShouldDoFullPaintInvalidation(); 1836 setShouldDoFullPaintInvalidation();
1837 } 1837 }
1838 1838
1839 static inline bool layoutObjectHasBackground(const LayoutObject* layoutObject)
1840 {
1841 return layoutObject && layoutObject->hasBackground();
1842 }
1843
1844 void LayoutObject::styleWillChange(StyleDifference diff, const ComputedStyle& ne wStyle) 1839 void LayoutObject::styleWillChange(StyleDifference diff, const ComputedStyle& ne wStyle)
1845 { 1840 {
1846 if (m_style) { 1841 if (m_style) {
1847 // If our z-index changes value or our visibility changes, 1842 // If our z-index changes value or our visibility changes,
1848 // we need to dirty our stacking context's z-order list. 1843 // we need to dirty our stacking context's z-order list.
1849 bool visibilityChanged = m_style->visibility() != newStyle.visibility() 1844 bool visibilityChanged = m_style->visibility() != newStyle.visibility()
1850 || m_style->zIndex() != newStyle.zIndex() 1845 || m_style->zIndex() != newStyle.zIndex()
1851 || m_style->hasAutoZIndex() != newStyle.hasAutoZIndex(); 1846 || m_style->hasAutoZIndex() != newStyle.hasAutoZIndex();
1852 if (visibilityChanged) { 1847 if (visibilityChanged) {
1853 document().setAnnotatedRegionsDirty(true); 1848 document().setAnnotatedRegionsDirty(true);
(...skipping 25 matching lines...) Expand all
1879 // Clearing these bits is required to avoid leaving stale layoutObjects. 1874 // Clearing these bits is required to avoid leaving stale layoutObjects.
1880 // FIXME: We shouldn't need that hack if our logic was totally correct. 1875 // FIXME: We shouldn't need that hack if our logic was totally correct.
1881 if (diff.needsLayout()) { 1876 if (diff.needsLayout()) {
1882 setFloating(false); 1877 setFloating(false);
1883 clearPositionedState(); 1878 clearPositionedState();
1884 } 1879 }
1885 } else { 1880 } else {
1886 s_affectsParentBlock = false; 1881 s_affectsParentBlock = false;
1887 } 1882 }
1888 1883
1889 if (view()->frameView()) {
1890 bool shouldBlitOnFixedBackgroundImage = false;
1891 if (RuntimeEnabledFeatures::fastMobileScrollingEnabled()) {
1892 // On low-powered/mobile devices, preventing blitting on a scroll ca n cause noticeable delays
1893 // when scrolling a page with a fixed background image. As an optimi zation, assuming there are
1894 // no fixed positoned elements on the page, we can acclerate scrolli ng (via blitting) if we
1895 // ignore the CSS property "background-attachment: fixed".
1896 shouldBlitOnFixedBackgroundImage = true;
1897 }
1898 bool newStyleSlowScroll = !shouldBlitOnFixedBackgroundImage && newStyle. hasFixedBackgroundImage();
1899 bool oldStyleSlowScroll = m_style && !shouldBlitOnFixedBackgroundImage & & m_style->hasFixedBackgroundImage();
1900
1901 bool drawsRootBackground = isDocumentElement() || (isBody() && !layoutOb jectHasBackground(document().documentElement()->layoutObject()));
1902 if (drawsRootBackground && !shouldBlitOnFixedBackgroundImage) {
1903 if (view()->compositor()->supportsFixedRootBackgroundCompositing()) {
1904 if (newStyleSlowScroll && newStyle.hasEntirelyFixedBackground())
1905 newStyleSlowScroll = false;
1906
1907 if (oldStyleSlowScroll && m_style->hasEntirelyFixedBackground())
1908 oldStyleSlowScroll = false;
1909 }
1910 }
1911
1912 if (oldStyleSlowScroll != newStyleSlowScroll) {
1913 if (oldStyleSlowScroll)
1914 view()->frameView()->removeSlowRepaintObject();
1915 if (newStyleSlowScroll)
1916 view()->frameView()->addSlowRepaintObject();
1917 }
1918 }
1919
1920 // Elements with non-auto touch-action will send a SetTouchAction message 1884 // Elements with non-auto touch-action will send a SetTouchAction message
1921 // on touchstart in EventHandler::handleTouchEvent, and so effectively have 1885 // on touchstart in EventHandler::handleTouchEvent, and so effectively have
1922 // a touchstart handler that must be reported. 1886 // a touchstart handler that must be reported.
1923 // 1887 //
1924 // Since a CSS property cannot be applied directly to a text node, a 1888 // Since a CSS property cannot be applied directly to a text node, a
1925 // handler will have already been added for its parent so ignore it. 1889 // handler will have already been added for its parent so ignore it.
1926 TouchAction oldTouchAction = m_style ? m_style->touchAction() : TouchActionA uto; 1890 TouchAction oldTouchAction = m_style ? m_style->touchAction() : TouchActionA uto;
1927 if (node() && !node()->isTextNode() && (oldTouchAction == TouchActionAuto) ! = (newStyle.touchAction() == TouchActionAuto)) { 1891 if (node() && !node()->isTextNode() && (oldTouchAction == TouchActionAuto) ! = (newStyle.touchAction() == TouchActionAuto)) {
1928 EventHandlerRegistry& registry = document().frameHost()->eventHandlerReg istry(); 1892 EventHandlerRegistry& registry = document().frameHost()->eventHandlerReg istry();
1929 if (newStyle.touchAction() != TouchActionAuto) 1893 if (newStyle.touchAction() != TouchActionAuto)
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 2430
2467 if (StyleImage* borderImage = m_style->borderImage().image()) 2431 if (StyleImage* borderImage = m_style->borderImage().image())
2468 borderImage->removeClient(this); 2432 borderImage->removeClient(this);
2469 2433
2470 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image()) 2434 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image())
2471 maskBoxImage->removeClient(this); 2435 maskBoxImage->removeClient(this);
2472 2436
2473 removeShapeImageClient(m_style->shapeOutside()); 2437 removeShapeImageClient(m_style->shapeOutside());
2474 } 2438 }
2475 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->removeLayout Object(this); 2439 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->removeLayout Object(this);
2440
2441 if (frameView() && m_bitfields.isSlowRepaintObject())
2442 frameView()->removeSlowRepaintObject();
Ian Vollick 2015/07/14 02:27:11 why not setIsSlowRepaintObject(false)?
trchen 2015/07/14 03:36:37 That probably works too. I can do that.
2476 } 2443 }
2477 2444
2478 void LayoutObject::insertedIntoTree() 2445 void LayoutObject::insertedIntoTree()
2479 { 2446 {
2480 // FIXME: We should ASSERT(isRooted()) here but generated content makes some out-of-order insertion. 2447 // FIXME: We should ASSERT(isRooted()) here but generated content makes some out-of-order insertion.
2481 2448
2482 // Keep our layer hierarchy updated. Optimize for the common case where we d on't have any children 2449 // Keep our layer hierarchy updated. Optimize for the common case where we d on't have any children
2483 // and don't have a layer attached to ourselves. 2450 // and don't have a layer attached to ourselves.
2484 DeprecatedPaintLayer* layer = nullptr; 2451 DeprecatedPaintLayer* layer = nullptr;
2485 if (slowFirstChild() || hasLayer()) { 2452 if (slowFirstChild() || hasLayer()) {
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
3263 } 3230 }
3264 3231
3265 // FIXME: If we had a flag to force invalidations in a whole subtree, we could g et rid of this function (crbug.com/410097). 3232 // FIXME: If we had a flag to force invalidations in a whole subtree, we could g et rid of this function (crbug.com/410097).
3266 void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescen dants() 3233 void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescen dants()
3267 { 3234 {
3268 // Need to access the current compositing status. 3235 // Need to access the current compositing status.
3269 DisableCompositingQueryAsserts disabler; 3236 DisableCompositingQueryAsserts disabler;
3270 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendantsInternal(t his); 3237 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendantsInternal(t his);
3271 } 3238 }
3272 3239
3240 void LayoutObject::setIsSlowRepaintObject(bool isSlowRepaintObject)
3241 {
3242 ASSERT(frameView());
3243 if (m_bitfields.isSlowRepaintObject() == isSlowRepaintObject)
3244 return;
3245 m_bitfields.setIsSlowRepaintObject(isSlowRepaintObject);
3246 if (isSlowRepaintObject)
3247 frameView()->addSlowRepaintObject();
3248 else
3249 frameView()->removeSlowRepaintObject();
3250 }
3251
3273 } // namespace blink 3252 } // namespace blink
3274 3253
3275 #ifndef NDEBUG 3254 #ifndef NDEBUG
3276 3255
3277 void showTree(const blink::LayoutObject* object) 3256 void showTree(const blink::LayoutObject* object)
3278 { 3257 {
3279 if (object) 3258 if (object)
3280 object->showTreeForThis(); 3259 object->showTreeForThis();
3281 else 3260 else
3282 fprintf(stderr, "Cannot showTree. Root is (nil)\n"); 3261 fprintf(stderr, "Cannot showTree. Root is (nil)\n");
(...skipping 18 matching lines...) Expand all
3301 const blink::LayoutObject* root = object1; 3280 const blink::LayoutObject* root = object1;
3302 while (root->parent()) 3281 while (root->parent())
3303 root = root->parent(); 3282 root = root->parent();
3304 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3283 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3305 } else { 3284 } else {
3306 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); 3285 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n");
3307 } 3286 }
3308 } 3287 }
3309 3288
3310 #endif 3289 #endif
OLDNEW
« Source/core/layout/LayoutBox.cpp ('K') | « Source/core/layout/LayoutObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698