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

Side by Side Diff: Source/bindings/dart/DartUtilities.cpp

Issue 300393002: Merge DevTools Refactor CL to Blink36 (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/1985
Patch Set: PTAL Created 6 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
OLDNEW
1 // Copyright 2011, Google Inc. 1 // Copyright 2011, 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 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 } 935 }
936 936
937 DOMWindow* DartUtilities::domWindowForCurrentIsolate() 937 DOMWindow* DartUtilities::domWindowForCurrentIsolate()
938 { 938 {
939 DartDOMData* domData = DartDOMData::current(); 939 DartDOMData* domData = DartDOMData::current();
940 ASSERT(domData->scriptExecutionContext()->isDocument()); 940 ASSERT(domData->scriptExecutionContext()->isDocument());
941 Document* document = static_cast<Document*>(domData->scriptExecutionContext( )); 941 Document* document = static_cast<Document*>(domData->scriptExecutionContext( ));
942 return document->domWindow(); 942 return document->domWindow();
943 } 943 }
944 944
945 V8ScriptState* DartUtilities::v8ScriptStateForCurrentIsolate()
946 {
947 return V8ScriptState::forMainWorld(domWindowForCurrentIsolate()->frame());
948 }
949
945 ExecutionContext* DartUtilities::scriptExecutionContext() 950 ExecutionContext* DartUtilities::scriptExecutionContext()
946 { 951 {
947 if (Dart_CurrentIsolate()) 952 if (Dart_CurrentIsolate())
948 return DartDOMData::current()->scriptExecutionContext(); 953 return DartDOMData::current()->scriptExecutionContext();
949 return 0; 954 return 0;
950 } 955 }
951 956
952 bool DartUtilities::processingUserGesture() 957 bool DartUtilities::processingUserGesture()
953 { 958 {
954 // FIXME: implement this. 959 // FIXME: implement this.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 // FIXME: Cause of sources tab sometimes interpreting line/column inform ation relative to the page instead of the script tag body? 1031 // FIXME: Cause of sources tab sometimes interpreting line/column inform ation relative to the page instead of the script tag body?
1027 const char* scriptName = "undefined"; 1032 const char* scriptName = "undefined";
1028 scriptCallStackFrames.append(ScriptCallFrame(functionName, scriptName, s criptUrl, lineNumber, columnNumber)); 1033 scriptCallStackFrames.append(ScriptCallFrame(functionName, scriptName, s criptUrl, lineNumber, columnNumber));
1029 } 1034 }
1030 if (scriptCallStackFrames.isEmpty()) 1035 if (scriptCallStackFrames.isEmpty())
1031 scriptCallStackFrames.append(ScriptCallFrame("undefined", "undefined", " undefined", 0, 0)); 1036 scriptCallStackFrames.append(ScriptCallFrame("undefined", "undefined", " undefined", 0, 0));
1032 1037
1033 return ScriptCallStack::create(scriptCallStackFrames); 1038 return ScriptCallStack::create(scriptCallStackFrames);
1034 } 1039 }
1035 1040
1041 ScriptCallFrame DartUtilities::getTopFrame(Dart_StackTrace stackTrace, Dart_Hand le& exception)
1042 {
1043 {
1044 uintptr_t frameCount = 0;
1045 Dart_Handle result = Dart_StackTraceLength(stackTrace, reinterpret_cast< intptr_t*>(&frameCount));
1046 if (Dart_IsError(result)) {
1047 exception = result;
1048 goto fail;
1049 }
1050 if (!frameCount) {
1051 exception = Dart_NewStringFromCString("Empty stack trace");
1052 goto fail;
1053 }
1054 Dart_ActivationFrame frame = 0;
1055 result = Dart_GetActivationFrame(stackTrace, 0, &frame);
1056 if (Dart_IsError(result)) {
1057 exception = result;
1058 goto fail;
1059 }
1060 ASSERT(frame);
1061 return toScriptCallFrame(frame, exception);
1062 }
1063 fail:
1064 return ScriptCallFrame("undefined", "undefined", "undefined", 0, 0);
1065 }
1066
1067 ScriptCallFrame DartUtilities::toScriptCallFrame(Dart_ActivationFrame frame, Dar t_Handle& exception)
1068 {
1069 ASSERT(frame);
1070 Dart_Handle functionName;
1071 Dart_Handle scriptUrl;
1072 intptr_t lineNumber = 0;
1073 intptr_t columnNumber = 0;
1074 Dart_Handle result = Dart_ActivationFrameInfo(frame, &functionName, &scriptU rl, &lineNumber, &columnNumber);
1075 if (Dart_IsError(result)) {
1076 exception = result;
1077 return ScriptCallFrame("undefined", "undefined", "undefined", 0, 0);
1078 }
1079 return ScriptCallFrame(DartUtilities::toString(functionName), "undefined", D artUtilities::toString(scriptUrl), lineNumber, columnNumber);
1080 }
1081
1036 PassRefPtr<ScriptCallStack> DartUtilities::createScriptCallStack() 1082 PassRefPtr<ScriptCallStack> DartUtilities::createScriptCallStack()
1037 { 1083 {
1038 Dart_StackTrace trace = 0; 1084 Dart_StackTrace trace = 0;
1039 Dart_Handle ALLOW_UNUSED result = Dart_GetStackTrace(&trace); 1085 Dart_Handle ALLOW_UNUSED result = Dart_GetStackTrace(&trace);
1040 ASSERT(!Dart_IsError(result)); 1086 ASSERT(!Dart_IsError(result));
1041 ASSERT(!Dart_IsNull(result)); 1087 ASSERT(!Dart_IsNull(result));
1042 ASSERT(trace); 1088 ASSERT(trace);
1043 return createScriptCallStackFromStackTrace(trace); 1089 return createScriptCallStackFromStackTrace(trace);
1044 } 1090 }
1045 1091
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 if (!v) { 1214 if (!v) {
1169 return 0; 1215 return 0;
1170 } 1216 }
1171 ASSERT(valueLen > 0 && static_cast<size_t>(valueLen) > strlen(v)); 1217 ASSERT(valueLen > 0 && static_cast<size_t>(valueLen) > strlen(v));
1172 strncpy(value, v, valueLen); 1218 strncpy(value, v, valueLen);
1173 value[valueLen - 1] = '\0'; 1219 value[valueLen - 1] = '\0';
1174 return strlen(value); 1220 return strlen(value);
1175 #endif 1221 #endif
1176 } 1222 }
1177 } 1223 }
OLDNEW
« no previous file with comments | « Source/bindings/dart/DartUtilities.h ('k') | Source/bindings/dart/custom/DartInjectedScriptHostCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698