| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Harri Porten (porten@kde.org) | 2 * Copyright (C) 2000 Harri Porten (porten@kde.org) |
| 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
| 4 * Copyright (C) 2004-2006 Apple Computer, Inc. | 4 * Copyright (C) 2004-2006 Apple Computer, Inc. |
| 5 * Copyright (C) 2006 James G. Speth (speth@end.com) | 5 * Copyright (C) 2006 James G. Speth (speth@end.com) |
| 6 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) | 6 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) |
| 7 * Copyright 2007, 2008 Google Inc. All Rights Reserved. | 7 * Copyright 2007, 2008 Google Inc. All Rights Reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Lesser General Public | 10 * modify it under the terms of the GNU Lesser General Public |
| (...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 | 1065 |
| 1066 Document* doc = imp->frame()->document(); | 1066 Document* doc = imp->frame()->document(); |
| 1067 if (!doc) | 1067 if (!doc) |
| 1068 return; | 1068 return; |
| 1069 | 1069 |
| 1070 String key = ToWebCoreString(name); | 1070 String key = ToWebCoreString(name); |
| 1071 String event_type = EventNameFromAttributeName(key); | 1071 String event_type = EventNameFromAttributeName(key); |
| 1072 | 1072 |
| 1073 if (value->IsNull()) { | 1073 if (value->IsNull()) { |
| 1074 // Clear the event listener | 1074 // Clear the event listener |
| 1075 imp->clearInlineEventListener(event_type); | 1075 imp->clearAttributeEventListener(event_type); |
| 1076 } else { | 1076 } else { |
| 1077 V8Proxy* proxy = V8Proxy::retrieve(imp->frame()); | 1077 V8Proxy* proxy = V8Proxy::retrieve(imp->frame()); |
| 1078 if (!proxy) | 1078 if (!proxy) |
| 1079 return; | 1079 return; |
| 1080 | 1080 |
| 1081 RefPtr<EventListener> listener = | 1081 RefPtr<EventListener> listener = |
| 1082 proxy->FindOrCreateV8EventListener(value, true); | 1082 proxy->FindOrCreateV8EventListener(value, true); |
| 1083 if (listener) { | 1083 if (listener) { |
| 1084 imp->setInlineEventListener(event_type, listener); | 1084 imp->setAttributeEventListener(event_type, listener); |
| 1085 } | 1085 } |
| 1086 } | 1086 } |
| 1087 } | 1087 } |
| 1088 | 1088 |
| 1089 | 1089 |
| 1090 ACCESSOR_GETTER(DOMWindowEventHandler) { | 1090 ACCESSOR_GETTER(DOMWindowEventHandler) { |
| 1091 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper( | 1091 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper( |
| 1092 V8ClassIndex::DOMWINDOW, info.This()); | 1092 V8ClassIndex::DOMWINDOW, info.This()); |
| 1093 if (holder.IsEmpty()) | 1093 if (holder.IsEmpty()) |
| 1094 return v8::Undefined(); | 1094 return v8::Undefined(); |
| 1095 | 1095 |
| 1096 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>( | 1096 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>( |
| 1097 V8ClassIndex::DOMWINDOW, holder); | 1097 V8ClassIndex::DOMWINDOW, holder); |
| 1098 if (!imp->frame()) | 1098 if (!imp->frame()) |
| 1099 return v8::Undefined(); | 1099 return v8::Undefined(); |
| 1100 | 1100 |
| 1101 Document* doc = imp->frame()->document(); | 1101 Document* doc = imp->frame()->document(); |
| 1102 if (!doc) | 1102 if (!doc) |
| 1103 return v8::Undefined(); | 1103 return v8::Undefined(); |
| 1104 | 1104 |
| 1105 String key = ToWebCoreString(name); | 1105 String key = ToWebCoreString(name); |
| 1106 String event_type = EventNameFromAttributeName(key); | 1106 String event_type = EventNameFromAttributeName(key); |
| 1107 | 1107 |
| 1108 EventListener* listener = imp->getInlineEventListener(event_type); | 1108 EventListener* listener = imp->getAttributeEventListener(event_type); |
| 1109 return V8Proxy::EventListenerToV8Object(listener); | 1109 return V8Proxy::EventListenerToV8Object(listener); |
| 1110 } | 1110 } |
| 1111 | 1111 |
| 1112 | 1112 |
| 1113 ACCESSOR_SETTER(ElementEventHandler) { | 1113 ACCESSOR_SETTER(ElementEventHandler) { |
| 1114 Node* node = V8Proxy::DOMWrapperToNode<Node>(info.Holder()); | 1114 Node* node = V8Proxy::DOMWrapperToNode<Node>(info.Holder()); |
| 1115 | 1115 |
| 1116 // Name starts with 'on', remove them. | 1116 // Name starts with 'on', remove them. |
| 1117 String key = ToWebCoreString(name); | 1117 String key = ToWebCoreString(name); |
| 1118 ASSERT(key.startsWith("on")); | 1118 ASSERT(key.startsWith("on")); |
| 1119 String event_type = key.substring(2); | 1119 String event_type = key.substring(2); |
| 1120 | 1120 |
| 1121 // Set handler if the value is a function. Otherwise, clear the | 1121 // Set handler if the value is a function. Otherwise, clear the |
| 1122 // event handler. | 1122 // event handler. |
| 1123 if (value->IsFunction()) { | 1123 if (value->IsFunction()) { |
| 1124 V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame()); | 1124 V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame()); |
| 1125 // the document might be created using createDocument, | 1125 // the document might be created using createDocument, |
| 1126 // which does not have a frame, use the active frame | 1126 // which does not have a frame, use the active frame |
| 1127 if (!proxy) | 1127 if (!proxy) |
| 1128 proxy = V8Proxy::retrieve(V8Proxy::retrieveActiveFrame()); | 1128 proxy = V8Proxy::retrieve(V8Proxy::retrieveActiveFrame()); |
| 1129 if (!proxy) | 1129 if (!proxy) |
| 1130 return; | 1130 return; |
| 1131 | 1131 |
| 1132 RefPtr<EventListener> listener = | 1132 RefPtr<EventListener> listener = |
| 1133 proxy->FindOrCreateV8EventListener(value, true); | 1133 proxy->FindOrCreateV8EventListener(value, true); |
| 1134 if (listener) { | 1134 if (listener) { |
| 1135 node->setInlineEventListener(event_type, listener); | 1135 node->setAttributeEventListener(event_type, listener); |
| 1136 } | 1136 } |
| 1137 } else { | 1137 } else { |
| 1138 node->clearInlineEventListener(event_type); | 1138 node->clearAttributeEventListener(event_type); |
| 1139 } | 1139 } |
| 1140 } | 1140 } |
| 1141 | 1141 |
| 1142 | 1142 |
| 1143 ACCESSOR_GETTER(ElementEventHandler) { | 1143 ACCESSOR_GETTER(ElementEventHandler) { |
| 1144 Node* node = V8Proxy::DOMWrapperToNode<Node>(info.Holder()); | 1144 Node* node = V8Proxy::DOMWrapperToNode<Node>(info.Holder()); |
| 1145 | 1145 |
| 1146 // Name starts with 'on', remove them. | 1146 // Name starts with 'on', remove them. |
| 1147 String key = ToWebCoreString(name); | 1147 String key = ToWebCoreString(name); |
| 1148 ASSERT(key.startsWith("on")); | 1148 ASSERT(key.startsWith("on")); |
| 1149 String event_type = key.substring(2); | 1149 String event_type = key.substring(2); |
| 1150 | 1150 |
| 1151 EventListener* listener = node->getInlineEventListener(event_type); | 1151 EventListener* listener = node->getAttributeEventListener(event_type); |
| 1152 return V8Proxy::EventListenerToV8Object(listener); | 1152 return V8Proxy::EventListenerToV8Object(listener); |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 // --------------- Security Checks ------------------------- | 1155 // --------------- Security Checks ------------------------- |
| 1156 NAMED_ACCESS_CHECK(DOMWindow) { | 1156 NAMED_ACCESS_CHECK(DOMWindow) { |
| 1157 ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::DOMWINDOW); | 1157 ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::DOMWINDOW); |
| 1158 v8::Handle<v8::Value> window = | 1158 v8::Handle<v8::Value> window = |
| 1159 V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, host); | 1159 V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, host); |
| 1160 if (window.IsEmpty()) | 1160 if (window.IsEmpty()) |
| 1161 return false; // the frame is gone. | 1161 return false; // the frame is gone. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 #undef MAKE_CASE | 1303 #undef MAKE_CASE |
| 1304 | 1304 |
| 1305 default: | 1305 default: |
| 1306 return V8ClassIndex::INVALID_CLASS_INDEX; | 1306 return V8ClassIndex::INVALID_CLASS_INDEX; |
| 1307 } | 1307 } |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 #endif // ENABLE(SVG) | 1310 #endif // ENABLE(SVG) |
| 1311 | 1311 |
| 1312 } // namespace WebCore | 1312 } // namespace WebCore |
| OLD | NEW |