Changeset 155417 in webkit
- Timestamp:
- Sep 9, 2013 10:43:51 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r155416 r155417 1 2013-09-09 Andreas Kling <akling@apple.com> 2 3 ScriptController should have a Frame& internally. 4 <https://webkit.org/b/121071> 5 6 Reviewed by Anders Carlsson. 7 8 Change ScriptController::m_frame to a reference since it's tied to 9 the lifetime of the owning Frame. 10 1 11 2013-09-09 Andreas Kling <akling@apple.com> 2 12 -
trunk/Source/WebCore/bindings/ScriptControllerBase.cpp
r154449 r155417 40 40 bool ScriptController::canExecuteScripts(ReasonForCallingCanExecuteScripts reason) 41 41 { 42 if (m_frame ->document() && m_frame->document()->isSandboxed(SandboxScripts)) {42 if (m_frame.document() && m_frame.document()->isSandboxed(SandboxScripts)) { 43 43 // FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists. 44 44 if (reason == AboutToExecuteScript) 45 m_frame ->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked script execution in '" + m_frame->document()->url().stringCenterEllipsizedToLength() + "' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.");45 m_frame.document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked script execution in '" + m_frame.document()->url().stringCenterEllipsizedToLength() + "' because the document's frame is sandboxed and the 'allow-scripts' permission is not set."); 46 46 return false; 47 47 } 48 48 49 if (m_frame ->document() && m_frame->document()->isViewSource()) {50 ASSERT(m_frame ->document()->securityOrigin()->isUnique());49 if (m_frame.document() && m_frame.document()->isViewSource()) { 50 ASSERT(m_frame.document()->securityOrigin()->isUnique()); 51 51 return true; 52 52 } 53 53 54 const bool allowed = m_frame ->loader().client().allowScript(m_frame->settings().isScriptEnabled());54 const bool allowed = m_frame.loader().client().allowScript(m_frame.settings().isScriptEnabled()); 55 55 if (!allowed && reason == AboutToExecuteScript) 56 m_frame ->loader().client().didNotAllowScript();56 m_frame.loader().client().didNotAllowScript(); 57 57 return allowed; 58 58 } … … 61 61 { 62 62 UserGestureIndicator gestureIndicator(forceUserGesture ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture); 63 return executeScript(ScriptSourceCode(script, m_frame ->document()->url()));63 return executeScript(ScriptSourceCode(script, m_frame.document()->url())); 64 64 } 65 65 … … 69 69 return ScriptValue(); 70 70 71 Ref Ptr<Frame> protect(m_frame); // Script execution can destroy the frame, and thus the ScriptController.71 Ref<Frame> protect(m_frame); // Script execution can destroy the frame, and thus the ScriptController. 72 72 73 73 return evaluate(sourceCode); … … 79 79 return false; 80 80 81 if (!m_frame ->page()82 || !m_frame ->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_frame->document()->url(), eventHandlerPosition().m_line))81 if (!m_frame.page() 82 || !m_frame.document()->contentSecurityPolicy()->allowJavaScriptURLs(m_frame.document()->url(), eventHandlerPosition().m_line)) 83 83 return true; 84 84 85 85 // We need to hold onto the Frame here because executing script can 86 86 // destroy the frame. 87 Ref Ptr<Frame> protector(m_frame);88 RefPtr<Document> ownerDocument(m_frame ->document());87 Ref<Frame> protector(m_frame); 88 RefPtr<Document> ownerDocument(m_frame.document()); 89 89 90 90 const int javascriptSchemeLength = sizeof("javascript:") - 1; … … 95 95 // If executing script caused this frame to be removed from the page, we 96 96 // don't want to try to replace its document! 97 if (!m_frame ->page())97 if (!m_frame.page()) 98 98 return true; 99 99 … … 109 109 if (shouldReplaceDocumentIfJavaScriptURL == ReplaceDocumentIfJavaScriptURL) { 110 110 // We're still in a frame, so there should be a DocumentLoader. 111 ASSERT(m_frame ->document()->loader());111 ASSERT(m_frame.document()->loader()); 112 112 113 113 // DocumentWriter::replaceDocument can cause the DocumentLoader to get deref'ed and possible destroyed, 114 114 // so protect it with a RefPtr. 115 if (RefPtr<DocumentLoader> loader = m_frame ->document()->loader())115 if (RefPtr<DocumentLoader> loader = m_frame.document()->loader()) 116 116 loader->writer()->replaceDocument(scriptResult, ownerDocument.get()); 117 117 } -
trunk/Source/WebCore/bindings/js/ScriptController.cpp
r154142 r155417 66 66 } 67 67 68 ScriptController::ScriptController(Frame *frame)68 ScriptController::ScriptController(Frame& frame) 69 69 : m_frame(frame) 70 70 , m_sourceURL(0) … … 108 108 ASSERT(!m_windowShells.contains(world)); 109 109 Structure* structure = JSDOMWindowShell::createStructure(*world->vm(), jsNull()); 110 Strong<JSDOMWindowShell> windowShell(*world->vm(), JSDOMWindowShell::create(m_frame ->document()->domWindow(), structure, world));110 Strong<JSDOMWindowShell> windowShell(*world->vm(), JSDOMWindowShell::create(m_frame.document()->domWindow(), structure, world)); 111 111 Strong<JSDOMWindowShell> windowShell2(windowShell); 112 112 m_windowShells.add(world, windowShell); … … 134 134 JSLockHolder lock(exec); 135 135 136 Ref Ptr<Frame> protect = m_frame;137 138 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript( m_frame, sourceURL, sourceCode.startLine());136 Ref<Frame> protect(m_frame); 137 138 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(&m_frame, sourceURL, sourceCode.startLine()); 139 139 140 140 JSValue evaluationException; … … 193 193 m_cacheableBindingRootObject->updateGlobalObject(windowShell->window()); 194 194 195 if (Page* page = m_frame ->page()) {195 if (Page* page = m_frame.page()) { 196 196 attachDebugger(windowShell, page->debugger()); 197 197 windowShell->window()->setProfileGroup(page->group().identifier()); … … 215 215 windowShell->window()->updateDocument(); 216 216 217 if (m_frame ->document())218 windowShell->window()->setEvalEnabled(m_frame ->document()->contentSecurityPolicy()->allowEval(0, ContentSecurityPolicy::SuppressReport), m_frame->document()->contentSecurityPolicy()->evalDisabledErrorMessage());219 220 if (Page* page = m_frame ->page()) {217 if (m_frame.document()) 218 windowShell->window()->setEvalEnabled(m_frame.document()->contentSecurityPolicy()->allowEval(0, ContentSecurityPolicy::SuppressReport), m_frame.document()->contentSecurityPolicy()->evalDisabledErrorMessage()); 219 220 if (Page* page = m_frame.page()) { 221 221 attachDebugger(windowShell, page->debugger()); 222 222 windowShell->window()->setProfileGroup(page->group().identifier()); 223 223 } 224 224 225 m_frame ->loader().dispatchDidClearWindowObjectInWorld(world);225 m_frame.loader().dispatchDidClearWindowObjectInWorld(world); 226 226 227 227 return windowShell; … … 230 230 TextPosition ScriptController::eventHandlerPosition() const 231 231 { 232 ScriptableDocumentParser* parser = m_frame ->document()->scriptableDocumentParser();232 ScriptableDocumentParser* parser = m_frame.document()->scriptableDocumentParser(); 233 233 if (parser) 234 234 return parser->textPosition(); … … 459 459 { 460 460 UserGestureIndicator gestureIndicator(forceUserGesture ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture); 461 ScriptSourceCode sourceCode(script, m_frame ->document()->url());461 ScriptSourceCode sourceCode(script, m_frame.document()->url()); 462 462 463 463 if (!canExecuteScripts(AboutToExecuteScript) || isPaused()) -
trunk/Source/WebCore/bindings/js/ScriptController.h
r149871 r155417 66 66 67 67 public: 68 ScriptController(Frame*);68 explicit ScriptController(Frame&); 69 69 ~ScriptController(); 70 70 … … 166 166 167 167 ShellMap m_windowShells; 168 Frame *m_frame;168 Frame& m_frame; 169 169 const String* m_sourceURL; 170 170 -
trunk/Source/WebCore/page/Frame.cpp
r155374 r155417 158 158 , m_navigationScheduler(this) 159 159 , m_ownerElement(ownerElement) 160 , m_script( adoptPtr(new ScriptController(this)))160 , m_script(createOwned<ScriptController>(*this)) 161 161 , m_editor(Editor::create(*this)) 162 162 , m_selection(adoptPtr(new FrameSelection(this)))
Note: See TracChangeset
for help on using the changeset viewer.