Gecko:LineBreakerAPI: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 23: | Line 23: | ||
}; | }; | ||
/** | |||
* Asks the linebreaker to compute line break opportunities for a block | |||
* of text. The text is a sequence of text chunks. The chunks with | |||
* non-null mBreakOutput get break opportunities computed for them and | |||
* stored in the array pointed to by mBreakOutput. | |||
*/ | |||
void ComputeLineBreaks(const TextChunk* aTextChunks, PRUint32 aNumChunks); | void ComputeLineBreaks(const TextChunk* aTextChunks, PRUint32 aNumChunks); | ||
}; | }; | ||
Revision as of 02:04, 17 November 2006
New Linebreaking API
Overview
- Compute linebreaks for a run of text with one API call, where the run of text begins and ends with either a known line-break or non-text content
- The run of text can contain text from different DOM nodes
- We only need to compute linebreaks for some parts of the text (for other parts of the text we already know the linebreaks or there can't be linebreaks because of CSS white-space override)
- There should only be ONE linebreaker algorithm seen by layout. If we need language-specific behaviour, the linebreaker should implement that internally.
Suggestion
class nsLineBreaker {
public:
struct TextChunk {
nsIAtom* mLanguageHint;
const void* mCharacters;
PRUint32 mLength;
enum { CHAR, UNICHAR } mCharacterType;
PRPackedBool* mBreakOutput; /* mLength + 1 bytes, set to PR_TRUE if we can
break *before* the corresponding character of
mText. Can be null, meaning we don't need to
know the breakability of this text chunk. */
};
/**
* Asks the linebreaker to compute line break opportunities for a block
* of text. The text is a sequence of text chunks. The chunks with
* non-null mBreakOutput get break opportunities computed for them and
* stored in the array pointed to by mBreakOutput.
*/
void ComputeLineBreaks(const TextChunk* aTextChunks, PRUint32 aNumChunks);
};