Diff
Modified: trunk/Source/WebCore/ChangeLog (112257 => 112258)
--- trunk/Source/WebCore/ChangeLog 2012-03-27 12:32:06 UTC (rev 112257)
+++ trunk/Source/WebCore/ChangeLog 2012-03-27 12:40:38 UTC (rev 112258)
@@ -1,3 +1,57 @@
+2012-03-27 Antti Koivisto <[email protected]>
+
+ Remove Document::mappedElementSheet()
+ https://bugs.webkit.org/show_bug.cgi?id=82242
+
+ Reviewed by Anreas Kling and Nikolas Zimmermann.
+
+ The only thing this is used for anymore is SVGFontFaceElement. That can be handled without
+ the confusing extra stylesheet.
+
+ * css/CSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::CSSStyleSelector):
+ * css/CSSStyleSelector.h:
+ (CSSStyleSelector):
+
+ - Add font face rules from registered SVGFontFaceElements.
+ - Simplify the constructor signature. Stylesheets are part of the document.
+
+ * dom/Document.cpp:
+ (WebCore::Document::~Document):
+ (WebCore::Document::createStyleSelector):
+ (WebCore):
+ (WebCore::Document::updateBaseURL):
+ * dom/Document.h:
+ (WebCore):
+ (WebCore::Document::documentUserSheets):
+ (Document):
+
+ - Remove mappedElementSheet
+ - Adapt to the CSSStyleSelector constructor signature changes.
+
+ * svg/SVGDocumentExtensions.cpp:
+ (WebCore::SVGDocumentExtensions::svgFontFaceElements):
+ (WebCore):
+ (WebCore::SVGDocumentExtensions::registerSVGFontFaceElement):
+ (WebCore::SVGDocumentExtensions::unregisterSVGFontFaceElement):
+ * svg/SVGDocumentExtensions.h:
+ (WebCore):
+ (SVGDocumentExtensions):
+
+ - Add map for SVGFontFaceElements
+
+ * svg/SVGFontFaceElement.cpp:
+ (WebCore::SVGFontFaceElement::insertedIntoDocument):
+ (WebCore::SVGFontFaceElement::removedFromDocument):
+ (WebCore):
+ * svg/SVGFontFaceElement.h:
+ (SVGFontFaceElement):
+ (WebCore::SVGFontFaceElement::fontFaceRule):
+
+ - Switch to updating svgFontFaceElements map.
+ - Use elementSheet as the parent sheet (nothing is ever added to the elementSheet, it is used for
+ resolving relative URLs only).
+
2012-03-27 Vsevolod Vlasov <[email protected]>
Web Inspector: startEditing should remove tabIndex attribute from the element if it was not set before.
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (112257 => 112258)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2012-03-27 12:32:06 UTC (rev 112257)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2012-03-27 12:40:38 UTC (rev 112258)
@@ -91,6 +91,8 @@
#include "RenderTheme.h"
#include "RotateTransformOperation.h"
#include "RuntimeEnabledFeatures.h"
+#include "SVGDocumentExtensions.h"
+#include "SVGFontFaceElement.h"
#include "ScaleTransformOperation.h"
#include "SecurityOrigin.h"
#include "Settings.h"
@@ -321,13 +323,11 @@
return rightToLeftDecl.get();
}
-CSSStyleSelector::CSSStyleSelector(Document* document, StyleSheetList* styleSheets, CSSStyleSheet* mappedElementSheet,
- CSSStyleSheet* pageUserSheet, const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets, const Vector<RefPtr<CSSStyleSheet> >* documentUserSheets,
- bool strictParsing, bool matchAuthorAndUserStyles)
+CSSStyleSelector::CSSStyleSelector(Document* document, bool matchAuthorAndUserStyles)
: m_hasUAAppearance(false)
, m_backgroundData(BackgroundFillLayer)
, m_matchedPropertiesCacheAdditionsSinceLastSweep(0)
- , m_checker(document, strictParsing)
+ , m_checker(document, !document->inQuirksMode())
, m_parentStyle(0)
, m_rootElementStyle(0)
, m_element(0)
@@ -386,9 +386,9 @@
// FIXME: This sucks! The user sheet is reparsed every time!
OwnPtr<RuleSet> tempUserStyle = adoptPtr(new RuleSet);
- if (pageUserSheet)
+ if (CSSStyleSheet* pageUserSheet = document->pageUserSheet())
tempUserStyle->addRulesFromSheet(pageUserSheet, *m_medium, this);
- if (pageGroupUserSheets) {
+ if (const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets = document->pageGroupUserSheets()) {
unsigned length = pageGroupUserSheets->size();
for (unsigned i = 0; i < length; i++) {
if (pageGroupUserSheets->at(i)->isUserStyleSheet())
@@ -397,7 +397,7 @@
m_authorStyle->addRulesFromSheet(pageGroupUserSheets->at(i).get(), *m_medium, this);
}
}
- if (documentUserSheets) {
+ if (const Vector<RefPtr<CSSStyleSheet> >* documentUserSheets = document->documentUserSheets()) {
unsigned length = documentUserSheets->size();
for (unsigned i = 0; i < length; i++) {
if (documentUserSheets->at(i)->isUserStyleSheet())
@@ -410,14 +410,16 @@
if (tempUserStyle->m_ruleCount > 0 || tempUserStyle->m_pageRules.size() > 0)
m_userStyle = tempUserStyle.release();
- // Add rules from elements like SVG's <font-face>
- if (mappedElementSheet) {
- // FIXME: see if style scopes can/should be added here.
- m_authorStyle->addRulesFromSheet(mappedElementSheet, *m_medium, this);
+#if ENABLE(SVG_FONTS)
+ if (document->svgExtensions()) {
+ const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document->svgExtensions()->svgFontFaceElements();
+ HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.end();
+ for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElements.begin(); it != end; ++it)
+ fontSelector()->addFontFaceRule((*it)->fontFaceRule());
}
+#endif
- // add stylesheets from document
- appendAuthorStylesheets(0, styleSheets->vector());
+ appendAuthorStylesheets(0, document->styleSheets()->vector());
}
static PassOwnPtr<RuleSet> makeRuleSet(const Vector<CSSStyleSelector::RuleSelectorPair>& rules)
Modified: trunk/Source/WebCore/css/CSSStyleSelector.h (112257 => 112258)
--- trunk/Source/WebCore/css/CSSStyleSelector.h 2012-03-27 12:32:06 UTC (rev 112257)
+++ trunk/Source/WebCore/css/CSSStyleSelector.h 2012-03-27 12:40:38 UTC (rev 112258)
@@ -104,9 +104,7 @@
class CSSStyleSelector {
WTF_MAKE_NONCOPYABLE(CSSStyleSelector); WTF_MAKE_FAST_ALLOCATED;
public:
- CSSStyleSelector(Document*, StyleSheetList* authorSheets, CSSStyleSheet* mappedElementSheet,
- CSSStyleSheet* pageUserSheet, const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets, const Vector<RefPtr<CSSStyleSheet> >* documentUserSheets,
- bool strictParsing, bool matchAuthorAndUserStyles);
+ CSSStyleSelector(Document*, bool matchAuthorAndUserStyles);
~CSSStyleSelector();
// Using these during tree walk will allow style selector to optimize child and descendant selector lookups.
Modified: trunk/Source/WebCore/dom/Document.cpp (112257 => 112258)
--- trunk/Source/WebCore/dom/Document.cpp 2012-03-27 12:32:06 UTC (rev 112257)
+++ trunk/Source/WebCore/dom/Document.cpp 2012-03-27 12:40:38 UTC (rev 112258)
@@ -584,8 +584,6 @@
if (m_elemSheet)
m_elemSheet->clearOwnerNode();
- if (m_mappedElementSheet)
- m_mappedElementSheet->clearOwnerNode();
if (m_pageUserSheet)
m_pageUserSheet->clearOwnerNode();
if (m_pageGroupUserSheets) {
@@ -1884,11 +1882,10 @@
bool matchAuthorAndUserStyles = true;
if (Settings* docSettings = settings())
matchAuthorAndUserStyles = docSettings->authorAndUserStylesEnabled();
- m_styleSelector = adoptPtr(new CSSStyleSelector(this, m_styleSheets.get(), m_mappedElementSheet.get(), pageUserSheet(), pageGroupUserSheets(), m_userSheets.get(),
- !inQuirksMode(), matchAuthorAndUserStyles));
+ m_styleSelector = adoptPtr(new CSSStyleSelector(this, matchAuthorAndUserStyles));
combineCSSFeatureFlags();
}
-
+
inline void Document::clearStyleSelector()
{
m_styleSelector.clear();
@@ -2552,8 +2549,6 @@
if (m_elemSheet)
m_elemSheet->setFinalURL(m_baseURL);
- if (m_mappedElementSheet)
- m_mappedElementSheet->setFinalURL(m_baseURL);
if (!equalIgnoringFragmentIdentifier(oldBaseURL, m_baseURL)) {
// Base URL change changes any relative visited links.
@@ -2777,13 +2772,6 @@
return m_elemSheet.get();
}
-CSSStyleSheet* Document::mappedElementSheet()
-{
- if (!m_mappedElementSheet)
- m_mappedElementSheet = CSSStyleSheet::createInline(this, m_baseURL);
- return m_mappedElementSheet.get();
-}
-
int Document::nodeAbsIndex(Node *node)
{
ASSERT(node->document() == this);
Modified: trunk/Source/WebCore/dom/Document.h (112257 => 112258)
--- trunk/Source/WebCore/dom/Document.h 2012-03-27 12:32:06 UTC (rev 112257)
+++ trunk/Source/WebCore/dom/Document.h 2012-03-27 12:40:38 UTC (rev 112258)
@@ -631,10 +631,10 @@
void clearPageGroupUserSheets();
void updatePageGroupUserSheets();
+ const Vector<RefPtr<CSSStyleSheet> >* documentUserSheets() const { return m_userSheets.get(); }
void addUserSheet(PassRefPtr<CSSStyleSheet> userSheet);
CSSStyleSheet* elementSheet();
- CSSStyleSheet* mappedElementSheet();
virtual PassRefPtr<DocumentParser> createParser();
DocumentParser* parser() const { return m_parser.get(); }
@@ -1257,7 +1257,6 @@
bool m_hasNodesWithPlaceholderStyle;
RefPtr<CSSStyleSheet> m_elemSheet;
- RefPtr<CSSStyleSheet> m_mappedElementSheet;
RefPtr<CSSStyleSheet> m_pageUserSheet;
mutable OwnPtr<Vector<RefPtr<CSSStyleSheet> > > m_pageGroupUserSheets;
OwnPtr<Vector<RefPtr<CSSStyleSheet> > > m_userSheets;
Modified: trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp (112257 => 112258)
--- trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp 2012-03-27 12:32:06 UTC (rev 112257)
+++ trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp 2012-03-27 12:40:38 UTC (rev 112258)
@@ -50,6 +50,8 @@
SVGDocumentExtensions::~SVGDocumentExtensions()
{
+ ASSERT(m_svgFontFaceElements.isEmpty());
+
deleteAllValues(m_animatedElements);
deleteAllValues(m_pendingResources);
deleteAllValues(m_pendingResourcesForRemoval);
@@ -418,6 +420,19 @@
(*vectorIt)->svgAttributeChanged(XLinkNames::hrefAttr);
}
+#if ENABLE(SVG_FONTS)
+void SVGDocumentExtensions::registerSVGFontFaceElement(SVGFontFaceElement* element)
+{
+ m_svgFontFaceElements.add(element);
}
+void SVGDocumentExtensions::unregisterSVGFontFaceElement(SVGFontFaceElement* element)
+{
+ ASSERT(m_svgFontFaceElements.contains(element));
+ m_svgFontFaceElements.remove(element);
+}
#endif
+
+}
+
+#endif
Modified: trunk/Source/WebCore/svg/SVGDocumentExtensions.h (112257 => 112258)
--- trunk/Source/WebCore/svg/SVGDocumentExtensions.h 2012-03-27 12:32:06 UTC (rev 112257)
+++ trunk/Source/WebCore/svg/SVGDocumentExtensions.h 2012-03-27 12:40:38 UTC (rev 112258)
@@ -34,6 +34,9 @@
class Document;
class RenderSVGResourceContainer;
class SVGElement;
+#if ENABLE(SVG_FONTS)
+class SVGFontFaceElement;
+#endif
class SVGResourcesCache;
class SVGSMILElement;
class SVGSVGElement;
@@ -72,10 +75,19 @@
void removeAllTargetReferencesForElement(SVGElement* referencingElement);
void removeAllElementReferencesForTarget(SVGElement* referencedElement);
+#if ENABLE(SVG_FONTS)
+ const HashSet<SVGFontFaceElement*>& svgFontFaceElements() const { return m_svgFontFaceElements; }
+ void registerSVGFontFaceElement(SVGFontFaceElement*);
+ void unregisterSVGFontFaceElement(SVGFontFaceElement*);
+#endif
+
private:
Document* m_document; // weak reference
HashSet<SVGSVGElement*> m_timeContainers; // For SVG 1.2 support this will need to be made more general.
HashMap<SVGElement*, HashSet<SVGSMILElement*>* > m_animatedElements;
+#if ENABLE(SVG_FONTS)
+ HashSet<SVGFontFaceElement*> m_svgFontFaceElements;
+#endif
HashMap<AtomicString, RenderSVGResourceContainer*> m_resources;
HashMap<AtomicString, SVGPendingElements*> m_pendingResources; // Resources that are pending.
HashMap<AtomicString, SVGPendingElements*> m_pendingResourcesForRemoval; // Resources that are pending and scheduled for removal.
Modified: trunk/Source/WebCore/svg/SVGFontFaceElement.cpp (112257 => 112258)
--- trunk/Source/WebCore/svg/SVGFontFaceElement.cpp 2012-03-27 12:32:06 UTC (rev 112257)
+++ trunk/Source/WebCore/svg/SVGFontFaceElement.cpp 2012-03-27 12:40:38 UTC (rev 112258)
@@ -36,6 +36,7 @@
#include "CSSValueList.h"
#include "Document.h"
#include "Font.h"
+#include "SVGDocumentExtensions.h"
#include "SVGFontElement.h"
#include "SVGFontFaceSrcElement.h"
#include "SVGGlyphElement.h"
@@ -318,16 +319,21 @@
void SVGFontFaceElement::insertedIntoDocument()
{
SVGElement::insertedIntoDocument();
- document()->mappedElementSheet()->append(m_fontFaceRule);
- m_fontFaceRule->setParentStyleSheet(document()->mappedElementSheet());
+
+ document()->accessSVGExtensions()->registerSVGFontFaceElement(this);
+ m_fontFaceRule->setParentStyleSheet(document()->elementSheet());
+
rebuildFontFace();
}
void SVGFontFaceElement::removedFromDocument()
{
- removeFromMappedElementSheet();
SVGElement::removedFromDocument();
+
+ document()->accessSVGExtensions()->unregisterSVGFontFaceElement(this);
m_fontFaceRule->declaration()->parseDeclaration(emptyString(), 0);
+
+ document()->styleSelectorChanged(DeferRecalcStyle);
}
void SVGFontFaceElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
@@ -336,21 +342,6 @@
rebuildFontFace();
}
-void SVGFontFaceElement::removeFromMappedElementSheet()
-{
- CSSStyleSheet* mappedElementSheet = document()->mappedElementSheet();
- if (!mappedElementSheet)
- return;
-
- for (unsigned i = 0; i < mappedElementSheet->length(); ++i) {
- if (mappedElementSheet->item(i) == m_fontFaceRule) {
- mappedElementSheet->remove(i);
- break;
- }
- }
- document()->styleSelectorChanged(DeferRecalcStyle);
-}
-
} // namespace WebCore
#endif // ENABLE(SVG_FONTS)
Modified: trunk/Source/WebCore/svg/SVGFontFaceElement.h (112257 => 112258)
--- trunk/Source/WebCore/svg/SVGFontFaceElement.h 2012-03-27 12:32:06 UTC (rev 112257)
+++ trunk/Source/WebCore/svg/SVGFontFaceElement.h 2012-03-27 12:40:38 UTC (rev 112258)
@@ -48,7 +48,8 @@
SVGFontElement* associatedFontElement() const;
void rebuildFontFace();
- void removeFromMappedElementSheet();
+
+ CSSFontFaceRule* fontFaceRule() const { return m_fontFaceRule.get(); }
private:
SVGFontFaceElement(const QualifiedName&, Document*);