Changeset 35050 in webkit
- Timestamp:
- Jul 7, 2008, 5:29:51 PM (18 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
bindings/js/ScriptController.cpp (modified) (6 diffs)
-
bindings/js/ScriptController.h (modified) (3 diffs)
-
page/Navigator.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r35049 r35050 1 2008-07-07 Darin Adler <darin@apple.com> 2 3 Reviewed by Mark Rowe. 4 5 - fix <rdar://problem/6020441> REGRESSION: Layers on NWA.com render ugly 6 7 The old version of the OpenCube QuickMenu library used on this site still has code 8 that detects Netscape 4 by checking appVersion to see if it has the substring "4." 9 in it. We decided to special-case the filename of the script and tweak the appVersion 10 for files with that name. 11 12 * bindings/js/ScriptController.cpp: 13 (WebCore::ScriptController::ScriptController): Replace m_processingInlineCode with 14 m_sourceURL. Use false instead of 0 to initialize a boolean. 15 (WebCore::ScriptController::evaluate): Call argument sourceURL, not filename. 16 Store current sourceURL in m_sourceURL. This fixes a mistake in the code that 17 maintained the value of m_processingInlineCode, since the old code set it to 18 false rather than restoring it. Renamed a local variable named sourceURL to 19 exceptionSourceURL for clarity. 20 (WebCore::ScriptController::processingUserGesture): Code that formerly used 21 m_processingInlineCode to detect that it was evaluating code with no URL now 22 uses m_sourceURL to do the same check. 23 24 * bindings/js/ScriptController.h: Renamed filename argument to sourceURL; it has always 25 been a URL, not a file path. Added a public sourceURL function and m_sourceURL and 26 removed m_processingInlineCode. 27 28 * page/Navigator.cpp: 29 (WebCore::shouldHideFourDot): Added. Returns true if the currently running script has 30 a source URL ending in "/dqm_script.js" and if the settings say we should do 31 site-specific quirks (really JavaScript-library-specific in this case). 32 (WebCore::Navigator::appVersion): Replace "4." with "4_" if shouldHideFourDot is true. 33 1 34 2008-07-07 Cameron Zwarich <cwzwarich@uwaterloo.ca> 2 35 -
trunk/WebCore/bindings/js/ScriptController.cpp
r34947 r35050 53 53 : m_frame(frame) 54 54 , m_handlerLineno(0) 55 , m_ processingTimerCallback(0)56 , m_processing InlineCode(0)55 , m_sourceURL(0) 56 , m_processingTimerCallback(false) 57 57 , m_paused(false) 58 58 { … … 69 69 } 70 70 71 JSValue* ScriptController::evaluate(const String& filename, int baseLine, const String& str)71 JSValue* ScriptController::evaluate(const String& sourceURL, int baseLine, const String& str) 72 72 { 73 73 // evaluate code. Returns the JS return value or 0 … … 80 80 // See smart window.open policy for where this is used. 81 81 ExecState* exec = m_windowShell->window()->globalExec(); 82 m_processingInlineCode = filename.isNull(); 82 const String* savedSourceURL = m_sourceURL; 83 m_sourceURL = &sourceURL; 83 84 84 85 JSLock lock(false); … … 89 90 90 91 m_windowShell->window()->startTimeoutCheck(); 91 Completion comp = Interpreter::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), filename, baseLine, StringSourceProvider::create(str), m_windowShell);92 Completion comp = Interpreter::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceURL, baseLine, StringSourceProvider::create(str), m_windowShell); 92 93 m_windowShell->window()->stopTimeoutCheck(); 93 94 94 95 if (comp.complType() == Normal || comp.complType() == ReturnValue) { 95 m_ processingInlineCode = false;96 m_sourceURL = savedSourceURL; 96 97 return comp.value(); 97 98 } … … 100 101 UString errorMessage = comp.value()->toString(exec); 101 102 int lineNumber = comp.value()->toObject(exec)->get(exec, Identifier(exec, "line"))->toInt32(exec); 102 UString sourceURL = comp.value()->toObject(exec)->get(exec, Identifier(exec, "sourceURL"))->toString(exec);103 m_frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, errorMessage, lineNumber, sourceURL);104 } 105 106 m_ processingInlineCode = false;103 UString exceptionSourceURL = comp.value()->toObject(exec)->get(exec, Identifier(exec, "sourceURL"))->toString(exec); 104 m_frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, errorMessage, lineNumber, exceptionSourceURL); 105 } 106 107 m_sourceURL = savedSourceURL; 107 108 return 0; 108 109 } … … 188 189 return true; 189 190 } else { // no event 190 if (m_ processingInlineCode&& !m_processingTimerCallback) {191 if (m_sourceURL && m_sourceURL->isNull() && !m_processingTimerCallback) { 191 192 // This is the <a href="javascript:window.open('...')> case -> we let it through 192 193 return true; -
trunk/WebCore/bindings/js/ScriptController.h
r34588 r35050 57 57 } 58 58 59 KJS::JSValue* evaluate(const String& filename, int baseLine, const String& code);59 KJS::JSValue* evaluate(const String& sourceURL, int baseLine, const String& code); 60 60 void clear(); 61 61 PassRefPtr<EventListener> createHTMLEventHandler(const String& functionName, const String& code, Node*); … … 79 79 void updateDocument(); 80 80 81 const String* sourceURL() const { return m_sourceURL; } // 0 if we are not evaluating any script 82 81 83 private: 82 84 void initScriptIfNeeded() … … 91 93 Frame* m_frame; 92 94 int m_handlerLineno; 93 95 const String* m_sourceURL; 96 94 97 bool m_processingTimerCallback; 95 bool m_processingInlineCode;96 98 bool m_paused; 97 99 }; -
trunk/WebCore/page/Navigator.cpp
r33457 r35050 34 34 #include "PluginArray.h" 35 35 #include "PluginData.h" 36 #include "ScriptController.h" 36 37 #include "Settings.h" 37 38 … … 100 101 } 101 102 103 // If this function returns true, we need to hide the substring "4." that would otherwise 104 // appear in the appVersion string. This is to avoid problems with old versions of a 105 // library called OpenCube QuickMenus, which as of this writing is still being used on 106 // sites such as nwa.com -- the library thinks Safari is Netscape 4 if we don't do this! 107 static bool shouldHideFourDot(Frame* frame) 108 { 109 const String* sourceURL = frame->script()->sourceURL(); 110 if (!sourceURL) 111 return false; 112 Settings* settings = frame->settings(); 113 if (!settings) 114 return false; 115 return sourceURL->endsWith("/dqm_script.js") && settings->needsSiteSpecificQuirks(); 116 } 117 102 118 String Navigator::appVersion() const 103 119 { … … 106 122 // Version is everything in the user agent string past the "Mozilla/" prefix. 107 123 const String& userAgent = m_frame->loader()->userAgent(m_frame->document() ? m_frame->document()->url() : KURL()); 108 return userAgent.substring(userAgent.find('/') + 1); 124 String appVersion = userAgent.substring(userAgent.find('/') + 1); 125 if (shouldHideFourDot(m_frame)) 126 appVersion.replace("4.", "4_"); 127 return appVersion; 109 128 } 110 129
Note:
See TracChangeset
for help on using the changeset viewer.