Beispiel #1
0
int Screen::availTop() const
{
    if (!m_frame)
        return 0;
    FrameHost* host = m_frame->host();
    if (!host)
        return 0;
    if (host->settings().reportScreenSizeInPhysicalPixelsQuirk())
        return lroundf(host->chromeClient().screenInfo().availableRect.y * host->deviceScaleFactor());
    return static_cast<int>(host->chromeClient().screenInfo().availableRect.y);
}
Beispiel #2
0
int Screen::width() const
{
    if (!m_frame)
        return 0;
    FrameHost* host = m_frame->host();
    if (!host)
        return 0;
    if (host->settings().reportScreenSizeInPhysicalPixelsQuirk())
        return lroundf(host->chromeClient().screenInfo().rect.width * host->deviceScaleFactor());
    return host->chromeClient().screenInfo().rect.width;
}
Beispiel #3
0
bool BarProp::visible() const {
  if (!frame())
    return false;
  FrameHost* host = frame()->host();
  if (!host)
    return false;

  switch (m_type) {
    case Locationbar:
    case Personalbar:
    case Toolbar:
      return host->chromeClient().toolbarsVisible();
    case Menubar:
      return host->chromeClient().menubarVisible();
    case Scrollbars:
      return host->chromeClient().scrollbarsVisible();
    case Statusbar:
      return host->chromeClient().statusbarVisible();
  }

  ASSERT_NOT_REACHED();
  return false;
}
static Frame* createNewWindow(LocalFrame& openerFrame, const FrameLoadRequest& request, const WindowFeatures& features, NavigationPolicy policy, bool& created)
{
    FrameHost* oldHost = openerFrame.host();
    if (!oldHost)
        return nullptr;

    Page* page = oldHost->chromeClient().createWindow(&openerFrame, request, features, policy);
    if (!page)
        return nullptr;
    FrameHost* host = &page->frameHost();

    ASSERT(page->mainFrame());
    LocalFrame& frame = *toLocalFrame(page->mainFrame());

    if (request.frameName() != "_blank")
        frame.tree().setName(request.frameName());

    host->chromeClient().setWindowFeatures(features);

    // 'x' and 'y' specify the location of the window, while 'width' and 'height'
    // specify the size of the viewport. We can only resize the window, so adjust
    // for the difference between the window size and the viewport size.

    IntRect windowRect = host->chromeClient().windowRect();
    IntSize viewportSize = host->chromeClient().pageRect().size();

    if (features.xSet)
        windowRect.setX(features.x);
    if (features.ySet)
        windowRect.setY(features.y);
    if (features.widthSet)
        windowRect.setWidth(features.width + (windowRect.width() - viewportSize.width()));
    if (features.heightSet)
        windowRect.setHeight(features.height + (windowRect.height() - viewportSize.height()));

    host->chromeClient().setWindowRectWithAdjustment(windowRect);
    host->chromeClient().show(policy);

    if (openerFrame.document()->isSandboxed(SandboxPropagatesToAuxiliaryBrowsingContexts))
        frame.loader().forceSandboxFlags(openerFrame.securityContext()->getSandboxFlags());

    // This call may suspend the execution by running nested message loop.
    InspectorInstrumentation::windowCreated(&openerFrame, &frame);
    created = true;
    return &frame;
}
Beispiel #5
0
// https://fullscreen.spec.whatwg.org/#exit-fullscreen
void Fullscreen::exitFullscreen(Document& document) {
  // The exitFullscreen() method must run these steps:

  // 1. Let doc be the context object. (i.e. "this")
  if (!document.isActive())
    return;

  // 2. If doc's fullscreen element stack is empty, terminate these steps.
  if (!fullscreenElementFrom(document))
    return;

  // 3. Let descendants be all the doc's descendant browsing context's documents
  // with a non-empty fullscreen element stack (if any), ordered so that the
  // child of the doc is last and the document furthest away from the doc is
  // first.
  HeapDeque<Member<Document>> descendants;
  for (Frame* descendant =
           document.frame() ? document.frame()->tree().traverseNext() : nullptr;
       descendant; descendant = descendant->tree().traverseNext()) {
    if (!descendant->isLocalFrame())
      continue;
    DCHECK(toLocalFrame(descendant)->document());
    if (fullscreenElementFrom(*toLocalFrame(descendant)->document()))
      descendants.prepend(toLocalFrame(descendant)->document());
  }

  // 4. For each descendant in descendants, empty descendant's fullscreen
  // element stack, and queue a task to fire an event named fullscreenchange
  // with its bubbles attribute set to true on descendant.
  for (auto& descendant : descendants) {
    DCHECK(descendant);
    RequestType requestType =
        from(*descendant).m_fullscreenElementStack.last().second;
    from(*descendant).clearFullscreenElementStack();
    from(document).enqueueChangeEvent(*descendant, requestType);
  }

  // 5. While doc is not null, run these substeps:
  Element* newTop = nullptr;
  for (Document* currentDoc = &document; currentDoc;) {
    RequestType requestType =
        from(*currentDoc).m_fullscreenElementStack.last().second;

    // 1. Pop the top element of doc's fullscreen element stack.
    from(*currentDoc).popFullscreenElementStack();

    //    If doc's fullscreen element stack is non-empty and the element now at
    //    the top is either not in a document or its node document is not doc,
    //    repeat this substep.
    newTop = fullscreenElementFrom(*currentDoc);
    if (newTop && (!newTop->isConnected() || newTop->document() != currentDoc))
      continue;

    // 2. Queue a task to fire an event named fullscreenchange with its bubbles
    // attribute set to true on doc.
    from(document).enqueueChangeEvent(*currentDoc, requestType);

    // 3. If doc's fullscreen element stack is empty and doc's browsing context
    // has a browsing context container, set doc to that browsing context
    // container's node document.
    //
    // OOPIF: If browsing context container's document is in another
    // process, keep moving up the ancestor chain and looking for a
    // browsing context container with a local document.
    // TODO(alexmos): Deal with nested fullscreen cases, see
    // https://crbug.com/617369.
    if (!newTop) {
      Frame* frame = currentDoc->frame()->tree().parent();
      while (frame && frame->isRemoteFrame())
        frame = frame->tree().parent();
      if (frame) {
        currentDoc = toLocalFrame(frame)->document();
        continue;
      }
    }

    // 4. Otherwise, set doc to null.
    currentDoc = nullptr;
  }

  // 6. Return, and run the remaining steps asynchronously.
  // 7. Optionally, perform some animation.

  FrameHost* host = document.frameHost();

  // Speculative fix for engaget.com/videos per crbug.com/336239.
  // FIXME: This check is wrong. We DCHECK(document->isActive()) above
  // so this should be redundant and should be removed!
  if (!host)
    return;

  // Only exit out of full screen window mode if there are no remaining elements
  // in the full screen stack.
  if (!newTop) {
    // FIXME: if the frame exiting fullscreen is not the frame that entered
    // fullscreen (but a parent frame for example),
    // m_currentFullScreenElement might be null. We want to pass an element
    // that is part of the document so we will pass the documentElement in
    // that case. This should be fix by exiting fullscreen for a frame
    // instead of an element, see https://crbug.com/441259
    Element* currentFullScreenElement = currentFullScreenElementFrom(document);
    host->chromeClient().exitFullscreenForElement(
        currentFullScreenElement ? currentFullScreenElement
                                 : document.documentElement());
    return;
  }

  // Otherwise, notify the chrome of the new full screen element.
  host->chromeClient().enterFullscreenForElement(newTop);
}
Beispiel #6
0
static Frame* createWindow(LocalFrame& openerFrame, LocalFrame& lookupFrame, const FrameLoadRequest& request, const WindowFeatures& features, NavigationPolicy policy, ShouldSetOpener shouldSetOpener, bool& created)
{
    created = false;

    ASSERT(!features.dialog || request.frameName().isEmpty());
    ASSERT(request.resourceRequest().requestorOrigin() || openerFrame.document()->url().isEmpty());
    ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeAuxiliary);

    if (!request.frameName().isEmpty() && request.frameName() != "_blank" && policy == NavigationPolicyIgnore) {
        if (Frame* frame = lookupFrame.findFrameForNavigation(request.frameName(), openerFrame)) {
            if (request.frameName() != "_self") {
                if (FrameHost* host = frame->host()) {
                    if (host == openerFrame.host())
                        frame->page()->focusController().setFocusedFrame(frame);
                    else
                        host->chromeClient().focus();
                }
            }
            return frame;
        }
    }

    // Sandboxed frames cannot open new auxiliary browsing contexts.
    if (openerFrame.document()->isSandboxed(SandboxPopups)) {
        // FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
        openerFrame.document()->addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, ErrorMessageLevel, "Blocked opening '" + request.resourceRequest().url().elidedString() + "' in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set."));
        return nullptr;
    }

    if (openerFrame.settings() && !openerFrame.settings()->supportsMultipleWindows())
        return openerFrame.tree().top();

    FrameHost* oldHost = openerFrame.host();
    if (!oldHost)
        return nullptr;

    Page* page = oldHost->chromeClient().createWindow(&openerFrame, request, features, policy, shouldSetOpener);
    if (!page)
        return nullptr;
    FrameHost* host = &page->frameHost();

    ASSERT(page->mainFrame());
    Frame& frame = *page->mainFrame();

    if (request.frameName() != "_blank")
        frame.tree().setName(request.frameName());

    host->chromeClient().setWindowFeatures(features);

    // 'x' and 'y' specify the location of the window, while 'width' and 'height'
    // specify the size of the viewport. We can only resize the window, so adjust
    // for the difference between the window size and the viewport size.

    IntRect windowRect = host->chromeClient().windowRect();
    IntSize viewportSize = host->chromeClient().pageRect().size();

    if (features.xSet)
        windowRect.setX(features.x);
    if (features.ySet)
        windowRect.setY(features.y);
    if (features.widthSet)
        windowRect.setWidth(features.width + (windowRect.width() - viewportSize.width()));
    if (features.heightSet)
        windowRect.setHeight(features.height + (windowRect.height() - viewportSize.height()));

    host->chromeClient().setWindowRectWithAdjustment(windowRect);
    host->chromeClient().show(policy);

    // TODO(japhet): There's currently no way to set sandbox flags on a RemoteFrame and have it propagate
    // to the real frame in a different process. See crbug.com/483584.
    if (frame.isLocalFrame() && openerFrame.document()->isSandboxed(SandboxPropagatesToAuxiliaryBrowsingContexts))
        toLocalFrame(&frame)->loader().forceSandboxFlags(openerFrame.document()->sandboxFlags());

    created = true;
    return &frame;
}