| 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 17 matching lines...) Expand all Loading... |
| 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 FrameSerializer_h | 31 #ifndef FrameSerializer_h |
| 32 #define FrameSerializer_h | 32 #define FrameSerializer_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/Deque.h" |
| 38 #include "wtf/Forward.h" | 39 #include "wtf/Forward.h" |
| 39 #include "wtf/HashSet.h" | 40 #include "wtf/HashSet.h" |
| 40 #include "wtf/Vector.h" | 41 #include "wtf/Vector.h" |
| 41 | 42 |
| 42 namespace blink { | 43 namespace blink { |
| 43 | 44 |
| 44 class Attribute; | 45 class Attribute; |
| 45 class CSSRule; | 46 class CSSRule; |
| 46 class CSSStyleSheet; | 47 class CSSStyleSheet; |
| 47 class CSSValue; | 48 class CSSValue; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return false; | 100 return false; |
| 100 } | 101 } |
| 101 | 102 |
| 102 // Returns custom attributes that need to add in order to serialize the | 103 // Returns custom attributes that need to add in order to serialize the |
| 103 // element. | 104 // element. |
| 104 virtual Vector<Attribute> getCustomAttributes(const Element&) { | 105 virtual Vector<Attribute> getCustomAttributes(const Element&) { |
| 105 return Vector<Attribute>(); | 106 return Vector<Attribute>(); |
| 106 } | 107 } |
| 107 }; | 108 }; |
| 108 | 109 |
| 109 // Constructs a serializer that will write output to the given vector of | 110 // Constructs a serializer that will write output to the given deque of |
| 110 // SerializedResources and uses the Delegate for controlling some | 111 // SerializedResources and uses the Delegate for controlling some |
| 111 // serialization aspects. Callers need to ensure that both arguments stay | 112 // serialization aspects. Callers need to ensure that both arguments stay |
| 112 // alive until the FrameSerializer gets destroyed. | 113 // alive until the FrameSerializer gets destroyed. |
| 113 FrameSerializer(Vector<SerializedResource>&, Delegate&); | 114 FrameSerializer(Deque<SerializedResource>&, Delegate&); |
| 114 | 115 |
| 115 // Initiates the serialization of the frame. All serialized content and | 116 // Initiates the serialization of the frame. All serialized content and |
| 116 // retrieved resources are added to the Vector passed to the constructor. | 117 // retrieved resources are added to the Deque passed to the constructor. |
| 117 // The first resource in that vector is the frame's serialized content. | 118 // The first resource in that deque is the frame's serialized content. |
| 118 // Subsequent resources are images, css, etc. | 119 // Subsequent resources are images, css, etc. |
| 119 void serializeFrame(const LocalFrame&); | 120 void serializeFrame(const LocalFrame&); |
| 120 | 121 |
| 121 static String markOfTheWebDeclaration(const KURL&); | 122 static String markOfTheWebDeclaration(const KURL&); |
| 122 | 123 |
| 123 private: | 124 private: |
| 124 // Serializes the stylesheet back to text and adds it to the resources if URL | 125 // Serializes the stylesheet back to text and adds it to the resources if URL |
| 125 // is not-empty. It also adds any resources included in that stylesheet | 126 // is not-empty. It also adds any resources included in that stylesheet |
| 126 // (including any imported stylesheets and their own resources). | 127 // (including any imported stylesheets and their own resources). |
| 127 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&); | 128 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&); |
| 128 | 129 |
| 129 // Serializes the css rule (including any imported stylesheets), adding | 130 // Serializes the css rule (including any imported stylesheets), adding |
| 130 // referenced resources. | 131 // referenced resources. |
| 131 void serializeCSSRule(CSSRule*); | 132 void serializeCSSRule(CSSRule*); |
| 132 | 133 |
| 133 bool shouldAddURL(const KURL&); | 134 bool shouldAddURL(const KURL&); |
| 134 | 135 |
| 135 void addToResources(const String& mimeType, | 136 void addToResources(const String& mimeType, |
| 136 ResourceHasCacheControlNoStoreHeader, | 137 ResourceHasCacheControlNoStoreHeader, |
| 137 PassRefPtr<const SharedBuffer>, | 138 PassRefPtr<const SharedBuffer>, |
| 138 const KURL&); | 139 const KURL&); |
| 139 void addImageToResources(ImageResourceContent*, const KURL&); | 140 void addImageToResources(ImageResourceContent*, const KURL&); |
| 140 void addFontToResources(FontResource*); | 141 void addFontToResources(FontResource*); |
| 141 | 142 |
| 142 void retrieveResourcesForProperties(const StylePropertySet*, Document&); | 143 void retrieveResourcesForProperties(const StylePropertySet*, Document&); |
| 143 void retrieveResourcesForCSSValue(const CSSValue&, Document&); | 144 void retrieveResourcesForCSSValue(const CSSValue&, Document&); |
| 144 | 145 |
| 145 Vector<SerializedResource>* m_resources; | 146 Deque<SerializedResource>* m_resources; |
| 146 HashSet<KURL> m_resourceURLs; | 147 HashSet<KURL> m_resourceURLs; |
| 147 | 148 |
| 148 bool m_isSerializingCss; | 149 bool m_isSerializingCss; |
| 149 | 150 |
| 150 Delegate& m_delegate; | 151 Delegate& m_delegate; |
| 151 }; | 152 }; |
| 152 | 153 |
| 153 } // namespace blink | 154 } // namespace blink |
| 154 | 155 |
| 155 #endif // FrameSerializer_h | 156 #endif // FrameSerializer_h |
| OLD | NEW |