| 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. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
| 4 * All rights reserved. | 4 * All rights reserved. |
| 5 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 #include "core/css/resolver/ElementStyleResources.h" | 24 #include "core/css/resolver/ElementStyleResources.h" |
| 25 | 25 |
| 26 #include "core/CSSPropertyNames.h" | 26 #include "core/CSSPropertyNames.h" |
| 27 #include "core/css/CSSCursorImageValue.h" | 27 #include "core/css/CSSCursorImageValue.h" |
| 28 #include "core/css/CSSGradientValue.h" | 28 #include "core/css/CSSGradientValue.h" |
| 29 #include "core/css/CSSImageValue.h" | 29 #include "core/css/CSSImageValue.h" |
| 30 #include "core/css/CSSURIValue.h" | 30 #include "core/css/CSSURIValue.h" |
| 31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
| 32 #include "core/fetch/ResourceFetcher.h" | 32 #include "core/fetch/ResourceFetcher.h" |
| 33 #include "core/layout/svg/ReferenceFilterBuilder.h" |
| 33 #include "core/style/ComputedStyle.h" | 34 #include "core/style/ComputedStyle.h" |
| 34 #include "core/style/ContentData.h" | 35 #include "core/style/ContentData.h" |
| 35 #include "core/style/CursorData.h" | 36 #include "core/style/CursorData.h" |
| 36 #include "core/style/FillLayer.h" | 37 #include "core/style/FillLayer.h" |
| 37 #include "core/style/FilterOperation.h" | 38 #include "core/style/FilterOperation.h" |
| 38 #include "core/style/StyleFetchedImage.h" | 39 #include "core/style/StyleFetchedImage.h" |
| 39 #include "core/style/StyleFetchedImageSet.h" | 40 #include "core/style/StyleFetchedImageSet.h" |
| 40 #include "core/style/StyleGeneratedImage.h" | 41 #include "core/style/StyleGeneratedImage.h" |
| 41 #include "core/style/StyleImage.h" | 42 #include "core/style/StyleImage.h" |
| 42 #include "core/style/StyleInvalidImage.h" | 43 #include "core/style/StyleInvalidImage.h" |
| 43 #include "core/style/StylePendingImage.h" | 44 #include "core/style/StylePendingImage.h" |
| 44 #include "core/svg/SVGElementProxy.h" | |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 ElementStyleResources::ElementStyleResources(Document& document, | 48 ElementStyleResources::ElementStyleResources(Document& document, |
| 49 float deviceScaleFactor) | 49 float deviceScaleFactor) |
| 50 : m_document(&document), m_deviceScaleFactor(deviceScaleFactor) {} | 50 : m_document(&document), m_deviceScaleFactor(deviceScaleFactor) {} |
| 51 | 51 |
| 52 StyleImage* ElementStyleResources::styleImage(CSSPropertyID property, | 52 StyleImage* ElementStyleResources::styleImage(CSSPropertyID property, |
| 53 const CSSValue& value) { | 53 const CSSValue& value) { |
| 54 if (value.isImageValue()) | 54 if (value.isImageValue()) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 StyleImage* ElementStyleResources::cursorOrPendingFromValue( | 101 StyleImage* ElementStyleResources::cursorOrPendingFromValue( |
| 102 CSSPropertyID property, | 102 CSSPropertyID property, |
| 103 const CSSCursorImageValue& value) { | 103 const CSSCursorImageValue& value) { |
| 104 if (value.isCachePending(m_deviceScaleFactor)) { | 104 if (value.isCachePending(m_deviceScaleFactor)) { |
| 105 m_pendingImageProperties.add(property); | 105 m_pendingImageProperties.add(property); |
| 106 return StylePendingImage::create(value); | 106 return StylePendingImage::create(value); |
| 107 } | 107 } |
| 108 return value.cachedImage(m_deviceScaleFactor); | 108 return value.cachedImage(m_deviceScaleFactor); |
| 109 } | 109 } |
| 110 | 110 |
| 111 SVGElementProxy& ElementStyleResources::cachedOrPendingFromValue( | 111 void ElementStyleResources::addPendingSVGDocument( |
| 112 const CSSURIValue& value) { | 112 FilterOperation* filterOperation, |
| 113 return value.ensureElementProxy(*m_document); | 113 const CSSURIValue* cssUriValue) { |
| 114 m_pendingSVGDocuments.set(filterOperation, cssUriValue); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void ElementStyleResources::loadPendingSVGDocuments( | 117 void ElementStyleResources::loadPendingSVGDocuments( |
| 117 ComputedStyle* computedStyle) { | 118 ComputedStyle* computedStyle) { |
| 118 if (!computedStyle->hasFilter()) | 119 if (!computedStyle->hasFilter() || m_pendingSVGDocuments.isEmpty()) |
| 119 return; | 120 return; |
| 121 |
| 120 FilterOperations::FilterOperationVector& filterOperations = | 122 FilterOperations::FilterOperationVector& filterOperations = |
| 121 computedStyle->mutableFilter().operations(); | 123 computedStyle->mutableFilter().operations(); |
| 122 for (auto& filterOperation : filterOperations) { | 124 for (unsigned i = 0; i < filterOperations.size(); ++i) { |
| 123 if (filterOperation->type() != FilterOperation::REFERENCE) | 125 FilterOperation* filterOperation = filterOperations.at(i); |
| 124 continue; | 126 if (filterOperation->type() == FilterOperation::REFERENCE) { |
| 125 ReferenceFilterOperation& referenceOperation = | 127 ReferenceFilterOperation* referenceFilter = |
| 126 toReferenceFilterOperation(*filterOperation); | 128 toReferenceFilterOperation(filterOperation); |
| 127 referenceOperation.elementProxy().resolve(*m_document); | 129 |
| 130 const CSSURIValue* value = m_pendingSVGDocuments.get(referenceFilter); |
| 131 if (!value) |
| 132 continue; |
| 133 DocumentResource* resource = value->load(*m_document); |
| 134 if (!resource) |
| 135 continue; |
| 136 |
| 137 // Stash the DocumentResource on the reference filter. |
| 138 ReferenceFilterBuilder::setDocumentResourceReference( |
| 139 referenceFilter, new DocumentResourceReference(resource)); |
| 140 } |
| 128 } | 141 } |
| 129 } | 142 } |
| 130 | 143 |
| 131 StyleImage* ElementStyleResources::loadPendingImage( | 144 StyleImage* ElementStyleResources::loadPendingImage( |
| 132 ComputedStyle* style, | 145 ComputedStyle* style, |
| 133 StylePendingImage* pendingImage, | 146 StylePendingImage* pendingImage, |
| 134 CrossOriginAttributeValue crossOrigin) { | 147 CrossOriginAttributeValue crossOrigin) { |
| 135 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) | 148 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) |
| 136 return imageValue->cacheImage(*m_document, crossOrigin); | 149 return imageValue->cacheImage(*m_document, crossOrigin); |
| 137 | 150 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 } | 286 } |
| 274 } | 287 } |
| 275 } | 288 } |
| 276 | 289 |
| 277 void ElementStyleResources::loadPendingResources(ComputedStyle* computedStyle) { | 290 void ElementStyleResources::loadPendingResources(ComputedStyle* computedStyle) { |
| 278 loadPendingImages(computedStyle); | 291 loadPendingImages(computedStyle); |
| 279 loadPendingSVGDocuments(computedStyle); | 292 loadPendingSVGDocuments(computedStyle); |
| 280 } | 293 } |
| 281 | 294 |
| 282 } // namespace blink | 295 } // namespace blink |
| OLD | NEW |