summaryrefslogtreecommitdiff
path: root/Source/WebCore/css/CSSStyleSheet.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/WebCore/css/CSSStyleSheet.cpp
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/WebCore/css/CSSStyleSheet.cpp')
-rw-r--r--Source/WebCore/css/CSSStyleSheet.cpp58
1 files changed, 26 insertions, 32 deletions
diff --git a/Source/WebCore/css/CSSStyleSheet.cpp b/Source/WebCore/css/CSSStyleSheet.cpp
index 1fc893925..d8229a44a 100644
--- a/Source/WebCore/css/CSSStyleSheet.cpp
+++ b/Source/WebCore/css/CSSStyleSheet.cpp
@@ -21,28 +21,26 @@
#include "config.h"
#include "CSSStyleSheet.h"
-#include "AuthorStyleSheets.h"
#include "CSSCharsetRule.h"
#include "CSSFontFaceRule.h"
#include "CSSImportRule.h"
-#include "CSSKeyframesRule.h"
#include "CSSParser.h"
#include "CSSRuleList.h"
#include "CSSStyleRule.h"
#include "CachedCSSStyleSheet.h"
#include "Document.h"
+#include "DocumentStyleSheetCollection.h"
#include "ExceptionCode.h"
-#include "ExtensionStyleSheets.h"
#include "HTMLNames.h"
#include "HTMLStyleElement.h"
#include "MediaList.h"
#include "Node.h"
#include "SVGNames.h"
-#include "SVGStyleElement.h"
#include "SecurityOrigin.h"
#include "StyleResolver.h"
#include "StyleRule.h"
#include "StyleSheetContents.h"
+#include "WebKitCSSKeyframesRule.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -69,49 +67,47 @@ static bool isAcceptableCSSStyleSheetParent(Node* parentNode)
// Only these nodes can be parents of StyleSheets, and they need to call clearOwnerNode() when moved out of document.
return !parentNode
|| parentNode->isDocumentNode()
- || is<HTMLLinkElement>(*parentNode)
- || is<HTMLStyleElement>(*parentNode)
- || is<SVGStyleElement>(*parentNode)
+ || parentNode->hasTagName(HTMLNames::linkTag)
+ || isHTMLStyleElement(parentNode)
+#if ENABLE(SVG)
+ || parentNode->hasTagName(SVGNames::styleTag)
+#endif
|| parentNode->nodeType() == Node::PROCESSING_INSTRUCTION_NODE;
}
#endif
-Ref<CSSStyleSheet> CSSStyleSheet::create(Ref<StyleSheetContents>&& sheet, CSSImportRule* ownerRule)
+PassRef<CSSStyleSheet> CSSStyleSheet::create(PassRef<StyleSheetContents> sheet, CSSImportRule* ownerRule)
{
- return adoptRef(*new CSSStyleSheet(WTFMove(sheet), ownerRule));
+ return adoptRef(*new CSSStyleSheet(std::move(sheet), ownerRule));
}
-Ref<CSSStyleSheet> CSSStyleSheet::create(Ref<StyleSheetContents>&& sheet, Node* ownerNode)
+PassRef<CSSStyleSheet> CSSStyleSheet::create(PassRef<StyleSheetContents> sheet, Node* ownerNode)
{
- return adoptRef(*new CSSStyleSheet(WTFMove(sheet), ownerNode, TextPosition::minimumPosition(), false));
+ return adoptRef(*new CSSStyleSheet(std::move(sheet), ownerNode, false));
}
-Ref<CSSStyleSheet> CSSStyleSheet::createInline(Node& ownerNode, const URL& baseURL, const TextPosition& startPosition, const String& encoding)
+PassRef<CSSStyleSheet> CSSStyleSheet::createInline(Node& ownerNode, const URL& baseURL, const String& encoding)
{
CSSParserContext parserContext(ownerNode.document(), baseURL, encoding);
- return adoptRef(*new CSSStyleSheet(StyleSheetContents::create(baseURL.string(), parserContext), &ownerNode, startPosition, true));
+ return adoptRef(*new CSSStyleSheet(StyleSheetContents::create(baseURL.string(), parserContext), &ownerNode, true));
}
-CSSStyleSheet::CSSStyleSheet(Ref<StyleSheetContents>&& contents, CSSImportRule* ownerRule)
- : m_contents(WTFMove(contents))
+CSSStyleSheet::CSSStyleSheet(PassRef<StyleSheetContents> contents, CSSImportRule* ownerRule)
+ : m_contents(std::move(contents))
, m_isInlineStylesheet(false)
, m_isDisabled(false)
- , m_mutatedRules(false)
, m_ownerNode(0)
, m_ownerRule(ownerRule)
- , m_startPosition()
{
m_contents->registerClient(this);
}
-CSSStyleSheet::CSSStyleSheet(Ref<StyleSheetContents>&& contents, Node* ownerNode, const TextPosition& startPosition, bool isInlineStylesheet)
- : m_contents(WTFMove(contents))
+CSSStyleSheet::CSSStyleSheet(PassRef<StyleSheetContents> contents, Node* ownerNode, bool isInlineStylesheet)
+ : m_contents(std::move(contents))
, m_isInlineStylesheet(isInlineStylesheet)
, m_isDisabled(false)
- , m_mutatedRules(false)
, m_ownerNode(ownerNode)
, m_ownerRule(0)
- , m_startPosition(startPosition)
{
ASSERT(isAcceptableCSSStyleSheetParent(ownerNode));
m_contents->registerClient(this);
@@ -171,7 +167,7 @@ void CSSStyleSheet::didMutateRules(RuleMutationType mutationType, WhetherContent
if (!owner)
return;
- if (mutationType == RuleInsertion && !contentsWereClonedForMutation && !owner->authorStyleSheets().activeStyleSheetsContains(this)) {
+ if (mutationType == RuleInsertion && !contentsWereClonedForMutation && !owner->styleSheetCollection().activeStyleSheetsContains(this)) {
if (insertedKeyframesRule) {
if (StyleResolver* resolver = owner->styleResolverIfExists())
resolver->addKeyframeStyle(insertedKeyframesRule);
@@ -182,8 +178,6 @@ void CSSStyleSheet::didMutateRules(RuleMutationType mutationType, WhetherContent
}
owner->styleResolverChanged(DeferRecalcStyle);
-
- m_mutatedRules = true;
}
void CSSStyleSheet::didMutate()
@@ -208,7 +202,7 @@ void CSSStyleSheet::reattachChildRuleCSSOMWrappers()
for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) {
if (!m_childRuleCSSOMWrappers[i])
continue;
- m_childRuleCSSOMWrappers[i]->reattach(*m_contents->ruleAt(i));
+ m_childRuleCSSOMWrappers[i]->reattach(m_contents->ruleAt(i));
}
}
@@ -274,10 +268,10 @@ bool CSSStyleSheet::canAccessRules() const
return false;
}
-RefPtr<CSSRuleList> CSSStyleSheet::rules()
+PassRefPtr<CSSRuleList> CSSStyleSheet::rules()
{
if (!canAccessRules())
- return nullptr;
+ return 0;
// IE behavior.
RefPtr<StaticCSSRuleList> nonCharsetRules = StaticCSSRuleList::create();
unsigned ruleCount = length();
@@ -287,7 +281,7 @@ RefPtr<CSSRuleList> CSSStyleSheet::rules()
continue;
nonCharsetRules->rules().append(rule);
}
- return nonCharsetRules;
+ return nonCharsetRules.release();
}
unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, ExceptionCode& ec)
@@ -300,14 +294,14 @@ unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
return 0;
}
CSSParser p(m_contents.get().parserContext());
- RefPtr<StyleRuleBase> rule = p.parseRule(m_contents.ptr(), ruleString);
+ RefPtr<StyleRuleBase> rule = p.parseRule(&m_contents.get(), ruleString);
if (!rule) {
ec = SYNTAX_ERR;
return 0;
}
- RuleMutationScope mutationScope(this, RuleInsertion, is<StyleRuleKeyframes>(*rule) ? downcast<StyleRuleKeyframes>(rule.get()) : nullptr);
+ RuleMutationScope mutationScope(this, RuleInsertion, rule->type() == StyleRuleBase::Keyframes ? static_cast<StyleRuleKeyframes*>(rule.get()) : 0);
bool success = m_contents.get().wrapperInsertRule(rule, index);
if (!success) {
@@ -361,10 +355,10 @@ int CSSStyleSheet::addRule(const String& selector, const String& style, Exceptio
}
-RefPtr<CSSRuleList> CSSStyleSheet::cssRules()
+PassRefPtr<CSSRuleList> CSSStyleSheet::cssRules()
{
if (!canAccessRules())
- return nullptr;
+ return 0;
if (!m_ruleListCSSOMWrapper)
m_ruleListCSSOMWrapper = std::make_unique<StyleSheetCSSRuleList>(this);
return m_ruleListCSSOMWrapper.get();