void HTMLLinkElement::process() { if (!inDocument()) return; String type = m_type.lower(); // IE extension: location of small icon for locationbar / bookmarks // We'll record this URL per document, even if we later only use it in top level frames if (m_isIcon && m_url.isValid() && !m_url.isEmpty()) document()->setIconURL(m_url.string(), type); if (m_isDNSPrefetch && m_url.isValid() && !m_url.isEmpty()) ResourceHandle::prepareForURL(m_url); bool acceptIfTypeContainsTextCSS = document()->page() && document()->page()->settings() && document()->page()->settings()->treatsAnyTextCSSLinkAsStylesheet(); // Stylesheet // This was buggy and would incorrectly match <link rel="alternate">, which has a different specified meaning. -dwh if (m_disabledState != 2 && (m_isStyleSheet || (acceptIfTypeContainsTextCSS && type.contains("text/css"))) && document()->frame() && m_url.isValid()) { // also, don't load style sheets for standalone documents String charset = getAttribute(charsetAttr); if (charset.isEmpty() && document()->frame()) charset = document()->frame()->loader()->encoding(); if (m_cachedSheet) { if (m_loading) document()->removePendingSheet(); m_cachedSheet->removeClient(this); m_cachedSheet = 0; } if (!dispatchBeforeLoadEvent(m_url)) return; m_loading = true; // Add ourselves as a pending sheet, but only if we aren't an alternate // stylesheet. Alternate stylesheets don't hold up render tree construction. if (!isAlternate()) document()->addPendingSheet(); m_cachedSheet = document()->docLoader()->requestCSSStyleSheet(m_url, charset); if (m_cachedSheet) m_cachedSheet->addClient(this); else { // The request may have been denied if (for example) the stylesheet is local and the document is remote. m_loading = false; if (!isAlternate()) document()->removePendingSheet(); } } else if (m_sheet) { // we no longer contain a stylesheet, e.g. perhaps rel or type was changed m_sheet = 0; document()->updateStyleSelector(); } }
bool HTMLLinkElement::shouldLoadLink() { RefPtr<Document> originalDocument = document(); if (!dispatchBeforeLoadEvent(m_url)) return false; // A beforeload handler might have removed us from the document or changed the document. if (!inDocument() || document() != originalDocument) return false; return true; }
// FIXME: This should be unified with HTMLEmbedElement::updateWidget and // moved down into HTMLPluginImageElement.cpp void HTMLObjectElement::updateWidget(bool onlyCreateNonNetscapePlugins) { ASSERT(!renderEmbeddedObject()->pluginCrashedOrWasMissing()); // FIXME: We should ASSERT(needsWidgetUpdate()), but currently // FrameView::updateWidget() calls updateWidget(false) without checking if // the widget actually needs updating! setNeedsWidgetUpdate(false); // FIXME: This should ASSERT isFinishedParsingChildren() instead. if (!isFinishedParsingChildren()) return; String url = this->url(); // If the object does not specify a MIME type via a type attribute, but does // contain a classid attribute, try to map the classid to a MIME type. String serviceType = this->serviceType(); if (serviceType.isEmpty()) serviceType = serviceTypeForClassId(classId()); // FIXME: These should be joined into a PluginParameters class. Vector<String> paramNames; Vector<String> paramValues; parametersForPlugin(paramNames, paramValues, url, serviceType); // Note: url is modified above by parametersForPlugin. if (!allowedToLoadFrameURL(url)) return; bool fallbackContent = hasFallbackContent(); renderEmbeddedObject()->setHasFallbackContent(fallbackContent); if (onlyCreateNonNetscapePlugins && wouldLoadAsNetscapePlugin(url, serviceType)) return; bool beforeLoadAllowedLoad = dispatchBeforeLoadEvent(url); // beforeload events can modify the DOM, potentially causing // RenderWidget::destroy() to be called. Ensure we haven't been // destroyed before continuing. // FIXME: Should this render fallback content? if (!renderer()) return; SubframeLoader* loader = document()->frame()->loader()->subframeLoader(); bool success = beforeLoadAllowedLoad && loader->requestObject(this, url, getAttribute(nameAttr), serviceType, paramNames, paramValues); if (!success && fallbackContent) renderFallbackContent(); }
// FIXME: This should be unified with HTMLEmbedElement::updateWidget and // moved down into HTMLPluginImageElement.cpp void HTMLObjectElement::updateWidget(PluginCreationOption pluginCreationOption) { ASSERT(!renderEmbeddedObject()->pluginCrashedOrWasMissing()); // FIXME: We should ASSERT(needsWidgetUpdate()), but currently // FrameView::updateWidget() calls updateWidget(false) without checking if // the widget actually needs updating! setNeedsWidgetUpdate(false); // FIXME: This should ASSERT isFinishedParsingChildren() instead. if (!isFinishedParsingChildren()) return; String url = this->url(); String serviceType = this->serviceType(); // FIXME: These should be joined into a PluginParameters class. Vector<String> paramNames; Vector<String> paramValues; parametersForPlugin(paramNames, paramValues, url, serviceType); // Note: url is modified above by parametersForPlugin. if (!allowedToLoadFrameURL(url)) return; bool fallbackContent = hasFallbackContent(); renderEmbeddedObject()->setHasFallbackContent(fallbackContent); if (pluginCreationOption == CreateOnlyNonNetscapePlugins && wouldLoadAsNetscapePlugin(url, serviceType)) return; ASSERT(!m_inBeforeLoadEventHandler); m_inBeforeLoadEventHandler = true; bool beforeLoadAllowedLoad = dispatchBeforeLoadEvent(url); m_inBeforeLoadEventHandler = false; // beforeload events can modify the DOM, potentially causing // RenderWidget::destroy() to be called. Ensure we haven't been // destroyed before continuing. // FIXME: Should this render fallback content? if (!renderer()) return; RefPtr<HTMLObjectElement> protect(this); // Loading the plugin might remove us from the document. SubframeLoader* loader = document()->frame()->loader()->subframeLoader(); bool success = beforeLoadAllowedLoad && hasValidClassId() && loader->requestObject(this, url, getAttribute(nameAttr), serviceType, paramNames, paramValues); if (!success && fallbackContent) renderFallbackContent(); }
void ProcessingInstruction::checkStyleSheet() { if (m_target == "xml-stylesheet" && document().frame() && parentNode() == &document()) { // see http://www.w3.org/TR/xml-stylesheet/ // ### support stylesheet included in a fragment of this (or another) document // ### make sure this gets called when adding from javascript bool attrsOk; const HashMap<String, String> attrs = parseAttributes(data(), attrsOk); if (!attrsOk) return; HashMap<String, String>::const_iterator i = attrs.find("type"); String type; if (i != attrs.end()) type = i->value; m_isCSS = type.isEmpty() || type == "text/css"; #if ENABLE(XSLT) m_isXSL = (type == "text/xml" || type == "text/xsl" || type == "application/xml" || type == "application/xhtml+xml" || type == "application/rss+xml" || type == "application/atom+xml"); if (!m_isCSS && !m_isXSL) #else if (!m_isCSS) #endif return; String href = attrs.get("href"); String alternate = attrs.get("alternate"); m_alternate = alternate == "yes"; m_title = attrs.get("title"); m_media = attrs.get("media"); if (m_alternate && m_title.isEmpty()) return; if (href.length() > 1 && href[0] == '#') { m_localHref = href.substring(1); #if ENABLE(XSLT) // We need to make a synthetic XSLStyleSheet that is embedded. It needs to be able // to kick off import/include loads that can hang off some parent sheet. if (m_isXSL) { URL finalURL(ParsedURLString, m_localHref); m_sheet = XSLStyleSheet::createEmbedded(this, finalURL); m_loading = false; } #endif } else { if (m_cachedSheet) { m_cachedSheet->removeClient(this); m_cachedSheet = 0; } String url = document().completeURL(href).string(); if (!dispatchBeforeLoadEvent(url)) return; m_loading = true; document().styleSheetCollection().addPendingSheet(); CachedResourceRequest request(ResourceRequest(document().completeURL(href))); #if ENABLE(XSLT) if (m_isXSL) m_cachedSheet = document().cachedResourceLoader()->requestXSLStyleSheet(request); else #endif { String charset = attrs.get("charset"); if (charset.isEmpty()) charset = document().charset(); request.setCharset(charset); m_cachedSheet = document().cachedResourceLoader()->requestCSSStyleSheet(request); } if (m_cachedSheet) m_cachedSheet->addClient(this); else { // The request may have been denied if (for example) the stylesheet is local and the document is remote. m_loading = false; document().styleSheetCollection().removePendingSheet(); } } } }
void HTMLLinkElement::process() { if (!inDocument()) { ASSERT(!m_sheet); return; } String type = m_type.lower(); // IE extension: location of small icon for locationbar / bookmarks // We'll record this URL per document, even if we later only use it in top level frames if (m_relAttribute.m_isIcon && m_url.isValid() && !m_url.isEmpty()) document()->setIconURL(m_url.string(), type); if (m_relAttribute.m_isDNSPrefetch) { Settings* settings = document()->settings(); // FIXME: The href attribute of the link element can be in "//hostname" form, and we shouldn't attempt // to complete that as URL <https://bugs.webkit.org/show_bug.cgi?id=48857>. if (settings && settings->dnsPrefetchingEnabled() && m_url.isValid() && !m_url.isEmpty()) ResourceHandle::prepareForURL(m_url); } #if ENABLE(LINK_PREFETCH) if (m_relAttribute.m_isLinkPrefetch && m_url.isValid() && document()->frame()) document()->cachedResourceLoader()->requestLinkPrefetch(m_url); #endif bool acceptIfTypeContainsTextCSS = document()->page() && document()->page()->settings() && document()->page()->settings()->treatsAnyTextCSSLinkAsStylesheet(); // Stylesheet // This was buggy and would incorrectly match <link rel="alternate">, which has a different specified meaning. -dwh if (m_disabledState != Disabled && (m_relAttribute.m_isStyleSheet || (acceptIfTypeContainsTextCSS && type.contains("text/css"))) && document()->frame() && m_url.isValid()) { // also, don't load style sheets for standalone documents String charset = getAttribute(charsetAttr); if (charset.isEmpty() && document()->frame()) charset = document()->frame()->loader()->writer()->encoding(); if (m_cachedSheet) { if (m_loading) document()->removePendingSheet(); m_cachedSheet->removeClient(this); m_cachedSheet = 0; } if (!dispatchBeforeLoadEvent(m_url)) return; m_loading = true; // Add ourselves as a pending sheet, but only if we aren't an alternate // stylesheet. Alternate stylesheets don't hold up render tree construction. if (!isAlternate()) document()->addPendingSheet(); m_cachedSheet = document()->cachedResourceLoader()->requestCSSStyleSheet(m_url, charset); if (m_cachedSheet) m_cachedSheet->addClient(this); else { // The request may have been denied if (for example) the stylesheet is local and the document is remote. m_loading = false; if (!isAlternate()) document()->removePendingSheet(); } } else if (m_sheet) { // we no longer contain a stylesheet, e.g. perhaps rel or type was changed m_sheet = 0; document()->styleSelectorChanged(DeferRecalcStyle); } }