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

Side by Side Diff: Source/WebKit/mac/WebView/WebFrame.mm

Issue 7734002: Merge 93732 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/835/
Patch Set: Created 9 years, 4 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
« no previous file with comments | « Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } 601 }
602 602
603 - (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string 603 - (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string
604 { 604 {
605 return [self _stringByEvaluatingJavaScriptFromString:string forceUserGesture :true]; 605 return [self _stringByEvaluatingJavaScriptFromString:string forceUserGesture :true];
606 } 606 }
607 607
608 - (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string forceUs erGesture:(BOOL)forceUserGesture 608 - (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string forceUs erGesture:(BOOL)forceUserGesture
609 { 609 {
610 ASSERT(_private->coreFrame->document()); 610 ASSERT(_private->coreFrame->document());
611 RetainPtr<WebFrame> protect(self); // Executing arbitrary JavaScript can des troy the frame.
611 612
612 JSValue result = _private->coreFrame->script()->executeScript(string, forceU serGesture).jsValue(); 613 JSValue result = _private->coreFrame->script()->executeScript(string, forceU serGesture).jsValue();
613 614
614 if (!_private->coreFrame) // In case the script removed our frame from the p age. 615 if (!_private->coreFrame) // In case the script removed our frame from the p age.
615 return @""; 616 return @"";
616 617
617 // This bizarre set of rules matches behavior from WebKit for Safari 2.0. 618 // This bizarre set of rules matches behavior from WebKit for Safari 2.0.
618 // If you don't like it, use -[WebScriptObject evaluateWebScript:] or 619 // If you don't like it, use -[WebScriptObject evaluateWebScript:] or
619 // JSEvaluateScript instead, since they have less surprising semantics. 620 // JSEvaluateScript instead, since they have less surprising semantics.
620 if (!result || (!result.isBoolean() && !result.isString() && !result.isNumbe r())) 621 if (!result || (!result.isBoolean() && !result.isString() && !result.isNumbe r()))
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 JSDOMWindow* anyWorldGlobalObject = _private->coreFrame->script()->globalObj ect(mainThreadNormalWorld()); 1198 JSDOMWindow* anyWorldGlobalObject = _private->coreFrame->script()->globalObj ect(mainThreadNormalWorld());
1198 1199
1199 // The global object is probably a shell object? - if so, we know how to use this! 1200 // The global object is probably a shell object? - if so, we know how to use this!
1200 JSC::JSObject* globalObjectObj = toJS(globalObjectRef); 1201 JSC::JSObject* globalObjectObj = toJS(globalObjectRef);
1201 if (!strcmp(globalObjectObj->classInfo()->className, "JSDOMWindowShell")) 1202 if (!strcmp(globalObjectObj->classInfo()->className, "JSDOMWindowShell"))
1202 anyWorldGlobalObject = static_cast<JSDOMWindowShell*>(globalObjectObj)-> window(); 1203 anyWorldGlobalObject = static_cast<JSDOMWindowShell*>(globalObjectObj)-> window();
1203 1204
1204 // Get the frame frome the global object we've settled on. 1205 // Get the frame frome the global object we've settled on.
1205 Frame* frame = anyWorldGlobalObject->impl()->frame(); 1206 Frame* frame = anyWorldGlobalObject->impl()->frame();
1206 ASSERT(frame->document()); 1207 ASSERT(frame->document());
1208 RetainPtr<WebFrame> webFrame(kit(frame)); // Running arbitrary JavaScript ca n destroy the frame.
1209
1207 JSValue result = frame->script()->executeScriptInWorld(core(world), string, true).jsValue(); 1210 JSValue result = frame->script()->executeScriptInWorld(core(world), string, true).jsValue();
1208 1211
1209 if (!frame) // In case the script removed our frame from the page. 1212 if (!webFrame->_private->coreFrame) // In case the script removed our frame from the page.
1210 return @""; 1213 return @"";
1211 1214
1212 // This bizarre set of rules matches behavior from WebKit for Safari 2.0. 1215 // This bizarre set of rules matches behavior from WebKit for Safari 2.0.
1213 // If you don't like it, use -[WebScriptObject evaluateWebScript:] or 1216 // If you don't like it, use -[WebScriptObject evaluateWebScript:] or
1214 // JSEvaluateScript instead, since they have less surprising semantics. 1217 // JSEvaluateScript instead, since they have less surprising semantics.
1215 if (!result || (!result.isBoolean() && !result.isString() && !result.isNumbe r())) 1218 if (!result || (!result.isBoolean() && !result.isString() && !result.isNumbe r()))
1216 return @""; 1219 return @"";
1217 1220
1218 JSLock lock(SilenceAssertionsOnly); 1221 JSLock lock(SilenceAssertionsOnly);
1219 return ustringToString(result.toString(anyWorldGlobalObject->globalExec())); 1222 return ustringToString(result.toString(anyWorldGlobalObject->globalExec()));
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 1597
1595 - (JSGlobalContextRef)globalContext 1598 - (JSGlobalContextRef)globalContext
1596 { 1599 {
1597 Frame* coreFrame = _private->coreFrame; 1600 Frame* coreFrame = _private->coreFrame;
1598 if (!coreFrame) 1601 if (!coreFrame)
1599 return 0; 1602 return 0;
1600 return toGlobalRef(coreFrame->script()->globalObject(mainThreadNormalWorld() )->globalExec()); 1603 return toGlobalRef(coreFrame->script()->globalObject(mainThreadNormalWorld() )->globalExec());
1601 } 1604 }
1602 1605
1603 @end 1606 @end
OLDNEW
« no previous file with comments | « Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698