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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 class Document; | 51 class Document; |
52 class LocalFrame; | 52 class LocalFrame; |
53 class Page; | 53 class Page; |
54 class LayoutObject; | 54 class LayoutObject; |
55 class Resource; | 55 class Resource; |
56 class SharedBuffer; | 56 class SharedBuffer; |
57 class StylePropertySet; | 57 class StylePropertySet; |
58 | 58 |
59 struct SerializedResource; | 59 struct SerializedResource; |
60 | 60 |
61 // This class is used to serialize a page contents back to text (typically HTML) . | 61 // This class is used to serialize frame's contents back to text (typically HTML ). |
62 // It serializes all the page frames and retrieves resources such as images and CSS stylesheets. | 62 // It serializes frame's document and resources such as images and CSS styleshee ts. |
63 // TODO(lukasza): Rename this class to FrameSerializer. | |
63 class CORE_EXPORT PageSerializer final { | 64 class CORE_EXPORT PageSerializer final { |
64 STACK_ALLOCATED(); | 65 STACK_ALLOCATED(); |
65 public: | 66 public: |
66 class Delegate { | 67 class Delegate { |
67 USING_FAST_MALLOC(Delegate); | 68 USING_FAST_MALLOC(Delegate); |
68 public: | 69 public: |
69 virtual ~Delegate() { } | 70 virtual ~Delegate() { } |
70 virtual bool shouldIgnoreAttribute(const Attribute&) = 0; | 71 virtual bool shouldIgnoreAttribute(const Attribute&) = 0; |
71 }; | 72 }; |
72 | 73 |
73 PageSerializer(Vector<SerializedResource>*, PassOwnPtr<Delegate>); | 74 PageSerializer(Vector<SerializedResource>*, PassOwnPtr<Delegate>); |
74 | 75 |
75 // Initiates the serialization of the frame's page. All serialized content a nd retrieved | 76 // Initiates the serialization of the frame. All serialized content and |
76 // resources are added to the Vector passed to the constructor. The first re source in that | 77 // retrieved resources are added to the Vector passed to the constructor. |
77 // vector is the top frame serialized content. | 78 // The first resource in that vector is the frame's serialized content. |
78 void serialize(Page*); | 79 // Subsequent resources are images, css, etc. |
80 void serializeFrame(LocalFrame&); | |
tkent
2015/11/18 22:32:55
nit: Can we change |LocalFrame&| to |const LocalFr
Łukasz Anforowicz
2015/11/18 23:27:41
Done (constness cascaded into urlForBlankFrame and
| |
79 | 81 |
80 void registerRewriteURL(const String& from, const String& to); | 82 void registerRewriteURL(const String& from, const String& to); |
81 void setRewriteURLFolder(const String&); | 83 void setRewriteURLFolder(const String&); |
82 | 84 |
83 KURL urlForBlankFrame(LocalFrame*); | 85 KURL urlForBlankFrame(LocalFrame*); |
84 | 86 |
85 Delegate* delegate(); | 87 Delegate* delegate(); |
86 | 88 |
87 static String markOfTheWebDeclaration(const KURL&); | 89 static String markOfTheWebDeclaration(const KURL&); |
88 | 90 |
89 private: | 91 private: |
90 void serializeFrame(LocalFrame*); | |
91 | |
92 // Serializes the stylesheet back to text and adds it to the resources if UR L is not-empty. | 92 // Serializes the stylesheet back to text and adds it to the resources if UR L is not-empty. |
93 // It also adds any resources included in that stylesheet (including any imp orted stylesheets and their own resources). | 93 // It also adds any resources included in that stylesheet (including any imp orted stylesheets and their own resources). |
94 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&); | 94 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&); |
95 | 95 |
96 // Serializes the css rule (including any imported stylesheets), adding refe renced resources. | 96 // Serializes the css rule (including any imported stylesheets), adding refe renced resources. |
97 void serializeCSSRule(CSSRule*); | 97 void serializeCSSRule(CSSRule*); |
98 | 98 |
99 bool shouldAddURL(const KURL&); | 99 bool shouldAddURL(const KURL&); |
100 | 100 |
101 void addToResources(Resource *, PassRefPtr<SharedBuffer>, const KURL&); | 101 void addToResources(Resource *, PassRefPtr<SharedBuffer>, const KURL&); |
(...skipping 11 matching lines...) Expand all Loading... | |
113 HashMap<String, String> m_rewriteURLs; | 113 HashMap<String, String> m_rewriteURLs; |
114 String m_rewriteFolder; | 114 String m_rewriteFolder; |
115 unsigned m_blankFrameCounter; | 115 unsigned m_blankFrameCounter; |
116 | 116 |
117 OwnPtr<Delegate> m_delegate; | 117 OwnPtr<Delegate> m_delegate; |
118 }; | 118 }; |
119 | 119 |
120 } // namespace blink | 120 } // namespace blink |
121 | 121 |
122 #endif // PageSerializer_h | 122 #endif // PageSerializer_h |
OLD | NEW |