Bug 655877 - Part 27: Ignore text-shadow in SVG text frames. r=roc

This commit is contained in:
Cameron McCormack 2012-08-08 21:37:13 +10:00
parent a4823ad875
commit 444f2c079a
4 changed files with 30 additions and 6 deletions

View File

@ -76,6 +76,7 @@
#include "nsSVGIntegrationUtils.h"
#include "nsSVGForeignObjectFrame.h"
#include "nsSVGOuterSVGFrame.h"
#include "nsStyleStructInlines.h"
#include "mozilla/Preferences.h"
@ -2118,7 +2119,7 @@ nsLayoutUtils::GetTextShadowRectsUnion(const nsRect& aTextAndDecorationsRect,
PRUint32 aFlags)
{
const nsStyleText* textStyle = aFrame->GetStyleText();
if (!textStyle->mTextShadow)
if (!textStyle->HasTextShadow(aFrame))
return aTextAndDecorationsRect;
nsRect resultRect = aTextAndDecorationsRect;
@ -3224,7 +3225,7 @@ nsLayoutUtils::PaintTextShadow(const nsIFrame* aFrame,
void* aCallbackData)
{
const nsStyleText* textStyle = aFrame->GetStyleText();
if (!textStyle->mTextShadow)
if (!textStyle->HasTextShadow(aFrame))
return;
// Text shadow happens with the last value being painted at the back,

View File

@ -5075,10 +5075,14 @@ static bool GetSelectionTextColors(SelectionType aType,
* If text-shadow was not specified, *aShadow is left untouched
* (NOT reset to null), and the function returns false.
*/
static bool GetSelectionTextShadow(SelectionType aType,
static bool GetSelectionTextShadow(nsIFrame* aFrame,
SelectionType aType,
nsTextPaintStyle& aTextPaintStyle,
nsCSSShadowArray** aShadow)
{
if (aFrame->IsSVGText()) {
return false;
}
switch (aType) {
case nsISelectionController::SELECTION_NORMAL:
return aTextPaintStyle.GetSelectionShadow(aShadow);
@ -5374,8 +5378,8 @@ nsTextFrame::PaintTextWithSelectionColors(gfxContext* aCtx,
// Determine what shadow, if any, to draw - either from textStyle
// or from the ::-moz-selection pseudo-class if specified there
nsCSSShadowArray *shadow = textStyle->mTextShadow;
GetSelectionTextShadow(type, aTextPaintStyle, &shadow);
nsCSSShadowArray *shadow = textStyle->GetTextShadow(this);
GetSelectionTextShadow(this, type, aTextPaintStyle, &shadow);
// Draw shadows, if any
if (shadow) {
@ -5742,7 +5746,7 @@ nsTextFrame::PaintText(nsRenderingContext* aRenderingContext, nsPoint aPt,
nscolor foregroundColor = textPaintStyle.GetTextColor();
if (!aCallbacks) {
const nsStyleText* textStyle = GetStyleText();
if (textStyle->mTextShadow) {
if (textStyle->HasTextShadow(this)) {
// Text shadow happens with the last value being painted at the back,
// ie. it is painted first.
gfxTextRun::Metrics shadowMetrics =

View File

@ -1324,6 +1324,10 @@ struct nsStyleText {
bool WordCanWrap() const {
return WhiteSpaceCanWrap() && mWordWrap == NS_STYLE_WORDWRAP_BREAK_WORD;
}
// These are defined in nsStyleStructInlines.h.
inline bool HasTextShadow(const nsIFrame* aFrame) const;
inline nsCSSShadowArray* GetTextShadow(const nsIFrame* aFrame) const;
};
struct nsStyleVisibility {

View File

@ -55,6 +55,21 @@ nsStyleBorder::GetSubImage(PRUint8 aIndex) const
return subImage;
}
bool
nsStyleText::HasTextShadow(const nsIFrame* aFrame) const
{
return mTextShadow && !aFrame->IsSVGText();
}
nsCSSShadowArray*
nsStyleText::GetTextShadow(const nsIFrame* aFrame) const
{
if (aFrame->IsSVGText()) {
return nullptr;
}
return mTextShadow;
}
bool
nsStyleDisplay::IsBlockInside(const nsIFrame* aFrame) const
{