Chromium Code Reviews| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 #include "bindings/core/v8/ScriptValue.h" | 93 #include "bindings/core/v8/ScriptValue.h" |
| 94 #include "bindings/core/v8/V8Binding.h" | 94 #include "bindings/core/v8/V8Binding.h" |
| 95 #include "bindings/core/v8/V8GCController.h" | 95 #include "bindings/core/v8/V8GCController.h" |
| 96 #include "bindings/core/v8/V8PerIsolateData.h" | 96 #include "bindings/core/v8/V8PerIsolateData.h" |
| 97 #include "core/HTMLNames.h" | 97 #include "core/HTMLNames.h" |
| 98 #include "core/dom/Document.h" | 98 #include "core/dom/Document.h" |
| 99 #include "core/dom/IconURL.h" | 99 #include "core/dom/IconURL.h" |
| 100 #include "core/dom/MessagePort.h" | 100 #include "core/dom/MessagePort.h" |
| 101 #include "core/dom/Node.h" | 101 #include "core/dom/Node.h" |
| 102 #include "core/dom/NodeTraversal.h" | 102 #include "core/dom/NodeTraversal.h" |
| 103 #include "core/dom/SuspendableScriptExecutor.h" | |
| 103 #include "core/dom/shadow/ShadowRoot.h" | 104 #include "core/dom/shadow/ShadowRoot.h" |
| 104 #include "core/editing/Editor.h" | 105 #include "core/editing/Editor.h" |
| 105 #include "core/editing/FrameSelection.h" | 106 #include "core/editing/FrameSelection.h" |
| 106 #include "core/editing/InputMethodController.h" | 107 #include "core/editing/InputMethodController.h" |
| 107 #include "core/editing/PlainTextRange.h" | 108 #include "core/editing/PlainTextRange.h" |
| 108 #include "core/editing/SpellChecker.h" | 109 #include "core/editing/SpellChecker.h" |
| 109 #include "core/editing/TextAffinity.h" | 110 #include "core/editing/TextAffinity.h" |
| 110 #include "core/editing/TextIterator.h" | 111 #include "core/editing/TextIterator.h" |
| 111 #include "core/editing/htmlediting.h" | 112 #include "core/editing/htmlediting.h" |
| 112 #include "core/editing/markup.h" | 113 #include "core/editing/markup.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 #include "public/web/WebSecurityOrigin.h" | 194 #include "public/web/WebSecurityOrigin.h" |
| 194 #include "public/web/WebSerializedScriptValue.h" | 195 #include "public/web/WebSerializedScriptValue.h" |
| 195 #include "web/AssociatedURLLoader.h" | 196 #include "web/AssociatedURLLoader.h" |
| 196 #include "web/CompositionUnderlineVectorBuilder.h" | 197 #include "web/CompositionUnderlineVectorBuilder.h" |
| 197 #include "web/FindInPageCoordinates.h" | 198 #include "web/FindInPageCoordinates.h" |
| 198 #include "web/GeolocationClientProxy.h" | 199 #include "web/GeolocationClientProxy.h" |
| 199 #include "web/LocalFileSystemClient.h" | 200 #include "web/LocalFileSystemClient.h" |
| 200 #include "web/MIDIClientProxy.h" | 201 #include "web/MIDIClientProxy.h" |
| 201 #include "web/NotificationPermissionClientImpl.h" | 202 #include "web/NotificationPermissionClientImpl.h" |
| 202 #include "web/PageOverlay.h" | 203 #include "web/PageOverlay.h" |
| 204 #include "web/ScriptExecutionCallbackImpl.h" | |
| 203 #include "web/SharedWorkerRepositoryClientImpl.h" | 205 #include "web/SharedWorkerRepositoryClientImpl.h" |
| 204 #include "web/TextFinder.h" | 206 #include "web/TextFinder.h" |
| 205 #include "web/WebDataSourceImpl.h" | 207 #include "web/WebDataSourceImpl.h" |
| 206 #include "web/WebDevToolsAgentPrivate.h" | 208 #include "web/WebDevToolsAgentPrivate.h" |
| 207 #include "web/WebPluginContainerImpl.h" | 209 #include "web/WebPluginContainerImpl.h" |
| 208 #include "web/WebRemoteFrameImpl.h" | 210 #include "web/WebRemoteFrameImpl.h" |
| 209 #include "web/WebViewImpl.h" | 211 #include "web/WebViewImpl.h" |
| 210 #include "wtf/CurrentTime.h" | 212 #include "wtf/CurrentTime.h" |
| 211 #include "wtf/HashMap.h" | 213 #include "wtf/HashMap.h" |
| 212 #include <algorithm> | 214 #include <algorithm> |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 if (output.length() >= maxChars - frameSeparatorLength) | 273 if (output.length() >= maxChars - frameSeparatorLength) |
| 272 return; | 274 return; |
| 273 | 275 |
| 274 output.append(frameSeparator, frameSeparatorLength); | 276 output.append(frameSeparator, frameSeparatorLength); |
| 275 frameContentAsPlainText(maxChars, curLocalChild, output); | 277 frameContentAsPlainText(maxChars, curLocalChild, output); |
| 276 if (output.length() >= maxChars) | 278 if (output.length() >= maxChars) |
| 277 return; // Filled up the buffer. | 279 return; // Filled up the buffer. |
| 278 } | 280 } |
| 279 } | 281 } |
| 280 | 282 |
| 283 static Vector<ScriptSourceCode> createSourcesVector(const WebScriptSource* sourc esIn, unsigned numSources) | |
|
pfeldman
2014/10/22 15:38:17
Should we have operator ScriptSourceCode() in orde
kozyatinskiy1
2014/10/22 16:46:58
Done.
| |
| 284 { | |
| 285 Vector<ScriptSourceCode> sources; | |
| 286 for (unsigned i = 0; i < numSources; ++i) { | |
| 287 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL ine), OrdinalNumber::first()); | |
| 288 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos ition)); | |
| 289 } | |
| 290 return sources; | |
| 291 } | |
| 292 | |
| 281 WebPluginContainerImpl* WebLocalFrameImpl::pluginContainerFromFrame(LocalFrame* frame) | 293 WebPluginContainerImpl* WebLocalFrameImpl::pluginContainerFromFrame(LocalFrame* frame) |
| 282 { | 294 { |
| 283 if (!frame) | 295 if (!frame) |
| 284 return 0; | 296 return 0; |
| 285 if (!frame->document() || !frame->document()->isPluginDocument()) | 297 if (!frame->document() || !frame->document()->isPluginDocument()) |
| 286 return 0; | 298 return 0; |
| 287 PluginDocument* pluginDocument = toPluginDocument(frame->document()); | 299 PluginDocument* pluginDocument = toPluginDocument(frame->document()); |
| 288 return toWebPluginContainerImpl(pluginDocument->pluginWidget()); | 300 return toWebPluginContainerImpl(pluginDocument->pluginWidget()); |
| 289 } | 301 } |
| 290 | 302 |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 699 v8::HandleScope handleScope(toIsolate(frame())); | 711 v8::HandleScope handleScope(toIsolate(frame())); |
| 700 frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, sou rce.url, position)); | 712 frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, sou rce.url, position)); |
| 701 } | 713 } |
| 702 | 714 |
| 703 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip tSource* sourcesIn, unsigned numSources, int extensionGroup) | 715 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip tSource* sourcesIn, unsigned numSources, int extensionGroup) |
| 704 { | 716 { |
| 705 ASSERT(frame()); | 717 ASSERT(frame()); |
| 706 RELEASE_ASSERT(worldID > 0); | 718 RELEASE_ASSERT(worldID > 0); |
| 707 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); | 719 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); |
| 708 | 720 |
| 709 Vector<ScriptSourceCode> sources; | 721 Vector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSources ); |
| 710 for (unsigned i = 0; i < numSources; ++i) { | |
| 711 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL ine), OrdinalNumber::first()); | |
| 712 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos ition)); | |
| 713 } | |
| 714 | |
| 715 v8::HandleScope handleScope(toIsolate(frame())); | 722 v8::HandleScope handleScope(toIsolate(frame())); |
| 716 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGr oup, 0); | 723 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGr oup, 0); |
| 717 } | 724 } |
| 718 | 725 |
| 719 void WebLocalFrameImpl::setIsolatedWorldSecurityOrigin(int worldID, const WebSec urityOrigin& securityOrigin) | 726 void WebLocalFrameImpl::setIsolatedWorldSecurityOrigin(int worldID, const WebSec urityOrigin& securityOrigin) |
| 720 { | 727 { |
| 721 ASSERT(frame()); | 728 ASSERT(frame()); |
| 722 DOMWrapperWorld::setIsolatedWorldSecurityOrigin(worldID, securityOrigin.get( )); | 729 DOMWrapperWorld::setIsolatedWorldSecurityOrigin(worldID, securityOrigin.get( )); |
| 723 } | 730 } |
| 724 | 731 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 776 } | 783 } |
| 777 | 784 |
| 778 v8::Handle<v8::Value> WebLocalFrameImpl::executeScriptAndReturnValue(const WebSc riptSource& source) | 785 v8::Handle<v8::Value> WebLocalFrameImpl::executeScriptAndReturnValue(const WebSc riptSource& source) |
| 779 { | 786 { |
| 780 ASSERT(frame()); | 787 ASSERT(frame()); |
| 781 | 788 |
| 782 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi nalNumber::first()); | 789 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi nalNumber::first()); |
| 783 return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSource Code(source.code, source.url, position)); | 790 return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSource Code(source.code, source.url, position)); |
| 784 } | 791 } |
| 785 | 792 |
| 793 void WebLocalFrameImpl::requestExecuteScriptAndReturnValue(const WebScriptSource & source, bool userGesture, WebScriptExecutionCallback* callback) | |
| 794 { | |
| 795 ASSERT(frame()); | |
| 796 | |
| 797 Vector<ScriptSourceCode> sources = createSourcesVector(&source, 1); | |
| 798 SuspendableScriptExecutor* executor = new SuspendableScriptExecutor(frame(), 0, sources, 0, userGesture, adoptPtr(new ScriptExecutionCallbackImpl(callback)) ); | |
| 799 executor->run(); | |
| 800 } | |
| 801 | |
| 786 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip tSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local <v8::Value> >* results) | 802 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip tSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local <v8::Value> >* results) |
| 787 { | 803 { |
| 788 ASSERT(frame()); | 804 ASSERT(frame()); |
| 789 RELEASE_ASSERT(worldID > 0); | 805 RELEASE_ASSERT(worldID > 0); |
| 790 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); | 806 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); |
| 791 | 807 |
| 792 Vector<ScriptSourceCode> sources; | 808 Vector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSources ); |
| 793 | |
| 794 for (unsigned i = 0; i < numSources; ++i) { | |
| 795 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL ine), OrdinalNumber::first()); | |
| 796 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos ition)); | |
| 797 } | |
| 798 | 809 |
| 799 if (results) { | 810 if (results) { |
| 800 Vector<v8::Local<v8::Value> > scriptResults; | 811 Vector<v8::Local<v8::Value> > scriptResults; |
| 801 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi onGroup, &scriptResults); | 812 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi onGroup, &scriptResults); |
| 802 WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size()); | 813 WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size()); |
| 803 for (unsigned i = 0; i < scriptResults.size(); i++) | 814 for (unsigned i = 0; i < scriptResults.size(); i++) |
| 804 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR esults[i]); | 815 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR esults[i]); |
| 805 results->swap(v8Results); | 816 results->swap(v8Results); |
| 806 } else { | 817 } else { |
| 807 v8::HandleScope handleScope(toIsolate(frame())); | 818 v8::HandleScope handleScope(toIsolate(frame())); |
| 808 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi onGroup, 0); | 819 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi onGroup, 0); |
| 809 } | 820 } |
| 810 } | 821 } |
| 811 | 822 |
| 823 void WebLocalFrameImpl::requestExecuteScriptInIsolatedWorld(int worldID, const W ebScriptSource* sourcesIn, unsigned numSources, int extensionGroup, bool userGes ture, WebScriptExecutionCallback* callback) | |
| 824 { | |
| 825 ASSERT(frame()); | |
| 826 RELEASE_ASSERT(worldID > 0); | |
| 827 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); | |
| 828 | |
| 829 Vector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSources ); | |
| 830 SuspendableScriptExecutor* executor = new SuspendableScriptExecutor(frame(), worldID, sources, extensionGroup, userGesture, adoptPtr(new ScriptExecutionCall backImpl(callback))); | |
| 831 executor->run(); | |
| 832 } | |
| 833 | |
| 812 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[]) | 834 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[]) |
| 813 { | 835 { |
| 814 ASSERT(frame()); | 836 ASSERT(frame()); |
| 815 return frame()->script().callFunction(function, receiver, argc, argv); | 837 return frame()->script().callFunction(function, receiver, argc, argv); |
| 816 } | 838 } |
| 817 | 839 |
| 818 v8::Local<v8::Context> WebLocalFrameImpl::mainWorldScriptContext() const | 840 v8::Local<v8::Context> WebLocalFrameImpl::mainWorldScriptContext() const |
| 819 { | 841 { |
| 820 return toV8Context(frame(), DOMWrapperWorld::mainWorld()); | 842 return toV8Context(frame(), DOMWrapperWorld::mainWorld()); |
| 821 } | 843 } |
| (...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1945 | 1967 |
| 1946 void WebLocalFrameImpl::invalidateAll() const | 1968 void WebLocalFrameImpl::invalidateAll() const |
| 1947 { | 1969 { |
| 1948 ASSERT(frame() && frame()->view()); | 1970 ASSERT(frame() && frame()->view()); |
| 1949 FrameView* view = frame()->view(); | 1971 FrameView* view = frame()->view(); |
| 1950 view->invalidateRect(view->frameRect()); | 1972 view->invalidateRect(view->frameRect()); |
| 1951 invalidateScrollbar(); | 1973 invalidateScrollbar(); |
| 1952 } | 1974 } |
| 1953 | 1975 |
| 1954 } // namespace blink | 1976 } // namespace blink |
| OLD | NEW |