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

Issue 1308953009: Move Image ownership out of CSSValue (Closed)

Created:
5 years, 3 months ago by sashab
Modified:
4 years ago
Reviewers:
Timothy Loh
CC:
blink-reviews, blink-reviews-style_chromium.org, blink-reviews-css, sof, eae+blinkwatch, blink-reviews-dom_chromium.org, dglazkov+blink, apavlov+blink_chromium.org, darktears, rwlbuis, shans
Target Ref:
refs/heads/master
Project:
blink
Visibility:
Public.

Description

Move Image ownership out of CSSValue Move Image ownership out of CSSValue, keeping CSSValues as immutable objects. Created a class CSStyleImageMap which is stored on ElementStyleResources and ComputedStyle (although ComputedStyle needs to stay small, so this isn't a good place for it). Still a WIP. DNL.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+186 lines, -102 lines) Patch
M Source/core/css/CSSCanvasValue.h View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/css/CSSCrossfadeValue.h View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/css/CSSCrossfadeValue.cpp View 8 chunks +29 lines, -25 lines 0 comments Download
M Source/core/css/CSSCursorImageValue.h View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/css/CSSCursorImageValue.cpp View 3 chunks +4 lines, -4 lines 0 comments Download
M Source/core/css/CSSGradientValue.h View 2 chunks +3 lines, -2 lines 0 comments Download
M Source/core/css/CSSImageGeneratorValue.h View 2 chunks +5 lines, -2 lines 0 comments Download
M Source/core/css/CSSImageGeneratorValue.cpp View 2 chunks +10 lines, -10 lines 0 comments Download
M Source/core/css/CSSImageValue.h View 3 chunks +15 lines, -8 lines 0 comments Download
M Source/core/css/CSSImageValue.cpp View 6 chunks +29 lines, -8 lines 0 comments Download
M Source/core/css/parser/CSSPropertyParser.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/css/resolver/ElementStyleResources.h View 3 chunks +8 lines, -0 lines 0 comments Download
M Source/core/css/resolver/ElementStyleResources.cpp View 3 chunks +15 lines, -9 lines 0 comments Download
M Source/core/css/resolver/StyleResourceLoader.h View 3 chunks +4 lines, -4 lines 0 comments Download
M Source/core/css/resolver/StyleResourceLoader.cpp View 9 chunks +19 lines, -17 lines 0 comments Download
M Source/core/dom/Element.cpp View 1 chunk +9 lines, -2 lines 0 comments Download
M Source/core/style/ComputedStyle.h View 3 chunks +5 lines, -0 lines 0 comments Download
M Source/core/style/ComputedStyle.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/core/style/StyleFetchedImage.cpp View 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/style/StyleFetchedImageSet.cpp View 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/style/StyleGeneratedImage.cpp View 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/style/StyleImage.h View 4 chunks +18 lines, -2 lines 0 comments Download
M Source/core/style/StylePendingImage.h View 1 chunk +1 line, -0 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 6 (1 generated)
sashab
Quick question, no need to look at this patch in detail -- where do you ...
5 years, 3 months ago (2015-09-03 03:46:10 UTC) #2
sashab
5 years, 3 months ago (2015-09-03 03:46:37 UTC) #3
esprehn
On 2015/09/03 at 03:46:10, sashab wrote: > Quick question, no need to look at this ...
5 years, 3 months ago (2015-09-03 04:29:36 UTC) #4
esprehn
On 2015/09/03 at 04:29:36, esprehn wrote: > On 2015/09/03 at 03:46:10, sashab wrote: > > ...
5 years, 3 months ago (2015-09-03 04:31:21 UTC) #5
sashab
5 years, 3 months ago (2015-09-03 07:21:05 UTC) #6
On 2015/09/03 04:31:21, esprehn wrote:
> On 2015/09/03 at 04:29:36, esprehn wrote:
> > On 2015/09/03 at 03:46:10, sashab wrote:
> > > Quick question, no need to look at this patch in detail -- where do you
> think is a good place to own images referred to by CSS? I've got
> ElementStyleResources as the owner for during style resolve, but after that
I'm
> not sure. Should I store them on ComputedStyle? StylePropertySet? Document?
etc.
> > 
> > I don't think we can do all these hash table lookups... while I do like the
> purity of making them immutable doing a table lookup for every image doesn't
> seem like a good idea.
> 
> So to answer your question, the StyleImage needs to own the image resource,
and
> the ComputedStyle (specifically the FillLayers probably) should have a RefPtr
to
> them.

Thanks; OK, I'll have a look at FillLayers.

I agree with the hash table lookups being slow. Another idea is to create the
CSSValues with a reference to the image, stored in a list on
ElementStyleResources and then in FillLayers or wherever. This would be similar
to the CSSValues owning a copy of the image, except that the CSSValues can be
created/destroyed safely while the image can have their ownership transferred.

I.e.:

class CSSImageValue {
public:
  create(StyleImageEntry&) { ... }
  StyleImage* cachedOrPendingImage() const
  {
     ... logic ...
     image.value = PendingImage::create() // can still be const because this
doesn't count as modifying CSSImageValue
     return image.value;
  }
  ~CSSImageValue() { image.parent->delete(this); }

private:
  StyleImageEntry& image;
}

Some places would still have to remove & re-create the image completely, e.g.
see the CL changes in Element.cpp when the image URL is re-resolved.

The only problem is if they're created in the parser etc where the
StyleImageEntry isn't available yet... Maybe we'd have to plumb
ElementStyleResources through so we can make space for it.

Powered by Google App Engine
This is Rietveld 408576698