| OLD | NEW |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 continue; | 70 continue; |
| 71 | 71 |
| 72 // Stash the DocumentResource on the reference filter. | 72 // Stash the DocumentResource on the reference filter. |
| 73 ReferenceFilterBuilder::setDocumentResourceReference(referenceFilter
, adoptPtr(new DocumentResourceReference(resource))); | 73 ReferenceFilterBuilder::setDocumentResourceReference(referenceFilter
, adoptPtr(new DocumentResourceReference(resource))); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 elementStyleResources.clearPendingSVGDocuments(); | 77 elementStyleResources.clearPendingSVGDocuments(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 static PassRefPtrWillBeRawPtr<StyleImage> doLoadPendingImage(Document* document,
StylePendingImage* pendingImage, float deviceScaleFactor, const ResourceLoaderO
ptions& options) | 80 static PassRefPtrWillBeRawPtr<StyleImage> doLoadPendingImage(Document* document,
CSSStyleImageMap& imageMap, StylePendingImage* pendingImage, float deviceScaleF
actor, const ResourceLoaderOptions& options) |
| 81 { | 81 { |
| 82 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) | 82 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) |
| 83 return imageValue->cachedImage(document, options); | 83 return imageValue->cachedImage(document, options, imageMap); |
| 84 | 84 |
| 85 if (CSSImageGeneratorValue* imageGeneratorValue | 85 if (CSSImageGeneratorValue* imageGeneratorValue |
| 86 = pendingImage->cssImageGeneratorValue()) { | 86 = pendingImage->cssImageGeneratorValue()) { |
| 87 imageGeneratorValue->loadSubimages(document); | 87 imageGeneratorValue->loadSubimages(document, imageMap); |
| 88 return StyleGeneratedImage::create(imageGeneratorValue); | 88 return StyleGeneratedImage::create(imageGeneratorValue); |
| 89 } | 89 } |
| 90 | 90 |
| 91 if (CSSCursorImageValue* cursorImageValue | 91 if (CSSCursorImageValue* cursorImageValue |
| 92 = pendingImage->cssCursorImageValue()) | 92 = pendingImage->cssCursorImageValue()) |
| 93 return cursorImageValue->cachedImage(document, deviceScaleFactor); | 93 return cursorImageValue->cachedImage(document, imageMap, deviceScaleFact
or); |
| 94 | 94 |
| 95 if (CSSImageSetValue* imageSetValue = pendingImage->cssImageSetValue()) | 95 if (CSSImageSetValue* imageSetValue = pendingImage->cssImageSetValue()) |
| 96 return imageSetValue->cachedImageSet(document, deviceScaleFactor, option
s); | 96 return imageSetValue->cachedImageSet(document, deviceScaleFactor, option
s); |
| 97 | 97 |
| 98 return nullptr; | 98 return nullptr; |
| 99 } | 99 } |
| 100 | 100 |
| 101 PassRefPtrWillBeRawPtr<StyleImage> StyleResourceLoader::loadPendingImage(StylePe
ndingImage* pendingImage, float deviceScaleFactor) | 101 PassRefPtrWillBeRawPtr<StyleImage> StyleResourceLoader::loadPendingImage(CSSStyl
eImageMap& imageMap, StylePendingImage* pendingImage, float deviceScaleFactor) |
| 102 { | 102 { |
| 103 return doLoadPendingImage(m_document, pendingImage, deviceScaleFactor, Resou
rceFetcher::defaultResourceOptions()); | 103 return doLoadPendingImage(m_document, imageMap, pendingImage, deviceScaleFac
tor, ResourceFetcher::defaultResourceOptions()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void StyleResourceLoader::loadPendingShapeImage(ComputedStyle* computedStyle, Sh
apeValue* shapeValue, float deviceScaleFactor) | 106 void StyleResourceLoader::loadPendingShapeImage(ComputedStyle* computedStyle, CS
SStyleImageMap& imageMap, ShapeValue* shapeValue, float deviceScaleFactor) |
| 107 { | 107 { |
| 108 if (!shapeValue) | 108 if (!shapeValue) |
| 109 return; | 109 return; |
| 110 | 110 |
| 111 StyleImage* image = shapeValue->image(); | 111 StyleImage* image = shapeValue->image(); |
| 112 if (!image || !image->isPendingImage()) | 112 if (!image || !image->isPendingImage()) |
| 113 return; | 113 return; |
| 114 | 114 |
| 115 ResourceLoaderOptions options = ResourceFetcher::defaultResourceOptions(); | 115 ResourceLoaderOptions options = ResourceFetcher::defaultResourceOptions(); |
| 116 options.allowCredentials = DoNotAllowStoredCredentials; | 116 options.allowCredentials = DoNotAllowStoredCredentials; |
| 117 options.credentialsRequested = ClientDidNotRequestCredentials; | 117 options.credentialsRequested = ClientDidNotRequestCredentials; |
| 118 options.corsEnabled = IsCORSEnabled; | 118 options.corsEnabled = IsCORSEnabled; |
| 119 | 119 |
| 120 shapeValue->setImage(doLoadPendingImage(m_document, toStylePendingImage(imag
e), deviceScaleFactor, options)); | 120 shapeValue->setImage(doLoadPendingImage(m_document, imageMap, toStylePending
Image(image), deviceScaleFactor, options)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void StyleResourceLoader::loadPendingImages(ComputedStyle* style, ElementStyleRe
sources& elementStyleResources) | 123 void StyleResourceLoader::loadPendingImages(ComputedStyle* style, ElementStyleRe
sources& elementStyleResources) |
| 124 { | 124 { |
| 125 if (elementStyleResources.pendingImageProperties().isEmpty()) | 125 if (elementStyleResources.pendingImageProperties().isEmpty()) |
| 126 return; | 126 return; |
| 127 | 127 |
| 128 PendingImagePropertyMap::const_iterator::Keys end = elementStyleResources.pe
ndingImageProperties().end().keys(); | 128 PendingImagePropertyMap::const_iterator::Keys end = elementStyleResources.pe
ndingImageProperties().end().keys(); |
| 129 for (PendingImagePropertyMap::const_iterator::Keys it = elementStyleResource
s.pendingImageProperties().begin().keys(); it != end; ++it) { | 129 for (PendingImagePropertyMap::const_iterator::Keys it = elementStyleResource
s.pendingImageProperties().begin().keys(); it != end; ++it) { |
| 130 CSSPropertyID currentProperty = *it; | 130 CSSPropertyID currentProperty = *it; |
| 131 CSSStyleImageMap& imageMap = elementStyleResources.mutableCssImages(); |
| 131 | 132 |
| 132 switch (currentProperty) { | 133 switch (currentProperty) { |
| 133 case CSSPropertyBackgroundImage: { | 134 case CSSPropertyBackgroundImage: { |
| 134 for (FillLayer* backgroundLayer = &style->accessBackgroundLayers();
backgroundLayer; backgroundLayer = backgroundLayer->next()) { | 135 for (FillLayer* backgroundLayer = &style->accessBackgroundLayers();
backgroundLayer; backgroundLayer = backgroundLayer->next()) { |
| 135 if (backgroundLayer->image() && backgroundLayer->image()->isPend
ingImage()) | 136 if (backgroundLayer->image() && backgroundLayer->image()->isPend
ingImage()) |
| 136 backgroundLayer->setImage(loadPendingImage(toStylePendingIma
ge(backgroundLayer->image()), elementStyleResources.deviceScaleFactor())); | 137 backgroundLayer->setImage(loadPendingImage(imageMap, toStyle
PendingImage(backgroundLayer->image()), elementStyleResources.deviceScaleFactor(
))); |
| 137 } | 138 } |
| 138 break; | 139 break; |
| 139 } | 140 } |
| 140 case CSSPropertyContent: { | 141 case CSSPropertyContent: { |
| 141 for (ContentData* contentData = const_cast<ContentData*>(style->cont
entData()); contentData; contentData = contentData->next()) { | 142 for (ContentData* contentData = const_cast<ContentData*>(style->cont
entData()); contentData; contentData = contentData->next()) { |
| 142 if (contentData->isImage()) { | 143 if (contentData->isImage()) { |
| 143 StyleImage* image = toImageContentData(contentData)->image()
; | 144 StyleImage* image = toImageContentData(contentData)->image()
; |
| 144 if (image->isPendingImage()) { | 145 if (image->isPendingImage()) { |
| 145 RefPtrWillBeRawPtr<StyleImage> loadedImage = loadPending
Image(toStylePendingImage(image), elementStyleResources.deviceScaleFactor()); | 146 RefPtrWillBeRawPtr<StyleImage> loadedImage = loadPending
Image(imageMap, toStylePendingImage(image), elementStyleResources.deviceScaleFac
tor()); |
| 146 if (loadedImage) | 147 if (loadedImage) |
| 147 toImageContentData(contentData)->setImage(loadedImag
e.release()); | 148 toImageContentData(contentData)->setImage(loadedImag
e.release()); |
| 148 } | 149 } |
| 149 } | 150 } |
| 150 } | 151 } |
| 151 break; | 152 break; |
| 152 } | 153 } |
| 153 case CSSPropertyCursor: { | 154 case CSSPropertyCursor: { |
| 154 if (CursorList* cursorList = style->cursors()) { | 155 if (CursorList* cursorList = style->cursors()) { |
| 155 for (size_t i = 0; i < cursorList->size(); ++i) { | 156 for (size_t i = 0; i < cursorList->size(); ++i) { |
| 156 CursorData& currentCursor = cursorList->at(i); | 157 CursorData& currentCursor = cursorList->at(i); |
| 157 if (StyleImage* image = currentCursor.image()) { | 158 if (StyleImage* image = currentCursor.image()) { |
| 158 if (image->isPendingImage()) | 159 if (image->isPendingImage()) |
| 159 currentCursor.setImage(loadPendingImage(toStylePendi
ngImage(image), elementStyleResources.deviceScaleFactor())); | 160 currentCursor.setImage(loadPendingImage(imageMap, to
StylePendingImage(image), elementStyleResources.deviceScaleFactor())); |
| 160 } | 161 } |
| 161 } | 162 } |
| 162 } | 163 } |
| 163 break; | 164 break; |
| 164 } | 165 } |
| 165 case CSSPropertyListStyleImage: { | 166 case CSSPropertyListStyleImage: { |
| 166 if (style->listStyleImage() && style->listStyleImage()->isPendingIma
ge()) | 167 if (style->listStyleImage() && style->listStyleImage()->isPendingIma
ge()) |
| 167 style->setListStyleImage(loadPendingImage(toStylePendingImage(st
yle->listStyleImage()), elementStyleResources.deviceScaleFactor())); | 168 style->setListStyleImage(loadPendingImage(imageMap, toStylePendi
ngImage(style->listStyleImage()), elementStyleResources.deviceScaleFactor())); |
| 168 break; | 169 break; |
| 169 } | 170 } |
| 170 case CSSPropertyBorderImageSource: { | 171 case CSSPropertyBorderImageSource: { |
| 171 if (style->borderImageSource() && style->borderImageSource()->isPend
ingImage()) | 172 if (style->borderImageSource() && style->borderImageSource()->isPend
ingImage()) |
| 172 style->setBorderImageSource(loadPendingImage(toStylePendingImage
(style->borderImageSource()), elementStyleResources.deviceScaleFactor())); | 173 style->setBorderImageSource(loadPendingImage(imageMap, toStylePe
ndingImage(style->borderImageSource()), elementStyleResources.deviceScaleFactor(
))); |
| 173 break; | 174 break; |
| 174 } | 175 } |
| 175 case CSSPropertyWebkitBoxReflect: { | 176 case CSSPropertyWebkitBoxReflect: { |
| 176 if (StyleReflection* reflection = style->boxReflect()) { | 177 if (StyleReflection* reflection = style->boxReflect()) { |
| 177 const NinePieceImage& maskImage = reflection->mask(); | 178 const NinePieceImage& maskImage = reflection->mask(); |
| 178 if (maskImage.image() && maskImage.image()->isPendingImage()) { | 179 if (maskImage.image() && maskImage.image()->isPendingImage()) { |
| 179 RefPtrWillBeRawPtr<StyleImage> loadedImage = loadPendingImag
e(toStylePendingImage(maskImage.image()), elementStyleResources.deviceScaleFacto
r()); | 180 RefPtrWillBeRawPtr<StyleImage> loadedImage = loadPendingImag
e(imageMap, toStylePendingImage(maskImage.image()), elementStyleResources.device
ScaleFactor()); |
| 180 reflection->setMask(NinePieceImage(loadedImage.release(), ma
skImage.imageSlices(), maskImage.fill(), maskImage.borderSlices(), maskImage.out
set(), maskImage.horizontalRule(), maskImage.verticalRule())); | 181 reflection->setMask(NinePieceImage(loadedImage.release(), ma
skImage.imageSlices(), maskImage.fill(), maskImage.borderSlices(), maskImage.out
set(), maskImage.horizontalRule(), maskImage.verticalRule())); |
| 181 } | 182 } |
| 182 } | 183 } |
| 183 break; | 184 break; |
| 184 } | 185 } |
| 185 case CSSPropertyWebkitMaskBoxImageSource: { | 186 case CSSPropertyWebkitMaskBoxImageSource: { |
| 186 if (style->maskBoxImageSource() && style->maskBoxImageSource()->isPe
ndingImage()) | 187 if (style->maskBoxImageSource() && style->maskBoxImageSource()->isPe
ndingImage()) |
| 187 style->setMaskBoxImageSource(loadPendingImage(toStylePendingImag
e(style->maskBoxImageSource()), elementStyleResources.deviceScaleFactor())); | 188 style->setMaskBoxImageSource(loadPendingImage(imageMap, toStyleP
endingImage(style->maskBoxImageSource()), elementStyleResources.deviceScaleFacto
r())); |
| 188 break; | 189 break; |
| 189 } | 190 } |
| 190 case CSSPropertyWebkitMaskImage: { | 191 case CSSPropertyWebkitMaskImage: { |
| 191 for (FillLayer* maskLayer = &style->accessMaskLayers(); maskLayer; m
askLayer = maskLayer->next()) { | 192 for (FillLayer* maskLayer = &style->accessMaskLayers(); maskLayer; m
askLayer = maskLayer->next()) { |
| 192 if (maskLayer->image() && maskLayer->image()->isPendingImage()) | 193 if (maskLayer->image() && maskLayer->image()->isPendingImage()) |
| 193 maskLayer->setImage(loadPendingImage(toStylePendingImage(mas
kLayer->image()), elementStyleResources.deviceScaleFactor())); | 194 maskLayer->setImage(loadPendingImage(imageMap, toStylePendin
gImage(maskLayer->image()), elementStyleResources.deviceScaleFactor())); |
| 194 } | 195 } |
| 195 break; | 196 break; |
| 196 } | 197 } |
| 197 case CSSPropertyShapeOutside: | 198 case CSSPropertyShapeOutside: |
| 198 loadPendingShapeImage(style, style->shapeOutside(), elementStyleReso
urces.deviceScaleFactor()); | 199 loadPendingShapeImage(style, imageMap, style->shapeOutside(), elemen
tStyleResources.deviceScaleFactor()); |
| 199 break; | 200 break; |
| 200 default: | 201 default: |
| 201 ASSERT_NOT_REACHED(); | 202 ASSERT_NOT_REACHED(); |
| 202 } | 203 } |
| 203 } | 204 } |
| 204 | 205 |
| 205 elementStyleResources.clearPendingImageProperties(); | 206 elementStyleResources.clearPendingImageProperties(); |
| 207 elementStyleResources.clearCSSImages(); |
| 206 } | 208 } |
| 207 | 209 |
| 208 void StyleResourceLoader::loadPendingResources(ComputedStyle* computedStyle, Ele
mentStyleResources& elementStyleResources) | 210 void StyleResourceLoader::loadPendingResources(ComputedStyle* computedStyle, Ele
mentStyleResources& elementStyleResources) |
| 209 { | 211 { |
| 210 // Start loading images referenced by this style. | 212 // Start loading images referenced by this style. |
| 211 loadPendingImages(computedStyle, elementStyleResources); | 213 loadPendingImages(computedStyle, elementStyleResources); |
| 212 | 214 |
| 213 // Start loading the SVG Documents referenced by this style. | 215 // Start loading the SVG Documents referenced by this style. |
| 214 loadPendingSVGDocuments(computedStyle, elementStyleResources); | 216 loadPendingSVGDocuments(computedStyle, elementStyleResources); |
| 215 } | 217 } |
| 216 | 218 |
| 217 } | 219 } |
| OLD | NEW |