Files
palemoon27/layout/generic/nsGridContainerFrame.h
roytam1 38663d2b9f import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1230163 - White-space copy issue: Add conditional compile also for SeaMonkey. r=ehsan (6c6cf03257)
- Bug 1066663, move call to SetDragState to happen when a window is lowered to avoid the issue with selection being prevented, r=smaug (7a15008ac3)
- Bug 1245452, null check window->GetDocShell return value, r=khuey (77fee59e52)
- Bug 1168398 - Ensure that the presshell is initialized before attempting to scroll something into its view; r=enndeakin (4aba157104)
- Bug 1227461, don't iterate multiple times past the top-level document during tab navigation, prevents hang navigating in page info dialog, r=smaug (0a69f5085d)
- Bug 1263443 - Typo in nsGkAtomList.h; r=smaug (9a0b34d075)
- Bug 1260480 - Remove mozNoMarginBoxes. r=dbaron (fb06487de9)
- Bug 1254378 - Make SpeechSynthesis an event target with a "voiceschanged" event. r=smaug (8d00157559)
- some missing bits to be reapplied (e046af733d)
- Bug 1097398 Part 1 - Move AccessibleCaret default assets to layout/style/. r=nalexander, r=heycam (694c4617d2)
- Bug 1097398 Part 2 - Add preferences to make carets always tilt. r=roc (61ccfa508e)
- Bug 1252368 - Move resource files in layout/style/ into layout/style/res/ directory. r=nalexander (6049fec5ba)
- partial of Bug 1258177 - Make the list-item markers non-selectable. r=bz (9387a5a1f7)
- Bug 1259889 Part 2 - Load html.css lazily for pref changes. r=heycam (16f139a9b4)
- Bug 1258657 Part 1 - Change summary default style to "display: list-item" to match html spec. r=bz (a90a87025c)
- Bug 1258657 Part 2 - Remove SummaryFrame. r=bz (7e555a570e)
- Bug 1236828 part 1 - Apply proper clip state to top layer frames. r=mstange (5f3b55e475)
- Bug 1236828 part 2 - Make frame constructor support absolutely-positioned top layer frame. r=bz (052f7d5d71)
- Bug 1236828 part 3 - Allow setting position: absolute for top layer element and add test. r=heycam (ddf55b2e57)
- Bug 1264533 - Correct the universal selector for summary to include all namespaces. r=bz (4bd53c11cc)
- simple formatting (f19a2351a2)
- Bug 1235321 - Enable using line cursor to optimize reflowing absolute frames. r=bz (35199c6780)
- Bug 1260090 - Remove nsBlockFrameSuper as nsContainerFrame alias. r=dholbert (dbf60b2ef2)
- minor format fix (a057efcf1c)
- minor format fix (ac1f3b6691)
- Bug 1145218 followup - Properly parenthesize macro argument. No review. (6a5d9fcf64)
- Bug 1256727 - Back out the functional parts of cset 59a1ca7d784c now that we have a better fix using empty transactions. r=me (007080dd0a)
- Bug 1256040 - Follow-up fix for nsGridContainerFrame.h/cpp compile errors in non-unified build. r=me (9c08e31572)
- Bug 1243125 - patch 0 - Relax overly-harsh writing mode assertions in nsReflowMetrics size accessors. r=dholbert (3f75521c74)
- Bug 1243125 - patch 1 - Check block size instead of height when detecting truncated frames. r=jfkthame (66a36d7c35)
- Bug 1243125 - patch 2 - Don't ever set NS_FRAME_TRUNCATED for orthogonal flows. r=dholbert (ce4650213c)
- Bug 1243125 - Reftest for floats overflowing container, with diverse writing-modes. r=jfkthame (f621d8d17e)
- Bug 1250674 - Don't print header/footer if larger than user defined margins. r=dbaron (604e4c8f28)
- Bug 1182247 - Only RegisterPluginForGeometryUpdates in nsPluginFrame::EndSwapDocShells if mInstanceOwner is non-null. r=tnikkel (8958766501)
- fix misspatch compared to esr52 (06be2eb39c)
- Bug 1237236 - When collapsing the selection to the end of textframe that ends in a significant newline then set mHint to CARET_ASSOCIATE_AFTER so that the caret is rendered at the start of the next line if any. r=ehsan (1f86bf7a57)
- Bug 1258308 - Lookup the frame (continuation) associated with aParentNode/aOffset instead of assuming it's always the primary frame (follow-up from bug 1237236). r=ehsa (8849eecf94)
- Bug 1259949 - Set the CARET_ASSOCIATE_AFTER hint also when we collapse just after a text node that ends with a significant newline. r=ehsan (065b4f6c9a)
- Bug 1261718. In nsSubDocumentFrame when getting the document from a view go through the view manager because it is more like to succeed. r=mats (508f485aeb)
- Bug 1178060 - Ensure that if there is a document-level apz-aware event listener on a subdocument, we build the nsDisplaySubdocument item to hold that information. r=tn (8e235581a5)
- Bug 1240799 - Apply axis height for mfrac elements without bar. r=fredw (6a5fb4a3fa)
- Bug 1224113 - fix ref count issue during channel close. r=jdm (35c5a01787)
2024-08-02 16:52:24 +08:00

258 lines
9.5 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code is subject to the terms of the Mozilla Public License
* version 2.0 (the "License"). You can obtain a copy of the License at
* http://mozilla.org/MPL/2.0/. */
/* rendering object for CSS "display: grid | inline-grid" */
#ifndef nsGridContainerFrame_h___
#define nsGridContainerFrame_h___
#include "mozilla/Maybe.h"
#include "mozilla/TypeTraits.h"
#include "nsContainerFrame.h"
#include "nsHashKeys.h"
#include "nsTHashtable.h"
/**
* Factory function.
* @return a newly allocated nsGridContainerFrame (infallible)
*/
nsContainerFrame* NS_NewGridContainerFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext);
namespace mozilla {
/**
* The number of implicit / explicit tracks and their sizes.
*/
struct ComputedGridTrackInfo
{
ComputedGridTrackInfo(uint32_t aNumLeadingImplicitTracks,
uint32_t aNumExplicitTracks,
nsTArray<nscoord>&& aSizes)
: mNumLeadingImplicitTracks(aNumLeadingImplicitTracks)
, mNumExplicitTracks(aNumExplicitTracks)
, mSizes(aSizes)
{}
uint32_t mNumLeadingImplicitTracks;
uint32_t mNumExplicitTracks;
nsTArray<nscoord> mSizes;
};
} // namespace mozilla
class nsGridContainerFrame final : public nsContainerFrame
{
public:
NS_DECL_FRAMEARENA_HELPERS
NS_DECL_QUERYFRAME_TARGET(nsGridContainerFrame)
NS_DECL_QUERYFRAME
typedef mozilla::ComputedGridTrackInfo ComputedGridTrackInfo;
// nsIFrame overrides
void Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus) override;
nscoord GetMinISize(nsRenderingContext* aRenderingContext) override;
nscoord GetPrefISize(nsRenderingContext* aRenderingContext) override;
void MarkIntrinsicISizesDirty() override;
nsIAtom* GetType() const override;
bool IsFrameOfType(uint32_t aFlags) const override
{
return nsContainerFrame::IsFrameOfType(aFlags &
~nsIFrame::eCanContainOverflowContainers);
}
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) override;
#ifdef DEBUG_FRAME_DUMP
nsresult GetFrameName(nsAString& aResult) const override;
#endif
// nsContainerFrame overrides
bool DrainSelfOverflowList() override;
void AppendFrames(ChildListID aListID, nsFrameList& aFrameList) override;
void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
nsFrameList& aFrameList) override;
void RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) override;
#ifdef DEBUG
void SetInitialChildList(ChildListID aListID,
nsFrameList& aChildList) override;
#endif
/**
* Return the containing block for aChild which MUST be an abs.pos. child
* of a grid container. This is just a helper method for
* nsAbsoluteContainingBlock::Reflow - it's not meant to be used elsewhere.
*/
static const nsRect& GridItemCB(nsIFrame* aChild);
NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridItemContainingBlockRect, nsRect)
NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridColTrackInfo, ComputedGridTrackInfo)
const ComputedGridTrackInfo* GetComputedTemplateColumns()
{
return Properties().Get(GridColTrackInfo());
}
NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridRowTrackInfo, ComputedGridTrackInfo)
const ComputedGridTrackInfo* GetComputedTemplateRows()
{
return Properties().Get(GridRowTrackInfo());
}
struct TrackSize;
protected:
static const uint32_t kAutoLine;
// The maximum line number, in the zero-based translated grid.
static const uint32_t kTranslatedMaxLine;
typedef mozilla::LogicalPoint LogicalPoint;
typedef mozilla::LogicalRect LogicalRect;
typedef mozilla::LogicalSize LogicalSize;
typedef mozilla::WritingMode WritingMode;
typedef mozilla::css::GridNamedArea GridNamedArea;
typedef mozilla::layout::AutoFrameListPtr AutoFrameListPtr;
typedef nsLayoutUtils::IntrinsicISizeType IntrinsicISizeType;
struct Grid;
struct GridArea;
class GridItemCSSOrderIterator;
struct GridItemInfo;
struct GridReflowState;
class LineNameMap;
struct LineRange;
struct SharedGridData;
struct TrackSizingFunctions;
struct Tracks;
struct TranslatedLineRange;
friend nsContainerFrame* NS_NewGridContainerFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext);
explicit nsGridContainerFrame(nsStyleContext* aContext)
: nsContainerFrame(aContext)
, mCachedMinISize(NS_INTRINSIC_WIDTH_UNKNOWN)
, mCachedPrefISize(NS_INTRINSIC_WIDTH_UNKNOWN)
{}
/**
* XXX temporary - move the ImplicitNamedAreas stuff to the style system.
* The implicit area names that come from x-start .. x-end lines in
* grid-template-columns / grid-template-rows are stored in this frame
* property when needed, as a ImplicitNamedAreas* value.
*/
typedef nsTHashtable<nsStringHashKey> ImplicitNamedAreas;
NS_DECLARE_FRAME_PROPERTY_DELETABLE(ImplicitNamedAreasProperty,
ImplicitNamedAreas)
void InitImplicitNamedAreas(const nsStylePosition* aStyle);
void AddImplicitNamedAreas(const nsTArray<nsTArray<nsString>>& aLineNameLists);
ImplicitNamedAreas* GetImplicitNamedAreas() const {
return Properties().Get(ImplicitNamedAreasProperty());
}
/**
* Reflow and place our children.
* @return the consumed size of all of this grid container's continuations
* so far including this frame
*/
nscoord ReflowChildren(GridReflowState& aState,
const LogicalRect& aContentArea,
nsHTMLReflowMetrics& aDesiredSize,
nsReflowStatus& aStatus);
/**
* Helper for GetMinISize / GetPrefISize.
*/
nscoord IntrinsicISize(nsRenderingContext* aRenderingContext,
IntrinsicISizeType aConstraint);
// Helper for AppendFrames / InsertFrames.
void NoteNewChildren(ChildListID aListID, const nsFrameList& aFrameList);
// Helper to move child frames into the kOverflowList.
void MergeSortedOverflow(nsFrameList& aList);
// Helper to move child frames into the kExcessOverflowContainersList:.
void MergeSortedExcessOverflowContainers(nsFrameList& aList);
#ifdef DEBUG
void SanityCheckGridItemsBeforeReflow() const;
#endif // DEBUG
private:
// Helpers for ReflowChildren
struct Fragmentainer {
/**
* The distance from the first grid container fragment's block-axis content
* edge to the fragmentainer end.
*/
nscoord mToFragmentainerEnd;
/**
* True if the current fragment is at the start of the fragmentainer.
*/
bool mIsTopOfPage;
/**
* Is there a Class C break opportunity at the start content edge?
*/
bool mCanBreakAtStart;
/**
* Is there a Class C break opportunity at the end content edge?
*/
bool mCanBreakAtEnd;
/**
* Is the grid container's block-size unconstrained?
*/
bool mIsAutoBSize;
};
mozilla::Maybe<nsGridContainerFrame::Fragmentainer>
GetNearestFragmentainer(const GridReflowState& aState) const;
// @return the consumed size of all continuations so far including this frame
nscoord ReflowInFragmentainer(GridReflowState& aState,
const LogicalRect& aContentArea,
nsHTMLReflowMetrics& aDesiredSize,
nsReflowStatus& aStatus,
Fragmentainer& aFragmentainer,
const nsSize& aContainerSize);
// Helper for ReflowInFragmentainer
// @return the consumed size of all continuations so far including this frame
nscoord ReflowRowsInFragmentainer(GridReflowState& aState,
const LogicalRect& aContentArea,
nsHTMLReflowMetrics& aDesiredSize,
nsReflowStatus& aStatus,
Fragmentainer& aFragmentainer,
const nsSize& aContainerSize,
const nsTArray<const GridItemInfo*>& aItems,
uint32_t aStartRow,
uint32_t aEndRow,
nscoord aBSize,
nscoord aAvailableSize);
// Helper for ReflowChildren / ReflowInFragmentainer
void ReflowInFlowChild(nsIFrame* aChild,
const GridItemInfo* aGridItemInfo,
nsSize aContainerSize,
const Fragmentainer* aFragmentainer,
const GridReflowState& aState,
const LogicalRect& aContentArea,
nsHTMLReflowMetrics& aDesiredSize,
nsReflowStatus& aStatus);
/**
* Cached values to optimize GetMinISize/GetPrefISize.
*/
nscoord mCachedMinISize;
nscoord mCachedPrefISize;
#ifdef DEBUG
// If true, NS_STATE_GRID_DID_PUSH_ITEMS may be set even though all pushed
// frames may have been removed. This is used to suppress an assertion
// in case RemoveFrame removed all associated child frames.
bool mDidPushItemsBitMayLie;
#endif
};
#endif /* nsGridContainerFrame_h___ */