diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderScrollbar.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/rendering/RenderScrollbar.cpp')
-rw-r--r-- | Source/WebCore/rendering/RenderScrollbar.cpp | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/Source/WebCore/rendering/RenderScrollbar.cpp b/Source/WebCore/rendering/RenderScrollbar.cpp index 4bd887f8f..56bf759cc 100644 --- a/Source/WebCore/rendering/RenderScrollbar.cpp +++ b/Source/WebCore/rendering/RenderScrollbar.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2009, 2013 Apple Inc. All Rights Reserved. + * Copyright (C) 2008, 2009, 2013, 2015 Apple Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,13 +36,13 @@ namespace WebCore { -RefPtr<Scrollbar> RenderScrollbar::createCustomScrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, Element* ownerElement, Frame* owningFrame) +Ref<Scrollbar> RenderScrollbar::createCustomScrollbar(ScrollableArea& scrollableArea, ScrollbarOrientation orientation, Element* ownerElement, Frame* owningFrame) { - return adoptRef(new RenderScrollbar(scrollableArea, orientation, ownerElement, owningFrame)); + return adoptRef(*new RenderScrollbar(scrollableArea, orientation, ownerElement, owningFrame)); } -RenderScrollbar::RenderScrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, Element* ownerElement, Frame* owningFrame) - : Scrollbar(scrollableArea, orientation, RegularScrollbar, RenderScrollbarTheme::renderScrollbarTheme()) +RenderScrollbar::RenderScrollbar(ScrollableArea& scrollableArea, ScrollbarOrientation orientation, Element* ownerElement, Frame* owningFrame) + : Scrollbar(scrollableArea, orientation, RegularScrollbar, RenderScrollbarTheme::renderScrollbarTheme(), true) , m_ownerElement(ownerElement) , m_owningFrame(owningFrame) { @@ -77,7 +77,9 @@ RenderBox* RenderScrollbar::owningRenderer() const return currentRenderer; } ASSERT(m_ownerElement); - return m_ownerElement->renderer() ? m_ownerElement->renderer()->enclosingBox() : nullptr; + if (m_ownerElement->renderer()) + return &m_ownerElement->renderer()->enclosingBox(); + return nullptr; } void RenderScrollbar::setParent(ScrollView* parent) @@ -100,9 +102,9 @@ void RenderScrollbar::styleChanged() updateScrollbarParts(); } -void RenderScrollbar::paint(GraphicsContext* context, const IntRect& damageRect) +void RenderScrollbar::paint(GraphicsContext& context, const IntRect& damageRect, Widget::SecurityOriginPaintPolicy) { - if (context->updatingControlTints()) { + if (context.updatingControlTints()) { updateScrollbarParts(); return; } @@ -136,12 +138,12 @@ void RenderScrollbar::setPressedPart(ScrollbarPart part) updateScrollbarPart(TrackBGPart); } -PassRefPtr<RenderStyle> RenderScrollbar::getScrollbarPseudoStyle(ScrollbarPart partType, PseudoId pseudoId) +std::unique_ptr<RenderStyle> RenderScrollbar::getScrollbarPseudoStyle(ScrollbarPart partType, PseudoId pseudoId) { if (!owningRenderer()) return 0; - RefPtr<RenderStyle> result = owningRenderer()->getUncachedPseudoStyle(PseudoStyleRequest(pseudoId, this, partType), &owningRenderer()->style()); + std::unique_ptr<RenderStyle> result = owningRenderer()->getUncachedPseudoStyle(PseudoStyleRequest(pseudoId, this, partType), &owningRenderer()->style()); // Scrollbars for root frames should always have background color // unless explicitly specified as transparent. So we force it. // This is because WebKit assumes scrollbar to be always painted and missing background @@ -211,12 +213,12 @@ void RenderScrollbar::updateScrollbarPart(ScrollbarPart partType) if (partType == NoPart) return; - RefPtr<RenderStyle> partStyle = getScrollbarPseudoStyle(partType, pseudoForScrollbarPart(partType)); + std::unique_ptr<RenderStyle> partStyle = getScrollbarPseudoStyle(partType, pseudoForScrollbarPart(partType)); bool needRenderer = partStyle && partStyle->display() != NONE; if (needRenderer && partStyle->display() != BLOCK) { // See if we are a button that should not be visible according to OS settings. - ScrollbarButtonsPlacement buttonsPlacement = theme()->buttonsPlacement(); + ScrollbarButtonsPlacement buttonsPlacement = theme().buttonsPlacement(); switch (partType) { case BackButtonStartPart: needRenderer = (buttonsPlacement == ScrollbarButtonsSingle || buttonsPlacement == ScrollbarButtonsDoubleStart || @@ -243,14 +245,14 @@ void RenderScrollbar::updateScrollbarPart(ScrollbarPart partType) } if (auto& partRendererSlot = m_parts.add(partType, nullptr).iterator->value) - partRendererSlot->setStyle(partStyle.releaseNonNull()); + partRendererSlot->setStyle(WTFMove(*partStyle)); else { - partRendererSlot = createRenderer<RenderScrollbarPart>(owningRenderer()->document(), partStyle.releaseNonNull(), this, partType); + partRendererSlot = createRenderer<RenderScrollbarPart>(owningRenderer()->document(), WTFMove(*partStyle), this, partType); partRendererSlot->initializeStyle(); } } -void RenderScrollbar::paintPart(GraphicsContext* graphicsContext, ScrollbarPart partType, const IntRect& rect) +void RenderScrollbar::paintPart(GraphicsContext& graphicsContext, ScrollbarPart partType, const IntRect& rect) { RenderScrollbarPart* partRenderer = m_parts.get(partType); if (!partRenderer) @@ -267,27 +269,27 @@ IntRect RenderScrollbar::buttonRect(ScrollbarPart partType) partRenderer->layout(); bool isHorizontal = orientation() == HorizontalScrollbar; + IntSize pixelSnappedIntSize = snappedIntRect(partRenderer->frameRect()).size(); if (partType == BackButtonStartPart) - return IntRect(location(), IntSize(isHorizontal ? partRenderer->pixelSnappedWidth() : width(), isHorizontal ? height() : partRenderer->pixelSnappedHeight())); + return IntRect(location(), IntSize(isHorizontal ? pixelSnappedIntSize.width() : width(), isHorizontal ? height() : pixelSnappedIntSize.height())); if (partType == ForwardButtonEndPart) - return IntRect(isHorizontal ? x() + width() - partRenderer->pixelSnappedWidth() : x(), - isHorizontal ? y() : y() + height() - partRenderer->pixelSnappedHeight(), - isHorizontal ? partRenderer->pixelSnappedWidth() : width(), - isHorizontal ? height() : partRenderer->pixelSnappedHeight()); + return IntRect(isHorizontal ? x() + width() - pixelSnappedIntSize.width() : x(), isHorizontal ? y() : y() + height() - pixelSnappedIntSize.height(), + isHorizontal ? pixelSnappedIntSize.width() : width(), + isHorizontal ? height() : pixelSnappedIntSize.height()); if (partType == ForwardButtonStartPart) { IntRect previousButton = buttonRect(BackButtonStartPart); return IntRect(isHorizontal ? x() + previousButton.width() : x(), isHorizontal ? y() : y() + previousButton.height(), - isHorizontal ? partRenderer->pixelSnappedWidth() : width(), - isHorizontal ? height() : partRenderer->pixelSnappedHeight()); + isHorizontal ? pixelSnappedIntSize.width() : width(), + isHorizontal ? height() : pixelSnappedIntSize.height()); } IntRect followingButton = buttonRect(ForwardButtonEndPart); - return IntRect(isHorizontal ? x() + width() - followingButton.width() - partRenderer->pixelSnappedWidth() : x(), - isHorizontal ? y() : y() + height() - followingButton.height() - partRenderer->pixelSnappedHeight(), - isHorizontal ? partRenderer->pixelSnappedWidth() : width(), - isHorizontal ? height() : partRenderer->pixelSnappedHeight()); + return IntRect(isHorizontal ? x() + width() - followingButton.width() - pixelSnappedIntSize.width() : x(), + isHorizontal ? y() : y() + height() - followingButton.height() - pixelSnappedIntSize.height(), + isHorizontal ? pixelSnappedIntSize.width() : width(), + isHorizontal ? height() : pixelSnappedIntSize.height()); } IntRect RenderScrollbar::trackRect(int startLength, int endLength) @@ -325,10 +327,10 @@ IntRect RenderScrollbar::trackPieceRectWithMargins(ScrollbarPart partType, const IntRect rect = oldRect; if (orientation() == HorizontalScrollbar) { rect.setX(rect.x() + partRenderer->marginLeft()); - rect.setWidth(rect.width() - partRenderer->marginWidth()); + rect.setWidth(rect.width() - partRenderer->horizontalMarginExtent()); } else { rect.setY(rect.y() + partRenderer->marginTop()); - rect.setHeight(rect.height() - partRenderer->marginHeight()); + rect.setHeight(rect.height() - partRenderer->verticalMarginExtent()); } return rect; } |