| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All |
| 7 * rights reserved. | 7 * rights reserved. |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 DCHECK(contents); | 547 DCHECK(contents); |
| 548 DCHECK(contents->isCacheableForStyleElement()); | 548 DCHECK(contents->isCacheableForStyleElement()); |
| 549 DCHECK(contents->hasSingleOwnerDocument()); | 549 DCHECK(contents->hasSingleOwnerDocument()); |
| 550 contents->setIsUsedFromTextCache(); | 550 contents->setIsUsedFromTextCache(); |
| 551 styleSheet = CSSStyleSheet::createInline(contents, element, startPosition); | 551 styleSheet = CSSStyleSheet::createInline(contents, element, startPosition); |
| 552 } | 552 } |
| 553 | 553 |
| 554 DCHECK(styleSheet); | 554 DCHECK(styleSheet); |
| 555 if (!element.isInShadowTree()) { | 555 if (!element.isInShadowTree()) { |
| 556 styleSheet->setTitle(element.title()); | 556 styleSheet->setTitle(element.title()); |
| 557 setPreferredStylesheetSetNameIfNotSet(element.title(), | 557 setPreferredStylesheetSetNameIfNotSet(element.title()); |
| 558 DontUpdateActiveSheets); | |
| 559 } | 558 } |
| 560 return styleSheet; | 559 return styleSheet; |
| 561 } | 560 } |
| 562 | 561 |
| 563 CSSStyleSheet* StyleEngine::parseSheet(Element& element, | 562 CSSStyleSheet* StyleEngine::parseSheet(Element& element, |
| 564 const String& text, | 563 const String& text, |
| 565 TextPosition startPosition) { | 564 TextPosition startPosition) { |
| 566 CSSStyleSheet* styleSheet = nullptr; | 565 CSSStyleSheet* styleSheet = nullptr; |
| 567 styleSheet = CSSStyleSheet::createInline(element, KURL(), startPosition, | 566 styleSheet = CSSStyleSheet::createInline(element, KURL(), startPosition, |
| 568 document().characterSet()); | 567 document().characterSet()); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 if (!enabled) { | 916 if (!enabled) { |
| 918 m_styleResolverStats = nullptr; | 917 m_styleResolverStats = nullptr; |
| 919 return; | 918 return; |
| 920 } | 919 } |
| 921 if (!m_styleResolverStats) | 920 if (!m_styleResolverStats) |
| 922 m_styleResolverStats = StyleResolverStats::create(); | 921 m_styleResolverStats = StyleResolverStats::create(); |
| 923 else | 922 else |
| 924 m_styleResolverStats->reset(); | 923 m_styleResolverStats->reset(); |
| 925 } | 924 } |
| 926 | 925 |
| 927 void StyleEngine::setPreferredStylesheetSetNameIfNotSet( | 926 void StyleEngine::setPreferredStylesheetSetNameIfNotSet(const String& name) { |
| 928 const String& name, | |
| 929 ActiveSheetsUpdate activeSheetsUpdate) { | |
| 930 if (!m_preferredStylesheetSetName.isEmpty()) | 927 if (!m_preferredStylesheetSetName.isEmpty()) |
| 931 return; | 928 return; |
| 932 m_preferredStylesheetSetName = name; | 929 m_preferredStylesheetSetName = name; |
| 933 // TODO(rune@opera.com): Setting the selected set here is wrong if the set | 930 // TODO(rune@opera.com): Setting the selected set here is wrong if the set |
| 934 // has been previously set by through Document.selectedStylesheetSet. Our | 931 // has been previously set by through Document.selectedStylesheetSet. Our |
| 935 // current implementation ignores the effect of Document.selectedStylesheetSet | 932 // current implementation ignores the effect of Document.selectedStylesheetSet |
| 936 // and either only collects persistent style, or additionally preferred | 933 // and either only collects persistent style, or additionally preferred |
| 937 // style when present. | 934 // style when present. |
| 938 m_selectedStylesheetSetName = name; | 935 m_selectedStylesheetSetName = name; |
| 939 | 936 markDocumentDirty(); |
| 940 // TODO(rune@opera.com): For async stylesheet update, we should always mark | |
| 941 // the TreeScope dirty here, and the synchronous active stylesheet update | |
| 942 // (resolverChanged) should go away. | |
| 943 if (activeSheetsUpdate == UpdateActiveSheets) { | |
| 944 markDocumentDirty(); | |
| 945 resolverChanged(AnalyzedStyleUpdate); | |
| 946 } | |
| 947 } | 937 } |
| 948 | 938 |
| 949 void StyleEngine::setSelectedStylesheetSetName(const String& name) { | 939 void StyleEngine::setSelectedStylesheetSetName(const String& name) { |
| 950 m_selectedStylesheetSetName = name; | 940 m_selectedStylesheetSetName = name; |
| 951 // TODO(rune@opera.com): Setting Document.selectedStylesheetSet currently | 941 // TODO(rune@opera.com): Setting Document.selectedStylesheetSet currently |
| 952 // has no other effect than the ability to read back the set value using | 942 // has no other effect than the ability to read back the set value using |
| 953 // the same api. If it did have an effect, we should have marked the | 943 // the same api. If it did have an effect, we should have marked the |
| 954 // document scope dirty and triggered an update of the active stylesheets | 944 // document scope dirty and triggered an update of the active stylesheets |
| 955 // from here. | 945 // from here. |
| 956 } | 946 } |
| 957 | 947 |
| 958 void StyleEngine::setHttpDefaultStyle(const String& content) { | 948 void StyleEngine::setHttpDefaultStyle(const String& content) { |
| 959 setPreferredStylesheetSetNameIfNotSet(content, UpdateActiveSheets); | 949 setPreferredStylesheetSetNameIfNotSet(content); |
| 960 } | 950 } |
| 961 | 951 |
| 962 void StyleEngine::ensureUAStyleForFullscreen() { | 952 void StyleEngine::ensureUAStyleForFullscreen() { |
| 963 if (m_globalRuleSet.hasFullscreenUAStyle()) | 953 if (m_globalRuleSet.hasFullscreenUAStyle()) |
| 964 return; | 954 return; |
| 965 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetForFullscreen(); | 955 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetForFullscreen(); |
| 966 m_globalRuleSet.markDirty(); | 956 m_globalRuleSet.markDirty(); |
| 967 m_globalRuleSet.update(document()); | 957 m_globalRuleSet.update(document()); |
| 968 } | 958 } |
| 969 | 959 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 } | 1167 } |
| 1178 | 1168 |
| 1179 DEFINE_TRACE_WRAPPERS(StyleEngine) { | 1169 DEFINE_TRACE_WRAPPERS(StyleEngine) { |
| 1180 for (auto sheet : m_injectedAuthorStyleSheets) { | 1170 for (auto sheet : m_injectedAuthorStyleSheets) { |
| 1181 visitor->traceWrappers(sheet); | 1171 visitor->traceWrappers(sheet); |
| 1182 } | 1172 } |
| 1183 visitor->traceWrappers(m_documentStyleSheetCollection); | 1173 visitor->traceWrappers(m_documentStyleSheetCollection); |
| 1184 } | 1174 } |
| 1185 | 1175 |
| 1186 } // namespace blink | 1176 } // namespace blink |
| OLD | NEW |