int LayoutScrollbar::minimumThumbLength() const
{
    LayoutScrollbarPart* partLayoutObject = m_parts.get(ThumbPart);
    if (!partLayoutObject)
        return 0;
    partLayoutObject->layout();
    return orientation() == HorizontalScrollbar ? partLayoutObject->size().width() : partLayoutObject->size().height();
}
Beispiel #2
0
void LayoutScrollbar::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;
  LayoutScrollbarPart* part = m_parts.get(ScrollbarBGPart);
  if (part) {
    part->layout();
    newThickness =
        (isHorizontal ? part->size().height() : part->size().width()).toInt();
  }

  if (newThickness != oldThickness) {
    setFrameRect(
        IntRect(location(), IntSize(isHorizontal ? width() : newThickness,
                                    isHorizontal ? newThickness : height())));
    if (LayoutBox* box = owningLayoutObjectWithinFrame()) {
      if (box->isLayoutBlock())
        toLayoutBlock(box)->notifyScrollbarThicknessChanged();
      box->setChildNeedsLayout();
      if (m_scrollableArea)
        m_scrollableArea->setScrollCornerNeedsPaintInvalidation();
    }
  }
}