| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 259 } |
| 260 | 260 |
| 261 void WebLocalFrameImpl::executeScript(const WebScriptSource& source) | 261 void WebLocalFrameImpl::executeScript(const WebScriptSource& source) |
| 262 { | 262 { |
| 263 ASSERT(frame()); | 263 ASSERT(frame()); |
| 264 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); | 264 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); |
| 265 v8::HandleScope handleScope(toIsolate(frame())); | 265 v8::HandleScope handleScope(toIsolate(frame())); |
| 266 frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, sou
rce.url, position)); | 266 frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, sou
rce.url, position)); |
| 267 } | 267 } |
| 268 | 268 |
| 269 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
tSource* sourcesIn, unsigned numSources, int extensionGroup) | |
| 270 { | |
| 271 ASSERT(frame()); | |
| 272 RELEASE_ASSERT(worldID > 0); | |
| 273 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); | |
| 274 | |
| 275 Vector<ScriptSourceCode> sources; | |
| 276 for (unsigned i = 0; i < numSources; ++i) { | |
| 277 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL
ine), OrdinalNumber::first()); | |
| 278 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos
ition)); | |
| 279 } | |
| 280 | |
| 281 v8::HandleScope handleScope(toIsolate(frame())); | |
| 282 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGr
oup, 0); | |
| 283 } | |
| 284 | |
| 285 void WebLocalFrameImpl::setIsolatedWorldHumanReadableName(int worldID, const Web
String& humanReadableName) | |
| 286 { | |
| 287 ASSERT(frame()); | |
| 288 DOMWrapperWorld::setIsolatedWorldHumanReadableName(worldID, humanReadableNam
e); | |
| 289 } | |
| 290 | |
| 291 void WebLocalFrameImpl::addMessageToConsole(const WebConsoleMessage& message) | 269 void WebLocalFrameImpl::addMessageToConsole(const WebConsoleMessage& message) |
| 292 { | 270 { |
| 293 ASSERT(frame()); | 271 ASSERT(frame()); |
| 294 | 272 |
| 295 MessageLevel webCoreMessageLevel; | 273 MessageLevel webCoreMessageLevel; |
| 296 switch (message.level) { | 274 switch (message.level) { |
| 297 case WebConsoleMessage::LevelDebug: | 275 case WebConsoleMessage::LevelDebug: |
| 298 webCoreMessageLevel = DebugMessageLevel; | 276 webCoreMessageLevel = DebugMessageLevel; |
| 299 break; | 277 break; |
| 300 case WebConsoleMessage::LevelLog: | 278 case WebConsoleMessage::LevelLog: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 325 { | 303 { |
| 326 ASSERT(frame()); | 304 ASSERT(frame()); |
| 327 | 305 |
| 328 // TODO: Remove this after blink has rolled and chromium change landed. (crr
ev.com/516753002) | 306 // TODO: Remove this after blink has rolled and chromium change landed. (crr
ev.com/516753002) |
| 329 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 307 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 330 | 308 |
| 331 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); | 309 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); |
| 332 return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSource
Code(source.code, source.url, position)); | 310 return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSource
Code(source.code, source.url, position)); |
| 333 } | 311 } |
| 334 | 312 |
| 335 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
tSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local
<v8::Value> >* results) | |
| 336 { | |
| 337 ASSERT(frame()); | |
| 338 RELEASE_ASSERT(worldID > 0); | |
| 339 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); | |
| 340 | |
| 341 Vector<ScriptSourceCode> sources; | |
| 342 | |
| 343 for (unsigned i = 0; i < numSources; ++i) { | |
| 344 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL
ine), OrdinalNumber::first()); | |
| 345 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos
ition)); | |
| 346 } | |
| 347 | |
| 348 if (results) { | |
| 349 Vector<v8::Local<v8::Value> > scriptResults; | |
| 350 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, &scriptResults); | |
| 351 WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size()); | |
| 352 for (unsigned i = 0; i < scriptResults.size(); i++) | |
| 353 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR
esults[i]); | |
| 354 results->swap(v8Results); | |
| 355 } else { | |
| 356 v8::HandleScope handleScope(toIsolate(frame())); | |
| 357 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, 0); | |
| 358 } | |
| 359 } | |
| 360 | |
| 361 v8::Handle<v8::Value> WebLocalFrameImpl::callFunctionEvenIfScriptDisabled(v8::Ha
ndle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handl
e<v8::Value> argv[]) | 313 v8::Handle<v8::Value> WebLocalFrameImpl::callFunctionEvenIfScriptDisabled(v8::Ha
ndle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handl
e<v8::Value> argv[]) |
| 362 { | 314 { |
| 363 ASSERT(frame()); | 315 ASSERT(frame()); |
| 364 return frame()->script().callFunction(function, receiver, argc, argv); | 316 return frame()->script().callFunction(function, receiver, argc, argv); |
| 365 } | 317 } |
| 366 | 318 |
| 367 v8::Local<v8::Context> WebLocalFrameImpl::mainWorldScriptContext() const | 319 v8::Local<v8::Context> WebLocalFrameImpl::mainWorldScriptContext() const |
| 368 { | 320 { |
| 369 return toV8Context(frame(), DOMWrapperWorld::mainWorld()); | 321 return toV8Context(frame(), DOMWrapperWorld::mainWorld()); |
| 370 } | 322 } |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 } | 699 } |
| 748 | 700 |
| 749 void WebLocalFrameImpl::invalidateAll() const | 701 void WebLocalFrameImpl::invalidateAll() const |
| 750 { | 702 { |
| 751 ASSERT(frame() && frame()->view()); | 703 ASSERT(frame() && frame()->view()); |
| 752 FrameView* view = frame()->view(); | 704 FrameView* view = frame()->view(); |
| 753 view->invalidateRect(view->frameRect()); | 705 view->invalidateRect(view->frameRect()); |
| 754 } | 706 } |
| 755 | 707 |
| 756 } // namespace blink | 708 } // namespace blink |
| OLD | NEW |