Files
palemoon27/layout/style/CounterStyleManager.h
T
roytam1 3a02ab4d4d import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1131308 (part 0) - Fix minor problems with RemovingIterator. r=froydnj. (5c232c9ca)
- Bug 1176163 - Remove remaining uses of PL_DHashTableEnumerate() from xpcom/. r=froydnj. (bd2478b3a)
- Bug 1179657 - Remove PL_DHASHMETER. r=froydnj. (30f581478)
- Bug 1131308 (part 1) - Improve PLDHashTable's internal checking. r=froydnj. (faba4a3b9)
- Bug 1180084 - Convert TestPLDHash.cpp to a gtest. r=froydnj. (de6ee3c5c)
- Bug 1171578 - Avoid crashing if indexedDB is used at a particular point in the worker shutdown sequence, r=baku. (f325c218e)
- Bug 804975 - Part 1: Expose WritingMode bits. r=dbaron (0635d01dd)
- Bug 1072101 - Part 1: Implement FontFaceSet.size. r=peterv (7e0b4848a)
- Bug 1144977 - Part 1: Don't include FontFace objects in more than one loadingdone/loadingerror event. r=jdaggett (4d10b3269)
- Bug 1072101 - Part 2: Implement FontFaceSet.{entries,values}. r=peterv (1c636f4f1)
- Bug 1072101 - Part 3: Implement FontFaceSet.forEach. r=peterv (842a5cdbe)
- Bug 1072101 - Part 4: Implement FontFaceSet.{keys,@@iterator}. r=peterv (4dfb3afe9)
- Bug 1072101 - Part 5: Remove indexed property access on FontFaceSet. r=peterv (edef47d70)
- Bug 1072101 - Unified build fix; no review. (7c1538f6c)
- Bug 861449 - Incremental css::Rule destroyer. r=dbaron (5e60f4394)
- Bug 1175800 - Remove typedefs from nsComputedDOMStyle.cpp as they interfere with others under unified compilation. r=bzbarsky (2bd45e7ed)
- Bug 1147766 - Part 1: Add a mozilla::RangedArray class, for fixed length arrays with a non-zero base index. r=waldo (42be428bc)
- Bug 1147766 - Part 2: Replace FixedStyleStructArray with mozilla::RangedArray. r=dbaron (4d28a0a5e)
- Bug 1171282 - Avoid some unnecessary |operator new| null-checks in layout/. r=dholbert. (60e1690c1)
- Bug 1168664 - Stop mistakenly using the transform reference box's width to calculate the Z component in ProcessMatrix3D. r=mattwoodrow (18f9021b1)
- Bug 1171842 - Use jump table instead of nested if statements for peeking compute function of style struct. r=dbaron (a5160b962)
- Bug 1170173 - Parse CSS 'contain' property. r=dholbert (3d8a37dee)
- Bug 1144607 part 1 - Remove CounterStyleManager::BuildCounterStyle for anonymous counter styles. r=dbaron (331397d01)
- Bug 1144607 part 2 - Support string value for list-style-tyle. r=dbaron (0b4bca0c7)
- Bug 1144607 part 3 - Reftests for string value on list-style-type. r=dbaron (2a483f621)
- Bug 1144607 followup - Fix submitted reftest for string value of list-style-type. DONTBUILD (ad23ac443)
- Bug 1151220 - [css-grid] Fix a couple of typos in InitializeTrackSize. r=dholbert (840f3b8a4)
- Bug 1151201 - [css-grid] Update parsing of 'auto' in track-sizing functions to latest version of the spec. r=simon.sapin (abdb0c0ea)
2021-02-02 20:52:33 +08:00

191 lines
6.0 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef mozilla_CounterStyleManager_h_
#define mozilla_CounterStyleManager_h_
#include "nsStringFwd.h"
#include "nsRefPtrHashtable.h"
#include "nsHashKeys.h"
#include "nsStyleConsts.h"
#include "mozilla/Attributes.h"
#include "nsCSSValue.h"
class nsPresContext;
namespace mozilla {
class WritingMode;
typedef int32_t CounterValue;
class CounterStyleManager;
class AnonymousCounterStyle;
struct NegativeType;
struct PadType;
class CounterStyle
{
protected:
explicit MOZ_CONSTEXPR CounterStyle(int32_t aStyle)
: mStyle(aStyle)
{
}
private:
CounterStyle(const CounterStyle& aOther) = delete;
void operator=(const CounterStyle& other) = delete;
public:
int32_t GetStyle() const { return mStyle; }
bool IsNone() const { return mStyle == NS_STYLE_LIST_STYLE_NONE; }
bool IsCustomStyle() const { return mStyle == NS_STYLE_LIST_STYLE_CUSTOM; }
// A style is dependent if it depends on the counter style manager.
// Custom styles are certainly dependent. In addition, some builtin
// styles are dependent for fallback.
bool IsDependentStyle() const;
virtual void GetPrefix(nsSubstring& aResult) = 0;
virtual void GetSuffix(nsSubstring& aResult) = 0;
void GetCounterText(CounterValue aOrdinal,
WritingMode aWritingMode,
nsSubstring& aResult,
bool& aIsRTL);
virtual void GetSpokenCounterText(CounterValue aOrdinal,
WritingMode aWritingMode,
nsSubstring& aResult,
bool& aIsBullet);
// XXX This method could be removed once ::-moz-list-bullet and
// ::-moz-list-number are completely merged into ::marker.
virtual bool IsBullet() = 0;
virtual void GetNegative(NegativeType& aResult) = 0;
/**
* This method returns whether an ordinal is in the range of this
* counter style. Note that, it is possible that an ordinal in range
* is rejected by the generating algorithm.
*/
virtual bool IsOrdinalInRange(CounterValue aOrdinal) = 0;
/**
* This method returns whether an ordinal is in the default range of
* this counter style. This is the effective range when no 'range'
* descriptor is specified.
*/
virtual bool IsOrdinalInAutoRange(CounterValue aOrdinal) = 0;
virtual void GetPad(PadType& aResult) = 0;
virtual CounterStyle* GetFallback() = 0;
virtual uint8_t GetSpeakAs() = 0;
virtual bool UseNegativeSign() = 0;
virtual void CallFallbackStyle(CounterValue aOrdinal,
WritingMode aWritingMode,
nsSubstring& aResult,
bool& aIsRTL);
virtual bool GetInitialCounterText(CounterValue aOrdinal,
WritingMode aWritingMode,
nsSubstring& aResult,
bool& aIsRTL) = 0;
virtual AnonymousCounterStyle* AsAnonymous() { return nullptr; }
NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
protected:
int32_t mStyle;
};
class AnonymousCounterStyle final : public CounterStyle
{
public:
explicit AnonymousCounterStyle(const nsSubstring& aContent);
explicit AnonymousCounterStyle(const nsCSSValue::Array* aValue);
virtual void GetPrefix(nsAString& aResult) override;
virtual void GetSuffix(nsAString& aResult) override;
virtual bool IsBullet() override;
virtual void GetNegative(NegativeType& aResult) override;
virtual bool IsOrdinalInRange(CounterValue aOrdinal) override;
virtual bool IsOrdinalInAutoRange(CounterValue aOrdinal) override;
virtual void GetPad(PadType& aResult) override;
virtual CounterStyle* GetFallback() override;
virtual uint8_t GetSpeakAs() override;
virtual bool UseNegativeSign() override;
virtual bool GetInitialCounterText(CounterValue aOrdinal,
WritingMode aWritingMode,
nsSubstring& aResult,
bool& aIsRTL) override;
virtual AnonymousCounterStyle* AsAnonymous() override { return this; }
bool IsSingleString() const { return mSingleString; }
uint8_t GetSystem() const { return mSystem; }
const nsTArray<nsString>& GetSymbols() const { return mSymbols; }
NS_INLINE_DECL_REFCOUNTING(AnonymousCounterStyle, override)
private:
~AnonymousCounterStyle() {}
bool mSingleString;
uint8_t mSystem;
nsTArray<nsString> mSymbols;
};
class CounterStyleManager final
{
private:
~CounterStyleManager();
public:
explicit CounterStyleManager(nsPresContext* aPresContext);
static void InitializeBuiltinCounterStyles();
void Disconnect();
bool IsInitial() const
{
// only 'none' and 'decimal'
return mCacheTable.Count() == 2;
}
CounterStyle* BuildCounterStyle(const nsSubstring& aName);
static CounterStyle* GetBuiltinStyle(int32_t aStyle);
static CounterStyle* GetNoneStyle()
{
return GetBuiltinStyle(NS_STYLE_LIST_STYLE_NONE);
}
static CounterStyle* GetDecimalStyle()
{
return GetBuiltinStyle(NS_STYLE_LIST_STYLE_DECIMAL);
}
// This method will scan all existing counter styles generated by this
// manager, and remove or mark data dirty accordingly. It returns true
// if any counter style is changed, false elsewise. This method should
// be called when any counter style may be affected.
bool NotifyRuleChanged();
nsPresContext* PresContext() const { return mPresContext; }
NS_INLINE_DECL_REFCOUNTING(CounterStyleManager)
private:
nsPresContext* mPresContext;
nsRefPtrHashtable<nsStringHashKey, CounterStyle> mCacheTable;
};
} // namespace mozilla
#endif /* !defined(mozilla_CounterStyleManager_h_) */