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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 class Page; | 48 class Page; |
49 class RenderObject; | 49 class RenderObject; |
50 class Resource; | 50 class Resource; |
51 class SharedBuffer; | 51 class SharedBuffer; |
52 class StylePropertySet; | 52 class StylePropertySet; |
53 class StyleRule; | 53 class StyleRule; |
54 class StyleRuleFontFace; | 54 class StyleRuleFontFace; |
55 | 55 |
56 struct SerializedResource; | 56 struct SerializedResource; |
57 | 57 |
| 58 // This hash map is used to map resource URL of original link to its local |
| 59 // file path. |
| 60 typedef HashMap<String, String> LinkLocalPathMap; |
| 61 |
58 // This class is used to serialize a page contents back to text (typically HTML)
. | 62 // This class is used to serialize a page contents back to text (typically HTML)
. |
59 // It serializes all the page frames and retrieves resources such as images and
CSS stylesheets. | 63 // It serializes all the page frames and retrieves resources such as images and
CSS stylesheets. |
60 class PageSerializer { | 64 class PageSerializer { |
61 public: | 65 public: |
62 explicit PageSerializer(Vector<SerializedResource>*); | 66 PageSerializer(Vector<SerializedResource>*, LinkLocalPathMap* = 0, String di
rectory = ""); |
63 | 67 |
64 // Initiates the serialization of the frame's page. All serialized content a
nd retrieved | 68 // Initiates the serialization of the frame's page. All serialized content a
nd retrieved |
65 // resources are added to the Vector passed to the constructor. The first re
source in that | 69 // resources are added to the Vector passed to the constructor. The first re
source in that |
66 // vector is the top frame serialized content. | 70 // vector is the top frame serialized content. |
67 void serialize(Page*); | 71 void serialize(Page*); |
68 | 72 |
69 KURL urlForBlankFrame(Frame*); | 73 KURL urlForBlankFrame(Frame*); |
70 | 74 |
71 private: | 75 private: |
72 void serializeFrame(Frame*); | 76 void serializeFrame(Frame*); |
73 | 77 |
74 // Serializes the stylesheet back to text and adds it to the resources if UR
L is not-empty. | 78 // Serializes the stylesheet back to text and adds it to the resources if UR
L is not-empty. |
75 // It also adds any resources included in that stylesheet (including any imp
orted stylesheets and their own resources). | 79 // It also adds any resources included in that stylesheet (including any imp
orted stylesheets and their own resources). |
76 void serializeCSSStyleSheet(CSSStyleSheet*, const KURL&); | 80 void serializeCSSStyleSheet(CSSStyleSheet*, const KURL&); |
77 | 81 |
78 bool shouldAddURL(const KURL&); | 82 bool shouldAddURL(const KURL&); |
79 | 83 |
80 void addToResources(Resource *, PassRefPtr<SharedBuffer>, const KURL&); | 84 void addToResources(Resource *, PassRefPtr<SharedBuffer>, const KURL&); |
81 void addImageToResources(ImageResource*, RenderObject*, const KURL&); | 85 void addImageToResources(ImageResource*, RenderObject*, const KURL&); |
82 void addFontToResources(FontResource*); | 86 void addFontToResources(FontResource*); |
83 | 87 |
84 void retrieveResourcesForProperties(const StylePropertySet*, Document*); | 88 void retrieveResourcesForProperties(const StylePropertySet*, Document*); |
85 void retrieveResourcesForCSSValue(CSSValue*, Document*); | 89 void retrieveResourcesForCSSValue(CSSValue*, Document*); |
86 | 90 |
87 Vector<SerializedResource>* m_resources; | 91 Vector<SerializedResource>* m_resources; |
88 ListHashSet<KURL> m_resourceURLs; | 92 ListHashSet<KURL> m_resourceURLs; |
89 HashMap<Frame*, KURL> m_blankFrameURLs; | 93 HashMap<Frame*, KURL> m_blankFrameURLs; |
| 94 LinkLocalPathMap* m_URLs; |
| 95 String m_directory; |
90 unsigned m_blankFrameCounter; | 96 unsigned m_blankFrameCounter; |
91 }; | 97 }; |
92 | 98 |
93 } | 99 } |
94 | 100 |
95 #endif | 101 #endif |
OLD | NEW |