OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
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 ErrorEvent_h | 31 #ifndef ErrorEvent_h |
32 #define ErrorEvent_h | 32 #define ErrorEvent_h |
33 | 33 |
| 34 #include "bindings/v8/DOMWrapperWorld.h" |
34 #include "core/dom/Event.h" | 35 #include "core/dom/Event.h" |
| 36 #include "wtf/RefPtr.h" |
35 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
36 | 38 |
37 namespace WebCore { | 39 namespace WebCore { |
38 | 40 |
39 struct ErrorEventInit : public EventInit { | 41 struct ErrorEventInit : public EventInit { |
40 ErrorEventInit(); | 42 ErrorEventInit(); |
41 | 43 |
42 String message; | 44 String message; |
43 String filename; | 45 String filename; |
44 unsigned lineno; | 46 unsigned lineno; |
45 unsigned colno; | 47 unsigned colno; |
46 }; | 48 }; |
47 | 49 |
48 class ErrorEvent : public Event { | 50 class ErrorEvent : public Event { |
49 public: | 51 public: |
50 static PassRefPtr<ErrorEvent> create() | 52 static PassRefPtr<ErrorEvent> create() |
51 { | 53 { |
52 return adoptRef(new ErrorEvent); | 54 return adoptRef(new ErrorEvent); |
53 } | 55 } |
54 static PassRefPtr<ErrorEvent> create(const String& message, const String& fi
leName, unsigned lineNumber, unsigned columnNumber) | 56 static PassRefPtr<ErrorEvent> create(const String& message, const String& fi
leName, unsigned lineNumber, unsigned columnNumber, PassRefPtr<DOMWrapperWorld>
world) |
55 { | 57 { |
56 return adoptRef(new ErrorEvent(message, fileName, lineNumber, columnNumb
er)); | 58 return adoptRef(new ErrorEvent(message, fileName, lineNumber, columnNumb
er, world)); |
57 } | 59 } |
58 static PassRefPtr<ErrorEvent> create(const AtomicString& type, const ErrorEv
entInit& initializer) | 60 static PassRefPtr<ErrorEvent> create(const AtomicString& type, const ErrorEv
entInit& initializer) |
59 { | 61 { |
60 return adoptRef(new ErrorEvent(type, initializer)); | 62 return adoptRef(new ErrorEvent(type, initializer)); |
61 } | 63 } |
62 static PassRefPtr<ErrorEvent> createSanitizedError() | 64 static PassRefPtr<ErrorEvent> createSanitizedError(PassRefPtr<DOMWrapperWorl
d> world) |
63 { | 65 { |
64 return adoptRef(new ErrorEvent("Script error.", String(), 0, 0)); | 66 return adoptRef(new ErrorEvent("Script error.", String(), 0, 0, world)); |
65 } | 67 } |
66 virtual ~ErrorEvent(); | 68 virtual ~ErrorEvent(); |
67 | 69 |
68 // As 'message' is exposed to JavaScript, never return unsanitizedMessage. | 70 // As 'message' is exposed to JavaScript, never return unsanitizedMessage. |
69 const String& message() const { return m_sanitizedMessage; } | 71 const String& message() const { return m_sanitizedMessage; } |
70 const String& filename() const { return m_fileName; } | 72 const String& filename() const { return m_fileName; } |
71 unsigned lineno() const { return m_lineNumber; } | 73 unsigned lineno() const { return m_lineNumber; } |
72 unsigned colno() const { return m_columnNumber; } | 74 unsigned colno() const { return m_columnNumber; } |
73 | 75 |
74 // 'messageForConsole' is not exposed to JavaScript, and prefers 'm_unsaniti
zedMessage'. | 76 // 'messageForConsole' is not exposed to JavaScript, and prefers 'm_unsaniti
zedMessage'. |
75 const String& messageForConsole() const { return !m_unsanitizedMessage.isEmp
ty() ? m_unsanitizedMessage : m_sanitizedMessage; } | 77 const String& messageForConsole() const { return !m_unsanitizedMessage.isEmp
ty() ? m_unsanitizedMessage : m_sanitizedMessage; } |
76 | 78 |
77 virtual const AtomicString& interfaceName() const; | 79 virtual const AtomicString& interfaceName() const; |
78 | 80 |
| 81 PassRefPtr<DOMWrapperWorld> world() const { return m_world; } |
| 82 |
79 void setUnsanitizedMessage(const String&); | 83 void setUnsanitizedMessage(const String&); |
80 | 84 |
81 private: | 85 private: |
82 ErrorEvent(); | 86 ErrorEvent(); |
83 ErrorEvent(const String& message, const String& fileName, unsigned lineNumbe
r, unsigned columnNumber); | 87 ErrorEvent(const String& message, const String& fileName, unsigned lineNumbe
r, unsigned columnNumber, PassRefPtr<DOMWrapperWorld>); |
84 ErrorEvent(const AtomicString&, const ErrorEventInit&); | 88 ErrorEvent(const AtomicString&, const ErrorEventInit&); |
85 | 89 |
86 String m_unsanitizedMessage; | 90 String m_unsanitizedMessage; |
87 String m_sanitizedMessage; | 91 String m_sanitizedMessage; |
88 String m_fileName; | 92 String m_fileName; |
89 unsigned m_lineNumber; | 93 unsigned m_lineNumber; |
90 unsigned m_columnNumber; | 94 unsigned m_columnNumber; |
| 95 |
| 96 RefPtr<DOMWrapperWorld> m_world; |
91 }; | 97 }; |
92 | 98 |
93 } // namespace WebCore | 99 } // namespace WebCore |
94 | 100 |
95 #endif // ErrorEvent_h | 101 #endif // ErrorEvent_h |
OLD | NEW |