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

Side by Side Diff: webkit/port/bindings/v8/v8_custom.cpp

Issue 121001: Update DEPS to pull in upstream change that removes RGBA32Buffer::bitmap(), a... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « webkit/port/bindings/v8/v8_custom.h ('k') | webkit/port/bindings/v8/v8_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2000 Harri Porten (porten@kde.org)
3 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
4 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
5 * Copyright (C) 2006 James G. Speth (speth@end.com)
6 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org)
7 * Copyright (C) 2007, 2008 Google Inc. All Rights Reserved.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24 #include "config.h"
25
26 #include <Assertions.h>
27 #include <wtf/ASCIICType.h>
28
29 #include "v8_proxy.h"
30 #include "v8_binding.h"
31 #include "V8NPObject.h"
32
33 #include "V8CanvasGradient.h"
34 #include "V8CanvasPattern.h"
35 #include "V8CustomEventListener.h"
36 #include "V8Document.h"
37 #include "V8DOMWindow.h"
38 #include "V8HTMLCanvasElement.h"
39 #include "V8HTMLDocument.h"
40 #include "V8HTMLImageElement.h"
41 #include "V8NamedNodesCollection.h"
42 #include "V8Node.h"
43 #include "V8Proxy.h"
44 #include "V8XPathNSResolver.h"
45 #include "V8XPathResult.h"
46
47 #include "Attr.h"
48 #include "Base64.h"
49 #include "CanvasGradient.h"
50 #include "CanvasPattern.h"
51 #include "CanvasRenderingContext2D.h"
52 #include "CanvasStyle.h"
53 #include "Clipboard.h"
54 #include "ClipboardEvent.h"
55 #include "Console.h"
56 #include "DOMParser.h"
57 #include "DOMStringList.h"
58 #include "DOMTimer.h"
59 #include "Document.h"
60 #include "DocumentFragment.h"
61 #include "Event.h"
62 #include "EventTarget.h"
63 #include "FloatRect.h"
64 #include "Frame.h"
65 #include "FrameLoader.h"
66 #include "FrameTree.h"
67 #include "HTMLBodyElement.h"
68 #include "HTMLCanvasElement.h"
69 #include "HTMLDocument.h"
70 #include "HTMLEmbedElement.h"
71 #include "HTMLImageElement.h"
72 #include "HTMLInputElement.h"
73 #include "HTMLNames.h"
74 #include "History.h"
75 #include "JSXPathNSResolver.h"
76 #include "KURL.h"
77 #include "Location.h"
78 #include "MessageChannel.h"
79 #include "MessagePort.h"
80 #include "MouseEvent.h"
81 #include "NodeIterator.h"
82 #include "NodeList.h"
83 #include "RGBColor.h"
84 #include "RenderPartObject.h"
85 #include "RenderWidget.h"
86 #include "ScheduledAction.h"
87 #include "ScriptState.h"
88 #include "ScriptController.h"
89 #include "ScriptSourceCode.h"
90 #include "SecurityOrigin.h"
91 #include "StyleSheetList.h"
92 #include "TreeWalker.h"
93 #include "WebKitCSSMatrix.h"
94 #include "WebKitPoint.h"
95 #include "XMLSerializer.h"
96 #include "XPathEvaluator.h"
97 #include "XPathResult.h"
98 #include "XSLTProcessor.h"
99
100 #if ENABLE(SVG)
101 #include "V8SVGPODTypeWrapper.h"
102 #include "SVGElementInstance.h"
103 #include "SVGException.h"
104 #include "SVGPathSeg.h"
105 #endif
106
107 #include "Navigator.h"
108
109 namespace WebCore {
110
111 CALLBACK_FUNC_DECL(WebKitPointConstructor) {
112 INC_STATS("DOM.WebKitPoint.Constructor");
113 return V8Proxy::ConstructDOMObject<V8ClassIndex::WEBKITPOINT,
114 WebKitPoint>(args);
115 }
116
117 // DOMImplementation is a singleton in WebCore. If we use our normal
118 // mapping from DOM objects to V8 wrappers, the same wrapper will be
119 // shared for all frames in the same process. This is a major
120 // security problem. Therefore, we generate a DOMImplementation
121 // wrapper per document and store it in an internal field of the
122 // document. Since the DOMImplementation object is a singleton, we do
123 // not have to do anything to keep the DOMImplementation object alive
124 // for the lifetime of the wrapper.
125 ACCESSOR_GETTER(DocumentImplementation) {
126 ASSERT(info.Holder()->InternalFieldCount() >=
127 kDocumentMinimumInternalFieldCount);
128 // Check if the internal field already contains a wrapper.
129 v8::Local<v8::Value> implementation =
130 info.Holder()->GetInternalField(kDocumentImplementationIndex);
131 if (!implementation->IsUndefined()) {
132 return implementation;
133 }
134 // Generate a wrapper.
135 Document* doc = V8Proxy::DOMWrapperToNative<Document>(info.Holder());
136 v8::Handle<v8::Value> wrapper =
137 V8Proxy::DOMImplementationToV8Object(doc->implementation());
138 // Store the wrapper in the internal field.
139 info.Holder()->SetInternalField(kDocumentImplementationIndex, wrapper);
140
141 return wrapper;
142 }
143
144 // --------------- Security Checks -------------------------
145 INDEXED_ACCESS_CHECK(History) {
146 ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::HISTORY);
147 // Only allow same origin access
148 History* imp =
149 V8Proxy::ToNativeObject<History>(V8ClassIndex::HISTORY, host);
150 return V8Proxy::CanAccessFrame(imp->frame(), false);
151 }
152
153
154 NAMED_ACCESS_CHECK(History) {
155 ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::HISTORY);
156 // Only allow same origin access
157 History* imp =
158 V8Proxy::ToNativeObject<History>(V8ClassIndex::HISTORY, host);
159 return V8Proxy::CanAccessFrame(imp->frame(), false);
160 }
161
162
163
164 #undef INDEXED_ACCESS_CHECK
165 #undef NAMED_ACCESS_CHECK
166 #undef NAMED_PROPERTY_GETTER
167 #undef NAMED_PROPERTY_SETTER
168
169
170 // static
171 Frame* V8Custom::GetTargetFrame(v8::Local<v8::Object> host,
172 v8::Local<v8::Value> data) {
173 Frame* target = 0;
174 switch (V8ClassIndex::FromInt(data->Int32Value())) {
175 case V8ClassIndex::DOMWINDOW: {
176 v8::Handle<v8::Value> window =
177 V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, host);
178 if (window.IsEmpty())
179 return target;
180
181 DOMWindow* target_win =
182 V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, window);
183 target = target_win->frame();
184 break;
185 }
186 case V8ClassIndex::LOCATION: {
187 History* imp =
188 V8Proxy::ToNativeObject<History>(V8ClassIndex::HISTORY, host);
189 target = imp->frame();
190 break;
191 }
192 case V8ClassIndex::HISTORY: {
193 Location* imp =
194 V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, host);
195 target = imp->frame();
196 break;
197 }
198 default:
199 break;
200 }
201 return target;
202 }
203
204 #if ENABLE(SVG)
205 V8ClassIndex::V8WrapperType V8Custom::DowncastSVGPathSeg(void* path_seg) {
206 WebCore::SVGPathSeg *real_path_seg =
207 reinterpret_cast<WebCore::SVGPathSeg*>(path_seg);
208
209 switch (real_path_seg->pathSegType()) {
210 #define MAKE_CASE(svg_val, v8_val) \
211 case WebCore::SVGPathSeg::svg_val: \
212 return V8ClassIndex::v8_val;
213
214 MAKE_CASE(PATHSEG_CLOSEPATH, SVGPATHSEGCLOSEPATH)
215 MAKE_CASE(PATHSEG_MOVETO_ABS, SVGPATHSEGMOVETOABS)
216 MAKE_CASE(PATHSEG_MOVETO_REL, SVGPATHSEGMOVETOREL)
217 MAKE_CASE(PATHSEG_LINETO_ABS, SVGPATHSEGLINETOABS)
218 MAKE_CASE(PATHSEG_LINETO_REL, SVGPATHSEGLINETOREL)
219 MAKE_CASE(PATHSEG_CURVETO_CUBIC_ABS, SVGPATHSEGCURVETOCUBICABS)
220 MAKE_CASE(PATHSEG_CURVETO_CUBIC_REL, SVGPATHSEGCURVETOCUBICREL)
221 MAKE_CASE(PATHSEG_CURVETO_QUADRATIC_ABS, SVGPATHSEGCURVETOQUADRATICABS)
222 MAKE_CASE(PATHSEG_CURVETO_QUADRATIC_REL, SVGPATHSEGCURVETOQUADRATICREL)
223 MAKE_CASE(PATHSEG_ARC_ABS, SVGPATHSEGARCABS)
224 MAKE_CASE(PATHSEG_ARC_REL, SVGPATHSEGARCREL)
225 MAKE_CASE(PATHSEG_LINETO_HORIZONTAL_ABS, SVGPATHSEGLINETOHORIZONTALABS)
226 MAKE_CASE(PATHSEG_LINETO_HORIZONTAL_REL, SVGPATHSEGLINETOHORIZONTALREL)
227 MAKE_CASE(PATHSEG_LINETO_VERTICAL_ABS, SVGPATHSEGLINETOVERTICALABS)
228 MAKE_CASE(PATHSEG_LINETO_VERTICAL_REL, SVGPATHSEGLINETOVERTICALREL)
229 MAKE_CASE(PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, SVGPATHSEGCURVETOCUBICSMOOTHABS)
230 MAKE_CASE(PATHSEG_CURVETO_CUBIC_SMOOTH_REL, SVGPATHSEGCURVETOCUBICSMOOTHREL)
231 MAKE_CASE(PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, \
232 SVGPATHSEGCURVETOQUADRATICSMOOTHABS)
233 MAKE_CASE(PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, \
234 SVGPATHSEGCURVETOQUADRATICSMOOTHREL)
235
236 #undef MAKE_CASE
237
238 default:
239 return V8ClassIndex::INVALID_CLASS_INDEX;
240 }
241 }
242
243 #endif // ENABLE(SVG)
244
245 } // namespace WebCore
OLDNEW
« no previous file with comments | « webkit/port/bindings/v8/v8_custom.h ('k') | webkit/port/bindings/v8/v8_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698