| 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 r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 DCHECK(contents); | 524 DCHECK(contents); |
| 525 DCHECK(contents->isCacheableForStyleElement()); | 525 DCHECK(contents->isCacheableForStyleElement()); |
| 526 DCHECK(contents->hasSingleOwnerDocument()); | 526 DCHECK(contents->hasSingleOwnerDocument()); |
| 527 contents->setIsUsedFromTextCache(); | 527 contents->setIsUsedFromTextCache(); |
| 528 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition); | 528 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition); |
| 529 } | 529 } |
| 530 | 530 |
| 531 DCHECK(styleSheet); | 531 DCHECK(styleSheet); |
| 532 if (!e->isInShadowTree()) { | 532 if (!e->isInShadowTree()) { |
| 533 styleSheet->setTitle(e->title()); | 533 styleSheet->setTitle(e->title()); |
| 534 setPreferredStylesheetSetNameIfNotSet(e->title()); | 534 setPreferredStylesheetSetNameIfNotSet(e->title(), DontUpdateActiveSheets
); |
| 535 } | 535 } |
| 536 return styleSheet; | 536 return styleSheet; |
| 537 } | 537 } |
| 538 | 538 |
| 539 CSSStyleSheet* StyleEngine::parseSheet(Element* e, const String& text, TextPosit
ion startPosition) | 539 CSSStyleSheet* StyleEngine::parseSheet(Element* e, const String& text, TextPosit
ion startPosition) |
| 540 { | 540 { |
| 541 CSSStyleSheet* styleSheet = nullptr; | 541 CSSStyleSheet* styleSheet = nullptr; |
| 542 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume
nt().characterSet()); | 542 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume
nt().characterSet()); |
| 543 styleSheet->contents()->parseStringAtPosition(text, startPosition); | 543 styleSheet->contents()->parseStringAtPosition(text, startPosition); |
| 544 return styleSheet; | 544 return styleSheet; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 if (!enabled) { | 752 if (!enabled) { |
| 753 m_styleResolverStats = nullptr; | 753 m_styleResolverStats = nullptr; |
| 754 return; | 754 return; |
| 755 } | 755 } |
| 756 if (!m_styleResolverStats) | 756 if (!m_styleResolverStats) |
| 757 m_styleResolverStats = StyleResolverStats::create(); | 757 m_styleResolverStats = StyleResolverStats::create(); |
| 758 else | 758 else |
| 759 m_styleResolverStats->reset(); | 759 m_styleResolverStats->reset(); |
| 760 } | 760 } |
| 761 | 761 |
| 762 void StyleEngine::setPreferredStylesheetSetNameIfNotSet(const String& name) | 762 void StyleEngine::setPreferredStylesheetSetNameIfNotSet(const String& name, Acti
veSheetsUpdate activeSheetsUpdate) |
| 763 { | 763 { |
| 764 if (!m_preferredStylesheetSetName.isEmpty()) | 764 if (!m_preferredStylesheetSetName.isEmpty()) |
| 765 return; | 765 return; |
| 766 m_preferredStylesheetSetName = name; | 766 m_preferredStylesheetSetName = name; |
| 767 // TODO(rune@opera.com): Setting the selected set here is wrong if the set | 767 // TODO(rune@opera.com): Setting the selected set here is wrong if the set |
| 768 // has been previously set by through Document.selectedStylesheetSet. Our | 768 // has been previously set by through Document.selectedStylesheetSet. Our |
| 769 // current implementation ignores the effect of Document.selectedStylesheetS
et | 769 // current implementation ignores the effect of Document.selectedStylesheetS
et |
| 770 // and either only collects persistent style, or additionally preferred | 770 // and either only collects persistent style, or additionally preferred |
| 771 // style when present. We are currently not marking the document scope dirty | 771 // style when present. |
| 772 // because preferred style is updated during active stylesheet update which | |
| 773 // would make this method re-entrant. Will need to change for async update. | |
| 774 m_selectedStylesheetSetName = name; | 772 m_selectedStylesheetSetName = name; |
| 773 |
| 774 // TODO(rune@opera.com): For async stylesheet update, we should always mark |
| 775 // the TreeScope dirty here, and the synchronous active stylesheet update |
| 776 // (resolverChanged) should go away. |
| 777 if (activeSheetsUpdate == UpdateActiveSheets) { |
| 778 markDocumentDirty(); |
| 779 resolverChanged(AnalyzedStyleUpdate); |
| 780 } |
| 775 } | 781 } |
| 776 | 782 |
| 777 void StyleEngine::setSelectedStylesheetSetName(const String& name) | 783 void StyleEngine::setSelectedStylesheetSetName(const String& name) |
| 778 { | 784 { |
| 779 m_selectedStylesheetSetName = name; | 785 m_selectedStylesheetSetName = name; |
| 780 // TODO(rune@opera.com): Setting Document.selectedStylesheetSet currently | 786 // TODO(rune@opera.com): Setting Document.selectedStylesheetSet currently |
| 781 // has no other effect than the ability to read back the set value using | 787 // has no other effect than the ability to read back the set value using |
| 782 // the same api. If it did have an effect, we should have marked the | 788 // the same api. If it did have an effect, we should have marked the |
| 783 // document scope dirty and triggered an update of the active stylesheets | 789 // document scope dirty and triggered an update of the active stylesheets |
| 784 // from here. | 790 // from here. |
| 785 } | 791 } |
| 786 | 792 |
| 787 void StyleEngine::setHttpDefaultStyle(const String& content) | 793 void StyleEngine::setHttpDefaultStyle(const String& content) |
| 788 { | 794 { |
| 789 setPreferredStylesheetSetNameIfNotSet(content); | 795 setPreferredStylesheetSetNameIfNotSet(content, UpdateActiveSheets); |
| 790 markDocumentDirty(); | |
| 791 resolverChanged(FullStyleUpdate); | |
| 792 } | 796 } |
| 793 | 797 |
| 794 void StyleEngine::ensureFullscreenUAStyle() | 798 void StyleEngine::ensureFullscreenUAStyle() |
| 795 { | 799 { |
| 796 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetForFullscreen(); | 800 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetForFullscreen(); |
| 797 if (!m_resolver) | 801 if (!m_resolver) |
| 798 return; | 802 return; |
| 799 if (!m_resolver->hasFullscreenUAStyle()) | 803 if (!m_resolver->hasFullscreenUAStyle()) |
| 800 m_resolver->resetRuleFeatures(); | 804 m_resolver->resetRuleFeatures(); |
| 801 } | 805 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 829 | 833 |
| 830 DEFINE_TRACE_WRAPPERS(StyleEngine) | 834 DEFINE_TRACE_WRAPPERS(StyleEngine) |
| 831 { | 835 { |
| 832 for (auto sheet : m_injectedAuthorStyleSheets) { | 836 for (auto sheet : m_injectedAuthorStyleSheets) { |
| 833 visitor->traceWrappers(sheet); | 837 visitor->traceWrappers(sheet); |
| 834 } | 838 } |
| 835 visitor->traceWrappers(m_documentStyleSheetCollection); | 839 visitor->traceWrappers(m_documentStyleSheetCollection); |
| 836 } | 840 } |
| 837 | 841 |
| 838 } // namespace blink | 842 } // namespace blink |
| OLD | NEW |