Commit 626379c7 authored by rune's avatar rune Committed by Commit bot

Setting preferred stylesheet simplified.

With active stylesheets being applied asynchronously, we no longer need
to avoid the synchronous stylesheet update during link processing. We
can just mark the treeScope dirty to trigger the preferred set to be
updated as part of updateActiveStyleSheets().

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2552353003
Cr-Commit-Position: refs/heads/master@{#439115}
parent c9b1073f
...@@ -204,8 +204,7 @@ void ProcessingInstruction::setCSSStyleSheet( ...@@ -204,8 +204,7 @@ void ProcessingInstruction::setCSSStyleSheet(
cssSheet->setDisabled(m_alternate); cssSheet->setDisabled(m_alternate);
cssSheet->setTitle(m_title); cssSheet->setTitle(m_title);
if (!m_alternate && !m_title.isEmpty()) if (!m_alternate && !m_title.isEmpty())
document().styleEngine().setPreferredStylesheetSetNameIfNotSet( document().styleEngine().setPreferredStylesheetSetNameIfNotSet(m_title);
m_title, StyleEngine::DontUpdateActiveSheets);
cssSheet->setMediaQueries(MediaQuerySet::create(m_media)); cssSheet->setMediaQueries(MediaQuerySet::create(m_media));
m_sheet = cssSheet; m_sheet = cssSheet;
......
...@@ -552,8 +552,7 @@ CSSStyleSheet* StyleEngine::createSheet(Element& element, ...@@ -552,8 +552,7 @@ CSSStyleSheet* StyleEngine::createSheet(Element& element,
DCHECK(styleSheet); DCHECK(styleSheet);
if (!element.isInShadowTree()) { if (!element.isInShadowTree()) {
styleSheet->setTitle(element.title()); styleSheet->setTitle(element.title());
setPreferredStylesheetSetNameIfNotSet(element.title(), setPreferredStylesheetSetNameIfNotSet(element.title());
DontUpdateActiveSheets);
} }
return styleSheet; return styleSheet;
} }
...@@ -901,9 +900,7 @@ void StyleEngine::setStatsEnabled(bool enabled) { ...@@ -901,9 +900,7 @@ void StyleEngine::setStatsEnabled(bool enabled) {
m_styleResolverStats->reset(); m_styleResolverStats->reset();
} }
void StyleEngine::setPreferredStylesheetSetNameIfNotSet( void StyleEngine::setPreferredStylesheetSetNameIfNotSet(const String& name) {
const String& name,
ActiveSheetsUpdate activeSheetsUpdate) {
if (!m_preferredStylesheetSetName.isEmpty()) if (!m_preferredStylesheetSetName.isEmpty())
return; return;
m_preferredStylesheetSetName = name; m_preferredStylesheetSetName = name;
...@@ -913,14 +910,7 @@ void StyleEngine::setPreferredStylesheetSetNameIfNotSet( ...@@ -913,14 +910,7 @@ void StyleEngine::setPreferredStylesheetSetNameIfNotSet(
// and either only collects persistent style, or additionally preferred // and either only collects persistent style, or additionally preferred
// style when present. // style when present.
m_selectedStylesheetSetName = name; m_selectedStylesheetSetName = name;
// TODO(rune@opera.com): For async stylesheet update, we should always mark
// the TreeScope dirty here, and the synchronous active stylesheet update
// (resolverChanged) should go away.
if (activeSheetsUpdate == UpdateActiveSheets) {
markDocumentDirty(); markDocumentDirty();
resolverChanged(AnalyzedStyleUpdate);
}
} }
void StyleEngine::setSelectedStylesheetSetName(const String& name) { void StyleEngine::setSelectedStylesheetSetName(const String& name) {
...@@ -933,7 +923,7 @@ void StyleEngine::setSelectedStylesheetSetName(const String& name) { ...@@ -933,7 +923,7 @@ void StyleEngine::setSelectedStylesheetSetName(const String& name) {
} }
void StyleEngine::setHttpDefaultStyle(const String& content) { void StyleEngine::setHttpDefaultStyle(const String& content) {
setPreferredStylesheetSetNameIfNotSet(content, UpdateActiveSheets); setPreferredStylesheetSetNameIfNotSet(content);
} }
void StyleEngine::ensureUAStyleForFullscreen() { void StyleEngine::ensureUAStyleForFullscreen() {
......
...@@ -124,14 +124,13 @@ class CORE_EXPORT StyleEngine final ...@@ -124,14 +124,13 @@ class CORE_EXPORT StyleEngine final
void updateActiveStyle(); void updateActiveStyle();
void markAllTreeScopesDirty() { m_allTreeScopesDirty = true; } void markAllTreeScopesDirty() { m_allTreeScopesDirty = true; }
enum ActiveSheetsUpdate { DontUpdateActiveSheets, UpdateActiveSheets };
String preferredStylesheetSetName() const { String preferredStylesheetSetName() const {
return m_preferredStylesheetSetName; return m_preferredStylesheetSetName;
} }
String selectedStylesheetSetName() const { String selectedStylesheetSetName() const {
return m_selectedStylesheetSetName; return m_selectedStylesheetSetName;
} }
void setPreferredStylesheetSetNameIfNotSet(const String&, ActiveSheetsUpdate); void setPreferredStylesheetSetNameIfNotSet(const String&);
void setSelectedStylesheetSetName(const String&); void setSelectedStylesheetSetName(const String&);
void setHttpDefaultStyle(const String&); void setHttpDefaultStyle(const String&);
......
...@@ -99,7 +99,7 @@ void HTMLLinkElement::parseAttribute(const QualifiedName& name, ...@@ -99,7 +99,7 @@ void HTMLLinkElement::parseAttribute(const QualifiedName& name,
} else { } else {
if (name == titleAttr) { if (name == titleAttr) {
if (LinkStyle* link = linkStyle()) if (LinkStyle* link = linkStyle())
link->setSheetTitle(value, StyleEngine::UpdateActiveSheets); link->setSheetTitle(value);
} }
HTMLElement::parseAttribute(name, oldValue, value); HTMLElement::parseAttribute(name, oldValue, value);
......
...@@ -307,8 +307,7 @@ LinkStyle::LoadReturnValue LinkStyle::loadStylesheetIfNeeded( ...@@ -307,8 +307,7 @@ LinkStyle::LoadReturnValue LinkStyle::loadStylesheetIfNeeded(
String title = m_owner->title(); String title = m_owner->title();
if (!title.isEmpty() && !m_owner->isAlternate() && if (!title.isEmpty() && !m_owner->isAlternate() &&
m_disabledState != EnabledViaScript && m_owner->isInDocumentTree()) { m_disabledState != EnabledViaScript && m_owner->isInDocumentTree()) {
document().styleEngine().setPreferredStylesheetSetNameIfNotSet( document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title);
title, StyleEngine::DontUpdateActiveSheets);
} }
bool mediaQueryMatches = true; bool mediaQueryMatches = true;
...@@ -396,9 +395,7 @@ void LinkStyle::process() { ...@@ -396,9 +395,7 @@ void LinkStyle::process() {
} }
} }
void LinkStyle::setSheetTitle( void LinkStyle::setSheetTitle(const String& title) {
const String& title,
StyleEngine::ActiveSheetsUpdate updateActiveSheets) {
if (!m_owner->isInDocumentTree() || !m_owner->relAttribute().isStyleSheet()) if (!m_owner->isInDocumentTree() || !m_owner->relAttribute().isStyleSheet())
return; return;
...@@ -409,10 +406,8 @@ void LinkStyle::setSheetTitle( ...@@ -409,10 +406,8 @@ void LinkStyle::setSheetTitle(
return; return;
const KURL& href = m_owner->getNonEmptyURLAttribute(hrefAttr); const KURL& href = m_owner->getNonEmptyURLAttribute(hrefAttr);
if (href.isValid() && !href.isEmpty()) { if (href.isValid() && !href.isEmpty())
document().styleEngine().setPreferredStylesheetSetNameIfNotSet( document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title);
title, updateActiveSheets);
}
} }
void LinkStyle::ownerRemoved() { void LinkStyle::ownerRemoved() {
......
...@@ -45,9 +45,7 @@ class LinkStyle final : public LinkResource, ResourceOwner<StyleSheetResource> { ...@@ -45,9 +45,7 @@ class LinkStyle final : public LinkResource, ResourceOwner<StyleSheetResource> {
bool sheetLoaded(); bool sheetLoaded();
void setDisabledState(bool); void setDisabledState(bool);
void setSheetTitle( void setSheetTitle(const String&);
const String&,
StyleEngine::ActiveSheetsUpdate = StyleEngine::DontUpdateActiveSheets);
bool styleSheetIsLoading() const; bool styleSheetIsLoading() const;
bool hasSheet() const { return m_sheet; } bool hasSheet() const { return m_sheet; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment