Bug 1682003 - Avoid UTF-8 -> UTF-16 conversion during CSSOM serialization. r=heycam

This lifts a bunch of string conversions higher up the stack, but allows
us to make the servo code use utf-8 unconditionally, and seemed faster
in my benchmarking (see comment 0).

It should also make a bunch of attribute setters faster too (like
setting .cssText), now that we use UTF8String for them (we couldn't
because we couldn't specify different string types for the getter and
setters).

Differential Revision: https://phabricator.services.mozilla.com/D99590
This commit is contained in:
Emilio Cobos Álvarez 2020-12-17 14:04:35 +00:00
Родитель c2e233ef78
Коммит 039592f4d8
122 изменённых файлов: 672 добавлений и 750 удалений

Просмотреть файл

@ -21,12 +21,16 @@ StyleInfo::StyleInfo(dom::Element* aElement) : mElement(aElement) {
void StyleInfo::Display(nsAString& aValue) {
aValue.Truncate();
mComputedStyle->GetComputedPropertyValue(eCSSProperty_display, aValue);
nsAutoCString value;
mComputedStyle->GetComputedPropertyValue(eCSSProperty_display, value);
CopyUTF8toUTF16(value, aValue);
}
void StyleInfo::TextAlign(nsAString& aValue) {
aValue.Truncate();
mComputedStyle->GetComputedPropertyValue(eCSSProperty_text_align, aValue);
nsAutoCString value;
mComputedStyle->GetComputedPropertyValue(eCSSProperty_text_align, value);
CopyUTF8toUTF16(value, aValue);
}
void StyleInfo::TextIndent(nsAString& aValue) {

Просмотреть файл

@ -220,7 +220,7 @@ sdnAccessible::get_computedStyle(
for (index = realIndex = 0; index < length && realIndex < aMaxStyleProperties;
index++) {
nsAutoCString property;
nsAutoString value;
nsAutoCString value;
// Ignore -moz-* properties.
cssDecl->Item(index, property);
@ -230,7 +230,8 @@ sdnAccessible::get_computedStyle(
if (!value.IsEmpty()) {
aStyleProperties[realIndex] =
::SysAllocString(NS_ConvertUTF8toUTF16(property).get());
aStyleValues[realIndex] = ::SysAllocString(value.get());
aStyleValues[realIndex] =
::SysAllocString(NS_ConvertUTF8toUTF16(value).get());
++realIndex;
}
}
@ -256,12 +257,12 @@ sdnAccessible::get_computedStyleForProperties(
uint32_t index = 0;
for (index = 0; index < aNumStyleProperties; index++) {
nsAutoString value;
nsAutoCString value;
if (aStyleProperties[index])
cssDecl->GetPropertyValue(
NS_ConvertUTF16toUTF8(nsDependentString(aStyleProperties[index])),
value); // Get property value
aStyleValues[index] = ::SysAllocString(value.get());
aStyleValues[index] = ::SysAllocString(NS_ConvertUTF8toUTF16(value).get());
}
return S_OK;

Просмотреть файл

@ -167,7 +167,7 @@ int32_t ComputedTimingFunction::Compare(
return 0;
}
void ComputedTimingFunction::AppendToString(nsAString& aResult) const {
void ComputedTimingFunction::AppendToString(nsACString& aResult) const {
nsTimingFunction timing;
switch (mType) {
case Type::CubicBezier:

Просмотреть файл

@ -94,7 +94,7 @@ class ComputedTimingFunction {
return !(*this == aOther);
}
int32_t Compare(const ComputedTimingFunction& aRhs) const;
void AppendToString(nsAString& aResult) const;
void AppendToString(nsACString& aResult) const;
static double GetPortion(const Maybe<ComputedTimingFunction>& aFunction,
double aPortion, BeforeFlag aBeforeFlag) {

Просмотреть файл

@ -1037,12 +1037,11 @@ void DumpAnimationProperties(
for (auto& p : aAnimationProperties) {
printf("%s\n", nsCString(nsCSSProps::GetStringValue(p.mProperty)).get());
for (auto& s : p.mSegments) {
nsString fromValue, toValue;
nsAutoCString fromValue, toValue;
s.mFromValue.SerializeSpecifiedValue(p.mProperty, aRawSet, fromValue);
s.mToValue.SerializeSpecifiedValue(p.mProperty, aRawSet, toValue);
printf(" %f..%f: %s..%s\n", s.mFromKey, s.mToKey,
NS_ConvertUTF16toUTF8(fromValue).get(),
NS_ConvertUTF16toUTF8(toValue).get());
printf(" %f..%f: %s..%s\n", s.mFromKey, s.mToKey, fromValue.get(),
toValue.get());
}
}
}
@ -1131,7 +1130,7 @@ static void CreatePropertyValue(
aResult.mOffset = aOffset;
if (!aValue.IsNull()) {
nsString stringValue;
nsAutoCString stringValue;
aValue.SerializeSpecifiedValue(aProperty, aRawSet, stringValue);
aResult.mValue.Construct(stringValue);
}
@ -1140,7 +1139,7 @@ static void CreatePropertyValue(
aResult.mEasing.Construct();
aTimingFunction->AppendToString(aResult.mEasing.Value());
} else {
aResult.mEasing.Construct(u"linear"_ns);
aResult.mEasing.Construct("linear"_ns);
}
aResult.mComposite = aComposite;
@ -1298,7 +1297,7 @@ void KeyframeEffect::GetKeyframes(JSContext* aCx, nsTArray<JSObject*>& aResult,
JS::Rooted<JSObject*> keyframeObject(aCx, &keyframeJSValue.toObject());
for (const PropertyValuePair& propertyValue : keyframe.mPropertyValues) {
nsAutoString stringValue;
nsAutoCString stringValue;
// Don't serialize the custom properties for this keyframe.
if (propertyValue.mProperty ==
nsCSSPropertyID::eCSSPropertyExtra_variable) {
@ -1338,7 +1337,7 @@ void KeyframeEffect::GetKeyframes(JSContext* aCx, nsTArray<JSObject*>& aResult,
}
JS::Rooted<JS::Value> value(aCx);
if (!ToJSValue(aCx, stringValue, &value) ||
if (!NonVoidUTF8StringToJsval(aCx, stringValue, &value) ||
!JS_DefineProperty(aCx, keyframeObject, name, value,
JSPROP_ENUMERATE)) {
aRv.Throw(NS_ERROR_FAILURE);

Просмотреть файл

@ -60,7 +60,7 @@ enum class ListAllowance { eDisallow, eAllow };
*/
struct PropertyValuesPair {
nsCSSPropertyID mProperty;
nsTArray<nsString> mValues;
nsTArray<nsCString> mValues;
};
/**
@ -153,13 +153,13 @@ static bool GetPropertyValuesPairs(JSContext* aCx,
static bool AppendStringOrStringSequenceToArray(JSContext* aCx,
JS::Handle<JS::Value> aValue,
ListAllowance aAllowLists,
nsTArray<nsString>& aValues);
nsTArray<nsCString>& aValues);
static bool AppendValueAsString(JSContext* aCx, nsTArray<nsString>& aValues,
static bool AppendValueAsString(JSContext* aCx, nsTArray<nsCString>& aValues,
JS::Handle<JS::Value> aValue);
static Maybe<PropertyValuePair> MakePropertyValuePair(
nsCSSPropertyID aProperty, const nsAString& aStringValue,
nsCSSPropertyID aProperty, const nsACString& aStringValue,
dom::Document* aDocument);
static bool HasValidOffsets(const nsTArray<Keyframe>& aKeyframes);
@ -574,7 +574,7 @@ static bool GetPropertyValuesPairs(JSContext* aCx,
static bool AppendStringOrStringSequenceToArray(JSContext* aCx,
JS::Handle<JS::Value> aValue,
ListAllowance aAllowLists,
nsTArray<nsString>& aValues) {
nsTArray<nsCString>& aValues) {
if (aAllowLists == ListAllowance::eAllow && aValue.isObject()) {
// The value is an object, and we want to allow lists; convert
// aValue to (DOMString or sequence<DOMString>).
@ -613,17 +613,17 @@ static bool AppendStringOrStringSequenceToArray(JSContext* aCx,
/**
* Converts aValue to DOMString and appends it to aValues.
*/
static bool AppendValueAsString(JSContext* aCx, nsTArray<nsString>& aValues,
static bool AppendValueAsString(JSContext* aCx, nsTArray<nsCString>& aValues,
JS::Handle<JS::Value> aValue) {
return ConvertJSValueToString(aCx, aValue, dom::eStringify, dom::eStringify,
*aValues.AppendElement());
}
static void ReportInvalidPropertyValueToConsole(
nsCSSPropertyID aProperty, const nsAString& aInvalidPropertyValue,
nsCSSPropertyID aProperty, const nsACString& aInvalidPropertyValue,
dom::Document* aDoc) {
AutoTArray<nsString, 2> params;
params.AppendElement(aInvalidPropertyValue);
params.AppendElement(NS_ConvertUTF8toUTF16(aInvalidPropertyValue));
CopyASCIItoUTF16(nsCSSProps::GetStringValue(aProperty),
*params.AppendElement());
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "Animation"_ns,
@ -642,7 +642,7 @@ static void ReportInvalidPropertyValueToConsole(
* an invalid property value.
*/
static Maybe<PropertyValuePair> MakePropertyValuePair(
nsCSSPropertyID aProperty, const nsAString& aStringValue,
nsCSSPropertyID aProperty, const nsACString& aStringValue,
dom::Document* aDocument) {
MOZ_ASSERT(aDocument);
Maybe<PropertyValuePair> result;
@ -1017,7 +1017,7 @@ static void GetKeyframeListFromPropertyIndexedKeyframe(
size_t n = pair.mValues.Length() - 1;
size_t i = 0;
for (const nsString& stringValue : pair.mValues) {
for (const nsCString& stringValue : pair.mValues) {
// For single-valued lists, the single value should be added to a
// keyframe with offset 1.
double offset = n ? i++ / double(n) : 1;
@ -1097,7 +1097,7 @@ static void GetKeyframeListFromPropertyIndexedKeyframe(
// This corresponds to step 5, "Otherwise," branch, substeps 7-11 of
// https://drafts.csswg.org/web-animations/#processing-a-keyframes-argument
FallibleTArray<Maybe<ComputedTimingFunction>> easings;
auto parseAndAppendEasing = [&](const nsString& easingString,
auto parseAndAppendEasing = [&](const nsACString& easingString,
ErrorResult& aRv) {
auto easing = TimingParams::ParseEasing(easingString, aRv);
if (!aRv.Failed() && !easings.AppendElement(std::move(easing), fallible)) {
@ -1106,14 +1106,14 @@ static void GetKeyframeListFromPropertyIndexedKeyframe(
};
auto& easing = keyframeDict.mEasing;
if (easing.IsString()) {
parseAndAppendEasing(easing.GetAsString(), aRv);
if (easing.IsUTF8String()) {
parseAndAppendEasing(easing.GetAsUTF8String(), aRv);
if (aRv.Failed()) {
aResult.Clear();
return;
}
} else {
for (const nsString& easingString : easing.GetAsStringSequence()) {
for (const auto& easingString : easing.GetAsUTF8StringSequence()) {
parseAndAppendEasing(easingString, aRv);
if (aRv.Failed()) {
aResult.Clear();

Просмотреть файл

@ -190,11 +190,10 @@ TimingParams TimingParams::MergeOptionalEffectTiming(
/* static */
Maybe<ComputedTimingFunction> TimingParams::ParseEasing(
const nsAString& aEasing, ErrorResult& aRv) {
const nsACString& aEasing, ErrorResult& aRv) {
nsTimingFunction timingFunction;
if (!ServoCSSParser::ParseEasing(aEasing, timingFunction)) {
aRv.ThrowTypeError<dom::MSG_INVALID_EASING_ERROR>(
NS_ConvertUTF16toUTF8(aEasing));
aRv.ThrowTypeError<dom::MSG_INVALID_EASING_ERROR>(aEasing);
return Nothing();
}

Просмотреть файл

@ -119,7 +119,7 @@ struct TimingParams {
}
}
static Maybe<ComputedTimingFunction> ParseEasing(const nsAString& aEasing,
static Maybe<ComputedTimingFunction> ParseEasing(const nsACString& aEasing,
ErrorResult& aRv);
static StickyTimeDuration CalcActiveDuration(

Просмотреть файл

@ -179,7 +179,7 @@ bool AnonymousContent::WrapObject(JSContext* aCx,
void AnonymousContent::GetComputedStylePropertyValue(
const nsAString& aElementId, const nsACString& aPropertyName,
DOMString& aResult, ErrorResult& aRv) {
nsACString& aResult, ErrorResult& aRv) {
Element* element = GetElementById(aElementId);
if (!element) {
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
@ -215,7 +215,7 @@ void AnonymousContent::SetStyle(const nsACString& aProperty,
nsGenericHTMLElement* element = nsGenericHTMLElement::FromNode(mContentNode);
nsCOMPtr<nsICSSDeclaration> declaration = element->Style();
declaration->SetProperty(aProperty, aValue, u""_ns, IgnoreErrors());
declaration->SetProperty(aProperty, aValue, ""_ns, IgnoreErrors());
}
} // namespace mozilla::dom

Просмотреть файл

@ -75,7 +75,7 @@ class AnonymousContent final {
void GetComputedStylePropertyValue(const nsAString& aElementId,
const nsACString& aPropertyName,
DOMString& aResult, ErrorResult& aRv);
nsACString& aResult, ErrorResult& aRv);
void GetTargetIdForEvent(Event& aEvent, DOMString& aResult);

Просмотреть файл

@ -189,15 +189,14 @@ DOMIntersectionObserver::CreateLazyLoadObserver(Document& aDocument) {
return observer.forget();
}
bool DOMIntersectionObserver::SetRootMargin(const nsAString& aString) {
bool DOMIntersectionObserver::SetRootMargin(const nsACString& aString) {
return Servo_IntersectionObserverRootMargin_Parse(&aString, &mRootMargin);
}
nsISupports* DOMIntersectionObserver::GetParentObject() const { return mOwner; }
void DOMIntersectionObserver::GetRootMargin(DOMString& aRetVal) {
nsString& retVal = aRetVal;
Servo_IntersectionObserverRootMargin_ToString(&mRootMargin, &retVal);
void DOMIntersectionObserver::GetRootMargin(nsACString& aRetVal) {
Servo_IntersectionObserverRootMargin_ToString(&mRootMargin, &aRetVal);
}
void DOMIntersectionObserver::GetThresholds(nsTArray<double>& aRetVal) {

Просмотреть файл

@ -110,7 +110,9 @@ class DOMIntersectionObserver final : public nsISupports,
nsINode* GetRoot() const { return mRoot; }
void GetRootMargin(DOMString& aRetVal);
void GetRootMargin(nsACString&);
bool SetRootMargin(const nsACString&);
void GetThresholds(nsTArray<double>& aRetVal);
void Observe(Element& aTarget);
void Unobserve(Element& aTarget);
@ -120,8 +122,6 @@ class DOMIntersectionObserver final : public nsISupports,
void TakeRecords(nsTArray<RefPtr<DOMIntersectionObserverEntry>>& aRetVal);
bool SetRootMargin(const nsAString& aString);
void Update(Document* aDocument, DOMHighResTimeStamp time);
MOZ_CAN_RUN_SCRIPT void Notify();

Просмотреть файл

@ -8736,7 +8736,7 @@ void Document::DoNotifyPossibleTitleChange() {
}
already_AddRefed<MediaQueryList> Document::MatchMedia(
const nsAString& aMediaQueryList, CallerType aCallerType) {
const nsACString& aMediaQueryList, CallerType aCallerType) {
RefPtr<MediaQueryList> result =
new MediaQueryList(this, aMediaQueryList, aCallerType);

Просмотреть файл

@ -2471,7 +2471,7 @@ class Document : public nsINode,
* Support for window.matchMedia()
*/
already_AddRefed<MediaQueryList> MatchMedia(const nsAString& aMediaQueryList,
already_AddRefed<MediaQueryList> MatchMedia(const nsACString& aMediaQueryList,
CallerType aCallerType);
LinkedList<MediaQueryList>& MediaQueryLists() { return mDOMMediaQueryLists; }

Просмотреть файл

@ -562,7 +562,9 @@ void nsAttrValue::ToString(nsAString& aResult) const {
aResult.Truncate();
MiscContainer* container = GetMiscContainer();
if (DeclarationBlock* decl = container->mValue.mCSSDeclaration) {
decl->ToString(aResult);
nsAutoCString result;
decl->ToString(result);
CopyUTF8toUTF16(result, aResult);
}
// This can be reached during parallel selector matching with attribute

Просмотреть файл

@ -2171,11 +2171,14 @@ nsDOMWindowUtils::GetVisitedDependentComputedStyle(
ENSURE_SUCCESS(rv, rv.StealNSResult());
}
nsAutoCString result;
static_cast<nsComputedDOMStyle*>(decl.get())->SetExposeVisitedStyle(true);
nsresult rv =
decl->GetPropertyValue(NS_ConvertUTF16toUTF8(aPropertyName), aResult);
decl->GetPropertyValue(NS_ConvertUTF16toUTF8(aPropertyName), result);
static_cast<nsComputedDOMStyle*>(decl.get())->SetExposeVisitedStyle(false);
CopyUTF8toUTF16(result, aResult);
return rv;
}
@ -2822,8 +2825,10 @@ nsDOMWindowUtils::ComputeAnimationDistance(Element* aElement,
return NS_ERROR_ILLEGAL_VALUE;
}
AnimationValue v1 = AnimationValue::FromString(property, aValue1, aElement);
AnimationValue v2 = AnimationValue::FromString(property, aValue2, aElement);
AnimationValue v1 = AnimationValue::FromString(
property, NS_ConvertUTF16toUTF8(aValue1), aElement);
AnimationValue v2 = AnimationValue::FromString(
property, NS_ConvertUTF16toUTF8(aValue2), aElement);
if (v1.IsNull() || v2.IsNull()) {
return NS_ERROR_ILLEGAL_VALUE;
}
@ -2883,8 +2888,10 @@ nsDOMWindowUtils::GetUnanimatedComputedStyle(Element* aElement,
if (!aElement->GetComposedDoc()) {
return NS_ERROR_FAILURE;
}
nsAutoCString result;
Servo_AnimationValue_Serialize(value, propertyID,
presShell->StyleSet()->RawSet(), &aResult);
presShell->StyleSet()->RawSet(), &result);
CopyUTF8toUTF16(result, aResult);
return NS_OK;
}

Просмотреть файл

@ -3539,7 +3539,7 @@ void nsGlobalWindowInner::CancelAnimationFrame(int32_t aHandle,
}
already_AddRefed<MediaQueryList> nsGlobalWindowInner::MatchMedia(
const nsAString& aMediaQueryList, CallerType aCallerType,
const nsACString& aMediaQueryList, CallerType aCallerType,
ErrorResult& aError) {
ENSURE_ACTIVE_DOCUMENT(aError, nullptr);
return mDoc->MatchMedia(aMediaQueryList, aCallerType);

Просмотреть файл

@ -737,7 +737,7 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
mozilla::ErrorResult& aError) override;
mozilla::dom::VisualViewport* VisualViewport();
already_AddRefed<mozilla::dom::MediaQueryList> MatchMedia(
const nsAString& aQuery, mozilla::dom::CallerType aCallerType,
const nsACString& aQuery, mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aError);
nsScreen* GetScreen(mozilla::ErrorResult& aError);
void MoveTo(int32_t aXPos, int32_t aYPos,

Просмотреть файл

@ -10,8 +10,10 @@ import runpy
# Generates a line of WebIDL with the given spelling of the property name
# (whether camelCase, _underscorePrefixed, etc.) and the given array of
# extended attributes.
def generateLine(propName, extendedAttrs):
return " [%s] attribute [TreatNullAs=EmptyString] DOMString %s;\n" % (
return " [%s] attribute [TreatNullAs=EmptyString] UTF8String %s;\n" % (
", ".join(extendedAttrs),
propName,
)

Просмотреть файл

@ -66,13 +66,13 @@ class BasicRenderingContext2D {
// CanvasFillStrokeStyles
//
virtual void GetStrokeStyle(
OwningStringOrCanvasGradientOrCanvasPattern& aValue) = 0;
OwningUTF8StringOrCanvasGradientOrCanvasPattern& aValue) = 0;
virtual void SetStrokeStyle(
const StringOrCanvasGradientOrCanvasPattern& aValue) = 0;
const UTF8StringOrCanvasGradientOrCanvasPattern& aValue) = 0;
virtual void GetFillStyle(
OwningStringOrCanvasGradientOrCanvasPattern& aValue) = 0;
OwningUTF8StringOrCanvasGradientOrCanvasPattern& aValue) = 0;
virtual void SetFillStyle(
const StringOrCanvasGradientOrCanvasPattern& aValue) = 0;
const UTF8StringOrCanvasGradientOrCanvasPattern& aValue) = 0;
virtual already_AddRefed<CanvasGradient> CreateLinearGradient(double aX0,
double aY0,
double aX1,
@ -92,8 +92,8 @@ class BasicRenderingContext2D {
virtual void SetShadowOffsetY(double aShadowOffsetY) = 0;
virtual double ShadowBlur() = 0;
virtual void SetShadowBlur(double aShadowBlur) = 0;
virtual void GetShadowColor(nsAString& aShadowColor) = 0;
virtual void SetShadowColor(const nsAString& aShadowColor) = 0;
virtual void GetShadowColor(nsACString& aShadowColor) = 0;
virtual void SetShadowColor(const nsACString& aShadowColor) = 0;
//
// CanvasRect

Просмотреть файл

@ -1054,12 +1054,12 @@ void CanvasRenderingContext2D::RemoveShutdownObserver() {
}
}
void CanvasRenderingContext2D::SetStyleFromString(const nsAString& aStr,
void CanvasRenderingContext2D::SetStyleFromString(const nsACString& aStr,
Style aWhichStyle) {
MOZ_ASSERT(!aStr.IsVoid());
nscolor color;
if (!ParseColor(NS_ConvertUTF16toUTF8(aStr), &color)) {
if (!ParseColor(aStr, &color)) {
return;
}
@ -1067,30 +1067,31 @@ void CanvasRenderingContext2D::SetStyleFromString(const nsAString& aStr,
}
void CanvasRenderingContext2D::GetStyleAsUnion(
OwningStringOrCanvasGradientOrCanvasPattern& aValue, Style aWhichStyle) {
OwningUTF8StringOrCanvasGradientOrCanvasPattern& aValue,
Style aWhichStyle) {
const ContextState& state = CurrentState();
if (state.patternStyles[aWhichStyle]) {
aValue.SetAsCanvasPattern() = state.patternStyles[aWhichStyle];
} else if (state.gradientStyles[aWhichStyle]) {
aValue.SetAsCanvasGradient() = state.gradientStyles[aWhichStyle];
} else {
StyleColorToString(state.colorStyles[aWhichStyle], aValue.SetAsString());
StyleColorToString(state.colorStyles[aWhichStyle],
aValue.SetAsUTF8String());
}
}
// static
void CanvasRenderingContext2D::StyleColorToString(const nscolor& aColor,
nsAString& aStr) {
nsACString& aStr) {
aStr.Truncate();
// We can't reuse the normal CSS color stringification code,
// because the spec calls for a different algorithm for canvas.
if (NS_GET_A(aColor) == 255) {
CopyUTF8toUTF16(nsPrintfCString("#%02x%02x%02x", NS_GET_R(aColor),
NS_GET_G(aColor), NS_GET_B(aColor)),
aStr);
aStr.AppendPrintf("#%02x%02x%02x", NS_GET_R(aColor), NS_GET_G(aColor),
NS_GET_B(aColor));
} else {
CopyUTF8toUTF16(nsPrintfCString("rgba(%d, %d, %d, ", NS_GET_R(aColor),
NS_GET_G(aColor), NS_GET_B(aColor)),
aStr);
aStr.AppendPrintf("rgba(%d, %d, %d, ", NS_GET_R(aColor), NS_GET_G(aColor),
NS_GET_B(aColor));
aStr.AppendFloat(nsStyleUtil::ColorComponentToFloat(NS_GET_A(aColor)));
aStr.Append(')');
}
@ -1991,9 +1992,10 @@ void CanvasRenderingContext2D::GetMozCurrentTransformInverse(
//
void CanvasRenderingContext2D::SetStyleFromUnion(
const StringOrCanvasGradientOrCanvasPattern& aValue, Style aWhichStyle) {
if (aValue.IsString()) {
SetStyleFromString(aValue.GetAsString(), aWhichStyle);
const UTF8StringOrCanvasGradientOrCanvasPattern& aValue,
Style aWhichStyle) {
if (aValue.IsUTF8String()) {
SetStyleFromString(aValue.GetAsUTF8String(), aWhichStyle);
return;
}
@ -2193,9 +2195,9 @@ already_AddRefed<CanvasPattern> CanvasRenderingContext2D::CreatePattern(
//
// shadows
//
void CanvasRenderingContext2D::SetShadowColor(const nsAString& aShadowColor) {
void CanvasRenderingContext2D::SetShadowColor(const nsACString& aShadowColor) {
nscolor color;
if (!ParseColor(NS_ConvertUTF16toUTF8(aShadowColor), &color)) {
if (!ParseColor(aShadowColor, &color)) {
return;
}
@ -2207,7 +2209,7 @@ void CanvasRenderingContext2D::SetShadowColor(const nsAString& aShadowColor) {
//
static already_AddRefed<RawServoDeclarationBlock> CreateDeclarationForServo(
nsCSSPropertyID aProperty, const nsAString& aPropertyValue,
nsCSSPropertyID aProperty, const nsACString& aPropertyValue,
Document* aDocument) {
ServoCSSParser::ParsingEnvironment env{aDocument->DefaultStyleAttrURLData(),
aDocument->GetCompatibilityMode(),
@ -2234,13 +2236,13 @@ static already_AddRefed<RawServoDeclarationBlock> CreateDeclarationForServo(
}
static already_AddRefed<RawServoDeclarationBlock> CreateFontDeclarationForServo(
const nsAString& aFont, Document* aDocument) {
const nsACString& aFont, Document* aDocument) {
return CreateDeclarationForServo(eCSSProperty_font, aFont, aDocument);
}
static already_AddRefed<ComputedStyle> GetFontStyleForServo(
Element* aElement, const nsAString& aFont, PresShell* aPresShell,
nsAString& aOutUsedFont, ErrorResult& aError) {
Element* aElement, const nsACString& aFont, PresShell* aPresShell,
nsACString& aOutUsedFont, ErrorResult& aError) {
RefPtr<RawServoDeclarationBlock> declarations =
CreateFontDeclarationForServo(aFont, aPresShell->GetDocument());
if (!declarations) {
@ -2271,7 +2273,7 @@ static already_AddRefed<ComputedStyle> GetFontStyleForServo(
}
} else {
RefPtr<RawServoDeclarationBlock> declarations =
CreateFontDeclarationForServo(u"10px sans-serif"_ns,
CreateFontDeclarationForServo("10px sans-serif"_ns,
aPresShell->GetDocument());
MOZ_ASSERT(declarations);
@ -2297,12 +2299,13 @@ static already_AddRefed<ComputedStyle> GetFontStyleForServo(
}
static already_AddRefed<RawServoDeclarationBlock>
CreateFilterDeclarationForServo(const nsAString& aFilter, Document* aDocument) {
CreateFilterDeclarationForServo(const nsACString& aFilter,
Document* aDocument) {
return CreateDeclarationForServo(eCSSProperty_filter, aFilter, aDocument);
}
static already_AddRefed<ComputedStyle> ResolveFilterStyleForServo(
const nsAString& aFilterString, const ComputedStyle* aParentStyle,
const nsACString& aFilterString, const ComputedStyle* aParentStyle,
PresShell* aPresShell, ErrorResult& aError) {
RefPtr<RawServoDeclarationBlock> declarations =
CreateFilterDeclarationForServo(aFilterString, aPresShell->GetDocument());
@ -2326,7 +2329,7 @@ static already_AddRefed<ComputedStyle> ResolveFilterStyleForServo(
}
bool CanvasRenderingContext2D::ParseFilter(
const nsAString& aString, StyleOwnedSlice<StyleFilter>& aFilterChain,
const nsACString& aString, StyleOwnedSlice<StyleFilter>& aFilterChain,
ErrorResult& aError) {
if (!mCanvasElement && !mDocShell) {
NS_WARNING(
@ -2341,7 +2344,7 @@ bool CanvasRenderingContext2D::ParseFilter(
return false;
}
nsAutoString usedFont; // unused
nsAutoCString usedFont; // unused
RefPtr<ComputedStyle> parentStyle = GetFontStyleForServo(
mCanvasElement, GetFont(), presShell, usedFont, aError);
@ -2359,7 +2362,7 @@ bool CanvasRenderingContext2D::ParseFilter(
return true;
}
void CanvasRenderingContext2D::SetFilter(const nsAString& aFilter,
void CanvasRenderingContext2D::SetFilter(const nsACString& aFilter,
ErrorResult& aError) {
StyleOwnedSlice<StyleFilter> filterChain;
if (ParseFilter(aFilter, filterChain, aError)) {
@ -3182,12 +3185,12 @@ void CanvasRenderingContext2D::TransformWillUpdate() {
// text
//
void CanvasRenderingContext2D::SetFont(const nsAString& aFont,
void CanvasRenderingContext2D::SetFont(const nsACString& aFont,
ErrorResult& aError) {
SetFontInternal(aFont, aError);
}
bool CanvasRenderingContext2D::SetFontInternal(const nsAString& aFont,
bool CanvasRenderingContext2D::SetFontInternal(const nsACString& aFont,
ErrorResult& aError) {
/*
* If font is defined with relative units (e.g. ems) and the parent
@ -3210,7 +3213,7 @@ bool CanvasRenderingContext2D::SetFontInternal(const nsAString& aFont,
return false;
}
nsString usedFont;
nsCString usedFont;
RefPtr<ComputedStyle> sc =
GetFontStyleForServo(mCanvasElement, aFont, presShell, usedFont, aError);
if (!sc) {
@ -4010,7 +4013,7 @@ gfxFontGroup* CanvasRenderingContext2D::GetCurrentFontStyle() {
// use lazy initilization for the font group since it's rather expensive
if (!CurrentState().fontGroup) {
ErrorResult err;
constexpr auto kDefaultFontStyle = u"10px sans-serif"_ns;
constexpr auto kDefaultFontStyle = "10px sans-serif"_ns;
static float kDefaultFontSize = 10.0;
RefPtr<PresShell> presShell = GetPresShell();
bool fontUpdated = SetFontInternal(kDefaultFontStyle, err);

Просмотреть файл

@ -46,8 +46,8 @@ typedef HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOr
CanvasImageSource;
class ImageBitmap;
class ImageData;
class StringOrCanvasGradientOrCanvasPattern;
class OwningStringOrCanvasGradientOrCanvasPattern;
class UTF8StringOrCanvasGradientOrCanvasPattern;
class OwningUTF8StringOrCanvasGradientOrCanvasPattern;
class TextMetrics;
class CanvasGradient;
class CanvasPath;
@ -130,22 +130,22 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
mozilla::ErrorResult& aError) override;
void GetStrokeStyle(
OwningStringOrCanvasGradientOrCanvasPattern& aValue) override {
OwningUTF8StringOrCanvasGradientOrCanvasPattern& aValue) override {
GetStyleAsUnion(aValue, Style::STROKE);
}
void SetStrokeStyle(
const StringOrCanvasGradientOrCanvasPattern& aValue) override {
const UTF8StringOrCanvasGradientOrCanvasPattern& aValue) override {
SetStyleFromUnion(aValue, Style::STROKE);
}
void GetFillStyle(
OwningStringOrCanvasGradientOrCanvasPattern& aValue) override {
OwningUTF8StringOrCanvasGradientOrCanvasPattern& aValue) override {
GetStyleAsUnion(aValue, Style::FILL);
}
void SetFillStyle(
const StringOrCanvasGradientOrCanvasPattern& aValue) override {
const UTF8StringOrCanvasGradientOrCanvasPattern& aValue) override {
SetStyleFromUnion(aValue, Style::FILL);
}
@ -179,14 +179,14 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
}
}
void GetShadowColor(nsAString& aShadowColor) override {
void GetShadowColor(nsACString& aShadowColor) override {
StyleColorToString(CurrentState().shadowColor, aShadowColor);
}
void GetFilter(nsAString& aFilter) { aFilter = CurrentState().filterString; }
void GetFilter(nsACString& aFilter) { aFilter = CurrentState().filterString; }
void SetShadowColor(const nsAString& aShadowColor) override;
void SetFilter(const nsAString& aFilter, mozilla::ErrorResult& aError);
void SetShadowColor(const nsACString& aShadowColor) override;
void SetFilter(const nsACString& aFilter, mozilla::ErrorResult& aError);
void ClearRect(double aX, double aY, double aW, double aH) override;
void FillRect(double aX, double aY, double aW, double aH) override;
void StrokeRect(double aX, double aY, double aW, double aH) override;
@ -277,9 +277,9 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
}
}
void GetFont(nsAString& aFont) { aFont = GetFont(); }
void GetFont(nsACString& aFont) { aFont = GetFont(); }
void SetFont(const nsAString& aFont, mozilla::ErrorResult& aError);
void SetFont(const nsACString& aFont, mozilla::ErrorResult& aError);
void GetTextAlign(nsAString& aTextAlign);
void SetTextAlign(const nsAString& aTextAlign);
void GetTextBaseline(nsAString& aTextBaseline);
@ -371,9 +371,9 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
void SetLineDashOffset(double aOffset) override;
double LineDashOffset() const override;
void GetMozTextStyle(nsAString& aMozTextStyle) { GetFont(aMozTextStyle); }
void GetMozTextStyle(nsACString& aMozTextStyle) { GetFont(aMozTextStyle); }
void SetMozTextStyle(const nsAString& aMozTextStyle,
void SetMozTextStyle(const nsACString& aMozTextStyle,
mozilla::ErrorResult& aError) {
SetFont(aMozTextStyle, aError);
}
@ -543,9 +543,10 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
void SetTransformInternal(const mozilla::gfx::Matrix& aTransform);
// Some helpers. Doesn't modify a color on failure.
void SetStyleFromUnion(const StringOrCanvasGradientOrCanvasPattern& aValue,
Style aWhichStyle);
void SetStyleFromString(const nsAString& aStr, Style aWhichStyle);
void SetStyleFromUnion(
const UTF8StringOrCanvasGradientOrCanvasPattern& aValue,
Style aWhichStyle);
void SetStyleFromString(const nsACString& aStr, Style aWhichStyle);
void SetStyleFromGradient(CanvasGradient& aGradient, Style aWhichStyle) {
CurrentState().SetGradientStyle(aWhichStyle, &aGradient);
@ -555,21 +556,21 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
CurrentState().SetPatternStyle(aWhichStyle, &aPattern);
}
void GetStyleAsUnion(OwningStringOrCanvasGradientOrCanvasPattern& aValue,
void GetStyleAsUnion(OwningUTF8StringOrCanvasGradientOrCanvasPattern& aValue,
Style aWhichStyle);
// Returns whether a color was successfully parsed.
bool ParseColor(const nsACString& aString, nscolor* aColor);
static void StyleColorToString(const nscolor& aColor, nsAString& aStr);
static void StyleColorToString(const nscolor& aColor, nsACString& aStr);
// Returns whether a filter was successfully parsed.
bool ParseFilter(const nsAString& aString,
bool ParseFilter(const nsACString& aString,
StyleOwnedSlice<StyleFilter>& aFilterChain,
ErrorResult& aError);
// Returns whether the font was successfully updated.
bool SetFontInternal(const nsAString& aFont, mozilla::ErrorResult& aError);
bool SetFontInternal(const nsACString& aFont, mozilla::ErrorResult& aError);
// Clears the target and updates mOpaque based on mOpaqueAttrValue and
// mContextAttributesHasAlpha.
@ -682,7 +683,7 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
mozilla::gfx::Rect aDest, mozilla::gfx::Rect aSrc,
gfx::IntSize aImgSize);
nsString& GetFont() {
nsCString& GetFont() {
/* will initilize the value if not set, else does nothing */
GetCurrentFontStyle();
@ -931,7 +932,7 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
EnumeratedArray<Style, Style::MAX, RefPtr<CanvasPattern>> patternStyles;
EnumeratedArray<Style, Style::MAX, nscolor> colorStyles;
nsString font;
nsCString font;
TextAlign textAlign = TextAlign::START;
TextBaseline textBaseline = TextBaseline::ALPHABETIC;
@ -952,7 +953,7 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
mozilla::gfx::CapStyle lineCap = mozilla::gfx::CapStyle::BUTT;
mozilla::gfx::JoinStyle lineJoin = mozilla::gfx::JoinStyle::MITER_OR_BEVEL;
nsString filterString = nsString(u"none");
nsCString filterString{"none"};
StyleOwnedSlice<StyleFilter> filterChain;
// RAII object that we obtain when we start to observer SVG filter elements
// for rendering changes. When released we stop observing the SVG elements.

Просмотреть файл

@ -23,8 +23,8 @@ namespace InspectorUtils {
unsigned long getRelativeRuleLine(CSSRule rule);
boolean hasRulesModifiedByCSSOM(CSSStyleSheet sheet);
unsigned long getSelectorCount(CSSStyleRule rule);
[Throws] DOMString getSelectorText(CSSStyleRule rule,
unsigned long selectorIndex);
[Throws] UTF8String getSelectorText(CSSStyleRule rule,
unsigned long selectorIndex);
[Throws] unsigned long long getSpecificity(CSSStyleRule rule,
unsigned long selectorIndex);
[Throws] boolean selectorMatchesElement(

Просмотреть файл

@ -54,7 +54,7 @@ void HTMLFontElement::MapAttributesIntoRule(
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::face);
if (value && value->Type() == nsAttrValue::eString &&
!value->IsEmptyString()) {
aDecls.SetFontFamily(value->GetStringValue());
aDecls.SetFontFamily(NS_ConvertUTF16toUTF8(value->GetStringValue()));
}
}
// size: int

Просмотреть файл

@ -793,7 +793,8 @@ bool HTMLLinkElement::CheckPreloadAttrs(const nsAttrValue& aAs,
// Check if media attribute is valid.
if (!aMedia.IsEmpty()) {
RefPtr<MediaList> mediaList = MediaList::Create(aMedia);
RefPtr<MediaList> mediaList =
MediaList::Create(NS_ConvertUTF16toUTF8(aMedia));
if (!mediaList->Matches(*aDocument)) {
return false;
}

Просмотреть файл

@ -53,17 +53,18 @@ bool HTMLSourceElement::WouldMatchMediaForDocument(const nsAString& aMedia,
return true;
}
RefPtr<MediaList> mediaList = MediaList::Create(aMedia);
RefPtr<MediaList> mediaList =
MediaList::Create(NS_ConvertUTF16toUTF8(aMedia));
return mediaList->Matches(*aDocument);
}
void HTMLSourceElement::UpdateMediaList(const nsAttrValue* aValue) {
mMediaList = nullptr;
nsString mediaStr;
if (!aValue || (mediaStr = aValue->GetStringValue()).IsEmpty()) {
if (!aValue) {
return;
}
NS_ConvertUTF16toUTF8 mediaStr(aValue->GetStringValue());
mMediaList = MediaList::Create(mediaStr);
}

Просмотреть файл

@ -541,7 +541,7 @@ void MathMLElement::MapMathMLAttributesInto(
}
if (value && value->Type() == nsAttrValue::eString &&
!aDecls.PropertyIsSet(eCSSProperty_font_family)) {
aDecls.SetFontFamily(value->GetStringValue());
aDecls.SetFontFamily(NS_ConvertUTF16toUTF8(value->GetStringValue()));
}
// fontstyle

Просмотреть файл

@ -425,7 +425,8 @@ static ServoAnimationValues ValueFromStringHelper(nsCSSPropertyID aPropID,
ServoCSSParser::ParsingEnvironment env =
ServoCSSParser::GetParsingEnvironment(doc);
RefPtr<RawServoDeclarationBlock> servoDeclarationBlock =
ServoCSSParser::ParseProperty(aPropID, aString, env,
ServoCSSParser::ParseProperty(aPropID, NS_ConvertUTF16toUTF8(aString),
env,
ParsingMode::AllowUnitlessLength |
ParsingMode::AllowAllNumericValues);
if (!servoDeclarationBlock) {

Просмотреть файл

@ -33,7 +33,7 @@ dictionary EffectTiming {
unrestricted double iterations = 1.0;
(unrestricted double or DOMString) duration = "auto";
PlaybackDirection direction = "normal";
DOMString easing = "linear";
UTF8String easing = "linear";
};
dictionary OptionalEffectTiming {
@ -44,7 +44,7 @@ dictionary OptionalEffectTiming {
unrestricted double iterations;
(unrestricted double or DOMString) duration;
PlaybackDirection direction;
DOMString easing;
UTF8String easing;
};
dictionary ComputedEffectTiming : EffectTiming {

Просмотреть файл

@ -83,7 +83,7 @@ interface AnonymousContent {
* anonymous content.
*/
[Throws]
DOMString? getComputedStylePropertyValue(DOMString elementId,
UTF8String? getComputedStylePropertyValue(DOMString elementId,
UTF8String propertyName);
/**

Просмотреть файл

@ -31,14 +31,14 @@ enum CompositeOperationOrAuto { "replace", "add", "accumulate", "auto" };
[GenerateInit]
dictionary BasePropertyIndexedKeyframe {
(double? or sequence<double?>) offset = [];
(DOMString or sequence<DOMString>) easing = [];
(UTF8String or sequence<UTF8String>) easing = [];
(CompositeOperationOrAuto or sequence<CompositeOperationOrAuto>) composite = [];
};
[GenerateInit]
dictionary BaseKeyframe {
double? offset = null;
DOMString easing = "linear";
UTF8String easing = "linear";
[Pref="dom.animations-api.compositing.enabled"]
CompositeOperationOrAuto composite = "auto";

Просмотреть файл

@ -11,5 +11,5 @@
[Exposed=Window]
interface CSSConditionRule : CSSGroupingRule {
[SetterThrows]
attribute DOMString conditionText;
attribute UTF8String conditionText;
};

Просмотреть файл

@ -11,14 +11,14 @@
[Exposed=Window]
interface CSSCounterStyleRule : CSSRule {
attribute DOMString name;
attribute DOMString system;
attribute DOMString symbols;
attribute DOMString additiveSymbols;
attribute DOMString negative;
attribute DOMString prefix;
attribute DOMString suffix;
attribute DOMString range;
attribute DOMString pad;
attribute DOMString speakAs;
attribute DOMString fallback;
attribute UTF8String system;
attribute UTF8String symbols;
attribute UTF8String additiveSymbols;
attribute UTF8String negative;
attribute UTF8String prefix;
attribute UTF8String suffix;
attribute UTF8String range;
attribute UTF8String pad;
attribute UTF8String speakAs;
attribute UTF8String fallback;
};

Просмотреть файл

@ -12,7 +12,7 @@
[Exposed=Window]
interface CSSFontFeatureValuesRule : CSSRule {
[SetterThrows]
attribute DOMString fontFamily;
attribute UTF8String fontFamily;
// Not yet implemented
// readonly attribute CSSFontFeatureValuesMap annotation;
@ -26,5 +26,5 @@ interface CSSFontFeatureValuesRule : CSSRule {
partial interface CSSFontFeatureValuesRule {
// Gecko addition?
[SetterThrows]
attribute DOMString valueText;
attribute UTF8String valueText;
};

Просмотреть файл

@ -12,7 +12,7 @@
interface CSSGroupingRule : CSSRule {
[SameObject] readonly attribute CSSRuleList cssRules;
[Throws]
unsigned long insertRule(DOMString rule, optional unsigned long index = 0);
unsigned long insertRule(UTF8String rule, optional unsigned long index = 0);
[Throws]
void deleteRule(unsigned long index);
};

Просмотреть файл

@ -10,6 +10,6 @@
// https://drafts.csswg.org/css-animations/#interface-csskeyframerule
[Exposed=Window]
interface CSSKeyframeRule : CSSRule {
attribute DOMString keyText;
attribute UTF8String keyText;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
};

Просмотреть файл

@ -26,7 +26,7 @@ interface CSSRule {
// const unsigned short MARGIN_RULE = 9;
const unsigned short NAMESPACE_RULE = 10;
readonly attribute unsigned short type;
attribute DOMString cssText;
attribute UTF8String cssText;
readonly attribute CSSRule? parentRule;
readonly attribute CSSStyleSheet? parentStyleSheet;
};

Просмотреть файл

@ -13,7 +13,7 @@
Exposed=Window]
interface CSSStyleDeclaration {
[CEReactions, SetterNeedsSubjectPrincipal=NonSystem, SetterThrows]
attribute DOMString cssText;
attribute UTF8String cssText;
readonly attribute unsigned long length;
getter UTF8String item(unsigned long index);
@ -22,12 +22,12 @@ interface CSSStyleDeclaration {
sequence<UTF8String> getCSSImageURLs(UTF8String property);
[Throws]
DOMString getPropertyValue(UTF8String property);
DOMString getPropertyPriority(UTF8String property);
UTF8String getPropertyValue(UTF8String property);
UTF8String getPropertyPriority(UTF8String property);
[CEReactions, NeedsSubjectPrincipal=NonSystem, Throws]
void setProperty(UTF8String property, [TreatNullAs=EmptyString] UTF8String value, optional [TreatNullAs=EmptyString] DOMString priority = "");
void setProperty(UTF8String property, [TreatNullAs=EmptyString] UTF8String value, optional [TreatNullAs=EmptyString] UTF8String priority = "");
[CEReactions, Throws]
DOMString removeProperty(UTF8String property);
UTF8String removeProperty(UTF8String property);
readonly attribute CSSRule? parentRule;
};

Просмотреть файл

@ -10,6 +10,6 @@
// https://drafts.csswg.org/cssom/#the-cssstylerule-interface
[Exposed=Window]
interface CSSStyleRule : CSSRule {
attribute DOMString selectorText;
attribute UTF8String selectorText;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
};

Просмотреть файл

@ -15,7 +15,7 @@ enum CSSStyleSheetParsingMode {
};
dictionary CSSStyleSheetInit {
(MediaList or DOMString) media = "";
(MediaList or UTF8String) media = "";
boolean disabled = false;
UTF8String baseURL;
};
@ -31,7 +31,7 @@ interface CSSStyleSheet : StyleSheet {
[ChromeOnly, BinaryName="parsingModeDOM"]
readonly attribute CSSStyleSheetParsingMode parsingMode;
[Throws, NeedsSubjectPrincipal]
unsigned long insertRule(DOMString rule, optional unsigned long index = 0);
unsigned long insertRule(UTF8String rule, optional unsigned long index = 0);
[Throws, NeedsSubjectPrincipal]
void deleteRule(unsigned long index);
[Throws, Pref="layout.css.constructable-stylesheets.enabled"]
@ -45,5 +45,5 @@ interface CSSStyleSheet : StyleSheet {
[Throws, NeedsSubjectPrincipal, BinaryName="deleteRule"]
void removeRule(optional unsigned long index = 0);
[Throws, NeedsSubjectPrincipal]
long addRule(optional DOMString selector = "undefined", optional DOMString style = "undefined", optional unsigned long index);
long addRule(optional UTF8String selector = "undefined", optional UTF8String style = "undefined", optional unsigned long index);
};

Просмотреть файл

@ -50,7 +50,7 @@ interface CanvasRenderingContext2D {
attribute object mozCurrentTransformInverse;
[SetterThrows]
attribute DOMString mozTextStyle;
attribute UTF8String mozTextStyle;
// image smoothing mode -- if disabled, images won't be smoothed
// if scaled.
@ -183,8 +183,8 @@ interface mixin CanvasImageSmoothing {
interface mixin CanvasFillStrokeStyles {
// colors and styles (see also the CanvasPathDrawingStyles interface)
attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black)
attribute (DOMString or CanvasGradient or CanvasPattern) fillStyle; // (default black)
attribute (UTF8String or CanvasGradient or CanvasPattern) strokeStyle; // (default black)
attribute (UTF8String or CanvasGradient or CanvasPattern) fillStyle; // (default black)
[NewObject]
CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
[NewObject, Throws]
@ -200,12 +200,12 @@ interface mixin CanvasShadowStyles {
attribute double shadowOffsetY; // (default 0)
[LenientFloat]
attribute double shadowBlur; // (default 0)
attribute DOMString shadowColor; // (default transparent black)
attribute UTF8String shadowColor; // (default transparent black)
};
interface mixin CanvasFilters {
[Pref="canvas.filters.enabled", SetterThrows]
attribute DOMString filter; // (default empty string = no filter)
attribute UTF8String filter; // (default empty string = no filter)
};
interface mixin CanvasRect {
@ -295,7 +295,7 @@ interface mixin CanvasPathDrawingStyles {
interface mixin CanvasTextDrawingStyles {
// text
[SetterThrows]
attribute DOMString font; // (default 10px sans-serif)
attribute UTF8String font; // (default 10px sans-serif)
attribute DOMString textAlign; // "start", "end", "left", "right", "center" (default: "start")
attribute DOMString textBaseline; // "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" (default: "alphabetic")
};

Просмотреть файл

@ -13,14 +13,14 @@
typedef (ArrayBuffer or ArrayBufferView) BinaryData;
dictionary FontFaceDescriptors {
DOMString style = "normal";
DOMString weight = "normal";
DOMString stretch = "normal";
DOMString unicodeRange = "U+0-10FFFF";
DOMString variant = "normal";
DOMString featureSettings = "normal";
DOMString variationSettings = "normal";
DOMString display = "auto";
UTF8String style = "normal";
UTF8String weight = "normal";
UTF8String stretch = "normal";
UTF8String unicodeRange = "U+0-10FFFF";
UTF8String variant = "normal";
UTF8String featureSettings = "normal";
UTF8String variationSettings = "normal";
UTF8String display = "auto";
};
enum FontFaceLoadStatus { "unloaded", "loading", "loaded", "error" };
@ -31,19 +31,19 @@ enum FontFaceLoadStatus { "unloaded", "loading", "loaded", "error" };
Exposed=Window]
interface FontFace {
[Throws]
constructor(DOMString family,
(DOMString or BinaryData) source,
constructor(UTF8String family,
(UTF8String or BinaryData) source,
optional FontFaceDescriptors descriptors = {});
[SetterThrows] attribute DOMString family;
[SetterThrows] attribute DOMString style;
[SetterThrows] attribute DOMString weight;
[SetterThrows] attribute DOMString stretch;
[SetterThrows] attribute DOMString unicodeRange;
[SetterThrows] attribute DOMString variant;
[SetterThrows] attribute DOMString featureSettings;
[SetterThrows, Pref="layout.css.font-variations.enabled"] attribute DOMString variationSettings;
[SetterThrows, Pref="layout.css.font-display.enabled"] attribute DOMString display;
[SetterThrows] attribute UTF8String family;
[SetterThrows] attribute UTF8String style;
[SetterThrows] attribute UTF8String weight;
[SetterThrows] attribute UTF8String stretch;
[SetterThrows] attribute UTF8String unicodeRange;
[SetterThrows] attribute UTF8String variant;
[SetterThrows] attribute UTF8String featureSettings;
[SetterThrows, Pref="layout.css.font-variations.enabled"] attribute UTF8String variationSettings;
[SetterThrows, Pref="layout.css.font-display.enabled"] attribute UTF8String display;
readonly attribute FontFaceLoadStatus status;

Просмотреть файл

@ -52,11 +52,11 @@ interface FontFaceSet : EventTarget {
// check and start loads if appropriate
// and fulfill promise when all loads complete
[NewObject] Promise<sequence<FontFace>> load(DOMString font, optional DOMString text = " ");
[NewObject] Promise<sequence<FontFace>> load(UTF8String font, optional DOMString text = " ");
// return whether all fonts in the fontlist are loaded
// (does not initiate load if not available)
[Throws] boolean check(DOMString font, optional DOMString text = " ");
[Throws] boolean check(UTF8String font, optional DOMString text = " ");
// async notification that font loading and layout operations are done
[Throws] readonly attribute Promise<void> ready;

Просмотреть файл

@ -36,7 +36,7 @@ interface IntersectionObserver {
[Constant]
readonly attribute Node? root;
[Constant]
readonly attribute DOMString rootMargin;
readonly attribute UTF8String rootMargin;
[Constant,Cached]
readonly attribute sequence<double> thresholds;
void observe(Element target);
@ -57,7 +57,7 @@ dictionary IntersectionObserverEntryInit {
};
dictionary IntersectionObserverInit {
(Element or Document)? root = null;
DOMString rootMargin = "0px";
(Element or Document)? root = null;
UTF8String rootMargin = "0px";
(double or sequence<double>) threshold = 0;
};

Просмотреть файл

@ -49,8 +49,8 @@ interface KeyframeEffect : AnimationEffect {
// Non-standard extensions
dictionary AnimationPropertyValueDetails {
required double offset;
DOMString value;
DOMString easing;
UTF8String value;
UTF8String easing;
required CompositeOperation composite;
};

Просмотреть файл

@ -7,12 +7,12 @@
[Exposed=Window]
interface MediaList {
stringifier attribute [TreatNullAs=EmptyString] DOMString mediaText;
stringifier attribute [TreatNullAs=EmptyString] UTF8String mediaText;
readonly attribute unsigned long length;
getter DOMString? item(unsigned long index);
getter UTF8String? item(unsigned long index);
[Throws]
void deleteMedium(DOMString oldMedium);
void deleteMedium(UTF8String oldMedium);
[Throws]
void appendMedium(DOMString newMedium);
void appendMedium(UTF8String newMedium);
};

Просмотреть файл

@ -13,7 +13,7 @@
[ProbablyShortLivingWrapper,
Exposed=Window]
interface MediaQueryList : EventTarget {
readonly attribute DOMString media;
readonly attribute UTF8String media;
readonly attribute boolean matches;
[Throws]

Просмотреть файл

@ -11,11 +11,11 @@ interface MediaQueryListEvent : Event {
constructor(DOMString type,
optional MediaQueryListEventInit eventInitDict = {});
readonly attribute DOMString media;
readonly attribute UTF8String media;
readonly attribute boolean matches;
};
dictionary MediaQueryListEventInit : EventInit {
DOMString media = "";
UTF8String media = "";
boolean matches = false;
};

Просмотреть файл

@ -323,7 +323,7 @@ dictionary ScrollToOptions : ScrollOptions {
partial interface Window {
//[Throws, NewObject, NeedsCallerType] MediaQueryList matchMedia(DOMString query);
[Throws, NewObject, NeedsCallerType] MediaQueryList? matchMedia(DOMString query);
[Throws, NewObject, NeedsCallerType] MediaQueryList? matchMedia(UTF8String query);
// Per spec, screen is SameObject, but we don't actually guarantee that given
// nsGlobalWindow::Cleanup. :(
//[SameObject, Replaceable, Throws] readonly attribute Screen screen;

Просмотреть файл

@ -434,7 +434,7 @@ nsresult CSSEditUtils::SetCSSPropertyPixelsWithoutTransaction(
s.AppendLiteral("px");
ErrorResult error;
cssDecl->SetProperty(propertyNameString, s, EmptyString(), error);
cssDecl->SetProperty(propertyNameString, s, EmptyCString(), error);
if (error.Failed()) {
NS_WARNING("nsICSSDeclaration::SetProperty() failed");
return error.StealNSResult();
@ -515,9 +515,13 @@ nsresult CSSEditUtils::GetComputedCSSInlinePropertyBase(nsIContent& aContent,
//
// FIXME(bug 1606994): nsAtomCString copies, we should just keep around the
// property id.
//
// FIXME: Maybe we can avoid copying aValue too, though it's no worse than
// what we used to do.
nsAutoCString value;
MOZ_ALWAYS_SUCCEEDS(
computedDOMStyle->GetPropertyValue(nsAtomCString(&aCSSProperty), aValue));
computedDOMStyle->GetPropertyValue(nsAtomCString(&aCSSProperty), value));
CopyUTF8toUTF16(value, aValue);
return NS_OK;
}
@ -537,12 +541,14 @@ nsresult CSSEditUtils::GetSpecifiedCSSInlinePropertyBase(nsIContent& aContent,
return NS_OK;
}
// FIXME: Same comments as above.
nsCSSPropertyID prop =
nsCSSProps::LookupProperty(nsAtomCString(&aCSSProperty));
MOZ_ASSERT(prop != eCSSProperty_UNKNOWN);
decl->GetPropertyValueByID(prop, aValue);
nsAutoCString value;
decl->GetPropertyValueByID(prop, value);
CopyUTF8toUTF16(value, aValue);
return NS_OK;
}
@ -1041,13 +1047,11 @@ bool CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSetInternal(
isSet = true;
}
} else if (nsGkAtoms::u == aHTMLProperty) {
nsAutoString val;
val.AssignLiteral("underline");
isSet = ChangeStyleTransaction::ValueIncludes(aValue, val);
isSet = ChangeStyleTransaction::ValueIncludes(
NS_ConvertUTF16toUTF8(aValue), "underline"_ns);
} else if (nsGkAtoms::strike == aHTMLProperty) {
nsAutoString val;
val.AssignLiteral("line-through");
isSet = ChangeStyleTransaction::ValueIncludes(aValue, val);
isSet = ChangeStyleTransaction::ValueIncludes(
NS_ConvertUTF16toUTF8(aValue), "line-through"_ns);
} else if ((nsGkAtoms::font == aHTMLProperty &&
aAttribute == nsGkAtoms::color) ||
aAttribute == nsGkAtoms::bgcolor) {
@ -1249,7 +1253,7 @@ bool CSSEditUtils::DoStyledElementsHaveSameStyle(
}
for (uint32_t i = 0; i < firstLength; i++) {
nsAutoString firstValue, otherValue;
nsAutoCString firstValue, otherValue;
nsAutoCString propertyNameString;
firstCSSDecl->Item(i, propertyNameString);
DebugOnly<nsresult> rvIgnored =
@ -1266,7 +1270,7 @@ bool CSSEditUtils::DoStyledElementsHaveSameStyle(
}
}
for (uint32_t i = 0; i < otherLength; i++) {
nsAutoString firstValue, otherValue;
nsAutoCString firstValue, otherValue;
nsAutoCString propertyNameString;
otherCSSDecl->Item(i, propertyNameString);
DebugOnly<nsresult> rvIgnored =

Просмотреть файл

@ -47,14 +47,15 @@ ChangeStyleTransaction::ChangeStyleTransaction(nsStyledElement& aStyledElement,
: EditTransactionBase(),
mStyledElement(&aStyledElement),
mProperty(&aProperty),
mValue(aValue),
mUndoValue(),
mRedoValue(),
mRemoveProperty(aRemove),
mUndoAttributeWasSet(false),
mRedoAttributeWasSet(false) {}
mRedoAttributeWasSet(false) {
CopyUTF16toUTF8(aValue, mValue);
}
#define kNullCh (char16_t('\0'))
#define kNullCh ('\0')
NS_IMPL_CYCLE_COLLECTION_INHERITED(ChangeStyleTransaction, EditTransactionBase,
mStyledElement)
@ -67,17 +68,16 @@ NS_IMPL_RELEASE_INHERITED(ChangeStyleTransaction, EditTransactionBase)
// Answers true if aValue is in the string list of white-space separated values
// aValueList.
bool ChangeStyleTransaction::ValueIncludes(const nsAString& aValueList,
const nsAString& aValue) {
nsAutoString valueList(aValueList);
bool ChangeStyleTransaction::ValueIncludes(const nsACString& aValueList,
const nsACString& aValue) {
nsAutoCString valueList(aValueList);
bool result = false;
// put an extra null at the end
valueList.Append(kNullCh);
char16_t* value = ToNewUnicode(aValue);
char16_t* start = valueList.BeginWriting();
char16_t* end = start;
char* start = valueList.BeginWriting();
char* end = start;
while (kNullCh != *start) {
while (kNullCh != *start && nsCRT::IsAsciiSpace(*start)) {
@ -94,29 +94,28 @@ bool ChangeStyleTransaction::ValueIncludes(const nsAString& aValueList,
*end = kNullCh;
if (start < end) {
if (nsDependentString(value).Equals(nsDependentString(start),
nsCaseInsensitiveStringComparator)) {
if (aValue.Equals(nsDependentCString(start),
nsCaseInsensitiveCStringComparator)) {
result = true;
break;
}
}
start = ++end;
}
free(value);
return result;
}
// Removes the value aRemoveValue from the string list of white-space separated
// values aValueList
void ChangeStyleTransaction::RemoveValueFromListOfValues(
nsAString& aValues, const nsAString& aRemoveValue) {
nsAutoString classStr(aValues);
nsAutoString outString;
nsACString& aValues, const nsACString& aRemoveValue) {
nsAutoCString classStr(aValues);
nsAutoCString outString;
// put an extra null at the end
classStr.Append(kNullCh);
char16_t* start = classStr.BeginWriting();
char16_t* end = start;
char* start = classStr.BeginWriting();
char* end = start;
while (kNullCh != *start) {
while (kNullCh != *start && nsCRT::IsAsciiSpace(*start)) {
@ -134,7 +133,7 @@ void ChangeStyleTransaction::RemoveValueFromListOfValues(
if (start < end && !aRemoveValue.Equals(start)) {
outString.Append(start);
outString.Append(char16_t(' '));
outString.Append(' ');
}
start = ++end;
@ -158,7 +157,7 @@ NS_IMETHODIMP ChangeStyleTransaction::DoTransaction() {
mUndoAttributeWasSet =
mStyledElement->HasAttr(kNameSpaceID_None, nsGkAtoms::style);
nsAutoString values;
nsAutoCString values;
nsresult rv = cssDecl->GetPropertyValue(propertyNameString, values);
if (NS_FAILED(rv)) {
NS_WARNING("nsICSSDeclaration::GetPropertyPriorityValue() failed");
@ -170,10 +169,10 @@ NS_IMETHODIMP ChangeStyleTransaction::DoTransaction() {
bool multiple = AcceptsMoreThanOneValue(*mProperty);
if (mRemoveProperty) {
nsAutoString returnString;
nsAutoCString returnString;
if (multiple) {
// Let's remove only the value we have to remove and not the others
RemoveValueFromListOfValues(values, u"none"_ns);
RemoveValueFromListOfValues(values, "none"_ns);
RemoveValueFromListOfValues(values, mValue);
if (values.IsEmpty()) {
ErrorResult error;
@ -184,10 +183,9 @@ NS_IMETHODIMP ChangeStyleTransaction::DoTransaction() {
}
} else {
ErrorResult error;
nsAutoString priority;
nsAutoCString priority;
cssDecl->GetPropertyPriority(propertyNameString, priority);
cssDecl->SetProperty(propertyNameString, NS_ConvertUTF16toUTF8(values),
priority, error);
cssDecl->SetProperty(propertyNameString, values, priority, error);
if (error.Failed()) {
NS_WARNING("nsICSSDeclaration::SetProperty() failed");
return error.StealNSResult();
@ -202,7 +200,7 @@ NS_IMETHODIMP ChangeStyleTransaction::DoTransaction() {
}
}
} else {
nsAutoString priority;
nsAutoCString priority;
cssDecl->GetPropertyPriority(propertyNameString, priority);
if (multiple) {
// Let's add the value we have to add to the others
@ -211,8 +209,7 @@ NS_IMETHODIMP ChangeStyleTransaction::DoTransaction() {
values.Assign(mValue);
}
ErrorResult error;
cssDecl->SetProperty(propertyNameString, NS_ConvertUTF16toUTF8(values),
priority, error);
cssDecl->SetProperty(propertyNameString, values, priority, error);
if (error.Failed()) {
NS_WARNING("nsICSSDeclaration::SetProperty() failed");
return error.StealNSResult();
@ -239,7 +236,7 @@ NS_IMETHODIMP ChangeStyleTransaction::DoTransaction() {
}
nsresult ChangeStyleTransaction::SetStyle(bool aAttributeWasSet,
nsAString& aValue) {
nsACString& aValue) {
if (NS_WARN_IF(!mStyledElement)) {
return NS_ERROR_NOT_AVAILABLE;
}
@ -256,7 +253,7 @@ nsresult ChangeStyleTransaction::SetStyle(bool aAttributeWasSet,
ErrorResult error;
if (aValue.IsEmpty()) {
// An empty value means we have to remove the property
nsAutoString returnString;
nsAutoCString returnString;
cssDecl->RemoveProperty(propertyNameString, returnString, error);
if (error.Failed()) {
NS_WARNING("nsICSSDeclaration::RemoveProperty() failed");
@ -264,10 +261,9 @@ nsresult ChangeStyleTransaction::SetStyle(bool aAttributeWasSet,
}
}
// Let's recreate the declaration as it was
nsAutoString priority;
nsAutoCString priority;
cssDecl->GetPropertyPriority(propertyNameString, priority);
cssDecl->SetProperty(propertyNameString, NS_ConvertUTF16toUTF8(aValue),
priority, error);
cssDecl->SetProperty(propertyNameString, aValue, priority, error);
NS_WARNING_ASSERTION(!error.Failed(),
"nsICSSDeclaration::SetProperty() failed");
return error.StealNSResult();
@ -302,7 +298,7 @@ bool ChangeStyleTransaction::AcceptsMoreThanOneValue(nsAtom& aCSSProperty) {
// Adds the value aNewValue to the list of white-space separated values aValues
void ChangeStyleTransaction::AddValueToMultivalueProperty(
nsAString& aValues, const nsAString& aNewValue) {
nsACString& aValues, const nsACString& aNewValue) {
if (aValues.IsEmpty() || aValues.LowerCaseEqualsLiteral("none")) {
aValues.Assign(aNewValue);
} else if (!ValueIncludes(aValues, aNewValue)) {

Просмотреть файл

@ -69,8 +69,8 @@ class ChangeStyleTransaction final : public EditTransactionBase {
* @param aValue [IN] the value to look for in the list
* @return true if the value is in the list of values
*/
static bool ValueIncludes(const nsAString& aValueList,
const nsAString& aValue);
static bool ValueIncludes(const nsACString& aValueList,
const nsACString& aValue);
private:
virtual ~ChangeStyleTransaction() = default;
@ -82,8 +82,8 @@ class ChangeStyleTransaction final : public EditTransactionBase {
* @param aNewValue [IN] a value this code adds to aValues if it is not
* already in
*/
void AddValueToMultivalueProperty(nsAString& aValues,
const nsAString& aNewValue);
void AddValueToMultivalueProperty(nsACString& aValues,
const nsACString& aNewValue);
/**
* Returns true if the property accepts more than one value.
@ -98,8 +98,8 @@ class ChangeStyleTransaction final : public EditTransactionBase {
* @param aValues [IN] a list of white-space separated values
* @param aRemoveValue [IN] the value to remove from the list
*/
void RemoveValueFromListOfValues(nsAString& aValues,
const nsAString& aRemoveValue);
void RemoveValueFromListOfValues(nsACString& aValues,
const nsACString& aRemoveValue);
/**
* If the boolean is true and if the value is not the empty string,
@ -108,7 +108,7 @@ class ChangeStyleTransaction final : public EditTransactionBase {
* is false, just remove the style attribute.
*/
MOZ_CAN_RUN_SCRIPT nsresult SetStyle(bool aAttributeWasSet,
nsAString& aValue);
nsACString& aValue);
// The element to operate upon.
RefPtr<nsStyledElement> mStyledElement;
@ -117,12 +117,12 @@ class ChangeStyleTransaction final : public EditTransactionBase {
RefPtr<nsAtom> mProperty;
// The value to set the property to (ignored if mRemoveProperty==true).
nsString mValue;
nsCString mValue;
// The value to set the property to for undo.
nsString mUndoValue;
nsCString mUndoValue;
// The value to set the property to for redo.
nsString mRedoValue;
nsCString mRedoValue;
// true if the operation is to remove mProperty from mElement.
bool mRemoveProperty;

Просмотреть файл

@ -57,7 +57,7 @@ static int32_t GetCSSFloatValue(nsComputedDOMStyle* aComputedStyle,
MOZ_ASSERT(aComputedStyle);
// get the computed CSSValue of the property
nsAutoString value;
nsAutoCString value;
nsresult rv = aComputedStyle->GetPropertyValue(aProperty, value);
if (NS_FAILED(rv)) {
NS_WARNING("nsComputedDOMStyle::GetPropertyValue() failed");

Просмотреть файл

@ -110,10 +110,10 @@ void nsSearchControlFrame::UpdateClearButtonState() {
nsGenericHTMLElement* element = nsGenericHTMLElement::FromNode(mClearButton);
nsCOMPtr<nsICSSDeclaration> declaration = element->Style();
if (content->IsValueEmpty()) {
declaration->SetProperty("visibility"_ns, "hidden"_ns, u""_ns,
declaration->SetProperty("visibility"_ns, "hidden"_ns, ""_ns,
IgnoreErrors());
} else {
nsAutoString dummy;
nsAutoCString dummy;
declaration->RemoveProperty("visibility"_ns, dummy, IgnoreErrors());
}
}

Просмотреть файл

@ -298,7 +298,7 @@ static void SetOpacityOnElement(nsIContent* aContent, double aOpacity) {
nsICSSDeclaration* decl = inlineStyleContent->Style();
nsAutoCString str;
str.AppendFloat(aOpacity);
decl->SetProperty("opacity"_ns, str, u""_ns, IgnoreErrors());
decl->SetProperty("opacity"_ns, str, EmptyCString(), IgnoreErrors());
}
}
@ -327,7 +327,7 @@ static void UnsetOpacityOnElement(nsIContent* aContent) {
if (RefPtr<nsStyledElement> inlineStyleContent =
nsStyledElement::FromNodeOrNull(aContent)) {
nsICSSDeclaration* decl = inlineStyleContent->Style();
nsAutoString dummy;
nsAutoCString dummy;
decl->RemoveProperty("opacity"_ns, dummy, IgnoreErrors());
}
}

Просмотреть файл

@ -7874,10 +7874,9 @@ void nsIFrame::ListMatchedRules(FILE* out, const char* aPrefix) const {
nsTArray<const RawServoStyleRule*> rawRuleList;
Servo_ComputedValues_GetStyleRuleList(mComputedStyle, &rawRuleList);
for (const RawServoStyleRule* rawRule : rawRuleList) {
nsString ruleText;
nsAutoCString ruleText;
Servo_StyleRule_GetCssText(rawRule, &ruleText);
fprintf_stderr(out, "%s%s\n", aPrefix,
NS_ConvertUTF16toUTF8(ruleText).get());
fprintf_stderr(out, "%s%s\n", aPrefix, ruleText.get());
}
}
@ -12506,9 +12505,9 @@ void ReflowInput::DisplayInitFrameTypeExit(nsIFrame* aFrame,
if (aFrame->IsFloating()) printf(" float");
{
nsAutoString result;
nsAutoCString result;
aFrame->Style()->GetComputedPropertyValue(eCSSProperty_display, result);
printf(" display=%s", NS_ConvertUTF16toUTF8(result).get());
printf(" display=%s", result.get());
}
// This array must exactly match the NS_CSS_FRAME_TYPE constants.

Просмотреть файл

@ -300,7 +300,7 @@ uint32_t InspectorUtils::GetSelectorCount(GlobalObject& aGlobal,
/* static */
void InspectorUtils::GetSelectorText(GlobalObject& aGlobal,
BindingStyleRule& aRule,
uint32_t aSelectorIndex, nsString& aText,
uint32_t aSelectorIndex, nsACString& aText,
ErrorResult& aRv) {
aRv = aRule.GetSelectorText(aSelectorIndex, aText);
}

Просмотреть файл

@ -88,7 +88,7 @@ class InspectorUtils {
// For all three functions below, aSelectorIndex is 0-based
static void GetSelectorText(GlobalObject& aGlobal, BindingStyleRule& aRule,
uint32_t aSelectorIndex, nsString& aText,
uint32_t aSelectorIndex, nsACString& aText,
ErrorResult& aRv);
static uint64_t GetSpecificity(GlobalObject& aGlobal, BindingStyleRule& aRule,
uint32_t aSelectorIndex, ErrorResult& aRv);

Просмотреть файл

@ -337,9 +337,9 @@ void ActiveLayerTracker::NotifyAnimated(nsIFrame* aFrame,
LayerActivity* layerActivity = GetLayerActivityForUpdate(aFrame);
uint8_t& mutationCount = layerActivity->RestyleCountForProperty(aProperty);
if (mutationCount != 0xFF) {
nsAutoString oldValue;
nsAutoCString oldValue;
aDOMCSSDecl->GetPropertyValue(aProperty, oldValue);
if (NS_ConvertUTF16toUTF8(oldValue) != aNewValue) {
if (oldValue != aNewValue) {
// We know this is animated, so just hack the mutation count.
mutationCount = 0xFF;
}

Просмотреть файл

@ -46,7 +46,7 @@ class BindingStyleRule : public css::Rule {
virtual uint32_t GetSelectorCount() = 0;
virtual nsresult GetSelectorText(uint32_t aSelectorIndex,
nsAString& aText) = 0;
nsACString& aText) = 0;
virtual nsresult GetSpecificity(uint32_t aSelectorIndex,
uint64_t* aSpecificity) = 0;
virtual nsresult SelectorMatchesElement(dom::Element* aElement,
@ -57,8 +57,8 @@ class BindingStyleRule : public css::Rule {
virtual NotNull<DeclarationBlock*> GetDeclarationBlock() const = 0;
// WebIDL API
virtual void GetSelectorText(nsAString& aSelectorText) = 0;
virtual void SetSelectorText(const nsAString& aSelectorText) = 0;
virtual void GetSelectorText(nsACString& aSelectorText) = 0;
virtual void SetSelectorText(const nsACString& aSelectorText) = 0;
virtual nsICSSDeclaration* Style() = 0;
virtual JSObject* WrapObject(JSContext* aCx,

Просмотреть файл

@ -31,7 +31,7 @@ uint16_t CSSCounterStyleRule::Type() const {
return CSSRule_Binding::COUNTER_STYLE_RULE;
}
void CSSCounterStyleRule::GetCssText(nsAString& aCssText) const {
void CSSCounterStyleRule::GetCssText(nsACString& aCssText) const {
Servo_CounterStyleRule_GetCssText(mRawRule, &aCssText);
}
@ -54,23 +54,22 @@ void CSSCounterStyleRule::SetName(const nsAString& aName) {
}
}
#define CSS_COUNTER_DESC(name_, method_) \
void CSSCounterStyleRule::Get##method_(nsAString& aValue) { \
aValue.Truncate(); \
Servo_CounterStyleRule_GetDescriptorCssText( \
mRawRule, eCSSCounterDesc_##method_, &aValue); \
} \
void CSSCounterStyleRule::Set##method_(const nsAString& aValue) { \
if (IsReadOnly()) { \
return; \
} \
NS_ConvertUTF16toUTF8 value(aValue); \
if (Servo_CounterStyleRule_SetDescriptor( \
mRawRule, eCSSCounterDesc_##method_, &value)) { \
if (StyleSheet* sheet = GetStyleSheet()) { \
sheet->RuleChanged(this, StyleRuleChangeKind::Generic); \
} \
} \
#define CSS_COUNTER_DESC(name_, method_) \
void CSSCounterStyleRule::Get##method_(nsACString& aValue) { \
MOZ_ASSERT(aValue.IsEmpty()); \
Servo_CounterStyleRule_GetDescriptorCssText( \
mRawRule, eCSSCounterDesc_##method_, &aValue); \
} \
void CSSCounterStyleRule::Set##method_(const nsACString& aValue) { \
if (IsReadOnly()) { \
return; \
} \
if (Servo_CounterStyleRule_SetDescriptor( \
mRawRule, eCSSCounterDesc_##method_, &aValue)) { \
if (StyleSheet* sheet = GetStyleSheet()) { \
sheet->RuleChanged(this, StyleRuleChangeKind::Generic); \
} \
} \
}
#include "nsCSSCounterDescList.h"
#undef CSS_COUNTER_DESC

Просмотреть файл

@ -38,12 +38,12 @@ class CSSCounterStyleRule final : public css::Rule {
// WebIDL interface
uint16_t Type() const override;
void GetCssText(nsAString& aCssText) const override;
void GetCssText(nsACString& aCssText) const override;
void GetName(nsAString& aName);
void SetName(const nsAString& aName);
#define CSS_COUNTER_DESC(name_, method_) \
void Get##method_(nsAString& aValue); \
void Set##method_(const nsAString& aValue);
void Get##method_(nsACString& aValue); \
void Set##method_(const nsACString& aValue);
#include "nsCSSCounterDescList.h"
#undef CSS_COUNTER_DESC

Просмотреть файл

@ -36,17 +36,17 @@ NS_IMPL_RELEASE_USING_AGGREGATOR(CSSFontFaceRuleDecl, ContainingRule())
// helper for string GetPropertyValue and RemovePropertyValue
void CSSFontFaceRuleDecl::GetPropertyValue(nsCSSFontDesc aFontDescID,
nsAString& aResult) const {
nsACString& aResult) const {
MOZ_ASSERT(aResult.IsEmpty());
Servo_FontFaceRule_GetDescriptorCssText(mRawRule, aFontDescID, &aResult);
}
void CSSFontFaceRuleDecl::GetCssText(nsAString& aCssText) {
aCssText.Truncate();
void CSSFontFaceRuleDecl::GetCssText(nsACString& aCssText) {
MOZ_ASSERT(aCssText.IsEmpty());
Servo_FontFaceRule_GetDeclCssText(mRawRule, &aCssText);
}
void CSSFontFaceRuleDecl::SetCssText(const nsAString& aCssText,
void CSSFontFaceRuleDecl::SetCssText(const nsACString& aCssText,
nsIPrincipal* aSubjectPrincipal,
ErrorResult& aRv) {
if (ContainingRule()->IsReadOnly()) {
@ -59,7 +59,7 @@ void CSSFontFaceRuleDecl::SetCssText(const nsAString& aCssText,
NS_IMETHODIMP
CSSFontFaceRuleDecl::GetPropertyValue(const nsACString& aPropName,
nsAString& aResult) {
nsACString& aResult) {
aResult.Truncate();
nsCSSFontDesc descID = nsCSSProps::LookupFontDesc(aPropName);
if (descID != eCSSFontDesc_UNKNOWN) {
@ -69,7 +69,8 @@ CSSFontFaceRuleDecl::GetPropertyValue(const nsACString& aPropName,
}
void CSSFontFaceRuleDecl::RemoveProperty(const nsACString& aPropName,
nsAString& aResult, ErrorResult& aRv) {
nsACString& aResult,
ErrorResult& aRv) {
nsCSSFontDesc descID = nsCSSProps::LookupFontDesc(aPropName);
NS_ASSERTION(descID >= eCSSFontDesc_UNKNOWN && descID < eCSSFontDesc_COUNT,
"LookupFontDesc returned value out of range");
@ -86,14 +87,14 @@ void CSSFontFaceRuleDecl::RemoveProperty(const nsACString& aPropName,
}
void CSSFontFaceRuleDecl::GetPropertyPriority(const nsACString& aPropName,
nsAString& aResult) {
nsACString& aResult) {
// font descriptors do not have priorities at present
aResult.Truncate();
}
void CSSFontFaceRuleDecl::SetProperty(const nsACString& aPropName,
const nsACString& aValue,
const nsAString& aPriority,
const nsACString& aPriority,
nsIPrincipal* aSubjectPrincipal,
ErrorResult& aRv) {
// FIXME(heycam): If we are changing unicode-range, then a FontFace object
@ -192,7 +193,7 @@ uint16_t CSSFontFaceRule::Type() const {
return CSSRule_Binding::FONT_FACE_RULE;
}
void CSSFontFaceRule::GetCssText(nsAString& aCssText) const {
void CSSFontFaceRule::GetCssText(nsACString& aCssText) const {
aCssText.Truncate();
Servo_FontFaceRule_GetCssText(Raw(), &aCssText);
}

Просмотреть файл

@ -25,7 +25,7 @@ class CSSFontFaceRuleDecl final : public nsICSSDeclaration {
void IndexedGetter(uint32_t aIndex, bool& aFound,
nsACString& aPropName) final;
void GetPropertyValue(nsCSSFontDesc aFontDescID, nsAString& aResult) const;
void GetPropertyValue(nsCSSFontDesc aFontDescID, nsACString& aResult) const;
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
@ -66,7 +66,7 @@ class CSSFontFaceRule final : public css::Rule {
// WebIDL interface
uint16_t Type() const final;
void GetCssText(nsAString& aCssText) const final;
void GetCssText(nsACString& aCssText) const final;
nsICSSDeclaration* Style();
// Methods of mozilla::css::Rule

Просмотреть файл

@ -30,21 +30,21 @@ void CSSFontFeatureValuesRule::List(FILE* out, int32_t aIndent) const {
/* CSSRule implementation */
void CSSFontFeatureValuesRule::GetCssText(nsAString& aCssText) const {
void CSSFontFeatureValuesRule::GetCssText(nsACString& aCssText) const {
Servo_FontFeatureValuesRule_GetCssText(mRawRule, &aCssText);
}
/* CSSFontFeatureValuesRule implementation */
void CSSFontFeatureValuesRule::GetFontFamily(nsAString& aFamilyListStr) {
void CSSFontFeatureValuesRule::GetFontFamily(nsACString& aFamilyListStr) {
Servo_FontFeatureValuesRule_GetFontFamily(mRawRule, &aFamilyListStr);
}
void CSSFontFeatureValuesRule::GetValueText(nsAString& aValueText) {
void CSSFontFeatureValuesRule::GetValueText(nsACString& aValueText) {
Servo_FontFeatureValuesRule_GetValueText(mRawRule, &aValueText);
}
void CSSFontFeatureValuesRule::SetFontFamily(const nsAString& aFontFamily,
void CSSFontFeatureValuesRule::SetFontFamily(const nsACString& aFontFamily,
ErrorResult& aRv) {
if (IsReadOnly()) {
return;
@ -53,7 +53,7 @@ void CSSFontFeatureValuesRule::SetFontFamily(const nsAString& aFontFamily,
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
}
void CSSFontFeatureValuesRule::SetValueText(const nsAString& aValueText,
void CSSFontFeatureValuesRule::SetValueText(const nsACString& aValueText,
ErrorResult& aRv) {
if (IsReadOnly()) {
return;

Просмотреть файл

@ -32,11 +32,11 @@ class CSSFontFeatureValuesRule final : public css::Rule {
return CSSRule_Binding::FONT_FEATURE_VALUES_RULE;
}
void GetCssText(nsAString& aCssText) const override;
void GetFontFamily(nsAString& aFamily);
void SetFontFamily(const nsAString& aFamily, mozilla::ErrorResult& aRv);
void GetValueText(nsAString& aValueText);
void SetValueText(const nsAString& aValueText, mozilla::ErrorResult& aRv);
void GetCssText(nsACString& aCssText) const override;
void GetFontFamily(nsACString& aFamily);
void SetFontFamily(const nsACString& aFamily, mozilla::ErrorResult& aRv);
void GetValueText(nsACString& aValueText);
void SetValueText(const nsACString& aValueText, mozilla::ErrorResult& aRv);
size_t SizeOfIncludingThis(
mozilla::MallocSizeOf aMallocSizeOf) const override;

Просмотреть файл

@ -88,7 +88,7 @@ void CSSImportRule::GetHref(nsAString& aHref) const {
}
/* virtual */
void CSSImportRule::GetCssText(nsAString& aCssText) const {
void CSSImportRule::GetCssText(nsACString& aCssText) const {
Servo_ImportRule_GetCssText(mRawRule, &aCssText);
}

Просмотреть файл

@ -33,7 +33,7 @@ class CSSImportRule final : public css::Rule {
// WebIDL interface
uint16_t Type() const final { return CSSRule_Binding::IMPORT_RULE; }
void GetCssText(nsAString& aCssText) const override;
void GetCssText(nsACString& aCssText) const override;
void GetHref(nsAString& aHref) const;
dom::MediaList* GetMedia() const;
StyleSheet* GetStyleSheet() const { return mChildSheet; }

Просмотреть файл

@ -151,16 +151,16 @@ void CSSKeyframeRule::UpdateRule(Func aCallback) {
}
}
void CSSKeyframeRule::GetKeyText(nsAString& aKeyText) {
void CSSKeyframeRule::GetKeyText(nsACString& aKeyText) {
Servo_Keyframe_GetKeyText(mRaw, &aKeyText);
}
void CSSKeyframeRule::SetKeyText(const nsAString& aKeyText) {
NS_ConvertUTF16toUTF8 keyText(aKeyText);
UpdateRule([this, &keyText]() { Servo_Keyframe_SetKeyText(mRaw, &keyText); });
void CSSKeyframeRule::SetKeyText(const nsACString& aKeyText) {
UpdateRule(
[this, &aKeyText]() { Servo_Keyframe_SetKeyText(mRaw, &aKeyText); });
}
void CSSKeyframeRule::GetCssText(nsAString& aCssText) const {
void CSSKeyframeRule::GetCssText(nsACString& aCssText) const {
Servo_Keyframe_GetCssText(mRaw, &aCssText);
}

Просмотреть файл

@ -35,9 +35,9 @@ class CSSKeyframeRule final : public css::Rule {
// WebIDL interface
uint16_t Type() const final { return CSSRule_Binding::KEYFRAME_RULE; }
void GetCssText(nsAString& aCssText) const final;
void GetKeyText(nsAString& aKey);
void SetKeyText(const nsAString& aKey);
void GetCssText(nsACString& aCssText) const final;
void GetKeyText(nsACString& aKey);
void SetKeyText(const nsACString& aKey);
nsICSSDeclaration* Style();
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;

Просмотреть файл

@ -281,7 +281,7 @@ void CSSKeyframesRule::DeleteRule(const nsAString& aKey) {
}
/* virtual */
void CSSKeyframesRule::GetCssText(nsAString& aCssText) const {
void CSSKeyframesRule::GetCssText(nsACString& aCssText) const {
Servo_KeyframesRule_GetCssText(mRawRule, &aCssText);
}

Просмотреть файл

@ -35,7 +35,7 @@ class CSSKeyframesRule final : public css::Rule {
uint16_t Type() const final { return CSSRule_Binding::KEYFRAMES_RULE; }
const RawServoKeyframesRule* Raw() const { return mRawRule.get(); }
void GetCssText(nsAString& aCssText) const final;
void GetCssText(nsACString& aCssText) const final;
void GetName(nsAString& aName) const;
void SetName(const nsAString& aName);
CSSRuleList* CssRules();

Просмотреть файл

@ -68,11 +68,11 @@ void CSSMediaRule::List(FILE* out, int32_t aIndent) const {
}
#endif
void CSSMediaRule::GetConditionText(nsAString& aConditionText) {
void CSSMediaRule::GetConditionText(nsACString& aConditionText) {
Media()->GetMediaText(aConditionText);
}
void CSSMediaRule::SetConditionText(const nsAString& aConditionText,
void CSSMediaRule::SetConditionText(const nsACString& aConditionText,
ErrorResult& aRv) {
if (IsReadOnly()) {
return;
@ -81,7 +81,7 @@ void CSSMediaRule::SetConditionText(const nsAString& aConditionText,
}
/* virtual */
void CSSMediaRule::GetCssText(nsAString& aCssText) const {
void CSSMediaRule::GetCssText(nsACString& aCssText) const {
Servo_MediaRule_GetCssText(mRawRule, &aCssText);
}

Просмотреть файл

@ -32,9 +32,9 @@ class CSSMediaRule final : public css::ConditionRule {
// WebIDL interface
uint16_t Type() const override { return CSSRule_Binding::MEDIA_RULE; }
// WebIDL interface
void GetCssText(nsAString& aCssText) const final;
void GetConditionText(nsAString& aConditionText) final;
void SetConditionText(const nsAString& aConditionText,
void GetCssText(nsACString& aCssText) const final;
void GetConditionText(nsACString& aConditionText) final;
void SetConditionText(const nsACString& aConditionText,
ErrorResult& aRv) final;
dom::MediaList* Media();

Просмотреть файл

@ -99,11 +99,11 @@ void CSSMozDocumentRule::List(FILE* out, int32_t aIndent) const {
}
#endif
void CSSMozDocumentRule::GetConditionText(nsAString& aConditionText) {
void CSSMozDocumentRule::GetConditionText(nsACString& aConditionText) {
Servo_MozDocumentRule_GetConditionText(mRawRule, &aConditionText);
}
void CSSMozDocumentRule::SetConditionText(const nsAString& aConditionText,
void CSSMozDocumentRule::SetConditionText(const nsACString& aConditionText,
ErrorResult& aRv) {
if (IsReadOnly()) {
return;
@ -113,7 +113,7 @@ void CSSMozDocumentRule::SetConditionText(const nsAString& aConditionText,
}
/* virtual */
void CSSMozDocumentRule::GetCssText(nsAString& aCssText) const {
void CSSMozDocumentRule::GetCssText(nsACString& aCssText) const {
Servo_MozDocumentRule_GetCssText(mRawRule, &aCssText);
}

Просмотреть файл

@ -34,9 +34,9 @@ class CSSMozDocumentRule final : public css::ConditionRule {
// WebIDL interface
uint16_t Type() const final { return CSSRule_Binding::DOCUMENT_RULE; }
void GetCssText(nsAString& aCssText) const final;
void GetConditionText(nsAString& aConditionText) final;
void SetConditionText(const nsAString& aConditionText,
void GetCssText(nsACString& aCssText) const final;
void GetConditionText(nsACString& aConditionText) final;
void SetConditionText(const nsACString& aConditionText,
ErrorResult& aRv) final;
size_t SizeOfIncludingThis(MallocSizeOf) const override;

Просмотреть файл

@ -34,7 +34,7 @@ void CSSNamespaceRule::GetURLSpec(nsString& aURLSpec) const {
atom->ToString(aURLSpec);
}
void CSSNamespaceRule::GetCssText(nsAString& aCssText) const {
void CSSNamespaceRule::GetCssText(nsACString& aCssText) const {
Servo_NamespaceRule_GetCssText(mRawRule, &aCssText);
}

Просмотреть файл

@ -34,7 +34,7 @@ class CSSNamespaceRule final : public css::Rule {
void GetURLSpec(nsString& aURLSpec) const;
// WebIDL interface
void GetCssText(nsAString& aCssText) const final;
void GetCssText(nsACString& aCssText) const final;
// WebIDL interfaces
uint16_t Type() const final { return CSSRule_Binding::NAMESPACE_RULE; }

Просмотреть файл

@ -143,7 +143,7 @@ void CSSPageRule::List(FILE* out, int32_t aIndent) const {
/* CSSRule implementation */
void CSSPageRule::GetCssText(nsAString& aCssText) const {
void CSSPageRule::GetCssText(nsACString& aCssText) const {
Servo_PageRule_GetCssText(mRawRule, &aCssText);
}

Просмотреть файл

@ -64,7 +64,7 @@ class CSSPageRule final : public css::Rule {
// WebIDL interfaces
uint16_t Type() const final { return CSSRule_Binding::PAGE_RULE; }
void GetCssText(nsAString& aCssText) const final;
void GetCssText(nsACString& aCssText) const final;
nsICSSDeclaration* Style();
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;

Просмотреть файл

@ -154,7 +154,7 @@ void CSSStyleRule::List(FILE* out, int32_t aIndent) const {
/* CSSRule implementation */
void CSSStyleRule::GetCssText(nsAString& aCssText) const {
void CSSStyleRule::GetCssText(nsACString& aCssText) const {
Servo_StyleRule_GetCssText(mRawRule, &aCssText);
}
@ -162,11 +162,11 @@ nsICSSDeclaration* CSSStyleRule::Style() { return &mDecls; }
/* CSSStyleRule implementation */
void CSSStyleRule::GetSelectorText(nsAString& aSelectorText) {
void CSSStyleRule::GetSelectorText(nsACString& aSelectorText) {
Servo_StyleRule_GetSelectorText(mRawRule, &aSelectorText);
}
void CSSStyleRule::SetSelectorText(const nsAString& aSelectorText) {
void CSSStyleRule::SetSelectorText(const nsACString& aSelectorText) {
if (IsReadOnly()) {
return;
}
@ -193,7 +193,7 @@ uint32_t CSSStyleRule::GetSelectorCount() {
}
nsresult CSSStyleRule::GetSelectorText(uint32_t aSelectorIndex,
nsAString& aText) {
nsACString& aText) {
Servo_StyleRule_GetSelectorTextAtIndex(mRawRule, aSelectorIndex, &aText);
return NS_OK;
}

Просмотреть файл

@ -62,7 +62,7 @@ class CSSStyleRule final : public BindingStyleRule, public SupportsWeakPtr {
bool IsCCLeaf() const final MOZ_MUST_OVERRIDE;
uint32_t GetSelectorCount() override;
nsresult GetSelectorText(uint32_t aSelectorIndex, nsAString& aText) override;
nsresult GetSelectorText(uint32_t aSelectorIndex, nsACString& aText) override;
nsresult GetSpecificity(uint32_t aSelectorIndex,
uint64_t* aSpecificity) override;
nsresult SelectorMatchesElement(dom::Element* aElement,
@ -74,9 +74,9 @@ class CSSStyleRule final : public BindingStyleRule, public SupportsWeakPtr {
// WebIDL interface
uint16_t Type() const final { return dom::CSSRule_Binding::STYLE_RULE; }
void GetCssText(nsAString& aCssText) const final;
void GetSelectorText(nsAString& aSelectorText) final;
void SetSelectorText(const nsAString& aSelectorText) final;
void GetCssText(nsACString& aCssText) const final;
void GetSelectorText(nsACString& aSelectorText) final;
void SetSelectorText(const nsACString& aSelectorText) final;
nsICSSDeclaration* Style() final;
RawServoStyleRule* Raw() const { return mRawRule; }

Просмотреть файл

@ -41,11 +41,11 @@ void CSSSupportsRule::List(FILE* out, int32_t aIndent) const {
}
#endif
void CSSSupportsRule::GetConditionText(nsAString& aConditionText) {
void CSSSupportsRule::GetConditionText(nsACString& aConditionText) {
Servo_SupportsRule_GetConditionText(mRawRule, &aConditionText);
}
void CSSSupportsRule::SetConditionText(const nsAString& aConditionText,
void CSSSupportsRule::SetConditionText(const nsACString& aConditionText,
ErrorResult& aRv) {
if (IsReadOnly()) {
return;
@ -55,7 +55,7 @@ void CSSSupportsRule::SetConditionText(const nsAString& aConditionText,
}
/* virtual */
void CSSSupportsRule::GetCssText(nsAString& aCssText) const {
void CSSSupportsRule::GetCssText(nsACString& aCssText) const {
Servo_SupportsRule_GetCssText(mRawRule, &aCssText);
}

Просмотреть файл

@ -28,9 +28,9 @@ class CSSSupportsRule : public css::ConditionRule {
// WebIDL interface
uint16_t Type() const override { return CSSRule_Binding::SUPPORTS_RULE; }
void GetCssText(nsAString& aCssText) const final;
void GetConditionText(nsAString& aConditionText) final;
void SetConditionText(const nsAString& aConditionText,
void GetCssText(nsACString& aCssText) const final;
void GetConditionText(nsACString& aConditionText) final;
void SetConditionText(const nsACString& aConditionText,
ErrorResult& aRv) final;
size_t SizeOfIncludingThis(MallocSizeOf) const override;

Просмотреть файл

@ -65,7 +65,7 @@ class ComputedStyle {
ServoComputedDataForgotten aComputedValues);
// Returns the computed (not resolved) value of the given property.
void GetComputedPropertyValue(nsCSSPropertyID aId, nsAString& aOut) const {
void GetComputedPropertyValue(nsCSSPropertyID aId, nsACString& aOut) const {
Servo_GetPropertyValue(this, aId, &aOut);
}

Просмотреть файл

@ -16,6 +16,7 @@
#include "mozilla/ServoBindings.h"
#include "nsCSSPropertyID.h"
#include "nsString.h"
class nsHTMLCSSStyleSheet;
@ -145,14 +146,21 @@ class DeclarationBlock final {
size_t SizeofIncludingThis(MallocSizeOf);
static already_AddRefed<DeclarationBlock> FromCssText(
const nsACString& aCssText, URLExtraData* aExtraData,
nsCompatibility aMode, css::Loader* aLoader, uint16_t aRuleType) {
RefPtr<RawServoDeclarationBlock> raw =
Servo_ParseStyleAttribute(&aCssText, aExtraData, aMode, aLoader,
aRuleType)
.Consume();
return MakeAndAddRef<DeclarationBlock>(raw.forget());
}
static already_AddRefed<DeclarationBlock> FromCssText(
const nsAString& aCssText, URLExtraData* aExtraData,
nsCompatibility aMode, css::Loader* aLoader, uint16_t aRuleType) {
NS_ConvertUTF16toUTF8 value(aCssText);
RefPtr<RawServoDeclarationBlock> raw =
Servo_ParseStyleAttribute(&value, aExtraData, aMode, aLoader, aRuleType)
.Consume();
return MakeAndAddRef<DeclarationBlock>(raw.forget());
return FromCssText(value, aExtraData, aMode, aLoader, aRuleType);
}
RawServoDeclarationBlock* Raw() const { return mRaw; }
@ -175,7 +183,7 @@ class DeclarationBlock final {
&mRaw);
}
void ToString(nsAString& aResult) const {
void ToString(nsACString& aResult) const {
Servo_DeclarationBlock_GetCssText(mRaw, &aResult);
}
@ -186,11 +194,11 @@ class DeclarationBlock final {
return Servo_DeclarationBlock_GetNthProperty(mRaw, aIndex, &aReturn);
}
void GetPropertyValue(const nsACString& aProperty, nsAString& aValue) const {
void GetPropertyValue(const nsACString& aProperty, nsACString& aValue) const {
Servo_DeclarationBlock_GetPropertyValue(mRaw, &aProperty, &aValue);
}
void GetPropertyValueByID(nsCSSPropertyID aPropID, nsAString& aValue) const {
void GetPropertyValueByID(nsCSSPropertyID aPropID, nsACString& aValue) const {
Servo_DeclarationBlock_GetPropertyValueById(mRaw, aPropID, &aValue);
}

Просмотреть файл

@ -155,8 +155,8 @@ already_AddRefed<FontFace> FontFace::CreateForRule(
}
already_AddRefed<FontFace> FontFace::Constructor(
const GlobalObject& aGlobal, const nsAString& aFamily,
const StringOrArrayBufferOrArrayBufferView& aSource,
const GlobalObject& aGlobal, const nsACString& aFamily,
const UTF8StringOrArrayBufferOrArrayBufferView& aSource,
const FontFaceDescriptors& aDescriptors, ErrorResult& aRv) {
nsISupports* global = aGlobal.GetAsSupports();
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(global);
@ -176,10 +176,10 @@ already_AddRefed<FontFace> FontFace::Constructor(
}
void FontFace::InitializeSource(
const StringOrArrayBufferOrArrayBufferView& aSource) {
if (aSource.IsString()) {
const UTF8StringOrArrayBufferOrArrayBufferView& aSource) {
if (aSource.IsUTF8String()) {
IgnoredErrorResult rv;
SetDescriptor(eCSSFontDesc_Src, aSource.GetAsString(), rv);
SetDescriptor(eCSSFontDesc_Src, aSource.GetAsUTF8String(), rv);
if (rv.Failed()) {
Reject(NS_ERROR_DOM_SYNTAX_ERR);
@ -205,98 +205,99 @@ void FontFace::InitializeSource(
DoLoad();
}
void FontFace::GetFamily(nsString& aResult) {
void FontFace::GetFamily(nsACString& aResult) {
GetDesc(eCSSFontDesc_Family, aResult);
}
void FontFace::SetFamily(const nsAString& aValue, ErrorResult& aRv) {
void FontFace::SetFamily(const nsACString& aValue, ErrorResult& aRv) {
mFontFaceSet->FlushUserFontSet();
if (SetDescriptor(eCSSFontDesc_Family, aValue, aRv)) {
DescriptorUpdated();
}
}
void FontFace::GetStyle(nsString& aResult) {
void FontFace::GetStyle(nsACString& aResult) {
GetDesc(eCSSFontDesc_Style, aResult);
}
void FontFace::SetStyle(const nsAString& aValue, ErrorResult& aRv) {
void FontFace::SetStyle(const nsACString& aValue, ErrorResult& aRv) {
if (SetDescriptor(eCSSFontDesc_Style, aValue, aRv)) {
DescriptorUpdated();
}
}
void FontFace::GetWeight(nsString& aResult) {
void FontFace::GetWeight(nsACString& aResult) {
GetDesc(eCSSFontDesc_Weight, aResult);
}
void FontFace::SetWeight(const nsAString& aValue, ErrorResult& aRv) {
void FontFace::SetWeight(const nsACString& aValue, ErrorResult& aRv) {
mFontFaceSet->FlushUserFontSet();
if (SetDescriptor(eCSSFontDesc_Weight, aValue, aRv)) {
DescriptorUpdated();
}
}
void FontFace::GetStretch(nsString& aResult) {
void FontFace::GetStretch(nsACString& aResult) {
GetDesc(eCSSFontDesc_Stretch, aResult);
}
void FontFace::SetStretch(const nsAString& aValue, ErrorResult& aRv) {
void FontFace::SetStretch(const nsACString& aValue, ErrorResult& aRv) {
mFontFaceSet->FlushUserFontSet();
if (SetDescriptor(eCSSFontDesc_Stretch, aValue, aRv)) {
DescriptorUpdated();
}
}
void FontFace::GetUnicodeRange(nsString& aResult) {
void FontFace::GetUnicodeRange(nsACString& aResult) {
GetDesc(eCSSFontDesc_UnicodeRange, aResult);
}
void FontFace::SetUnicodeRange(const nsAString& aValue, ErrorResult& aRv) {
void FontFace::SetUnicodeRange(const nsACString& aValue, ErrorResult& aRv) {
mFontFaceSet->FlushUserFontSet();
if (SetDescriptor(eCSSFontDesc_UnicodeRange, aValue, aRv)) {
DescriptorUpdated();
}
}
void FontFace::GetVariant(nsString& aResult) {
void FontFace::GetVariant(nsACString& aResult) {
// XXX Just expose the font-variant descriptor as "normal" until we
// support it properly (bug 1055385).
aResult.AssignLiteral("normal");
}
void FontFace::SetVariant(const nsAString& aValue, ErrorResult& aRv) {
void FontFace::SetVariant(const nsACString& aValue, ErrorResult& aRv) {
// XXX Ignore assignments to variant until we support font-variant
// descriptors (bug 1055385).
}
void FontFace::GetFeatureSettings(nsString& aResult) {
void FontFace::GetFeatureSettings(nsACString& aResult) {
GetDesc(eCSSFontDesc_FontFeatureSettings, aResult);
}
void FontFace::SetFeatureSettings(const nsAString& aValue, ErrorResult& aRv) {
void FontFace::SetFeatureSettings(const nsACString& aValue, ErrorResult& aRv) {
mFontFaceSet->FlushUserFontSet();
if (SetDescriptor(eCSSFontDesc_FontFeatureSettings, aValue, aRv)) {
DescriptorUpdated();
}
}
void FontFace::GetVariationSettings(nsString& aResult) {
void FontFace::GetVariationSettings(nsACString& aResult) {
GetDesc(eCSSFontDesc_FontVariationSettings, aResult);
}
void FontFace::SetVariationSettings(const nsAString& aValue, ErrorResult& aRv) {
void FontFace::SetVariationSettings(const nsACString& aValue,
ErrorResult& aRv) {
mFontFaceSet->FlushUserFontSet();
if (SetDescriptor(eCSSFontDesc_FontVariationSettings, aValue, aRv)) {
DescriptorUpdated();
}
}
void FontFace::GetDisplay(nsString& aResult) {
void FontFace::GetDisplay(nsACString& aResult) {
GetDesc(eCSSFontDesc_Display, aResult);
}
void FontFace::SetDisplay(const nsAString& aValue, ErrorResult& aRv) {
void FontFace::SetDisplay(const nsACString& aValue, ErrorResult& aRv) {
if (SetDescriptor(eCSSFontDesc_Display, aValue, aRv)) {
DescriptorUpdated();
}
@ -474,7 +475,7 @@ already_AddRefed<URLExtraData> FontFace::GetURLExtraData() const {
// Boolean result indicates whether the value of the descriptor was actually
// changed.
bool FontFace::SetDescriptor(nsCSSFontDesc aFontDesc, const nsAString& aValue,
bool FontFace::SetDescriptor(nsCSSFontDesc aFontDesc, const nsACString& aValue,
ErrorResult& aRv) {
// FIXME We probably don't need to distinguish between this anymore
// since we have common backend now.
@ -485,11 +486,9 @@ bool FontFace::SetDescriptor(nsCSSFontDesc aFontDesc, const nsAString& aValue,
// FIXME(heycam): Should not allow modification of FontFaces that are
// CSS-connected and whose rule is read only.
NS_ConvertUTF16toUTF8 value(aValue);
RefPtr<URLExtraData> url = GetURLExtraData();
bool changed;
if (!Servo_FontFaceRule_SetDescriptor(GetData(), aFontDesc, &value, url,
if (!Servo_FontFaceRule_SetDescriptor(GetData(), aFontDesc, &aValue, url,
&changed)) {
aRv.ThrowSyntaxError("Invalid font descriptor");
return false;
@ -506,7 +505,7 @@ bool FontFace::SetDescriptor(nsCSSFontDesc aFontDesc, const nsAString& aValue,
return true;
}
bool FontFace::SetDescriptors(const nsAString& aFamily,
bool FontFace::SetDescriptors(const nsACString& aFamily,
const FontFaceDescriptors& aDescriptors) {
MOZ_ASSERT(!HasRule());
MOZ_ASSERT(!mDescriptors);
@ -514,7 +513,7 @@ bool FontFace::SetDescriptors(const nsAString& aFamily,
mDescriptors = Servo_FontFaceRule_CreateEmpty().Consume();
// Helper to call SetDescriptor and return true on success, false on failure.
auto setDesc = [=](nsCSSFontDesc aDesc, const nsAString& aVal) -> bool {
auto setDesc = [=](nsCSSFontDesc aDesc, const nsACString& aVal) -> bool {
IgnoredErrorResult rv;
SetDescriptor(aDesc, aVal, rv);
return !rv.Failed();
@ -548,7 +547,7 @@ bool FontFace::SetDescriptors(const nsAString& aFamily,
return true;
}
void FontFace::GetDesc(nsCSSFontDesc aDescID, nsString& aResult) const {
void FontFace::GetDesc(nsCSSFontDesc aDescID, nsACString& aResult) const {
aResult.Truncate();
Servo_FontFaceRule_GetDescriptorCssText(GetData(), aDescID, &aResult);

Просмотреть файл

@ -28,7 +28,7 @@ class FontFaceBufferSource;
struct FontFaceDescriptors;
class FontFaceSet;
class Promise;
class StringOrArrayBufferOrArrayBufferView;
class UTF8StringOrArrayBufferOrArrayBufferView;
} // namespace dom
} // namespace mozilla
@ -149,28 +149,28 @@ class FontFace final : public nsISupports, public nsWrapperCache {
// Web IDL
static already_AddRefed<FontFace> Constructor(
const GlobalObject& aGlobal, const nsAString& aFamily,
const StringOrArrayBufferOrArrayBufferView& aSource,
const GlobalObject& aGlobal, const nsACString& aFamily,
const UTF8StringOrArrayBufferOrArrayBufferView& aSource,
const FontFaceDescriptors& aDescriptors, ErrorResult& aRV);
void GetFamily(nsString& aResult);
void SetFamily(const nsAString& aValue, ErrorResult& aRv);
void GetStyle(nsString& aResult);
void SetStyle(const nsAString& aValue, ErrorResult& aRv);
void GetWeight(nsString& aResult);
void SetWeight(const nsAString& aValue, ErrorResult& aRv);
void GetStretch(nsString& aResult);
void SetStretch(const nsAString& aValue, ErrorResult& aRv);
void GetUnicodeRange(nsString& aResult);
void SetUnicodeRange(const nsAString& aValue, ErrorResult& aRv);
void GetVariant(nsString& aResult);
void SetVariant(const nsAString& aValue, ErrorResult& aRv);
void GetFeatureSettings(nsString& aResult);
void SetFeatureSettings(const nsAString& aValue, ErrorResult& aRv);
void GetVariationSettings(nsString& aResult);
void SetVariationSettings(const nsAString& aValue, ErrorResult& aRv);
void GetDisplay(nsString& aResult);
void SetDisplay(const nsAString& aValue, ErrorResult& aRv);
void GetFamily(nsACString& aResult);
void SetFamily(const nsACString& aValue, ErrorResult& aRv);
void GetStyle(nsACString& aResult);
void SetStyle(const nsACString& aValue, ErrorResult& aRv);
void GetWeight(nsACString& aResult);
void SetWeight(const nsACString& aValue, ErrorResult& aRv);
void GetStretch(nsACString& aResult);
void SetStretch(const nsACString& aValue, ErrorResult& aRv);
void GetUnicodeRange(nsACString& aResult);
void SetUnicodeRange(const nsACString& aValue, ErrorResult& aRv);
void GetVariant(nsACString& aResult);
void SetVariant(const nsACString& aValue, ErrorResult& aRv);
void GetFeatureSettings(nsACString& aResult);
void SetFeatureSettings(const nsACString& aValue, ErrorResult& aRv);
void GetVariationSettings(nsACString& aResult);
void SetVariationSettings(const nsACString& aValue, ErrorResult& aRv);
void GetDisplay(nsACString& aResult);
void SetDisplay(const nsACString& aValue, ErrorResult& aRv);
FontFaceLoadStatus Status();
Promise* Load(ErrorResult& aRv);
@ -180,7 +180,7 @@ class FontFace final : public nsISupports, public nsWrapperCache {
FontFace(nsISupports* aParent, FontFaceSet* aFontFaceSet);
~FontFace();
void InitializeSource(const StringOrArrayBufferOrArrayBufferView& aSource);
void InitializeSource(const UTF8StringOrArrayBufferOrArrayBufferView&);
// Helper function for Load.
void DoLoad();
@ -188,7 +188,7 @@ class FontFace final : public nsISupports, public nsWrapperCache {
// Helper function for the descriptor setter methods.
// Returns true if the descriptor was modified, false if descriptor is
// unchanged (which may not be an error: check aRv for actual failure).
bool SetDescriptor(nsCSSFontDesc aFontDesc, const nsAString& aValue,
bool SetDescriptor(nsCSSFontDesc aFontDesc, const nsACString& aValue,
ErrorResult& aRv);
/**
@ -196,7 +196,7 @@ class FontFace final : public nsISupports, public nsWrapperCache {
* to the JS constructor.
* Returns true on success, false if parsing any descriptor failed.
*/
bool SetDescriptors(const nsAString& aFamily,
bool SetDescriptors(const nsACString& aFamily,
const FontFaceDescriptors& aDescriptors);
/**
@ -210,7 +210,7 @@ class FontFace final : public nsISupports, public nsWrapperCache {
*/
void SetStatus(FontFaceLoadStatus aStatus);
void GetDesc(nsCSSFontDesc aDescID, nsString& aResult) const;
void GetDesc(nsCSSFontDesc aDescID, nsACString& aResult) const;
already_AddRefed<URLExtraData> GetURLExtraData() const;

Просмотреть файл

@ -198,7 +198,7 @@ void FontFaceSet::RemoveDOMContentLoadedListener() {
}
void FontFaceSet::ParseFontShorthandForMatching(
const nsAString& aFont, RefPtr<SharedFontList>& aFamilyList,
const nsACString& aFont, RefPtr<SharedFontList>& aFamilyList,
FontWeight& aWeight, FontStretch& aStretch, FontSlantStyle& aStyle,
ErrorResult& aRv) {
auto style = StyleComputedFontStyleDescriptor::Normal();
@ -245,7 +245,7 @@ static bool HasAnyCharacterInUnicodeRange(gfxUserFontEntry* aEntry,
return false;
}
void FontFaceSet::FindMatchingFontFaces(const nsAString& aFont,
void FontFaceSet::FindMatchingFontFaces(const nsACString& aFont,
const nsAString& aText,
nsTArray<FontFace*>& aFontFaces,
ErrorResult& aRv) {
@ -318,7 +318,7 @@ TimeStamp FontFaceSet::GetNavigationStartTimeStamp() {
}
already_AddRefed<Promise> FontFaceSet::Load(JSContext* aCx,
const nsAString& aFont,
const nsACString& aFont,
const nsAString& aText,
ErrorResult& aRv) {
FlushUserFontSet();
@ -345,7 +345,7 @@ already_AddRefed<Promise> FontFaceSet::Load(JSContext* aCx,
return Promise::All(aCx, promises, aRv);
}
bool FontFaceSet::Check(const nsAString& aFont, const nsAString& aText,
bool FontFaceSet::Check(const nsACString& aFont, const nsAString& aText,
ErrorResult& aRv) {
FlushUserFontSet();
@ -1218,7 +1218,7 @@ nsresult FontFaceSet::LogMessage(gfxUserFontEntry* aUserFontEntry,
// try to give the user an indication of where the rule came from
RawServoFontFaceRule* rule = FindRuleForUserFontEntry(aUserFontEntry);
nsString href;
nsString text;
nsAutoCString text;
uint32_t line = 0;
uint32_t column = 0;
if (rule) {
@ -1247,8 +1247,8 @@ nsresult FontFaceSet::LogMessage(gfxUserFontEntry* aUserFontEntry,
uint64_t innerWindowID = mDocument->InnerWindowID();
rv = scriptError->InitWithWindowID(NS_ConvertUTF8toUTF16(message),
href, // file
text, // src line
href, // file
NS_ConvertUTF8toUTF16(text), // src line
line, column,
aFlags, // flags
"CSS Loader", // category (make separate?)

Просмотреть файл

@ -176,9 +176,9 @@ class FontFaceSet final : public DOMEventTargetHelper,
IMPL_EVENT_HANDLER(loading)
IMPL_EVENT_HANDLER(loadingdone)
IMPL_EVENT_HANDLER(loadingerror)
already_AddRefed<dom::Promise> Load(JSContext* aCx, const nsAString& aFont,
already_AddRefed<dom::Promise> Load(JSContext* aCx, const nsACString& aFont,
const nsAString& aText, ErrorResult& aRv);
bool Check(const nsAString& aFont, const nsAString& aText, ErrorResult& aRv);
bool Check(const nsACString& aFont, const nsAString& aText, ErrorResult& aRv);
dom::Promise* GetReady(ErrorResult& aRv);
dom::FontFaceSetLoadStatus Status();
@ -298,11 +298,11 @@ class FontFaceSet final : public DOMEventTargetHelper,
// Helper function for HasLoadingFontFaces.
void UpdateHasLoadingFontFaces();
void ParseFontShorthandForMatching(const nsAString& aFont,
void ParseFontShorthandForMatching(const nsACString& aFont,
RefPtr<SharedFontList>& aFamilyList,
FontWeight& aWeight, FontStretch& aStretch,
FontSlantStyle& aStyle, ErrorResult& aRv);
void FindMatchingFontFaces(const nsAString& aFont, const nsAString& aText,
void FindMatchingFontFaces(const nsACString& aFont, const nsAString& aText,
nsTArray<FontFace*>& aFontFaces, ErrorResult& aRv);
void DispatchLoadingEventAndReplaceReadyPromise();

Просмотреть файл

@ -74,7 +74,7 @@ void GroupRule::DropSheetReference() {
Rule::DropSheetReference();
}
uint32_t GroupRule::InsertRule(const nsAString& aRule, uint32_t aIndex,
uint32_t GroupRule::InsertRule(const nsACString& aRule, uint32_t aIndex,
ErrorResult& aRv) {
if (IsReadOnly()) {
return 0;

Просмотреть файл

@ -69,7 +69,7 @@ class GroupRule : public Rule {
// WebIDL API
dom::CSSRuleList* CssRules() { return mRuleList; }
uint32_t InsertRule(const nsAString& aRule, uint32_t aIndex,
uint32_t InsertRule(const nsACString& aRule, uint32_t aIndex,
ErrorResult& aRv);
void DeleteRule(uint32_t aIndex, ErrorResult& aRv);
@ -83,8 +83,8 @@ class ConditionRule : public GroupRule {
using GroupRule::GroupRule;
public:
virtual void GetConditionText(nsAString& aConditionText) = 0;
virtual void SetConditionText(const nsAString& aConditionText,
virtual void GetConditionText(nsACString& aConditionText) = 0;
virtual void SetConditionText(const nsACString& aConditionText,
ErrorResult& aRv) = 0;
};

Просмотреть файл

@ -1017,7 +1017,7 @@ Loader::MediaMatched Loader::PrepareSheet(
if (!aMediaString.IsEmpty()) {
NS_ASSERTION(!aMediaList,
"must not provide both aMediaString and aMediaList");
mediaList = MediaList::Create(aMediaString);
mediaList = MediaList::Create(NS_ConvertUTF16toUTF8(aMediaString));
}
aSheet.SetMedia(do_AddRef(mediaList));

Просмотреть файл

@ -31,11 +31,12 @@ void MappedDeclarations::SetBackgroundImage(const nsAttrValue& aValue) {
if (aValue.Type() != nsAttrValue::eURL) {
return;
}
// FIXME(emilio): Going through URL parsing again seems slightly wasteful.
nsAutoString str;
aValue.ToString(str);
nsAutoCString utf8;
CopyUTF16toUTF8(str, utf8);
Servo_DeclarationBlock_SetBackgroundImage(
mDecl, &str, mDocument->DefaultStyleAttrURLData());
mDecl, &utf8, mDocument->DefaultStyleAttrURLData());
}
} // namespace mozilla

Просмотреть файл

@ -178,7 +178,7 @@ class MappedDeclarations final {
}
// Set font-family to a string
void SetFontFamily(const nsString& aValue) {
void SetFontFamily(const nsACString& aValue) {
Servo_DeclarationBlock_SetFontFamily(mDecl, &aValue);
}

Просмотреть файл

@ -72,23 +72,23 @@ already_AddRefed<MediaList> MediaList::Clone() {
MediaList::MediaList() : mRawList(Servo_MediaList_Create().Consume()) {}
MediaList::MediaList(const nsAString& aMedia, CallerType aCallerType)
MediaList::MediaList(const nsACString& aMedia, CallerType aCallerType)
: MediaList() {
SetTextInternal(aMedia, aCallerType);
}
void MediaList::GetText(nsAString& aMediaText) {
void MediaList::GetText(nsACString& aMediaText) {
Servo_MediaList_GetText(mRawList, &aMediaText);
}
/* static */
already_AddRefed<MediaList> MediaList::Create(const nsAString& aMedia,
already_AddRefed<MediaList> MediaList::Create(const nsACString& aMedia,
CallerType aCallerType) {
RefPtr<MediaList> mediaList = new MediaList(aMedia, aCallerType);
return mediaList.forget();
}
void MediaList::SetText(const nsAString& aMediaText) {
void MediaList::SetText(const nsACString& aMediaText) {
if (IsReadOnly()) {
return;
}
@ -96,28 +96,26 @@ void MediaList::SetText(const nsAString& aMediaText) {
SetTextInternal(aMediaText, CallerType::NonSystem);
}
void MediaList::GetMediaText(nsAString& aMediaText) { GetText(aMediaText); }
void MediaList::GetMediaText(nsACString& aMediaText) { GetText(aMediaText); }
void MediaList::SetTextInternal(const nsAString& aMediaText,
void MediaList::SetTextInternal(const nsACString& aMediaText,
CallerType aCallerType) {
NS_ConvertUTF16toUTF8 mediaText(aMediaText);
Servo_MediaList_SetText(mRawList, &mediaText, aCallerType);
Servo_MediaList_SetText(mRawList, &aMediaText, aCallerType);
}
uint32_t MediaList::Length() { return Servo_MediaList_GetLength(mRawList); }
void MediaList::IndexedGetter(uint32_t aIndex, bool& aFound,
nsAString& aReturn) {
nsACString& aReturn) {
aFound = Servo_MediaList_GetMediumAt(mRawList, aIndex, &aReturn);
if (!aFound) {
SetDOMStringToNull(aReturn);
aReturn.SetIsVoid(true);
}
}
void MediaList::Delete(const nsAString& aOldMedium, ErrorResult& aRv) {
void MediaList::Delete(const nsACString& aOldMedium, ErrorResult& aRv) {
MOZ_ASSERT(!IsReadOnly());
NS_ConvertUTF16toUTF8 oldMedium(aOldMedium);
if (Servo_MediaList_DeleteMedium(mRawList, &oldMedium)) {
if (Servo_MediaList_DeleteMedium(mRawList, &aOldMedium)) {
return;
}
aRv.ThrowNotFoundError("Medium not in list");
@ -130,7 +128,7 @@ bool MediaList::Matches(const Document& aDocument) const {
return Servo_MediaList_Matches(mRawList, rawSet);
}
void MediaList::Append(const nsAString& aNewMedium, ErrorResult& aRv) {
void MediaList::Append(const nsACString& aNewMedium, ErrorResult& aRv) {
MOZ_ASSERT(!IsReadOnly());
if (aNewMedium.IsEmpty()) {
// XXXbz per spec there should not be an exception here, as far as
@ -138,24 +136,23 @@ void MediaList::Append(const nsAString& aNewMedium, ErrorResult& aRv) {
aRv.ThrowNotFoundError("Empty medium");
return;
}
NS_ConvertUTF16toUTF8 newMedium(aNewMedium);
Servo_MediaList_AppendMedium(mRawList, &newMedium);
Servo_MediaList_AppendMedium(mRawList, &aNewMedium);
}
void MediaList::SetMediaText(const nsAString& aMediaText) {
void MediaList::SetMediaText(const nsACString& aMediaText) {
DoMediaChange([&](ErrorResult& aRv) { SetText(aMediaText); }, IgnoreErrors());
}
void MediaList::Item(uint32_t aIndex, nsAString& aReturn) {
void MediaList::Item(uint32_t aIndex, nsACString& aReturn) {
bool dummy;
IndexedGetter(aIndex, dummy, aReturn);
}
void MediaList::DeleteMedium(const nsAString& aOldMedium, ErrorResult& aRv) {
void MediaList::DeleteMedium(const nsACString& aOldMedium, ErrorResult& aRv) {
DoMediaChange([&](ErrorResult& aRv) { Delete(aOldMedium, aRv); }, aRv);
}
void MediaList::AppendMedium(const nsAString& aNewMedium, ErrorResult& aRv) {
void MediaList::AppendMedium(const nsACString& aNewMedium, ErrorResult& aRv) {
DoMediaChange([&](ErrorResult& aRv) { Append(aNewMedium, aRv); }, aRv);
}

Просмотреть файл

@ -35,27 +35,27 @@ class MediaList final : public nsISupports, public nsWrapperCache {
: mRawList(aRawList) {}
static already_AddRefed<MediaList> Create(
const nsAString& aMedia, CallerType aCallerType = CallerType::NonSystem);
const nsACString& aMedia, CallerType aCallerType = CallerType::NonSystem);
already_AddRefed<MediaList> Clone();
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
nsISupports* GetParentObject() const;
void GetText(nsAString& aMediaText);
void SetText(const nsAString& aMediaText);
void GetText(nsACString& aMediaText);
void SetText(const nsACString& aMediaText);
bool Matches(const Document&) const;
void SetStyleSheet(StyleSheet* aSheet);
// WebIDL
void GetMediaText(nsAString& aMediaText);
void SetMediaText(const nsAString& aMediaText);
void GetMediaText(nsACString& aMediaText);
void SetMediaText(const nsACString& aMediaText);
uint32_t Length();
void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aReturn);
void Item(uint32_t aIndex, nsAString& aResult);
void DeleteMedium(const nsAString& aMedium, ErrorResult& aRv);
void AppendMedium(const nsAString& aMedium, ErrorResult& aRv);
void IndexedGetter(uint32_t aIndex, bool& aFound, nsACString& aReturn);
void Item(uint32_t aIndex, nsACString& aResult);
void DeleteMedium(const nsACString& aMedium, ErrorResult& aRv);
void AppendMedium(const nsACString& aMedium, ErrorResult& aRv);
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const;
@ -64,13 +64,13 @@ class MediaList final : public nsISupports, public nsWrapperCache {
}
protected:
MediaList(const nsAString& aMedia, CallerType);
MediaList(const nsACString& aMedia, CallerType);
MediaList();
void SetTextInternal(const nsAString& aMediaText, CallerType);
void SetTextInternal(const nsACString& aMediaText, CallerType);
void Delete(const nsAString& aOldMedium, ErrorResult& aRv);
void Append(const nsAString& aNewMedium, ErrorResult& aRv);
void Delete(const nsACString& aOldMedium, ErrorResult& aRv);
void Append(const nsACString& aNewMedium, ErrorResult& aRv);
~MediaList() {
MOZ_ASSERT(!mStyleSheet, "Backpointer should have been cleared");

Просмотреть файл

@ -20,7 +20,7 @@ namespace mozilla {
namespace dom {
MediaQueryList::MediaQueryList(Document* aDocument,
const nsAString& aMediaQueryList,
const nsACString& aMediaQueryList,
CallerType aCallerType)
: DOMEventTargetHelper(aDocument->GetInnerWindow()),
mDocument(aDocument),
@ -56,7 +56,7 @@ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(MediaQueryList, DOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(MediaQueryList, DOMEventTargetHelper)
void MediaQueryList::GetMedia(nsAString& aMedia) {
void MediaQueryList::GetMedia(nsACString& aMedia) {
mMediaList->GetText(aMedia);
}

Просмотреть файл

@ -29,7 +29,7 @@ class MediaQueryList final : public DOMEventTargetHelper,
public:
// The caller who constructs is responsible for calling Evaluate
// before calling any other methods.
MediaQueryList(Document* aDocument, const nsAString& aMediaQueryList,
MediaQueryList(Document* aDocument, const nsACString& aMediaQueryList,
CallerType aCallerType);
private:
@ -50,7 +50,7 @@ class MediaQueryList final : public DOMEventTargetHelper,
JS::Handle<JSObject*> aGivenProto) override;
// WebIDL methods
void GetMedia(nsAString& aMedia);
void GetMedia(nsACString& aMedia);
bool Matches();
void AddListener(EventListener* aListener, ErrorResult& aRv);
void RemoveListener(EventListener* aListener, ErrorResult& aRv);

Просмотреть файл

@ -86,7 +86,7 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
/* virtual */
void Rule::DropSheetReference() { mSheet = nullptr; }
void Rule::SetCssText(const nsAString& aCssText) {
void Rule::SetCssText(const nsACString& aCssText) {
// We used to throw for some rule types, but not all. Specifically, we did
// not throw for StyleRule. Let's just always not throw.
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше