| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #include "wtf/Vector.h" | 58 #include "wtf/Vector.h" |
| 59 #include "wtf/text/StringConcatenate.h" | 59 #include "wtf/text/StringConcatenate.h" |
| 60 | 60 |
| 61 using namespace WebCore; | 61 using namespace WebCore; |
| 62 | 62 |
| 63 namespace { | 63 namespace { |
| 64 | 64 |
| 65 KURL getSubResourceURLFromElement(Element* element) | 65 KURL getSubResourceURLFromElement(Element* element) |
| 66 { | 66 { |
| 67 ASSERT(element); | 67 ASSERT(element); |
| 68 const QualifiedName* attributeName = 0; | 68 const QualifiedName* attributeName = element->subResourceAttributeName(); |
| 69 if (element->hasTagName(HTMLNames::imgTag) || element->hasTagName(HTMLNames:
:scriptTag)) | |
| 70 attributeName = &HTMLNames::srcAttr; | |
| 71 else if (element->hasTagName(HTMLNames::inputTag)) { | |
| 72 if (toHTMLInputElement(element)->isImageButton()) | |
| 73 attributeName = &HTMLNames::srcAttr; | |
| 74 } else if (element->hasTagName(HTMLNames::bodyTag) | |
| 75 || element->hasTagName(HTMLNames::tableTag) | |
| 76 || element->hasTagName(HTMLNames::trTag) | |
| 77 || element->hasTagName(HTMLNames::tdTag)) | |
| 78 attributeName = &HTMLNames::backgroundAttr; | |
| 79 else if (element->hasTagName(HTMLNames::blockquoteTag) | |
| 80 || element->hasTagName(HTMLNames::qTag) | |
| 81 || element->hasTagName(HTMLNames::delTag) | |
| 82 || element->hasTagName(HTMLNames::insTag)) | |
| 83 attributeName = &HTMLNames::citeAttr; | |
| 84 else if (element->hasTagName(HTMLNames::linkTag)) { | |
| 85 // If the link element is not css, ignore it. | |
| 86 if (equalIgnoringCase(element->getAttribute(HTMLNames::typeAttr), "text/
css")) { | |
| 87 // FIXME: Add support for extracting links of sub-resources which | |
| 88 // are inside style-sheet such as @import, @font-face, url(), etc. | |
| 89 attributeName = &HTMLNames::hrefAttr; | |
| 90 } | |
| 91 } else if (element->hasTagName(HTMLNames::objectTag)) | |
| 92 attributeName = &HTMLNames::dataAttr; | |
| 93 else if (element->hasTagName(HTMLNames::embedTag)) | |
| 94 attributeName = &HTMLNames::srcAttr; | |
| 95 | |
| 96 if (!attributeName) | 69 if (!attributeName) |
| 97 return KURL(); | 70 return KURL(); |
| 98 | 71 |
| 99 String value = element->getAttribute(*attributeName); | 72 String value = element->getAttribute(*attributeName); |
| 100 // Ignore javascript content. | 73 // Ignore javascript content. |
| 101 if (value.isEmpty() || value.stripWhiteSpace().startsWith("javascript:", fal
se)) | 74 if (value.isEmpty() || value.stripWhiteSpace().startsWith("javascript:", fal
se)) |
| 102 return KURL(); | 75 return KURL(); |
| 103 | 76 |
| 104 return element->document().completeURL(value); | 77 return element->document().completeURL(value); |
| 105 } | 78 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 262 |
| 290 WebString WebPageSerializer::generateBaseTagDeclaration(const WebString& baseTar
get) | 263 WebString WebPageSerializer::generateBaseTagDeclaration(const WebString& baseTar
get) |
| 291 { | 264 { |
| 292 if (baseTarget.isEmpty()) | 265 if (baseTarget.isEmpty()) |
| 293 return String("<base href=\".\">"); | 266 return String("<base href=\".\">"); |
| 294 String baseString = "<base href=\".\" target=\"" + static_cast<const String&
>(baseTarget) + "\">"; | 267 String baseString = "<base href=\".\" target=\"" + static_cast<const String&
>(baseTarget) + "\">"; |
| 295 return baseString; | 268 return baseString; |
| 296 } | 269 } |
| 297 | 270 |
| 298 } // namespace blink | 271 } // namespace blink |
| OLD | NEW |