From: simonjam@chromium.org Date: Thu, 26 May 2011 06:20:35 +0000 (+0000) Subject: 2011-05-25 James Simonsen X-Git-Tag: 070512121124~31544 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fe1c18070d883a1b5d9c5ab017a9b5baf4c7f833;p=profile%2Fivi%2Fwebkit-efl.git 2011-05-25 James Simonsen Reviewed by Adam Barth. Add site-specific hack for zipcar.com with old versions of requirejs. https://bugs.webkit.org/show_bug.cgi?id=61321 Old versions of requirejs (< 0.15.0) try to load scripts in parallel but execute them in order. This used to work in webkit by setting a bogus script type (script/cache), then changing the type to a valid one when they wanted to execute it. This hack translates the behavior into the new API (by disabling forceAsync). * html/HTMLScriptElement.cpp: (WebCore::needsOldRequirejsQuirk): Added. (WebCore::HTMLScriptElement::insertedIntoDocument): If hack is needed, set a proper script type so script loads. If script isn't async, disable forceAsync so script executes in order. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87361 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index e7af073..7f05d7f 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,21 @@ +2011-05-25 James Simonsen + + Reviewed by Adam Barth. + + Add site-specific hack for zipcar.com with old versions of requirejs. + https://bugs.webkit.org/show_bug.cgi?id=61321 + + Old versions of requirejs (< 0.15.0) try to load scripts in parallel but execute them in + order. This used to work in webkit by setting a bogus script type (script/cache), then + changing the type to a valid one when they wanted to execute it. This hack translates the + behavior into the new API (by disabling forceAsync). + + * html/HTMLScriptElement.cpp: + (WebCore::needsOldRequirejsQuirk): Added. + (WebCore::HTMLScriptElement::insertedIntoDocument): + If hack is needed, set a proper script type so script loads. + If script isn't async, disable forceAsync so script executes in order. + 2011-05-25 Andreas Kling Reviewed by David Levin. diff --git a/Source/WebCore/html/HTMLScriptElement.cpp b/Source/WebCore/html/HTMLScriptElement.cpp index 168e6d2..14bcf8c 100644 --- a/Source/WebCore/html/HTMLScriptElement.cpp +++ b/Source/WebCore/html/HTMLScriptElement.cpp @@ -29,6 +29,7 @@ #include "EventNames.h" #include "HTMLNames.h" #include "ScriptEventListener.h" +#include "Settings.h" #include "Text.h" namespace WebCore { @@ -81,8 +82,33 @@ void HTMLScriptElement::parseMappedAttribute(Attribute* attr) HTMLElement::parseMappedAttribute(attr); } +static bool needsOldRequirejsQuirk(HTMLScriptElement* element) +{ + if (element->fastGetAttribute(typeAttr) != "script/cache") + return false; + + Document* document = element->document(); + + const KURL& url = document->url(); + if (!equalIgnoringCase(url.host(), "www.zipcar.com")) + return false; + + Settings* settings = document->settings(); + if (!settings) + return false; + if (!settings->needsSiteSpecificQuirks()) + return false; + + return true; +} + void HTMLScriptElement::insertedIntoDocument() { + if (needsOldRequirejsQuirk(this)) { + if (!asyncAttributeValue()) + handleAsyncAttribute(); // Clear forceAsync, so this script loads in parallel, but executes in order. + setAttribute(typeAttr, "text/javascript"); + } HTMLElement::insertedIntoDocument(); ScriptElement::insertedIntoDocument(); }