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(
cssSheet->setDisabled(m_alternate);
cssSheet->setTitle(m_title);
if (!m_alternate && !m_title.isEmpty())
document().styleEngine().setPreferredStylesheetSetNameIfNotSet(
m_title, StyleEngine::DontUpdateActiveSheets);
document().styleEngine().setPreferredStylesheetSetNameIfNotSet(m_title);
cssSheet->setMediaQueries(MediaQuerySet::create(m_media));
m_sheet = cssSheet;
......
......@@ -552,8 +552,7 @@ CSSStyleSheet* StyleEngine::createSheet(Element& element,
DCHECK(styleSheet);
if (!element.isInShadowTree()) {
styleSheet->setTitle(element.title());
setPreferredStylesheetSetNameIfNotSet(element.title(),
DontUpdateActiveSheets);
setPreferredStylesheetSetNameIfNotSet(element.title());
}
return styleSheet;
}
......@@ -901,9 +900,7 @@ void StyleEngine::setStatsEnabled(bool enabled) {
m_styleResolverStats->reset();
}
void StyleEngine::setPreferredStylesheetSetNameIfNotSet(
const String& name,
ActiveSheetsUpdate activeSheetsUpdate) {
void StyleEngine::setPreferredStylesheetSetNameIfNotSet(const String& name) {
if (!m_preferredStylesheetSetName.isEmpty())
return;
m_preferredStylesheetSetName = name;
......@@ -913,14 +910,7 @@ void StyleEngine::setPreferredStylesheetSetNameIfNotSet(
// and either only collects persistent style, or additionally preferred
// style when present.
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();
resolverChanged(AnalyzedStyleUpdate);
}
markDocumentDirty();
}
void StyleEngine::setSelectedStylesheetSetName(const String& name) {
......@@ -933,7 +923,7 @@ void StyleEngine::setSelectedStylesheetSetName(const String& name) {
}
void StyleEngine::setHttpDefaultStyle(const String& content) {
setPreferredStylesheetSetNameIfNotSet(content, UpdateActiveSheets);
setPreferredStylesheetSetNameIfNotSet(content);
}
void StyleEngine::ensureUAStyleForFullscreen() {
......
......@@ -124,14 +124,13 @@ class CORE_EXPORT StyleEngine final
void updateActiveStyle();
void markAllTreeScopesDirty() { m_allTreeScopesDirty = true; }
enum ActiveSheetsUpdate { DontUpdateActiveSheets, UpdateActiveSheets };
String preferredStylesheetSetName() const {
return m_preferredStylesheetSetName;
}
String selectedStylesheetSetName() const {
return m_selectedStylesheetSetName;
}
void setPreferredStylesheetSetNameIfNotSet(const String&, ActiveSheetsUpdate);
void setPreferredStylesheetSetNameIfNotSet(const String&);
void setSelectedStylesheetSetName(const String&);
void setHttpDefaultStyle(const String&);
......
......@@ -99,7 +99,7 @@ void HTMLLinkElement::parseAttribute(const QualifiedName& name,
} else {
if (name == titleAttr) {
if (LinkStyle* link = linkStyle())
link->setSheetTitle(value, StyleEngine::UpdateActiveSheets);
link->setSheetTitle(value);
}
HTMLElement::parseAttribute(name, oldValue, value);
......
......@@ -307,8 +307,7 @@ LinkStyle::LoadReturnValue LinkStyle::loadStylesheetIfNeeded(
String title = m_owner->title();
if (!title.isEmpty() && !m_owner->isAlternate() &&
m_disabledState != EnabledViaScript && m_owner->isInDocumentTree()) {
document().styleEngine().setPreferredStylesheetSetNameIfNotSet(
title, StyleEngine::DontUpdateActiveSheets);
document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title);
}
bool mediaQueryMatches = true;
......@@ -396,9 +395,7 @@ void LinkStyle::process() {
}
}
void LinkStyle::setSheetTitle(
const String& title,
StyleEngine::ActiveSheetsUpdate updateActiveSheets) {
void LinkStyle::setSheetTitle(const String& title) {
if (!m_owner->isInDocumentTree() || !m_owner->relAttribute().isStyleSheet())
return;
......@@ -409,10 +406,8 @@ void LinkStyle::setSheetTitle(
return;
const KURL& href = m_owner->getNonEmptyURLAttribute(hrefAttr);
if (href.isValid() && !href.isEmpty()) {
document().styleEngine().setPreferredStylesheetSetNameIfNotSet(
title, updateActiveSheets);
}
if (href.isValid() && !href.isEmpty())
document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title);
}
void LinkStyle::ownerRemoved() {
......
......@@ -45,9 +45,7 @@ class LinkStyle final : public LinkResource, ResourceOwner<StyleSheetResource> {
bool sheetLoaded();
void setDisabledState(bool);
void setSheetTitle(
const String&,
StyleEngine::ActiveSheetsUpdate = StyleEngine::DontUpdateActiveSheets);
void setSheetTitle(const String&);
bool styleSheetIsLoading() const;
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