예제 #1
0
PassRefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString,
    const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame)
{
    RefPtr<Document> ownerDocument = &sourceNode->document();
    bool sourceIsDocument = (sourceNode == ownerDocument.get());
    String documentSource = sourceString;

    RefPtr<Document> result;
    if (sourceMIMEType == "text/plain") {
        result = Document::create(DocumentInit(sourceIsDocument ? ownerDocument->url() : KURL(), frame));
        transformTextStringToXHTMLDocumentString(documentSource);
    } else
        result = DOMImplementation::createDocument(sourceMIMEType, frame, sourceIsDocument ? ownerDocument->url() : KURL(), false);

    // Before parsing, we need to save & detach the old document and get the new document
    // in place. We have to do this only if we're rendering the result document.
    if (frame) {
        if (FrameView* view = frame->view())
            view->clear();

        if (Document* oldDocument = frame->document()) {
            result->setTransformSourceDocument(oldDocument);
            result->setSecurityOrigin(oldDocument->securityOrigin());
            result->setCookieURL(oldDocument->cookieURL());
            result->contentSecurityPolicy()->copyStateFrom(oldDocument->contentSecurityPolicy());
        }

        frame->domWindow()->setDocument(result);
    }

    result->setEncoding(sourceEncoding.isEmpty() ? UTF8Encoding() : WTF::TextEncoding(sourceEncoding));
    result->setContent(documentSource);

    return result.release();
}
예제 #2
0
HTMLImportLoader::State HTMLImportLoader::startWritingAndParsing(const ResourceResponse& response)
{
    DocumentInit init = DocumentInit(response.url(), 0, m_import->master()->contextDocument(), m_import)
        .withRegistrationContext(m_import->master()->registrationContext());
    m_importedDocument = HTMLDocument::create(init);
    m_writer = DocumentWriter::create(m_importedDocument.get(), response.mimeType(), response.textEncodingName());

    return StateLoading;
}
예제 #3
0
HTMLImportLoader::State HTMLImportLoader::startWritingAndParsing(const ResourceResponse& response)
{
    ASSERT(!m_imports.isEmpty());
    DocumentInit init = DocumentInit(response.url(), 0, m_controller->master()->contextDocument(), m_controller)
        .withRegistrationContext(m_controller->master()->registrationContext());
    m_document = HTMLDocument::create(init);
    m_writer = DocumentWriter::create(m_document.get(), response.mimeType(), "UTF-8");

    return StateLoading;
}
예제 #4
0
HTMLImportLoader::State HTMLImportLoader::startWritingAndParsing(mojo::URLResponsePtr response)
{
    ASSERT(!m_imports.isEmpty());
    KURL url(ParsedURLString, String::fromUTF8(response->url));
    DocumentInit init = DocumentInit(url, 0, m_controller->master()->contextDocument(), m_controller)
        .withRegistrationContext(m_controller->master()->registrationContext());
    m_document = HTMLDocument::create(init);
    m_document->startParsing();
    m_document->parser()->parse(response->body.Pass());
    return StateLoading;
}
PassRefPtr<Document> DocumentResource::createDocument(const KURL& url)
{
    switch (type()) {
    case SVGDocument:
        return SVGDocument::create(DocumentInit(url));
    default:
        // FIXME: We'll add more types to support HTMLImports.
        ASSERT_NOT_REACHED();
        return 0;
    }
}
예제 #6
0
HTMLImportLoader::State HTMLImportLoader::startWritingAndParsing(const ResourceResponse& response)
{
    // Current canAccess() implementation isn't sufficient for catching cross-domain redirects: http://crbug.com/256976
    if (!m_parent->document()->fetcher()->canAccess(m_resource.get()))
        return StateError;

    DocumentInit init = DocumentInit(response.url(), 0, root()->document()->contextDocument(), this)
        .withRegistrationContext(root()->document()->registrationContext());
    m_importedDocument = HTMLDocument::create(init);
    m_importedDocument->initContentSecurityPolicy(ContentSecurityPolicyResponseHeaders(response));
    m_writer = DocumentWriter::create(m_importedDocument.get(), response.mimeType(), response.textEncodingName());

    return StateLoading;
}
예제 #7
0
PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame* frame, const KURL& url, bool inViewSourceMode)
{
    return createDocument(type, DocumentInit(url, frame), inViewSourceMode);
}
예제 #8
0
DocumentInit DocumentInit::fromContext(WeakPtrWillBeRawPtr<Document> contextDocument, const KURL& url)
{
    return DocumentInit(url, 0, contextDocument, 0);
}
예제 #9
0
PassRefPtrWillBeRawPtr<Document> DOMParser::parseFromString(const String& str, const String& type)
{
    RefPtrWillBeRawPtr<Document> doc = DOMImplementation::createDocument(type, DocumentInit(KURL(), nullptr, m_contextDocument), false);
    doc->setContent(str);
    return doc.release();
}
예제 #10
0
DocumentInit DocumentInit::fromContext(Document* contextDocument, const KURL& url)
{
    return DocumentInit(url, 0, contextDocument, 0);
}