| 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/HTMLImageElement.h" | 44 #include "core/html/HTMLImageElement.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 return true; | 118 return true; |
| 118 if (web_delegate_.RemovePopupOverlay() && | 119 if (web_delegate_.RemovePopupOverlay() && |
| 119 ShouldIgnorePopupOverlayElement(element)) { | 120 ShouldIgnorePopupOverlayElement(element)) { |
| 120 return true; | 121 return true; |
| 121 } | 122 } |
| 122 return false; | 123 return false; |
| 123 } | 124 } |
| 124 | 125 |
| 125 bool MHTMLFrameSerializerDelegate::ShouldIgnoreHiddenElement( | 126 bool MHTMLFrameSerializerDelegate::ShouldIgnoreHiddenElement( |
| 126 const Element& element) { | 127 const Element& element) { |
| 127 // Do not include elements that are are set to hidden without affecting layout | 128 // Do not include the element that is marked with hidden attribute. |
| 128 // by the page. For those elements that are hidden by default, they will not | 129 if (element.FastHasAttribute(HTMLNames::hiddenAttr)) |
| 129 // be excluded: | 130 return true; |
| 130 // 1) All elements that are head or part of head, including head, meta, style, | 131 |
| 131 // link and etc. | 132 // Do not include the hidden form element. |
| 132 // 2) Some specific elements in body: meta, style, datalist, option and etc. | 133 return isHTMLInputElement(element) && |
| 133 if (element.GetLayoutObject()) | 134 toHTMLInputElement(&element)->type() == InputTypeNames::hidden; |
| 134 return false; | |
| 135 if (isHTMLHeadElement(element) || isHTMLMetaElement(element) || | |
| 136 isHTMLStyleElement(element) || isHTMLDataListElement(element) || | |
| 137 isHTMLOptionElement(element) || isHTMLLinkElement(element)) { | |
| 138 return false; | |
| 139 } | |
| 140 Element* parent = element.parentElement(); | |
| 141 return parent && !isHTMLHeadElement(parent); | |
| 142 } | 135 } |
| 143 | 136 |
| 144 bool MHTMLFrameSerializerDelegate::ShouldIgnoreMetaElement( | 137 bool MHTMLFrameSerializerDelegate::ShouldIgnoreMetaElement( |
| 145 const Element& element) { | 138 const Element& element) { |
| 146 // Do not include meta elements that declare Content-Security-Policy | 139 // Do not include meta elements that declare Content-Security-Policy |
| 147 // directives. They should have already been enforced when the original | 140 // directives. They should have already been enforced when the original |
| 148 // document is loaded. Since only the rendered resources are encapsulated in | 141 // document is loaded. Since only the rendered resources are encapsulated in |
| 149 // the saved MHTML page, there is no need to carry the directives. If they | 142 // the saved MHTML page, there is no need to carry the directives. If they |
| 150 // are still kept in the MHTML, child frames that are referred to using cid: | 143 // are still kept in the MHTML, child frames that are referred to using cid: |
| 151 // scheme could be prevented from loading. | 144 // scheme could be prevented from loading. |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 const WebString& base_target) { | 460 const WebString& base_target) { |
| 468 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. | 461 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. |
| 469 if (base_target.IsEmpty()) | 462 if (base_target.IsEmpty()) |
| 470 return String("<base href=\".\">"); | 463 return String("<base href=\".\">"); |
| 471 String base_string = "<base href=\".\" target=\"" + | 464 String base_string = "<base href=\".\" target=\"" + |
| 472 static_cast<const String&>(base_target) + "\">"; | 465 static_cast<const String&>(base_target) + "\">"; |
| 473 return base_string; | 466 return base_string; |
| 474 } | 467 } |
| 475 | 468 |
| 476 } // namespace blink | 469 } // namespace blink |
| OLD | NEW |