Issue #457 - Remove the constructor from gfxShapedText::CompressedGlyph and make it a trivial class

Also provide a couple of convenience "factory" methods to create simple and complex glyph values.
This commit is contained in:
trav90 2022-05-28 11:45:35 -05:00 committed by roytam1
commit c782076add
9 changed files with 137 additions and 102 deletions

View file

@ -70,7 +70,7 @@ struct gfxTextRunDrawCallbacks {
* of text. It stores runs of positioned glyph data, each run having a single
* gfxFont. The glyphs are associated with a string of source text, and the
* gfxTextRun APIs take parameters that are offsets into that source text.
*
*
* gfxTextRuns are mostly immutable. The only things that can change are
* inter-cluster spacing and line break placement. Spacing is always obtained
* lazily by methods that need it, it is not cached. Line breaks are stored
@ -78,7 +78,7 @@ struct gfxTextRunDrawCallbacks {
* not actually do anything to explicitly account for line breaks). Initially
* there are no line breaks. The textrun can record line breaks before or after
* any given cluster. (Line breaks specified inside clusters are ignored.)
*
*
* It is important that zero-length substrings are handled correctly. This will
* be on the test!
*/
@ -163,11 +163,11 @@ public:
* Set the potential linebreaks for a substring of the textrun. These are
* the "allow break before" points. Initially, there are no potential
* linebreaks.
*
*
* This can change glyphs and/or geometry! Some textruns' shapes
* depend on potential line breaks (e.g., title-case-converting textruns).
* This function is virtual so that those textruns can reshape themselves.
*
*
* @return true if this changed the linebreaks, false if the new line
* breaks are the same as the old
*/
@ -179,7 +179,7 @@ public:
* potential line break points and computation of spacing. We pass the data
* this way to allow lazy data acquisition; for example BreakAndMeasureText
* will want to only ask for properties of text it's actually looking at.
*
*
* NOTE that requested spacing may not actually be applied, if the textrun
* is unable to apply it in some context. Exception: spacing around a
* whitespace character MUST always be applied.
@ -238,7 +238,7 @@ public:
* Draws a substring. Uses only GetSpacing from aBreakProvider.
* The provided point is the baseline origin on the left of the string
* for LTR, on the right of the string for RTL.
*
*
* Drawing should respect advance widths in the sense that for LTR runs,
* Draw(Range(start, middle), pt, ...) followed by
* Draw(Range(middle, end), gfxPoint(pt.x + advance, pt.y), ...)
@ -250,7 +250,7 @@ public:
* Draw(Range(start, middle), gfxPoint(pt.x + advance, pt.y), ...)
* should have the same effect as
* Draw(Range(start, end), pt, ...)
*
*
* Glyphs should be drawn in logical content order, which can be significant
* if they overlap (perhaps due to negative spacing).
*/
@ -307,14 +307,14 @@ public:
* Clear all stored line breaks for the given range (both before and after),
* and then set the line-break state before aRange.start to aBreakBefore and
* after the last cluster to aBreakAfter.
*
*
* We require that before and after line breaks be consistent. For clusters
* i and i+1, we require that if there is a break after cluster i, a break
* will be specified before cluster i+1. This may be temporarily violated
* (e.g. after reflowing line L and before reflowing line L+1); to handle
* these temporary violations, we say that there is a break betwen i and i+1
* if a break is specified after i OR a break is specified before i+1.
*
*
* This can change textrun geometry! The existence of a linebreak can affect
* the advance width of the cluster before the break (when kerning) or the
* geometry of one cluster before the break or any number of clusters
@ -322,11 +322,11 @@ public:
* arbitrary; if some scripts require breaking it, then we need to
* alter nsTextFrame::TrimTrailingWhitespace, perhaps drastically becase
* it could affect the layout of frames before it...)
*
*
* We return true if glyphs or geometry changed, false otherwise. This
* function is virtual so that gfxTextRun subclasses can reshape
* properly.
*
*
* @param aAdvanceWidthDelta if non-null, returns the change in advance
* width of the given range.
*/
@ -393,7 +393,7 @@ public:
* @param aBreakPriority in/out the priority of the break opportunity
* saved in the line. If we are prioritizing break opportunities, we will
* not set a break with a lower priority. @see gfxBreakPriority.
*
*
* Note that negative advance widths are possible especially if negative
* spacing is provided.
*/
@ -596,11 +596,11 @@ public:
// when the part is at the start of the ligature, and after-spacing
// when the part is as the end of the ligature
gfxFloat mPartWidth;
bool mClipBeforePart;
bool mClipAfterPart;
};
// return storage used by this run, for memory reporter;
// nsTransformedTextRun needs to override this as it holds additional data
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf)
@ -681,7 +681,7 @@ protected:
CompressedGlyph *mCharacterGlyphs;
private:
// **** general helpers ****
// **** general helpers ****
// Get the total advance for a range of glyphs.
int32_t GetAdvanceForGlyphs(Range aRange) const;
@ -765,6 +765,7 @@ private:
class gfxFontGroup : public gfxTextRunFactory {
public:
typedef mozilla::unicode::Script Script;
typedef gfxShapedText::CompressedGlyph CompressedGlyph;
static void Shutdown(); // platform must call this to release the languageAtomService