⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 35050 in webkit


Ignore:
Timestamp:
Jul 7, 2008, 5:29:51 PM (18 years ago)
Author:
Darin Adler
Message:

2008-07-07 Darin Adler <Darin Adler>

Reviewed by Mark Rowe.

  • fix <rdar://problem/6020441> REGRESSION: Layers on NWA.com render ugly

The old version of the OpenCube QuickMenu library used on this site still has code
that detects Netscape 4 by checking appVersion to see if it has the substring "4."
in it. We decided to special-case the filename of the script and tweak the appVersion
for files with that name.

  • bindings/js/ScriptController.cpp: (WebCore::ScriptController::ScriptController): Replace m_processingInlineCode with m_sourceURL. Use false instead of 0 to initialize a boolean. (WebCore::ScriptController::evaluate): Call argument sourceURL, not filename. Store current sourceURL in m_sourceURL. This fixes a mistake in the code that maintained the value of m_processingInlineCode, since the old code set it to false rather than restoring it. Renamed a local variable named sourceURL to exceptionSourceURL for clarity. (WebCore::ScriptController::processingUserGesture): Code that formerly used m_processingInlineCode to detect that it was evaluating code with no URL now uses m_sourceURL to do the same check.
  • bindings/js/ScriptController.h: Renamed filename argument to sourceURL; it has always been a URL, not a file path. Added a public sourceURL function and m_sourceURL and removed m_processingInlineCode.
  • page/Navigator.cpp: (WebCore::shouldHideFourDot): Added. Returns true if the currently running script has a source URL ending in "/dqm_script.js" and if the settings say we should do site-specific quirks (really JavaScript-library-specific in this case). (WebCore::Navigator::appVersion): Replace "4." with "4_" if shouldHideFourDot is true.
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r35049 r35050  
     12008-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
    1342008-07-07  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
    235
  • trunk/WebCore/bindings/js/ScriptController.cpp

    r34947 r35050  
    5353    : m_frame(frame)
    5454    , m_handlerLineno(0)
    55     , m_processingTimerCallback(0)
    56     , m_processingInlineCode(0)
     55    , m_sourceURL(0)
     56    , m_processingTimerCallback(false)
    5757    , m_paused(false)
    5858{
     
    6969}
    7070
    71 JSValue* ScriptController::evaluate(const String& filename, int baseLine, const String& str)
     71JSValue* ScriptController::evaluate(const String& sourceURL, int baseLine, const String& str)
    7272{
    7373    // evaluate code. Returns the JS return value or 0
     
    8080    // See smart window.open policy for where this is used.
    8181    ExecState* exec = m_windowShell->window()->globalExec();
    82     m_processingInlineCode = filename.isNull();
     82    const String* savedSourceURL = m_sourceURL;
     83    m_sourceURL = &sourceURL;
    8384
    8485    JSLock lock(false);
     
    8990
    9091    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);
    9293    m_windowShell->window()->stopTimeoutCheck();
    9394
    9495    if (comp.complType() == Normal || comp.complType() == ReturnValue) {
    95         m_processingInlineCode = false;
     96        m_sourceURL = savedSourceURL;
    9697        return comp.value();
    9798    }
     
    100101        UString errorMessage = comp.value()->toString(exec);
    101102        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;
    107108    return 0;
    108109}
     
    188189            return true;
    189190    } else { // no event
    190         if (m_processingInlineCode && !m_processingTimerCallback) {
     191        if (m_sourceURL && m_sourceURL->isNull() && !m_processingTimerCallback) {
    191192            // This is the <a href="javascript:window.open('...')> case -> we let it through
    192193            return true;
  • trunk/WebCore/bindings/js/ScriptController.h

    r34588 r35050  
    5757    }
    5858
    59     KJS::JSValue* evaluate(const String& filename, int baseLine, const String& code);
     59    KJS::JSValue* evaluate(const String& sourceURL, int baseLine, const String& code);
    6060    void clear();
    6161    PassRefPtr<EventListener> createHTMLEventHandler(const String& functionName, const String& code, Node*);
     
    7979    void updateDocument();
    8080
     81    const String* sourceURL() const { return m_sourceURL; } // 0 if we are not evaluating any script
     82
    8183private:
    8284    void initScriptIfNeeded()
     
    9193    Frame* m_frame;
    9294    int m_handlerLineno;
    93    
     95    const String* m_sourceURL;
     96
    9497    bool m_processingTimerCallback;
    95     bool m_processingInlineCode;
    9698    bool m_paused;
    9799};
  • trunk/WebCore/page/Navigator.cpp

    r33457 r35050  
    3434#include "PluginArray.h"
    3535#include "PluginData.h"
     36#include "ScriptController.h"
    3637#include "Settings.h"
    3738
     
    100101}
    101102
     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!
     107static 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
    102118String Navigator::appVersion() const
    103119{
     
    106122    // Version is everything in the user agent string past the "Mozilla/" prefix.
    107123    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;
    109128}
    110129
Note: See TracChangeset for help on using the changeset viewer.