2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* structs that contain the data provided by nsStyleContext, the
|
|
|
|
* internal API for computed style data for an element
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsStyleStruct.h"
|
2008-07-16 23:30:25 -07:00
|
|
|
#include "nsStyleStructInlines.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsStyleConsts.h"
|
2007-09-05 03:27:06 -07:00
|
|
|
#include "nsThemeConstants.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsPresContext.h"
|
2009-04-01 14:59:02 -07:00
|
|
|
#include "nsIWidget.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIStyleRule.h"
|
2011-06-20 22:03:59 -07:00
|
|
|
#include "nsCRTGlue.h"
|
2009-08-20 14:52:47 -07:00
|
|
|
#include "nsCSSProps.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsHTMLReflowState.h"
|
|
|
|
#include "prenv.h"
|
|
|
|
|
2010-10-06 15:18:52 -07:00
|
|
|
#include "nsSVGUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsBidiUtils.h"
|
2011-01-13 02:40:12 -08:00
|
|
|
#include "nsLayoutUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "imgIRequest.h"
|
2009-08-21 13:39:25 -07:00
|
|
|
#include "imgIContainer.h"
|
2007-10-08 14:58:22 -07:00
|
|
|
#include "prlog.h"
|
|
|
|
|
2012-02-23 08:19:00 -08:00
|
|
|
MOZ_STATIC_ASSERT((((1 << nsStyleStructID_Length) - 1) &
|
|
|
|
~(NS_STYLE_INHERIT_MASK)) == 0,
|
|
|
|
"Not enough bits in NS_STYLE_INHERIT_MASK");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
inline bool IsFixedUnit(const nsStyleCoord& aCoord, bool aEnumOK)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-08-31 09:05:12 -07:00
|
|
|
return aCoord.ConvertsToLength() ||
|
|
|
|
(aEnumOK && aCoord.GetUnit() == eStyleUnit_Enumerated);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool EqualURIs(nsIURI *aURI1, nsIURI *aURI2)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-28 23:19:26 -07:00
|
|
|
bool eq;
|
2007-03-22 10:30:00 -07:00
|
|
|
return aURI1 == aURI2 || // handle null==null, and optimize
|
|
|
|
(aURI1 && aURI2 &&
|
|
|
|
NS_SUCCEEDED(aURI1->Equals(aURI2, &eq)) && // not equal on fail
|
|
|
|
eq);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool EqualURIs(nsCSSValue::URL *aURI1, nsCSSValue::URL *aURI2)
|
2007-07-18 14:56:57 -07:00
|
|
|
{
|
|
|
|
return aURI1 == aURI2 || // handle null==null, and optimize
|
|
|
|
(aURI1 && aURI2 && aURI1->URIEquals(*aURI2));
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool EqualImages(imgIRequest *aImage1, imgIRequest* aImage2)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aImage1 == aImage2) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!aImage1 || !aImage2) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri1, uri2;
|
|
|
|
aImage1->GetURI(getter_AddRefs(uri1));
|
|
|
|
aImage2->GetURI(getter_AddRefs(uri2));
|
|
|
|
return EqualURIs(uri1, uri2);
|
|
|
|
}
|
|
|
|
|
2011-06-20 22:03:59 -07:00
|
|
|
// A nullsafe wrapper for strcmp. We depend on null-safety.
|
|
|
|
static int safe_strcmp(const PRUnichar* a, const PRUnichar* b)
|
|
|
|
{
|
|
|
|
if (!a || !b) {
|
|
|
|
return (int)(a - b);
|
|
|
|
}
|
|
|
|
return NS_strcmp(a, b);
|
|
|
|
}
|
|
|
|
|
2008-07-07 17:56:52 -07:00
|
|
|
static nsChangeHint CalcShadowDifference(nsCSSShadowArray* lhs,
|
|
|
|
nsCSSShadowArray* rhs);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// --------------------
|
|
|
|
// nsStyleFont
|
|
|
|
//
|
2008-01-09 01:38:28 -08:00
|
|
|
nsStyleFont::nsStyleFont(const nsFont& aFont, nsPresContext *aPresContext)
|
|
|
|
: mFont(aFont),
|
2008-10-10 07:56:18 -07:00
|
|
|
mGenericID(kGenericFont_NONE)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleFont);
|
2012-01-24 05:09:55 -08:00
|
|
|
Init(aPresContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleFont::nsStyleFont(const nsStyleFont& aSrc)
|
2008-01-09 01:38:28 -08:00
|
|
|
: mFont(aSrc.mFont)
|
|
|
|
, mSize(aSrc.mSize)
|
2008-10-10 07:56:18 -07:00
|
|
|
, mGenericID(aSrc.mGenericID)
|
2008-01-09 01:38:28 -08:00
|
|
|
, mScriptLevel(aSrc.mScriptLevel)
|
|
|
|
, mScriptUnconstrainedSize(aSrc.mScriptUnconstrainedSize)
|
|
|
|
, mScriptMinSize(aSrc.mScriptMinSize)
|
2008-02-18 23:36:50 -08:00
|
|
|
, mScriptSizeMultiplier(aSrc.mScriptSizeMultiplier)
|
2012-01-24 05:09:55 -08:00
|
|
|
, mLanguage(aSrc.mLanguage)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleFont);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleFont::nsStyleFont(nsPresContext* aPresContext)
|
2012-01-25 15:52:26 -08:00
|
|
|
// passing nsnull to GetDefaultFont make it use the doc language
|
|
|
|
: mFont(*(aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID, nsnull))),
|
2008-10-10 07:56:18 -07:00
|
|
|
mGenericID(kGenericFont_NONE)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleFont);
|
2012-01-24 05:09:55 -08:00
|
|
|
Init(aPresContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleFont::Init(nsPresContext* aPresContext)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
mSize = mFont.size = nsStyleFont::ZoomText(aPresContext, mFont.size);
|
2008-01-09 01:38:28 -08:00
|
|
|
mScriptUnconstrainedSize = mSize;
|
2010-08-13 02:58:04 -07:00
|
|
|
mScriptMinSize = aPresContext->CSSTwipsToAppUnits(
|
2008-01-09 01:38:28 -08:00
|
|
|
NS_POINTS_TO_TWIPS(NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT));
|
|
|
|
mScriptLevel = 0;
|
|
|
|
mScriptSizeMultiplier = NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER;
|
2012-01-24 05:09:55 -08:00
|
|
|
|
|
|
|
nsAutoString language;
|
|
|
|
aPresContext->Document()->GetContentLanguage(language);
|
|
|
|
language.StripWhitespace();
|
|
|
|
|
|
|
|
// Content-Language may be a comma-separated list of language codes,
|
|
|
|
// in which case the HTML5 spec says to treat it as unknown
|
|
|
|
if (!language.IsEmpty() &&
|
|
|
|
language.FindChar(PRUnichar(',')) == kNotFound) {
|
|
|
|
mLanguage = do_GetAtom(language);
|
|
|
|
} else {
|
|
|
|
// we didn't find a (usable) Content-Language, so we fall back
|
|
|
|
// to whatever the presContext guessed from the charset
|
|
|
|
mLanguage = aPresContext->GetLanguageFromCharset();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
|
|
|
nsStyleFont::operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
|
|
|
void* result = aContext->AllocateFromShell(sz);
|
|
|
|
if (result)
|
|
|
|
memset(result, 0, sz);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleFont::Destroy(nsPresContext* aContext) {
|
|
|
|
this->~nsStyleFont();
|
|
|
|
aContext->FreeToShell(sizeof(nsStyleFont), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleFont::CalcDifference(const nsStyleFont& aOther) const
|
|
|
|
{
|
2012-01-24 05:09:55 -08:00
|
|
|
if (mSize != aOther.mSize ||
|
|
|
|
mLanguage != aOther.mLanguage) {
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-01-24 05:09:55 -08:00
|
|
|
return CalcFontDifference(mFont, aOther.mFont);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleFont::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* static */ nscoord
|
|
|
|
nsStyleFont::ZoomText(nsPresContext *aPresContext, nscoord aSize)
|
|
|
|
{
|
|
|
|
return nscoord(float(aSize) * aPresContext->TextZoom());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ nscoord
|
|
|
|
nsStyleFont::UnZoomText(nsPresContext *aPresContext, nscoord aSize)
|
|
|
|
{
|
|
|
|
return nscoord(float(aSize) / aPresContext->TextZoom());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleFont::CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2)
|
|
|
|
{
|
|
|
|
if ((aFont1.size == aFont2.size) &&
|
|
|
|
(aFont1.sizeAdjust == aFont2.sizeAdjust) &&
|
|
|
|
(aFont1.style == aFont2.style) &&
|
|
|
|
(aFont1.variant == aFont2.variant) &&
|
|
|
|
(aFont1.weight == aFont2.weight) &&
|
2009-01-29 12:39:18 -08:00
|
|
|
(aFont1.stretch == aFont2.stretch) &&
|
2010-07-13 13:30:42 -07:00
|
|
|
(aFont1.name == aFont2.name) &&
|
2012-04-25 23:24:26 -07:00
|
|
|
(aFont1.fontFeatureSettings == aFont2.fontFeatureSettings) &&
|
2010-07-13 13:30:42 -07:00
|
|
|
(aFont1.languageOverride == aFont2.languageOverride)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if ((aFont1.decorations == aFont2.decorations)) {
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsFixedData(const nsStyleSides& aSides, bool aEnumOK)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2010-08-31 09:05:12 -07:00
|
|
|
if (!IsFixedUnit(aSides.Get(side), aEnumOK))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static nscoord CalcCoord(const nsStyleCoord& aCoord,
|
|
|
|
const nscoord* aEnumTable,
|
|
|
|
PRInt32 aNumEnums)
|
|
|
|
{
|
2010-08-31 09:05:12 -07:00
|
|
|
if (aCoord.GetUnit() == eStyleUnit_Enumerated) {
|
|
|
|
NS_ABORT_IF_FALSE(aEnumTable, "must have enum table");
|
|
|
|
PRInt32 value = aCoord.GetIntValue();
|
|
|
|
if (0 <= value && value < aNumEnums) {
|
|
|
|
return aEnumTable[aCoord.GetIntValue()];
|
|
|
|
}
|
|
|
|
NS_NOTREACHED("unexpected enum value");
|
|
|
|
return 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-08-31 09:05:12 -07:00
|
|
|
NS_ABORT_IF_FALSE(aCoord.ConvertsToLength(), "unexpected unit");
|
|
|
|
return nsRuleNode::ComputeCoordPercentCalc(aCoord, 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleMargin::nsStyleMargin() {
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleMargin);
|
2009-10-13 19:38:20 -07:00
|
|
|
nsStyleCoord zero(0, nsStyleCoord::CoordConstructor);
|
2007-05-10 22:58:34 -07:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mMargin.Set(side, zero);
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasCachedMargin = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleMargin::nsStyleMargin(const nsStyleMargin& aSrc) {
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleMargin);
|
2007-03-22 10:30:00 -07:00
|
|
|
mMargin = aSrc.mMargin;
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasCachedMargin = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
|
|
|
nsStyleMargin::operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
|
|
|
void* result = aContext->AllocateFromShell(sz);
|
|
|
|
if (result)
|
|
|
|
memset(result, 0, sz);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleMargin::Destroy(nsPresContext* aContext) {
|
|
|
|
this->~nsStyleMargin();
|
|
|
|
aContext->FreeToShell(sizeof(nsStyleMargin), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nsStyleMargin::RecalcData()
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
if (IsFixedData(mMargin, false)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2011-04-18 20:07:22 -07:00
|
|
|
mCachedMargin.Side(side) = CalcCoord(mMargin.Get(side), nsnull, 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasCachedMargin = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasCachedMargin = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleMargin::CalcDifference(const nsStyleMargin& aOther) const
|
|
|
|
{
|
|
|
|
if (mMargin == aOther.mMargin) {
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
2009-08-03 18:22:13 -07:00
|
|
|
// Margin differences can't affect descendant intrinsic sizes and
|
|
|
|
// don't need to force children to reflow.
|
|
|
|
return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
|
|
|
|
NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
|
|
|
|
nsChangeHint_NeedDirtyReflow));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleMargin::MaxDifference()
|
|
|
|
{
|
2009-08-03 18:22:13 -07:00
|
|
|
return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
|
|
|
|
NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
|
|
|
|
nsChangeHint_NeedDirtyReflow));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsStylePadding::nsStylePadding() {
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStylePadding);
|
2009-10-13 19:38:20 -07:00
|
|
|
nsStyleCoord zero(0, nsStyleCoord::CoordConstructor);
|
2007-05-10 22:58:34 -07:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mPadding.Set(side, zero);
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasCachedPadding = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePadding::nsStylePadding(const nsStylePadding& aSrc) {
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStylePadding);
|
2007-03-22 10:30:00 -07:00
|
|
|
mPadding = aSrc.mPadding;
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasCachedPadding = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
|
|
|
nsStylePadding::operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
|
|
|
void* result = aContext->AllocateFromShell(sz);
|
|
|
|
if (result)
|
|
|
|
memset(result, 0, sz);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStylePadding::Destroy(nsPresContext* aContext) {
|
|
|
|
this->~nsStylePadding();
|
|
|
|
aContext->FreeToShell(sizeof(nsStylePadding), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsStylePadding::RecalcData()
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
if (IsFixedData(mPadding, false)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2010-09-09 08:21:46 -07:00
|
|
|
// Clamp negative calc() to 0.
|
2011-04-18 20:07:22 -07:00
|
|
|
mCachedPadding.Side(side) =
|
2010-09-09 08:21:46 -07:00
|
|
|
NS_MAX(CalcCoord(mPadding.Get(side), nsnull, 0), 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasCachedPadding = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasCachedPadding = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStylePadding::CalcDifference(const nsStylePadding& aOther) const
|
|
|
|
{
|
|
|
|
if (mPadding == aOther.mPadding) {
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
2009-08-03 18:22:13 -07:00
|
|
|
// Padding differences can't affect descendant intrinsic sizes, but do need
|
|
|
|
// to force children to reflow so that we can reposition them, since their
|
|
|
|
// offsets are from our frame bounds but our content rect's position within
|
|
|
|
// those bounds is moving.
|
|
|
|
return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
|
|
|
|
nsChangeHint_ClearDescendantIntrinsics);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStylePadding::MaxDifference()
|
|
|
|
{
|
2009-08-03 18:22:13 -07:00
|
|
|
return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
|
|
|
|
nsChangeHint_ClearDescendantIntrinsics);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsStyleBorder::nsStyleBorder(nsPresContext* aPresContext)
|
2011-12-22 15:34:45 -08:00
|
|
|
: mBorderColors(nsnull),
|
|
|
|
mBoxShadow(nsnull),
|
2010-09-07 17:30:40 -07:00
|
|
|
#ifdef DEBUG
|
2011-12-22 15:34:45 -08:00
|
|
|
mImageTracked(false),
|
2010-09-07 17:30:40 -07:00
|
|
|
#endif
|
2011-12-22 15:34:45 -08:00
|
|
|
mBorderImageSource(nsnull),
|
|
|
|
mBorderImageFill(NS_STYLE_BORDER_IMAGE_SLICE_NOFILL),
|
|
|
|
mBorderImageRepeatH(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH),
|
|
|
|
mBorderImageRepeatV(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH),
|
|
|
|
mFloatEdge(NS_STYLE_FLOAT_EDGE_CONTENT),
|
|
|
|
mComputedBorder(0, 0, 0, 0)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleBorder);
|
2011-12-22 15:34:45 -08:00
|
|
|
|
|
|
|
NS_FOR_CSS_HALF_CORNERS (corner) {
|
|
|
|
mBorderRadius.Set(corner, nsStyleCoord(0, nsStyleCoord::CoordConstructor));
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord medium =
|
|
|
|
(aPresContext->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM];
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2011-12-22 15:34:45 -08:00
|
|
|
mBorderImageSlice.Set(side, nsStyleCoord(1.0f, eStyleUnit_Percent));
|
|
|
|
mBorderImageWidth.Set(side, nsStyleCoord(1.0f, eStyleUnit_Factor));
|
|
|
|
mBorderImageOutset.Set(side, nsStyleCoord(0.0f, eStyleUnit_Factor));
|
|
|
|
|
2011-04-18 20:07:22 -07:00
|
|
|
mBorder.Side(side) = medium;
|
2007-03-22 10:30:00 -07:00
|
|
|
mBorderStyle[side] = NS_STYLE_BORDER_STYLE_NONE | BORDER_COLOR_FOREGROUND;
|
|
|
|
mBorderColor[side] = NS_RGB(0, 0, 0);
|
2008-09-30 22:50:52 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
mTwipsPerPixel = aPresContext->DevPixelsToAppUnits(1);
|
|
|
|
}
|
|
|
|
|
2008-10-17 01:13:16 -07:00
|
|
|
nsBorderColors::~nsBorderColors()
|
|
|
|
{
|
|
|
|
NS_CSS_DELETE_LIST_MEMBER(nsBorderColors, this, mNext);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBorderColors*
|
2011-09-28 23:19:26 -07:00
|
|
|
nsBorderColors::Clone(bool aDeep) const
|
2008-10-17 01:13:16 -07:00
|
|
|
{
|
|
|
|
nsBorderColors* result = new nsBorderColors(mColor);
|
|
|
|
if (NS_UNLIKELY(!result))
|
|
|
|
return result;
|
|
|
|
if (aDeep)
|
2011-10-17 07:59:28 -07:00
|
|
|
NS_CSS_CLONE_LIST_MEMBER(nsBorderColors, this, mNext, result, (false));
|
2008-10-17 01:13:16 -07:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsStyleBorder::nsStyleBorder(const nsStyleBorder& aSrc)
|
2011-12-22 15:34:45 -08:00
|
|
|
: mBorderColors(nsnull),
|
2008-07-16 23:30:25 -07:00
|
|
|
mBoxShadow(aSrc.mBoxShadow),
|
2011-12-22 15:34:45 -08:00
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked(false),
|
|
|
|
#endif
|
|
|
|
mBorderImageSource(aSrc.mBorderImageSource),
|
|
|
|
mBorderRadius(aSrc.mBorderRadius),
|
|
|
|
mBorderImageSlice(aSrc.mBorderImageSlice),
|
2008-07-16 23:30:25 -07:00
|
|
|
mBorderImageWidth(aSrc.mBorderImageWidth),
|
2011-12-22 15:34:45 -08:00
|
|
|
mBorderImageOutset(aSrc.mBorderImageOutset),
|
2012-04-17 12:22:49 -07:00
|
|
|
mBorderImageFill(aSrc.mBorderImageFill),
|
2011-12-22 15:34:45 -08:00
|
|
|
mBorderImageRepeatH(aSrc.mBorderImageRepeatH),
|
|
|
|
mBorderImageRepeatV(aSrc.mBorderImageRepeatV),
|
|
|
|
mFloatEdge(aSrc.mFloatEdge),
|
2008-07-16 23:30:25 -07:00
|
|
|
mComputedBorder(aSrc.mComputedBorder),
|
|
|
|
mBorder(aSrc.mBorder),
|
|
|
|
mTwipsPerPixel(aSrc.mTwipsPerPixel)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleBorder);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aSrc.mBorderColors) {
|
|
|
|
EnsureBorderColors();
|
|
|
|
for (PRInt32 i = 0; i < 4; i++)
|
|
|
|
if (aSrc.mBorderColors[i])
|
2008-10-17 01:13:16 -07:00
|
|
|
mBorderColors[i] = aSrc.mBorderColors[i]->Clone();
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
|
|
|
mBorderColors[i] = nsnull;
|
|
|
|
}
|
2008-07-07 17:56:52 -07:00
|
|
|
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mBorderStyle[side] = aSrc.mBorderStyle[side];
|
|
|
|
mBorderColor[side] = aSrc.mBorderColor[side];
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-07-16 23:30:25 -07:00
|
|
|
nsStyleBorder::~nsStyleBorder()
|
|
|
|
{
|
2010-09-07 17:30:40 -07:00
|
|
|
NS_ABORT_IF_FALSE(!mImageTracked,
|
|
|
|
"nsStyleBorder being destroyed while still tracking image!");
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_DTOR(nsStyleBorder);
|
2008-07-16 23:30:25 -07:00
|
|
|
if (mBorderColors) {
|
|
|
|
for (PRInt32 i = 0; i < 4; i++)
|
|
|
|
delete mBorderColors[i];
|
|
|
|
delete [] mBorderColors;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-22 15:34:45 -08:00
|
|
|
void*
|
2007-03-22 10:30:00 -07:00
|
|
|
nsStyleBorder::operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
|
|
|
void* result = aContext->AllocateFromShell(sz);
|
|
|
|
if (result)
|
|
|
|
memset(result, 0, sz);
|
|
|
|
return result;
|
|
|
|
}
|
2011-12-22 15:34:45 -08:00
|
|
|
|
|
|
|
nsMargin
|
|
|
|
nsStyleBorder::GetImageOutset() const
|
|
|
|
{
|
|
|
|
// We don't check whether there is a border-image (which is OK since
|
|
|
|
// the initial values yields 0 outset) so that we don't have to
|
|
|
|
// reflow to update overflow areas when an image loads.
|
|
|
|
nsMargin outset;
|
|
|
|
NS_FOR_CSS_SIDES(s) {
|
|
|
|
nsStyleCoord coord = mBorderImageOutset.Get(s);
|
|
|
|
nscoord value;
|
|
|
|
switch (coord.GetUnit()) {
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
value = coord.GetCoordValue();
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Factor:
|
|
|
|
value = coord.GetFactorValue() * mComputedBorder.Side(s);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unexpected CSS unit for image outset");
|
|
|
|
value = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
outset.Side(s) = value;
|
|
|
|
}
|
|
|
|
return outset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsStyleBorder::Destroy(nsPresContext* aContext) {
|
2011-12-22 15:34:45 -08:00
|
|
|
if (mBorderImageSource)
|
2010-09-07 17:30:40 -07:00
|
|
|
UntrackImage(aContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
this->~nsStyleBorder();
|
|
|
|
aContext->FreeToShell(sizeof(nsStyleBorder), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleBorder::CalcDifference(const nsStyleBorder& aOther) const
|
|
|
|
{
|
2008-11-02 16:58:46 -08:00
|
|
|
nsChangeHint shadowDifference =
|
|
|
|
CalcShadowDifference(mBoxShadow, aOther.mBoxShadow);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Note that differences in mBorder don't affect rendering (which should only
|
|
|
|
// use mComputedBorder), so don't need to be tested for here.
|
2009-08-03 18:22:13 -07:00
|
|
|
// XXXbz we should be able to return a more specific change hint for
|
2012-05-30 22:19:49 -07:00
|
|
|
// at least GetComputedBorder() differences...
|
2008-11-02 16:58:46 -08:00
|
|
|
if (mTwipsPerPixel != aOther.mTwipsPerPixel ||
|
2012-05-30 22:19:49 -07:00
|
|
|
GetComputedBorder() != aOther.GetComputedBorder() ||
|
2008-11-02 16:58:46 -08:00
|
|
|
mFloatEdge != aOther.mFloatEdge ||
|
2011-12-22 15:34:45 -08:00
|
|
|
mBorderImageOutset != aOther.mBorderImageOutset ||
|
2008-11-02 16:58:46 -08:00
|
|
|
(shadowDifference & nsChangeHint_ReflowFrame))
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-11-02 16:58:46 -08:00
|
|
|
// Note that mBorderStyle stores not only the border style but also
|
|
|
|
// color-related flags. Given that we've already done an mComputedBorder
|
|
|
|
// comparison, border-style differences can only lead to a VISUAL hint. So
|
|
|
|
// it's OK to just compare the values directly -- if either the actual
|
|
|
|
// style or the color flags differ we want to repaint.
|
|
|
|
NS_FOR_CSS_SIDES(ix) {
|
|
|
|
if (mBorderStyle[ix] != aOther.mBorderStyle[ix] ||
|
|
|
|
mBorderColor[ix] != aOther.mBorderColor[ix])
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2008-11-02 16:58:46 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-11-02 16:58:46 -08:00
|
|
|
if (mBorderRadius != aOther.mBorderRadius ||
|
|
|
|
!mBorderColors != !aOther.mBorderColors)
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2008-07-26 09:14:49 -07:00
|
|
|
|
2008-11-02 16:58:46 -08:00
|
|
|
if (IsBorderImageLoaded() || aOther.IsBorderImageLoaded()) {
|
2011-12-22 15:34:45 -08:00
|
|
|
if (mBorderImageSource != aOther.mBorderImageSource ||
|
|
|
|
mBorderImageRepeatH != aOther.mBorderImageRepeatH ||
|
|
|
|
mBorderImageRepeatV != aOther.mBorderImageRepeatV ||
|
|
|
|
mBorderImageSlice != aOther.mBorderImageSlice ||
|
|
|
|
mBorderImageFill != aOther.mBorderImageFill ||
|
|
|
|
mBorderImageWidth != aOther.mBorderImageWidth ||
|
|
|
|
mBorderImageOutset != aOther.mBorderImageOutset)
|
2008-11-02 16:58:46 -08:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-11-02 16:58:46 -08:00
|
|
|
// Note that at this point if mBorderColors is non-null so is
|
|
|
|
// aOther.mBorderColors
|
|
|
|
if (mBorderColors) {
|
|
|
|
NS_FOR_CSS_SIDES(ix) {
|
|
|
|
if (!nsBorderColors::Equal(mBorderColors[ix],
|
|
|
|
aOther.mBorderColors[ix]))
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-11-02 16:58:46 -08:00
|
|
|
|
|
|
|
return shadowDifference;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleBorder::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-09-07 17:30:40 -07:00
|
|
|
void
|
|
|
|
nsStyleBorder::TrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
|
|
|
NS_ABORT_IF_FALSE(!mImageTracked, "Already tracking image!");
|
2011-12-22 15:34:45 -08:00
|
|
|
NS_ABORT_IF_FALSE(mBorderImageSource, "Can't track null image!");
|
2010-09-07 17:30:40 -07:00
|
|
|
|
|
|
|
// Register the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
|
|
|
if (doc)
|
2011-12-22 15:34:45 -08:00
|
|
|
doc->AddImage(mBorderImageSource);
|
2010-09-07 17:30:40 -07:00
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleBorder::UntrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
|
|
|
NS_ABORT_IF_FALSE(mImageTracked, "Image not tracked!");
|
2011-12-22 15:34:45 -08:00
|
|
|
NS_ABORT_IF_FALSE(mBorderImageSource, "Can't track null image!");
|
2010-09-07 17:30:40 -07:00
|
|
|
|
|
|
|
// Unregister the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
|
|
|
if (doc)
|
2011-12-22 15:34:45 -08:00
|
|
|
doc->RemoveImage(mBorderImageSource);
|
2010-09-07 17:30:40 -07:00
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsStyleOutline::nsStyleOutline(nsPresContext* aPresContext)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleOutline);
|
2007-03-22 10:30:00 -07:00
|
|
|
// spacing values not inherited
|
2009-10-13 19:38:20 -07:00
|
|
|
nsStyleCoord zero(0, nsStyleCoord::CoordConstructor);
|
2008-09-30 22:50:52 -07:00
|
|
|
NS_FOR_CSS_HALF_CORNERS(corner) {
|
|
|
|
mOutlineRadius.Set(corner, zero);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-09-12 20:45:37 -07:00
|
|
|
mOutlineOffset = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
mOutlineWidth = nsStyleCoord(NS_STYLE_BORDER_WIDTH_MEDIUM, eStyleUnit_Enumerated);
|
|
|
|
mOutlineStyle = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
mOutlineColor = NS_RGB(0, 0, 0);
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasCachedOutline = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
mTwipsPerPixel = aPresContext->DevPixelsToAppUnits(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleOutline::nsStyleOutline(const nsStyleOutline& aSrc) {
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleOutline);
|
2007-03-22 10:30:00 -07:00
|
|
|
memcpy((nsStyleOutline*)this, &aSrc, sizeof(nsStyleOutline));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleOutline::RecalcData(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
if (NS_STYLE_BORDER_STYLE_NONE == GetOutlineStyle()) {
|
|
|
|
mCachedOutlineWidth = 0;
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasCachedOutline = true;
|
|
|
|
} else if (IsFixedUnit(mOutlineWidth, true)) {
|
2010-09-09 08:21:46 -07:00
|
|
|
// Clamp negative calc() to 0.
|
2007-03-22 10:30:00 -07:00
|
|
|
mCachedOutlineWidth =
|
2010-09-09 08:21:46 -07:00
|
|
|
NS_MAX(CalcCoord(mOutlineWidth, aContext->GetBorderWidthTable(), 3), 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
mCachedOutlineWidth =
|
|
|
|
NS_ROUND_BORDER_TO_PIXELS(mCachedOutlineWidth, mTwipsPerPixel);
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasCachedOutline = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasCachedOutline = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleOutline::CalcDifference(const nsStyleOutline& aOther) const
|
|
|
|
{
|
2011-09-28 23:19:26 -07:00
|
|
|
bool outlineWasVisible =
|
2007-03-22 10:30:00 -07:00
|
|
|
mCachedOutlineWidth > 0 && mOutlineStyle != NS_STYLE_BORDER_STYLE_NONE;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool outlineIsVisible =
|
2007-03-22 10:30:00 -07:00
|
|
|
aOther.mCachedOutlineWidth > 0 && aOther.mOutlineStyle != NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
if (outlineWasVisible != outlineIsVisible ||
|
|
|
|
(outlineIsVisible && (mOutlineOffset != aOther.mOutlineOffset ||
|
|
|
|
mOutlineWidth != aOther.mOutlineWidth ||
|
|
|
|
mTwipsPerPixel != aOther.mTwipsPerPixel))) {
|
2012-02-07 03:31:37 -08:00
|
|
|
return NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if ((mOutlineStyle != aOther.mOutlineStyle) ||
|
|
|
|
(mOutlineColor != aOther.mOutlineColor) ||
|
|
|
|
(mOutlineRadius != aOther.mOutlineRadius)) {
|
|
|
|
return nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleOutline::MaxDifference()
|
|
|
|
{
|
2012-02-07 03:31:37 -08:00
|
|
|
return NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleList
|
|
|
|
//
|
|
|
|
nsStyleList::nsStyleList()
|
|
|
|
: mListStyleType(NS_STYLE_LIST_STYLE_DISC),
|
|
|
|
mListStylePosition(NS_STYLE_LIST_STYLE_POSITION_OUTSIDE)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleList);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleList::~nsStyleList()
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_DTOR(nsStyleList);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleList::nsStyleList(const nsStyleList& aSource)
|
|
|
|
: mListStyleType(aSource.mListStyleType),
|
|
|
|
mListStylePosition(aSource.mListStylePosition),
|
|
|
|
mImageRegion(aSource.mImageRegion)
|
|
|
|
{
|
2010-08-16 09:23:09 -07:00
|
|
|
SetListStyleImage(aSource.GetListStyleImage());
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleList);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleList::CalcDifference(const nsStyleList& aOther) const
|
|
|
|
{
|
|
|
|
if (mListStylePosition != aOther.mListStylePosition)
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
if (EqualImages(mListStyleImage, aOther.mListStyleImage) &&
|
|
|
|
mListStyleType == aOther.mListStyleType) {
|
2011-04-18 20:07:23 -07:00
|
|
|
if (mImageRegion.IsEqualInterior(aOther.mImageRegion))
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
if (mImageRegion.width == aOther.mImageRegion.width &&
|
|
|
|
mImageRegion.height == aOther.mImageRegion.height)
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleList::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleXUL
|
|
|
|
//
|
|
|
|
nsStyleXUL::nsStyleXUL()
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleXUL);
|
2007-03-22 10:30:00 -07:00
|
|
|
mBoxAlign = NS_STYLE_BOX_ALIGN_STRETCH;
|
|
|
|
mBoxDirection = NS_STYLE_BOX_DIRECTION_NORMAL;
|
|
|
|
mBoxFlex = 0.0f;
|
|
|
|
mBoxOrient = NS_STYLE_BOX_ORIENT_HORIZONTAL;
|
|
|
|
mBoxPack = NS_STYLE_BOX_PACK_START;
|
|
|
|
mBoxOrdinal = 1;
|
2011-10-17 07:59:28 -07:00
|
|
|
mStretchStack = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleXUL::~nsStyleXUL()
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_DTOR(nsStyleXUL);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleXUL::nsStyleXUL(const nsStyleXUL& aSource)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleXUL);
|
2007-03-22 10:30:00 -07:00
|
|
|
memcpy((nsStyleXUL*)this, &aSource, sizeof(nsStyleXUL));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleXUL::CalcDifference(const nsStyleXUL& aOther) const
|
|
|
|
{
|
|
|
|
if (mBoxAlign == aOther.mBoxAlign &&
|
|
|
|
mBoxDirection == aOther.mBoxDirection &&
|
|
|
|
mBoxFlex == aOther.mBoxFlex &&
|
|
|
|
mBoxOrient == aOther.mBoxOrient &&
|
|
|
|
mBoxPack == aOther.mBoxPack &&
|
|
|
|
mBoxOrdinal == aOther.mBoxOrdinal)
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
if (mBoxOrdinal != aOther.mBoxOrdinal)
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleXUL::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleColumn
|
|
|
|
//
|
2008-07-19 03:38:25 -07:00
|
|
|
nsStyleColumn::nsStyleColumn(nsPresContext* aPresContext)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColumn);
|
2007-03-22 10:30:00 -07:00
|
|
|
mColumnCount = NS_STYLE_COLUMN_COUNT_AUTO;
|
|
|
|
mColumnWidth.SetAutoValue();
|
|
|
|
mColumnGap.SetNormalValue();
|
2008-07-19 03:38:25 -07:00
|
|
|
|
|
|
|
mColumnRuleWidth = (aPresContext->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM];
|
|
|
|
mColumnRuleStyle = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
mColumnRuleColor = NS_RGB(0, 0, 0);
|
2011-10-17 07:59:28 -07:00
|
|
|
mColumnRuleColorIsForeground = true;
|
2008-07-19 03:38:25 -07:00
|
|
|
|
|
|
|
mTwipsPerPixel = aPresContext->AppUnitsPerDevPixel();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColumn::~nsStyleColumn()
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_DTOR(nsStyleColumn);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColumn::nsStyleColumn(const nsStyleColumn& aSource)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColumn);
|
2007-03-22 10:30:00 -07:00
|
|
|
memcpy((nsStyleColumn*)this, &aSource, sizeof(nsStyleColumn));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleColumn::CalcDifference(const nsStyleColumn& aOther) const
|
|
|
|
{
|
|
|
|
if ((mColumnWidth.GetUnit() == eStyleUnit_Auto)
|
|
|
|
!= (aOther.mColumnWidth.GetUnit() == eStyleUnit_Auto) ||
|
|
|
|
mColumnCount != aOther.mColumnCount)
|
|
|
|
// We force column count changes to do a reframe, because it's tricky to handle
|
|
|
|
// some edge cases where the column count gets smaller and content overflows.
|
|
|
|
// XXX not ideal
|
2008-07-19 03:38:25 -07:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (mColumnWidth != aOther.mColumnWidth ||
|
2012-06-13 09:00:56 -07:00
|
|
|
mColumnGap != aOther.mColumnGap)
|
2008-07-19 03:38:25 -07:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
|
|
|
|
if (GetComputedColumnRuleWidth() != aOther.GetComputedColumnRuleWidth() ||
|
|
|
|
mColumnRuleStyle != aOther.mColumnRuleStyle ||
|
|
|
|
mColumnRuleColor != aOther.mColumnRuleColor ||
|
|
|
|
mColumnRuleColorIsForeground != aOther.mColumnRuleColorIsForeground)
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleColumn::MaxDifference()
|
|
|
|
{
|
2008-07-19 03:38:25 -07:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleSVG
|
|
|
|
//
|
|
|
|
nsStyleSVG::nsStyleSVG()
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleSVG);
|
2007-03-22 10:30:00 -07:00
|
|
|
mFill.mType = eStyleSVGPaintType_Color;
|
|
|
|
mFill.mPaint.mColor = NS_RGB(0,0,0);
|
|
|
|
mFill.mFallbackColor = NS_RGB(0,0,0);
|
|
|
|
mStroke.mType = eStyleSVGPaintType_None;
|
|
|
|
mStroke.mPaint.mColor = NS_RGB(0,0,0);
|
|
|
|
mStroke.mFallbackColor = NS_RGB(0,0,0);
|
|
|
|
mStrokeDasharray = nsnull;
|
|
|
|
|
2007-07-21 07:20:25 -07:00
|
|
|
mStrokeDashoffset.SetCoordValue(0);
|
|
|
|
mStrokeWidth.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(1));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
mFillOpacity = 1.0f;
|
|
|
|
mStrokeMiterlimit = 4.0f;
|
|
|
|
mStrokeOpacity = 1.0f;
|
|
|
|
|
|
|
|
mStrokeDasharrayLength = 0;
|
|
|
|
mClipRule = NS_STYLE_FILL_RULE_NONZERO;
|
|
|
|
mColorInterpolation = NS_STYLE_COLOR_INTERPOLATION_SRGB;
|
|
|
|
mColorInterpolationFilters = NS_STYLE_COLOR_INTERPOLATION_LINEARRGB;
|
|
|
|
mFillRule = NS_STYLE_FILL_RULE_NONZERO;
|
2009-03-21 08:36:38 -07:00
|
|
|
mImageRendering = NS_STYLE_IMAGE_RENDERING_AUTO;
|
2007-03-22 10:30:00 -07:00
|
|
|
mShapeRendering = NS_STYLE_SHAPE_RENDERING_AUTO;
|
|
|
|
mStrokeLinecap = NS_STYLE_STROKE_LINECAP_BUTT;
|
|
|
|
mStrokeLinejoin = NS_STYLE_STROKE_LINEJOIN_MITER;
|
|
|
|
mTextAnchor = NS_STYLE_TEXT_ANCHOR_START;
|
|
|
|
mTextRendering = NS_STYLE_TEXT_RENDERING_AUTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVG::~nsStyleSVG()
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_DTOR(nsStyleSVG);
|
2007-03-22 10:30:00 -07:00
|
|
|
delete [] mStrokeDasharray;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleSVG);
|
2007-03-22 10:30:00 -07:00
|
|
|
mFill = aSource.mFill;
|
|
|
|
mStroke = aSource.mStroke;
|
|
|
|
|
|
|
|
mMarkerEnd = aSource.mMarkerEnd;
|
|
|
|
mMarkerMid = aSource.mMarkerMid;
|
2007-07-21 07:20:25 -07:00
|
|
|
mMarkerStart = aSource.mMarkerStart;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
mStrokeDasharrayLength = aSource.mStrokeDasharrayLength;
|
|
|
|
if (aSource.mStrokeDasharray) {
|
|
|
|
mStrokeDasharray = new nsStyleCoord[mStrokeDasharrayLength];
|
|
|
|
if (mStrokeDasharray)
|
|
|
|
memcpy(mStrokeDasharray,
|
|
|
|
aSource.mStrokeDasharray,
|
|
|
|
mStrokeDasharrayLength * sizeof(nsStyleCoord));
|
|
|
|
else
|
|
|
|
mStrokeDasharrayLength = 0;
|
|
|
|
} else {
|
|
|
|
mStrokeDasharray = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
mStrokeDashoffset = aSource.mStrokeDashoffset;
|
|
|
|
mStrokeWidth = aSource.mStrokeWidth;
|
|
|
|
|
|
|
|
mFillOpacity = aSource.mFillOpacity;
|
|
|
|
mStrokeMiterlimit = aSource.mStrokeMiterlimit;
|
|
|
|
mStrokeOpacity = aSource.mStrokeOpacity;
|
|
|
|
|
|
|
|
mClipRule = aSource.mClipRule;
|
|
|
|
mColorInterpolation = aSource.mColorInterpolation;
|
|
|
|
mColorInterpolationFilters = aSource.mColorInterpolationFilters;
|
|
|
|
mFillRule = aSource.mFillRule;
|
2009-03-21 08:36:38 -07:00
|
|
|
mImageRendering = aSource.mImageRendering;
|
2007-03-22 10:30:00 -07:00
|
|
|
mShapeRendering = aSource.mShapeRendering;
|
|
|
|
mStrokeLinecap = aSource.mStrokeLinecap;
|
|
|
|
mStrokeLinejoin = aSource.mStrokeLinejoin;
|
|
|
|
mTextAnchor = aSource.mTextAnchor;
|
|
|
|
mTextRendering = aSource.mTextRendering;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool PaintURIChanged(const nsStyleSVGPaint& aPaint1,
|
2008-09-30 17:51:05 -07:00
|
|
|
const nsStyleSVGPaint& aPaint2)
|
|
|
|
{
|
|
|
|
if (aPaint1.mType != aPaint2.mType) {
|
|
|
|
return aPaint1.mType == eStyleSVGPaintType_Server ||
|
|
|
|
aPaint2.mType == eStyleSVGPaintType_Server;
|
|
|
|
}
|
|
|
|
return aPaint1.mType == eStyleSVGPaintType_Server &&
|
|
|
|
!EqualURIs(aPaint1.mPaint.mPaintServer, aPaint2.mPaint.mPaintServer);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsChangeHint nsStyleSVG::CalcDifference(const nsStyleSVG& aOther) const
|
|
|
|
{
|
2008-09-30 17:51:05 -07:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
|
|
|
if (mTextRendering != aOther.mTextRendering) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
// May be needed for non-svg frames
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReflowFrame);
|
|
|
|
}
|
|
|
|
|
2009-01-21 17:02:40 -08:00
|
|
|
if (!EqualURIs(mMarkerEnd, aOther.mMarkerEnd) ||
|
|
|
|
!EqualURIs(mMarkerMid, aOther.mMarkerMid) ||
|
|
|
|
!EqualURIs(mMarkerStart, aOther.mMarkerStart)) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateEffects);
|
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
2008-09-30 17:51:05 -07:00
|
|
|
if (mFill != aOther.mFill ||
|
|
|
|
mStroke != aOther.mStroke) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
if (PaintURIChanged(mFill, aOther.mFill) ||
|
|
|
|
PaintURIChanged(mStroke, aOther.mStroke)) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateEffects);
|
|
|
|
}
|
|
|
|
// Nothing more to do, below we can only set "repaint"
|
|
|
|
return hint;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-01-21 17:02:40 -08:00
|
|
|
if ( mStrokeDashoffset != aOther.mStrokeDashoffset ||
|
2007-03-22 10:30:00 -07:00
|
|
|
mStrokeWidth != aOther.mStrokeWidth ||
|
|
|
|
|
|
|
|
mFillOpacity != aOther.mFillOpacity ||
|
|
|
|
mStrokeMiterlimit != aOther.mStrokeMiterlimit ||
|
|
|
|
mStrokeOpacity != aOther.mStrokeOpacity ||
|
|
|
|
|
|
|
|
mClipRule != aOther.mClipRule ||
|
|
|
|
mColorInterpolation != aOther.mColorInterpolation ||
|
|
|
|
mColorInterpolationFilters != aOther.mColorInterpolationFilters ||
|
|
|
|
mFillRule != aOther.mFillRule ||
|
2009-03-21 08:36:38 -07:00
|
|
|
mImageRendering != aOther.mImageRendering ||
|
2007-03-22 10:30:00 -07:00
|
|
|
mShapeRendering != aOther.mShapeRendering ||
|
|
|
|
mStrokeDasharrayLength != aOther.mStrokeDasharrayLength ||
|
|
|
|
mStrokeLinecap != aOther.mStrokeLinecap ||
|
|
|
|
mStrokeLinejoin != aOther.mStrokeLinejoin ||
|
2008-09-30 17:51:05 -07:00
|
|
|
mTextAnchor != aOther.mTextAnchor) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
return hint;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// length of stroke dasharrays are the same (tested above) - check entries
|
|
|
|
for (PRUint32 i=0; i<mStrokeDasharrayLength; i++)
|
2008-09-30 17:51:05 -07:00
|
|
|
if (mStrokeDasharray[i] != aOther.mStrokeDasharray[i]) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
return hint;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-30 17:51:05 -07:00
|
|
|
return hint;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleSVG::MaxDifference()
|
|
|
|
{
|
2008-09-30 17:51:05 -07:00
|
|
|
return NS_CombineHint(NS_CombineHint(nsChangeHint_UpdateEffects,
|
|
|
|
nsChangeHint_ReflowFrame),
|
|
|
|
nsChangeHint_RepaintFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleSVGReset
|
|
|
|
//
|
|
|
|
nsStyleSVGReset::nsStyleSVGReset()
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleSVGReset);
|
2007-03-22 10:30:00 -07:00
|
|
|
mStopColor = NS_RGB(0,0,0);
|
|
|
|
mFloodColor = NS_RGB(0,0,0);
|
2007-07-25 23:57:42 -07:00
|
|
|
mLightingColor = NS_RGB(255,255,255);
|
2007-03-22 10:30:00 -07:00
|
|
|
mClipPath = nsnull;
|
|
|
|
mFilter = nsnull;
|
|
|
|
mMask = nsnull;
|
|
|
|
mStopOpacity = 1.0f;
|
|
|
|
mFloodOpacity = 1.0f;
|
|
|
|
mDominantBaseline = NS_STYLE_DOMINANT_BASELINE_AUTO;
|
2012-05-18 01:33:40 -07:00
|
|
|
mVectorEffect = NS_STYLE_VECTOR_EFFECT_NONE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGReset::~nsStyleSVGReset()
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_DTOR(nsStyleSVGReset);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGReset::nsStyleSVGReset(const nsStyleSVGReset& aSource)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleSVGReset);
|
2007-03-22 10:30:00 -07:00
|
|
|
mStopColor = aSource.mStopColor;
|
|
|
|
mFloodColor = aSource.mFloodColor;
|
2007-07-25 23:57:42 -07:00
|
|
|
mLightingColor = aSource.mLightingColor;
|
2007-03-22 10:30:00 -07:00
|
|
|
mClipPath = aSource.mClipPath;
|
|
|
|
mFilter = aSource.mFilter;
|
|
|
|
mMask = aSource.mMask;
|
|
|
|
mStopOpacity = aSource.mStopOpacity;
|
|
|
|
mFloodOpacity = aSource.mFloodOpacity;
|
|
|
|
mDominantBaseline = aSource.mDominantBaseline;
|
2012-05-18 01:33:40 -07:00
|
|
|
mVectorEffect = aSource.mVectorEffect;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleSVGReset::CalcDifference(const nsStyleSVGReset& aOther) const
|
|
|
|
{
|
2008-08-05 17:55:07 -07:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
|
|
|
if (!EqualURIs(mClipPath, aOther.mClipPath) ||
|
|
|
|
!EqualURIs(mFilter, aOther.mFilter) ||
|
|
|
|
!EqualURIs(mMask, aOther.mMask)) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateEffects);
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReflowFrame);
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
2008-09-30 17:51:05 -07:00
|
|
|
} else if (mStopColor != aOther.mStopColor ||
|
|
|
|
mFloodColor != aOther.mFloodColor ||
|
|
|
|
mLightingColor != aOther.mLightingColor ||
|
|
|
|
mStopOpacity != aOther.mStopOpacity ||
|
|
|
|
mFloodOpacity != aOther.mFloodOpacity ||
|
2012-05-18 01:33:40 -07:00
|
|
|
mDominantBaseline != aOther.mDominantBaseline ||
|
|
|
|
mVectorEffect != aOther.mVectorEffect)
|
2008-08-05 17:55:07 -07:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
|
|
|
|
return hint;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleSVGReset::MaxDifference()
|
|
|
|
{
|
2008-08-05 17:55:07 -07:00
|
|
|
return NS_CombineHint(NS_CombineHint(nsChangeHint_UpdateEffects,
|
|
|
|
nsChangeHint_ReflowFrame),
|
|
|
|
nsChangeHint_RepaintFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// nsStyleSVGPaint implementation
|
2007-10-19 08:36:15 -07:00
|
|
|
nsStyleSVGPaint::~nsStyleSVGPaint()
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
|
|
|
NS_IF_RELEASE(mPaint.mPaintServer);
|
2007-10-19 08:36:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleSVGPaint::SetType(nsStyleSVGPaintType aType)
|
|
|
|
{
|
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
|
|
|
this->~nsStyleSVGPaint();
|
|
|
|
new (this) nsStyleSVGPaint();
|
|
|
|
}
|
|
|
|
mType = aType;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGPaint& nsStyleSVGPaint::operator=(const nsStyleSVGPaint& aOther)
|
|
|
|
{
|
2007-10-19 08:36:15 -07:00
|
|
|
if (this == &aOther)
|
|
|
|
return *this;
|
|
|
|
|
|
|
|
SetType(aOther.mType);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
mFallbackColor = aOther.mFallbackColor;
|
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
|
|
|
mPaint.mPaintServer = aOther.mPaint.mPaintServer;
|
|
|
|
NS_IF_ADDREF(mPaint.mPaintServer);
|
|
|
|
} else {
|
|
|
|
mPaint.mColor = aOther.mPaint.mColor;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool nsStyleSVGPaint::operator==(const nsStyleSVGPaint& aOther) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (mType != aOther.mType)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mType == eStyleSVGPaintType_Server)
|
|
|
|
return EqualURIs(mPaint.mPaintServer, aOther.mPaint.mPaintServer) &&
|
|
|
|
mFallbackColor == aOther.mFallbackColor;
|
|
|
|
if (mType == eStyleSVGPaintType_None)
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
return mPaint.mColor == aOther.mPaint.mColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStylePosition
|
|
|
|
//
|
|
|
|
nsStylePosition::nsStylePosition(void)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStylePosition);
|
2007-03-22 10:30:00 -07:00
|
|
|
// positioning values not inherited
|
|
|
|
nsStyleCoord autoCoord(eStyleUnit_Auto);
|
|
|
|
mOffset.SetLeft(autoCoord);
|
|
|
|
mOffset.SetTop(autoCoord);
|
|
|
|
mOffset.SetRight(autoCoord);
|
|
|
|
mOffset.SetBottom(autoCoord);
|
|
|
|
mWidth.SetAutoValue();
|
|
|
|
mMinWidth.SetCoordValue(0);
|
2007-05-10 23:01:31 -07:00
|
|
|
mMaxWidth.SetNoneValue();
|
2007-03-22 10:30:00 -07:00
|
|
|
mHeight.SetAutoValue();
|
|
|
|
mMinHeight.SetCoordValue(0);
|
2007-05-10 23:01:31 -07:00
|
|
|
mMaxHeight.SetNoneValue();
|
2007-03-22 10:30:00 -07:00
|
|
|
mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;
|
|
|
|
mZIndex.SetAutoValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePosition::~nsStylePosition(void)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_DTOR(nsStylePosition);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePosition::nsStylePosition(const nsStylePosition& aSource)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStylePosition);
|
2007-03-22 10:30:00 -07:00
|
|
|
memcpy((nsStylePosition*)this, &aSource, sizeof(nsStylePosition));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStylePosition::CalcDifference(const nsStylePosition& aOther) const
|
|
|
|
{
|
2009-10-29 18:47:46 -07:00
|
|
|
nsChangeHint hint =
|
|
|
|
(mZIndex == aOther.mZIndex) ? NS_STYLE_HINT_NONE : nsChangeHint_RepaintFrame;
|
2009-10-29 18:47:43 -07:00
|
|
|
|
|
|
|
if (mBoxSizing != aOther.mBoxSizing) {
|
2009-10-29 20:43:52 -07:00
|
|
|
// Can affect both widths and heights; just a bad scene.
|
2009-10-29 18:47:46 -07:00
|
|
|
return NS_CombineHint(hint, nsChangeHint_ReflowFrame);
|
2009-10-29 18:47:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mHeight != aOther.mHeight ||
|
|
|
|
mMinHeight != aOther.mMinHeight ||
|
|
|
|
mMaxHeight != aOther.mMaxHeight) {
|
2009-12-29 12:13:54 -08:00
|
|
|
// Height changes can affect descendant intrinsic sizes due to replaced
|
|
|
|
// elements with percentage heights in descendants which also have
|
|
|
|
// percentage heights. And due to our not-so-great computation of mVResize
|
|
|
|
// in nsHTMLReflowState, they do need to force reflow of the whole subtree.
|
|
|
|
// XXXbz due to XUL caching heights as well, height changes also need to
|
|
|
|
// clear ancestor intrinsics!
|
|
|
|
return NS_CombineHint(hint, nsChangeHint_ReflowFrame);
|
2009-10-29 18:47:43 -07:00
|
|
|
}
|
|
|
|
|
Bug 157681 - Part 2: Optimize positioned frame offset changes by moving the frame as opposed to reflowing it in case we know that the size of the frame will not change; r=dbaron
This patch adds a change hint to signal that one of the offsets on a
frame has been changed. When processing the hint, we do one of the
following things based on the position property of the frame.
* For static frames, we ignore the offset changes completely, as they
will not change the layout.
* For relative positioned frames, this patch refactors the
nsHTMLReflowState::ComputeRelativeOffsets function so that it can be
used from other callers, and it uses that to compute the new relative
offsets, and uses the offsets computed previously to compute the new
position of the frame.
* For absolute positioned frames, we set up a fake parent reflow state
object, and then we create a new reflow state object for the frame in
question. This setup is similar to what nsFrame::BoxReflow does.
Once we have the new reflow state object, we use it to compute the
absolute offsets, and then we use the computed offsets to set the new
position of the frame. The offset computation is similar to what
nsAbsoluteContainingBlock::ReflowAbsoluteFrame does. In some cases
where it is possible for the dimensions of the frame to change based
on the offset changes, we fall back to a full reflow.
2012-06-05 21:53:48 -07:00
|
|
|
if (mWidth != aOther.mWidth ||
|
|
|
|
mMinWidth != aOther.mMinWidth ||
|
|
|
|
mMaxWidth != aOther.mMaxWidth) {
|
|
|
|
// None of our width differences can affect descendant intrinsic
|
|
|
|
// sizes and none of them need to force children to reflow.
|
|
|
|
return
|
|
|
|
NS_CombineHint(hint,
|
|
|
|
NS_SubtractHint(nsChangeHint_ReflowFrame,
|
|
|
|
NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
|
|
|
|
nsChangeHint_NeedDirtyReflow)));
|
2009-08-03 18:22:13 -07:00
|
|
|
}
|
|
|
|
|
Bug 157681 - Part 2: Optimize positioned frame offset changes by moving the frame as opposed to reflowing it in case we know that the size of the frame will not change; r=dbaron
This patch adds a change hint to signal that one of the offsets on a
frame has been changed. When processing the hint, we do one of the
following things based on the position property of the frame.
* For static frames, we ignore the offset changes completely, as they
will not change the layout.
* For relative positioned frames, this patch refactors the
nsHTMLReflowState::ComputeRelativeOffsets function so that it can be
used from other callers, and it uses that to compute the new relative
offsets, and uses the offsets computed previously to compute the new
position of the frame.
* For absolute positioned frames, we set up a fake parent reflow state
object, and then we create a new reflow state object for the frame in
question. This setup is similar to what nsFrame::BoxReflow does.
Once we have the new reflow state object, we use it to compute the
absolute offsets, and then we use the computed offsets to set the new
position of the frame. The offset computation is similar to what
nsAbsoluteContainingBlock::ReflowAbsoluteFrame does. In some cases
where it is possible for the dimensions of the frame to change based
on the offset changes, we fall back to a full reflow.
2012-06-05 21:53:48 -07:00
|
|
|
// If width and height have not changed, but any of the offsets have changed,
|
|
|
|
// then return the respective hints so that we would hopefully be able to
|
|
|
|
// avoid reflowing.
|
|
|
|
// Note that it is possible that we'll need to reflow when processing
|
|
|
|
// restyles, but we don't have enough information to make a good decision
|
|
|
|
// right now.
|
|
|
|
if (mOffset != aOther.mOffset) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint(nsChangeHint_RecomputePosition |
|
|
|
|
nsChangeHint_UpdateOverflow));
|
|
|
|
}
|
|
|
|
return hint;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStylePosition::MaxDifference()
|
|
|
|
{
|
Bug 157681 - Part 2: Optimize positioned frame offset changes by moving the frame as opposed to reflowing it in case we know that the size of the frame will not change; r=dbaron
This patch adds a change hint to signal that one of the offsets on a
frame has been changed. When processing the hint, we do one of the
following things based on the position property of the frame.
* For static frames, we ignore the offset changes completely, as they
will not change the layout.
* For relative positioned frames, this patch refactors the
nsHTMLReflowState::ComputeRelativeOffsets function so that it can be
used from other callers, and it uses that to compute the new relative
offsets, and uses the offsets computed previously to compute the new
position of the frame.
* For absolute positioned frames, we set up a fake parent reflow state
object, and then we create a new reflow state object for the frame in
question. This setup is similar to what nsFrame::BoxReflow does.
Once we have the new reflow state object, we use it to compute the
absolute offsets, and then we use the computed offsets to set the new
position of the frame. The offset computation is similar to what
nsAbsoluteContainingBlock::ReflowAbsoluteFrame does. In some cases
where it is possible for the dimensions of the frame to change based
on the offset changes, we fall back to a full reflow.
2012-06-05 21:53:48 -07:00
|
|
|
return NS_CombineHint(NS_STYLE_HINT_REFLOW,
|
|
|
|
nsChangeHint(nsChangeHint_RecomputePosition |
|
|
|
|
nsChangeHint_UpdateOverflow));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
/* static */ bool
|
2010-08-11 12:32:53 -07:00
|
|
|
nsStylePosition::WidthCoordDependsOnContainer(const nsStyleCoord &aCoord)
|
|
|
|
{
|
|
|
|
return aCoord.GetUnit() == eStyleUnit_Auto ||
|
2010-08-25 03:17:55 -07:00
|
|
|
aCoord.HasPercent() ||
|
2010-08-11 12:32:53 -07:00
|
|
|
(aCoord.GetUnit() == eStyleUnit_Enumerated &&
|
|
|
|
(aCoord.GetIntValue() == NS_STYLE_WIDTH_FIT_CONTENT ||
|
|
|
|
aCoord.GetIntValue() == NS_STYLE_WIDTH_AVAILABLE));
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// --------------------
|
|
|
|
// nsStyleTable
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleTable::nsStyleTable()
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTable);
|
2007-03-22 10:30:00 -07:00
|
|
|
// values not inherited
|
|
|
|
mLayoutStrategy = NS_STYLE_TABLE_LAYOUT_AUTO;
|
|
|
|
mCols = NS_STYLE_TABLE_COLS_NONE;
|
|
|
|
mFrame = NS_STYLE_TABLE_FRAME_NONE;
|
|
|
|
mRules = NS_STYLE_TABLE_RULES_NONE;
|
|
|
|
mSpan = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTable::~nsStyleTable(void)
|
2009-08-07 07:38:44 -07:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleTable);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTable::nsStyleTable(const nsStyleTable& aSource)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTable);
|
2007-03-22 10:30:00 -07:00
|
|
|
memcpy((nsStyleTable*)this, &aSource, sizeof(nsStyleTable));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleTable::CalcDifference(const nsStyleTable& aOther) const
|
|
|
|
{
|
|
|
|
// Changes in mRules may require reframing (if border-collapse stuff changes, for example).
|
2008-02-08 11:56:03 -08:00
|
|
|
if (mRules != aOther.mRules || mSpan != aOther.mSpan ||
|
|
|
|
mLayoutStrategy != aOther.mLayoutStrategy)
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2008-02-08 11:56:03 -08:00
|
|
|
if (mFrame != aOther.mFrame || mCols != aOther.mCols)
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
return NS_STYLE_HINT_NONE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleTable::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// -----------------------
|
|
|
|
// nsStyleTableBorder
|
|
|
|
|
|
|
|
nsStyleTableBorder::nsStyleTableBorder(nsPresContext* aPresContext)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTableBorder);
|
2007-03-22 10:30:00 -07:00
|
|
|
mBorderCollapse = NS_STYLE_BORDER_SEPARATE;
|
|
|
|
|
|
|
|
nsCompatibility compatMode = eCompatibility_FullStandards;
|
|
|
|
if (aPresContext)
|
|
|
|
compatMode = aPresContext->CompatibilityMode();
|
|
|
|
mEmptyCells = (compatMode == eCompatibility_NavQuirks)
|
|
|
|
? NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND
|
|
|
|
: NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
|
2008-02-26 18:02:20 -08:00
|
|
|
mCaptionSide = NS_STYLE_CAPTION_SIDE_TOP;
|
2008-09-12 20:45:37 -07:00
|
|
|
mBorderSpacingX = 0;
|
|
|
|
mBorderSpacingY = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTableBorder::~nsStyleTableBorder(void)
|
2009-08-07 07:38:44 -07:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleTableBorder);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTableBorder::nsStyleTableBorder(const nsStyleTableBorder& aSource)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTableBorder);
|
2007-03-22 10:30:00 -07:00
|
|
|
memcpy((nsStyleTableBorder*)this, &aSource, sizeof(nsStyleTableBorder));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleTableBorder::CalcDifference(const nsStyleTableBorder& aOther) const
|
|
|
|
{
|
|
|
|
// Border-collapse changes need a reframe, because we use a different frame
|
|
|
|
// class for table cells in the collapsed border model. This is used to
|
|
|
|
// conserve memory when using the separated border model (collapsed borders
|
|
|
|
// require extra state to be stored).
|
|
|
|
if (mBorderCollapse != aOther.mBorderCollapse) {
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((mCaptionSide == aOther.mCaptionSide) &&
|
|
|
|
(mBorderSpacingX == aOther.mBorderSpacingX) &&
|
|
|
|
(mBorderSpacingY == aOther.mBorderSpacingY)) {
|
|
|
|
if (mEmptyCells == aOther.mEmptyCells)
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleTableBorder::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleColor
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleColor::nsStyleColor(nsPresContext* aPresContext)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColor);
|
2007-03-22 10:30:00 -07:00
|
|
|
mColor = aPresContext->DefaultColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColor::nsStyleColor(const nsStyleColor& aSource)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColor);
|
2007-03-22 10:30:00 -07:00
|
|
|
mColor = aSource.mColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleColor::CalcDifference(const nsStyleColor& aOther) const
|
|
|
|
{
|
|
|
|
if (mColor == aOther.mColor)
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleColor::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-08-01 08:53:40 -07:00
|
|
|
// --------------------
|
|
|
|
// nsStyleGradient
|
|
|
|
//
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2009-08-01 08:53:40 -07:00
|
|
|
nsStyleGradient::operator==(const nsStyleGradient& aOther) const
|
|
|
|
{
|
2009-11-02 11:36:43 -08:00
|
|
|
NS_ABORT_IF_FALSE(mSize == NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER ||
|
|
|
|
mShape != NS_STYLE_GRADIENT_SHAPE_LINEAR,
|
|
|
|
"incorrect combination of shape and size");
|
|
|
|
NS_ABORT_IF_FALSE(aOther.mSize == NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER ||
|
|
|
|
aOther.mShape != NS_STYLE_GRADIENT_SHAPE_LINEAR,
|
|
|
|
"incorrect combination of shape and size");
|
|
|
|
|
|
|
|
if (mShape != aOther.mShape ||
|
|
|
|
mSize != aOther.mSize ||
|
|
|
|
mRepeating != aOther.mRepeating ||
|
2011-10-22 12:41:11 -07:00
|
|
|
mToCorner != aOther.mToCorner ||
|
2009-11-02 11:36:43 -08:00
|
|
|
mBgPosX != aOther.mBgPosX ||
|
|
|
|
mBgPosY != aOther.mBgPosY ||
|
|
|
|
mAngle != aOther.mAngle)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-01 08:53:40 -07:00
|
|
|
|
|
|
|
if (mStops.Length() != aOther.mStops.Length())
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-01 08:53:40 -07:00
|
|
|
|
|
|
|
for (PRUint32 i = 0; i < mStops.Length(); i++) {
|
2009-11-02 11:36:43 -08:00
|
|
|
if (mStops[i].mLocation != aOther.mStops[i].mLocation ||
|
2009-08-01 08:53:40 -07:00
|
|
|
mStops[i].mColor != aOther.mStops[i].mColor)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-01 08:53:40 -07:00
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-08-01 08:53:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleGradient::nsStyleGradient(void)
|
2009-11-02 11:36:43 -08:00
|
|
|
: mShape(NS_STYLE_GRADIENT_SHAPE_LINEAR)
|
|
|
|
, mSize(NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER)
|
2011-10-17 07:59:28 -07:00
|
|
|
, mRepeating(false)
|
2011-10-22 12:41:11 -07:00
|
|
|
, mToCorner(false)
|
2009-08-01 08:53:40 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2011-01-02 17:48:09 -08:00
|
|
|
nsStyleGradient::IsOpaque()
|
|
|
|
{
|
|
|
|
for (PRUint32 i = 0; i < mStops.Length(); i++) {
|
|
|
|
if (NS_GET_A(mStops[i].mColor) < 255)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2011-01-02 17:48:09 -08:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2011-01-02 17:48:09 -08:00
|
|
|
}
|
|
|
|
|
2009-08-21 13:39:25 -07:00
|
|
|
// --------------------
|
|
|
|
// nsStyleImage
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleImage::nsStyleImage()
|
|
|
|
: mType(eStyleImageType_Null)
|
|
|
|
, mCropRect(nsnull)
|
2010-08-05 14:57:18 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
, mImageTracked(false)
|
|
|
|
#endif
|
2009-08-21 13:39:25 -07:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleImage::~nsStyleImage()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleImage);
|
|
|
|
if (mType != eStyleImageType_Null)
|
|
|
|
SetNull();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleImage::nsStyleImage(const nsStyleImage& aOther)
|
|
|
|
: mType(eStyleImageType_Null)
|
|
|
|
, mCropRect(nsnull)
|
2010-08-05 14:57:18 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
, mImageTracked(false)
|
|
|
|
#endif
|
2009-08-21 13:39:25 -07:00
|
|
|
{
|
|
|
|
// We need our own copy constructor because we don't want
|
|
|
|
// to copy the reference count
|
|
|
|
MOZ_COUNT_CTOR(nsStyleImage);
|
|
|
|
DoCopy(aOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleImage&
|
|
|
|
nsStyleImage::operator=(const nsStyleImage& aOther)
|
|
|
|
{
|
|
|
|
if (this != &aOther)
|
|
|
|
DoCopy(aOther);
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImage::DoCopy(const nsStyleImage& aOther)
|
|
|
|
{
|
|
|
|
SetNull();
|
|
|
|
|
|
|
|
if (aOther.mType == eStyleImageType_Image)
|
|
|
|
SetImageData(aOther.mImage);
|
|
|
|
else if (aOther.mType == eStyleImageType_Gradient)
|
|
|
|
SetGradientData(aOther.mGradient);
|
2010-08-13 06:33:37 -07:00
|
|
|
else if (aOther.mType == eStyleImageType_Element)
|
|
|
|
SetElementId(aOther.mElementId);
|
2009-08-21 13:39:25 -07:00
|
|
|
|
|
|
|
SetCropRect(aOther.mCropRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImage::SetNull()
|
|
|
|
{
|
2010-08-05 14:57:18 -07:00
|
|
|
NS_ABORT_IF_FALSE(!mImageTracked,
|
|
|
|
"Calling SetNull() with image tracked!");
|
|
|
|
|
2009-08-21 13:39:25 -07:00
|
|
|
if (mType == eStyleImageType_Gradient)
|
|
|
|
mGradient->Release();
|
|
|
|
else if (mType == eStyleImageType_Image)
|
|
|
|
NS_RELEASE(mImage);
|
2010-08-13 06:33:37 -07:00
|
|
|
else if (mType == eStyleImageType_Element)
|
2011-06-20 22:03:59 -07:00
|
|
|
NS_Free(mElementId);
|
2009-08-21 13:39:25 -07:00
|
|
|
|
|
|
|
mType = eStyleImageType_Null;
|
|
|
|
mCropRect = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImage::SetImageData(imgIRequest* aImage)
|
|
|
|
{
|
2010-08-05 14:57:18 -07:00
|
|
|
NS_ABORT_IF_FALSE(!mImageTracked,
|
|
|
|
"Setting a new image without untracking the old one!");
|
|
|
|
|
2009-08-21 13:39:25 -07:00
|
|
|
NS_IF_ADDREF(aImage);
|
|
|
|
|
|
|
|
if (mType != eStyleImageType_Null)
|
|
|
|
SetNull();
|
|
|
|
|
|
|
|
if (aImage) {
|
|
|
|
mImage = aImage;
|
|
|
|
mType = eStyleImageType_Image;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-05 14:57:18 -07:00
|
|
|
void
|
|
|
|
nsStyleImage::TrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
|
|
|
NS_ABORT_IF_FALSE(!mImageTracked, "Already tracking image!");
|
|
|
|
NS_ABORT_IF_FALSE(mType == eStyleImageType_Image,
|
|
|
|
"Can't track image when there isn't one!");
|
|
|
|
|
|
|
|
// Register the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
|
|
|
if (doc)
|
|
|
|
doc->AddImage(mImage);
|
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImage::UntrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
|
|
|
NS_ABORT_IF_FALSE(mImageTracked, "Image not tracked!");
|
|
|
|
NS_ABORT_IF_FALSE(mType == eStyleImageType_Image,
|
|
|
|
"Can't untrack image when there isn't one!");
|
|
|
|
|
|
|
|
// Unregister the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
|
|
|
if (doc)
|
|
|
|
doc->RemoveImage(mImage);
|
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-08-21 13:39:25 -07:00
|
|
|
void
|
|
|
|
nsStyleImage::SetGradientData(nsStyleGradient* aGradient)
|
|
|
|
{
|
|
|
|
if (aGradient)
|
|
|
|
aGradient->AddRef();
|
|
|
|
|
|
|
|
if (mType != eStyleImageType_Null)
|
|
|
|
SetNull();
|
|
|
|
|
|
|
|
if (aGradient) {
|
|
|
|
mGradient = aGradient;
|
|
|
|
mType = eStyleImageType_Gradient;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-13 06:33:37 -07:00
|
|
|
void
|
|
|
|
nsStyleImage::SetElementId(const PRUnichar* aElementId)
|
|
|
|
{
|
|
|
|
if (mType != eStyleImageType_Null)
|
|
|
|
SetNull();
|
|
|
|
|
|
|
|
if (aElementId) {
|
2011-06-20 22:03:59 -07:00
|
|
|
mElementId = NS_strdup(aElementId);
|
2010-08-13 06:33:37 -07:00
|
|
|
mType = eStyleImageType_Element;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-21 13:39:25 -07:00
|
|
|
void
|
|
|
|
nsStyleImage::SetCropRect(nsStyleSides* aCropRect)
|
|
|
|
{
|
|
|
|
if (aCropRect) {
|
|
|
|
mCropRect = new nsStyleSides(*aCropRect);
|
|
|
|
// There is really not much we can do if 'new' fails
|
|
|
|
} else {
|
|
|
|
mCropRect = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static PRInt32
|
|
|
|
ConvertToPixelCoord(const nsStyleCoord& aCoord, PRInt32 aPercentScale)
|
|
|
|
{
|
|
|
|
double pixelValue;
|
|
|
|
switch (aCoord.GetUnit()) {
|
|
|
|
case eStyleUnit_Percent:
|
|
|
|
pixelValue = aCoord.GetPercentValue() * aPercentScale;
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Factor:
|
|
|
|
pixelValue = aCoord.GetFactorValue();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unexpected unit for image crop rect");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
NS_ABORT_IF_FALSE(pixelValue >= 0, "we ensured non-negative while parsing");
|
2009-09-16 08:01:36 -07:00
|
|
|
pixelValue = NS_MIN(pixelValue, double(PR_INT32_MAX)); // avoid overflow
|
2009-08-21 13:39:25 -07:00
|
|
|
return NS_lround(pixelValue);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2009-08-21 13:39:25 -07:00
|
|
|
nsStyleImage::ComputeActualCropRect(nsIntRect& aActualCropRect,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aIsEntireImage) const
|
2009-08-21 13:39:25 -07:00
|
|
|
{
|
|
|
|
if (mType != eStyleImageType_Image)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-21 13:39:25 -07:00
|
|
|
|
|
|
|
nsCOMPtr<imgIContainer> imageContainer;
|
|
|
|
mImage->GetImage(getter_AddRefs(imageContainer));
|
|
|
|
if (!imageContainer)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-21 13:39:25 -07:00
|
|
|
|
|
|
|
nsIntSize imageSize;
|
|
|
|
imageContainer->GetWidth(&imageSize.width);
|
|
|
|
imageContainer->GetHeight(&imageSize.height);
|
|
|
|
if (imageSize.width <= 0 || imageSize.height <= 0)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-21 13:39:25 -07:00
|
|
|
|
|
|
|
PRInt32 left = ConvertToPixelCoord(mCropRect->GetLeft(), imageSize.width);
|
|
|
|
PRInt32 top = ConvertToPixelCoord(mCropRect->GetTop(), imageSize.height);
|
|
|
|
PRInt32 right = ConvertToPixelCoord(mCropRect->GetRight(), imageSize.width);
|
|
|
|
PRInt32 bottom = ConvertToPixelCoord(mCropRect->GetBottom(), imageSize.height);
|
|
|
|
|
|
|
|
// IntersectRect() returns an empty rect if we get negative width or height
|
|
|
|
nsIntRect cropRect(left, top, right - left, bottom - top);
|
|
|
|
nsIntRect imageRect(nsIntPoint(0, 0), imageSize);
|
|
|
|
aActualCropRect.IntersectRect(imageRect, cropRect);
|
|
|
|
|
|
|
|
if (aIsEntireImage)
|
2011-04-18 20:07:23 -07:00
|
|
|
*aIsEntireImage = aActualCropRect.IsEqualInterior(imageRect);
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-08-21 13:39:25 -07:00
|
|
|
}
|
|
|
|
|
2009-09-12 15:44:18 -07:00
|
|
|
nsresult
|
2010-08-05 14:30:19 -07:00
|
|
|
nsStyleImage::RequestDecode() const
|
2009-09-12 15:44:18 -07:00
|
|
|
{
|
|
|
|
if ((mType == eStyleImageType_Image) && mImage)
|
|
|
|
return mImage->RequestDecode();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2009-08-21 13:39:25 -07:00
|
|
|
nsStyleImage::IsOpaque() const
|
|
|
|
{
|
|
|
|
if (!IsComplete())
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-21 13:39:25 -07:00
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
if (mType == eStyleImageType_Gradient)
|
|
|
|
return mGradient->IsOpaque();
|
2009-08-21 13:39:25 -07:00
|
|
|
|
2010-08-13 06:33:37 -07:00
|
|
|
if (mType == eStyleImageType_Element)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-08-13 06:33:37 -07:00
|
|
|
|
2009-08-21 13:39:25 -07:00
|
|
|
NS_ABORT_IF_FALSE(mType == eStyleImageType_Image, "unexpected image type");
|
|
|
|
|
|
|
|
nsCOMPtr<imgIContainer> imageContainer;
|
|
|
|
mImage->GetImage(getter_AddRefs(imageContainer));
|
|
|
|
NS_ABORT_IF_FALSE(imageContainer, "IsComplete() said image container is ready");
|
|
|
|
|
|
|
|
// Check if the crop region of the current image frame is opaque
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isOpaque;
|
2009-08-21 13:39:25 -07:00
|
|
|
if (NS_SUCCEEDED(imageContainer->GetCurrentFrameIsOpaque(&isOpaque)) &&
|
|
|
|
isOpaque) {
|
|
|
|
if (!mCropRect)
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-08-21 13:39:25 -07:00
|
|
|
|
|
|
|
// Must make sure if mCropRect contains at least a pixel.
|
2011-10-17 07:59:28 -07:00
|
|
|
// XXX Is this optimization worth it? Maybe I should just return false.
|
2009-08-21 13:39:25 -07:00
|
|
|
nsIntRect actualCropRect;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool rv = ComputeActualCropRect(actualCropRect);
|
2009-08-21 13:39:25 -07:00
|
|
|
NS_ASSERTION(rv, "ComputeActualCropRect() can not fail here");
|
|
|
|
return rv && !actualCropRect.IsEmpty();
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-21 13:39:25 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2009-08-21 13:39:25 -07:00
|
|
|
nsStyleImage::IsComplete() const
|
|
|
|
{
|
|
|
|
switch (mType) {
|
|
|
|
case eStyleImageType_Null:
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-21 13:39:25 -07:00
|
|
|
case eStyleImageType_Gradient:
|
2010-08-13 06:33:37 -07:00
|
|
|
case eStyleImageType_Element:
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-08-21 13:39:25 -07:00
|
|
|
case eStyleImageType_Image:
|
|
|
|
{
|
|
|
|
PRUint32 status = imgIRequest::STATUS_ERROR;
|
|
|
|
return NS_SUCCEEDED(mImage->GetImageStatus(&status)) &&
|
|
|
|
(status & imgIRequest::STATUS_SIZE_AVAILABLE) &&
|
|
|
|
(status & imgIRequest::STATUS_FRAME_COMPLETE);
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unexpected image type");
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-21 13:39:25 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static inline bool
|
2009-08-21 13:39:25 -07:00
|
|
|
EqualRects(const nsStyleSides* aRect1, const nsStyleSides* aRect2)
|
|
|
|
{
|
|
|
|
return aRect1 == aRect2 || /* handles null== null, and optimize */
|
|
|
|
(aRect1 && aRect2 && *aRect1 == *aRect2);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2009-08-21 13:39:25 -07:00
|
|
|
nsStyleImage::operator==(const nsStyleImage& aOther) const
|
|
|
|
{
|
|
|
|
if (mType != aOther.mType)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-21 13:39:25 -07:00
|
|
|
|
|
|
|
if (!EqualRects(mCropRect, aOther.mCropRect))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-21 13:39:25 -07:00
|
|
|
|
|
|
|
if (mType == eStyleImageType_Image)
|
|
|
|
return EqualImages(mImage, aOther.mImage);
|
|
|
|
|
|
|
|
if (mType == eStyleImageType_Gradient)
|
|
|
|
return *mGradient == *aOther.mGradient;
|
|
|
|
|
2010-08-13 06:33:37 -07:00
|
|
|
if (mType == eStyleImageType_Element)
|
2011-06-20 22:03:59 -07:00
|
|
|
return NS_strcmp(mElementId, aOther.mElementId) == 0;
|
2010-08-13 06:33:37 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-08-21 13:39:25 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// --------------------
|
|
|
|
// nsStyleBackground
|
|
|
|
//
|
|
|
|
|
2008-09-12 08:35:53 -07:00
|
|
|
nsStyleBackground::nsStyleBackground()
|
2009-02-19 21:29:21 -08:00
|
|
|
: mAttachmentCount(1)
|
|
|
|
, mClipCount(1)
|
|
|
|
, mOriginCount(1)
|
|
|
|
, mRepeatCount(1)
|
|
|
|
, mPositionCount(1)
|
|
|
|
, mImageCount(1)
|
2009-05-28 11:09:05 -07:00
|
|
|
, mSizeCount(1)
|
2009-02-19 21:29:21 -08:00
|
|
|
, mBackgroundColor(NS_RGBA(0, 0, 0, 0))
|
|
|
|
, mBackgroundInlinePolicy(NS_STYLE_BG_INLINE_POLICY_CONTINUOUS)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleBackground);
|
2009-02-19 21:29:21 -08:00
|
|
|
Layer *onlyLayer = mLayers.AppendElement();
|
|
|
|
NS_ASSERTION(onlyLayer, "auto array must have room for 1 element");
|
|
|
|
onlyLayer->SetInitialValues();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::nsStyleBackground(const nsStyleBackground& aSource)
|
2009-02-19 21:29:21 -08:00
|
|
|
: mAttachmentCount(aSource.mAttachmentCount)
|
|
|
|
, mClipCount(aSource.mClipCount)
|
|
|
|
, mOriginCount(aSource.mOriginCount)
|
|
|
|
, mRepeatCount(aSource.mRepeatCount)
|
|
|
|
, mPositionCount(aSource.mPositionCount)
|
|
|
|
, mImageCount(aSource.mImageCount)
|
2009-05-28 11:09:05 -07:00
|
|
|
, mSizeCount(aSource.mSizeCount)
|
2009-02-19 21:29:21 -08:00
|
|
|
, mLayers(aSource.mLayers) // deep copy
|
|
|
|
, mBackgroundColor(aSource.mBackgroundColor)
|
|
|
|
, mBackgroundInlinePolicy(aSource.mBackgroundInlinePolicy)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleBackground);
|
2009-02-19 21:29:21 -08:00
|
|
|
// If the deep copy of mLayers failed, truncate the counts.
|
|
|
|
PRUint32 count = mLayers.Length();
|
|
|
|
if (count != aSource.mLayers.Length()) {
|
|
|
|
NS_WARNING("truncating counts due to out-of-memory");
|
2009-09-16 08:01:36 -07:00
|
|
|
mAttachmentCount = NS_MAX(mAttachmentCount, count);
|
|
|
|
mClipCount = NS_MAX(mClipCount, count);
|
|
|
|
mOriginCount = NS_MAX(mOriginCount, count);
|
|
|
|
mRepeatCount = NS_MAX(mRepeatCount, count);
|
|
|
|
mPositionCount = NS_MAX(mPositionCount, count);
|
|
|
|
mImageCount = NS_MAX(mImageCount, count);
|
|
|
|
mSizeCount = NS_MAX(mSizeCount, count);
|
2009-02-19 21:29:21 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::~nsStyleBackground()
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_DTOR(nsStyleBackground);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-08-05 14:57:18 -07:00
|
|
|
void
|
|
|
|
nsStyleBackground::Destroy(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Untrack all the images stored in our layers
|
|
|
|
for (PRUint32 i = 0; i < mImageCount; ++i)
|
|
|
|
mLayers[i].UntrackImages(aContext);
|
|
|
|
|
|
|
|
this->~nsStyleBackground();
|
|
|
|
aContext->FreeToShell(sizeof(nsStyleBackground), this);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsChangeHint nsStyleBackground::CalcDifference(const nsStyleBackground& aOther) const
|
|
|
|
{
|
2010-08-13 06:33:37 -07:00
|
|
|
const nsStyleBackground* moreLayers =
|
|
|
|
mImageCount > aOther.mImageCount ? this : &aOther;
|
|
|
|
const nsStyleBackground* lessLayers =
|
|
|
|
mImageCount > aOther.mImageCount ? &aOther : this;
|
2009-02-19 21:29:21 -08:00
|
|
|
|
2010-08-13 06:33:37 -07:00
|
|
|
bool hasVisualDifference = false;
|
|
|
|
|
|
|
|
NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, moreLayers) {
|
|
|
|
if (i < lessLayers->mImageCount) {
|
|
|
|
if (moreLayers->mLayers[i] != lessLayers->mLayers[i]) {
|
|
|
|
if ((moreLayers->mLayers[i].mImage.GetType() == eStyleImageType_Element) ||
|
|
|
|
(lessLayers->mLayers[i].mImage.GetType() == eStyleImageType_Element))
|
|
|
|
return NS_CombineHint(nsChangeHint_UpdateEffects, NS_STYLE_HINT_VISUAL);
|
|
|
|
hasVisualDifference = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (moreLayers->mLayers[i].mImage.GetType() == eStyleImageType_Element)
|
|
|
|
return NS_CombineHint(nsChangeHint_UpdateEffects, NS_STYLE_HINT_VISUAL);
|
|
|
|
hasVisualDifference = true;
|
|
|
|
}
|
2009-02-19 21:29:21 -08:00
|
|
|
}
|
|
|
|
|
2010-08-13 06:33:37 -07:00
|
|
|
if (hasVisualDifference ||
|
|
|
|
mBackgroundColor != aOther.mBackgroundColor ||
|
|
|
|
mBackgroundInlinePolicy != aOther.mBackgroundInlinePolicy)
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
|
2009-02-19 21:29:21 -08:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleBackground::MaxDifference()
|
|
|
|
{
|
2010-08-13 06:33:37 -07:00
|
|
|
return NS_CombineHint(nsChangeHint_UpdateEffects, NS_STYLE_HINT_VISUAL);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool nsStyleBackground::HasFixedBackground() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-02-19 21:29:21 -08:00
|
|
|
NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, this) {
|
|
|
|
const Layer &layer = mLayers[i];
|
2009-08-01 08:53:40 -07:00
|
|
|
if (layer.mAttachment == NS_STYLE_BG_ATTACHMENT_FIXED &&
|
2009-08-21 13:39:25 -07:00
|
|
|
!layer.mImage.IsEmpty()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-02-19 21:29:21 -08:00
|
|
|
}
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-02-19 21:29:21 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool nsStyleBackground::IsTransparent() const
|
2009-02-19 21:29:21 -08:00
|
|
|
{
|
2009-08-21 13:39:25 -07:00
|
|
|
return BottomLayer().mImage.IsEmpty() &&
|
2009-08-01 08:53:40 -07:00
|
|
|
mImageCount == 1 &&
|
2009-02-19 21:29:21 -08:00
|
|
|
NS_GET_A(mBackgroundColor) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleBackground::Position::SetInitialValues()
|
|
|
|
{
|
2011-05-23 13:36:18 -07:00
|
|
|
// Initial value is "0% 0%"
|
2010-09-15 08:11:26 -07:00
|
|
|
mXPosition.mPercent = 0.0f;
|
|
|
|
mXPosition.mLength = 0;
|
2011-10-17 07:59:28 -07:00
|
|
|
mXPosition.mHasPercent = true;
|
2010-09-15 08:11:26 -07:00
|
|
|
mYPosition.mPercent = 0.0f;
|
|
|
|
mYPosition.mLength = 0;
|
2011-10-17 07:59:28 -07:00
|
|
|
mYPosition.mHasPercent = true;
|
2009-02-19 21:29:21 -08:00
|
|
|
}
|
|
|
|
|
2011-01-13 02:40:12 -08:00
|
|
|
bool
|
|
|
|
nsStyleBackground::Size::DependsOnFrameSize(const nsStyleImage& aImage) const
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(aImage.GetType() != eStyleImageType_Null,
|
|
|
|
"caller should have handled this");
|
|
|
|
|
|
|
|
// If either dimension contains a non-zero percentage, rendering for that
|
|
|
|
// dimension straightforwardly depends on frame size.
|
|
|
|
if ((mWidthType == eLengthPercentage && mWidth.mPercent != 0.0f) ||
|
|
|
|
(mHeightType == eLengthPercentage && mHeight.mPercent != 0.0f)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// So too for contain and cover.
|
|
|
|
if (mWidthType == eContain || mWidthType == eCover) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If both dimensions are fixed lengths, there's no dependency.
|
|
|
|
if (mWidthType == eLengthPercentage && mHeightType == eLengthPercentage) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ABORT_IF_FALSE((mWidthType == eLengthPercentage && mHeightType == eAuto) ||
|
|
|
|
(mWidthType == eAuto && mHeightType == eLengthPercentage) ||
|
|
|
|
(mWidthType == eAuto && mHeightType == eAuto),
|
|
|
|
"logic error");
|
|
|
|
|
|
|
|
nsStyleImageType type = aImage.GetType();
|
|
|
|
|
|
|
|
// Gradient rendering depends on frame size when auto is involved because
|
|
|
|
// gradients have no intrinsic ratio or dimensions, and therefore the relevant
|
|
|
|
// dimension is "treat[ed] as 100%".
|
|
|
|
if (type == eStyleImageType_Gradient) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX Element rendering for auto or fixed length doesn't depend on frame size
|
|
|
|
// according to the spec. However, we don't implement the spec yet, so
|
|
|
|
// for now we bail and say element() plus auto affects ultimate size.
|
|
|
|
if (type == eStyleImageType_Element) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == eStyleImageType_Image) {
|
|
|
|
nsCOMPtr<imgIContainer> imgContainer;
|
|
|
|
aImage.GetImageData()->GetImage(getter_AddRefs(imgContainer));
|
|
|
|
if (imgContainer) {
|
|
|
|
nsIntSize imageSize;
|
|
|
|
nsSize imageRatio;
|
|
|
|
bool hasWidth, hasHeight;
|
|
|
|
nsLayoutUtils::ComputeSizeForDrawing(imgContainer, imageSize, imageRatio,
|
|
|
|
hasWidth, hasHeight);
|
|
|
|
|
|
|
|
// If the image has a fixed width and height, rendering never depends on
|
|
|
|
// the frame size.
|
|
|
|
if (hasWidth && hasHeight) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the image has an intrinsic ratio, rendering will depend on frame
|
|
|
|
// size when background-size is all auto.
|
|
|
|
if (imageRatio != nsSize(0, 0)) {
|
|
|
|
return mWidthType == mHeightType;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, rendering depends on frame size when the image dimensions
|
|
|
|
// and background-size don't complement each other.
|
|
|
|
return !(hasWidth && mHeightType == eLengthPercentage) &&
|
|
|
|
!(hasHeight && mWidthType == eLengthPercentage);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
NS_NOTREACHED("missed an enum value");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Passed the gauntlet: no dependency.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-05-28 11:09:05 -07:00
|
|
|
void
|
|
|
|
nsStyleBackground::Size::SetInitialValues()
|
|
|
|
{
|
|
|
|
mWidthType = mHeightType = eAuto;
|
|
|
|
}
|
|
|
|
|
2010-09-15 08:11:26 -07:00
|
|
|
bool
|
2009-05-28 11:09:05 -07:00
|
|
|
nsStyleBackground::Size::operator==(const Size& aOther) const
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mWidthType < eDimensionType_COUNT,
|
|
|
|
"bad mWidthType for this");
|
|
|
|
NS_ABORT_IF_FALSE(mHeightType < eDimensionType_COUNT,
|
|
|
|
"bad mHeightType for this");
|
|
|
|
NS_ABORT_IF_FALSE(aOther.mWidthType < eDimensionType_COUNT,
|
|
|
|
"bad mWidthType for aOther");
|
|
|
|
NS_ABORT_IF_FALSE(aOther.mHeightType < eDimensionType_COUNT,
|
|
|
|
"bad mHeightType for aOther");
|
|
|
|
|
2010-09-15 08:11:26 -07:00
|
|
|
return mWidthType == aOther.mWidthType &&
|
|
|
|
mHeightType == aOther.mHeightType &&
|
|
|
|
(mWidthType != eLengthPercentage || mWidth == aOther.mWidth) &&
|
|
|
|
(mHeightType != eLengthPercentage || mHeight == aOther.mHeight);
|
2009-05-28 11:09:05 -07:00
|
|
|
}
|
|
|
|
|
2012-02-24 21:23:14 -08:00
|
|
|
void
|
|
|
|
nsStyleBackground::Repeat::SetInitialValues()
|
|
|
|
{
|
|
|
|
mXRepeat = NS_STYLE_BG_REPEAT_REPEAT;
|
|
|
|
mYRepeat = NS_STYLE_BG_REPEAT_REPEAT;
|
|
|
|
}
|
|
|
|
|
2009-02-19 21:29:21 -08:00
|
|
|
nsStyleBackground::Layer::Layer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::Layer::~Layer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleBackground::Layer::SetInitialValues()
|
|
|
|
{
|
|
|
|
mAttachment = NS_STYLE_BG_ATTACHMENT_SCROLL;
|
|
|
|
mClip = NS_STYLE_BG_CLIP_BORDER;
|
|
|
|
mOrigin = NS_STYLE_BG_ORIGIN_PADDING;
|
2012-02-24 21:23:14 -08:00
|
|
|
mRepeat.SetInitialValues();
|
2009-02-19 21:29:21 -08:00
|
|
|
mPosition.SetInitialValues();
|
2009-05-28 11:09:05 -07:00
|
|
|
mSize.SetInitialValues();
|
2009-08-01 08:53:40 -07:00
|
|
|
mImage.SetNull();
|
2009-02-19 21:29:21 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2010-10-06 15:18:52 -07:00
|
|
|
nsStyleBackground::Layer::RenderingMightDependOnFrameSize() const
|
|
|
|
{
|
2010-10-06 15:18:52 -07:00
|
|
|
// Do we even have an image?
|
|
|
|
if (mImage.IsEmpty()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-10-06 15:18:52 -07:00
|
|
|
}
|
|
|
|
|
2011-01-13 02:40:12 -08:00
|
|
|
return mPosition.DependsOnFrameSize() || mSize.DependsOnFrameSize(mImage);
|
2010-10-06 15:18:52 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2010-10-06 15:18:52 -07:00
|
|
|
nsStyleBackground::Layer::operator==(const Layer& aOther) const
|
2009-02-19 21:29:21 -08:00
|
|
|
{
|
|
|
|
return mAttachment == aOther.mAttachment &&
|
|
|
|
mClip == aOther.mClip &&
|
|
|
|
mOrigin == aOther.mOrigin &&
|
|
|
|
mRepeat == aOther.mRepeat &&
|
|
|
|
mPosition == aOther.mPosition &&
|
2009-05-28 11:09:05 -07:00
|
|
|
mSize == aOther.mSize &&
|
2009-08-01 08:53:40 -07:00
|
|
|
mImage == aOther.mImage;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// --------------------
|
|
|
|
// nsStyleDisplay
|
|
|
|
//
|
2009-08-20 14:52:47 -07:00
|
|
|
void nsTimingFunction::AssignFromKeyword(PRInt32 aTimingFunctionType)
|
|
|
|
{
|
2011-04-11 23:18:42 -07:00
|
|
|
switch (aTimingFunctionType) {
|
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_STEP_START:
|
|
|
|
mType = StepStart;
|
|
|
|
mSteps = 1;
|
|
|
|
return;
|
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_STEP_END:
|
|
|
|
mType = StepEnd;
|
|
|
|
mSteps = 1;
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
mType = Function;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-02-23 08:19:00 -08:00
|
|
|
MOZ_STATIC_ASSERT(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE == 0 &&
|
|
|
|
NS_STYLE_TRANSITION_TIMING_FUNCTION_LINEAR == 1 &&
|
|
|
|
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN == 2 &&
|
|
|
|
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_OUT == 3 &&
|
|
|
|
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN_OUT == 4,
|
|
|
|
"transition timing function constants not as expected");
|
2009-08-20 14:52:47 -07:00
|
|
|
|
|
|
|
static const float timingFunctionValues[5][4] = {
|
|
|
|
{ 0.25, 0.10, 0.25, 1.00 }, // ease
|
|
|
|
{ 0.00, 0.00, 1.00, 1.00 }, // linear
|
|
|
|
{ 0.42, 0.00, 1.00, 1.00 }, // ease-in
|
|
|
|
{ 0.00, 0.00, 0.58, 1.00 }, // ease-out
|
|
|
|
{ 0.42, 0.00, 0.58, 1.00 } // ease-in-out
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_ABORT_IF_FALSE(0 <= aTimingFunctionType && aTimingFunctionType < 5,
|
|
|
|
"keyword out of range");
|
2011-04-11 23:18:42 -07:00
|
|
|
mFunc.mX1 = timingFunctionValues[aTimingFunctionType][0];
|
|
|
|
mFunc.mY1 = timingFunctionValues[aTimingFunctionType][1];
|
|
|
|
mFunc.mX2 = timingFunctionValues[aTimingFunctionType][2];
|
|
|
|
mFunc.mY2 = timingFunctionValues[aTimingFunctionType][3];
|
2009-08-20 14:52:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTransition::nsTransition(const nsTransition& aCopy)
|
|
|
|
: mTimingFunction(aCopy.mTimingFunction)
|
|
|
|
, mDuration(aCopy.mDuration)
|
|
|
|
, mDelay(aCopy.mDelay)
|
|
|
|
, mProperty(aCopy.mProperty)
|
2010-10-20 17:24:16 -07:00
|
|
|
, mUnknownProperty(aCopy.mUnknownProperty)
|
2009-08-20 14:52:47 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTransition::SetInitialValues()
|
|
|
|
{
|
|
|
|
mTimingFunction = nsTimingFunction(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE);
|
|
|
|
mDuration = 0.0;
|
|
|
|
mDelay = 0.0;
|
|
|
|
mProperty = eCSSPropertyExtra_all_properties;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTransition::SetUnknownProperty(const nsAString& aUnknownProperty)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsCSSProps::LookupProperty(aUnknownProperty) ==
|
|
|
|
eCSSProperty_UNKNOWN,
|
|
|
|
"should be unknown property");
|
|
|
|
mProperty = eCSSProperty_UNKNOWN;
|
|
|
|
mUnknownProperty = do_GetAtom(aUnknownProperty);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-11 23:18:42 -07:00
|
|
|
nsAnimation::nsAnimation(const nsAnimation& aCopy)
|
|
|
|
: mTimingFunction(aCopy.mTimingFunction)
|
|
|
|
, mDuration(aCopy.mDuration)
|
|
|
|
, mDelay(aCopy.mDelay)
|
|
|
|
, mName(aCopy.mName)
|
|
|
|
, mDirection(aCopy.mDirection)
|
|
|
|
, mFillMode(aCopy.mFillMode)
|
|
|
|
, mPlayState(aCopy.mPlayState)
|
|
|
|
, mIterationCount(aCopy.mIterationCount)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsAnimation::SetInitialValues()
|
|
|
|
{
|
|
|
|
mTimingFunction = nsTimingFunction(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE);
|
|
|
|
mDuration = 0.0;
|
|
|
|
mDelay = 0.0;
|
|
|
|
mName = EmptyString();
|
|
|
|
mDirection = NS_STYLE_ANIMATION_DIRECTION_NORMAL;
|
|
|
|
mFillMode = NS_STYLE_ANIMATION_FILL_MODE_NONE;
|
|
|
|
mPlayState = NS_STYLE_ANIMATION_PLAY_STATE_RUNNING;
|
|
|
|
mIterationCount = 1.0f;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsStyleDisplay::nsStyleDisplay()
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleDisplay);
|
2007-09-05 03:27:06 -07:00
|
|
|
mAppearance = NS_THEME_NONE;
|
2007-03-22 10:30:00 -07:00
|
|
|
mDisplay = NS_STYLE_DISPLAY_INLINE;
|
2011-10-29 00:04:20 -07:00
|
|
|
mOriginalDisplay = mDisplay;
|
2007-03-22 10:30:00 -07:00
|
|
|
mPosition = NS_STYLE_POSITION_STATIC;
|
|
|
|
mFloats = NS_STYLE_FLOAT_NONE;
|
2011-10-29 00:04:20 -07:00
|
|
|
mOriginalFloats = mFloats;
|
2007-03-22 10:30:00 -07:00
|
|
|
mBreakType = NS_STYLE_CLEAR_NONE;
|
2011-10-17 07:59:28 -07:00
|
|
|
mBreakBefore = false;
|
|
|
|
mBreakAfter = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
mOverflowX = NS_STYLE_OVERFLOW_VISIBLE;
|
|
|
|
mOverflowY = NS_STYLE_OVERFLOW_VISIBLE;
|
2010-03-19 04:49:33 -07:00
|
|
|
mResize = NS_STYLE_RESIZE_NONE;
|
2007-03-22 10:30:00 -07:00
|
|
|
mClipFlags = NS_STYLE_CLIP_AUTO;
|
|
|
|
mClip.SetRect(0,0,0,0);
|
|
|
|
mOpacity = 1.0f;
|
2010-07-02 21:18:56 -07:00
|
|
|
mSpecifiedTransform = nsnull;
|
2008-09-13 02:42:11 -07:00
|
|
|
mTransformOrigin[0].SetPercentValue(0.5f); // Transform is centered on origin
|
2011-08-02 20:04:23 -07:00
|
|
|
mTransformOrigin[1].SetPercentValue(0.5f);
|
|
|
|
mTransformOrigin[2].SetCoordValue(0);
|
2011-08-02 20:04:24 -07:00
|
|
|
mPerspectiveOrigin[0].SetPercentValue(0.5f);
|
|
|
|
mPerspectiveOrigin[1].SetPercentValue(0.5f);
|
2011-08-02 20:04:22 -07:00
|
|
|
mChildPerspective.SetCoordValue(0);
|
2011-08-02 20:04:22 -07:00
|
|
|
mBackfaceVisibility = NS_STYLE_BACKFACE_VISIBILITY_VISIBLE;
|
2011-08-26 17:01:06 -07:00
|
|
|
mTransformStyle = NS_STYLE_TRANSFORM_STYLE_FLAT;
|
2011-05-10 06:47:46 -07:00
|
|
|
mOrient = NS_STYLE_ORIENT_HORIZONTAL;
|
2011-04-11 23:18:42 -07:00
|
|
|
|
2009-08-20 14:52:47 -07:00
|
|
|
mTransitions.AppendElement();
|
|
|
|
NS_ABORT_IF_FALSE(mTransitions.Length() == 1,
|
|
|
|
"appending within auto buffer should never fail");
|
|
|
|
mTransitions[0].SetInitialValues();
|
|
|
|
mTransitionTimingFunctionCount = 1;
|
|
|
|
mTransitionDurationCount = 1;
|
|
|
|
mTransitionDelayCount = 1;
|
|
|
|
mTransitionPropertyCount = 1;
|
2011-04-11 23:18:42 -07:00
|
|
|
|
|
|
|
mAnimations.AppendElement();
|
|
|
|
NS_ABORT_IF_FALSE(mAnimations.Length() == 1,
|
|
|
|
"appending within auto buffer should never fail");
|
|
|
|
mAnimations[0].SetInitialValues();
|
|
|
|
mAnimationTimingFunctionCount = 1;
|
|
|
|
mAnimationDurationCount = 1;
|
|
|
|
mAnimationDelayCount = 1;
|
|
|
|
mAnimationNameCount = 1;
|
|
|
|
mAnimationDirectionCount = 1;
|
|
|
|
mAnimationFillModeCount = 1;
|
|
|
|
mAnimationPlayStateCount = 1;
|
|
|
|
mAnimationIterationCountCount = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
|
2012-07-06 16:31:54 -07:00
|
|
|
: mBinding(aSource.mBinding)
|
|
|
|
, mClip(aSource.mClip)
|
|
|
|
, mOpacity(aSource.mOpacity)
|
|
|
|
, mDisplay(aSource.mDisplay)
|
|
|
|
, mOriginalDisplay(aSource.mOriginalDisplay)
|
|
|
|
, mAppearance(aSource.mAppearance)
|
|
|
|
, mPosition(aSource.mPosition)
|
|
|
|
, mFloats(aSource.mFloats)
|
|
|
|
, mOriginalFloats(aSource.mOriginalFloats)
|
|
|
|
, mBreakType(aSource.mBreakType)
|
|
|
|
, mBreakBefore(aSource.mBreakBefore)
|
|
|
|
, mBreakAfter(aSource.mBreakAfter)
|
|
|
|
, mOverflowX(aSource.mOverflowX)
|
|
|
|
, mOverflowY(aSource.mOverflowY)
|
|
|
|
, mResize(aSource.mResize)
|
|
|
|
, mClipFlags(aSource.mClipFlags)
|
|
|
|
, mOrient(aSource.mOrient)
|
|
|
|
, mBackfaceVisibility(aSource.mBackfaceVisibility)
|
|
|
|
, mTransformStyle(aSource.mTransformStyle)
|
|
|
|
, mSpecifiedTransform(aSource.mSpecifiedTransform)
|
|
|
|
, mChildPerspective(aSource.mChildPerspective)
|
|
|
|
, mTransitions(aSource.mTransitions)
|
2009-08-20 14:52:47 -07:00
|
|
|
, mTransitionTimingFunctionCount(aSource.mTransitionTimingFunctionCount)
|
|
|
|
, mTransitionDurationCount(aSource.mTransitionDurationCount)
|
|
|
|
, mTransitionDelayCount(aSource.mTransitionDelayCount)
|
|
|
|
, mTransitionPropertyCount(aSource.mTransitionPropertyCount)
|
2011-04-11 23:18:42 -07:00
|
|
|
, mAnimations(aSource.mAnimations)
|
|
|
|
, mAnimationTimingFunctionCount(aSource.mAnimationTimingFunctionCount)
|
|
|
|
, mAnimationDurationCount(aSource.mAnimationDurationCount)
|
|
|
|
, mAnimationDelayCount(aSource.mAnimationDelayCount)
|
|
|
|
, mAnimationNameCount(aSource.mAnimationNameCount)
|
|
|
|
, mAnimationDirectionCount(aSource.mAnimationDirectionCount)
|
|
|
|
, mAnimationFillModeCount(aSource.mAnimationFillModeCount)
|
|
|
|
, mAnimationPlayStateCount(aSource.mAnimationPlayStateCount)
|
|
|
|
, mAnimationIterationCountCount(aSource.mAnimationIterationCountCount)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleDisplay);
|
2012-07-06 16:31:54 -07:00
|
|
|
|
2008-09-13 02:42:11 -07:00
|
|
|
/* Copy over transform origin. */
|
|
|
|
mTransformOrigin[0] = aSource.mTransformOrigin[0];
|
|
|
|
mTransformOrigin[1] = aSource.mTransformOrigin[1];
|
2011-08-02 20:04:23 -07:00
|
|
|
mTransformOrigin[2] = aSource.mTransformOrigin[2];
|
2011-08-02 20:04:24 -07:00
|
|
|
mPerspectiveOrigin[0] = aSource.mPerspectiveOrigin[0];
|
|
|
|
mPerspectiveOrigin[1] = aSource.mPerspectiveOrigin[1];
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
|
|
|
|
{
|
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
|
|
|
if (!EqualURIs(mBinding, aOther.mBinding)
|
|
|
|
|| mPosition != aOther.mPosition
|
|
|
|
|| mDisplay != aOther.mDisplay
|
|
|
|
|| (mFloats == NS_STYLE_FLOAT_NONE) != (aOther.mFloats == NS_STYLE_FLOAT_NONE)
|
2011-09-13 12:09:51 -07:00
|
|
|
|| mOverflowX != aOther.mOverflowX
|
|
|
|
|| mOverflowY != aOther.mOverflowY
|
2010-03-19 04:49:33 -07:00
|
|
|
|| mResize != aOther.mResize)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
|
|
|
|
|
2009-08-03 18:22:13 -07:00
|
|
|
if (mFloats != aOther.mFloats) {
|
|
|
|
// Changing which side we float on doesn't affect descendants directly
|
|
|
|
NS_UpdateHint(hint,
|
|
|
|
NS_SubtractHint(nsChangeHint_ReflowFrame,
|
|
|
|
NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
|
|
|
|
nsChangeHint_NeedDirtyReflow)));
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// XXX the following is conservative, for now: changing float breaking shouldn't
|
|
|
|
// necessarily require a repaint, reflow should suffice.
|
|
|
|
if (mBreakType != aOther.mBreakType
|
|
|
|
|| mBreakBefore != aOther.mBreakBefore
|
|
|
|
|| mBreakAfter != aOther.mBreakAfter
|
2010-09-02 11:07:37 -07:00
|
|
|
|| mAppearance != aOther.mAppearance
|
2011-05-10 06:47:46 -07:00
|
|
|
|| mOrient != aOther.mOrient
|
2011-04-18 20:07:23 -07:00
|
|
|
|| mClipFlags != aOther.mClipFlags || !mClip.IsEqualInterior(aOther.mClip))
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_UpdateHint(hint, NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame));
|
|
|
|
|
2010-07-15 14:07:53 -07:00
|
|
|
if (mOpacity != aOther.mOpacity) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateOpacityLayer);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-13 02:42:11 -07:00
|
|
|
/* If we've added or removed the transform property, we need to reconstruct the frame to add
|
|
|
|
* or remove the view object, and also to handle abs-pos and fixed-pos containers.
|
|
|
|
*/
|
2010-07-02 21:18:56 -07:00
|
|
|
if (HasTransform() != aOther.HasTransform()) {
|
2008-09-13 02:42:11 -07:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
|
|
|
|
}
|
2010-07-02 21:18:56 -07:00
|
|
|
else if (HasTransform()) {
|
2008-09-13 02:42:11 -07:00
|
|
|
/* Otherwise, if we've kept the property lying around and we already had a
|
|
|
|
* transform, we need to see whether or not we've changed the transform.
|
2011-06-15 14:03:49 -07:00
|
|
|
* If so, we need to recompute its overflow rect (which probably changed
|
|
|
|
* if the transform changed) and to redraw within the bounds of that new
|
|
|
|
* overflow rect.
|
2008-09-13 02:42:11 -07:00
|
|
|
*/
|
2011-07-22 15:28:07 -07:00
|
|
|
if (!mSpecifiedTransform != !aOther.mSpecifiedTransform ||
|
2011-06-15 14:03:49 -07:00
|
|
|
(mSpecifiedTransform &&
|
|
|
|
*mSpecifiedTransform != *aOther.mSpecifiedTransform)) {
|
|
|
|
NS_UpdateHint(hint, NS_CombineHint(nsChangeHint_UpdateOverflow,
|
2010-08-01 20:07:04 -07:00
|
|
|
nsChangeHint_UpdateTransformLayer));
|
2011-06-15 14:03:49 -07:00
|
|
|
}
|
|
|
|
|
2012-01-18 12:04:51 -08:00
|
|
|
const nsChangeHint kUpdateOverflowAndRepaintHint =
|
|
|
|
NS_CombineHint(nsChangeHint_UpdateOverflow, nsChangeHint_RepaintFrame);
|
2011-08-02 20:04:23 -07:00
|
|
|
for (PRUint8 index = 0; index < 3; ++index)
|
2008-09-13 02:42:11 -07:00
|
|
|
if (mTransformOrigin[index] != aOther.mTransformOrigin[index]) {
|
2012-01-18 12:04:51 -08:00
|
|
|
NS_UpdateHint(hint, kUpdateOverflowAndRepaintHint);
|
2008-09-13 02:42:11 -07:00
|
|
|
break;
|
|
|
|
}
|
2011-08-02 20:04:22 -07:00
|
|
|
|
2011-08-02 20:04:24 -07:00
|
|
|
for (PRUint8 index = 0; index < 2; ++index)
|
|
|
|
if (mPerspectiveOrigin[index] != aOther.mPerspectiveOrigin[index]) {
|
2012-01-18 12:04:51 -08:00
|
|
|
NS_UpdateHint(hint, kUpdateOverflowAndRepaintHint);
|
2011-08-02 20:04:24 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-01-18 12:04:51 -08:00
|
|
|
if (mChildPerspective != aOther.mChildPerspective ||
|
|
|
|
mTransformStyle != aOther.mTransformStyle)
|
|
|
|
NS_UpdateHint(hint, kUpdateOverflowAndRepaintHint);
|
2011-08-02 20:04:22 -07:00
|
|
|
|
|
|
|
if (mBackfaceVisibility != aOther.mBackfaceVisibility)
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
2008-09-13 02:42:11 -07:00
|
|
|
}
|
2009-12-11 08:13:19 -08:00
|
|
|
|
|
|
|
// Note: Our current behavior for handling changes to the
|
|
|
|
// transition-duration, transition-delay, and transition-timing-function
|
2009-10-07 20:22:42 -07:00
|
|
|
// properties is to do nothing. In other words, the transition
|
|
|
|
// property that matters is what it is when the transition begins, and
|
|
|
|
// we don't stop a transition later because the transition property
|
|
|
|
// changed.
|
2009-12-11 08:13:19 -08:00
|
|
|
// We do handle changes to transition-property, but we don't need to
|
|
|
|
// bother with anything here, since the transition manager is notified
|
|
|
|
// of any style context change anyway.
|
2011-04-11 23:18:42 -07:00
|
|
|
|
|
|
|
// Note: Likewise, for animation-*, the animation manager gets
|
|
|
|
// notified about every new style context constructed, and it uses
|
|
|
|
// that opportunity to handle dynamic changes appropriately.
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleDisplay::MaxDifference()
|
|
|
|
{
|
|
|
|
// All the parts of FRAMECHANGE are present above in CalcDifference.
|
2011-06-15 14:03:49 -07:00
|
|
|
return nsChangeHint(NS_STYLE_HINT_FRAMECHANGE |
|
|
|
|
nsChangeHint_UpdateOpacityLayer |
|
|
|
|
nsChangeHint_UpdateTransformLayer |
|
|
|
|
nsChangeHint_UpdateOverflow);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleVisibility
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleVisibility::nsStyleVisibility(nsPresContext* aPresContext)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleVisibility);
|
2007-03-22 10:30:00 -07:00
|
|
|
PRUint32 bidiOptions = aPresContext->GetBidi();
|
|
|
|
if (GET_BIDI_OPTION_DIRECTION(bidiOptions) == IBMBIDI_TEXTDIRECTION_RTL)
|
|
|
|
mDirection = NS_STYLE_DIRECTION_RTL;
|
|
|
|
else
|
|
|
|
mDirection = NS_STYLE_DIRECTION_LTR;
|
|
|
|
|
|
|
|
mVisible = NS_STYLE_VISIBILITY_VISIBLE;
|
2009-08-26 20:53:35 -07:00
|
|
|
mPointerEvents = NS_STYLE_POINTER_EVENTS_AUTO;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleVisibility);
|
2007-03-22 10:30:00 -07:00
|
|
|
mDirection = aSource.mDirection;
|
|
|
|
mVisible = aSource.mVisible;
|
2009-08-26 20:53:35 -07:00
|
|
|
mPointerEvents = aSource.mPointerEvents;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther) const
|
|
|
|
{
|
2010-12-10 16:25:25 -08:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
|
|
|
if (mDirection != aOther.mDirection) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
|
2012-02-07 03:31:24 -08:00
|
|
|
} else if (mVisible != aOther.mVisible) {
|
2012-01-24 05:09:55 -08:00
|
|
|
if ((NS_STYLE_VISIBILITY_COLLAPSE == mVisible) ||
|
|
|
|
(NS_STYLE_VISIBILITY_COLLAPSE == aOther.mVisible)) {
|
|
|
|
NS_UpdateHint(hint, NS_STYLE_HINT_REFLOW);
|
|
|
|
} else {
|
2012-02-07 03:31:24 -08:00
|
|
|
NS_UpdateHint(hint, NS_STYLE_HINT_VISUAL);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2010-12-10 16:25:25 -08:00
|
|
|
return hint;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleVisibility::MaxDifference()
|
|
|
|
{
|
2010-12-10 16:25:25 -08:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsStyleContentData::~nsStyleContentData()
|
|
|
|
{
|
2010-08-06 10:27:01 -07:00
|
|
|
NS_ABORT_IF_FALSE(!mImageTracked,
|
|
|
|
"nsStyleContentData being destroyed while still tracking image!");
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mType == eStyleContentType_Image) {
|
|
|
|
NS_IF_RELEASE(mContent.mImage);
|
|
|
|
} else if (mType == eStyleContentType_Counter ||
|
|
|
|
mType == eStyleContentType_Counters) {
|
|
|
|
mContent.mCounters->Release();
|
|
|
|
} else if (mContent.mString) {
|
|
|
|
NS_Free(mContent.mString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContentData& nsStyleContentData::operator=(const nsStyleContentData& aOther)
|
|
|
|
{
|
|
|
|
if (this == &aOther)
|
|
|
|
return *this;
|
|
|
|
this->~nsStyleContentData();
|
2007-10-19 08:36:15 -07:00
|
|
|
new (this) nsStyleContentData();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
mType = aOther.mType;
|
|
|
|
if (mType == eStyleContentType_Image) {
|
|
|
|
mContent.mImage = aOther.mContent.mImage;
|
|
|
|
NS_IF_ADDREF(mContent.mImage);
|
|
|
|
} else if (mType == eStyleContentType_Counter ||
|
|
|
|
mType == eStyleContentType_Counters) {
|
|
|
|
mContent.mCounters = aOther.mContent.mCounters;
|
|
|
|
mContent.mCounters->AddRef();
|
|
|
|
} else if (aOther.mContent.mString) {
|
|
|
|
mContent.mString = NS_strdup(aOther.mContent.mString);
|
|
|
|
} else {
|
|
|
|
mContent.mString = nsnull;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool nsStyleContentData::operator==(const nsStyleContentData& aOther) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (mType != aOther.mType)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mType == eStyleContentType_Image) {
|
|
|
|
if (!mContent.mImage || !aOther.mContent.mImage)
|
|
|
|
return mContent.mImage == aOther.mContent.mImage;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool eq;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIURI> thisURI, otherURI;
|
|
|
|
mContent.mImage->GetURI(getter_AddRefs(thisURI));
|
|
|
|
aOther.mContent.mImage->GetURI(getter_AddRefs(otherURI));
|
|
|
|
return thisURI == otherURI || // handles null==null
|
|
|
|
(thisURI && otherURI &&
|
|
|
|
NS_SUCCEEDED(thisURI->Equals(otherURI, &eq)) &&
|
|
|
|
eq);
|
|
|
|
}
|
|
|
|
if (mType == eStyleContentType_Counter ||
|
|
|
|
mType == eStyleContentType_Counters)
|
|
|
|
return *mContent.mCounters == *aOther.mContent.mCounters;
|
2011-06-20 22:03:59 -07:00
|
|
|
return safe_strcmp(mContent.mString, aOther.mContent.mString) == 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-08-06 10:27:01 -07:00
|
|
|
void
|
|
|
|
nsStyleContentData::TrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
|
|
|
NS_ABORT_IF_FALSE(!mImageTracked, "Already tracking image!");
|
|
|
|
NS_ABORT_IF_FALSE(mType == eStyleContentType_Image,
|
|
|
|
"Tryingto do image tracking on non-image!");
|
|
|
|
NS_ABORT_IF_FALSE(mContent.mImage,
|
|
|
|
"Can't track image when there isn't one!");
|
|
|
|
|
|
|
|
// Register the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
|
|
|
if (doc)
|
|
|
|
doc->AddImage(mContent.mImage);
|
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleContentData::UntrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
|
|
|
NS_ABORT_IF_FALSE(mImageTracked, "Image not tracked!");
|
|
|
|
NS_ABORT_IF_FALSE(mType == eStyleContentType_Image,
|
|
|
|
"Trying to do image tracking on non-image!");
|
|
|
|
NS_ABORT_IF_FALSE(mContent.mImage,
|
|
|
|
"Can't untrack image when there isn't one!");
|
|
|
|
|
|
|
|
// Unregister the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
|
|
|
if (doc)
|
|
|
|
doc->RemoveImage(mContent.mImage);
|
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//-----------------------
|
|
|
|
// nsStyleContent
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleContent::nsStyleContent(void)
|
|
|
|
: mMarkerOffset(),
|
|
|
|
mContents(nsnull),
|
|
|
|
mIncrements(nsnull),
|
2009-05-13 01:26:48 -07:00
|
|
|
mResets(nsnull),
|
|
|
|
mContentCount(0),
|
|
|
|
mIncrementCount(0),
|
|
|
|
mResetCount(0)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleContent);
|
2007-05-10 22:58:34 -07:00
|
|
|
mMarkerOffset.SetAutoValue();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContent::~nsStyleContent(void)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_DTOR(nsStyleContent);
|
2007-03-22 10:30:00 -07:00
|
|
|
DELETE_ARRAY_IF(mContents);
|
|
|
|
DELETE_ARRAY_IF(mIncrements);
|
|
|
|
DELETE_ARRAY_IF(mResets);
|
|
|
|
}
|
|
|
|
|
2010-08-06 10:27:01 -07:00
|
|
|
void
|
|
|
|
nsStyleContent::Destroy(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Unregister any images we might have with the document.
|
|
|
|
for (PRUint32 i = 0; i < mContentCount; ++i) {
|
|
|
|
if ((mContents[i].mType == eStyleContentType_Image) &&
|
|
|
|
mContents[i].mContent.mImage) {
|
|
|
|
mContents[i].UntrackImage(aContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this->~nsStyleContent();
|
|
|
|
aContext->FreeToShell(sizeof(nsStyleContent), this);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsStyleContent::nsStyleContent(const nsStyleContent& aSource)
|
|
|
|
:mMarkerOffset(),
|
|
|
|
mContents(nsnull),
|
|
|
|
mIncrements(nsnull),
|
2009-05-13 01:26:48 -07:00
|
|
|
mResets(nsnull),
|
|
|
|
mContentCount(0),
|
|
|
|
mIncrementCount(0),
|
|
|
|
mResetCount(0)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleContent);
|
2007-03-22 10:30:00 -07:00
|
|
|
mMarkerOffset = aSource.mMarkerOffset;
|
|
|
|
|
|
|
|
PRUint32 index;
|
|
|
|
if (NS_SUCCEEDED(AllocateContents(aSource.ContentCount()))) {
|
|
|
|
for (index = 0; index < mContentCount; index++) {
|
|
|
|
ContentAt(index) = aSource.ContentAt(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(AllocateCounterIncrements(aSource.CounterIncrementCount()))) {
|
|
|
|
for (index = 0; index < mIncrementCount; index++) {
|
|
|
|
const nsStyleCounterData *data = aSource.GetCounterIncrementAt(index);
|
|
|
|
mIncrements[index].mCounter = data->mCounter;
|
|
|
|
mIncrements[index].mValue = data->mValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(AllocateCounterResets(aSource.CounterResetCount()))) {
|
|
|
|
for (index = 0; index < mResetCount; index++) {
|
|
|
|
const nsStyleCounterData *data = aSource.GetCounterResetAt(index);
|
|
|
|
mResets[index].mCounter = data->mCounter;
|
|
|
|
mResets[index].mValue = data->mValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleContent::CalcDifference(const nsStyleContent& aOther) const
|
|
|
|
{
|
2010-06-18 09:23:05 -07:00
|
|
|
// In ReResolveStyleContext we assume that if there's no existing
|
|
|
|
// ::before or ::after and we don't have to restyle children of the
|
|
|
|
// node then we can't end up with a ::before or ::after due to the
|
|
|
|
// restyle of the node itself. That's not quite true, but the only
|
|
|
|
// exception to the above is when the 'content' property of the node
|
|
|
|
// changes and the pseudo-element inherits the changed value. Since
|
|
|
|
// the code here triggers a frame change on the node in that case,
|
|
|
|
// the optimization in ReResolveStyleContext is ok. But if we ever
|
|
|
|
// change this code to not reconstruct frames on changes to the
|
|
|
|
// 'content' property, then we will need to revisit the optimization
|
|
|
|
// in ReResolveStyleContext.
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mContentCount != aOther.mContentCount ||
|
|
|
|
mIncrementCount != aOther.mIncrementCount ||
|
|
|
|
mResetCount != aOther.mResetCount) {
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 ix = mContentCount;
|
|
|
|
while (0 < ix--) {
|
|
|
|
if (mContents[ix] != aOther.mContents[ix]) {
|
|
|
|
// Unfortunately we need to reframe here; a simple reflow
|
|
|
|
// will not pick up different text or different image URLs,
|
|
|
|
// since we set all that up in the CSSFrameConstructor
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ix = mIncrementCount;
|
|
|
|
while (0 < ix--) {
|
|
|
|
if ((mIncrements[ix].mValue != aOther.mIncrements[ix].mValue) ||
|
|
|
|
(mIncrements[ix].mCounter != aOther.mIncrements[ix].mCounter)) {
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ix = mResetCount;
|
|
|
|
while (0 < ix--) {
|
|
|
|
if ((mResets[ix].mValue != aOther.mResets[ix].mValue) ||
|
|
|
|
(mResets[ix].mCounter != aOther.mResets[ix].mCounter)) {
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mMarkerOffset != aOther.mMarkerOffset) {
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleContent::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsresult nsStyleContent::AllocateContents(PRUint32 aCount)
|
|
|
|
{
|
2007-09-27 09:27:48 -07:00
|
|
|
// We need to run the destructors of the elements of mContents, so we
|
|
|
|
// delete and reallocate even if aCount == mContentCount. (If
|
|
|
|
// nsStyleContentData had its members private and managed their
|
|
|
|
// ownership on setting, we wouldn't need this, but that seems
|
|
|
|
// unnecessary at this point.)
|
|
|
|
DELETE_ARRAY_IF(mContents);
|
|
|
|
if (aCount) {
|
|
|
|
mContents = new nsStyleContentData[aCount];
|
|
|
|
if (! mContents) {
|
|
|
|
mContentCount = 0;
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2007-09-27 09:27:48 -07:00
|
|
|
mContentCount = aCount;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------
|
|
|
|
// nsStyleQuotes
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleQuotes::nsStyleQuotes(void)
|
|
|
|
: mQuotesCount(0),
|
|
|
|
mQuotes(nsnull)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleQuotes);
|
2008-08-19 07:18:58 -07:00
|
|
|
SetInitial();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleQuotes::~nsStyleQuotes(void)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_DTOR(nsStyleQuotes);
|
2007-03-22 10:30:00 -07:00
|
|
|
DELETE_ARRAY_IF(mQuotes);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleQuotes::nsStyleQuotes(const nsStyleQuotes& aSource)
|
|
|
|
: mQuotesCount(0),
|
|
|
|
mQuotes(nsnull)
|
2008-08-19 07:18:58 -07:00
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleQuotes);
|
2008-08-19 07:18:58 -07:00
|
|
|
CopyFrom(aSource);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleQuotes::SetInitial()
|
|
|
|
{
|
|
|
|
// The initial value for quotes is the en-US typographic convention:
|
|
|
|
// outermost are LEFT and RIGHT DOUBLE QUOTATION MARK, alternating
|
|
|
|
// with LEFT and RIGHT SINGLE QUOTATION MARK.
|
|
|
|
static const PRUnichar initialQuotes[8] = {
|
|
|
|
0x201C, 0, 0x201D, 0, 0x2018, 0, 0x2019, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(AllocateQuotes(2))) {
|
|
|
|
SetQuotesAt(0,
|
|
|
|
nsDependentString(&initialQuotes[0], 1),
|
|
|
|
nsDependentString(&initialQuotes[2], 1));
|
|
|
|
SetQuotesAt(1,
|
|
|
|
nsDependentString(&initialQuotes[4], 1),
|
|
|
|
nsDependentString(&initialQuotes[6], 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleQuotes::CopyFrom(const nsStyleQuotes& aSource)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (NS_SUCCEEDED(AllocateQuotes(aSource.QuotesCount()))) {
|
|
|
|
PRUint32 count = (mQuotesCount * 2);
|
|
|
|
for (PRUint32 index = 0; index < count; index += 2) {
|
|
|
|
aSource.GetQuotesAt(index, mQuotes[index], mQuotes[index + 1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleQuotes::CalcDifference(const nsStyleQuotes& aOther) const
|
|
|
|
{
|
|
|
|
// If the quotes implementation is ever going to change we might not need
|
|
|
|
// a framechange here and a reflow should be sufficient. See bug 35768.
|
|
|
|
if (mQuotesCount == aOther.mQuotesCount) {
|
|
|
|
PRUint32 ix = (mQuotesCount * 2);
|
|
|
|
while (0 < ix--) {
|
|
|
|
if (mQuotes[ix] != aOther.mQuotes[ix]) {
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleQuotes::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleTextReset
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleTextReset::nsStyleTextReset(void)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTextReset);
|
2007-03-22 10:30:00 -07:00
|
|
|
mVerticalAlign.SetIntValue(NS_STYLE_VERTICAL_ALIGN_BASELINE, eStyleUnit_Enumerated);
|
2011-04-22 22:16:41 -07:00
|
|
|
mTextBlink = NS_STYLE_TEXT_BLINK_NONE;
|
|
|
|
mTextDecorationLine = NS_STYLE_TEXT_DECORATION_LINE_NONE;
|
2011-03-31 05:26:35 -07:00
|
|
|
mTextDecorationColor = NS_RGB(0,0,0);
|
|
|
|
mTextDecorationStyle =
|
|
|
|
NS_STYLE_TEXT_DECORATION_STYLE_SOLID | BORDER_COLOR_FOREGROUND;
|
2007-03-22 10:30:00 -07:00
|
|
|
mUnicodeBidi = NS_STYLE_UNICODE_BIDI_NORMAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTextReset::nsStyleTextReset(const nsStyleTextReset& aSource)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTextReset);
|
2011-06-22 11:11:47 -07:00
|
|
|
*this = aSource;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-08-07 07:38:44 -07:00
|
|
|
nsStyleTextReset::~nsStyleTextReset(void)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleTextReset);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsChangeHint nsStyleTextReset::CalcDifference(const nsStyleTextReset& aOther) const
|
|
|
|
{
|
2008-03-29 14:25:15 -07:00
|
|
|
if (mVerticalAlign == aOther.mVerticalAlign
|
|
|
|
&& mUnicodeBidi == aOther.mUnicodeBidi) {
|
2011-04-22 22:16:41 -07:00
|
|
|
// Reflow for blink changes
|
|
|
|
if (mTextBlink != aOther.mTextBlink) {
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2011-03-31 05:26:35 -07:00
|
|
|
PRUint8 lineStyle = GetDecorationStyle();
|
|
|
|
PRUint8 otherLineStyle = aOther.GetDecorationStyle();
|
2011-04-22 22:16:41 -07:00
|
|
|
if (mTextDecorationLine != aOther.mTextDecorationLine ||
|
2011-03-31 05:26:35 -07:00
|
|
|
lineStyle != otherLineStyle) {
|
|
|
|
// Reflow for decoration line style changes only to or from double or
|
|
|
|
// wave because that may cause overflow area changes
|
|
|
|
if (lineStyle == NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE ||
|
|
|
|
lineStyle == NS_STYLE_TEXT_DECORATION_STYLE_WAVY ||
|
|
|
|
otherLineStyle == NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE ||
|
|
|
|
otherLineStyle == NS_STYLE_TEXT_DECORATION_STYLE_WAVY) {
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
// Repaint for other style decoration lines because they must be in
|
|
|
|
// default overflow rect
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Repaint for decoration color changes
|
|
|
|
nscolor decColor, otherDecColor;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isFG, otherIsFG;
|
2011-03-31 05:26:35 -07:00
|
|
|
GetDecorationColor(decColor, isFG);
|
|
|
|
aOther.GetDecorationColor(otherDecColor, otherIsFG);
|
|
|
|
if (isFG != otherIsFG || (!isFG && decColor != otherDecColor)) {
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2008-03-29 14:25:15 -07:00
|
|
|
}
|
|
|
|
|
2011-06-22 11:11:47 -07:00
|
|
|
if (mTextOverflow != aOther.mTextOverflow) {
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2008-03-29 14:25:15 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleTextReset::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-11-02 16:58:46 -08:00
|
|
|
// Allowed to return one of NS_STYLE_HINT_NONE, NS_STYLE_HINT_REFLOW
|
|
|
|
// or NS_STYLE_HINT_VISUAL. Currently we just return NONE or REFLOW, though.
|
2009-08-03 18:22:13 -07:00
|
|
|
// XXXbz can this not return a more specific hint? If that's ever
|
|
|
|
// changed, nsStyleBorder::CalcDifference will need changing too.
|
2008-07-07 17:56:52 -07:00
|
|
|
static nsChangeHint
|
|
|
|
CalcShadowDifference(nsCSSShadowArray* lhs,
|
|
|
|
nsCSSShadowArray* rhs)
|
|
|
|
{
|
|
|
|
if (lhs == rhs)
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
|
|
|
|
if (!lhs || !rhs || lhs->Length() != rhs->Length())
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
|
|
|
|
for (PRUint32 i = 0; i < lhs->Length(); ++i) {
|
|
|
|
if (*lhs->ShadowAt(i) != *rhs->ShadowAt(i))
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// --------------------
|
|
|
|
// nsStyleText
|
|
|
|
//
|
|
|
|
|
2008-06-05 16:06:34 -07:00
|
|
|
nsStyleText::nsStyleText(void)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleText);
|
2007-03-22 10:30:00 -07:00
|
|
|
mTextAlign = NS_STYLE_TEXT_ALIGN_DEFAULT;
|
2012-01-12 09:52:21 -08:00
|
|
|
mTextAlignLast = NS_STYLE_TEXT_ALIGN_AUTO;
|
2007-03-22 10:30:00 -07:00
|
|
|
mTextTransform = NS_STYLE_TEXT_TRANSFORM_NONE;
|
|
|
|
mWhiteSpace = NS_STYLE_WHITESPACE_NORMAL;
|
2012-05-07 12:18:23 -07:00
|
|
|
mWordBreak = NS_STYLE_WORDBREAK_NORMAL;
|
2008-07-24 00:16:18 -07:00
|
|
|
mWordWrap = NS_STYLE_WORDWRAP_NORMAL;
|
2011-05-04 04:14:50 -07:00
|
|
|
mHyphens = NS_STYLE_HYPHENS_MANUAL;
|
2011-11-23 18:48:23 -08:00
|
|
|
mTextSizeAdjust = NS_STYLE_TEXT_SIZE_ADJUST_AUTO;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
mLetterSpacing.SetNormalValue();
|
|
|
|
mLineHeight.SetNormalValue();
|
|
|
|
mTextIndent.SetCoordValue(0);
|
2008-12-27 17:58:14 -08:00
|
|
|
mWordSpacing = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-07-07 17:56:52 -07:00
|
|
|
mTextShadow = nsnull;
|
2009-09-26 13:23:47 -07:00
|
|
|
mTabSize = NS_STYLE_TABSIZE_INITIAL;
|
2008-06-03 16:42:13 -07:00
|
|
|
}
|
2008-06-03 15:25:31 -07:00
|
|
|
|
2008-06-05 16:06:34 -07:00
|
|
|
nsStyleText::nsStyleText(const nsStyleText& aSource)
|
|
|
|
: mTextAlign(aSource.mTextAlign),
|
2012-01-12 09:52:21 -08:00
|
|
|
mTextAlignLast(aSource.mTextAlignLast),
|
2008-06-05 16:06:34 -07:00
|
|
|
mTextTransform(aSource.mTextTransform),
|
|
|
|
mWhiteSpace(aSource.mWhiteSpace),
|
2012-05-07 12:18:23 -07:00
|
|
|
mWordBreak(aSource.mWordBreak),
|
2008-07-24 00:16:18 -07:00
|
|
|
mWordWrap(aSource.mWordWrap),
|
2011-05-04 04:14:50 -07:00
|
|
|
mHyphens(aSource.mHyphens),
|
2011-11-23 18:48:23 -08:00
|
|
|
mTextSizeAdjust(aSource.mTextSizeAdjust),
|
2009-10-14 19:42:03 -07:00
|
|
|
mTabSize(aSource.mTabSize),
|
2012-04-17 12:22:49 -07:00
|
|
|
mWordSpacing(aSource.mWordSpacing),
|
2008-06-05 16:06:34 -07:00
|
|
|
mLetterSpacing(aSource.mLetterSpacing),
|
|
|
|
mLineHeight(aSource.mLineHeight),
|
|
|
|
mTextIndent(aSource.mTextIndent),
|
2009-10-14 19:42:03 -07:00
|
|
|
mTextShadow(aSource.mTextShadow)
|
2009-08-07 07:38:44 -07:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleText);
|
|
|
|
}
|
2008-06-05 16:06:34 -07:00
|
|
|
|
2009-08-07 07:38:44 -07:00
|
|
|
nsStyleText::~nsStyleText(void)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleText);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aOther) const
|
|
|
|
{
|
2009-07-29 20:02:22 -07:00
|
|
|
if (NewlineIsSignificant() != aOther.NewlineIsSignificant()) {
|
2009-06-13 02:16:34 -07:00
|
|
|
// This may require construction of suppressed text frames
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
|
2008-06-05 16:06:34 -07:00
|
|
|
if ((mTextAlign != aOther.mTextAlign) ||
|
2012-01-12 09:52:21 -08:00
|
|
|
(mTextAlignLast != aOther.mTextAlignLast) ||
|
2008-06-05 16:06:34 -07:00
|
|
|
(mTextTransform != aOther.mTextTransform) ||
|
2009-07-29 20:02:22 -07:00
|
|
|
(mWhiteSpace != aOther.mWhiteSpace) ||
|
2012-05-07 12:18:23 -07:00
|
|
|
(mWordBreak != aOther.mWordBreak) ||
|
2008-07-24 00:16:18 -07:00
|
|
|
(mWordWrap != aOther.mWordWrap) ||
|
2011-05-04 04:14:50 -07:00
|
|
|
(mHyphens != aOther.mHyphens) ||
|
2011-11-23 18:48:23 -08:00
|
|
|
(mTextSizeAdjust != aOther.mTextSizeAdjust) ||
|
2008-06-05 16:06:34 -07:00
|
|
|
(mLetterSpacing != aOther.mLetterSpacing) ||
|
|
|
|
(mLineHeight != aOther.mLineHeight) ||
|
|
|
|
(mTextIndent != aOther.mTextIndent) ||
|
2009-09-26 13:23:47 -07:00
|
|
|
(mWordSpacing != aOther.mWordSpacing) ||
|
|
|
|
(mTabSize != aOther.mTabSize))
|
2008-06-05 16:06:34 -07:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
|
2008-07-07 17:56:52 -07:00
|
|
|
return CalcShadowDifference(mTextShadow, aOther.mTextShadow);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleText::MaxDifference()
|
|
|
|
{
|
2009-06-13 02:16:34 -07:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//-----------------------
|
|
|
|
// nsStyleUserInterface
|
|
|
|
//
|
|
|
|
|
|
|
|
nsCursorImage::nsCursorImage()
|
2011-10-17 07:59:28 -07:00
|
|
|
: mHaveHotspot(false)
|
2007-03-22 10:30:00 -07:00
|
|
|
, mHotspotX(0.0f)
|
|
|
|
, mHotspotY(0.0f)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-16 09:19:26 -07:00
|
|
|
nsCursorImage::nsCursorImage(const nsCursorImage& aOther)
|
|
|
|
: mHaveHotspot(aOther.mHaveHotspot)
|
|
|
|
, mHotspotX(aOther.mHotspotX)
|
|
|
|
, mHotspotY(aOther.mHotspotY)
|
|
|
|
{
|
|
|
|
SetImage(aOther.GetImage());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCursorImage::~nsCursorImage()
|
|
|
|
{
|
|
|
|
SetImage(nsnull);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCursorImage&
|
|
|
|
nsCursorImage::operator=(const nsCursorImage& aOther)
|
|
|
|
{
|
|
|
|
if (this != &aOther) {
|
|
|
|
mHaveHotspot = aOther.mHaveHotspot;
|
|
|
|
mHotspotX = aOther.mHotspotX;
|
|
|
|
mHotspotY = aOther.mHotspotY;
|
|
|
|
SetImage(aOther.GetImage());
|
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsStyleUserInterface::nsStyleUserInterface(void)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUserInterface);
|
2007-03-22 10:30:00 -07:00
|
|
|
mUserInput = NS_STYLE_USER_INPUT_AUTO;
|
|
|
|
mUserModify = NS_STYLE_USER_MODIFY_READ_ONLY;
|
|
|
|
mUserFocus = NS_STYLE_USER_FOCUS_NONE;
|
|
|
|
|
|
|
|
mCursor = NS_STYLE_CURSOR_AUTO; // fix for bugzilla bug 51113
|
|
|
|
|
|
|
|
mCursorArrayLength = 0;
|
|
|
|
mCursorArray = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUserInterface::nsStyleUserInterface(const nsStyleUserInterface& aSource) :
|
|
|
|
mUserInput(aSource.mUserInput),
|
|
|
|
mUserModify(aSource.mUserModify),
|
|
|
|
mUserFocus(aSource.mUserFocus),
|
|
|
|
mCursor(aSource.mCursor)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUserInterface);
|
2007-03-22 10:30:00 -07:00
|
|
|
CopyCursorArrayFrom(aSource);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUserInterface::~nsStyleUserInterface(void)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_DTOR(nsStyleUserInterface);
|
2007-03-22 10:30:00 -07:00
|
|
|
delete [] mCursorArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aOther) const
|
|
|
|
{
|
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
if (mCursor != aOther.mCursor)
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateCursor);
|
|
|
|
|
|
|
|
// We could do better. But it wouldn't be worth it, URL-specified cursors are
|
|
|
|
// rare.
|
|
|
|
if (mCursorArrayLength > 0 || aOther.mCursorArrayLength > 0)
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateCursor);
|
|
|
|
|
|
|
|
if (mUserModify != aOther.mUserModify)
|
|
|
|
NS_UpdateHint(hint, NS_STYLE_HINT_VISUAL);
|
|
|
|
|
|
|
|
if ((mUserInput != aOther.mUserInput) &&
|
|
|
|
((NS_STYLE_USER_INPUT_NONE == mUserInput) ||
|
|
|
|
(NS_STYLE_USER_INPUT_NONE == aOther.mUserInput))) {
|
|
|
|
NS_UpdateHint(hint, NS_STYLE_HINT_FRAMECHANGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ignore mUserFocus
|
|
|
|
|
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleUserInterface::MaxDifference()
|
|
|
|
{
|
|
|
|
return nsChangeHint(nsChangeHint_UpdateCursor | NS_STYLE_HINT_FRAMECHANGE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleUserInterface::CopyCursorArrayFrom(const nsStyleUserInterface& aSource)
|
|
|
|
{
|
|
|
|
mCursorArray = nsnull;
|
|
|
|
mCursorArrayLength = 0;
|
|
|
|
if (aSource.mCursorArrayLength) {
|
|
|
|
mCursorArray = new nsCursorImage[aSource.mCursorArrayLength];
|
|
|
|
if (mCursorArray) {
|
|
|
|
mCursorArrayLength = aSource.mCursorArrayLength;
|
|
|
|
for (PRUint32 i = 0; i < mCursorArrayLength; ++i)
|
|
|
|
mCursorArray[i] = aSource.mCursorArray[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------
|
|
|
|
// nsStyleUIReset
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleUIReset::nsStyleUIReset(void)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUIReset);
|
2007-03-22 10:30:00 -07:00
|
|
|
mUserSelect = NS_STYLE_USER_SELECT_AUTO;
|
|
|
|
mForceBrokenImageIcon = 0;
|
2007-05-16 08:51:37 -07:00
|
|
|
mIMEMode = NS_STYLE_IME_MODE_AUTO;
|
2008-10-14 07:44:25 -07:00
|
|
|
mWindowShadow = NS_STYLE_WINDOW_SHADOW_DEFAULT;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUIReset::nsStyleUIReset(const nsStyleUIReset& aSource)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUIReset);
|
2007-03-22 10:30:00 -07:00
|
|
|
mUserSelect = aSource.mUserSelect;
|
|
|
|
mForceBrokenImageIcon = aSource.mForceBrokenImageIcon;
|
2007-05-16 08:51:37 -07:00
|
|
|
mIMEMode = aSource.mIMEMode;
|
2008-10-14 07:44:25 -07:00
|
|
|
mWindowShadow = aSource.mWindowShadow;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUIReset::~nsStyleUIReset(void)
|
|
|
|
{
|
2009-08-07 07:38:44 -07:00
|
|
|
MOZ_COUNT_DTOR(nsStyleUIReset);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleUIReset::CalcDifference(const nsStyleUIReset& aOther) const
|
|
|
|
{
|
2007-05-16 08:51:37 -07:00
|
|
|
// ignore mIMEMode
|
2008-10-14 07:44:25 -07:00
|
|
|
if (mForceBrokenImageIcon != aOther.mForceBrokenImageIcon)
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
if (mWindowShadow != aOther.mWindowShadow) {
|
|
|
|
// We really need just an nsChangeHint_SyncFrameView, except
|
|
|
|
// on an ancestor of the frame, so we get that by doing a
|
|
|
|
// reflow.
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-10-14 07:44:25 -07:00
|
|
|
if (mUserSelect != aOther.mUserSelect)
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
return NS_STYLE_HINT_NONE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleUIReset::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|