OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2007-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 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "bindings/core/v8/V8InspectorFrontendHost.h" | 32 #include "bindings/core/v8/V8InspectorFrontendHost.h" |
33 | 33 |
34 #include "bindings/core/v8/V8Binding.h" | 34 #include "bindings/core/v8/V8Binding.h" |
| 35 #include "bindings/core/v8/V8HTMLDocument.h" |
35 #include "bindings/core/v8/V8MouseEvent.h" | 36 #include "bindings/core/v8/V8MouseEvent.h" |
36 #include "bindings/core/v8/V8Window.h" | 37 #include "bindings/core/v8/V8Window.h" |
37 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
38 #include "core/frame/LocalDOMWindow.h" | 39 #include "core/frame/LocalDOMWindow.h" |
39 #include "core/inspector/InspectorController.h" | 40 #include "core/inspector/InspectorController.h" |
40 #include "core/inspector/InspectorFrontendClient.h" | 41 #include "core/inspector/InspectorFrontendClient.h" |
41 #include "core/inspector/InspectorFrontendHost.h" | 42 #include "core/inspector/InspectorFrontendHost.h" |
42 #include "platform/ContextMenu.h" | 43 #include "platform/ContextMenu.h" |
43 #include "public/platform/Platform.h" | 44 #include "public/platform/Platform.h" |
44 #include "wtf/text/WTFString.h" | 45 #include "wtf/text/WTFString.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 if (!y->IsNumber()) | 140 if (!y->IsNumber()) |
140 return; | 141 return; |
141 | 142 |
142 v8::Local<v8::Value> array = v8::Local<v8::Value>::Cast(info[2]); | 143 v8::Local<v8::Value> array = v8::Local<v8::Value>::Cast(info[2]); |
143 if (!array->IsArray()) | 144 if (!array->IsArray()) |
144 return; | 145 return; |
145 ContextMenu menu; | 146 ContextMenu menu; |
146 if (!populateContextMenuItems(v8::Local<v8::Array>::Cast(array), menu, info.
GetIsolate())) | 147 if (!populateContextMenuItems(v8::Local<v8::Array>::Cast(array), menu, info.
GetIsolate())) |
147 return; | 148 return; |
148 | 149 |
149 v8::Isolate* isolate = info.GetIsolate(); | 150 Document* document = nullptr; |
150 v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChai
n(isolate->GetEnteredContext()->Global(), isolate); | 151 if (info.Length() >= 4) { |
151 if (windowWrapper.IsEmpty()) | 152 v8::Local<v8::Object> documentWrapper = v8::Local<v8::Object>::Cast(info
[3]); |
152 return; | 153 if (!V8HTMLDocument::wrapperTypeInfo.equals(toWrapperTypeInfo(documentWr
apper))) |
153 LocalDOMWindow* window = V8Window::toImpl(windowWrapper); | 154 return; |
154 if (!window->document() || !window->document()->page()) | 155 document = V8HTMLDocument::toImpl(documentWrapper); |
| 156 } else { |
| 157 v8::Isolate* isolate = info.GetIsolate(); |
| 158 v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototype
Chain(isolate->GetEnteredContext()->Global(), isolate); |
| 159 if (windowWrapper.IsEmpty()) |
| 160 return; |
| 161 LocalDOMWindow* window = V8Window::toImpl(windowWrapper); |
| 162 document = window ? window->document() : nullptr; |
| 163 } |
| 164 if (!document || !document->page()) |
155 return; | 165 return; |
156 | 166 |
157 InspectorFrontendHost* frontendHost = V8InspectorFrontendHost::toImpl(info.H
older()); | 167 InspectorFrontendHost* frontendHost = V8InspectorFrontendHost::toImpl(info.H
older()); |
158 Vector<ContextMenuItem> items = menu.items(); | 168 Vector<ContextMenuItem> items = menu.items(); |
159 frontendHost->showContextMenu(window->document()->page(), static_cast<float>
(x->NumberValue()), static_cast<float>(y->NumberValue()), items); | 169 frontendHost->showContextMenu(document->page(), static_cast<float>(x->Number
Value()), static_cast<float>(y->NumberValue()), items); |
160 } | 170 } |
161 | 171 |
162 static void histogramEnumeration(const char* name, const v8::FunctionCallbackInf
o<v8::Value>& info, int boundaryValue) | 172 static void histogramEnumeration(const char* name, const v8::FunctionCallbackInf
o<v8::Value>& info, int boundaryValue) |
163 { | 173 { |
164 if (info.Length() < 1 || !info[0]->IsInt32()) | 174 if (info.Length() < 1 || !info[0]->IsInt32()) |
165 return; | 175 return; |
166 | 176 |
167 int sample = info[0]->ToInt32()->Value(); | 177 int sample = info[0]->ToInt32()->Value(); |
168 if (sample < boundaryValue) | 178 if (sample < boundaryValue) |
169 blink::Platform::current()->histogramEnumeration(name, sample, boundaryV
alue); | 179 blink::Platform::current()->histogramEnumeration(name, sample, boundaryV
alue); |
170 } | 180 } |
171 | 181 |
172 void V8InspectorFrontendHost::recordActionTakenMethodCustom(const v8::FunctionCa
llbackInfo<v8::Value>& info) | 182 void V8InspectorFrontendHost::recordActionTakenMethodCustom(const v8::FunctionCa
llbackInfo<v8::Value>& info) |
173 { | 183 { |
174 histogramEnumeration("DevTools.ActionTaken", info, 100); | 184 histogramEnumeration("DevTools.ActionTaken", info, 100); |
175 } | 185 } |
176 | 186 |
177 void V8InspectorFrontendHost::recordPanelShownMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& info) | 187 void V8InspectorFrontendHost::recordPanelShownMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& info) |
178 { | 188 { |
179 histogramEnumeration("DevTools.PanelShown", info, 20); | 189 histogramEnumeration("DevTools.PanelShown", info, 20); |
180 } | 190 } |
181 | 191 |
182 } // namespace blink | 192 } // namespace blink |
183 | 193 |
OLD | NEW |