void paintPageOverlay(const PageOverlay&, GraphicsContext& graphicsContext, const WebSize& webViewSize) const override
    {
        if (m_overlay->isEmpty())
            return;

        FrameView* view = m_overlay->overlayMainFrame()->view();
        DCHECK(!view->needsLayout());
        view->paint(graphicsContext, CullRect(IntRect(0, 0, view->width(), view->height())));
    }
Example #2
0
void InspectorOverlay::paint(GraphicsContext& context)
{
    if (m_pausedInDebuggerMessage.isNull() && !m_highlightNode && !m_highlightRect)
        return;
    GraphicsContextStateSaver stateSaver(context);
    FrameView* view = overlayPage()->mainFrame()->view();
    ASSERT(!view->needsLayout());
    view->paint(&context, IntRect(0, 0, view->width(), view->height()));
}
Example #3
0
void InspectorOverlay::paint(GraphicsContext& context)
{
    if (isEmpty())
        return;
    GraphicsContextStateSaver stateSaver(context);
    FrameView* view = overlayPage()->mainFrame()->view();
    ASSERT(!view->needsLayout());
    view->paint(&context, IntRect(0, 0, view->width(), view->height()));
}
Example #4
0
IntSize WebFrame::size()
{
    Frame* coreFrame = core(this);
    if (!coreFrame)
        return IntSize();
    FrameView* view = coreFrame->view();
    if (!view)
        return IntSize();
    return IntSize(view->width(), view->height());
}
Example #5
0
void InspectorOverlay::paint(GraphicsContext& context)
{
    if (!shouldShowOverlay())
        return;

    GraphicsContextStateSaver stateSaver(context);
    FrameView* view = overlayPage()->mainFrame().view();
    view->updateLayoutAndStyleIfNeededRecursive();
    view->paint(&context, IntRect(0, 0, view->width(), view->height()));
}
Example #6
0
void RenderPartObject::layout()
{
    ASSERT(needsLayout());

    calcWidth();
    calcHeight();
    
#ifdef FLATTEN_IFRAME
    // Some IFrames have a width and/or height of 1 when they are meant to be
    // hidden. If that is the case, don't try to expand.
    if (m_widget && m_widget->isFrameView() &&
            m_width > 1 && m_height > 1) {
        FrameView* view = static_cast<FrameView*>(m_widget);
        RenderView* root = NULL;
        if (view->frame() && view->frame()->document() &&
            view->frame()->document()->renderer() && view->frame()->document()->renderer()->isRenderView())
            root = static_cast<RenderView*>(view->frame()->document()->renderer());
        if (root) {
            // Update the dimensions to get the correct minimum preferred width
            updateWidgetPosition();

            // Use the preferred width if it is larger.
            m_width = max(m_width, root->minPrefWidth());
            int extraWidth = paddingLeft() + paddingRight() + borderLeft() + borderRight();
            int extraHeight = paddingTop() + paddingBottom() + borderTop() + borderBottom();
            // Resize the view to recalc the height.
            int height = m_height - extraHeight;
            int width = m_width - extraWidth;
            if (width > view->width())
                height = 0;
            if (width != view->width() || height != view->height()) {
                view->resize(width, height);
                root->setNeedsLayout(true, false);
            }
            // Layout the view.
            if (view->needsLayout())
                view->layout();
            int contentHeight = view->contentsHeight();
            int contentWidth = view->contentsWidth();
            // Do not shrink iframes with specified sizes
            if (contentHeight > m_height || style()->height().isAuto())
                m_height = contentHeight;
            m_width = std::min(contentWidth, 800);
        }
    }
#endif
    adjustOverflowForBoxShadow();

    RenderPart::layout();

    if (!m_widget && m_view)
        m_view->addWidgetToUpdate(this);
    
    setNeedsLayout(false);
}
    void paintPageOverlay(const PageOverlay&, GraphicsContext& graphicsContext, const WebSize& webViewSize) const override
    {
        if (m_overlay->isEmpty())
            return;

        // Skip cache because the following paint may conflict with the view's real painting.
        DisplayItemCacheSkipper cacheSkipper(graphicsContext);
        FrameView* view = m_overlay->overlayMainFrame()->view();
        ASSERT(!view->needsLayout());
        view->paint(graphicsContext, CullRect(IntRect(0, 0, view->width(), view->height())));
    }
int DOMWindow::innerHeight() const
{
    if (!m_frame)
        return 0;

    FrameView* view = m_frame->view();
    if (!view)
        return 0;

    return view->height();
}
Example #9
0
bool ImageDocument::imageFitsInWindow() const
{
    if (!m_imageElement)
        return true;

    FrameView* view = frame()->view();

    IntSize imageSize = m_imageElement->cachedImage()->imageSize(view->pageZoomFactor());
    IntSize windowSize = IntSize(view->width(), view->height());

    return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height();
}
Example #10
0
IntRect PluginView::calculateClipRect() const
{
    FrameView* frameView = toFrameView(parent());
    bool visible = frameView && isVisible();
    RenderObject* renderer = m_element->renderer();

    if (visible && frameView->width() && frameView->height() && renderer) {
        IntSize windowSize = frameView->hostWindow()->platformPageClient()->viewportSize();

        // Get the clipped rectangle for this player within the current frame.
        IntRect visibleContentRect;
        IntRect contentRect = renderer->absoluteClippedOverflowRect();
        FloatPoint contentLocal = renderer->absoluteToLocal(FloatPoint(contentRect.location()));

        contentRect.setLocation(roundedIntPoint(contentLocal));
        contentRect.move(frameRect().x(), frameRect().y());

        // Clip against any frames that the widget is inside. Note that if the frames are also clipped
        // by a div, that will not be included in this calculation. That is an improvement that still
        // needs to be made.
        const Widget* current = this;
        while (current->parent() && visible) {
            // Determine if it is visible in this scrollview.
            visibleContentRect = current->parent()->visibleContentRect();

            // Special case for the root ScrollView. Its size does not match the actual window size.
            if (current->parent() == root())
                visibleContentRect.setSize(windowSize);

            contentRect.intersect(visibleContentRect);
            visible = !contentRect.isEmpty();

            // Offset to visible coordinates in scrollview widget's coordinate system (except in the case of
            // the top scroll view).
            if (current->parent()->parent())
                contentRect.move(-visibleContentRect.x(), -visibleContentRect.y());

            current = current->parent();

            // Don't include the offset for the root window or we get the wrong coordinates.
            if (current->parent()) {
                // Move content rect into the parent scrollview's coordinates.
                IntRect curFrameRect = current->frameRect();
                contentRect.move(curFrameRect.x(), curFrameRect.y());
            }
        }

        return contentRect;
    }

    return IntRect();
}
Example #11
0
bool ImageDocument::imageFitsInWindow()
{
    if (!m_imageElement)
        return true;

    FrameView* view = this->view();
    if (!view)
        return true;

    LayoutSize imageSize = this->imageSize();
    LayoutSize windowSize = LayoutSize(view->width(), view->height());
    return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height();
}
Example #12
0
IntRect PageOverlay::bounds() const
{
    FrameView* frameView = m_webPage->corePage()->mainFrame()->view();

    int width = frameView->width();
    int height = frameView->height();

    if (!ScrollbarTheme::theme()->usesOverlayScrollbars()) {
        if (frameView->verticalScrollbar())
            width -= frameView->verticalScrollbar()->width();
        if (frameView->horizontalScrollbar())
            height -= frameView->horizontalScrollbar()->height();
    }    
    return IntRect(0, 0, width, height);
}
TEST(RemoteFrameThrottlingTest, ThrottledLocalRoot)
{
    FrameTestHelpers::TestWebViewClient viewClient;
    WebViewImpl* webView = WebViewImpl::create(&viewClient);
    webView->resize(WebSize(640, 480));

    // Create a remote root frame with a local child frame.
    FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
    webView->setMainFrame(remoteClient.frame());
    remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createUnique());

    WebFrameOwnerProperties properties;
    FrameTestHelpers::TestWebFrameClient localFrameClient;
    WebRemoteFrame* rootFrame = webView->mainFrame()->toWebRemoteFrame();
    WebLocalFrame* localFrame = rootFrame->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);

    WebString baseURL("http://internal.test/");
    URLTestHelpers::registerMockedURLFromBaseURL(baseURL, "simple_div.html");
    FrameTestHelpers::loadFrame(localFrame, baseURL.utf8() + "simple_div.html");

    FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView();
    EXPECT_TRUE(frameView->frame().isLocalRoot());

    // Enable throttling for the child frame.
    frameView->setFrameRect(IntRect(0, 480, frameView->width(), frameView->height()));
    frameView->frame().securityContext()->setSecurityOrigin(SecurityOrigin::createUnique());
    frameView->updateAllLifecyclePhases();
    testing::runPendingTasks();
    EXPECT_TRUE(frameView->shouldThrottleRendering());

    Document* frameDocument = frameView->frame().document();
    if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled())
        EXPECT_EQ(DocumentLifecycle::PaintClean, frameDocument->lifecycle().state());
    else
        EXPECT_EQ(DocumentLifecycle::PaintInvalidationClean, frameDocument->lifecycle().state());

    // Mutate the local child frame contents.
    auto* divElement = frameDocument->getElementById("div");
    divElement->setAttribute(styleAttr, "width: 50px");
    EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle().state());

    // Update the lifecycle again. The frame's lifecycle should not advance
    // because of throttling even though it is the local root.
    frameView->updateAllLifecyclePhases();
    testing::runPendingTasks();
    EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle().state());
    webView->close();
}
Example #14
0
float ImageDocument::scale()
{
    if (!m_imageElement)
        return 1;

    FrameView* view = this->view();
    if (!view)
        return 1;

    LayoutSize imageSize = this->imageSize();

    float widthScale = view->width() / imageSize.width().toFloat();
    float heightScale = view->height() / imageSize.height().toFloat();

    return std::min(widthScale, heightScale);
}
Example #15
0
void PluginView::handleScrollEvent()
{
    FrameView* frameView = toFrameView(parent());

    // As a special case, if the frameView extent in either dimension is
    // empty, then send an on screen event. This is important for sites like
    // picnik.com which use a hidden iframe (read: width = 0 and height = 0)
    // with an embedded swf to execute some javascript. Unless we send an
    // on screen event the swf will not execute the javascript and the real
    // site will never load.
    bool onScreenEvent = frameView && (!frameView->width() || !frameView->height());

    NPEvent npEvent;
    npEvent.type = m_clipRect.isEmpty() && !onScreenEvent ? NP_OffScreenEvent : NP_OnScreenEvent;
    npEvent.data = 0;
    dispatchNPEvent(npEvent);
}
Example #16
0
float ImageDocument::scale() const
{
    if (!m_imageElement)
        return 1.0f;

    FrameView* view = frame()->view();
    if (!view)
        return 1;

    IntSize imageSize = m_imageElement->cachedImage()->imageSize(view->pageZoomFactor());
    IntSize windowSize = IntSize(view->width(), view->height());

    float widthScale = (float)windowSize.width() / imageSize.width();
    float heightScale = (float)windowSize.height() / imageSize.height();

    return min(widthScale, heightScale);
}
bool ImageDocument::imageFitsInWindow() const
{
    ASSERT(m_shrinkToFitMode == Desktop);

    if (!m_imageElement || m_imageElement->document() != this)
        return true;

    FrameView* view = frame()->view();
    if (!view)
        return true;

    ASSERT(m_imageElement->cachedImage());
    LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForLayoutObject(m_imageElement->layoutObject(), pageZoomFactor(this));
    LayoutSize windowSize = LayoutSize(view->width(), view->height());

    return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height();
}
float ImageDocument::scale() const
{
    if (!m_imageElement || m_imageElement->document() != this)
        return 1.0f;

    FrameView* view = frame()->view();
    if (!view)
        return 1;

    ASSERT(m_imageElement->cachedImage());
    LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForLayoutObject(m_imageElement->layoutObject(), pageZoomFactor(this));
    LayoutSize windowSize = LayoutSize(view->width(), view->height());

    float widthScale = windowSize.width().toFloat() / imageSize.width().toFloat();
    float heightScale = windowSize.height().toFloat() / imageSize.height().toFloat();

    return min(widthScale, heightScale);
}
float ImageDocument::scale() const
{
    // on iPhone big images are subsampled to make them smaller - don't resize them.
    return 1.0f;

    if (!m_imageElement)
        return 1.0f;

    FrameView* view = frame()->view();
    if (!view)
        return 1;

    IntSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
    IntSize windowSize = IntSize(view->width(), view->height());
    
    float widthScale = (float)windowSize.width() / imageSize.width();
    float heightScale = (float)windowSize.height() / imageSize.height();

    return min(widthScale, heightScale);
}
Example #20
0
void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)
{
    if (!m_page)
        return;

    FrameView* view = m_page->mainFrame()->view();

    context->save();
    context->setCompositeOperation(compositeOp);
    context->clip(enclosingIntRect(dstRect));
    if (compositeOp != CompositeSourceOver)
        context->beginTransparencyLayer(1);

    FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height());
    
    // We can only draw the entire frame, clipped to the rect we want. So compute where the top left
    // of the image would be if we were drawing without clipping, and translate accordingly.
    FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.location().y() * scale.height());
    FloatPoint destOffset = dstRect.location() - topLeftOffset;

    context->translate(destOffset.x(), destOffset.y());
    context->scale(scale);

    view->resize(size());

    if (view->needsLayout())
        view->layout();

    view->paint(context, IntRect(0, 0, view->width(), view->height()));

    if (compositeOp != CompositeSourceOver)
        context->endTransparencyLayer();

    context->restore();

    if (imageObserver())
        imageObserver()->didDraw(this);
}
Example #21
0
static inline float dimensionForViewportUnit(const SVGElement* context,
                                             CSSPrimitiveValue::UnitType unit) {
  if (!context)
    return 0;

  const Document& document = context->document();
  FrameView* view = document.view();
  if (!view)
    return 0;

  const ComputedStyle* style = computedStyleForLengthResolving(context);
  if (!style)
    return 0;

  FloatSize viewportSize(view->width(), view->height());

  switch (unit) {
    case CSSPrimitiveValue::UnitType::ViewportWidth:
      return viewportLengthPercent(viewportSize.width()) /
             style->effectiveZoom();

    case CSSPrimitiveValue::UnitType::ViewportHeight:
      return viewportLengthPercent(viewportSize.height()) /
             style->effectiveZoom();

    case CSSPrimitiveValue::UnitType::ViewportMin:
      return viewportMinPercent(viewportSize) / style->effectiveZoom();

    case CSSPrimitiveValue::UnitType::ViewportMax:
      return viewportMaxPercent(viewportSize) / style->effectiveZoom();
    default:
      break;
  }

  ASSERT_NOT_REACHED();
  return 0;
}
void RenderPartObject::layout()
{
    ASSERT(needsLayout());

#ifdef FLATTEN_IFRAME
    RenderPart::calcWidth();
    RenderPart::calcHeight();
    // Calculate the styled dimensions by subtracting the border and padding.
    int extraWidth = paddingLeft() + paddingRight() + borderLeft() + borderRight();
    int extraHeight = paddingTop() + paddingBottom() + borderTop() + borderBottom();
    int styleWidth = width() - extraWidth;
    int styleHeight = height() - extraHeight;
    // Some IFrames have a width and/or height of 1 when they are meant to be
    // hidden. If that is the case, do not try to expand.
    if (node()->hasTagName(iframeTag) && widget() && widget()->isFrameView() &&
            styleWidth > 1 && styleHeight > 1) {
        HTMLIFrameElement* element = static_cast<HTMLIFrameElement*>(node());
        bool scrolling = element->scrollingMode() != ScrollbarAlwaysOff;
        bool widthIsFixed = style()->width().isFixed();
        bool heightIsFixed = style()->height().isFixed();
        // If an iframe has a fixed dimension and suppresses scrollbars, it
        // will disrupt layout if we force it to expand. Plus on a desktop,
        // the extra content is not accessible.
        if (scrolling || !widthIsFixed || !heightIsFixed) {
            FrameView* view = static_cast<FrameView*>(widget());
            RenderView* root = view ? view->frame()->contentRenderer() : NULL;
            if (root && style()->visibility() != HIDDEN) {
                // Update the dimensions to get the correct minimum preferred
                // width
                updateWidgetPosition();

                // Use the preferred width if it is larger and only if
                // scrollbars are visible or the width style is not fixed.
                if (scrolling || !widthIsFixed)
                    setWidth(max(width(), root->minPrefWidth()) + extraWidth);

                // Resize the view to recalc the height.
                int h = height() - extraHeight;
                int w = width() - extraWidth;
                if (w > view->width())
                    h = 0;
                if (w != view->width() || h != view->height()) {
                    view->resize(w, h);
                }

                // Layout the view.
//SAMSUNG CHANGE >>
		  // Browser freeze issue in http://www.enuri.com/
                /* do {
                    view->layout();
                } while (view->layoutPending() || root->needsLayout()); */
                
		  node()->document()->page()->mainFrame()->view()->layoutIfNeededRecursive();
 //SAMSUNG CHANGE <<


                int contentHeight = view->contentsHeight();
                int contentWidth = view->contentsWidth();
                // Only change the width or height if scrollbars are visible or
                // if the style is not a fixed value. Use the maximum value so
                // that iframes never shrink.
                if (scrolling || !heightIsFixed)
                    setHeight(max(height(), contentHeight + extraHeight));
                if (scrolling || !widthIsFixed)
                    setWidth(max(width(), contentWidth + extraWidth));

                // Update one last time
                updateWidgetPosition();

                // Layout one more time to ensure all objects have the correct
                // height.
                view->layout();

#if !ASSERT_DISABLED
                ASSERT(!view->layoutPending());
                ASSERT(!root->needsLayout());
                // Sanity check when assertions are enabled.
                RenderObject* c = root->nextInPreOrder();
                while (c) {
                    ASSERT(!c->needsLayout());
                    c = c->nextInPreOrder();
                }
#endif
            }
        }
    }
#else
    calcWidth();
    calcHeight();
#endif

    RenderPart::layout();

    m_overflow.clear();
    addShadowOverflow();

    setNeedsLayout(false);
}