From 13f7fca222eeadb3c3ecb6aa2eb5a645fbcde89f Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Thu, 30 Jun 2011 15:33:58 +0200 Subject: [PATCH] Bug 668319 - Allow to set opacity on ::-moz-tree-cell-text. r=roc --- layout/reftests/bugs/668319-1.xul | 20 +++++++++++++++++++ layout/reftests/bugs/reftest.list | 1 + .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 14 +++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 layout/reftests/bugs/668319-1.xul diff --git a/layout/reftests/bugs/668319-1.xul b/layout/reftests/bugs/668319-1.xul new file mode 100644 index 00000000000..fdf135b94a2 --- /dev/null +++ b/layout/reftests/bugs/668319-1.xul @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index d5023931d68..5a2076849ed 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1646,3 +1646,4 @@ fails-if(layersGPUAccelerated&&cocoaWidget) == 654950-1.html 654950-1-ref.html # == 658952.html 658952-ref.html == 664127-1.xul 664127-1-ref.xul == 660682-1.html 660682-1-ref.html +== 668319-1.xul about:blank diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 5adc6de25ba..b0bef65f6ea 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -3553,6 +3553,9 @@ nsTreeBodyFrame::PaintText(PRInt32 aRowIndex, // out and to paint. nsStyleContext* textContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext); + // Obtain opacity value for the image. + float opacity = textContext->GetStyleDisplay()->mOpacity; + // Obtain the margins for the text and then deflate our rect by that // amount. The text is assumed to be contained within the deflated rect. nsRect textRect(aTextRect); @@ -3619,8 +3622,19 @@ nsTreeBodyFrame::PaintText(PRInt32 aRowIndex, PRUint8 direction = aTextRTL ? NS_STYLE_DIRECTION_RTL : NS_STYLE_DIRECTION_LTR; + gfxContext* ctx = aRenderingContext.ThebesContext(); + if (opacity != 1.0f) { + ctx->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA); + } + nsLayoutUtils::DrawString(this, &aRenderingContext, text.get(), text.Length(), textRect.TopLeft() + nsPoint(0, baseline), direction); + + if (opacity != 1.0f) { + ctx->PopGroupToSource(); + ctx->Paint(opacity); + } + #ifdef MOZ_TIMELINE NS_TIMELINE_STOP_TIMER("Render Outline Text"); NS_TIMELINE_MARK_TIMER("Render Outline Text");