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

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

Issue 42634: Revert change 12507 and 12532 because it breaks the ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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_proxy.h ('k') | webkit/webkit.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008, Google Inc. 1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved. 2 // 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
29 29
30 #include "config.h" 30 #include "config.h"
31 31
32 #include <algorithm> 32 #include <algorithm>
33 #include <utility> 33 #include <utility>
34 34
35 #include <v8.h> 35 #include <v8.h>
36 #include <v8-debug.h> 36 #include <v8-debug.h>
37 37
38 #include "v8_proxy.h" 38 #include "v8_proxy.h"
39 #include "dom_wrapper_map.h"
39 #include "v8_index.h" 40 #include "v8_index.h"
40 #include "v8_binding.h" 41 #include "v8_binding.h"
41 #include "v8_custom.h" 42 #include "v8_custom.h"
42 #include "v8_nodefilter.h" 43 #include "v8_nodefilter.h"
43 #include "V8Collection.h" 44 #include "V8Collection.h"
44 #include "V8DOMWindow.h" 45 #include "V8DOMWindow.h"
45 46
46 #include "ChromiumBridge.h" 47 #include "ChromiumBridge.h"
47 #include "DOMObjectsInclude.h" 48
49 #include "BarInfo.h"
50 #include "CanvasGradient.h"
51 #include "CanvasPattern.h"
52 #include "CanvasPixelArray.h"
53 #include "CanvasRenderingContext2D.h"
54 #include "CanvasStyle.h"
55 #include "CharacterData.h"
56 #include "ClientRect.h"
57 #include "ClientRectList.h"
58 #include "Clipboard.h"
59 #include "Console.h"
60 #include "Counter.h"
61 #include "CSSCharsetRule.h"
62 #include "CSSFontFaceRule.h"
63 #include "CSSImportRule.h"
64 #include "CSSMediaRule.h"
65 #include "CSSPageRule.h"
66 #include "CSSRule.h"
67 #include "CSSRuleList.h"
68 #include "CSSValueList.h"
69 #include "CSSStyleRule.h"
70 #include "CSSStyleSheet.h"
71 #include "CSSVariablesDeclaration.h"
72 #include "CSSVariablesRule.h"
73 #include "Database.h"
74 #include "DocumentType.h"
75 #include "DocumentFragment.h"
76 #include "DOMCoreException.h"
77 #include "DOMImplementation.h"
78 #include "DOMParser.h"
79 #include "DOMSelection.h"
80 #include "DOMStringList.h"
81 #include "DOMWindow.h"
82 #include "Entity.h"
83 #include "EventListener.h"
84 #include "EventTarget.h"
85 #include "Event.h"
86 #include "EventException.h"
87 #include "ExceptionCode.h"
88 #include "File.h"
89 #include "FileList.h"
90 #include "Frame.h"
91 #include "FrameLoader.h"
92 #include "FrameTree.h"
93 #include "History.h"
94 #include "HTMLNames.h"
95 #include "HTMLDocument.h"
96 #include "HTMLElement.h"
97 #include "HTMLImageElement.h"
98 #include "HTMLInputElement.h"
99 #include "HTMLSelectElement.h"
100 #include "HTMLOptionsCollection.h"
101 #include "ImageData.h"
102 #include "InspectorController.h"
103 #include "KeyboardEvent.h"
104 #include "Location.h"
105 #include "MediaError.h"
106 #include "MediaList.h"
107 #include "MediaPlayer.h"
108 #include "MessageChannel.h"
109 #include "MessageEvent.h"
110 #include "MessagePort.h"
111 #include "MimeTypeArray.h"
112 #include "MouseEvent.h"
113 #include "MutationEvent.h"
114 #include "Navigator.h" // for MimeTypeArray
115 #include "NodeFilter.h"
116 #include "Notation.h"
117 #include "NodeList.h"
118 #include "NodeIterator.h"
119 #include "OverflowEvent.h"
120 #include "Page.h"
121 #include "Plugin.h"
122 #include "PluginArray.h"
123 #include "ProcessingInstruction.h"
124 #include "ProgressEvent.h"
125 #include "Range.h"
126 #include "RangeException.h"
127 #include "Rect.h"
128 #include "RGBColor.h"
129 #include "Screen.h"
130 #include "ScriptExecutionContext.h"
131 #include "SecurityOrigin.h"
132 #include "Settings.h"
133 #include "SQLTransaction.h"
134 #include "SQLResultSet.h"
135 #include "SQLResultSetRowList.h"
136 #include "StyleSheet.h"
137 #include "StyleSheetList.h"
138 #include "SVGColor.h"
139 #include "SVGPaint.h"
140 #include "TextEvent.h"
141 #include "TextMetrics.h"
142 #include "TimeRanges.h"
143 #include "TreeWalker.h"
144 #include "XSLTProcessor.h"
145 #include "V8AbstractEventListener.h"
146 #include "V8CustomEventListener.h"
147 #include "V8DOMWindow.h"
148 #include "V8HTMLElement.h"
149 #include "V8LazyEventListener.h"
150 #include "V8ObjectEventListener.h"
151 #include "WebKitAnimationEvent.h"
152 #include "WebKitCSSKeyframeRule.h"
153 #include "WebKitCSSKeyframesRule.h"
154 #include "WebKitCSSMatrix.h"
155 #include "WebKitCSSTransformValue.h"
156 #include "WebKitPoint.h"
157 #include "WebKitTransitionEvent.h"
158 #include "WheelEvent.h"
159 #include "XMLHttpRequest.h"
160 #include "XMLHttpRequestException.h"
161 #include "XMLHttpRequestProgressEvent.h"
162 #include "XMLHttpRequestUpload.h"
163 #include "XMLSerializer.h"
164 #include "XPathException.h"
165 #include "XPathExpression.h"
166 #include "XPathNSResolver.h"
167 #include "XPathResult.h"
168
48 169
49 #include "ScriptController.h" 170 #include "ScriptController.h"
50 171
172 #if ENABLE(SVG)
173 #include "SVGAngle.h"
174 #include "SVGAnimatedPoints.h"
175 #include "SVGElement.h"
176 #include "SVGElementInstance.h"
177 #include "SVGElementInstanceList.h"
178 #include "SVGException.h"
179 #include "SVGLength.h"
180 #include "SVGLengthList.h"
181 #include "SVGNumberList.h"
182 #include "SVGPathSeg.h"
183 #include "SVGPathSegArc.h"
184 #include "SVGPathSegClosePath.h"
185 #include "SVGPathSegCurvetoCubic.h"
186 #include "SVGPathSegCurvetoCubicSmooth.h"
187 #include "SVGPathSegCurvetoQuadratic.h"
188 #include "SVGPathSegCurvetoQuadraticSmooth.h"
189 #include "SVGPathSegLineto.h"
190 #include "SVGPathSegLinetoHorizontal.h"
191 #include "SVGPathSegLinetoVertical.h"
192 #include "SVGPathSegList.h"
193 #include "SVGPathSegMoveto.h"
194 #include "SVGPointList.h"
195 #include "SVGPreserveAspectRatio.h"
196 #include "SVGRenderingIntent.h"
197 #include "SVGStringList.h"
198 #include "SVGTransform.h"
199 #include "SVGTransformList.h"
200 #include "SVGUnitTypes.h"
201 #include "SVGURIReference.h"
202 #include "SVGZoomEvent.h"
203 #include "V8SVGPODTypeWrapper.h"
204 #endif // SVG
205
206 #if ENABLE(WORKERS)
207 #include "Worker.h"
208 #include "WorkerContext.h"
209 #include "WorkerLocation.h"
210 #include "WorkerNavigator.h"
211 #endif // WORKERS
212
213 #if ENABLE(XPATH)
214 #include "XPathEvaluator.h"
215 #endif
216
217
51 namespace WebCore { 218 namespace WebCore {
52 219
220
221 // DOM binding algorithm:
222 //
223 // There are two kinds of DOM objects:
224 // 1. DOM tree nodes, such as Document, HTMLElement, ...
225 // there classes implements TreeShared<T> interface;
226 // 2. Non-node DOM objects, such as CSSRule, Location, etc.
227 // these classes implement a ref-counted scheme.
228 //
229 // A DOM object may have a JS wrapper object. If a tree node
230 // is alive, its JS wrapper must be kept alive even it is not
231 // reachable from JS roots.
232 // However, JS wrappers of non-node objects can go away if
233 // not reachable from other JS objects. It works like a cache.
234 //
235 // DOM objects are ref-counted, and JS objects are traced from
236 // a set of root objects. They can create a cycle. To break
237 // cycles, we do following:
238 // Handles from DOM objects to JS wrappers are always weak,
239 // so JS wrappers of non-node object cannot create a cycle.
240 // Before starting a global GC, we create a virtual connection
241 // between nodes in the same tree in the JS heap. If the wrapper
242 // of one node in a tree is alive, wrappers of all nodes in
243 // the same tree are considered alive. This is done by creating
244 // object groups in GC prologue callbacks. The mark-compact
245 // collector will remove these groups after each GC.
246
247
53 // Static utility context. 248 // Static utility context.
54 v8::Persistent<v8::Context> V8Proxy::m_utilityContext; 249 v8::Persistent<v8::Context> V8Proxy::m_utilityContext;
55 250
56 // Static list of registered extensions 251 // Static list of registered extensions
57 V8ExtensionList V8Proxy::m_extensions; 252 V8ExtensionList V8Proxy::m_extensions;
58 253
59 254
255 // A helper class for undetectable document.all
256 class UndetectableHTMLCollection : public HTMLCollection {
257 };
258
60 #ifndef NDEBUG 259 #ifndef NDEBUG
61 // Keeps track of global handles created (not JS wrappers 260 // Keeps track of global handles created (not JS wrappers
62 // of DOM objects). Often these global handles are source 261 // of DOM objects). Often these global handles are source
63 // of leaks. 262 // of leaks.
64 // 263 //
65 // If you want to let a C++ object hold a persistent handle 264 // If you want to let a C++ object hold a persistent handle
66 // to a JS object, you should register the handle here to 265 // to a JS object, you should register the handle here to
67 // keep track of leaks. 266 // keep track of leaks.
68 // 267 //
69 // When creating a persistent handle, call: 268 // When creating a persistent handle, call:
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 { 378 {
180 for (DOMNodeMap::iterator it = node_map.begin(), end = node_map.end(); 379 for (DOMNodeMap::iterator it = node_map.begin(), end = node_map.end();
181 it != end; ++it) { 380 it != end; ++it) {
182 Node* node = it->first; 381 Node* node = it->first;
183 USE_VAR(node); 382 USE_VAR(node);
184 ASSERT(v8::Persistent<v8::Object>(it->second).IsWeak()); 383 ASSERT(v8::Persistent<v8::Object>(it->second).IsWeak());
185 } 384 }
186 } 385 }
187 #endif // NDEBUG 386 #endif // NDEBUG
188 387
388 static void WeakDOMObjectCallback(v8::Persistent<v8::Value> obj, void* para);
389 static void WeakActiveDOMObjectCallback(v8::Persistent<v8::Value> obj,
390 void* para);
391 static void WeakNodeCallback(v8::Persistent<v8::Value> obj, void* para);
392 // A map from DOM node to its JS wrapper.
393 static DOMWrapperMap<Node>& GetDOMNodeMap()
394 {
395 static DOMWrapperMap<Node> static_dom_node_map(&WeakNodeCallback);
396 return static_dom_node_map;
397 }
398
399
400 // A map from a DOM object (non-node) to its JS wrapper. This map does not
401 // contain the DOM objects which can have pending activity (active dom objects).
402 DOMWrapperMap<void>& GetDOMObjectMap()
403 {
404 static DOMWrapperMap<void>
405 static_dom_object_map(&WeakDOMObjectCallback);
406 return static_dom_object_map;
407 }
408
409
410 // A map from a DOM object to its JS wrapper for DOM objects which
411 // can have pending activity.
412 static DOMWrapperMap<void>& GetActiveDOMObjectMap()
413 {
414 static DOMWrapperMap<void>
415 static_active_dom_object_map(&WeakActiveDOMObjectCallback);
416 return static_active_dom_object_map;
417 }
418
189 #if ENABLE(SVG) 419 #if ENABLE(SVG)
420 static void WeakSVGElementInstanceCallback(v8::Persistent<v8::Value> obj,
421 void* param);
422
423 // A map for SVGElementInstances.
424 static DOMWrapperMap<SVGElementInstance>& dom_svg_element_instance_map()
425 {
426 static DOMWrapperMap<SVGElementInstance>
427 static_dom_svg_element_instance_map(&WeakSVGElementInstanceCallback);
428 return static_dom_svg_element_instance_map;
429 }
430
431 static void WeakSVGElementInstanceCallback(v8::Persistent<v8::Value> obj,
432 void* param)
433 {
434 SVGElementInstance* instance = static_cast<SVGElementInstance*>(param);
435 ASSERT(dom_svg_element_instance_map().contains(instance));
436
437 instance->deref();
438 dom_svg_element_instance_map().forget(instance);
439 }
440
190 v8::Handle<v8::Value> V8Proxy::SVGElementInstanceToV8Object( 441 v8::Handle<v8::Value> V8Proxy::SVGElementInstanceToV8Object(
191 SVGElementInstance* instance) 442 SVGElementInstance* instance)
192 { 443 {
193 if (!instance) 444 if (!instance)
194 return v8::Null(); 445 return v8::Null();
195 446
196 v8::Handle<v8::Object> existing_instance = getDOMSVGElementInstanceMap().get(i nstance); 447 v8::Handle<v8::Object> existing_instance = dom_svg_element_instance_map().get( instance);
197 if (!existing_instance.IsEmpty()) 448 if (!existing_instance.IsEmpty())
198 return existing_instance; 449 return existing_instance;
199 450
200 instance->ref(); 451 instance->ref();
201 452
202 // Instantiate the V8 object and remember it 453 // Instantiate the V8 object and remember it
203 v8::Handle<v8::Object> result = 454 v8::Handle<v8::Object> result =
204 InstantiateV8Object(V8ClassIndex::SVGELEMENTINSTANCE, 455 InstantiateV8Object(V8ClassIndex::SVGELEMENTINSTANCE,
205 V8ClassIndex::SVGELEMENTINSTANCE, 456 V8ClassIndex::SVGELEMENTINSTANCE,
206 instance); 457 instance);
207 if (!result.IsEmpty()) { 458 if (!result.IsEmpty()) {
208 // Only update the DOM SVG element map if the result is non-empty. 459 // Only update the DOM SVG element map if the result is non-empty.
209 getDOMSVGElementInstanceMap().set(instance, 460 dom_svg_element_instance_map().set(instance,
210 v8::Persistent<v8::Object>::New(result)); 461 v8::Persistent<v8::Object>::New(result));
211 } 462 }
212 return result; 463 return result;
213 } 464 }
214 465
466
467 // SVG non-node elements may have a reference to a context node which
468 // should be notified when the element is change
469 static void WeakSVGObjectWithContext(v8::Persistent<v8::Value> obj,
470 void* dom_obj);
471
472 // Map of SVG objects with contexts to V8 objects
473 static DOMWrapperMap<void>& dom_svg_object_with_context_map() {
474 static DOMWrapperMap<void>
475 static_dom_svg_object_with_context_map(&WeakSVGObjectWithContext);
476 return static_dom_svg_object_with_context_map;
477 }
478
479 // Map of SVG objects with contexts to their contexts
480 static HashMap<void*, SVGElement*>& svg_object_to_context_map()
481 {
482 static HashMap<void*, SVGElement*> static_svg_object_to_context_map;
483 return static_svg_object_to_context_map;
484 }
485
215 v8::Handle<v8::Value> V8Proxy::SVGObjectWithContextToV8Object( 486 v8::Handle<v8::Value> V8Proxy::SVGObjectWithContextToV8Object(
216 V8ClassIndex::V8WrapperType type, void* object) 487 V8ClassIndex::V8WrapperType type, void* object)
217 { 488 {
218 if (!object) 489 if (!object)
219 return v8::Null(); 490 return v8::Null();
220 491
221 v8::Persistent<v8::Object> result = 492 v8::Persistent<v8::Object> result =
222 getDOMSVGObjectWithContextMap().get(object); 493 dom_svg_object_with_context_map().get(object);
223 if (!result.IsEmpty()) return result; 494 if (!result.IsEmpty()) return result;
224 495
225 // Special case: SVGPathSegs need to be downcast to their real type 496 // Special case: SVGPathSegs need to be downcast to their real type
226 if (type == V8ClassIndex::SVGPATHSEG) 497 if (type == V8ClassIndex::SVGPATHSEG)
227 type = V8Custom::DowncastSVGPathSeg(object); 498 type = V8Custom::DowncastSVGPathSeg(object);
228 499
229 v8::Local<v8::Object> v8obj = InstantiateV8Object(type, type, object); 500 v8::Local<v8::Object> v8obj = InstantiateV8Object(type, type, object);
230 if (!v8obj.IsEmpty()) { 501 if (!v8obj.IsEmpty()) {
231 result = v8::Persistent<v8::Object>::New(v8obj); 502 result = v8::Persistent<v8::Object>::New(v8obj);
232 switch (type) { 503 switch (type) {
233 #define MAKE_CASE(TYPE, NAME) \ 504 #define MAKE_CASE(TYPE, NAME) \
234 case V8ClassIndex::TYPE: static_cast<NAME*>(object)->ref(); break; 505 case V8ClassIndex::TYPE: static_cast<NAME*>(object)->ref(); break;
235 SVG_OBJECT_TYPES(MAKE_CASE) 506 SVG_OBJECT_TYPES(MAKE_CASE)
236 #undef MAKE_CASE 507 #undef MAKE_CASE
237 #define MAKE_CASE(TYPE, NAME) \ 508 #define MAKE_CASE(TYPE, NAME) \
238 case V8ClassIndex::TYPE: \ 509 case V8ClassIndex::TYPE: \
239 static_cast<V8SVGPODTypeWrapper<NAME>*>(object)->ref(); break; 510 static_cast<V8SVGPODTypeWrapper<NAME>*>(object)->ref(); break;
240 SVG_POD_NATIVE_TYPES(MAKE_CASE) 511 SVG_POD_NATIVE_TYPES(MAKE_CASE)
241 #undef MAKE_CASE 512 #undef MAKE_CASE
242 default: 513 default:
243 ASSERT(false); 514 ASSERT(false);
244 } 515 }
245 getDOMSVGObjectWithContextMap().set(object, result); 516 dom_svg_object_with_context_map().set(object, result);
246 } 517 }
247 518
248 return result; 519 return result;
249 } 520 }
250 521
251 // Map of SVG objects with contexts to their contexts 522 static void WeakSVGObjectWithContext(v8::Persistent<v8::Value> obj,
252 static HashMap<void*, SVGElement*>& svg_object_to_context_map() { 523 void* dom_obj)
253 static HashMap<void*, SVGElement*> static_svg_object_to_context_map; 524 {
254 return static_svg_object_to_context_map; 525 v8::HandleScope handle_scope;
526 ASSERT(dom_svg_object_with_context_map().contains(dom_obj));
527 ASSERT(obj->IsObject());
528
529 // Forget function removes object from the map and dispose the wrapper.
530 dom_svg_object_with_context_map().forget(dom_obj);
531
532 V8ClassIndex::V8WrapperType type =
533 V8Proxy::GetDOMWrapperType(v8::Handle<v8::Object>::Cast(obj));
534
535 switch (type) {
536 #define MAKE_CASE(TYPE, NAME) \
537 case V8ClassIndex::TYPE: static_cast<NAME*>(dom_obj)->deref(); break;
538 SVG_OBJECT_TYPES(MAKE_CASE)
539 #undef MAKE_CASE
540 #define MAKE_CASE(TYPE, NAME) \
541 case V8ClassIndex::TYPE: \
542 static_cast<V8SVGPODTypeWrapper<NAME>*>(dom_obj)->deref(); break;
543 SVG_POD_NATIVE_TYPES(MAKE_CASE)
544 #undef MAKE_CASE
545 default:
546 ASSERT(false);
547 }
255 } 548 }
256 549
257 void V8Proxy::SetSVGContext(void* obj, SVGElement* context) 550 void V8Proxy::SetSVGContext(void* obj, SVGElement* context)
258 { 551 {
259 SVGElement* old_context = svg_object_to_context_map().get(obj); 552 SVGElement* old_context = svg_object_to_context_map().get(obj);
260 553
261 if (old_context == context) 554 if (old_context == context)
262 return; 555 return;
263 556
264 if (old_context) 557 if (old_context)
265 old_context->deref(); 558 old_context->deref();
266 559
267 if (context) 560 if (context)
268 context->ref(); 561 context->ref();
269 562
270 svg_object_to_context_map().set(obj, context); 563 svg_object_to_context_map().set(obj, context);
271 } 564 }
272 565
273 SVGElement* V8Proxy::GetSVGContext(void* obj) 566 SVGElement* V8Proxy::GetSVGContext(void* obj)
274 { 567 {
275 return svg_object_to_context_map().get(obj); 568 return svg_object_to_context_map().get(obj);
276 } 569 }
570
277 #endif 571 #endif
278 572
573 // Called when obj is near death (not reachable from JS roots)
574 // It is time to remove the entry from the table and dispose
575 // the handle.
576 static void WeakDOMObjectCallback(v8::Persistent<v8::Value> obj,
577 void* dom_obj) {
578 v8::HandleScope scope;
579 ASSERT(GetDOMObjectMap().contains(dom_obj));
580 ASSERT(obj->IsObject());
581
582 // Forget function removes object from the map and dispose the wrapper.
583 GetDOMObjectMap().forget(dom_obj);
584
585 V8ClassIndex::V8WrapperType type =
586 V8Proxy::GetDOMWrapperType(v8::Handle<v8::Object>::Cast(obj));
587 switch (type) {
588 #define MAKE_CASE(TYPE, NAME) \
589 case V8ClassIndex::TYPE: static_cast<NAME*>(dom_obj)->deref(); break;
590 DOM_OBJECT_TYPES(MAKE_CASE)
591 #undef MAKE_CASE
592 default:
593 ASSERT(false);
594 }
595 }
596
597
598 static void WeakActiveDOMObjectCallback(v8::Persistent<v8::Value> obj,
599 void* dom_obj)
600 {
601 v8::HandleScope scope;
602 ASSERT(GetActiveDOMObjectMap().contains(dom_obj));
603 ASSERT(obj->IsObject());
604
605 // Forget function removes object from the map and dispose the wrapper.
606 GetActiveDOMObjectMap().forget(dom_obj);
607
608 V8ClassIndex::V8WrapperType type =
609 V8Proxy::GetDOMWrapperType(v8::Handle<v8::Object>::Cast(obj));
610 switch (type) {
611 #define MAKE_CASE(TYPE, NAME) \
612 case V8ClassIndex::TYPE: static_cast<NAME*>(dom_obj)->deref(); break;
613 ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE)
614 #undef MAKE_CASE
615 default:
616 ASSERT(false);
617 }
618 }
619
620 static void WeakNodeCallback(v8::Persistent<v8::Value> obj, void* param)
621 {
622 Node* node = static_cast<Node*>(param);
623 ASSERT(GetDOMNodeMap().contains(node));
624
625 GetDOMNodeMap().forget(node);
626 node->deref();
627 }
628
629
279 // A map from a DOM node to its JS wrapper, the wrapper 630 // A map from a DOM node to its JS wrapper, the wrapper
280 // is kept as a strong reference to survive GCs. 631 // is kept as a strong reference to survive GCs.
281 static DOMObjectMap& gc_protected_map() { 632 static DOMObjectMap& gc_protected_map() {
282 static DOMObjectMap static_gc_protected_map; 633 static DOMObjectMap static_gc_protected_map;
283 return static_gc_protected_map; 634 return static_gc_protected_map;
284 } 635 }
285 636
286 // static 637 // static
287 void V8Proxy::GCProtect(void* dom_object) 638 void V8Proxy::GCProtect(void* dom_object)
288 { 639 {
289 if (!dom_object) 640 if (!dom_object)
290 return; 641 return;
291 if (gc_protected_map().contains(dom_object)) 642 if (gc_protected_map().contains(dom_object))
292 return; 643 return;
293 if (!getDOMObjectMap().contains(dom_object)) 644 if (!GetDOMObjectMap().contains(dom_object))
294 return; 645 return;
295 646
296 // Create a new (strong) persistent handle for the object. 647 // Create a new (strong) persistent handle for the object.
297 v8::Persistent<v8::Object> wrapper = getDOMObjectMap().get(dom_object); 648 v8::Persistent<v8::Object> wrapper = GetDOMObjectMap().get(dom_object);
298 if (wrapper.IsEmpty()) return; 649 if (wrapper.IsEmpty()) return;
299 650
300 gc_protected_map().set(dom_object, *v8::Persistent<v8::Object>::New(wrapper)); 651 gc_protected_map().set(dom_object, *v8::Persistent<v8::Object>::New(wrapper));
301 } 652 }
302 653
303 654
304 // static 655 // static
305 void V8Proxy::GCUnprotect(void* dom_object) 656 void V8Proxy::GCUnprotect(void* dom_object)
306 { 657 {
307 if (!dom_object) 658 if (!dom_object)
308 return; 659 return;
309 if (!gc_protected_map().contains(dom_object)) 660 if (!gc_protected_map().contains(dom_object))
310 return; 661 return;
311 662
312 // Dispose the strong reference. 663 // Dispose the strong reference.
313 v8::Persistent<v8::Object> wrapper(gc_protected_map().take(dom_object)); 664 v8::Persistent<v8::Object> wrapper(gc_protected_map().take(dom_object));
314 wrapper.Dispose(); 665 wrapper.Dispose();
315 } 666 }
316 667
317 668
318 // Create object groups for DOM tree nodes. 669 // Create object groups for DOM tree nodes.
319 static void GCPrologue() 670 static void GCPrologue()
320 { 671 {
321 v8::HandleScope scope; 672 v8::HandleScope scope;
322 673
323 #ifndef NDEBUG 674 #ifndef NDEBUG
324 EnumerateDOMObjectMap(getDOMObjectMap().impl()); 675 EnumerateDOMObjectMap(GetDOMObjectMap().impl());
325 #endif 676 #endif
326 677
327 // Run through all objects with possible pending activity making their 678 // Run through all objects with possible pending activity making their
328 // wrappers non weak if there is pending activity. 679 // wrappers non weak if there is pending activity.
329 DOMObjectMap active_map = getActiveDOMObjectMap().impl(); 680 DOMObjectMap active_map = GetActiveDOMObjectMap().impl();
330 for (DOMObjectMap::iterator it = active_map.begin(), end = active_map.end(); 681 for (DOMObjectMap::iterator it = active_map.begin(), end = active_map.end();
331 it != end; ++it) { 682 it != end; ++it) {
332 void* obj = it->first; 683 void* obj = it->first;
333 v8::Persistent<v8::Object> wrapper = v8::Persistent<v8::Object>(it->second); 684 v8::Persistent<v8::Object> wrapper = v8::Persistent<v8::Object>(it->second);
334 ASSERT(wrapper.IsWeak()); 685 ASSERT(wrapper.IsWeak());
335 V8ClassIndex::V8WrapperType type = V8Proxy::GetDOMWrapperType(wrapper); 686 V8ClassIndex::V8WrapperType type = V8Proxy::GetDOMWrapperType(wrapper);
336 switch (type) { 687 switch (type) {
337 #define MAKE_CASE(TYPE, NAME) \ 688 #define MAKE_CASE(TYPE, NAME) \
338 case V8ClassIndex::TYPE: { \ 689 case V8ClassIndex::TYPE: { \
339 NAME* impl = static_cast<NAME*>(obj); \ 690 NAME* impl = static_cast<NAME*>(obj); \
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 V8Custom::kMessagePortEntangledPortIndex, v8::Undefined()); 733 V8Custom::kMessagePortEntangledPortIndex, v8::Undefined());
383 } 734 }
384 } 735 }
385 } 736 }
386 } 737 }
387 738
388 // Create object groups. 739 // Create object groups.
389 typedef std::pair<uintptr_t, Node*> GrouperPair; 740 typedef std::pair<uintptr_t, Node*> GrouperPair;
390 typedef Vector<GrouperPair> GrouperList; 741 typedef Vector<GrouperPair> GrouperList;
391 742
392 DOMNodeMap node_map = getDOMNodeMap().impl(); 743 DOMNodeMap node_map = GetDOMNodeMap().impl();
393 GrouperList grouper; 744 GrouperList grouper;
394 grouper.reserveCapacity(node_map.size()); 745 grouper.reserveCapacity(node_map.size());
395 746
396 for (DOMNodeMap::iterator it = node_map.begin(), end = node_map.end(); 747 for (DOMNodeMap::iterator it = node_map.begin(), end = node_map.end();
397 it != end; ++it) { 748 it != end; ++it) {
398 Node* node = it->first; 749 Node* node = it->first;
399 750
400 // If the node is in document, put it in the ownerDocument's object group. 751 // If the node is in document, put it in the ownerDocument's object group.
401 // 752 //
402 // If an image element was created by JavaScript "new Image", 753 // If an image element was created by JavaScript "new Image",
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 // has one object, it has nothing else that needs to be kept alive. 799 // has one object, it has nothing else that needs to be kept alive.
449 if (next_key_index - i <= 1) { 800 if (next_key_index - i <= 1) {
450 i = next_key_index; 801 i = next_key_index;
451 continue; 802 continue;
452 } 803 }
453 804
454 Vector<v8::Persistent<v8::Value> > group; 805 Vector<v8::Persistent<v8::Value> > group;
455 group.reserveCapacity(next_key_index - i); 806 group.reserveCapacity(next_key_index - i);
456 for (; i < next_key_index; ++i) { 807 for (; i < next_key_index; ++i) {
457 v8::Persistent<v8::Value> wrapper = 808 v8::Persistent<v8::Value> wrapper =
458 getDOMNodeMap().get(grouper[i].second); 809 GetDOMNodeMap().get(grouper[i].second);
459 if (!wrapper.IsEmpty()) 810 if (!wrapper.IsEmpty())
460 group.append(wrapper); 811 group.append(wrapper);
461 } 812 }
462 813
463 if (group.size() > 1) 814 if (group.size() > 1)
464 v8::V8::AddObjectGroup(&group[0], group.size()); 815 v8::V8::AddObjectGroup(&group[0], group.size());
465 816
466 ASSERT(i == next_key_index); 817 ASSERT(i == next_key_index);
467 } 818 }
468 } 819 }
469 820
470 821
471 static void GCEpilogue() 822 static void GCEpilogue()
472 { 823 {
473 v8::HandleScope scope; 824 v8::HandleScope scope;
474 825
475 // Run through all objects with pending activity making their wrappers weak 826 // Run through all objects with pending activity making their wrappers weak
476 // again. 827 // again.
477 DOMObjectMap active_map = getActiveDOMObjectMap().impl(); 828 DOMObjectMap active_map = GetActiveDOMObjectMap().impl();
478 for (DOMObjectMap::iterator it = active_map.begin(), end = active_map.end(); 829 for (DOMObjectMap::iterator it = active_map.begin(), end = active_map.end();
479 it != end; ++it) { 830 it != end; ++it) {
480 void* obj = it->first; 831 void* obj = it->first;
481 v8::Persistent<v8::Object> wrapper = v8::Persistent<v8::Object>(it->second); 832 v8::Persistent<v8::Object> wrapper = v8::Persistent<v8::Object>(it->second);
482 V8ClassIndex::V8WrapperType type = V8Proxy::GetDOMWrapperType(wrapper); 833 V8ClassIndex::V8WrapperType type = V8Proxy::GetDOMWrapperType(wrapper);
483 switch (type) { 834 switch (type) {
484 #define MAKE_CASE(TYPE, NAME) \ 835 #define MAKE_CASE(TYPE, NAME) \
485 case V8ClassIndex::TYPE: { \ 836 case V8ClassIndex::TYPE: { \
486 NAME* impl = static_cast<NAME*>(obj); \ 837 NAME* impl = static_cast<NAME*>(obj); \
487 if (impl->hasPendingActivity()) { \ 838 if (impl->hasPendingActivity()) { \
488 ASSERT(!wrapper.IsWeak()); \ 839 ASSERT(!wrapper.IsWeak()); \
489 wrapper.MakeWeak(impl, &weakActiveDOMObjectCallback); \ 840 wrapper.MakeWeak(impl, &WeakActiveDOMObjectCallback); \
490 } \ 841 } \
491 break; \ 842 break; \
492 } 843 }
493 ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE) 844 ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE)
494 default: 845 default:
495 ASSERT(false); 846 ASSERT(false);
496 #undef MAKE_CASE 847 #undef MAKE_CASE
497 } 848 }
498 } 849 }
499 850
500 #ifndef NDEBUG 851 #ifndef NDEBUG
501 // Check all survivals are weak. 852 // Check all survivals are weak.
502 EnumerateDOMObjectMap(getDOMObjectMap().impl()); 853 EnumerateDOMObjectMap(GetDOMObjectMap().impl());
503 EnumerateDOMNodeMap(getDOMNodeMap().impl()); 854 EnumerateDOMNodeMap(GetDOMNodeMap().impl());
504 EnumerateDOMObjectMap(gc_protected_map()); 855 EnumerateDOMObjectMap(gc_protected_map());
505 EnumerateGlobalHandles(); 856 EnumerateGlobalHandles();
506 #undef USE_VAR 857 #undef USE_VAR
507 #endif 858 #endif
508 } 859 }
509 860
510 861
511 typedef HashMap<int, v8::FunctionTemplate*> FunctionTemplateMap; 862 typedef HashMap<int, v8::FunctionTemplate*> FunctionTemplateMap;
512 863
513 bool AllowAllocation::m_current = false; 864 bool AllowAllocation::m_current = false;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 #ifndef NDEBUG 1106 #ifndef NDEBUG
756 UnregisterGlobalHandle(this, m_global); 1107 UnregisterGlobalHandle(this, m_global);
757 #endif 1108 #endif
758 m_global.Dispose(); 1109 m_global.Dispose();
759 m_global.Clear(); 1110 m_global.Clear();
760 } 1111 }
761 } 1112 }
762 1113
763 1114
764 bool V8Proxy::DOMObjectHasJSWrapper(void* obj) { 1115 bool V8Proxy::DOMObjectHasJSWrapper(void* obj) {
765 return getDOMObjectMap().contains(obj) || 1116 return GetDOMObjectMap().contains(obj) ||
766 getActiveDOMObjectMap().contains(obj); 1117 GetActiveDOMObjectMap().contains(obj);
767 } 1118 }
768 1119
769 1120
770 // The caller must have increased obj's ref count. 1121 // The caller must have increased obj's ref count.
771 void V8Proxy::SetJSWrapperForDOMObject(void* obj, v8::Persistent<v8::Object> wra pper) 1122 void V8Proxy::SetJSWrapperForDOMObject(void* obj, v8::Persistent<v8::Object> wra pper)
772 { 1123 {
773 ASSERT(MaybeDOMWrapper(wrapper)); 1124 ASSERT(MaybeDOMWrapper(wrapper));
774 #ifndef NDEBUG 1125 #ifndef NDEBUG
775 V8ClassIndex::V8WrapperType type = V8Proxy::GetDOMWrapperType(wrapper); 1126 V8ClassIndex::V8WrapperType type = V8Proxy::GetDOMWrapperType(wrapper);
776 switch (type) { 1127 switch (type) {
777 #define MAKE_CASE(TYPE, NAME) case V8ClassIndex::TYPE: 1128 #define MAKE_CASE(TYPE, NAME) case V8ClassIndex::TYPE:
778 ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE) 1129 ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE)
779 ASSERT(false); 1130 ASSERT(false);
780 #undef MAKE_CASE 1131 #undef MAKE_CASE
781 default: break; 1132 default: break;
782 } 1133 }
783 #endif 1134 #endif
784 getDOMObjectMap().set(obj, wrapper); 1135 GetDOMObjectMap().set(obj, wrapper);
785 } 1136 }
786 1137
787 // The caller must have increased obj's ref count. 1138 // The caller must have increased obj's ref count.
788 void V8Proxy::SetJSWrapperForActiveDOMObject(void* obj, v8::Persistent<v8::Objec t> wrapper) 1139 void V8Proxy::SetJSWrapperForActiveDOMObject(void* obj, v8::Persistent<v8::Objec t> wrapper)
789 { 1140 {
790 ASSERT(MaybeDOMWrapper(wrapper)); 1141 ASSERT(MaybeDOMWrapper(wrapper));
791 #ifndef NDEBUG 1142 #ifndef NDEBUG
792 V8ClassIndex::V8WrapperType type = V8Proxy::GetDOMWrapperType(wrapper); 1143 V8ClassIndex::V8WrapperType type = V8Proxy::GetDOMWrapperType(wrapper);
793 switch (type) { 1144 switch (type) {
794 #define MAKE_CASE(TYPE, NAME) case V8ClassIndex::TYPE: break; 1145 #define MAKE_CASE(TYPE, NAME) case V8ClassIndex::TYPE: break;
795 ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE) 1146 ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE)
796 default: ASSERT(false); 1147 default: ASSERT(false);
797 #undef MAKE_CASE 1148 #undef MAKE_CASE
798 } 1149 }
799 #endif 1150 #endif
800 getActiveDOMObjectMap().set(obj, wrapper); 1151 GetActiveDOMObjectMap().set(obj, wrapper);
801 } 1152 }
802 1153
803 // The caller must have increased node's ref count. 1154 // The caller must have increased node's ref count.
804 void V8Proxy::SetJSWrapperForDOMNode(Node* node, v8::Persistent<v8::Object> wrap per) 1155 void V8Proxy::SetJSWrapperForDOMNode(Node* node, v8::Persistent<v8::Object> wrap per)
805 { 1156 {
806 ASSERT(MaybeDOMWrapper(wrapper)); 1157 ASSERT(MaybeDOMWrapper(wrapper));
807 getDOMNodeMap().set(node, wrapper); 1158 GetDOMNodeMap().set(node, wrapper);
808 } 1159 }
809 1160
810 PassRefPtr<EventListener> V8Proxy::createInlineEventListener( 1161 PassRefPtr<EventListener> V8Proxy::createInlineEventListener(
811 const String& functionName, 1162 const String& functionName,
812 const String& code, Node* node) 1163 const String& code, Node* node)
813 { 1164 {
814 return V8LazyEventListener::create(m_frame, code, functionName); 1165 return V8LazyEventListener::create(m_frame, code, functionName);
815 } 1166 }
816 1167
817 #if ENABLE(SVG) 1168 #if ENABLE(SVG)
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 default: 2625 default:
2275 break; 2626 break;
2276 } 2627 }
2277 2628
2278 #undef MAKE_CASE 2629 #undef MAKE_CASE
2279 2630
2280 if (!imp) return v8::Null(); 2631 if (!imp) return v8::Null();
2281 2632
2282 // Non DOM node 2633 // Non DOM node
2283 v8::Persistent<v8::Object> result = is_active_dom_object ? 2634 v8::Persistent<v8::Object> result = is_active_dom_object ?
2284 getActiveDOMObjectMap().get(imp) : 2635 GetActiveDOMObjectMap().get(imp) :
2285 getDOMObjectMap().get(imp); 2636 GetDOMObjectMap().get(imp);
2286 if (result.IsEmpty()) { 2637 if (result.IsEmpty()) {
2287 v8::Local<v8::Object> v8obj = InstantiateV8Object(type, type, imp); 2638 v8::Local<v8::Object> v8obj = InstantiateV8Object(type, type, imp);
2288 if (!v8obj.IsEmpty()) { 2639 if (!v8obj.IsEmpty()) {
2289 // Go through big switch statement, it has some duplications 2640 // Go through big switch statement, it has some duplications
2290 // that were handled by code above (such as CSSVALUE, CSSRULE, etc). 2641 // that were handled by code above (such as CSSVALUE, CSSRULE, etc).
2291 switch (type) { 2642 switch (type) {
2292 #define MAKE_CASE(TYPE, NAME) \ 2643 #define MAKE_CASE(TYPE, NAME) \
2293 case V8ClassIndex::TYPE: static_cast<NAME*>(imp)->ref(); break; 2644 case V8ClassIndex::TYPE: static_cast<NAME*>(imp)->ref(); break;
2294 DOM_OBJECT_TYPES(MAKE_CASE) 2645 DOM_OBJECT_TYPES(MAKE_CASE)
2295 #undef MAKE_CASE 2646 #undef MAKE_CASE
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2745 #undef FOR_EACH_TAG 3096 #undef FOR_EACH_TAG
2746 3097
2747 #endif // ENABLE(SVG) 3098 #endif // ENABLE(SVG)
2748 3099
2749 3100
2750 v8::Handle<v8::Value> V8Proxy::EventToV8Object(Event* event) 3101 v8::Handle<v8::Value> V8Proxy::EventToV8Object(Event* event)
2751 { 3102 {
2752 if (!event) 3103 if (!event)
2753 return v8::Null(); 3104 return v8::Null();
2754 3105
2755 v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(event); 3106 v8::Handle<v8::Object> wrapper = GetDOMObjectMap().get(event);
2756 if (!wrapper.IsEmpty()) 3107 if (!wrapper.IsEmpty())
2757 return wrapper; 3108 return wrapper;
2758 3109
2759 V8ClassIndex::V8WrapperType type = V8ClassIndex::EVENT; 3110 V8ClassIndex::V8WrapperType type = V8ClassIndex::EVENT;
2760 3111
2761 if (event->isUIEvent()) { 3112 if (event->isUIEvent()) {
2762 if (event->isKeyboardEvent()) 3113 if (event->isKeyboardEvent())
2763 type = V8ClassIndex::KEYBOARDEVENT; 3114 type = V8ClassIndex::KEYBOARDEVENT;
2764 else if (event->isTextEvent()) 3115 else if (event->isTextEvent())
2765 type = V8ClassIndex::TEXTEVENT; 3116 type = V8ClassIndex::TEXTEVENT;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2804 3155
2805 return result; 3156 return result;
2806 } 3157 }
2807 3158
2808 3159
2809 // Caller checks node is not null. 3160 // Caller checks node is not null.
2810 v8::Handle<v8::Value> V8Proxy::NodeToV8Object(Node* node) 3161 v8::Handle<v8::Value> V8Proxy::NodeToV8Object(Node* node)
2811 { 3162 {
2812 if (!node) return v8::Null(); 3163 if (!node) return v8::Null();
2813 3164
2814 v8::Handle<v8::Object> wrapper = getDOMNodeMap().get(node); 3165 v8::Handle<v8::Object> wrapper = GetDOMNodeMap().get(node);
2815 if (!wrapper.IsEmpty()) 3166 if (!wrapper.IsEmpty())
2816 return wrapper; 3167 return wrapper;
2817 3168
2818 bool is_document = false; // document type node has special handling 3169 bool is_document = false; // document type node has special handling
2819 V8ClassIndex::V8WrapperType type; 3170 V8ClassIndex::V8WrapperType type;
2820 3171
2821 switch (node->nodeType()) { 3172 switch (node->nodeType()) {
2822 case Node::ELEMENT_NODE: 3173 case Node::ELEMENT_NODE:
2823 if (node->isHTMLElement()) 3174 if (node->isHTMLElement())
2824 type = GetHTMLElementType(static_cast<HTMLElement*>(node)); 3175 type = GetHTMLElementType(static_cast<HTMLElement*>(node));
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2950 return ToV8Object(V8ClassIndex::WORKER, worker); 3301 return ToV8Object(V8ClassIndex::WORKER, worker);
2951 #endif // WORKERS 3302 #endif // WORKERS
2952 3303
2953 Node* node = target->toNode(); 3304 Node* node = target->toNode();
2954 if (node) 3305 if (node)
2955 return NodeToV8Object(node); 3306 return NodeToV8Object(node);
2956 3307
2957 // XMLHttpRequest is created within its JS counterpart. 3308 // XMLHttpRequest is created within its JS counterpart.
2958 XMLHttpRequest* xhr = target->toXMLHttpRequest(); 3309 XMLHttpRequest* xhr = target->toXMLHttpRequest();
2959 if (xhr) { 3310 if (xhr) {
2960 v8::Handle<v8::Object> wrapper = getActiveDOMObjectMap().get(xhr); 3311 v8::Handle<v8::Object> wrapper = GetActiveDOMObjectMap().get(xhr);
2961 ASSERT(!wrapper.IsEmpty()); 3312 ASSERT(!wrapper.IsEmpty());
2962 return wrapper; 3313 return wrapper;
2963 } 3314 }
2964 3315
2965 // MessagePort is created within its JS counterpart 3316 // MessagePort is created within its JS counterpart
2966 MessagePort* port = target->toMessagePort(); 3317 MessagePort* port = target->toMessagePort();
2967 if (port) { 3318 if (port) {
2968 v8::Handle<v8::Object> wrapper = getActiveDOMObjectMap().get(port); 3319 v8::Handle<v8::Object> wrapper = GetActiveDOMObjectMap().get(port);
2969 ASSERT(!wrapper.IsEmpty()); 3320 ASSERT(!wrapper.IsEmpty());
2970 return wrapper; 3321 return wrapper;
2971 } 3322 }
2972 3323
2973 XMLHttpRequestUpload* upload = target->toXMLHttpRequestUpload(); 3324 XMLHttpRequestUpload* upload = target->toXMLHttpRequestUpload();
2974 if (upload) { 3325 if (upload) {
2975 v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(upload); 3326 v8::Handle<v8::Object> wrapper = GetDOMObjectMap().get(upload);
2976 ASSERT(!wrapper.IsEmpty()); 3327 ASSERT(!wrapper.IsEmpty());
2977 return wrapper; 3328 return wrapper;
2978 } 3329 }
2979 3330
2980 ASSERT(0); 3331 ASSERT(0);
2981 return v8::Handle<v8::Value>(); 3332 return v8::Handle<v8::Value>();
2982 } 3333 }
2983 3334
2984 3335
2985 v8::Handle<v8::Value> V8Proxy::EventListenerToV8Object( 3336 v8::Handle<v8::Value> V8Proxy::EventListenerToV8Object(
(...skipping 21 matching lines...) Expand all
3007 return v8::Null(); 3358 return v8::Null();
3008 } 3359 }
3009 return result; 3360 return result;
3010 } 3361 }
3011 3362
3012 3363
3013 v8::Handle<v8::Value> V8Proxy::StyleSheetToV8Object(StyleSheet* sheet) 3364 v8::Handle<v8::Value> V8Proxy::StyleSheetToV8Object(StyleSheet* sheet)
3014 { 3365 {
3015 if (!sheet) return v8::Null(); 3366 if (!sheet) return v8::Null();
3016 3367
3017 v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(sheet); 3368 v8::Handle<v8::Object> wrapper = GetDOMObjectMap().get(sheet);
3018 if (!wrapper.IsEmpty()) 3369 if (!wrapper.IsEmpty())
3019 return wrapper; 3370 return wrapper;
3020 3371
3021 V8ClassIndex::V8WrapperType type = V8ClassIndex::STYLESHEET; 3372 V8ClassIndex::V8WrapperType type = V8ClassIndex::STYLESHEET;
3022 if (sheet->isCSSStyleSheet()) 3373 if (sheet->isCSSStyleSheet())
3023 type = V8ClassIndex::CSSSTYLESHEET; 3374 type = V8ClassIndex::CSSSTYLESHEET;
3024 3375
3025 v8::Handle<v8::Object> result = 3376 v8::Handle<v8::Object> result =
3026 InstantiateV8Object(type, V8ClassIndex::STYLESHEET, sheet); 3377 InstantiateV8Object(type, V8ClassIndex::STYLESHEET, sheet);
3027 if (!result.IsEmpty()) { 3378 if (!result.IsEmpty()) {
(...skipping 11 matching lines...) Expand all
3039 } 3390 }
3040 3391
3041 return result; 3392 return result;
3042 } 3393 }
3043 3394
3044 3395
3045 v8::Handle<v8::Value> V8Proxy::CSSValueToV8Object(CSSValue* value) 3396 v8::Handle<v8::Value> V8Proxy::CSSValueToV8Object(CSSValue* value)
3046 { 3397 {
3047 if (!value) return v8::Null(); 3398 if (!value) return v8::Null();
3048 3399
3049 v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(value); 3400 v8::Handle<v8::Object> wrapper = GetDOMObjectMap().get(value);
3050 if (!wrapper.IsEmpty()) 3401 if (!wrapper.IsEmpty())
3051 return wrapper; 3402 return wrapper;
3052 3403
3053 V8ClassIndex::V8WrapperType type; 3404 V8ClassIndex::V8WrapperType type;
3054 3405
3055 if (value->isWebKitCSSTransformValue()) 3406 if (value->isWebKitCSSTransformValue())
3056 type = V8ClassIndex::WEBKITCSSTRANSFORMVALUE; 3407 type = V8ClassIndex::WEBKITCSSTRANSFORMVALUE;
3057 else if (value->isValueList()) 3408 else if (value->isValueList())
3058 type = V8ClassIndex::CSSVALUELIST; 3409 type = V8ClassIndex::CSSVALUELIST;
3059 else if (value->isPrimitiveValue()) 3410 else if (value->isPrimitiveValue())
(...skipping 16 matching lines...) Expand all
3076 } 3427 }
3077 3428
3078 return result; 3429 return result;
3079 } 3430 }
3080 3431
3081 3432
3082 v8::Handle<v8::Value> V8Proxy::CSSRuleToV8Object(CSSRule* rule) 3433 v8::Handle<v8::Value> V8Proxy::CSSRuleToV8Object(CSSRule* rule)
3083 { 3434 {
3084 if (!rule) return v8::Null(); 3435 if (!rule) return v8::Null();
3085 3436
3086 v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(rule); 3437 v8::Handle<v8::Object> wrapper = GetDOMObjectMap().get(rule);
3087 if (!wrapper.IsEmpty()) 3438 if (!wrapper.IsEmpty())
3088 return wrapper; 3439 return wrapper;
3089 3440
3090 V8ClassIndex::V8WrapperType type; 3441 V8ClassIndex::V8WrapperType type;
3091 3442
3092 switch (rule->type()) { 3443 switch (rule->type()) {
3093 case CSSRule::STYLE_RULE: 3444 case CSSRule::STYLE_RULE:
3094 type = V8ClassIndex::CSSSTYLERULE; 3445 type = V8ClassIndex::CSSSTYLERULE;
3095 break; 3446 break;
3096 case CSSRule::CHARSET_RULE: 3447 case CSSRule::CHARSET_RULE:
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 } 3611 }
3261 3612
3262 void V8Proxy::RegisterExtension(v8::Extension* extension, 3613 void V8Proxy::RegisterExtension(v8::Extension* extension,
3263 const String& schemeRestriction) { 3614 const String& schemeRestriction) {
3264 v8::RegisterExtension(extension); 3615 v8::RegisterExtension(extension);
3265 V8ExtensionInfo info = {schemeRestriction, extension}; 3616 V8ExtensionInfo info = {schemeRestriction, extension};
3266 m_extensions.push_back(info); 3617 m_extensions.push_back(info);
3267 } 3618 }
3268 3619
3269 } // namespace WebCore 3620 } // namespace WebCore
OLDNEW
« no previous file with comments | « webkit/port/bindings/v8/v8_proxy.h ('k') | webkit/webkit.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698