2016-01-11 02:28:35 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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/. */
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2006-03-25 08:47:31 +03:00
|
|
|
/*
|
|
|
|
* structs that contain the data provided by nsStyleContext, the
|
|
|
|
* internal API for computed style data for an element
|
|
|
|
*/
|
|
|
|
|
2002-07-03 21:14:41 +04:00
|
|
|
#include "nsStyleStruct.h"
|
2008-07-17 10:30:25 +04:00
|
|
|
#include "nsStyleStructInlines.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2007-09-05 14:27:06 +04:00
|
|
|
#include "nsThemeConstants.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
#include "nsString.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2016-03-31 02:30:39 +03:00
|
|
|
#include "nsIAppShellService.h"
|
2009-04-02 01:59:02 +04:00
|
|
|
#include "nsIWidget.h"
|
2011-06-21 09:03:59 +04:00
|
|
|
#include "nsCRTGlue.h"
|
2015-10-01 14:26:52 +03:00
|
|
|
#include "nsCSSParser.h"
|
2009-08-21 01:52:47 +04:00
|
|
|
#include "nsCSSProps.h"
|
2016-07-29 00:51:12 +03:00
|
|
|
#include "nsDeviceContext.h"
|
|
|
|
#include "nsStyleUtil.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2002-02-19 23:41:32 +03:00
|
|
|
#include "nsBidiUtils.h"
|
2011-01-13 13:40:12 +03:00
|
|
|
#include "nsLayoutUtils.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2004-03-09 06:57:51 +03:00
|
|
|
#include "imgIRequest.h"
|
2009-08-22 00:39:25 +04:00
|
|
|
#include "imgIContainer.h"
|
2014-06-12 05:12:00 +04:00
|
|
|
#include "CounterStyleManager.h"
|
2007-10-09 01:58:22 +04:00
|
|
|
|
2015-11-20 08:09:00 +03:00
|
|
|
#include "mozilla/dom/AnimationEffectReadOnlyBinding.h" // for PlaybackDirection
|
2012-10-26 17:32:10 +04:00
|
|
|
#include "mozilla/Likely.h"
|
2013-09-07 17:01:08 +04:00
|
|
|
#include "nsIURI.h"
|
2013-10-02 15:40:07 +04:00
|
|
|
#include "nsIDocument.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2012-10-26 17:32:10 +04:00
|
|
|
|
2015-03-31 06:05:33 +03:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2013-07-18 21:59:53 +04:00
|
|
|
static_assert((((1 << nsStyleStructID_Length) - 1) &
|
|
|
|
~(NS_STYLE_INHERIT_MASK)) == 0,
|
|
|
|
"Not enough bits in NS_STYLE_INHERIT_MASK");
|
2004-03-09 06:57:51 +03:00
|
|
|
|
2015-04-30 21:42:50 +03:00
|
|
|
// These are the limits that we choose to clamp grid line numbers to.
|
|
|
|
// http://dev.w3.org/csswg/css-grid/#overlarge-grids
|
|
|
|
const int32_t nsStyleGridLine::kMinLine = -10000;
|
|
|
|
const int32_t nsStyleGridLine::kMaxLine = 10000;
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
static bool
|
|
|
|
EqualURIs(nsIURI *aURI1, nsIURI *aURI2)
|
2003-10-04 10:36:33 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool eq;
|
2003-10-04 10:36:33 +04:00
|
|
|
return aURI1 == aURI2 || // handle null==null, and optimize
|
|
|
|
(aURI1 && aURI2 &&
|
|
|
|
NS_SUCCEEDED(aURI1->Equals(aURI2, &eq)) && // not equal on fail
|
|
|
|
eq);
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
static bool
|
2016-09-02 17:22:48 +03:00
|
|
|
DefinitelyEqualURIsAndPrincipal(css::URLValue* aURI1, css::URLValue* aURI2)
|
2007-07-19 01:56:57 +04:00
|
|
|
{
|
2016-09-02 17:22:48 +03:00
|
|
|
return aURI1 == aURI2 ||
|
|
|
|
(aURI1 && aURI2 && aURI1->DefinitelyEqualURIsAndPrincipal(*aURI2));
|
2007-07-19 01:56:57 +04:00
|
|
|
}
|
|
|
|
|
2016-06-18 02:02:43 +03:00
|
|
|
static
|
|
|
|
bool EqualURIs(const FragmentOrURL* aURI1, const FragmentOrURL* aURI2)
|
|
|
|
{
|
|
|
|
return aURI1 == aURI2 || // handle null==null, and optimize
|
|
|
|
(aURI1 && aURI2 && *aURI1 == *aURI2);
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
static bool
|
|
|
|
EqualImages(imgIRequest *aImage1, imgIRequest* aImage2)
|
2004-03-09 06:57:51 +03:00
|
|
|
{
|
|
|
|
if (aImage1 == aImage2) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2004-03-09 06:57:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!aImage1 || !aImage2) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2004-03-09 06:57:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri1, uri2;
|
|
|
|
aImage1->GetURI(getter_AddRefs(uri1));
|
|
|
|
aImage2->GetURI(getter_AddRefs(uri2));
|
|
|
|
return EqualURIs(uri1, uri2);
|
|
|
|
}
|
|
|
|
|
2011-06-21 09:03:59 +04:00
|
|
|
// A nullsafe wrapper for strcmp. We depend on null-safety.
|
2016-06-03 18:56:54 +03:00
|
|
|
static int
|
|
|
|
safe_strcmp(const char16_t* a, const char16_t* b)
|
2011-06-21 09:03:59 +04:00
|
|
|
{
|
|
|
|
if (!a || !b) {
|
|
|
|
return (int)(a - b);
|
|
|
|
}
|
|
|
|
return NS_strcmp(a, b);
|
|
|
|
}
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
int32_t
|
|
|
|
StyleStructContext::AppUnitsPerDevPixel()
|
|
|
|
{
|
|
|
|
return DeviceContext()->AppUnitsPerDevPixel();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDeviceContext*
|
|
|
|
StyleStructContext::HackilyFindSomeDeviceContext()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAppShellService> appShell(do_GetService("@mozilla.org/appshell/appShellService;1"));
|
|
|
|
MOZ_ASSERT(appShell);
|
|
|
|
nsCOMPtr<mozIDOMWindowProxy> win;
|
|
|
|
appShell->GetHiddenDOMWindow(getter_AddRefs(win));
|
|
|
|
return nsLayoutUtils::GetDeviceContextForScreenInfo(static_cast<nsPIDOMWindowOuter*>(win.get()));
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
static bool AreShadowArraysEqual(nsCSSShadowArray* lhs, nsCSSShadowArray* rhs);
|
2008-07-08 04:56:52 +04:00
|
|
|
|
2016-08-06 01:16:50 +03:00
|
|
|
// --------------------
|
|
|
|
// FragmentOrURL
|
|
|
|
//
|
|
|
|
void
|
|
|
|
FragmentOrURL::SetValue(const nsCSSValue* aValue)
|
|
|
|
{
|
2016-08-15 07:00:03 +03:00
|
|
|
mozilla::css::URLValueData *urlData = aValue->GetUnit() == eCSSUnit_URL
|
|
|
|
? static_cast<mozilla::css::URLValueData *>(aValue->GetURLStructValue())
|
|
|
|
: static_cast<mozilla::css::URLValueData *>(aValue->GetImageStructValue());
|
|
|
|
MOZ_ASSERT_IF(urlData->GetLocalURLFlag(), urlData->GetURI());
|
|
|
|
mIsLocalRef = urlData->GetLocalURLFlag();
|
2016-08-06 01:16:50 +03:00
|
|
|
|
2016-08-15 07:00:03 +03:00
|
|
|
mURL = urlData->GetURI();
|
2016-08-06 01:16:50 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (mIsLocalRef) {
|
|
|
|
bool hasRef = false;
|
|
|
|
mURL->GetHasRef(&hasRef);
|
|
|
|
MOZ_ASSERT(hasRef);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FragmentOrURL::SetNull()
|
|
|
|
{
|
|
|
|
mURL = nullptr;
|
|
|
|
mIsLocalRef = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
FragmentOrURL&
|
|
|
|
FragmentOrURL::operator=(const FragmentOrURL& aOther)
|
|
|
|
{
|
|
|
|
mIsLocalRef = aOther.mIsLocalRef;
|
|
|
|
mURL = aOther.mURL;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
FragmentOrURL::operator==(const FragmentOrURL& aOther) const
|
|
|
|
{
|
|
|
|
if (aOther.mIsLocalRef != mIsLocalRef) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EqualURIs(aOther.mURL, mURL);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
FragmentOrURL::EqualsExceptRef(nsIURI* aURI) const
|
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
mURL->EqualsExceptRef(aURI, &ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FragmentOrURL::GetSourceString(nsString &aRef) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mURL);
|
|
|
|
|
|
|
|
nsCString cref;
|
|
|
|
if (mIsLocalRef) {
|
|
|
|
mURL->GetRef(cref);
|
|
|
|
cref.Insert('#', 0);
|
|
|
|
} else {
|
2016-08-31 13:10:10 +03:00
|
|
|
// It's not entirely clear how to best handle failure here. Ensuring the
|
|
|
|
// string is empty seems safest.
|
|
|
|
nsresult rv = mURL->GetSpec(cref);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
cref.Truncate();
|
|
|
|
}
|
2016-08-06 01:16:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
aRef = NS_ConvertUTF8toUTF16(cref);
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsIURI>
|
|
|
|
FragmentOrURL::Resolve(nsIURI* aURI) const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURI> result;
|
|
|
|
|
|
|
|
if (mIsLocalRef) {
|
|
|
|
nsCString ref;
|
|
|
|
mURL->GetRef(ref);
|
|
|
|
|
|
|
|
aURI->Clone(getter_AddRefs(result));
|
|
|
|
result->SetRef(ref);
|
|
|
|
} else {
|
|
|
|
result = mURL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsIURI>
|
|
|
|
FragmentOrURL::Resolve(nsIContent* aContent) const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURI> url = aContent->GetBaseURI();
|
|
|
|
return Resolve(url);
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleFont
|
|
|
|
//
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleFont::nsStyleFont(const nsFont& aFont, StyleStructContext aContext)
|
2012-08-21 06:23:32 +04:00
|
|
|
: mFont(aFont)
|
2016-03-31 02:30:39 +03:00
|
|
|
, mSize(nsStyleFont::ZoomText(aContext, mFont.size))
|
2012-08-21 06:23:32 +04:00
|
|
|
, mGenericID(kGenericFont_NONE)
|
2015-10-08 02:19:29 +03:00
|
|
|
, mScriptLevel(0)
|
|
|
|
, mMathVariant(NS_MATHML_MATHVARIANT_NONE)
|
|
|
|
, mMathDisplay(NS_MATHML_DISPLAYSTYLE_INLINE)
|
2015-10-08 02:19:29 +03:00
|
|
|
, mMinFontSizeRatio(100) // 100%
|
2012-08-21 06:23:32 +04:00
|
|
|
, mExplicitLanguage(false)
|
2015-10-08 02:19:29 +03:00
|
|
|
, mAllowZoom(true)
|
|
|
|
, mScriptUnconstrainedSize(mSize)
|
2016-03-31 22:47:20 +03:00
|
|
|
, mScriptMinSize(nsPresContext::CSSTwipsToAppUnits(
|
2015-10-08 02:19:29 +03:00
|
|
|
NS_POINTS_TO_TWIPS(NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT)))
|
|
|
|
, mScriptSizeMultiplier(NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER)
|
2016-03-31 02:30:39 +03:00
|
|
|
, mLanguage(GetLanguage(aContext))
|
2001-09-27 22:33:58 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleFont);
|
2015-10-08 02:19:29 +03:00
|
|
|
mFont.size = mSize;
|
2001-09-27 22:33:58 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
nsStyleFont::nsStyleFont(const nsStyleFont& aSrc)
|
2008-01-09 12:38:28 +03:00
|
|
|
: mFont(aSrc.mFont)
|
|
|
|
, mSize(aSrc.mSize)
|
2008-10-10 18:56:18 +04:00
|
|
|
, mGenericID(aSrc.mGenericID)
|
2008-01-09 12:38:28 +03:00
|
|
|
, mScriptLevel(aSrc.mScriptLevel)
|
2013-12-02 20:49:00 +04:00
|
|
|
, mMathVariant(aSrc.mMathVariant)
|
2014-01-14 18:39:50 +04:00
|
|
|
, mMathDisplay(aSrc.mMathDisplay)
|
2015-10-08 02:19:29 +03:00
|
|
|
, mMinFontSizeRatio(aSrc.mMinFontSizeRatio)
|
2012-08-21 06:23:32 +04:00
|
|
|
, mExplicitLanguage(aSrc.mExplicitLanguage)
|
2013-06-29 07:28:50 +04:00
|
|
|
, mAllowZoom(aSrc.mAllowZoom)
|
2008-01-09 12:38:28 +03:00
|
|
|
, mScriptUnconstrainedSize(aSrc.mScriptUnconstrainedSize)
|
|
|
|
, mScriptMinSize(aSrc.mScriptMinSize)
|
2008-02-19 10:36:50 +03:00
|
|
|
, mScriptSizeMultiplier(aSrc.mScriptSizeMultiplier)
|
2012-01-24 17:09:55 +04:00
|
|
|
, mLanguage(aSrc.mLanguage)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleFont);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleFont::nsStyleFont(StyleStructContext aContext)
|
|
|
|
: nsStyleFont(*aContext.GetDefaultFont(kPresContext_DefaultVariableFont_ID),
|
|
|
|
aContext)
|
2003-03-13 18:29:36 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-07-27 04:13:04 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleFont::Destroy(nsPresContext* aContext) {
|
2001-06-02 01:04:23 +04:00
|
|
|
this->~nsStyleFont();
|
2014-07-16 09:27:13 +04:00
|
|
|
aContext->PresShell()->
|
2015-09-17 05:08:19 +03:00
|
|
|
FreeByObjectID(eArenaObjectID_nsStyleFont, this);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2013-06-29 07:28:50 +04:00
|
|
|
void
|
|
|
|
nsStyleFont::EnableZoom(nsPresContext* aContext, bool aEnable)
|
|
|
|
{
|
|
|
|
if (mAllowZoom == aEnable) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mAllowZoom = aEnable;
|
|
|
|
if (mAllowZoom) {
|
|
|
|
mSize = nsStyleFont::ZoomText(aContext, mSize);
|
|
|
|
mFont.size = nsStyleFont::ZoomText(aContext, mFont.size);
|
|
|
|
mScriptUnconstrainedSize =
|
|
|
|
nsStyleFont::ZoomText(aContext, mScriptUnconstrainedSize);
|
|
|
|
} else {
|
|
|
|
mSize = nsStyleFont::UnZoomText(aContext, mSize);
|
|
|
|
mFont.size = nsStyleFont::UnZoomText(aContext, mFont.size);
|
|
|
|
mScriptUnconstrainedSize =
|
|
|
|
nsStyleFont::UnZoomText(aContext, mScriptUnconstrainedSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleFont::CalcDifference(const nsStyleFont& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-06-21 04:47:54 +03:00
|
|
|
MOZ_ASSERT(mAllowZoom == aNewData.mAllowZoom,
|
2013-06-29 07:28:50 +04:00
|
|
|
"expected mAllowZoom to be the same on both nsStyleFonts");
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mSize != aNewData.mSize ||
|
|
|
|
mFont != aNewData.mFont ||
|
|
|
|
mLanguage != aNewData.mLanguage ||
|
|
|
|
mExplicitLanguage != aNewData.mExplicitLanguage ||
|
|
|
|
mMathVariant != aNewData.mMathVariant ||
|
|
|
|
mMathDisplay != aNewData.mMathDisplay ||
|
|
|
|
mMinFontSizeRatio != aNewData.mMinFontSizeRatio) {
|
2012-01-24 17:09:55 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2001-09-27 22:33:58 +04:00
|
|
|
}
|
2014-09-05 07:48:43 +04:00
|
|
|
|
|
|
|
// XXX Should any of these cause a non-nsChangeHint_NeutralChange change?
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mGenericID != aNewData.mGenericID ||
|
|
|
|
mScriptLevel != aNewData.mScriptLevel ||
|
|
|
|
mScriptUnconstrainedSize != aNewData.mScriptUnconstrainedSize ||
|
|
|
|
mScriptMinSize != aNewData.mScriptMinSize ||
|
|
|
|
mScriptSizeMultiplier != aNewData.mScriptSizeMultiplier) {
|
2014-09-05 07:48:43 +04:00
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2003-03-13 18:29:36 +03:00
|
|
|
/* static */ nscoord
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleFont::ZoomText(StyleStructContext aContext, nscoord aSize)
|
2003-03-13 18:29:36 +03:00
|
|
|
{
|
2015-11-16 19:32:39 +03:00
|
|
|
// aSize can be negative (e.g.: calc(-1px)) so we can't assert that here.
|
|
|
|
// The caller is expected deal with that.
|
2016-03-31 02:30:39 +03:00
|
|
|
return NSToCoordTruncClamped(float(aSize) * aContext.TextZoom());
|
2003-03-13 18:29:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ nscoord
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleFont::UnZoomText(nsPresContext *aPresContext, nscoord aSize)
|
2003-03-13 18:29:36 +03:00
|
|
|
{
|
2015-11-16 19:32:39 +03:00
|
|
|
// aSize can be negative (e.g.: calc(-1px)) so we can't assert that here.
|
|
|
|
// The caller is expected deal with that.
|
2015-11-21 06:41:00 +03:00
|
|
|
return NSToCoordTruncClamped(float(aSize) / aPresContext->TextZoom());
|
2003-03-13 18:29:36 +03:00
|
|
|
}
|
|
|
|
|
2015-10-08 02:19:29 +03:00
|
|
|
/* static */ already_AddRefed<nsIAtom>
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleFont::GetLanguage(StyleStructContext aContext)
|
2015-10-08 02:19:29 +03:00
|
|
|
{
|
2016-03-31 02:30:39 +03:00
|
|
|
RefPtr<nsIAtom> language = aContext.GetContentLanguage();
|
2015-11-28 03:56:33 +03:00
|
|
|
if (!language) {
|
2015-10-08 02:19:29 +03:00
|
|
|
// we didn't find a (usable) Content-Language, so we fall back
|
|
|
|
// to whatever the presContext guessed from the charset
|
2015-11-28 03:56:33 +03:00
|
|
|
// NOTE this should not be used elsewhere, because we want websites
|
|
|
|
// to use UTF-8 with proper language tag, instead of relying on
|
|
|
|
// deriving language from charset. See bug 1040668 comment 67.
|
2016-03-31 02:30:39 +03:00
|
|
|
language = aContext.GetLanguageFromCharset();
|
2015-10-08 02:19:29 +03:00
|
|
|
}
|
2015-11-28 03:56:33 +03:00
|
|
|
return language.forget();
|
2015-10-08 02:19:29 +03:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
static nscoord
|
|
|
|
CalcCoord(const nsStyleCoord& aCoord, const nscoord* aEnumTable, int32_t aNumEnums)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2010-08-31 20:05:12 +04:00
|
|
|
if (aCoord.GetUnit() == eStyleUnit_Enumerated) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aEnumTable, "must have enum table");
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t value = aCoord.GetIntValue();
|
2010-08-31 20:05:12 +04:00
|
|
|
if (0 <= value && value < aNumEnums) {
|
|
|
|
return aEnumTable[aCoord.GetIntValue()];
|
|
|
|
}
|
|
|
|
NS_NOTREACHED("unexpected enum value");
|
|
|
|
return 0;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aCoord.ConvertsToLength(), "unexpected unit");
|
2010-08-31 20:05:12 +04:00
|
|
|
return nsRuleNode::ComputeCoordPercentCalc(aCoord, 0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleMargin::nsStyleMargin(StyleStructContext aContext)
|
2014-07-16 09:27:12 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleMargin);
|
2009-10-14 06:38:20 +04:00
|
|
|
nsStyleCoord zero(0, nsStyleCoord::CoordConstructor);
|
2007-05-11 09:58:34 +04:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mMargin.Set(side, zero);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2014-07-16 09:27:12 +04:00
|
|
|
nsStyleMargin::nsStyleMargin(const nsStyleMargin& aSrc)
|
|
|
|
: mMargin(aSrc.mMargin)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleMargin);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-07-27 04:13:04 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleMargin::Destroy(nsPresContext* aContext) {
|
2001-06-02 01:04:23 +04:00
|
|
|
this->~nsStyleMargin();
|
2014-07-16 09:27:13 +04:00
|
|
|
aContext->PresShell()->
|
2015-09-17 05:08:19 +03:00
|
|
|
FreeByObjectID(eArenaObjectID_nsStyleMargin, this);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleMargin::CalcDifference(const nsStyleMargin& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mMargin == aNewData.mMargin) {
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2009-08-04 05:22:13 +04:00
|
|
|
// Margin differences can't affect descendant intrinsic sizes and
|
|
|
|
// don't need to force children to reflow.
|
2015-06-21 07:54:15 +03:00
|
|
|
return nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_ReflowChangesSizeOrPosition |
|
|
|
|
nsChangeHint_ClearAncestorIntrinsics;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStylePadding::nsStylePadding(StyleStructContext aContext)
|
2014-07-16 09:27:12 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStylePadding);
|
2009-10-14 06:38:20 +04:00
|
|
|
nsStyleCoord zero(0, nsStyleCoord::CoordConstructor);
|
2007-05-11 09:58:34 +04:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mPadding.Set(side, zero);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2014-07-16 09:27:12 +04:00
|
|
|
nsStylePadding::nsStylePadding(const nsStylePadding& aSrc)
|
|
|
|
: mPadding(aSrc.mPadding)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStylePadding);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-07-27 04:13:04 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStylePadding::Destroy(nsPresContext* aContext) {
|
2001-06-02 01:04:23 +04:00
|
|
|
this->~nsStylePadding();
|
2014-07-16 09:27:13 +04:00
|
|
|
aContext->PresShell()->
|
2015-09-17 05:08:19 +03:00
|
|
|
FreeByObjectID(eArenaObjectID_nsStylePadding, this);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStylePadding::CalcDifference(const nsStylePadding& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mPadding == aNewData.mPadding) {
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2009-08-04 05:22:13 +04: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.
|
2016-05-23 06:26:03 +03:00
|
|
|
return NS_STYLE_HINT_REFLOW & ~nsChangeHint_ClearDescendantIntrinsics;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleBorder::nsStyleBorder(StyleStructContext aContext)
|
2016-06-03 18:56:54 +03:00
|
|
|
: mBorderColors(nullptr)
|
|
|
|
, mBorderImageFill(NS_STYLE_BORDER_IMAGE_SLICE_NOFILL)
|
|
|
|
, mBorderImageRepeatH(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH)
|
|
|
|
, mBorderImageRepeatV(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH)
|
2016-07-25 09:26:05 +03:00
|
|
|
, mFloatEdge(StyleFloatEdge::ContentBox)
|
2016-08-26 10:14:32 +03:00
|
|
|
, mBoxDecorationBreak(StyleBoxDecorationBreak::Slice)
|
2016-06-03 18:56:54 +03:00
|
|
|
, mComputedBorder(0, 0, 0, 0)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleBorder);
|
2011-12-23 03:34:45 +04:00
|
|
|
|
|
|
|
NS_FOR_CSS_HALF_CORNERS (corner) {
|
|
|
|
mBorderRadius.Set(corner, nsStyleCoord(0, nsStyleCoord::CoordConstructor));
|
|
|
|
}
|
|
|
|
|
2005-04-29 19:44:38 +04:00
|
|
|
nscoord medium =
|
2016-03-31 22:47:20 +03:00
|
|
|
(StaticPresData::Get()->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM];
|
2005-04-29 19:44:38 +04:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2011-12-23 03:34:45 +04: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-19 07:07:22 +04:00
|
|
|
mBorder.Side(side) = medium;
|
2005-04-29 19:44:38 +04:00
|
|
|
mBorderStyle[side] = NS_STYLE_BORDER_STYLE_NONE | BORDER_COLOR_FOREGROUND;
|
|
|
|
mBorderColor[side] = NS_RGB(0, 0, 0);
|
2008-10-01 09:50:52 +04:00
|
|
|
}
|
2006-12-27 17:21:43 +03:00
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
mTwipsPerPixel = aContext.DevPixelsToAppUnits(1);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2008-10-17 12:13:16 +04:00
|
|
|
nsBorderColors::~nsBorderColors()
|
|
|
|
{
|
|
|
|
NS_CSS_DELETE_LIST_MEMBER(nsBorderColors, this, mNext);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBorderColors*
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBorderColors::Clone(bool aDeep) const
|
2008-10-17 12:13:16 +04:00
|
|
|
{
|
|
|
|
nsBorderColors* result = new nsBorderColors(mColor);
|
2016-07-06 08:06:13 +03:00
|
|
|
if (MOZ_UNLIKELY(!result)) {
|
2008-10-17 12:13:16 +04:00
|
|
|
return result;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
|
|
|
if (aDeep) {
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_CSS_CLONE_LIST_MEMBER(nsBorderColors, this, mNext, result, (false));
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-10-17 12:13:16 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleBorder::nsStyleBorder(const nsStyleBorder& aSrc)
|
2016-06-03 18:56:54 +03:00
|
|
|
: mBorderColors(nullptr)
|
|
|
|
, mBorderRadius(aSrc.mBorderRadius)
|
|
|
|
, mBorderImageSource(aSrc.mBorderImageSource)
|
|
|
|
, mBorderImageSlice(aSrc.mBorderImageSlice)
|
|
|
|
, mBorderImageWidth(aSrc.mBorderImageWidth)
|
|
|
|
, mBorderImageOutset(aSrc.mBorderImageOutset)
|
|
|
|
, mBorderImageFill(aSrc.mBorderImageFill)
|
|
|
|
, mBorderImageRepeatH(aSrc.mBorderImageRepeatH)
|
|
|
|
, mBorderImageRepeatV(aSrc.mBorderImageRepeatV)
|
|
|
|
, mFloatEdge(aSrc.mFloatEdge)
|
|
|
|
, mBoxDecorationBreak(aSrc.mBoxDecorationBreak)
|
|
|
|
, mComputedBorder(aSrc.mComputedBorder)
|
|
|
|
, mBorder(aSrc.mBorder)
|
|
|
|
, mTwipsPerPixel(aSrc.mTwipsPerPixel)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleBorder);
|
2001-12-05 11:35:05 +03:00
|
|
|
if (aSrc.mBorderColors) {
|
|
|
|
EnsureBorderColors();
|
2016-07-06 08:06:13 +03:00
|
|
|
for (int32_t i = 0; i < 4; i++) {
|
|
|
|
if (aSrc.mBorderColors[i]) {
|
2008-10-17 12:13:16 +04:00
|
|
|
mBorderColors[i] = aSrc.mBorderColors[i]->Clone();
|
2016-07-06 08:06:13 +03:00
|
|
|
} else {
|
2012-07-30 18:20:58 +04:00
|
|
|
mBorderColors[i] = nullptr;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
|
|
|
}
|
2001-12-05 11:35:05 +03:00
|
|
|
}
|
2008-07-08 04:56:52 +04:00
|
|
|
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mBorderStyle[side] = aSrc.mBorderStyle[side];
|
|
|
|
mBorderColor[side] = aSrc.mBorderColor[side];
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2008-07-17 10:30:25 +04:00
|
|
|
nsStyleBorder::~nsStyleBorder()
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleBorder);
|
2008-07-17 10:30:25 +04:00
|
|
|
if (mBorderColors) {
|
2016-07-06 08:06:13 +03:00
|
|
|
for (int32_t i = 0; i < 4; i++) {
|
2008-07-17 10:30:25 +04:00
|
|
|
delete mBorderColors[i];
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-07-17 10:30:25 +04:00
|
|
|
delete [] mBorderColors;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-23 03:34:45 +04: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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleBorder::Destroy(nsPresContext* aContext) {
|
2014-01-31 07:36:41 +04:00
|
|
|
UntrackImage(aContext);
|
2001-06-02 01:04:23 +04:00
|
|
|
this->~nsStyleBorder();
|
2014-07-16 09:27:13 +04:00
|
|
|
aContext->PresShell()->
|
2015-09-17 05:08:19 +03:00
|
|
|
FreeByObjectID(eArenaObjectID_nsStyleBorder, this);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleBorder::CalcDifference(const nsStyleBorder& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-04 05:22:13 +04:00
|
|
|
// XXXbz we should be able to return a more specific change hint for
|
2012-05-31 09:19:49 +04:00
|
|
|
// at least GetComputedBorder() differences...
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTwipsPerPixel != aNewData.mTwipsPerPixel ||
|
|
|
|
GetComputedBorder() != aNewData.GetComputedBorder() ||
|
|
|
|
mFloatEdge != aNewData.mFloatEdge ||
|
|
|
|
mBorderImageOutset != aNewData.mBorderImageOutset ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mBoxDecorationBreak != aNewData.mBoxDecorationBreak) {
|
2008-11-03 03:58:46 +03:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2005-04-29 19:44:38 +04:00
|
|
|
|
2012-09-07 21:13:36 +04:00
|
|
|
NS_FOR_CSS_SIDES(ix) {
|
|
|
|
// See the explanation in nsChangeHint.h of
|
|
|
|
// nsChangeHint_BorderStyleNoneChange .
|
|
|
|
// Furthermore, even though we know *this* side is 0 width, just
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
// assume a repaint hint for some other change rather than bother
|
2012-09-07 21:13:36 +04:00
|
|
|
// tracking this result through the rest of the function.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (HasVisibleStyle(ix) != aNewData.HasVisibleStyle(ix)) {
|
2016-04-12 08:52:42 +03:00
|
|
|
return nsChangeHint_RepaintFrame |
|
|
|
|
nsChangeHint_BorderStyleNoneChange;
|
2012-09-07 21:13:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-03 03:58:46 +03:00
|
|
|
// Note that mBorderStyle stores not only the border style but also
|
|
|
|
// color-related flags. Given that we've already done an mComputedBorder
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
// comparison, border-style differences can only lead to a repaint hint. So
|
2008-11-03 03:58:46 +03:00
|
|
|
// 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) {
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBorderStyle[ix] != aNewData.mBorderStyle[ix] ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mBorderColor[ix] != aNewData.mBorderColor[ix]) {
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-11-03 03:58:46 +03:00
|
|
|
}
|
2001-12-19 14:59:31 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBorderRadius != aNewData.mBorderRadius ||
|
2016-07-06 08:06:13 +03:00
|
|
|
!mBorderColors != !aNewData.mBorderColors) {
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-07-26 20:14:49 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (IsBorderImageLoaded() || aNewData.IsBorderImageLoaded()) {
|
|
|
|
if (mBorderImageSource != aNewData.mBorderImageSource ||
|
|
|
|
mBorderImageRepeatH != aNewData.mBorderImageRepeatH ||
|
|
|
|
mBorderImageRepeatV != aNewData.mBorderImageRepeatV ||
|
|
|
|
mBorderImageSlice != aNewData.mBorderImageSlice ||
|
|
|
|
mBorderImageFill != aNewData.mBorderImageFill ||
|
|
|
|
mBorderImageWidth != aNewData.mBorderImageWidth ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mBorderImageOutset != aNewData.mBorderImageOutset) {
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-11-03 03:58:46 +03:00
|
|
|
}
|
2001-12-19 14:59:31 +03:00
|
|
|
|
2008-11-03 03:58:46 +03:00
|
|
|
// Note that at this point if mBorderColors is non-null so is
|
2016-06-21 04:47:54 +03:00
|
|
|
// aNewData.mBorderColors
|
2008-11-03 03:58:46 +03:00
|
|
|
if (mBorderColors) {
|
|
|
|
NS_FOR_CSS_SIDES(ix) {
|
|
|
|
if (!nsBorderColors::Equal(mBorderColors[ix],
|
2016-07-06 08:06:13 +03:00
|
|
|
aNewData.mBorderColors[ix])) {
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-11-03 03:58:46 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2008-11-03 03:58:46 +03:00
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
// mBorder is the specified border value. Changes to this don't
|
|
|
|
// need any change processing, since we operate on the computed
|
|
|
|
// border values instead.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBorder != aNewData.mBorder) {
|
2014-09-05 07:48:43 +04:00
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleOutline::nsStyleOutline(StyleStructContext aContext)
|
2016-05-02 06:11:45 +03:00
|
|
|
: mOutlineWidth(NS_STYLE_BORDER_WIDTH_MEDIUM, eStyleUnit_Enumerated)
|
|
|
|
, mOutlineOffset(0)
|
2016-05-11 07:03:34 +03:00
|
|
|
, mActualOutlineWidth(0)
|
2016-05-02 06:11:45 +03:00
|
|
|
, mOutlineColor(NS_RGB(0, 0, 0))
|
|
|
|
, mOutlineStyle(NS_STYLE_BORDER_STYLE_NONE)
|
|
|
|
, mTwipsPerPixel(aContext.DevPixelsToAppUnits(1))
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleOutline);
|
2001-06-01 02:19:43 +04:00
|
|
|
// spacing values not inherited
|
2009-10-14 06:38:20 +04:00
|
|
|
nsStyleCoord zero(0, nsStyleCoord::CoordConstructor);
|
2008-10-01 09:50:52 +04:00
|
|
|
NS_FOR_CSS_HALF_CORNERS(corner) {
|
|
|
|
mOutlineRadius.Set(corner, zero);
|
2005-09-19 19:47:26 +04:00
|
|
|
}
|
|
|
|
|
2015-04-28 21:48:39 +03:00
|
|
|
SetOutlineInitialColor();
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2014-06-19 07:17:10 +04:00
|
|
|
nsStyleOutline::nsStyleOutline(const nsStyleOutline& aSrc)
|
|
|
|
: mOutlineRadius(aSrc.mOutlineRadius)
|
|
|
|
, mOutlineWidth(aSrc.mOutlineWidth)
|
|
|
|
, mOutlineOffset(aSrc.mOutlineOffset)
|
2016-05-11 07:03:34 +03:00
|
|
|
, mActualOutlineWidth(aSrc.mActualOutlineWidth)
|
2014-06-19 07:17:10 +04:00
|
|
|
, mOutlineColor(aSrc.mOutlineColor)
|
|
|
|
, mOutlineStyle(aSrc.mOutlineStyle)
|
|
|
|
, mTwipsPerPixel(aSrc.mTwipsPerPixel)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleOutline);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-07-27 04:13:04 +03:00
|
|
|
void
|
2016-05-08 21:22:00 +03:00
|
|
|
nsStyleOutline::RecalcData()
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2005-03-27 15:36:08 +04:00
|
|
|
if (NS_STYLE_BORDER_STYLE_NONE == GetOutlineStyle()) {
|
2016-05-11 07:03:34 +03:00
|
|
|
mActualOutlineWidth = 0;
|
2016-04-21 01:05:30 +03:00
|
|
|
} else {
|
2016-05-04 00:20:48 +03:00
|
|
|
MOZ_ASSERT(mOutlineWidth.ConvertsToLength() ||
|
|
|
|
mOutlineWidth.GetUnit() == eStyleUnit_Enumerated);
|
2010-09-09 19:21:46 +04:00
|
|
|
// Clamp negative calc() to 0.
|
2016-05-11 07:03:34 +03:00
|
|
|
mActualOutlineWidth =
|
2016-05-08 21:22:00 +03:00
|
|
|
std::max(CalcCoord(mOutlineWidth,
|
|
|
|
StaticPresData::Get()->GetBorderWidthTable(), 3), 0);
|
2016-05-11 07:03:34 +03:00
|
|
|
mActualOutlineWidth =
|
|
|
|
NS_ROUND_BORDER_TO_PIXELS(mActualOutlineWidth, mTwipsPerPixel);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleOutline::CalcDifference(const nsStyleOutline& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mActualOutlineWidth != aNewData.mActualOutlineWidth ||
|
2016-05-11 07:03:34 +03:00
|
|
|
(mActualOutlineWidth > 0 &&
|
2016-06-21 04:47:54 +03:00
|
|
|
mOutlineOffset != aNewData.mOutlineOffset)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return nsChangeHint_UpdateOverflow |
|
|
|
|
nsChangeHint_SchedulePaint;
|
2004-07-16 20:56:21 +04:00
|
|
|
}
|
2014-09-05 07:48:43 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mOutlineStyle != aNewData.mOutlineStyle ||
|
|
|
|
mOutlineColor != aNewData.mOutlineColor ||
|
|
|
|
mOutlineRadius != aNewData.mOutlineRadius) {
|
2016-05-11 07:03:34 +03:00
|
|
|
if (mActualOutlineWidth > 0) {
|
|
|
|
return nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
return nsChangeHint_NeutralChange;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2014-09-05 07:48:43 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mOutlineWidth != aNewData.mOutlineWidth ||
|
|
|
|
mOutlineOffset != aNewData.mOutlineOffset ||
|
|
|
|
mTwipsPerPixel != aNewData.mTwipsPerPixel) {
|
2014-09-05 07:48:43 +04:00
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleList
|
|
|
|
//
|
2016-07-27 04:13:04 +03:00
|
|
|
nsStyleList::nsStyleList(StyleStructContext aContext)
|
2016-06-03 18:56:54 +03:00
|
|
|
: mListStylePosition(NS_STYLE_LIST_STYLE_POSITION_OUTSIDE)
|
|
|
|
, mCounterStyle(aContext.BuildCounterStyle(NS_LITERAL_STRING("disc")))
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleList);
|
2016-04-12 08:52:40 +03:00
|
|
|
SetQuotesInitial();
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-07-27 04:13:04 +03:00
|
|
|
nsStyleList::~nsStyleList()
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleList);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleList::nsStyleList(const nsStyleList& aSource)
|
2016-06-03 18:56:54 +03:00
|
|
|
: mListStylePosition(aSource.mListStylePosition)
|
|
|
|
, mCounterStyle(aSource.mCounterStyle)
|
|
|
|
, mQuotes(aSource.mQuotes)
|
|
|
|
, mImageRegion(aSource.mImageRegion)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2010-08-16 20:23:09 +04:00
|
|
|
SetListStyleImage(aSource.GetListStyleImage());
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleList);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-04-12 08:52:40 +03:00
|
|
|
void
|
|
|
|
nsStyleList::SetQuotesInherit(const nsStyleList* aOther)
|
|
|
|
{
|
|
|
|
mQuotes = aOther->mQuotes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleList::SetQuotesInitial()
|
|
|
|
{
|
|
|
|
if (!sInitialQuotes) {
|
|
|
|
// 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 char16_t initialQuotes[8] = {
|
|
|
|
0x201C, 0, 0x201D, 0, 0x2018, 0, 0x2019, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
sInitialQuotes = new nsStyleQuoteValues;
|
|
|
|
sInitialQuotes->mQuotePairs.AppendElement(
|
|
|
|
std::make_pair(nsDependentString(&initialQuotes[0], 1),
|
|
|
|
nsDependentString(&initialQuotes[2], 1)));
|
|
|
|
sInitialQuotes->mQuotePairs.AppendElement(
|
|
|
|
std::make_pair(nsDependentString(&initialQuotes[4], 1),
|
|
|
|
nsDependentString(&initialQuotes[6], 1)));
|
|
|
|
}
|
|
|
|
|
|
|
|
mQuotes = sInitialQuotes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleList::SetQuotesNone()
|
|
|
|
{
|
|
|
|
if (!sNoneQuotes) {
|
|
|
|
sNoneQuotes = new nsStyleQuoteValues;
|
|
|
|
}
|
|
|
|
mQuotes = sNoneQuotes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleList::SetQuotes(nsStyleQuoteValues::QuotePairArray&& aValues)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-04-12 08:52:40 +03:00
|
|
|
mQuotes = new nsStyleQuoteValues;
|
|
|
|
mQuotes->mQuotePairs = Move(aValues);
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsStyleQuoteValues::QuotePairArray&
|
|
|
|
nsStyleList::GetQuotePairs() const
|
|
|
|
{
|
|
|
|
return mQuotes->mQuotePairs;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleList::CalcDifference(const nsStyleList& aNewData) const
|
2016-04-12 08:52:40 +03:00
|
|
|
{
|
|
|
|
// 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.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mQuotes != aNewData.mQuotes &&
|
|
|
|
(mQuotes || aNewData.mQuotes) &&
|
|
|
|
GetQuotePairs() != aNewData.GetQuotePairs()) {
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2016-04-12 08:52:40 +03:00
|
|
|
}
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mListStylePosition != aNewData.mListStylePosition) {
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (EqualImages(mListStyleImage, aNewData.mListStyleImage) &&
|
|
|
|
mCounterStyle == aNewData.mCounterStyle) {
|
|
|
|
if (mImageRegion.IsEqualInterior(aNewData.mImageRegion)) {
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2014-09-20 05:43:00 +04:00
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mImageRegion.width == aNewData.mImageRegion.width &&
|
2016-07-06 08:06:13 +03:00
|
|
|
mImageRegion.height == aNewData.mImageRegion.height) {
|
2002-11-06 10:31:27 +03:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2002-11-06 10:31:27 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2016-04-12 08:52:40 +03:00
|
|
|
StaticRefPtr<nsStyleQuoteValues>
|
|
|
|
nsStyleList::sInitialQuotes;
|
|
|
|
|
|
|
|
StaticRefPtr<nsStyleQuoteValues>
|
|
|
|
nsStyleList::sNoneQuotes;
|
|
|
|
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleXUL
|
|
|
|
//
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleXUL::nsStyleXUL(StyleStructContext aContext)
|
2016-05-02 06:11:45 +03:00
|
|
|
: mBoxFlex(0.0f)
|
|
|
|
, mBoxOrdinal(1)
|
2016-08-26 10:09:19 +03:00
|
|
|
, mBoxAlign(StyleBoxAlign::Stretch)
|
2016-08-26 10:17:09 +03:00
|
|
|
, mBoxDirection(StyleBoxDirection::Normal)
|
2016-08-26 10:18:41 +03:00
|
|
|
, mBoxOrient(StyleBoxOrient::Horizontal)
|
2016-08-26 10:11:54 +03:00
|
|
|
, mBoxPack(StyleBoxPack::Start)
|
2016-05-02 06:11:45 +03:00
|
|
|
, mStretchStack(true)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleXUL);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-02 06:11:45 +03:00
|
|
|
nsStyleXUL::~nsStyleXUL()
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleXUL);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleXUL::nsStyleXUL(const nsStyleXUL& aSource)
|
2014-06-19 07:17:10 +04:00
|
|
|
: mBoxFlex(aSource.mBoxFlex)
|
|
|
|
, mBoxOrdinal(aSource.mBoxOrdinal)
|
|
|
|
, mBoxAlign(aSource.mBoxAlign)
|
|
|
|
, mBoxDirection(aSource.mBoxDirection)
|
|
|
|
, mBoxOrient(aSource.mBoxOrient)
|
|
|
|
, mBoxPack(aSource.mBoxPack)
|
|
|
|
, mStretchStack(aSource.mStretchStack)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleXUL);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleXUL::CalcDifference(const nsStyleXUL& aNewData) const
|
|
|
|
{
|
|
|
|
if (mBoxAlign == aNewData.mBoxAlign &&
|
|
|
|
mBoxDirection == aNewData.mBoxDirection &&
|
|
|
|
mBoxFlex == aNewData.mBoxFlex &&
|
|
|
|
mBoxOrient == aNewData.mBoxOrient &&
|
|
|
|
mBoxPack == aNewData.mBoxPack &&
|
|
|
|
mBoxOrdinal == aNewData.mBoxOrdinal &&
|
2016-07-06 08:06:13 +03:00
|
|
|
mStretchStack == aNewData.mStretchStack) {
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
|
|
|
if (mBoxOrdinal != aNewData.mBoxOrdinal) {
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2004-06-17 15:57:37 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleColumn
|
|
|
|
//
|
2013-05-31 19:51:43 +04:00
|
|
|
/* static */ const uint32_t nsStyleColumn::kMaxColumnCount = 1000;
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleColumn::nsStyleColumn(StyleStructContext aContext)
|
2016-05-02 06:11:45 +03:00
|
|
|
: mColumnCount(NS_STYLE_COLUMN_COUNT_AUTO)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mColumnWidth(eStyleUnit_Auto)
|
|
|
|
, mColumnGap(eStyleUnit_Normal)
|
2016-05-02 06:11:45 +03:00
|
|
|
, mColumnRuleColor(NS_RGB(0, 0, 0))
|
|
|
|
, mColumnRuleStyle(NS_STYLE_BORDER_STYLE_NONE)
|
|
|
|
, mColumnFill(NS_STYLE_COLUMN_FILL_BALANCE)
|
|
|
|
, mColumnRuleColorIsForeground(true)
|
|
|
|
, mColumnRuleWidth((StaticPresData::Get()
|
|
|
|
->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM])
|
|
|
|
, mTwipsPerPixel(aContext.AppUnitsPerDevPixel())
|
2008-07-19 14:38:25 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColumn);
|
2004-06-17 15:57:37 +04:00
|
|
|
}
|
|
|
|
|
2016-05-02 06:11:45 +03:00
|
|
|
nsStyleColumn::~nsStyleColumn()
|
2004-06-17 15:57:37 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleColumn);
|
2004-06-17 15:57:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColumn::nsStyleColumn(const nsStyleColumn& aSource)
|
2014-06-19 07:17:10 +04:00
|
|
|
: mColumnCount(aSource.mColumnCount)
|
|
|
|
, mColumnWidth(aSource.mColumnWidth)
|
|
|
|
, mColumnGap(aSource.mColumnGap)
|
|
|
|
, mColumnRuleColor(aSource.mColumnRuleColor)
|
|
|
|
, mColumnRuleStyle(aSource.mColumnRuleStyle)
|
|
|
|
, mColumnFill(aSource.mColumnFill)
|
|
|
|
, mColumnRuleColorIsForeground(aSource.mColumnRuleColorIsForeground)
|
|
|
|
, mColumnRuleWidth(aSource.mColumnRuleWidth)
|
|
|
|
, mTwipsPerPixel(aSource.mTwipsPerPixel)
|
2004-06-17 15:57:37 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColumn);
|
2004-06-17 15:57:37 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleColumn::CalcDifference(const nsStyleColumn& aNewData) const
|
2004-06-17 15:57:37 +04:00
|
|
|
{
|
2004-07-18 16:12:46 +04:00
|
|
|
if ((mColumnWidth.GetUnit() == eStyleUnit_Auto)
|
2016-06-21 04:47:54 +03:00
|
|
|
!= (aNewData.mColumnWidth.GetUnit() == eStyleUnit_Auto) ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mColumnCount != aNewData.mColumnCount) {
|
2004-10-08 16:17:10 +04:00
|
|
|
// 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
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2004-07-18 16:12:46 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mColumnWidth != aNewData.mColumnWidth ||
|
|
|
|
mColumnGap != aNewData.mColumnGap ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mColumnFill != aNewData.mColumnFill) {
|
2008-07-19 14:38:25 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-07-19 14:38:25 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (GetComputedColumnRuleWidth() != aNewData.GetComputedColumnRuleWidth() ||
|
|
|
|
mColumnRuleStyle != aNewData.mColumnRuleStyle ||
|
|
|
|
mColumnRuleColor != aNewData.mColumnRuleColor ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mColumnRuleColorIsForeground != aNewData.mColumnRuleColorIsForeground) {
|
2008-07-19 14:38:25 +04:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2004-07-18 16:12:46 +04:00
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
// XXX Is it right that we never check mTwipsPerPixel to return a
|
|
|
|
// non-nsChangeHint_NeutralChange hint?
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mColumnRuleWidth != aNewData.mColumnRuleWidth ||
|
|
|
|
mTwipsPerPixel != aNewData.mTwipsPerPixel) {
|
2014-09-05 07:48:43 +04:00
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2004-06-17 15:57:37 +04:00
|
|
|
}
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
// --------------------
|
|
|
|
// nsStyleSVG
|
|
|
|
//
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleSVG::nsStyleSVG(StyleStructContext aContext)
|
2016-05-03 12:26:28 +03:00
|
|
|
: mFill(eStyleSVGPaintType_Color) // Will be initialized to NS_RGB(0, 0, 0)
|
|
|
|
, mStroke(eStyleSVGPaintType_None)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mStrokeDashoffset(0, nsStyleCoord::CoordConstructor)
|
2016-06-03 18:56:54 +03:00
|
|
|
, mStrokeWidth(nsPresContext::CSSPixelsToAppUnits(1), nsStyleCoord::CoordConstructor)
|
2016-05-03 12:26:28 +03:00
|
|
|
, mFillOpacity(1.0f)
|
|
|
|
, mStrokeMiterlimit(4.0f)
|
|
|
|
, mStrokeOpacity(1.0f)
|
2016-08-17 09:43:26 +03:00
|
|
|
, mClipRule(StyleFillRule::Nonzero)
|
2016-05-03 12:26:28 +03:00
|
|
|
, mColorInterpolation(NS_STYLE_COLOR_INTERPOLATION_SRGB)
|
|
|
|
, mColorInterpolationFilters(NS_STYLE_COLOR_INTERPOLATION_LINEARRGB)
|
2016-08-17 09:43:26 +03:00
|
|
|
, mFillRule(StyleFillRule::Nonzero)
|
2016-05-03 12:26:28 +03:00
|
|
|
, mPaintOrder(NS_STYLE_PAINT_ORDER_NORMAL)
|
|
|
|
, mShapeRendering(NS_STYLE_SHAPE_RENDERING_AUTO)
|
|
|
|
, mStrokeLinecap(NS_STYLE_STROKE_LINECAP_BUTT)
|
|
|
|
, mStrokeLinejoin(NS_STYLE_STROKE_LINEJOIN_MITER)
|
|
|
|
, mTextAnchor(NS_STYLE_TEXT_ANCHOR_START)
|
2016-06-03 10:16:39 +03:00
|
|
|
, mContextFlags((eStyleSVGOpacitySource_Normal << FILL_OPACITY_SOURCE_SHIFT) |
|
|
|
|
(eStyleSVGOpacitySource_Normal << STROKE_OPACITY_SOURCE_SHIFT))
|
2016-01-11 02:28:35 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleSVG);
|
2016-05-03 12:26:28 +03:00
|
|
|
}
|
2016-01-11 02:28:35 +03:00
|
|
|
|
|
|
|
nsStyleSVG::~nsStyleSVG()
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleSVG);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource)
|
2016-05-03 12:26:28 +03:00
|
|
|
: mFill(aSource.mFill)
|
|
|
|
, mStroke(aSource.mStroke)
|
|
|
|
, mMarkerEnd(aSource.mMarkerEnd)
|
|
|
|
, mMarkerMid(aSource.mMarkerMid)
|
|
|
|
, mMarkerStart(aSource.mMarkerStart)
|
2016-05-26 09:01:58 +03:00
|
|
|
, mStrokeDasharray(aSource.mStrokeDasharray)
|
2016-05-03 12:26:28 +03:00
|
|
|
, 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)
|
|
|
|
, mPaintOrder(aSource.mPaintOrder)
|
|
|
|
, mShapeRendering(aSource.mShapeRendering)
|
|
|
|
, mStrokeLinecap(aSource.mStrokeLinecap)
|
|
|
|
, mStrokeLinejoin(aSource.mStrokeLinejoin)
|
|
|
|
, mTextAnchor(aSource.mTextAnchor)
|
2016-06-03 10:16:39 +03:00
|
|
|
, mContextFlags(aSource.mContextFlags)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleSVG);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
static bool
|
|
|
|
PaintURIChanged(const nsStyleSVGPaint& aPaint1, const nsStyleSVGPaint& aPaint2)
|
2008-10-01 04:51:05 +04:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleSVG::CalcDifference(const nsStyleSVG& aNewData) const
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2008-10-01 04:51:05 +04:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2016-06-23 21:11:51 +03:00
|
|
|
if (mMarkerEnd != aNewData.mMarkerEnd || mMarkerMid != aNewData.mMarkerMid ||
|
|
|
|
mMarkerStart != aNewData.mMarkerStart) {
|
2013-05-24 21:31:33 +04:00
|
|
|
// Markers currently contribute to nsSVGPathGeometryFrame::mRect,
|
|
|
|
// so we need a reflow as well as a repaint. No intrinsic sizes need
|
|
|
|
// to change, so nsChangeHint_NeedReflow is sufficient.
|
2016-05-23 06:26:03 +03:00
|
|
|
return nsChangeHint_UpdateEffects |
|
|
|
|
nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_NeedDirtyReflow | // XXX remove me: bug 876085
|
|
|
|
nsChangeHint_RepaintFrame;
|
2009-01-22 04:02:40 +03:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mFill != aNewData.mFill ||
|
|
|
|
mStroke != aNewData.mStroke ||
|
|
|
|
mFillOpacity != aNewData.mFillOpacity ||
|
|
|
|
mStrokeOpacity != aNewData.mStrokeOpacity) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
2016-06-21 04:47:54 +03:00
|
|
|
if (HasStroke() != aNewData.HasStroke() ||
|
|
|
|
(!HasStroke() && HasFill() != aNewData.HasFill())) {
|
2013-11-23 17:32:21 +04:00
|
|
|
// Frame bounds and overflow rects depend on whether we "have" fill or
|
|
|
|
// stroke. Whether we have stroke or not just changed, or else we have no
|
|
|
|
// stroke (in which case whether we have fill or not is significant to frame
|
|
|
|
// bounds) and whether we have fill or not just changed. In either case we
|
|
|
|
// need to reflow so the frame rect is updated.
|
|
|
|
// XXXperf this is a waste on non nsSVGPathGeometryFrames.
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_NeedDirtyReflow; // XXX remove me: bug 876085
|
2013-11-23 17:32:21 +04:00
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (PaintURIChanged(mFill, aNewData.mFill) ||
|
|
|
|
PaintURIChanged(mStroke, aNewData.mStroke)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateEffects;
|
2008-10-01 04:51:05 +04:00
|
|
|
}
|
2013-05-24 21:31:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Stroke currently contributes to nsSVGPathGeometryFrame::mRect, so
|
|
|
|
// we need a reflow here. No intrinsic sizes need to change, so
|
|
|
|
// nsChangeHint_NeedReflow is sufficient.
|
|
|
|
// Note that stroke-dashoffset does not affect nsSVGPathGeometryFrame::mRect.
|
2016-04-12 08:52:41 +03:00
|
|
|
// text-anchor changes also require a reflow since it changes frames' rects.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mStrokeWidth != aNewData.mStrokeWidth ||
|
|
|
|
mStrokeMiterlimit != aNewData.mStrokeMiterlimit ||
|
|
|
|
mStrokeLinecap != aNewData.mStrokeLinecap ||
|
|
|
|
mStrokeLinejoin != aNewData.mStrokeLinejoin ||
|
|
|
|
mTextAnchor != aNewData.mTextAnchor) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return hint |
|
|
|
|
nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_NeedDirtyReflow | // XXX remove me: bug 876085
|
|
|
|
nsChangeHint_RepaintFrame;
|
2008-10-01 04:51:05 +04:00
|
|
|
}
|
2007-01-08 19:48:56 +03:00
|
|
|
|
2013-05-24 21:31:33 +04:00
|
|
|
if (hint & nsChangeHint_RepaintFrame) {
|
|
|
|
return hint; // we don't add anything else below
|
|
|
|
}
|
2013-05-25 00:03:03 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if ( mStrokeDashoffset != aNewData.mStrokeDashoffset ||
|
|
|
|
mClipRule != aNewData.mClipRule ||
|
|
|
|
mColorInterpolation != aNewData.mColorInterpolation ||
|
|
|
|
mColorInterpolationFilters != aNewData.mColorInterpolationFilters ||
|
|
|
|
mFillRule != aNewData.mFillRule ||
|
|
|
|
mPaintOrder != aNewData.mPaintOrder ||
|
|
|
|
mShapeRendering != aNewData.mShapeRendering ||
|
|
|
|
mStrokeDasharray != aNewData.mStrokeDasharray ||
|
|
|
|
mContextFlags != aNewData.mContextFlags) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return hint | nsChangeHint_RepaintFrame;
|
2008-10-01 04:51:05 +04:00
|
|
|
}
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2008-10-01 04:51:05 +04:00
|
|
|
return hint;
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2016-02-17 03:19:27 +03:00
|
|
|
// --------------------
|
2016-07-27 13:14:36 +03:00
|
|
|
// StyleBasicShape
|
2016-02-17 03:19:27 +03:00
|
|
|
|
|
|
|
nsCSSKeyword
|
2016-07-27 13:14:36 +03:00
|
|
|
StyleBasicShape::GetShapeTypeName() const
|
2016-02-17 03:19:27 +03:00
|
|
|
{
|
|
|
|
switch (mType) {
|
2016-07-27 12:59:33 +03:00
|
|
|
case StyleBasicShapeType::Polygon:
|
2016-02-17 03:19:27 +03:00
|
|
|
return eCSSKeyword_polygon;
|
2016-07-27 12:59:33 +03:00
|
|
|
case StyleBasicShapeType::Circle:
|
2016-02-17 03:19:27 +03:00
|
|
|
return eCSSKeyword_circle;
|
2016-07-27 12:59:33 +03:00
|
|
|
case StyleBasicShapeType::Ellipse:
|
2016-02-17 03:19:27 +03:00
|
|
|
return eCSSKeyword_ellipse;
|
2016-07-27 12:59:33 +03:00
|
|
|
case StyleBasicShapeType::Inset:
|
2016-02-17 03:19:27 +03:00
|
|
|
return eCSSKeyword_inset;
|
|
|
|
}
|
|
|
|
NS_NOTREACHED("unexpected type");
|
|
|
|
return eCSSKeyword_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2013-07-23 02:08:33 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleFilter
|
|
|
|
//
|
|
|
|
nsStyleFilter::nsStyleFilter()
|
2013-08-06 11:53:30 +04:00
|
|
|
: mType(NS_STYLE_FILTER_NONE)
|
2013-08-05 11:02:27 +04:00
|
|
|
, mDropShadow(nullptr)
|
2013-07-23 02:08:33 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleFilter);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleFilter::nsStyleFilter(const nsStyleFilter& aSource)
|
2013-08-06 11:53:30 +04:00
|
|
|
: mType(NS_STYLE_FILTER_NONE)
|
2013-08-05 11:02:27 +04:00
|
|
|
, mDropShadow(nullptr)
|
2013-07-23 02:08:33 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleFilter);
|
2013-08-06 11:53:30 +04:00
|
|
|
if (aSource.mType == NS_STYLE_FILTER_URL) {
|
2016-07-23 11:16:59 +03:00
|
|
|
CopyURL(aSource);
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (aSource.mType == NS_STYLE_FILTER_DROP_SHADOW) {
|
2013-08-05 11:02:27 +04:00
|
|
|
SetDropShadow(aSource.mDropShadow);
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (aSource.mType != NS_STYLE_FILTER_NONE) {
|
2013-08-05 11:02:27 +04:00
|
|
|
SetFilterParameter(aSource.mFilterParameter, aSource.mType);
|
2013-07-23 02:08:33 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleFilter::~nsStyleFilter()
|
|
|
|
{
|
2013-08-05 11:02:27 +04:00
|
|
|
ReleaseRef();
|
2013-07-23 02:08:33 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleFilter);
|
|
|
|
}
|
|
|
|
|
2013-08-05 11:02:27 +04:00
|
|
|
nsStyleFilter&
|
|
|
|
nsStyleFilter::operator=(const nsStyleFilter& aOther)
|
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (this == &aOther) {
|
2013-08-05 11:02:27 +04:00
|
|
|
return *this;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2013-08-05 11:02:27 +04:00
|
|
|
|
2013-08-06 11:53:30 +04:00
|
|
|
if (aOther.mType == NS_STYLE_FILTER_URL) {
|
2016-07-23 11:16:59 +03:00
|
|
|
CopyURL(aOther);
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (aOther.mType == NS_STYLE_FILTER_DROP_SHADOW) {
|
2013-08-05 11:02:27 +04:00
|
|
|
SetDropShadow(aOther.mDropShadow);
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (aOther.mType != NS_STYLE_FILTER_NONE) {
|
2013-08-05 11:02:27 +04:00
|
|
|
SetFilterParameter(aOther.mFilterParameter, aOther.mType);
|
2015-04-13 05:34:15 +03:00
|
|
|
} else {
|
|
|
|
ReleaseRef();
|
|
|
|
mType = NS_STYLE_FILTER_NONE;
|
2013-08-05 11:02:27 +04:00
|
|
|
}
|
2015-04-13 05:34:15 +03:00
|
|
|
|
2013-08-05 11:02:27 +04:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2013-07-23 02:08:33 +04:00
|
|
|
bool
|
|
|
|
nsStyleFilter::operator==(const nsStyleFilter& aOther) const
|
|
|
|
{
|
|
|
|
if (mType != aOther.mType) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-08-06 11:53:30 +04:00
|
|
|
if (mType == NS_STYLE_FILTER_URL) {
|
2013-07-23 02:08:33 +04:00
|
|
|
return EqualURIs(mURL, aOther.mURL);
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (mType == NS_STYLE_FILTER_DROP_SHADOW) {
|
2013-08-05 11:02:27 +04:00
|
|
|
return *mDropShadow == *aOther.mDropShadow;
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (mType != NS_STYLE_FILTER_NONE) {
|
2013-07-26 10:02:33 +04:00
|
|
|
return mFilterParameter == aOther.mFilterParameter;
|
2013-07-23 02:08:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-05 11:02:27 +04:00
|
|
|
void
|
|
|
|
nsStyleFilter::ReleaseRef()
|
|
|
|
{
|
2013-08-06 11:53:30 +04:00
|
|
|
if (mType == NS_STYLE_FILTER_DROP_SHADOW) {
|
2013-08-05 11:02:27 +04:00
|
|
|
NS_ASSERTION(mDropShadow, "expected pointer");
|
|
|
|
mDropShadow->Release();
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (mType == NS_STYLE_FILTER_URL) {
|
2013-08-05 11:02:27 +04:00
|
|
|
NS_ASSERTION(mURL, "expected pointer");
|
2016-07-23 11:16:59 +03:00
|
|
|
delete mURL;
|
2013-08-05 11:02:27 +04:00
|
|
|
}
|
2015-04-13 05:34:15 +03:00
|
|
|
mURL = nullptr;
|
2013-08-05 11:02:27 +04:00
|
|
|
}
|
|
|
|
|
2016-07-23 11:16:59 +03:00
|
|
|
void
|
|
|
|
nsStyleFilter::CopyURL(const nsStyleFilter& aOther)
|
|
|
|
{
|
|
|
|
ReleaseRef();
|
|
|
|
mURL = new FragmentOrURL(*aOther.mURL);
|
|
|
|
mType = NS_STYLE_FILTER_URL;
|
|
|
|
}
|
|
|
|
|
2013-08-05 11:02:27 +04:00
|
|
|
void
|
|
|
|
nsStyleFilter::SetFilterParameter(const nsStyleCoord& aFilterParameter,
|
2013-08-06 11:53:30 +04:00
|
|
|
int32_t aType)
|
2013-08-05 11:02:27 +04:00
|
|
|
{
|
|
|
|
ReleaseRef();
|
|
|
|
mFilterParameter = aFilterParameter;
|
|
|
|
mType = aType;
|
|
|
|
}
|
|
|
|
|
2016-07-23 11:16:59 +03:00
|
|
|
bool
|
|
|
|
nsStyleFilter::SetURL(const nsCSSValue* aValue)
|
2013-08-05 11:02:27 +04:00
|
|
|
{
|
2016-07-23 11:16:59 +03:00
|
|
|
if (!aValue->GetURLValue()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-08-05 11:02:27 +04:00
|
|
|
ReleaseRef();
|
2016-07-23 11:16:59 +03:00
|
|
|
|
|
|
|
mURL = new FragmentOrURL();
|
|
|
|
mURL->SetValue(aValue);
|
|
|
|
|
2013-08-06 11:53:30 +04:00
|
|
|
mType = NS_STYLE_FILTER_URL;
|
2016-07-23 11:16:59 +03:00
|
|
|
return true;
|
2013-08-05 11:02:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleFilter::SetDropShadow(nsCSSShadowArray* aDropShadow)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aDropShadow, "expected pointer");
|
|
|
|
ReleaseRef();
|
|
|
|
mDropShadow = aDropShadow;
|
|
|
|
mDropShadow->AddRef();
|
2013-08-06 11:53:30 +04:00
|
|
|
mType = NS_STYLE_FILTER_DROP_SHADOW;
|
2013-08-05 11:02:27 +04:00
|
|
|
}
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
// --------------------
|
|
|
|
// nsStyleSVGReset
|
|
|
|
//
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleSVGReset::nsStyleSVGReset(StyleStructContext aContext)
|
2016-06-03 18:56:54 +03:00
|
|
|
: mMask(nsStyleImageLayers::LayerType::Mask)
|
|
|
|
, mStopColor(NS_RGB(0, 0, 0))
|
2016-05-03 12:26:28 +03:00
|
|
|
, mFloodColor(NS_RGB(0, 0, 0))
|
|
|
|
, mLightingColor(NS_RGB(255, 255, 255))
|
|
|
|
, mStopOpacity(1.0f)
|
|
|
|
, mFloodOpacity(1.0f)
|
|
|
|
, mDominantBaseline(NS_STYLE_DOMINANT_BASELINE_AUTO)
|
|
|
|
, mVectorEffect(NS_STYLE_VECTOR_EFFECT_NONE)
|
|
|
|
, mMaskType(NS_STYLE_MASK_TYPE_LUMINANCE)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
{
|
2016-01-11 02:28:35 +03:00
|
|
|
MOZ_COUNT_CTOR(nsStyleSVGReset);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGReset::~nsStyleSVGReset()
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleSVGReset);
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGReset::nsStyleSVGReset(const nsStyleSVGReset& aSource)
|
2016-01-28 08:39:00 +03:00
|
|
|
: mMask(aSource.mMask)
|
2016-05-03 12:26:28 +03:00
|
|
|
, mClipPath(aSource.mClipPath)
|
|
|
|
, mStopColor(aSource.mStopColor)
|
|
|
|
, mFloodColor(aSource.mFloodColor)
|
|
|
|
, mLightingColor(aSource.mLightingColor)
|
|
|
|
, mStopOpacity(aSource.mStopOpacity)
|
|
|
|
, mFloodOpacity(aSource.mFloodOpacity)
|
|
|
|
, mDominantBaseline(aSource.mDominantBaseline)
|
|
|
|
, mVectorEffect(aSource.mVectorEffect)
|
|
|
|
, mMaskType(aSource.mMaskType)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleSVGReset);
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
void
|
|
|
|
nsStyleSVGReset::Destroy(nsPresContext* aContext)
|
|
|
|
{
|
2016-01-28 08:39:00 +03:00
|
|
|
mMask.UntrackImages(aContext);
|
2016-01-28 08:28:00 +03:00
|
|
|
|
|
|
|
this->~nsStyleSVGReset();
|
|
|
|
aContext->PresShell()->
|
|
|
|
FreeByObjectID(mozilla::eArenaObjectID_nsStyleSVGReset, this);
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleSVGReset::CalcDifference(const nsStyleSVGReset& aNewData) const
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
{
|
2008-08-06 04:55:07 +04:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mClipPath != aNewData.mClipPath) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateEffects |
|
|
|
|
nsChangeHint_RepaintFrame;
|
2016-04-12 08:52:43 +03:00
|
|
|
// clip-path changes require that we update the PreEffectsBBoxProperty,
|
|
|
|
// which is done during overflow computation.
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateOverflow;
|
2013-05-24 21:31:33 +04:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mDominantBaseline != aNewData.mDominantBaseline) {
|
2013-05-24 21:31:33 +04:00
|
|
|
// XXXjwatt: why NS_STYLE_HINT_REFLOW? Isn't that excessive?
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= NS_STYLE_HINT_REFLOW;
|
2016-06-21 04:47:54 +03:00
|
|
|
} else if (mVectorEffect != aNewData.mVectorEffect) {
|
2013-05-24 21:31:33 +04:00
|
|
|
// Stroke currently affects nsSVGPathGeometryFrame::mRect, and
|
|
|
|
// vector-effect affect stroke. As a result we need to reflow if
|
|
|
|
// vector-effect changes in order to have nsSVGPathGeometryFrame::
|
|
|
|
// ReflowSVG called to update its mRect. No intrinsic sizes need
|
|
|
|
// to change so nsChangeHint_NeedReflow is sufficient.
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_NeedDirtyReflow | // XXX remove me: bug 876085
|
|
|
|
nsChangeHint_RepaintFrame;
|
2016-06-21 04:47:54 +03:00
|
|
|
} else if (mStopColor != aNewData.mStopColor ||
|
|
|
|
mFloodColor != aNewData.mFloodColor ||
|
|
|
|
mLightingColor != aNewData.mLightingColor ||
|
|
|
|
mStopOpacity != aNewData.mStopOpacity ||
|
|
|
|
mFloodOpacity != aNewData.mFloodOpacity ||
|
|
|
|
mMaskType != aNewData.mMaskType) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
2013-05-24 21:31:33 +04:00
|
|
|
}
|
2008-08-06 04:55:07 +04:00
|
|
|
|
2016-09-22 13:24:52 +03:00
|
|
|
hint |= mMask.CalcDifference(aNewData.mMask,
|
|
|
|
nsStyleImageLayers::LayerType::Mask);
|
2016-01-28 08:28:00 +03:00
|
|
|
|
2008-08-06 04:55:07 +04:00
|
|
|
return hint;
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2004-10-15 03:02:53 +04:00
|
|
|
// nsStyleSVGPaint implementation
|
2016-05-03 12:26:27 +03:00
|
|
|
nsStyleSVGPaint::nsStyleSVGPaint(nsStyleSVGPaintType aType)
|
|
|
|
: mType(nsStyleSVGPaintType(0))
|
|
|
|
, mFallbackColor(NS_RGB(0, 0, 0))
|
2007-10-19 19:36:15 +04:00
|
|
|
{
|
2016-05-03 12:26:27 +03:00
|
|
|
SetType(aType);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGPaint::nsStyleSVGPaint(const nsStyleSVGPaint& aSource)
|
|
|
|
: mType(nsStyleSVGPaintType(0))
|
|
|
|
, mFallbackColor(NS_RGB(0, 0, 0))
|
|
|
|
{
|
|
|
|
SetType(aSource.mType);
|
|
|
|
|
|
|
|
mFallbackColor = aSource.mFallbackColor;
|
2004-10-15 03:02:53 +04:00
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
2016-07-04 20:00:15 +03:00
|
|
|
mPaint.mPaintServer = new FragmentOrURL(*aSource.mPaint.mPaintServer);
|
2016-05-03 12:26:27 +03:00
|
|
|
} else {
|
|
|
|
mPaint.mColor = aSource.mPaint.mColor;
|
2007-10-19 19:36:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:27 +03:00
|
|
|
nsStyleSVGPaint::~nsStyleSVGPaint()
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleSVGPaint::Reset()
|
|
|
|
{
|
|
|
|
SetType(nsStyleSVGPaintType(0));
|
|
|
|
}
|
|
|
|
|
2007-10-19 19:36:15 +04:00
|
|
|
void
|
|
|
|
nsStyleSVGPaint::SetType(nsStyleSVGPaintType aType)
|
|
|
|
{
|
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
2016-07-04 20:00:15 +03:00
|
|
|
delete mPaint.mPaintServer;
|
2016-05-03 12:26:27 +03:00
|
|
|
mPaint.mPaintServer = nullptr;
|
|
|
|
} else {
|
|
|
|
mPaint.mColor = NS_RGB(0, 0, 0);
|
2007-10-19 19:36:15 +04:00
|
|
|
}
|
|
|
|
mType = aType;
|
2004-10-15 03:02:53 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsStyleSVGPaint&
|
|
|
|
nsStyleSVGPaint::operator=(const nsStyleSVGPaint& aOther)
|
2004-10-15 03:02:53 +04:00
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (this == &aOther) {
|
2007-10-19 19:36:15 +04:00
|
|
|
return *this;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2007-10-19 19:36:15 +04:00
|
|
|
|
|
|
|
SetType(aOther.mType);
|
|
|
|
|
2007-01-09 14:02:17 +03:00
|
|
|
mFallbackColor = aOther.mFallbackColor;
|
2004-10-15 03:02:53 +04:00
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
2016-07-04 20:00:15 +03:00
|
|
|
mPaint.mPaintServer = new FragmentOrURL(*aOther.mPaint.mPaintServer);
|
2004-10-15 03:02:53 +04:00
|
|
|
} else {
|
|
|
|
mPaint.mColor = aOther.mPaint.mColor;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsStyleSVGPaint::operator==(const nsStyleSVGPaint& aOther) const
|
2004-10-15 03:02:53 +04:00
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != aOther.mType) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
2007-01-09 14:02:17 +03:00
|
|
|
return EqualURIs(mPaint.mPaintServer, aOther.mPaint.mPaintServer) &&
|
|
|
|
mFallbackColor == aOther.mFallbackColor;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
|
|
|
if (mType == eStyleSVGPaintType_Color) {
|
2012-09-06 08:58:46 +04:00
|
|
|
return mPaint.mColor == aOther.mPaint.mColor;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2012-09-06 08:58:46 +04:00
|
|
|
return true;
|
2004-10-15 03:02:53 +04:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStylePosition
|
|
|
|
//
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStylePosition::nsStylePosition(StyleStructContext aContext)
|
2016-05-03 12:26:30 +03:00
|
|
|
: mWidth(eStyleUnit_Auto)
|
|
|
|
, mMinWidth(eStyleUnit_Auto)
|
|
|
|
, mMaxWidth(eStyleUnit_None)
|
|
|
|
, mHeight(eStyleUnit_Auto)
|
|
|
|
, mMinHeight(eStyleUnit_Auto)
|
|
|
|
, mMaxHeight(eStyleUnit_None)
|
|
|
|
, mFlexBasis(eStyleUnit_Auto)
|
|
|
|
, mGridAutoColumnsMin(eStyleUnit_Auto)
|
|
|
|
, mGridAutoColumnsMax(eStyleUnit_Auto)
|
|
|
|
, mGridAutoRowsMin(eStyleUnit_Auto)
|
|
|
|
, mGridAutoRowsMax(eStyleUnit_Auto)
|
|
|
|
, mGridAutoFlow(NS_STYLE_GRID_AUTO_FLOW_ROW)
|
2016-05-03 12:26:28 +03:00
|
|
|
, mBoxSizing(StyleBoxSizing::Content)
|
|
|
|
, mAlignContent(NS_STYLE_ALIGN_NORMAL)
|
|
|
|
, mAlignItems(NS_STYLE_ALIGN_NORMAL)
|
|
|
|
, mAlignSelf(NS_STYLE_ALIGN_AUTO)
|
|
|
|
, mJustifyContent(NS_STYLE_JUSTIFY_NORMAL)
|
|
|
|
, mJustifyItems(NS_STYLE_JUSTIFY_AUTO)
|
|
|
|
, mJustifySelf(NS_STYLE_JUSTIFY_AUTO)
|
|
|
|
, mFlexDirection(NS_STYLE_FLEX_DIRECTION_ROW)
|
|
|
|
, mFlexWrap(NS_STYLE_FLEX_WRAP_NOWRAP)
|
|
|
|
, mObjectFit(NS_STYLE_OBJECT_FIT_FILL)
|
|
|
|
, mOrder(NS_STYLE_ORDER_INITIAL)
|
|
|
|
, mFlexGrow(0.0f)
|
|
|
|
, mFlexShrink(1.0f)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mZIndex(eStyleUnit_Auto)
|
2016-05-25 11:48:52 +03:00
|
|
|
, mGridColumnGap(nscoord(0), nsStyleCoord::CoordConstructor)
|
|
|
|
, mGridRowGap(nscoord(0), nsStyleCoord::CoordConstructor)
|
2014-03-11 02:54:13 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStylePosition);
|
2014-09-10 05:09:32 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// positioning values not inherited
|
2014-09-10 05:09:32 +04:00
|
|
|
|
|
|
|
mObjectPosition.SetInitialPercentValues(0.5f);
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleCoord autoCoord(eStyleUnit_Auto);
|
2016-05-03 12:26:30 +03:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mOffset.Set(side, autoCoord);
|
|
|
|
}
|
2014-03-11 02:54:15 +04:00
|
|
|
|
|
|
|
// The initial value of grid-auto-columns and grid-auto-rows is 'auto',
|
2015-04-30 21:42:50 +03:00
|
|
|
// which computes to 'minmax(auto, auto)'.
|
2014-03-11 02:54:15 +04:00
|
|
|
|
2014-03-21 19:06:16 +04:00
|
|
|
// Other members get their default constructors
|
|
|
|
// which initialize them to representations of their respective initial value.
|
|
|
|
// mGridTemplateAreas: nullptr for 'none'
|
2014-03-27 19:54:40 +04:00
|
|
|
// mGridTemplate{Rows,Columns}: false and empty arrays for 'none'
|
2014-03-21 19:06:16 +04:00
|
|
|
// mGrid{Column,Row}{Start,End}: false/0/empty values for 'auto'
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStylePosition::~nsStylePosition()
|
2014-03-11 02:54:13 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStylePosition);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePosition::nsStylePosition(const nsStylePosition& aSource)
|
2014-09-10 05:09:32 +04:00
|
|
|
: mObjectPosition(aSource.mObjectPosition)
|
|
|
|
, mOffset(aSource.mOffset)
|
2014-06-19 07:17:10 +04:00
|
|
|
, mWidth(aSource.mWidth)
|
|
|
|
, mMinWidth(aSource.mMinWidth)
|
|
|
|
, mMaxWidth(aSource.mMaxWidth)
|
|
|
|
, mHeight(aSource.mHeight)
|
|
|
|
, mMinHeight(aSource.mMinHeight)
|
|
|
|
, mMaxHeight(aSource.mMaxHeight)
|
|
|
|
, mFlexBasis(aSource.mFlexBasis)
|
|
|
|
, mGridAutoColumnsMin(aSource.mGridAutoColumnsMin)
|
|
|
|
, mGridAutoColumnsMax(aSource.mGridAutoColumnsMax)
|
|
|
|
, mGridAutoRowsMin(aSource.mGridAutoRowsMin)
|
|
|
|
, mGridAutoRowsMax(aSource.mGridAutoRowsMax)
|
|
|
|
, mGridAutoFlow(aSource.mGridAutoFlow)
|
|
|
|
, mBoxSizing(aSource.mBoxSizing)
|
|
|
|
, mAlignContent(aSource.mAlignContent)
|
|
|
|
, mAlignItems(aSource.mAlignItems)
|
|
|
|
, mAlignSelf(aSource.mAlignSelf)
|
2015-11-03 17:18:05 +03:00
|
|
|
, mJustifyContent(aSource.mJustifyContent)
|
2015-11-03 17:18:05 +03:00
|
|
|
, mJustifyItems(aSource.mJustifyItems)
|
2015-11-03 17:18:05 +03:00
|
|
|
, mJustifySelf(aSource.mJustifySelf)
|
2014-06-19 07:17:10 +04:00
|
|
|
, mFlexDirection(aSource.mFlexDirection)
|
|
|
|
, mFlexWrap(aSource.mFlexWrap)
|
2014-09-10 05:09:32 +04:00
|
|
|
, mObjectFit(aSource.mObjectFit)
|
2014-06-19 07:17:10 +04:00
|
|
|
, mOrder(aSource.mOrder)
|
|
|
|
, mFlexGrow(aSource.mFlexGrow)
|
|
|
|
, mFlexShrink(aSource.mFlexShrink)
|
|
|
|
, mZIndex(aSource.mZIndex)
|
|
|
|
, mGridTemplateColumns(aSource.mGridTemplateColumns)
|
2014-03-11 02:54:13 +04:00
|
|
|
, mGridTemplateRows(aSource.mGridTemplateRows)
|
2014-03-11 02:54:14 +04:00
|
|
|
, mGridTemplateAreas(aSource.mGridTemplateAreas)
|
2014-03-11 02:54:17 +04:00
|
|
|
, mGridColumnStart(aSource.mGridColumnStart)
|
|
|
|
, mGridColumnEnd(aSource.mGridColumnEnd)
|
|
|
|
, mGridRowStart(aSource.mGridRowStart)
|
|
|
|
, mGridRowEnd(aSource.mGridRowEnd)
|
2015-11-18 21:52:27 +03:00
|
|
|
, mGridColumnGap(aSource.mGridColumnGap)
|
|
|
|
, mGridRowGap(aSource.mGridRowGap)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStylePosition);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2013-09-10 04:08:41 +04:00
|
|
|
static bool
|
|
|
|
IsAutonessEqual(const nsStyleSides& aSides1, const nsStyleSides& aSides2)
|
|
|
|
{
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
if ((aSides1.GetUnit(side) == eStyleUnit_Auto) !=
|
|
|
|
(aSides2.GetUnit(side) == eStyleUnit_Auto)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-09 14:22:02 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStylePosition::CalcDifference(const nsStylePosition& aNewData,
|
2015-10-23 02:57:35 +03:00
|
|
|
const nsStyleVisibility* aOldStyleVisibility) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2014-09-10 05:09:32 +04:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2015-01-15 20:51:19 +03:00
|
|
|
// Changes to "z-index" require a repaint.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mZIndex != aNewData.mZIndex) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
2015-01-15 09:43:05 +03:00
|
|
|
}
|
|
|
|
|
2015-01-15 20:51:19 +03:00
|
|
|
// Changes to "object-fit" & "object-position" require a repaint. They
|
|
|
|
// may also require a reflow, if we have a nsSubDocumentFrame, so that we
|
|
|
|
// can adjust the size & position of the subdocument.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mObjectFit != aNewData.mObjectFit ||
|
|
|
|
mObjectPosition != aNewData.mObjectPosition) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame |
|
|
|
|
nsChangeHint_NeedReflow;
|
2015-01-15 20:51:19 +03:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mOrder != aNewData.mOrder) {
|
2014-08-01 22:13:28 +04:00
|
|
|
// "order" impacts both layout order and stacking order, so we need both a
|
|
|
|
// reflow and a repaint when it changes. (Technically, we only need a
|
|
|
|
// reflow if we're in a multi-line flexbox (which we can't be sure about,
|
|
|
|
// since that's determined by styling on our parent) -- there, "order" can
|
|
|
|
// affect which flex line we end up on, & hence can affect our sizing by
|
|
|
|
// changing the group of flex items we're competing with for space.)
|
2016-05-23 06:26:03 +03:00
|
|
|
return hint |
|
|
|
|
nsChangeHint_RepaintFrame |
|
|
|
|
nsChangeHint_AllReflowHints;
|
2014-08-01 22:13:28 +04:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBoxSizing != aNewData.mBoxSizing) {
|
2009-10-30 06:43:52 +03:00
|
|
|
// Can affect both widths and heights; just a bad scene.
|
2016-05-23 06:26:03 +03:00
|
|
|
return hint |
|
|
|
|
nsChangeHint_AllReflowHints;
|
2009-10-30 04:47:43 +03:00
|
|
|
}
|
|
|
|
|
2012-07-07 04:06:19 +04:00
|
|
|
// Properties that apply to flex items:
|
2014-08-01 22:13:28 +04:00
|
|
|
// XXXdholbert These should probably be more targeted (bug 819536)
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mAlignSelf != aNewData.mAlignSelf ||
|
|
|
|
mFlexBasis != aNewData.mFlexBasis ||
|
|
|
|
mFlexGrow != aNewData.mFlexGrow ||
|
|
|
|
mFlexShrink != aNewData.mFlexShrink) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return hint |
|
|
|
|
nsChangeHint_AllReflowHints;
|
2012-07-07 04:06:19 +04:00
|
|
|
}
|
|
|
|
|
2013-12-05 22:57:50 +04:00
|
|
|
// Properties that apply to flex containers:
|
|
|
|
// - flex-direction can swap a flex container between vertical & horizontal.
|
|
|
|
// - align-items can change the sizing of a flex container & the positioning
|
|
|
|
// of its children.
|
|
|
|
// - flex-wrap changes whether a flex container's children are wrapped, which
|
|
|
|
// impacts their sizing/positioning and hence impacts the container's size.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mAlignItems != aNewData.mAlignItems ||
|
|
|
|
mFlexDirection != aNewData.mFlexDirection ||
|
|
|
|
mFlexWrap != aNewData.mFlexWrap) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return hint |
|
|
|
|
nsChangeHint_AllReflowHints;
|
2012-07-07 04:06:20 +04:00
|
|
|
}
|
|
|
|
|
2014-03-11 02:54:13 +04:00
|
|
|
// Properties that apply to grid containers:
|
2014-03-11 02:54:17 +04:00
|
|
|
// FIXME: only for grid containers
|
|
|
|
// (ie. 'display: grid' or 'display: inline-grid')
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mGridTemplateColumns != aNewData.mGridTemplateColumns ||
|
|
|
|
mGridTemplateRows != aNewData.mGridTemplateRows ||
|
|
|
|
mGridTemplateAreas != aNewData.mGridTemplateAreas ||
|
|
|
|
mGridAutoColumnsMin != aNewData.mGridAutoColumnsMin ||
|
|
|
|
mGridAutoColumnsMax != aNewData.mGridAutoColumnsMax ||
|
|
|
|
mGridAutoRowsMin != aNewData.mGridAutoRowsMin ||
|
|
|
|
mGridAutoRowsMax != aNewData.mGridAutoRowsMax ||
|
|
|
|
mGridAutoFlow != aNewData.mGridAutoFlow) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return hint |
|
|
|
|
nsChangeHint_AllReflowHints;
|
2014-03-11 02:54:13 +04:00
|
|
|
}
|
|
|
|
|
2014-03-11 02:54:17 +04:00
|
|
|
// Properties that apply to grid items:
|
|
|
|
// FIXME: only for grid items
|
|
|
|
// (ie. parent frame is 'display: grid' or 'display: inline-grid')
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mGridColumnStart != aNewData.mGridColumnStart ||
|
|
|
|
mGridColumnEnd != aNewData.mGridColumnEnd ||
|
|
|
|
mGridRowStart != aNewData.mGridRowStart ||
|
|
|
|
mGridRowEnd != aNewData.mGridRowEnd ||
|
|
|
|
mGridColumnGap != aNewData.mGridColumnGap ||
|
|
|
|
mGridRowGap != aNewData.mGridRowGap) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return hint |
|
|
|
|
nsChangeHint_AllReflowHints;
|
2014-03-11 02:54:17 +04:00
|
|
|
}
|
2014-03-11 02:54:13 +04:00
|
|
|
|
2015-11-03 17:18:05 +03:00
|
|
|
// Changing 'justify-content/items/self' might affect the positioning,
|
2015-11-03 17:18:05 +03:00
|
|
|
// but it won't affect any sizing.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mJustifyContent != aNewData.mJustifyContent ||
|
|
|
|
mJustifyItems != aNewData.mJustifyItems ||
|
|
|
|
mJustifySelf != aNewData.mJustifySelf) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeedReflow;
|
2012-07-07 04:06:19 +04:00
|
|
|
}
|
|
|
|
|
2015-09-10 22:07:26 +03:00
|
|
|
// 'align-content' doesn't apply to a single-line flexbox but we don't know
|
|
|
|
// if we're a flex container at this point so we can't optimize for that.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mAlignContent != aNewData.mAlignContent) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeedReflow;
|
2013-12-05 22:57:50 +04:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
bool widthChanged = mWidth != aNewData.mWidth ||
|
|
|
|
mMinWidth != aNewData.mMinWidth ||
|
|
|
|
mMaxWidth != aNewData.mMaxWidth;
|
|
|
|
bool heightChanged = mHeight != aNewData.mHeight ||
|
|
|
|
mMinHeight != aNewData.mMinHeight ||
|
|
|
|
mMaxHeight != aNewData.mMaxHeight;
|
2015-10-23 02:57:35 +03:00
|
|
|
|
|
|
|
// If aOldStyleVisibility is null, we don't need to bother with any of
|
|
|
|
// these tests, since we know that the element never had its
|
|
|
|
// nsStyleVisibility accessed, which means it couldn't have done
|
|
|
|
// layout.
|
|
|
|
// Note that we pass an nsStyleVisibility here because we don't want
|
|
|
|
// to cause a new struct to be computed during
|
|
|
|
// nsStyleContext::CalcStyleDifference, which can lead to incorrect
|
|
|
|
// style data.
|
|
|
|
// It doesn't matter whether we're looking at the old or new
|
|
|
|
// visibility struct, since a change between vertical and horizontal
|
|
|
|
// writing-mode will cause a reframe, and it's easier to pass the old.
|
|
|
|
if (aOldStyleVisibility) {
|
|
|
|
bool isVertical = WritingMode(aOldStyleVisibility).IsVertical();
|
|
|
|
if (isVertical ? widthChanged : heightChanged) {
|
|
|
|
// Block-size changes can affect descendant intrinsic sizes due to
|
|
|
|
// replaced elements with percentage bsizes in descendants which
|
|
|
|
// also have percentage bsizes. This is handled via
|
|
|
|
// nsChangeHint_UpdateComputedBSize which clears intrinsic sizes
|
|
|
|
// for frames that have such replaced elements.
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_UpdateComputedBSize |
|
|
|
|
nsChangeHint_ReflowChangesSizeOrPosition;
|
2015-10-23 02:57:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isVertical ? heightChanged : widthChanged) {
|
|
|
|
// None of our inline-size differences can affect descendant
|
|
|
|
// intrinsic sizes and none of them need to force children to
|
|
|
|
// reflow.
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_AllReflowHints &
|
|
|
|
~(nsChangeHint_ClearDescendantIntrinsics |
|
|
|
|
nsChangeHint_NeedDirtyReflow);
|
2015-10-23 02:57:35 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (widthChanged || heightChanged) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2015-10-23 02:57:35 +03:00
|
|
|
}
|
2009-08-04 05:22:13 +04:00
|
|
|
}
|
|
|
|
|
2015-08-04 07:41:50 +03:00
|
|
|
// If any of the offsets have changed, then return the respective hints
|
|
|
|
// so that we would hopefully be able to avoid reflowing.
|
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-06 08:53:48 +04:00
|
|
|
// 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.
|
2013-09-10 04:08:41 +04:00
|
|
|
// Don't try to handle changes between "auto" and non-auto efficiently;
|
|
|
|
// that's tricky to do and will hardly ever be able to avoid a reflow.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mOffset != aNewData.mOffset) {
|
|
|
|
if (IsAutonessEqual(mOffset, aNewData.mOffset)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_RecomputePosition |
|
|
|
|
nsChangeHint_UpdateParentOverflow;
|
2013-09-10 04:08:41 +04:00
|
|
|
} else {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_AllReflowHints;
|
2013-09-10 04:08:41 +04: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-06 08:53:48 +04:00
|
|
|
}
|
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
/* static */ bool
|
2010-08-11 23:32:53 +04:00
|
|
|
nsStylePosition::WidthCoordDependsOnContainer(const nsStyleCoord &aCoord)
|
|
|
|
{
|
2014-07-22 19:24:34 +04:00
|
|
|
return aCoord.HasPercent() ||
|
2010-08-11 23:32:53 +04:00
|
|
|
(aCoord.GetUnit() == eStyleUnit_Enumerated &&
|
|
|
|
(aCoord.GetIntValue() == NS_STYLE_WIDTH_FIT_CONTENT ||
|
|
|
|
aCoord.GetIntValue() == NS_STYLE_WIDTH_AVAILABLE));
|
|
|
|
}
|
|
|
|
|
2015-11-03 17:18:05 +03:00
|
|
|
uint8_t
|
2016-01-05 23:27:13 +03:00
|
|
|
nsStylePosition::ComputedAlignSelf(nsStyleContext* aParent) const
|
2015-11-03 17:18:06 +03:00
|
|
|
{
|
|
|
|
if (mAlignSelf != NS_STYLE_ALIGN_AUTO) {
|
2015-11-28 23:37:44 +03:00
|
|
|
return mAlignSelf;
|
2015-11-03 17:18:06 +03:00
|
|
|
}
|
|
|
|
if (MOZ_LIKELY(aParent)) {
|
2016-01-05 23:27:13 +03:00
|
|
|
auto parentAlignItems = aParent->StylePosition()->ComputedAlignItems();
|
2015-11-03 17:18:06 +03:00
|
|
|
MOZ_ASSERT(!(parentAlignItems & NS_STYLE_ALIGN_LEGACY),
|
|
|
|
"align-items can't have 'legacy'");
|
2015-11-28 23:37:44 +03:00
|
|
|
return parentAlignItems;
|
2015-11-03 17:18:06 +03:00
|
|
|
}
|
2016-01-05 23:27:13 +03:00
|
|
|
return NS_STYLE_ALIGN_NORMAL;
|
2015-11-03 17:18:05 +03:00
|
|
|
}
|
|
|
|
|
2015-11-03 17:18:05 +03:00
|
|
|
uint8_t
|
2016-01-05 23:27:13 +03:00
|
|
|
nsStylePosition::ComputedJustifyItems(nsStyleContext* aParent) const
|
2015-11-03 17:18:05 +03:00
|
|
|
{
|
|
|
|
if (mJustifyItems != NS_STYLE_JUSTIFY_AUTO) {
|
2015-11-28 23:37:44 +03:00
|
|
|
return mJustifyItems;
|
2015-11-03 17:18:05 +03:00
|
|
|
}
|
|
|
|
if (MOZ_LIKELY(aParent)) {
|
|
|
|
auto inheritedJustifyItems =
|
2016-01-05 23:27:13 +03:00
|
|
|
aParent->StylePosition()->ComputedJustifyItems(aParent->GetParent());
|
|
|
|
// "If the inherited value of justify-items includes the 'legacy' keyword,
|
|
|
|
// 'auto' computes to the inherited value." Otherwise, 'normal'.
|
2015-11-03 17:18:05 +03:00
|
|
|
if (inheritedJustifyItems & NS_STYLE_JUSTIFY_LEGACY) {
|
|
|
|
return inheritedJustifyItems;
|
|
|
|
}
|
|
|
|
}
|
2016-01-05 23:27:13 +03:00
|
|
|
return NS_STYLE_JUSTIFY_NORMAL;
|
2015-11-03 17:18:05 +03:00
|
|
|
}
|
|
|
|
|
2015-11-03 17:18:05 +03:00
|
|
|
uint8_t
|
2016-01-05 23:27:13 +03:00
|
|
|
nsStylePosition::ComputedJustifySelf(nsStyleContext* aParent) const
|
2015-11-03 17:18:05 +03:00
|
|
|
{
|
|
|
|
if (mJustifySelf != NS_STYLE_JUSTIFY_AUTO) {
|
2015-11-28 23:37:44 +03:00
|
|
|
return mJustifySelf;
|
2015-11-03 17:18:05 +03:00
|
|
|
}
|
|
|
|
if (MOZ_LIKELY(aParent)) {
|
|
|
|
auto inheritedJustifyItems = aParent->StylePosition()->
|
2016-01-05 23:27:13 +03:00
|
|
|
ComputedJustifyItems(aParent->GetParent());
|
2015-11-28 23:37:44 +03:00
|
|
|
return inheritedJustifyItems & ~NS_STYLE_JUSTIFY_LEGACY;
|
2015-11-03 17:18:05 +03:00
|
|
|
}
|
2016-01-05 23:27:13 +03:00
|
|
|
return NS_STYLE_JUSTIFY_NORMAL;
|
2015-11-03 17:18:05 +03:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleTable
|
|
|
|
//
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleTable::nsStyleTable(StyleStructContext aContext)
|
2016-05-03 12:26:28 +03:00
|
|
|
: mLayoutStrategy(NS_STYLE_TABLE_LAYOUT_AUTO)
|
|
|
|
, mSpan(1)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTable);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleTable::~nsStyleTable()
|
2009-08-07 18:38:44 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleTable);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTable::nsStyleTable(const nsStyleTable& aSource)
|
2014-06-19 07:17:10 +04:00
|
|
|
: mLayoutStrategy(aSource.mLayoutStrategy)
|
|
|
|
, mSpan(aSource.mSpan)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTable);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
nsChangeHint
|
|
|
|
nsStyleTable::CalcDifference(const nsStyleTable& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mSpan != aNewData.mSpan ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mLayoutStrategy != aNewData.mLayoutStrategy) {
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------
|
|
|
|
// nsStyleTableBorder
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleTableBorder::nsStyleTableBorder(StyleStructContext aContext)
|
2016-05-03 12:26:29 +03:00
|
|
|
: mBorderSpacingCol(0)
|
|
|
|
, mBorderSpacingRow(0)
|
|
|
|
, mBorderCollapse(NS_STYLE_BORDER_SEPARATE)
|
|
|
|
, mCaptionSide(NS_STYLE_CAPTION_SIDE_TOP)
|
|
|
|
, mEmptyCells(NS_STYLE_TABLE_EMPTY_CELLS_SHOW)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTableBorder);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleTableBorder::~nsStyleTableBorder()
|
2009-08-07 18:38:44 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleTableBorder);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTableBorder::nsStyleTableBorder(const nsStyleTableBorder& aSource)
|
2015-03-20 07:16:00 +03:00
|
|
|
: mBorderSpacingCol(aSource.mBorderSpacingCol)
|
|
|
|
, mBorderSpacingRow(aSource.mBorderSpacingRow)
|
2014-06-19 07:17:10 +04:00
|
|
|
, mBorderCollapse(aSource.mBorderCollapse)
|
|
|
|
, mCaptionSide(aSource.mCaptionSide)
|
|
|
|
, mEmptyCells(aSource.mEmptyCells)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTableBorder);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleTableBorder::CalcDifference(const nsStyleTableBorder& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2003-02-13 22:06:18 +03:00
|
|
|
// 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).
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBorderCollapse != aNewData.mBorderCollapse) {
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2003-02-13 22:06:18 +03:00
|
|
|
}
|
2016-05-03 12:26:29 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if ((mCaptionSide == aNewData.mCaptionSide) &&
|
|
|
|
(mBorderSpacingCol == aNewData.mBorderSpacingCol) &&
|
|
|
|
(mBorderSpacingRow == aNewData.mBorderSpacingRow)) {
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mEmptyCells == aNewData.mEmptyCells) {
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2016-07-06 08:06:13 +03:00
|
|
|
} else {
|
2016-07-06 06:40:49 +03:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleColor
|
|
|
|
//
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleColor::nsStyleColor(StyleStructContext aContext)
|
2016-05-03 12:26:29 +03:00
|
|
|
: mColor(aContext.DefaultColor())
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColor);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColor::nsStyleColor(const nsStyleColor& aSource)
|
2016-05-03 12:26:29 +03:00
|
|
|
: mColor(aSource.mColor)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColor);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleColor::CalcDifference(const nsStyleColor& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mColor == aNewData.mColor) {
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2009-08-01 19:53:40 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleGradient
|
|
|
|
//
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-08-01 19:53:40 +04:00
|
|
|
nsStyleGradient::operator==(const nsStyleGradient& aOther) const
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mSize == NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER ||
|
|
|
|
mShape != NS_STYLE_GRADIENT_SHAPE_LINEAR,
|
|
|
|
"incorrect combination of shape and size");
|
|
|
|
MOZ_ASSERT(aOther.mSize == NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER ||
|
|
|
|
aOther.mShape != NS_STYLE_GRADIENT_SHAPE_LINEAR,
|
|
|
|
"incorrect combination of shape and size");
|
2009-11-02 22:36:43 +03:00
|
|
|
|
|
|
|
if (mShape != aOther.mShape ||
|
|
|
|
mSize != aOther.mSize ||
|
|
|
|
mRepeating != aOther.mRepeating ||
|
2015-07-15 17:37:22 +03:00
|
|
|
mLegacySyntax != aOther.mLegacySyntax ||
|
2009-11-02 22:36:43 +03:00
|
|
|
mBgPosX != aOther.mBgPosX ||
|
|
|
|
mBgPosY != aOther.mBgPosY ||
|
2012-07-07 18:27:08 +04:00
|
|
|
mAngle != aOther.mAngle ||
|
|
|
|
mRadiusX != aOther.mRadiusX ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mRadiusY != aOther.mRadiusY) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-01 19:53:40 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mStops.Length() != aOther.mStops.Length()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-01 19:53:40 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < mStops.Length(); i++) {
|
2014-10-22 16:24:00 +04:00
|
|
|
const auto& stop1 = mStops[i];
|
|
|
|
const auto& stop2 = aOther.mStops[i];
|
|
|
|
if (stop1.mLocation != stop2.mLocation ||
|
|
|
|
stop1.mIsInterpolationHint != stop2.mIsInterpolationHint ||
|
2016-07-06 08:06:13 +03:00
|
|
|
(!stop1.mIsInterpolationHint && stop1.mColor != stop2.mColor)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-01 19:53:40 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-08-01 19:53:40 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleGradient::nsStyleGradient()
|
2009-11-02 22:36:43 +03:00
|
|
|
: mShape(NS_STYLE_GRADIENT_SHAPE_LINEAR)
|
|
|
|
, mSize(NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER)
|
2011-10-17 18:59:28 +04:00
|
|
|
, mRepeating(false)
|
2015-07-15 17:37:22 +03:00
|
|
|
, mLegacySyntax(false)
|
2009-08-01 19:53:40 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-01-03 04:48:09 +03:00
|
|
|
nsStyleGradient::IsOpaque()
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < mStops.Length(); i++) {
|
2016-07-06 08:06:13 +03:00
|
|
|
if (NS_GET_A(mStops[i].mColor) < 255) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2011-01-03 04:48:09 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-01-03 04:48:09 +03:00
|
|
|
}
|
|
|
|
|
2012-08-27 08:09:46 +04:00
|
|
|
bool
|
|
|
|
nsStyleGradient::HasCalc()
|
|
|
|
{
|
2012-10-04 09:31:56 +04:00
|
|
|
for (uint32_t i = 0; i < mStops.Length(); i++) {
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mStops[i].mLocation.IsCalcUnit()) {
|
2012-10-04 09:31:56 +04:00
|
|
|
return true;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2012-10-04 09:31:56 +04:00
|
|
|
}
|
2012-08-27 08:09:46 +04:00
|
|
|
return mBgPosX.IsCalcUnit() || mBgPosY.IsCalcUnit() || mAngle.IsCalcUnit() ||
|
2014-02-17 04:05:10 +04:00
|
|
|
mRadiusX.IsCalcUnit() || mRadiusY.IsCalcUnit();
|
2012-08-27 08:09:46 +04:00
|
|
|
}
|
|
|
|
|
2016-08-01 03:23:00 +03:00
|
|
|
// --------------------
|
|
|
|
// CachedBorderImageData
|
|
|
|
//
|
2016-08-01 03:24:00 +03:00
|
|
|
void
|
|
|
|
CachedBorderImageData::SetCachedSVGViewportSize(
|
|
|
|
const mozilla::Maybe<nsSize>& aSVGViewportSize)
|
|
|
|
{
|
|
|
|
mCachedSVGViewportSize = aSVGViewportSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
const mozilla::Maybe<nsSize>&
|
|
|
|
CachedBorderImageData::GetCachedSVGViewportSize()
|
|
|
|
{
|
|
|
|
return mCachedSVGViewportSize;
|
|
|
|
}
|
|
|
|
|
2016-08-01 03:23:00 +03:00
|
|
|
void
|
|
|
|
CachedBorderImageData::PurgeCachedImages()
|
|
|
|
{
|
|
|
|
mSubImages.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CachedBorderImageData::SetSubImage(uint8_t aIndex, imgIContainer* aSubImage)
|
|
|
|
{
|
|
|
|
mSubImages.ReplaceObjectAt(aSubImage, aIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
imgIContainer*
|
|
|
|
CachedBorderImageData::GetSubImage(uint8_t aIndex)
|
|
|
|
{
|
|
|
|
imgIContainer* subImage = nullptr;
|
|
|
|
if (aIndex < mSubImages.Count())
|
|
|
|
subImage = mSubImages[aIndex];
|
|
|
|
return subImage;
|
|
|
|
}
|
|
|
|
|
2009-08-22 00:39:25 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleImage
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleImage::nsStyleImage()
|
|
|
|
: mType(eStyleImageType_Null)
|
2012-07-30 18:20:58 +04:00
|
|
|
, mCropRect(nullptr)
|
2010-08-06 01:57:18 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
, mImageTracked(false)
|
|
|
|
#endif
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleImage::~nsStyleImage()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleImage);
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != eStyleImageType_Null) {
|
2009-08-22 00:39:25 +04:00
|
|
|
SetNull();
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleImage::nsStyleImage(const nsStyleImage& aOther)
|
|
|
|
: mType(eStyleImageType_Null)
|
2012-07-30 18:20:58 +04:00
|
|
|
, mCropRect(nullptr)
|
2010-08-06 01:57:18 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
, mImageTracked(false)
|
|
|
|
#endif
|
2009-08-22 00:39:25 +04: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)
|
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (this != &aOther) {
|
2009-08-22 00:39:25 +04:00
|
|
|
DoCopy(aOther);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImage::DoCopy(const nsStyleImage& aOther)
|
|
|
|
{
|
|
|
|
SetNull();
|
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (aOther.mType == eStyleImageType_Image) {
|
2009-08-22 00:39:25 +04:00
|
|
|
SetImageData(aOther.mImage);
|
2016-07-06 08:06:13 +03:00
|
|
|
} else if (aOther.mType == eStyleImageType_Gradient) {
|
2009-08-22 00:39:25 +04:00
|
|
|
SetGradientData(aOther.mGradient);
|
2016-07-06 08:06:13 +03:00
|
|
|
} else if (aOther.mType == eStyleImageType_Element) {
|
2010-08-13 17:33:37 +04:00
|
|
|
SetElementId(aOther.mElementId);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-29 01:06:02 +03:00
|
|
|
UniquePtr<nsStyleSides> cropRectCopy;
|
|
|
|
if (aOther.mCropRect) {
|
|
|
|
cropRectCopy = MakeUnique<nsStyleSides>(*aOther.mCropRect.get());
|
|
|
|
}
|
|
|
|
SetCropRect(Move(cropRectCopy));
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImage::SetNull()
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mImageTracked,
|
|
|
|
"Calling SetNull() with image tracked!");
|
2010-08-06 01:57:18 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType == eStyleImageType_Gradient) {
|
2009-08-22 00:39:25 +04:00
|
|
|
mGradient->Release();
|
2016-07-06 08:06:13 +03:00
|
|
|
} else if (mType == eStyleImageType_Image) {
|
2009-08-22 00:39:25 +04:00
|
|
|
NS_RELEASE(mImage);
|
2016-07-06 08:06:13 +03:00
|
|
|
} else if (mType == eStyleImageType_Element) {
|
2015-04-01 08:29:55 +03:00
|
|
|
free(mElementId);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
mType = eStyleImageType_Null;
|
2012-07-30 18:20:58 +04:00
|
|
|
mCropRect = nullptr;
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-07-29 18:56:39 +04:00
|
|
|
nsStyleImage::SetImageData(imgRequestProxy* aImage)
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mImageTracked,
|
|
|
|
"Setting a new image without untracking the old one!");
|
2010-08-06 01:57:18 +04:00
|
|
|
|
2009-08-22 00:39:25 +04:00
|
|
|
NS_IF_ADDREF(aImage);
|
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != eStyleImageType_Null) {
|
2009-08-22 00:39:25 +04:00
|
|
|
SetNull();
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
if (aImage) {
|
|
|
|
mImage = aImage;
|
|
|
|
mType = eStyleImageType_Image;
|
|
|
|
}
|
2016-08-01 03:23:00 +03:00
|
|
|
if (mCachedBIData) {
|
|
|
|
mCachedBIData->PurgeCachedImages();
|
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
2010-08-06 01:57:18 +04:00
|
|
|
void
|
|
|
|
nsStyleImage::TrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mImageTracked, "Already tracking image!");
|
|
|
|
MOZ_ASSERT(mType == eStyleImageType_Image,
|
|
|
|
"Can't track image when there isn't one!");
|
2010-08-06 01:57:18 +04:00
|
|
|
|
|
|
|
// Register the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
2016-07-06 08:06:13 +03:00
|
|
|
if (doc) {
|
2010-08-06 01:57:18 +04:00
|
|
|
doc->AddImage(mImage);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2010-08-06 01:57:18 +04:00
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImage::UntrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mImageTracked, "Image not tracked!");
|
|
|
|
MOZ_ASSERT(mType == eStyleImageType_Image,
|
|
|
|
"Can't untrack image when there isn't one!");
|
2010-08-06 01:57:18 +04:00
|
|
|
|
|
|
|
// Unregister the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
2016-07-06 08:06:13 +03:00
|
|
|
if (doc) {
|
2016-07-19 08:29:21 +03:00
|
|
|
doc->RemoveImage(mImage);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2010-08-06 01:57:18 +04:00
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-08-22 00:39:25 +04:00
|
|
|
void
|
|
|
|
nsStyleImage::SetGradientData(nsStyleGradient* aGradient)
|
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (aGradient) {
|
2009-08-22 00:39:25 +04:00
|
|
|
aGradient->AddRef();
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != eStyleImageType_Null) {
|
2009-08-22 00:39:25 +04:00
|
|
|
SetNull();
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
if (aGradient) {
|
|
|
|
mGradient = aGradient;
|
|
|
|
mType = eStyleImageType_Gradient;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-13 17:33:37 +04:00
|
|
|
void
|
2014-01-04 19:02:17 +04:00
|
|
|
nsStyleImage::SetElementId(const char16_t* aElementId)
|
2010-08-13 17:33:37 +04:00
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != eStyleImageType_Null) {
|
2010-08-13 17:33:37 +04:00
|
|
|
SetNull();
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2010-08-13 17:33:37 +04:00
|
|
|
|
|
|
|
if (aElementId) {
|
2011-06-21 09:03:59 +04:00
|
|
|
mElementId = NS_strdup(aElementId);
|
2010-08-13 17:33:37 +04:00
|
|
|
mType = eStyleImageType_Element;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-22 00:39:25 +04:00
|
|
|
void
|
2016-07-29 01:06:02 +03:00
|
|
|
nsStyleImage::SetCropRect(UniquePtr<nsStyleSides> aCropRect)
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
2016-07-29 01:06:02 +03:00
|
|
|
mCropRect = Move(aCropRect);
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t
|
|
|
|
ConvertToPixelCoord(const nsStyleCoord& aCoord, int32_t aPercentScale)
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(pixelValue >= 0, "we ensured non-negative while parsing");
|
2013-01-15 16:22:03 +04:00
|
|
|
pixelValue = std::min(pixelValue, double(INT32_MAX)); // avoid overflow
|
2009-08-22 00:39:25 +04:00
|
|
|
return NS_lround(pixelValue);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-08-22 00:39:25 +04:00
|
|
|
nsStyleImage::ComputeActualCropRect(nsIntRect& aActualCropRect,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* aIsEntireImage) const
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != eStyleImageType_Image) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
nsCOMPtr<imgIContainer> imageContainer;
|
|
|
|
mImage->GetImage(getter_AddRefs(imageContainer));
|
2016-07-06 08:06:13 +03:00
|
|
|
if (!imageContainer) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
nsIntSize imageSize;
|
|
|
|
imageContainer->GetWidth(&imageSize.width);
|
|
|
|
imageContainer->GetHeight(&imageSize.height);
|
2016-07-06 08:06:13 +03:00
|
|
|
if (imageSize.width <= 0 || imageSize.height <= 0) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t left = ConvertToPixelCoord(mCropRect->GetLeft(), imageSize.width);
|
|
|
|
int32_t top = ConvertToPixelCoord(mCropRect->GetTop(), imageSize.height);
|
|
|
|
int32_t right = ConvertToPixelCoord(mCropRect->GetRight(), imageSize.width);
|
|
|
|
int32_t bottom = ConvertToPixelCoord(mCropRect->GetBottom(), imageSize.height);
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (aIsEntireImage) {
|
2011-04-19 07:07:23 +04:00
|
|
|
*aIsEntireImage = aActualCropRect.IsEqualInterior(imageRect);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
2009-09-13 02:44:18 +04:00
|
|
|
nsresult
|
2012-10-13 00:04:03 +04:00
|
|
|
nsStyleImage::StartDecoding() const
|
2009-09-13 02:44:18 +04:00
|
|
|
{
|
2016-08-15 04:57:13 +03:00
|
|
|
if (mType == eStyleImageType_Image) {
|
2012-10-05 00:02:15 +04:00
|
|
|
return mImage->StartDecoding();
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-09-13 02:44:18 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-08-22 00:39:25 +04:00
|
|
|
nsStyleImage::IsOpaque() const
|
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (!IsComplete()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType == eStyleImageType_Gradient) {
|
2011-01-03 04:48:09 +03:00
|
|
|
return mGradient->IsOpaque();
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType == eStyleImageType_Element) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2010-08-13 17:33:37 +04:00
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mType == eStyleImageType_Image, "unexpected image type");
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
nsCOMPtr<imgIContainer> imageContainer;
|
|
|
|
mImage->GetImage(getter_AddRefs(imageContainer));
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(imageContainer, "IsComplete() said image container is ready");
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2014-11-25 10:42:43 +03:00
|
|
|
// Check if the crop region of the image is opaque.
|
2016-08-23 05:15:38 +03:00
|
|
|
if (imageContainer->WillDrawOpaqueNow()) {
|
2016-07-06 08:06:13 +03:00
|
|
|
if (!mCropRect) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
// Must make sure if mCropRect contains at least a pixel.
|
2011-10-17 18:59:28 +04:00
|
|
|
// XXX Is this optimization worth it? Maybe I should just return false.
|
2009-08-22 00:39:25 +04:00
|
|
|
nsIntRect actualCropRect;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool rv = ComputeActualCropRect(actualCropRect);
|
2009-08-22 00:39:25 +04:00
|
|
|
NS_ASSERTION(rv, "ComputeActualCropRect() can not fail here");
|
|
|
|
return rv && !actualCropRect.IsEmpty();
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-08-22 00:39:25 +04:00
|
|
|
nsStyleImage::IsComplete() const
|
|
|
|
{
|
|
|
|
switch (mType) {
|
|
|
|
case eStyleImageType_Null:
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-22 00:39:25 +04:00
|
|
|
case eStyleImageType_Gradient:
|
2010-08-13 17:33:37 +04:00
|
|
|
case eStyleImageType_Element:
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-08-22 00:39:25 +04:00
|
|
|
case eStyleImageType_Image:
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t status = imgIRequest::STATUS_ERROR;
|
2009-08-22 00:39:25 +04:00
|
|
|
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 18:59:28 +04:00
|
|
|
return false;
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-19 12:40:02 +04:00
|
|
|
bool
|
|
|
|
nsStyleImage::IsLoaded() const
|
|
|
|
{
|
|
|
|
switch (mType) {
|
|
|
|
case eStyleImageType_Null:
|
|
|
|
return false;
|
|
|
|
case eStyleImageType_Gradient:
|
|
|
|
case eStyleImageType_Element:
|
|
|
|
return true;
|
|
|
|
case eStyleImageType_Image:
|
|
|
|
{
|
|
|
|
uint32_t status = imgIRequest::STATUS_ERROR;
|
|
|
|
return NS_SUCCEEDED(mImage->GetImageStatus(&status)) &&
|
|
|
|
!(status & imgIRequest::STATUS_ERROR) &&
|
|
|
|
(status & imgIRequest::STATUS_LOAD_COMPLETE);
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unexpected image type");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static inline bool
|
2016-07-29 01:06:02 +03:00
|
|
|
EqualRects(const UniquePtr<nsStyleSides>& aRect1, const UniquePtr<nsStyleSides>& aRect2)
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
|
|
|
return aRect1 == aRect2 || /* handles null== null, and optimize */
|
|
|
|
(aRect1 && aRect2 && *aRect1 == *aRect2);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-08-22 00:39:25 +04:00
|
|
|
nsStyleImage::operator==(const nsStyleImage& aOther) const
|
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != aOther.mType) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (!EqualRects(mCropRect, aOther.mCropRect)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType == eStyleImageType_Image) {
|
2009-08-22 00:39:25 +04:00
|
|
|
return EqualImages(mImage, aOther.mImage);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType == eStyleImageType_Gradient) {
|
2009-08-22 00:39:25 +04:00
|
|
|
return *mGradient == *aOther.mGradient;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType == eStyleImageType_Element) {
|
2011-06-21 09:03:59 +04:00
|
|
|
return NS_strcmp(mElementId, aOther.mElementId) == 0;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2010-08-13 17:33:37 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
2016-08-01 03:24:00 +03:00
|
|
|
void
|
|
|
|
nsStyleImage::PurgeCacheForViewportChange(
|
|
|
|
const mozilla::Maybe<nsSize>& aSVGViewportSize,
|
|
|
|
const bool aHasIntrinsicRatio) const
|
|
|
|
{
|
|
|
|
EnsureCachedBIData();
|
|
|
|
|
|
|
|
// If we're redrawing with a different viewport-size than we used for our
|
|
|
|
// cached subimages, then we can't trust that our subimages are valid;
|
|
|
|
// any percent sizes/positions in our SVG doc may be different now. Purge!
|
|
|
|
// (We don't have to purge if the SVG document has an intrinsic ratio,
|
|
|
|
// though, because the actual size of elements in SVG documant's coordinate
|
|
|
|
// axis are fixed in this case.)
|
|
|
|
if (aSVGViewportSize != mCachedBIData->GetCachedSVGViewportSize() &&
|
|
|
|
!aHasIntrinsicRatio) {
|
|
|
|
mCachedBIData->PurgeCachedImages();
|
|
|
|
mCachedBIData->SetCachedSVGViewportSize(aSVGViewportSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
2016-01-28 08:24:00 +03:00
|
|
|
// nsStyleImageLayers
|
2001-06-01 02:19:43 +04:00
|
|
|
//
|
|
|
|
|
2016-08-17 04:37:48 +03:00
|
|
|
const nsCSSPropertyID nsStyleImageLayers::kBackgroundLayerTable[] = {
|
2016-01-28 08:28:00 +03:00
|
|
|
eCSSProperty_background, // shorthand
|
|
|
|
eCSSProperty_background_color, // color
|
|
|
|
eCSSProperty_background_image, // image
|
|
|
|
eCSSProperty_background_repeat, // repeat
|
2016-04-29 21:12:10 +03:00
|
|
|
eCSSProperty_background_position_x, // positionX
|
|
|
|
eCSSProperty_background_position_y, // positionY
|
2016-01-28 08:28:00 +03:00
|
|
|
eCSSProperty_background_clip, // clip
|
|
|
|
eCSSProperty_background_origin, // origin
|
|
|
|
eCSSProperty_background_size, // size
|
|
|
|
eCSSProperty_background_attachment, // attachment
|
|
|
|
eCSSProperty_UNKNOWN, // maskMode
|
|
|
|
eCSSProperty_UNKNOWN // composite
|
|
|
|
};
|
|
|
|
|
2016-03-01 14:52:17 +03:00
|
|
|
#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
|
2016-08-17 04:37:48 +03:00
|
|
|
const nsCSSPropertyID nsStyleImageLayers::kMaskLayerTable[] = {
|
2016-01-28 08:28:00 +03:00
|
|
|
eCSSProperty_mask, // shorthand
|
|
|
|
eCSSProperty_UNKNOWN, // color
|
|
|
|
eCSSProperty_mask_image, // image
|
|
|
|
eCSSProperty_mask_repeat, // repeat
|
2016-04-29 21:12:10 +03:00
|
|
|
eCSSProperty_mask_position_x, // positionX
|
|
|
|
eCSSProperty_mask_position_y, // positionY
|
2016-01-28 08:28:00 +03:00
|
|
|
eCSSProperty_mask_clip, // clip
|
|
|
|
eCSSProperty_mask_origin, // origin
|
|
|
|
eCSSProperty_mask_size, // size
|
|
|
|
eCSSProperty_UNKNOWN, // attachment
|
|
|
|
eCSSProperty_mask_mode, // maskMode
|
|
|
|
eCSSProperty_mask_composite // composite
|
|
|
|
};
|
2016-03-01 14:52:17 +03:00
|
|
|
#endif
|
2016-01-28 08:28:00 +03:00
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsStyleImageLayers::nsStyleImageLayers(nsStyleImageLayers::LayerType aType)
|
2009-02-20 08:29:21 +03:00
|
|
|
: mAttachmentCount(1)
|
|
|
|
, mClipCount(1)
|
|
|
|
, mOriginCount(1)
|
|
|
|
, mRepeatCount(1)
|
2016-04-29 21:12:10 +03:00
|
|
|
, mPositionXCount(1)
|
|
|
|
, mPositionYCount(1)
|
2009-02-20 08:29:21 +03:00
|
|
|
, mImageCount(1)
|
2009-05-28 22:09:05 +04:00
|
|
|
, mSizeCount(1)
|
2016-01-28 08:28:00 +03:00
|
|
|
, mMaskModeCount(1)
|
2013-11-08 19:07:36 +04:00
|
|
|
, mBlendModeCount(1)
|
2016-01-28 08:28:00 +03:00
|
|
|
, mCompositeCount(1)
|
2016-04-19 02:51:16 +03:00
|
|
|
, mLayers(nsStyleAutoArray<Layer>::WITH_SINGLE_INITIAL_ELEMENT)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-01-28 08:24:00 +03:00
|
|
|
MOZ_COUNT_CTOR(nsStyleImageLayers);
|
2016-06-03 18:56:54 +03:00
|
|
|
|
|
|
|
// Ensure first layer is initialized as specified layer type
|
|
|
|
mLayers[0].Initialize(aType);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::nsStyleImageLayers(const nsStyleImageLayers &aSource)
|
2009-02-20 08:29:21 +03:00
|
|
|
: mAttachmentCount(aSource.mAttachmentCount)
|
|
|
|
, mClipCount(aSource.mClipCount)
|
|
|
|
, mOriginCount(aSource.mOriginCount)
|
|
|
|
, mRepeatCount(aSource.mRepeatCount)
|
2016-04-29 21:12:10 +03:00
|
|
|
, mPositionXCount(aSource.mPositionXCount)
|
|
|
|
, mPositionYCount(aSource.mPositionYCount)
|
2009-02-20 08:29:21 +03:00
|
|
|
, mImageCount(aSource.mImageCount)
|
2009-05-28 22:09:05 +04:00
|
|
|
, mSizeCount(aSource.mSizeCount)
|
2016-01-28 08:28:00 +03:00
|
|
|
, mMaskModeCount(aSource.mMaskModeCount)
|
2013-11-08 19:07:36 +04:00
|
|
|
, mBlendModeCount(aSource.mBlendModeCount)
|
2016-01-28 08:28:00 +03:00
|
|
|
, mCompositeCount(aSource.mCompositeCount)
|
2009-02-20 08:29:21 +03:00
|
|
|
, mLayers(aSource.mLayers) // deep copy
|
|
|
|
{
|
2016-01-28 08:24:00 +03:00
|
|
|
MOZ_COUNT_CTOR(nsStyleImageLayers);
|
2009-02-20 08:29:21 +03:00
|
|
|
// If the deep copy of mLayers failed, truncate the counts.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t count = mLayers.Length();
|
2009-02-20 08:29:21 +03:00
|
|
|
if (count != aSource.mLayers.Length()) {
|
|
|
|
NS_WARNING("truncating counts due to out-of-memory");
|
2013-01-15 16:22:03 +04:00
|
|
|
mAttachmentCount = std::max(mAttachmentCount, count);
|
|
|
|
mClipCount = std::max(mClipCount, count);
|
|
|
|
mOriginCount = std::max(mOriginCount, count);
|
|
|
|
mRepeatCount = std::max(mRepeatCount, count);
|
2016-04-29 21:12:10 +03:00
|
|
|
mPositionXCount = std::max(mPositionXCount, count);
|
|
|
|
mPositionYCount = std::max(mPositionYCount, count);
|
2013-01-15 16:22:03 +04:00
|
|
|
mImageCount = std::max(mImageCount, count);
|
|
|
|
mSizeCount = std::max(mSizeCount, count);
|
2016-01-28 08:28:00 +03:00
|
|
|
mMaskModeCount = std::max(mMaskModeCount, count);
|
2016-01-28 08:24:00 +03:00
|
|
|
mBlendModeCount = std::max(mBlendModeCount, count);
|
2016-01-28 08:28:00 +03:00
|
|
|
mCompositeCount = std::max(mCompositeCount, count);
|
2009-02-20 08:29:21 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-01-28 08:28:00 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleImageLayers::CalcDifference(const nsStyleImageLayers& aNewLayers,
|
2016-09-22 13:24:52 +03:00
|
|
|
nsStyleImageLayers::LayerType aType) const
|
2016-01-28 08:28:00 +03:00
|
|
|
{
|
2016-09-22 13:24:52 +03:00
|
|
|
nsChangeHint positionChangeHint =
|
|
|
|
(aType == nsStyleImageLayers::LayerType::Background)
|
|
|
|
? nsChangeHint_UpdateBackgroundPosition
|
|
|
|
: nsChangeHint_RepaintFrame;
|
|
|
|
|
2016-01-28 08:28:00 +03:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
|
|
|
const nsStyleImageLayers& moreLayers =
|
2016-06-21 04:47:54 +03:00
|
|
|
mImageCount > aNewLayers.mImageCount ?
|
|
|
|
*this : aNewLayers;
|
2016-01-28 08:28:00 +03:00
|
|
|
const nsStyleImageLayers& lessLayers =
|
2016-06-21 04:47:54 +03:00
|
|
|
mImageCount > aNewLayers.mImageCount ?
|
|
|
|
aNewLayers : *this;
|
2016-01-28 08:28:00 +03:00
|
|
|
|
|
|
|
NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(i, moreLayers) {
|
|
|
|
if (i < lessLayers.mImageCount) {
|
|
|
|
nsChangeHint layerDifference =
|
2016-06-14 14:36:01 +03:00
|
|
|
moreLayers.mLayers[i].CalcDifference(lessLayers.mLayers[i],
|
2016-09-22 13:24:52 +03:00
|
|
|
positionChangeHint);
|
2016-01-28 08:28:00 +03:00
|
|
|
hint |= layerDifference;
|
|
|
|
if (layerDifference &&
|
|
|
|
((moreLayers.mLayers[i].mImage.GetType() == eStyleImageType_Element) ||
|
|
|
|
(lessLayers.mLayers[i].mImage.GetType() == eStyleImageType_Element))) {
|
|
|
|
hint |= nsChangeHint_UpdateEffects | nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
if (moreLayers.mLayers[i].mImage.GetType() == eStyleImageType_Element) {
|
|
|
|
hint |= nsChangeHint_UpdateEffects | nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-22 13:24:52 +03:00
|
|
|
if (aType == nsStyleImageLayers::LayerType::Mask &&
|
|
|
|
mImageCount != aNewLayers.mImageCount) {
|
|
|
|
hint |= nsChangeHint_UpdateEffects;
|
|
|
|
}
|
|
|
|
|
2016-01-28 08:28:00 +03:00
|
|
|
if (hint) {
|
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mAttachmentCount != aNewLayers.mAttachmentCount ||
|
|
|
|
mBlendModeCount != aNewLayers.mBlendModeCount ||
|
|
|
|
mClipCount != aNewLayers.mClipCount ||
|
|
|
|
mCompositeCount != aNewLayers.mCompositeCount ||
|
|
|
|
mMaskModeCount != aNewLayers.mMaskModeCount ||
|
|
|
|
mOriginCount != aNewLayers.mOriginCount ||
|
|
|
|
mRepeatCount != aNewLayers.mRepeatCount ||
|
|
|
|
mPositionXCount != aNewLayers.mPositionXCount ||
|
|
|
|
mPositionYCount != aNewLayers.mPositionYCount ||
|
|
|
|
mSizeCount != aNewLayers.mSizeCount) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2016-01-28 08:28:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsStyleImageLayers::HasLayerWithImage() const
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < mImageCount; i++) {
|
2016-03-02 11:27:21 +03:00
|
|
|
// mLayers[i].mSourceURI can be nullptr if mask-image prop value is
|
|
|
|
// <element-reference> or <gradient>
|
|
|
|
// mLayers[i].mImage can be empty if mask-image prop value is a reference
|
|
|
|
// to SVG mask element.
|
|
|
|
// So we need to test both mSourceURI and mImage.
|
2016-08-06 01:38:44 +03:00
|
|
|
if (mLayers[i].mSourceURI.GetSourceURL() || !mLayers[i].mImage.IsEmpty()) {
|
2016-01-28 08:28:00 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2016-08-25 12:59:51 +03:00
|
|
|
nsStyleImageLayers::IsInitialPositionForLayerType(Position aPosition, LayerType aType)
|
|
|
|
{
|
|
|
|
float intialValue = nsStyleImageLayers::GetInitialPositionForLayerType(aType);
|
|
|
|
if (aPosition.mXPosition.mPercent == intialValue &&
|
|
|
|
aPosition.mXPosition.mLength == 0 &&
|
|
|
|
aPosition.mXPosition.mHasPercent &&
|
|
|
|
aPosition.mYPosition.mPercent == intialValue &&
|
|
|
|
aPosition.mYPosition.mLength == 0 &&
|
|
|
|
aPosition.mYPosition.mHasPercent) {
|
2016-08-15 10:33:03 +03:00
|
|
|
return true;
|
2016-01-28 08:28:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-08-06 01:57:18 +04:00
|
|
|
void
|
2016-08-25 12:59:51 +03:00
|
|
|
Position::SetInitialPercentValues(float aPercentVal)
|
2009-02-20 08:29:21 +03:00
|
|
|
{
|
2014-09-09 22:40:18 +04:00
|
|
|
mXPosition.mPercent = aPercentVal;
|
2010-09-15 19:11:26 +04:00
|
|
|
mXPosition.mLength = 0;
|
2011-10-17 18:59:28 +04:00
|
|
|
mXPosition.mHasPercent = true;
|
2014-09-09 22:40:18 +04:00
|
|
|
mYPosition.mPercent = aPercentVal;
|
2010-09-15 19:11:26 +04:00
|
|
|
mYPosition.mLength = 0;
|
2011-10-17 18:59:28 +04:00
|
|
|
mYPosition.mHasPercent = true;
|
2009-02-20 08:29:21 +03:00
|
|
|
}
|
|
|
|
|
2014-02-04 05:54:22 +04:00
|
|
|
void
|
2016-08-25 12:59:51 +03:00
|
|
|
Position::SetInitialZeroValues()
|
2014-02-04 05:54:22 +04:00
|
|
|
{
|
|
|
|
mXPosition.mPercent = 0;
|
|
|
|
mXPosition.mLength = 0;
|
|
|
|
mXPosition.mHasPercent = false;
|
|
|
|
mYPosition.mPercent = 0;
|
|
|
|
mYPosition.mLength = 0;
|
|
|
|
mYPosition.mHasPercent = false;
|
|
|
|
}
|
|
|
|
|
2011-01-13 13:40:12 +03:00
|
|
|
bool
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::Size::DependsOnPositioningAreaSize(const nsStyleImage& aImage) const
|
2011-01-13 13:40:12 +03:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aImage.GetType() != eStyleImageType_Null,
|
|
|
|
"caller should have handled this");
|
2011-01-13 13:40:12 +03:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT((mWidthType == eLengthPercentage && mHeightType == eAuto) ||
|
|
|
|
(mWidthType == eAuto && mHeightType == eLengthPercentage) ||
|
|
|
|
(mWidthType == eAuto && mHeightType == eAuto),
|
|
|
|
"logic error");
|
2011-01-13 13:40:12 +03:00
|
|
|
|
|
|
|
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) {
|
2015-03-30 18:35:47 +03:00
|
|
|
CSSIntSize imageSize;
|
2011-01-13 13:40:12 +03:00
|
|
|
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 22:09:05 +04:00
|
|
|
void
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::Size::SetInitialValues()
|
2009-05-28 22:09:05 +04:00
|
|
|
{
|
|
|
|
mWidthType = mHeightType = eAuto;
|
|
|
|
}
|
|
|
|
|
2010-09-15 19:11:26 +04:00
|
|
|
bool
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::Size::operator==(const Size& aOther) const
|
2009-05-28 22:09:05 +04:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mWidthType < eDimensionType_COUNT,
|
|
|
|
"bad mWidthType for this");
|
|
|
|
MOZ_ASSERT(mHeightType < eDimensionType_COUNT,
|
|
|
|
"bad mHeightType for this");
|
|
|
|
MOZ_ASSERT(aOther.mWidthType < eDimensionType_COUNT,
|
|
|
|
"bad mWidthType for aOther");
|
|
|
|
MOZ_ASSERT(aOther.mHeightType < eDimensionType_COUNT,
|
|
|
|
"bad mHeightType for aOther");
|
2009-05-28 22:09:05 +04:00
|
|
|
|
2010-09-15 19:11:26 +04:00
|
|
|
return mWidthType == aOther.mWidthType &&
|
|
|
|
mHeightType == aOther.mHeightType &&
|
|
|
|
(mWidthType != eLengthPercentage || mWidth == aOther.mWidth) &&
|
|
|
|
(mHeightType != eLengthPercentage || mHeight == aOther.mHeight);
|
2009-05-28 22:09:05 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
bool
|
|
|
|
nsStyleImageLayers::Repeat::IsInitialValue(LayerType aType) const
|
|
|
|
{
|
2016-07-18 12:02:58 +03:00
|
|
|
if (aType == LayerType::Background) {
|
2016-06-03 18:56:54 +03:00
|
|
|
return mXRepeat == NS_STYLE_IMAGELAYER_REPEAT_REPEAT &&
|
|
|
|
mYRepeat == NS_STYLE_IMAGELAYER_REPEAT_REPEAT;
|
2016-07-18 12:02:58 +03:00
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(aType == LayerType::Mask);
|
|
|
|
return mXRepeat == NS_STYLE_IMAGELAYER_REPEAT_NO_REPEAT &&
|
|
|
|
mYRepeat == NS_STYLE_IMAGELAYER_REPEAT_NO_REPEAT;
|
2016-06-03 18:56:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-25 09:23:14 +04:00
|
|
|
void
|
2016-06-03 18:56:54 +03:00
|
|
|
nsStyleImageLayers::Repeat::SetInitialValues(LayerType aType)
|
2012-02-25 09:23:14 +04:00
|
|
|
{
|
2016-07-18 12:02:58 +03:00
|
|
|
if (aType == LayerType::Background) {
|
2016-06-03 18:56:54 +03:00
|
|
|
mXRepeat = NS_STYLE_IMAGELAYER_REPEAT_REPEAT;
|
|
|
|
mYRepeat = NS_STYLE_IMAGELAYER_REPEAT_REPEAT;
|
|
|
|
} else {
|
2016-07-18 12:02:58 +03:00
|
|
|
MOZ_ASSERT(aType == LayerType::Mask);
|
|
|
|
|
|
|
|
mXRepeat = NS_STYLE_IMAGELAYER_REPEAT_NO_REPEAT;
|
|
|
|
mYRepeat = NS_STYLE_IMAGELAYER_REPEAT_NO_REPEAT;
|
2016-06-03 18:56:54 +03:00
|
|
|
}
|
2012-02-25 09:23:14 +04:00
|
|
|
}
|
|
|
|
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::Layer::Layer()
|
2016-06-03 18:56:54 +03:00
|
|
|
: mClip(NS_STYLE_IMAGELAYER_CLIP_BORDER)
|
|
|
|
, mAttachment(NS_STYLE_IMAGELAYER_ATTACHMENT_SCROLL)
|
|
|
|
, mBlendMode(NS_STYLE_BLEND_NORMAL)
|
|
|
|
, mComposite(NS_STYLE_MASK_COMPOSITE_ADD)
|
|
|
|
, mMaskMode(NS_STYLE_MASK_MODE_MATCH_SOURCE)
|
2009-02-20 08:29:21 +03:00
|
|
|
{
|
2016-01-28 08:24:00 +03:00
|
|
|
mImage.SetNull();
|
|
|
|
mSize.SetInitialValues();
|
2009-02-20 08:29:21 +03:00
|
|
|
}
|
|
|
|
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::Layer::~Layer()
|
2009-02-20 08:29:21 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
void
|
|
|
|
nsStyleImageLayers::Layer::Initialize(nsStyleImageLayers::LayerType aType)
|
|
|
|
{
|
|
|
|
mRepeat.SetInitialValues(aType);
|
|
|
|
|
2016-08-15 10:33:03 +03:00
|
|
|
float initialPositionValue =
|
2016-08-25 12:59:51 +03:00
|
|
|
nsStyleImageLayers::GetInitialPositionForLayerType(aType);
|
2016-08-15 10:33:03 +03:00
|
|
|
mPosition.SetInitialPercentValues(initialPositionValue);
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
if (aType == LayerType::Background) {
|
|
|
|
mOrigin = NS_STYLE_IMAGELAYER_ORIGIN_PADDING;
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(aType == LayerType::Mask, "unsupported layer type.");
|
|
|
|
mOrigin = NS_STYLE_IMAGELAYER_ORIGIN_BORDER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::Layer::RenderingMightDependOnPositioningAreaSizeChange() const
|
2010-10-07 02:18:52 +04:00
|
|
|
{
|
2010-10-07 02:18:52 +04:00
|
|
|
// Do we even have an image?
|
|
|
|
if (mImage.IsEmpty()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-10-07 02:18:52 +04:00
|
|
|
}
|
|
|
|
|
2012-11-08 19:05:32 +04:00
|
|
|
return mPosition.DependsOnPositioningAreaSize() ||
|
2016-06-02 03:09:00 +03:00
|
|
|
mSize.DependsOnPositioningAreaSize(mImage) ||
|
|
|
|
mRepeat.DependsOnPositioningAreaSize();
|
2010-10-07 02:18:52 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::Layer::operator==(const Layer& aOther) const
|
2009-02-20 08:29:21 +03:00
|
|
|
{
|
|
|
|
return mAttachment == aOther.mAttachment &&
|
|
|
|
mClip == aOther.mClip &&
|
|
|
|
mOrigin == aOther.mOrigin &&
|
|
|
|
mRepeat == aOther.mRepeat &&
|
2013-11-08 19:07:36 +04:00
|
|
|
mBlendMode == aOther.mBlendMode &&
|
2009-02-20 08:29:21 +03:00
|
|
|
mPosition == aOther.mPosition &&
|
2009-05-28 22:09:05 +04:00
|
|
|
mSize == aOther.mSize &&
|
2016-01-28 08:28:00 +03:00
|
|
|
mImage == aOther.mImage &&
|
|
|
|
mMaskMode == aOther.mMaskMode &&
|
2016-01-28 08:37:00 +03:00
|
|
|
mComposite == aOther.mComposite &&
|
2016-08-06 01:38:44 +03:00
|
|
|
mSourceURI == aOther.mSourceURI;
|
2009-08-01 19:53:40 +04:00
|
|
|
}
|
|
|
|
|
2015-11-02 19:36:35 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleImageLayers::Layer::CalcDifference(const nsStyleImageLayers::Layer& aNewLayer,
|
2016-06-14 14:36:01 +03:00
|
|
|
nsChangeHint aPositionChangeHint) const
|
2015-11-02 19:36:35 +03:00
|
|
|
{
|
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
2016-08-06 01:38:44 +03:00
|
|
|
if (mSourceURI != aNewLayer.mSourceURI) {
|
2016-09-22 13:24:52 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame | nsChangeHint_UpdateEffects;
|
2016-07-19 07:35:44 +03:00
|
|
|
|
|
|
|
// If Layer::mSourceURI links to a SVG mask, it has a fragment. Not vice
|
|
|
|
// versa. Here are examples of URI contains a fragment, two of them link
|
|
|
|
// to a SVG mask:
|
|
|
|
// mask:url(a.svg#maskID); // The fragment of this URI is an ID of a mask
|
|
|
|
// // element in a.svg.
|
|
|
|
// mask:url(#localMaskID); // The fragment of this URI is an ID of a mask
|
|
|
|
// // element in local document.
|
|
|
|
// mask:url(b.svg#viewBoxID); // The fragment of this URI is an ID of a
|
|
|
|
// // viewbox defined in b.svg.
|
|
|
|
// That is, if mSourceURI has a fragment, it may link to a SVG mask; If
|
|
|
|
// not, it "must" not link to a SVG mask.
|
|
|
|
bool maybeSVGMask = false;
|
2016-08-06 01:38:44 +03:00
|
|
|
if (mSourceURI.IsLocalRef()) {
|
|
|
|
maybeSVGMask = true;
|
|
|
|
} else if (mSourceURI.GetSourceURL()) {
|
|
|
|
mSourceURI.GetSourceURL()->GetHasRef(&maybeSVGMask);
|
2016-07-19 07:35:44 +03:00
|
|
|
}
|
2016-08-06 01:38:44 +03:00
|
|
|
|
|
|
|
if (!maybeSVGMask) {
|
|
|
|
if (aNewLayer.mSourceURI.IsLocalRef()) {
|
|
|
|
maybeSVGMask = true;
|
|
|
|
} else if (aNewLayer.mSourceURI.GetSourceURL()) {
|
|
|
|
aNewLayer.mSourceURI.GetSourceURL()->GetHasRef(&maybeSVGMask);
|
|
|
|
}
|
2016-07-19 07:35:44 +03:00
|
|
|
}
|
|
|
|
|
2016-09-22 13:24:52 +03:00
|
|
|
// Return nsChangeHint_UpdateOverflow if either URI might link to an SVG
|
|
|
|
// mask.
|
2016-07-19 07:35:44 +03:00
|
|
|
if (maybeSVGMask) {
|
|
|
|
// Mask changes require that we update the PreEffectsBBoxProperty,
|
|
|
|
// which is done during overflow computation.
|
|
|
|
hint |= nsChangeHint_UpdateOverflow;
|
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
} else if (mAttachment != aNewLayer.mAttachment ||
|
|
|
|
mClip != aNewLayer.mClip ||
|
|
|
|
mOrigin != aNewLayer.mOrigin ||
|
|
|
|
mRepeat != aNewLayer.mRepeat ||
|
|
|
|
mBlendMode != aNewLayer.mBlendMode ||
|
|
|
|
mSize != aNewLayer.mSize ||
|
|
|
|
mImage != aNewLayer.mImage ||
|
|
|
|
mMaskMode != aNewLayer.mMaskMode ||
|
|
|
|
mComposite != aNewLayer.mComposite) {
|
2015-11-02 19:36:35 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
}
|
2016-01-28 08:37:00 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mPosition != aNewLayer.mPosition) {
|
2016-06-14 14:36:01 +03:00
|
|
|
hint |= aPositionChangeHint;
|
2015-11-02 19:36:35 +03:00
|
|
|
}
|
2016-01-28 08:37:00 +03:00
|
|
|
|
2015-11-02 19:36:35 +03:00
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
2016-01-28 08:24:00 +03:00
|
|
|
// --------------------
|
|
|
|
// nsStyleBackground
|
|
|
|
//
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleBackground::nsStyleBackground(StyleStructContext aContext)
|
2016-06-03 18:56:54 +03:00
|
|
|
: mImage(nsStyleImageLayers::LayerType::Background)
|
|
|
|
, mBackgroundColor(NS_RGBA(0, 0, 0, 0))
|
2016-01-28 08:24:00 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleBackground);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::nsStyleBackground(const nsStyleBackground& aSource)
|
2016-01-28 08:39:00 +03:00
|
|
|
: mImage(aSource.mImage)
|
2016-01-28 08:24:00 +03:00
|
|
|
, mBackgroundColor(aSource.mBackgroundColor)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleBackground);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::~nsStyleBackground()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleBackground);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleBackground::Destroy(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Untrack all the images stored in our layers
|
2016-01-28 08:39:00 +03:00
|
|
|
mImage.UntrackImages(aContext);
|
2016-01-28 08:24:00 +03:00
|
|
|
|
|
|
|
this->~nsStyleBackground();
|
|
|
|
aContext->PresShell()->
|
|
|
|
FreeByObjectID(eArenaObjectID_nsStyleBackground, this);
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleBackground::CalcDifference(const nsStyleBackground& aNewData) const
|
2016-01-28 08:24:00 +03:00
|
|
|
{
|
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBackgroundColor != aNewData.mBackgroundColor) {
|
2016-01-28 08:24:00 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
hint |= mImage.CalcDifference(aNewData.mImage,
|
2016-09-22 13:24:52 +03:00
|
|
|
nsStyleImageLayers::LayerType::Background);
|
2016-01-28 08:24:00 +03:00
|
|
|
|
2016-01-28 08:28:00 +03:00
|
|
|
return hint;
|
2016-01-28 08:24:00 +03:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
bool
|
|
|
|
nsStyleBackground::HasFixedBackground(nsIFrame* aFrame) const
|
2016-01-28 08:24:00 +03:00
|
|
|
{
|
2016-01-28 08:39:00 +03:00
|
|
|
NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(i, mImage) {
|
|
|
|
const nsStyleImageLayers::Layer &layer = mImage.mLayers[i];
|
2016-01-28 08:27:00 +03:00
|
|
|
if (layer.mAttachment == NS_STYLE_IMAGELAYER_ATTACHMENT_FIXED &&
|
2016-04-26 00:20:13 +03:00
|
|
|
!layer.mImage.IsEmpty() &&
|
|
|
|
!nsLayoutUtils::IsTransformed(aFrame)) {
|
2016-01-28 08:24:00 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
bool
|
|
|
|
nsStyleBackground::IsTransparent() const
|
2016-01-28 08:24:00 +03:00
|
|
|
{
|
|
|
|
return BottomLayer().mImage.IsEmpty() &&
|
2016-01-28 08:39:00 +03:00
|
|
|
mImage.mImageCount == 1 &&
|
2016-01-28 08:24:00 +03:00
|
|
|
NS_GET_A(mBackgroundColor) == 0;
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
void
|
|
|
|
nsTimingFunction::AssignFromKeyword(int32_t aTimingFunctionType)
|
2009-08-21 01:52:47 +04:00
|
|
|
{
|
2011-04-12 10:18:42 +04:00
|
|
|
switch (aTimingFunctionType) {
|
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_STEP_START:
|
2015-09-29 05:20:13 +03:00
|
|
|
mType = Type::StepStart;
|
2011-04-12 10:18:42 +04:00
|
|
|
mSteps = 1;
|
|
|
|
return;
|
2015-09-29 05:20:13 +03:00
|
|
|
default:
|
2015-11-23 08:33:47 +03:00
|
|
|
MOZ_FALLTHROUGH_ASSERT("aTimingFunctionType must be a keyword value");
|
2011-04-12 10:18:42 +04:00
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_STEP_END:
|
2015-09-29 05:20:13 +03:00
|
|
|
mType = Type::StepEnd;
|
2011-04-12 10:18:42 +04:00
|
|
|
mSteps = 1;
|
|
|
|
return;
|
2015-09-29 05:20:13 +03:00
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE:
|
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_LINEAR:
|
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN:
|
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_OUT:
|
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN_OUT:
|
|
|
|
mType = static_cast<Type>(aTimingFunctionType);
|
2011-04-12 10:18:42 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-07-18 21:59:53 +04:00
|
|
|
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-21 01:52:47 +04:00
|
|
|
|
|
|
|
static const float timingFunctionValues[5][4] = {
|
2013-04-28 14:02:35 +04:00
|
|
|
{ 0.25f, 0.10f, 0.25f, 1.00f }, // ease
|
|
|
|
{ 0.00f, 0.00f, 1.00f, 1.00f }, // linear
|
|
|
|
{ 0.42f, 0.00f, 1.00f, 1.00f }, // ease-in
|
|
|
|
{ 0.00f, 0.00f, 0.58f, 1.00f }, // ease-out
|
|
|
|
{ 0.42f, 0.00f, 0.58f, 1.00f } // ease-in-out
|
2009-08-21 01:52:47 +04:00
|
|
|
};
|
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(0 <= aTimingFunctionType && aTimingFunctionType < 5,
|
|
|
|
"keyword out of range");
|
2011-04-12 10:18:42 +04:00
|
|
|
mFunc.mX1 = timingFunctionValues[aTimingFunctionType][0];
|
|
|
|
mFunc.mY1 = timingFunctionValues[aTimingFunctionType][1];
|
|
|
|
mFunc.mX2 = timingFunctionValues[aTimingFunctionType][2];
|
|
|
|
mFunc.mY2 = timingFunctionValues[aTimingFunctionType][3];
|
2009-08-21 01:52:47 +04:00
|
|
|
}
|
|
|
|
|
2016-07-25 09:22:34 +03:00
|
|
|
StyleTransition::StyleTransition(const StyleTransition& aCopy)
|
2009-08-21 01:52:47 +04:00
|
|
|
: mTimingFunction(aCopy.mTimingFunction)
|
|
|
|
, mDuration(aCopy.mDuration)
|
|
|
|
, mDelay(aCopy.mDelay)
|
|
|
|
, mProperty(aCopy.mProperty)
|
2010-10-21 04:24:16 +04:00
|
|
|
, mUnknownProperty(aCopy.mUnknownProperty)
|
2009-08-21 01:52:47 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-06-27 03:57:12 +04:00
|
|
|
void
|
2016-07-25 09:22:34 +03:00
|
|
|
StyleTransition::SetInitialValues()
|
2009-08-21 01:52:47 +04:00
|
|
|
{
|
|
|
|
mTimingFunction = nsTimingFunction(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE);
|
|
|
|
mDuration = 0.0;
|
|
|
|
mDelay = 0.0;
|
|
|
|
mProperty = eCSSPropertyExtra_all_properties;
|
|
|
|
}
|
|
|
|
|
2014-06-27 03:57:12 +04:00
|
|
|
void
|
2016-08-17 04:37:48 +03:00
|
|
|
StyleTransition::SetUnknownProperty(nsCSSPropertyID aProperty,
|
2015-11-25 04:45:02 +03:00
|
|
|
const nsAString& aPropertyString)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(nsCSSProps::LookupProperty(aPropertyString,
|
2016-05-10 11:44:05 +03:00
|
|
|
CSSEnabledState::eForAllContent) ==
|
2015-11-25 04:45:02 +03:00
|
|
|
aProperty,
|
|
|
|
"property and property string should match");
|
|
|
|
MOZ_ASSERT(aProperty == eCSSProperty_UNKNOWN ||
|
|
|
|
aProperty == eCSSPropertyExtra_variable,
|
|
|
|
"should be either unknown or custom property");
|
|
|
|
mProperty = aProperty;
|
2016-03-29 02:09:43 +03:00
|
|
|
mUnknownProperty = NS_Atomize(aPropertyString);
|
2009-08-21 01:52:47 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
bool
|
2016-07-25 09:26:05 +03:00
|
|
|
StyleTransition::operator==(const StyleTransition& aOther) const
|
2014-09-05 07:48:43 +04:00
|
|
|
{
|
|
|
|
return mTimingFunction == aOther.mTimingFunction &&
|
|
|
|
mDuration == aOther.mDuration &&
|
|
|
|
mDelay == aOther.mDelay &&
|
|
|
|
mProperty == aOther.mProperty &&
|
|
|
|
(mProperty != eCSSProperty_UNKNOWN ||
|
|
|
|
mUnknownProperty == aOther.mUnknownProperty);
|
|
|
|
}
|
|
|
|
|
2016-07-25 09:26:05 +03:00
|
|
|
StyleAnimation::StyleAnimation(const StyleAnimation& aCopy)
|
2011-04-12 10:18:42 +04:00
|
|
|
: 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
|
2016-07-25 09:22:34 +03:00
|
|
|
StyleAnimation::SetInitialValues()
|
2011-04-12 10:18:42 +04:00
|
|
|
{
|
|
|
|
mTimingFunction = nsTimingFunction(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE);
|
|
|
|
mDuration = 0.0;
|
|
|
|
mDelay = 0.0;
|
|
|
|
mName = EmptyString();
|
2015-11-20 08:09:00 +03:00
|
|
|
mDirection = dom::PlaybackDirection::Normal;
|
|
|
|
mFillMode = dom::FillMode::None;
|
2011-04-12 10:18:42 +04:00
|
|
|
mPlayState = NS_STYLE_ANIMATION_PLAY_STATE_RUNNING;
|
|
|
|
mIterationCount = 1.0f;
|
|
|
|
}
|
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
bool
|
2016-07-25 09:26:05 +03:00
|
|
|
StyleAnimation::operator==(const StyleAnimation& aOther) const
|
2014-09-05 07:48:43 +04:00
|
|
|
{
|
|
|
|
return mTimingFunction == aOther.mTimingFunction &&
|
|
|
|
mDuration == aOther.mDuration &&
|
|
|
|
mDelay == aOther.mDelay &&
|
|
|
|
mName == aOther.mName &&
|
|
|
|
mDirection == aOther.mDirection &&
|
|
|
|
mFillMode == aOther.mFillMode &&
|
|
|
|
mPlayState == aOther.mPlayState &&
|
|
|
|
mIterationCount == aOther.mIterationCount;
|
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:29 +03:00
|
|
|
// --------------------
|
|
|
|
// nsStyleDisplay
|
|
|
|
//
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleDisplay::nsStyleDisplay(StyleStructContext aContext)
|
2016-08-28 05:31:50 +03:00
|
|
|
: mDisplay(StyleDisplay::Inline)
|
|
|
|
, mOriginalDisplay(StyleDisplay::Inline)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mContain(NS_STYLE_CONTAIN_NONE)
|
|
|
|
, mAppearance(NS_THEME_NONE)
|
|
|
|
, mPosition(NS_STYLE_POSITION_STATIC)
|
2016-09-03 21:46:58 +03:00
|
|
|
, mFloat(StyleFloat::None)
|
|
|
|
, mOriginalFloat(StyleFloat::None)
|
|
|
|
, mBreakType(StyleClear::None)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mBreakInside(NS_STYLE_PAGE_BREAK_AUTO)
|
|
|
|
, mBreakBefore(false)
|
|
|
|
, mBreakAfter(false)
|
|
|
|
, mOverflowX(NS_STYLE_OVERFLOW_VISIBLE)
|
|
|
|
, mOverflowY(NS_STYLE_OVERFLOW_VISIBLE)
|
|
|
|
, mOverflowClipBox(NS_STYLE_OVERFLOW_CLIP_BOX_PADDING_BOX)
|
|
|
|
, mResize(NS_STYLE_RESIZE_NONE)
|
|
|
|
, mOrient(NS_STYLE_ORIENT_INLINE)
|
|
|
|
, mIsolation(NS_STYLE_ISOLATION_AUTO)
|
|
|
|
, mTopLayer(NS_STYLE_TOP_LAYER_NONE)
|
|
|
|
, mWillChangeBitField(0)
|
|
|
|
, mTouchAction(NS_STYLE_TOUCH_ACTION_AUTO)
|
|
|
|
, mScrollBehavior(NS_STYLE_SCROLL_BEHAVIOR_AUTO)
|
|
|
|
, mScrollSnapTypeX(NS_STYLE_SCROLL_SNAP_TYPE_NONE)
|
|
|
|
, mScrollSnapTypeY(NS_STYLE_SCROLL_SNAP_TYPE_NONE)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mScrollSnapPointsX(eStyleUnit_None)
|
|
|
|
, mScrollSnapPointsY(eStyleUnit_None)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mBackfaceVisibility(NS_STYLE_BACKFACE_VISIBILITY_VISIBLE)
|
|
|
|
, mTransformStyle(NS_STYLE_TRANSFORM_STYLE_FLAT)
|
|
|
|
, mTransformBox(NS_STYLE_TRANSFORM_BOX_BORDER_BOX)
|
|
|
|
, mSpecifiedTransform(nullptr)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mChildPerspective(eStyleUnit_None)
|
|
|
|
, mVerticalAlign(NS_STYLE_VERTICAL_ALIGN_BASELINE, eStyleUnit_Enumerated)
|
2016-04-19 02:51:16 +03:00
|
|
|
, mTransitions(nsStyleAutoArray<StyleTransition>::WITH_SINGLE_INITIAL_ELEMENT)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mTransitionTimingFunctionCount(1)
|
|
|
|
, mTransitionDurationCount(1)
|
|
|
|
, mTransitionDelayCount(1)
|
|
|
|
, mTransitionPropertyCount(1)
|
2016-04-19 02:51:16 +03:00
|
|
|
, mAnimations(nsStyleAutoArray<StyleAnimation>::WITH_SINGLE_INITIAL_ELEMENT)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mAnimationTimingFunctionCount(1)
|
|
|
|
, mAnimationDurationCount(1)
|
|
|
|
, mAnimationDelayCount(1)
|
|
|
|
, mAnimationNameCount(1)
|
|
|
|
, mAnimationDirectionCount(1)
|
|
|
|
, mAnimationFillModeCount(1)
|
|
|
|
, mAnimationPlayStateCount(1)
|
|
|
|
, mAnimationIterationCountCount(1)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleDisplay);
|
2016-05-04 08:35:21 +03:00
|
|
|
mTransformOrigin[0].SetPercentValue(0.5f); // Transform is centered on origin
|
|
|
|
mTransformOrigin[1].SetPercentValue(0.5f);
|
|
|
|
mTransformOrigin[2].SetCoordValue(0);
|
|
|
|
mPerspectiveOrigin[0].SetPercentValue(0.5f);
|
|
|
|
mPerspectiveOrigin[1].SetPercentValue(0.5f);
|
2016-05-03 12:26:30 +03:00
|
|
|
|
2014-02-04 05:54:22 +04:00
|
|
|
// Initial value for mScrollSnapDestination is "0px 0px"
|
|
|
|
mScrollSnapDestination.SetInitialZeroValues();
|
2011-04-12 10:18:42 +04:00
|
|
|
|
2009-08-21 01:52:47 +04:00
|
|
|
mTransitions[0].SetInitialValues();
|
2011-04-12 10:18:42 +04:00
|
|
|
mAnimations[0].SetInitialValues();
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
|
2012-07-07 03:31:54 +04:00
|
|
|
: mBinding(aSource.mBinding)
|
|
|
|
, mDisplay(aSource.mDisplay)
|
|
|
|
, mOriginalDisplay(aSource.mOriginalDisplay)
|
2015-06-04 17:38:00 +03:00
|
|
|
, mContain(aSource.mContain)
|
2012-07-07 03:31:54 +04:00
|
|
|
, mAppearance(aSource.mAppearance)
|
|
|
|
, mPosition(aSource.mPosition)
|
2016-06-19 00:16:20 +03:00
|
|
|
, mFloat(aSource.mFloat)
|
|
|
|
, mOriginalFloat(aSource.mOriginalFloat)
|
2012-07-07 03:31:54 +04:00
|
|
|
, mBreakType(aSource.mBreakType)
|
2012-11-08 20:09:37 +04:00
|
|
|
, mBreakInside(aSource.mBreakInside)
|
2012-07-07 03:31:54 +04:00
|
|
|
, mBreakBefore(aSource.mBreakBefore)
|
|
|
|
, mBreakAfter(aSource.mBreakAfter)
|
|
|
|
, mOverflowX(aSource.mOverflowX)
|
|
|
|
, mOverflowY(aSource.mOverflowY)
|
2014-02-22 05:18:23 +04:00
|
|
|
, mOverflowClipBox(aSource.mOverflowClipBox)
|
2012-07-07 03:31:54 +04:00
|
|
|
, mResize(aSource.mResize)
|
|
|
|
, mOrient(aSource.mOrient)
|
2014-10-15 16:13:00 +04:00
|
|
|
, mIsolation(aSource.mIsolation)
|
2015-10-07 06:04:32 +03:00
|
|
|
, mTopLayer(aSource.mTopLayer)
|
2015-03-20 07:12:17 +03:00
|
|
|
, mWillChangeBitField(aSource.mWillChangeBitField)
|
|
|
|
, mWillChange(aSource.mWillChange)
|
2014-01-15 19:03:15 +04:00
|
|
|
, mTouchAction(aSource.mTouchAction)
|
2014-09-15 23:29:58 +04:00
|
|
|
, mScrollBehavior(aSource.mScrollBehavior)
|
2014-02-04 05:54:22 +04:00
|
|
|
, mScrollSnapTypeX(aSource.mScrollSnapTypeX)
|
|
|
|
, mScrollSnapTypeY(aSource.mScrollSnapTypeY)
|
|
|
|
, mScrollSnapPointsX(aSource.mScrollSnapPointsX)
|
|
|
|
, mScrollSnapPointsY(aSource.mScrollSnapPointsY)
|
|
|
|
, mScrollSnapDestination(aSource.mScrollSnapDestination)
|
|
|
|
, mScrollSnapCoordinate(aSource.mScrollSnapCoordinate)
|
2015-03-20 07:12:17 +03:00
|
|
|
, mBackfaceVisibility(aSource.mBackfaceVisibility)
|
|
|
|
, mTransformStyle(aSource.mTransformStyle)
|
2015-05-16 00:43:25 +03:00
|
|
|
, mTransformBox(aSource.mTransformBox)
|
2015-03-20 07:12:17 +03:00
|
|
|
, mSpecifiedTransform(aSource.mSpecifiedTransform)
|
|
|
|
, mChildPerspective(aSource.mChildPerspective)
|
2016-04-12 08:52:41 +03:00
|
|
|
, mVerticalAlign(aSource.mVerticalAlign)
|
2012-07-07 03:31:54 +04:00
|
|
|
, mTransitions(aSource.mTransitions)
|
2009-08-21 01:52:47 +04:00
|
|
|
, mTransitionTimingFunctionCount(aSource.mTransitionTimingFunctionCount)
|
|
|
|
, mTransitionDurationCount(aSource.mTransitionDurationCount)
|
|
|
|
, mTransitionDelayCount(aSource.mTransitionDelayCount)
|
|
|
|
, mTransitionPropertyCount(aSource.mTransitionPropertyCount)
|
2011-04-12 10:18:42 +04: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)
|
2016-07-22 10:40:01 +03:00
|
|
|
, mShapeOutside(aSource.mShapeOutside)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleDisplay);
|
2016-05-04 08:35:21 +03:00
|
|
|
|
|
|
|
/* Copy over transform origin. */
|
|
|
|
mTransformOrigin[0] = aSource.mTransformOrigin[0];
|
|
|
|
mTransformOrigin[1] = aSource.mTransformOrigin[1];
|
|
|
|
mTransformOrigin[2] = aSource.mTransformOrigin[2];
|
|
|
|
mPerspectiveOrigin[0] = aSource.mPerspectiveOrigin[0];
|
|
|
|
mPerspectiveOrigin[1] = aSource.mPerspectiveOrigin[1];
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleDisplay::CalcDifference(const nsStyleDisplay& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2003-07-12 01:16:12 +04:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
2002-09-30 15:56:37 +04:00
|
|
|
|
2016-09-02 17:22:48 +03:00
|
|
|
if (!DefinitelyEqualURIsAndPrincipal(mBinding, aNewData.mBinding)
|
2016-06-21 04:47:54 +03:00
|
|
|
|| mPosition != aNewData.mPosition
|
|
|
|
|| mDisplay != aNewData.mDisplay
|
|
|
|
|| mContain != aNewData.mContain
|
2016-09-03 21:46:58 +03:00
|
|
|
|| (mFloat == StyleFloat::None) != (aNewData.mFloat == StyleFloat::None)
|
2016-06-21 04:47:54 +03:00
|
|
|
|| mOverflowX != aNewData.mOverflowX
|
|
|
|
|| mOverflowY != aNewData.mOverflowY
|
|
|
|
|| mScrollBehavior != aNewData.mScrollBehavior
|
|
|
|
|| mScrollSnapTypeX != aNewData.mScrollSnapTypeX
|
|
|
|
|| mScrollSnapTypeY != aNewData.mScrollSnapTypeY
|
|
|
|
|| mScrollSnapPointsX != aNewData.mScrollSnapPointsX
|
|
|
|
|| mScrollSnapPointsY != aNewData.mScrollSnapPointsY
|
|
|
|
|| mScrollSnapDestination != aNewData.mScrollSnapDestination
|
|
|
|
|| mTopLayer != aNewData.mTopLayer
|
2016-07-06 08:06:13 +03:00
|
|
|
|| mResize != aNewData.mResize) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_ReconstructFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2002-09-30 15:56:37 +04:00
|
|
|
|
2014-02-04 05:54:22 +04:00
|
|
|
/* Note: When mScrollBehavior, mScrollSnapTypeX, mScrollSnapTypeY,
|
|
|
|
* mScrollSnapPointsX, mScrollSnapPointsY, or mScrollSnapDestination are
|
|
|
|
* changed, nsChangeHint_NeutralChange is not sufficient to enter
|
|
|
|
* nsCSSFrameConstructor::PropagateScrollToViewport. By using the same hint
|
|
|
|
* as used when the overflow css property changes,
|
2014-10-28 23:41:00 +03:00
|
|
|
* nsChangeHint_ReconstructFrame, PropagateScrollToViewport will be called.
|
|
|
|
*
|
|
|
|
* The scroll-behavior css property is not expected to change often (the
|
|
|
|
* CSSOM-View DOM methods are likely to be used in those cases); however,
|
|
|
|
* if this does become common perhaps a faster-path might be worth while.
|
|
|
|
*/
|
|
|
|
|
2013-12-09 03:26:07 +04:00
|
|
|
if ((mAppearance == NS_THEME_TEXTFIELD &&
|
2016-06-21 04:47:54 +03:00
|
|
|
aNewData.mAppearance != NS_THEME_TEXTFIELD) ||
|
2013-12-09 03:26:07 +04:00
|
|
|
(mAppearance != NS_THEME_TEXTFIELD &&
|
2016-06-21 04:47:54 +03:00
|
|
|
aNewData.mAppearance == NS_THEME_TEXTFIELD)) {
|
2013-12-09 03:26:07 +04:00
|
|
|
// This is for <input type=number> where we allow authors to specify a
|
|
|
|
// |-moz-appearance:textfield| to get a control without a spinner. (The
|
|
|
|
// spinner is present for |-moz-appearance:number-input| but also other
|
|
|
|
// values such as 'none'.) We need to reframe since we want to use
|
|
|
|
// nsTextControlFrame instead of nsNumberControlFrame if the author
|
|
|
|
// specifies 'textfield'.
|
|
|
|
return nsChangeHint_ReconstructFrame;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mFloat != aNewData.mFloat) {
|
2009-08-04 05:22:13 +04:00
|
|
|
// Changing which side we float on doesn't affect descendants directly
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_AllReflowHints &
|
|
|
|
~(nsChangeHint_ClearDescendantIntrinsics |
|
|
|
|
nsChangeHint_NeedDirtyReflow);
|
2009-08-04 05:22:13 +04:00
|
|
|
}
|
2003-11-15 01:55:46 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mVerticalAlign != aNewData.mVerticalAlign) {
|
2016-04-12 08:52:41 +03:00
|
|
|
// XXX Can this just be AllReflowHints + RepaintFrame, and be included in
|
|
|
|
// the block below?
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= NS_STYLE_HINT_REFLOW;
|
2016-04-12 08:52:41 +03:00
|
|
|
}
|
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
// XXX the following is conservative, for now: changing float breaking shouldn't
|
|
|
|
// necessarily require a repaint, reflow should suffice.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBreakType != aNewData.mBreakType
|
|
|
|
|| mBreakInside != aNewData.mBreakInside
|
|
|
|
|| mBreakBefore != aNewData.mBreakBefore
|
|
|
|
|| mBreakAfter != aNewData.mBreakAfter
|
|
|
|
|| mAppearance != aNewData.mAppearance
|
|
|
|
|| mOrient != aNewData.mOrient
|
2016-07-06 08:06:13 +03:00
|
|
|
|| mOverflowClipBox != aNewData.mOverflowClipBox) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_AllReflowHints |
|
|
|
|
nsChangeHint_RepaintFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2002-09-30 15:56:37 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mIsolation != aNewData.mIsolation) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
2014-09-24 17:48:00 +04:00
|
|
|
}
|
|
|
|
|
2015-03-20 07:12:17 +03: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.
|
|
|
|
*/
|
2016-06-21 04:47:54 +03:00
|
|
|
if (HasTransformStyle() != aNewData.HasTransformStyle()) {
|
2015-03-20 07:12:17 +03:00
|
|
|
// We do not need to apply nsChangeHint_UpdateTransformLayer since
|
|
|
|
// nsChangeHint_RepaintFrame will forcibly invalidate the frame area and
|
|
|
|
// ensure layers are rebuilt (or removed).
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateContainingBlock |
|
|
|
|
nsChangeHint_UpdateOverflow |
|
|
|
|
nsChangeHint_RepaintFrame;
|
2015-03-20 07:12:17 +03:00
|
|
|
} else {
|
|
|
|
/* 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.
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* If the property isn't present in either style struct, we still do the
|
|
|
|
* comparisons but turn all the resulting change hints into
|
|
|
|
* nsChangeHint_NeutralChange.
|
|
|
|
*/
|
|
|
|
nsChangeHint transformHint = nsChangeHint(0);
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (!mSpecifiedTransform != !aNewData.mSpecifiedTransform ||
|
2015-03-20 07:12:17 +03:00
|
|
|
(mSpecifiedTransform &&
|
2016-06-21 04:47:54 +03:00
|
|
|
*mSpecifiedTransform != *aNewData.mSpecifiedTransform)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
transformHint |= nsChangeHint_UpdateTransformLayer;
|
2015-03-20 07:12:17 +03:00
|
|
|
|
|
|
|
if (mSpecifiedTransform &&
|
2016-06-21 04:47:54 +03:00
|
|
|
aNewData.mSpecifiedTransform) {
|
2016-05-23 06:26:03 +03:00
|
|
|
transformHint |= nsChangeHint_UpdatePostTransformOverflow;
|
2015-03-20 07:12:17 +03:00
|
|
|
} else {
|
2016-05-23 06:26:03 +03:00
|
|
|
transformHint |= nsChangeHint_UpdateOverflow;
|
2015-03-20 07:12:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsChangeHint kUpdateOverflowAndRepaintHint =
|
2016-05-23 06:26:03 +03:00
|
|
|
nsChangeHint_UpdateOverflow | nsChangeHint_RepaintFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
for (uint8_t index = 0; index < 3; ++index) {
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTransformOrigin[index] != aNewData.mTransformOrigin[index]) {
|
2016-05-23 06:26:03 +03:00
|
|
|
transformHint |= nsChangeHint_UpdateTransformLayer |
|
|
|
|
nsChangeHint_UpdatePostTransformOverflow;
|
2015-03-20 07:12:17 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for (uint8_t index = 0; index < 2; ++index) {
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mPerspectiveOrigin[index] != aNewData.mPerspectiveOrigin[index]) {
|
2016-05-23 06:26:03 +03:00
|
|
|
transformHint |= kUpdateOverflowAndRepaintHint;
|
2015-03-20 07:12:17 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2015-03-20 07:12:17 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (HasPerspectiveStyle() != aNewData.HasPerspectiveStyle()) {
|
2015-08-05 00:29:16 +03:00
|
|
|
// A change from/to being a containing block for position:fixed.
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateContainingBlock;
|
2015-08-05 00:29:16 +03:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mChildPerspective != aNewData.mChildPerspective ||
|
|
|
|
mTransformStyle != aNewData.mTransformStyle ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mTransformBox != aNewData.mTransformBox) {
|
2016-05-23 06:26:03 +03:00
|
|
|
transformHint |= kUpdateOverflowAndRepaintHint;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2015-03-20 07:12:17 +03:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mBackfaceVisibility != aNewData.mBackfaceVisibility) {
|
2016-05-23 06:26:03 +03:00
|
|
|
transformHint |= nsChangeHint_RepaintFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2015-03-20 07:12:17 +03:00
|
|
|
|
|
|
|
if (transformHint) {
|
|
|
|
if (HasTransformStyle()) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= transformHint;
|
2015-03-20 07:12:17 +03:00
|
|
|
} else {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2015-03-20 07:12:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-27 04:13:04 +03:00
|
|
|
// Note that the HasTransformStyle() != aNewData.HasTransformStyle()
|
2015-03-20 07:12:17 +03:00
|
|
|
// test above handles relevant changes in the
|
2016-07-27 04:13:04 +03:00
|
|
|
// NS_STYLE_WILL_CHANGE_TRANSFORM bit, which in turn handles frame
|
|
|
|
// reconstruction for changes in the containing block of
|
2015-12-01 02:46:44 +03:00
|
|
|
// fixed-positioned elements.
|
2015-03-20 07:12:17 +03:00
|
|
|
uint8_t willChangeBitsChanged =
|
2016-06-21 04:47:54 +03:00
|
|
|
mWillChangeBitField ^ aNewData.mWillChangeBitField;
|
2015-12-01 02:46:44 +03:00
|
|
|
if (willChangeBitsChanged & (NS_STYLE_WILL_CHANGE_STACKING_CONTEXT |
|
|
|
|
NS_STYLE_WILL_CHANGE_SCROLL |
|
|
|
|
NS_STYLE_WILL_CHANGE_OPACITY)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
2015-03-20 07:12:17 +03:00
|
|
|
}
|
|
|
|
|
2015-12-01 02:46:44 +03:00
|
|
|
if (willChangeBitsChanged & NS_STYLE_WILL_CHANGE_FIXPOS_CB) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateContainingBlock;
|
2015-12-01 02:46:44 +03:00
|
|
|
}
|
|
|
|
|
2016-06-01 20:13:14 +03:00
|
|
|
// If touch-action is changed, we need to regenerate the event regions on
|
|
|
|
// the layers and send it over to the compositor for APZ to handle.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTouchAction != aNewData.mTouchAction) {
|
2016-06-01 20:13:14 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2009-12-11 19:13:19 +03:00
|
|
|
// Note: Our current behavior for handling changes to the
|
|
|
|
// transition-duration, transition-delay, and transition-timing-function
|
2009-10-08 07:22:42 +04: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 19:13:19 +03: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-12 10:18:42 +04: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.
|
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
// But we still need to return nsChangeHint_NeutralChange for these
|
|
|
|
// properties, since some data did change in the style struct.
|
|
|
|
|
|
|
|
if (!hint &&
|
2016-06-21 04:47:54 +03:00
|
|
|
(mOriginalDisplay != aNewData.mOriginalDisplay ||
|
|
|
|
mOriginalFloat != aNewData.mOriginalFloat ||
|
|
|
|
mTransitions != aNewData.mTransitions ||
|
2014-09-05 07:48:43 +04:00
|
|
|
mTransitionTimingFunctionCount !=
|
2016-06-21 04:47:54 +03:00
|
|
|
aNewData.mTransitionTimingFunctionCount ||
|
|
|
|
mTransitionDurationCount != aNewData.mTransitionDurationCount ||
|
|
|
|
mTransitionDelayCount != aNewData.mTransitionDelayCount ||
|
|
|
|
mTransitionPropertyCount != aNewData.mTransitionPropertyCount ||
|
|
|
|
mAnimations != aNewData.mAnimations ||
|
|
|
|
mAnimationTimingFunctionCount != aNewData.mAnimationTimingFunctionCount ||
|
|
|
|
mAnimationDurationCount != aNewData.mAnimationDurationCount ||
|
|
|
|
mAnimationDelayCount != aNewData.mAnimationDelayCount ||
|
|
|
|
mAnimationNameCount != aNewData.mAnimationNameCount ||
|
|
|
|
mAnimationDirectionCount != aNewData.mAnimationDirectionCount ||
|
|
|
|
mAnimationFillModeCount != aNewData.mAnimationFillModeCount ||
|
|
|
|
mAnimationPlayStateCount != aNewData.mAnimationPlayStateCount ||
|
|
|
|
mAnimationIterationCountCount != aNewData.mAnimationIterationCountCount ||
|
2016-07-22 10:40:01 +03:00
|
|
|
mScrollSnapCoordinate != aNewData.mScrollSnapCoordinate ||
|
|
|
|
mShapeOutside != aNewData.mShapeOutside)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2014-09-05 07:48:43 +04:00
|
|
|
}
|
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleVisibility
|
|
|
|
//
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleVisibility::nsStyleVisibility(StyleStructContext aContext)
|
2016-05-03 12:26:29 +03:00
|
|
|
: mDirection(aContext.GetBidi() == IBMBIDI_TEXTDIRECTION_RTL
|
|
|
|
? NS_STYLE_DIRECTION_RTL
|
|
|
|
: NS_STYLE_DIRECTION_LTR)
|
|
|
|
, mVisible(NS_STYLE_VISIBILITY_VISIBLE)
|
|
|
|
, mImageRendering(NS_STYLE_IMAGE_RENDERING_AUTO)
|
|
|
|
, mWritingMode(NS_STYLE_WRITING_MODE_HORIZONTAL_TB)
|
|
|
|
, mTextOrientation(NS_STYLE_TEXT_ORIENTATION_MIXED)
|
|
|
|
, mColorAdjust(NS_STYLE_COLOR_ADJUST_ECONOMY)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleVisibility);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource)
|
2016-05-03 12:26:29 +03:00
|
|
|
: mImageOrientation(aSource.mImageOrientation)
|
|
|
|
, mDirection(aSource.mDirection)
|
|
|
|
, mVisible(aSource.mVisible)
|
|
|
|
, mImageRendering(aSource.mImageRendering)
|
|
|
|
, mWritingMode(aSource.mWritingMode)
|
|
|
|
, mTextOrientation(aSource.mTextOrientation)
|
|
|
|
, mColorAdjust(aSource.mColorAdjust)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleVisibility);
|
2016-05-03 12:26:29 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleVisibility::CalcDifference(const nsStyleVisibility& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2010-12-11 03:25:25 +03:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mDirection != aNewData.mDirection || mWritingMode != aNewData.mWritingMode) {
|
2015-08-12 13:02:02 +03:00
|
|
|
// It's important that a change in mWritingMode results in frame
|
|
|
|
// reconstruction, because it may affect intrinsic size (see
|
|
|
|
// nsSubDocumentFrame::GetIntrinsicISize/BSize).
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_ReconstructFrame;
|
2013-05-24 21:31:33 +04:00
|
|
|
} else {
|
2016-06-21 04:47:54 +03:00
|
|
|
if ((mImageOrientation != aNewData.mImageOrientation)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_AllReflowHints |
|
|
|
|
nsChangeHint_RepaintFrame;
|
2013-08-29 02:39:06 +04:00
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mVisible != aNewData.mVisible) {
|
2013-05-24 21:31:33 +04:00
|
|
|
if ((NS_STYLE_VISIBILITY_COLLAPSE == mVisible) ||
|
2016-06-21 04:47:54 +03:00
|
|
|
(NS_STYLE_VISIBILITY_COLLAPSE == aNewData.mVisible)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= NS_STYLE_HINT_REFLOW;
|
2013-05-24 21:31:33 +04:00
|
|
|
} else {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= NS_STYLE_HINT_VISUAL;
|
2013-05-24 21:31:33 +04:00
|
|
|
}
|
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTextOrientation != aNewData.mTextOrientation) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= NS_STYLE_HINT_REFLOW;
|
2014-12-11 21:56:19 +03:00
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mImageRendering != aNewData.mImageRendering) {
|
2016-04-12 08:52:40 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mColorAdjust != aNewData.mColorAdjust) {
|
2016-03-08 20:25:24 +03:00
|
|
|
// color-adjust only affects media where dynamic changes can't happen.
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2016-03-08 20:25:24 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2010-12-11 03:25:25 +03:00
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2004-07-15 02:19:22 +04:00
|
|
|
nsStyleContentData::~nsStyleContentData()
|
|
|
|
{
|
2016-08-16 23:57:31 +03:00
|
|
|
MOZ_COUNT_DTOR(nsStyleContentData);
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mImageTracked,
|
|
|
|
"nsStyleContentData being destroyed while still tracking image!");
|
2004-07-15 02:19:22 +04:00
|
|
|
if (mType == eStyleContentType_Image) {
|
|
|
|
NS_IF_RELEASE(mContent.mImage);
|
2005-04-02 03:07:00 +04:00
|
|
|
} else if (mType == eStyleContentType_Counter ||
|
|
|
|
mType == eStyleContentType_Counters) {
|
|
|
|
mContent.mCounters->Release();
|
2004-07-15 02:19:22 +04:00
|
|
|
} else if (mContent.mString) {
|
2015-04-01 08:29:55 +03:00
|
|
|
free(mContent.mString);
|
2004-07-15 02:19:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-16 23:57:31 +03:00
|
|
|
nsStyleContentData::nsStyleContentData(const nsStyleContentData& aOther)
|
|
|
|
: mType(aOther.mType)
|
|
|
|
#ifdef DEBUG
|
|
|
|
, mImageTracked(false)
|
|
|
|
#endif
|
2004-07-15 02:19:22 +04:00
|
|
|
{
|
2016-08-16 23:57:31 +03:00
|
|
|
MOZ_COUNT_CTOR(nsStyleContentData);
|
2004-07-15 02:19:22 +04:00
|
|
|
if (mType == eStyleContentType_Image) {
|
|
|
|
mContent.mImage = aOther.mContent.mImage;
|
|
|
|
NS_IF_ADDREF(mContent.mImage);
|
2005-04-02 03:07:00 +04:00
|
|
|
} else if (mType == eStyleContentType_Counter ||
|
|
|
|
mType == eStyleContentType_Counters) {
|
|
|
|
mContent.mCounters = aOther.mContent.mCounters;
|
|
|
|
mContent.mCounters->AddRef();
|
2004-07-15 02:19:22 +04:00
|
|
|
} else if (aOther.mContent.mString) {
|
2006-11-17 04:49:06 +03:00
|
|
|
mContent.mString = NS_strdup(aOther.mContent.mString);
|
2004-07-15 02:19:22 +04:00
|
|
|
} else {
|
2012-07-30 18:20:58 +04:00
|
|
|
mContent.mString = nullptr;
|
2004-07-15 02:19:22 +04:00
|
|
|
}
|
2016-08-16 23:57:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContentData&
|
|
|
|
nsStyleContentData::operator=(const nsStyleContentData& aOther)
|
|
|
|
{
|
|
|
|
if (this == &aOther) {
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
this->~nsStyleContentData();
|
|
|
|
new (this) nsStyleContentData(aOther);
|
|
|
|
|
2004-07-15 02:19:22 +04:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
bool
|
|
|
|
nsStyleContentData::operator==(const nsStyleContentData& aOther) const
|
2004-07-15 02:19:22 +04:00
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != aOther.mType) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2004-07-15 02:19:22 +04:00
|
|
|
if (mType == eStyleContentType_Image) {
|
2016-07-06 08:06:13 +03:00
|
|
|
if (!mContent.mImage || !aOther.mContent.mImage) {
|
2005-09-20 06:02:21 +04:00
|
|
|
return mContent.mImage == aOther.mContent.mImage;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2011-09-29 10:19:26 +04:00
|
|
|
bool eq;
|
2004-07-15 02:19:22 +04: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);
|
|
|
|
}
|
2005-04-02 03:07:00 +04:00
|
|
|
if (mType == eStyleContentType_Counter ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mType == eStyleContentType_Counters) {
|
2005-04-02 03:07:00 +04:00
|
|
|
return *mContent.mCounters == *aOther.mContent.mCounters;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2011-06-21 09:03:59 +04:00
|
|
|
return safe_strcmp(mContent.mString, aOther.mContent.mString) == 0;
|
2004-07-15 02:19:22 +04:00
|
|
|
}
|
|
|
|
|
2010-08-06 21:27:01 +04:00
|
|
|
void
|
|
|
|
nsStyleContentData::TrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mImageTracked, "Already tracking image!");
|
|
|
|
MOZ_ASSERT(mType == eStyleContentType_Image,
|
|
|
|
"Trying to do image tracking on non-image!");
|
|
|
|
MOZ_ASSERT(mContent.mImage,
|
|
|
|
"Can't track image when there isn't one!");
|
2010-08-06 21:27:01 +04:00
|
|
|
|
|
|
|
// Register the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
2016-07-06 08:06:13 +03:00
|
|
|
if (doc) {
|
2010-08-06 21:27:01 +04:00
|
|
|
doc->AddImage(mContent.mImage);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2010-08-06 21:27:01 +04:00
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleContentData::UntrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mImageTracked, "Image not tracked!");
|
|
|
|
MOZ_ASSERT(mType == eStyleContentType_Image,
|
|
|
|
"Trying to do image tracking on non-image!");
|
|
|
|
MOZ_ASSERT(mContent.mImage,
|
|
|
|
"Can't untrack image when there isn't one!");
|
2010-08-06 21:27:01 +04:00
|
|
|
|
|
|
|
// Unregister the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
2016-07-06 08:06:13 +03:00
|
|
|
if (doc) {
|
2016-07-19 08:29:21 +03:00
|
|
|
doc->RemoveImage(mContent.mImage);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2010-08-06 21:27:01 +04:00
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
//-----------------------
|
|
|
|
// nsStyleContent
|
|
|
|
//
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleContent::nsStyleContent(StyleStructContext aContext)
|
2016-05-03 12:26:30 +03:00
|
|
|
: mMarkerOffset(eStyleUnit_Auto)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleContent);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleContent::~nsStyleContent()
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleContent);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:29 +03:00
|
|
|
void
|
2010-08-06 21:27:01 +04:00
|
|
|
nsStyleContent::Destroy(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Unregister any images we might have with the document.
|
2016-08-16 23:57:31 +03:00
|
|
|
for (auto& content : mContents) {
|
|
|
|
if (content.mType == eStyleContentType_Image && content.mContent.mImage) {
|
|
|
|
content.UntrackImage(aContext);
|
2010-08-06 21:27:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this->~nsStyleContent();
|
2016-08-16 23:57:31 +03:00
|
|
|
aContext->PresShell()->FreeByObjectID(eArenaObjectID_nsStyleContent, this);
|
2010-08-06 21:27:01 +04:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleContent::nsStyleContent(const nsStyleContent& aSource)
|
2016-05-03 12:26:29 +03:00
|
|
|
: mMarkerOffset(aSource.mMarkerOffset)
|
2016-08-16 23:57:31 +03:00
|
|
|
, mContents(aSource.mContents)
|
|
|
|
, mIncrements(aSource.mIncrements)
|
|
|
|
, mResets(aSource.mResets)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleContent);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleContent::CalcDifference(const nsStyleContent& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2010-06-18 20:23:05 +04: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.
|
|
|
|
|
2016-08-16 23:57:31 +03:00
|
|
|
// Unfortunately we need to reframe even if the content lengths are the same;
|
|
|
|
// a simple reflow will not pick up different text or different image URLs,
|
|
|
|
// since we set all that up in the CSSFrameConstructor
|
|
|
|
if (mContents != aNewData.mContents ||
|
|
|
|
mIncrements != aNewData.mIncrements ||
|
|
|
|
mResets != aNewData.mResets) {
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2005-04-02 03:07:00 +04:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mMarkerOffset != aNewData.mMarkerOffset) {
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
2004-07-15 03:51:25 +04:00
|
|
|
|
2016-08-16 23:57:31 +03:00
|
|
|
return nsChangeHint(0);
|
2016-08-19 10:23:42 +03:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleTextReset
|
|
|
|
//
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleTextReset::nsStyleTextReset(StyleStructContext aContext)
|
2016-05-03 12:26:29 +03:00
|
|
|
: mTextDecorationLine(NS_STYLE_TEXT_DECORATION_LINE_NONE)
|
|
|
|
, mUnicodeBidi(NS_STYLE_UNICODE_BIDI_NORMAL)
|
2016-07-28 10:23:36 +03:00
|
|
|
, mInitialLetterSink(0)
|
|
|
|
, mInitialLetterSize(0.0f)
|
2016-06-03 18:56:54 +03:00
|
|
|
, mTextDecorationStyle(NS_STYLE_TEXT_DECORATION_STYLE_SOLID | BORDER_COLOR_FOREGROUND)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mTextDecorationColor(NS_RGB(0, 0, 0))
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTextReset);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:29 +03:00
|
|
|
nsStyleTextReset::nsStyleTextReset(const nsStyleTextReset& aSource)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTextReset);
|
2011-06-22 22:11:47 +04:00
|
|
|
*this = aSource;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleTextReset::~nsStyleTextReset()
|
2009-08-07 18:38:44 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleTextReset);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2016-04-12 08:52:41 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleTextReset::CalcDifference(const nsStyleTextReset& aNewData) const
|
2016-04-12 08:52:41 +03:00
|
|
|
{
|
2016-07-28 10:23:36 +03:00
|
|
|
if (mUnicodeBidi != aNewData.mUnicodeBidi ||
|
|
|
|
mInitialLetterSink != aNewData.mInitialLetterSink ||
|
|
|
|
mInitialLetterSize != aNewData.mInitialLetterSize) {
|
2016-04-12 08:52:41 +03:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
2011-03-31 16:26:35 +04:00
|
|
|
|
2016-04-12 08:52:41 +03:00
|
|
|
uint8_t lineStyle = GetDecorationStyle();
|
2016-06-21 04:47:54 +03:00
|
|
|
uint8_t otherLineStyle = aNewData.GetDecorationStyle();
|
|
|
|
if (mTextDecorationLine != aNewData.mTextDecorationLine ||
|
2016-04-12 08:52:41 +03:00
|
|
|
lineStyle != otherLineStyle) {
|
|
|
|
// Changes to our text-decoration line can impact our overflow area &
|
|
|
|
// also our descendants' overflow areas (particularly for text-frame
|
|
|
|
// descendants). So, we update those areas & trigger a repaint.
|
|
|
|
return nsChangeHint_RepaintFrame |
|
|
|
|
nsChangeHint_UpdateSubtreeOverflow |
|
|
|
|
nsChangeHint_SchedulePaint;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Repaint for decoration color changes
|
2016-08-16 12:05:08 +03:00
|
|
|
// Dummy initialisations to keep Valgrind/Memcheck happy.
|
|
|
|
// See bug 1289098 comment 1.
|
|
|
|
nscolor decColor = NS_RGBA(0, 0, 0, 0);
|
|
|
|
nscolor otherDecColor = NS_RGBA(0, 0, 0, 0);
|
2016-04-12 08:52:41 +03:00
|
|
|
bool isFG, otherIsFG;
|
|
|
|
GetDecorationColor(decColor, isFG);
|
2016-06-21 04:47:54 +03:00
|
|
|
aNewData.GetDecorationColor(otherDecColor, otherIsFG);
|
2016-04-12 08:52:41 +03:00
|
|
|
if (isFG != otherIsFG || (!isFG && decColor != otherDecColor)) {
|
|
|
|
return nsChangeHint_RepaintFrame;
|
|
|
|
}
|
2008-03-30 00:25:15 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTextOverflow != aNewData.mTextOverflow) {
|
2016-04-12 08:52:41 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2008-03-30 00:25:15 +03:00
|
|
|
}
|
2016-04-12 08:52:41 +03:00
|
|
|
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2015-10-02 06:05:28 +03:00
|
|
|
// Returns true if the given shadow-arrays are equal.
|
|
|
|
static bool
|
|
|
|
AreShadowArraysEqual(nsCSSShadowArray* lhs,
|
2008-07-08 04:56:52 +04:00
|
|
|
nsCSSShadowArray* rhs)
|
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (lhs == rhs) {
|
2015-10-02 06:05:28 +03:00
|
|
|
return true;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-07-08 04:56:52 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (!lhs || !rhs || lhs->Length() != rhs->Length()) {
|
2015-10-02 06:05:28 +03:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-07-08 04:56:52 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < lhs->Length(); ++i) {
|
2016-07-06 08:06:13 +03:00
|
|
|
if (*lhs->ShadowAt(i) != *rhs->ShadowAt(i)) {
|
2015-10-02 06:05:28 +03:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-07-08 04:56:52 +04:00
|
|
|
}
|
2015-10-02 06:05:28 +03:00
|
|
|
return true;
|
2008-07-08 04:56:52 +04:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleText
|
|
|
|
//
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleText::nsStyleText(StyleStructContext aContext)
|
2016-05-11 07:03:34 +03:00
|
|
|
: mTextAlign(NS_STYLE_TEXT_ALIGN_START)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mTextAlignLast(NS_STYLE_TEXT_ALIGN_AUTO)
|
|
|
|
, mTextAlignTrue(false)
|
|
|
|
, mTextAlignLastTrue(false)
|
|
|
|
, mTextTransform(NS_STYLE_TEXT_TRANSFORM_NONE)
|
|
|
|
, mWhiteSpace(NS_STYLE_WHITESPACE_NORMAL)
|
|
|
|
, mWordBreak(NS_STYLE_WORDBREAK_NORMAL)
|
2016-05-24 03:27:21 +03:00
|
|
|
, mOverflowWrap(NS_STYLE_OVERFLOWWRAP_NORMAL)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mHyphens(NS_STYLE_HYPHENS_MANUAL)
|
|
|
|
, mRubyAlign(NS_STYLE_RUBY_ALIGN_SPACE_AROUND)
|
|
|
|
, mRubyPosition(NS_STYLE_RUBY_POSITION_OVER)
|
|
|
|
, mTextSizeAdjust(NS_STYLE_TEXT_SIZE_ADJUST_AUTO)
|
|
|
|
, mTextCombineUpright(NS_STYLE_TEXT_COMBINE_UPRIGHT_NONE)
|
|
|
|
, mControlCharacterVisibility(nsCSSParser::ControlCharVisibilityDefault())
|
|
|
|
, mTextEmphasisStyle(NS_STYLE_TEXT_EMPHASIS_STYLE_NONE)
|
|
|
|
, mTextRendering(NS_STYLE_TEXT_RENDERING_AUTO)
|
|
|
|
, mTabSize(NS_STYLE_TABSIZE_INITIAL)
|
2016-09-16 07:40:45 +03:00
|
|
|
, mTextEmphasisColor(StyleComplexColor::CurrentColor())
|
|
|
|
, mWebkitTextFillColor(StyleComplexColor::CurrentColor())
|
|
|
|
, mWebkitTextStrokeColor(StyleComplexColor::CurrentColor())
|
2016-05-03 12:26:30 +03:00
|
|
|
, mWordSpacing(0, nsStyleCoord::CoordConstructor)
|
|
|
|
, mLetterSpacing(eStyleUnit_Normal)
|
|
|
|
, mLineHeight(eStyleUnit_Normal)
|
|
|
|
, mTextIndent(0, nsStyleCoord::CoordConstructor)
|
|
|
|
, mWebkitTextStrokeWidth(0, nsStyleCoord::CoordConstructor)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mTextShadow(nullptr)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleText);
|
2016-03-31 02:30:39 +03:00
|
|
|
nsCOMPtr<nsIAtom> language = aContext.GetContentLanguage();
|
2015-11-28 03:56:33 +03:00
|
|
|
mTextEmphasisPosition = language &&
|
2016-07-21 08:03:25 +03:00
|
|
|
nsStyleUtil::MatchesLanguagePrefix(language, u"zh") ?
|
2015-11-28 03:56:33 +03:00
|
|
|
NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT_ZH :
|
|
|
|
NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT;
|
2008-06-04 03:42:13 +04:00
|
|
|
}
|
2008-06-04 02:25:31 +04:00
|
|
|
|
2008-06-06 03:06:34 +04:00
|
|
|
nsStyleText::nsStyleText(const nsStyleText& aSource)
|
2016-05-03 12:26:29 +03:00
|
|
|
: mTextAlign(aSource.mTextAlign)
|
|
|
|
, mTextAlignLast(aSource.mTextAlignLast)
|
|
|
|
, mTextAlignTrue(false)
|
|
|
|
, mTextAlignLastTrue(false)
|
|
|
|
, mTextTransform(aSource.mTextTransform)
|
|
|
|
, mWhiteSpace(aSource.mWhiteSpace)
|
|
|
|
, mWordBreak(aSource.mWordBreak)
|
2016-05-24 03:27:21 +03:00
|
|
|
, mOverflowWrap(aSource.mOverflowWrap)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mHyphens(aSource.mHyphens)
|
|
|
|
, mRubyAlign(aSource.mRubyAlign)
|
|
|
|
, mRubyPosition(aSource.mRubyPosition)
|
|
|
|
, mTextSizeAdjust(aSource.mTextSizeAdjust)
|
|
|
|
, mTextCombineUpright(aSource.mTextCombineUpright)
|
|
|
|
, mControlCharacterVisibility(aSource.mControlCharacterVisibility)
|
|
|
|
, mTextEmphasisPosition(aSource.mTextEmphasisPosition)
|
|
|
|
, mTextEmphasisStyle(aSource.mTextEmphasisStyle)
|
|
|
|
, mTextRendering(aSource.mTextRendering)
|
|
|
|
, mTabSize(aSource.mTabSize)
|
|
|
|
, mTextEmphasisColor(aSource.mTextEmphasisColor)
|
|
|
|
, mWebkitTextFillColor(aSource.mWebkitTextFillColor)
|
|
|
|
, mWebkitTextStrokeColor(aSource.mWebkitTextStrokeColor)
|
|
|
|
, mWordSpacing(aSource.mWordSpacing)
|
|
|
|
, mLetterSpacing(aSource.mLetterSpacing)
|
|
|
|
, mLineHeight(aSource.mLineHeight)
|
|
|
|
, mTextIndent(aSource.mTextIndent)
|
|
|
|
, mWebkitTextStrokeWidth(aSource.mWebkitTextStrokeWidth)
|
|
|
|
, mTextShadow(aSource.mTextShadow)
|
|
|
|
, mTextEmphasisStyleString(aSource.mTextEmphasisStyleString)
|
2009-08-07 18:38:44 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleText);
|
|
|
|
}
|
2008-06-06 03:06:34 +04:00
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleText::~nsStyleText()
|
2009-08-07 18:38:44 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleText);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleText::CalcDifference(const nsStyleText& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2012-09-07 09:42:19 +04:00
|
|
|
if (WhiteSpaceOrNewlineIsSignificant() !=
|
2016-06-21 04:47:54 +03:00
|
|
|
aNewData.WhiteSpaceOrNewlineIsSignificant()) {
|
2009-06-13 13:16:34 +04:00
|
|
|
// This may require construction of suppressed text frames
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2009-06-13 13:16:34 +04:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTextCombineUpright != aNewData.mTextCombineUpright ||
|
|
|
|
mControlCharacterVisibility != aNewData.mControlCharacterVisibility) {
|
2013-08-19 14:26:44 +04:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if ((mTextAlign != aNewData.mTextAlign) ||
|
|
|
|
(mTextAlignLast != aNewData.mTextAlignLast) ||
|
|
|
|
(mTextAlignTrue != aNewData.mTextAlignTrue) ||
|
|
|
|
(mTextAlignLastTrue != aNewData.mTextAlignLastTrue) ||
|
|
|
|
(mTextTransform != aNewData.mTextTransform) ||
|
|
|
|
(mWhiteSpace != aNewData.mWhiteSpace) ||
|
|
|
|
(mWordBreak != aNewData.mWordBreak) ||
|
|
|
|
(mOverflowWrap != aNewData.mOverflowWrap) ||
|
|
|
|
(mHyphens != aNewData.mHyphens) ||
|
|
|
|
(mRubyAlign != aNewData.mRubyAlign) ||
|
|
|
|
(mRubyPosition != aNewData.mRubyPosition) ||
|
|
|
|
(mTextSizeAdjust != aNewData.mTextSizeAdjust) ||
|
|
|
|
(mLetterSpacing != aNewData.mLetterSpacing) ||
|
|
|
|
(mLineHeight != aNewData.mLineHeight) ||
|
|
|
|
(mTextIndent != aNewData.mTextIndent) ||
|
|
|
|
(mWordSpacing != aNewData.mWordSpacing) ||
|
2016-07-06 08:06:13 +03:00
|
|
|
(mTabSize != aNewData.mTabSize)) {
|
2008-06-06 03:06:34 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-06-06 03:06:34 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (HasTextEmphasis() != aNewData.HasTextEmphasis() ||
|
2015-12-08 20:55:01 +03:00
|
|
|
(HasTextEmphasis() &&
|
2016-06-21 04:47:54 +03:00
|
|
|
mTextEmphasisPosition != aNewData.mTextEmphasisPosition)) {
|
2015-12-08 20:55:01 +03:00
|
|
|
// Text emphasis position change could affect line height calculation.
|
|
|
|
return nsChangeHint_AllReflowHints |
|
|
|
|
nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2016-04-12 08:52:41 +03:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
|
|
|
// text-rendering changes require a reflow since they change SVG
|
|
|
|
// frames' rects.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTextRendering != aNewData.mTextRendering) {
|
2016-04-12 08:52:41 +03:00
|
|
|
hint |= nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_NeedDirtyReflow | // XXX remove me: bug 876085
|
|
|
|
nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (!AreShadowArraysEqual(mTextShadow, aNewData.mTextShadow) ||
|
|
|
|
mTextEmphasisStyle != aNewData.mTextEmphasisStyle ||
|
|
|
|
mTextEmphasisStyleString != aNewData.mTextEmphasisStyleString ||
|
|
|
|
mWebkitTextStrokeWidth != aNewData.mWebkitTextStrokeWidth) {
|
2016-04-12 08:52:41 +03:00
|
|
|
hint |= nsChangeHint_UpdateSubtreeOverflow |
|
|
|
|
nsChangeHint_SchedulePaint |
|
|
|
|
nsChangeHint_RepaintFrame;
|
|
|
|
|
|
|
|
// We don't add any other hints below.
|
|
|
|
return hint;
|
2015-11-28 03:56:33 +03:00
|
|
|
}
|
|
|
|
|
2016-09-16 07:40:45 +03:00
|
|
|
if (mTextEmphasisColor != aNewData.mTextEmphasisColor ||
|
2016-06-21 04:47:54 +03:00
|
|
|
mWebkitTextFillColor != aNewData.mWebkitTextFillColor ||
|
|
|
|
mWebkitTextStrokeColor != aNewData.mWebkitTextStrokeColor) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_SchedulePaint |
|
|
|
|
nsChangeHint_RepaintFrame;
|
2016-04-12 08:52:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hint) {
|
|
|
|
return hint;
|
2015-11-28 03:56:33 +03:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTextEmphasisPosition != aNewData.mTextEmphasisPosition) {
|
2015-12-08 20:55:01 +03:00
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2015-11-28 03:56:33 +03:00
|
|
|
LogicalSide
|
|
|
|
nsStyleText::TextEmphasisSide(WritingMode aWM) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(
|
|
|
|
(!(mTextEmphasisPosition & NS_STYLE_TEXT_EMPHASIS_POSITION_LEFT) !=
|
|
|
|
!(mTextEmphasisPosition & NS_STYLE_TEXT_EMPHASIS_POSITION_RIGHT)) &&
|
|
|
|
(!(mTextEmphasisPosition & NS_STYLE_TEXT_EMPHASIS_POSITION_OVER) !=
|
|
|
|
!(mTextEmphasisPosition & NS_STYLE_TEXT_EMPHASIS_POSITION_UNDER)));
|
2016-02-25 03:09:34 +03:00
|
|
|
mozilla::Side side = aWM.IsVertical() ?
|
2015-11-28 03:56:33 +03:00
|
|
|
(mTextEmphasisPosition & NS_STYLE_TEXT_EMPHASIS_POSITION_LEFT
|
|
|
|
? eSideLeft : eSideRight) :
|
|
|
|
(mTextEmphasisPosition & NS_STYLE_TEXT_EMPHASIS_POSITION_OVER
|
|
|
|
? eSideTop : eSideBottom);
|
|
|
|
LogicalSide result = aWM.LogicalSideForPhysicalSide(side);
|
|
|
|
MOZ_ASSERT(IsBlock(result));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
//-----------------------
|
|
|
|
// nsStyleUserInterface
|
|
|
|
//
|
|
|
|
|
2005-07-01 08:29:42 +04:00
|
|
|
nsCursorImage::nsCursorImage()
|
2011-10-17 18:59:28 +04:00
|
|
|
: mHaveHotspot(false)
|
2005-07-01 08:29:42 +04:00
|
|
|
, mHotspotX(0.0f)
|
|
|
|
, mHotspotY(0.0f)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-16 20:19:26 +04:00
|
|
|
nsCursorImage::nsCursorImage(const nsCursorImage& aOther)
|
|
|
|
: mHaveHotspot(aOther.mHaveHotspot)
|
|
|
|
, mHotspotX(aOther.mHotspotX)
|
|
|
|
, mHotspotY(aOther.mHotspotY)
|
|
|
|
{
|
|
|
|
SetImage(aOther.GetImage());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCursorImage::~nsCursorImage()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
SetImage(nullptr);
|
2010-08-16 20:19:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCursorImage&
|
|
|
|
nsCursorImage::operator=(const nsCursorImage& aOther)
|
|
|
|
{
|
|
|
|
if (this != &aOther) {
|
|
|
|
mHaveHotspot = aOther.mHaveHotspot;
|
|
|
|
mHotspotX = aOther.mHotspotX;
|
|
|
|
mHotspotY = aOther.mHotspotY;
|
|
|
|
SetImage(aOther.GetImage());
|
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleUserInterface::nsStyleUserInterface(StyleStructContext aContext)
|
2016-05-03 12:26:30 +03:00
|
|
|
: mUserInput(NS_STYLE_USER_INPUT_AUTO)
|
|
|
|
, mUserModify(NS_STYLE_USER_MODIFY_READ_ONLY)
|
2016-09-03 21:46:58 +03:00
|
|
|
, mUserFocus(StyleUserFocus::None)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mPointerEvents(NS_STYLE_POINTER_EVENTS_AUTO)
|
|
|
|
, mCursor(NS_STYLE_CURSOR_AUTO)
|
|
|
|
, mCursorArrayLength(0)
|
|
|
|
, mCursorArray(nullptr)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUserInterface);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleUserInterface::nsStyleUserInterface(const nsStyleUserInterface& aSource)
|
|
|
|
: mUserInput(aSource.mUserInput)
|
|
|
|
, mUserModify(aSource.mUserModify)
|
|
|
|
, mUserFocus(aSource.mUserFocus)
|
|
|
|
, mPointerEvents(aSource.mPointerEvents)
|
|
|
|
, mCursor(aSource.mCursor)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUserInterface);
|
2005-07-01 08:29:42 +04:00
|
|
|
CopyCursorArrayFrom(aSource);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleUserInterface::~nsStyleUserInterface()
|
2016-05-03 12:26:30 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleUserInterface);
|
2005-07-01 08:29:42 +04:00
|
|
|
delete [] mCursorArray;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2004-12-28 16:48:25 +03:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mCursor != aNewData.mCursor) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateCursor;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2004-12-31 00:56:11 +03:00
|
|
|
// We could do better. But it wouldn't be worth it, URL-specified cursors are
|
|
|
|
// rare.
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mCursorArrayLength > 0 || aNewData.mCursorArrayLength > 0) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateCursor;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2004-12-31 00:56:11 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mPointerEvents != aNewData.mPointerEvents) {
|
2016-04-12 08:52:41 +03:00
|
|
|
// nsSVGPathGeometryFrame's mRect depends on stroke _and_ on the value
|
|
|
|
// of pointer-events. See nsSVGPathGeometryFrame::ReflowSVG's use of
|
|
|
|
// GetHitTestFlags. (Only a reflow, no visual change.)
|
|
|
|
hint |= nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_NeedDirtyReflow; // XXX remove me: bug 876085
|
|
|
|
}
|
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mUserModify != aNewData.mUserModify) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= NS_STYLE_HINT_VISUAL;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mUserInput != aNewData.mUserInput) {
|
2014-09-05 07:48:43 +04:00
|
|
|
if (NS_STYLE_USER_INPUT_NONE == mUserInput ||
|
2016-06-21 04:47:54 +03:00
|
|
|
NS_STYLE_USER_INPUT_NONE == aNewData.mUserInput) {
|
2016-07-06 08:06:14 +03:00
|
|
|
hint |= nsChangeHint_ReconstructFrame;
|
2014-09-05 07:48:43 +04:00
|
|
|
} else {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2014-09-05 07:48:43 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mUserFocus != aNewData.mUserFocus) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2014-09-05 07:48:43 +04:00
|
|
|
}
|
2004-12-28 16:48:25 +03:00
|
|
|
|
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2005-07-01 08:29:42 +04:00
|
|
|
void
|
|
|
|
nsStyleUserInterface::CopyCursorArrayFrom(const nsStyleUserInterface& aSource)
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
mCursorArray = nullptr;
|
2005-07-01 08:29:42 +04:00
|
|
|
mCursorArrayLength = 0;
|
|
|
|
if (aSource.mCursorArrayLength) {
|
|
|
|
mCursorArray = new nsCursorImage[aSource.mCursorArrayLength];
|
|
|
|
if (mCursorArray) {
|
|
|
|
mCursorArrayLength = aSource.mCursorArrayLength;
|
2016-07-06 08:06:13 +03:00
|
|
|
for (uint32_t i = 0; i < mCursorArrayLength; ++i) {
|
2005-07-01 08:29:42 +04:00
|
|
|
mCursorArray[i] = aSource.mCursorArray[i];
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2005-07-01 08:29:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
//-----------------------
|
|
|
|
// nsStyleUIReset
|
|
|
|
//
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleUIReset::nsStyleUIReset(StyleStructContext aContext)
|
2016-08-10 19:12:21 +03:00
|
|
|
: mUserSelect(StyleUserSelect::Auto)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mForceBrokenImageIcon(0)
|
|
|
|
, mIMEMode(NS_STYLE_IME_MODE_AUTO)
|
|
|
|
, mWindowDragging(NS_STYLE_WINDOW_DRAGGING_DEFAULT)
|
|
|
|
, mWindowShadow(NS_STYLE_WINDOW_SHADOW_DEFAULT)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUIReset);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleUIReset::nsStyleUIReset(const nsStyleUIReset& aSource)
|
|
|
|
: mUserSelect(aSource.mUserSelect)
|
|
|
|
, mForceBrokenImageIcon(aSource.mForceBrokenImageIcon)
|
|
|
|
, mIMEMode(aSource.mIMEMode)
|
|
|
|
, mWindowDragging(aSource.mWindowDragging)
|
|
|
|
, mWindowShadow(aSource.mWindowShadow)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUIReset);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleUIReset::~nsStyleUIReset()
|
2016-05-03 12:26:30 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleUIReset);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleUIReset::CalcDifference(const nsStyleUIReset& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2007-05-16 19:51:37 +04:00
|
|
|
// ignore mIMEMode
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mForceBrokenImageIcon != aNewData.mForceBrokenImageIcon) {
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mWindowShadow != aNewData.mWindowShadow) {
|
2008-10-14 18:44:25 +04:00
|
|
|
// 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;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mUserSelect != aNewData.mUserSelect) {
|
2008-10-14 18:44:25 +04:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2016-01-27 13:58:33 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mWindowDragging != aNewData.mWindowDragging) {
|
2016-01-27 13:58:33 +03:00
|
|
|
return nsChangeHint_SchedulePaint;
|
|
|
|
}
|
|
|
|
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2013-12-12 06:09:40 +04:00
|
|
|
|
|
|
|
//-----------------------
|
|
|
|
// nsStyleVariables
|
|
|
|
//
|
|
|
|
|
2016-03-31 02:30:39 +03:00
|
|
|
nsStyleVariables::nsStyleVariables(StyleStructContext aContext)
|
2013-12-12 06:09:40 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleVariables);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleVariables::nsStyleVariables(const nsStyleVariables& aSource)
|
2016-05-03 12:26:30 +03:00
|
|
|
: mVariables(aSource.mVariables)
|
2013-12-12 06:09:40 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleVariables);
|
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleVariables::~nsStyleVariables()
|
2013-12-12 06:09:40 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleVariables);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleVariables::CalcDifference(const nsStyleVariables& aNewData) const
|
2013-12-12 06:09:40 +04:00
|
|
|
{
|
|
|
|
return nsChangeHint(0);
|
|
|
|
}
|
2016-04-12 08:52:42 +03:00
|
|
|
|
|
|
|
//-----------------------
|
|
|
|
// nsStyleEffects
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleEffects::nsStyleEffects(StyleStructContext aContext)
|
|
|
|
: mBoxShadow(nullptr)
|
2016-04-12 08:52:42 +03:00
|
|
|
, mClip(0, 0, 0, 0)
|
2016-04-12 08:52:43 +03:00
|
|
|
, mOpacity(1.0f)
|
2016-04-12 08:52:42 +03:00
|
|
|
, mClipFlags(NS_STYLE_CLIP_AUTO)
|
2016-04-12 08:52:42 +03:00
|
|
|
, mMixBlendMode(NS_STYLE_BLEND_NORMAL)
|
2016-04-12 08:52:42 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleEffects);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleEffects::nsStyleEffects(const nsStyleEffects& aSource)
|
2016-04-12 08:52:43 +03:00
|
|
|
: mFilters(aSource.mFilters)
|
|
|
|
, mBoxShadow(aSource.mBoxShadow)
|
2016-04-12 08:52:42 +03:00
|
|
|
, mClip(aSource.mClip)
|
2016-04-12 08:52:43 +03:00
|
|
|
, mOpacity(aSource.mOpacity)
|
2016-04-12 08:52:42 +03:00
|
|
|
, mClipFlags(aSource.mClipFlags)
|
2016-04-12 08:52:42 +03:00
|
|
|
, mMixBlendMode(aSource.mMixBlendMode)
|
2016-04-12 08:52:42 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleEffects);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleEffects::~nsStyleEffects()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleEffects);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleEffects::CalcDifference(const nsStyleEffects& aNewData) const
|
2016-04-12 08:52:42 +03:00
|
|
|
{
|
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (!AreShadowArraysEqual(mBoxShadow, aNewData.mBoxShadow)) {
|
2016-04-12 08:52:42 +03:00
|
|
|
// Update overflow regions & trigger DLBI to be sure it's noticed.
|
|
|
|
// Also request a repaint, since it's possible that only the color
|
|
|
|
// of the shadow is changing (and UpdateOverflow/SchedulePaint won't
|
|
|
|
// repaint for that, since they won't know what needs invalidating.)
|
|
|
|
hint |= nsChangeHint_UpdateOverflow |
|
|
|
|
nsChangeHint_SchedulePaint |
|
|
|
|
nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mClipFlags != aNewData.mClipFlags) {
|
2016-04-12 08:52:42 +03:00
|
|
|
hint |= nsChangeHint_AllReflowHints |
|
|
|
|
nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (!mClip.IsEqualInterior(aNewData.mClip)) {
|
2016-04-12 08:52:42 +03:00
|
|
|
// If the clip has changed, we just need to update overflow areas. DLBI
|
|
|
|
// will handle the invalidation.
|
|
|
|
hint |= nsChangeHint_UpdateOverflow |
|
|
|
|
nsChangeHint_SchedulePaint;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mOpacity != aNewData.mOpacity) {
|
2016-04-12 08:52:43 +03:00
|
|
|
// If we're going from the optimized >=0.99 opacity value to 1.0 or back, then
|
|
|
|
// repaint the frame because DLBI will not catch the invalidation. Otherwise,
|
|
|
|
// just update the opacity layer.
|
2016-06-21 04:47:54 +03:00
|
|
|
if ((mOpacity >= 0.99f && mOpacity < 1.0f && aNewData.mOpacity == 1.0f) ||
|
|
|
|
(aNewData.mOpacity >= 0.99f && aNewData.mOpacity < 1.0f && mOpacity == 1.0f)) {
|
2016-04-12 08:52:43 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
} else {
|
|
|
|
hint |= nsChangeHint_UpdateOpacityLayer;
|
2016-06-21 04:47:54 +03:00
|
|
|
if ((mOpacity == 1.0f) != (aNewData.mOpacity == 1.0f)) {
|
2016-04-12 08:52:43 +03:00
|
|
|
hint |= nsChangeHint_UpdateUsesOpacity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (HasFilters() != aNewData.HasFilters()) {
|
2016-04-12 08:52:43 +03:00
|
|
|
// A change from/to being a containing block for position:fixed.
|
|
|
|
hint |= nsChangeHint_UpdateContainingBlock;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mFilters != aNewData.mFilters) {
|
2016-04-12 08:52:43 +03:00
|
|
|
hint |= nsChangeHint_UpdateEffects |
|
|
|
|
nsChangeHint_RepaintFrame |
|
|
|
|
nsChangeHint_UpdateOverflow;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mMixBlendMode != aNewData.mMixBlendMode) {
|
2016-04-12 08:52:42 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2016-04-12 08:52:42 +03:00
|
|
|
if (!hint &&
|
2016-06-21 04:47:54 +03:00
|
|
|
!mClip.IsEqualEdges(aNewData.mClip)) {
|
2016-04-12 08:52:42 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2016-04-12 08:52:42 +03:00
|
|
|
return hint;
|
|
|
|
}
|