2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
34 // FIXME: Remove once chromium dependencies on v8_utility.h are removed.
35 #define V8UTILITIES_DEFINED 1
45 // Use an array to hold dependents. It works like a ref-counted scheme. A value can be added more than once to the DOM object.
46 void createHiddenDependency(v8::Local<v8::Object>, v8::Local<v8::Value>, int cacheIndex);
47 void removeHiddenDependency(v8::Local<v8::Object>, v8::Local<v8::Value>, int cacheIndex);
49 bool processingUserGesture();
50 bool shouldAllowNavigation(Frame*);
51 KURL completeURL(const String& relativeURL);
52 void navigateIfAllowed(Frame*, const KURL&, bool lockHistory, bool lockBackForwardList);
54 class AllowAllocation {
56 inline AllowAllocation()
58 m_previous = m_current;
62 inline ~AllowAllocation()
64 m_current = m_previous;
67 static bool m_current;
73 class SafeAllocation {
75 static inline v8::Local<v8::Object> newInstance(v8::Handle<v8::Function>);
76 static inline v8::Local<v8::Object> newInstance(v8::Handle<v8::ObjectTemplate>);
77 static inline v8::Local<v8::Object> newInstance(v8::Handle<v8::Function>, int argc, v8::Handle<v8::Value> argv[]);
79 // FIXME: These NewInstance functions are here to ease upstreaming. Remove along with V8UTILITIES_DEFINED once chromium dependencies on v8_utility.h are removed.
80 static inline v8::Local<v8::Object> NewInstance(v8::Handle<v8::Function>);
81 static inline v8::Local<v8::Object> NewInstance(v8::Handle<v8::ObjectTemplate>);
82 static inline v8::Local<v8::Object> NewInstance(v8::Handle<v8::Function>, int argc, v8::Handle<v8::Value> argv[]);
85 v8::Local<v8::Object> SafeAllocation::newInstance(v8::Handle<v8::Function> function)
87 if (function.IsEmpty())
88 return v8::Local<v8::Object>();
89 AllowAllocation allow;
90 return function->NewInstance();
93 v8::Local<v8::Object> SafeAllocation::newInstance(v8::Handle<v8::ObjectTemplate> objectTemplate)
95 if (objectTemplate.IsEmpty())
96 return v8::Local<v8::Object>();
97 AllowAllocation allow;
98 return objectTemplate->NewInstance();
101 v8::Local<v8::Object> SafeAllocation::newInstance(v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[])
103 if (function.IsEmpty())
104 return v8::Local<v8::Object>();
105 AllowAllocation allow;
106 return function->NewInstance(argc, argv);
109 // FIXME: These NewInstance functions are here to ease upstreaming. Remove along with V8UTILITIES_DEFINED once chromium dependencies on v8_utility.h are removed.
110 v8::Local<v8::Object> SafeAllocation::NewInstance(v8::Handle<v8::Function> function)
112 return newInstance(function);
115 v8::Local<v8::Object> SafeAllocation::NewInstance(v8::Handle<v8::ObjectTemplate> objectTemplate)
117 return newInstance(objectTemplate);
120 v8::Local<v8::Object> SafeAllocation::NewInstance(v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[])
122 return newInstance(function, argc, argv);
125 } // namespace WebCore
127 #endif // V8Utilities_h