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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ImageResource.h

Issue 1427943002: Wrap SVGImage for container during paint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use IntSize for SVGImageForContainer Created 5 years, 1 month 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) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org> 3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
(...skipping 23 matching lines...) Expand all
34 namespace blink { 34 namespace blink {
35 35
36 class ImageResourceClient; 36 class ImageResourceClient;
37 class FetchRequest; 37 class FetchRequest;
38 class ResourceFetcher; 38 class ResourceFetcher;
39 class FloatSize; 39 class FloatSize;
40 class Length; 40 class Length;
41 class MemoryCache; 41 class MemoryCache;
42 class LayoutObject; 42 class LayoutObject;
43 class SecurityOrigin; 43 class SecurityOrigin;
44 class SVGImageForContainer;
45 44
46 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver { 45 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver {
47 friend class MemoryCache; 46 friend class MemoryCache;
48 47
49 public: 48 public:
50 typedef ImageResourceClient ClientType; 49 typedef ImageResourceClient ClientType;
51 50
52 static ResourcePtr<ImageResource> fetch(FetchRequest&, ResourceFetcher*); 51 static ResourcePtr<ImageResource> fetch(FetchRequest&, ResourceFetcher*);
53 52
54 ImageResource(blink::Image*); 53 ImageResource(blink::Image*);
55 // Exposed for testing 54 // Exposed for testing
56 ImageResource(const ResourceRequest&, blink::Image*); 55 ImageResource(const ResourceRequest&, blink::Image*);
57 ~ImageResource() override; 56 ~ImageResource() override;
58 57
59 void load(ResourceFetcher*, const ResourceLoaderOptions&) override; 58 void load(ResourceFetcher*, const ResourceLoaderOptions&) override;
60 59
61 blink::Image* image(); // Returns the nullImage() if the image is not availa ble yet. 60 blink::Image* image(); // Returns the nullImage() if the image is not availa ble yet.
62 blink::Image* imageForLayoutObject(const LayoutObject*); // Returns the null Image() if the image is not available yet.
63 bool hasImage() const { return m_image.get(); } 61 bool hasImage() const { return m_image.get(); }
64 // Side effect: ensures decoded image is in cache, therefore should only be called when about to draw the image. 62 // Side effect: ensures decoded image is in cache, therefore should only be called when about to draw the image.
65 // FIXME: Decoding image on the main thread is expensive, so rather than for cing decode, consider returning false 63 // FIXME: Decoding image on the main thread is expensive, so rather than for cing decode, consider returning false
66 // when image is not decoded yet, as we do in case of deferred decoding. 64 // when image is not decoded yet, as we do in case of deferred decoding.
67 bool currentFrameKnownToBeOpaque(const LayoutObject*); 65 bool currentFrameKnownToBeOpaque(const LayoutObject*);
68 66
69 static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor); // Returns an image and the image's resolution scale factor. 67 static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor); // Returns an image and the image's resolution scale factor.
70 bool willPaintBrokenImage() const; 68 bool willPaintBrokenImage() const;
71 69
72 bool canRender(const LayoutObject& layoutObject, float multiplier) { return !errorOccurred() && !imageSizeForLayoutObject(&layoutObject, multiplier).isEmpty (); } 70 bool canRender(const LayoutObject& layoutObject, float multiplier) { return !errorOccurred() && !imageSizeForLayoutObject(&layoutObject, multiplier).isEmpty (); }
73 71
74 void setContainerSizeForLayoutObject(const ImageResourceClient*, const IntSi ze&, float);
75 bool usesImageContainerSize() const; 72 bool usesImageContainerSize() const;
76 bool imageHasRelativeWidth() const; 73 bool imageHasRelativeWidth() const;
77 bool imageHasRelativeHeight() const; 74 bool imageHasRelativeHeight() const;
78 // The device pixel ratio we got from the server for this image, or 1.0. 75 // The device pixel ratio we got from the server for this image, or 1.0.
79 float devicePixelRatioHeaderValue() const { return m_devicePixelRatioHeaderV alue; } 76 float devicePixelRatioHeaderValue() const { return m_devicePixelRatioHeaderV alue; }
80 bool hasDevicePixelRatioHeaderValue() const { return m_hasDevicePixelRatioHe aderValue; } 77 bool hasDevicePixelRatioHeaderValue() const { return m_hasDevicePixelRatioHe aderValue; }
81 78
82 enum SizeType { 79 enum SizeType {
83 NormalSize, // Report the size of the image associated with a certain la youtObject 80 IntrinsicSize, // Report the intrinsic size.
84 IntrinsicSize, // Report the intrinsic size, i.e. ignore whatever has be en set extrinsically.
85 IntrinsicCorrectedToDPR, // Report the intrinsic size corrected to accou nt for image density. 81 IntrinsicCorrectedToDPR, // Report the intrinsic size corrected to accou nt for image density.
86 }; 82 };
87 // This method takes a zoom multiplier that can be used to increase the natu ral size of the image by the zoom. 83 // This method takes a zoom multiplier that can be used to increase the natu ral size of the image by the zoom.
88 LayoutSize imageSizeForLayoutObject(const LayoutObject*, float multiplier, S izeType = NormalSize); // returns the size of the complete image. 84 LayoutSize imageSizeForLayoutObject(const LayoutObject*, float multiplier, S izeType = IntrinsicSize); // returns the size of the complete image.
89 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei ght, FloatSize& intrinsicRatio); 85 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei ght, FloatSize& intrinsicRatio);
90 86
91 bool isAccessAllowed(SecurityOrigin*); 87 bool isAccessAllowed(SecurityOrigin*);
92 88
93 void updateImageAnimationPolicy(); 89 void updateImageAnimationPolicy();
94 90
95 void didAddClient(ResourceClient*) override; 91 void didAddClient(ResourceClient*) override;
96 void didRemoveClient(ResourceClient*) override; 92 void didRemoveClient(ResourceClient*) override;
97 93
98 void allClientsRemoved() override; 94 void allClientsRemoved() override;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 ImageResource(const ResourceRequest&); 131 ImageResource(const ResourceRequest&);
136 132
137 void clear(); 133 void clear();
138 134
139 void setCustomAcceptHeader(); 135 void setCustomAcceptHeader();
140 void createImage(); 136 void createImage();
141 void updateImage(bool allDataReceived); 137 void updateImage(bool allDataReceived);
142 void clearImage(); 138 void clearImage();
143 // If not null, changeRect is the changed part of the image. 139 // If not null, changeRect is the changed part of the image.
144 void notifyObservers(const IntRect* changeRect = nullptr); 140 void notifyObservers(const IntRect* changeRect = nullptr);
145 IntSize svgImageSizeForLayoutObject(const LayoutObject*) const;
146 blink::Image* svgImageForLayoutObject(const LayoutObject*);
147 bool loadingMultipartContent() const; 141 bool loadingMultipartContent() const;
148 142
149 float m_devicePixelRatioHeaderValue; 143 float m_devicePixelRatioHeaderValue;
150 144
151 typedef HashMap<const ImageResourceClient*, RefPtr<SVGImageForContainer>> Im ageForContainerMap;
152 OwnPtr<ImageForContainerMap> m_imageForContainerMap;
153
154 RefPtr<blink::Image> m_image; 145 RefPtr<blink::Image> m_image;
155 bool m_hasDevicePixelRatioHeaderValue; 146 bool m_hasDevicePixelRatioHeaderValue;
156 }; 147 };
157 148
158 DEFINE_RESOURCE_TYPE_CASTS(Image); 149 DEFINE_RESOURCE_TYPE_CASTS(Image);
159 150
160 } 151 }
161 152
162 #endif 153 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/DEPS ('k') | third_party/WebKit/Source/core/fetch/ImageResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698