]> git.saurik.com Git - iphone-api.git/blob - WebCore/Console.h
Adding the WebCore headers (for Cydget).
[iphone-api.git] / WebCore / Console.h
1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef Console_h
30 #define Console_h
31
32 #include "PlatformString.h"
33
34 #if USE(JSC)
35 #include <profiler/Profile.h>
36 #endif
37
38 #include <wtf/RefCounted.h>
39 #include <wtf/PassRefPtr.h>
40
41 namespace WebCore {
42
43 #if USE(JSC)
44 typedef Vector<RefPtr<JSC::Profile> > ProfilesArray;
45 #endif
46
47 class Frame;
48 class Page;
49 class String;
50 class ScriptCallStack;
51
52 // Keep in sync with inspector/front-end/Console.js
53 enum MessageSource {
54 HTMLMessageSource,
55 WMLMessageSource,
56 XMLMessageSource,
57 JSMessageSource,
58 CSSMessageSource,
59 OtherMessageSource
60 };
61
62 enum MessageLevel {
63 TipMessageLevel,
64 LogMessageLevel,
65 WarningMessageLevel,
66 ErrorMessageLevel,
67 ObjectMessageLevel,
68 NodeMessageLevel,
69 TraceMessageLevel,
70 StartGroupMessageLevel,
71 EndGroupMessageLevel
72 };
73
74 class Console : public RefCounted<Console> {
75 public:
76 static PassRefPtr<Console> create(Frame* frame) { return adoptRef(new Console(frame)); }
77
78 void disconnectFrame();
79
80 void addMessage(MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);
81
82 void debug(ScriptCallStack*);
83 void error(ScriptCallStack*);
84 void info(ScriptCallStack*);
85 void log(ScriptCallStack*);
86 void warn(ScriptCallStack*);
87 void dir(ScriptCallStack*);
88 void dirxml(ScriptCallStack*);
89 void trace(ScriptCallStack*);
90 void assertCondition(bool condition, ScriptCallStack*);
91 void count(ScriptCallStack*);
92 #if USE(JSC)
93 void profile(const JSC::UString&, ScriptCallStack*);
94 void profileEnd(const JSC::UString&, ScriptCallStack*);
95 #endif
96 void time(const String&);
97 void timeEnd(const String&, ScriptCallStack*);
98 void group(ScriptCallStack*);
99 void groupEnd();
100
101 static bool shouldPrintExceptions();
102 static void setShouldPrintExceptions(bool);
103
104 #if USE(JSC)
105 const ProfilesArray& profiles() const { return m_profiles; }
106 #endif
107
108 private:
109 inline Page* page() const;
110 void addMessage(MessageLevel, ScriptCallStack*, bool acceptNoArguments = false);
111
112 Console(Frame*);
113
114 Frame* m_frame;
115 #if USE(JSC)
116 ProfilesArray m_profiles;
117 #endif
118 };
119
120 } // namespace WebCore
121
122 #endif // Console_h