Bug 1745113 Part 4 - Change AppUnitWidthOfString to take a Span parameter. r=jfkthame

`Span` is more versatile than `const String&`, and existing callers passing a
String into this function do not need any change.

This patch makes the next part simpler.

Differential Revision: https://phabricator.services.mozilla.com/D135642
This commit is contained in:
Ting-Yu Lin 2022-01-13 18:36:04 +00:00
Родитель e418a257b5
Коммит 529d2dbd76
1 изменённых файлов: 4 добавлений и 3 удалений

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

@ -18,6 +18,7 @@
#include "mozilla/SVGImageContext.h"
#include "mozilla/ToString.h"
#include "mozilla/TypedEnumBits.h"
#include "mozilla/Span.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/WritingModes.h"
#include "mozilla/layout/FrameChildList.h"
@ -1654,11 +1655,11 @@ class nsLayoutUtils {
DrawTarget* aDrawTarget) {
return AppUnitWidthOfString(&aC, 1, aFontMetrics, aDrawTarget);
}
static nscoord AppUnitWidthOfString(const nsString& aString,
static nscoord AppUnitWidthOfString(mozilla::Span<const char16_t> aString,
nsFontMetrics& aFontMetrics,
DrawTarget* aDrawTarget) {
return nsLayoutUtils::AppUnitWidthOfString(aString.get(), aString.Length(),
aFontMetrics, aDrawTarget);
return nsLayoutUtils::AppUnitWidthOfString(
aString.Elements(), aString.Length(), aFontMetrics, aDrawTarget);
}
static nscoord AppUnitWidthOfString(const char16_t* aString, uint32_t aLength,
nsFontMetrics& aFontMetrics,