mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove HTMLLinkElement
Please use <import> instead. R=esprehn@chromium.org Review URL: https://codereview.chromium.org/696413002
This commit is contained in:
parent
3eb5be249e
commit
512c4591a6
@ -53,7 +53,6 @@
|
||||
#include "core/frame/LocalFrame.h"
|
||||
#include "core/frame/Settings.h"
|
||||
#include "core/frame/UseCounter.h"
|
||||
#include "core/html/HTMLLinkElement.h"
|
||||
#include "core/html/imports/HTMLImportChild.h"
|
||||
#include "core/html/imports/HTMLImportLoader.h"
|
||||
#include "core/html/parser/HTMLDocumentParser.h"
|
||||
|
||||
@ -760,8 +760,6 @@ sky_core_files = [
|
||||
"html/HTMLImageLoader.h",
|
||||
"html/HTMLImportElement.cpp",
|
||||
"html/HTMLImportElement.h",
|
||||
"html/HTMLLinkElement.cpp",
|
||||
"html/HTMLLinkElement.h",
|
||||
"html/HTMLMediaElement.cpp",
|
||||
"html/HTMLMediaSource.cpp",
|
||||
"html/HTMLMediaSource.h",
|
||||
@ -783,10 +781,6 @@ sky_core_files = [
|
||||
"html/HTMLVideoElement.h",
|
||||
"html/ImageData.cpp",
|
||||
"html/ImageData.h",
|
||||
"html/LinkRelAttribute.cpp",
|
||||
"html/LinkRelAttribute.h",
|
||||
"html/LinkResource.cpp",
|
||||
"html/LinkResource.h",
|
||||
"html/MediaError.h",
|
||||
"html/MediaFragmentURIParser.cpp",
|
||||
"html/MediaFragmentURIParser.h",
|
||||
@ -922,8 +916,6 @@ sky_core_files = [
|
||||
"html/imports/HTMLImportTreeRoot.h",
|
||||
"html/imports/HTMLImportsController.cpp",
|
||||
"html/imports/HTMLImportsController.h",
|
||||
"html/imports/LinkImport.cpp",
|
||||
"html/imports/LinkImport.h",
|
||||
"html/parser/AtomicHTMLToken.h",
|
||||
"html/parser/BackgroundHTMLParser.cpp",
|
||||
"html/parser/BackgroundHTMLParser.h",
|
||||
@ -1271,7 +1263,6 @@ core_idl_files = get_path_info([
|
||||
"html/HTMLElement.idl",
|
||||
"html/HTMLImageElement.idl",
|
||||
"html/HTMLImportElement.idl",
|
||||
"html/HTMLLinkElement.idl",
|
||||
"html/HTMLMediaElement.idl",
|
||||
"html/HTMLMetaElement.idl",
|
||||
"html/HTMLPictureElement.idl",
|
||||
|
||||
@ -77,7 +77,6 @@ static bool isAcceptableCSSStyleSheetParent(Node* parentNode)
|
||||
// clearOwnerNode() in the owner's destructor in oilpan.
|
||||
return !parentNode
|
||||
|| parentNode->isDocumentNode()
|
||||
|| isHTMLLinkElement(*parentNode)
|
||||
|| isHTMLStyleElement(*parentNode);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -101,7 +101,6 @@
|
||||
#include "core/html/HTMLAnchorElement.h"
|
||||
#include "core/html/HTMLCanvasElement.h"
|
||||
#include "core/html/HTMLDocument.h"
|
||||
#include "core/html/HTMLLinkElement.h"
|
||||
#include "core/html/HTMLMetaElement.h"
|
||||
#include "core/html/HTMLScriptElement.h"
|
||||
#include "core/html/HTMLStyleElement.h"
|
||||
@ -1525,7 +1524,6 @@ void Document::implicitClose()
|
||||
if (frame()) {
|
||||
ImageLoader::dispatchPendingLoadEvents();
|
||||
ImageLoader::dispatchPendingErrorEvents();
|
||||
HTMLLinkElement::dispatchPendingLoadEvents();
|
||||
}
|
||||
|
||||
// JS running below could remove the frame or destroy the RenderView so we call
|
||||
|
||||
@ -94,7 +94,6 @@ class HTMLElement;
|
||||
class HTMLImport;
|
||||
class HTMLImportLoader;
|
||||
class HTMLImportsController;
|
||||
class HTMLLinkElement;
|
||||
class HTMLScriptElement;
|
||||
class HitTestRequest;
|
||||
class LayoutPoint;
|
||||
|
||||
@ -50,17 +50,6 @@ void DocumentStyleSheetCollection::collectStyleSheetsFromCandidates(StyleEngine*
|
||||
Node* n = *it;
|
||||
StyleSheetCandidate candidate(*n);
|
||||
|
||||
if (candidate.isImport()) {
|
||||
Document* document = candidate.importedDocument();
|
||||
if (!document)
|
||||
continue;
|
||||
if (collector.hasVisited(document))
|
||||
continue;
|
||||
collector.willVisit(document);
|
||||
document->styleEngine()->updateStyleSheetsInImport(collector);
|
||||
continue;
|
||||
}
|
||||
|
||||
StyleSheet* sheet = candidate.sheet();
|
||||
if (!sheet)
|
||||
continue;
|
||||
|
||||
@ -31,7 +31,6 @@
|
||||
#include "config.h"
|
||||
#include "core/dom/Document.h"
|
||||
|
||||
#include "core/html/HTMLLinkElement.h"
|
||||
#include "core/testing/DummyPageHolder.h"
|
||||
#include "platform/heap/Handle.h"
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
@ -1502,7 +1502,7 @@ KURL Element::hrefURL() const
|
||||
{
|
||||
// FIXME: These all have href() or url(), but no common super class. Why doesn't
|
||||
// <link> implement URLUtils?
|
||||
if (isHTMLAnchorElement(*this) || isHTMLLinkElement(*this))
|
||||
if (isHTMLAnchorElement(*this))
|
||||
return getURLAttribute(HTMLNames::hrefAttr);
|
||||
return KURL();
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
#include "core/dom/Element.h"
|
||||
#include "core/dom/ShadowTreeStyleSheetCollection.h"
|
||||
#include "core/dom/shadow/ShadowRoot.h"
|
||||
#include "core/html/HTMLLinkElement.h"
|
||||
#include "core/html/HTMLStyleElement.h"
|
||||
#include "core/html/imports/HTMLImportsController.h"
|
||||
#include "core/page/Page.h"
|
||||
#include "core/frame/Settings.h"
|
||||
|
||||
@ -29,23 +29,11 @@
|
||||
|
||||
#include "core/dom/Element.h"
|
||||
#include "core/dom/StyleEngine.h"
|
||||
#include "core/html/HTMLLinkElement.h"
|
||||
#include "core/html/HTMLStyleElement.h"
|
||||
#include "core/html/imports/HTMLImport.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
bool StyleSheetCandidate::isImport() const
|
||||
{
|
||||
return m_type == HTMLLink && toHTMLLinkElement(node()).isImport();
|
||||
}
|
||||
|
||||
Document* StyleSheetCandidate::importedDocument() const
|
||||
{
|
||||
ASSERT(isImport());
|
||||
return toHTMLLinkElement(node()).import();
|
||||
}
|
||||
|
||||
bool StyleSheetCandidate::canBeActivated() const
|
||||
{
|
||||
StyleSheet* sheet = this->sheet();
|
||||
@ -55,8 +43,6 @@ bool StyleSheetCandidate::canBeActivated() const
|
||||
StyleSheetCandidate::Type StyleSheetCandidate::typeOf(Node& node)
|
||||
{
|
||||
if (node.isHTMLElement()) {
|
||||
if (isHTMLLinkElement(node))
|
||||
return HTMLLink;
|
||||
if (isHTMLStyleElement(node))
|
||||
return HTMLStyle;
|
||||
|
||||
@ -71,8 +57,6 @@ StyleSheetCandidate::Type StyleSheetCandidate::typeOf(Node& node)
|
||||
StyleSheet* StyleSheetCandidate::sheet() const
|
||||
{
|
||||
switch (m_type) {
|
||||
case HTMLLink:
|
||||
return toHTMLLinkElement(node()).sheet();
|
||||
case HTMLStyle:
|
||||
return toHTMLStyleElement(node()).sheet();
|
||||
}
|
||||
|
||||
@ -41,7 +41,6 @@ class StyleSheetCandidate {
|
||||
STACK_ALLOCATED();
|
||||
public:
|
||||
enum Type {
|
||||
HTMLLink,
|
||||
HTMLStyle,
|
||||
};
|
||||
|
||||
@ -50,11 +49,9 @@ public:
|
||||
, m_type(typeOf(node))
|
||||
{ }
|
||||
|
||||
bool isImport() const;
|
||||
bool canBeActivated() const;
|
||||
|
||||
StyleSheet* sheet() const;
|
||||
Document* importedDocument() const;
|
||||
|
||||
private:
|
||||
Node& node() const { return *m_node; }
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
#include "core/css/resolver/StyleResolver.h"
|
||||
#include "core/dom/Element.h"
|
||||
#include "core/dom/StyleEngine.h"
|
||||
#include "core/html/HTMLLinkElement.h"
|
||||
#include "core/html/HTMLStyleElement.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
@ -334,7 +334,7 @@ void DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPr
|
||||
RefPtr<Node> node = range->firstNode();
|
||||
while (node && node != range->pastLastNode()) {
|
||||
RefPtr<Node> nextNode = NodeTraversal::next(*node);
|
||||
if (isHTMLStyleElement(*node) || isHTMLLinkElement(*node)) {
|
||||
if (isHTMLStyleElement(*node)) {
|
||||
nextNode = NodeTraversal::nextSkippingChildren(*node);
|
||||
RefPtr<Element> rootEditableElement = node->rootEditableElement();
|
||||
if (rootEditableElement.get()) {
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include "core/html/HTMLImportElement.h"
|
||||
|
||||
#include "core/dom/Document.h"
|
||||
#include "core/fetch/FetchRequest.h"
|
||||
#include "core/html/imports/HTMLImportsController.h"
|
||||
#include "core/html/imports/HTMLImportChild.h"
|
||||
|
||||
|
||||
@ -1,334 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
|
||||
* (C) 1999 Antti Koivisto (koivisto@kde.org)
|
||||
* (C) 2001 Dirk Mueller (mueller@kde.org)
|
||||
* Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com)
|
||||
* Copyright (C) 2011 Google Inc. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "core/html/HTMLLinkElement.h"
|
||||
|
||||
#include "core/HTMLNames.h"
|
||||
#include "core/css/MediaList.h"
|
||||
#include "core/css/MediaQueryEvaluator.h"
|
||||
#include "core/css/StyleSheetContents.h"
|
||||
#include "core/css/resolver/StyleResolver.h"
|
||||
#include "core/dom/Attribute.h"
|
||||
#include "core/dom/Document.h"
|
||||
#include "core/dom/StyleEngine.h"
|
||||
#include "core/events/Event.h"
|
||||
#include "core/events/EventSender.h"
|
||||
#include "core/fetch/FetchRequest.h"
|
||||
#include "core/fetch/ResourceFetcher.h"
|
||||
#include "core/frame/FrameView.h"
|
||||
#include "core/frame/LocalFrame.h"
|
||||
#include "core/html/imports/LinkImport.h"
|
||||
#include "core/html/parser/HTMLParserIdioms.h"
|
||||
#include "core/loader/FrameLoaderClient.h"
|
||||
#include "core/rendering/style/RenderStyle.h"
|
||||
#include "core/rendering/style/StyleInheritedData.h"
|
||||
#include "platform/RuntimeEnabledFeatures.h"
|
||||
#include "wtf/StdLibExtras.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
template <typename CharacterType>
|
||||
static void parseSizes(const CharacterType* value, unsigned length, Vector<IntSize>& iconSizes)
|
||||
{
|
||||
enum State {
|
||||
ParseStart,
|
||||
ParseWidth,
|
||||
ParseHeight
|
||||
};
|
||||
int width = 0;
|
||||
unsigned start = 0;
|
||||
unsigned i = 0;
|
||||
State state = ParseStart;
|
||||
bool invalid = false;
|
||||
for (; i < length; ++i) {
|
||||
if (state == ParseWidth) {
|
||||
if (value[i] == 'x' || value[i] == 'X') {
|
||||
if (i == start) {
|
||||
invalid = true;
|
||||
break;
|
||||
}
|
||||
width = charactersToInt(value + start, i - start);
|
||||
start = i + 1;
|
||||
state = ParseHeight;
|
||||
} else if (value[i] < '0' || value[i] > '9') {
|
||||
invalid = true;
|
||||
break;
|
||||
}
|
||||
} else if (state == ParseHeight) {
|
||||
if (value[i] == ' ') {
|
||||
if (i == start) {
|
||||
invalid = true;
|
||||
break;
|
||||
}
|
||||
int height = charactersToInt(value + start, i - start);
|
||||
iconSizes.append(IntSize(width, height));
|
||||
start = i + 1;
|
||||
state = ParseStart;
|
||||
} else if (value[i] < '0' || value[i] > '9') {
|
||||
invalid = true;
|
||||
break;
|
||||
}
|
||||
} else if (state == ParseStart) {
|
||||
if (value[i] >= '0' && value[i] <= '9') {
|
||||
start = i;
|
||||
state = ParseWidth;
|
||||
} else if (value[i] != ' ') {
|
||||
invalid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (invalid || state == ParseWidth || (state == ParseHeight && start == i)) {
|
||||
iconSizes.clear();
|
||||
return;
|
||||
}
|
||||
if (state == ParseHeight && i > start) {
|
||||
int height = charactersToInt(value + start, i - start);
|
||||
iconSizes.append(IntSize(width, height));
|
||||
}
|
||||
}
|
||||
|
||||
static LinkEventSender& linkLoadEventSender()
|
||||
{
|
||||
DEFINE_STATIC_LOCAL(LinkEventSender, sharedLoadEventSender, (EventTypeNames::load));
|
||||
return sharedLoadEventSender;
|
||||
}
|
||||
|
||||
void HTMLLinkElement::parseSizesAttribute(const AtomicString& value, Vector<IntSize>& iconSizes)
|
||||
{
|
||||
ASSERT(iconSizes.isEmpty());
|
||||
if (value.isEmpty())
|
||||
return;
|
||||
if (value.is8Bit())
|
||||
parseSizes(value.characters8(), value.length(), iconSizes);
|
||||
else
|
||||
parseSizes(value.characters16(), value.length(), iconSizes);
|
||||
}
|
||||
|
||||
inline HTMLLinkElement::HTMLLinkElement(Document& document, bool createdByParser)
|
||||
: HTMLElement(HTMLNames::linkTag, document)
|
||||
, m_sizes(DOMSettableTokenList::create())
|
||||
, m_createdByParser(createdByParser)
|
||||
, m_isInShadowTree(false)
|
||||
{
|
||||
ScriptWrappable::init(this);
|
||||
}
|
||||
|
||||
PassRefPtr<HTMLLinkElement> HTMLLinkElement::create(Document& document, bool createdByParser)
|
||||
{
|
||||
return adoptRef(new HTMLLinkElement(document, createdByParser));
|
||||
}
|
||||
|
||||
HTMLLinkElement::~HTMLLinkElement()
|
||||
{
|
||||
#if !ENABLE(OILPAN)
|
||||
m_link.clear();
|
||||
|
||||
if (inDocument())
|
||||
document().styleEngine()->removeStyleSheetCandidateNode(this);
|
||||
#endif
|
||||
|
||||
linkLoadEventSender().cancelEvent(this);
|
||||
}
|
||||
|
||||
void HTMLLinkElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
|
||||
{
|
||||
if (name == HTMLNames::relAttr) {
|
||||
m_relAttribute = LinkRelAttribute(value);
|
||||
process();
|
||||
} else if (name == HTMLNames::hrefAttr) {
|
||||
process();
|
||||
} else if (name == HTMLNames::typeAttr) {
|
||||
m_type = value;
|
||||
process();
|
||||
} else if (name == HTMLNames::sizesAttr) {
|
||||
m_sizes->setValue(value);
|
||||
parseSizesAttribute(value, m_iconSizes);
|
||||
process();
|
||||
} else if (name == HTMLNames::mediaAttr) {
|
||||
m_media = value.string().lower();
|
||||
process();
|
||||
} else {
|
||||
HTMLElement::parseAttribute(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
LinkResource* HTMLLinkElement::linkResourceToProcess()
|
||||
{
|
||||
bool visible = inDocument() && !m_isInShadowTree;
|
||||
if (!visible)
|
||||
return 0;
|
||||
|
||||
if (!m_link && m_relAttribute.isImport())
|
||||
m_link = LinkImport::create(this);
|
||||
|
||||
return m_link.get();
|
||||
}
|
||||
|
||||
LinkImport* HTMLLinkElement::linkImport() const
|
||||
{
|
||||
if (!m_link || m_link->type() != LinkResource::Import)
|
||||
return 0;
|
||||
return static_cast<LinkImport*>(m_link.get());
|
||||
}
|
||||
|
||||
Document* HTMLLinkElement::import() const
|
||||
{
|
||||
if (LinkImport* link = linkImport())
|
||||
return link->importedDocument();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HTMLLinkElement::process()
|
||||
{
|
||||
if (LinkResource* link = linkResourceToProcess())
|
||||
link->process();
|
||||
}
|
||||
|
||||
Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode* insertionPoint)
|
||||
{
|
||||
HTMLElement::insertedInto(insertionPoint);
|
||||
if (!insertionPoint->inDocument())
|
||||
return InsertionDone;
|
||||
|
||||
m_isInShadowTree = isInShadowTree();
|
||||
if (m_isInShadowTree)
|
||||
return InsertionDone;
|
||||
|
||||
document().styleEngine()->addStyleSheetCandidateNode(this, m_createdByParser);
|
||||
|
||||
process();
|
||||
|
||||
if (m_link)
|
||||
m_link->ownerInserted();
|
||||
|
||||
return InsertionDone;
|
||||
}
|
||||
|
||||
void HTMLLinkElement::removedFrom(ContainerNode* insertionPoint)
|
||||
{
|
||||
HTMLElement::removedFrom(insertionPoint);
|
||||
if (!insertionPoint->inDocument())
|
||||
return;
|
||||
|
||||
if (m_isInShadowTree)
|
||||
return;
|
||||
document().styleEngine()->removeStyleSheetCandidateNode(this);
|
||||
|
||||
RefPtr<StyleSheet> removedSheet = sheet();
|
||||
|
||||
if (m_link)
|
||||
m_link->ownerRemoved();
|
||||
|
||||
document().removedStyleSheet(removedSheet.get());
|
||||
}
|
||||
|
||||
void HTMLLinkElement::finishParsingChildren()
|
||||
{
|
||||
m_createdByParser = false;
|
||||
HTMLElement::finishParsingChildren();
|
||||
}
|
||||
|
||||
void HTMLLinkElement::dispatchPendingLoadEvents()
|
||||
{
|
||||
linkLoadEventSender().dispatchPendingEvents();
|
||||
}
|
||||
|
||||
void HTMLLinkElement::dispatchPendingEvent(LinkEventSender* eventSender)
|
||||
{
|
||||
ASSERT_UNUSED(eventSender, eventSender == &linkLoadEventSender());
|
||||
ASSERT(m_link);
|
||||
// FIXME(sky): Remove
|
||||
}
|
||||
|
||||
void HTMLLinkElement::scheduleEvent()
|
||||
{
|
||||
linkLoadEventSender().dispatchEventSoon(this);
|
||||
}
|
||||
|
||||
bool HTMLLinkElement::isURLAttribute(const Attribute& attribute) const
|
||||
{
|
||||
return attribute.name().localName() == HTMLNames::hrefAttr || HTMLElement::isURLAttribute(attribute);
|
||||
}
|
||||
|
||||
bool HTMLLinkElement::hasLegalLinkAttribute(const QualifiedName& name) const
|
||||
{
|
||||
return name == HTMLNames::hrefAttr || HTMLElement::hasLegalLinkAttribute(name);
|
||||
}
|
||||
|
||||
const QualifiedName& HTMLLinkElement::subResourceAttributeName() const
|
||||
{
|
||||
// If the link element is not css, ignore it.
|
||||
if (equalIgnoringCase(getAttribute(HTMLNames::typeAttr), "text/css")) {
|
||||
// FIXME: Add support for extracting links of sub-resources which
|
||||
// are inside style-sheet such as @import, @font-face, url(), etc.
|
||||
return HTMLNames::hrefAttr;
|
||||
}
|
||||
return HTMLElement::subResourceAttributeName();
|
||||
}
|
||||
|
||||
KURL HTMLLinkElement::href() const
|
||||
{
|
||||
return document().completeURL(getAttribute(HTMLNames::hrefAttr));
|
||||
}
|
||||
|
||||
const AtomicString& HTMLLinkElement::rel() const
|
||||
{
|
||||
return getAttribute(HTMLNames::relAttr);
|
||||
}
|
||||
|
||||
const AtomicString& HTMLLinkElement::type() const
|
||||
{
|
||||
return getAttribute(HTMLNames::typeAttr);
|
||||
}
|
||||
|
||||
bool HTMLLinkElement::async() const
|
||||
{
|
||||
return hasAttribute(HTMLNames::asyncAttr);
|
||||
}
|
||||
|
||||
String HTMLLinkElement::as() const
|
||||
{
|
||||
return stripLeadingAndTrailingHTMLSpaces(getAttribute(HTMLNames::asAttr));
|
||||
}
|
||||
|
||||
const Vector<IntSize>& HTMLLinkElement::iconSizes() const
|
||||
{
|
||||
return m_iconSizes;
|
||||
}
|
||||
|
||||
DOMSettableTokenList* HTMLLinkElement::sizes() const
|
||||
{
|
||||
return m_sizes.get();
|
||||
}
|
||||
|
||||
void HTMLLinkElement::trace(Visitor* visitor)
|
||||
{
|
||||
visitor->trace(m_link);
|
||||
visitor->trace(m_sizes);
|
||||
HTMLElement::trace(visitor);
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
|
||||
* (C) 1999 Antti Koivisto (koivisto@kde.org)
|
||||
* Copyright (C) 2003, 2008, 2010 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2011 Google Inc. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HTMLLinkElement_h
|
||||
#define HTMLLinkElement_h
|
||||
|
||||
#include "core/css/CSSStyleSheet.h"
|
||||
#include "core/dom/DOMSettableTokenList.h"
|
||||
#include "core/fetch/ResourceOwner.h"
|
||||
#include "core/html/HTMLElement.h"
|
||||
#include "core/html/LinkRelAttribute.h"
|
||||
#include "core/html/LinkResource.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class DocumentFragment;
|
||||
class HTMLLinkElement;
|
||||
class KURL;
|
||||
class LinkImport;
|
||||
|
||||
template<typename T> class EventSender;
|
||||
typedef EventSender<HTMLLinkElement> LinkEventSender;
|
||||
|
||||
class HTMLLinkElement final : public HTMLElement {
|
||||
DEFINE_WRAPPERTYPEINFO();
|
||||
public:
|
||||
static PassRefPtr<HTMLLinkElement> create(Document&, bool createdByParser);
|
||||
virtual ~HTMLLinkElement();
|
||||
|
||||
KURL href() const;
|
||||
const AtomicString& rel() const;
|
||||
String media() const { return m_media; }
|
||||
String typeValue() const { return m_type; }
|
||||
const LinkRelAttribute& relAttribute() const { return m_relAttribute; }
|
||||
|
||||
const AtomicString& type() const;
|
||||
|
||||
// the icon sizes as parsed from the HTML attribute
|
||||
const Vector<IntSize>& iconSizes() const;
|
||||
|
||||
bool async() const;
|
||||
String as() const;
|
||||
|
||||
CSSStyleSheet* sheet() const { return 0; }
|
||||
Document* import() const;
|
||||
|
||||
bool isImport() const { return linkImport(); }
|
||||
bool isDisabled() const { return false; }
|
||||
|
||||
DOMSettableTokenList* sizes() const;
|
||||
|
||||
void dispatchPendingEvent(LinkEventSender*);
|
||||
void scheduleEvent();
|
||||
void dispatchEventImmediately();
|
||||
static void dispatchPendingLoadEvents();
|
||||
|
||||
// For LinkStyle
|
||||
bool shouldProcessStyle() { return false; }
|
||||
bool isCreatedByParser() const { return m_createdByParser; }
|
||||
|
||||
// Parse the icon size attribute into |iconSizes|, make this method public
|
||||
// visible for testing purpose.
|
||||
static void parseSizesAttribute(const AtomicString& value, Vector<IntSize>& iconSizes);
|
||||
|
||||
virtual void trace(Visitor*) override;
|
||||
|
||||
private:
|
||||
virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
|
||||
|
||||
LinkImport* linkImport() const;
|
||||
LinkResource* linkResourceToProcess();
|
||||
|
||||
void process();
|
||||
static void processCallback(Node*);
|
||||
|
||||
// From Node and subclassses
|
||||
virtual InsertionNotificationRequest insertedInto(ContainerNode*) override;
|
||||
virtual void removedFrom(ContainerNode*) override;
|
||||
virtual bool isURLAttribute(const Attribute&) const override;
|
||||
virtual bool hasLegalLinkAttribute(const QualifiedName&) const override;
|
||||
virtual const QualifiedName& subResourceAttributeName() const override;
|
||||
virtual void finishParsingChildren() override;
|
||||
|
||||
private:
|
||||
HTMLLinkElement(Document&, bool createdByParser);
|
||||
|
||||
OwnPtr<LinkResource> m_link;
|
||||
|
||||
String m_type;
|
||||
String m_media;
|
||||
RefPtr<DOMSettableTokenList> m_sizes;
|
||||
Vector<IntSize> m_iconSizes;
|
||||
LinkRelAttribute m_relAttribute;
|
||||
|
||||
bool m_createdByParser;
|
||||
bool m_isInShadowTree;
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // HTMLLinkElement_h
|
||||
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006, 2010 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
|
||||
* Copyright (C) 2011 Google Inc. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
interface HTMLLinkElement : HTMLElement {
|
||||
[Reflect, URL] attribute DOMString href;
|
||||
[Reflect] attribute DOMString rel;
|
||||
readonly attribute Document import;
|
||||
};
|
||||
@ -1,77 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "config.h"
|
||||
#include "core/html/HTMLLinkElement.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using namespace blink;
|
||||
|
||||
namespace {
|
||||
|
||||
class HTMLLinkElementSizesAttributeTest : public testing::Test {
|
||||
};
|
||||
|
||||
TEST(HTMLLinkElementSizesAttributeTest, parseSizes)
|
||||
{
|
||||
AtomicString sizesAttribute = "32x33";
|
||||
Vector<IntSize> sizes;
|
||||
HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes);
|
||||
ASSERT_EQ(1U, sizes.size());
|
||||
EXPECT_EQ(32, sizes[0].width());
|
||||
EXPECT_EQ(33, sizes[0].height());
|
||||
|
||||
UChar attribute[] = {'3', '2', 'x', '3', '3', 0};
|
||||
sizesAttribute = attribute;
|
||||
sizes.clear();
|
||||
HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes);
|
||||
ASSERT_EQ(1U, sizes.size());
|
||||
EXPECT_EQ(32, sizes[0].width());
|
||||
EXPECT_EQ(33, sizes[0].height());
|
||||
|
||||
|
||||
sizesAttribute = " 32x33 16X17 128x129 ";
|
||||
sizes.clear();
|
||||
HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes);
|
||||
ASSERT_EQ(3U, sizes.size());
|
||||
EXPECT_EQ(32, sizes[0].width());
|
||||
EXPECT_EQ(33, sizes[0].height());
|
||||
EXPECT_EQ(16, sizes[1].width());
|
||||
EXPECT_EQ(17, sizes[1].height());
|
||||
EXPECT_EQ(128, sizes[2].width());
|
||||
EXPECT_EQ(129, sizes[2].height());
|
||||
|
||||
sizesAttribute = "any";
|
||||
sizes.clear();
|
||||
HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes);
|
||||
ASSERT_EQ(0U, sizes.size());
|
||||
|
||||
sizesAttribute = "32x33 32";
|
||||
sizes.clear();
|
||||
HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes);
|
||||
ASSERT_EQ(0U, sizes.size());
|
||||
|
||||
sizesAttribute = "32x33 32x";
|
||||
sizes.clear();
|
||||
HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes);
|
||||
ASSERT_EQ(0U, sizes.size());
|
||||
|
||||
sizesAttribute = "32x33 x32";
|
||||
sizes.clear();
|
||||
HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes);
|
||||
ASSERT_EQ(0U, sizes.size());
|
||||
|
||||
sizesAttribute = "32x33 any";
|
||||
sizes.clear();
|
||||
HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes);
|
||||
ASSERT_EQ(0U, sizes.size());
|
||||
|
||||
sizesAttribute = "32x33, 64x64";
|
||||
sizes.clear();
|
||||
HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes);
|
||||
ASSERT_EQ(0U, sizes.size());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@ -7,7 +7,6 @@ canvas
|
||||
content interfaceName=HTMLContentElement
|
||||
img interfaceName=HTMLImageElement, constructorNeedsCreatedByParser
|
||||
import
|
||||
link constructorNeedsCreatedByParser
|
||||
meta
|
||||
picture interfaceName=HTMLPictureElement
|
||||
script
|
||||
|
||||
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Google Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "core/html/LinkRelAttribute.h"
|
||||
|
||||
#include "platform/RuntimeEnabledFeatures.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
LinkRelAttribute::LinkRelAttribute(const String& rel)
|
||||
: m_isStyleSheet(false)
|
||||
, m_isLinkPrefetch(false)
|
||||
, m_isLinkSubresource(false)
|
||||
, m_isLinkNext(false)
|
||||
, m_isImport(false)
|
||||
, m_isManifest(false)
|
||||
{
|
||||
if (rel.isEmpty())
|
||||
return;
|
||||
String relCopy = rel;
|
||||
relCopy.replace('\n', ' ');
|
||||
Vector<String> list;
|
||||
relCopy.split(' ', list);
|
||||
Vector<String>::const_iterator end = list.end();
|
||||
for (Vector<String>::const_iterator it = list.begin(); it != end; ++it) {
|
||||
if (equalIgnoringCase(*it, "stylesheet")) {
|
||||
if (!m_isImport)
|
||||
m_isStyleSheet = true;
|
||||
} else if (equalIgnoringCase(*it, "import")) {
|
||||
if (!m_isStyleSheet)
|
||||
m_isImport = true;
|
||||
} else if (equalIgnoringCase(*it, "prefetch")) {
|
||||
m_isLinkPrefetch = true;
|
||||
} else if (equalIgnoringCase(*it, "subresource")) {
|
||||
m_isLinkSubresource = true;
|
||||
} else if (equalIgnoringCase(*it, "next")) {
|
||||
m_isLinkNext = true;
|
||||
} else if (equalIgnoringCase(*it, "manifest")) {
|
||||
m_isManifest = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Google Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LinkRelAttribute_h
|
||||
#define LinkRelAttribute_h
|
||||
|
||||
#include "wtf/text/WTFString.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class LinkRelAttribute {
|
||||
public:
|
||||
explicit LinkRelAttribute(const String& = "");
|
||||
|
||||
bool isStyleSheet() const { return m_isStyleSheet; }
|
||||
bool isLinkPrefetch() const { return m_isLinkPrefetch; }
|
||||
bool isLinkSubresource() const { return m_isLinkSubresource; }
|
||||
bool isLinkNext() const { return m_isLinkNext; }
|
||||
bool isImport() const { return m_isImport; }
|
||||
bool isManifest() const { return m_isManifest; }
|
||||
|
||||
private:
|
||||
bool m_isStyleSheet : 1;
|
||||
bool m_isLinkPrefetch : 1;
|
||||
bool m_isLinkSubresource : 1;
|
||||
bool m_isLinkNext : 1;
|
||||
bool m_isImport : 1;
|
||||
bool m_isManifest : 1;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Google Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "core/html/LinkResource.h"
|
||||
|
||||
#include "core/HTMLNames.h"
|
||||
#include "core/dom/Document.h"
|
||||
#include "core/html/HTMLLinkElement.h"
|
||||
#include "core/html/imports/HTMLImportsController.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
LinkResource::LinkResource(HTMLLinkElement* owner)
|
||||
: m_owner(owner)
|
||||
{
|
||||
}
|
||||
|
||||
LinkResource::~LinkResource()
|
||||
{
|
||||
}
|
||||
|
||||
bool LinkResource::shouldLoadResource() const
|
||||
{
|
||||
return m_owner->document().frame() || m_owner->document().importsController();
|
||||
}
|
||||
|
||||
LocalFrame* LinkResource::loadingFrame() const
|
||||
{
|
||||
HTMLImportsController* importsController = m_owner->document().importsController();
|
||||
if (!importsController)
|
||||
return m_owner->document().frame();
|
||||
return importsController->master()->frame();
|
||||
}
|
||||
|
||||
void LinkResource::trace(Visitor* visitor)
|
||||
{
|
||||
visitor->trace(m_owner);
|
||||
}
|
||||
|
||||
LinkRequestBuilder::LinkRequestBuilder(HTMLLinkElement* owner)
|
||||
: m_owner(owner)
|
||||
, m_url(owner->getNonEmptyURLAttribute(HTMLNames::hrefAttr))
|
||||
{
|
||||
m_charset = m_owner->getAttribute(HTMLNames::charsetAttr);
|
||||
if (m_charset.isEmpty() && m_owner->document().frame())
|
||||
m_charset = m_owner->document().charset();
|
||||
}
|
||||
|
||||
FetchRequest LinkRequestBuilder::build(bool blocking) const
|
||||
{
|
||||
ResourceLoadPriority priority = blocking ? ResourceLoadPriorityUnresolved : ResourceLoadPriorityVeryLow;
|
||||
return FetchRequest(ResourceRequest(m_owner->document().completeURL(m_url)), m_owner->localName(), m_charset, priority);
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Google Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LinkResource_h
|
||||
#define LinkResource_h
|
||||
|
||||
#include "core/fetch/FetchRequest.h"
|
||||
#include "platform/heap/Handle.h"
|
||||
#include "platform/weborigin/KURL.h"
|
||||
#include "wtf/text/WTFString.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class HTMLLinkElement;
|
||||
|
||||
class LinkResource : public DummyBase<LinkResource> {
|
||||
WTF_MAKE_NONCOPYABLE(LinkResource); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
|
||||
public:
|
||||
enum Type {
|
||||
Style,
|
||||
Import,
|
||||
Manifest
|
||||
};
|
||||
|
||||
explicit LinkResource(HTMLLinkElement*);
|
||||
virtual ~LinkResource();
|
||||
|
||||
bool shouldLoadResource() const;
|
||||
LocalFrame* loadingFrame() const;
|
||||
|
||||
virtual Type type() const = 0;
|
||||
virtual void process() = 0;
|
||||
virtual void ownerRemoved() { }
|
||||
virtual void ownerInserted() { }
|
||||
virtual bool hasLoaded() const = 0;
|
||||
|
||||
virtual void trace(Visitor*);
|
||||
|
||||
protected:
|
||||
RawPtr<HTMLLinkElement> m_owner;
|
||||
};
|
||||
|
||||
class LinkRequestBuilder {
|
||||
STACK_ALLOCATED();
|
||||
public:
|
||||
explicit LinkRequestBuilder(HTMLLinkElement* owner);
|
||||
|
||||
bool isValid() const { return !m_url.isEmpty() && m_url.isValid(); }
|
||||
const KURL& url() const { return m_url; }
|
||||
const AtomicString& charset() const { return m_charset; }
|
||||
FetchRequest build(bool blocking) const;
|
||||
|
||||
private:
|
||||
RawPtr<HTMLLinkElement> m_owner;
|
||||
KURL m_url;
|
||||
AtomicString m_charset;
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // LinkResource_h
|
||||
@ -33,7 +33,6 @@
|
||||
|
||||
#include "core/dom/DocumentSupplementable.h"
|
||||
#include "core/fetch/RawResource.h"
|
||||
#include "core/html/LinkResource.h"
|
||||
#include "core/html/imports/HTMLImport.h"
|
||||
#include "platform/Supplementable.h"
|
||||
#include "platform/Timer.h"
|
||||
|
||||
@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Google Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "core/html/imports/LinkImport.h"
|
||||
|
||||
#include "core/dom/Document.h"
|
||||
#include "core/html/HTMLLinkElement.h"
|
||||
#include "core/html/imports/HTMLImportChild.h"
|
||||
#include "core/html/imports/HTMLImportLoader.h"
|
||||
#include "core/html/imports/HTMLImportTreeRoot.h"
|
||||
#include "core/html/imports/HTMLImportsController.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
PassOwnPtr<LinkImport> LinkImport::create(HTMLLinkElement* owner)
|
||||
{
|
||||
return adoptPtr(new LinkImport(owner));
|
||||
}
|
||||
|
||||
LinkImport::LinkImport(HTMLLinkElement* owner)
|
||||
: LinkResource(owner)
|
||||
, m_child(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
LinkImport::~LinkImport()
|
||||
{
|
||||
#if !ENABLE(OILPAN)
|
||||
if (m_child) {
|
||||
m_child->clearClient();
|
||||
m_child = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Document* LinkImport::importedDocument() const
|
||||
{
|
||||
if (!m_child || !m_owner || !m_owner->inDocument())
|
||||
return 0;
|
||||
if (m_child->loader()->hasError())
|
||||
return 0;
|
||||
return m_child->document();
|
||||
}
|
||||
|
||||
void LinkImport::process()
|
||||
{
|
||||
if (m_child)
|
||||
return;
|
||||
if (!m_owner)
|
||||
return;
|
||||
if (!shouldLoadResource())
|
||||
return;
|
||||
|
||||
if (!m_owner->document().importsController()) {
|
||||
ASSERT(m_owner->document().frame()); // The document should be the master.
|
||||
HTMLImportsController::provideTo(m_owner->document());
|
||||
}
|
||||
|
||||
LinkRequestBuilder builder(m_owner);
|
||||
if (!builder.isValid()) {
|
||||
didFinish();
|
||||
return;
|
||||
}
|
||||
|
||||
m_child = m_owner->document().importsController()->load(m_owner->document().import(), this, builder.build(true));
|
||||
if (!m_child) {
|
||||
didFinish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void LinkImport::didFinish()
|
||||
{
|
||||
if (!m_owner || !m_owner->inDocument())
|
||||
return;
|
||||
m_owner->scheduleEvent();
|
||||
}
|
||||
|
||||
#if !ENABLE(OILPAN)
|
||||
void LinkImport::importChildWasDestroyed(HTMLImportChild* child)
|
||||
{
|
||||
ASSERT(m_child == child);
|
||||
m_child = nullptr;
|
||||
m_owner = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool LinkImport::isSync() const
|
||||
{
|
||||
return m_owner && !m_owner->async();
|
||||
}
|
||||
|
||||
Element* LinkImport::link()
|
||||
{
|
||||
return m_owner;
|
||||
}
|
||||
|
||||
bool LinkImport::hasLoaded() const
|
||||
{
|
||||
// Should never be called after importChildWasDestroyed was called.
|
||||
ASSERT(m_owner);
|
||||
return m_child && m_child->isDone() && !m_child->loader()->hasError();
|
||||
}
|
||||
|
||||
void LinkImport::ownerInserted()
|
||||
{
|
||||
if (m_child)
|
||||
m_child->ownerInserted();
|
||||
}
|
||||
|
||||
void LinkImport::trace(Visitor* visitor)
|
||||
{
|
||||
visitor->trace(m_child);
|
||||
HTMLImportChildClient::trace(visitor);
|
||||
LinkResource::trace(visitor);
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Google Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LinkImport_h
|
||||
#define LinkImport_h
|
||||
|
||||
#include "core/html/LinkResource.h"
|
||||
#include "core/html/imports/HTMLImportChildClient.h"
|
||||
#include "wtf/FastAllocBase.h"
|
||||
#include "wtf/PassOwnPtr.h"
|
||||
#include "wtf/RefPtr.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class Document;
|
||||
class HTMLImportChild;
|
||||
|
||||
//
|
||||
// A LinkResource subclasss used for @rel=import.
|
||||
//
|
||||
class LinkImport final : public LinkResource, public HTMLImportChildClient {
|
||||
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
|
||||
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LinkImport);
|
||||
public:
|
||||
|
||||
static PassOwnPtr<LinkImport> create(HTMLLinkElement* owner);
|
||||
|
||||
explicit LinkImport(HTMLLinkElement* owner);
|
||||
virtual ~LinkImport();
|
||||
|
||||
// LinkResource
|
||||
virtual void process() override;
|
||||
virtual Type type() const override { return Import; }
|
||||
virtual bool hasLoaded() const override;
|
||||
virtual void trace(Visitor*) override;
|
||||
virtual void ownerInserted() override;
|
||||
|
||||
// HTMLImportChildClient
|
||||
virtual void didFinish() override;
|
||||
#if !ENABLE(OILPAN)
|
||||
virtual void importChildWasDestroyed(HTMLImportChild*) override;
|
||||
#endif
|
||||
virtual bool isSync() const override;
|
||||
virtual Element* link() override;
|
||||
|
||||
Document* importedDocument() const;
|
||||
|
||||
private:
|
||||
RawPtr<HTMLImportChild> m_child;
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // LinkImport_h
|
||||
@ -99,7 +99,6 @@
|
||||
#include "core/frame/LocalDOMWindow.h"
|
||||
#include "core/frame/Settings.h"
|
||||
#include "core/html/HTMLAnchorElement.h"
|
||||
#include "core/html/HTMLLinkElement.h"
|
||||
#include "core/inspector/ConsoleMessage.h"
|
||||
#include "core/inspector/ScriptCallStack.h"
|
||||
#include "core/loader/MojoLoader.h"
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
#include "core/frame/FrameView.h"
|
||||
#include "core/frame/LocalFrame.h"
|
||||
#include "core/frame/Settings.h"
|
||||
#include "core/html/HTMLLinkElement.h"
|
||||
#include "core/html/HTMLImportElement.h"
|
||||
#include "core/html/HTMLMediaElement.h"
|
||||
#include "core/html/ime/InputMethodContext.h"
|
||||
#include "core/loader/FrameLoader.h"
|
||||
@ -1660,12 +1660,11 @@ WebFrame* WebViewImpl::focusedFrame()
|
||||
void WebViewImpl::injectModule(const WebString& path)
|
||||
{
|
||||
RefPtr<Document> document = m_page->mainFrame()->document();
|
||||
RefPtr<HTMLLinkElement> link = HTMLLinkElement::create(*document, false);
|
||||
link->setAttribute(HTMLNames::relAttr, "import");
|
||||
link->setAttribute(HTMLNames::hrefAttr, path);
|
||||
RefPtr<HTMLImportElement> import = HTMLImportElement::create(*document);
|
||||
import->setAttribute(HTMLNames::srcAttr, path);
|
||||
if (!document->documentElement())
|
||||
return;
|
||||
document->documentElement()->appendChild(link.release());
|
||||
document->documentElement()->appendChild(import.release());
|
||||
}
|
||||
|
||||
void WebViewImpl::setFocusedFrame(WebFrame* frame)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user