void HTMLAnchorElement::setHash(const String& value) { KURL url = href(); if (value[0] == '#') url.setFragmentIdentifier(value.substring(1)); else url.setFragmentIdentifier(value); setHref(url.string()); }
void Resource::load(ResourceFetcher* fetcher, const ResourceLoaderOptions& options) { m_options = options; m_loading = true; ResourceRequest request(m_revalidatingRequest.isNull() ? m_resourceRequest : m_revalidatingRequest); if (!accept().isEmpty()) request.setHTTPAccept(accept()); // FIXME: It's unfortunate that the cache layer and below get to know anything about fragment identifiers. // We should look into removing the expectation of that knowledge from the platform network stacks. if (!m_fragmentIdentifierForRequest.isNull()) { KURL url = request.url(); url.setFragmentIdentifier(m_fragmentIdentifierForRequest); request.setURL(url); m_fragmentIdentifierForRequest = String(); } m_status = Pending; if (m_loader) { ASSERT(m_revalidatingRequest.isNull()); RELEASE_ASSERT(m_options.synchronousPolicy == RequestSynchronously); m_loader->changeToSynchronous(); return; } m_loader = ResourceLoader::create(fetcher, this, request, options); m_loader->start(); }
void CachedResource::load(CachedResourceLoader* cachedResourceLoader, const ResourceLoaderOptions& options) { if (!cachedResourceLoader->frame()) { failBeforeStarting(); return; } m_options = options; m_loading = true; if (!accept().isEmpty()) m_resourceRequest.setHTTPAccept(accept()); if (isCacheValidator()) { CachedResource* resourceToRevalidate = m_resourceToRevalidate; ASSERT(resourceToRevalidate->canUseCacheValidator()); ASSERT(resourceToRevalidate->isLoaded()); const String& lastModified = resourceToRevalidate->response().httpHeaderField("Last-Modified"); const String& eTag = resourceToRevalidate->response().httpHeaderField("ETag"); if (!lastModified.isEmpty() || !eTag.isEmpty()) { ASSERT(cachedResourceLoader->cachePolicy(type()) != CachePolicyReload); if (cachedResourceLoader->cachePolicy(type()) == CachePolicyRevalidate) m_resourceRequest.setHTTPHeaderField("Cache-Control", "max-age=0"); if (!lastModified.isEmpty()) m_resourceRequest.setHTTPHeaderField("If-Modified-Since", lastModified); if (!eTag.isEmpty()) m_resourceRequest.setHTTPHeaderField("If-None-Match", eTag); } } if (type() == CachedResource::LinkPrefetch || type() == CachedResource::LinkSubresource) m_resourceRequest.setHTTPHeaderField("Purpose", "prefetch"); m_resourceRequest.setPriority(loadPriority()); // FIXME: It's unfortunate that the cache layer and below get to know anything about fragment identifiers. // We should look into removing the expectation of that knowledge from the platform network stacks. ResourceRequest request(m_resourceRequest); if (!m_fragmentIdentifierForRequest.isNull()) { KURL url = request.url(); url.setFragmentIdentifier(m_fragmentIdentifierForRequest); request.setURL(url); m_fragmentIdentifierForRequest = String(); } m_loader = ResourceLoader::create(cachedResourceLoader->frame(), this, request, options); if (!m_loader) { failBeforeStarting(); return; } m_status = Pending; }
void JSLocation::setHash(ExecState* exec, JSValue value) { Frame* frame = impl()->frame(); ASSERT(frame); KURL url = frame->loader()->url(); String oldFragmentIdentifier = url.fragmentIdentifier(); String str = value.toString(exec); if (str.startsWith("#")) str = str.substring(1); if (equalIgnoringNullity(oldFragmentIdentifier, str)) return; url.setFragmentIdentifier(str); navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false); }
void Location::setHash(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, const String& hash) { if (!m_frame) return; KURL url = m_frame->document()->url(); String oldFragmentIdentifier = url.fragmentIdentifier(); String newFragmentIdentifier = hash; if (hash[0] == '#') newFragmentIdentifier = hash.substring(1); url.setFragmentIdentifier(newFragmentIdentifier); // Note that by parsing the URL and *then* comparing fragments, we are // comparing fragments post-canonicalization, and so this handles the // cases where fragment identifiers are ignored or invalid. if (equalIgnoringNullity(oldFragmentIdentifier, url.fragmentIdentifier())) return; setLocation(url.string(), callingWindow, enteredWindow); }
void V8Location::hashAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { INC_STATS("DOM.Location.hash._set"); v8::Handle<v8::Object> holder = info.Holder(); Location* imp = V8Location::toNative(holder); String hash = toWebCoreString(value); Frame* frame = imp->frame(); if (!frame) return; KURL url = frame->loader()->url(); String oldRef = url.fragmentIdentifier(); if (hash.startsWith("#")) hash = hash.substring(1); if (oldRef == hash || (oldRef.isNull() && hash.isEmpty())) return; url.setFragmentIdentifier(hash); navigateIfAllowed(frame, url, false, false); }
void CachedResource::load(CachedResourceLoader* cachedResourceLoader, const ResourceLoaderOptions& options) { if (!cachedResourceLoader->frame()) { failBeforeStarting(); return; } FrameLoader* frameLoader = cachedResourceLoader->frame()->loader(); if (options.securityCheck == DoSecurityCheck && (frameLoader->state() == FrameStateProvisional || !frameLoader->activeDocumentLoader() || frameLoader->activeDocumentLoader()->isStopping())) { failBeforeStarting(); return; } m_options = options; m_loading = true; #if PLATFORM(CHROMIUM) || PLATFORM(BLACKBERRY) if (m_resourceRequest.targetType() == ResourceRequest::TargetIsUnspecified) m_resourceRequest.setTargetType(cachedResourceTypeToTargetType(type())); #endif if (!accept().isEmpty()) m_resourceRequest.setHTTPAccept(accept()); if (isCacheValidator()) { CachedResource* resourceToRevalidate = m_resourceToRevalidate; ASSERT(resourceToRevalidate->canUseCacheValidator()); ASSERT(resourceToRevalidate->isLoaded()); const String& lastModified = resourceToRevalidate->response().httpHeaderField("Last-Modified"); const String& eTag = resourceToRevalidate->response().httpHeaderField("ETag"); if (!lastModified.isEmpty() || !eTag.isEmpty()) { ASSERT(cachedResourceLoader->cachePolicy() != CachePolicyReload); if (cachedResourceLoader->cachePolicy() == CachePolicyRevalidate) m_resourceRequest.setHTTPHeaderField("Cache-Control", "max-age=0"); if (!lastModified.isEmpty()) m_resourceRequest.setHTTPHeaderField("If-Modified-Since", lastModified); if (!eTag.isEmpty()) m_resourceRequest.setHTTPHeaderField("If-None-Match", eTag); } } #if ENABLE(LINK_PREFETCH) if (type() == CachedResource::LinkPrefetch || type() == CachedResource::LinkSubresource) m_resourceRequest.setHTTPHeaderField("Purpose", "prefetch"); #endif m_resourceRequest.setPriority(loadPriority()); if (type() != MainResource) addAdditionalRequestHeaders(cachedResourceLoader); // FIXME: It's unfortunate that the cache layer and below get to know anything about fragment identifiers. // We should look into removing the expectation of that knowledge from the platform network stacks. ResourceRequest request(m_resourceRequest); if (!m_fragmentIdentifierForRequest.isNull()) { KURL url = request.url(); url.setFragmentIdentifier(m_fragmentIdentifierForRequest); request.setURL(url); m_fragmentIdentifierForRequest = String(); } #if USE(PLATFORM_STRATEGIES) m_loader = platformStrategies()->loaderStrategy()->resourceLoadScheduler()->scheduleSubresourceLoad(cachedResourceLoader->frame(), this, request, request.priority(), options); #else m_loader = resourceLoadScheduler()->scheduleSubresourceLoad(cachedResourceLoader->frame(), this, request, request.priority(), options); #endif if (!m_loader) { failBeforeStarting(); return; } m_status = Pending; }