summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/svg/svg_element_rare_data.cc
blob: 6f51b6517233c76e5a45bf412c16414dc4b3b669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/core/svg/svg_element_rare_data.h"

#include "third_party/blink/renderer/core/css/resolver/style_resolver.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/layout/svg/svg_resources.h"

namespace blink {

MutableCSSPropertyValueSet*
SVGElementRareData::EnsureAnimatedSMILStyleProperties() {
  if (!animated_smil_style_properties_) {
    animated_smil_style_properties_ =
        MutableCSSPropertyValueSet::Create(kSVGAttributeMode);
  }
  return animated_smil_style_properties_.Get();
}

ComputedStyle* SVGElementRareData::OverrideComputedStyle(
    Element* element,
    const ComputedStyle* parent_style) {
  DCHECK(element);
  if (!use_override_computed_style_)
    return nullptr;
  if (!override_computed_style_ || needs_override_computed_style_update_) {
    // The style computed here contains no CSS Animations/Transitions or SMIL
    // induced rules - this is needed to compute the "base value" for the SMIL
    // animation sandwhich model.
    override_computed_style_ =
        element->GetDocument().EnsureStyleResolver().StyleForElement(
            element, parent_style, parent_style, kMatchAllRulesExcludingSMIL);
    needs_override_computed_style_update_ = false;
  }
  DCHECK(override_computed_style_);
  return override_computed_style_.get();
}

void SVGElementRareData::ClearOverriddenComputedStyle() {
  override_computed_style_ = nullptr;
}

SVGResourceClient& SVGElementRareData::EnsureSVGResourceClient(
    SVGElement* element) {
  if (!resource_client_)
    resource_client_ = MakeGarbageCollected<SVGElementResourceClient>(element);
  return *resource_client_;
}

void SVGElementRareData::Trace(blink::Visitor* visitor) {
  visitor->Trace(outgoing_references_);
  visitor->Trace(incoming_references_);
  visitor->Trace(animated_smil_style_properties_);
  visitor->Trace(element_instances_);
  visitor->Trace(corresponding_element_);
  visitor->Trace(resource_client_);
}

AffineTransform* SVGElementRareData::AnimateMotionTransform() {
  return &animate_motion_transform_;
}

}  // namespace blink