Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "public/web/WebFrameSerializer.h" | 31 #include "public/web/WebFrameSerializer.h" |
| 32 | 32 |
| 33 #include "core/HTMLNames.h" | 33 #include "core/HTMLNames.h" |
| 34 #include "core/InputTypeNames.h" | |
| 34 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
| 35 #include "core/dom/Element.h" | 36 #include "core/dom/Element.h" |
| 36 #include "core/frame/Frame.h" | 37 #include "core/frame/Frame.h" |
| 37 #include "core/frame/FrameSerializer.h" | 38 #include "core/frame/FrameSerializer.h" |
| 38 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
| 39 #include "core/frame/RemoteFrame.h" | 40 #include "core/frame/RemoteFrame.h" |
| 40 #include "core/html/HTMLAllCollection.h" | 41 #include "core/html/HTMLAllCollection.h" |
| 41 #include "core/html/HTMLFrameElementBase.h" | 42 #include "core/html/HTMLFrameElementBase.h" |
| 42 #include "core/html/HTMLFrameOwnerElement.h" | 43 #include "core/html/HTMLFrameOwnerElement.h" |
| 43 #include "core/html/HTMLInputElement.h" | 44 #include "core/html/HTMLInputElement.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 74 namespace blink { | 75 namespace blink { |
| 75 | 76 |
| 76 namespace { | 77 namespace { |
| 77 | 78 |
| 78 class MHTMLFrameSerializerDelegate final : public FrameSerializer::Delegate { | 79 class MHTMLFrameSerializerDelegate final : public FrameSerializer::Delegate { |
| 79 WTF_MAKE_NONCOPYABLE(MHTMLFrameSerializerDelegate); | 80 WTF_MAKE_NONCOPYABLE(MHTMLFrameSerializerDelegate); |
| 80 | 81 |
| 81 public: | 82 public: |
| 82 explicit MHTMLFrameSerializerDelegate( | 83 explicit MHTMLFrameSerializerDelegate( |
| 83 WebFrameSerializer::MHTMLPartsGenerationDelegate&); | 84 WebFrameSerializer::MHTMLPartsGenerationDelegate&); |
| 85 bool shouldIgnoreElement(const Element&) override; | |
| 84 bool shouldIgnoreAttribute(const Element&, const Attribute&) override; | 86 bool shouldIgnoreAttribute(const Element&, const Attribute&) override; |
| 85 bool rewriteLink(const Element&, String& rewrittenLink) override; | 87 bool rewriteLink(const Element&, String& rewrittenLink) override; |
| 86 bool shouldSkipResourceWithURL(const KURL&) override; | 88 bool shouldSkipResourceWithURL(const KURL&) override; |
| 87 bool shouldSkipResource(const Resource&) override; | 89 bool shouldSkipResource(const Resource&) override; |
| 88 | 90 |
| 89 private: | 91 private: |
| 90 WebFrameSerializer::MHTMLPartsGenerationDelegate& m_webDelegate; | 92 WebFrameSerializer::MHTMLPartsGenerationDelegate& m_webDelegate; |
| 91 }; | 93 }; |
| 92 | 94 |
| 93 MHTMLFrameSerializerDelegate::MHTMLFrameSerializerDelegate( | 95 MHTMLFrameSerializerDelegate::MHTMLFrameSerializerDelegate( |
| 94 WebFrameSerializer::MHTMLPartsGenerationDelegate& webDelegate) | 96 WebFrameSerializer::MHTMLPartsGenerationDelegate& webDelegate) |
| 95 : m_webDelegate(webDelegate) {} | 97 : m_webDelegate(webDelegate) {} |
| 96 | 98 |
| 99 bool MHTMLFrameSerializerDelegate::shouldIgnoreElement(const Element& element) { | |
| 100 // Do not include any hidden elements since they will not be made visible | |
| 101 // due to the fact that the script execution is disabled for MHTML loading. | |
| 102 if (element.hasAttribute(HTMLNames::hiddenAttr)) | |
| 103 return true; | |
| 104 return isHTMLInputElement(element) && | |
| 105 toHTMLInputElement(&element)->type() == InputTypeNames::hidden; | |
| 106 } | |
|
tkent
2016/11/30 08:22:34
Can you check existence of layoutObject(), or chec
jianli
2016/12/01 02:13:08
Done.
| |
| 107 | |
| 97 bool MHTMLFrameSerializerDelegate::shouldIgnoreAttribute( | 108 bool MHTMLFrameSerializerDelegate::shouldIgnoreAttribute( |
| 98 const Element& element, | 109 const Element& element, |
| 99 const Attribute& attribute) { | 110 const Attribute& attribute) { |
| 100 // TODO(fgorski): Presence of srcset attribute causes MHTML to not display | 111 // TODO(fgorski): Presence of srcset attribute causes MHTML to not display |
| 101 // images, as only the value of src is pulled into the archive. Discarding | 112 // images, as only the value of src is pulled into the archive. Discarding |
| 102 // srcset prevents the problem. Long term we should make sure to MHTML plays | 113 // srcset prevents the problem. Long term we should make sure to MHTML plays |
| 103 // nicely with srcset. | 114 // nicely with srcset. |
| 104 if (attribute.localName() == HTMLNames::srcsetAttr) | 115 if (attribute.localName() == HTMLNames::srcsetAttr) |
| 105 return true; | 116 return true; |
| 106 | 117 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 const WebString& baseTarget) { | 325 const WebString& baseTarget) { |
| 315 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. | 326 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. |
| 316 if (baseTarget.isEmpty()) | 327 if (baseTarget.isEmpty()) |
| 317 return String("<base href=\".\">"); | 328 return String("<base href=\".\">"); |
| 318 String baseString = "<base href=\".\" target=\"" + | 329 String baseString = "<base href=\".\" target=\"" + |
| 319 static_cast<const String&>(baseTarget) + "\">"; | 330 static_cast<const String&>(baseTarget) + "\">"; |
| 320 return baseString; | 331 return baseString; |
| 321 } | 332 } |
| 322 | 333 |
| 323 } // namespace blink | 334 } // namespace blink |
| OLD | NEW |