void SVGImage::draw(SkCanvas* canvas, const SkPaint& paint, const FloatRect& dstRect, const FloatRect& srcRect, RespectImageOrientationEnum, ImageClampingMode) { if (!m_page) return; FrameView* view = frameView(); view->resize(containerSize()); // Always call processUrlFragment, even if the url is empty, because // there may have been a previous url/fragment that needs to be reset. view->processUrlFragment(m_url); SkPictureBuilder imagePicture(dstRect); { ClipRecorder clipRecorder(imagePicture.context(), *this, DisplayItem::ClipNodeImage, LayoutRect(enclosingIntRect(dstRect))); // 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 scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()); FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.location().y() * scale.height()); FloatPoint destOffset = dstRect.location() - topLeftOffset; AffineTransform transform = AffineTransform::translation(destOffset.x(), destOffset.y()); transform.scale(scale.width(), scale.height()); TransformRecorder transformRecorder(imagePicture.context(), *this, transform); view->updateAllLifecyclePhases(); view->paint(&imagePicture.context(), enclosingIntRect(srcRect)); ASSERT(!view->needsLayout()); } { SkAutoCanvasRestore ar(canvas, false); if (drawNeedsLayer(paint)) { SkRect layerRect = dstRect; canvas->saveLayer(&layerRect, &paint); } RefPtr<const SkPicture> recording = imagePicture.endRecording(); canvas->drawPicture(recording.get()); } if (imageObserver()) imageObserver()->didDraw(this); // Start any (SMIL) animations if needed. This will restart or continue // animations if preceded by calls to resetAnimation or stopAnimation // respectively. startAnimation(); }
void RenderWidget::updateWidgetPosition() { if (!m_widget || !node()) // Check the node in case destroy() has been called. return; bool boundsChanged = updateWidgetGeometry(); // if the frame bounds got changed, or if view needs layout (possibly indicating // content size is wrong) we have to do a layout to set the right widget size if (m_widget && m_widget->isFrameView()) { FrameView* frameView = toFrameView(m_widget.get()); // Check the frame's page to make sure that the frame isn't in the process of being destroyed. if ((boundsChanged || frameView->needsLayout()) && frameView->frame().page()) frameView->layout(); } }
void ScrollingCoordinatorChromium::touchEventTargetRectsDidChange(const Document*) { #if ENABLE(TOUCH_EVENT_TRACKING) // The rects are always evaluated and used in the main frame coordinates. FrameView* frameView = m_page->mainFrame()->view(); Document* document = m_page->mainFrame()->document(); // Wait until after layout to update. if (frameView->needsLayout() || !document) return; Vector<IntRect> touchEventTargetRects; computeAbsoluteTouchEventTargetRects(document, touchEventTargetRects); setTouchEventTargetRects(touchEventTargetRects); #endif }
void SVGImage::draw(GraphicsContext& context, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator compositeOp, BlendMode blendMode, ImageOrientationDescription) { if (!m_page) return; FrameView* view = frameView(); ASSERT(view); GraphicsContextStateSaver stateSaver(context); context.setCompositeOperation(compositeOp, blendMode); context.clip(enclosingIntRect(dstRect)); float alpha = context.alpha(); bool compositingRequiresTransparencyLayer = compositeOp != CompositeSourceOver || blendMode != BlendModeNormal || alpha < 1; if (compositingRequiresTransparencyLayer) { context.beginTransparencyLayer(alpha); context.setCompositeOperation(CompositeSourceOver, BlendModeNormal); } 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(containerSize()); if (!m_url.isEmpty()) view->scrollToFragment(m_url); if (view->needsLayout()) view->layout(); view->paint(context, intersection(context.clipBounds(), enclosingIntRect(srcRect))); if (compositingRequiresTransparencyLayer) context.endTransparencyLayer(); stateSaver.restore(); if (imageObserver()) imageObserver()->didDraw(this); }
// Checks if |node| is offscreen the visible area (viewport) of its container // document. In case it is, one can scroll in direction or take any different // desired action later on. bool hasOffscreenRect(Node* node, FocusDirection direction) { // Get the FrameView in which |node| is (which means the current viewport if |node| // is not in an inner document), so we can check if its content rect is visible // before we actually move the focus to it. FrameView* frameView = node->document()->view(); if (!frameView) return true; ASSERT(!frameView->needsLayout()); IntRect containerViewportRect = frameView->visibleContentRect(); // We want to select a node if it is currently off screen, but will be // exposed after we scroll. Adjust the viewport to post-scrolling position. // If the container has overflow:hidden, we cannot scroll, so we do not pass direction // and we do not adjust for scrolling. switch (direction) { case FocusDirectionLeft: containerViewportRect.setX(containerViewportRect.x() - Scrollbar::pixelsPerLineStep()); containerViewportRect.setWidth(containerViewportRect.width() + Scrollbar::pixelsPerLineStep()); break; case FocusDirectionRight: containerViewportRect.setWidth(containerViewportRect.width() + Scrollbar::pixelsPerLineStep()); break; case FocusDirectionUp: containerViewportRect.setY(containerViewportRect.y() - Scrollbar::pixelsPerLineStep()); containerViewportRect.setHeight(containerViewportRect.height() + Scrollbar::pixelsPerLineStep()); break; case FocusDirectionDown: containerViewportRect.setHeight(containerViewportRect.height() + Scrollbar::pixelsPerLineStep()); break; default: break; } RenderObject* render = node->renderer(); if (!render) return true; IntRect rect(render->absoluteClippedOverflowRect()); if (rect.isEmpty()) return true; return !containerViewportRect.intersects(rect); }
void RenderWidget::updateWidgetPosition() { if (!m_widget || !node()) // Check the node in case destroy() has been called. return; IntRect contentBox = contentBoxRect(); IntRect absoluteContentBox = IntRect(localToAbsoluteQuad(FloatQuad(contentBox)).boundingBox()); bool boundsChanged = setWidgetGeometry(absoluteContentBox, contentBox.size()); // if the frame bounds got changed, or if view needs layout (possibly indicating // content size is wrong) we have to do a layout to set the right widget size if (m_widget && m_widget->isFrameView()) { FrameView* frameView = static_cast<FrameView*>(m_widget.get()); // Check the frame's page to make sure that the frame isn't in the process of being destroyed. if ((boundsChanged || frameView->needsLayout()) && frameView->frame()->page()) frameView->layout(); } }
void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator compositeOp, blink::WebBlendMode blendMode) { if (!m_page) return; GraphicsContextStateSaver stateSaver(*context); context->setCompositeOperation(compositeOp, blendMode); context->clip(enclosingIntRect(dstRect)); bool compositingRequiresTransparencyLayer = compositeOp != CompositeSourceOver || blendMode != blink::WebBlendModeNormal; float opacity = context->getNormalizedAlpha() / 255.f; bool requiresTransparencyLayer = compositingRequiresTransparencyLayer || opacity < 1; if (requiresTransparencyLayer) { context->beginTransparencyLayer(opacity); if (compositingRequiresTransparencyLayer) context->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal); } 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); FrameView* view = frameView(); view->resize(containerSize()); if (view->needsLayout()) view->layout(); view->paint(context, enclosingIntRect(srcRect)); if (requiresTransparencyLayer) context->endLayer(); stateSaver.restore(); if (imageObserver()) imageObserver()->didDraw(this); }
void RenderWidget::updateWidgetPosition() { if (!m_widget) return; WeakPtr<RenderWidget> weakThis = createWeakPtr(); bool widgetSizeChanged = updateWidgetGeometry(); if (!weakThis) return; // if the frame size got changed, or if view needs layout (possibly indicating // content size is wrong) we have to do a layout to set the right widget size. if (m_widget->isFrameView()) { FrameView* frameView = toFrameView(m_widget.get()); // Check the frame's page to make sure that the frame isn't in the process of being destroyed. if ((widgetSizeChanged || frameView->needsLayout()) && frameView->frame().page()) frameView->layout(); } }
void LayoutPart::updateWidgetGeometry() { Widget* widget = this->widget(); if (!widget || !node()) // Check the node in case destroy() has been called. return; bool boundsChanged = updateWidgetGeometryInternal(); // If the frame bounds got changed, or if view needs layout (possibly indicating // content size is wrong) we have to do a layout to set the right widget size. if (widget && widget->isFrameView()) { FrameView* frameView = toFrameView(widget); // Check the frame's page to make sure that the frame isn't in the process of being destroyed. if ((boundsChanged || frameView->needsLayout()) && frameView->frame().page()) frameView->layout(); } widget->widgetGeometryMayHaveChanged(); }
void RenderWidget::updateWidgetPosition() { if (!m_widget) return; // FIXME: This doesn't work correctly with transforms. FloatPoint absPos = localToAbsolute(); absPos.move(borderLeft() + paddingLeft(), borderTop() + paddingTop()); int w = width() - borderLeft() - borderRight() - paddingLeft() - paddingRight(); int h = height() - borderTop() - borderBottom() - paddingTop() - paddingBottom(); bool boundsChanged = setWidgetGeometry(IntRect(absPos.x(), absPos.y(), w, h)); // if the frame bounds got changed, or if view needs layout (possibly indicating // content size is wrong) we have to do a layout to set the right widget size if (m_widget->isFrameView()) { FrameView* frameView = static_cast<FrameView*>(m_widget.get()); if (boundsChanged || frameView->needsLayout()) frameView->layout(); } }
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); }
void RenderWidget::updateWidgetPosition() { if (!m_widget || !node()) // Check the node in case destroy() has been called. return; // FIXME: This doesn't work correctly with transforms. FloatPoint absPos = localToAbsolute(); absPos.move(borderLeft() + paddingLeft(), borderTop() + paddingTop()); int w = width() - borderAndPaddingWidth(); int h = height() - borderAndPaddingHeight(); bool boundsChanged = setWidgetGeometry(IntRect(absPos.x(), absPos.y(), w, h)); // if the frame bounds got changed, or if view needs layout (possibly indicating // content size is wrong) we have to do a layout to set the right widget size if (m_widget && m_widget->isFrameView()) { FrameView* frameView = static_cast<FrameView*>(m_widget.get()); // Check the frame's page to make sure that the frame isn't in the process of being destroyed. if ((boundsChanged || frameView->needsLayout()) && frameView->frame()->page()) frameView->layout(); } }
void InspectorOverlay::update() { if (!shouldShowOverlay()) { m_client->hideHighlight(); return; } FrameView* view = m_page.mainFrame().view(); if (!view) return; FrameView* overlayView = overlayPage()->mainFrame().view(); IntSize viewportSize = view->unscaledVisibleContentSizeIncludingObscuredArea(); IntSize frameViewFullSize = view->unscaledVisibleContentSizeIncludingObscuredArea(ScrollableArea::IncludeScrollbars); overlayPage()->setPageScaleFactor(m_page.pageScaleFactor(), IntPoint()); frameViewFullSize.scale(m_page.pageScaleFactor()); overlayView->resize(frameViewFullSize); // Clear canvas and paint things. // FIXME: Remove extra parameter? reset(viewportSize, IntSize()); // Include scrollbars to avoid masking them by the gutter. drawGutter(); drawNodeHighlight(); drawQuadHighlight(); drawPausedInDebuggerMessage(); // Position DOM elements. overlayPage()->mainFrame().document()->recalcStyle(Style::Force); if (overlayView->needsLayout()) overlayView->layout(); // Kick paint. m_client->highlight(); }
void InspectorOverlay::update() { if (!m_highlightNode && !m_highlightQuad && m_pausedInDebuggerMessage.isNull() && m_size.isEmpty()) { m_client->hideHighlight(); return; } FrameView* view = m_page->mainFrame()->view(); if (!view) return; FrameView* overlayView = overlayPage()->mainFrame()->view(); IntSize viewportSize = view->visibleContentRect().size(); IntSize frameViewFullSize = view->visibleContentRect(ScrollableArea::IncludeScrollbars).size(); IntSize size = m_size.isEmpty() ? frameViewFullSize : m_size; overlayPage()->setPageScaleFactor(m_page->pageScaleFactor(), IntPoint()); size.scale(m_page->pageScaleFactor()); overlayView->resize(size); // Clear canvas and paint things. reset(viewportSize, m_size.isEmpty() ? IntSize() : frameViewFullSize); // Include scrollbars to avoid masking them by the gutter. drawGutter(); drawNodeHighlight(); drawQuadHighlight(); drawPausedInDebuggerMessage(); // Position DOM elements. overlayPage()->mainFrame()->document()->recalcStyle(Node::Force); if (overlayView->needsLayout()) overlayView->layout(); // Kick paint. m_client->highlight(); }