OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // V8LazyEventListener is a wrapper for a JavaScript code string that is com
piled and evaluated when an event is fired. | 47 // V8LazyEventListener is a wrapper for a JavaScript code string that is com
piled and evaluated when an event is fired. |
48 // A V8LazyEventListener is either a HTML or SVG event handler. | 48 // A V8LazyEventListener is either a HTML or SVG event handler. |
49 class V8LazyEventListener FINAL : public V8AbstractEventListener { | 49 class V8LazyEventListener FINAL : public V8AbstractEventListener { |
50 public: | 50 public: |
51 static PassRefPtr<V8LazyEventListener> create(const AtomicString& functi
onName, const AtomicString& eventParameterName, const String& code, const String
& sourceURL, const TextPosition& position, Node* node, v8::Isolate* isolate) | 51 static PassRefPtr<V8LazyEventListener> create(const AtomicString& functi
onName, const AtomicString& eventParameterName, const String& code, const String
& sourceURL, const TextPosition& position, Node* node, v8::Isolate* isolate) |
52 { | 52 { |
53 return adoptRef(new V8LazyEventListener(functionName, eventParameter
Name, code, sourceURL, position, node, isolate)); | 53 return adoptRef(new V8LazyEventListener(functionName, eventParameter
Name, code, sourceURL, position, node, isolate)); |
54 } | 54 } |
55 | 55 |
56 virtual bool isLazy() const OVERRIDE { return true; } | 56 virtual bool isLazy() const OVERRIDE { return true; } |
| 57 // V8LazyEventListener is always for the main world. |
| 58 virtual DOMWrapperWorld& world() const OVERRIDE { return DOMWrapperWorld
::mainWorld(); } |
| 59 |
| 60 virtual void handleEvent(ExecutionContext*, Event*) OVERRIDE; |
57 | 61 |
58 protected: | 62 protected: |
59 virtual void prepareListenerObject(ExecutionContext*) OVERRIDE; | 63 virtual void prepareListenerObject(ExecutionContext*) OVERRIDE; |
60 | 64 |
61 private: | 65 private: |
62 V8LazyEventListener(const AtomicString& functionName, const AtomicString
& eventParameterName, const String& code, const String sourceURL, const TextPosi
tion&, Node*, v8::Isolate*); | 66 V8LazyEventListener(const AtomicString& functionName, const AtomicString
& eventParameterName, const String& code, const String sourceURL, const TextPosi
tion&, Node*, v8::Isolate*); |
63 | 67 |
64 virtual v8::Local<v8::Value> callListenerFunction(ExecutionContext*, v8:
:Handle<v8::Value> jsEvent, Event*) OVERRIDE; | 68 virtual v8::Local<v8::Value> callListenerFunction(ExecutionContext*, v8:
:Handle<v8::Value> jsEvent, Event*) OVERRIDE; |
65 | 69 |
66 // Needs to return true for all event handlers implemented in JavaScript
so that | 70 // Needs to return true for all event handlers implemented in JavaScript
so that |
67 // the SVG code does not add the event handler in both | 71 // the SVG code does not add the event handler in both |
68 // SVGUseElement::buildShadowTree and again in | 72 // SVGUseElement::buildShadowTree and again in |
69 // SVGUseElement::transferEventListenersToShadowTree | 73 // SVGUseElement::transferEventListenersToShadowTree |
70 virtual bool wasCreatedFromMarkup() const OVERRIDE { return true; } | 74 virtual bool wasCreatedFromMarkup() const OVERRIDE { return true; } |
71 | 75 |
72 AtomicString m_functionName; | 76 AtomicString m_functionName; |
73 AtomicString m_eventParameterName; | 77 AtomicString m_eventParameterName; |
74 String m_code; | 78 String m_code; |
75 String m_sourceURL; | 79 String m_sourceURL; |
76 Node* m_node; | 80 Node* m_node; |
77 TextPosition m_position; | 81 TextPosition m_position; |
78 }; | 82 }; |
79 | 83 |
80 } // namespace WebCore | 84 } // namespace WebCore |
81 | 85 |
82 #endif // V8LazyEventListener_h | 86 #endif // V8LazyEventListener_h |
OLD | NEW |