void RenderScrollbar::paintPart(GraphicsContext* graphicsContext, ScrollbarPart partType, const IntRect& rect) { RenderScrollbarPart* partRenderer = m_parts.get(partType); if (!partRenderer) return; partRenderer->paintIntoRect(graphicsContext, x(), y(), rect); }
void RenderScrollbar::updateScrollbarParts(bool destroy) { updateScrollbarPart(ScrollbarBGPart, destroy); updateScrollbarPart(BackButtonStartPart, destroy); updateScrollbarPart(ForwardButtonStartPart, destroy); updateScrollbarPart(BackTrackPart, destroy); updateScrollbarPart(ThumbPart, destroy); updateScrollbarPart(ForwardTrackPart, destroy); updateScrollbarPart(BackButtonEndPart, destroy); updateScrollbarPart(ForwardButtonEndPart, destroy); updateScrollbarPart(TrackBGPart, destroy); if (destroy) return; // See if the scrollbar's thickness changed. If so, we need to mark our owning object as needing a layout. bool isHorizontal = orientation() == HorizontalScrollbar; int oldThickness = isHorizontal ? height() : width(); int newThickness = 0; RenderScrollbarPart* part = m_parts.get(ScrollbarBGPart); if (part) { part->layout(); newThickness = isHorizontal ? part->height() : part->width(); } if (newThickness != oldThickness) { setFrameRect(IntRect(x(), y(), isHorizontal ? width() : newThickness, isHorizontal ? newThickness : height())); owningRenderer()->setChildNeedsLayout(true); } }
IntRect RenderScrollbar::buttonRect(ScrollbarPart partType) { RenderScrollbarPart* partRenderer = m_parts.get(partType); if (!partRenderer) return IntRect(); partRenderer->layout(); bool isHorizontal = orientation() == HorizontalScrollbar; IntSize pixelSnappedIntSize = snappedIntRect(partRenderer->frameRect()).size(); if (partType == BackButtonStartPart) return IntRect(location(), IntSize(isHorizontal ? pixelSnappedIntSize.width() : width(), isHorizontal ? height() : pixelSnappedIntSize.height())); if (partType == ForwardButtonEndPart) 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 ? pixelSnappedIntSize.width() : width(), isHorizontal ? height() : pixelSnappedIntSize.height()); } IntRect followingButton = buttonRect(ForwardButtonEndPart); 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()); }
int RenderScrollbar::minimumThumbLength() { RenderScrollbarPart* partRenderer = m_parts.get(ThumbPart); if (!partRenderer) return 0; partRenderer->layout(); return orientation() == HorizontalScrollbar ? partRenderer->width() : partRenderer->height(); }
float RenderScrollbar::opacity() { RenderScrollbarPart* partRenderer = m_parts.get(ScrollbarBGPart); if (!partRenderer) return 1; return partRenderer->style().opacity(); }
RenderScrollbar::RenderScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, RenderBox* renderer, Frame* owningFrame) : Scrollbar(client, orientation, RegularScrollbar, RenderScrollbarTheme::renderScrollbarTheme()) , m_owner(renderer) , m_owningFrame(owningFrame) { // FIXME: We need to do this because RenderScrollbar::styleChanged is called as soon as the scrollbar is created. // Update the scrollbar size. updateScrollbarPart(ScrollbarBGPart); RenderScrollbarPart* part = m_parts.get(ScrollbarBGPart); if (!part) return; part->layout(); setFrameRect(IntRect(0, 0, part->width(), part->height())); }
void RenderScrollbar::updateScrollbarPart(ScrollbarPart partType, bool destroy) { if (partType == NoPart) return; RefPtr<RenderStyle> partStyle = !destroy ? getScrollbarPseudoStyle(partType, pseudoForScrollbarPart(partType)) : PassRefPtr<RenderStyle>(0); bool needRenderer = !destroy && partStyle && partStyle->display() != NONE && partStyle->visibility() == VISIBLE; if (needRenderer && partStyle->display() != BLOCK) { // See if we are a button that should not be visible according to OS settings. ScrollbarButtonsPlacement buttonsPlacement = theme()->buttonsPlacement(); switch (partType) { case BackButtonStartPart: needRenderer = (buttonsPlacement == ScrollbarButtonsSingle || buttonsPlacement == ScrollbarButtonsDoubleStart || buttonsPlacement == ScrollbarButtonsDoubleBoth); break; case ForwardButtonStartPart: needRenderer = (buttonsPlacement == ScrollbarButtonsDoubleStart || buttonsPlacement == ScrollbarButtonsDoubleBoth); break; case BackButtonEndPart: needRenderer = (buttonsPlacement == ScrollbarButtonsDoubleEnd || buttonsPlacement == ScrollbarButtonsDoubleBoth); break; case ForwardButtonEndPart: needRenderer = (buttonsPlacement == ScrollbarButtonsSingle || buttonsPlacement == ScrollbarButtonsDoubleEnd || buttonsPlacement == ScrollbarButtonsDoubleBoth); break; default: break; } } RenderScrollbarPart* partRenderer = m_parts.get(partType); if (!partRenderer && needRenderer) { partRenderer = new (owningRenderer()->renderArena()) RenderScrollbarPart(owningRenderer()->document(), this, partType); m_parts.set(partType, partRenderer); } else if (partRenderer && !needRenderer) { m_parts.remove(partType); partRenderer->destroy(); partRenderer = 0; } if (partRenderer) partRenderer->setStyle(partStyle.release()); }
void RenderScrollbar::readyWRATHWidgetPart(ContextOfWRATH *ctx, PaintedWidgetsOfWRATHHandleT<Scrollbar> &hnd, ScrollbarPart partType, const IntRect &rect) { RenderScrollbar_RenderPart *d; d=RenderScrollbar_RenderPart::object(this, hnd); ContextOfWRATH::AutoPushNode autoPushRoot(ctx, d->m_root_node); d->m_part.visible(false); RenderScrollbarPart* partRenderer = m_parts.get(partType); if (!partRenderer) return; d->m_part.visible(true); partRenderer->readyWRATHWidgetIntoRect(d->m_part, ctx, x(), y(), rect); }
IntRect RenderScrollbar::trackPieceRectWithMargins(ScrollbarPart partType, const IntRect& oldRect) { RenderScrollbarPart* partRenderer = m_parts.get(partType); if (!partRenderer) return oldRect; partRenderer->layout(); IntRect rect = oldRect; if (orientation() == HorizontalScrollbar) { rect.setX(rect.x() + partRenderer->marginLeft()); rect.setWidth(rect.width() - (partRenderer->marginLeft() + partRenderer->marginRight())); } else { rect.setY(rect.y() + partRenderer->marginTop()); rect.setHeight(rect.height() - (partRenderer->marginTop() + partRenderer->marginBottom())); } return rect; }
IntRect RenderScrollbar::trackRect(int startLength, int endLength) { RenderScrollbarPart* part = m_parts.get(TrackBGPart); if (part) part->layout(); if (orientation() == HorizontalScrollbar) { int marginLeft = part ? part->marginLeft() : 0; int marginRight = part ? part->marginRight() : 0; startLength += marginLeft; endLength += marginRight; int totalLength = startLength + endLength; return IntRect(x() + startLength, y(), width() - totalLength, height()); } int marginTop = part ? part->marginTop() : 0; int marginBottom = part ? part->marginBottom() : 0; startLength += marginTop; endLength += marginBottom; int totalLength = startLength + endLength; return IntRect(x(), y() + startLength, width(), height() - totalLength); }
IntRect RenderScrollbar::buttonRect(ScrollbarPart partType) { RenderScrollbarPart* partRenderer = m_parts.get(partType); if (!partRenderer) return IntRect(); partRenderer->layout(); bool isHorizontal = orientation() == HorizontalScrollbar; if (partType == BackButtonStartPart) return IntRect(x(), y(), isHorizontal ? partRenderer->width() : width(), isHorizontal ? height() : partRenderer->height()); if (partType == ForwardButtonEndPart) return IntRect(isHorizontal ? x() + width() - partRenderer->width() : x(), isHorizontal ? y() : y() + height() - partRenderer->height(), isHorizontal ? partRenderer->width() : width(), isHorizontal ? height() : partRenderer->height()); if (partType == ForwardButtonStartPart) { IntRect previousButton = buttonRect(BackButtonStartPart); return IntRect(isHorizontal ? x() + previousButton.width() : x(), isHorizontal ? y() : y() + previousButton.height(), isHorizontal ? partRenderer->width() : width(), isHorizontal ? height() : partRenderer->height()); } IntRect followingButton = buttonRect(ForwardButtonEndPart); return IntRect(isHorizontal ? x() + width() - followingButton.width() - partRenderer->width() : x(), isHorizontal ? y() : y() + height() - followingButton.height() - partRenderer->height(), isHorizontal ? partRenderer->width() : width(), isHorizontal ? height() : partRenderer->height()); }
RenderScrollbarPart* RenderScrollbarPart::createAnonymous(Document* document, RenderScrollbar* scrollbar, ScrollbarPart part) { RenderScrollbarPart* renderer = new (document->renderArena()) RenderScrollbarPart(scrollbar, part); renderer->setDocumentForAnonymous(document); return renderer; }