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

Side by Side Diff: third_party/WebKit/Source/core/page/PageSerializer.h

Issue 1441553002: Generating CIDs in Blink during MHTML serialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mhtml-per-frame-page-serializer-only
Patch Set: Replace list Replaced initializer lists with array initialization. Created 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 17 matching lines...) Expand all
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 #ifndef PageSerializer_h 31 #ifndef PageSerializer_h
32 #define PageSerializer_h 32 #define PageSerializer_h
33 33
34 #include "core/CoreExport.h" 34 #include "core/CoreExport.h"
35 #include "platform/heap/Handle.h" 35 #include "platform/heap/Handle.h"
36 #include "platform/weborigin/KURL.h" 36 #include "platform/weborigin/KURL.h"
37 #include "platform/weborigin/KURLHash.h" 37 #include "platform/weborigin/KURLHash.h"
38 #include "wtf/HashMap.h"
39 #include "wtf/ListHashSet.h" 38 #include "wtf/ListHashSet.h"
40 #include "wtf/PassOwnPtr.h" 39 #include "wtf/PassOwnPtr.h"
41 #include "wtf/Vector.h" 40 #include "wtf/Vector.h"
41 #include "wtf/text/WTFString.h"
42 42
43 namespace blink { 43 namespace blink {
44 44
45 class Attribute; 45 class Attribute;
46 class FontResource;
47 class ImageResource;
48 class CSSRule; 46 class CSSRule;
49 class CSSStyleSheet; 47 class CSSStyleSheet;
50 class CSSValue; 48 class CSSValue;
51 class Document; 49 class Document;
50 class Element;
51 class FontResource;
52 class ImageResource;
52 class LocalFrame; 53 class LocalFrame;
53 class Node; 54 class Node;
54 class Page; 55 class Page;
55 class LayoutObject; 56 class LayoutObject;
56 class Resource; 57 class Resource;
57 class SharedBuffer; 58 class SharedBuffer;
58 class StylePropertySet; 59 class StylePropertySet;
59 60
60 struct SerializedResource; 61 struct SerializedResource;
61 62
62 // This class is used to serialize frame's contents back to text (typically HTML ). 63 // This class is used to serialize frame's contents back to text (typically HTML ).
63 // It serializes frame's document and resources such as images and CSS styleshee ts. 64 // It serializes frame's document and resources such as images and CSS styleshee ts.
64 // TODO(lukasza): Rename this class to FrameSerializer. 65 // TODO(lukasza): Rename this class to FrameSerializer.
65 class CORE_EXPORT PageSerializer final { 66 class CORE_EXPORT PageSerializer final {
66 STACK_ALLOCATED(); 67 STACK_ALLOCATED();
67 public: 68 public:
68 class Delegate { 69 class Delegate {
69 USING_FAST_MALLOC(Delegate);
70 public: 70 public:
71 virtual ~Delegate() { }
72 virtual bool shouldIgnoreAttribute(const Attribute&) = 0; 71 virtual bool shouldIgnoreAttribute(const Attribute&) = 0;
72
73 // Method allowing the Delegate control which URLs are written into the
74 // generated html document.
75 //
76 // When URL of the element needs to be rewritten, this method should
77 // return true and populate |rewrittenLink| with a desired value of the
78 // html attribute value to be used in place of the original link.
79 // (i.e. in place of img.src or iframe.src or object.data).
80 //
81 // If no link rewriting is desired, this method should return false.
82 virtual bool rewriteLink(const Element&, String& rewrittenLink) = 0;
73 }; 83 };
74 84
75 PageSerializer(Vector<SerializedResource>*, PassOwnPtr<Delegate>); 85 // Constructs a serializer that will write output to the given vector of
86 // SerializedResources and use the optional Delegate for controlling some
87 // serialization aspects. Callers need to ensure that the Delegate stays
88 // alive until the PageSerializer gets destroyed.
89 PageSerializer(Vector<SerializedResource>&, Delegate*);
76 90
77 // Initiates the serialization of the frame. All serialized content and 91 // Initiates the serialization of the frame. All serialized content and
78 // retrieved resources are added to the Vector passed to the constructor. 92 // retrieved resources are added to the Vector passed to the constructor.
79 // The first resource in that vector is the frame's serialized content. 93 // The first resource in that vector is the frame's serialized content.
80 // Subsequent resources are images, css, etc. 94 // Subsequent resources are images, css, etc.
81 void serializeFrame(const LocalFrame&); 95 void serializeFrame(const LocalFrame&);
82 96
83 void registerRewriteURL(const String& from, const String& to);
84 void setRewriteURLFolder(const String&);
85
86 KURL urlForBlankFrame(const LocalFrame&);
87
88 Delegate* delegate(); 97 Delegate* delegate();
89 98
90 static String markOfTheWebDeclaration(const KURL&); 99 static String markOfTheWebDeclaration(const KURL&);
91 100
92 private: 101 private:
93 // Serializes the stylesheet back to text and adds it to the resources if UR L is not-empty. 102 // Serializes the stylesheet back to text and adds it to the resources if UR L is not-empty.
94 // It also adds any resources included in that stylesheet (including any imp orted stylesheets and their own resources). 103 // It also adds any resources included in that stylesheet (including any imp orted stylesheets and their own resources).
95 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&); 104 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&);
96 105
97 // Serializes the css rule (including any imported stylesheets), adding refe renced resources. 106 // Serializes the css rule (including any imported stylesheets), adding refe renced resources.
98 void serializeCSSRule(CSSRule*); 107 void serializeCSSRule(CSSRule*);
99 108
100 bool shouldAddURL(const KURL&); 109 bool shouldAddURL(const KURL&);
101 110
102 void addToResources(Resource *, PassRefPtr<SharedBuffer>, const KURL&); 111 void addToResources(Resource *, PassRefPtr<SharedBuffer>, const KURL&);
103 void addImageToResources(ImageResource*, const KURL&); 112 void addImageToResources(ImageResource*, const KURL&);
104 void addFontToResources(FontResource*); 113 void addFontToResources(FontResource*);
105 114
106 void retrieveResourcesForProperties(const StylePropertySet*, Document&); 115 void retrieveResourcesForProperties(const StylePropertySet*, Document&);
107 void retrieveResourcesForCSSValue(CSSValue*, Document&); 116 void retrieveResourcesForCSSValue(CSSValue*, Document&);
108 117
109 Vector<SerializedResource>* m_resources; 118 Vector<SerializedResource>* m_resources;
110 ListHashSet<KURL> m_resourceURLs; 119 ListHashSet<KURL> m_resourceURLs;
111 120
112 using BlankFrameURLMap = WillBeHeapHashMap<RawPtrWillBeMember<const LocalFra me>, KURL>; 121 Delegate* m_delegate;
113 BlankFrameURLMap m_blankFrameURLs;
114 HashMap<String, String> m_rewriteURLs;
115 String m_rewriteFolder;
116 unsigned m_blankFrameCounter;
117
118 OwnPtr<Delegate> m_delegate;
119 }; 122 };
120 123
121 // TODO(lukasza): Stop exposing this implementation detail once the serializers 124 // TODO(lukasza): Stop exposing this implementation detail once the serializers
122 // are merged. 125 // are merged.
123 CORE_EXPORT bool isCharsetSpecifyingNode(const Node&); 126 CORE_EXPORT bool isCharsetSpecifyingNode(const Node&);
124 127
125 } // namespace blink 128 } // namespace blink
126 129
127 #endif // PageSerializer_h 130 #endif // PageSerializer_h
OLDNEW
« no previous file with comments | « chrome/test/data/save_page/frames-runtime-changes.htm ('k') | third_party/WebKit/Source/core/page/PageSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698