Changeset 126717 in webkit
- Timestamp:
- Aug 26, 2012 4:48:39 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r126716 r126717 1 2012-08-26 Antti Koivisto <antti@apple.com> 2 3 Remove parent pointer from StyleSheetContents and StyleRuleImport 4 https://bugs.webkit.org/show_bug.cgi?id=94926 5 6 Reviewed by Andreas Kling. 7 8 To be able to cache and share @imported stylesheets in the future there must not be any parent 9 pointers in the stylesheet tree. 10 11 Parent pointers are used during loading to invoke load completion callbacks and for 12 accessing document context information (like the security origin). They are not used after 13 the sheet load is complete. Instead of keeping the parent pointers around indefinitely as part of the 14 stylesheet data structure we just keep a pointer to the root CSSStyleSheet for the duration of the load. 15 16 This patch doesn't enable any new caching or generally change the behavior. 17 18 * css/CSSStyleSheet.cpp: 19 (WebCore::CSSStyleSheet::insertRule): 20 (WebCore::CSSStyleSheet::rootStyleSheet): 21 (WebCore): 22 (WebCore::CSSStyleSheet::ownerDocument): 23 * css/CSSStyleSheet.h: 24 (CSSStyleSheet): 25 * css/StyleRuleImport.cpp: 26 (WebCore::StyleRuleImport::LoadContext::LoadContext): 27 28 Simplify by making StyleRuleImport CachedStyleSheetClient directly. LoadContext contains 29 fields that can be thrown away after load completes. 30 31 (WebCore): 32 (WebCore::StyleRuleImport::StyleRuleImport): 33 (WebCore::StyleRuleImport::~StyleRuleImport): 34 (WebCore::StyleRuleImport::setCSSStyleSheet): 35 (WebCore::StyleRuleImport::isLoading): 36 (WebCore::StyleRuleImport::hadLoadError): 37 (WebCore::StyleRuleImport::requestStyleSheet): 38 * css/StyleRuleImport.h: 39 (StyleRuleImport): 40 (LoadContext): 41 * css/StyleSheetContents.cpp: 42 (WebCore::StyleSheetContents::StyleSheetContents): 43 44 Remove now unnecessary constructor. 45 46 (WebCore::StyleSheetContents::isCacheable): 47 (WebCore::StyleSheetContents::parserAppendRule): 48 (WebCore::StyleSheetContents::clearRules): 49 (WebCore::StyleSheetContents::wrapperInsertRule): 50 (WebCore::StyleSheetContents::wrapperDeleteRule): 51 (WebCore::StyleSheetContents::requestImportedStyleSheets): 52 (WebCore): 53 (WebCore::StyleSheetContents::parseAuthorStyleSheet): 54 (WebCore::StyleSheetContents::parseStringAtLine): 55 (WebCore::StyleSheetContents::checkImportedSheetLoadCompleted): 56 (WebCore::StyleSheetContents::checkLoadCompleted): 57 (WebCore::StyleSheetContents::getAncestors): 58 (WebCore::StyleSheetContents::hasImportCycle): 59 60 Move the cycle checking to the root stylesheet so we don't need to pass the entire chain around. 61 The extra work here is unlikely to cause problems, massive import trees don't really occur in 62 practice. 63 64 * css/StyleSheetContents.h: 65 (WebCore::StyleSheetContents::create): 66 (StyleSheetContents): 67 * dom/ProcessingInstruction.cpp: 68 (WebCore::ProcessingInstruction::parseStyleSheet): 69 * dom/StyleElement.cpp: 70 (WebCore::StyleElement::createSheet): 71 * html/HTMLLinkElement.cpp: 72 (WebCore::HTMLLinkElement::setCSSStyleSheet): 73 1 74 2012-08-26 Andreas Kling <kling@webkit.org> 2 75 -
trunk/Source/WebCore/css/CSSStyleSheet.cpp
r126656 r126717 38 38 #include "SecurityOrigin.h" 39 39 #include "StyleRule.h" 40 #include "StyleRuleImport.h" 40 41 #include "StyleSheetContents.h" 41 42 #include <wtf/text/StringBuilder.h> … … 284 285 ec = HIERARCHY_REQUEST_ERR; 285 286 return 0; 286 } 287 } 288 if (rule->isImportRule()) 289 static_cast<StyleRuleImport*>(rule.get())->requestStyleSheet(rootStyleSheet(), m_contents->parserContext()); 290 287 291 if (!m_childRuleCSSOMWrappers.isEmpty()) 288 292 m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>()); … … 371 375 } 372 376 373 Document* CSSStyleSheet::ownerDocument() const377 CSSStyleSheet* CSSStyleSheet::rootStyleSheet() const 374 378 { 375 379 const CSSStyleSheet* root = this; 376 380 while (root->parentStyleSheet()) 377 381 root = root->parentStyleSheet(); 382 return const_cast<CSSStyleSheet*>(root); 383 } 384 385 Document* CSSStyleSheet::ownerDocument() const 386 { 387 const CSSStyleSheet* root = rootStyleSheet(); 378 388 return root->ownerNode() ? root->ownerNode()->document() : 0; 379 389 } -
trunk/Source/WebCore/css/CSSStyleSheet.h
r125805 r126717 82 82 83 83 void clearOwnerRule() { m_ownerRule = 0; } 84 CSSStyleSheet* rootStyleSheet() const; 84 85 Document* ownerDocument() const; 85 86 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); } -
trunk/Source/WebCore/css/StyleRuleImport.cpp
r126154 r126717 33 33 namespace WebCore { 34 34 35 StyleRuleImport::LoadContext::LoadContext(CSSStyleSheet* rootStyleSheet, const CSSParserContext& parentParserContext) 36 : rootStyleSheet(rootStyleSheet) 37 , parentParserContext(parentParserContext) 38 { 39 } 40 35 41 PassRefPtr<StyleRuleImport> StyleRuleImport::create(const String& href, PassRefPtr<MediaQuerySet> media) 36 42 { … … 40 46 StyleRuleImport::StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet> media) 41 47 : StyleRuleBase(Import, 0) 42 , m_parentStyleSheet(0)43 , m_styleSheetClient(this)44 48 , m_strHref(href) 45 49 , m_mediaQueries(media) 46 50 , m_cachedSheet(0) 47 , m_loading(false)48 51 { 49 52 if (!m_mediaQueries) … … 53 56 StyleRuleImport::~StyleRuleImport() 54 57 { 55 if (m_styleSheet)56 m_styleSheet->clearOwnerRule();57 58 if (m_cachedSheet) 58 m_cachedSheet->removeClient( &m_styleSheetClient);59 m_cachedSheet->removeClient(this); 59 60 } 60 61 61 void StyleRuleImport::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* cachedStyleSheet)62 void StyleRuleImport::setCSSStyleSheet(const String& url, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*) 62 63 { 63 if (m_styleSheet) 64 m_styleSheet->clearOwnerRule(); 64 ASSERT(m_loadContext); 65 ASSERT(!m_styleSheet); 66 ASSERT(m_cachedSheet); 65 67 66 CSSParserContext context = m_parentStyleSheet ? m_parentStyleSheet->parserContext() : CSSStrictMode; 67 context.charset = charset; 68 OwnPtr<LoadContext> loadContext = m_loadContext.release(); 69 70 CSSParserContext parserContext = loadContext->parentParserContext; 68 71 if (!baseURL.isNull()) 69 context.baseURL = baseURL; 72 parserContext.baseURL = baseURL; 73 parserContext.charset = charset; 70 74 71 m_styleSheet = StyleSheetContents::create(this, href, context); 75 m_styleSheet = StyleSheetContents::create(url, parserContext); 76 m_styleSheet->parseAuthorStyleSheet(m_cachedSheet.get(), loadContext->rootStyleSheet.get()); 72 77 73 Document* document = m_parentStyleSheet ? m_parentStyleSheet->singleOwnerDocument() : 0; 74 m_styleSheet->parseAuthorStyleSheet(cachedStyleSheet, document ? document->securityOrigin() : 0); 75 76 m_loading = false; 77 78 if (m_parentStyleSheet) { 79 m_parentStyleSheet->notifyLoadedSheet(cachedStyleSheet); 80 m_parentStyleSheet->checkLoaded(); 81 } 78 loadContext->rootStyleSheet->contents()->checkLoadCompleted(); 82 79 } 83 80 84 81 bool StyleRuleImport::isLoading() const 85 82 { 86 return m_load ing|| (m_styleSheet && m_styleSheet->isLoading());83 return m_loadContext || (m_styleSheet && m_styleSheet->isLoading()); 87 84 } 88 85 89 void StyleRuleImport::requestStyleSheet() 86 bool StyleRuleImport::hadLoadError() const 90 87 { 91 if (!m_parentStyleSheet) 88 return m_cachedSheet && m_cachedSheet->errorOccurred(); 89 } 90 91 void StyleRuleImport::requestStyleSheet(CSSStyleSheet* rootSheet, const CSSParserContext& parserContext) 92 { 93 ASSERT(!rootSheet->parentStyleSheet()); 94 ASSERT(!m_cachedSheet); 95 96 Node* ownerNode = rootSheet->ownerNode(); 97 if (!ownerNode) 92 98 return; 93 Document* document = m_parentStyleSheet->singleOwnerDocument(); 94 if (!document) 99 Document* document = ownerNode->document(); 100 101 KURL resolvedURL; 102 if (!parserContext.baseURL.isNull()) 103 resolvedURL = KURL(parserContext.baseURL, m_strHref); 104 else 105 resolvedURL = document->completeURL(m_strHref); 106 107 StyleSheetContents* rootSheetContents = rootSheet->contents(); 108 if (rootSheetContents->hasImportCycle(this, resolvedURL, document->baseURL())) 95 109 return; 96 110 111 ResourceRequest request(resolvedURL); 97 112 CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader(); 98 if (!cachedResourceLoader) 113 if (rootSheetContents->isUserStyleSheet()) 114 m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request, parserContext.charset); 115 else 116 m_cachedSheet = cachedResourceLoader->requestCSSStyleSheet(request, parserContext.charset); 117 118 if (!m_cachedSheet) 99 119 return; 120 // if the import rule is issued dynamically, the sheet may be 121 // removed from the pending sheet count, so let the doc know 122 // the sheet being imported is pending. 123 if (rootSheetContents->loadCompleted()) 124 ownerNode->startLoadingDynamicSheet(); 100 125 101 KURL absURL; 102 if (!m_parentStyleSheet->baseURL().isNull()) 103 // use parent styleheet's URL as the base URL 104 absURL = KURL(m_parentStyleSheet->baseURL(), m_strHref); 105 else 106 absURL = document->completeURL(m_strHref); 107 108 // Check for a cycle in our import chain. If we encounter a stylesheet 109 // in our parent chain with the same URL, then just bail. 110 StyleSheetContents* rootSheet = m_parentStyleSheet; 111 for (StyleSheetContents* sheet = m_parentStyleSheet; sheet; sheet = sheet->parentStyleSheet()) { 112 if (equalIgnoringFragmentIdentifier(absURL, sheet->baseURL()) 113 || equalIgnoringFragmentIdentifier(absURL, document->completeURL(sheet->originalURL()))) 114 return; 115 rootSheet = sheet; 116 } 117 118 ResourceRequest request(absURL); 119 if (m_parentStyleSheet->isUserStyleSheet()) 120 m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request, m_parentStyleSheet->charset()); 121 else 122 m_cachedSheet = cachedResourceLoader->requestCSSStyleSheet(request, m_parentStyleSheet->charset()); 123 if (m_cachedSheet) { 124 // if the import rule is issued dynamically, the sheet may be 125 // removed from the pending sheet count, so let the doc know 126 // the sheet being imported is pending. 127 if (m_parentStyleSheet && m_parentStyleSheet->loadCompleted() && rootSheet == m_parentStyleSheet) 128 m_parentStyleSheet->startLoadingDynamicSheet(); 129 m_loading = true; 130 m_cachedSheet->addClient(&m_styleSheetClient); 131 } 126 m_loadContext = adoptPtr(new LoadContext(rootSheet, parserContext)); 127 m_cachedSheet->addClient(this); 132 128 } 133 129 -
trunk/Source/WebCore/css/StyleRuleImport.h
r124435 r126717 23 23 #define StyleRuleImport_h 24 24 25 #include "CSSParserMode.h" 25 26 #include "CachedResourceHandle.h" 26 27 #include "CachedStyleSheetClient.h" … … 34 35 class StyleSheetContents; 35 36 36 class StyleRuleImport : public StyleRuleBase {37 class StyleRuleImport : public StyleRuleBase, public CachedStyleSheetClient { 37 38 public: 38 39 static PassRefPtr<StyleRuleImport> create(const String& href, PassRefPtr<MediaQuerySet>); 39 40 40 ~StyleRuleImport(); 41 42 StyleSheetContents* parentStyleSheet() const { return m_parentStyleSheet; } 43 void setParentStyleSheet(StyleSheetContents* sheet) { ASSERT(sheet); m_parentStyleSheet = sheet; } 44 void clearParentStyleSheet() { m_parentStyleSheet = 0; } 41 virtual ~StyleRuleImport(); 45 42 46 43 String href() const { return m_strHref; } … … 48 45 49 46 bool isLoading() const; 47 bool hadLoadError() const; 50 48 MediaQuerySet* mediaQueries() { return m_mediaQueries.get(); } 51 49 52 void requestStyleSheet( );50 void requestStyleSheet(CSSStyleSheet* rootSheet, const CSSParserContext&); 53 51 54 52 void reportDescendantMemoryUsage(MemoryObjectInfo*) const; 55 53 56 54 private: 57 // NOTE: We put the CachedStyleSheetClient in a member instead of inheriting from it58 // to avoid adding a vptr to StyleRuleImport.59 class ImportedStyleSheetClient : public CachedStyleSheetClient {60 public:61 ImportedStyleSheetClient(StyleRuleImport* ownerRule) : m_ownerRule(ownerRule) { }62 virtual ~ImportedStyleSheetClient() { }63 virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet)64 {65 m_ownerRule->setCSSStyleSheet(href, baseURL, charset, sheet);66 }67 private:68 StyleRuleImport* m_ownerRule;69 };70 71 void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*);72 friend class ImportedStyleSheetClient;73 74 55 StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet>); 75 56 76 StyleSheetContents* m_parentStyleSheet;57 virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*); 77 58 78 ImportedStyleSheetClient m_styleSheetClient;79 59 String m_strHref; 80 60 RefPtr<MediaQuerySet> m_mediaQueries; 81 61 RefPtr<StyleSheetContents> m_styleSheet; 62 82 63 CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet; 83 bool m_loading; 64 struct LoadContext { 65 LoadContext(CSSStyleSheet* rootStyleSheet, const CSSParserContext& parentParserContext); 66 RefPtr<CSSStyleSheet> rootStyleSheet; 67 CSSParserContext parentParserContext; 68 }; 69 OwnPtr<LoadContext> m_loadContext; 84 70 }; 85 71 -
trunk/Source/WebCore/css/StyleSheetContents.cpp
r126154 r126717 55 55 } 56 56 57 StyleSheetContents::StyleSheetContents(StyleRuleImport* ownerRule, const String& originalURL, const CSSParserContext& context) 58 : m_ownerRule(ownerRule) 59 , m_originalURL(originalURL) 57 StyleSheetContents::StyleSheetContents(const String& originalURL, const CSSParserContext& context) 58 : m_originalURL(originalURL) 60 59 , m_loadCompleted(false) 61 , m_isUserStyleSheet(ownerRule && ownerRule->parentStyleSheet() && ownerRule->parentStyleSheet()->isUserStyleSheet())62 60 , m_hasSyntacticallyValidCSSHeader(true) 63 61 , m_didLoadErrorOccur(false) … … 71 69 StyleSheetContents::StyleSheetContents(const StyleSheetContents& o) 72 70 : RefCounted<StyleSheetContents>() 73 , m_ownerRule(0)74 71 , m_originalURL(o.m_originalURL) 75 72 , m_encodingFromCharsetRule(o.m_encodingFromCharsetRule) … … 104 101 // FIXME: Support copying import rules. 105 102 if (!m_importRules.isEmpty()) 106 return false;107 // FIXME: Support cached stylesheets in import rules.108 if (m_ownerRule)109 103 return false; 110 104 // This would require dealing with multiple clients for load callbacks. … … 130 124 ASSERT(m_childRules.isEmpty()); 131 125 m_importRules.append(static_cast<StyleRuleImport*>(rule.get())); 132 m_importRules.last()->setParentStyleSheet(this);133 m_importRules.last()->requestStyleSheet();134 126 return; 135 127 } … … 170 162 void StyleSheetContents::clearRules() 171 163 { 172 for (unsigned i = 0; i < m_importRules.size(); ++i) {173 ASSERT(m_importRules.at(i)->parentStyleSheet() == this);174 m_importRules[i]->clearParentStyleSheet();175 }176 164 m_importRules.clear(); 177 165 m_childRules.clear(); … … 208 196 return false; 209 197 m_importRules.insert(childVectorIndex, static_cast<StyleRuleImport*>(rule.get())); 210 m_importRules[childVectorIndex]->setParentStyleSheet(this);211 m_importRules[childVectorIndex]->requestStyleSheet();212 // FIXME: Stylesheet doesn't actually change meaningfully before the imported sheets are loaded.213 198 return true; 214 199 } … … 236 221 } 237 222 if (childVectorIndex < m_importRules.size()) { 238 m_importRules[childVectorIndex]->clearParentStyleSheet();239 223 m_importRules.remove(childVectorIndex); 240 224 return; … … 267 251 } 268 252 269 void StyleSheetContents::parseAuthorStyleSheet(const CachedCSSStyleSheet* cachedStyleSheet, const SecurityOrigin* securityOrigin) 270 { 253 void StyleSheetContents::requestImportedStyleSheets(CSSStyleSheet* rootSheet) 254 { 255 ASSERT(!rootSheet->parentStyleSheet()); 256 for (unsigned i = 0; i < m_importRules.size(); ++i) 257 m_importRules[i]->requestStyleSheet(rootSheet, parserContext()); 258 } 259 260 void StyleSheetContents::parseAuthorStyleSheet(const CachedCSSStyleSheet* cachedStyleSheet, CSSStyleSheet* rootSheet) 261 { 262 if (cachedStyleSheet->errorOccurred()) { 263 m_didLoadErrorOccur = true; 264 return; 265 } 266 Document* ownerDocument = rootSheet->ownerDocument(); 267 if (!ownerDocument) 268 return; 271 269 // Check to see if we should enforce the MIME type of the CSS resource in strict mode. 272 270 // Running in iWeb 2 is one example of where we don't want to - <rdar://problem/6099748> … … 282 280 // This prevents an attacker playing games by injecting CSS strings into HTML, XML, JSON, etc. etc. 283 281 if (!hasValidMIMEType && !hasSyntacticallyValidCSSHeader()) { 282 const SecurityOrigin* securityOrigin = ownerDocument->securityOrigin(); 284 283 bool isCrossOriginCSS = !securityOrigin || !securityOrigin->canRequest(baseURL()); 285 284 if (isCrossOriginCSS) { … … 295 294 // while the other lacks the second trailing newline. 296 295 if (baseURL().string().endsWith(slashKHTMLFixesDotCss) && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText) 297 && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1) 296 && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1) { 298 297 clearRules(); 299 } 298 return; 299 } 300 } 301 302 requestImportedStyleSheets(rootSheet); 300 303 } 301 304 … … 310 313 p.parseSheet(this, sheetText, startLineNumber); 311 314 315 if (!m_clients.isEmpty()) { 316 ASSERT(m_clients.size() == 1); 317 requestImportedStyleSheets(m_clients[0]); 318 } 312 319 return true; 313 320 } … … 322 329 } 323 330 324 void StyleSheetContents::checkLoaded() 325 { 326 if (isLoading()) 327 return; 328 329 // Avoid |this| being deleted by scripts that run via 330 // ScriptableDocumentParser::executeScriptsWaitingForStylesheets(). 331 // See <rdar://problem/6622300>. 332 RefPtr<StyleSheetContents> protector(this); 333 StyleSheetContents* parentSheet = parentStyleSheet(); 334 if (parentSheet) { 335 parentSheet->checkLoaded(); 336 m_loadCompleted = true; 337 return; 338 } 339 RefPtr<Node> ownerNode = singleOwnerNode(); 340 if (!ownerNode) { 341 m_loadCompleted = true; 342 return; 343 } 331 bool StyleSheetContents::checkImportedSheetLoadCompleted() 332 { 333 for (unsigned i = 0; i < m_importRules.size(); ++i) { 334 StyleRuleImport* importRule = m_importRules[i].get(); 335 if (importRule->isLoading()) 336 return false; 337 if (importRule->styleSheet() && !importRule->styleSheet()->checkImportedSheetLoadCompleted()) 338 return false; 339 if (importRule->hadLoadError()) 340 m_didLoadErrorOccur = true; 341 } 342 m_loadCompleted = true; 343 return true; 344 } 345 346 void StyleSheetContents::checkLoadCompleted() 347 { 348 if (m_clients.isEmpty()) 349 return; 350 if (!checkImportedSheetLoadCompleted()) 351 return; 352 353 ASSERT(hasOneClient()); 354 ASSERT(!m_clients[0]->parentStyleSheet()); 355 RefPtr<Node> ownerNode = m_clients[0]->ownerNode(); 356 if (!ownerNode) 357 return; 358 344 359 m_loadCompleted = ownerNode->sheetLoaded(); 345 360 if (m_loadCompleted) … … 347 362 } 348 363 349 void StyleSheetContents::notifyLoadedSheet(const CachedCSSStyleSheet* sheet) 350 { 351 ASSERT(sheet); 352 m_didLoadErrorOccur |= sheet->errorOccurred(); 353 } 354 355 void StyleSheetContents::startLoadingDynamicSheet() 356 { 357 if (Node* owner = singleOwnerNode()) 358 owner->startLoadingDynamicSheet(); 359 } 360 361 StyleSheetContents* StyleSheetContents::rootStyleSheet() const 362 { 363 const StyleSheetContents* root = this; 364 while (root->parentStyleSheet()) 365 root = root->parentStyleSheet(); 366 return const_cast<StyleSheetContents*>(root); 367 } 368 369 Node* StyleSheetContents::singleOwnerNode() const 370 { 371 StyleSheetContents* root = rootStyleSheet(); 372 if (root->m_clients.isEmpty()) 373 return 0; 374 ASSERT(root->m_clients.size() == 1); 375 return root->m_clients[0]->ownerNode(); 376 } 377 378 Document* StyleSheetContents::singleOwnerDocument() const 379 { 380 Node* ownerNode = singleOwnerNode(); 381 return ownerNode ? ownerNode->document() : 0; 364 bool StyleSheetContents::getAncestors(const StyleRuleImport* importRule, Vector<const StyleSheetContents*>& result) const 365 { 366 result.append(this); 367 for (unsigned i = 0; i < m_importRules.size(); ++i) { 368 if (m_importRules[i] == importRule) 369 return true; 370 } 371 for (unsigned i = 0; i < m_importRules.size(); ++i) { 372 if (m_importRules[i]->styleSheet() && m_importRules[i]->styleSheet()->getAncestors(importRule, result)) 373 return true; 374 } 375 result.removeLast(); 376 return false; 377 } 378 379 bool StyleSheetContents::hasImportCycle(const StyleRuleImport* importRule, const KURL& importURL, const KURL& documentBaseURL) const 380 { 381 Vector<const StyleSheetContents*> ancestors; 382 getAncestors(importRule, ancestors); 383 384 KURL parentBaseURL = documentBaseURL; 385 for (unsigned i = 0; i < ancestors.size(); ++i) { 386 if (equalIgnoringFragmentIdentifier(importURL, ancestors[i]->baseURL())) 387 return true; 388 if (equalIgnoringFragmentIdentifier(importURL, KURL(parentBaseURL, ancestors[i]->originalURL()))) 389 return true; 390 parentBaseURL = ancestors[i]->baseURL(); 391 } 392 return false; 382 393 } 383 394 … … 452 463 } 453 464 454 StyleSheetContents* StyleSheetContents::parentStyleSheet() const455 {456 return m_ownerRule ? m_ownerRule->parentStyleSheet() : 0;457 }458 459 465 void StyleSheetContents::registerClient(CSSStyleSheet* sheet) 460 466 { -
trunk/Source/WebCore/css/StyleSheetContents.h
r125805 r126717 45 45 static PassRefPtr<StyleSheetContents> create(const CSSParserContext& context = CSSParserContext(CSSStrictMode)) 46 46 { 47 return adoptRef(new StyleSheetContents( 0,String(), context));47 return adoptRef(new StyleSheetContents(String(), context)); 48 48 } 49 49 static PassRefPtr<StyleSheetContents> create(const String& originalURL, const CSSParserContext& context) 50 50 { 51 return adoptRef(new StyleSheetContents(0, originalURL, context)); 52 } 53 static PassRefPtr<StyleSheetContents> create(StyleRuleImport* ownerRule, const String& originalURL, const CSSParserContext& context) 54 { 55 return adoptRef(new StyleSheetContents(ownerRule, originalURL, context)); 51 return adoptRef(new StyleSheetContents(originalURL, context)); 56 52 } 57 53 … … 62 58 const AtomicString& determineNamespace(const AtomicString& prefix); 63 59 64 void parseAuthorStyleSheet(const CachedCSSStyleSheet*, const SecurityOrigin*);60 void parseAuthorStyleSheet(const CachedCSSStyleSheet*, CSSStyleSheet* rootSheet); 65 61 bool parseString(const String&); 66 62 bool parseStringAtLine(const String&, int startLineNumber); … … 70 66 bool isLoading() const; 71 67 72 void checkLoaded(); 73 void startLoadingDynamicSheet(); 74 75 StyleSheetContents* rootStyleSheet() const; 76 Node* singleOwnerNode() const; 77 Document* singleOwnerDocument() const; 68 void checkLoadCompleted(); 78 69 79 70 const String& charset() const { return m_parserContext.charset; } … … 103 94 const Vector<RefPtr<StyleRuleImport> >& importRules() const { return m_importRules; } 104 95 105 void notifyLoadedSheet(const CachedCSSStyleSheet*); 106 107 StyleSheetContents* parentStyleSheet() const; 108 StyleRuleImport* ownerRule() const { return m_ownerRule; } 109 void clearOwnerRule() { m_ownerRule = 0; } 110 96 bool hasImportCycle(const StyleRuleImport* importRule, const KURL& importURL, const KURL& documentBaseURL) const; 97 111 98 // Note that href is the URL that started the redirect chain that led to 112 99 // this style sheet. This property probably isn't useful for much except … … 124 111 bool wrapperInsertRule(PassRefPtr<StyleRuleBase>, unsigned index); 125 112 void wrapperDeleteRule(unsigned index); 113 114 void requestImportedStyleSheets(CSSStyleSheet* rootSheet); 126 115 127 116 PassRefPtr<StyleSheetContents> copy() const { return adoptRef(new StyleSheetContents(*this)); } … … 141 130 142 131 private: 143 StyleSheetContents( StyleRuleImport* ownerRule,const String& originalURL, const CSSParserContext&);132 StyleSheetContents(const String& originalURL, const CSSParserContext&); 144 133 StyleSheetContents(const StyleSheetContents&); 145 134 146 135 void clearCharsetRule(); 147 136 148 StyleRuleImport* m_ownerRule; 137 bool checkImportedSheetLoadCompleted(); 138 bool getAncestors(const StyleRuleImport*, Vector<const StyleSheetContents*>& result) const; 149 139 150 140 String m_originalURL; -
trunk/Source/WebCore/dom/ProcessingInstruction.cpp
r126127 r126717 255 255 256 256 if (m_isCSS) 257 static_cast<CSSStyleSheet*>(m_sheet.get())->contents()->checkLoad ed();257 static_cast<CSSStyleSheet*>(m_sheet.get())->contents()->checkLoadCompleted(); 258 258 #if ENABLE(XSLT) 259 259 else if (m_isXSL) -
trunk/Source/WebCore/dom/StyleElement.cpp
r118585 r126717 182 182 183 183 if (m_sheet) 184 m_sheet->contents()->checkLoad ed();184 m_sheet->contents()->checkLoadCompleted(); 185 185 } 186 186 -
trunk/Source/WebCore/html/HTMLLinkElement.cpp
r125988 r126717 324 324 m_sheet->setTitle(title()); 325 325 326 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, document()->securityOrigin());326 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_sheet.get()); 327 327 328 328 m_loading = false; 329 styleSheet->notifyLoadedSheet(cachedStyleSheet); 330 styleSheet->checkLoaded(); 329 styleSheet->checkLoadCompleted(); 331 330 332 331 #if ENABLE(PARSED_STYLE_SHEET_CACHING)
Note: See TracChangeset
for help on using the changeset viewer.