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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSImageGeneratorValue.h

Issue 2941533002: Break StyleImage dependency on LayoutObject (Closed)
Patch Set: Address reviewer comments Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 19 matching lines...) Expand all
30 #include "core/css/CSSValue.h" 30 #include "core/css/CSSValue.h"
31 #include "platform/geometry/IntSizeHash.h" 31 #include "platform/geometry/IntSizeHash.h"
32 #include "platform/heap/SelfKeepAlive.h" 32 #include "platform/heap/SelfKeepAlive.h"
33 #include "platform/wtf/HashCountedSet.h" 33 #include "platform/wtf/HashCountedSet.h"
34 #include "platform/wtf/RefPtr.h" 34 #include "platform/wtf/RefPtr.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 class Document; 38 class Document;
39 class Image; 39 class Image;
40 class LayoutObject;
41 class FloatSize; 40 class FloatSize;
42 class ComputedStyle; 41 class ComputedStyle;
42 class ImageResourceObserver;
43 43
44 struct SizeAndCount { 44 struct SizeAndCount {
45 DISALLOW_NEW(); 45 DISALLOW_NEW();
46 SizeAndCount(IntSize new_size = IntSize(), int new_count = 0) 46 SizeAndCount(IntSize new_size = IntSize(), int new_count = 0)
47 : size(new_size), count(new_count) {} 47 : size(new_size), count(new_count) {}
48 48
49 IntSize size; 49 IntSize size;
50 int count; 50 int count;
51 }; 51 };
52 52
53 using LayoutObjectSizeCountMap = HashMap<const LayoutObject*, SizeAndCount>; 53 using ClientSizeCountMap = HashMap<const ImageResourceObserver*, SizeAndCount>;
54 54
55 class CORE_EXPORT CSSImageGeneratorValue : public CSSValue { 55 class CORE_EXPORT CSSImageGeneratorValue : public CSSValue {
56 public: 56 public:
57 ~CSSImageGeneratorValue(); 57 ~CSSImageGeneratorValue();
58 58
59 void AddClient(const LayoutObject*, const IntSize&); 59 void AddClient(const ImageResourceObserver*, const IntSize&);
60 void RemoveClient(const LayoutObject*); 60 void RemoveClient(const ImageResourceObserver*);
61 PassRefPtr<Image> GetImage(const LayoutObject&, const IntSize&); 61 PassRefPtr<Image> GetImage(const ImageResourceObserver&,
62 const Document&,
63 const ComputedStyle&,
64 const IntSize&);
62 65
63 bool IsFixedSize() const; 66 bool IsFixedSize() const;
64 IntSize FixedSize(const Document&, const FloatSize& default_object_size); 67 IntSize FixedSize(const Document&, const FloatSize& default_object_size);
65 68
66 bool IsPending() const; 69 bool IsPending() const;
67 bool KnownToBeOpaque(const Document&, const ComputedStyle&) const; 70 bool KnownToBeOpaque(const Document&, const ComputedStyle&) const;
68 71
69 void LoadSubimages(const Document&); 72 void LoadSubimages(const Document&);
70 73
71 CSSImageGeneratorValue* ValueWithURLsMadeAbsolute(); 74 CSSImageGeneratorValue* ValueWithURLsMadeAbsolute();
72 75
73 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { 76 DEFINE_INLINE_TRACE_AFTER_DISPATCH() {
74 CSSValue::TraceAfterDispatch(visitor); 77 CSSValue::TraceAfterDispatch(visitor);
75 } 78 }
76 79
77 protected: 80 protected:
78 explicit CSSImageGeneratorValue(ClassType); 81 explicit CSSImageGeneratorValue(ClassType);
79 82
80 Image* GetImage(const LayoutObject*, const IntSize&); 83 Image* GetImage(const ImageResourceObserver*,
84 const Document&,
85 const ComputedStyle&,
86 const IntSize&);
81 void PutImage(const IntSize&, PassRefPtr<Image>); 87 void PutImage(const IntSize&, PassRefPtr<Image>);
82 const LayoutObjectSizeCountMap& Clients() const { return clients_; } 88 const ClientSizeCountMap& Clients() const { return clients_; }
83 89
84 HashCountedSet<IntSize> 90 HashCountedSet<IntSize>
85 sizes_; // A count of how many times a given image size is in use. 91 sizes_; // A count of how many times a given image size is in use.
86 LayoutObjectSizeCountMap 92 ClientSizeCountMap
87 clients_; // A map from LayoutObjects (with entry count) to image sizes. 93 clients_; // A map from LayoutObjects (with entry count) to image sizes.
88 HashMap<IntSize, RefPtr<Image>> 94 HashMap<IntSize, RefPtr<Image>>
89 images_; // A cache of Image objects by image size. 95 images_; // A cache of Image objects by image size.
90 96
91 // TODO(Oilpan): when/if we can make the layoutObject point directly to the 97 // TODO(Oilpan): when/if we can make the layoutObject point directly to the
92 // CSSImageGenerator value using a member we don't need to have this hack 98 // CSSImageGenerator value using a member we don't need to have this hack
93 // where we keep a persistent to the instance as long as there are clients in 99 // where we keep a persistent to the instance as long as there are clients in
94 // the LayoutObjectSizeCountMap. 100 // the ClientSizeCountMap.
95 SelfKeepAlive<CSSImageGeneratorValue> keep_alive_; 101 SelfKeepAlive<CSSImageGeneratorValue> keep_alive_;
96 }; 102 };
97 103
98 DEFINE_CSS_VALUE_TYPE_CASTS(CSSImageGeneratorValue, IsImageGeneratorValue()); 104 DEFINE_CSS_VALUE_TYPE_CASTS(CSSImageGeneratorValue, IsImageGeneratorValue());
99 105
100 } // namespace blink 106 } // namespace blink
101 107
102 #endif // CSSImageGeneratorValue_h 108 #endif // CSSImageGeneratorValue_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSGradientValue.cpp ('k') | third_party/WebKit/Source/core/css/CSSImageGeneratorValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698