Files
palemoon27/layout/generic/TextOverflow.h
T
roytam1 c0011dadb2 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1160013 CachePushStreamChild should hold the parent DOM object alive. r=baku (07626c5e44)
- Bug 1179772 Make Cache API honor devtools SW testing flag in SW itself. r=ehsan (4d915be43c)
- Bug 1181577 Delay creation of QuotaInitRunnable until Cache Context actually started. r=ehsan (9991aafa07)
- Bug 1210128 Ensure Cache API context internal state is consistent when shutdown during initialization. r=janv (25fbcf3136)
- Bug 1138916 Fix Cache::MatchAll() assertion in WorkerFeature handling. r=baku (73fe25803b)
- Bug 1186312 - Cache API should not accept system principals for child processes. r=bkelly (c140f627f8)
- align (acb75b3a8d)
- Bug 1215290 Cache API should store unfiltered Response URL. r=ehsan (55238dd04a)
- Bug 1217501 P4 Fill headers before setting guard when reading response from Cache. r=ehsan (787cb31d84)
- bits of  Bug 1202902 (82e2e451cc)
- Bug 1147329 - Handle in-process case for Cut/Copy/Paste feature. r=kanru (66cabbf705)
- Bug 1199161 - Add selectedTextContent to CaretStateChangedEvent. r=kanru, sr=smaug (5eb99e303b)
- Bug 1217515 - Clean up the way touch event support is configured. r=roc (24a7db4a42)
- Bug 1216937 - Assign default URL for mozbrowseropenwindow event. r=smaug (fc7aaa533b)
- Bug 1101115, implement nsChromeRegistryContent::IsLocaleRTL so that file directory view works in e10s rtl mode, r=bsmedberg (c0eb12391f)
- Bug 1186787 (part 1) - Replace nsBaseHashtable::EnumerateRead() calls in chrome/ with iterators. r=froydnj. (2508253415)
- Bug 1186787 (part 2) - Replace nsBaseHashtable::EnumerateRead() calls in chrome/ with iterators. r=froydnj. (193c37c478)
- Bug 1170207 - allow overrides of chrome://../skin/ URIs with other chrome://../skin/ URIs within skin manifests, r=bsmedberg (3c24e2006c)
- Bug 1210463 - part 3 - Remove the very obsolete NS_IMPL_MOZILLA192_NSGETMODULE. r=froydnj (c7300c145b)
- Bug 1210463 - part 1 - Remove some unneeded null checks on new in ModuleUtils. r=froydnj (73affb8e34)
- Bug 1210463 - part 2 - Use some smart pointers in ModuleUtils.h. r=froydnj (f5eeb12cb3)
- Bug 1210463 - part 2 - Use some smart pointers in ModuleUtils.h. r=froydnj (788f944a41)
- Bug 1215143 - FF Android VR returns orientation that is 90deg off on x-axis. r=vlad (fc0d86c800)
- Bug 1166667 - Remove LangGroupFromUnicodeRange due to unused. r=jfkthame (e3bb039e41)
- Bug 1119062 - enable unicode-range in release builds. r=dbaron (8d48c7ab14)
- bits of 1117227 in headers (ad920e2094)
- Bug 1220020. Recompute the current animated geometry root when a child scroll frame forces us to be layerized, and therefore turns us into an animated geometry root. r=mstange (4cfb015eb7)
- Bug 1220114. Part 1. Change ScrollFrameHelper::DecideScrollableLayer to recompute the current animated geometry root any time mWillBuildScrollableLayer changes in addition to when usingDisplayPort changes. r=mstange (9e8512babe)
- Bug 1220114. Part 2. If a scroll frame is forced to layerize because of an active descendant scroll frame then set a displayport on the ancestor scroll frame so that next paint we don't have to force layerization after the fact and we can do a fully proper paint. r=mstange (a3d7734f75)
- Bug 1228357 - When saving/restoring a scrollframe's state, only save/restore resolution for the root scrollframe. r=roc (7018d5bcae)
- Bug 1224307 - Fix page scrolling for non-full-width fixed headers/footers [r=tn]  Please enter the commit message for your changes. Lines starting (55eebe3d49)
- Bug 1081272 - Include position and transform when computing header/footer size [r=tn] (c91104a099)
- Bug 1145546: take auto-direction into account in GetScrolledRect, r=jfkthame (a5bf400639)
- spaces (4a2918cb4c)
- Bug 1225376 part 1 - [css-align] Don't compute left/right to start in the style system anymore (due to pending spec change). Map the used value instead (in layout). r=dholbert (677b9eba16)
- Bug 1225376 part 2 - [css-align] Add mochitests for align/justify-items/self/content computed values. (580ef62eb6)
- Bug 1225376 part 3 - [css-grid] Crashtest. (3e5b06dce4)
- Bug 1148515 - Do the scrollbar thumb layer wrapping in nsSliderFrameso that the thumb's event region is wrapped, too. r=tn (0ff596193e)
- Bug 1133732. Header include got missed in rebase. on CLOSED TREE (b870504066)
- Bug 1133732. Make button box frames listen for blurs so they de-activate on blur. r=smaug (5c6274f99d)
- Bug 1170052 part 1: Refactor nsImageBoxFrame::PaintImage() so its final failure case is an early return. r=seth (7308f3f32e)
- Bug 1170052 part 2: Support object-fit & object-position on XUL <image src=""> elements. r=seth (74ab4c8813)
- Bug 1170052 part 3: Add scripts to generate reftests for object-fit/object-position applied to XUL <image>. (NPOTB) (5b1e1b6b90)
- Bug 1170052 part 4: Add reftests for object-fit/object-position on XUL <image> element (as modified copies of existing <img> tests). (test-only) (7f678646e8)
- Bug 1170052 part 5: Mark new reftests as "skip-if(Mulet)" to avoid impacting reftest chunking on that platform in a way that makes SVG reftests fail mysteriously. (d6c7e5ff05)
- Bug 1170052 part 6: Skip new XUL reftests on B2G Emulator as well, since XUL reftests trigger error pages on that platform. (3f4ddeddcd)
- Bug 1194493 - Ensure the 'mVertical' flag is set appropriately on the nsFontMetrics we use to draw text for an nsTextBoxFrame. r=smontagu (a6eed3f9b8)
- Bug 1155359 - Set NS_FRAME_IS_BIDI on nsTextBoxFrame if text direction is set to RTL r=roc (2715d47271)
- crash reporter (015ee49944)
2023-03-20 16:03:44 +08:00

261 lines
9.8 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
/* 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/. */
#ifndef TextOverflow_h_
#define TextOverflow_h_
#include "nsDisplayList.h"
#include "nsTHashtable.h"
#include "nsAutoPtr.h"
#include "mozilla/Likely.h"
#include "mozilla/WritingModes.h"
#include <algorithm>
class nsIScrollableFrame;
class nsLineBox;
namespace mozilla {
namespace css {
/**
* A class for rendering CSS3 text-overflow.
* Usage:
* 1. allocate an object using WillProcessLines
* 2. then call ProcessLine for each line you are building display lists for
*/
class TextOverflow {
public:
/**
* Allocate an object for text-overflow processing.
* @return nullptr if no processing is necessary. The caller owns the object.
*/
static TextOverflow* WillProcessLines(nsDisplayListBuilder* aBuilder,
nsIFrame* aBlockFrame);
/**
* Analyze the display lists for text overflow and what kind of item is at
* the content edges. Add display items for text-overflow markers as needed
* and remove or clip items that would overlap a marker.
*/
void ProcessLine(const nsDisplayListSet& aLists, nsLineBox* aLine);
/**
* Get the resulting text-overflow markers (the list may be empty).
* @return a DisplayList containing any text-overflow markers.
*/
nsDisplayList& GetMarkers() { return mMarkerList; }
/**
* @return true if aBlockFrmae has text-overflow:clip on both sides.
*/
static bool HasClippedOverflow(nsIFrame* aBlockFrame);
/**
* @return true if aBlockFrame needs analysis for text overflow.
*/
static bool CanHaveTextOverflow(nsDisplayListBuilder* aBuilder,
nsIFrame* aBlockFrame);
typedef nsTHashtable<nsPtrHashKey<nsIFrame> > FrameHashtable;
protected:
TextOverflow(nsDisplayListBuilder* aBuilder,
nsIFrame* aBlockFrame);
typedef mozilla::WritingMode WritingMode;
typedef mozilla::LogicalRect LogicalRect;
struct AlignmentEdges {
AlignmentEdges() : mAssigned(false) {}
void Accumulate(WritingMode aWM, const LogicalRect& aRect)
{
if (MOZ_LIKELY(mAssigned)) {
mIStart = std::min(mIStart, aRect.IStart(aWM));
mIEnd = std::max(mIEnd, aRect.IEnd(aWM));
} else {
mIStart = aRect.IStart(aWM);
mIEnd = aRect.IEnd(aWM);
mAssigned = true;
}
}
nscoord ISize() { return mIEnd - mIStart; }
nscoord mIStart;
nscoord mIEnd;
bool mAssigned;
};
struct InnerClipEdges {
InnerClipEdges() : mAssignedIStart(false), mAssignedIEnd(false) {}
void AccumulateIStart(WritingMode aWM, const LogicalRect& aRect)
{
if (MOZ_LIKELY(mAssignedIStart)) {
mIStart = std::max(mIStart, aRect.IStart(aWM));
} else {
mIStart = aRect.IStart(aWM);
mAssignedIStart = true;
}
}
void AccumulateIEnd(WritingMode aWM, const LogicalRect& aRect)
{
if (MOZ_LIKELY(mAssignedIEnd)) {
mIEnd = std::min(mIEnd, aRect.IEnd(aWM));
} else {
mIEnd = aRect.IEnd(aWM);
mAssignedIEnd = true;
}
}
nscoord mIStart;
nscoord mIEnd;
bool mAssignedIStart;
bool mAssignedIEnd;
};
LogicalRect
GetLogicalScrollableOverflowRectRelativeToBlock(nsIFrame* aFrame) const
{
return LogicalRect(mBlockWM,
aFrame->GetScrollableOverflowRect() +
aFrame->GetOffsetTo(mBlock),
mBlockSize);
}
/**
* Examines frames on the line to determine whether we should draw a left
* and/or right marker, and if so, which frames should be completely hidden
* and the bounds of what will be displayed between the markers.
* @param aLine the line we're processing
* @param aFramesToHide frames that should have their display items removed
* @param aAlignmentEdges the outermost edges of all text and atomic
* inline-level frames that are inside the area between the markers
*/
void ExamineLineFrames(nsLineBox* aLine,
FrameHashtable* aFramesToHide,
AlignmentEdges* aAlignmentEdges);
/**
* LineHasOverflowingText calls this to analyze edges, both the block's
* content edges and the hypothetical marker edges aligned at the block edges.
* @param aFrame the descendant frame of mBlock that we're analyzing
* @param aContentArea the block's content area
* @param aInsideMarkersArea the rectangle between the markers
* @param aFramesToHide frames that should have their display items removed
* @param aAlignmentEdges the outermost edges of all text and atomic
* inline-level frames that are inside the area between the markers
* @param aFoundVisibleTextOrAtomic is set to true if a text or atomic
* inline-level frame is visible between the marker edges
* @param aClippedMarkerEdges the innermost edges of all text and atomic
* inline-level frames that are clipped by the current marker width
*/
void ExamineFrameSubtree(nsIFrame* aFrame,
const LogicalRect& aContentArea,
const LogicalRect& aInsideMarkersArea,
FrameHashtable* aFramesToHide,
AlignmentEdges* aAlignmentEdges,
bool* aFoundVisibleTextOrAtomic,
InnerClipEdges* aClippedMarkerEdges);
/**
* ExamineFrameSubtree calls this to analyze a frame against the hypothetical
* marker edges (aInsideMarkersArea) for text frames and atomic inline-level
* elements. A text frame adds its extent inside aInsideMarkersArea where
* grapheme clusters are fully visible. An atomic adds its border box if
* it's fully inside aInsideMarkersArea, otherwise the frame is added to
* aFramesToHide.
* @param aFrame the descendant frame of mBlock that we're analyzing
* @param aFrameType aFrame's frame type
* @param aInsideMarkersArea the rectangle between the markers
* @param aFramesToHide frames that should have their display items removed
* @param aAlignmentEdges the outermost edges of all text and atomic
* inline-level frames that are inside the area between the markers
* inside aInsideMarkersArea
* @param aFoundVisibleTextOrAtomic is set to true if a text or atomic
* inline-level frame is visible between the marker edges
* @param aClippedMarkerEdges the innermost edges of all text and atomic
* inline-level frames that are clipped by the current marker width
*/
void AnalyzeMarkerEdges(nsIFrame* aFrame,
const nsIAtom* aFrameType,
const LogicalRect& aInsideMarkersArea,
FrameHashtable* aFramesToHide,
AlignmentEdges* aAlignmentEdges,
bool* aFoundVisibleTextOrAtomic,
InnerClipEdges* aClippedMarkerEdges);
/**
* Clip or remove items given the final marker edges. ("clip" here just means
* assigning mVisIStartEdge/mVisIEndEdge for any nsCharClipDisplayItem that
* needs it; see nsDisplayList.h for a description of that item).
* @param aFramesToHide remove display items for these frames
* @param aInsideMarkersArea is the area inside the markers
*/
void PruneDisplayListContents(nsDisplayList* aList,
const FrameHashtable& aFramesToHide,
const LogicalRect& aInsideMarkersArea);
/**
* ProcessLine calls this to create display items for the markers and insert
* them into mMarkerList.
* @param aLine the line we're processing
* @param aCreateIStart if true, create a marker on the inline start side
* @param aCreateIEnd if true, create a marker on the inline end side
* @param aInsideMarkersArea is the area inside the markers
*/
void CreateMarkers(const nsLineBox* aLine,
bool aCreateIStart, bool aCreateIEnd,
const LogicalRect& aInsideMarkersArea);
LogicalRect mContentArea;
nsDisplayListBuilder* mBuilder;
nsIFrame* mBlock;
nsIScrollableFrame* mScrollableFrame;
nsDisplayList mMarkerList;
nsSize mBlockSize;
WritingMode mBlockWM;
bool mCanHaveInlineAxisScrollbar;
bool mAdjustForPixelSnapping;
class Marker {
public:
void Init(const nsStyleTextOverflowSide& aStyle) {
mInitialized = false;
mISize = 0;
mStyle = &aStyle;
}
/**
* Setup the marker string and calculate its size, if not done already.
*/
void SetupString(nsIFrame* aFrame);
bool IsNeeded() const {
return mHasOverflow;
}
void Reset() {
mHasOverflow = false;
}
// The current width of the marker, the range is [0 .. mIntrinsicISize].
nscoord mISize;
// The intrinsic width of the marker.
nscoord mIntrinsicISize;
// The style for this side.
const nsStyleTextOverflowSide* mStyle;
// True if there is visible overflowing inline content on this side.
bool mHasOverflow;
// True if mMarkerString and mWidth have been setup from style.
bool mInitialized;
// True if the style is text-overflow:clip on this side and the marker
// won't cause the line to become empty.
bool mActive;
};
Marker mIStart; // the inline start marker
Marker mIEnd; // the inline end marker
};
} // namespace css
} // namespace mozilla
#endif /* !defined(TextOverflow_h_) */