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

Unified Diff: Source/core/dom/StyleEngine.cpp

Issue 257363002: Added addXSLStyleSheet and removeXSLStyleSheet to StyleEngine. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months 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
« Source/core/dom/StyleEngine.h ('K') | « Source/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/StyleEngine.cpp
diff --git a/Source/core/dom/StyleEngine.cpp b/Source/core/dom/StyleEngine.cpp
index 95ad29c10c4b9ba51d77e1d5a8396d3944139ce7..fceaab9afa1536587b0f9d86540d7b20811333c6 100644
--- a/Source/core/dom/StyleEngine.cpp
+++ b/Source/core/dom/StyleEngine.cpp
@@ -71,6 +71,7 @@ StyleEngine::StyleEngine(Document& document)
// We don't need to create CSSFontSelector for imported document or
// HTMLTemplateElement's document, because those documents have no frame.
, m_fontSelector(document.frame() ? CSSFontSelector::create(&document) : nullptr)
+ , m_xslStyleSheet(0)
{
}
@@ -286,7 +287,7 @@ void StyleEngine::addStyleSheetCandidateNode(Node* node, bool createdByParser)
TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : m_document;
ASSERT(isHTMLStyleElement(node) || treeScope == m_document);
-
+ ASSERT(!isXSLStyleSheet(node));
TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(treeScope);
ASSERT(collection);
collection->addStyleSheetCandidateNode(node, createdByParser);
@@ -304,6 +305,7 @@ void StyleEngine::removeStyleSheetCandidateNode(Node* node)
void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopingNode, TreeScope& treeScope)
{
ASSERT(isHTMLStyleElement(node) || treeScope == m_document);
+ ASSERT(!isXSLStyleSheet(node));
TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScope);
ASSERT(collection);
@@ -313,6 +315,37 @@ void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopi
m_activeTreeScopes.remove(&treeScope);
}
+void StyleEngine::addXSLStyleSheet(Node* node, bool createdByParser)
esprehn 2014/05/22 18:32:20 This should just take a ProcessingInstruction*
tasak 2014/05/27 06:17:30 Done.
+{
+ if (!node->inDocument())
+ return;
+
+ ASSERT(isXSLStyleSheet(node));
+ bool needToUpdate = false;
+ if (createdByParser || !m_xslStyleSheet) {
+ needToUpdate = !m_xslStyleSheet;
+ } else {
+ unsigned position = m_xslStyleSheet->compareDocumentPositionInternal(node, Node::TreatShadowTreesAsDisconnected);
+ needToUpdate = position & Node::DOCUMENT_POSITION_FOLLOWING;
+ }
+
+ if (!needToUpdate)
+ return;
+
+ markTreeScopeDirty(m_document);
+ m_xslStyleSheet = toProcessingInstruction(node);
+}
+
+void StyleEngine::removeXSLStyleSheet(Node* node)
esprehn 2014/05/22 18:32:20 ditto
tasak 2014/05/27 06:17:30 Done.
+{
+ ASSERT(isXSLStyleSheet(node));
+ if (m_xslStyleSheet != node)
+ return;
+
+ markTreeScopeDirty(m_document);
+ m_xslStyleSheet = 0;
+}
+
void StyleEngine::modifiedStyleSheetCandidateNode(Node* node)
{
if (!node->inDocument())
@@ -488,6 +521,11 @@ bool StyleEngine::shouldClearResolver() const
return !m_didCalculateResolver && !haveStylesheetsLoaded();
}
+bool StyleEngine::shouldApplyXSLTransform() const
+{
+ return m_xslStyleSheet && RuntimeEnabledFeatures::xsltEnabled() && !m_document.transformSourceDocument();
esprehn 2014/05/22 18:32:20 Early return on the runtime enabled feature. if (
tasak 2014/05/27 06:17:30 Done.
+}
+
StyleResolverChange StyleEngine::resolverChanged(RecalcStyleTime time, StyleResolverUpdateMode mode)
{
StyleResolverChange change;
@@ -505,6 +543,15 @@ StyleResolverChange StyleEngine::resolverChanged(RecalcStyleTime time, StyleReso
return change;
}
+ if (shouldApplyXSLTransform()) {
+ // Processing instruction (XML documents only).
+ // We don't support linking to embedded CSS stylesheets, see <https://bugs.webkit.org/show_bug.cgi?id=49281> for discussion.
+ // Don't apply XSL transforms to already transformed documents -- <rdar://problem/4132806>
+ if (!m_document.parsing() && !m_xslStyleSheet->isLoading())
+ m_document.applyXSLTransform(m_xslStyleSheet);
+ return change;
+ }
+
m_didCalculateResolver = true;
if (m_document.didLayoutWithPendingStylesheets() && !hasPendingSheets())
change.setNeedsRepaint();
« Source/core/dom/StyleEngine.h ('K') | « Source/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698