void setCookies(const KURL& url, const KURL& policyURL, const String& value) { DeprecatedString str = url.url(); DeprecatedString result("Set-Cookie:"); DeprecatedString val = value.deprecatedString(); //add everything in the cookie result.append(val); //Check if it had appended domain, path bool noDomainSet = !val.contains(DeprecatedString("domain=")); bool noPathSet = !val.contains(DeprecatedString("path=")); if(noDomainSet || noPathSet) { char pathBuffer[SIZE_OF_LATIN1_BUFFERS]; char domainBuffer[SIZE_OF_LATIN1_BUFFERS]; int tl_domainLocationInUrlBegins = str.find("://") + SIZE_OF_COLONSLASHSLASH; int tl_domainLocationInUrlEnds = str.find("/",tl_domainLocationInUrlBegins) - 1; result.append(';'); if(noDomainSet) { str.copyLatin1(domainBuffer, tl_domainLocationInUrlBegins, tl_domainLocationInUrlEnds - tl_domainLocationInUrlBegins + 1); domainBuffer[tl_domainLocationInUrlEnds - tl_domainLocationInUrlBegins + 1] = '\0'; result.append(DeprecatedString(" domain=")); result.append(DeprecatedString::fromLatin1(domainBuffer)); result.append(';'); } if(noPathSet) { int tl_pathLocationInUrlEnds = str.findRev("/"); str.copyLatin1(pathBuffer, tl_domainLocationInUrlEnds + 1, // 1 because it'll include '/' tl_pathLocationInUrlEnds - tl_domainLocationInUrlEnds ); pathBuffer[tl_pathLocationInUrlEnds = tl_domainLocationInUrlEnds] = '\0'; result.append(DeprecatedString(" path=")); result.append(DeprecatedString::fromLatin1(pathBuffer)); result.append(';'); } } if(val.startsWith(DeprecatedString("https://"))) { result.append(DeprecatedString(" secure")); } //Connect with Runtime. // WebKitApollo::g_HostFunctions->setJavaScriptCookie(result.latin1()); }
static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPosPrefix = 0) { DeprecatedString prop = propertyName; int i = prop.length(); if (!i) return prop; while (--i) { ::UChar c = prop[i].unicode(); if (c >= 'A' && c <= 'Z') prop.insert(i, '-'); } prop = prop.lower(); if (hadPixelOrPosPrefix) *hadPixelOrPosPrefix = false; if (prop.startsWith("css-")) prop = prop.mid(4); else if (prop.startsWith("pixel-")) { prop = prop.mid(6); if (hadPixelOrPosPrefix) *hadPixelOrPosPrefix = true; } else if (prop.startsWith("pos-")) { prop = prop.mid(4); if (hadPixelOrPosPrefix) *hadPixelOrPosPrefix = true; } else if (prop.startsWith("khtml-") || prop.startsWith("apple-") || prop.startsWith("webkit-")) prop.insert(0, '-'); return prop; }