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 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 */ | 20 */ |
21 | 21 |
22 #include "config.h" | 22 #include "config.h" |
23 #include "core/xml/XSLImportRule.h" | 23 #include "core/xml/XSLImportRule.h" |
24 | 24 |
25 #include "core/FetchInitiatorTypeNames.h" | 25 #include "core/FetchInitiatorTypeNames.h" |
26 #include "core/dom/Document.h" | 26 #include "core/dom/Document.h" |
27 #include "core/fetch/FetchRequest.h" | 27 #include "core/fetch/FetchRequest.h" |
28 #include "core/fetch/ResourceFetcher.h" | 28 #include "core/fetch/ResourceFetcher.h" |
29 #include "core/fetch/XSLStyleSheetResource.h" | 29 #include "core/fetch/XSLStyleSheetResource.h" |
30 #include "platform/SharedBuffer.h" | |
30 | 31 |
31 namespace blink { | 32 namespace blink { |
32 | 33 |
33 XSLImportRule::XSLImportRule(XSLStyleSheet* parent, const String& href) | 34 XSLImportRule::XSLImportRule(XSLStyleSheet* parent, const String& href) |
34 : m_parentStyleSheet(parent) | 35 : m_parentStyleSheet(parent) |
35 , m_strHref(href) | 36 , m_strHref(href) |
36 , m_resource(0) | |
37 , m_loading(false) | 37 , m_loading(false) |
38 { | 38 { |
39 } | 39 } |
40 | 40 |
41 XSLImportRule::~XSLImportRule() | 41 XSLImportRule::~XSLImportRule() |
42 { | 42 { |
43 #if !ENABLE(OILPAN) | 43 #if !ENABLE(OILPAN) |
44 if (m_styleSheet) | 44 if (m_styleSheet) |
45 m_styleSheet->setParentStyleSheet(0); | 45 m_styleSheet->setParentStyleSheet(0); |
46 #endif | 46 #endif |
47 | |
48 if (m_resource) | |
49 m_resource->removeClient(this); | |
50 } | 47 } |
51 | 48 |
52 void XSLImportRule::setXSLStyleSheet(const String& href, const KURL& baseURL, co nst String& sheet) | 49 void XSLImportRule::setXSLStyleSheet(const String& href, const KURL& baseURL, co nst String& sheet) |
53 { | 50 { |
54 if (m_styleSheet) | 51 if (m_styleSheet) |
55 m_styleSheet->setParentStyleSheet(0); | 52 m_styleSheet->setParentStyleSheet(0); |
56 | 53 |
57 m_styleSheet = XSLStyleSheet::create(this, href, baseURL); | 54 m_styleSheet = XSLStyleSheet::create(this, href, baseURL); |
58 | 55 |
59 XSLStyleSheet* parent = parentStyleSheet(); | 56 XSLStyleSheet* parent = parentStyleSheet(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 absHref = KURL(parentSheet->baseURL(), m_strHref).string(); | 89 absHref = KURL(parentSheet->baseURL(), m_strHref).string(); |
93 } | 90 } |
94 | 91 |
95 // Check for a cycle in our import chain. If we encounter a stylesheet in | 92 // Check for a cycle in our import chain. If we encounter a stylesheet in |
96 // our parent chain with the same URL, then just bail. | 93 // our parent chain with the same URL, then just bail. |
97 for (XSLStyleSheet* parentSheet = parentStyleSheet(); parentSheet; parentShe et = parentSheet->parentStyleSheet()) { | 94 for (XSLStyleSheet* parentSheet = parentStyleSheet(); parentSheet; parentShe et = parentSheet->parentStyleSheet()) { |
98 if (absHref == parentSheet->baseURL().string()) | 95 if (absHref == parentSheet->baseURL().string()) |
99 return; | 96 return; |
100 } | 97 } |
101 | 98 |
102 FetchRequest request(ResourceRequest(fetcher->document()->completeURL(absHre f)), FetchInitiatorTypeNames::xml); | 99 ResourceLoaderOptions fetchOptions(ResourceFetcher::defaultResourceOptions() ); |
103 m_resource = fetcher->fetchXSLStyleSheet(request); | 100 FetchRequest request(ResourceRequest(fetcher->document()->completeURL(absHre f)), FetchInitiatorTypeNames::xml, fetchOptions); |
101 request.setOriginRestriction(FetchRequest::RestrictToSameOrigin); | |
102 ResourcePtr<Resource> resource = fetcher->fetchSynchronously(request); | |
103 if (!resource) | |
104 return; | |
104 | 105 |
105 if (m_resource) { | 106 ASSERT(!m_styleSheet); |
106 m_resource->addClient(this); | 107 if (SharedBuffer* data = resource->resourceBuffer()) |
107 | 108 setXSLStyleSheet(absHref, parentSheet->baseURL(), String(data->data(), d ata->size())); |
abarth-chromium
2014/09/03 05:19:47
String(data->data(), data->size()) <--- This seem
tasak
2014/09/04 11:14:40
Done.
I used TextResourceDecoder (XSLStyleSheetRes
| |
108 // If the imported sheet is in the cache, then setXSLStyleSheet gets | |
109 // called, and the sheet even gets parsed (via parseString). In this | |
110 // case we have loaded (even if our subresources haven't), so if we have | |
111 // a stylesheet after checking the cache, then we've clearly loaded. | |
112 if (!m_styleSheet) | |
113 m_loading = true; | |
114 } | |
115 } | 109 } |
116 | 110 |
117 void XSLImportRule::trace(Visitor* visitor) | 111 void XSLImportRule::trace(Visitor* visitor) |
118 { | 112 { |
119 visitor->trace(m_parentStyleSheet); | 113 visitor->trace(m_parentStyleSheet); |
120 visitor->trace(m_styleSheet); | 114 visitor->trace(m_styleSheet); |
121 } | 115 } |
122 | 116 |
123 } // namespace blink | 117 } // namespace blink |
OLD | NEW |