1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsTextFrame_h__
7 #define nsTextFrame_h__
9 #include "mozilla/Attributes.h"
11 #include "nsSplittableFrame.h"
12 #include "nsLineBox.h"
13 #include "gfxSkipChars.h"
14 #include "gfxTextRun.h"
15 #include "nsDisplayList.h"
16 #include "JustificationUtils.h"
18 // Undo the windows.h damage
19 #if defined(XP_WIN) && defined(DrawText)
23 class nsTextPaintStyle
;
24 class PropertyProvider
;
25 struct SelectionDetails
;
28 typedef nsFrame nsTextFrameBase
;
30 class nsDisplayTextGeometry
;
33 class nsTextFrameTextRunCache
{
36 static void Shutdown();
39 class nsTextFrame
: public nsTextFrameBase
{
41 NS_DECL_QUERYFRAME_TARGET(nsTextFrame
)
42 NS_DECL_FRAMEARENA_HELPERS
44 friend class nsContinuingTextFrame
;
45 friend class nsDisplayTextGeometry
;
46 friend class nsDisplayText
;
48 explicit nsTextFrame(nsStyleContext
* aContext
)
49 : nsTextFrameBase(aContext
)
51 NS_ASSERTION(mContentOffset
== 0, "Bogus content offset");
58 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
59 const nsRect
& aDirtyRect
,
60 const nsDisplayListSet
& aLists
) MOZ_OVERRIDE
;
62 virtual void Init(nsIContent
* aContent
,
63 nsContainerFrame
* aParent
,
64 nsIFrame
* aPrevInFlow
) MOZ_OVERRIDE
;
66 virtual void DestroyFrom(nsIFrame
* aDestructRoot
) MOZ_OVERRIDE
;
68 virtual nsresult
GetCursor(const nsPoint
& aPoint
,
69 nsIFrame::Cursor
& aCursor
) MOZ_OVERRIDE
;
71 virtual nsresult
CharacterDataChanged(CharacterDataChangeInfo
* aInfo
) MOZ_OVERRIDE
;
73 virtual void DidSetStyleContext(nsStyleContext
* aOldStyleContext
) MOZ_OVERRIDE
;
75 virtual nsIFrame
* GetNextContinuation() const MOZ_OVERRIDE
{
76 return mNextContinuation
;
78 virtual void SetNextContinuation(nsIFrame
* aNextContinuation
) MOZ_OVERRIDE
{
79 NS_ASSERTION (!aNextContinuation
|| GetType() == aNextContinuation
->GetType(),
80 "setting a next continuation with incorrect type!");
81 NS_ASSERTION (!nsSplittableFrame::IsInNextContinuationChain(aNextContinuation
, this),
82 "creating a loop in continuation chain!");
83 mNextContinuation
= aNextContinuation
;
84 if (aNextContinuation
)
85 aNextContinuation
->RemoveStateBits(NS_FRAME_IS_FLUID_CONTINUATION
);
87 virtual nsIFrame
* GetNextInFlowVirtual() const MOZ_OVERRIDE
{ return GetNextInFlow(); }
88 nsIFrame
* GetNextInFlow() const {
89 return mNextContinuation
&& (mNextContinuation
->GetStateBits() & NS_FRAME_IS_FLUID_CONTINUATION
) ?
90 mNextContinuation
: nullptr;
92 virtual void SetNextInFlow(nsIFrame
* aNextInFlow
) MOZ_OVERRIDE
{
93 NS_ASSERTION (!aNextInFlow
|| GetType() == aNextInFlow
->GetType(),
94 "setting a next in flow with incorrect type!");
95 NS_ASSERTION (!nsSplittableFrame::IsInNextContinuationChain(aNextInFlow
, this),
96 "creating a loop in continuation chain!");
97 mNextContinuation
= aNextInFlow
;
99 aNextInFlow
->AddStateBits(NS_FRAME_IS_FLUID_CONTINUATION
);
101 virtual nsIFrame
* LastInFlow() const MOZ_OVERRIDE
;
102 virtual nsIFrame
* LastContinuation() const MOZ_OVERRIDE
;
104 virtual nsSplittableType
GetSplittableType() const MOZ_OVERRIDE
{
105 return NS_FRAME_SPLITTABLE
;
109 * Get the "type" of the frame
111 * @see nsGkAtoms::textFrame
113 virtual nsIAtom
* GetType() const MOZ_OVERRIDE
;
115 virtual bool IsFrameOfType(uint32_t aFlags
) const MOZ_OVERRIDE
117 // Set the frame state bit for text frames to mark them as replaced.
118 // XXX kipp: temporary
119 return nsFrame::IsFrameOfType(aFlags
& ~(nsIFrame::eReplaced
|
120 nsIFrame::eLineParticipant
));
123 virtual void InvalidateFrame(uint32_t aDisplayItemKey
= 0) MOZ_OVERRIDE
;
124 virtual void InvalidateFrameWithRect(const nsRect
& aRect
, uint32_t aDisplayItemKey
= 0) MOZ_OVERRIDE
;
126 #ifdef DEBUG_FRAME_DUMP
127 void List(FILE* out
= stderr
, const char* aPrefix
= "", uint32_t aFlags
= 0) const MOZ_OVERRIDE
;
128 virtual nsresult
GetFrameName(nsAString
& aResult
) const MOZ_OVERRIDE
;
129 void ToCString(nsCString
& aBuf
, int32_t* aTotalContentLength
) const;
133 virtual nsFrameState
GetDebugStateBits() const MOZ_OVERRIDE
;
136 virtual ContentOffsets
CalcContentOffsetsFromFramePoint(nsPoint aPoint
) MOZ_OVERRIDE
;
137 ContentOffsets
GetCharacterOffsetAtFramePoint(const nsPoint
&aPoint
);
140 * This is called only on the primary text frame. It indicates that
141 * the selection state of the given character range has changed.
142 * Text in the range is unconditionally invalidated
143 * (Selection::Repaint depends on this).
144 * @param aSelected true if the selection has been added to the range,
146 * @param aType the type of selection added or removed
148 void SetSelectedRange(uint32_t aStart
, uint32_t aEnd
, bool aSelected
,
149 SelectionType aType
);
151 virtual FrameSearchResult
PeekOffsetNoAmount(bool aForward
, int32_t* aOffset
) MOZ_OVERRIDE
;
152 virtual FrameSearchResult
PeekOffsetCharacter(bool aForward
, int32_t* aOffset
,
153 bool aRespectClusters
= true) MOZ_OVERRIDE
;
154 virtual FrameSearchResult
PeekOffsetWord(bool aForward
, bool aWordSelectEatSpace
, bool aIsKeyboardSelect
,
155 int32_t* aOffset
, PeekWordState
* aState
) MOZ_OVERRIDE
;
157 virtual nsresult
CheckVisibility(nsPresContext
* aContext
, int32_t aStartIndex
, int32_t aEndIndex
, bool aRecurse
, bool *aFinished
, bool *_retval
) MOZ_OVERRIDE
;
159 // Flags for aSetLengthFlags
160 enum { ALLOW_FRAME_CREATION_AND_DESTRUCTION
= 0x01 };
162 // Update offsets to account for new length. This may clear mTextRun.
163 void SetLength(int32_t aLength
, nsLineLayout
* aLineLayout
,
164 uint32_t aSetLengthFlags
= 0);
166 virtual nsresult
GetOffsets(int32_t &start
, int32_t &end
)const MOZ_OVERRIDE
;
168 virtual void AdjustOffsetsForBidi(int32_t start
, int32_t end
) MOZ_OVERRIDE
;
170 virtual nsresult
GetPointFromOffset(int32_t inOffset
,
171 nsPoint
* outPoint
) MOZ_OVERRIDE
;
173 virtual nsresult
GetChildFrameContainingOffset(int32_t inContentOffset
,
175 int32_t* outFrameContentOffset
,
176 nsIFrame
** outChildFrame
) MOZ_OVERRIDE
;
178 virtual bool IsVisibleInSelection(nsISelection
* aSelection
) MOZ_OVERRIDE
;
180 virtual bool IsEmpty() MOZ_OVERRIDE
;
181 virtual bool IsSelfEmpty() MOZ_OVERRIDE
{ return IsEmpty(); }
182 virtual nscoord
GetLogicalBaseline(mozilla::WritingMode aWritingMode
) const MOZ_OVERRIDE
;
184 virtual bool HasSignificantTerminalNewline() const MOZ_OVERRIDE
;
187 * Returns true if this text frame is logically adjacent to the end of the
190 bool IsAtEndOfLine() const;
193 * Call this only after reflow the frame. Returns true if non-collapsed
194 * characters are present.
196 bool HasNoncollapsedCharacters() const {
197 return (GetStateBits() & TEXT_HAS_NONCOLLAPSED_CHARACTERS
) != 0;
201 virtual mozilla::a11y::AccType
AccessibleType() MOZ_OVERRIDE
;
204 float GetFontSizeInflation() const;
205 bool IsCurrentFontInflation(float aInflation
) const;
206 bool HasFontSizeInflation() const {
207 return (GetStateBits() & TEXT_HAS_FONT_INFLATION
) != 0;
209 void SetFontSizeInflation(float aInflation
);
211 virtual void MarkIntrinsicISizesDirty() MOZ_OVERRIDE
;
212 virtual nscoord
GetMinISize(nsRenderingContext
*aRenderingContext
) MOZ_OVERRIDE
;
213 virtual nscoord
GetPrefISize(nsRenderingContext
*aRenderingContext
) MOZ_OVERRIDE
;
214 virtual void AddInlineMinISize(nsRenderingContext
*aRenderingContext
,
215 InlineMinISizeData
*aData
) MOZ_OVERRIDE
;
216 virtual void AddInlinePrefISize(nsRenderingContext
*aRenderingContext
,
217 InlinePrefISizeData
*aData
) MOZ_OVERRIDE
;
218 virtual mozilla::LogicalSize
219 ComputeSize(nsRenderingContext
*aRenderingContext
,
220 mozilla::WritingMode aWritingMode
,
221 const mozilla::LogicalSize
& aCBSize
,
222 nscoord aAvailableISize
,
223 const mozilla::LogicalSize
& aMargin
,
224 const mozilla::LogicalSize
& aBorder
,
225 const mozilla::LogicalSize
& aPadding
,
226 ComputeSizeFlags aFlags
) MOZ_OVERRIDE
;
227 virtual nsRect
ComputeTightBounds(gfxContext
* aContext
) const MOZ_OVERRIDE
;
228 virtual nsresult
GetPrefWidthTightBounds(nsRenderingContext
* aContext
,
230 nscoord
* aXMost
) MOZ_OVERRIDE
;
231 virtual void Reflow(nsPresContext
* aPresContext
,
232 nsHTMLReflowMetrics
& aMetrics
,
233 const nsHTMLReflowState
& aReflowState
,
234 nsReflowStatus
& aStatus
) MOZ_OVERRIDE
;
235 virtual bool CanContinueTextRun() const MOZ_OVERRIDE
;
236 // Method that is called for a text frame that is logically
237 // adjacent to the end of the line (i.e. followed only by empty text frames,
238 // placeholders or inlines containing such).
240 // true if we trimmed some space or changed metrics in some other way.
241 // In this case, we should call RecomputeOverflow on this frame.
243 // an amount to *subtract* from the frame's width (zero if !mChanged)
246 TrimOutput
TrimTrailingWhiteSpace(nsRenderingContext
* aRC
);
247 virtual nsresult
GetRenderedText(nsAString
* aString
= nullptr,
248 gfxSkipChars
* aSkipChars
= nullptr,
249 gfxSkipCharsIterator
* aSkipIter
= nullptr,
250 uint32_t aSkippedStartOffset
= 0,
251 uint32_t aSkippedMaxLength
= UINT32_MAX
) MOZ_OVERRIDE
;
254 RecomputeOverflow(const nsHTMLReflowState
& aBlockReflowState
);
257 // Anything in reflow (but not intrinsic width calculation) or
258 // painting should use the inflated text run (i.e., with font size
259 // inflation applied).
261 // Intrinsic width calculation should use the non-inflated text run.
262 // When there is font size inflation, it will be different.
266 void AddInlineMinISizeForFlow(nsRenderingContext
*aRenderingContext
,
267 nsIFrame::InlineMinISizeData
*aData
,
268 TextRunType aTextRunType
);
269 void AddInlinePrefISizeForFlow(nsRenderingContext
*aRenderingContext
,
270 InlinePrefISizeData
*aData
,
271 TextRunType aTextRunType
);
274 * Calculate the horizontal bounds of the grapheme clusters that fit entirely
275 * inside the given left/right edges (which are positive lengths from the
276 * respective frame edge). If an input value is zero it is ignored and the
277 * result for that edge is zero. All out parameter values are undefined when
278 * the method returns false.
279 * @return true if at least one whole grapheme cluster fit between the edges
281 bool MeasureCharClippedText(nscoord aLeftEdge
, nscoord aRightEdge
,
282 nscoord
* aSnappedLeftEdge
,
283 nscoord
* aSnappedRightEdge
);
285 * Same as above; this method also the returns the corresponding text run
286 * offset and number of characters that fit. All out parameter values are
287 * undefined when the method returns false.
288 * @return true if at least one whole grapheme cluster fit between the edges
290 bool MeasureCharClippedText(PropertyProvider
& aProvider
,
291 nscoord aLeftEdge
, nscoord aRightEdge
,
292 uint32_t* aStartOffset
, uint32_t* aMaxLength
,
293 nscoord
* aSnappedLeftEdge
,
294 nscoord
* aSnappedRightEdge
);
297 * Object with various callbacks for PaintText() to invoke for different parts
298 * of the frame's text rendering, when we're generating paths rather than
301 * Callbacks are invoked in the following order:
303 * (NotifyBeforeSelectionBackground NotifySelectionBackgroundPathEmitted)?
304 * (NotifyBeforeDecorationLine NotifyDecorationLinePathEmitted)*
306 * (NotifyGlyphPathEmitted |
307 * (NotifyBeforeSVGGlyphPainted NotifyAfterSVGGlyphPainted))*
309 * (NotifyBeforeDecorationLine NotifyDecorationLinePathEmitted)*
310 * (NotifyBeforeSelectionDecorationLine NotifySelectionDecorationLinePathEmitted)*
312 * The color of each part of the frame's text rendering is passed as an argument
313 * to the NotifyBefore* callback for that part. The nscolor can take on one of
314 * the three selection special colors defined in LookAndFeel.h --
315 * NS_TRANSPARENT, NS_SAME_AS_FOREGROUND_COLOR and
316 * NS_40PERCENT_FOREGROUND_COLOR.
318 struct DrawPathCallbacks
: gfxTextRunDrawCallbacks
321 * @param aShouldPaintSVGGlyphs Whether SVG glyphs should be painted.
323 explicit DrawPathCallbacks(bool aShouldPaintSVGGlyphs
= false)
324 : gfxTextRunDrawCallbacks(aShouldPaintSVGGlyphs
)
329 * Called just before any paths have been emitted to the gfxContext
330 * for the glyphs of the frame's text.
332 virtual void NotifyBeforeText(nscolor aColor
) { }
335 * Called just after all the paths have been emitted to the gfxContext
336 * for the glyphs of the frame's text.
338 virtual void NotifyAfterText() { }
341 * Called just before a path corresponding to the selection background
342 * has been emitted to the gfxContext.
344 virtual void NotifyBeforeSelectionBackground(nscolor aColor
) { }
347 * Called just after a path corresponding to the selection background
348 * has been emitted to the gfxContext.
350 virtual void NotifySelectionBackgroundPathEmitted() { }
353 * Called just before a path corresponding to a text decoration line
354 * has been emitted to the gfxContext.
356 virtual void NotifyBeforeDecorationLine(nscolor aColor
) { }
359 * Called just after a path corresponding to a text decoration line
360 * has been emitted to the gfxContext.
362 virtual void NotifyDecorationLinePathEmitted() { }
365 * Called just before a path corresponding to a selection decoration line
366 * has been emitted to the gfxContext.
368 virtual void NotifyBeforeSelectionDecorationLine(nscolor aColor
) { }
371 * Called just after a path corresponding to a selection decoration line
372 * has been emitted to the gfxContext.
374 virtual void NotifySelectionDecorationLinePathEmitted() { }
377 // Primary frame paint method called from nsDisplayText. Can also be used
378 // to generate paths rather than paint the frame's text by passing a callback
379 // object. The private DrawText() is what applies the text to a graphics
381 void PaintText(nsRenderingContext
* aRenderingContext
, nsPoint aPt
,
382 const nsRect
& aDirtyRect
, const nsCharClipDisplayItem
& aItem
,
383 gfxTextContextPaint
* aContextPaint
= nullptr,
384 DrawPathCallbacks
* aCallbacks
= nullptr);
385 // helper: paint text frame when we're impacted by at least one selection.
386 // Return false if the text was not painted and we should continue with
388 bool PaintTextWithSelection(gfxContext
* aCtx
,
389 const gfxPoint
& aFramePt
,
390 const gfxPoint
& aTextBaselinePt
,
391 const gfxRect
& aDirtyRect
,
392 PropertyProvider
& aProvider
,
393 uint32_t aContentOffset
,
394 uint32_t aContentLength
,
395 nsTextPaintStyle
& aTextPaintStyle
,
396 const nsCharClipDisplayItem::ClipEdges
& aClipEdges
,
397 gfxTextContextPaint
* aContextPaint
,
398 DrawPathCallbacks
* aCallbacks
);
399 // helper: paint text with foreground and background colors determined
400 // by selection(s). Also computes a mask of all selection types applying to
401 // our text, returned in aAllTypes.
402 // Return false if the text was not painted and we should continue with
404 bool PaintTextWithSelectionColors(gfxContext
* aCtx
,
405 const gfxPoint
& aFramePt
,
406 const gfxPoint
& aTextBaselinePt
,
407 const gfxRect
& aDirtyRect
,
408 PropertyProvider
& aProvider
,
409 uint32_t aContentOffset
,
410 uint32_t aContentLength
,
411 nsTextPaintStyle
& aTextPaintStyle
,
412 SelectionDetails
* aDetails
,
413 SelectionType
* aAllTypes
,
414 const nsCharClipDisplayItem::ClipEdges
& aClipEdges
,
415 DrawPathCallbacks
* aCallbacks
);
416 // helper: paint text decorations for text selected by aSelectionType
417 void PaintTextSelectionDecorations(gfxContext
* aCtx
,
418 const gfxPoint
& aFramePt
,
419 const gfxPoint
& aTextBaselinePt
,
420 const gfxRect
& aDirtyRect
,
421 PropertyProvider
& aProvider
,
422 uint32_t aContentOffset
,
423 uint32_t aContentLength
,
424 nsTextPaintStyle
& aTextPaintStyle
,
425 SelectionDetails
* aDetails
,
426 SelectionType aSelectionType
,
427 DrawPathCallbacks
* aCallbacks
);
429 virtual nscolor
GetCaretColorAt(int32_t aOffset
) MOZ_OVERRIDE
;
431 int16_t GetSelectionStatus(int16_t* aSelectionFlags
);
433 int32_t GetContentOffset() const { return mContentOffset
; }
434 int32_t GetContentLength() const
436 NS_ASSERTION(GetContentEnd() - mContentOffset
>= 0, "negative length");
437 return GetContentEnd() - mContentOffset
;
439 int32_t GetContentEnd() const;
440 // This returns the length the frame thinks it *should* have after it was
441 // last reflowed (0 if it hasn't been reflowed yet). This should be used only
442 // when setting up the text offsets for a new continuation frame.
443 int32_t GetContentLengthHint() const { return mContentLengthHint
; }
445 // Compute the length of the content mapped by this frame
446 // and all its in-flow siblings. Basically this means starting at mContentOffset
447 // and going to the end of the text node or the next bidi continuation
449 int32_t GetInFlowContentLength();
452 * Acquires the text run for this content, if necessary.
453 * @param aWhichTextRun indicates whether to get an inflated or non-inflated
455 * @param aReferenceContext the rendering context to use as a reference for
456 * creating the textrun, if available (if not, we'll create one which will
458 * @param aLineContainer the block ancestor for this frame, or nullptr if
460 * @param aFlowEndInTextRun if non-null, this returns the textrun offset of
461 * end of the text associated with this frame and its in-flow siblings
462 * @return a gfxSkipCharsIterator set up to map DOM offsets for this frame
463 * to offsets into the textrun; its initial offset is set to this frame's
466 gfxSkipCharsIterator
EnsureTextRun(TextRunType aWhichTextRun
,
467 gfxContext
* aReferenceContext
= nullptr,
468 nsIFrame
* aLineContainer
= nullptr,
469 const nsLineList::iterator
* aLine
= nullptr,
470 uint32_t* aFlowEndInTextRun
= nullptr);
472 gfxTextRun
* GetTextRun(TextRunType aWhichTextRun
) {
473 if (aWhichTextRun
== eInflated
|| !HasFontSizeInflation())
475 return GetUninflatedTextRun();
477 gfxTextRun
* GetUninflatedTextRun();
478 void SetTextRun(gfxTextRun
* aTextRun
, TextRunType aWhichTextRun
,
480 bool IsInTextRunUserData() const {
481 return GetStateBits() &
482 (TEXT_IN_TEXTRUN_USER_DATA
| TEXT_IN_UNINFLATED_TEXTRUN_USER_DATA
);
485 * Notify the frame that it should drop its pointer to a text run.
486 * Returns whether the text run was removed (i.e., whether it was
487 * associated with this frame, either as its inflated or non-inflated
490 bool RemoveTextRun(gfxTextRun
* aTextRun
);
492 * Clears out |mTextRun| (or the uninflated text run, when aInflated
493 * is nsTextFrame::eNotInflated and there is inflation) from all frames that hold a
494 * reference to it, starting at |aStartContinuation|, or if it's
495 * nullptr, starting at |this|. Deletes the text run if all references
496 * were cleared and it's not cached.
498 void ClearTextRun(nsTextFrame
* aStartContinuation
,
499 TextRunType aWhichTextRun
);
501 void ClearTextRuns() {
502 ClearTextRun(nullptr, nsTextFrame::eInflated
);
503 if (HasFontSizeInflation()) {
504 ClearTextRun(nullptr, nsTextFrame::eNotInflated
);
509 * Wipe out references to textrun(s) without deleting the textruns.
511 void DisconnectTextRuns();
513 // Get the DOM content range mapped by this frame after excluding
514 // whitespace subject to start-of-line and end-of-line trimming.
515 // The textrun must have been created before calling this.
516 struct TrimmedOffsets
{
519 int32_t GetEnd() const { return mStart
+ mLength
; }
521 TrimmedOffsets
GetTrimmedOffsets(const nsTextFragment
* aFrag
,
522 bool aTrimAfter
, bool aPostReflow
= true);
524 // Similar to Reflow(), but for use from nsLineLayout
525 void ReflowText(nsLineLayout
& aLineLayout
, nscoord aAvailableWidth
,
526 nsRenderingContext
* aRenderingContext
,
527 nsHTMLReflowMetrics
& aMetrics
, nsReflowStatus
& aStatus
);
529 bool IsFloatingFirstLetterChild() const;
531 virtual bool UpdateOverflow() MOZ_OVERRIDE
;
533 void AssignJustificationGaps(const mozilla::JustificationAssignment
& aAssign
);
534 mozilla::JustificationAssignment
GetJustificationAssignment() const;
537 virtual ~nsTextFrame();
539 nsIFrame
* mNextContinuation
;
540 // The key invariant here is that mContentOffset never decreases along
541 // a next-continuation chain. And of course mContentOffset is always <= the
542 // the text node's content length, and the mContentOffset for the first frame
543 // is always 0. Furthermore the text mapped by a frame is determined by
544 // GetContentOffset() and GetContentLength()/GetContentEnd(), which get
545 // the length from the difference between this frame's offset and the next
546 // frame's offset, or the text length if there is no next frame. This means
547 // the frames always map the text node without overlapping or leaving any gaps.
548 int32_t mContentOffset
;
549 // This does *not* indicate the length of text currently mapped by the frame;
550 // instead it's a hint saying that this frame *wants* to map this much text
551 // so if we create a new continuation, this is where that continuation should
553 int32_t mContentLengthHint
;
555 gfxTextRun
* mTextRun
;
558 * Return true if the frame is part of a Selection.
559 * Helper method to implement the public IsSelected() API.
561 virtual bool IsFrameSelected() const MOZ_OVERRIDE
;
563 // The caller of this method must call DestroySelectionDetails() on the
564 // return value, if that return value is not null. Calling
565 // DestroySelectionDetails() on a null value is still OK, just not necessary.
566 SelectionDetails
* GetSelectionDetails();
568 void UnionAdditionalOverflow(nsPresContext
* aPresContext
,
570 PropertyProvider
& aProvider
,
571 nsRect
* aVisualOverflowRect
,
572 bool aIncludeTextDecorations
);
574 void PaintOneShadow(uint32_t aOffset
,
576 nsCSSShadowItem
* aShadowDetails
,
577 PropertyProvider
* aProvider
,
578 const nsRect
& aDirtyRect
,
579 const gfxPoint
& aFramePt
,
580 const gfxPoint
& aTextBaselinePt
,
582 const nscolor
& aForegroundColor
,
583 const nsCharClipDisplayItem::ClipEdges
& aClipEdges
,
584 nscoord aLeftSideOffset
,
585 gfxRect
& aBoundingBox
);
587 struct LineDecoration
{
590 // This is represents the offset from our baseline to mFrame's baseline;
591 // positive offsets are *above* the baseline and negative offsets below
592 nscoord mBaselineOffset
;
597 LineDecoration(nsIFrame
*const aFrame
,
599 const nscolor aColor
,
600 const uint8_t aStyle
)
602 mBaselineOffset(aOff
),
607 LineDecoration(const LineDecoration
& aOther
)
608 : mFrame(aOther
.mFrame
),
609 mBaselineOffset(aOther
.mBaselineOffset
),
610 mColor(aOther
.mColor
),
611 mStyle(aOther
.mStyle
)
614 bool operator==(const LineDecoration
& aOther
) const {
615 return mFrame
== aOther
.mFrame
&&
616 mStyle
== aOther
.mStyle
&&
617 mColor
== aOther
.mColor
&&
618 mBaselineOffset
== aOther
.mBaselineOffset
;
621 bool operator!=(const LineDecoration
& aOther
) const {
622 return !(*this == aOther
);
625 struct TextDecorations
{
626 nsAutoTArray
<LineDecoration
, 1> mOverlines
, mUnderlines
, mStrikes
;
628 TextDecorations() { }
630 bool HasDecorationLines() const {
631 return HasUnderline() || HasOverline() || HasStrikeout();
633 bool HasUnderline() const {
634 return !mUnderlines
.IsEmpty();
636 bool HasOverline() const {
637 return !mOverlines
.IsEmpty();
639 bool HasStrikeout() const {
640 return !mStrikes
.IsEmpty();
642 bool operator==(const TextDecorations
& aOther
) const {
643 return mOverlines
== aOther
.mOverlines
&&
644 mUnderlines
== aOther
.mUnderlines
&&
645 mStrikes
== aOther
.mStrikes
;
648 bool operator!=(const TextDecorations
& aOther
) const {
649 return !(*this == aOther
);
653 enum TextDecorationColorResolution
{
657 void GetTextDecorations(nsPresContext
* aPresContext
,
658 TextDecorationColorResolution aColorResolution
,
659 TextDecorations
& aDecorations
);
661 void DrawTextRun(gfxContext
* const aCtx
,
662 const gfxPoint
& aTextBaselinePt
,
665 PropertyProvider
& aProvider
,
667 gfxFloat
& aAdvanceWidth
,
668 bool aDrawSoftHyphen
,
669 gfxTextContextPaint
* aContextPaint
,
670 DrawPathCallbacks
* aCallbacks
);
672 void DrawTextRunAndDecorations(gfxContext
* const aCtx
,
673 const gfxRect
& aDirtyRect
,
674 const gfxPoint
& aFramePt
,
675 const gfxPoint
& aTextBaselinePt
,
678 PropertyProvider
& aProvider
,
679 const nsTextPaintStyle
& aTextStyle
,
681 const nsCharClipDisplayItem::ClipEdges
& aClipEdges
,
682 gfxFloat
& aAdvanceWidth
,
683 bool aDrawSoftHyphen
,
684 const TextDecorations
& aDecorations
,
685 const nscolor
* const aDecorationOverrideColor
,
686 gfxTextContextPaint
* aContextPaint
,
687 DrawPathCallbacks
* aCallbacks
);
689 void DrawText(gfxContext
* const aCtx
,
690 const gfxRect
& aDirtyRect
,
691 const gfxPoint
& aFramePt
,
692 const gfxPoint
& aTextBaselinePt
,
695 PropertyProvider
& aProvider
,
696 const nsTextPaintStyle
& aTextStyle
,
698 const nsCharClipDisplayItem::ClipEdges
& aClipEdges
,
699 gfxFloat
& aAdvanceWidth
,
700 bool aDrawSoftHyphen
,
701 const nscolor
* const aDecorationOverrideColor
= nullptr,
702 gfxTextContextPaint
* aContextPaint
= nullptr,
703 DrawPathCallbacks
* aCallbacks
= nullptr);
705 // Set non empty rect to aRect, it should be overflow rect or frame rect.
706 // If the result rect is larger than the given rect, this returns true.
707 bool CombineSelectionUnderlineRect(nsPresContext
* aPresContext
,
710 ContentOffsets
GetCharacterOffsetAtFramePointInternal(nsPoint aPoint
,
711 bool aForInsertionPoint
);
713 void ClearFrameOffsetCache();
715 virtual bool HasAnyNoncollapsedCharacters() MOZ_OVERRIDE
;
717 void ClearMetrics(nsHTMLReflowMetrics
& aMetrics
);
719 NS_DECLARE_FRAME_PROPERTY(JustificationAssignment
, nullptr)