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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp

Issue 1858753003: Remove RawPtr from core/css (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * Copyright (C) 2013 Google Inc. All rights reserved. 4 * Copyright (C) 2013 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "platform/graphics/filters/FilterOperation.h" 42 #include "platform/graphics/filters/FilterOperation.h"
43 43
44 namespace blink { 44 namespace blink {
45 45
46 ElementStyleResources::ElementStyleResources(Document& document, float deviceSca leFactor) 46 ElementStyleResources::ElementStyleResources(Document& document, float deviceSca leFactor)
47 : m_document(&document) 47 : m_document(&document)
48 , m_deviceScaleFactor(deviceScaleFactor) 48 , m_deviceScaleFactor(deviceScaleFactor)
49 { 49 {
50 } 50 }
51 51
52 RawPtr<StyleImage> ElementStyleResources::styleImage(CSSPropertyID property, con st CSSValue& value) 52 StyleImage* ElementStyleResources::styleImage(CSSPropertyID property, const CSSV alue& value)
53 { 53 {
54 if (value.isImageValue()) 54 if (value.isImageValue())
55 return cachedOrPendingFromValue(property, toCSSImageValue(value)); 55 return cachedOrPendingFromValue(property, toCSSImageValue(value));
56 56
57 if (value.isImageGeneratorValue()) 57 if (value.isImageGeneratorValue())
58 return generatedOrPendingFromValue(property, toCSSImageGeneratorValue(va lue)); 58 return generatedOrPendingFromValue(property, toCSSImageGeneratorValue(va lue));
59 59
60 if (value.isImageSetValue()) 60 if (value.isImageSetValue())
61 return setOrPendingFromValue(property, toCSSImageSetValue(value)); 61 return setOrPendingFromValue(property, toCSSImageSetValue(value));
62 62
63 if (value.isCursorImageValue()) 63 if (value.isCursorImageValue())
64 return cursorOrPendingFromValue(property, toCSSCursorImageValue(value)); 64 return cursorOrPendingFromValue(property, toCSSCursorImageValue(value));
65 65
66 return nullptr; 66 return nullptr;
67 } 67 }
68 68
69 RawPtr<StyleImage> ElementStyleResources::generatedOrPendingFromValue(CSSPropert yID property, const CSSImageGeneratorValue& value) 69 StyleImage* ElementStyleResources::generatedOrPendingFromValue(CSSPropertyID pro perty, const CSSImageGeneratorValue& value)
70 { 70 {
71 if (value.isPending()) { 71 if (value.isPending()) {
72 m_pendingImageProperties.add(property); 72 m_pendingImageProperties.add(property);
73 return StylePendingImage::create(value); 73 return StylePendingImage::create(value);
74 } 74 }
75 return StyleGeneratedImage::create(value); 75 return StyleGeneratedImage::create(value);
76 } 76 }
77 77
78 RawPtr<StyleImage> ElementStyleResources::setOrPendingFromValue(CSSPropertyID pr operty, const CSSImageSetValue& value) 78 StyleImage* ElementStyleResources::setOrPendingFromValue(CSSPropertyID property, const CSSImageSetValue& value)
79 { 79 {
80 if (value.isCachePending(m_deviceScaleFactor)) { 80 if (value.isCachePending(m_deviceScaleFactor)) {
81 m_pendingImageProperties.add(property); 81 m_pendingImageProperties.add(property);
82 return StylePendingImage::create(value); 82 return StylePendingImage::create(value);
83 } 83 }
84 return value.cachedImage(m_deviceScaleFactor); 84 return value.cachedImage(m_deviceScaleFactor);
85 } 85 }
86 86
87 RawPtr<StyleImage> ElementStyleResources::cachedOrPendingFromValue(CSSPropertyID property, const CSSImageValue& value) 87 StyleImage* ElementStyleResources::cachedOrPendingFromValue(CSSPropertyID proper ty, const CSSImageValue& value)
88 { 88 {
89 if (value.isCachePending()) { 89 if (value.isCachePending()) {
90 m_pendingImageProperties.add(property); 90 m_pendingImageProperties.add(property);
91 return StylePendingImage::create(value); 91 return StylePendingImage::create(value);
92 } 92 }
93 value.restoreCachedResourceIfNeeded(*m_document); 93 value.restoreCachedResourceIfNeeded(*m_document);
94 return value.cachedImage(); 94 return value.cachedImage();
95 } 95 }
96 96
97 RawPtr<StyleImage> ElementStyleResources::cursorOrPendingFromValue(CSSPropertyID property, const CSSCursorImageValue& value) 97 StyleImage* ElementStyleResources::cursorOrPendingFromValue(CSSPropertyID proper ty, const CSSCursorImageValue& value)
98 { 98 {
99 if (value.isCachePending(m_deviceScaleFactor)) { 99 if (value.isCachePending(m_deviceScaleFactor)) {
100 m_pendingImageProperties.add(property); 100 m_pendingImageProperties.add(property);
101 return StylePendingImage::create(value); 101 return StylePendingImage::create(value);
102 } 102 }
103 return value.cachedImage(m_deviceScaleFactor); 103 return value.cachedImage(m_deviceScaleFactor);
104 } 104 }
105 105
106 void ElementStyleResources::addPendingSVGDocument(FilterOperation* filterOperati on, CSSSVGDocumentValue* cssSVGDocumentValue) 106 void ElementStyleResources::addPendingSVGDocument(FilterOperation* filterOperati on, CSSSVGDocumentValue* cssSVGDocumentValue)
107 { 107 {
108 m_pendingSVGDocuments.set(filterOperation, cssSVGDocumentValue); 108 m_pendingSVGDocuments.set(filterOperation, cssSVGDocumentValue);
109 } 109 }
110 110
111 void ElementStyleResources::loadPendingSVGDocuments(ComputedStyle* computedStyle ) 111 void ElementStyleResources::loadPendingSVGDocuments(ComputedStyle* computedStyle )
112 { 112 {
113 if (!computedStyle->hasFilter() || m_pendingSVGDocuments.isEmpty()) 113 if (!computedStyle->hasFilter() || m_pendingSVGDocuments.isEmpty())
114 return; 114 return;
115 115
116 FilterOperations::FilterOperationVector& filterOperations = computedStyle->m utableFilter().operations(); 116 FilterOperations::FilterOperationVector& filterOperations = computedStyle->m utableFilter().operations();
117 for (unsigned i = 0; i < filterOperations.size(); ++i) { 117 for (unsigned i = 0; i < filterOperations.size(); ++i) {
118 RawPtr<FilterOperation> filterOperation = filterOperations.at(i); 118 FilterOperation* filterOperation = filterOperations.at(i);
119 if (filterOperation->type() == FilterOperation::REFERENCE) { 119 if (filterOperation->type() == FilterOperation::REFERENCE) {
120 ReferenceFilterOperation* referenceFilter = toReferenceFilterOperati on(filterOperation.get()); 120 ReferenceFilterOperation* referenceFilter = toReferenceFilterOperati on(filterOperation);
121 121
122 CSSSVGDocumentValue* value = m_pendingSVGDocuments.get(referenceFilt er); 122 CSSSVGDocumentValue* value = m_pendingSVGDocuments.get(referenceFilt er);
123 if (!value) 123 if (!value)
124 continue; 124 continue;
125 DocumentResource* resource = value->load(m_document); 125 DocumentResource* resource = value->load(m_document);
126 if (!resource) 126 if (!resource)
127 continue; 127 continue;
128 128
129 // Stash the DocumentResource on the reference filter. 129 // Stash the DocumentResource on the reference filter.
130 ReferenceFilterBuilder::setDocumentResourceReference(referenceFilter , adoptPtr(new DocumentResourceReference(resource))); 130 ReferenceFilterBuilder::setDocumentResourceReference(referenceFilter , adoptPtr(new DocumentResourceReference(resource)));
131 } 131 }
132 } 132 }
133 } 133 }
134 134
135 RawPtr<StyleImage> ElementStyleResources::loadPendingImage(StylePendingImage* pe ndingImage, CrossOriginAttributeValue crossOrigin) 135 StyleImage* ElementStyleResources::loadPendingImage(StylePendingImage* pendingIm age, CrossOriginAttributeValue crossOrigin)
136 { 136 {
137 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) 137 if (CSSImageValue* imageValue = pendingImage->cssImageValue())
138 return imageValue->cacheImage(m_document, crossOrigin); 138 return imageValue->cacheImage(m_document, crossOrigin);
139 139
140 if (CSSImageGeneratorValue* imageGeneratorValue = pendingImage->cssImageGene ratorValue()) { 140 if (CSSImageGeneratorValue* imageGeneratorValue = pendingImage->cssImageGene ratorValue()) {
141 imageGeneratorValue->loadSubimages(m_document); 141 imageGeneratorValue->loadSubimages(m_document);
142 return StyleGeneratedImage::create(*imageGeneratorValue); 142 return StyleGeneratedImage::create(*imageGeneratorValue);
143 } 143 }
144 144
145 if (CSSCursorImageValue* cursorImageValue = pendingImage->cssCursorImageValu e()) 145 if (CSSCursorImageValue* cursorImageValue = pendingImage->cssCursorImageValu e())
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 210 }
211 case CSSPropertyBorderImageSource: { 211 case CSSPropertyBorderImageSource: {
212 if (style->borderImageSource() && style->borderImageSource()->isPend ingImage()) 212 if (style->borderImageSource() && style->borderImageSource()->isPend ingImage())
213 style->setBorderImageSource(loadPendingImage(toStylePendingImage (style->borderImageSource()))); 213 style->setBorderImageSource(loadPendingImage(toStylePendingImage (style->borderImageSource())));
214 break; 214 break;
215 } 215 }
216 case CSSPropertyWebkitBoxReflect: { 216 case CSSPropertyWebkitBoxReflect: {
217 if (StyleReflection* reflection = style->boxReflect()) { 217 if (StyleReflection* reflection = style->boxReflect()) {
218 const NinePieceImage& maskImage = reflection->mask(); 218 const NinePieceImage& maskImage = reflection->mask();
219 if (maskImage.image() && maskImage.image()->isPendingImage()) { 219 if (maskImage.image() && maskImage.image()->isPendingImage()) {
220 RawPtr<StyleImage> loadedImage = loadPendingImage(toStylePen dingImage(maskImage.image())); 220 StyleImage* loadedImage = loadPendingImage(toStylePendingIma ge(maskImage.image()));
221 reflection->setMask(NinePieceImage(loadedImage.release(), ma skImage.imageSlices(), maskImage.fill(), maskImage.borderSlices(), maskImage.out set(), maskImage.horizontalRule(), maskImage.verticalRule())); 221 reflection->setMask(NinePieceImage(loadedImage, maskImage.im ageSlices(), maskImage.fill(), maskImage.borderSlices(), maskImage.outset(), mas kImage.horizontalRule(), maskImage.verticalRule()));
222 } 222 }
223 } 223 }
224 break; 224 break;
225 } 225 }
226 case CSSPropertyWebkitMaskBoxImageSource: { 226 case CSSPropertyWebkitMaskBoxImageSource: {
227 if (style->maskBoxImageSource() && style->maskBoxImageSource()->isPe ndingImage()) 227 if (style->maskBoxImageSource() && style->maskBoxImageSource()->isPe ndingImage())
228 style->setMaskBoxImageSource(loadPendingImage(toStylePendingImag e(style->maskBoxImageSource()))); 228 style->setMaskBoxImageSource(loadPendingImage(toStylePendingImag e(style->maskBoxImageSource())));
229 break; 229 break;
230 } 230 }
231 case CSSPropertyWebkitMaskImage: { 231 case CSSPropertyWebkitMaskImage: {
(...skipping 13 matching lines...) Expand all
245 } 245 }
246 } 246 }
247 247
248 void ElementStyleResources::loadPendingResources(ComputedStyle* computedStyle) 248 void ElementStyleResources::loadPendingResources(ComputedStyle* computedStyle)
249 { 249 {
250 loadPendingImages(computedStyle); 250 loadPendingImages(computedStyle);
251 loadPendingSVGDocuments(computedStyle); 251 loadPendingSVGDocuments(computedStyle);
252 } 252 }
253 253
254 } // namespace blink 254 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698