Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: sky/engine/core/events/ErrorEvent.h

Issue 922893002: Merge the Sky Engine changes from the SkyDart branch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/events/CustomEvent.idl ('k') | sky/engine/core/events/ErrorEvent.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 SKY_ENGINE_CORE_EVENTS_ERROREVENT_H_ 31 #ifndef SKY_ENGINE_CORE_EVENTS_ERROREVENT_H_
32 #define SKY_ENGINE_CORE_EVENTS_ERROREVENT_H_ 32 #define SKY_ENGINE_CORE_EVENTS_ERROREVENT_H_
33 33
34 #include "sky/engine/bindings/core/v8/DOMWrapperWorld.h"
35 #include "sky/engine/core/events/Event.h" 34 #include "sky/engine/core/events/Event.h"
36 #include "sky/engine/wtf/RefPtr.h" 35 #include "sky/engine/wtf/RefPtr.h"
37 #include "sky/engine/wtf/text/WTFString.h" 36 #include "sky/engine/wtf/text/WTFString.h"
38 37
39 namespace blink { 38 namespace blink {
40 39
41 struct ErrorEventInit : public EventInit { 40 struct ErrorEventInit : public EventInit {
42 ErrorEventInit(); 41 ErrorEventInit();
43 42
44 String message; 43 String message;
45 String filename; 44 String filename;
46 unsigned lineno; 45 unsigned lineno;
47 unsigned colno; 46 unsigned colno;
48 }; 47 };
49 48
50 class ErrorEvent final : public Event { 49 class ErrorEvent final : public Event {
51 DEFINE_WRAPPERTYPEINFO(); 50 DEFINE_WRAPPERTYPEINFO();
52 public: 51 public:
53 static PassRefPtr<ErrorEvent> create() 52 static PassRefPtr<ErrorEvent> create()
54 { 53 {
55 return adoptRef(new ErrorEvent); 54 return adoptRef(new ErrorEvent);
56 } 55 }
57 static PassRefPtr<ErrorEvent> create(const String& message, const String& fi leName, unsigned lineNumber, unsigned columnNumber, DOMWrapperWorld* world) 56 static PassRefPtr<ErrorEvent> create(const String& message, const String& fi leName, unsigned lineNumber, unsigned columnNumber)
58 { 57 {
59 return adoptRef(new ErrorEvent(message, fileName, lineNumber, columnNumb er, world)); 58 return adoptRef(new ErrorEvent(message, fileName, lineNumber, columnNumb er));
60 } 59 }
61 static PassRefPtr<ErrorEvent> create(const AtomicString& type, const ErrorEv entInit& initializer) 60 static PassRefPtr<ErrorEvent> create(const AtomicString& type, const ErrorEv entInit& initializer)
62 { 61 {
63 return adoptRef(new ErrorEvent(type, initializer)); 62 return adoptRef(new ErrorEvent(type, initializer));
64 } 63 }
65 static PassRefPtr<ErrorEvent> createSanitizedError(DOMWrapperWorld* world)
66 {
67 return adoptRef(new ErrorEvent("Script error.", String(), 0, 0, world));
68 }
69 virtual ~ErrorEvent(); 64 virtual ~ErrorEvent();
70 65
71 // As 'message' is exposed to JavaScript, never return unsanitizedMessage. 66 // As 'message' is exposed to JavaScript, never return unsanitizedMessage.
72 const String& message() const { return m_sanitizedMessage; } 67 const String& message() const { return m_sanitizedMessage; }
73 const String& filename() const { return m_fileName; } 68 const String& filename() const { return m_fileName; }
74 unsigned lineno() const { return m_lineNumber; } 69 unsigned lineno() const { return m_lineNumber; }
75 unsigned colno() const { return m_columnNumber; } 70 unsigned colno() const { return m_columnNumber; }
76 71
77 // 'messageForConsole' is not exposed to JavaScript, and prefers 'm_unsaniti zedMessage'. 72 // 'messageForConsole' is not exposed to JavaScript, and prefers 'm_unsaniti zedMessage'.
78 const String& messageForConsole() const { return !m_unsanitizedMessage.isEmp ty() ? m_unsanitizedMessage : m_sanitizedMessage; } 73 const String& messageForConsole() const { return !m_unsanitizedMessage.isEmp ty() ? m_unsanitizedMessage : m_sanitizedMessage; }
79 74
80 virtual const AtomicString& interfaceName() const override; 75 virtual const AtomicString& interfaceName() const override;
81 76
82 DOMWrapperWorld* world() const { return m_world.get(); }
83
84 void setUnsanitizedMessage(const String&); 77 void setUnsanitizedMessage(const String&);
85 78
86 private: 79 private:
87 ErrorEvent(); 80 ErrorEvent();
88 ErrorEvent(const String& message, const String& fileName, unsigned lineNumbe r, unsigned columnNumber, DOMWrapperWorld*); 81 ErrorEvent(const String& message, const String& fileName, unsigned lineNumbe r, unsigned columnNumber);
89 ErrorEvent(const AtomicString&, const ErrorEventInit&); 82 ErrorEvent(const AtomicString&, const ErrorEventInit&);
90 83
91 String m_unsanitizedMessage; 84 String m_unsanitizedMessage;
92 String m_sanitizedMessage; 85 String m_sanitizedMessage;
93 String m_fileName; 86 String m_fileName;
94 unsigned m_lineNumber; 87 unsigned m_lineNumber;
95 unsigned m_columnNumber; 88 unsigned m_columnNumber;
96
97 RefPtr<DOMWrapperWorld> m_world;
98 }; 89 };
99 90
100 } // namespace blink 91 } // namespace blink
101 92
102 #endif // SKY_ENGINE_CORE_EVENTS_ERROREVENT_H_ 93 #endif // SKY_ENGINE_CORE_EVENTS_ERROREVENT_H_
OLDNEW
« no previous file with comments | « sky/engine/core/events/CustomEvent.idl ('k') | sky/engine/core/events/ErrorEvent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698