Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Unified Diff: third_party/WebKit/Source/web/WebFrameSerializer.cpp

Issue 2826533002: Merge to M59: Only skip certain hidden elements at MHTML serialization (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/WebFrameSerializer.cpp
diff --git a/third_party/WebKit/Source/web/WebFrameSerializer.cpp b/third_party/WebKit/Source/web/WebFrameSerializer.cpp
index f178033f0bb4787cf31822eae7634d7b05e26ca0..8dd4fd826ff07edc13d1bf0c8f2067da67d865fd 100644
--- a/third_party/WebKit/Source/web/WebFrameSerializer.cpp
+++ b/third_party/WebKit/Source/web/WebFrameSerializer.cpp
@@ -31,6 +31,7 @@
#include "public/web/WebFrameSerializer.h"
#include "core/HTMLNames.h"
+#include "core/InputTypeNames.h"
#include "core/dom/Document.h"
#include "core/dom/Element.h"
#include "core/frame/Frame.h"
@@ -124,21 +125,13 @@ bool MHTMLFrameSerializerDelegate::ShouldIgnoreElement(const Element& element) {
bool MHTMLFrameSerializerDelegate::ShouldIgnoreHiddenElement(
const Element& element) {
- // Do not include elements that are are set to hidden without affecting layout
- // by the page. For those elements that are hidden by default, they will not
- // be excluded:
- // 1) All elements that are head or part of head, including head, meta, style,
- // link and etc.
- // 2) Some specific elements in body: meta, style, datalist, option and etc.
- if (element.GetLayoutObject())
- return false;
- if (isHTMLHeadElement(element) || isHTMLMetaElement(element) ||
- isHTMLStyleElement(element) || isHTMLDataListElement(element) ||
- isHTMLOptionElement(element) || isHTMLLinkElement(element)) {
- return false;
- }
- Element* parent = element.parentElement();
- return parent && !isHTMLHeadElement(parent);
+ // Do not include the element that is marked with hidden attribute.
+ if (element.FastHasAttribute(HTMLNames::hiddenAttr))
+ return true;
+
+ // Do not include the hidden form element.
+ return isHTMLInputElement(element) &&
+ toHTMLInputElement(&element)->type() == InputTypeNames::hidden;
}
bool MHTMLFrameSerializerDelegate::ShouldIgnoreMetaElement(
« no previous file with comments | « chrome/browser/download/save_page_browsertest.cc ('k') | third_party/WebKit/Source/web/tests/WebFrameSerializerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698