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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 struct SerializedResource; | 61 struct SerializedResource; |
62 | 62 |
63 // This class is used to serialize frame's contents back to text (typically HTML ). | 63 // This class is used to serialize frame's contents back to text (typically HTML ). |
64 // It serializes frame's document and resources such as images and CSS styleshee ts. | 64 // It serializes frame's document and resources such as images and CSS styleshee ts. |
65 // TODO(lukasza): Rename this class to FrameSerializer. | 65 // TODO(lukasza): Rename this class to FrameSerializer. |
66 class CORE_EXPORT PageSerializer final { | 66 class CORE_EXPORT PageSerializer final { |
67 STACK_ALLOCATED(); | 67 STACK_ALLOCATED(); |
68 public: | 68 public: |
69 class Delegate { | 69 class Delegate { |
70 public: | 70 public: |
71 virtual bool shouldIgnoreAttribute(const Attribute&) = 0; | 71 // Controls whether HTML serialization should skip the given attribute. |
72 // Default implementation always returns false. | |
dcheng
2015/12/22 01:01:45
Just inline the default implementations.
Łukasz Anforowicz
2015/12/22 21:06:46
Done.
| |
73 virtual bool shouldIgnoreAttribute(const Attribute&); | |
72 | 74 |
73 // Method allowing the Delegate control which URLs are written into the | 75 // Method allowing the Delegate control which URLs are written into the |
74 // generated html document. | 76 // generated html document. |
75 // | 77 // |
76 // When URL of the element needs to be rewritten, this method should | 78 // When URL of the element needs to be rewritten, this method should |
77 // return true and populate |rewrittenLink| with a desired value of the | 79 // return true and populate |rewrittenLink| with a desired value of the |
78 // html attribute value to be used in place of the original link. | 80 // html attribute value to be used in place of the original link. |
79 // (i.e. in place of img.src or iframe.src or object.data). | 81 // (i.e. in place of img.src or iframe.src or object.data). |
80 // | 82 // |
81 // If no link rewriting is desired, this method should return false. | 83 // If no link rewriting is desired, this method should return false. |
82 virtual bool rewriteLink(const Element&, String& rewrittenLink) = 0; | 84 // |
85 // Default implementation always returns false. | |
86 virtual bool rewriteLink(const Element&, String& rewrittenLink); | |
87 | |
88 // Tells whether to skip serialization of a subresource with a given URI . | |
89 // Used to deduplicate resources across multiple frames. | |
90 // | |
91 // Default implementation always returns false. | |
92 virtual bool shouldSkipResource(const KURL&); | |
83 }; | 93 }; |
84 | 94 |
85 // Constructs a serializer that will write output to the given vector of | 95 // Constructs a serializer that will write output to the given vector of |
86 // SerializedResources and use the optional Delegate for controlling some | 96 // SerializedResources and use the optional Delegate for controlling some |
87 // serialization aspects. Callers need to ensure that the Delegate stays | 97 // serialization aspects. Callers need to ensure that the Delegate stays |
88 // alive until the PageSerializer gets destroyed. | 98 // alive until the PageSerializer gets destroyed. |
89 PageSerializer(Vector<SerializedResource>&, Delegate*); | 99 PageSerializer(Vector<SerializedResource>&, Delegate*); |
90 | 100 |
91 // Initiates the serialization of the frame. All serialized content and | 101 // Initiates the serialization of the frame. All serialized content and |
92 // retrieved resources are added to the Vector passed to the constructor. | 102 // retrieved resources are added to the Vector passed to the constructor. |
(...skipping 24 matching lines...) Expand all Loading... | |
117 | 127 |
118 Vector<SerializedResource>* m_resources; | 128 Vector<SerializedResource>* m_resources; |
119 ListHashSet<KURL> m_resourceURLs; | 129 ListHashSet<KURL> m_resourceURLs; |
120 | 130 |
121 Delegate* m_delegate; | 131 Delegate* m_delegate; |
122 }; | 132 }; |
123 | 133 |
124 } // namespace blink | 134 } // namespace blink |
125 | 135 |
126 #endif // PageSerializer_h | 136 #endif // PageSerializer_h |
OLD | NEW |