source: webkit/trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h

Last change on this file was 293637, checked in by Chris Dumez, 3 years ago

Reduce usage of std::unique_ptr<HashSet> / std::unique_ptr<HashMap>
https://bugs.webkit.org/show_bug.cgi?id=239903

Reviewed by Yusuke Suzuki.

Reduce usage of std::unique_ptr<HashSet> / std::unique_ptr<HashMap> as HashSet / HashMap
are already essentially pointers. This avoids some unnecessary dereferencing.

  • Source/JavaScriptCore/heap/Heap.cpp:

(JSC::Heap::addCoreConstraints):

  • Source/JavaScriptCore/heap/Heap.h:
  • Source/JavaScriptCore/heap/HeapInlines.h:
  • Source/WebKit/WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp:

(WebKit::WebPasteboardOverrides::addOverride):
(WebKit::WebPasteboardOverrides::removeOverride):
(WebKit::WebPasteboardOverrides::overriddenTypes):
(WebKit::WebPasteboardOverrides::getDataForOverride const):

  • Source/WebKit/WebProcess/WebCoreSupport/WebPasteboardOverrides.h:
  • Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp:

(WebCore::DatabaseTracker::recordCreatingDatabase):
(WebCore::DatabaseTracker::doneCreatingDatabase):
(WebCore::DatabaseTracker::creatingDatabase):
(WebCore::DatabaseTracker::recordDeletingDatabase):
(WebCore::DatabaseTracker::doneDeletingDatabase):
(WebCore::DatabaseTracker::isDeletingDatabase):
(WebCore::DatabaseTracker::canDeleteOrigin):

  • Source/WebCore/Modules/webdatabase/DatabaseTracker.h:
  • Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp:

(WebCore::PropertySetCSSStyleDeclaration::wrapForDeprecatedCSSOM):
(WebCore::StyleRuleCSSStyleDeclaration::didMutate):
(WebCore::InlineCSSStyleDeclaration::didMutate):

  • Source/WebCore/css/PropertySetCSSStyleDeclaration.h:
  • Source/WebCore/dom/MutationObserver.cpp:

(WebCore::MutationObserver::deliver):

  • Source/WebCore/dom/MutationObserverRegistration.cpp:

(WebCore::MutationObserverRegistration::observedSubtreeNodeWillDetach):
(WebCore::MutationObserverRegistration::takeTransientRegistrations):
(WebCore::MutationObserverRegistration::isReachableFromOpaqueRoots const):

  • Source/WebCore/dom/MutationObserverRegistration.h:

(WebCore::MutationObserverRegistration::hasTransientRegistrations const):

  • Source/WebCore/platform/graphics/GlyphMetricsMap.h:

(WebCore::GlyphMetricsMap<T>::locatePageSlowCase):

  • Source/WebCore/rendering/RenderBlock.cpp:

(WebCore::insertIntoTrackedRendererMaps):
(WebCore::removeFromTrackedRendererMaps):
(WebCore::removeBlockFromPercentageDescendantAndContainerMaps):

  • Source/WebCore/style/StyleScope.cpp:

(WebCore::Style::Scope::updateActiveStyleSheets):
(WebCore::Style::Scope::activeStyleSheetsContains const):

  • Source/WebCore/style/StyleScope.h:

Canonical link: https://commits.webkit.org/250141@main

File size: 5.2 KB
Line 
1/*
2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#pragma once
27
28#include "CSSParserContext.h"
29#include "CSSStyleDeclaration.h"
30#include "DeprecatedCSSOMValue.h"
31#include <memory>
32#include <wtf/HashMap.h>
33#include <wtf/RefPtr.h>
34#include <wtf/WeakPtr.h>
35
36namespace WebCore {
37
38class CSSRule;
39class CSSProperty;
40class CSSValue;
41class MutableStyleProperties;
42class StyleSheetContents;
43class StyledElement;
44
45class PropertySetCSSStyleDeclaration : public CSSStyleDeclaration {
46 WTF_MAKE_ISO_ALLOCATED(PropertySetCSSStyleDeclaration);
47public:
48 explicit PropertySetCSSStyleDeclaration(MutableStyleProperties& propertySet)
49 : m_propertySet(&propertySet)
50 { }
51
52 virtual void clearParentElement() { ASSERT_NOT_REACHED(); }
53
54 StyleSheetContents* contextStyleSheet() const;
55
56protected:
57 enum MutationType { NoChanges, PropertyChanged };
58
59 virtual CSSParserContext cssParserContext() const;
60
61 MutableStyleProperties* m_propertySet;
62 HashMap<CSSValue*, WeakPtr<DeprecatedCSSOMValue>> m_cssomValueWrappers;
63
64private:
65 void ref() override;
66 void deref() override;
67
68 CSSRule* parentRule() const override { return nullptr; }
69 unsigned length() const final;
70 String item(unsigned index) const final;
71 RefPtr<DeprecatedCSSOMValue> getPropertyCSSValue(const String& propertyName) final;
72 String getPropertyValue(const String& propertyName) final;
73 String getPropertyPriority(const String& propertyName) final;
74 String getPropertyShorthand(const String& propertyName) final;
75 bool isPropertyImplicit(const String& propertyName) final;
76 ExceptionOr<void> setProperty(const String& propertyName, const String& value, const String& priority) final;
77 ExceptionOr<String> removeProperty(const String& propertyName) final;
78 String cssText() const final;
79 ExceptionOr<void> setCssText(const String&) final;
80 RefPtr<CSSValue> getPropertyCSSValueInternal(CSSPropertyID) final;
81 String getPropertyValueInternal(CSSPropertyID) final;
82 ExceptionOr<void> setPropertyInternal(CSSPropertyID, const String& value, bool important) final;
83
84 Ref<MutableStyleProperties> copyProperties() const final;
85
86 RefPtr<DeprecatedCSSOMValue> wrapForDeprecatedCSSOM(CSSValue*);
87
88 virtual bool willMutate() WARN_UNUSED_RETURN { return true; }
89 virtual void didMutate(MutationType) { }
90};
91
92class StyleRuleCSSStyleDeclaration final : public PropertySetCSSStyleDeclaration {
93 WTF_MAKE_ISO_ALLOCATED(StyleRuleCSSStyleDeclaration);
94public:
95 static Ref<StyleRuleCSSStyleDeclaration> create(MutableStyleProperties& propertySet, CSSRule& parentRule)
96 {
97 return adoptRef(*new StyleRuleCSSStyleDeclaration(propertySet, parentRule));
98 }
99 virtual ~StyleRuleCSSStyleDeclaration();
100
101 void clearParentRule() { m_parentRule = nullptr; }
102
103 void ref() final;
104 void deref() final;
105
106 void reattach(MutableStyleProperties&);
107
108private:
109 StyleRuleCSSStyleDeclaration(MutableStyleProperties&, CSSRule&);
110
111 CSSStyleSheet* parentStyleSheet() const final;
112
113 CSSRule* parentRule() const final { return m_parentRule; }
114
115 bool willMutate() final WARN_UNUSED_RETURN;
116 void didMutate(MutationType) final;
117 CSSParserContext cssParserContext() const final;
118
119 unsigned m_refCount;
120 StyleRuleType m_parentRuleType;
121 CSSRule* m_parentRule;
122};
123
124class InlineCSSStyleDeclaration final : public PropertySetCSSStyleDeclaration {
125 WTF_MAKE_ISO_ALLOCATED(InlineCSSStyleDeclaration);
126public:
127 InlineCSSStyleDeclaration(MutableStyleProperties& propertySet, StyledElement& parentElement)
128 : PropertySetCSSStyleDeclaration(propertySet)
129 , m_parentElement(&parentElement)
130 {
131 }
132
133private:
134 CSSStyleSheet* parentStyleSheet() const final;
135 StyledElement* parentElement() const final { return m_parentElement; }
136 void clearParentElement() final { m_parentElement = nullptr; }
137
138 bool willMutate() final WARN_UNUSED_RETURN;
139 void didMutate(MutationType) final;
140 CSSParserContext cssParserContext() const final;
141
142 StyledElement* m_parentElement;
143};
144
145} // namespace WebCore
Note: See TracBrowser for help on using the repository browser.