2018-01-11 04:38:01 +00: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: */
|
|
|
|
/* 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_InspectorFontFace_h
|
|
|
|
#define mozilla_InspectorFontFace_h
|
|
|
|
|
Bug 1449087 part 2 - Use Servo data to back @font-face rule. r=emilio
This patch does the following things:
* Create a new class ServoFontFaceRule for CSSOM of @font-face rule
which mostly follows how nsCSSFontFaceRule was implemented.
* Remove the old nsCSSFontFaceRule and binding code to create it.
* Have FontFace backed by Servo data via making mRule and mDescriptors
of the class hold RawServoFontFaceRule like ServoFontFaceRule.
To keep this patch small, it effectively just delays the conversion
from Servo data to nsCSSValue from parsing to using. This may cause
worse performance if the font set is flushed repeatedly. Supposing we
don't flush font set very frequently, it may not be a big deal.
We may still want to remove the intermediate nsCSSValue conversion at
some point, and have everything converted to their final form directly
when used, but that can happen in followups.
There are some unfortunate bits from this change:
* We lose style sheet for logging in FontFaceSet. This is probably not
all that worse, because we wouldn't have that before either if the
page doesn't use CSSOM to visit it. But we should figure out some
approach to fix it anyway.
* InspectorFontFace no longer shares the same rule object as CSSOM.
This isn't really a problem if the @font-face rule isn't very mutable.
Unless we want to make the rule returned from InspectorFontFace to be
mutable (i.e. via inspector), not using the same object probably isn't
too bad.
This patch switches the code we use to serialize stuff in FontFace and
CSSFontFaceRule, which leads to some failures in tests. Specifically,
the expected changes including:
* Value of font-family now can be serialized to identifier sequence like
font-family property. The old code always serializes it to string,
but it doesn't seem to have different requirement than the property.
Blink can serialize to identifier as well.
* Family name inside local() is also changed to use the same way as
family names elsewhere (i.e. can be identifier sequence). Blink has
the same behavior as the old code, but I don't think it's a big deal.
* The order of descriptors serialized gets changed. I don't think it
matters at all.
* Empty string as font-family via using string syntax is no longer
considered invalid for FontFace. I don't find it is mentioned anywhere
that it should be specifically treated invalid.
MozReview-Commit-ID: 32Fk3Fi9uTs
--HG--
extra : rebase_source : 6221ec8fc56de357b06dd27e770fb175348a2f77
2018-04-03 22:42:10 +00:00
|
|
|
#include "mozilla/ServoFontFaceRule.h"
|
2018-01-11 04:38:01 +00:00
|
|
|
#include "mozilla/dom/InspectorUtilsBinding.h"
|
|
|
|
#include "mozilla/dom/NonRefcountedDOMObject.h"
|
2018-02-15 18:48:22 +00:00
|
|
|
#include "nsRange.h"
|
2018-05-11 07:56:12 +00:00
|
|
|
#include "gfxFont.h"
|
2018-01-11 04:38:01 +00:00
|
|
|
|
|
|
|
class gfxFontGroup;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Information on font face usage by a given DOM Range, as returned by
|
|
|
|
* InspectorUtils.getUsedFontFaces.
|
|
|
|
*/
|
|
|
|
class InspectorFontFace final : public NonRefcountedDOMObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
InspectorFontFace(gfxFontEntry* aFontEntry,
|
|
|
|
gfxFontGroup* aFontGroup,
|
2018-05-11 07:56:12 +00:00
|
|
|
gfxTextRange::MatchType aMatchType)
|
2018-01-11 04:38:01 +00:00
|
|
|
: mFontEntry(aFontEntry)
|
|
|
|
, mFontGroup(aFontGroup)
|
|
|
|
, mMatchType(aMatchType)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(InspectorFontFace);
|
|
|
|
}
|
|
|
|
|
|
|
|
~InspectorFontFace()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(InspectorFontFace);
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxFontEntry* GetFontEntry() const { return mFontEntry; }
|
2018-05-11 07:56:12 +00:00
|
|
|
void AddMatchType(gfxTextRange::MatchType aMatchType) {
|
|
|
|
mMatchType |= aMatchType;
|
|
|
|
}
|
2018-01-11 04:38:01 +00:00
|
|
|
|
2018-02-15 18:48:22 +00:00
|
|
|
void AddRange(nsRange* aRange);
|
|
|
|
size_t RangeCount() const {
|
|
|
|
return mRanges.Length();
|
|
|
|
}
|
|
|
|
|
2018-01-11 04:38:01 +00:00
|
|
|
// Web IDL
|
|
|
|
bool FromFontGroup();
|
|
|
|
bool FromLanguagePrefs();
|
|
|
|
bool FromSystemFallback();
|
|
|
|
void GetName(nsAString& aName);
|
|
|
|
void GetCSSFamilyName(nsAString& aCSSFamilyName);
|
Bug 1449087 part 2 - Use Servo data to back @font-face rule. r=emilio
This patch does the following things:
* Create a new class ServoFontFaceRule for CSSOM of @font-face rule
which mostly follows how nsCSSFontFaceRule was implemented.
* Remove the old nsCSSFontFaceRule and binding code to create it.
* Have FontFace backed by Servo data via making mRule and mDescriptors
of the class hold RawServoFontFaceRule like ServoFontFaceRule.
To keep this patch small, it effectively just delays the conversion
from Servo data to nsCSSValue from parsing to using. This may cause
worse performance if the font set is flushed repeatedly. Supposing we
don't flush font set very frequently, it may not be a big deal.
We may still want to remove the intermediate nsCSSValue conversion at
some point, and have everything converted to their final form directly
when used, but that can happen in followups.
There are some unfortunate bits from this change:
* We lose style sheet for logging in FontFaceSet. This is probably not
all that worse, because we wouldn't have that before either if the
page doesn't use CSSOM to visit it. But we should figure out some
approach to fix it anyway.
* InspectorFontFace no longer shares the same rule object as CSSOM.
This isn't really a problem if the @font-face rule isn't very mutable.
Unless we want to make the rule returned from InspectorFontFace to be
mutable (i.e. via inspector), not using the same object probably isn't
too bad.
This patch switches the code we use to serialize stuff in FontFace and
CSSFontFaceRule, which leads to some failures in tests. Specifically,
the expected changes including:
* Value of font-family now can be serialized to identifier sequence like
font-family property. The old code always serializes it to string,
but it doesn't seem to have different requirement than the property.
Blink can serialize to identifier as well.
* Family name inside local() is also changed to use the same way as
family names elsewhere (i.e. can be identifier sequence). Blink has
the same behavior as the old code, but I don't think it's a big deal.
* The order of descriptors serialized gets changed. I don't think it
matters at all.
* Empty string as font-family via using string syntax is no longer
considered invalid for FontFace. I don't find it is mentioned anywhere
that it should be specifically treated invalid.
MozReview-Commit-ID: 32Fk3Fi9uTs
--HG--
extra : rebase_source : 6221ec8fc56de357b06dd27e770fb175348a2f77
2018-04-03 22:42:10 +00:00
|
|
|
ServoFontFaceRule* GetRule();
|
2018-01-11 04:38:01 +00:00
|
|
|
int32_t SrcIndex();
|
|
|
|
void GetURI(nsAString& aURI);
|
|
|
|
void GetLocalName(nsAString& aLocalName);
|
|
|
|
void GetFormat(nsAString& aFormat);
|
|
|
|
void GetMetadata(nsAString& aMetadata);
|
|
|
|
|
2018-01-29 13:24:11 +00:00
|
|
|
void GetVariationAxes(nsTArray<InspectorVariationAxis>& aResult,
|
|
|
|
ErrorResult& aRV);
|
|
|
|
void GetVariationInstances(nsTArray<InspectorVariationInstance>& aResult,
|
|
|
|
ErrorResult& aRV);
|
2018-01-30 09:57:39 +00:00
|
|
|
void GetFeatures(nsTArray<InspectorFontFeature>& aResult,
|
|
|
|
ErrorResult& aRV);
|
2018-01-26 15:47:20 +00:00
|
|
|
|
2018-02-15 18:48:22 +00:00
|
|
|
void GetRanges(nsTArray<RefPtr<nsRange>>& aResult);
|
|
|
|
|
2018-01-11 04:38:01 +00:00
|
|
|
bool WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto,
|
|
|
|
JS::MutableHandle<JSObject*> aReflector)
|
|
|
|
{
|
|
|
|
return InspectorFontFaceBinding::Wrap(aCx, this, aGivenProto, aReflector);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
RefPtr<gfxFontEntry> mFontEntry;
|
|
|
|
RefPtr<gfxFontGroup> mFontGroup;
|
Bug 1449087 part 2 - Use Servo data to back @font-face rule. r=emilio
This patch does the following things:
* Create a new class ServoFontFaceRule for CSSOM of @font-face rule
which mostly follows how nsCSSFontFaceRule was implemented.
* Remove the old nsCSSFontFaceRule and binding code to create it.
* Have FontFace backed by Servo data via making mRule and mDescriptors
of the class hold RawServoFontFaceRule like ServoFontFaceRule.
To keep this patch small, it effectively just delays the conversion
from Servo data to nsCSSValue from parsing to using. This may cause
worse performance if the font set is flushed repeatedly. Supposing we
don't flush font set very frequently, it may not be a big deal.
We may still want to remove the intermediate nsCSSValue conversion at
some point, and have everything converted to their final form directly
when used, but that can happen in followups.
There are some unfortunate bits from this change:
* We lose style sheet for logging in FontFaceSet. This is probably not
all that worse, because we wouldn't have that before either if the
page doesn't use CSSOM to visit it. But we should figure out some
approach to fix it anyway.
* InspectorFontFace no longer shares the same rule object as CSSOM.
This isn't really a problem if the @font-face rule isn't very mutable.
Unless we want to make the rule returned from InspectorFontFace to be
mutable (i.e. via inspector), not using the same object probably isn't
too bad.
This patch switches the code we use to serialize stuff in FontFace and
CSSFontFaceRule, which leads to some failures in tests. Specifically,
the expected changes including:
* Value of font-family now can be serialized to identifier sequence like
font-family property. The old code always serializes it to string,
but it doesn't seem to have different requirement than the property.
Blink can serialize to identifier as well.
* Family name inside local() is also changed to use the same way as
family names elsewhere (i.e. can be identifier sequence). Blink has
the same behavior as the old code, but I don't think it's a big deal.
* The order of descriptors serialized gets changed. I don't think it
matters at all.
* Empty string as font-family via using string syntax is no longer
considered invalid for FontFace. I don't find it is mentioned anywhere
that it should be specifically treated invalid.
MozReview-Commit-ID: 32Fk3Fi9uTs
--HG--
extra : rebase_source : 6221ec8fc56de357b06dd27e770fb175348a2f77
2018-04-03 22:42:10 +00:00
|
|
|
RefPtr<ServoFontFaceRule> mRule;
|
2018-05-11 07:56:12 +00:00
|
|
|
gfxTextRange::MatchType mMatchType;
|
2018-02-15 18:48:22 +00:00
|
|
|
|
|
|
|
nsTArray<RefPtr<nsRange>> mRanges;
|
2018-01-11 04:38:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_InspectorFontFace_h
|