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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/SVGResources.cpp

Issue 2065593002: Unprefix the CSS 'filter' property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust test Created 4 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) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #include "core/layout/svg/SVGResources.h" 20 #include "core/layout/svg/SVGResources.h"
21 21
22 #include "core/SVGNames.h" 22 #include "core/SVGNames.h"
23 #include "core/layout/svg/LayoutSVGResourceClipper.h" 23 #include "core/layout/svg/LayoutSVGResourceClipper.h"
24 #include "core/layout/svg/LayoutSVGResourceFilter.h" 24 #include "core/layout/svg/LayoutSVGResourceFilter.h"
25 #include "core/layout/svg/LayoutSVGResourceMarker.h" 25 #include "core/layout/svg/LayoutSVGResourceMarker.h"
26 #include "core/layout/svg/LayoutSVGResourceMasker.h" 26 #include "core/layout/svg/LayoutSVGResourceMasker.h"
27 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" 27 #include "core/layout/svg/LayoutSVGResourcePaintServer.h"
28 #include "core/style/SVGComputedStyle.h" 28 #include "core/style/ComputedStyle.h"
29 #include "core/svg/SVGFilterElement.h" 29 #include "core/svg/SVGFilterElement.h"
30 #include "core/svg/SVGGradientElement.h" 30 #include "core/svg/SVGGradientElement.h"
31 #include "core/svg/SVGPatternElement.h" 31 #include "core/svg/SVGPatternElement.h"
32 #include "core/svg/SVGURIReference.h" 32 #include "core/svg/SVGURIReference.h"
33 33
34 #ifndef NDEBUG 34 #ifndef NDEBUG
35 #include <stdio.h> 35 #include <stdio.h>
36 #endif 36 #endif
37 37
38 namespace blink { 38 namespace blink {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 196 }
197 197
198 static inline SVGResources& ensureResources(OwnPtr<SVGResources>& resources) 198 static inline SVGResources& ensureResources(OwnPtr<SVGResources>& resources)
199 { 199 {
200 if (!resources) 200 if (!resources)
201 resources = adoptPtr(new SVGResources); 201 resources = adoptPtr(new SVGResources);
202 202
203 return *resources.get(); 203 return *resources.get();
204 } 204 }
205 205
206 PassOwnPtr<SVGResources> SVGResources::buildResources(const LayoutObject* object , const SVGComputedStyle& style) 206 PassOwnPtr<SVGResources> SVGResources::buildResources(const LayoutObject* object , const ComputedStyle& computedStyle)
207 { 207 {
208 ASSERT(object); 208 ASSERT(object);
209 209
210 Node* node = object->node(); 210 Node* node = object->node();
211 ASSERT(node); 211 ASSERT(node);
212 ASSERT_WITH_SECURITY_IMPLICATION(node->isSVGElement()); 212 ASSERT_WITH_SECURITY_IMPLICATION(node->isSVGElement());
213 213
214 SVGElement* element = toSVGElement(node); 214 SVGElement* element = toSVGElement(node);
215 ASSERT(element); 215 ASSERT(element);
216 216
217 const AtomicString& tagName = element->localName(); 217 const AtomicString& tagName = element->localName();
218 ASSERT(!tagName.isNull()); 218 ASSERT(!tagName.isNull());
219 219
220 TreeScope& treeScope = element->treeScope(); 220 TreeScope& treeScope = element->treeScope();
221 SVGDocumentExtensions& extensions = element->document().accessSVGExtensions( ); 221 SVGDocumentExtensions& extensions = element->document().accessSVGExtensions( );
222 222
223 const SVGComputedStyle& style = computedStyle.svgStyle();
224
223 OwnPtr<SVGResources> resources; 225 OwnPtr<SVGResources> resources;
224 if (clipperFilterMaskerTags().contains(tagName)) { 226 if (clipperFilterMaskerTags().contains(tagName)) {
225 if (style.hasClipper()) { 227 if (style.hasClipper()) {
226 AtomicString id = style.clipperResource(); 228 AtomicString id = style.clipperResource();
227 if (!ensureResources(resources).setClipper(getLayoutSVGResourceById< LayoutSVGResourceClipper>(treeScope, id))) 229 if (!ensureResources(resources).setClipper(getLayoutSVGResourceById< LayoutSVGResourceClipper>(treeScope, id)))
228 registerPendingResource(extensions, id, element); 230 registerPendingResource(extensions, id, element);
229 } 231 }
230 232
231 if (style.hasFilter()) { 233 if (computedStyle.hasFilter() && !object->isSVGRoot()) {
232 AtomicString id = style.filterResource(); 234 const FilterOperations& filterOperations = computedStyle.filter();
233 if (!ensureResources(resources).setFilter(getLayoutSVGResourceById<L ayoutSVGResourceFilter>(treeScope, id))) 235 if (filterOperations.size() == 1) {
pdr. 2016/06/15 09:50:32 Why do we only use the first filter op instead of
fs 2016/06/15 11:02:43 Because we only want to support the same "subset"
234 registerPendingResource(extensions, id, element); 236 const FilterOperation& filterOperation = *filterOperations.at(0) ;
237 if (filterOperation.type() == FilterOperation::REFERENCE) {
238 const auto& referenceFilterOperation = toReferenceFilterOper ation(filterOperation);
239 AtomicString id = SVGURIReference::fragmentIdentifierFromIRI String(referenceFilterOperation.url(), treeScope);
240 if (!ensureResources(resources).setFilter(getLayoutSVGResour ceById<LayoutSVGResourceFilter>(treeScope, id)))
241 registerPendingResource(extensions, id, element);
242 }
243 }
235 } 244 }
236 245
237 if (style.hasMasker()) { 246 if (style.hasMasker()) {
238 AtomicString id = style.maskerResource(); 247 AtomicString id = style.maskerResource();
239 if (!ensureResources(resources).setMasker(getLayoutSVGResourceById<L ayoutSVGResourceMasker>(treeScope, id))) 248 if (!ensureResources(resources).setMasker(getLayoutSVGResourceById<L ayoutSVGResourceMasker>(treeScope, id)))
240 registerPendingResource(extensions, id, element); 249 registerPendingResource(extensions, id, element);
241 } 250 }
242 } 251 }
243 252
244 if (style.hasMarkers() && supportsMarkers(*element)) { 253 if (style.hasMarkers() && supportsMarkers(*element)) {
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 if (LayoutSVGResourcePaintServer* stroke = m_fillStrokeData->stroke) 673 if (LayoutSVGResourcePaintServer* stroke = m_fillStrokeData->stroke)
665 fprintf(stderr, " |-> Stroke : %p (node=%p)\n", stroke, stroke-> element()); 674 fprintf(stderr, " |-> Stroke : %p (node=%p)\n", stroke, stroke-> element());
666 } 675 }
667 676
668 if (m_linkedResource) 677 if (m_linkedResource)
669 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, m_ linkedResource->element()); 678 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, m_ linkedResource->element());
670 } 679 }
671 #endif 680 #endif
672 681
673 } // namespace blink 682 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698