Attachment #425945: Part 1: hookup view managers unconditionally for bug #130078

View | Details | Raw Unified | Return to bug 130078
Collapse All | Expand All

(-)a/layout/base/nsDocumentViewer.cpp (-48 / +6 lines)
Line     Link Here 
 Lines 2329-2355   DocumentViewerImpl::MakeWindow(const nsS Link Here 
2329
  return rv;
2329
  return rv;
2330
}
2330
}
2331
2331
2332
nsIView*
2332
nsIView*
2333
DocumentViewerImpl::FindContainerView()
2333
DocumentViewerImpl::FindContainerView()
2334
{
2334
{
2335
  nsIView* containerView = nsnull;
2335
  nsIView* containerView = nsnull;
2336
2336
2337
  nsCOMPtr<nsIContent> containerElement;
2338
  nsCOMPtr<nsIDocShellTreeItem> docShellItem = do_QueryReferent(mContainer);
2339
  nsCOMPtr<nsPIDOMWindow> pwin(do_GetInterface(docShellItem));
2340
  if (pwin) {
2341
    containerElement = do_QueryInterface(pwin->GetFrameElementInternal());
2342
  }
2343
        
2344
  if (mParentWidget) {
2337
  if (mParentWidget) {
2345
    containerView = nsIView::GetViewFor(mParentWidget);
2338
    containerView = nsIView::GetViewFor(mParentWidget);
2346
  } else {
2339
  } else if (mContainer) {
2347
    if (mContainer && pwin) {
2340
    nsCOMPtr<nsIDocShellTreeItem> docShellItem = do_QueryReferent(mContainer);
2341
    nsCOMPtr<nsPIDOMWindow> pwin(do_GetInterface(docShellItem));
2342
    if (pwin) {
2343
      nsCOMPtr<nsIContent> containerElement = do_QueryInterface(pwin->GetFrameElementInternal());
2348
      nsCOMPtr<nsIPresShell> parentPresShell;
2344
      nsCOMPtr<nsIPresShell> parentPresShell;
2349
      if (docShellItem) {
2345
      if (docShellItem) {
2350
        nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem;
2346
        nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem;
2351
        docShellItem->GetParent(getter_AddRefs(parentDocShellItem));
2347
        docShellItem->GetParent(getter_AddRefs(parentDocShellItem));
2352
        if (parentDocShellItem) {
2348
        if (parentDocShellItem) {
2353
          nsCOMPtr<nsIDocShell> parentDocShell = do_QueryInterface(parentDocShellItem);
2349
          nsCOMPtr<nsIDocShell> parentDocShell = do_QueryInterface(parentDocShellItem);
2354
          parentDocShell->GetPresShell(getter_AddRefs(parentPresShell));
2350
          parentDocShell->GetPresShell(getter_AddRefs(parentPresShell));
2355
        }
2351
        }
 Lines 2377-2431   DocumentViewerImpl::FindContainerView() Link Here 
2377
          }
2373
          }
2378
        } else {
2374
        } else {
2379
          NS_WARNING("Subdocument container has no frame");
2375
          NS_WARNING("Subdocument container has no frame");
2380
        }
2376
        }
2381
      }
2377
      }
2382
    }
2378
    }
2383
  }
2379
  }
2384
2380
2385
  if (!containerView)
2381
  return containerView;
2386
    return nsnull;
2387
2388
  if (containerElement &&
2389
      containerElement->HasAttr(kNameSpaceID_None, nsGkAtoms::transparent))
2390
    return containerView;
2391
2392
  nsIWidget* outerWidget = containerView->GetNearestWidget(nsnull);
2393
  if (outerWidget &&
2394
      outerWidget->GetTransparencyMode() == eTransparencyTransparent)
2395
    return containerView;
2396
2397
  // see if the containerView has already been hooked into a foreign view manager hierarchy
2398
  // if it has, then we have to hook into the hierarchy too otherwise bad things will happen.
2399
  nsIViewManager* containerVM = containerView->GetViewManager();
2400
  nsIView* pView = containerView;
2401
  do {
2402
    pView = pView->GetParent();
2403
  } while (pView && pView->GetViewManager() == containerVM);
2404
  if (pView)
2405
    return containerView;
2406
2407
  // OK, so the container is not already hooked up into a foreign view manager hierarchy.
2408
  // That means we can choose not to hook ourselves up.
2409
  //
2410
  // If the parent container is a chrome shell and we are a content shell
2411
  // then we won't hook into its view
2412
  // tree. This will improve performance a little bit (especially given scrolling/painting perf bugs)
2413
  // but is really just for peace of mind. This check can be removed if we want to support fancy
2414
  // chrome effects like transparent controls floating over content, transparent Web browsers, and
2415
  // things like that, and the perf bugs are fixed.
2416
  nsCOMPtr<nsIDocShellTreeItem> container(do_QueryReferent(mContainer));
2417
  if (container) {
2418
    nsCOMPtr<nsIDocShellTreeItem> sameTypeParent;
2419
    container->GetSameTypeParent(getter_AddRefs(sameTypeParent));
2420
    if (sameTypeParent)
2421
      return containerView;
2422
  }
2423
  return nsnull;
2424
}
2382
}
2425
2383
2426
nsresult
2384
nsresult
2427
DocumentViewerImpl::CreateDeviceContext(nsIView* aContainerView)
2385
DocumentViewerImpl::CreateDeviceContext(nsIView* aContainerView)
2428
{
2386
{
2429
  NS_PRECONDITION(!mPresShell && !mPresContext && !mWindow,
2387
  NS_PRECONDITION(!mPresShell && !mPresContext && !mWindow,
2430
                  "This will screw up our existing presentation");
2388
                  "This will screw up our existing presentation");
2431
  NS_PRECONDITION(mDocument, "Gotta have a document here");
2389
  NS_PRECONDITION(mDocument, "Gotta have a document here");

Return to bug 130078