Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef ErrorEvent_h | 31 #ifndef ErrorEvent_h |
| 32 #define ErrorEvent_h | 32 #define ErrorEvent_h |
| 33 | 33 |
| 34 #include "core/dom/Event.h" | 34 #include "core/dom/Event.h" |
| 35 #include "wtf/text/WTFString.h" | 35 #include "wtf/text/WTFString.h" |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 class DOMWrapperWorld; | |
| 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, 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() |
|
adamk
2013/09/05 19:24:20
What is this used for? Why is passing 0 for world
Mike West
2013/09/06 11:57:03
This is used for cross-origin onerror messages: th
| |
| 63 { | 65 { |
| 64 return adoptRef(new ErrorEvent("Script error.", String(), 0, 0)); | 66 return adoptRef(new ErrorEvent("Script error.", String(), 0, 0, 0)); |
| 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 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, 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 DOMWrapperWorld* m_world; | |
|
adamk
2013/09/05 19:24:20
Seems a little bit scary to skip a RefPtr here. As
Mike West
2013/09/06 11:57:03
No good reason, as long as there aren't any side-e
| |
| 91 }; | 97 }; |
| 92 | 98 |
| 93 } // namespace WebCore | 99 } // namespace WebCore |
| 94 | 100 |
| 95 #endif // ErrorEvent_h | 101 #endif // ErrorEvent_h |
| OLD | NEW |