OLD | NEW |
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 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 #ifndef PageSerializer_h | 31 #ifndef PageSerializer_h |
32 #define PageSerializer_h | 32 #define PageSerializer_h |
33 | 33 |
| 34 #include "platform/heap/Handle.h" |
34 #include "platform/weborigin/KURL.h" | 35 #include "platform/weborigin/KURL.h" |
35 #include "platform/weborigin/KURLHash.h" | 36 #include "platform/weborigin/KURLHash.h" |
36 #include "wtf/HashMap.h" | 37 #include "wtf/HashMap.h" |
37 #include "wtf/ListHashSet.h" | 38 #include "wtf/ListHashSet.h" |
38 #include "wtf/Vector.h" | 39 #include "wtf/Vector.h" |
39 | 40 |
40 namespace blink { | 41 namespace blink { |
41 | 42 |
42 class FontResource; | 43 class FontResource; |
43 class ImageResource; | 44 class ImageResource; |
44 class CSSStyleSheet; | 45 class CSSStyleSheet; |
45 class CSSValue; | 46 class CSSValue; |
46 class Document; | 47 class Document; |
47 class LocalFrame; | 48 class LocalFrame; |
48 class Page; | 49 class Page; |
49 class RenderObject; | 50 class RenderObject; |
50 class Resource; | 51 class Resource; |
51 class SharedBuffer; | 52 class SharedBuffer; |
52 class StylePropertySet; | 53 class StylePropertySet; |
53 | 54 |
54 struct SerializedResource; | 55 struct SerializedResource; |
55 | 56 |
56 // This class is used to serialize a page contents back to text (typically HTML)
. | 57 // This class is used to serialize a page contents back to text (typically HTML)
. |
57 // It serializes all the page frames and retrieves resources such as images and
CSS stylesheets. | 58 // It serializes all the page frames and retrieves resources such as images and
CSS stylesheets. |
58 class PageSerializer { | 59 class PageSerializer final { |
| 60 STACK_ALLOCATED(); |
59 public: | 61 public: |
60 explicit PageSerializer(Vector<SerializedResource>*); | 62 explicit PageSerializer(Vector<SerializedResource>*); |
61 | 63 |
62 // Initiates the serialization of the frame's page. All serialized content a
nd retrieved | 64 // Initiates the serialization of the frame's page. All serialized content a
nd retrieved |
63 // resources are added to the Vector passed to the constructor. The first re
source in that | 65 // resources are added to the Vector passed to the constructor. The first re
source in that |
64 // vector is the top frame serialized content. | 66 // vector is the top frame serialized content. |
65 void serialize(Page*); | 67 void serialize(Page*); |
66 | 68 |
67 KURL urlForBlankFrame(LocalFrame*); | 69 KURL urlForBlankFrame(LocalFrame*); |
68 | 70 |
69 private: | 71 private: |
70 void serializeFrame(LocalFrame*); | 72 void serializeFrame(LocalFrame*); |
71 | 73 |
72 // Serializes the stylesheet back to text and adds it to the resources if UR
L is not-empty. | 74 // Serializes the stylesheet back to text and adds it to the resources if UR
L is not-empty. |
73 // It also adds any resources included in that stylesheet (including any imp
orted stylesheets and their own resources). | 75 // It also adds any resources included in that stylesheet (including any imp
orted stylesheets and their own resources). |
74 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&); | 76 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&); |
75 | 77 |
76 bool shouldAddURL(const KURL&); | 78 bool shouldAddURL(const KURL&); |
77 | 79 |
78 void addToResources(Resource *, PassRefPtr<SharedBuffer>, const KURL&); | 80 void addToResources(Resource *, PassRefPtr<SharedBuffer>, const KURL&); |
79 void addImageToResources(ImageResource*, RenderObject*, const KURL&); | 81 void addImageToResources(ImageResource*, RenderObject*, const KURL&); |
80 void addFontToResources(FontResource*); | 82 void addFontToResources(FontResource*); |
81 | 83 |
82 void retrieveResourcesForProperties(const StylePropertySet*, Document&); | 84 void retrieveResourcesForProperties(const StylePropertySet*, Document&); |
83 void retrieveResourcesForCSSValue(CSSValue*, Document&); | 85 void retrieveResourcesForCSSValue(CSSValue*, Document&); |
84 | 86 |
85 Vector<SerializedResource>* m_resources; | 87 Vector<SerializedResource>* m_resources; |
86 ListHashSet<KURL> m_resourceURLs; | 88 ListHashSet<KURL> m_resourceURLs; |
87 HashMap<LocalFrame*, KURL> m_blankFrameURLs; | 89 |
| 90 using BlankFrameURLMap = WillBeHeapHashMap<RawPtrWillBeMember<LocalFrame>, K
URL>; |
| 91 BlankFrameURLMap m_blankFrameURLs; |
88 unsigned m_blankFrameCounter; | 92 unsigned m_blankFrameCounter; |
89 }; | 93 }; |
90 | 94 |
91 } | 95 } // namespace blink |
92 | 96 |
93 #endif | 97 #endif // PageSerializer_h |
OLD | NEW |