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

Side by Side Diff: third_party/WebKit/Source/core/dom/StyleEngine.cpp

Issue 2337193004: Setting the link title may change the preferred set. (Closed)
Patch Set: Rebased Created 4 years, 3 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 unified diff | Download patch
OLDNEW
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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 DCHECK(contents); 526 DCHECK(contents);
527 DCHECK(contents->isCacheableForStyleElement()); 527 DCHECK(contents->isCacheableForStyleElement());
528 DCHECK(contents->hasSingleOwnerDocument()); 528 DCHECK(contents->hasSingleOwnerDocument());
529 contents->setIsUsedFromTextCache(); 529 contents->setIsUsedFromTextCache();
530 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition); 530 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition);
531 } 531 }
532 532
533 DCHECK(styleSheet); 533 DCHECK(styleSheet);
534 if (!e->isInShadowTree()) { 534 if (!e->isInShadowTree()) {
535 styleSheet->setTitle(e->title()); 535 styleSheet->setTitle(e->title());
536 setPreferredStylesheetSetNameIfNotSet(e->title()); 536 setPreferredStylesheetSetNameIfNotSet(e->title(), DontUpdateActiveSheets );
537 } 537 }
538 return styleSheet; 538 return styleSheet;
539 } 539 }
540 540
541 CSSStyleSheet* StyleEngine::parseSheet(Element* e, const String& text, TextPosit ion startPosition) 541 CSSStyleSheet* StyleEngine::parseSheet(Element* e, const String& text, TextPosit ion startPosition)
542 { 542 {
543 CSSStyleSheet* styleSheet = nullptr; 543 CSSStyleSheet* styleSheet = nullptr;
544 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume nt().characterSet()); 544 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume nt().characterSet());
545 styleSheet->contents()->parseStringAtPosition(text, startPosition); 545 styleSheet->contents()->parseStringAtPosition(text, startPosition);
546 return styleSheet; 546 return styleSheet;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 if (!enabled) { 754 if (!enabled) {
755 m_styleResolverStats = nullptr; 755 m_styleResolverStats = nullptr;
756 return; 756 return;
757 } 757 }
758 if (!m_styleResolverStats) 758 if (!m_styleResolverStats)
759 m_styleResolverStats = StyleResolverStats::create(); 759 m_styleResolverStats = StyleResolverStats::create();
760 else 760 else
761 m_styleResolverStats->reset(); 761 m_styleResolverStats->reset();
762 } 762 }
763 763
764 void StyleEngine::setPreferredStylesheetSetNameIfNotSet(const String& name) 764 void StyleEngine::setPreferredStylesheetSetNameIfNotSet(const String& name, Acti veSheetsUpdate activeSheetsUpdate)
765 { 765 {
766 if (!m_preferredStylesheetSetName.isEmpty()) 766 if (!m_preferredStylesheetSetName.isEmpty())
767 return; 767 return;
768 m_preferredStylesheetSetName = name; 768 m_preferredStylesheetSetName = name;
769 // TODO(rune@opera.com): Setting the selected set here is wrong if the set 769 // TODO(rune@opera.com): Setting the selected set here is wrong if the set
770 // has been previously set by through Document.selectedStylesheetSet. Our 770 // has been previously set by through Document.selectedStylesheetSet. Our
771 // current implementation ignores the effect of Document.selectedStylesheetS et 771 // current implementation ignores the effect of Document.selectedStylesheetS et
772 // and either only collects persistent style, or additionally preferred 772 // and either only collects persistent style, or additionally preferred
773 // style when present. We are currently not marking the document scope dirty 773 // style when present.
774 // because preferred style is updated during active stylesheet update which
775 // would make this method re-entrant. Will need to change for async update.
776 m_selectedStylesheetSetName = name; 774 m_selectedStylesheetSetName = name;
775
776 // TODO(rune@opera.com): For async stylesheet update, we should always mark
777 // the TreeScope dirty here, and the synchronous active stylesheet update
778 // (resolverChanged) should go away.
779 if (activeSheetsUpdate == UpdateActiveSheets) {
780 markDocumentDirty();
781 resolverChanged(AnalyzedStyleUpdate);
782 }
777 } 783 }
778 784
779 void StyleEngine::setSelectedStylesheetSetName(const String& name) 785 void StyleEngine::setSelectedStylesheetSetName(const String& name)
780 { 786 {
781 m_selectedStylesheetSetName = name; 787 m_selectedStylesheetSetName = name;
782 // TODO(rune@opera.com): Setting Document.selectedStylesheetSet currently 788 // TODO(rune@opera.com): Setting Document.selectedStylesheetSet currently
783 // has no other effect than the ability to read back the set value using 789 // has no other effect than the ability to read back the set value using
784 // the same api. If it did have an effect, we should have marked the 790 // the same api. If it did have an effect, we should have marked the
785 // document scope dirty and triggered an update of the active stylesheets 791 // document scope dirty and triggered an update of the active stylesheets
786 // from here. 792 // from here.
787 } 793 }
788 794
789 void StyleEngine::setHttpDefaultStyle(const String& content) 795 void StyleEngine::setHttpDefaultStyle(const String& content)
790 { 796 {
791 setPreferredStylesheetSetNameIfNotSet(content); 797 setPreferredStylesheetSetNameIfNotSet(content, UpdateActiveSheets);
792 markDocumentDirty();
793 resolverChanged(FullStyleUpdate);
794 } 798 }
795 799
796 void StyleEngine::ensureFullscreenUAStyle() 800 void StyleEngine::ensureFullscreenUAStyle()
797 { 801 {
798 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetForFullscreen(); 802 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetForFullscreen();
799 if (!m_resolver) 803 if (!m_resolver)
800 return; 804 return;
801 if (!m_resolver->hasFullscreenUAStyle()) 805 if (!m_resolver->hasFullscreenUAStyle())
802 m_resolver->resetRuleFeatures(); 806 m_resolver->resetRuleFeatures();
803 } 807 }
(...skipping 28 matching lines...) Expand all
832 836
833 DEFINE_TRACE_WRAPPERS(StyleEngine) 837 DEFINE_TRACE_WRAPPERS(StyleEngine)
834 { 838 {
835 for (auto sheet : m_injectedAuthorStyleSheets) { 839 for (auto sheet : m_injectedAuthorStyleSheets) {
836 visitor->traceWrappers(sheet); 840 visitor->traceWrappers(sheet);
837 } 841 }
838 visitor->traceWrappers(m_documentStyleSheetCollection); 842 visitor->traceWrappers(m_documentStyleSheetCollection);
839 } 843 }
840 844
841 } // namespace blink 845 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | third_party/WebKit/Source/core/html/HTMLLinkElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698