2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-09-24 06:19:14 +04:00
|
|
|
|
|
|
|
#ifndef nsTextFrame_h__
|
|
|
|
#define nsTextFrame_h__
|
|
|
|
|
2013-05-29 23:37:49 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2015-08-19 10:37:39 +03:00
|
|
|
#include "mozilla/EventForwards.h"
|
2015-01-27 19:32:24 +03:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2017-01-20 12:39:57 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2018-03-19 22:18:07 +03:00
|
|
|
#include "mozilla/dom/CharacterData.h"
|
2007-09-24 06:19:14 +04:00
|
|
|
#include "nsFrame.h"
|
2017-05-10 17:48:50 +03:00
|
|
|
#include "nsFrameSelection.h"
|
2009-08-31 22:25:35 +04:00
|
|
|
#include "nsSplittableFrame.h"
|
2007-09-24 06:19:14 +04:00
|
|
|
#include "nsLineBox.h"
|
|
|
|
#include "gfxSkipChars.h"
|
2014-09-16 13:58:12 +04:00
|
|
|
#include "gfxTextRun.h"
|
2011-06-22 22:11:48 +04:00
|
|
|
#include "nsDisplayList.h"
|
2018-11-26 20:59:50 +03:00
|
|
|
#include "nsFontMetrics.h"
|
2014-11-10 04:25:17 +03:00
|
|
|
#include "JustificationUtils.h"
|
2015-05-04 00:52:53 +03:00
|
|
|
#include "RubyUtils.h"
|
2007-09-24 06:19:14 +04:00
|
|
|
|
2015-01-08 10:28:09 +03:00
|
|
|
// Undo the windows.h damage
|
|
|
|
#if defined(XP_WIN) && defined(DrawText)
|
|
|
|
# undef DrawText
|
|
|
|
#endif
|
|
|
|
|
2007-09-24 06:19:14 +04:00
|
|
|
class nsTextPaintStyle;
|
|
|
|
class PropertyProvider;
|
2014-08-06 09:19:25 +04:00
|
|
|
struct SelectionDetails;
|
|
|
|
class nsTextFragment;
|
2007-09-24 06:19:14 +04:00
|
|
|
|
2012-08-29 09:39:01 +04:00
|
|
|
class nsDisplayTextGeometry;
|
|
|
|
class nsDisplayText;
|
|
|
|
|
2016-07-22 16:56:09 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class SVGContextPaint;
|
|
|
|
};
|
|
|
|
|
2017-01-26 15:41:39 +03:00
|
|
|
class nsTextFrame : public nsFrame {
|
2016-03-08 10:56:18 +03:00
|
|
|
typedef mozilla::LayoutDeviceRect LayoutDeviceRect;
|
2017-08-24 13:14:04 +03:00
|
|
|
typedef mozilla::SelectionTypeMask SelectionTypeMask;
|
2016-06-11 05:06:37 +03:00
|
|
|
typedef mozilla::SelectionType SelectionType;
|
2015-08-19 10:37:39 +03:00
|
|
|
typedef mozilla::TextRangeStyle TextRangeStyle;
|
2015-01-27 19:32:24 +03:00
|
|
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
2015-11-09 07:19:00 +03:00
|
|
|
typedef mozilla::gfx::Point Point;
|
2015-01-27 19:32:24 +03:00
|
|
|
typedef mozilla::gfx::Rect Rect;
|
2015-11-09 07:19:00 +03:00
|
|
|
typedef mozilla::gfx::Size Size;
|
2016-03-08 10:56:18 +03:00
|
|
|
typedef gfxTextRun::Range Range;
|
2015-01-27 19:32:24 +03:00
|
|
|
|
2007-09-24 06:19:14 +04:00
|
|
|
public:
|
2019-02-05 19:45:54 +03:00
|
|
|
explicit nsTextFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
|
|
|
|
ClassID aID = kClassID)
|
|
|
|
: nsFrame(aStyle, aPresContext, aID),
|
2017-05-26 13:11:11 +03:00
|
|
|
mNextContinuation(nullptr),
|
|
|
|
mContentOffset(0),
|
|
|
|
mContentLengthHint(0),
|
|
|
|
mAscent(0) {}
|
2017-04-30 18:30:08 +03:00
|
|
|
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsTextFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2008-01-04 20:09:35 +03:00
|
|
|
friend class nsContinuingTextFrame;
|
2012-08-29 09:39:01 +04:00
|
|
|
friend class nsDisplayTextGeometry;
|
|
|
|
friend class nsDisplayText;
|
2008-01-04 20:09:35 +03:00
|
|
|
|
2012-08-05 05:01:19 +04:00
|
|
|
// nsQueryFrame
|
|
|
|
NS_DECL_QUERYFRAME
|
|
|
|
|
2007-09-24 06:19:14 +04:00
|
|
|
// nsIFrame
|
2017-01-26 15:41:39 +03:00
|
|
|
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
2018-11-29 02:17:25 +03:00
|
|
|
const nsDisplayListSet& aLists) final;
|
2017-01-26 15:41:39 +03:00
|
|
|
|
|
|
|
void Init(nsIContent* aContent, nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) override;
|
|
|
|
|
2017-11-07 03:20:33 +03:00
|
|
|
void DestroyFrom(nsIFrame* aDestructRoot,
|
|
|
|
PostDestroyData& aPostDestroyData) override;
|
2017-01-26 15:41:39 +03:00
|
|
|
|
2019-03-13 21:38:09 +03:00
|
|
|
mozilla::Maybe<Cursor> GetCursor(const nsPoint&) final;
|
2017-01-26 15:41:39 +03:00
|
|
|
|
2018-02-27 17:30:27 +03:00
|
|
|
nsresult CharacterDataChanged(const CharacterDataChangeInfo&) final;
|
2017-01-26 15:41:39 +03:00
|
|
|
|
2017-01-26 16:23:04 +03:00
|
|
|
nsTextFrame* GetPrevContinuation() const override { return nullptr; }
|
2018-02-06 09:46:57 +03:00
|
|
|
nsTextFrame* GetNextContinuation() const final { return mNextContinuation; }
|
|
|
|
void SetNextContinuation(nsIFrame* aNextContinuation) final {
|
2017-04-30 18:30:08 +03:00
|
|
|
NS_ASSERTION(!aNextContinuation || Type() == aNextContinuation->Type(),
|
2017-01-26 15:41:39 +03:00
|
|
|
"setting a next continuation with incorrect type!");
|
|
|
|
NS_ASSERTION(
|
|
|
|
!nsSplittableFrame::IsInNextContinuationChain(aNextContinuation, this),
|
|
|
|
"creating a loop in continuation chain!");
|
2017-01-26 16:23:04 +03:00
|
|
|
mNextContinuation = static_cast<nsTextFrame*>(aNextContinuation);
|
2007-09-24 06:19:14 +04:00
|
|
|
if (aNextContinuation)
|
|
|
|
aNextContinuation->RemoveStateBits(NS_FRAME_IS_FLUID_CONTINUATION);
|
2017-03-09 15:18:26 +03:00
|
|
|
// Setting a non-fluid continuation might affect our flow length (they're
|
|
|
|
// quite rare so we assume it always does) so we delete our cached value:
|
2017-08-08 01:13:30 +03:00
|
|
|
if (GetContent()->HasFlag(NS_HAS_FLOWLENGTH_PROPERTY)) {
|
|
|
|
GetContent()->DeleteProperty(nsGkAtoms::flowlength);
|
|
|
|
GetContent()->UnsetFlags(NS_HAS_FLOWLENGTH_PROPERTY);
|
|
|
|
}
|
2007-09-24 06:19:14 +04:00
|
|
|
}
|
2018-11-29 02:17:25 +03:00
|
|
|
nsIFrame* GetNextInFlowVirtual() const final { return GetNextInFlow(); }
|
2017-01-26 16:23:04 +03:00
|
|
|
nsTextFrame* GetNextInFlow() const {
|
2017-01-26 15:41:39 +03:00
|
|
|
return mNextContinuation && (mNextContinuation->GetStateBits() &
|
|
|
|
NS_FRAME_IS_FLUID_CONTINUATION)
|
|
|
|
? mNextContinuation
|
|
|
|
: nullptr;
|
2007-09-24 06:19:14 +04:00
|
|
|
}
|
2018-02-06 09:46:57 +03:00
|
|
|
void SetNextInFlow(nsIFrame* aNextInFlow) final {
|
2017-04-30 18:30:08 +03:00
|
|
|
NS_ASSERTION(!aNextInFlow || Type() == aNextInFlow->Type(),
|
2017-01-26 15:41:39 +03:00
|
|
|
"setting a next in flow with incorrect type!");
|
|
|
|
NS_ASSERTION(
|
|
|
|
!nsSplittableFrame::IsInNextContinuationChain(aNextInFlow, this),
|
|
|
|
"creating a loop in continuation chain!");
|
2017-01-26 16:23:04 +03:00
|
|
|
mNextContinuation = static_cast<nsTextFrame*>(aNextInFlow);
|
2017-03-09 15:18:26 +03:00
|
|
|
if (mNextContinuation &&
|
|
|
|
!mNextContinuation->HasAnyStateBits(NS_FRAME_IS_FLUID_CONTINUATION)) {
|
|
|
|
// Changing from non-fluid to fluid continuation might affect our flow
|
|
|
|
// length, so we delete our cached value:
|
2017-08-08 01:13:30 +03:00
|
|
|
if (GetContent()->HasFlag(NS_HAS_FLOWLENGTH_PROPERTY)) {
|
|
|
|
GetContent()->DeleteProperty(nsGkAtoms::flowlength);
|
|
|
|
GetContent()->UnsetFlags(NS_HAS_FLOWLENGTH_PROPERTY);
|
|
|
|
}
|
2017-03-09 15:18:26 +03:00
|
|
|
}
|
|
|
|
if (aNextInFlow) {
|
2007-09-24 06:19:14 +04:00
|
|
|
aNextInFlow->AddStateBits(NS_FRAME_IS_FLUID_CONTINUATION);
|
2017-03-09 15:18:26 +03:00
|
|
|
}
|
2007-09-24 06:19:14 +04:00
|
|
|
}
|
2018-02-06 09:46:57 +03:00
|
|
|
nsTextFrame* LastInFlow() const final;
|
|
|
|
nsTextFrame* LastContinuation() const final;
|
2017-01-26 15:41:39 +03:00
|
|
|
|
2018-02-06 09:46:57 +03:00
|
|
|
bool IsFrameOfType(uint32_t aFlags) const final {
|
2007-09-24 06:19:14 +04:00
|
|
|
// Set the frame state bit for text frames to mark them as replaced.
|
|
|
|
// XXX kipp: temporary
|
2017-01-26 15:41:39 +03:00
|
|
|
return nsFrame::IsFrameOfType(
|
|
|
|
aFlags & ~(nsIFrame::eReplaced | nsIFrame::eLineParticipant));
|
2007-09-24 06:19:14 +04:00
|
|
|
}
|
|
|
|
|
2015-05-04 00:52:53 +03:00
|
|
|
bool ShouldSuppressLineBreak() const {
|
|
|
|
// If the parent frame of the text frame is ruby content box, it must
|
|
|
|
// suppress line break inside. This check is necessary, because when
|
|
|
|
// a whitespace is only contained by pseudo ruby frames, its style
|
|
|
|
// context won't have SuppressLineBreak bit set.
|
2017-04-30 18:30:08 +03:00
|
|
|
if (mozilla::RubyUtils::IsRubyContentBox(GetParent()->Type())) {
|
2015-05-04 00:52:53 +03:00
|
|
|
return true;
|
|
|
|
}
|
2018-03-22 21:20:41 +03:00
|
|
|
return Style()->ShouldSuppressLineBreak();
|
2015-05-04 00:52:53 +03:00
|
|
|
}
|
|
|
|
|
2018-11-29 02:17:25 +03:00
|
|
|
void InvalidateFrame(uint32_t aDisplayItemKey = 0,
|
|
|
|
bool aRebuildDisplayItems = true) final;
|
2017-01-26 15:41:39 +03:00
|
|
|
void InvalidateFrameWithRect(const nsRect& aRect,
|
2018-04-04 07:15:49 +03:00
|
|
|
uint32_t aDisplayItemKey = 0,
|
2018-11-29 02:17:25 +03:00
|
|
|
bool aRebuildDisplayItems = true) final;
|
2013-02-11 10:22:20 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2017-01-26 15:41:39 +03:00
|
|
|
void List(FILE* out = stderr, const char* aPrefix = "",
|
2018-11-29 02:17:25 +03:00
|
|
|
uint32_t aFlags = 0) const final;
|
|
|
|
nsresult GetFrameName(nsAString& aResult) const final;
|
2014-01-06 03:31:14 +04:00
|
|
|
void ToCString(nsCString& aBuf, int32_t* aTotalContentLength) const;
|
|
|
|
#endif
|
|
|
|
|
2018-11-29 02:17:25 +03:00
|
|
|
ContentOffsets CalcContentOffsetsFromFramePoint(const nsPoint& aPoint) final;
|
2017-01-26 15:41:39 +03:00
|
|
|
ContentOffsets GetCharacterOffsetAtFramePoint(const nsPoint& aPoint);
|
2009-05-15 04:46:24 +04:00
|
|
|
|
2009-07-27 02:05:41 +04:00
|
|
|
/**
|
|
|
|
* This is called only on the primary text frame. It indicates that
|
|
|
|
* the selection state of the given character range has changed.
|
|
|
|
* Text in the range is unconditionally invalidated
|
2012-06-11 03:44:50 +04:00
|
|
|
* (Selection::Repaint depends on this).
|
2009-07-27 02:05:41 +04:00
|
|
|
* @param aSelected true if the selection has been added to the range,
|
|
|
|
* false otherwise
|
|
|
|
* @param aType the type of selection added or removed
|
|
|
|
*/
|
2017-01-26 15:41:39 +03:00
|
|
|
void SetSelectedRange(uint32_t aStart, uint32_t aEnd, bool aSelected,
|
2016-06-11 05:06:37 +03:00
|
|
|
SelectionType aSelectionType);
|
2009-07-27 02:05:41 +04:00
|
|
|
|
2017-01-26 15:41:39 +03:00
|
|
|
FrameSearchResult PeekOffsetNoAmount(bool aForward, int32_t* aOffset) final;
|
Bug 1375825 - part2: ContentEventHandler::ExpandToClusterBoundary() should check the return value of nsTextFrame::PeekOffsetCharacter() r=jfkthame
ContentEventHandler::ExpandToClusterBoundary() doesn't check the return value of nsTextFrame::PeekOffsetCharacter(). Therefore, it may set its result to reversed offset. (e.g., when aForward is true and offset is 6, the result may be 5. When aForward is false and offset is 5, the result may be 6.)
For avoiding that, ContentEventHandler::ExpandToClusterBoundary() should check the result and only when it returns nsIFrame::FOUND, it should compute the proper offset.
On the other hand, it's too bad for ContentEventHandler that nsTextFrame::PeekOffsetCharacter() to return nsIFrame::CONTINUE_UNSELECTABLE when the user-select style is "all" because IME doesn't expect such cases.
Therefore, this patch adds additional argument to nsIFrame::PeekOffsetCharacter(), aOptions which is a struct containing bool members. The reason why it's not a bit mask enum is, such struct doesn't cause simple mistake at checking the value and the code is shorter. When mIgnoreUserStyleAll of it is true, this patch makes nsTextFrame not return nsIFrame::CONTINUE_UNSELECTABLE.
MozReview-Commit-ID: ACNNBTP92YZ
--HG--
extra : rebase_source : bd85da902e7fb59135d15514cb20a5599a4a640b
2017-06-29 04:58:16 +03:00
|
|
|
FrameSearchResult PeekOffsetCharacter(
|
|
|
|
bool aForward, int32_t* aOffset,
|
|
|
|
PeekOffsetCharacterOptions aOptions = PeekOffsetCharacterOptions()) final;
|
2017-01-26 15:41:39 +03:00
|
|
|
FrameSearchResult PeekOffsetWord(bool aForward, bool aWordSelectEatSpace,
|
|
|
|
bool aIsKeyboardSelect, int32_t* aOffset,
|
2019-02-23 00:12:48 +03:00
|
|
|
PeekWordState* aState, bool aTrimSpaces)
|
|
|
|
final;
|
2017-01-26 15:41:39 +03:00
|
|
|
|
|
|
|
nsresult CheckVisibility(nsPresContext* aContext, int32_t aStartIndex,
|
|
|
|
int32_t aEndIndex, bool aRecurse, bool* aFinished,
|
2018-11-29 02:17:25 +03:00
|
|
|
bool* _retval) final;
|
2007-09-24 06:19:14 +04:00
|
|
|
|
2011-02-21 11:02:23 +03:00
|
|
|
// Flags for aSetLengthFlags
|
2017-01-26 15:41:39 +03:00
|
|
|
enum { ALLOW_FRAME_CREATION_AND_DESTRUCTION = 0x01 };
|
2011-02-21 11:02:23 +03:00
|
|
|
|
2007-09-24 06:19:14 +04:00
|
|
|
// Update offsets to account for new length. This may clear mTextRun.
|
2017-01-26 15:41:39 +03:00
|
|
|
void SetLength(int32_t aLength, nsLineLayout* aLineLayout,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aSetLengthFlags = 0);
|
2017-01-26 15:41:39 +03:00
|
|
|
|
2018-11-29 02:17:25 +03:00
|
|
|
nsresult GetOffsets(int32_t& start, int32_t& end) const final;
|
2017-01-26 15:41:39 +03:00
|
|
|
|
2018-11-29 02:17:25 +03:00
|
|
|
void AdjustOffsetsForBidi(int32_t start, int32_t end) final;
|
2017-01-26 15:41:39 +03:00
|
|
|
|
2018-11-29 02:17:25 +03:00
|
|
|
nsresult GetPointFromOffset(int32_t inOffset, nsPoint* outPoint) final;
|
2017-01-26 15:41:39 +03:00
|
|
|
nsresult GetCharacterRectsInRange(int32_t aInOffset, int32_t aLength,
|
2018-11-29 02:17:25 +03:00
|
|
|
nsTArray<nsRect>& aRects) final;
|
2017-01-26 15:41:39 +03:00
|
|
|
|
|
|
|
nsresult GetChildFrameContainingOffset(int32_t inContentOffset, bool inHint,
|
|
|
|
int32_t* outFrameContentOffset,
|
2018-11-29 02:17:25 +03:00
|
|
|
nsIFrame** outChildFrame) final;
|
2017-01-26 15:41:39 +03:00
|
|
|
|
2018-11-29 02:17:25 +03:00
|
|
|
bool IsEmpty() final;
|
|
|
|
bool IsSelfEmpty() final { return IsEmpty(); }
|
2018-02-06 09:46:57 +03:00
|
|
|
nscoord GetLogicalBaseline(mozilla::WritingMode aWritingMode) const final;
|
2017-01-26 15:41:39 +03:00
|
|
|
|
2018-11-29 02:17:25 +03:00
|
|
|
bool HasSignificantTerminalNewline() const final;
|
2007-11-08 07:07:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if this text frame is logically adjacent to the end of the
|
|
|
|
* line.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsAtEndOfLine() const;
|
2017-01-26 15:41:39 +03:00
|
|
|
|
2008-02-14 12:08:33 +03:00
|
|
|
/**
|
|
|
|
* Call this only after reflow the frame. Returns true if non-collapsed
|
|
|
|
* characters are present.
|
|
|
|
*/
|
2017-01-26 15:41:39 +03:00
|
|
|
bool HasNoncollapsedCharacters() const {
|
2008-02-14 12:08:33 +03:00
|
|
|
return (GetStateBits() & TEXT_HAS_NONCOLLAPSED_CHARACTERS) != 0;
|
|
|
|
}
|
2017-01-26 15:41:39 +03:00
|
|
|
|
2007-09-24 06:19:14 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2018-11-29 02:17:25 +03:00
|
|
|
mozilla::a11y::AccType AccessibleType() final;
|
2007-09-24 06:19:14 +04:00
|
|
|
#endif
|
2011-11-24 06:48:23 +04:00
|
|
|
|
|
|
|
float GetFontSizeInflation() const;
|
2012-07-26 01:25:26 +04:00
|
|
|
bool IsCurrentFontInflation(float aInflation) const;
|
2017-01-26 15:41:39 +03:00
|
|
|
bool HasFontSizeInflation() const {
|
2011-11-24 06:48:23 +04:00
|
|
|
return (GetStateBits() & TEXT_HAS_FONT_INFLATION) != 0;
|
|
|
|
}
|
|
|
|
void SetFontSizeInflation(float aInflation);
|
|
|
|
|
2018-11-29 02:17:25 +03:00
|
|
|
void MarkIntrinsicISizesDirty() final;
|
|
|
|
nscoord GetMinISize(gfxContext* aRenderingContext) final;
|
|
|
|
nscoord GetPrefISize(gfxContext* aRenderingContext) final;
|
2017-06-09 22:14:53 +03:00
|
|
|
void AddInlineMinISize(gfxContext* aRenderingContext,
|
2017-01-26 15:41:39 +03:00
|
|
|
InlineMinISizeData* aData) override;
|
2017-06-09 22:14:53 +03:00
|
|
|
void AddInlinePrefISize(gfxContext* aRenderingContext,
|
2017-01-26 15:41:39 +03:00
|
|
|
InlinePrefISizeData* aData) override;
|
2017-06-09 22:14:53 +03:00
|
|
|
mozilla::LogicalSize ComputeSize(
|
|
|
|
gfxContext* aRenderingContext, mozilla::WritingMode aWritingMode,
|
2017-01-26 15:41:39 +03:00
|
|
|
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
|
|
|
|
const mozilla::LogicalSize& aMargin, const mozilla::LogicalSize& aBorder,
|
|
|
|
const mozilla::LogicalSize& aPadding, ComputeSizeFlags aFlags) final;
|
2018-11-29 02:17:25 +03:00
|
|
|
nsRect ComputeTightBounds(DrawTarget* aDrawTarget) const final;
|
2017-06-09 22:14:53 +03:00
|
|
|
nsresult GetPrefWidthTightBounds(gfxContext* aContext, nscoord* aX,
|
2018-11-29 02:17:25 +03:00
|
|
|
nscoord* aXMost) final;
|
2017-01-26 15:41:39 +03:00
|
|
|
void Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics,
|
|
|
|
const ReflowInput& aReflowInput, nsReflowStatus& aStatus) final;
|
2018-11-29 02:17:25 +03:00
|
|
|
bool CanContinueTextRun() const final;
|
2007-12-01 12:24:24 +03:00
|
|
|
// Method that is called for a text frame that is logically
|
|
|
|
// adjacent to the end of the line (i.e. followed only by empty text frames,
|
|
|
|
// placeholders or inlines containing such).
|
2017-01-26 15:41:39 +03:00
|
|
|
struct TrimOutput {
|
2007-12-01 12:24:24 +03:00
|
|
|
// true if we trimmed some space or changed metrics in some other way.
|
2010-10-07 08:25:45 +04:00
|
|
|
// In this case, we should call RecomputeOverflow on this frame.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mChanged;
|
2007-12-01 12:24:24 +03:00
|
|
|
// an amount to *subtract* from the frame's width (zero if !mChanged)
|
2017-01-26 15:41:39 +03:00
|
|
|
nscoord mDeltaWidth;
|
2007-12-01 12:24:24 +03:00
|
|
|
};
|
2015-12-16 00:56:41 +03:00
|
|
|
TrimOutput TrimTrailingWhiteSpace(DrawTarget* aDrawTarget);
|
2017-01-26 15:41:39 +03:00
|
|
|
RenderedText GetRenderedText(
|
|
|
|
uint32_t aStartOffset = 0, uint32_t aEndOffset = UINT32_MAX,
|
|
|
|
TextOffsetType aOffsetType = TextOffsetType::OFFSETS_IN_CONTENT_TEXT,
|
|
|
|
TrailingWhitespace aTrimTrailingWhitespace =
|
2018-11-29 02:17:25 +03:00
|
|
|
TrailingWhitespace::TRIM_TRAILING_WHITESPACE) final;
|
2007-09-24 06:19:14 +04:00
|
|
|
|
2015-03-07 23:27:36 +03:00
|
|
|
nsOverflowAreas RecomputeOverflow(nsIFrame* aBlockFrame);
|
2007-09-24 06:19:14 +04:00
|
|
|
|
2017-01-26 15:41:39 +03:00
|
|
|
enum TextRunType {
|
2012-01-25 05:21:29 +04:00
|
|
|
// Anything in reflow (but not intrinsic width calculation) or
|
|
|
|
// painting should use the inflated text run (i.e., with font size
|
|
|
|
// inflation applied).
|
|
|
|
eInflated,
|
|
|
|
// Intrinsic width calculation should use the non-inflated text run.
|
|
|
|
// When there is font size inflation, it will be different.
|
|
|
|
eNotInflated
|
|
|
|
};
|
|
|
|
|
2017-06-09 22:14:53 +03:00
|
|
|
void AddInlineMinISizeForFlow(gfxContext* aRenderingContext,
|
2017-01-26 15:41:39 +03:00
|
|
|
nsIFrame::InlineMinISizeData* aData,
|
2012-03-27 09:37:16 +04:00
|
|
|
TextRunType aTextRunType);
|
2017-06-09 22:14:53 +03:00
|
|
|
void AddInlinePrefISizeForFlow(gfxContext* aRenderingContext,
|
2017-01-26 15:41:39 +03:00
|
|
|
InlinePrefISizeData* aData,
|
2012-03-27 09:37:16 +04:00
|
|
|
TextRunType aTextRunType);
|
2007-09-24 06:19:14 +04:00
|
|
|
|
2011-06-22 22:11:48 +04:00
|
|
|
/**
|
|
|
|
* Calculate the horizontal bounds of the grapheme clusters that fit entirely
|
2015-04-29 10:18:53 +03:00
|
|
|
* inside the given left[top]/right[bottom] edges (which are positive lengths
|
|
|
|
* from the respective frame edge). If an input value is zero it is ignored
|
|
|
|
* and the result for that edge is zero. All out parameter values are
|
|
|
|
* undefined when the method returns false.
|
2011-06-22 22:11:48 +04:00
|
|
|
* @return true if at least one whole grapheme cluster fit between the edges
|
|
|
|
*/
|
2017-01-26 15:41:39 +03:00
|
|
|
bool MeasureCharClippedText(nscoord aVisIStartEdge, nscoord aVisIEndEdge,
|
2015-04-29 10:18:53 +03:00
|
|
|
nscoord* aSnappedStartEdge,
|
|
|
|
nscoord* aSnappedEndEdge);
|
2011-06-22 22:11:48 +04:00
|
|
|
/**
|
|
|
|
* Same as above; this method also the returns the corresponding text run
|
|
|
|
* offset and number of characters that fit. All out parameter values are
|
|
|
|
* undefined when the method returns false.
|
|
|
|
* @return true if at least one whole grapheme cluster fit between the edges
|
|
|
|
*/
|
2011-11-24 06:48:23 +04:00
|
|
|
bool MeasureCharClippedText(PropertyProvider& aProvider,
|
2017-01-26 15:41:39 +03:00
|
|
|
nscoord aVisIStartEdge, nscoord aVisIEndEdge,
|
|
|
|
uint32_t* aStartOffset, uint32_t* aMaxLength,
|
2015-04-29 10:18:53 +03:00
|
|
|
nscoord* aSnappedStartEdge,
|
|
|
|
nscoord* aSnappedEndEdge);
|
2012-08-08 15:37:12 +04:00
|
|
|
|
2018-01-04 22:43:55 +03:00
|
|
|
/**
|
|
|
|
* Return true if this box has some text to display.
|
|
|
|
* It returns false if at least one of these conditions are met:
|
|
|
|
* a. the frame hasn't been reflowed yet
|
|
|
|
* b. GetContentLength() == 0
|
|
|
|
* c. it contains only non-significant white-space
|
|
|
|
*/
|
|
|
|
bool HasNonSuppressedText();
|
|
|
|
|
2012-08-08 15:37:12 +04:00
|
|
|
/**
|
|
|
|
* Object with various callbacks for PaintText() to invoke for different parts
|
|
|
|
* of the frame's text rendering, when we're generating paths rather than
|
|
|
|
* painting.
|
|
|
|
*
|
|
|
|
* Callbacks are invoked in the following order:
|
|
|
|
*
|
2015-02-18 01:01:54 +03:00
|
|
|
* NotifySelectionBackgroundNeedsFill?
|
2015-02-03 23:00:18 +03:00
|
|
|
* PaintDecorationLine*
|
2012-08-08 15:37:12 +04:00
|
|
|
* NotifyBeforeText
|
2015-02-18 01:01:54 +03:00
|
|
|
* NotifyGlyphPathEmitted*
|
2012-08-08 15:37:12 +04:00
|
|
|
* NotifyAfterText
|
2015-02-03 23:00:18 +03:00
|
|
|
* PaintDecorationLine*
|
2015-02-04 16:51:22 +03:00
|
|
|
* PaintSelectionDecorationLine*
|
2012-08-08 15:37:12 +04:00
|
|
|
*
|
|
|
|
* The color of each part of the frame's text rendering is passed as an
|
|
|
|
* argument to the NotifyBefore* callback for that part. The nscolor can take
|
|
|
|
* on one of the three selection special colors defined in LookAndFeel.h --
|
|
|
|
* NS_TRANSPARENT, NS_SAME_AS_FOREGROUND_COLOR and
|
|
|
|
* NS_40PERCENT_FOREGROUND_COLOR.
|
|
|
|
*/
|
2013-02-11 10:22:20 +04:00
|
|
|
struct DrawPathCallbacks : gfxTextRunDrawCallbacks {
|
|
|
|
/**
|
|
|
|
* @param aShouldPaintSVGGlyphs Whether SVG glyphs should be painted.
|
|
|
|
*/
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit DrawPathCallbacks(bool aShouldPaintSVGGlyphs = false)
|
2013-02-11 10:22:20 +04:00
|
|
|
: gfxTextRunDrawCallbacks(aShouldPaintSVGGlyphs) {}
|
|
|
|
|
2015-01-27 19:32:24 +03:00
|
|
|
/**
|
|
|
|
* Called to have the selection highlight drawn before the text is drawn
|
|
|
|
* over the top.
|
|
|
|
*/
|
|
|
|
virtual void NotifySelectionBackgroundNeedsFill(const Rect& aBackgroundRect,
|
|
|
|
nscolor aColor,
|
2017-01-26 15:41:39 +03:00
|
|
|
DrawTarget& aDrawTarget) {}
|
2015-01-27 19:32:24 +03:00
|
|
|
|
2015-02-03 23:00:18 +03:00
|
|
|
/**
|
|
|
|
* Called before (for under/over-line) or after (for line-through) the text
|
|
|
|
* is drawn to have a text decoration line drawn.
|
|
|
|
*/
|
2017-01-26 15:41:39 +03:00
|
|
|
virtual void PaintDecorationLine(Rect aPath, nscolor aColor) {}
|
2015-02-04 16:51:22 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called after selected text is drawn to have a decoration line drawn over
|
|
|
|
* the text. (All types of text decoration are drawn after the text when
|
|
|
|
* text is selected.)
|
|
|
|
*/
|
2017-01-26 15:41:39 +03:00
|
|
|
virtual void PaintSelectionDecorationLine(Rect aPath, nscolor aColor) {}
|
2015-02-03 23:00:18 +03:00
|
|
|
|
2012-08-08 15:37:12 +04:00
|
|
|
/**
|
|
|
|
* Called just before any paths have been emitted to the gfxContext
|
|
|
|
* for the glyphs of the frame's text.
|
|
|
|
*/
|
2017-01-26 15:41:39 +03:00
|
|
|
virtual void NotifyBeforeText(nscolor aColor) {}
|
2012-08-08 15:37:12 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called just after all the paths have been emitted to the gfxContext
|
|
|
|
* for the glyphs of the frame's text.
|
|
|
|
*/
|
2017-01-26 15:41:39 +03:00
|
|
|
virtual void NotifyAfterText() {}
|
2012-08-08 15:37:12 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called just before a path corresponding to a selection decoration line
|
|
|
|
* has been emitted to the gfxContext.
|
|
|
|
*/
|
2017-01-26 15:41:39 +03:00
|
|
|
virtual void NotifyBeforeSelectionDecorationLine(nscolor aColor) {}
|
2012-08-08 15:37:12 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called just after a path corresponding to a selection decoration line
|
|
|
|
* has been emitted to the gfxContext.
|
|
|
|
*/
|
2017-01-26 15:41:39 +03:00
|
|
|
virtual void NotifySelectionDecorationLinePathEmitted() {}
|
2012-08-08 15:37:12 +04:00
|
|
|
};
|
|
|
|
|
2016-03-08 10:56:18 +03:00
|
|
|
struct PaintTextParams {
|
|
|
|
gfxContext* context;
|
2017-10-24 11:59:09 +03:00
|
|
|
mozilla::gfx::Point framePt;
|
2016-03-08 10:56:18 +03:00
|
|
|
LayoutDeviceRect dirtyRect;
|
2016-07-22 16:56:09 +03:00
|
|
|
mozilla::SVGContextPaint* contextPaint = nullptr;
|
2016-03-08 10:56:18 +03:00
|
|
|
DrawPathCallbacks* callbacks = nullptr;
|
2017-01-26 15:41:39 +03:00
|
|
|
enum {
|
2019-02-04 22:10:18 +03:00
|
|
|
PaintText, // Normal text painting.
|
|
|
|
GenerateTextMask // To generate a mask from a text frame. Should
|
|
|
|
// only paint text itself with opaque color.
|
|
|
|
// Text shadow, text selection color and text
|
|
|
|
// decoration are all discarded in this state.
|
2016-07-19 15:48:19 +03:00
|
|
|
};
|
|
|
|
uint8_t state = PaintText;
|
2017-01-26 15:41:39 +03:00
|
|
|
explicit PaintTextParams(gfxContext* aContext) : context(aContext) {}
|
2016-07-19 15:48:19 +03:00
|
|
|
|
|
|
|
bool IsPaintText() const { return state == PaintText; }
|
|
|
|
bool IsGenerateTextMask() const { return state == GenerateTextMask; }
|
2016-03-08 10:56:18 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PaintTextSelectionParams : PaintTextParams {
|
2017-10-24 11:59:09 +03:00
|
|
|
mozilla::gfx::Point textBaselinePt;
|
2016-03-08 10:56:18 +03:00
|
|
|
PropertyProvider* provider = nullptr;
|
|
|
|
Range contentRange;
|
|
|
|
nsTextPaintStyle* textPaintStyle = nullptr;
|
|
|
|
explicit PaintTextSelectionParams(const PaintTextParams& aParams)
|
2017-01-26 15:41:39 +03:00
|
|
|
: PaintTextParams(aParams) {}
|
2016-03-08 10:56:18 +03:00
|
|
|
};
|
|
|
|
|
2016-03-08 10:56:18 +03:00
|
|
|
struct DrawTextRunParams {
|
|
|
|
gfxContext* context;
|
|
|
|
PropertyProvider* provider = nullptr;
|
|
|
|
gfxFloat* advanceWidth = nullptr;
|
2016-07-22 16:56:09 +03:00
|
|
|
mozilla::SVGContextPaint* contextPaint = nullptr;
|
2016-03-08 10:56:18 +03:00
|
|
|
DrawPathCallbacks* callbacks = nullptr;
|
|
|
|
nscolor textColor = NS_RGBA(0, 0, 0, 0);
|
2016-04-22 20:40:39 +03:00
|
|
|
nscolor textStrokeColor = NS_RGBA(0, 0, 0, 0);
|
|
|
|
float textStrokeWidth = 0.0f;
|
2016-03-08 10:56:18 +03:00
|
|
|
bool drawSoftHyphen = false;
|
|
|
|
explicit DrawTextRunParams(gfxContext* aContext) : context(aContext) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DrawTextParams : DrawTextRunParams {
|
2017-10-24 11:59:09 +03:00
|
|
|
mozilla::gfx::Point framePt;
|
2016-03-08 10:56:18 +03:00
|
|
|
LayoutDeviceRect dirtyRect;
|
2016-03-08 10:56:18 +03:00
|
|
|
const nsTextPaintStyle* textStyle = nullptr;
|
|
|
|
const nsCharClipDisplayItem::ClipEdges* clipEdges = nullptr;
|
|
|
|
const nscolor* decorationOverrideColor = nullptr;
|
|
|
|
explicit DrawTextParams(gfxContext* aContext)
|
2017-01-26 15:41:39 +03:00
|
|
|
: DrawTextRunParams(aContext) {}
|
2016-03-08 10:56:18 +03:00
|
|
|
};
|
|
|
|
|
2012-08-08 15:37:12 +04:00
|
|
|
// Primary frame paint method called from nsDisplayText. Can also be used
|
|
|
|
// to generate paths rather than paint the frame's text by passing a callback
|
|
|
|
// object. The private DrawText() is what applies the text to a graphics
|
|
|
|
// context.
|
2016-03-08 10:56:18 +03:00
|
|
|
void PaintText(const PaintTextParams& aParams,
|
2016-03-08 10:56:18 +03:00
|
|
|
const nsCharClipDisplayItem& aItem, float aOpacity = 1.0f);
|
2007-09-24 06:19:14 +04:00
|
|
|
// helper: paint text frame when we're impacted by at least one selection.
|
2011-06-30 04:56:50 +04:00
|
|
|
// Return false if the text was not painted and we should continue with
|
2007-09-24 06:19:14 +04:00
|
|
|
// the fast path.
|
2017-01-26 15:41:39 +03:00
|
|
|
bool PaintTextWithSelection(
|
|
|
|
const PaintTextSelectionParams& aParams,
|
|
|
|
const nsCharClipDisplayItem::ClipEdges& aClipEdges);
|
2007-09-24 06:19:14 +04:00
|
|
|
// helper: paint text with foreground and background colors determined
|
|
|
|
// by selection(s). Also computes a mask of all selection types applying to
|
2017-08-24 13:14:04 +03:00
|
|
|
// our text, returned in aAllSelectionTypeMask.
|
2011-06-30 04:56:50 +04:00
|
|
|
// Return false if the text was not painted and we should continue with
|
|
|
|
// the fast path.
|
2016-06-07 16:42:06 +03:00
|
|
|
bool PaintTextWithSelectionColors(
|
2017-01-26 15:41:39 +03:00
|
|
|
const PaintTextSelectionParams& aParams,
|
|
|
|
const mozilla::UniquePtr<SelectionDetails>& aDetails,
|
2017-08-24 13:14:04 +03:00
|
|
|
SelectionTypeMask* aAllSelectionTypeMask,
|
2017-01-26 15:41:39 +03:00
|
|
|
const nsCharClipDisplayItem::ClipEdges& aClipEdges);
|
2007-09-24 06:19:14 +04:00
|
|
|
// helper: paint text decorations for text selected by aSelectionType
|
2016-03-08 10:56:18 +03:00
|
|
|
void PaintTextSelectionDecorations(
|
|
|
|
const PaintTextSelectionParams& aParams,
|
2017-01-20 12:39:57 +03:00
|
|
|
const mozilla::UniquePtr<SelectionDetails>& aDetails,
|
2016-06-11 05:06:37 +03:00
|
|
|
SelectionType aSelectionType);
|
2007-09-24 06:19:14 +04:00
|
|
|
|
2015-11-28 03:56:33 +03:00
|
|
|
void DrawEmphasisMarks(gfxContext* aContext, mozilla::WritingMode aWM,
|
2017-10-24 11:59:09 +03:00
|
|
|
const mozilla::gfx::Point& aTextBaselinePt,
|
|
|
|
const mozilla::gfx::Point& aFramePt, Range aRange,
|
2015-12-04 08:28:34 +03:00
|
|
|
const nscolor* aDecorationOverrideColor,
|
2016-03-08 10:56:18 +03:00
|
|
|
PropertyProvider* aProvider);
|
2015-11-28 03:56:33 +03:00
|
|
|
|
2018-11-29 02:17:25 +03:00
|
|
|
nscolor GetCaretColorAt(int32_t aOffset) final;
|
2010-04-01 06:35:48 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int16_t GetSelectionStatus(int16_t* aSelectionFlags);
|
2007-09-24 06:19:14 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetContentOffset() const { return mContentOffset; }
|
|
|
|
int32_t GetContentLength() const {
|
2008-01-04 20:09:35 +03:00
|
|
|
NS_ASSERTION(GetContentEnd() - mContentOffset >= 0, "negative length");
|
|
|
|
return GetContentEnd() - mContentOffset;
|
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetContentEnd() const;
|
2007-09-24 06:19:14 +04:00
|
|
|
// This returns the length the frame thinks it *should* have after it was
|
|
|
|
// last reflowed (0 if it hasn't been reflowed yet). This should be used only
|
|
|
|
// when setting up the text offsets for a new continuation frame.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetContentLengthHint() const { return mContentLengthHint; }
|
2007-09-24 06:19:14 +04:00
|
|
|
|
|
|
|
// Compute the length of the content mapped by this frame
|
|
|
|
// and all its in-flow siblings. Basically this means starting at
|
|
|
|
// mContentOffset and going to the end of the text node or the next bidi
|
|
|
|
// continuation boundary.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetInFlowContentLength();
|
2007-09-24 06:19:14 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Acquires the text run for this content, if necessary.
|
2012-02-07 03:37:08 +04:00
|
|
|
* @param aWhichTextRun indicates whether to get an inflated or non-inflated
|
|
|
|
* text run
|
2015-12-16 00:56:41 +03:00
|
|
|
* @param aRefDrawTarget the DrawTarget to use as a reference for creating the
|
|
|
|
* textrun, if available (if not, we'll create one which will just be slower)
|
2012-07-30 18:20:58 +04:00
|
|
|
* @param aLineContainer the block ancestor for this frame, or nullptr if
|
2012-02-07 03:37:08 +04:00
|
|
|
* unknown
|
2007-09-24 06:19:14 +04:00
|
|
|
* @param aFlowEndInTextRun if non-null, this returns the textrun offset of
|
|
|
|
* end of the text associated with this frame and its in-flow siblings
|
|
|
|
* @return a gfxSkipCharsIterator set up to map DOM offsets for this frame
|
|
|
|
* to offsets into the textrun; its initial offset is set to this frame's
|
|
|
|
* content offset
|
|
|
|
*/
|
2017-01-26 15:41:39 +03:00
|
|
|
gfxSkipCharsIterator EnsureTextRun(
|
|
|
|
TextRunType aWhichTextRun, DrawTarget* aRefDrawTarget = nullptr,
|
|
|
|
nsIFrame* aLineContainer = nullptr,
|
|
|
|
const nsLineList::iterator* aLine = nullptr,
|
|
|
|
uint32_t* aFlowEndInTextRun = nullptr);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-01-26 15:41:39 +03:00
|
|
|
gfxTextRun* GetTextRun(TextRunType aWhichTextRun) {
|
2011-11-24 06:48:23 +04:00
|
|
|
if (aWhichTextRun == eInflated || !HasFontSizeInflation()) return mTextRun;
|
|
|
|
return GetUninflatedTextRun();
|
|
|
|
}
|
|
|
|
gfxTextRun* GetUninflatedTextRun();
|
2017-01-26 15:41:39 +03:00
|
|
|
void SetTextRun(gfxTextRun* aTextRun, TextRunType aWhichTextRun,
|
2011-11-24 06:48:23 +04:00
|
|
|
float aInflation);
|
2017-01-26 15:41:39 +03:00
|
|
|
bool IsInTextRunUserData() const {
|
2014-05-28 07:39:25 +04:00
|
|
|
return GetStateBits() &
|
2017-01-26 15:41:39 +03:00
|
|
|
(TEXT_IN_TEXTRUN_USER_DATA | TEXT_IN_UNINFLATED_TEXTRUN_USER_DATA);
|
2014-05-28 07:39:25 +04:00
|
|
|
}
|
2010-10-15 08:03:33 +04:00
|
|
|
/**
|
2011-11-24 06:48:23 +04:00
|
|
|
* Notify the frame that it should drop its pointer to a text run.
|
|
|
|
* Returns whether the text run was removed (i.e., whether it was
|
|
|
|
* associated with this frame, either as its inflated or non-inflated
|
|
|
|
* text run.
|
2010-10-15 08:03:33 +04:00
|
|
|
*/
|
2011-11-24 06:48:23 +04:00
|
|
|
bool RemoveTextRun(gfxTextRun* aTextRun);
|
|
|
|
/**
|
|
|
|
* Clears out |mTextRun| (or the uninflated text run, when aInflated
|
|
|
|
* is nsTextFrame::eNotInflated and there is inflation) from all frames that
|
|
|
|
* hold a reference to it, starting at |aStartContinuation|, or if it's
|
2012-07-30 18:20:58 +04:00
|
|
|
* nullptr, starting at |this|. Deletes the text run if all references
|
2011-11-24 06:48:23 +04:00
|
|
|
* were cleared and it's not cached.
|
|
|
|
*/
|
2017-01-26 15:41:39 +03:00
|
|
|
void ClearTextRun(nsTextFrame* aStartContinuation, TextRunType aWhichTextRun);
|
2011-11-24 06:48:23 +04:00
|
|
|
|
2017-01-26 15:41:39 +03:00
|
|
|
void ClearTextRuns() {
|
2012-07-30 18:20:58 +04:00
|
|
|
ClearTextRun(nullptr, nsTextFrame::eInflated);
|
2012-05-23 19:27:15 +04:00
|
|
|
if (HasFontSizeInflation()) {
|
2012-07-30 18:20:58 +04:00
|
|
|
ClearTextRun(nullptr, nsTextFrame::eNotInflated);
|
2012-05-23 19:27:15 +04:00
|
|
|
}
|
2011-11-24 06:48:23 +04:00
|
|
|
}
|
2007-09-24 06:19:14 +04:00
|
|
|
|
2014-05-28 07:39:25 +04:00
|
|
|
/**
|
|
|
|
* Wipe out references to textrun(s) without deleting the textruns.
|
|
|
|
*/
|
|
|
|
void DisconnectTextRuns();
|
|
|
|
|
2007-09-24 06:19:14 +04:00
|
|
|
// Get the DOM content range mapped by this frame after excluding
|
|
|
|
// whitespace subject to start-of-line and end-of-line trimming.
|
|
|
|
// The textrun must have been created before calling this.
|
2017-01-26 15:41:39 +03:00
|
|
|
struct TrimmedOffsets {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mStart;
|
|
|
|
int32_t mLength;
|
|
|
|
int32_t GetEnd() const { return mStart + mLength; }
|
2007-09-24 06:19:14 +04:00
|
|
|
};
|
2019-02-23 00:12:27 +03:00
|
|
|
enum class TrimmedOffsetFlags : uint8_t {
|
|
|
|
kDefaultTrimFlags = 0,
|
|
|
|
kNotPostReflow = 1 << 0,
|
2019-02-23 00:12:48 +03:00
|
|
|
kNoTrimAfter = 1 << 1,
|
|
|
|
kNoTrimBefore = 1 << 2
|
2019-02-23 00:12:27 +03:00
|
|
|
};
|
|
|
|
TrimmedOffsets GetTrimmedOffsets(const nsTextFragment* aFrag,
|
|
|
|
TrimmedOffsetFlags aFlags = TrimmedOffsetFlags::kDefaultTrimFlags) const;
|
2007-09-24 06:19:14 +04:00
|
|
|
|
2010-08-25 22:54:46 +04:00
|
|
|
// Similar to Reflow(), but for use from nsLineLayout
|
2017-01-26 15:41:39 +03:00
|
|
|
void ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
2015-12-16 00:56:41 +03:00
|
|
|
DrawTarget* aDrawTarget, ReflowOutput& aMetrics,
|
2017-01-26 15:41:39 +03:00
|
|
|
nsReflowStatus& aStatus);
|
2010-08-25 22:54:46 +04:00
|
|
|
|
2012-02-22 03:50:16 +04:00
|
|
|
bool IsFloatingFirstLetterChild() const;
|
|
|
|
|
2016-10-04 17:22:52 +03:00
|
|
|
bool IsInitialLetterChild() const;
|
|
|
|
|
2018-11-29 02:17:25 +03:00
|
|
|
bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) final;
|
2014-06-17 18:32:00 +04:00
|
|
|
|
2014-11-10 04:25:17 +03:00
|
|
|
void AssignJustificationGaps(const mozilla::JustificationAssignment& aAssign);
|
|
|
|
mozilla::JustificationAssignment GetJustificationAssignment() const;
|
|
|
|
|
2016-04-22 02:18:41 +03:00
|
|
|
uint32_t CountGraphemeClusters() const;
|
|
|
|
|
2018-11-29 02:17:25 +03:00
|
|
|
bool HasAnyNoncollapsedCharacters() final;
|
2018-05-24 16:44:09 +03:00
|
|
|
|
2018-10-06 20:31:51 +03:00
|
|
|
/**
|
|
|
|
* Call this after you have manually changed the text node contents without
|
|
|
|
* notifying that change. This behaves as if all the text contents changed.
|
|
|
|
* (You should only use this for native anonymous content.)
|
|
|
|
*/
|
|
|
|
void NotifyNativeAnonymousTextnodeChange(uint32_t aOldLength);
|
|
|
|
|
2018-11-26 20:59:50 +03:00
|
|
|
void SetInflatedFontMetrics(nsFontMetrics* aMetrics) {
|
|
|
|
mFontMetrics = aMetrics;
|
|
|
|
}
|
|
|
|
nsFontMetrics* InflatedFontMetrics() const { return mFontMetrics; }
|
|
|
|
|
2007-09-24 06:19:14 +04:00
|
|
|
protected:
|
|
|
|
virtual ~nsTextFrame();
|
2009-03-08 22:01:02 +03:00
|
|
|
|
2018-11-26 20:59:50 +03:00
|
|
|
RefPtr<nsFontMetrics> mFontMetrics;
|
2016-08-19 15:14:22 +03:00
|
|
|
RefPtr<gfxTextRun> mTextRun;
|
2017-01-26 16:23:04 +03:00
|
|
|
nsTextFrame* mNextContinuation;
|
2007-09-24 06:19:14 +04:00
|
|
|
// The key invariant here is that mContentOffset never decreases along
|
|
|
|
// a next-continuation chain. And of course mContentOffset is always <= the
|
|
|
|
// the text node's content length, and the mContentOffset for the first frame
|
|
|
|
// is always 0. Furthermore the text mapped by a frame is determined by
|
|
|
|
// GetContentOffset() and GetContentLength()/GetContentEnd(), which get
|
|
|
|
// the length from the difference between this frame's offset and the next
|
|
|
|
// frame's offset, or the text length if there is no next frame. This means
|
|
|
|
// the frames always map the text node without overlapping or leaving any
|
|
|
|
// gaps.
|
2017-01-26 15:41:39 +03:00
|
|
|
int32_t mContentOffset;
|
2007-09-24 06:19:14 +04:00
|
|
|
// This does *not* indicate the length of text currently mapped by the frame;
|
|
|
|
// instead it's a hint saying that this frame *wants* to map this much text
|
|
|
|
// so if we create a new continuation, this is where that continuation should
|
|
|
|
// start.
|
2017-01-26 15:41:39 +03:00
|
|
|
int32_t mContentLengthHint;
|
|
|
|
nscoord mAscent;
|
2007-09-24 06:19:14 +04:00
|
|
|
|
2011-12-20 13:15:41 +04:00
|
|
|
/**
|
|
|
|
* Return true if the frame is part of a Selection.
|
|
|
|
* Helper method to implement the public IsSelected() API.
|
|
|
|
*/
|
2018-11-29 02:17:25 +03:00
|
|
|
bool IsFrameSelected() const final;
|
2011-12-20 13:15:41 +04:00
|
|
|
|
2017-01-20 12:39:57 +03:00
|
|
|
mozilla::UniquePtr<SelectionDetails> GetSelectionDetails();
|
2011-08-03 22:30:58 +04:00
|
|
|
|
|
|
|
void UnionAdditionalOverflow(nsPresContext* aPresContext, nsIFrame* aBlock,
|
|
|
|
PropertyProvider& aProvider,
|
|
|
|
nsRect* aVisualOverflowRect,
|
|
|
|
bool aIncludeTextDecorations);
|
2008-02-16 18:31:27 +03:00
|
|
|
|
2015-11-28 03:56:33 +03:00
|
|
|
// Update information of emphasis marks, and return the visial
|
|
|
|
// overflow rect of the emphasis marks.
|
|
|
|
nsRect UpdateTextEmphasis(mozilla::WritingMode aWM,
|
|
|
|
PropertyProvider& aProvider);
|
|
|
|
|
2016-03-08 10:56:18 +03:00
|
|
|
struct PaintShadowParams {
|
|
|
|
gfxTextRun::Range range;
|
|
|
|
LayoutDeviceRect dirtyRect;
|
2017-10-24 11:59:09 +03:00
|
|
|
mozilla::gfx::Point framePt;
|
|
|
|
mozilla::gfx::Point textBaselinePt;
|
2016-03-08 10:56:18 +03:00
|
|
|
gfxContext* context;
|
|
|
|
nscolor foregroundColor = NS_RGBA(0, 0, 0, 0);
|
|
|
|
const nsCharClipDisplayItem::ClipEdges* clipEdges = nullptr;
|
|
|
|
PropertyProvider* provider = nullptr;
|
|
|
|
nscoord leftSideOffset = 0;
|
|
|
|
explicit PaintShadowParams(const PaintTextParams& aParams)
|
|
|
|
: dirtyRect(aParams.dirtyRect),
|
|
|
|
framePt(aParams.framePt),
|
2017-01-26 15:41:39 +03:00
|
|
|
context(aParams.context) {}
|
2016-03-08 10:56:18 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
void PaintOneShadow(const PaintShadowParams& aParams,
|
2008-07-08 04:56:52 +04:00
|
|
|
nsCSSShadowItem* aShadowDetails, gfxRect& aBoundingBox,
|
2015-02-02 12:19:28 +03:00
|
|
|
uint32_t aBlurFlags);
|
2008-06-13 02:02:32 +04:00
|
|
|
|
2014-11-18 13:23:45 +03:00
|
|
|
void PaintShadows(nsCSSShadowArray* aShadow,
|
2016-03-08 10:56:18 +03:00
|
|
|
const PaintShadowParams& aParams);
|
2014-11-18 13:23:45 +03:00
|
|
|
|
2017-01-26 15:41:39 +03:00
|
|
|
struct LineDecoration {
|
2011-08-03 22:30:58 +04:00
|
|
|
nsIFrame* mFrame;
|
|
|
|
|
|
|
|
// This is represents the offset from our baseline to mFrame's baseline;
|
|
|
|
// positive offsets are *above* the baseline and negative offsets below
|
|
|
|
nscoord mBaselineOffset;
|
|
|
|
|
|
|
|
nscolor mColor;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t mStyle;
|
2011-08-03 22:30:58 +04:00
|
|
|
|
2017-01-26 15:41:39 +03:00
|
|
|
LineDecoration(nsIFrame* const aFrame, const nscoord aOff,
|
2011-08-03 22:30:58 +04:00
|
|
|
const nscolor aColor, const uint8_t aStyle)
|
2017-01-26 15:41:39 +03:00
|
|
|
: mFrame(aFrame),
|
|
|
|
mBaselineOffset(aOff),
|
|
|
|
mColor(aColor),
|
|
|
|
mStyle(aStyle) {}
|
2011-08-03 22:30:58 +04:00
|
|
|
|
|
|
|
LineDecoration(const LineDecoration& aOther)
|
2017-01-26 15:41:39 +03:00
|
|
|
: mFrame(aOther.mFrame),
|
|
|
|
mBaselineOffset(aOther.mBaselineOffset),
|
|
|
|
mColor(aOther.mColor),
|
|
|
|
mStyle(aOther.mStyle) {}
|
2011-08-03 22:30:58 +04:00
|
|
|
|
2017-01-26 15:41:39 +03:00
|
|
|
bool operator==(const LineDecoration& aOther) const {
|
|
|
|
return mFrame == aOther.mFrame && mStyle == aOther.mStyle &&
|
2011-08-03 22:30:58 +04:00
|
|
|
mColor == aOther.mColor &&
|
|
|
|
mBaselineOffset == aOther.mBaselineOffset;
|
|
|
|
}
|
2012-08-29 09:39:01 +04:00
|
|
|
|
2017-01-26 15:41:39 +03:00
|
|
|
bool operator!=(const LineDecoration& aOther) const {
|
2012-08-29 09:39:01 +04:00
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
2011-08-03 22:30:58 +04:00
|
|
|
};
|
2017-01-26 15:41:39 +03:00
|
|
|
struct TextDecorations {
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<LineDecoration, 1> mOverlines, mUnderlines, mStrikes;
|
2011-08-03 22:30:58 +04:00
|
|
|
|
2017-01-26 15:41:39 +03:00
|
|
|
TextDecorations() {}
|
2011-08-03 22:30:58 +04:00
|
|
|
|
2017-01-26 15:41:39 +03:00
|
|
|
bool HasDecorationLines() const {
|
2011-04-23 09:13:09 +04:00
|
|
|
return HasUnderline() || HasOverline() || HasStrikeout();
|
2008-02-16 18:31:27 +03:00
|
|
|
}
|
2017-01-26 15:41:39 +03:00
|
|
|
bool HasUnderline() const { return !mUnderlines.IsEmpty(); }
|
|
|
|
bool HasOverline() const { return !mOverlines.IsEmpty(); }
|
|
|
|
bool HasStrikeout() const { return !mStrikes.IsEmpty(); }
|
|
|
|
bool operator==(const TextDecorations& aOther) const {
|
2012-08-29 09:39:01 +04:00
|
|
|
return mOverlines == aOther.mOverlines &&
|
2017-01-26 15:41:39 +03:00
|
|
|
mUnderlines == aOther.mUnderlines && mStrikes == aOther.mStrikes;
|
2012-08-29 09:39:01 +04:00
|
|
|
}
|
2017-01-26 15:41:39 +03:00
|
|
|
bool operator!=(const TextDecorations& aOther) const {
|
2012-08-29 09:39:01 +04:00
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
2008-02-16 18:31:27 +03:00
|
|
|
};
|
2017-01-26 15:41:39 +03:00
|
|
|
enum TextDecorationColorResolution { eResolvedColors, eUnresolvedColors };
|
2011-08-03 22:30:58 +04:00
|
|
|
void GetTextDecorations(nsPresContext* aPresContext,
|
2012-08-08 15:37:13 +04:00
|
|
|
TextDecorationColorResolution aColorResolution,
|
2011-08-03 22:30:58 +04:00
|
|
|
TextDecorations& aDecorations);
|
2008-03-30 00:25:15 +03:00
|
|
|
|
2017-10-24 11:59:09 +03:00
|
|
|
void DrawTextRun(Range aRange, const mozilla::gfx::Point& aTextBaselinePt,
|
2016-03-08 10:56:18 +03:00
|
|
|
const DrawTextRunParams& aParams);
|
|
|
|
|
2017-01-26 15:41:39 +03:00
|
|
|
void DrawTextRunAndDecorations(Range aRange,
|
2017-10-24 11:59:09 +03:00
|
|
|
const mozilla::gfx::Point& aTextBaselinePt,
|
2016-03-08 10:56:18 +03:00
|
|
|
const DrawTextParams& aParams,
|
|
|
|
const TextDecorations& aDecorations);
|
|
|
|
|
2017-10-24 11:59:09 +03:00
|
|
|
void DrawText(Range aRange, const mozilla::gfx::Point& aTextBaselinePt,
|
2016-03-08 10:56:18 +03:00
|
|
|
const DrawTextParams& aParams);
|
2011-08-03 22:30:58 +04:00
|
|
|
|
2009-04-03 11:26:28 +04:00
|
|
|
// Set non empty rect to aRect, it should be overflow rect or frame rect.
|
2011-10-17 18:59:28 +04:00
|
|
|
// If the result rect is larger than the given rect, this returns true.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool CombineSelectionUnderlineRect(nsPresContext* aPresContext,
|
2017-01-26 15:41:39 +03:00
|
|
|
nsRect& aRect);
|
2008-04-11 12:44:58 +04:00
|
|
|
|
2015-08-19 10:37:39 +03:00
|
|
|
/**
|
|
|
|
* Utility methods to paint selection.
|
|
|
|
*/
|
|
|
|
void DrawSelectionDecorations(
|
2016-03-08 10:56:18 +03:00
|
|
|
gfxContext* aContext, const LayoutDeviceRect& aDirtyRect,
|
2016-06-11 05:06:37 +03:00
|
|
|
mozilla::SelectionType aSelectionType, nsTextPaintStyle& aTextPaintStyle,
|
2017-01-26 15:41:39 +03:00
|
|
|
const TextRangeStyle& aRangeStyle, const Point& aPt,
|
2015-08-19 10:37:39 +03:00
|
|
|
gfxFloat aICoordInFrame, gfxFloat aWidth, gfxFloat aAscent,
|
|
|
|
const gfxFont::Metrics& aFontMetrics, DrawPathCallbacks* aCallbacks,
|
|
|
|
bool aVertical, uint8_t aDecoration);
|
2016-03-22 12:42:18 +03:00
|
|
|
|
|
|
|
struct PaintDecorationLineParams;
|
|
|
|
void PaintDecorationLine(const PaintDecorationLineParams& aParams);
|
2015-08-19 10:37:39 +03:00
|
|
|
/**
|
|
|
|
* ComputeDescentLimitForSelectionUnderline() computes the most far position
|
|
|
|
* where we can put selection underline.
|
|
|
|
*
|
|
|
|
* @return The maximum underline offset from the baseline (positive value
|
|
|
|
* means that the underline can put below the baseline).
|
|
|
|
*/
|
|
|
|
gfxFloat ComputeDescentLimitForSelectionUnderline(
|
2017-01-26 15:41:39 +03:00
|
|
|
nsPresContext* aPresContext, const gfxFont::Metrics& aFontMetrics);
|
2015-08-19 10:37:39 +03:00
|
|
|
/**
|
|
|
|
* This function encapsulates all knowledge of how selections affect
|
|
|
|
* foreground and background colors.
|
|
|
|
* @param aForeground the foreground color to use
|
|
|
|
* @param aBackground the background color to use, or RGBA(0,0,0,0) if no
|
|
|
|
* background should be painted
|
|
|
|
* @return true if the selection affects colors, false otherwise
|
|
|
|
*/
|
2016-06-11 05:06:37 +03:00
|
|
|
static bool GetSelectionTextColors(SelectionType aSelectionType,
|
2015-08-19 10:37:39 +03:00
|
|
|
nsTextPaintStyle& aTextPaintStyle,
|
2017-01-26 15:41:39 +03:00
|
|
|
const TextRangeStyle& aRangeStyle,
|
2015-08-19 10:37:39 +03:00
|
|
|
nscolor* aForeground,
|
|
|
|
nscolor* aBackground);
|
|
|
|
/**
|
|
|
|
* ComputeSelectionUnderlineHeight() computes selection underline height of
|
|
|
|
* the specified selection type from the font metrics.
|
|
|
|
*/
|
|
|
|
static gfxFloat ComputeSelectionUnderlineHeight(
|
2017-01-26 15:41:39 +03:00
|
|
|
nsPresContext* aPresContext, const gfxFont::Metrics& aFontMetrics,
|
|
|
|
SelectionType aSelectionType);
|
2015-08-19 10:37:39 +03:00
|
|
|
|
2017-01-26 15:41:39 +03:00
|
|
|
ContentOffsets GetCharacterOffsetAtFramePointInternal(
|
|
|
|
const nsPoint& aPoint, bool aForInsertionPoint);
|
2010-08-10 19:16:17 +04:00
|
|
|
|
|
|
|
void ClearFrameOffsetCache();
|
2010-08-14 02:58:26 +04:00
|
|
|
|
2016-07-21 13:36:38 +03:00
|
|
|
void ClearMetrics(ReflowOutput& aMetrics);
|
2016-06-23 14:02:14 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* UpdateIteratorFromOffset() updates the iterator from a given offset.
|
|
|
|
* Also, aInOffset may be updated to cluster start if aInOffset isn't
|
|
|
|
* the offset of cluster start.
|
|
|
|
*/
|
|
|
|
void UpdateIteratorFromOffset(const PropertyProvider& aProperties,
|
|
|
|
int32_t& aInOffset,
|
|
|
|
gfxSkipCharsIterator& aIter);
|
|
|
|
|
|
|
|
nsPoint GetPointFromIterator(const gfxSkipCharsIterator& aIter,
|
|
|
|
PropertyProvider& aProperties);
|
2007-09-24 06:19:14 +04:00
|
|
|
};
|
|
|
|
|
2019-02-23 00:12:27 +03:00
|
|
|
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(nsTextFrame::TrimmedOffsetFlags)
|
|
|
|
|
2007-09-24 06:19:14 +04:00
|
|
|
#endif
|