mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Delete StyleSheetList and support code.
We don't need this since we don't expose the list of sheets from Document or ShadowRoot in Sky. After removing this code I also simplified the system and deleted StyleSheetCandidate and DocumentStyleSheetCollector which don't really do anything anymore. Even if we do want to add back a list of sheets later it won't need code because we don't have a concept of a remote sheet like <link rel> did, and we don't have to deal with non-CSS sheets. R=ojan@chromium.org Review URL: https://codereview.chromium.org/803673003
This commit is contained in:
parent
85c3691e29
commit
586a535b7f
@ -342,8 +342,6 @@ sky_core_files = [
|
||||
"css/StyleKeyframe.cpp",
|
||||
"css/StyleRuleKeyframes.h",
|
||||
"css/StyleRuleKeyframes.cpp",
|
||||
"css/StyleSheetList.cpp",
|
||||
"css/StyleSheetList.h",
|
||||
"css/StyleSheetContents.cpp",
|
||||
"css/StyleSheetContents.h",
|
||||
"dom/ActiveDOMObject.cpp",
|
||||
@ -432,8 +430,6 @@ sky_core_files = [
|
||||
"dom/DocumentParser.h",
|
||||
"dom/DocumentStyleSheetCollection.cpp",
|
||||
"dom/DocumentStyleSheetCollection.h",
|
||||
"dom/DocumentStyleSheetCollector.cpp",
|
||||
"dom/DocumentStyleSheetCollector.h",
|
||||
"dom/DocumentSupplementable.h",
|
||||
"dom/DOMError.cpp",
|
||||
"dom/DOMError.h",
|
||||
@ -524,8 +520,6 @@ sky_core_files = [
|
||||
"dom/StaticNodeList.h",
|
||||
"dom/StyleEngine.cpp",
|
||||
"dom/StyleEngine.h",
|
||||
"dom/StyleSheetCandidate.cpp",
|
||||
"dom/StyleSheetCandidate.h",
|
||||
"dom/StyleSheetCollection.cpp",
|
||||
"dom/StyleSheetCollection.h",
|
||||
"dom/TemplateContentDocumentFragment.h",
|
||||
|
||||
@ -1,91 +0,0 @@
|
||||
/**
|
||||
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
|
||||
* Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "sky/engine/config.h"
|
||||
#include "sky/engine/core/css/StyleSheetList.h"
|
||||
|
||||
#include "sky/engine/core/dom/Document.h"
|
||||
#include "sky/engine/core/dom/StyleEngine.h"
|
||||
#include "sky/engine/core/html/HTMLStyleElement.h"
|
||||
#include "sky/engine/wtf/text/WTFString.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
StyleSheetList::StyleSheetList(TreeScope* treeScope)
|
||||
: m_treeScope(treeScope)
|
||||
{
|
||||
}
|
||||
|
||||
StyleSheetList::~StyleSheetList()
|
||||
{
|
||||
}
|
||||
|
||||
inline const Vector<RefPtr<CSSStyleSheet> >& StyleSheetList::styleSheets()
|
||||
{
|
||||
#if !ENABLE(OILPAN)
|
||||
if (!m_treeScope)
|
||||
return m_detachedStyleSheets;
|
||||
#endif
|
||||
return document()->styleEngine()->styleSheetsForStyleSheetList(*m_treeScope);
|
||||
}
|
||||
|
||||
void StyleSheetList::detachFromDocument()
|
||||
{
|
||||
m_detachedStyleSheets = document()->styleEngine()->styleSheetsForStyleSheetList(*m_treeScope);
|
||||
m_treeScope = nullptr;
|
||||
}
|
||||
|
||||
unsigned StyleSheetList::length()
|
||||
{
|
||||
return styleSheets().size();
|
||||
}
|
||||
|
||||
CSSStyleSheet* StyleSheetList::item(unsigned index)
|
||||
{
|
||||
const Vector<RefPtr<CSSStyleSheet> >& sheets = styleSheets();
|
||||
return index < sheets.size() ? sheets[index].get() : 0;
|
||||
}
|
||||
|
||||
HTMLStyleElement* StyleSheetList::getNamedItem(const AtomicString& name) const
|
||||
{
|
||||
#if !ENABLE(OILPAN)
|
||||
if (!m_treeScope)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
// IE also supports retrieving a stylesheet by name, using the name/id of the <style> tag
|
||||
// (this is consistent with all the other collections)
|
||||
// ### Bad implementation because returns a single element (are IDs always unique?)
|
||||
// and doesn't look for name attribute.
|
||||
// But unicity of stylesheet ids is good practice anyway ;)
|
||||
// FIXME: We should figure out if we should change this or fix the spec.
|
||||
Element* element = m_treeScope->getElementById(name);
|
||||
return isHTMLStyleElement(element) ? toHTMLStyleElement(element) : 0;
|
||||
}
|
||||
|
||||
CSSStyleSheet* StyleSheetList::anonymousNamedGetter(const AtomicString& name)
|
||||
{
|
||||
HTMLStyleElement* item = getNamedItem(name);
|
||||
if (!item)
|
||||
return 0;
|
||||
return item->sheet();
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
|
||||
* Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_CSS_STYLESHEETLIST_H_
|
||||
#define SKY_ENGINE_CORE_CSS_STYLESHEETLIST_H_
|
||||
|
||||
#include "sky/engine/core/css/CSSStyleSheet.h"
|
||||
#include "sky/engine/core/dom/TreeScope.h"
|
||||
#include "sky/engine/wtf/Forward.h"
|
||||
#include "sky/engine/wtf/PassRefPtr.h"
|
||||
#include "sky/engine/wtf/RefCounted.h"
|
||||
#include "sky/engine/wtf/Vector.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class CSSStyleSheet;
|
||||
class HTMLStyleElement;
|
||||
|
||||
class StyleSheetList : public RefCounted<StyleSheetList> {
|
||||
public:
|
||||
static PassRefPtr<StyleSheetList> create(TreeScope* treeScope) { return adoptRef(new StyleSheetList(treeScope)); }
|
||||
~StyleSheetList();
|
||||
|
||||
unsigned length();
|
||||
CSSStyleSheet* item(unsigned index);
|
||||
|
||||
HTMLStyleElement* getNamedItem(const AtomicString&) const;
|
||||
|
||||
Document* document() { return m_treeScope ? &m_treeScope->document() : 0; }
|
||||
|
||||
#if !ENABLE(OILPAN)
|
||||
void detachFromDocument();
|
||||
#endif
|
||||
|
||||
CSSStyleSheet* anonymousNamedGetter(const AtomicString&);
|
||||
|
||||
private:
|
||||
StyleSheetList(TreeScope*);
|
||||
const Vector<RefPtr<CSSStyleSheet> >& styleSheets();
|
||||
|
||||
RawPtr<TreeScope> m_treeScope;
|
||||
#if !ENABLE(OILPAN)
|
||||
Vector<RefPtr<CSSStyleSheet> > m_detachedStyleSheets;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_CSS_STYLESHEETLIST_H_
|
||||
@ -47,7 +47,6 @@
|
||||
#include "sky/engine/core/css/MediaQueryMatcher.h"
|
||||
#include "sky/engine/core/css/StylePropertySet.h"
|
||||
#include "sky/engine/core/css/StyleSheetContents.h"
|
||||
#include "sky/engine/core/css/StyleSheetList.h"
|
||||
#include "sky/engine/core/css/parser/BisonCSSParser.h"
|
||||
#include "sky/engine/core/css/resolver/FontBuilder.h"
|
||||
#include "sky/engine/core/css/resolver/StyleResolver.h"
|
||||
|
||||
@ -117,7 +117,6 @@ class SerializedScriptValue;
|
||||
class Settings;
|
||||
class StyleEngine;
|
||||
class StyleResolver;
|
||||
class StyleSheetList;
|
||||
class Text;
|
||||
class Touch;
|
||||
class TouchList;
|
||||
|
||||
@ -30,9 +30,8 @@
|
||||
#include "gen/sky/platform/RuntimeEnabledFeatures.h"
|
||||
#include "sky/engine/core/css/resolver/StyleResolver.h"
|
||||
#include "sky/engine/core/dom/Document.h"
|
||||
#include "sky/engine/core/dom/DocumentStyleSheetCollector.h"
|
||||
#include "sky/engine/core/dom/StyleEngine.h"
|
||||
#include "sky/engine/core/dom/StyleSheetCandidate.h"
|
||||
#include "sky/engine/core/html/HTMLStyleElement.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
@ -42,36 +41,30 @@ DocumentStyleSheetCollection::DocumentStyleSheetCollection(TreeScope& treeScope)
|
||||
ASSERT(treeScope.rootNode() == treeScope.rootNode().document());
|
||||
}
|
||||
|
||||
void DocumentStyleSheetCollection::collectStyleSheetsFromCandidates(StyleEngine* engine, DocumentStyleSheetCollector& collector)
|
||||
void DocumentStyleSheetCollection::collectStyleSheetsFromCandidates(StyleEngine* engine, StyleSheetCollection& collection)
|
||||
{
|
||||
DocumentOrderedList::iterator begin = m_styleSheetCandidateNodes.begin();
|
||||
DocumentOrderedList::iterator end = m_styleSheetCandidateNodes.end();
|
||||
for (DocumentOrderedList::iterator it = begin; it != end; ++it) {
|
||||
Node* n = *it;
|
||||
StyleSheetCandidate candidate(*n);
|
||||
|
||||
CSSStyleSheet* sheet = candidate.sheet();
|
||||
if (!sheet)
|
||||
Node* node = *it;
|
||||
if (!isHTMLStyleElement(*node))
|
||||
continue;
|
||||
|
||||
collector.appendSheetForList(sheet);
|
||||
if (candidate.canBeActivated())
|
||||
collector.appendActiveStyleSheet(sheet);
|
||||
if (CSSStyleSheet* sheet = toHTMLStyleElement(node)->sheet())
|
||||
collection.appendActiveStyleSheet(sheet);
|
||||
}
|
||||
}
|
||||
|
||||
void DocumentStyleSheetCollection::collectStyleSheets(StyleEngine* engine, DocumentStyleSheetCollector& collector)
|
||||
void DocumentStyleSheetCollection::collectStyleSheets(StyleEngine* engine, StyleSheetCollection& collection)
|
||||
{
|
||||
ASSERT(document().styleEngine() == engine);
|
||||
collector.appendActiveStyleSheets(engine->documentAuthorStyleSheets());
|
||||
collectStyleSheetsFromCandidates(engine, collector);
|
||||
collection.appendActiveStyleSheets(engine->documentAuthorStyleSheets());
|
||||
collectStyleSheetsFromCandidates(engine, collection);
|
||||
}
|
||||
|
||||
void DocumentStyleSheetCollection::updateActiveStyleSheets(StyleEngine* engine)
|
||||
{
|
||||
StyleSheetCollection collection;
|
||||
ActiveDocumentStyleSheetCollector collector(collection);
|
||||
collectStyleSheets(engine, collector);
|
||||
collectStyleSheets(engine, collection);
|
||||
|
||||
engine->clearMasterResolver();
|
||||
// FIMXE: The following depends on whether StyleRuleFontFace was modified or not.
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
|
||||
namespace blink {
|
||||
|
||||
class DocumentStyleSheetCollector;
|
||||
class StyleEngine;
|
||||
class TreeScope;
|
||||
|
||||
@ -46,12 +45,12 @@ public:
|
||||
}
|
||||
|
||||
void updateActiveStyleSheets(StyleEngine*);
|
||||
void collectStyleSheets(StyleEngine*, DocumentStyleSheetCollector&);
|
||||
|
||||
private:
|
||||
explicit DocumentStyleSheetCollection(TreeScope&);
|
||||
|
||||
void collectStyleSheetsFromCandidates(StyleEngine*, DocumentStyleSheetCollector&);
|
||||
void collectStyleSheets(StyleEngine*, StyleSheetCollection&);
|
||||
void collectStyleSheetsFromCandidates(StyleEngine*, StyleSheetCollection&);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
|
||||
* (C) 1999 Antti Koivisto (koivisto@kde.org)
|
||||
* (C) 2001 Dirk Mueller (mueller@kde.org)
|
||||
* (C) 2006 Alexey Proskuryakov (ap@webkit.org)
|
||||
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
|
||||
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
|
||||
* Copyright (C) 2013 Google Inc. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "sky/engine/config.h"
|
||||
#include "sky/engine/core/dom/DocumentStyleSheetCollector.h"
|
||||
|
||||
#include "sky/engine/core/css/CSSStyleSheet.h"
|
||||
#include "sky/engine/core/dom/DocumentStyleSheetCollection.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
DocumentStyleSheetCollector::DocumentStyleSheetCollector(Vector<RefPtr<CSSStyleSheet> >& sheetsForList, Vector<RefPtr<CSSStyleSheet> >& activeList, HashSet<RawPtr<Document> >& visitedDocuments)
|
||||
: m_styleSheetsForStyleSheetList(sheetsForList)
|
||||
, m_activeAuthorStyleSheets(activeList)
|
||||
, m_visitedDocuments(visitedDocuments)
|
||||
{
|
||||
}
|
||||
|
||||
DocumentStyleSheetCollector::~DocumentStyleSheetCollector()
|
||||
{
|
||||
}
|
||||
|
||||
void DocumentStyleSheetCollector::appendActiveStyleSheets(const Vector<RefPtr<CSSStyleSheet> >& sheets)
|
||||
{
|
||||
m_activeAuthorStyleSheets.appendVector(sheets);
|
||||
}
|
||||
|
||||
void DocumentStyleSheetCollector::appendActiveStyleSheet(CSSStyleSheet* sheet)
|
||||
{
|
||||
m_activeAuthorStyleSheets.append(sheet);
|
||||
}
|
||||
|
||||
void DocumentStyleSheetCollector::appendSheetForList(CSSStyleSheet* sheet)
|
||||
{
|
||||
m_styleSheetsForStyleSheetList.append(sheet);
|
||||
}
|
||||
|
||||
ActiveDocumentStyleSheetCollector::ActiveDocumentStyleSheetCollector(StyleSheetCollection& collection)
|
||||
: DocumentStyleSheetCollector(collection.m_styleSheetsForStyleSheetList, collection.m_activeAuthorStyleSheets, m_visitedDocuments)
|
||||
{
|
||||
}
|
||||
|
||||
ImportedDocumentStyleSheetCollector::ImportedDocumentStyleSheetCollector(DocumentStyleSheetCollector& collector, Vector<RefPtr<CSSStyleSheet> >& sheetForList)
|
||||
: DocumentStyleSheetCollector(sheetForList, collector.m_activeAuthorStyleSheets, collector.m_visitedDocuments)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_DOM_DOCUMENTSTYLESHEETCOLLECTOR_H_
|
||||
#define SKY_ENGINE_CORE_DOM_DOCUMENTSTYLESHEETCOLLECTOR_H_
|
||||
|
||||
#include "sky/engine/platform/heap/Handle.h"
|
||||
#include "sky/engine/wtf/HashSet.h"
|
||||
#include "sky/engine/wtf/RefPtr.h"
|
||||
#include "sky/engine/wtf/Vector.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class Document;
|
||||
class CSSStyleSheet;
|
||||
class StyleSheetCollection;
|
||||
|
||||
class DocumentStyleSheetCollector {
|
||||
// This class contains references to two on-heap collections, therefore
|
||||
// it's unhealthy to have it anywhere but on the stack, where stack
|
||||
// scanning will keep them alive.
|
||||
STACK_ALLOCATED();
|
||||
public:
|
||||
friend class ImportedDocumentStyleSheetCollector;
|
||||
|
||||
DocumentStyleSheetCollector(Vector<RefPtr<CSSStyleSheet> >& sheetsForList, Vector<RefPtr<CSSStyleSheet> >& activeList, HashSet<RawPtr<Document> >&);
|
||||
~DocumentStyleSheetCollector();
|
||||
|
||||
void appendActiveStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&);
|
||||
void appendActiveStyleSheet(CSSStyleSheet*);
|
||||
void appendSheetForList(CSSStyleSheet*);
|
||||
|
||||
bool hasVisited(Document* document) const { return m_visitedDocuments.contains(document); }
|
||||
void willVisit(Document* document) { m_visitedDocuments.add(document); }
|
||||
|
||||
private:
|
||||
Vector<RefPtr<CSSStyleSheet> >& m_styleSheetsForStyleSheetList;
|
||||
Vector<RefPtr<CSSStyleSheet> >& m_activeAuthorStyleSheets;
|
||||
HashSet<RawPtr<Document> >& m_visitedDocuments;
|
||||
};
|
||||
|
||||
class ActiveDocumentStyleSheetCollector final : public DocumentStyleSheetCollector {
|
||||
public:
|
||||
ActiveDocumentStyleSheetCollector(StyleSheetCollection&);
|
||||
private:
|
||||
HashSet<RawPtr<Document> > m_visitedDocuments;
|
||||
};
|
||||
|
||||
class ImportedDocumentStyleSheetCollector final : public DocumentStyleSheetCollector {
|
||||
public:
|
||||
ImportedDocumentStyleSheetCollector(DocumentStyleSheetCollector&, Vector<RefPtr<CSSStyleSheet> >&);
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_DOM_DOCUMENTSTYLESHEETCOLLECTOR_H_
|
||||
@ -49,11 +49,7 @@ void ShadowTreeStyleSheetCollection::collectStyleSheets(StyleEngine* engine, Sty
|
||||
Node* node = *it;
|
||||
if (!isHTMLStyleElement(*node))
|
||||
continue;
|
||||
|
||||
CSSStyleSheet* sheet = toHTMLStyleElement(node)->sheet();
|
||||
if (sheet)
|
||||
collection.appendSheetForList(sheet);
|
||||
if (sheet)
|
||||
if (CSSStyleSheet* sheet = toHTMLStyleElement(node)->sheet())
|
||||
collection.appendActiveStyleSheet(sheet);
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
#include "sky/engine/core/css/CSSStyleSheet.h"
|
||||
#include "sky/engine/core/css/FontFaceCache.h"
|
||||
#include "sky/engine/core/css/StyleSheetContents.h"
|
||||
#include "sky/engine/core/dom/DocumentStyleSheetCollector.h"
|
||||
#include "sky/engine/core/dom/Element.h"
|
||||
#include "sky/engine/core/dom/ShadowTreeStyleSheetCollection.h"
|
||||
#include "sky/engine/core/dom/shadow/ShadowRoot.h"
|
||||
@ -96,6 +95,13 @@ inline Document* StyleEngine::master()
|
||||
return import->master();
|
||||
}
|
||||
|
||||
const Vector<RefPtr<CSSStyleSheet>>& StyleEngine::activeAuthorStyleSheetsFor(TreeScope& treeScope)
|
||||
{
|
||||
if (treeScope == m_document)
|
||||
return documentStyleSheetCollection()->activeAuthorStyleSheets();
|
||||
return ensureStyleSheetCollectionFor(treeScope)->activeAuthorStyleSheets();
|
||||
}
|
||||
|
||||
void StyleEngine::insertTreeScopeInDocumentOrder(TreeScopeSet& treeScopes, TreeScope* treeScope)
|
||||
{
|
||||
if (treeScopes.isEmpty()) {
|
||||
@ -145,14 +151,6 @@ TreeScopeStyleSheetCollection* StyleEngine::styleSheetCollectionFor(TreeScope& t
|
||||
return it->value.get();
|
||||
}
|
||||
|
||||
const Vector<RefPtr<CSSStyleSheet> >& StyleEngine::styleSheetsForStyleSheetList(TreeScope& treeScope)
|
||||
{
|
||||
if (treeScope == m_document)
|
||||
return documentStyleSheetCollection()->styleSheetsForStyleSheetList();
|
||||
|
||||
return ensureStyleSheetCollectionFor(treeScope)->styleSheetsForStyleSheetList();
|
||||
}
|
||||
|
||||
void StyleEngine::modifiedStyleSheet(CSSStyleSheet* sheet)
|
||||
{
|
||||
if (!sheet)
|
||||
|
||||
@ -73,8 +73,7 @@ public:
|
||||
void detachFromDocument();
|
||||
#endif
|
||||
|
||||
const Vector<RefPtr<CSSStyleSheet> >& styleSheetsForStyleSheetList(TreeScope&);
|
||||
|
||||
const Vector<RefPtr<CSSStyleSheet>>& activeAuthorStyleSheetsFor(TreeScope&);
|
||||
const Vector<RefPtr<CSSStyleSheet> >& documentAuthorStyleSheets() const { return m_authorStyleSheets; }
|
||||
|
||||
void modifiedStyleSheet(CSSStyleSheet*);
|
||||
|
||||
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Google Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "sky/engine/config.h"
|
||||
#include "sky/engine/core/dom/StyleSheetCandidate.h"
|
||||
|
||||
#include "sky/engine/core/dom/Element.h"
|
||||
#include "sky/engine/core/dom/StyleEngine.h"
|
||||
#include "sky/engine/core/html/HTMLStyleElement.h"
|
||||
#include "sky/engine/core/html/imports/HTMLImport.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
bool StyleSheetCandidate::canBeActivated() const
|
||||
{
|
||||
// TODO(esprehn): Remove this.
|
||||
CSSStyleSheet* sheet = this->sheet();
|
||||
return sheet;
|
||||
}
|
||||
|
||||
StyleSheetCandidate::Type StyleSheetCandidate::typeOf(Node& node)
|
||||
{
|
||||
if (node.isHTMLElement()) {
|
||||
if (isHTMLStyleElement(node))
|
||||
return HTMLStyle;
|
||||
|
||||
ASSERT_NOT_REACHED();
|
||||
return HTMLStyle;
|
||||
}
|
||||
|
||||
ASSERT_NOT_REACHED();
|
||||
return HTMLStyle;
|
||||
}
|
||||
|
||||
CSSStyleSheet* StyleSheetCandidate::sheet() const
|
||||
{
|
||||
switch (m_type) {
|
||||
case HTMLStyle:
|
||||
return toHTMLStyleElement(node()).sheet();
|
||||
}
|
||||
|
||||
ASSERT_NOT_REACHED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Google Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_DOM_STYLESHEETCANDIDATE_H_
|
||||
#define SKY_ENGINE_CORE_DOM_STYLESHEETCANDIDATE_H_
|
||||
|
||||
#include "sky/engine/platform/heap/Handle.h"
|
||||
#include "sky/engine/wtf/text/AtomicString.h"
|
||||
#include "sky/engine/wtf/text/WTFString.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class CSSStyleSheet;
|
||||
class Document;
|
||||
class Node;
|
||||
|
||||
class StyleSheetCandidate {
|
||||
STACK_ALLOCATED();
|
||||
public:
|
||||
enum Type {
|
||||
HTMLStyle,
|
||||
};
|
||||
|
||||
StyleSheetCandidate(Node& node)
|
||||
: m_node(node)
|
||||
, m_type(typeOf(node))
|
||||
{ }
|
||||
|
||||
bool canBeActivated() const;
|
||||
|
||||
CSSStyleSheet* sheet() const;
|
||||
|
||||
private:
|
||||
Node& node() const { return *m_node; }
|
||||
|
||||
static Type typeOf(Node&);
|
||||
|
||||
RawPtr<Node> m_node;
|
||||
Type m_type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SKY_ENGINE_CORE_DOM_STYLESHEETCANDIDATE_H_
|
||||
|
||||
@ -41,17 +41,9 @@ StyleSheetCollection::~StyleSheetCollection()
|
||||
|
||||
void StyleSheetCollection::swap(StyleSheetCollection& other)
|
||||
{
|
||||
m_styleSheetsForStyleSheetList.swap(other.m_styleSheetsForStyleSheetList);
|
||||
m_activeAuthorStyleSheets.swap(other.m_activeAuthorStyleSheets);
|
||||
}
|
||||
|
||||
void StyleSheetCollection::swapSheetsForSheetList(Vector<RefPtr<CSSStyleSheet> >& sheets)
|
||||
{
|
||||
// Only called for collection of HTML Imports that never has active sheets.
|
||||
ASSERT(m_activeAuthorStyleSheets.isEmpty());
|
||||
m_styleSheetsForStyleSheetList.swap(sheets);
|
||||
}
|
||||
|
||||
void StyleSheetCollection::appendActiveStyleSheets(const Vector<RefPtr<CSSStyleSheet> >& sheets)
|
||||
{
|
||||
m_activeAuthorStyleSheets.appendVector(sheets);
|
||||
@ -62,9 +54,4 @@ void StyleSheetCollection::appendActiveStyleSheet(CSSStyleSheet* sheet)
|
||||
m_activeAuthorStyleSheets.append(sheet);
|
||||
}
|
||||
|
||||
void StyleSheetCollection::appendSheetForList(CSSStyleSheet* sheet)
|
||||
{
|
||||
m_styleSheetsForStyleSheetList.append(sheet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -41,25 +41,17 @@ class StyleSheetCollection {
|
||||
WTF_MAKE_NONCOPYABLE(StyleSheetCollection);
|
||||
WTF_MAKE_FAST_ALLOCATED;
|
||||
public:
|
||||
friend class ActiveDocumentStyleSheetCollector;
|
||||
friend class ImportedDocumentStyleSheetCollector;
|
||||
|
||||
StyleSheetCollection();
|
||||
virtual ~StyleSheetCollection();
|
||||
|
||||
Vector<RefPtr<CSSStyleSheet> >& activeAuthorStyleSheets() { return m_activeAuthorStyleSheets; }
|
||||
Vector<RefPtr<CSSStyleSheet> >& styleSheetsForStyleSheetList() { return m_styleSheetsForStyleSheetList; }
|
||||
const Vector<RefPtr<CSSStyleSheet> >& activeAuthorStyleSheets() const { return m_activeAuthorStyleSheets; }
|
||||
const Vector<RefPtr<CSSStyleSheet> >& styleSheetsForStyleSheetList() const { return m_styleSheetsForStyleSheetList; }
|
||||
|
||||
void swap(StyleSheetCollection&);
|
||||
void swapSheetsForSheetList(Vector<RefPtr<CSSStyleSheet> >&);
|
||||
void appendActiveStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&);
|
||||
void appendActiveStyleSheet(CSSStyleSheet*);
|
||||
void appendSheetForList(CSSStyleSheet*);
|
||||
|
||||
protected:
|
||||
Vector<RefPtr<CSSStyleSheet> > m_styleSheetsForStyleSheetList;
|
||||
Vector<RefPtr<CSSStyleSheet> > m_activeAuthorStyleSheets;
|
||||
};
|
||||
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
#include "sky/engine/core/dom/TreeScope.h"
|
||||
|
||||
#include "gen/sky/core/HTMLNames.h"
|
||||
#include "sky/engine/core/css/StyleSheetList.h"
|
||||
#include "sky/engine/core/css/resolver/ScopedStyleResolver.h"
|
||||
#include "sky/engine/core/dom/ContainerNode.h"
|
||||
#include "sky/engine/core/dom/Document.h"
|
||||
@ -425,8 +424,8 @@ bool TreeScope::hasSameStyles(TreeScope& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return true;
|
||||
const Vector<RefPtr<blink::CSSStyleSheet> >& list = document().styleEngine()->styleSheetsForStyleSheetList(*this);
|
||||
const Vector<RefPtr<blink::CSSStyleSheet> >& otherList = document().styleEngine()->styleSheetsForStyleSheetList(other);
|
||||
const Vector<RefPtr<blink::CSSStyleSheet> >& list = document().styleEngine()->activeAuthorStyleSheetsFor(*this);
|
||||
const Vector<RefPtr<blink::CSSStyleSheet> >& otherList = document().styleEngine()->activeAuthorStyleSheetsFor(other);
|
||||
|
||||
if (list.size() != otherList.size())
|
||||
return false;
|
||||
|
||||
@ -27,7 +27,6 @@
|
||||
#include "sky/engine/config.h"
|
||||
#include "sky/engine/core/dom/shadow/ElementShadow.h"
|
||||
|
||||
#include "sky/engine/core/css/StyleSheetList.h"
|
||||
#include "sky/engine/core/dom/Document.h"
|
||||
#include "sky/engine/core/dom/ElementTraversal.h"
|
||||
#include "sky/engine/core/dom/NodeTraversal.h"
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
#include "sky/engine/core/dom/shadow/ShadowRoot.h"
|
||||
|
||||
#include "sky/engine/bindings/core/v8/ExceptionState.h"
|
||||
#include "sky/engine/core/css/StyleSheetList.h"
|
||||
#include "sky/engine/core/css/resolver/StyleResolver.h"
|
||||
#include "sky/engine/core/dom/ElementTraversal.h"
|
||||
#include "sky/engine/core/dom/StyleEngine.h"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user