Commit 933f110f authored by Robert O'Callahan's avatar Robert O'Callahan
Browse files

Bug 352093. Part 15: Rework scrolling so that we don't need a dedicated native...

Bug 352093. Part 15: Rework scrolling so that we don't need a dedicated native widget for scrollframes. r=dbaron,joshmoz,karlt,jmathies
parent e992230f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -93,7 +93,8 @@ public:
  // nsIScrollPositionListener
  NS_IMETHOD ScrollPositionWillChange(nsIScrollableView *aView,
                                      nscoord aX, nscoord aY);
  virtual void ViewPositionDidChange(nsIScrollableView* aScrollable) {}
  virtual void ViewPositionDidChange(nsIScrollableView* aScrollable,
                                     nsTArray<nsIWidget::Configuration>* aConfigurations) {}
  NS_IMETHOD ScrollPositionDidChange(nsIScrollableView *aView,
                                     nscoord aX, nscoord aY);

+5 −42
Original line number Diff line number Diff line
@@ -1381,40 +1381,6 @@ nsGfxScrollFrameInner::BuildDisplayList(nsDisplayListBuilder* aBuilder,
  return NS_OK;
}

PRBool
nsGfxScrollFrameInner::NeedsClipWidget() const
{
  // Scrollports contained in form controls (e.g., listboxes) don't get
  // widgets.  Also, transformed elements don't need clip widgets since they
  // result in graphical glitches.
  for (nsIFrame* parentFrame = mOuter; parentFrame;
       parentFrame = nsLayoutUtils::GetCrossDocParentFrame(parentFrame)) {
    
    /* See if we have a transform... we should have no widget if that's the case. */
    if (parentFrame->GetStyleDisplay()->HasTransform())
      return PR_FALSE;

    /* If we're a form element, we don't need a widget. */
    nsIFormControlFrame* fcFrame = do_QueryFrame(parentFrame);
    if (fcFrame) {
      return PR_FALSE;
    }
  }

  // Scrollports that don't ever show associated scrollbars don't get
  // widgets, because they will seldom actually be scrolled.
  nsIScrollableFrame *scrollableFrame = do_QueryFrame(mOuter);
  ScrollbarStyles scrollbars = scrollableFrame->GetScrollbarStyles();
  if ((scrollbars.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN
       || scrollbars.mHorizontal == NS_STYLE_OVERFLOW_VISIBLE)
      && (scrollbars.mVertical == NS_STYLE_OVERFLOW_HIDDEN
          || scrollbars.mVertical == NS_STYLE_OVERFLOW_VISIBLE)) {
    return PR_FALSE;
  }
 
  return PR_TRUE;
}

void
nsGfxScrollFrameInner::CreateScrollableView()
{
@@ -1429,11 +1395,6 @@ nsGfxScrollFrameInner::CreateScrollableView()

  // Insert the view into the view hierarchy
  viewManager->InsertChild(outerView, view, nsnull, PR_TRUE);

  // Have the scrolling view create its internal widgets
  if (NeedsClipWidget()) {
    mScrollableView->CreateScrollControls(); 
  }
}

static void HandleScrollPref(nsIScrollable *aScrollable, PRInt32 aOrientation,
@@ -1792,11 +1753,15 @@ nsGfxScrollFrameInner::InternalScrollPositionDidChange(nscoord aX, nscoord aY)
}

void
nsGfxScrollFrameInner::ViewPositionDidChange(nsIScrollableView* aScrollable)
nsGfxScrollFrameInner::ViewPositionDidChange(nsIScrollableView* aScrollable,
                                             nsTArray<nsIWidget::Configuration>* aConfigurations)
{
  // Update frame position to match view offsets
  nsPoint childOffset = mScrolledFrame->GetView()->GetOffsetTo(mOuter->GetView());
  mScrolledFrame->SetPosition(childOffset);

  mOuter->PresContext()->RootPresContext()->
    GetPluginGeometryUpdates(mOuter, aConfigurations);
}

/**
@@ -1817,8 +1782,6 @@ nsGfxScrollFrameInner::ScrollPositionDidChange(nsIScrollableView* aScrollable, n
  mOuter->InvalidateWithFlags(nsRect(nsPoint(0, 0), mOuter->GetSize()),
                              nsIFrame::INVALIDATE_NOTIFY_ONLY);

  mOuter->PresContext()->RootPresContext()->UpdatePluginGeometry(mOuter);

  return NS_OK;
}

+2 −2
Original line number Diff line number Diff line
@@ -79,7 +79,6 @@ public:
  // reload our child frame list.
  // We need this if a scrollbar frame is recreated.
  void ReloadChildFrames();
  PRBool NeedsClipWidget() const;
  void CreateScrollableView();

  nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
@@ -98,7 +97,8 @@ public:
  // nsIScrollPositionListener

  NS_IMETHOD ScrollPositionWillChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);
  virtual void ViewPositionDidChange(nsIScrollableView* aScrollable);
  virtual void ViewPositionDidChange(nsIScrollableView* aScrollable,
                                     nsTArray<nsIWidget::Configuration>* aConfigurations);
  NS_IMETHOD ScrollPositionDidChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);

  // This gets called when the 'curpos' attribute on one of the scrollbars changes
+2 −1
Original line number Diff line number Diff line
@@ -130,7 +130,8 @@ public:

  // nsIScrollPositionListener
  NS_IMETHOD ScrollPositionWillChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);
  virtual void ViewPositionDidChange(nsIScrollableView* aScrollable) {}
  virtual void ViewPositionDidChange(nsIScrollableView* aScrollable,
                                     nsTArray<nsIWidget::Configuration>* aConfigurations) {}
  NS_IMETHOD ScrollPositionDidChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);

  // nsICanvasFrame
+2 −1
Original line number Diff line number Diff line
@@ -362,7 +362,8 @@ public:

  // nsIScrollPositionListener interface
  NS_IMETHOD ScrollPositionWillChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);
  virtual void ViewPositionDidChange(nsIScrollableView* aScrollable) {}
  virtual void ViewPositionDidChange(nsIScrollableView* aScrollable,
                                     nsTArray<nsIWidget::Configuration>* aConfigurations) {}
  NS_IMETHOD ScrollPositionDidChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);

  //locals
Loading