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

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

Issue 2824823003: DOM-based SVG resource tracking (Closed)
Patch Set: Update baselines Created 3 years, 7 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) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann
3 * <zimmermann@kde.org> 3 * <zimmermann@kde.org>
4 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> 4 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org>
5 * Copyright (C) 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2008 Apple Inc. All rights reserved.
6 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 6 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
7 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "core/frame/csp/ContentSecurityPolicy.h" 43 #include "core/frame/csp/ContentSecurityPolicy.h"
44 #include "core/html/HTMLElement.h" 44 #include "core/html/HTMLElement.h"
45 #include "core/inspector/ConsoleMessage.h" 45 #include "core/inspector/ConsoleMessage.h"
46 #include "core/layout/LayoutObject.h" 46 #include "core/layout/LayoutObject.h"
47 #include "core/layout/svg/LayoutSVGResourceContainer.h" 47 #include "core/layout/svg/LayoutSVGResourceContainer.h"
48 #include "core/svg/SVGDocumentExtensions.h" 48 #include "core/svg/SVGDocumentExtensions.h"
49 #include "core/svg/SVGElementRareData.h" 49 #include "core/svg/SVGElementRareData.h"
50 #include "core/svg/SVGGraphicsElement.h" 50 #include "core/svg/SVGGraphicsElement.h"
51 #include "core/svg/SVGSVGElement.h" 51 #include "core/svg/SVGSVGElement.h"
52 #include "core/svg/SVGTitleElement.h" 52 #include "core/svg/SVGTitleElement.h"
53 #include "core/svg/SVGTreeScopeResources.h"
54 #include "core/svg/SVGUseElement.h" 53 #include "core/svg/SVGUseElement.h"
55 #include "core/svg/properties/SVGProperty.h" 54 #include "core/svg/properties/SVGProperty.h"
56 #include "platform/wtf/AutoReset.h" 55 #include "platform/wtf/AutoReset.h"
57 #include "platform/wtf/Threading.h" 56 #include "platform/wtf/Threading.h"
58 57
59 namespace blink { 58 namespace blink {
60 59
61 using namespace HTMLNames; 60 using namespace HTMLNames;
62 using namespace SVGNames; 61 using namespace SVGNames;
63 62
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 void SVGElement::WillRecalcStyle(StyleRecalcChange change) { 102 void SVGElement::WillRecalcStyle(StyleRecalcChange change) {
104 if (!HasSVGRareData()) 103 if (!HasSVGRareData())
105 return; 104 return;
106 // If the style changes because of a regular property change (not induced by 105 // If the style changes because of a regular property change (not induced by
107 // SMIL animations themselves) reset the "computed style without SMIL style 106 // SMIL animations themselves) reset the "computed style without SMIL style
108 // properties", so the base value change gets reflected. 107 // properties", so the base value change gets reflected.
109 if (change > kNoChange || NeedsStyleRecalc()) 108 if (change > kNoChange || NeedsStyleRecalc())
110 SvgRareData()->SetNeedsOverrideComputedStyleUpdate(); 109 SvgRareData()->SetNeedsOverrideComputedStyleUpdate();
111 } 110 }
112 111
113 void SVGElement::BuildPendingResourcesIfNeeded() {
114 if (!NeedsPendingResourceHandling() || !isConnected() || InUseShadowTree())
115 return;
116 GetTreeScope().EnsureSVGTreeScopedResources().NotifyResourceAvailable(
117 GetIdAttribute());
118 }
119
120 SVGElementRareData* SVGElement::EnsureSVGRareData() { 112 SVGElementRareData* SVGElement::EnsureSVGRareData() {
121 if (HasSVGRareData()) 113 if (HasSVGRareData())
122 return SvgRareData(); 114 return SvgRareData();
123 115
124 svg_rare_data_ = new SVGElementRareData(this); 116 svg_rare_data_ = new SVGElementRareData(this);
125 return svg_rare_data_.Get(); 117 return svg_rare_data_.Get();
126 } 118 }
127 119
128 bool SVGElement::IsOutermostSVGSVGElement() const { 120 bool SVGElement::IsOutermostSVGSVGElement() const {
129 if (!isSVGSVGElement(*this)) 121 if (!isSVGSVGElement(*this))
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 if (apply_motion_transform == kIncludeMotionTransform && HasSVGRareData()) 392 if (apply_motion_transform == kIncludeMotionTransform && HasSVGRareData())
401 matrix.PreMultiply(*SvgRareData()->AnimateMotionTransform()); 393 matrix.PreMultiply(*SvgRareData()->AnimateMotionTransform());
402 394
403 return matrix; 395 return matrix;
404 } 396 }
405 397
406 Node::InsertionNotificationRequest SVGElement::InsertedInto( 398 Node::InsertionNotificationRequest SVGElement::InsertedInto(
407 ContainerNode* root_parent) { 399 ContainerNode* root_parent) {
408 Element::InsertedInto(root_parent); 400 Element::InsertedInto(root_parent);
409 UpdateRelativeLengthsInformation(); 401 UpdateRelativeLengthsInformation();
410 BuildPendingResourcesIfNeeded();
411 402
412 if (hasAttribute(nonceAttr) && getAttribute(nonceAttr) != g_empty_atom) { 403 if (hasAttribute(nonceAttr) && getAttribute(nonceAttr) != g_empty_atom) {
413 setNonce(getAttribute(nonceAttr)); 404 setNonce(getAttribute(nonceAttr));
414 if (RuntimeEnabledFeatures::hideNonceContentAttributeEnabled() && 405 if (RuntimeEnabledFeatures::hideNonceContentAttributeEnabled() &&
415 InActiveDocument() && 406 InActiveDocument() &&
416 GetDocument().GetContentSecurityPolicy()->HasHeaderDeliveredPolicy()) { 407 GetDocument().GetContentSecurityPolicy()->HasHeaderDeliveredPolicy()) {
417 setAttribute(nonceAttr, g_empty_atom); 408 setAttribute(nonceAttr, g_empty_atom);
418 } 409 }
419 } 410 }
420
421 return kInsertionDone; 411 return kInsertionDone;
422 } 412 }
423 413
424 void SVGElement::RemovedFrom(ContainerNode* root_parent) { 414 void SVGElement::RemovedFrom(ContainerNode* root_parent) {
425 bool was_in_document = root_parent->isConnected(); 415 bool was_in_document = root_parent->isConnected();
426 416
427 if (was_in_document && HasRelativeLengths()) { 417 if (was_in_document && HasRelativeLengths()) {
428 // The root of the subtree being removed should take itself out from its 418 // The root of the subtree being removed should take itself out from its
429 // parent's relative length set. For the other nodes in the subtree we don't 419 // parent's relative length set. For the other nodes in the subtree we don't
430 // need to do anything: they will get their own removedFrom() notification 420 // need to do anything: they will get their own removedFrom() notification
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 return; 954 return;
965 955
966 ToSVGElement(parent)->SendSVGLoadEventToSelfAndAncestorChainIfPossible(); 956 ToSVGElement(parent)->SendSVGLoadEventToSelfAndAncestorChainIfPossible();
967 } 957 }
968 958
969 void SVGElement::AttributeChanged(const AttributeModificationParams& params) { 959 void SVGElement::AttributeChanged(const AttributeModificationParams& params) {
970 Element::AttributeChanged(params); 960 Element::AttributeChanged(params);
971 961
972 if (params.name == HTMLNames::idAttr) { 962 if (params.name == HTMLNames::idAttr) {
973 RebuildAllIncomingReferences(); 963 RebuildAllIncomingReferences();
974
975 LayoutObject* object = GetLayoutObject();
976 // Notify resources about id changes, this is important as we cache
977 // resources by id in SVGDocumentExtensions
978 if (object && object->IsSVGResourceContainer()) {
979 ToLayoutSVGResourceContainer(object)->IdChanged(params.old_value,
980 params.new_value);
981 }
982 if (isConnected())
983 BuildPendingResourcesIfNeeded();
984 InvalidateInstances(); 964 InvalidateInstances();
985 return; 965 return;
986 } 966 }
987 967
988 // Changes to the style attribute are processed lazily (see 968 // Changes to the style attribute are processed lazily (see
989 // Element::getAttribute() and related methods), so we don't want changes to 969 // Element::getAttribute() and related methods), so we don't want changes to
990 // the style attribute to result in extra work here. 970 // the style attribute to result in extra work here.
991 if (params.name == HTMLNames::styleAttr) 971 if (params.name == HTMLNames::styleAttr)
992 return; 972 return;
993 973
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 visitor->Trace(class_name_); 1330 visitor->Trace(class_name_);
1351 Element::Trace(visitor); 1331 Element::Trace(visitor);
1352 } 1332 }
1353 1333
1354 const AtomicString& SVGElement::EventParameterName() { 1334 const AtomicString& SVGElement::EventParameterName() {
1355 DEFINE_STATIC_LOCAL(const AtomicString, evt_string, ("evt")); 1335 DEFINE_STATIC_LOCAL(const AtomicString, evt_string, ("evt"));
1356 return evt_string; 1336 return evt_string;
1357 } 1337 }
1358 1338
1359 } // namespace blink 1339 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGElement.h ('k') | third_party/WebKit/Source/core/svg/SVGFilterElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698