Beispiel #1
0
IntSize SVGImage::size() const
{
    IntSize defaultSize(300, 150);
    // FIXME: Eventually we'll be passed in the dest size and can scale against that
    IntSize destSize = defaultSize;
    
    if (!m_frame || !m_frame->document())
        return IntSize();
    
    SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement();
    if (!rootElement)
        return defaultSize;
    
    SVGLength width = rootElement->width();
    SVGLength height = rootElement->height();
    
    IntSize svgSize;
    if (width.unitType() == LengthTypePercentage)
        svgSize.setWidth(static_cast<int>(width.valueInSpecifiedUnits() * destSize.width()));
    else
        svgSize.setWidth(static_cast<int>(width.value()));
    if (height.unitType() == LengthTypePercentage)
        svgSize.setHeight(static_cast<int>(height.valueInSpecifiedUnits() * destSize.height()));
    else
        svgSize.setHeight(static_cast<int>(height.value()));
    
    return svgSize;
}
Beispiel #2
0
IntSize SVGImage::size() const
{
    if (!m_page)
        return IntSize();
    Frame* frame = m_page->mainFrame();
    SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement();
    if (!rootElement)
        return IntSize();
    
    SVGLength width = rootElement->width();
    SVGLength height = rootElement->height();
    
    IntSize svgSize;
    if (width.unitType() == LengthTypePercentage) 
        svgSize.setWidth(rootElement->relativeWidthValue());
    else
        svgSize.setWidth(static_cast<int>(width.value(rootElement)));

    if (height.unitType() == LengthTypePercentage) 
        svgSize.setHeight(rootElement->relativeHeightValue());
    else
        svgSize.setHeight(static_cast<int>(height.value(rootElement)));

    return svgSize;
}
Beispiel #3
0
void CCHeadsUpDisplay::draw(CCLayerTreeHostImpl* layerTreeHostImpl)
{
    CCRenderer* layerRenderer = layerTreeHostImpl->layerRenderer();
    WebKit::WebGraphicsContext3D* context = layerTreeHostImpl->context()->context3D();
    if (!context) {
        // FIXME: Implement this path for software compositing.
        return;
    }
    if (!m_hudTexture)
        m_hudTexture = ManagedTexture::create(layerRenderer->implTextureManager());

    const CCLayerTreeSettings& settings = layerTreeHostImpl->settings();
    // Use a fullscreen texture only if we need to...
    IntSize hudSize;
    if (showPlatformLayerTree(settings) || showDebugRects(settings)) {
        hudSize.setWidth(min(2048, layerTreeHostImpl->deviceViewportSize().width()));
        hudSize.setHeight(min(2048, layerTreeHostImpl->deviceViewportSize().height()));
    } else {
        hudSize.setWidth(512);
        hudSize.setHeight(128);
    }

    if (!m_hudTexture->reserve(hudSize, GraphicsContext3D::RGBA))
        return;

    // Render pixels into the texture.
    PlatformCanvas canvas;
    canvas.resize(hudSize);
    {
        PlatformCanvas::Painter painter(&canvas, PlatformCanvas::Painter::GrayscaleText);
        painter.context()->clearRect(FloatRect(0, 0, hudSize.width(), hudSize.height()));
        drawHudContents(painter.context(), layerTreeHostImpl, settings, hudSize);
    }

    // Upload to GL.
    {
        PlatformCanvas::AutoLocker locker(&canvas);

        m_hudTexture->bindTexture(layerTreeHostImpl->context(), layerRenderer->implTextureAllocator());
        bool uploadedViaMap = false;
        if (layerRenderer->capabilities().usingMapSub) {
            uint8_t* pixelDest = static_cast<uint8_t*>(context->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, hudSize.width(), hudSize.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY));

            if (pixelDest) {
                uploadedViaMap = true;
                memcpy(pixelDest, locker.pixels(), hudSize.width() * hudSize.height() * 4);
                context->unmapTexSubImage2DCHROMIUM(pixelDest);
            }
        }

        if (!uploadedViaMap) {
            GLC(context, context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, canvas.size().width(), canvas.size().height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, locker.pixels()));
        }
    }

    layerRenderer->drawHeadsUpDisplay(m_hudTexture.get(), hudSize);

    m_hudTexture->unreserve();
}
Beispiel #4
0
IntSize ScrollView::overhangAmount() const
{
    IntSize stretch;
    if (scrollY() < 0)
        stretch.setHeight(scrollY());
    else if (scrollY() > contentsHeight() - visibleContentRect().height())
        stretch.setHeight(scrollY() - (contentsHeight() - visibleContentRect().height()));

    if (scrollX() < 0)
        stretch.setWidth(scrollX());
    else if (scrollX() > contentsWidth() - visibleContentRect().width())
        stretch.setWidth(scrollX() - (contentsWidth() - visibleContentRect().width()));

    return stretch;
}
Beispiel #5
0
bool RenderThemeSafari::paintButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
    ASSERT(SafariThemeLibrary());

    // We inflate the rect as needed to account for padding included in the cell to accommodate the button
    // shadow.  We don't consider this part of the bounds of the control in WebKit.

    NSControlSize controlSize = controlSizeFromRect(r, buttonSizes());
    IntRect inflatedRect = r;

    ThemePart part;
    if (r.height() <= buttonSizes()[NSRegularControlSize].height()) {
        // Push button
        part = SafariTheme::PushButtonPart;

        IntSize size = buttonSizes()[controlSize];
        size.setWidth(r.width());

        // Center the button within the available space.
        if (inflatedRect.height() > size.height()) {
            inflatedRect.setY(inflatedRect.y() + (inflatedRect.height() - size.height()) / 2);
            inflatedRect.setHeight(size.height());
        }

        // Now inflate it to account for the shadow.
        inflatedRect = inflateRect(inflatedRect, size, buttonMargins(controlSize));
    } else
        part = SafariTheme::SquareButtonPart;

    paintThemePart(part, paintInfo.context->platformContext(), inflatedRect, controlSize, determineState(o));
    return false;
}
LayoutUnit RenderImage::computeReplacedLogicalWidth(bool includeMaxWidth) const
{
    // If we've got an explicit width/height assigned, propagate it to the image resource.    
    if (style()->logicalWidth().isFixed() && style()->logicalHeight().isFixed()) {
        LayoutUnit width = RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);
        m_imageResource->setContainerSizeForRenderer(IntSize(width, computeReplacedLogicalHeight()));
        return width;
    }

    IntSize containerSize;
    if (m_imageResource->imageHasRelativeWidth() || m_imageResource->imageHasRelativeHeight()) {
        // Propagate the containing block size to the image resource, otherwhise we can't compute our own intrinsic size, if it's relative.
        RenderObject* containingBlock = isPositioned() ? container() : this->containingBlock();
        if (containingBlock->isBox()) {
            RenderBox* box = toRenderBox(containingBlock);
            containerSize = IntSize(box->availableWidth(), box->availableHeight()); // Already contains zooming information.
        }
    } else {
        // Propagate the current zoomed image size to the image resource, otherwhise the image size will remain the same on-screen.
        CachedImage* cachedImage = m_imageResource->cachedImage();
        if (cachedImage && cachedImage->image()) {
            containerSize = cachedImage->image()->size();
            // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
            containerSize.setWidth(static_cast<LayoutUnit>(containerSize.width() * style()->effectiveZoom()));
            containerSize.setHeight(static_cast<LayoutUnit>(containerSize.height() * style()->effectiveZoom()));
        }
    }

    if (!containerSize.isEmpty()) {
        m_imageResource->setContainerSizeForRenderer(containerSize);
        const_cast<RenderImage*>(this)->updateIntrinsicSizeIfNeeded(containerSize, false);
    }

    return RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);
}
Beispiel #7
0
FloatSize AutoscrollController::calculateAutoscrollDelta() {
  LocalFrame* frame = m_autoscrollLayoutObject->frame();
  if (!frame)
    return FloatSize();

  IntPoint lastKnownMousePosition =
      frame->eventHandler().lastKnownMousePosition();

  // We need to check if the last known mouse position is out of the window.
  // When the mouse is out of the window, the position is incoherent
  static IntPoint previousMousePosition;
  if (lastKnownMousePosition.x() < 0 || lastKnownMousePosition.y() < 0)
    lastKnownMousePosition = previousMousePosition;
  else
    previousMousePosition = lastKnownMousePosition;

  IntSize delta = lastKnownMousePosition - m_middleClickAutoscrollStartPos;

  // at the center we let the space for the icon.
  if (abs(delta.width()) <= noMiddleClickAutoscrollRadius)
    delta.setWidth(0);
  if (abs(delta.height()) <= noMiddleClickAutoscrollRadius)
    delta.setHeight(0);
  return FloatSize(adjustedScrollDelta(delta));
}
Beispiel #8
0
IntSize DrawingBuffer::adjustSize(const IntSize& size) {
    IntSize adjustedSize = size;

    // Clamp if the desired size is greater than the maximum texture size for the device.
    if (adjustedSize.height() > m_maxTextureSize)
        adjustedSize.setHeight(m_maxTextureSize);

    if (adjustedSize.width() > m_maxTextureSize)
        adjustedSize.setWidth(m_maxTextureSize);

    // Try progressively smaller sizes until we find a size that fits or reach a scale limit.
    int scaleAttempts = 0;
    while ((s_currentResourceUsePixels + pixelDelta(adjustedSize)) > s_maximumResourceUsePixels) {
        scaleAttempts++;
        if (scaleAttempts > s_maxScaleAttempts)
            return IntSize();

        adjustedSize.scale(s_resourceAdjustedRatio);

        if (adjustedSize.isEmpty())
            return IntSize();
    }

    return adjustedSize;
}
IntSize ScrollView::overhangAmount() const
{
    IntSize stretch;

    int physicalScrollY = scrollPosition().y() + m_scrollOrigin.y();
    if (physicalScrollY < 0)
        stretch.setHeight(physicalScrollY);
    else if (physicalScrollY > contentsHeight() - visibleContentRect().height())
        stretch.setHeight(physicalScrollY - (contentsHeight() - visibleContentRect().height()));

    int physicalScrollX = scrollPosition().x() + m_scrollOrigin.x();
    if (physicalScrollX < 0)
        stretch.setWidth(physicalScrollX);
    else if (physicalScrollX > contentsWidth() - visibleContentRect().width())
        stretch.setWidth(physicalScrollX - (contentsWidth() - visibleContentRect().width()));

    return stretch;
}
Beispiel #10
0
IntSize ScrollbarGroup::contentsSize() const
{
    IntSize size;
    if (m_horizontalScrollbar)
        size.setWidth(m_horizontalScrollbar->scrollbar()->totalSize());
    else if (m_verticalScrollbar) {
        size.setWidth(m_verticalScrollbar->scrollbar()->x());
        if (m_verticalScrollbar->scrollbar()->isOverlayScrollbar())
            size.expand(WebPluginScrollbar::defaultThickness(), 0);
    }
    if (m_verticalScrollbar)
        size.setHeight(m_verticalScrollbar->scrollbar()->totalSize());
    else if (m_horizontalScrollbar) {
        size.setHeight(m_horizontalScrollbar->scrollbar()->y());
        if (m_horizontalScrollbar->scrollbar()->isOverlayScrollbar())
            size.expand(0, WebPluginScrollbar::defaultThickness());
    }
    return size;
}
PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(float sw, float sh) const
{
    FloatSize unscaledSize(sw, sh);
    IntSize scaledSize = m_canvas->convertLogicalToDevice(unscaledSize);
    if (scaledSize.width() < 1)
        scaledSize.setWidth(1);
    if (scaledSize.height() < 1)
        scaledSize.setHeight(1);
    
    return createEmptyImageData(scaledSize);
}
static inline IntSize outsetSizeForBlur(float stdDeviation)
{
    IntSize kernelSize = FEGaussianBlur::calculateUnscaledKernelSize(FloatPoint(stdDeviation, stdDeviation));

    IntSize outset;
    // We take the half kernel size and multiply it with three, because we run box blur three times.
    outset.setWidth(3 * kernelSize.width() * 0.5f);
    outset.setHeight(3 * kernelSize.height() * 0.5f);

    return outset;
}
Beispiel #13
0
void LayoutThemeDefault::setRadioSize(ComputedStyle& style) const
{
    // If the width and height are both specified, then we have nothing to do.
    if (!style.width().isIntrinsicOrAuto() && !style.height().isAuto())
        return;

    IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::PartRadio);
    float zoomLevel = style.effectiveZoom();
    size.setWidth(size.width() * zoomLevel);
    size.setHeight(size.height() * zoomLevel);
    setSizeIfAuto(style, size);
}
void RenderThemeChromiumDefault::setRadioSize(RenderStyle* style) const
{
    // If the width and height are both specified, then we have nothing to do.
    if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
        return;

    IntSize size = WebKit::Platform::current()->themeEngine()->getSize(WebKit::WebThemeEngine::PartRadio);
    float zoomLevel = style->effectiveZoom();
    size.setWidth(size.width() * zoomLevel);
    size.setHeight(size.height() * zoomLevel);
    setSizeIfAuto(style, size);
}
Beispiel #15
0
static inline IntSize outsetSizeForBlur(float stdDeviation)
{
    unsigned kernelSizeX = 0;
    unsigned kernelSizeY = 0;
    FEGaussianBlur::calculateUnscaledKernelSize(kernelSizeX, kernelSizeY, stdDeviation, stdDeviation);

    IntSize outset;
    // We take the half kernel size and multiply it with three, because we run box blur three times.
    outset.setWidth(3 * kernelSizeX * 0.5f);
    outset.setHeight(3 * kernelSizeY * 0.5f);

    return outset;
}
Beispiel #16
0
IntSize DrawingBuffer::adjustSize(const IntSize& desiredSize, const IntSize& curSize, int maxTextureSize)
{
    IntSize adjustedSize = desiredSize;

    // Clamp if the desired size is greater than the maximum texture size for the device.
    if (adjustedSize.height() > maxTextureSize)
        adjustedSize.setHeight(maxTextureSize);

    if (adjustedSize.width() > maxTextureSize)
        adjustedSize.setWidth(maxTextureSize);

    return adjustedSize;
}
Beispiel #17
0
IntSize FEGaussianBlur::calculateUnscaledKernelSize(const FloatPoint& stdDeviation)
{
    ASSERT(stdDeviation.x() >= 0 && stdDeviation.y() >= 0);
    IntSize kernelSize;

    if (stdDeviation.x())
        kernelSize.setWidth(clampedToKernelSize(stdDeviation.x()));

    if (stdDeviation.y())
        kernelSize.setHeight(clampedToKernelSize(stdDeviation.y()));

    return kernelSize;
}
void RenderStyle::getInnerBorderRadiiForRectWithBorderWidths(const IntRect& innerRect, unsigned short topWidth, unsigned short bottomWidth, unsigned short leftWidth, unsigned short rightWidth, IntSize& innerTopLeft, IntSize& innerTopRight, IntSize& innerBottomLeft, IntSize& innerBottomRight) const
{
    innerTopLeft = IntSize(surround->border.topLeft().width().calcValue(innerRect.width()), surround->border.topLeft().height().calcValue(innerRect.height()));
    innerTopRight = IntSize(surround->border.topRight().width().calcValue(innerRect.width()), surround->border.topRight().height().calcValue(innerRect.height()));
    innerBottomLeft = IntSize(surround->border.bottomLeft().width().calcValue(innerRect.width()), surround->border.bottomLeft().height().calcValue(innerRect.height()));
    innerBottomRight = IntSize(surround->border.bottomRight().width().calcValue(innerRect.width()), surround->border.bottomRight().height().calcValue(innerRect.height()));


    innerTopLeft.setWidth(max(0, innerTopLeft.width() - leftWidth));
    innerTopLeft.setHeight(max(0, innerTopLeft.height() - topWidth));

    innerTopRight.setWidth(max(0, innerTopRight.width() - rightWidth));
    innerTopRight.setHeight(max(0, innerTopRight.height() - topWidth));

    innerBottomLeft.setWidth(max(0, innerBottomLeft.width() - leftWidth));
    innerBottomLeft.setHeight(max(0, innerBottomLeft.height() - bottomWidth));

    innerBottomRight.setWidth(max(0, innerBottomRight.width() - rightWidth));
    innerBottomRight.setHeight(max(0, innerBottomRight.height() - bottomWidth));

    constrainCornerRadiiForRect(innerRect, innerTopLeft, innerTopRight, innerBottomLeft, innerBottomRight);
}
Beispiel #19
0
ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktopWidth, int deviceWidth, int deviceHeight, float devicePixelRatio, IntSize visibleViewport)
{
#if PLATFORM(IOS)
    // FIXME: This should probably be fixed elsewhere on iOS. iOS may only use computeViewportAttributes for tests.
    CGSize screenSize = wkGetViewportScreenSize();
    visibleViewport.setWidth(screenSize.width);
    visibleViewport.setHeight(screenSize.height);
#endif

    FloatSize initialViewportSize = convertToUserSpace(visibleViewport, devicePixelRatio);
    FloatSize deviceSize = convertToUserSpace(FloatSize(deviceWidth, deviceHeight), devicePixelRatio);

    return args.resolve(initialViewportSize, deviceSize, desktopWidth);
}
Beispiel #20
0
void clampImageBufferSizeToViewport(FrameView* frameView, IntSize& size)
{
    if (!frameView)
        return;

    int viewWidth = frameView->visibleWidth();
    int viewHeight = frameView->visibleHeight();

    if (size.width() > viewWidth)
        size.setWidth(viewWidth);

    if (size.height() > viewHeight)
        size.setHeight(viewHeight);
}
void ScrollView::setScrollOffset(const IntPoint& offset)
{
    int horizontalOffset = offset.x();
    int verticalOffset = offset.y();
    if (constrainsScrollingToContentEdge()) {
        horizontalOffset = max(min(horizontalOffset, contentsWidth() - visibleWidth()), 0);
        verticalOffset = max(min(verticalOffset, contentsHeight() - visibleHeight()), 0);
    }

    IntSize newOffset = m_scrollOffset;
    newOffset.setWidth(horizontalOffset - m_scrollOrigin.x());
    newOffset.setHeight(verticalOffset - m_scrollOrigin.y());

    scrollTo(newOffset);
}
PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(float sw, float sh, ExceptionCode& ec) const
{
    ec = 0;
    if (!isfinite(sw) || !isfinite(sh)) {
        ec = NOT_SUPPORTED_ERR;
        return 0;
    }
    FloatSize unscaledSize(sw, sh);
    IntSize scaledSize = canvas()->convertLogicalToDevice(unscaledSize);
    if (scaledSize.width() < 1)
        scaledSize.setWidth(1);
    if (scaledSize.height() < 1)
        scaledSize.setHeight(1);
    
    return createEmptyImageData(scaledSize);
}
Beispiel #23
0
bool RenderThemeSafari::paintMenuList(RenderObject* o, const PaintInfo& info, const IntRect& r)
{
    ASSERT(SafariThemeLibrary());

    NSControlSize controlSize = controlSizeFromRect(r, popupButtonSizes());
    IntRect inflatedRect = r;
    IntSize size = popupButtonSizes()[controlSize];
    size.setWidth(r.width());

    // Now inflate it to account for the shadow.
    if (r.width() >= minimumMenuListSize(o->style()))
        inflatedRect = inflateRect(inflatedRect, size, popupButtonMargins(controlSize));

    paintThemePart(DropDownButtonPart, info.context->platformContext(), inflatedRect, controlSize, determineState(o));

    return false;
}
Beispiel #24
0
void clampImageBufferSizeToViewport(RenderObject* object, IntSize& size)
{
    if (!object || !object->isRenderView())
        return;

    RenderView* view = static_cast<RenderView*>(object);
    if (!view->frameView())
        return;

    int viewWidth = view->frameView()->visibleWidth();
    int viewHeight = view->frameView()->visibleHeight();

    if (size.width() > viewWidth)
        size.setWidth(viewWidth);

    if (size.height() > viewHeight)
        size.setHeight(viewHeight);
}
Beispiel #25
0
IntSize FEGaussianBlur::calculateUnscaledKernelSize(const FloatPoint& std)
{
    ASSERT(std.x() >= 0 && std.y() >= 0);

    IntSize kernelSize;
    // Limit the kernel size to 1000. A bigger radius won't make a big difference for the result image but
    // inflates the absolute paint rect to much. This is compatible with Firefox' behavior.
    if (std.x()) {
        int size = std::max<unsigned>(2, static_cast<unsigned>(floorf(std.x() * gaussianKernelFactor() + 0.5f)));
        kernelSize.setWidth(std::min(size, gMaxKernelSize));
    }

    if (std.y()) {
        int size = std::max<unsigned>(2, static_cast<unsigned>(floorf(std.y() * gaussianKernelFactor() + 0.5f)));
        kernelSize.setHeight(std::min(size, gMaxKernelSize));
    }

    return kernelSize;
}
Beispiel #26
0
IntSize ScrollAnchor::computeAdjustment() const {
  // The anchor node can report fractional positions, but it is DIP-snapped when
  // painting (crbug.com/610805), so we must round the offsets to determine the
  // visual delta. If we scroll by the delta in LayoutUnits, the snapping of the
  // anchor node may round differently from the snapping of the scroll position.
  // (For example, anchor moving from 2.4px -> 2.6px is really 2px -> 3px, so we
  // should scroll by 1px instead of 0.2px.) This is true regardless of whether
  // the ScrollableArea actually uses fractional scroll positions.
  IntSize delta = roundedIntSize(computeRelativeOffset(m_anchorObject,
                                                       m_scroller, m_corner)) -
                  roundedIntSize(m_savedRelativeOffset);

  // Only adjust on the block layout axis.
  if (scrollerLayoutBox(m_scroller)->isHorizontalWritingMode())
    delta.setWidth(0);
  else
    delta.setHeight(0);
  return delta;
}
void RenderTheme::adjustRadioStyleUsingFallbackTheme(RenderStyle* style, Element*) const
{
    // If the width and height are both specified, then we have nothing to do.
    if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
        return;

    IntSize size = WebKit::Platform::current()->fallbackThemeEngine()->getSize(WebKit::WebFallbackThemeEngine::PartRadio);
    float zoomLevel = style->effectiveZoom();
    size.setWidth(size.width() * zoomLevel);
    size.setHeight(size.height() * zoomLevel);
    setSizeIfAuto(style, size);

    // padding - not honored by WinIE, needs to be removed.
    style->resetPadding();

    // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme)
    // for now, we will not honor it.
    style->resetBorder();
}
void ScrollView::valueChanged(Scrollbar* scrollbar)
{
    // Figure out if we really moved.
    IntSize newOffset = m_scrollOffset;
    if (scrollbar) {
        if (scrollbar->orientation() == HorizontalScrollbar)
            newOffset.setWidth(scrollbar->value());
        else if (scrollbar->orientation() == VerticalScrollbar)
            newOffset.setHeight(scrollbar->value());
    }

    IntSize scrollDelta = newOffset - m_scrollOffset;
    if (scrollDelta == IntSize())
        return;
    m_scrollOffset = newOffset;

    if (scrollbarsSuppressed())
        return;

    scrollContents(scrollDelta);
}
Beispiel #29
0
void Gradient::adjustParametersForTiledDrawing(IntSize& size, FloatRect& srcRect)
{
    if (m_radial)
        return;

    if (srcRect.isEmpty())
        return;

    if (m_p0.x() == m_p1.x()) {
        size.setWidth(1);
        srcRect.setWidth(1);
        srcRect.setX(0);
        return;
    }
    if (m_p0.y() != m_p1.y())
        return;

    size.setHeight(1);
    srcRect.setHeight(1);
    srcRect.setY(0);
}
static void adjustmentChanged(GtkAdjustment* adjustment, gpointer _that)
{
    ScrollView* that = reinterpret_cast<ScrollView*>(_that);

    // Figure out if we really moved.
    IntSize newOffset = that->scrollOffset();
    if (adjustment == that->m_horizontalAdjustment)
        newOffset.setWidth(static_cast<int>(gtk_adjustment_get_value(adjustment)));
    else if (adjustment == that->m_verticalAdjustment)
        newOffset.setHeight(static_cast<int>(gtk_adjustment_get_value(adjustment)));

    IntSize scrollDelta = newOffset - that->scrollOffset();
    if (scrollDelta == IntSize())
        return;
    that->setScrollOffset(newOffset);

    if (that->scrollbarsSuppressed())
        return;

    that->scrollContents(scrollDelta);
}