Attachment #220737: updated patch for bug #130078

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

(-)mozilla/layout/base/nsDocumentViewer.cpp (-32 / +16 lines)
Line     Link Here 
 Lines 2285-2347   DocumentViewerImpl::MakeWindow(nsIWidget Link Here 
2285
  if (NS_FAILED(rv))
2285
  if (NS_FAILED(rv))
2286
    return rv;
2286
    return rv;
2287
2287
2288
  // Reset the bounds offset so the root view is set to 0,0. The
2288
  // Reset the bounds offset so the root view is set to 0,0. The
2289
  // offset is specified in nsIViewManager::Init above.
2289
  // offset is specified in nsIViewManager::Init above.
2290
  // Besides, layout will reset the root view to (0,0) during reflow,
2290
  // Besides, layout will reset the root view to (0,0) during reflow,
2291
  // so changing it to 0,0 eliminates placing the root view in the
2291
  // so changing it to 0,0 eliminates placing the root view in the
2292
  // wrong place initially.
2292
  // wrong place initially.
2293
  tbounds.x = 0;
2293
  tbounds.x = 0;
2294
  tbounds.y = 0;
2294
  tbounds.y = 0;
2295
2295
2296
  // Create a child window of the parent that is our "root view/window"
2296
  // Create a child window of the parent that is our "root view/window"
2297
  // if aParentWidget has a view, we'll hook our view manager up to its view tree
2298
  nsIView* containerView = nsView::GetViewFor(aParentWidget);
2297
  nsIView* containerView = nsView::GetViewFor(aParentWidget);
2299
2298
2300
  if (containerView) {
2301
    // see if the containerView has already been hooked into a foreign view manager hierarchy
2302
    // if it has, then we have to hook into the hierarchy too otherwise bad things will happen.
2303
    nsIViewManager* containerVM = containerView->GetViewManager();
2304
    nsIView* pView = containerView;
2305
    do {
2306
      pView = pView->GetParent();
2307
    } while (pView && pView->GetViewManager() == containerVM);
2308
2309
    if (!pView) {
2310
      // OK, so the container is not already hooked up into a foreign view manager hierarchy.
2311
      // That means we can choose not to hook ourselves up.
2312
      //
2313
      // If the parent container is a chrome shell then we won't hook into its view
2314
      // tree. This will improve performance a little bit (especially given scrolling/painting perf bugs)
2315
      // but is really just for peace of mind. This check can be removed if we want to support fancy
2316
      // chrome effects like transparent controls floating over content, transparent Web browsers, and
2317
      // things like that, and the perf bugs are fixed.
2318
      nsCOMPtr<nsIDocShellTreeItem> container(do_QueryReferent(mContainer));
2319
      nsCOMPtr<nsIDocShellTreeItem> parentContainer;
2320
      PRInt32 itemType;
2321
      if (nsnull == container
2322
          || NS_FAILED(container->GetParent(getter_AddRefs(parentContainer)))
2323
          || nsnull == parentContainer
2324
          || NS_FAILED(parentContainer->GetItemType(&itemType))
2325
          || itemType != nsIDocShellTreeItem::typeContent) {
2326
        containerView = nsnull;
2327
      }
2328
    }
2329
  }
2330
2331
  // Create a view
2299
  // Create a view
2332
  nsIView* view = mViewManager->CreateView(tbounds, containerView);
2300
  nsIView* view = mViewManager->CreateView(tbounds, containerView);
2333
  if (!view)
2301
  if (!view)
2334
    return NS_ERROR_OUT_OF_MEMORY;
2302
    return NS_ERROR_OUT_OF_MEMORY;
2335
2303
2304
  if (containerView) {
2305
    nsCOMPtr<nsIDocShellTreeItem> container(do_QueryReferent(mContainer));
2306
    nsCOMPtr<nsIDocShellTreeItem> parentContainer;
2307
    PRInt32 itemType;
2308
    PRInt32 parentItemType;
2309
    if (container
2310
        && NS_SUCCEEDED(container->GetItemType(&itemType))
2311
        && itemType == nsIDocShellTreeItem::typeContent
2312
        && NS_SUCCEEDED(container->GetParent(getter_AddRefs(parentContainer)))
2313
        && parentContainer
2314
        && NS_SUCCEEDED(parentContainer->GetItemType(&parentItemType))
2315
        && parentItemType != nsIDocShellTreeItem::typeContent) {
2316
      view->SetUseDefaultBackgroundColor(PR_TRUE);
2317
    }
2318
  }
2319
2336
  // pass in a native widget to be the parent widget ONLY if the view hierarchy will stand alone.
2320
  // pass in a native widget to be the parent widget ONLY if the view hierarchy will stand alone.
2337
  // otherwise the view will find its own parent widget and "do the right thing" to
2321
  // otherwise the view will find its own parent widget and "do the right thing" to
2338
  // establish a parent/child widget relationship
2322
  // establish a parent/child widget relationship
2339
  rv = view->CreateWidget(kWidgetCID, nsnull,
2323
  rv = view->CreateWidget(kWidgetCID, nsnull,
2340
                          containerView != nsnull ? nsnull : aParentWidget->GetNativeData(NS_NATIVE_WIDGET),
2324
                          containerView != nsnull ? nsnull : aParentWidget->GetNativeData(NS_NATIVE_WIDGET),
2341
                          PR_TRUE, PR_FALSE);
2325
                          PR_TRUE, PR_FALSE);
2342
  if (NS_FAILED(rv))
2326
  if (NS_FAILED(rv))
2343
    return rv;
2327
    return rv;
2344
2328
2345
  // Setup hierarchical relationship in view manager
2329
  // Setup hierarchical relationship in view manager
2346
  mViewManager->SetRootView(view);
2330
  mViewManager->SetRootView(view);
2347
2331
(-)mozilla/layout/base/nsDisplayList.cpp (-6 / +15 lines)
Line     Link Here 
 Lines 499-530   HasNonZeroBorderRadius(const nsStyleBord Link Here 
499
499
500
  return PR_FALSE;
500
  return PR_FALSE;
501
}
501
}
502
502
503
PRBool
503
PRBool
504
nsDisplayBackground::IsOpaque(nsDisplayListBuilder* aBuilder) {
504
nsDisplayBackground::IsOpaque(nsDisplayListBuilder* aBuilder) {
505
  // theme background overrides any other background
505
  // theme background overrides any other background
506
  if (mFrame->IsThemed())
506
  if (mFrame->IsThemed())
507
    return PR_FALSE;
507
    return PR_FALSE;
508
508
509
  PRBool isCanvas;
509
  PRBool isCanvas;
510
  const nsStyleBackground* bg;
510
  const nsStyleBackground* bg;
511
  nsPresContext* presContext = mFrame->GetPresContext();
511
  PRBool hasBG =
512
  PRBool hasBG =
512
    nsCSSRendering::FindBackground(mFrame->GetPresContext(), mFrame, &bg, &isCanvas);
513
    nsCSSRendering::FindBackground(presContext, mFrame, &bg, &isCanvas);
513
  if (!hasBG || (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) ||
514
  if (!hasBG)
514
      bg->mBackgroundClip != NS_STYLE_BG_CLIP_BORDER ||
515
      HasNonZeroBorderRadius(mFrame->GetStyleBorder()) ||
516
      NS_GET_A(bg->mBackgroundColor) < 255)
517
    return PR_FALSE;
515
    return PR_FALSE;
518
  return PR_TRUE;
516
  PRBool isTranslucentColor = NS_GET_A(bg->mBackgroundColor) < 255 ||
517
    (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT);
518
  if (isCanvas) {
519
    nsIView* rootView;
520
    presContext->GetViewManager()->GetRootView(rootView);
521
    if (rootView->IsUsingDefaultBackgroundColor()) {
522
      isTranslucentColor = NS_GET_A(presContext->DefaultBackgroundColor()) < 255;
523
    }
524
  }
525
  return !isTranslucentColor &&
526
    bg->mBackgroundClip == NS_STYLE_BG_CLIP_BORDER &&
527
    !HasNonZeroBorderRadius(mFrame->GetStyleBorder());
519
}
528
}
520
529
521
PRBool
530
PRBool
522
nsDisplayBackground::IsUniform(nsDisplayListBuilder* aBuilder) {
531
nsDisplayBackground::IsUniform(nsDisplayListBuilder* aBuilder) {
523
  // theme background overrides any other background
532
  // theme background overrides any other background
524
  if (mFrame->IsThemed())
533
  if (mFrame->IsThemed())
525
    return PR_FALSE;
534
    return PR_FALSE;
526
535
527
  PRBool isCanvas;
536
  PRBool isCanvas;
528
  const nsStyleBackground* bg;
537
  const nsStyleBackground* bg;
529
  PRBool hasBG =
538
  PRBool hasBG =
530
    nsCSSRendering::FindBackground(mFrame->GetPresContext(), mFrame, &bg, &isCanvas);
539
    nsCSSRendering::FindBackground(mFrame->GetPresContext(), mFrame, &bg, &isCanvas);
(-)mozilla/layout/base/nsCSSRendering.cpp (-12 / +11 lines)
Line     Link Here 
 Lines 2782-2818   nsCSSRendering::PaintBackground(nsPresCo Link Here 
2782
                          aDirtyRect, aBorderArea, *color, aBorder,
2782
                          aDirtyRect, aBorderArea, *color, aBorder,
2783
                          aPadding, aUsePrintSettings, aBGClipRect);
2783
                          aPadding, aUsePrintSettings, aBGClipRect);
2784
    return;
2784
    return;
2785
  }
2785
  }
2786
2786
2787
  nsStyleBackground canvasColor(*color);
2787
  nsStyleBackground canvasColor(*color);
2788
2788
2789
  nsIViewManager* vm = aPresContext->GetViewManager();
2789
  nsIViewManager* vm = aPresContext->GetViewManager();
2790
2790
2791
  if (canvasColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) {
2791
  if (canvasColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) {
2792
    nsIView* rootView;
2792
    nsIView* rootView;
2793
    vm->GetRootView(rootView);
2793
    vm->GetRootView(rootView);
2794
    if (!rootView->GetParent()) {
2794
    PRBool useDefaultBackgroundColor = rootView->IsUsingDefaultBackgroundColor();
2795
      PRBool widgetIsTranslucent = PR_FALSE;
2795
    if (!rootView->GetParent() && rootView->HasWidget()) {
2796
      PRBool widgetIsTranslucent;
2797
      rootView->GetWidget()->GetWindowTranslucency(widgetIsTranslucent);
2798
      useDefaultBackgroundColor = !widgetIsTranslucent;
2799
    }
2796
2800
2797
      if (rootView->HasWidget()) {
2801
    if (useDefaultBackgroundColor) {
2798
        rootView->GetWidget()->GetWindowTranslucency(widgetIsTranslucent);
2802
      // Ensure that we always paint a color for the root (in case there's
2799
      }
2803
      // no background at all or a partly transparent image).
2800
      
2804
      canvasColor.mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
2801
      if (!widgetIsTranslucent) {
2805
      canvasColor.mBackgroundColor = aPresContext->DefaultBackgroundColor();
2802
        // Ensure that we always paint a color for the root (in case there's
2803
        // no background at all or a partly transparent image).
2804
        canvasColor.mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
2805
        canvasColor.mBackgroundColor = aPresContext->DefaultBackgroundColor();
2806
      }
2807
    }
2806
    }
2808
  }
2807
  }
2809
2808
2810
  vm->SetDefaultBackgroundColor(canvasColor.mBackgroundColor);
2809
  vm->SetDefaultBackgroundColor(canvasColor.mBackgroundColor);
2811
2810
2812
  // Since nsHTMLContainerFrame::CreateViewForFrame might have created
2811
  // Since nsHTMLContainerFrame::CreateViewForFrame might have created
2813
  // the view before we knew about the child with the fixed background
2812
  // the view before we knew about the child with the fixed background
2814
  // attachment (root or BODY) or the stylesheet specifying that
2813
  // attachment (root or BODY) or the stylesheet specifying that
2815
  // attachment, set the BitBlt flag here as well.
2814
  // attachment, set the BitBlt flag here as well.
2816
  if (canvasColor.mBackgroundAttachment == NS_STYLE_BG_ATTACHMENT_FIXED) {
2815
  if (canvasColor.mBackgroundAttachment == NS_STYLE_BG_ATTACHMENT_FIXED) {
2817
    nsIView *view = aForFrame->GetView();
2816
    nsIView *view = aForFrame->GetView();
2818
    if (view)
2817
    if (view)
(-)mozilla/view/public/nsIView.h (+14 lines)
Line     Link Here 
 Lines 81-104   enum nsViewVisibility { Link Here 
81
81
82
// Indicates that the view is using auto z-indexing
82
// Indicates that the view is using auto z-indexing
83
#define NS_VIEW_FLAG_AUTO_ZINDEX          0x0004
83
#define NS_VIEW_FLAG_AUTO_ZINDEX          0x0004
84
84
85
// Indicates that the view is a floating view.
85
// Indicates that the view is a floating view.
86
#define NS_VIEW_FLAG_FLOATING             0x0008
86
#define NS_VIEW_FLAG_FLOATING             0x0008
87
87
88
// If set it indicates that this view should be
88
// If set it indicates that this view should be
89
// displayed above z-index:auto views if this view 
89
// displayed above z-index:auto views if this view 
90
// is z-index:auto also
90
// is z-index:auto also
91
#define NS_VIEW_FLAG_TOPMOST              0x0010
91
#define NS_VIEW_FLAG_TOPMOST              0x0010
92
92
93
#define NS_VIEW_FLAG_USE_DEFAULT_BACKGROUND 0x0020
94
93
struct nsViewZIndex {
95
struct nsViewZIndex {
94
  PRBool mIsAuto;
96
  PRBool mIsAuto;
95
  PRInt32 mZIndex;
97
  PRInt32 mZIndex;
96
  PRBool mIsTopmost;
98
  PRBool mIsTopmost;
97
  
99
  
98
  nsViewZIndex(PRBool aIsAuto, PRInt32 aZIndex, PRBool aIsTopmost)
100
  nsViewZIndex(PRBool aIsAuto, PRInt32 aZIndex, PRBool aIsTopmost)
99
    : mIsAuto(aIsAuto), mZIndex(aZIndex), mIsTopmost(aIsTopmost) {}
101
    : mIsAuto(aIsAuto), mZIndex(aZIndex), mIsTopmost(aIsTopmost) {}
100
};
102
};
101
103
102
//----------------------------------------------------------------------
104
//----------------------------------------------------------------------
103
105
104
/**
106
/**
 Lines 273-297   public: Link Here 
273
   */
275
   */
274
  void SetHasUniformBackground(PRBool aUniform) {
276
  void SetHasUniformBackground(PRBool aUniform) {
275
    if (aUniform) {
277
    if (aUniform) {
276
      mVFlags |= NS_VIEW_FLAG_UNIFORM_BACKGROUND;
278
      mVFlags |= NS_VIEW_FLAG_UNIFORM_BACKGROUND;
277
    } else {
279
    } else {
278
      mVFlags &= ~NS_VIEW_FLAG_UNIFORM_BACKGROUND;
280
      mVFlags &= ~NS_VIEW_FLAG_UNIFORM_BACKGROUND;
279
    }
281
    }
280
  }
282
  }
281
283
282
  PRBool HasUniformBackground() {
284
  PRBool HasUniformBackground() {
283
    return mVFlags & NS_VIEW_FLAG_UNIFORM_BACKGROUND;
285
    return mVFlags & NS_VIEW_FLAG_UNIFORM_BACKGROUND;
284
  }
286
  }
287
  
288
  void SetUseDefaultBackgroundColor(PRBool aUseDefault) {
289
    if (aUseDefault) {
290
      mVFlags |= NS_VIEW_FLAG_USE_DEFAULT_BACKGROUND;
291
    } else {
292
      mVFlags &= ~NS_VIEW_FLAG_USE_DEFAULT_BACKGROUND;
293
    }
294
  }
285
295
296
  PRBool IsUsingDefaultBackgroundColor() {
297
    return mVFlags & NS_VIEW_FLAG_USE_DEFAULT_BACKGROUND;
298
  }
299
  
286
  /**
300
  /**
287
   * Set the view's link to client owned data.
301
   * Set the view's link to client owned data.
288
   * @param aData - data to associate with view. nsnull to disassociate
302
   * @param aData - data to associate with view. nsnull to disassociate
289
   */
303
   */
290
  void SetClientData(void *aData) { mClientData = aData; }
304
  void SetClientData(void *aData) { mClientData = aData; }
291
305
292
  /**
306
  /**
293
   * Query the view for it's link to client owned data.
307
   * Query the view for it's link to client owned data.
294
   * @result data associated with view or nsnull if there is none.
308
   * @result data associated with view or nsnull if there is none.
295
   */
309
   */
296
  void* GetClientData() const { return mClientData; }
310
  void* GetClientData() const { return mClientData; }
297
311

Return to bug 130078