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

Side by Side Diff: Source/WebCore/css/StyleResolver.cpp

Issue 11412176: Merge 135082 - REGRESSION(r129644): User StyleSheet not applying (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1312/
Patch Set: Created 8 years 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
« no previous file with comments | « Source/WebCore/css/StyleResolver.h ('k') | Source/WebCore/dom/Document.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 305
306 if (root) 306 if (root)
307 m_rootDefaultStyle = styleForElement(root, 0, DisallowStyleSharing, Matc hOnlyUserAgentRules); 307 m_rootDefaultStyle = styleForElement(root, 0, DisallowStyleSharing, Matc hOnlyUserAgentRules);
308 308
309 if (m_rootDefaultStyle && view) 309 if (m_rootDefaultStyle && view)
310 m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType(), view->fra me(), m_rootDefaultStyle.get())); 310 m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType(), view->fra me(), m_rootDefaultStyle.get()));
311 311
312 resetAuthorStyle(); 312 resetAuthorStyle();
313 313
314 DocumentStyleSheetCollection* styleSheetCollection = document->styleSheetCol lection(); 314 DocumentStyleSheetCollection* styleSheetCollection = document->styleSheetCol lection();
315 // FIXME: This sucks! The user sheet is reparsed every time!
316 OwnPtr<RuleSet> tempUserStyle = RuleSet::create(); 315 OwnPtr<RuleSet> tempUserStyle = RuleSet::create();
317 if (CSSStyleSheet* pageUserSheet = styleSheetCollection->pageUserSheet()) 316 if (CSSStyleSheet* pageUserSheet = styleSheetCollection->pageUserSheet())
318 tempUserStyle->addRulesFromSheet(pageUserSheet->contents(), *m_medium, t his); 317 tempUserStyle->addRulesFromSheet(pageUserSheet->contents(), *m_medium, t his);
319 addAuthorRulesAndCollectUserRulesFromSheets(styleSheetCollection->pageGroupU serSheets(), *tempUserStyle); 318 collectRulesFromUserStyleSheets(styleSheetCollection->injectedUserStyleSheet s(), *tempUserStyle);
320 addAuthorRulesAndCollectUserRulesFromSheets(styleSheetCollection->documentUs erSheets(), *tempUserStyle); 319 collectRulesFromUserStyleSheets(styleSheetCollection->documentUserStyleSheet s(), *tempUserStyle);
321 if (tempUserStyle->m_ruleCount > 0 || tempUserStyle->m_pageRules.size() > 0) 320 if (tempUserStyle->m_ruleCount > 0 || tempUserStyle->m_pageRules.size() > 0)
322 m_userStyle = tempUserStyle.release(); 321 m_userStyle = tempUserStyle.release();
323 322
324 #if ENABLE(SVG_FONTS) 323 #if ENABLE(SVG_FONTS)
325 if (document->svgExtensions()) { 324 if (document->svgExtensions()) {
326 const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document->svgE xtensions()->svgFontFaceElements(); 325 const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document->svgE xtensions()->svgFontFaceElements();
327 HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.e nd(); 326 HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.e nd();
328 for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElemen ts.begin(); it != end; ++it) 327 for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElemen ts.begin(); it != end; ++it)
329 fontSelector()->addFontFaceRule((*it)->fontFaceRule()); 328 fontSelector()->addFontFaceRule((*it)->fontFaceRule());
330 } 329 }
331 #endif 330 #endif
332 331
333 appendAuthorStyleSheets(0, styleSheetCollection->activeAuthorStyleSheets()); 332 appendAuthorStyleSheets(0, styleSheetCollection->activeAuthorStyleSheets());
334 } 333 }
335 334
336 void StyleResolver::addAuthorRulesAndCollectUserRulesFromSheets(const Vector<Ref Ptr<CSSStyleSheet> >* userSheets, RuleSet& userStyle) 335 void StyleResolver::collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyle Sheet> >& userSheets, RuleSet& userStyle)
337 { 336 {
338 if (!userSheets) 337 for (unsigned i = 0; i < userSheets.size(); ++i) {
339 return; 338 ASSERT(userSheets[i]->contents()->isUserStyleSheet());
340 339 userStyle.addRulesFromSheet(userSheets[i]->contents(), *m_medium, this);
341 unsigned length = userSheets->size();
342 for (unsigned i = 0; i < length; i++) {
343 StyleSheetContents* sheet = userSheets->at(i)->contents();
344 if (sheet->isUserStyleSheet())
345 userStyle.addRulesFromSheet(sheet, *m_medium, this);
346 else
347 m_authorStyle->addRulesFromSheet(sheet, *m_medium, this);
348 } 340 }
349 } 341 }
350 342
351 static PassOwnPtr<RuleSet> makeRuleSet(const Vector<RuleFeature>& rules) 343 static PassOwnPtr<RuleSet> makeRuleSet(const Vector<RuleFeature>& rules)
352 { 344 {
353 size_t size = rules.size(); 345 size_t size = rules.size();
354 if (!size) 346 if (!size)
355 return nullptr; 347 return nullptr;
356 OwnPtr<RuleSet> ruleSet = RuleSet::create(); 348 OwnPtr<RuleSet> ruleSet = RuleSet::create();
357 for (size_t i = 0; i < size; ++i) 349 for (size_t i = 0; i < size; ++i)
(...skipping 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2570 2562
2571 static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wra pperMap, HashSet<RefPtr<CSSStyleSheet> >& sheetWrapperSet, StyleSheetContents* s tyleSheet) 2563 static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wra pperMap, HashSet<RefPtr<CSSStyleSheet> >& sheetWrapperSet, StyleSheetContents* s tyleSheet)
2572 { 2564 {
2573 if (!styleSheet) 2565 if (!styleSheet)
2574 return; 2566 return;
2575 RefPtr<CSSStyleSheet> styleSheetWrapper = CSSStyleSheet::create(styleSheet); 2567 RefPtr<CSSStyleSheet> styleSheetWrapper = CSSStyleSheet::create(styleSheet);
2576 sheetWrapperSet.add(styleSheetWrapper); 2568 sheetWrapperSet.add(styleSheetWrapper);
2577 collectCSSOMWrappers(wrapperMap, styleSheetWrapper.get()); 2569 collectCSSOMWrappers(wrapperMap, styleSheetWrapper.get());
2578 } 2570 }
2579 2571
2572 static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wra pperMap, const Vector<RefPtr<CSSStyleSheet> >& sheets)
2573 {
2574 for (unsigned i = 0; i < sheets.size(); ++i)
2575 collectCSSOMWrappers(wrapperMap, sheets[i].get());
2576 }
2577
2580 static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wra pperMap, DocumentStyleSheetCollection* styleSheetCollection) 2578 static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wra pperMap, DocumentStyleSheetCollection* styleSheetCollection)
2581 { 2579 {
2582 const Vector<RefPtr<CSSStyleSheet> >& styleSheets = styleSheetCollection->ac tiveAuthorStyleSheets(); 2580 collectCSSOMWrappers(wrapperMap, styleSheetCollection->activeAuthorStyleShee ts());
2583 for (unsigned i = 0; i < styleSheets.size(); ++i)
2584 collectCSSOMWrappers(wrapperMap, styleSheets[i].get());
2585
2586 collectCSSOMWrappers(wrapperMap, styleSheetCollection->pageUserSheet()); 2581 collectCSSOMWrappers(wrapperMap, styleSheetCollection->pageUserSheet());
2587 { 2582 collectCSSOMWrappers(wrapperMap, styleSheetCollection->injectedUserStyleShee ts());
2588 const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets = styleSheetCo llection->pageGroupUserSheets(); 2583 collectCSSOMWrappers(wrapperMap, styleSheetCollection->documentUserStyleShee ts());
2589 if (pageGroupUserSheets) {
2590 for (size_t i = 0, size = pageGroupUserSheets->size(); i < size; ++i )
2591 collectCSSOMWrappers(wrapperMap, pageGroupUserSheets->at(i).get( ));
2592 }
2593 }
2594 {
2595 const Vector<RefPtr<CSSStyleSheet> >* documentUserSheets = styleSheetCol lection->documentUserSheets();
2596 if (documentUserSheets) {
2597 for (size_t i = 0, size = documentUserSheets->size(); i < size; ++i)
2598 collectCSSOMWrappers(wrapperMap, documentUserSheets->at(i).get() );
2599 }
2600 }
2601 } 2584 }
2602 2585
2603 CSSStyleRule* StyleResolver::ensureFullCSSOMWrapperForInspector(StyleRule* rule) 2586 CSSStyleRule* StyleResolver::ensureFullCSSOMWrapperForInspector(StyleRule* rule)
2604 { 2587 {
2605 if (m_styleRuleToCSSOMWrapperMap.isEmpty()) { 2588 if (m_styleRuleToCSSOMWrapperMap.isEmpty()) {
2606 collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrap perSet, simpleDefaultStyleSheet); 2589 collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrap perSet, simpleDefaultStyleSheet);
2607 collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrap perSet, defaultStyleSheet); 2590 collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrap perSet, defaultStyleSheet);
2608 collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrap perSet, quirksStyleSheet); 2591 collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrap perSet, quirksStyleSheet);
2609 collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrap perSet, svgStyleSheet); 2592 collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrap perSet, svgStyleSheet);
2610 collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrap perSet, mathMLStyleSheet); 2593 collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrap perSet, mathMLStyleSheet);
(...skipping 2588 matching lines...) Expand 10 before | Expand all | Expand 10 after
5199 info.addMember(m_scopeResolver); 5182 info.addMember(m_scopeResolver);
5200 5183
5201 // FIXME: move this to a place where it would be called only once? 5184 // FIXME: move this to a place where it would be called only once?
5202 info.addMember(defaultStyle); 5185 info.addMember(defaultStyle);
5203 info.addMember(defaultQuirksStyle); 5186 info.addMember(defaultQuirksStyle);
5204 info.addMember(defaultPrintStyle); 5187 info.addMember(defaultPrintStyle);
5205 info.addMember(defaultViewSourceStyle); 5188 info.addMember(defaultViewSourceStyle);
5206 } 5189 }
5207 5190
5208 } // namespace WebCore 5191 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/css/StyleResolver.h ('k') | Source/WebCore/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698