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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 private: | 98 private: |
| 99 bool ShouldIgnoreHiddenElement(const Element&); | 99 bool ShouldIgnoreHiddenElement(const Element&); |
| 100 bool ShouldIgnoreMetaElement(const Element&); | 100 bool ShouldIgnoreMetaElement(const Element&); |
| 101 bool ShouldIgnorePopupOverlayElement(const Element&); | 101 bool ShouldIgnorePopupOverlayElement(const Element&); |
| 102 void GetCustomAttributesForImageElement(const HTMLImageElement&, | 102 void GetCustomAttributesForImageElement(const HTMLImageElement&, |
| 103 Vector<Attribute>*); | 103 Vector<Attribute>*); |
| 104 void GetCustomAttributesForFormControlElement(const Element&, | 104 void GetCustomAttributesForFormControlElement(const Element&, |
| 105 Vector<Attribute>*); | 105 Vector<Attribute>*); |
| 106 | 106 |
| 107 WebFrameSerializer::MHTMLPartsGenerationDelegate& web_delegate_; | 107 WebFrameSerializer::MHTMLPartsGenerationDelegate& web_delegate_; |
| 108 bool has_popup_overlays_skipped_; | |
| 108 }; | 109 }; |
| 109 | 110 |
| 110 MHTMLFrameSerializerDelegate::MHTMLFrameSerializerDelegate( | 111 MHTMLFrameSerializerDelegate::MHTMLFrameSerializerDelegate( |
| 111 WebFrameSerializer::MHTMLPartsGenerationDelegate& web_delegate) | 112 WebFrameSerializer::MHTMLPartsGenerationDelegate& web_delegate) |
| 112 : web_delegate_(web_delegate) {} | 113 : web_delegate_(web_delegate), has_popup_overlays_skipped_(false) {} |
| 113 | 114 |
| 114 bool MHTMLFrameSerializerDelegate::ShouldIgnoreElement(const Element& element) { | 115 bool MHTMLFrameSerializerDelegate::ShouldIgnoreElement(const Element& element) { |
| 115 if (ShouldIgnoreHiddenElement(element)) | 116 if (ShouldIgnoreHiddenElement(element)) |
| 116 return true; | 117 return true; |
| 117 if (ShouldIgnoreMetaElement(element)) | 118 if (ShouldIgnoreMetaElement(element)) |
| 118 return true; | 119 return true; |
| 119 if (web_delegate_.RemovePopupOverlay() && | 120 if (web_delegate_.RemovePopupOverlay() && |
| 120 ShouldIgnorePopupOverlayElement(element)) { | 121 ShouldIgnorePopupOverlayElement(element)) { |
| 121 return true; | 122 return true; |
| 122 } | 123 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 LocalDOMWindow* window = element.GetDocument().domWindow(); | 164 LocalDOMWindow* window = element.GetDocument().domWindow(); |
| 164 DCHECK(window); | 165 DCHECK(window); |
| 165 LayoutPoint center_point(window->innerWidth() / 2, window->innerHeight() / 2); | 166 LayoutPoint center_point(window->innerWidth() / 2, window->innerHeight() / 2); |
| 166 if (!box->FrameRect().Contains(center_point)) | 167 if (!box->FrameRect().Contains(center_point)) |
| 167 return false; | 168 return false; |
| 168 | 169 |
| 169 // The z-index should be greater than the threshold. | 170 // The z-index should be greater than the threshold. |
| 170 if (box->Style()->ZIndex() < kPopupOverlayZIndexThreshold) | 171 if (box->Style()->ZIndex() < kPopupOverlayZIndexThreshold) |
| 171 return false; | 172 return false; |
| 172 | 173 |
| 174 if (!has_popup_overlays_skipped_) { | |
| 175 has_popup_overlays_skipped_ = true; | |
| 176 UMA_HISTOGRAM_BOOLEAN( | |
| 177 "PageSerialization.MhtmlGeneration.PopupOverlaySkippedCount", true); | |
|
Steven Holte
2017/04/27 23:41:53
Actually the name of this histogram and how you ar
jianli
2017/04/28 00:52:07
Done.
| |
| 178 } | |
| 179 | |
| 173 return true; | 180 return true; |
| 174 } | 181 } |
| 175 | 182 |
| 176 bool MHTMLFrameSerializerDelegate::ShouldIgnoreAttribute( | 183 bool MHTMLFrameSerializerDelegate::ShouldIgnoreAttribute( |
| 177 const Element& element, | 184 const Element& element, |
| 178 const Attribute& attribute) { | 185 const Attribute& attribute) { |
| 179 // TODO(fgorski): Presence of srcset attribute causes MHTML to not display | 186 // TODO(fgorski): Presence of srcset attribute causes MHTML to not display |
| 180 // images, as only the value of src is pulled into the archive. Discarding | 187 // images, as only the value of src is pulled into the archive. Discarding |
| 181 // srcset prevents the problem. Long term we should make sure to MHTML plays | 188 // srcset prevents the problem. Long term we should make sure to MHTML plays |
| 182 // nicely with srcset. | 189 // nicely with srcset. |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 const WebString& base_target) { | 467 const WebString& base_target) { |
| 461 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. | 468 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. |
| 462 if (base_target.IsEmpty()) | 469 if (base_target.IsEmpty()) |
| 463 return String("<base href=\".\">"); | 470 return String("<base href=\".\">"); |
| 464 String base_string = "<base href=\".\" target=\"" + | 471 String base_string = "<base href=\".\" target=\"" + |
| 465 static_cast<const String&>(base_target) + "\">"; | 472 static_cast<const String&>(base_target) + "\">"; |
| 466 return base_string; | 473 return base_string; |
| 467 } | 474 } |
| 468 | 475 |
| 469 } // namespace blink | 476 } // namespace blink |
| OLD | NEW |