OLD | NEW |
1 /* | 1 /* |
2 * This file is part of the XSL implementation. | 2 * This file is part of the XSL implementation. |
3 * | 3 * |
4 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 m_styleSheet->parseString(sheet); | 63 m_styleSheet->parseString(sheet); |
64 m_loading = false; | 64 m_loading = false; |
65 | 65 |
66 if (parent) | 66 if (parent) |
67 parent->checkLoaded(); | 67 parent->checkLoaded(); |
68 } | 68 } |
69 | 69 |
70 bool XSLImportRule::isLoading() | 70 bool XSLImportRule::isLoading() |
71 { | 71 { |
72 return (m_loading || (m_styleSheet && m_styleSheet->isLoading())); | 72 return m_loading || (m_styleSheet && m_styleSheet->isLoading()); |
73 } | 73 } |
74 | 74 |
75 void XSLImportRule::loadSheet() | 75 void XSLImportRule::loadSheet() |
76 { | 76 { |
77 ResourceFetcher* fetcher = 0; | 77 ResourceFetcher* fetcher = 0; |
78 | |
79 XSLStyleSheet* rootSheet = parentStyleSheet(); | 78 XSLStyleSheet* rootSheet = parentStyleSheet(); |
80 | 79 |
81 if (rootSheet) { | 80 if (rootSheet) { |
82 while (XSLStyleSheet* parentSheet = rootSheet->parentStyleSheet()) | 81 while (XSLStyleSheet* parentSheet = rootSheet->parentStyleSheet()) |
83 rootSheet = parentSheet; | 82 rootSheet = parentSheet; |
84 } | 83 } |
85 | 84 |
86 if (rootSheet) | 85 if (rootSheet) |
87 fetcher = rootSheet->fetcher(); | 86 fetcher = rootSheet->fetcher(); |
88 | 87 |
89 String absHref = m_strHref; | 88 String absHref = m_strHref; |
90 XSLStyleSheet* parentSheet = parentStyleSheet(); | 89 XSLStyleSheet* parentSheet = parentStyleSheet(); |
91 if (!parentSheet->baseURL().isNull()) | 90 if (!parentSheet->baseURL().isNull()) { |
92 // use parent styleheet's URL as the base URL | 91 // Use parent styleheet's URL as the base URL |
93 absHref = KURL(parentSheet->baseURL(), m_strHref).string(); | 92 absHref = KURL(parentSheet->baseURL(), m_strHref).string(); |
| 93 } |
94 | 94 |
95 // Check for a cycle in our import chain. If we encounter a stylesheet | 95 // Check for a cycle in our import chain. If we encounter a stylesheet in |
96 // in our parent chain with the same URL, then just bail. | 96 // our parent chain with the same URL, then just bail. |
97 for (XSLStyleSheet* parentSheet = parentStyleSheet(); parentSheet; parentShe
et = parentSheet->parentStyleSheet()) { | 97 for (XSLStyleSheet* parentSheet = parentStyleSheet(); parentSheet; parentShe
et = parentSheet->parentStyleSheet()) { |
98 if (absHref == parentSheet->baseURL().string()) | 98 if (absHref == parentSheet->baseURL().string()) |
99 return; | 99 return; |
100 } | 100 } |
101 | 101 |
102 FetchRequest request(ResourceRequest(fetcher->document()->completeURL(absHre
f)), FetchInitiatorTypeNames::xml); | 102 FetchRequest request(ResourceRequest(fetcher->document()->completeURL(absHre
f)), FetchInitiatorTypeNames::xml); |
103 m_resource = fetcher->fetchXSLStyleSheet(request); | 103 m_resource = fetcher->fetchXSLStyleSheet(request); |
104 | 104 |
105 if (m_resource) { | 105 if (m_resource) { |
106 m_resource->addClient(this); | 106 m_resource->addClient(this); |
107 | 107 |
108 // If the imported sheet is in the cache, then setXSLStyleSheet gets cal
led, | 108 // If the imported sheet is in the cache, then setXSLStyleSheet gets |
109 // and the sheet even gets parsed (via parseString). In this case we ha
ve | 109 // called, and the sheet even gets parsed (via parseString). In this |
110 // loaded (even if our subresources haven't), so if we have a stylesheet
after | 110 // case we have loaded (even if our subresources haven't), so if we have |
111 // checking the cache, then we've clearly loaded. | 111 // a stylesheet after checking the cache, then we've clearly loaded. |
112 if (!m_styleSheet) | 112 if (!m_styleSheet) |
113 m_loading = true; | 113 m_loading = true; |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 void XSLImportRule::trace(Visitor* visitor) | 117 void XSLImportRule::trace(Visitor* visitor) |
118 { | 118 { |
119 visitor->trace(m_parentStyleSheet); | 119 visitor->trace(m_parentStyleSheet); |
120 visitor->trace(m_styleSheet); | 120 visitor->trace(m_styleSheet); |
121 } | 121 } |
122 | 122 |
123 } // namespace WebCore | 123 } // namespace WebCore |
OLD | NEW |