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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // return true and populate |rewrittenLink| with a desired value of the | 78 // return true and populate |rewrittenLink| with a desired value of the |
79 // html attribute value to be used in place of the original link. | 79 // html attribute value to be used in place of the original link. |
80 // (i.e. in place of img.src or iframe.src or object.data). | 80 // (i.e. in place of img.src or iframe.src or object.data). |
81 // | 81 // |
82 // If no link rewriting is desired, this method should return false. | 82 // If no link rewriting is desired, this method should return false. |
83 virtual bool rewriteLink(const Element&, String& rewrittenLink) | 83 virtual bool rewriteLink(const Element&, String& rewrittenLink) |
84 { | 84 { |
85 return false; | 85 return false; |
86 } | 86 } |
87 | 87 |
88 // Tells whether to skip serialization of a subresource with a given URI
. | 88 // Tells whether to skip serialization of a subresource or CSSStyleSheet |
89 // Used to deduplicate resources across multiple frames. | 89 // with a given URI. Used to deduplicate resources across multiple frame
s. |
90 virtual bool shouldSkipResource(const KURL&) | 90 virtual bool shouldSkipResourceWithURL(const KURL&) |
91 { | 91 { |
92 return false; | 92 return false; |
93 } | 93 } |
| 94 |
| 95 // Tells whether to skip serialization of a subresource. |
| 96 virtual bool shouldSkipResource(const Resource&) |
| 97 { |
| 98 return false; |
| 99 } |
94 }; | 100 }; |
95 | 101 |
96 // Constructs a serializer that will write output to the given vector of | 102 // Constructs a serializer that will write output to the given vector of |
97 // SerializedResources and uses the Delegate for controlling some | 103 // SerializedResources and uses the Delegate for controlling some |
98 // serialization aspects. Callers need to ensure that both arguments stay | 104 // serialization aspects. Callers need to ensure that both arguments stay |
99 // alive until the FrameSerializer gets destroyed. | 105 // alive until the FrameSerializer gets destroyed. |
100 FrameSerializer(Vector<SerializedResource>&, Delegate&); | 106 FrameSerializer(Vector<SerializedResource>&, Delegate&); |
101 | 107 |
102 // Initiates the serialization of the frame. All serialized content and | 108 // Initiates the serialization of the frame. All serialized content and |
103 // retrieved resources are added to the Vector passed to the constructor. | 109 // retrieved resources are added to the Vector passed to the constructor. |
104 // The first resource in that vector is the frame's serialized content. | 110 // The first resource in that vector is the frame's serialized content. |
105 // Subsequent resources are images, css, etc. | 111 // Subsequent resources are images, css, etc. |
106 void serializeFrame(const LocalFrame&); | 112 void serializeFrame(const LocalFrame&); |
107 | 113 |
108 static String markOfTheWebDeclaration(const KURL&); | 114 static String markOfTheWebDeclaration(const KURL&); |
109 | 115 |
110 private: | 116 private: |
111 // Serializes the stylesheet back to text and adds it to the resources if UR
L is not-empty. | 117 // Serializes the stylesheet back to text and adds it to the resources if UR
L is not-empty. |
112 // It also adds any resources included in that stylesheet (including any imp
orted stylesheets and their own resources). | 118 // It also adds any resources included in that stylesheet (including any imp
orted stylesheets and their own resources). |
113 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&); | 119 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&); |
114 | 120 |
115 // Serializes the css rule (including any imported stylesheets), adding refe
renced resources. | 121 // Serializes the css rule (including any imported stylesheets), adding refe
renced resources. |
116 void serializeCSSRule(CSSRule*); | 122 void serializeCSSRule(CSSRule*); |
117 | 123 |
118 bool shouldAddURL(const KURL&); | 124 bool shouldAddURL(const KURL&); |
119 | 125 |
120 void addToResources(Resource *, PassRefPtr<SharedBuffer>, const KURL&); | 126 void addToResources(const Resource&, PassRefPtr<SharedBuffer>, const KURL&); |
121 void addImageToResources(ImageResource*, const KURL&); | 127 void addImageToResources(ImageResource*, const KURL&); |
122 void addFontToResources(FontResource*); | 128 void addFontToResources(FontResource*); |
123 | 129 |
124 void retrieveResourcesForProperties(const StylePropertySet*, Document&); | 130 void retrieveResourcesForProperties(const StylePropertySet*, Document&); |
125 void retrieveResourcesForCSSValue(CSSValue*, Document&); | 131 void retrieveResourcesForCSSValue(CSSValue*, Document&); |
126 | 132 |
127 Vector<SerializedResource>* m_resources; | 133 Vector<SerializedResource>* m_resources; |
128 HashSet<KURL> m_resourceURLs; | 134 HashSet<KURL> m_resourceURLs; |
129 | 135 |
130 Delegate& m_delegate; | 136 Delegate& m_delegate; |
131 }; | 137 }; |
132 | 138 |
133 } // namespace blink | 139 } // namespace blink |
134 | 140 |
135 #endif // FrameSerializer_h | 141 #endif // FrameSerializer_h |
OLD | NEW |