コード例 #1
0
DummyPageHolder::DummyPageHolder(
    const IntSize& initialViewSize,
    Page::PageClients* pageClients,
    PassOwnPtr<FrameLoaderClient> frameLoaderClient)
{
    if (!pageClients) {
        fillWithEmptyClients(m_pageClients);
    } else {
        m_pageClients.chromeClient = pageClients->chromeClient;
        m_pageClients.contextMenuClient = pageClients->contextMenuClient;
        m_pageClients.editorClient = pageClients->editorClient;
        m_pageClients.dragClient = pageClients->dragClient;
        m_pageClients.spellCheckerClient = pageClients->spellCheckerClient;
    }
    m_page = adoptPtrWillBeNoop(new Page(m_pageClients));
    Settings& settings = m_page->settings();
    // FIXME: http://crbug.com/363843. This needs to find a better way to
    // not create graphics layers.
    settings.setAcceleratedCompositingEnabled(false);

    m_frameLoaderClient = frameLoaderClient;
    if (!m_frameLoaderClient)
        m_frameLoaderClient = adoptPtr(new EmptyFrameLoaderClient);

    m_frame = LocalFrame::create(m_frameLoaderClient.get(), &m_page->frameHost(), 0);
    m_frame->setView(FrameView::create(m_frame.get(), initialViewSize));
    m_frame->init();
}
コード例 #2
0
DummyPageHolder::DummyPageHolder(const IntSize& initialViewSize,
                                 Page::PageClients* pageClientsArgument,
                                 FrameLoaderClient* frameLoaderClient,
                                 FrameSettingOverrideFunction settingOverrider,
                                 InterfaceProvider* interfaceProvider) {
  Page::PageClients pageClients;
  if (!pageClientsArgument) {
    fillWithEmptyClients(pageClients);
  } else {
    pageClients.chromeClient = pageClientsArgument->chromeClient;
    pageClients.contextMenuClient = pageClientsArgument->contextMenuClient;
    pageClients.editorClient = pageClientsArgument->editorClient;
    pageClients.spellCheckerClient = pageClientsArgument->spellCheckerClient;
  }
  m_page = Page::create(pageClients);
  Settings& settings = m_page->settings();
  // FIXME: http://crbug.com/363843. This needs to find a better way to
  // not create graphics layers.
  settings.setAcceleratedCompositingEnabled(false);
  if (settingOverrider)
    (*settingOverrider)(settings);

  m_frameLoaderClient = frameLoaderClient;
  if (!m_frameLoaderClient)
    m_frameLoaderClient = EmptyFrameLoaderClient::create();

  m_frame = LocalFrame::create(m_frameLoaderClient.get(), &m_page->frameHost(),
                               nullptr, interfaceProvider);
  m_frame->setView(FrameView::create(*m_frame, initialViewSize));
  m_frame->view()->page()->frameHost().visualViewport().setSize(
      initialViewSize);
  m_frame->init();
}
コード例 #3
0
Page* InspectorOverlay::overlayPage()
{
    if (m_overlayPage)
        return m_overlayPage.get();

    static FrameLoaderClient* dummyFrameLoaderClient =  new EmptyFrameLoaderClient;
    Page::PageClients pageClients;
    fillWithEmptyClients(pageClients);
    ASSERT(!m_overlayChromeClient);
    m_overlayChromeClient = adoptPtr(new InspectorOverlayChromeClient(m_page->chrome().client(), this));
    pageClients.chromeClient = m_overlayChromeClient.get();
    m_overlayPage = adoptPtr(new Page(pageClients));
    m_overlayPage->setGroupType(Page::InspectorPageGroup);

    Settings* settings = m_page->settings();
    Settings* overlaySettings = m_overlayPage->settings();

    overlaySettings->setStandardFontFamily(settings->standardFontFamily());
    overlaySettings->setSerifFontFamily(settings->serifFontFamily());
    overlaySettings->setSansSerifFontFamily(settings->sansSerifFontFamily());
    overlaySettings->setCursiveFontFamily(settings->cursiveFontFamily());
    overlaySettings->setFantasyFontFamily(settings->fantasyFontFamily());
    overlaySettings->setPictographFontFamily(settings->pictographFontFamily());
    overlaySettings->setMinimumFontSize(settings->minimumFontSize());
    overlaySettings->setMinimumLogicalFontSize(settings->minimumLogicalFontSize());
    overlaySettings->setMediaEnabled(false);
    overlaySettings->setScriptEnabled(true);
    overlaySettings->setPluginsEnabled(false);
    overlaySettings->setLoadsImagesAutomatically(true);

    RefPtr<Frame> frame = Frame::create(m_overlayPage.get(), 0, dummyFrameLoaderClient);
    frame->setView(FrameView::create(frame.get()));
    frame->init();
    FrameLoader* loader = frame->loader();
    frame->view()->setCanHaveScrollbars(false);
    frame->view()->setTransparent(true);
    ASSERT(loader->activeDocumentLoader());
    loader->activeDocumentLoader()->writer()->setMIMEType("text/html");
    loader->activeDocumentLoader()->writer()->begin();
    loader->activeDocumentLoader()->writer()->addData(reinterpret_cast<const char*>(InspectorOverlayPage_html), sizeof(InspectorOverlayPage_html));
    loader->activeDocumentLoader()->writer()->end();

    v8::HandleScope handleScope;
    v8::Handle<v8::Context> frameContext = frame->script()->currentWorldContext();
    v8::Context::Scope contextScope(frameContext);
    v8::Handle<v8::Value> overlayHostObj = toV8(m_overlayHost.get(), v8::Handle<v8::Object>(), frameContext->GetIsolate());
    v8::Handle<v8::Object> global = frameContext->Global();
    global->Set(v8::String::New("InspectorOverlayHost"), overlayHostObj);

#if OS(WINDOWS)
    evaluateInOverlay("setPlatform", "windows");
#elif OS(DARWIN)
    evaluateInOverlay("setPlatform", "mac");
#elif OS(UNIX)
    evaluateInOverlay("setPlatform", "linux");
#endif

    return m_overlayPage.get();
}
コード例 #4
0
void HTMLSelectElementTest::SetUp() {
  Page::PageClients pageClients;
  fillWithEmptyClients(pageClients);
  m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients);

  m_document = &m_dummyPageHolder->document();
  m_document->setMimeType("text/html");
}
コード例 #5
0
void HTMLFormControlElementTest::SetUp()
{
    Page::PageClients pageClients;
    fillWithEmptyClients(pageClients);
    m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients);

    m_document = toHTMLDocument(&m_dummyPageHolder->document());
    m_document->setMimeType("text/html");
    m_document->setCharset("utf-8");
}
コード例 #6
0
RenderingTest::RenderingTest(PassOwnPtrWillBeRawPtr<FrameLoaderClient> frameLoaderClient)
{
    Page::PageClients pageClients;
    fillWithEmptyClients(pageClients);
    DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<FakeChromeClient>, chromeClient, (FakeChromeClient::create()));
    pageClients.chromeClient = chromeClient.get();
    m_pageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients, frameLoaderClient, settingOverrider());

    Settings::setMockScrollbarsEnabled(true);
    RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true);
    EXPECT_TRUE(ScrollbarTheme::theme().usesOverlayScrollbars());
}
コード例 #7
0
ファイル: ImageDocumentTest.cpp プロジェクト: mirror/chromium
void ImageDocumentTest::createDocumentWithoutLoadingImage(int viewWidth,
                                                          int viewHeight) {
  Page::PageClients pageClients;
  fillWithEmptyClients(pageClients);
  m_chromeClient = new WindowToViewportScalingChromeClient();
  pageClients.chromeClient = m_chromeClient;
  m_dummyPageHolder =
      DummyPageHolder::create(IntSize(viewWidth, viewHeight), &pageClients);

  LocalFrame& frame = m_dummyPageHolder->frame();
  frame.document()->shutdown();
  DocumentInit init(KURL(), &frame);
  frame.localDOMWindow()->installNewDocument("image/jpeg", init);
}
コード例 #8
0
void CanvasFontCacheTest::SetUp()
{
    Page::PageClients pageClients;
    fillWithEmptyClients(pageClients);
    m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients);
    m_document = toHTMLDocument(&m_dummyPageHolder->document());
    m_document->documentElement()->setInnerHTML("<body><canvas id='c'></canvas></body>", ASSERT_NO_EXCEPTION);
    m_document->view()->updateAllLifecyclePhases();
    m_canvasElement = toHTMLCanvasElement(m_document->getElementById("c"));
    String canvasType("2d");
    CanvasContextCreationAttributes attributes;
    attributes.setAlpha(true);
    m_canvasElement->getCanvasRenderingContext(canvasType, attributes);
    context2d(); // Calling this for the checks
}
コード例 #9
0
void HTMLTextFormControlElementTest::SetUp()
{
    Page::PageClients pageClients;
    fillWithEmptyClients(pageClients);
    m_spellCheckerClient = wrapUnique(new DummySpellCheckerClient);
    pageClients.spellCheckerClient = m_spellCheckerClient.get();
    m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients);

    m_document = toHTMLDocument(&m_dummyPageHolder->document());
    m_document->documentElement()->setInnerHTML("<body><textarea id=textarea></textarea><input id=input /></body>", ASSERT_NO_EXCEPTION);
    m_document->view()->updateAllLifecyclePhases();
    m_textControl = toHTMLTextFormControlElement(m_document->getElementById("textarea"));
    m_textControl->focus();
    m_input = toHTMLInputElement(m_document->getElementById("input"));
}
コード例 #10
0
bool WebPagePopupImpl::initializePage() {
  Page::PageClients pageClients;
  fillWithEmptyClients(pageClients);
  m_chromeClient = PagePopupChromeClient::create(this);
  pageClients.chromeClient = m_chromeClient.get();

  Settings& mainSettings = m_webView->page()->settings();
  m_page = Page::create(pageClients);
  m_page->settings().setScriptEnabled(true);
  m_page->settings().setAllowScriptsToCloseWindows(true);
  m_page->settings().setDeviceSupportsTouch(mainSettings.deviceSupportsTouch());
  m_page->settings().setMinimumFontSize(mainSettings.minimumFontSize());
  m_page->settings().setMinimumLogicalFontSize(
      mainSettings.minimumLogicalFontSize());
  // FIXME: Should we support enabling a11y while a popup is shown?
  m_page->settings().setAccessibilityEnabled(
      mainSettings.accessibilityEnabled());
  m_page->settings().setScrollAnimatorEnabled(
      mainSettings.scrollAnimatorEnabled());

  provideContextFeaturesTo(*m_page, WTF::makeUnique<PagePopupFeaturesClient>());
  DEFINE_STATIC_LOCAL(FrameLoaderClient, emptyFrameLoaderClient,
                      (EmptyFrameLoaderClient::create()));
  LocalFrame* frame =
      LocalFrame::create(&emptyFrameLoaderClient, &m_page->frameHost(), 0);
  frame->setPagePopupOwner(m_popupClient->ownerElement());
  frame->setView(FrameView::create(*frame));
  frame->init();
  frame->view()->setParentVisible(true);
  frame->view()->setSelfVisible(true);
  frame->view()->setTransparent(false);
  if (AXObjectCache* cache =
          m_popupClient->ownerElement().document().existingAXObjectCache())
    cache->childrenChanged(&m_popupClient->ownerElement());

  DCHECK(frame->domWindow());
  PagePopupSupplement::install(*frame, *this, m_popupClient);
  DCHECK_EQ(m_popupClient->ownerElement().document().existingAXObjectCache(),
            frame->document()->existingAXObjectCache());

  RefPtr<SharedBuffer> data = SharedBuffer::create();
  m_popupClient->writeDocument(data.get());
  frame->loader().load(FrameLoadRequest(
      0, blankURL(), SubstituteData(data, "text/html", "UTF-8", KURL(),
                                    ForceSynchronousLoad)));
  frame->setPageZoomFactor(m_popupClient->zoomFactor());
  return true;
}
コード例 #11
0
bool SVGImage::dataChanged(bool allDataReceived)
{
    TRACE_EVENT0("webkit", "SVGImage::dataChanged");

    // Don't do anything if is an empty image.
    if (!data()->size())
        return true;

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

        Page::PageClients pageClients;
        fillWithEmptyClients(pageClients);
        m_chromeClient = adoptPtr(new SVGImageChromeClient(this));
        pageClients.chromeClient = m_chromeClient.get();

        // FIXME: If this SVG ends up loading itself, we might leak the world.
        // The Cache code does not know about ImageResources holding Frames and
        // won't know to break the cycle.
        // This will become an issue when SVGImage will be able to load other
        // SVGImage objects, but we're safe now, because SVGImage can only be
        // loaded by a top-level document.
        m_page = adoptPtr(new Page(pageClients));
        m_page->settings().setMediaEnabled(false);
        m_page->settings().setScriptEnabled(false);
        m_page->settings().setPluginsEnabled(false);
        m_page->settings().setAcceleratedCompositingEnabled(false);

        RefPtr<Frame> frame = Frame::create(FrameInit::create(0, m_page.get(), dummyFrameLoaderClient));
        frame->setView(FrameView::create(frame.get()));
        frame->init();
        FrameLoader& loader = frame->loader();
        loader.forceSandboxFlags(SandboxAll);

        frame->view()->setScrollbarsSuppressed(true);
        frame->view()->setCanHaveScrollbars(false); // SVG Images will always synthesize a viewBox, if it's not available, and thus never see scrollbars.
        frame->view()->setTransparent(true); // SVG Images are transparent.

        ASSERT(loader.activeDocumentLoader()); // DocumentLoader should have been created by frame->init().
        DocumentWriter* writer = loader.activeDocumentLoader()->beginWriting("image/svg+xml", "UTF-8");
        writer->addData(data()->data(), data()->size());
        loader.activeDocumentLoader()->endWriting(writer);
        // Set the intrinsic size before a container size is available.
        m_intrinsicSize = containerSize();
    }

    return m_page;
}
コード例 #12
0
void RenderingTest::SetUp()
{
    Page::PageClients pageClients;
    fillWithEmptyClients(pageClients);
    DEFINE_STATIC_LOCAL(EmptyChromeClient, chromeClient, (EmptyChromeClient::create()));
    pageClients.chromeClient = &chromeClient;
    m_pageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients, m_frameLoaderClient.release(), settingOverrider());

    Settings::setMockScrollbarsEnabled(true);
    RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true);
    EXPECT_TRUE(ScrollbarTheme::theme().usesOverlayScrollbars());

    // This ensures that the minimal DOM tree gets attached
    // correctly for tests that don't call setBodyInnerHTML.
    document().view()->updateAllLifecyclePhases();
}
コード例 #13
0
Page* InspectorOverlay::overlayPage()
{
    if (m_overlayPage)
        return m_overlayPage.get();

    static FrameLoaderClient* dummyFrameLoaderClient =  new EmptyFrameLoaderClient;
    Page::PageClients pageClients;
    fillWithEmptyClients(pageClients);
    m_overlayPage = adoptPtr(new Page(pageClients));

    Settings* settings = m_page->settings();
    Settings* overlaySettings = m_overlayPage->settings();

    overlaySettings->setStandardFontFamily(settings->standardFontFamily());
    overlaySettings->setSerifFontFamily(settings->serifFontFamily());
    overlaySettings->setSansSerifFontFamily(settings->sansSerifFontFamily());
    overlaySettings->setCursiveFontFamily(settings->cursiveFontFamily());
    overlaySettings->setFantasyFontFamily(settings->fantasyFontFamily());
    overlaySettings->setPictographFontFamily(settings->pictographFontFamily());
    overlaySettings->setMinimumFontSize(settings->minimumFontSize());
    overlaySettings->setMinimumLogicalFontSize(settings->minimumLogicalFontSize());
    overlaySettings->setMediaEnabled(false);
    overlaySettings->setScriptEnabled(true);
    overlaySettings->setPluginsEnabled(false);

    RefPtr<Frame> frame = Frame::create(m_overlayPage.get(), 0, dummyFrameLoaderClient);
    frame->setView(FrameView::create(frame.get()));
    frame->init();
    FrameLoader* loader = frame->loader();
    frame->view()->setCanHaveScrollbars(false);
    frame->view()->setTransparent(true);
    ASSERT(loader->activeDocumentLoader());
    loader->activeDocumentLoader()->writer()->setMIMEType("text/html");
    loader->activeDocumentLoader()->writer()->begin();
    loader->activeDocumentLoader()->writer()->addData(reinterpret_cast<const char*>(InspectorOverlayPage_html), sizeof(InspectorOverlayPage_html));
    loader->activeDocumentLoader()->writer()->end();

#if OS(WINDOWS)
    evaluateInOverlay("setPlatform", "windows");
#elif OS(MAC_OS_X)
    evaluateInOverlay("setPlatform", "mac");
#elif OS(UNIX)
    evaluateInOverlay("setPlatform", "linux");
#endif

    return m_overlayPage.get();
}
コード例 #14
0
ファイル: SVGImage.cpp プロジェクト: endlessm/WebKit
bool SVGImage::dataChanged(bool allDataReceived)
{
    // Don't do anything if is an empty image.
    if (!data()->size())
        return true;

    if (allDataReceived) {
        PageConfiguration pageConfiguration(makeUniqueRef<EmptyEditorClient>(), SocketProvider::create());
        fillWithEmptyClients(pageConfiguration);
        m_chromeClient = std::make_unique<SVGImageChromeClient>(this);
        pageConfiguration.chromeClient = m_chromeClient.get();

        // FIXME: If this SVG ends up loading itself, we might leak the world.
        // The Cache code does not know about CachedImages holding Frames and
        // won't know to break the cycle.
        // This will become an issue when SVGImage will be able to load other
        // SVGImage objects, but we're safe now, because SVGImage can only be
        // loaded by a top-level document.
        m_page = std::make_unique<Page>(WTFMove(pageConfiguration));
        m_page->settings().setMediaEnabled(false);
        m_page->settings().setScriptEnabled(false);
        m_page->settings().setPluginsEnabled(false);
        m_page->settings().setAcceleratedCompositingEnabled(false);

        Frame& frame = m_page->mainFrame();
        frame.setView(FrameView::create(frame));
        frame.init();
        FrameLoader& loader = frame.loader();
        loader.forceSandboxFlags(SandboxAll);

        frame.view()->setCanHaveScrollbars(false); // SVG Images will always synthesize a viewBox, if it's not available, and thus never see scrollbars.
        frame.view()->setTransparent(true); // SVG Images are transparent.

        ASSERT(loader.activeDocumentLoader()); // DocumentLoader should have been created by frame->init().
        loader.activeDocumentLoader()->writer().setMIMEType("image/svg+xml");
        loader.activeDocumentLoader()->writer().begin(URL()); // create the empty document
        loader.activeDocumentLoader()->writer().addData(data()->data(), data()->size());
        loader.activeDocumentLoader()->writer().end();

        // Set the intrinsic size before a container size is available.
        m_intrinsicSize = containerSize();
        reportApproximateMemoryCost();
    }

    return m_page != nullptr;
}
コード例 #15
0
ファイル: InspectorOverlay.cpp プロジェクト: aosm/WebCore
Page* InspectorOverlay::overlayPage()
{
    if (m_overlayPage)
        return m_overlayPage.get();

    Page::PageClients pageClients;
    fillWithEmptyClients(pageClients);
    m_overlayPage = std::make_unique<Page>(pageClients);

    Settings& settings = m_page.settings();
    Settings& overlaySettings = m_overlayPage->settings();

    overlaySettings.setStandardFontFamily(settings.standardFontFamily());
    overlaySettings.setSerifFontFamily(settings.serifFontFamily());
    overlaySettings.setSansSerifFontFamily(settings.sansSerifFontFamily());
    overlaySettings.setCursiveFontFamily(settings.cursiveFontFamily());
    overlaySettings.setFantasyFontFamily(settings.fantasyFontFamily());
    overlaySettings.setPictographFontFamily(settings.pictographFontFamily());
    overlaySettings.setMinimumFontSize(settings.minimumFontSize());
    overlaySettings.setMinimumLogicalFontSize(settings.minimumLogicalFontSize());
    overlaySettings.setMediaEnabled(false);
    overlaySettings.setScriptEnabled(true);
    overlaySettings.setPluginsEnabled(false);

    Frame& frame = m_overlayPage->mainFrame();
    frame.setView(FrameView::create(frame));
    frame.init();
    FrameLoader& loader = frame.loader();
    frame.view()->setCanHaveScrollbars(false);
    frame.view()->setTransparent(true);
    ASSERT(loader.activeDocumentLoader());
    loader.activeDocumentLoader()->writer().setMIMEType("text/html");
    loader.activeDocumentLoader()->writer().begin();
    loader.activeDocumentLoader()->writer().addData(reinterpret_cast<const char*>(InspectorOverlayPage_html), sizeof(InspectorOverlayPage_html));
    loader.activeDocumentLoader()->writer().end();

#if OS(WINDOWS)
    evaluateInOverlay("setPlatform", "windows");
#elif OS(MAC_OS_X)
    evaluateInOverlay("setPlatform", "mac");
#elif OS(UNIX)
    evaluateInOverlay("setPlatform", "linux");
#endif

    return m_overlayPage.get();
}
コード例 #16
0
bool SVGImage::dataChanged(bool allDataReceived)
{
    TRACE_EVENT0("webkit", "SVGImage::dataChanged");

    // Don't do anything if is an empty image.
    if (!data()->size())
        return true;

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

        Page::PageClients pageClients;
        fillWithEmptyClients(pageClients);
        m_chromeClient = adoptPtr(new SVGImageChromeClient(this));
        pageClients.chromeClient = m_chromeClient.get();

        // FIXME: If this SVG ends up loading itself, we might leak the world.
        // The Cache code does not know about ImageResources holding Frames and
        // won't know to break the cycle.
        // This will become an issue when SVGImage will be able to load other
        // SVGImage objects, but we're safe now, because SVGImage can only be
        // loaded by a top-level document.
        OwnPtr<Page> page = adoptPtr(new Page(pageClients));
        page->settings().setScriptEnabled(false);
        page->settings().setPluginsEnabled(false);
        page->settings().setAcceleratedCompositingEnabled(false);

        RefPtr<LocalFrame> frame = LocalFrame::create(dummyFrameLoaderClient, &page->frameHost(), 0);
        frame->setView(FrameView::create(frame.get()));
        frame->init();
        FrameLoader& loader = frame->loader();
        loader.forceSandboxFlags(SandboxAll);

        frame->view()->setScrollbarsSuppressed(true);
        frame->view()->setCanHaveScrollbars(false); // SVG Images will always synthesize a viewBox, if it's not available, and thus never see scrollbars.
        frame->view()->setTransparent(true); // SVG Images are transparent.

        m_page = page.release();

        loader.load(FrameLoadRequest(0, blankURL(), SubstituteData(data(), "image/svg+xml", "UTF-8", KURL(), ForceSynchronousLoad)));
        // Set the intrinsic size before a container size is available.
        m_intrinsicSize = containerSize();
    }

    return m_page;
}
コード例 #17
0
bool SVGImage::dataChanged(bool allDataReceived)
{
    // Don't do anything if is an empty image.
    if (!data()->size())
        return true;

    if (allDataReceived) {
        Page::PageClients pageClients;
        fillWithEmptyClients(pageClients);
        m_chromeClient = adoptPtr(new SVGImageChromeClient(this));
        pageClients.chromeClient = m_chromeClient.get();

        // FIXME: If this SVG ends up loading itself, we might leak the world.
        // The Cache code does not know about CachedImages holding Frames and
        // won't know to break the cycle.
        // This will become an issue when SVGImage will be able to load other
        // SVGImage objects, but we're safe now, because SVGImage can only be
        // loaded by a top-level document.
        m_page = adoptPtr(new Page(pageClients));
        m_page->settings().setMediaEnabled(false);
        m_page->settings().setScriptEnabled(false);
        m_page->settings().setPluginsEnabled(false);

        Frame& frame = m_page->mainFrame();
        frame.setView(FrameView::create(&frame));
        frame.init();
        FrameLoader& loader = frame.loader();
        loader.forceSandboxFlags(SandboxAll);

        frame.view()->setCanHaveScrollbars(false); // SVG Images will always synthesize a viewBox, if it's not available, and thus never see scrollbars.
        frame.view()->setTransparent(true); // SVG Images are transparent.

        ASSERT(loader.activeDocumentLoader()); // DocumentLoader should have been created by frame->init().
        loader.activeDocumentLoader()->writer()->setMIMEType("image/svg+xml");
        loader.activeDocumentLoader()->writer()->begin(KURL()); // create the empty document
        loader.activeDocumentLoader()->writer()->addData(data()->data(), data()->size());
        loader.activeDocumentLoader()->writer()->end();

        // Set the intrinsic size before a container size is available.
        m_intrinsicSize = containerSize();
    }

    return m_page;
}
コード例 #18
0
bool WebPagePopupImpl::initializePage()
{
    Page::PageClients pageClients;
    fillWithEmptyClients(pageClients);
    m_chromeClient = PagePopupChromeClient::create(this);
    pageClients.chromeClient = m_chromeClient.get();

    m_page = adoptPtrWillBeNoop(new Page(pageClients));
    m_page->settings().setScriptEnabled(true);
    m_page->settings().setAllowScriptsToCloseWindows(true);
    m_page->setDeviceScaleFactor(m_webView->deviceScaleFactor());
    m_page->settings().setDeviceSupportsTouch(m_webView->page()->settings().deviceSupportsTouch());
    // FIXME: Should we support enabling a11y while a popup is shown?
    m_page->settings().setAccessibilityEnabled(m_webView->page()->settings().accessibilityEnabled());
    m_page->settings().setScrollAnimatorEnabled(m_webView->page()->settings().scrollAnimatorEnabled());

    provideContextFeaturesTo(*m_page, adoptPtr(new PagePopupFeaturesClient()));
    DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<FrameLoaderClient>, emptyFrameLoaderClient, (EmptyFrameLoaderClient::create()));
    RefPtrWillBeRawPtr<LocalFrame> frame = LocalFrame::create(emptyFrameLoaderClient.get(), &m_page->frameHost(), 0);
    frame->setPagePopupOwner(m_popupClient->ownerElement());
    frame->setView(FrameView::create(frame.get()));
    frame->init();
    frame->view()->resize(m_popupClient->contentSize());
    frame->view()->setTransparent(false);
    if (AXObjectCache* cache = m_popupClient->ownerElement().document().existingAXObjectCache())
        cache->childrenChanged(&m_popupClient->ownerElement());

    ASSERT(frame->localDOMWindow());
    DOMWindowPagePopup::install(*frame->localDOMWindow(), *this, m_popupClient);
    ASSERT(m_popupClient->ownerElement().document().existingAXObjectCache() == frame->document()->existingAXObjectCache());

    RefPtr<SharedBuffer> data = SharedBuffer::create();
    m_popupClient->writeDocument(data.get());
    frame->loader().load(FrameLoadRequest(0, blankURL(), SubstituteData(data, "text/html", "UTF-8", KURL(), ForceSynchronousLoad)));

    return true;
}
コード例 #19
0
ファイル: SVGImage.cpp プロジェクト: howardroark2018/chromium
bool SVGImage::dataChanged(bool allDataReceived)
{
    TRACE_EVENT0("blink", "SVGImage::dataChanged");

    // Don't do anything if is an empty image.
    if (!data()->size())
        return true;

    if (allDataReceived) {
        // SVGImage will fire events (and the default C++ handlers run) but doesn't
        // actually allow script to run so it's fine to call into it. We allow this
        // since it means an SVG data url can synchronously load like other image
        // types.
        EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents;

        DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<FrameLoaderClient>, dummyFrameLoaderClient, (EmptyFrameLoaderClient::create()));

        if (m_page) {
            toLocalFrame(m_page->mainFrame())->loader().load(FrameLoadRequest(0, blankURL(), SubstituteData(data(), AtomicString("image/svg+xml", AtomicString::ConstructFromLiteral),
                AtomicString("UTF-8", AtomicString::ConstructFromLiteral), KURL(), ForceSynchronousLoad)));
            return true;
        }

        Page::PageClients pageClients;
        fillWithEmptyClients(pageClients);
        m_chromeClient = SVGImageChromeClient::create(this);
        pageClients.chromeClient = m_chromeClient.get();

        // FIXME: If this SVG ends up loading itself, we might leak the world.
        // The Cache code does not know about ImageResources holding Frames and
        // won't know to break the cycle.
        // This will become an issue when SVGImage will be able to load other
        // SVGImage objects, but we're safe now, because SVGImage can only be
        // loaded by a top-level document.
        OwnPtrWillBeRawPtr<Page> page;
        {
            TRACE_EVENT0("blink", "SVGImage::dataChanged::createPage");
            page = Page::create(pageClients);
            page->settings().setScriptEnabled(false);
            page->settings().setPluginsEnabled(false);
            page->settings().setAcceleratedCompositingEnabled(false);

            // Because this page is detached, it can't get default font settings
            // from the embedder. Copy over font settings so we have sensible
            // defaults. These settings are fixed and will not update if changed.
            if (!Page::ordinaryPages().isEmpty()) {
                Settings& defaultSettings = (*Page::ordinaryPages().begin())->settings();
                page->settings().genericFontFamilySettings() = defaultSettings.genericFontFamilySettings();
                page->settings().setMinimumFontSize(defaultSettings.minimumFontSize());
                page->settings().setMinimumLogicalFontSize(defaultSettings.minimumLogicalFontSize());
                page->settings().setDefaultFontSize(defaultSettings.defaultFontSize());
                page->settings().setDefaultFixedFontSize(defaultSettings.defaultFixedFontSize());
            }
        }

        RefPtrWillBeRawPtr<LocalFrame> frame = nullptr;
        {
            TRACE_EVENT0("blink", "SVGImage::dataChanged::createFrame");
            frame = LocalFrame::create(dummyFrameLoaderClient.get(), &page->frameHost(), 0);
            frame->setView(FrameView::create(frame.get()));
            frame->init();
        }

        FrameLoader& loader = frame->loader();
        loader.forceSandboxFlags(SandboxAll);

        frame->view()->setScrollbarsSuppressed(true);
        frame->view()->setCanHaveScrollbars(false); // SVG Images will always synthesize a viewBox, if it's not available, and thus never see scrollbars.
        frame->view()->setTransparent(true); // SVG Images are transparent.

        m_page = page.release();

        TRACE_EVENT0("blink", "SVGImage::dataChanged::load");
        loader.load(FrameLoadRequest(0, blankURL(), SubstituteData(data(), AtomicString("image/svg+xml", AtomicString::ConstructFromLiteral),
            AtomicString("UTF-8", AtomicString::ConstructFromLiteral), KURL(), ForceSynchronousLoad)));

        // Set the intrinsic size before a container size is available.
        m_intrinsicSize = containerSize();
    }

    return m_page;
}
コード例 #20
0
Page* InspectorOverlay::overlayPage() {
  if (m_overlayPage)
    return m_overlayPage.get();

  ScriptForbiddenScope::AllowUserAgentScript allowScript;

  DEFINE_STATIC_LOCAL(FrameLoaderClient, dummyFrameLoaderClient,
                      (EmptyFrameLoaderClient::create()));
  Page::PageClients pageClients;
  fillWithEmptyClients(pageClients);
  DCHECK(!m_overlayChromeClient);
  m_overlayChromeClient = InspectorOverlayChromeClient::create(
      m_frameImpl->frame()->host()->chromeClient(), *this);
  pageClients.chromeClient = m_overlayChromeClient.get();
  m_overlayPage = Page::create(pageClients);

  Settings& settings = m_frameImpl->frame()->host()->settings();
  Settings& overlaySettings = m_overlayPage->settings();

  overlaySettings.genericFontFamilySettings().updateStandard(
      settings.genericFontFamilySettings().standard());
  overlaySettings.genericFontFamilySettings().updateSerif(
      settings.genericFontFamilySettings().serif());
  overlaySettings.genericFontFamilySettings().updateSansSerif(
      settings.genericFontFamilySettings().sansSerif());
  overlaySettings.genericFontFamilySettings().updateCursive(
      settings.genericFontFamilySettings().cursive());
  overlaySettings.genericFontFamilySettings().updateFantasy(
      settings.genericFontFamilySettings().fantasy());
  overlaySettings.genericFontFamilySettings().updatePictograph(
      settings.genericFontFamilySettings().pictograph());
  overlaySettings.setMinimumFontSize(settings.minimumFontSize());
  overlaySettings.setMinimumLogicalFontSize(settings.minimumLogicalFontSize());
  overlaySettings.setScriptEnabled(true);
  overlaySettings.setPluginsEnabled(false);
  overlaySettings.setLoadsImagesAutomatically(true);
  // FIXME: http://crbug.com/363843. Inspector should probably create its
  // own graphics layers and attach them to the tree rather than going
  // through some non-composited paint function.
  overlaySettings.setAcceleratedCompositingEnabled(false);

  LocalFrame* frame = LocalFrame::create(&dummyFrameLoaderClient,
                                         &m_overlayPage->frameHost(), 0);
  frame->setView(FrameView::create(*frame));
  frame->init();
  FrameLoader& loader = frame->loader();
  frame->view()->setCanHaveScrollbars(false);
  frame->view()->setTransparent(true);

  const WebData& overlayPageHTMLResource =
      Platform::current()->loadResource("InspectorOverlayPage.html");
  RefPtr<SharedBuffer> data = SharedBuffer::create(
      overlayPageHTMLResource.data(), overlayPageHTMLResource.size());
  loader.load(FrameLoadRequest(
      0, blankURL(), SubstituteData(data, "text/html", "UTF-8", KURL(),
                                    ForceSynchronousLoad)));
  v8::Isolate* isolate = toIsolate(frame);
  ScriptState* scriptState = ScriptState::forMainWorld(frame);
  DCHECK(scriptState);
  ScriptState::Scope scope(scriptState);
  v8::Local<v8::Object> global = scriptState->context()->Global();
  v8::Local<v8::Value> overlayHostObj =
      toV8(m_overlayHost.get(), global, isolate);
  DCHECK(!overlayHostObj.IsEmpty());
  global
      ->Set(scriptState->context(),
            v8AtomicString(isolate, "InspectorOverlayHost"), overlayHostObj)
      .ToChecked();

#if OS(WIN)
  evaluateInOverlay("setPlatform", "windows");
#elif OS(MACOSX)
  evaluateInOverlay("setPlatform", "mac");
#elif OS(POSIX)
  evaluateInOverlay("setPlatform", "linux");
#endif

  return m_overlayPage.get();
}