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

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

Issue 196513007: Oilpan: Reapply: Remove all the RefPtrs and most of the raw pointers to style (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } while (it != begin); 160 } while (it != begin);
161 161
162 treeScopes.insertBefore(followingTreeScope, treeScope); 162 treeScopes.insertBefore(followingTreeScope, treeScope);
163 } 163 }
164 164
165 TreeScopeStyleSheetCollection* StyleEngine::ensureStyleSheetCollectionFor(TreeSc ope& treeScope) 165 TreeScopeStyleSheetCollection* StyleEngine::ensureStyleSheetCollectionFor(TreeSc ope& treeScope)
166 { 166 {
167 if (treeScope == m_document) 167 if (treeScope == m_document)
168 return &m_documentStyleSheetCollection; 168 return &m_documentStyleSheetCollection;
169 169
170 HashMap<TreeScope*, OwnPtr<TreeScopeStyleSheetCollection> >::AddResult resul t = m_styleSheetCollectionMap.add(&treeScope, nullptr); 170 WillBeHeapHashMap<TreeScope*, OwnPtrWillBeMember<ShadowTreeStyleSheetCollect ion> >::AddResult result = m_styleSheetCollectionMap.add(&treeScope, nullptr);
171 if (result.isNewEntry) 171 if (result.isNewEntry)
172 result.storedValue->value = adoptPtr(new ShadowTreeStyleSheetCollection( toShadowRoot(treeScope))); 172 result.storedValue->value = adoptPtrWillBeNoop(new ShadowTreeStyleSheetC ollection(toShadowRoot(treeScope)));
173 return result.storedValue->value.get(); 173 return result.storedValue->value.get();
174 } 174 }
175 175
176 TreeScopeStyleSheetCollection* StyleEngine::styleSheetCollectionFor(TreeScope& t reeScope) 176 TreeScopeStyleSheetCollection* StyleEngine::styleSheetCollectionFor(TreeScope& t reeScope)
177 { 177 {
178 if (treeScope == m_document) 178 if (treeScope == m_document)
179 return &m_documentStyleSheetCollection; 179 return &m_documentStyleSheetCollection;
180 180
181 HashMap<TreeScope*, OwnPtr<TreeScopeStyleSheetCollection> >::iterator it = m _styleSheetCollectionMap.find(&treeScope); 181 WillBeHeapHashMap<TreeScope*, OwnPtrWillBeMember<ShadowTreeStyleSheetCollect ion> >::iterator it = m_styleSheetCollectionMap.find(&treeScope);
182 if (it == m_styleSheetCollectionMap.end()) 182 if (it == m_styleSheetCollectionMap.end())
183 return 0; 183 return 0;
184 return it->value.get(); 184 return it->value.get();
185 } 185 }
186 186
187 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >& StyleEngine::styleSheet sForStyleSheetList(TreeScope& treeScope) 187 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >& StyleEngine::styleSheet sForStyleSheetList(TreeScope& treeScope)
188 { 188 {
189 if (treeScope == m_document) 189 if (treeScope == m_document)
190 return m_documentStyleSheetCollection.styleSheetsForStyleSheetList(); 190 return m_documentStyleSheetCollection.styleSheetsForStyleSheetList();
191 191
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 m_dirtyTreeScopes.add(&scope); 579 m_dirtyTreeScopes.add(&scope);
580 } 580 }
581 581
582 void StyleEngine::markDocumentDirty() 582 void StyleEngine::markDocumentDirty()
583 { 583 {
584 m_documentScopeDirty = true; 584 m_documentScopeDirty = true;
585 if (!HTMLImport::isMaster(&m_document)) 585 if (!HTMLImport::isMaster(&m_document))
586 m_document.import()->master()->styleEngine()->markDocumentDirty(); 586 m_document.import()->master()->styleEngine()->markDocumentDirty();
587 } 587 }
588 588
589 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex t, TextPosition startPosition, bool createdByParser) 589 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& text, TextPosition startPosition, bool createdByParser)
590 { 590 {
591 RefPtr<CSSStyleSheet> styleSheet; 591 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet;
592 592
593 e->document().styleEngine()->addPendingSheet(); 593 e->document().styleEngine()->addPendingSheet();
594 594
595 if (!e->document().inQuirksMode()) { 595 if (!e->document().inQuirksMode()) {
596 AtomicString textContent(text); 596 AtomicString textContent(text);
597 597
598 WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetContent s> >::iterator it = textToSheetCache().find(textContent); 598 WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetContent s> >::iterator it = textToSheetCache().find(textContent);
599 if (it == textToSheetCache().end()) { 599 if (it == textToSheetCache().end()) {
600 styleSheet = StyleEngine::parseSheet(e, text, startPosition, created ByParser); 600 styleSheet = StyleEngine::parseSheet(e, text, startPosition, created ByParser);
601 if (styleSheet->contents()->maybeCacheable()) { 601 if (styleSheet->contents()->maybeCacheable()) {
602 textToSheetCache().add(textContent, styleSheet->contents()); 602 textToSheetCache().add(textContent, styleSheet->contents());
603 sheetToTextCache().add(styleSheet->contents(), textContent); 603 sheetToTextCache().add(styleSheet->contents(), textContent);
604 } 604 }
605 } else { 605 } else {
606 ASSERT(it->value->maybeCacheable()); 606 ASSERT(it->value->maybeCacheable());
607 styleSheet = CSSStyleSheet::createInline(it->value, e, startPosition ); 607 styleSheet = CSSStyleSheet::createInline(it->value, e, startPosition );
608 } 608 }
609 } else { 609 } else {
610 // FIXME: currently we don't cache StyleSheetContents inQuirksMode. 610 // FIXME: currently we don't cache StyleSheetContents inQuirksMode.
611 styleSheet = StyleEngine::parseSheet(e, text, startPosition, createdByPa rser); 611 styleSheet = StyleEngine::parseSheet(e, text, startPosition, createdByPa rser);
612 } 612 }
613 613
614 ASSERT(styleSheet); 614 ASSERT(styleSheet);
615 styleSheet->setTitle(e->title()); 615 styleSheet->setTitle(e->title());
616 return styleSheet; 616 return styleSheet;
617 } 617 }
618 618
619 PassRefPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const String& text , TextPosition startPosition, bool createdByParser) 619 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const String& text, TextPosition startPosition, bool createdByParser)
620 { 620 {
621 RefPtr<CSSStyleSheet> styleSheet; 621 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet;
622 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume nt().inputEncoding()); 622 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume nt().inputEncoding());
623 styleSheet->contents()->parseStringAtPosition(text, startPosition, createdBy Parser); 623 styleSheet->contents()->parseStringAtPosition(text, startPosition, createdBy Parser);
624 return styleSheet; 624 return styleSheet;
625 } 625 }
626 626
627 void StyleEngine::removeSheet(StyleSheetContents* contents) 627 void StyleEngine::removeSheet(StyleSheetContents* contents)
628 { 628 {
629 WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, AtomicString>: :iterator it = sheetToTextCache().find(contents); 629 WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, AtomicString>: :iterator it = sheetToTextCache().find(contents);
630 if (it == sheetToTextCache().end()) 630 if (it == sheetToTextCache().end())
631 return; 631 return;
632 632
633 textToSheetCache().remove(it->value); 633 textToSheetCache().remove(it->value);
634 sheetToTextCache().remove(contents); 634 sheetToTextCache().remove(contents);
635 } 635 }
636 636
637 void StyleEngine::trace(Visitor* visitor) 637 void StyleEngine::trace(Visitor* visitor)
638 { 638 {
639 visitor->trace(m_injectedAuthorStyleSheets); 639 visitor->trace(m_injectedAuthorStyleSheets);
640 visitor->trace(m_authorStyleSheets); 640 visitor->trace(m_authorStyleSheets);
641 visitor->trace(m_documentStyleSheetCollection);
642 visitor->trace(m_styleSheetCollectionMap);
641 } 643 }
642 644
643 } 645 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698