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

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

Move global AtomStrings to a common header to promote reuse
https://bugs.webkit.org/show_bug.cgi?id=239585

Reviewed by Geoff Garen and Darin Adler.

Source/WebCore:

  • Headers.cmake:
  • Modules/async-clipboard/Clipboard.cpp:

(WebCore::Clipboard::getType):

  • Modules/mediastream/MediaStreamTrack.cpp:

(WebCore::MediaStreamTrack::contentHint const):
(WebCore::MediaStreamTrack::setContentHint):

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • animation/AnimationEffect.cpp:

(WebCore::AnimationEffect::getTiming const):
(WebCore::AnimationEffect::updateTiming):

  • animation/EffectTiming.h:
  • contentextensions/ContentExtensionParser.cpp:

(WebCore::ContentExtensions::isValidCSSSelector):

  • css/CSSStyleSheet.h:
  • css/FontFace.cpp:

(WebCore::FontFace::display const):

  • css/MediaFeatureNames.cpp:

(WebCore::MediaFeatureNames::init):

  • dom/DataTransfer.cpp:

(WebCore::normalizeType):
(WebCore::DataTransfer::setDataFromItemList):
(WebCore::DataTransfer::createForInputEvent):
(WebCore::DataTransfer::dropEffect const):

  • dom/Document.cpp:

(WebCore::Document::designMode const):

  • dom/InlineStyleSheetOwner.cpp:

(WebCore::isValidCSSContentType):

  • dom/ProcessingInstruction.cpp:

(WebCore::ProcessingInstruction::checkStyleSheet):

  • dom/mac/ImageControlsMac.cpp:
  • editing/FontShadow.cpp:

(WebCore::serializationForCSS):

  • editing/ReplaceSelectionCommand.cpp:

(WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):

  • editing/cocoa/DataDetection.mm:
  • editing/cocoa/HTMLConverter.mm:

(HTMLConverterCaches::propertyValueForNode):
(HTMLConverter::computedAttributesForElement):
(HTMLConverter::_enterElement):
(HTMLConverter::_processElement):

  • editing/markup.cpp:

(WebCore::createFragmentForTransformToFragment):

  • html/Autocapitalize.cpp:

(WebCore::stringForAutocapitalizeType):

  • html/Autofill.cpp:

(WebCore::AutofillData::createFromHTMLFormControlElement):

  • html/BaseCheckableInputType.cpp:

(WebCore::BaseCheckableInputType::saveFormControlState const):
(WebCore::BaseCheckableInputType::restoreFormControlState):
(WebCore::BaseCheckableInputType::fallbackValue const):

  • html/EnterKeyHint.cpp:

(WebCore::attributeValueForEnterKeyHint):

  • html/HTMLAudioElement.cpp:

(WebCore::HTMLAudioElement::createForLegacyFactoryFunction):

  • html/HTMLButtonElement.cpp:

(WebCore::HTMLButtonElement::formControlType const):

  • html/HTMLElement.cpp:

(WebCore::toValidDirValue):
(WebCore::HTMLElement::contentEditable const):
(WebCore::HTMLElement::setContentEditable):
(WebCore::HTMLElement::setAutocorrect):
(WebCore::plaintextOnlyName): Deleted.

  • html/HTMLFormElement.cpp:

(WebCore::HTMLFormElement::autocomplete const):

  • html/HTMLIFrameElement.cpp:

(WebCore::HTMLIFrameElement::loadingForBindings const):

  • html/HTMLImageElement.cpp:

(WebCore::HTMLImageElement::decoding const):
(WebCore::HTMLImageElement::loadingForBindings const):

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::preload const):

  • html/HTMLTextFormControlElement.cpp:

(WebCore::directionString):

  • html/InputMode.cpp:

(WebCore::InputModeNames::none):
(WebCore::InputModeNames::text):
(WebCore::InputModeNames::tel):
(WebCore::InputModeNames::url):
(WebCore::InputModeNames::email):
(WebCore::InputModeNames::search):

  • html/InputTypeNames.cpp:

(WebCore::InputTypeNames::email):
(WebCore::InputTypeNames::reset):
(WebCore::InputTypeNames::search):
(WebCore::InputTypeNames::submit):
(WebCore::InputTypeNames::telephone):
(WebCore::InputTypeNames::text):
(WebCore::InputTypeNames::url):

  • html/shadow/TextControlInnerElements.cpp:

(WebCore::TextControlInnerTextElement::updateInnerTextElementEditabilityImpl):

  • html/track/AudioTrack.cpp:

(WebCore::AudioTrack::isValidKind const):
(WebCore::AudioTrack::updateKindFromPrivate):
(WebCore::AudioTrack::alternativeKeyword): Deleted.
(WebCore::AudioTrack::mainKeyword): Deleted.
(WebCore::AudioTrack::commentaryKeyword): Deleted.

  • html/track/AudioTrack.h:
  • html/track/TextTrack.cpp:

(WebCore::TextTrack::TextTrack):
(WebCore::TextTrack::isValidKindKeyword):
(WebCore::TextTrack::kindKeyword const):
(WebCore::TextTrack::subtitlesKeyword): Deleted.
(WebCore::captionsKeyword): Deleted.

  • html/track/TextTrack.h:
  • html/track/VTTCue.cpp:

(WebCore::VTTCue::positionAlign const):
(WebCore::VTTCue::setPositionAlign):
(WebCore::VTTCue::toJSON const):
(WebCore::autoKeyword): Deleted.

  • html/track/VideoTrack.cpp:

(WebCore::VideoTrack::isValidKind const):
(WebCore::VideoTrack::updateKindFromPrivate):
(WebCore::VideoTrack::alternativeKeyword): Deleted.
(WebCore::VideoTrack::captionsKeyword): Deleted.
(WebCore::VideoTrack::mainKeyword): Deleted.
(WebCore::VideoTrack::subtitlesKeyword): Deleted.
(WebCore::VideoTrack::commentaryKeyword): Deleted.

  • html/track/VideoTrack.h:
  • html/track/WebVTTParser.cpp:

(WebCore::WebVTTParser::WebVTTParser):

  • inspector/agents/InspectorCSSAgent.cpp:

(WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument):

  • loader/FormSubmission.cpp:

(WebCore::FormSubmission::Attributes::parseEncodingType):

  • loader/NavigationScheduler.cpp:
  • loader/TextResourceDecoder.cpp:

(WebCore::TextResourceDecoder::textFromUTF8):

  • loader/archive/mhtml/MHTMLParser.cpp:

(WebCore::MHTMLParser::addResourceToArchive):

  • loader/cache/CachedCSSStyleSheet.cpp:

(WebCore::CachedCSSStyleSheet::CachedCSSStyleSheet):

  • mathml/MathMLPresentationElement.cpp:
  • page/CaptionUserPreferencesMediaAF.cpp:

(WebCore::addAudioTrackKindDisplayNameIfNeeded):

  • page/EventSource.cpp:

(WebCore::EventSource::EventSource):

  • page/Page.cpp:

(WebCore::Page::userStyleSheet const):

  • page/PageSerializer.cpp:

(WebCore::PageSerializer::serializeCSSStyleSheet):

  • page/PrintContext.cpp:

(WebCore::PrintContext::pageProperty):

  • page/ProcessWarming.cpp:

(WebCore::ProcessWarming::initializeNames):

  • platform/CommonAtomStrings.cpp: Added.

(WebCore::initializeCommonAtomStrings):

  • platform/CommonAtomStrings.h: Added.

(WebCore::alternativeAtom):
(WebCore::autoAtom):
(WebCore::captionsAtom):
(WebCore::commentaryAtom):
(WebCore::cssContentTypeAtom):
(WebCore::eagerAtom):
(WebCore::emailAtom):
(WebCore::falseAtom):
(WebCore::lazyAtom):
(WebCore::mainAtom):
(WebCore::noneAtom):
(WebCore::offAtom):
(WebCore::onAtom):
(WebCore::plaintextOnlyAtom):
(WebCore::resetAtom):
(WebCore::searchAtom):
(WebCore::submitAtom):
(WebCore::subtitlesAtom):
(WebCore::telAtom):
(WebCore::textAtom):
(WebCore::textPlainContentTypeAtom):
(WebCore::trueAtom):
(WebCore::urlAtom):

  • platform/Pasteboard.cpp:

(WebCore::Pasteboard::isSafeTypeForDOMToReadAndWrite):

  • platform/StaticPasteboard.cpp:

(WebCore::StaticPasteboard::writePlainText):

  • platform/animation/Animation.cpp:

(WebCore::Animation::initialName const):

  • platform/graphics/MediaPlayer.cpp:

(WebCore::MediaPlayer::load):
(WebCore::textPlain): Deleted.

  • platform/ios/wak/WebCoreThread.mm:

(StartWebThread):

  • platform/network/HTTPParsers.cpp:
  • platform/network/ios/WebCoreURLResponseIOS.h:

(WebCore::shouldUseQuickLookForMIMEType):

  • style/Styleable.cpp:

(WebCore::Styleable::animationListContainsNewlyValidAnimation const):
(WebCore::Styleable::updateCSSAnimations const):

  • svg/SVGAnimateMotionElement.cpp:

(WebCore::SVGAnimateMotionElement::rotateMode const):

  • svg/SVGAnimationElement.cpp:

(WebCore::sumAtom):
(WebCore::SVGAnimationElement::isAdditive const):
(WebCore::SVGAnimationElement::isAccumulated const):

  • svg/SVGFEConvolveMatrixElement.cpp:
  • svg/SVGFEConvolveMatrixElement.h:

(WebCore::SVGPropertyTraits<EdgeModeType>::toString):
(WebCore::SVGPropertyTraits<EdgeModeType>::fromString):

  • svg/SVGMarkerTypes.h:

(WebCore::SVGPropertyTraits<SVGMarkerOrientType>::fromString):
(WebCore::SVGPropertyTraits<SVGMarkerOrientType>::toString):
(WebCore::SVGPropertyTraits<SVGMarkerOrientType>::autoString): Deleted.

  • svg/SVGStyleElement.cpp:

(WebCore::SVGStyleElement::type const):

  • svg/SVGTextPathElement.h:

(WebCore::SVGPropertyTraits<SVGTextPathSpacingType>::toString):
(WebCore::SVGPropertyTraits<SVGTextPathSpacingType>::fromString):

  • svg/animation/SVGSMILElement.cpp:

(WebCore::indefiniteAtom):
(WebCore::SVGSMILElement::parseClockValue):
(WebCore::SVGSMILElement::repeatCount const):

  • svg/properties/SVGPropertyTraits.h:
  • workers/service/context/ServiceWorkerThread.cpp:

(WebCore::m_notificationClient):

  • xml/XPathValue.cpp:

Source/WebKit:

  • GPUProcess/GPUProcess.cpp:

(WebKit::GPUProcess::initializeGPUProcess):

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::initializeNetworkProcess):

  • Shared/Cocoa/WebKit2InitializeCocoa.mm:

(WebKit::runInitializationCode):

  • Shared/WebKit2Initialize.cpp:

(WebKit::InitializeWebKit2):

  • UIProcess/API/APIContentRuleListStore.cpp:

(API::ContentRuleListStore::compileContentRuleList):

Source/WebKitLegacy/win:

  • WebKitGraphics.cpp:

(makeFont):

Source/WTF:

  • wtf/text/AtomString.cpp:

(WTF::AtomString::init):

  • wtf/text/AtomString.h:

(WTF::xmlnsAtom):
(WTF::trueAtom): Deleted.
(WTF::falseAtom): Deleted.

Tools:

  • TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:

(TestWebKitAPI::makeBackend):

  • Property svn:eol-style set to native
File size: 6.2 KB
Line 
1/*
2 * (C) 1999-2003 Lars Knoll ([email protected])
3 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#pragma once
22
23#include "CSSRuleList.h"
24#include "CommonAtomStrings.h"
25#include "ExceptionOr.h"
26#include "StyleSheet.h"
27#include <memory>
28#include <wtf/Noncopyable.h>
29#include <wtf/TypeCasts.h>
30#include <wtf/WeakPtr.h>
31#include <wtf/text/AtomStringHash.h>
32#include <wtf/text/TextPosition.h>
33
34namespace WebCore {
35
36class CSSImportRule;
37class CSSParser;
38class CSSRule;
39class CSSStyleSheet;
40class CachedCSSStyleSheet;
41class Document;
42class Element;
43class MediaQuerySet;
44class StyleRuleKeyframes;
45class StyleSheetContents;
46
47namespace Style {
48class Scope;
49}
50
51class CSSStyleSheet final : public StyleSheet {
52public:
53 static Ref<CSSStyleSheet> create(Ref<StyleSheetContents>&&, CSSImportRule* ownerRule = 0);
54 static Ref<CSSStyleSheet> create(Ref<StyleSheetContents>&&, Node& ownerNode, const std::optional<bool>& isOriginClean = std::nullopt);
55 static Ref<CSSStyleSheet> createInline(Ref<StyleSheetContents>&&, Element& owner, const TextPosition& startPosition);
56
57 virtual ~CSSStyleSheet();
58
59 CSSStyleSheet* parentStyleSheet() const final;
60 Node* ownerNode() const final { return m_ownerNode; }
61 MediaList* media() const final;
62 String href() const final;
63 String title() const final { return m_title; }
64 bool disabled() const final { return m_isDisabled; }
65 void setDisabled(bool) final;
66
67 WEBCORE_EXPORT RefPtr<CSSRuleList> cssRules();
68 ExceptionOr<Ref<CSSRuleList>> cssRulesForBindings();
69 ExceptionOr<Ref<CSSRuleList>> rules() { return this->cssRulesForBindings(); }
70
71 WEBCORE_EXPORT ExceptionOr<unsigned> insertRule(const String& rule, unsigned index);
72 WEBCORE_EXPORT ExceptionOr<void> deleteRule(unsigned index);
73
74 WEBCORE_EXPORT ExceptionOr<int> addRule(const String& selector, const String& style, std::optional<unsigned> index);
75 ExceptionOr<void> removeRule(unsigned index) { return deleteRule(index); }
76
77 // For CSSRuleList.
78 unsigned length() const;
79 CSSRule* item(unsigned index);
80
81 void clearOwnerNode() final;
82 CSSImportRule* ownerRule() const final { return m_ownerRule; }
83 URL baseURL() const final;
84 bool isLoading() const final;
85
86 void clearOwnerRule() { m_ownerRule = 0; }
87
88 Document* ownerDocument() const;
89 CSSStyleSheet& rootStyleSheet();
90 const CSSStyleSheet& rootStyleSheet() const;
91 Style::Scope* styleScope();
92
93 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
94 void setMediaQueries(Ref<MediaQuerySet>&&);
95 void setTitle(const String& title) { m_title = title; }
96
97 bool hadRulesMutation() const { return m_mutatedRules; }
98 void clearHadRulesMutation() { m_mutatedRules = false; }
99
100 enum RuleMutationType { OtherMutation, RuleInsertion, KeyframesRuleMutation };
101 enum WhetherContentsWereClonedForMutation { ContentsWereNotClonedForMutation = 0, ContentsWereClonedForMutation };
102
103 class RuleMutationScope {
104 WTF_MAKE_NONCOPYABLE(RuleMutationScope);
105 public:
106 RuleMutationScope(CSSStyleSheet*, RuleMutationType = OtherMutation, StyleRuleKeyframes* insertedKeyframesRule = nullptr);
107 RuleMutationScope(CSSRule*);
108 ~RuleMutationScope();
109
110 private:
111 CSSStyleSheet* m_styleSheet;
112 RuleMutationType m_mutationType;
113 WhetherContentsWereClonedForMutation m_contentsWereClonedForMutation;
114 RefPtr<StyleRuleKeyframes> m_insertedKeyframesRule;
115 String m_modifiedKeyframesRuleName;
116 };
117
118 WhetherContentsWereClonedForMutation willMutateRules();
119 void didMutateRules(RuleMutationType, WhetherContentsWereClonedForMutation, StyleRuleKeyframes* insertedKeyframesRule, const String& modifiedKeyframesRuleName);
120 void didMutateRuleFromCSSStyleDeclaration();
121 void didMutate();
122
123 void clearChildRuleCSSOMWrappers();
124 void reattachChildRuleCSSOMWrappers();
125
126 StyleSheetContents& contents() { return m_contents; }
127
128 bool isInline() const { return m_isInlineStylesheet; }
129 TextPosition startPosition() const { return m_startPosition; }
130
131 void detachFromDocument() { m_ownerNode = nullptr; }
132
133 bool canAccessRules() const;
134
135 String debugDescription() const final;
136
137private:
138 CSSStyleSheet(Ref<StyleSheetContents>&&, CSSImportRule* ownerRule);
139 CSSStyleSheet(Ref<StyleSheetContents>&&, Node* ownerNode, const TextPosition& startPosition, bool isInlineStylesheet);
140 CSSStyleSheet(Ref<StyleSheetContents>&&, Node& ownerNode, const TextPosition& startPosition, bool isInlineStylesheet, const std::optional<bool>&);
141
142 bool isCSSStyleSheet() const final { return true; }
143 String type() const final { return cssContentTypeAtom(); }
144
145 Ref<StyleSheetContents> m_contents;
146 bool m_isInlineStylesheet { false };
147 bool m_isDisabled { false };
148 bool m_mutatedRules { false };
149 std::optional<bool> m_isOriginClean;
150 String m_title;
151 RefPtr<MediaQuerySet> m_mediaQueries;
152 WeakPtr<Style::Scope> m_styleScope;
153
154 Node* m_ownerNode { nullptr };
155 CSSImportRule* m_ownerRule { nullptr };
156
157 TextPosition m_startPosition;
158
159 mutable RefPtr<MediaList> m_mediaCSSOMWrapper;
160 mutable Vector<RefPtr<CSSRule>> m_childRuleCSSOMWrappers;
161 mutable std::unique_ptr<CSSRuleList> m_ruleListCSSOMWrapper;
162};
163
164} // namespace WebCore
165
166SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CSSStyleSheet)
167 static bool isType(const WebCore::StyleSheet& styleSheet) { return styleSheet.isCSSStyleSheet(); }
168SPECIALIZE_TYPE_TRAITS_END()
Note: See TracBrowser for help on using the repository browser.