Ejemplo n.º 1
0
bool SVGImage::dataChanged(bool allDataReceived)
{
    int length = m_data->size();
    if (!length) // if this was an empty image
        return true;
    
    if (allDataReceived) {
        static ChromeClient* dummyChromeClient = new SVGEmptyChromeClient;
        static FrameLoaderClient* dummyFrameLoaderClient =  new SVGEmptyFrameLoaderClient;
        static EditorClient* dummyEditorClient = new SVGEmptyEditorClient;
        static ContextMenuClient* dummyContextMenuClient = new SVGEmptyContextMenuClient;
        static DragClient* dummyDragClient = new SVGEmptyDragClient;

        // FIXME: If this SVG ends up loading itself, we'll leak this Frame (and associated DOM & render trees).
        // The Cache code does not know about CachedImages holding Frames and won't know to break the cycle.
        m_page.set(new Page(dummyChromeClient, dummyContextMenuClient, dummyEditorClient, dummyDragClient));
        m_frame = new Frame(m_page.get(), 0, dummyFrameLoaderClient);
        m_frame->init();
        m_frameView = new FrameView(m_frame.get());
        m_frameView->deref(); // FIXME: FrameView starts with a refcount of 1
        m_frame->setView(m_frameView.get());
        ResourceRequest fakeRequest(KURL(""));
        m_frame->loader()->load(fakeRequest); // Make sure the DocumentLoader is created
        m_frame->loader()->cancelContentPolicyCheck(); // cancel any policy checks
        m_frame->loader()->commitProvisionalLoad(0);
        m_frame->loader()->setResponseMIMEType("image/svg+xml");
        m_frame->loader()->begin("placeholder.svg"); // create the empty document
        m_frame->loader()->write(m_data->data(), m_data->size());
        m_frame->loader()->end();
    }
    return m_frameView;
}
Ejemplo n.º 2
0
bool SVGImage::dataChanged(bool allDataReceived)
{
    // Don't do anything if is an empty image.
    if (!data()->size())
        return true;

    if (allDataReceived) {
        static FrameLoaderClient* dummyFrameLoaderClient =  new EmptyFrameLoaderClient;

        Page::PageClients pageClients;
        m_chromeClient = adoptPtr(new SVGImageChromeClient(this));
        pageClients.chromeClient = m_chromeClient.get();
#if ENABLE(CONTEXT_MENUS)
        static ContextMenuClient* dummyContextMenuClient = new EmptyContextMenuClient;
        pageClients.contextMenuClient = dummyContextMenuClient;
#endif
        static EditorClient* dummyEditorClient = new EmptyEditorClient;
        pageClients.editorClient = dummyEditorClient;
#if ENABLE(DRAG_SUPPORT)
        static DragClient* dummyDragClient = new EmptyDragClient;
        pageClients.dragClient = dummyDragClient;
#endif
        static InspectorClient* dummyInspectorClient = new EmptyInspectorClient;
        pageClients.inspectorClient = dummyInspectorClient;
#if ENABLE(DEVICE_ORIENTATION)
        static DeviceMotionClient* dummyDeviceMotionClient = new EmptyDeviceMotionClient;
        pageClients.deviceMotionClient = dummyDeviceMotionClient;
        static DeviceOrientationClient* dummyDeviceOrientationClient = new EmptyDeviceOrientationClient;
        pageClients.deviceOrientationClient = dummyDeviceOrientationClient;
#endif

        // FIXME: If this SVG ends up loading itself, we might leak the world.
        // The comment said that the Cache code does not know about CachedImages
        // holding Frames and won't know to break the cycle. But 
        m_page.set(new Page(pageClients));
        m_page->settings()->setMediaEnabled(false);
        m_page->settings()->setJavaScriptEnabled(false);
        m_page->settings()->setPluginsEnabled(false);

        RefPtr<Frame> frame = Frame::create(m_page.get(), 0, dummyFrameLoaderClient);
        frame->setView(FrameView::create(frame.get()));
        frame->init();
        ResourceRequest fakeRequest(KURL(ParsedURLString, ""));
        FrameLoader* loader = frame->loader();
        loader->setForcedSandboxFlags(SandboxAll);
        loader->load(fakeRequest, false); // Make sure the DocumentLoader is created
        loader->policyChecker()->cancelCheck(); // cancel any policy checks
        loader->commitProvisionalLoad();
        loader->writer()->setMIMEType("image/svg+xml");
        loader->writer()->begin(KURL()); // create the empty document
        loader->writer()->addData(data()->data(), data()->size());
        loader->writer()->end();
        frame->view()->setTransparent(true); // SVG Images are transparent.
    }

    return m_page;
}
Ejemplo n.º 3
0
bool SVGImage::dataChanged(bool allDataReceived)
{
    int length = m_data->size();
    if (!length) // if this was an empty image
        return true;
    
    if (allDataReceived) {
        static FrameLoaderClient* dummyFrameLoaderClient =  new EmptyFrameLoaderClient;
        static EditorClient* dummyEditorClient = new EmptyEditorClient;
        static ContextMenuClient* dummyContextMenuClient = new EmptyContextMenuClient;
        static DragClient* dummyDragClient = new EmptyDragClient;
#if ENABLE(INSPECTOR)
        static InspectorClient* dummyInspectorClient = new EmptyInspectorClient;
#endif

        m_chromeClient.set(new SVGImageChromeClient(this));
        
        // FIXME: If this SVG ends up loading itself, we'll leak this Frame (and associated DOM & render trees).
        // The Cache code does not know about CachedImages holding Frames and won't know to break the cycle.
#if ENABLE(INSPECTOR)
        m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient));
#else
        m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, 0));
#endif
        m_page->settings()->setJavaScriptEnabled(false);
        m_page->settings()->setPluginsEnabled(false);

        m_frame = Frame::create(m_page.get(), 0, dummyFrameLoaderClient);
        m_frameView = new FrameView(m_frame.get());
        m_frameView->deref(); // FIXME: FrameView starts with a refcount of 1
        m_frame->setView(m_frameView.get());
        m_frame->init();
        ResourceRequest fakeRequest(KURL(""));
        m_frame->loader()->load(fakeRequest, false); // Make sure the DocumentLoader is created
        m_frame->loader()->cancelContentPolicyCheck(); // cancel any policy checks
        m_frame->loader()->commitProvisionalLoad(0);
        m_frame->loader()->setResponseMIMEType("image/svg+xml");
        m_frame->loader()->begin(KURL()); // create the empty document
        m_frame->loader()->write(m_data->data(), m_data->size());
        m_frame->loader()->end();
        m_frameView->setTransparent(true); // SVG Images are transparent.
    }
    return m_frameView;
}