Commit 42155761 authored by Robert O'Callahan's avatar Robert O'Callahan
Browse files

Bug 352093. Part 2: Create nsIViewManager::GetRootWidget.

parent f474c72e
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -59,10 +59,9 @@ enum nsRectVisibility {
  nsRectVisibility_kZeroAreaRect
}; 

// 98f676da-eb1a-467d-9c0e-0d64c2c88d85
#define NS_IVIEWMANAGER_IID   \
  { 0x98f676da, 0xeb1a, 0x467d, \
    { 0x9c, 0x0e, 0x0d, 0x64, 0xc2, 0xc8, 0x8d, 0x85 } }
  { 0x50c0a18c, 0x3e39, 0x4606, \
    { 0x85, 0x77, 0xe7, 0x3a, 0xcc, 0xb4, 0x66, 0xc9 } }

class nsIViewManager : public nsISupports
{
@@ -424,6 +423,12 @@ public:
   */
  NS_IMETHOD GetWidget(nsIWidget **aWidget) = 0;

  /**
   * Retrieve the widget at the root of the nearest enclosing
   * view manager whose root view has a widget.
   */
  NS_IMETHOD GetRootWidget(nsIWidget **aWidget) = 0;

  /**
   * Force update of view manager widget
   * Callers should use UpdateView(view, NS_VMREFRESH_IMMEDIATE) in most cases instead
+17 −0
Original line number Diff line number Diff line
@@ -1874,6 +1874,23 @@ NS_IMETHODIMP nsViewManager::GetWidget(nsIWidget **aWidget)
  return NS_OK;
}

NS_IMETHODIMP nsViewManager::GetRootWidget(nsIWidget **aWidget)
{
  if (!mRootView) {
    *aWidget = nsnull;
    return NS_OK;
  }
  if (mRootView->HasWidget()) {
    *aWidget = mRootView->GetWidget();
    NS_ADDREF(*aWidget);
    return NS_OK;
  }
  if (mRootView->GetParent())
    return mRootView->GetParent()->GetViewManager()->GetRootWidget(aWidget);
  *aWidget = nsnull;
  return NS_OK;
}

NS_IMETHODIMP nsViewManager::ForceUpdate()
{
  if (!IsRootVM()) {
+1 −0
Original line number Diff line number Diff line
@@ -173,6 +173,7 @@ public:

  NS_IMETHOD GetWidget(nsIWidget **aWidget);
  nsIWidget* GetWidget() { return mRootView ? mRootView->GetWidget() : nsnull; }
  NS_IMETHOD GetRootWidget(nsIWidget **aWidget);
  NS_IMETHOD ForceUpdate();
 
  NS_IMETHOD IsPainting(PRBool& aIsPainting);