OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008, 2009 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "core/html/HTMLDocument.h" | 28 #include "core/html/HTMLDocument.h" |
29 | 29 |
30 namespace WebCore { | 30 namespace WebCore { |
31 | 31 |
32 class HTMLTableCellElement; | 32 class HTMLTableCellElement; |
33 class HTMLTableSectionElement; | 33 class HTMLTableSectionElement; |
34 class HTMLToken; | 34 class HTMLToken; |
35 | 35 |
36 class HTMLViewSourceDocument FINAL : public HTMLDocument { | 36 class HTMLViewSourceDocument FINAL : public HTMLDocument { |
37 public: | 37 public: |
| 38 enum SourceAnnotation { |
| 39 AnnotateSourceAsSafe, |
| 40 AnnotateSourceAsXSS |
| 41 }; |
| 42 |
38 static PassRefPtrWillBeRawPtr<HTMLViewSourceDocument> create(const DocumentI
nit& initializer, const String& mimeType) | 43 static PassRefPtrWillBeRawPtr<HTMLViewSourceDocument> create(const DocumentI
nit& initializer, const String& mimeType) |
39 { | 44 { |
40 return adoptRefWillBeRefCountedGarbageCollected(new HTMLViewSourceDocume
nt(initializer, mimeType)); | 45 return adoptRefWillBeRefCountedGarbageCollected(new HTMLViewSourceDocume
nt(initializer, mimeType)); |
41 } | 46 } |
42 | 47 |
43 void addSource(const String&, HTMLToken&); | 48 void addSource(const String&, HTMLToken&, SourceAnnotation); |
44 | 49 |
45 virtual void trace(Visitor*) OVERRIDE; | 50 virtual void trace(Visitor*) OVERRIDE; |
46 | 51 |
47 private: | 52 private: |
48 HTMLViewSourceDocument(const DocumentInit&, const String& mimeType); | 53 HTMLViewSourceDocument(const DocumentInit&, const String& mimeType); |
49 | 54 |
50 virtual PassRefPtrWillBeRawPtr<DocumentParser> createParser() OVERRIDE; | 55 virtual PassRefPtrWillBeRawPtr<DocumentParser> createParser() OVERRIDE; |
51 | 56 |
52 void processDoctypeToken(const String& source, HTMLToken&); | 57 void processDoctypeToken(const String& source, HTMLToken&); |
53 void processEndOfFileToken(const String& source, HTMLToken&); | 58 void processEndOfFileToken(const String& source, HTMLToken&); |
54 void processTagToken(const String& source, HTMLToken&); | 59 void processTagToken(const String& source, HTMLToken&, SourceAnnotation); |
55 void processCommentToken(const String& source, HTMLToken&); | 60 void processCommentToken(const String& source, HTMLToken&); |
56 void processCharacterToken(const String& source, HTMLToken&); | 61 void processCharacterToken(const String& source, HTMLToken&, SourceAnnotatio
n); |
57 | 62 |
58 void createContainingTable(); | 63 void createContainingTable(); |
59 PassRefPtrWillBeRawPtr<Element> addSpanWithClassName(const AtomicString&); | 64 PassRefPtrWillBeRawPtr<Element> addSpanWithClassName(const AtomicString&); |
60 void addLine(const AtomicString& className); | 65 void addLine(const AtomicString& className); |
61 void finishLine(); | 66 void finishLine(); |
62 void addText(const String& text, const AtomicString& className); | 67 void addText(const String& text, const AtomicString& className, SourceAnnota
tion = AnnotateSourceAsSafe); |
63 int addRange(const String& source, int start, int end, const AtomicString& c
lassName, bool isLink = false, bool isAnchor = false, const AtomicString& link =
nullAtom); | 68 int addRange(const String& source, int start, int end, const AtomicString& c
lassName, bool isLink = false, bool isAnchor = false, const AtomicString& link =
nullAtom); |
| 69 void maybeAddSpanForAnnotation(SourceAnnotation); |
| 70 |
64 PassRefPtrWillBeRawPtr<Element> addLink(const AtomicString& url, bool isAnch
or); | 71 PassRefPtrWillBeRawPtr<Element> addLink(const AtomicString& url, bool isAnch
or); |
65 PassRefPtrWillBeRawPtr<Element> addBase(const AtomicString& href); | 72 PassRefPtrWillBeRawPtr<Element> addBase(const AtomicString& href); |
66 | 73 |
67 String m_type; | 74 String m_type; |
68 RefPtrWillBeMember<Element> m_current; | 75 RefPtrWillBeMember<Element> m_current; |
69 RefPtrWillBeMember<HTMLTableSectionElement> m_tbody; | 76 RefPtrWillBeMember<HTMLTableSectionElement> m_tbody; |
70 RefPtrWillBeMember<HTMLTableCellElement> m_td; | 77 RefPtrWillBeMember<HTMLTableCellElement> m_td; |
71 int m_lineNumber; | 78 int m_lineNumber; |
72 }; | 79 }; |
73 | 80 |
74 } | 81 } |
75 | 82 |
76 #endif // HTMLViewSourceDocument_h | 83 #endif // HTMLViewSourceDocument_h |
OLD | NEW |