| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/dom/StyleSheetCandidate.h" | 28 #include "core/dom/StyleSheetCandidate.h" |
| 29 | 29 |
| 30 #include "core/dom/Element.h" | 30 #include "core/dom/Element.h" |
| 31 #include "core/dom/StyleEngine.h" | 31 #include "core/dom/StyleEngine.h" |
| 32 #include "core/html/HTMLLinkElement.h" | |
| 33 #include "core/html/HTMLStyleElement.h" | 32 #include "core/html/HTMLStyleElement.h" |
| 34 #include "core/html/imports/HTMLImport.h" | 33 #include "core/html/imports/HTMLImport.h" |
| 35 | 34 |
| 36 namespace blink { | 35 namespace blink { |
| 37 | 36 |
| 38 bool StyleSheetCandidate::isImport() const | |
| 39 { | |
| 40 return m_type == HTMLLink && toHTMLLinkElement(node()).isImport(); | |
| 41 } | |
| 42 | |
| 43 Document* StyleSheetCandidate::importedDocument() const | |
| 44 { | |
| 45 ASSERT(isImport()); | |
| 46 return toHTMLLinkElement(node()).import(); | |
| 47 } | |
| 48 | |
| 49 bool StyleSheetCandidate::canBeActivated() const | 37 bool StyleSheetCandidate::canBeActivated() const |
| 50 { | 38 { |
| 51 StyleSheet* sheet = this->sheet(); | 39 StyleSheet* sheet = this->sheet(); |
| 52 return sheet && sheet->isCSSStyleSheet(); | 40 return sheet && sheet->isCSSStyleSheet(); |
| 53 } | 41 } |
| 54 | 42 |
| 55 StyleSheetCandidate::Type StyleSheetCandidate::typeOf(Node& node) | 43 StyleSheetCandidate::Type StyleSheetCandidate::typeOf(Node& node) |
| 56 { | 44 { |
| 57 if (node.isHTMLElement()) { | 45 if (node.isHTMLElement()) { |
| 58 if (isHTMLLinkElement(node)) | |
| 59 return HTMLLink; | |
| 60 if (isHTMLStyleElement(node)) | 46 if (isHTMLStyleElement(node)) |
| 61 return HTMLStyle; | 47 return HTMLStyle; |
| 62 | 48 |
| 63 ASSERT_NOT_REACHED(); | 49 ASSERT_NOT_REACHED(); |
| 64 return HTMLStyle; | 50 return HTMLStyle; |
| 65 } | 51 } |
| 66 | 52 |
| 67 ASSERT_NOT_REACHED(); | 53 ASSERT_NOT_REACHED(); |
| 68 return HTMLStyle; | 54 return HTMLStyle; |
| 69 } | 55 } |
| 70 | 56 |
| 71 StyleSheet* StyleSheetCandidate::sheet() const | 57 StyleSheet* StyleSheetCandidate::sheet() const |
| 72 { | 58 { |
| 73 switch (m_type) { | 59 switch (m_type) { |
| 74 case HTMLLink: | |
| 75 return toHTMLLinkElement(node()).sheet(); | |
| 76 case HTMLStyle: | 60 case HTMLStyle: |
| 77 return toHTMLStyleElement(node()).sheet(); | 61 return toHTMLStyleElement(node()).sheet(); |
| 78 } | 62 } |
| 79 | 63 |
| 80 ASSERT_NOT_REACHED(); | 64 ASSERT_NOT_REACHED(); |
| 81 return 0; | 65 return 0; |
| 82 } | 66 } |
| 83 | 67 |
| 84 } | 68 } |
| OLD | NEW |