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

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

Issue 2538953002: Remove hidden elements from MHTML (Closed)
Patch Set: Address feedback Created 4 years 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 eaa7ce181b5c6717af265c81928a8a5f1c8fe951..427b91bd0f6ec0a3bdc6db9efa38846de2a78d6f 100644
--- a/third_party/WebKit/Source/web/WebFrameSerializer.cpp
+++ b/third_party/WebKit/Source/web/WebFrameSerializer.cpp
@@ -81,6 +81,7 @@ class MHTMLFrameSerializerDelegate final : public FrameSerializer::Delegate {
public:
explicit MHTMLFrameSerializerDelegate(
WebFrameSerializer::MHTMLPartsGenerationDelegate&);
+ bool shouldIgnoreElement(const Element&) override;
bool shouldIgnoreAttribute(const Element&, const Attribute&) override;
bool rewriteLink(const Element&, String& rewrittenLink) override;
bool shouldSkipResourceWithURL(const KURL&) override;
@@ -94,6 +95,11 @@ MHTMLFrameSerializerDelegate::MHTMLFrameSerializerDelegate(
WebFrameSerializer::MHTMLPartsGenerationDelegate& webDelegate)
: m_webDelegate(webDelegate) {}
+bool MHTMLFrameSerializerDelegate::shouldIgnoreElement(const Element& element) {
+ // Do not include elements that are hidden and affect no layout.
+ return !element.layoutObject();
tkent 2016/12/01 14:56:43 Though I suggested this, it drops <head>, <meta>,
jianli 2016/12/07 02:21:02 We don't want to drop <head>, <meta>, <style>, <li
+}
+
bool MHTMLFrameSerializerDelegate::shouldIgnoreAttribute(
const Element& element,
const Attribute& attribute) {

Powered by Google App Engine
This is Rietveld 408576698