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

Side by Side Diff: Source/core/rendering/RenderObject.cpp

Issue 381473002: Use reference for FillLayer if possible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | Source/core/rendering/RenderTableCell.cpp » ('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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 return true; 897 return true;
898 } else if (img->usesImageContainerSize()) { 898 } else if (img->usesImageContainerSize()) {
899 return true; 899 return true;
900 } 900 }
901 901
902 return false; 902 return false;
903 } 903 }
904 904
905 bool RenderObject::mustInvalidateBackgroundOrBorderPaintOnWidthChange() const 905 bool RenderObject::mustInvalidateBackgroundOrBorderPaintOnWidthChange() const
906 { 906 {
907 if (hasMask() && mustInvalidateFillLayersPaintOnWidthChange(*style()->maskLa yers())) 907 if (hasMask() && mustInvalidateFillLayersPaintOnWidthChange(style()->maskLay ers()))
908 return true; 908 return true;
909 909
910 // If we don't have a background/border/mask, then nothing to do. 910 // If we don't have a background/border/mask, then nothing to do.
911 if (!hasBoxDecorationBackground()) 911 if (!hasBoxDecorationBackground())
912 return false; 912 return false;
913 913
914 if (mustInvalidateFillLayersPaintOnWidthChange(*style()->backgroundLayers()) ) 914 if (mustInvalidateFillLayersPaintOnWidthChange(style()->backgroundLayers()))
915 return true; 915 return true;
916 916
917 // Our fill layers are ok. Let's check border. 917 // Our fill layers are ok. Let's check border.
918 if (style()->hasBorder() && canRenderBorderImage()) 918 if (style()->hasBorder() && canRenderBorderImage())
919 return true; 919 return true;
920 920
921 return false; 921 return false;
922 } 922 }
923 923
924 bool RenderObject::mustInvalidateBackgroundOrBorderPaintOnHeightChange() const 924 bool RenderObject::mustInvalidateBackgroundOrBorderPaintOnHeightChange() const
925 { 925 {
926 if (hasMask() && mustInvalidateFillLayersPaintOnHeightChange(*style()->maskL ayers())) 926 if (hasMask() && mustInvalidateFillLayersPaintOnHeightChange(style()->maskLa yers()))
927 return true; 927 return true;
928 928
929 // If we don't have a background/border/mask, then nothing to do. 929 // If we don't have a background/border/mask, then nothing to do.
930 if (!hasBoxDecorationBackground()) 930 if (!hasBoxDecorationBackground())
931 return false; 931 return false;
932 932
933 if (mustInvalidateFillLayersPaintOnHeightChange(*style()->backgroundLayers() )) 933 if (mustInvalidateFillLayersPaintOnHeightChange(style()->backgroundLayers()) )
934 return true; 934 return true;
935 935
936 // Our fill layers are ok. Let's check border. 936 // Our fill layers are ok. Let's check border.
937 if (style()->hasBorder() && canRenderBorderImage()) 937 if (style()->hasBorder() && canRenderBorderImage())
938 return true; 938 return true;
939 939
940 return false; 940 return false;
941 } 941 }
942 942
943 void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2, 943 void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2,
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 if (m_style) 2014 if (m_style)
2015 diff = m_style->visualInvalidationDiff(*style); 2015 diff = m_style->visualInvalidationDiff(*style);
2016 2016
2017 diff = adjustStyleDifference(diff); 2017 diff = adjustStyleDifference(diff);
2018 2018
2019 styleWillChange(diff, *style); 2019 styleWillChange(diff, *style);
2020 2020
2021 RefPtr<RenderStyle> oldStyle = m_style.release(); 2021 RefPtr<RenderStyle> oldStyle = m_style.release();
2022 setStyleInternal(style); 2022 setStyleInternal(style);
2023 2023
2024 updateFillImages(oldStyle ? oldStyle->backgroundLayers() : 0, m_style ? m_st yle->backgroundLayers() : 0); 2024 updateFillImages(oldStyle ? &oldStyle->backgroundLayers() : 0, m_style->back groundLayers());
2025 updateFillImages(oldStyle ? oldStyle->maskLayers() : 0, m_style ? m_style->m askLayers() : 0); 2025 updateFillImages(oldStyle ? &oldStyle->maskLayers() : 0, m_style->maskLayers ());
2026 2026
2027 updateImage(oldStyle ? oldStyle->borderImage().image() : 0, m_style ? m_styl e->borderImage().image() : 0); 2027 updateImage(oldStyle ? oldStyle->borderImage().image() : 0, m_style->borderI mage().image());
2028 updateImage(oldStyle ? oldStyle->maskBoxImage().image() : 0, m_style ? m_sty le->maskBoxImage().image() : 0); 2028 updateImage(oldStyle ? oldStyle->maskBoxImage().image() : 0, m_style->maskBo xImage().image());
2029 2029
2030 updateShapeImage(oldStyle ? oldStyle->shapeOutside() : 0, m_style ? m_style- >shapeOutside() : 0); 2030 updateShapeImage(oldStyle ? oldStyle->shapeOutside() : 0, m_style->shapeOuts ide());
2031 2031
2032 bool doesNotNeedLayout = !m_parent || isText(); 2032 bool doesNotNeedLayout = !m_parent || isText();
2033 2033
2034 styleDidChange(diff, oldStyle.get()); 2034 styleDidChange(diff, oldStyle.get());
2035 2035
2036 // FIXME: |this| might be destroyed here. This can currently happen for a Re nderTextFragment when 2036 // FIXME: |this| might be destroyed here. This can currently happen for a Re nderTextFragment when
2037 // its first-letter block gets an update in RenderTextFragment::styleDidChan ge. For RenderTextFragment(s), 2037 // its first-letter block gets an update in RenderTextFragment::styleDidChan ge. For RenderTextFragment(s),
2038 // we will safely bail out with the doesNotNeedLayout flag. We might want to broaden this condition 2038 // we will safely bail out with the doesNotNeedLayout flag. We might want to broaden this condition
2039 // in the future as we move renderer changes out of layout and into style ch anges. 2039 // in the future as we move renderer changes out of layout and into style ch anges.
2040 if (doesNotNeedLayout) 2040 if (doesNotNeedLayout)
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 2246
2247 // Preserve the position style of anonymous block continuations as they can have relative position when 2247 // Preserve the position style of anonymous block continuations as they can have relative position when
2248 // they contain block descendants of relative positioned inlines. 2248 // they contain block descendants of relative positioned inlines.
2249 if (child->isRelPositioned() && toRenderBlock(child)->isAnonymousBlockCo ntinuation()) 2249 if (child->isRelPositioned() && toRenderBlock(child)->isAnonymousBlockCo ntinuation())
2250 newStyle->setPosition(child->style()->position()); 2250 newStyle->setPosition(child->style()->position());
2251 2251
2252 child->setStyle(newStyle.release()); 2252 child->setStyle(newStyle.release());
2253 } 2253 }
2254 } 2254 }
2255 2255
2256 void RenderObject::updateFillImages(const FillLayer* oldLayers, const FillLayer* newLayers) 2256 void RenderObject::updateFillImages(const FillLayer* oldLayers, const FillLayer& newLayers)
2257 { 2257 {
2258 // Optimize the common case 2258 // Optimize the common case
2259 if (oldLayers && !oldLayers->next() && newLayers && !newLayers->next() && (o ldLayers->image() == newLayers->image())) 2259 if (oldLayers && !oldLayers->next() && !newLayers.next() && (oldLayers->imag e() == newLayers.image()))
2260 return; 2260 return;
2261 2261
2262 // Go through the new layers and addClients first, to avoid removing all cli ents of an image. 2262 // Go through the new layers and addClients first, to avoid removing all cli ents of an image.
2263 for (const FillLayer* currNew = newLayers; currNew; currNew = currNew->next( )) { 2263 for (const FillLayer* currNew = &newLayers; currNew; currNew = currNew->next ()) {
2264 if (currNew->image()) 2264 if (currNew->image())
2265 currNew->image()->addClient(this); 2265 currNew->image()->addClient(this);
2266 } 2266 }
2267 2267
2268 for (const FillLayer* currOld = oldLayers; currOld; currOld = currOld->next( )) { 2268 for (const FillLayer* currOld = oldLayers; currOld; currOld = currOld->next( )) {
2269 if (currOld->image()) 2269 if (currOld->image())
2270 currOld->image()->removeClient(this); 2270 currOld->image()->removeClient(this);
2271 } 2271 }
2272 } 2272 }
2273 2273
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
2810 if (!shapeValue) 2810 if (!shapeValue)
2811 return; 2811 return;
2812 if (StyleImage* shapeImage = shapeValue->image()) 2812 if (StyleImage* shapeImage = shapeValue->image())
2813 shapeImage->removeClient(this); 2813 shapeImage->removeClient(this);
2814 } 2814 }
2815 2815
2816 void RenderObject::postDestroy() 2816 void RenderObject::postDestroy()
2817 { 2817 {
2818 // It seems ugly that this is not in willBeDestroyed(). 2818 // It seems ugly that this is not in willBeDestroyed().
2819 if (m_style) { 2819 if (m_style) {
2820 for (const FillLayer* bgLayer = m_style->backgroundLayers(); bgLayer; bg Layer = bgLayer->next()) { 2820 for (const FillLayer* bgLayer = &m_style->backgroundLayers(); bgLayer; b gLayer = bgLayer->next()) {
2821 if (StyleImage* backgroundImage = bgLayer->image()) 2821 if (StyleImage* backgroundImage = bgLayer->image())
2822 backgroundImage->removeClient(this); 2822 backgroundImage->removeClient(this);
2823 } 2823 }
2824 2824
2825 for (const FillLayer* maskLayer = m_style->maskLayers(); maskLayer; mask Layer = maskLayer->next()) { 2825 for (const FillLayer* maskLayer = &m_style->maskLayers(); maskLayer; mas kLayer = maskLayer->next()) {
2826 if (StyleImage* maskImage = maskLayer->image()) 2826 if (StyleImage* maskImage = maskLayer->image())
2827 maskImage->removeClient(this); 2827 maskImage->removeClient(this);
2828 } 2828 }
2829 2829
2830 if (StyleImage* borderImage = m_style->borderImage().image()) 2830 if (StyleImage* borderImage = m_style->borderImage().image())
2831 borderImage->removeClient(this); 2831 borderImage->removeClient(this);
2832 2832
2833 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image()) 2833 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image())
2834 maskBoxImage->removeClient(this); 2834 maskBoxImage->removeClient(this);
2835 2835
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
3447 { 3447 {
3448 if (object1) { 3448 if (object1) {
3449 const WebCore::RenderObject* root = object1; 3449 const WebCore::RenderObject* root = object1;
3450 while (root->parent()) 3450 while (root->parent())
3451 root = root->parent(); 3451 root = root->parent();
3452 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3452 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3453 } 3453 }
3454 } 3454 }
3455 3455
3456 #endif 3456 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | Source/core/rendering/RenderTableCell.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698