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

Unified Diff: sky/engine/core/css/CSSStyleSheet.cpp

Issue 780483002: Remove the CSSOM. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/core/css/CSSStyleSheet.h ('k') | sky/engine/core/css/CSSStyleSheet.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/css/CSSStyleSheet.cpp
diff --git a/sky/engine/core/css/CSSStyleSheet.cpp b/sky/engine/core/css/CSSStyleSheet.cpp
index 376aff1416b68a07a2740c238a19b83b5ed9cc32..62dc97ea88e526e2f0133b69751e4ecf9295187b 100644
--- a/sky/engine/core/css/CSSStyleSheet.cpp
+++ b/sky/engine/core/css/CSSStyleSheet.cpp
@@ -24,7 +24,6 @@
#include "sky/engine/bindings/core/v8/ExceptionState.h"
#include "sky/engine/bindings/core/v8/V8Binding.h"
#include "sky/engine/bindings/core/v8/V8PerIsolateData.h"
-#include "sky/engine/core/css/CSSRuleList.h"
#include "sky/engine/core/css/MediaList.h"
#include "sky/engine/core/css/StyleRule.h"
#include "sky/engine/core/css/StyleSheetContents.h"
@@ -38,27 +37,6 @@
namespace blink {
-class StyleSheetCSSRuleList final : public CSSRuleList {
-public:
- static PassOwnPtr<StyleSheetCSSRuleList> create(CSSStyleSheet* sheet)
- {
- return adoptPtr(new StyleSheetCSSRuleList(sheet));
- }
-
-private:
- StyleSheetCSSRuleList(CSSStyleSheet* sheet) : m_styleSheet(sheet) { }
-
- virtual void ref() override { m_styleSheet->ref(); }
- virtual void deref() override { m_styleSheet->deref(); }
-
- virtual unsigned length() const override { return m_styleSheet->length(); }
- virtual CSSRule* item(unsigned index) const override { return m_styleSheet->item(index); }
-
- virtual CSSStyleSheet* styleSheet() const override { return m_styleSheet; }
-
- RawPtr<CSSStyleSheet> m_styleSheet;
-};
-
#if ENABLE(ASSERT)
static bool isAcceptableCSSStyleSheetParent(Node* parentNode)
{
@@ -107,21 +85,6 @@ CSSStyleSheet::CSSStyleSheet(PassRefPtr<StyleSheetContents> contents, Node* owne
CSSStyleSheet::~CSSStyleSheet()
{
- // With oilpan the parent style sheet pointer is strong and the sheet and
- // its RuleCSSOMWrappers die together and we don't need to clear them here.
- // Also with oilpan the StyleSheetContents client pointers are weak and
- // therefore do not need to be cleared here.
- // For style rules outside the document, .parentStyleSheet can become null even if the style rule
- // is still observable from JavaScript. This matches the behavior of .parentNode for nodes, but
- // it's not ideal because it makes the CSSOM's behavior depend on the timing of garbage collection.
- for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) {
- if (m_childRuleCSSOMWrappers[i])
- m_childRuleCSSOMWrappers[i]->setParentStyleSheet(0);
- }
-
- if (m_mediaCSSOMWrapper)
- m_mediaCSSOMWrapper->clearParentStyleSheet();
-
m_contents->unregisterClient(this);
}
@@ -144,9 +107,6 @@ void CSSStyleSheet::willMutateRules()
m_contents->registerClient(this);
m_contents->setMutable();
-
- // Any existing CSSOM wrappers need to be connected to the copied child rules.
- reattachChildRuleCSSOMWrappers();
}
void CSSStyleSheet::didMutateRules()
@@ -166,20 +126,10 @@ void CSSStyleSheet::didMutate(StyleSheetUpdateType updateType)
owner->modifiedStyleSheet(this);
}
-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));
- }
-}
void CSSStyleSheet::setMediaQueries(PassRefPtr<MediaQuerySet> mediaQueries)
{
m_mediaQueries = mediaQueries;
- if (m_mediaCSSOMWrapper && m_mediaQueries)
- m_mediaCSSOMWrapper->reattach(m_mediaQueries.get());
// Add warning message to inspector whenever dpi/dpcm values are used for "screen" media.
reportMediaQueryWarningIfNeeded(ownerDocument(), m_mediaQueries.get());
@@ -190,22 +140,6 @@ unsigned CSSStyleSheet::length() const
return m_contents->ruleCount();
}
-CSSRule* CSSStyleSheet::item(unsigned index)
-{
- unsigned ruleCount = length();
- if (index >= ruleCount)
- return 0;
-
- if (m_childRuleCSSOMWrappers.isEmpty())
- m_childRuleCSSOMWrappers.grow(ruleCount);
- ASSERT(m_childRuleCSSOMWrappers.size() == ruleCount);
-
- RefPtr<CSSRule>& cssRule = m_childRuleCSSOMWrappers[index];
- if (!cssRule)
- cssRule = m_contents->ruleAt(index)->createCSSOMWrapper(this);
- return cssRule.get();
-}
-
void CSSStyleSheet::clearOwnerNode()
{
didMutate(EntireStyleSheetUpdate);
@@ -214,123 +148,14 @@ void CSSStyleSheet::clearOwnerNode()
m_ownerNode = nullptr;
}
-PassRefPtr<CSSRuleList> CSSStyleSheet::rules()
-{
- // IE behavior.
- RefPtr<StaticCSSRuleList> nonCharsetRules(StaticCSSRuleList::create());
- unsigned ruleCount = length();
- for (unsigned i = 0; i < ruleCount; ++i) {
- CSSRule* rule = item(i);
- nonCharsetRules->rules().append(rule);
- }
- return nonCharsetRules.release();
-}
-
-unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, ExceptionState& exceptionState)
-{
- ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_contents->ruleCount());
-
- if (index > length()) {
- exceptionState.throwDOMException(IndexSizeError, "The index provided (" + String::number(index) + ") is larger than the maximum index (" + String::number(length()) + ").");
- return 0;
- }
- CSSParserContext context(m_contents->parserContext(), UseCounter::getFrom(this));
- BisonCSSParser p(context);
- RefPtr<StyleRuleBase> rule = p.parseRule(m_contents.get(), ruleString);
-
- if (!rule) {
- exceptionState.throwDOMException(SyntaxError, "Failed to parse the rule '" + ruleString + "'.");
- return 0;
- }
- RuleMutationScope mutationScope(this);
-
- bool success = m_contents->wrapperInsertRule(rule, index);
- if (!success) {
- exceptionState.throwDOMException(HierarchyRequestError, "Failed to insert the rule.");
- return 0;
- }
- if (!m_childRuleCSSOMWrappers.isEmpty())
- m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>(nullptr));
-
- return index;
-}
-
-unsigned CSSStyleSheet::insertRule(const String& rule, ExceptionState& exceptionState)
-{
- UseCounter::countDeprecation(callingExecutionContext(V8PerIsolateData::mainThreadIsolate()), UseCounter::CSSStyleSheetInsertRuleOptionalArg);
- return insertRule(rule, 0, exceptionState);
-}
-
-void CSSStyleSheet::deleteRule(unsigned index, ExceptionState& exceptionState)
-{
- ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_contents->ruleCount());
-
- if (index >= length()) {
- exceptionState.throwDOMException(IndexSizeError, "The index provided (" + String::number(index) + ") is larger than the maximum index (" + String::number(length() - 1) + ").");
- return;
- }
- RuleMutationScope mutationScope(this);
-
- m_contents->wrapperDeleteRule(index);
-
- if (!m_childRuleCSSOMWrappers.isEmpty()) {
- if (m_childRuleCSSOMWrappers[index])
- m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0);
- m_childRuleCSSOMWrappers.remove(index);
- }
-}
-
-int CSSStyleSheet::addRule(const String& selector, const String& style, int index, ExceptionState& exceptionState)
-{
- StringBuilder text;
- text.append(selector);
- text.appendLiteral(" { ");
- text.append(style);
- if (!style.isEmpty())
- text.append(' ');
- text.append('}');
- insertRule(text.toString(), index, exceptionState);
-
- // As per Microsoft documentation, always return -1.
- return -1;
-}
-
-int CSSStyleSheet::addRule(const String& selector, const String& style, ExceptionState& exceptionState)
-{
- return addRule(selector, style, length(), exceptionState);
-}
-
-
-PassRefPtr<CSSRuleList> CSSStyleSheet::cssRules()
-{
- if (!m_ruleListCSSOMWrapper)
- m_ruleListCSSOMWrapper = StyleSheetCSSRuleList::create(this);
- return m_ruleListCSSOMWrapper.get();
-}
-
KURL CSSStyleSheet::baseURL() const
{
return m_contents->baseURL();
}
-MediaList* CSSStyleSheet::media() const
-{
- if (!m_mediaQueries)
- return 0;
-
- if (!m_mediaCSSOMWrapper)
- m_mediaCSSOMWrapper = MediaList::create(m_mediaQueries.get(), const_cast<CSSStyleSheet*>(this));
- return m_mediaCSSOMWrapper.get();
-}
-
Document* CSSStyleSheet::ownerDocument() const
{
return ownerNode() ? &ownerNode()->document() : 0;
}
-void CSSStyleSheet::clearChildRuleCSSOMWrappers()
-{
- m_childRuleCSSOMWrappers.clear();
-}
-
} // namespace blink
« no previous file with comments | « sky/engine/core/css/CSSStyleSheet.h ('k') | sky/engine/core/css/CSSStyleSheet.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698