mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1824489 - Remove nsBoxFrame, nsBoxLayout and related code. r=jwatt
We still have some remnants of XUL layout due to nsBox / nsLeafBoxFrame which XUL trees / nsTextBoxFrame still use. However all this code can go away before we get rid of those. nsSplitterFrame was the last thing inheriting from nsBoxFrame. Differential Revision: https://phabricator.services.mozilla.com/D173601
This commit is contained in:
parent
66824dd8b6
commit
b9d1536d46
@ -76,8 +76,6 @@
|
||||
#include "ChildIterator.h"
|
||||
#include "nsError.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsBoxFrame.h"
|
||||
#include "nsBoxLayout.h"
|
||||
#include "nsFlexContainerFrame.h"
|
||||
#include "nsGridContainerFrame.h"
|
||||
#include "RubyUtils.h"
|
||||
@ -2486,10 +2484,6 @@ nsIFrame* nsCSSFrameConstructor::ConstructDocElementFrame(
|
||||
if (display->mDisplay == StyleDisplay::Grid) {
|
||||
return NS_NewGridContainerFrame;
|
||||
}
|
||||
if (display->mDisplay == StyleDisplay::MozBox &&
|
||||
!computedStyle->StyleVisibility()->EmulateMozBoxWithFlex()) {
|
||||
return NS_NewBoxFrame;
|
||||
}
|
||||
return NS_NewFlexContainerFrame;
|
||||
}();
|
||||
contentFrame = func(mPresShell, computedStyle);
|
||||
@ -2644,8 +2638,7 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock(
|
||||
nsHTMLScrollFrame (if needed)
|
||||
nsCanvasFrame [abs-cb]
|
||||
root element frame (nsBlockFrame, SVGOuterSVGFrame,
|
||||
nsTableWrapperFrame, nsPlaceholderFrame,
|
||||
nsBoxFrame)
|
||||
nsTableWrapperFrame, nsPlaceholderFrame)
|
||||
|
||||
Print presentation, non-XUL
|
||||
|
||||
@ -4460,15 +4453,6 @@ nsCSSFrameConstructor::FindDisplayData(const nsStyleDisplay& aDisplay,
|
||||
aElement.OwnerDoc()->WarnOnceAbout(
|
||||
DeprecatedOperations::eMozBoxOrInlineBoxDisplay);
|
||||
}
|
||||
|
||||
// If we're emulating -moz-box with flexbox, then treat it as non-XUL and
|
||||
// fall through.
|
||||
if (aMozBoxLayout == StyleMozBoxLayout::Legacy) {
|
||||
static constexpr FrameConstructionData data =
|
||||
SCROLLABLE_ABSPOS_CONTAINER_XUL_FCDATA(
|
||||
ToCreationFunc(NS_NewBoxFrame));
|
||||
return &data;
|
||||
}
|
||||
[[fallthrough]];
|
||||
}
|
||||
case StyleDisplayInside::Flex:
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "nsRegion.h"
|
||||
#include "nsRepeatService.h"
|
||||
#include "nsFloatManager.h"
|
||||
#include "nsSprocketLayout.h"
|
||||
#include "nsTextControlFrame.h"
|
||||
#include "txMozillaXSLTProcessor.h"
|
||||
#include "nsTreeSanitizer.h"
|
||||
@ -347,7 +346,6 @@ void nsLayoutStatics::Shutdown() {
|
||||
|
||||
nsXULContentUtils::Finish();
|
||||
nsXULPrototypeCache::ReleaseGlobals();
|
||||
nsSprocketLayout::Shutdown();
|
||||
|
||||
SVGElementFactory::Shutdown();
|
||||
nsMathMLOperators::ReleaseTable();
|
||||
|
@ -11,7 +11,6 @@ FRAME_CLASSES = [
|
||||
Frame("nsBackdropFrame", "Backdrop", LEAF),
|
||||
Frame("nsBlockFrame", "Block", NOT_LEAF),
|
||||
Frame("nsBox", "None", NOT_LEAF),
|
||||
Frame("nsBoxFrame", "Box", NOT_LEAF),
|
||||
Frame("nsButtonBoxFrame", "Box", NOT_LEAF),
|
||||
Frame("nsCanvasFrame", "Canvas", NOT_LEAF),
|
||||
Frame("nsCheckboxRadioFrame", "CheckboxRadio", LEAF),
|
||||
|
@ -315,19 +315,11 @@ bool ReflowInput::ShouldReflowAllKids() const {
|
||||
|
||||
void ReflowInput::SetComputedISize(nscoord aComputedISize,
|
||||
ResetResizeFlags aFlags) {
|
||||
// It'd be nice to assert that |frame| is not in reflow, but this fails for
|
||||
// two reasons:
|
||||
//
|
||||
// 1) Viewport frames reset the computed isize on a copy of their reflow
|
||||
// input when reflowing fixed-pos kids. In that case we actually don't
|
||||
// want to mess with the resize flags, because comparing the frame's rect
|
||||
// to the munged computed width is pointless.
|
||||
// 2) nsIFrame::BoxReflow creates a reflow input for its parent. This reflow
|
||||
// input is not used to reflow the parent, but just as a parent for the
|
||||
// frame's own reflow input. So given a nsBoxFrame inside some non-XUL
|
||||
// (like a text control, for example), we'll end up creating a reflow
|
||||
// input for the parent while the parent is reflowing.
|
||||
|
||||
// It'd be nice to assert that |frame| is not in reflow, but this fails
|
||||
// because viewport frames reset the computed isize on a copy of their reflow
|
||||
// input when reflowing fixed-pos kids. In that case we actually don't want
|
||||
// to mess with the resize flags, because comparing the frame's rect to the
|
||||
// munged computed isize is pointless.
|
||||
NS_WARNING_ASSERTION(aComputedISize >= 0, "Invalid computed inline-size!");
|
||||
if (ComputedISize() != aComputedISize) {
|
||||
mComputedSize.ISize(mWritingMode) = std::max(0, aComputedISize);
|
||||
@ -340,18 +332,7 @@ void ReflowInput::SetComputedISize(nscoord aComputedISize,
|
||||
void ReflowInput::SetComputedBSize(nscoord aComputedBSize,
|
||||
ResetResizeFlags aFlags) {
|
||||
// It'd be nice to assert that |frame| is not in reflow, but this fails
|
||||
// for two reasons:
|
||||
//
|
||||
// 1) Viewport frames reset the computed block size on a copy of their reflow
|
||||
// input when reflowing fixed-pos kids. In that case we actually don't want
|
||||
// to mess with the resize flags, because comparing the frame's rect to the
|
||||
// munged computed bsize is pointless.
|
||||
// 2) nsIFrame::BoxReflow creates a reflow input for its parent. This reflow
|
||||
// input is not used to reflow the parent, but just as a parent for the
|
||||
// frame's own reflow input. So given a nsBoxFrame inside some non-XUL
|
||||
// (like a text control, for example), we'll end up creating a reflow
|
||||
// input for the parent while the parent is reflowing.
|
||||
|
||||
// for the same reason as above.
|
||||
NS_WARNING_ASSERTION(aComputedBSize >= 0, "Invalid computed block-size!");
|
||||
if (ComputedBSize() != aComputedBSize) {
|
||||
mComputedSize.BSize(mWritingMode) = std::max(0, aComputedBSize);
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "nsFrameState.h"
|
||||
|
||||
#include "nsBlockFrame.h"
|
||||
#include "nsBoxFrame.h"
|
||||
#include "nsFlexContainerFrame.h"
|
||||
#include "nsGridContainerFrame.h"
|
||||
#include "nsGfxScrollFrame.h"
|
||||
|
@ -313,16 +313,6 @@ FRAME_STATE_BIT(Generic, 59, NS_FRAME_IS_IN_SINGLE_CHAR_MI)
|
||||
// adjusting logic, or moving infrequently-used bits elsewhere. If more space
|
||||
// for frame state is still needed, look for bit field gaps in nsIFrame.
|
||||
|
||||
// == Frame state bits that apply to box frames ===============================
|
||||
|
||||
FRAME_STATE_GROUP(Box, nsBoxFrame)
|
||||
|
||||
FRAME_STATE_BIT(Box, 20, NS_STATE_BOX_CHILD_RESERVED)
|
||||
FRAME_STATE_BIT(Box, 22, NS_STATE_IS_HORIZONTAL)
|
||||
FRAME_STATE_BIT(Box, 23, NS_STATE_AUTO_STRETCH)
|
||||
FRAME_STATE_BIT(Box, 24, NS_STATE_MENU_HAS_POPUP_LIST)
|
||||
FRAME_STATE_BIT(Box, 25, NS_STATE_IS_DIRECTION_NORMAL)
|
||||
|
||||
// == Frame state bits that apply to flex container frames ====================
|
||||
|
||||
FRAME_STATE_GROUP(FlexContainer, nsFlexContainerFrame)
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsIAnonymousContentCreator.h"
|
||||
#include "nsBoxFrame.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsIScrollbarMediator.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
|
@ -4247,7 +4247,6 @@ void nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
|
||||
}
|
||||
|
||||
const nsStyleDisplay* ourDisp = StyleDisplay();
|
||||
// REVIEW: Taken from nsBoxFrame::Paint
|
||||
// Don't paint our children if the theme object is a leaf.
|
||||
if (IsThemed(ourDisp) && !PresContext()->Theme()->WidgetIsContainer(
|
||||
ourDisp->EffectiveAppearance())) {
|
||||
|
@ -4327,13 +4327,6 @@ class nsIFrame : public nsQueryFrame {
|
||||
virtual Valignment GetXULVAlign() const { return vAlign_Top; }
|
||||
virtual Halignment GetXULHAlign() const { return hAlign_Left; }
|
||||
|
||||
bool IsXULHorizontal() const {
|
||||
return (mState & NS_STATE_IS_HORIZONTAL) != 0;
|
||||
}
|
||||
bool IsXULNormalDirection() const {
|
||||
return (mState & NS_STATE_IS_DIRECTION_NORMAL) != 0;
|
||||
}
|
||||
|
||||
nsresult XULRedraw(nsBoxLayoutState& aState);
|
||||
|
||||
static bool AddXULPrefSize(nsIFrame* aBox, nsSize& aSize, bool& aWidth,
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "nsPresContext.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsBoxLayoutState.h"
|
||||
#include "nsBoxFrame.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "nsImageFrame.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
|
@ -55,7 +55,6 @@
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
|
||||
#include "imgIContainer.h"
|
||||
#include "nsBoxFrame.h"
|
||||
#include "nsImageFrame.h"
|
||||
#include "nsSubDocumentFrame.h"
|
||||
#include "nsViewManager.h"
|
||||
|
@ -20,8 +20,6 @@ EXPORTS += [
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
"nsBox.cpp",
|
||||
"nsBoxFrame.cpp",
|
||||
"nsBoxLayout.cpp",
|
||||
"nsBoxLayoutState.cpp",
|
||||
"nsLeafBoxFrame.cpp",
|
||||
"nsMenuPopupFrame.cpp",
|
||||
@ -30,7 +28,6 @@ UNIFIED_SOURCES += [
|
||||
"nsScrollbarFrame.cpp",
|
||||
"nsSliderFrame.cpp",
|
||||
"nsSplitterFrame.cpp",
|
||||
"nsSprocketLayout.cpp",
|
||||
"nsTextBoxFrame.cpp",
|
||||
"nsXULPopupManager.cpp",
|
||||
"nsXULTooltipListener.cpp",
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "nsIFrame.h"
|
||||
|
||||
#include "nsBoxLayoutState.h"
|
||||
#include "nsBoxFrame.h"
|
||||
#include "nsDOMAttributeMap.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsCOMPtr.h"
|
||||
@ -18,7 +17,6 @@
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsITheme.h"
|
||||
#include "nsBoxLayout.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "mozilla/dom/Attr.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
@ -1,861 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
//
|
||||
// Eric Vaughan
|
||||
// Netscape Communications
|
||||
//
|
||||
// See documentation in associated header file
|
||||
//
|
||||
|
||||
// How boxes layout
|
||||
// ----------------
|
||||
// Boxes layout a bit differently than html. html does a bottom up layout. Where
|
||||
// boxes do a top down.
|
||||
//
|
||||
// 1) First thing a box does it goes out and askes each child for its min, max,
|
||||
// and preferred sizes.
|
||||
//
|
||||
// 2) It then adds them up to determine its size.
|
||||
//
|
||||
// 3) If the box was asked to layout it self intrinically it will layout its
|
||||
// children at their preferred size otherwise it will layout the child at
|
||||
// the size it was told to. It will squeeze or stretch its children if
|
||||
// Necessary.
|
||||
//
|
||||
// However there is a catch. Some html components like block frames can not
|
||||
// determine their preferred size. this is their size if they were laid out
|
||||
// intrinsically. So the box will flow the child to determine this can cache the
|
||||
// value.
|
||||
|
||||
// Boxes and Incremental Reflow
|
||||
// ----------------------------
|
||||
// Boxes layout out top down by adding up their children's min, max, and
|
||||
// preferred sizes. Only problem is if a incremental reflow occurs. The
|
||||
// preferred size of a child deep in the hierarchy could change. And this could
|
||||
// change any number of syblings around the box. Basically any children in the
|
||||
// reflow chain must have their caches cleared so when asked for there current
|
||||
// size they can relayout themselves.
|
||||
|
||||
#include "nsBoxFrame.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "gfxUtils.h"
|
||||
#include "mozilla/ComputedStyle.h"
|
||||
#include "mozilla/CSSOrderAwareFrameIterator.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/dom/Touch.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "nsBoxLayout.h"
|
||||
#include "nsBoxLayoutState.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCSSAnonBoxes.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrameInlines.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsITheme.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "nsPlaceholderFrame.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsSliderFrame.h"
|
||||
#include "nsSprocketLayout.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsTransform2D.h"
|
||||
#include "nsView.h"
|
||||
#include "nsViewManager.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
// Needed for Print Preview
|
||||
|
||||
#include "mozilla/TouchEvents.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
nsContainerFrame* NS_NewBoxFrame(PresShell* aPresShell, ComputedStyle* aStyle) {
|
||||
return new (aPresShell) nsBoxFrame(aStyle, aPresShell->GetPresContext());
|
||||
}
|
||||
|
||||
NS_IMPL_FRAMEARENA_HELPERS(nsBoxFrame)
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_QUERYFRAME_HEAD(nsBoxFrame)
|
||||
NS_QUERYFRAME_ENTRY(nsBoxFrame)
|
||||
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
||||
#endif
|
||||
|
||||
nsBoxFrame::nsBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
|
||||
ClassID aID)
|
||||
: nsContainerFrame(aStyle, aPresContext, aID), mAscent(0) {
|
||||
AddStateBits(NS_STATE_IS_HORIZONTAL | NS_STATE_AUTO_STRETCH);
|
||||
|
||||
mValign = vAlign_Top;
|
||||
mHalign = hAlign_Left;
|
||||
|
||||
// Use the static sprocket layout
|
||||
nsCOMPtr<nsBoxLayout> layout;
|
||||
NS_NewSprocketLayout(layout);
|
||||
SetXULLayoutManager(layout);
|
||||
}
|
||||
|
||||
nsBoxFrame::~nsBoxFrame() = default;
|
||||
|
||||
void nsBoxFrame::SetInitialChildList(ChildListID aListID,
|
||||
nsFrameList&& aChildList) {
|
||||
nsContainerFrame::SetInitialChildList(aListID, std::move(aChildList));
|
||||
if (aListID == FrameChildListID::Principal) {
|
||||
// initialize our list of infos.
|
||||
nsBoxLayoutState state(PresContext());
|
||||
if (mLayoutManager)
|
||||
mLayoutManager->ChildrenSet(this, state, mFrames.FirstChild());
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */
|
||||
void nsBoxFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) {
|
||||
nsContainerFrame::DidSetComputedStyle(aOldComputedStyle);
|
||||
|
||||
// The values that CacheAttributes() computes depend on our style,
|
||||
// so we need to recompute them here...
|
||||
CacheAttributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize us. This is a good time to get the alignment of the box
|
||||
*/
|
||||
void nsBoxFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
||||
nsIFrame* aPrevInFlow) {
|
||||
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
||||
|
||||
if (HasAnyStateBits(NS_FRAME_FONT_INFLATION_CONTAINER)) {
|
||||
AddStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT);
|
||||
}
|
||||
|
||||
MarkIntrinsicISizesDirty();
|
||||
|
||||
CacheAttributes();
|
||||
}
|
||||
|
||||
void nsBoxFrame::CacheAttributes() {
|
||||
/*
|
||||
printf("Caching: ");
|
||||
XULDumpBox(stdout);
|
||||
printf("\n");
|
||||
*/
|
||||
|
||||
mValign = vAlign_Top;
|
||||
mHalign = hAlign_Left;
|
||||
|
||||
bool orient = false;
|
||||
GetInitialOrientation(orient);
|
||||
if (orient)
|
||||
AddStateBits(NS_STATE_IS_HORIZONTAL);
|
||||
else
|
||||
RemoveStateBits(NS_STATE_IS_HORIZONTAL);
|
||||
|
||||
bool normal = true;
|
||||
GetInitialDirection(normal);
|
||||
if (normal)
|
||||
AddStateBits(NS_STATE_IS_DIRECTION_NORMAL);
|
||||
else
|
||||
RemoveStateBits(NS_STATE_IS_DIRECTION_NORMAL);
|
||||
|
||||
GetInitialVAlignment(mValign);
|
||||
GetInitialHAlignment(mHalign);
|
||||
|
||||
bool autostretch = HasAnyStateBits(NS_STATE_AUTO_STRETCH);
|
||||
GetInitialAutoStretch(autostretch);
|
||||
if (autostretch)
|
||||
AddStateBits(NS_STATE_AUTO_STRETCH);
|
||||
else
|
||||
RemoveStateBits(NS_STATE_AUTO_STRETCH);
|
||||
}
|
||||
|
||||
bool nsBoxFrame::GetInitialHAlignment(nsBoxFrame::Halignment& aHalign) {
|
||||
if (!GetContent()) return false;
|
||||
|
||||
// For horizontal boxes we're checking PACK. For vertical boxes we are
|
||||
// checking ALIGN.
|
||||
const nsStyleXUL* boxInfo = StyleXUL();
|
||||
if (IsXULHorizontal()) {
|
||||
switch (boxInfo->mBoxPack) {
|
||||
case StyleBoxPack::Start:
|
||||
aHalign = nsBoxFrame::hAlign_Left;
|
||||
return true;
|
||||
case StyleBoxPack::Center:
|
||||
aHalign = nsBoxFrame::hAlign_Center;
|
||||
return true;
|
||||
case StyleBoxPack::End:
|
||||
aHalign = nsBoxFrame::hAlign_Right;
|
||||
return true;
|
||||
default: // Nonsensical value. Just bail.
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
switch (boxInfo->mBoxAlign) {
|
||||
case StyleBoxAlign::Start:
|
||||
aHalign = nsBoxFrame::hAlign_Left;
|
||||
return true;
|
||||
case StyleBoxAlign::Center:
|
||||
aHalign = nsBoxFrame::hAlign_Center;
|
||||
return true;
|
||||
case StyleBoxAlign::End:
|
||||
aHalign = nsBoxFrame::hAlign_Right;
|
||||
return true;
|
||||
default: // Nonsensical value. Just bail.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool nsBoxFrame::GetInitialVAlignment(nsBoxFrame::Valignment& aValign) {
|
||||
if (!GetContent()) return false;
|
||||
// For horizontal boxes we're checking ALIGN. For vertical boxes we are
|
||||
// checking PACK.
|
||||
const nsStyleXUL* boxInfo = StyleXUL();
|
||||
if (IsXULHorizontal()) {
|
||||
switch (boxInfo->mBoxAlign) {
|
||||
case StyleBoxAlign::Start:
|
||||
aValign = nsBoxFrame::vAlign_Top;
|
||||
return true;
|
||||
case StyleBoxAlign::Center:
|
||||
aValign = nsBoxFrame::vAlign_Middle;
|
||||
return true;
|
||||
case StyleBoxAlign::Baseline:
|
||||
aValign = nsBoxFrame::vAlign_BaseLine;
|
||||
return true;
|
||||
case StyleBoxAlign::End:
|
||||
aValign = nsBoxFrame::vAlign_Bottom;
|
||||
return true;
|
||||
default: // Nonsensical value. Just bail.
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
switch (boxInfo->mBoxPack) {
|
||||
case StyleBoxPack::Start:
|
||||
aValign = nsBoxFrame::vAlign_Top;
|
||||
return true;
|
||||
case StyleBoxPack::Center:
|
||||
aValign = nsBoxFrame::vAlign_Middle;
|
||||
return true;
|
||||
case StyleBoxPack::End:
|
||||
aValign = nsBoxFrame::vAlign_Bottom;
|
||||
return true;
|
||||
default: // Nonsensical value. Just bail.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nsBoxFrame::GetInitialOrientation(bool& aIsHorizontal) {
|
||||
// see if we are a vertical or horizontal box.
|
||||
if (!GetContent()) return;
|
||||
|
||||
const nsStyleXUL* boxInfo = StyleXUL();
|
||||
if (boxInfo->mBoxOrient == StyleBoxOrient::Horizontal) {
|
||||
aIsHorizontal = true;
|
||||
} else {
|
||||
aIsHorizontal = false;
|
||||
}
|
||||
}
|
||||
|
||||
void nsBoxFrame::GetInitialDirection(bool& aIsNormal) {
|
||||
if (!GetContent()) return;
|
||||
|
||||
if (IsXULHorizontal()) {
|
||||
// For horizontal boxes only, we initialize our value based off the CSS
|
||||
// 'direction' property. This means that BiDI users will end up with
|
||||
// horizontally inverted chrome.
|
||||
//
|
||||
// If text runs RTL then so do we.
|
||||
aIsNormal = StyleVisibility()->mDirection == StyleDirection::Ltr;
|
||||
if (GetContent()->IsElement()) {
|
||||
Element* element = GetContent()->AsElement();
|
||||
|
||||
// Now see if we have an attribute. The attribute overrides
|
||||
// the style system 'direction' property.
|
||||
static Element::AttrValuesArray strings[] = {nsGkAtoms::ltr,
|
||||
nsGkAtoms::rtl, nullptr};
|
||||
int32_t index = element->FindAttrValueIn(
|
||||
kNameSpaceID_None, nsGkAtoms::dir, strings, eCaseMatters);
|
||||
if (index >= 0) {
|
||||
bool values[] = {true, false};
|
||||
aIsNormal = values[index];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
aIsNormal = true; // Assume a normal direction in the vertical case.
|
||||
}
|
||||
|
||||
// Now check the style system to see if we should invert aIsNormal.
|
||||
const nsStyleXUL* boxInfo = StyleXUL();
|
||||
if (boxInfo->mBoxDirection == StyleBoxDirection::Reverse) {
|
||||
aIsNormal = !aIsNormal; // Invert our direction.
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns true if it was set.
|
||||
*/
|
||||
bool nsBoxFrame::GetInitialAutoStretch(bool& aStretch) {
|
||||
if (!GetContent()) return false;
|
||||
|
||||
// Check the CSS box-align property.
|
||||
const nsStyleXUL* boxInfo = StyleXUL();
|
||||
aStretch = (boxInfo->mBoxAlign == StyleBoxAlign::Stretch);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void nsBoxFrame::DidReflow(nsPresContext* aPresContext,
|
||||
const ReflowInput* aReflowInput) {
|
||||
nsFrameState preserveBits =
|
||||
GetStateBits() & (NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN);
|
||||
nsIFrame::DidReflow(aPresContext, aReflowInput);
|
||||
AddStateBits(preserveBits);
|
||||
if (preserveBits & NS_FRAME_IS_DIRTY) {
|
||||
this->MarkSubtreeDirty();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DO_NOISY_REFLOW
|
||||
static int myCounter = 0;
|
||||
static void printSize(char* aDesc, nscoord aSize) {
|
||||
printf(" %s: ", aDesc);
|
||||
if (aSize == NS_UNCONSTRAINEDSIZE) {
|
||||
printf("UC");
|
||||
} else {
|
||||
printf("%d", aSize);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* virtual */
|
||||
nscoord nsBoxFrame::GetMinISize(gfxContext* aRenderingContext) {
|
||||
nscoord result;
|
||||
DISPLAY_MIN_INLINE_SIZE(this, result);
|
||||
|
||||
nsBoxLayoutState state(PresContext(), aRenderingContext);
|
||||
nsSize minSize = GetXULMinSize(state);
|
||||
|
||||
// GetXULMinSize returns border-box width, and we want to return content
|
||||
// width. Since Reflow uses the reflow input's border and padding, we
|
||||
// actually just want to subtract what GetXULMinSize added, which is the
|
||||
// result of GetXULBorderAndPadding.
|
||||
nsMargin bp;
|
||||
GetXULBorderAndPadding(bp);
|
||||
|
||||
result = minSize.width - bp.LeftRight();
|
||||
result = std::max(result, 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* virtual */
|
||||
nscoord nsBoxFrame::GetPrefISize(gfxContext* aRenderingContext) {
|
||||
nscoord result;
|
||||
DISPLAY_PREF_INLINE_SIZE(this, result);
|
||||
|
||||
nsBoxLayoutState state(PresContext(), aRenderingContext);
|
||||
nsSize prefSize = GetXULPrefSize(state);
|
||||
|
||||
// GetXULPrefSize returns border-box width, and we want to return content
|
||||
// width. Since Reflow uses the reflow input's border and padding, we
|
||||
// actually just want to subtract what GetXULPrefSize added, which is the
|
||||
// result of GetXULBorderAndPadding.
|
||||
nsMargin bp;
|
||||
GetXULBorderAndPadding(bp);
|
||||
|
||||
result = prefSize.width - bp.LeftRight();
|
||||
result = std::max(result, 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void nsBoxFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
|
||||
const ReflowInput& aReflowInput,
|
||||
nsReflowStatus& aStatus) {
|
||||
MarkInReflow();
|
||||
// If you make changes to this method, please keep nsLeafBoxFrame::Reflow
|
||||
// in sync, if the changes are applicable there.
|
||||
|
||||
DO_GLOBAL_REFLOW_COUNT("nsBoxFrame");
|
||||
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
||||
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
|
||||
|
||||
NS_ASSERTION(
|
||||
aReflowInput.ComputedWidth() >= 0 && aReflowInput.ComputedHeight() >= 0,
|
||||
"Computed Size < 0");
|
||||
|
||||
#ifdef DO_NOISY_REFLOW
|
||||
printf(
|
||||
"\n-------------Starting BoxFrame Reflow ----------------------------\n");
|
||||
printf("%p ** nsBF::Reflow %d ", this, myCounter++);
|
||||
|
||||
printSize("AW", aReflowInput.AvailableWidth());
|
||||
printSize("AH", aReflowInput.AvailableHeight());
|
||||
printSize("CW", aReflowInput.ComputedWidth());
|
||||
printSize("CH", aReflowInput.ComputedHeight());
|
||||
|
||||
printf(" *\n");
|
||||
|
||||
#endif
|
||||
|
||||
// create the layout state
|
||||
nsBoxLayoutState state(aPresContext, aReflowInput.mRenderingContext,
|
||||
&aReflowInput, aReflowInput.mReflowDepth);
|
||||
|
||||
WritingMode wm = aReflowInput.GetWritingMode();
|
||||
LogicalSize computedSize = aReflowInput.ComputedSize();
|
||||
|
||||
LogicalMargin m = aReflowInput.ComputedLogicalBorderPadding(wm);
|
||||
// GetXULBorderAndPadding(m);
|
||||
|
||||
LogicalSize prefSize(wm);
|
||||
|
||||
// if we are told to layout intrinsic then get our preferred size.
|
||||
NS_ASSERTION(computedSize.ISize(wm) != NS_UNCONSTRAINEDSIZE,
|
||||
"computed inline size should always be computed");
|
||||
if (computedSize.BSize(wm) == NS_UNCONSTRAINEDSIZE) {
|
||||
nsSize physicalPrefSize = GetXULPrefSize(state);
|
||||
nsSize minSize = GetXULMinSize(state);
|
||||
nsSize maxSize = GetXULMaxSize(state);
|
||||
// XXXbz isn't GetXULPrefSize supposed to bounds-check for us?
|
||||
physicalPrefSize = XULBoundsCheck(minSize, physicalPrefSize, maxSize);
|
||||
prefSize = LogicalSize(wm, physicalPrefSize);
|
||||
}
|
||||
|
||||
// get our desiredSize
|
||||
computedSize.ISize(wm) += m.IStart(wm) + m.IEnd(wm);
|
||||
|
||||
if (aReflowInput.ComputedBSize() == NS_UNCONSTRAINEDSIZE) {
|
||||
computedSize.BSize(wm) = prefSize.BSize(wm);
|
||||
// prefSize is border-box but min/max constraints are content-box.
|
||||
nscoord blockDirBorderPadding =
|
||||
aReflowInput.ComputedLogicalBorderPadding(wm).BStartEnd(wm);
|
||||
nscoord contentBSize = computedSize.BSize(wm) - blockDirBorderPadding;
|
||||
// Note: contentHeight might be negative, but that's OK because min-height
|
||||
// is never negative.
|
||||
computedSize.BSize(wm) =
|
||||
aReflowInput.ApplyMinMaxHeight(contentBSize) + blockDirBorderPadding;
|
||||
} else {
|
||||
computedSize.BSize(wm) += m.BStart(wm) + m.BEnd(wm);
|
||||
}
|
||||
|
||||
nsSize physicalSize = computedSize.GetPhysicalSize(wm);
|
||||
nsRect r(mRect.x, mRect.y, physicalSize.width, physicalSize.height);
|
||||
|
||||
SetXULBounds(state, r);
|
||||
|
||||
// layout our children
|
||||
XULLayout(state);
|
||||
|
||||
// ok our child could have gotten bigger. So lets get its bounds
|
||||
|
||||
// get the ascent
|
||||
LogicalSize boxSize = GetLogicalSize(wm);
|
||||
nscoord ascent = boxSize.BSize(wm);
|
||||
|
||||
// getting the ascent could be a lot of work. Don't get it if
|
||||
// we are the root. The viewport doesn't care about it.
|
||||
if (!Style()->IsRootElementStyle()) {
|
||||
ascent = GetXULBoxAscent(state);
|
||||
}
|
||||
|
||||
aDesiredSize.SetSize(wm, boxSize);
|
||||
aDesiredSize.SetBlockStartAscent(ascent);
|
||||
|
||||
aDesiredSize.mOverflowAreas = GetOverflowAreas();
|
||||
|
||||
#ifdef DO_NOISY_REFLOW
|
||||
{
|
||||
printf("%p ** nsBF(done) W:%d H:%d ", this, aDesiredSize.Width(),
|
||||
aDesiredSize.Height());
|
||||
|
||||
if (maxElementSize) {
|
||||
printf("MW:%d\n", *maxElementWidth);
|
||||
} else {
|
||||
printf("MW:?\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ReflowAbsoluteFrames(aPresContext, aDesiredSize, aReflowInput, aStatus);
|
||||
}
|
||||
|
||||
nsSize nsBoxFrame::GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) {
|
||||
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
||||
"must have rendering context");
|
||||
|
||||
nsSize size(0, 0);
|
||||
DISPLAY_PREF_SIZE(this, size);
|
||||
if (!XULNeedsRecalc(mPrefSize)) {
|
||||
size = mPrefSize;
|
||||
return size;
|
||||
}
|
||||
|
||||
if (IsXULCollapsed()) return size;
|
||||
|
||||
// if the size was not completely redefined in CSS then ask our children
|
||||
bool widthSet, heightSet;
|
||||
if (!nsIFrame::AddXULPrefSize(this, size, widthSet, heightSet)) {
|
||||
if (mLayoutManager) {
|
||||
nsSize layoutSize = mLayoutManager->GetXULPrefSize(this, aBoxLayoutState);
|
||||
if (!widthSet) size.width = layoutSize.width;
|
||||
if (!heightSet) size.height = layoutSize.height;
|
||||
} else {
|
||||
size = nsIFrame::GetUncachedXULPrefSize(aBoxLayoutState);
|
||||
}
|
||||
}
|
||||
|
||||
nsSize minSize = GetXULMinSize(aBoxLayoutState);
|
||||
nsSize maxSize = GetXULMaxSize(aBoxLayoutState);
|
||||
mPrefSize = XULBoundsCheck(minSize, size, maxSize);
|
||||
|
||||
return mPrefSize;
|
||||
}
|
||||
|
||||
nscoord nsBoxFrame::GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) {
|
||||
if (!XULNeedsRecalc(mAscent)) {
|
||||
return mAscent;
|
||||
}
|
||||
|
||||
if (IsXULCollapsed()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mLayoutManager) {
|
||||
mAscent = mLayoutManager->GetAscent(this, aBoxLayoutState);
|
||||
} else {
|
||||
mAscent = GetXULPrefSize(aBoxLayoutState).height;
|
||||
}
|
||||
|
||||
return mAscent;
|
||||
}
|
||||
|
||||
nsSize nsBoxFrame::GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) {
|
||||
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
||||
"must have rendering context");
|
||||
|
||||
nsSize size(0, 0);
|
||||
DISPLAY_MIN_SIZE(this, size);
|
||||
if (!XULNeedsRecalc(mMinSize)) {
|
||||
size = mMinSize;
|
||||
return size;
|
||||
}
|
||||
|
||||
if (IsXULCollapsed()) return size;
|
||||
|
||||
// if the size was not completely redefined in CSS then ask our children
|
||||
bool widthSet, heightSet;
|
||||
if (!nsIFrame::AddXULMinSize(this, size, widthSet, heightSet)) {
|
||||
if (mLayoutManager) {
|
||||
nsSize layoutSize = mLayoutManager->GetXULMinSize(this, aBoxLayoutState);
|
||||
if (!widthSet) size.width = layoutSize.width;
|
||||
if (!heightSet) size.height = layoutSize.height;
|
||||
} else {
|
||||
size = nsIFrame::GetUncachedXULMinSize(aBoxLayoutState);
|
||||
}
|
||||
}
|
||||
|
||||
mMinSize = size;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
nsSize nsBoxFrame::GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState) {
|
||||
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
||||
"must have rendering context");
|
||||
|
||||
nsSize size(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
||||
DISPLAY_MAX_SIZE(this, size);
|
||||
if (!XULNeedsRecalc(mMaxSize)) {
|
||||
size = mMaxSize;
|
||||
return size;
|
||||
}
|
||||
|
||||
if (IsXULCollapsed()) return size;
|
||||
|
||||
// if the size was not completely redefined in CSS then ask our children
|
||||
bool widthSet, heightSet;
|
||||
if (!nsIFrame::AddXULMaxSize(this, size, widthSet, heightSet)) {
|
||||
if (mLayoutManager) {
|
||||
nsSize layoutSize = mLayoutManager->GetXULMaxSize(this, aBoxLayoutState);
|
||||
if (!widthSet) size.width = layoutSize.width;
|
||||
if (!heightSet) size.height = layoutSize.height;
|
||||
} else {
|
||||
size = nsIFrame::GetUncachedXULMaxSize(aBoxLayoutState);
|
||||
}
|
||||
}
|
||||
|
||||
mMaxSize = size;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* If subclassing please subclass this method not layout.
|
||||
* layout will call this method.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsBoxFrame::DoXULLayout(nsBoxLayoutState& aState) {
|
||||
ReflowChildFlags oldFlags = aState.LayoutFlags();
|
||||
aState.SetLayoutFlags(ReflowChildFlags::Default);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (mLayoutManager) {
|
||||
XULCoordNeedsRecalc(mAscent);
|
||||
rv = mLayoutManager->XULLayout(this, aState);
|
||||
}
|
||||
|
||||
aState.SetLayoutFlags(oldFlags);
|
||||
|
||||
if (HasAbsolutelyPositionedChildren()) {
|
||||
// Set up a |reflowInput| to pass into ReflowAbsoluteFrames
|
||||
WritingMode wm = GetWritingMode();
|
||||
ReflowInput reflowInput(
|
||||
aState.PresContext(), this, aState.GetRenderingContext(),
|
||||
LogicalSize(wm, GetLogicalSize().ISize(wm), NS_UNCONSTRAINEDSIZE));
|
||||
|
||||
// Set up a |desiredSize| to pass into ReflowAbsoluteFrames
|
||||
ReflowOutput desiredSize(reflowInput);
|
||||
desiredSize.Width() = mRect.width;
|
||||
desiredSize.Height() = mRect.height;
|
||||
|
||||
// get the ascent (cribbed from ::Reflow)
|
||||
nscoord ascent = mRect.height;
|
||||
|
||||
// getting the ascent could be a lot of work. Don't get it if
|
||||
// we are the root. The viewport doesn't care about it.
|
||||
if (!Style()->IsRootElementStyle()) {
|
||||
ascent = GetXULBoxAscent(aState);
|
||||
}
|
||||
desiredSize.SetBlockStartAscent(ascent);
|
||||
desiredSize.mOverflowAreas = GetOverflowAreas();
|
||||
|
||||
AddStateBits(NS_FRAME_IN_REFLOW);
|
||||
// Set up a |reflowStatus| to pass into ReflowAbsoluteFrames
|
||||
// (just a dummy value; hopefully that's OK)
|
||||
nsReflowStatus reflowStatus;
|
||||
ReflowAbsoluteFrames(aState.PresContext(), desiredSize, reflowInput,
|
||||
reflowStatus);
|
||||
RemoveStateBits(NS_FRAME_IN_REFLOW);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void nsBoxFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
||||
PostDestroyData& aPostDestroyData) {
|
||||
// clean up the container box's layout manager and child boxes
|
||||
SetXULLayoutManager(nullptr);
|
||||
|
||||
nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
|
||||
}
|
||||
|
||||
/* virtual */
|
||||
void nsBoxFrame::MarkIntrinsicISizesDirty() {
|
||||
XULSizeNeedsRecalc(mPrefSize);
|
||||
XULSizeNeedsRecalc(mMinSize);
|
||||
XULSizeNeedsRecalc(mMaxSize);
|
||||
XULCoordNeedsRecalc(mAscent);
|
||||
|
||||
if (mLayoutManager) {
|
||||
nsBoxLayoutState state(PresContext());
|
||||
mLayoutManager->IntrinsicISizesDirty(this, state);
|
||||
}
|
||||
|
||||
nsContainerFrame::MarkIntrinsicISizesDirty();
|
||||
}
|
||||
|
||||
void nsBoxFrame::RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) {
|
||||
MOZ_ASSERT(aListID == FrameChildListID::Principal,
|
||||
"We don't support out-of-flow kids");
|
||||
|
||||
nsPresContext* presContext = PresContext();
|
||||
nsBoxLayoutState state(presContext);
|
||||
|
||||
// remove the child frame
|
||||
mFrames.RemoveFrame(aOldFrame);
|
||||
|
||||
// notify the layout manager
|
||||
if (mLayoutManager) mLayoutManager->ChildrenRemoved(this, state, aOldFrame);
|
||||
|
||||
// destroy the child frame
|
||||
aOldFrame->Destroy();
|
||||
|
||||
// mark us dirty and generate a reflow command
|
||||
PresShell()->FrameNeedsReflow(this, IntrinsicDirty::FrameAndAncestors,
|
||||
NS_FRAME_HAS_DIRTY_CHILDREN);
|
||||
}
|
||||
|
||||
void nsBoxFrame::InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
|
||||
const nsLineList::iterator* aPrevFrameLine,
|
||||
nsFrameList&& aFrameList) {
|
||||
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
||||
"inserting after sibling frame with different parent");
|
||||
NS_ASSERTION(!aPrevFrame || mFrames.ContainsFrame(aPrevFrame),
|
||||
"inserting after sibling frame not in our child list");
|
||||
MOZ_ASSERT(aListID == FrameChildListID::Principal,
|
||||
"We don't support out-of-flow kids");
|
||||
|
||||
nsBoxLayoutState state(PresContext());
|
||||
|
||||
// insert the child frames
|
||||
const nsFrameList::Slice& newFrames =
|
||||
mFrames.InsertFrames(this, aPrevFrame, std::move(aFrameList));
|
||||
|
||||
// notify the layout manager
|
||||
if (mLayoutManager)
|
||||
mLayoutManager->ChildrenInserted(this, state, aPrevFrame, newFrames);
|
||||
|
||||
PresShell()->FrameNeedsReflow(this, IntrinsicDirty::FrameAndAncestors,
|
||||
NS_FRAME_HAS_DIRTY_CHILDREN);
|
||||
}
|
||||
|
||||
void nsBoxFrame::AppendFrames(ChildListID aListID, nsFrameList&& aFrameList) {
|
||||
MOZ_ASSERT(aListID == FrameChildListID::Principal,
|
||||
"We don't support out-of-flow kids");
|
||||
|
||||
nsBoxLayoutState state(PresContext());
|
||||
|
||||
// append the new frames
|
||||
const nsFrameList::Slice& newFrames =
|
||||
mFrames.AppendFrames(this, std::move(aFrameList));
|
||||
|
||||
// notify the layout manager
|
||||
if (mLayoutManager) mLayoutManager->ChildrenAppended(this, state, newFrames);
|
||||
|
||||
// XXXbz why is this NS_FRAME_FIRST_REFLOW check here?
|
||||
if (!HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) {
|
||||
PresShell()->FrameNeedsReflow(this, IntrinsicDirty::FrameAndAncestors,
|
||||
NS_FRAME_HAS_DIRTY_CHILDREN);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsBoxFrame::AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
|
||||
int32_t aModType) {
|
||||
nsresult rv =
|
||||
nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
||||
|
||||
// Ignore 'width', 'height', 'screenX', 'screenY' and 'sizemode' on a
|
||||
// <window>.
|
||||
if (mContent->IsXULElement(nsGkAtoms::window) &&
|
||||
(nsGkAtoms::width == aAttribute || nsGkAtoms::height == aAttribute ||
|
||||
nsGkAtoms::screenX == aAttribute || nsGkAtoms::screenY == aAttribute ||
|
||||
nsGkAtoms::sizemode == aAttribute)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height ||
|
||||
aAttribute == nsGkAtoms::align || aAttribute == nsGkAtoms::valign ||
|
||||
aAttribute == nsGkAtoms::minwidth || aAttribute == nsGkAtoms::maxwidth ||
|
||||
aAttribute == nsGkAtoms::minheight ||
|
||||
aAttribute == nsGkAtoms::maxheight || aAttribute == nsGkAtoms::orient ||
|
||||
aAttribute == nsGkAtoms::pack || aAttribute == nsGkAtoms::dir) {
|
||||
if (aAttribute == nsGkAtoms::align || aAttribute == nsGkAtoms::valign ||
|
||||
aAttribute == nsGkAtoms::orient || aAttribute == nsGkAtoms::pack ||
|
||||
aAttribute == nsGkAtoms::dir) {
|
||||
mValign = nsBoxFrame::vAlign_Top;
|
||||
mHalign = nsBoxFrame::hAlign_Left;
|
||||
|
||||
bool orient = true;
|
||||
GetInitialOrientation(orient);
|
||||
if (orient)
|
||||
AddStateBits(NS_STATE_IS_HORIZONTAL);
|
||||
else
|
||||
RemoveStateBits(NS_STATE_IS_HORIZONTAL);
|
||||
|
||||
bool normal = true;
|
||||
GetInitialDirection(normal);
|
||||
if (normal)
|
||||
AddStateBits(NS_STATE_IS_DIRECTION_NORMAL);
|
||||
else
|
||||
RemoveStateBits(NS_STATE_IS_DIRECTION_NORMAL);
|
||||
|
||||
GetInitialVAlignment(mValign);
|
||||
GetInitialHAlignment(mHalign);
|
||||
|
||||
bool autostretch = HasAnyStateBits(NS_STATE_AUTO_STRETCH);
|
||||
GetInitialAutoStretch(autostretch);
|
||||
if (autostretch)
|
||||
AddStateBits(NS_STATE_AUTO_STRETCH);
|
||||
else
|
||||
RemoveStateBits(NS_STATE_AUTO_STRETCH);
|
||||
}
|
||||
|
||||
PresShell()->FrameNeedsReflow(
|
||||
this, IntrinsicDirty::FrameAncestorsAndDescendants, NS_FRAME_IS_DIRTY);
|
||||
} else if (aAttribute == nsGkAtoms::rows &&
|
||||
mContent->IsXULElement(nsGkAtoms::tree)) {
|
||||
// Reflow ourselves and all our children if "rows" changes, since
|
||||
// nsTreeBodyFrame's layout reads this from its parent (this frame).
|
||||
PresShell()->FrameNeedsReflow(
|
||||
this, IntrinsicDirty::FrameAncestorsAndDescendants, NS_FRAME_IS_DIRTY);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists) {
|
||||
nsDisplayListCollection tempLists(aBuilder);
|
||||
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
||||
|
||||
BuildDisplayListForChildren(aBuilder, aLists);
|
||||
|
||||
// see if we have to draw a selection frame around this container
|
||||
DisplaySelectionOverlay(aBuilder, aLists.Content());
|
||||
}
|
||||
|
||||
void nsBoxFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists) {
|
||||
// Iterate over the children in CSS order.
|
||||
auto iter = CSSOrderAwareFrameIterator(
|
||||
this, FrameChildListID::Principal,
|
||||
CSSOrderAwareFrameIterator::ChildFilter::IncludeAll,
|
||||
CSSOrderAwareFrameIterator::OrderState::Unknown,
|
||||
CSSOrderAwareFrameIterator::OrderingProperty::BoxOrdinalGroup);
|
||||
// Put each child's background onto the BlockBorderBackgrounds list
|
||||
// to emulate the existing two-layer XUL painting scheme.
|
||||
nsDisplayListSet set(aLists, aLists.BlockBorderBackgrounds());
|
||||
for (; !iter.AtEnd(); iter.Next()) {
|
||||
BuildDisplayListForChild(aBuilder, iter.get(), set);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_FRAME_DUMP
|
||||
nsresult nsBoxFrame::GetFrameName(nsAString& aResult) const {
|
||||
return MakeFrameName(u"Box"_ns, aResult);
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult nsBoxFrame::LayoutChildAt(nsBoxLayoutState& aState, nsIFrame* aBox,
|
||||
const nsRect& aRect) {
|
||||
// get the current rect
|
||||
nsRect oldRect(aBox->GetRect());
|
||||
aBox->SetXULBounds(aState, aRect);
|
||||
|
||||
bool layout = aBox->IsSubtreeDirty();
|
||||
|
||||
if (layout ||
|
||||
(oldRect.width != aRect.width || oldRect.height != aRect.height)) {
|
||||
return aBox->XULLayout(aState);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
@ -1,162 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
/**
|
||||
|
||||
Eric D Vaughan
|
||||
nsBoxFrame is a frame that can lay its children out either vertically or
|
||||
horizontally. It lays them out according to a min max or preferred size.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef nsBoxFrame_h___
|
||||
#define nsBoxFrame_h___
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsBoxLayout.h"
|
||||
|
||||
class nsBoxLayoutState;
|
||||
|
||||
namespace mozilla {
|
||||
class PresShell;
|
||||
namespace gfx {
|
||||
class DrawTarget;
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
||||
nsContainerFrame* NS_NewBoxFrame(mozilla::PresShell* aPresShell,
|
||||
mozilla::ComputedStyle* aStyle);
|
||||
|
||||
class nsBoxFrame : public nsContainerFrame {
|
||||
protected:
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
|
||||
public:
|
||||
NS_DECL_FRAMEARENA_HELPERS(nsBoxFrame)
|
||||
#ifdef DEBUG
|
||||
NS_DECL_QUERYFRAME
|
||||
#endif
|
||||
|
||||
friend nsContainerFrame* NS_NewBoxFrame(mozilla::PresShell* aPresShell,
|
||||
ComputedStyle* aStyle);
|
||||
|
||||
// gets the rect inside our border and debug border. If you wish to paint
|
||||
// inside a box call this method to get the rect so you don't draw on the
|
||||
// debug border or outer border.
|
||||
|
||||
virtual void SetXULLayoutManager(nsBoxLayout* aLayout) override {
|
||||
mLayoutManager = aLayout;
|
||||
}
|
||||
virtual nsBoxLayout* GetXULLayoutManager() override { return mLayoutManager; }
|
||||
|
||||
virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
|
||||
virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
|
||||
virtual nsSize GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState) override;
|
||||
virtual nscoord GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) override;
|
||||
virtual Valignment GetXULVAlign() const override { return mValign; }
|
||||
virtual Halignment GetXULHAlign() const override { return mHalign; }
|
||||
NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState) override;
|
||||
|
||||
virtual bool XULComputesOwnOverflowArea() override { return false; }
|
||||
|
||||
// ----- child and sibling operations ---
|
||||
|
||||
// ----- public methods -------
|
||||
|
||||
virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
|
||||
nsIFrame* aPrevInFlow) override;
|
||||
|
||||
virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
|
||||
int32_t aModType) override;
|
||||
|
||||
virtual void MarkIntrinsicISizesDirty() override;
|
||||
virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;
|
||||
virtual nscoord GetPrefISize(gfxContext* aRenderingContext) override;
|
||||
|
||||
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
|
||||
const ReflowInput& aReflowInput,
|
||||
nsReflowStatus& aStatus) override;
|
||||
|
||||
void SetInitialChildList(ChildListID aListID,
|
||||
nsFrameList&& aChildList) override;
|
||||
void AppendFrames(ChildListID aListID, nsFrameList&& aFrameList) override;
|
||||
void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
|
||||
const nsLineList::iterator* aPrevFrameLine,
|
||||
nsFrameList&& aFrameList) override;
|
||||
virtual void RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) override;
|
||||
|
||||
virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
|
||||
|
||||
virtual bool IsFrameOfType(uint32_t aFlags) const override {
|
||||
// record that children that are ignorable whitespace should be excluded
|
||||
// (When content was loaded via the XUL content sink, it's already
|
||||
// been excluded, but we need this for when the XUL namespace is used
|
||||
// in other MIME types or when the XUL CSS display types are used with
|
||||
// non-XUL elements.)
|
||||
|
||||
// This is bogus, but it's what we've always done.
|
||||
// (Given that we're replaced, we need to say we're a replaced element
|
||||
// that contains a block so ReflowInput doesn't tell us to be
|
||||
// NS_UNCONSTRAINEDSIZE wide.)
|
||||
return nsContainerFrame::IsFrameOfType(
|
||||
aFlags &
|
||||
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock | eXULBox));
|
||||
}
|
||||
|
||||
#ifdef DEBUG_FRAME_DUMP
|
||||
virtual nsresult GetFrameName(nsAString& aResult) const override;
|
||||
#endif
|
||||
|
||||
virtual void DidReflow(nsPresContext* aPresContext,
|
||||
const ReflowInput* aReflowInput) override;
|
||||
|
||||
// virtual so nsButtonBoxFrame, nsSliderFrame and nsMenuFrame
|
||||
// can override it
|
||||
virtual void BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists);
|
||||
|
||||
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists) override;
|
||||
|
||||
static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIFrame* aBox,
|
||||
const nsRect& aRect);
|
||||
|
||||
private:
|
||||
explicit nsBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
|
||||
: nsBoxFrame(aStyle, aPresContext, kClassID) {}
|
||||
|
||||
protected:
|
||||
nsBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID);
|
||||
virtual ~nsBoxFrame();
|
||||
|
||||
virtual void GetInitialOrientation(bool& aIsHorizontal);
|
||||
virtual void GetInitialDirection(bool& aIsNormal);
|
||||
virtual bool GetInitialHAlignment(Halignment& aHalign);
|
||||
virtual bool GetInitialVAlignment(Valignment& aValign);
|
||||
virtual bool GetInitialAutoStretch(bool& aStretch);
|
||||
|
||||
virtual void DestroyFrom(nsIFrame* aDestructRoot,
|
||||
PostDestroyData& aPostDestroyData) override;
|
||||
|
||||
nsSize mPrefSize;
|
||||
nsSize mMinSize;
|
||||
nsSize mMaxSize;
|
||||
nscoord mAscent;
|
||||
|
||||
nsCOMPtr<nsBoxLayout> mLayoutManager;
|
||||
|
||||
private:
|
||||
void CacheAttributes();
|
||||
|
||||
// instance variables.
|
||||
Halignment mHalign;
|
||||
Valignment mValign;
|
||||
|
||||
}; // class nsBoxFrame
|
||||
|
||||
#endif
|
@ -1,74 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
//
|
||||
// Eric Vaughan
|
||||
// Netscape Communications
|
||||
//
|
||||
// See documentation in associated header file
|
||||
//
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsBoxLayout.h"
|
||||
|
||||
void nsBoxLayout::AddXULBorderAndPadding(nsIFrame* aBox, nsSize& aSize) {
|
||||
nsIFrame::AddXULBorderAndPadding(aBox, aSize);
|
||||
}
|
||||
|
||||
void nsBoxLayout::AddXULMargin(nsIFrame* aChild, nsSize& aSize) {
|
||||
nsIFrame::AddXULMargin(aChild, aSize);
|
||||
}
|
||||
|
||||
void nsBoxLayout::AddXULMargin(nsSize& aSize, const nsMargin& aMargin) {
|
||||
nsIFrame::AddXULMargin(aSize, aMargin);
|
||||
}
|
||||
|
||||
nsSize nsBoxLayout::GetXULPrefSize(nsIFrame* aBox,
|
||||
nsBoxLayoutState& aBoxLayoutState) {
|
||||
nsSize pref(0, 0);
|
||||
AddXULBorderAndPadding(aBox, pref);
|
||||
|
||||
return pref;
|
||||
}
|
||||
|
||||
nsSize nsBoxLayout::GetXULMinSize(nsIFrame* aBox,
|
||||
nsBoxLayoutState& aBoxLayoutState) {
|
||||
nsSize minSize(0, 0);
|
||||
AddXULBorderAndPadding(aBox, minSize);
|
||||
return minSize;
|
||||
}
|
||||
|
||||
nsSize nsBoxLayout::GetXULMaxSize(nsIFrame* aBox,
|
||||
nsBoxLayoutState& aBoxLayoutState) {
|
||||
// AddXULBorderAndPadding () never changes maxSize (NS_UNCONSTRAINEDSIZE)
|
||||
// AddXULBorderAndPadding(aBox, maxSize);
|
||||
return nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
||||
}
|
||||
|
||||
nscoord nsBoxLayout::GetAscent(nsIFrame* aBox,
|
||||
nsBoxLayoutState& aBoxLayoutState) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBoxLayout::XULLayout(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsBoxLayout::AddLargestSize(nsSize& aSize, const nsSize& aSize2) {
|
||||
if (aSize2.width > aSize.width) aSize.width = aSize2.width;
|
||||
|
||||
if (aSize2.height > aSize.height) aSize.height = aSize2.height;
|
||||
}
|
||||
|
||||
void nsBoxLayout::AddSmallestSize(nsSize& aSize, const nsSize& aSize2) {
|
||||
if (aSize2.width < aSize.width) aSize.width = aSize2.width;
|
||||
|
||||
if (aSize2.height < aSize.height) aSize.height = aSize2.height;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsBoxLayout, nsBoxLayout)
|
@ -1,67 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 nsBoxLayout_h___
|
||||
#define nsBoxLayout_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsFrameList.h"
|
||||
|
||||
class nsIFrame;
|
||||
class nsBoxLayoutState;
|
||||
struct nsSize;
|
||||
struct nsMargin;
|
||||
|
||||
#define NS_BOX_LAYOUT_IID \
|
||||
{ \
|
||||
0x09d522a7, 0x304c, 0x4137, { \
|
||||
0xaf, 0xc9, 0xe0, 0x80, 0x2e, 0x89, 0xb7, 0xe8 \
|
||||
} \
|
||||
}
|
||||
|
||||
class nsBoxLayout : public nsISupports {
|
||||
protected:
|
||||
virtual ~nsBoxLayout() = default;
|
||||
|
||||
public:
|
||||
nsBoxLayout() = default;
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_BOX_LAYOUT_IID)
|
||||
|
||||
NS_IMETHOD XULLayout(nsIFrame* aBox, nsBoxLayoutState& aState);
|
||||
|
||||
virtual nsSize GetXULPrefSize(nsIFrame* aBox,
|
||||
nsBoxLayoutState& aBoxLayoutState);
|
||||
virtual nsSize GetXULMinSize(nsIFrame* aBox,
|
||||
nsBoxLayoutState& aBoxLayoutState);
|
||||
virtual nsSize GetXULMaxSize(nsIFrame* aBox,
|
||||
nsBoxLayoutState& aBoxLayoutState);
|
||||
virtual nscoord GetAscent(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
|
||||
virtual void ChildrenInserted(nsIFrame* aBox, nsBoxLayoutState& aState,
|
||||
nsIFrame* aPrevBox,
|
||||
const nsFrameList::Slice& aNewChildren) {}
|
||||
virtual void ChildrenAppended(nsIFrame* aBox, nsBoxLayoutState& aState,
|
||||
const nsFrameList::Slice& aNewChildren) {}
|
||||
virtual void ChildrenRemoved(nsIFrame* aBox, nsBoxLayoutState& aState,
|
||||
nsIFrame* aChildList) {}
|
||||
virtual void ChildrenSet(nsIFrame* aBox, nsBoxLayoutState& aState,
|
||||
nsIFrame* aChildList) {}
|
||||
virtual void IntrinsicISizesDirty(nsIFrame* aBox, nsBoxLayoutState& aState) {}
|
||||
|
||||
virtual void AddXULBorderAndPadding(nsIFrame* aBox, nsSize& aSize);
|
||||
virtual void AddXULMargin(nsIFrame* aChild, nsSize& aSize);
|
||||
virtual void AddXULMargin(nsSize& aSize, const nsMargin& aMargin);
|
||||
|
||||
static void AddLargestSize(nsSize& aSize, const nsSize& aToAdd);
|
||||
static void AddSmallestSize(nsSize& aSize, const nsSize& aToAdd);
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsBoxLayout, NS_BOX_LAYOUT_IID)
|
||||
|
||||
#endif
|
@ -14,7 +14,6 @@
|
||||
#include "mozilla/ComputedStyle.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "nsLeafBoxFrame.h"
|
||||
#include "nsBoxFrame.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsPresContext.h"
|
||||
@ -128,11 +127,6 @@ void nsLeafBoxFrame::Reflow(nsPresContext* aPresContext,
|
||||
ReflowOutput& aDesiredSize,
|
||||
const ReflowInput& aReflowInput,
|
||||
nsReflowStatus& aStatus) {
|
||||
// This is mostly a copy of nsBoxFrame::Reflow().
|
||||
// We aren't able to share an implementation because of the frame
|
||||
// class hierarchy. If you make changes here, please keep
|
||||
// nsBoxFrame::Reflow in sync.
|
||||
|
||||
MarkInReflow();
|
||||
DO_GLOBAL_REFLOW_COUNT("nsLeafBoxFrame");
|
||||
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "nsScrollbarFrame.h"
|
||||
#include "nsRepeatService.h"
|
||||
#include "nsBoxLayoutState.h"
|
||||
#include "nsSprocketLayout.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsDisplayList.h"
|
||||
@ -433,9 +432,9 @@ void nsSliderFrame::BuildDisplayListForThumb(nsDisplayListBuilder* aBuilder,
|
||||
// If this scrollbar is the scrollbar of an actively scrolled scroll frame,
|
||||
// layerize the scrollbar thumb, wrap it in its own ContainerLayer and
|
||||
// attach scrolling information to it.
|
||||
// We do this here and not in the thumb's nsBoxFrame::BuildDisplayList so
|
||||
// that the event region that gets created for the thumb is included in
|
||||
// the nsDisplayOwnLayer contents.
|
||||
// We do this here and not in the thumb's BuildDisplayList so that the event
|
||||
// region that gets created for the thumb is included in the nsDisplayOwnLayer
|
||||
// contents.
|
||||
|
||||
const layers::ScrollableLayerGuid::ViewID scrollTargetId =
|
||||
aBuilder->GetCurrentScrollbarTarget();
|
||||
|
@ -8,9 +8,8 @@
|
||||
#define nsSliderFrame_h__
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsRepeatService.h"
|
||||
#include "nsBoxFrame.h"
|
||||
#include "nsAtom.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsITimer.h"
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include "SimpleXULLeafFrame.h"
|
||||
#include "gfxContext.h"
|
||||
#include "nsBoxFrame.h"
|
||||
#include "nsSplitterFrame.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsXULElement.h"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,154 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 nsSprocketLayout_h___
|
||||
#define nsSprocketLayout_h___
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsBoxLayout.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsFrameState.h"
|
||||
|
||||
class nsIFrame;
|
||||
struct nsRect;
|
||||
|
||||
class nsBoxSize {
|
||||
public:
|
||||
nsBoxSize();
|
||||
|
||||
nscoord pref;
|
||||
nscoord min;
|
||||
nscoord max;
|
||||
nscoord flex;
|
||||
nscoord left;
|
||||
nscoord right;
|
||||
bool collapsed;
|
||||
bool bogus;
|
||||
|
||||
nsBoxSize* next;
|
||||
|
||||
void* operator new(size_t sz, nsBoxLayoutState& aState) noexcept(true);
|
||||
void operator delete(void* aPtr, size_t sz);
|
||||
};
|
||||
|
||||
class nsComputedBoxSize {
|
||||
public:
|
||||
nsComputedBoxSize();
|
||||
|
||||
nscoord size;
|
||||
bool valid;
|
||||
bool resized;
|
||||
nsComputedBoxSize* next;
|
||||
|
||||
void* operator new(size_t sz, nsBoxLayoutState& aState) noexcept(true);
|
||||
void operator delete(void* aPtr, size_t sz);
|
||||
};
|
||||
|
||||
#define GET_WIDTH(size, isHorizontal) (isHorizontal ? size.width : size.height)
|
||||
#define GET_HEIGHT(size, isHorizontal) (isHorizontal ? size.height : size.width)
|
||||
#define GET_X(size, isHorizontal) (isHorizontal ? size.x : size.y)
|
||||
#define GET_Y(size, isHorizontal) (isHorizontal ? size.y : size.x)
|
||||
#define GET_COORD(aX, aY, isHorizontal) (isHorizontal ? aX : aY)
|
||||
|
||||
#define SET_WIDTH(size, coord, isHorizontal) \
|
||||
if (isHorizontal) { \
|
||||
(size).width = (coord); \
|
||||
} else { \
|
||||
(size).height = (coord); \
|
||||
}
|
||||
#define SET_HEIGHT(size, coord, isHorizontal) \
|
||||
if (isHorizontal) { \
|
||||
(size).height = (coord); \
|
||||
} else { \
|
||||
(size).width = (coord); \
|
||||
}
|
||||
#define SET_X(size, coord, isHorizontal) \
|
||||
if (isHorizontal) { \
|
||||
(size).x = (coord); \
|
||||
} else { \
|
||||
(size).y = (coord); \
|
||||
}
|
||||
#define SET_Y(size, coord, isHorizontal) \
|
||||
if (isHorizontal) { \
|
||||
(size).y = (coord); \
|
||||
} else { \
|
||||
(size).x = (coord); \
|
||||
}
|
||||
|
||||
#define SET_COORD(aX, aY, coord, isHorizontal) \
|
||||
if (isHorizontal) { \
|
||||
aX = (coord); \
|
||||
} else { \
|
||||
aY = (coord); \
|
||||
}
|
||||
|
||||
nsresult NS_NewSprocketLayout(nsCOMPtr<nsBoxLayout>& aNewLayout);
|
||||
|
||||
class nsSprocketLayout : public nsBoxLayout {
|
||||
public:
|
||||
friend nsresult NS_NewSprocketLayout(nsCOMPtr<nsBoxLayout>& aNewLayout);
|
||||
static void Shutdown();
|
||||
|
||||
NS_IMETHOD XULLayout(nsIFrame* aBox, nsBoxLayoutState& aState) override;
|
||||
|
||||
virtual nsSize GetXULPrefSize(nsIFrame* aBox,
|
||||
nsBoxLayoutState& aBoxLayoutState) override;
|
||||
virtual nsSize GetXULMinSize(nsIFrame* aBox,
|
||||
nsBoxLayoutState& aBoxLayoutState) override;
|
||||
virtual nsSize GetXULMaxSize(nsIFrame* aBox,
|
||||
nsBoxLayoutState& aBoxLayoutState) override;
|
||||
virtual nscoord GetAscent(nsIFrame* aBox,
|
||||
nsBoxLayoutState& aBoxLayoutState) override;
|
||||
|
||||
nsSprocketLayout();
|
||||
|
||||
static bool IsXULHorizontal(nsIFrame* aBox);
|
||||
|
||||
static void SetLargestSize(nsSize& aSize1, const nsSize& aSize2,
|
||||
bool aIsHorizontal);
|
||||
static void SetSmallestSize(nsSize& aSize1, const nsSize& aSize2,
|
||||
bool aIsHorizontal);
|
||||
|
||||
static void AddLargestSize(nsSize& aSize, const nsSize& aSizeToAdd,
|
||||
bool aIsHorizontal);
|
||||
static void AddSmallestSize(nsSize& aSize, const nsSize& aSizeToAdd,
|
||||
bool aIsHorizontal);
|
||||
static void AddCoord(nscoord& aCoord, nscoord aCoordToAdd);
|
||||
|
||||
protected:
|
||||
void ComputeChildsNextPosition(nsIFrame* aBox, const nscoord& aCurX,
|
||||
const nscoord& aCurY, nscoord& aNextX,
|
||||
nscoord& aNextY, const nsRect& aChildSize);
|
||||
|
||||
void ChildResized(nsIFrame* aBox, nsBoxLayoutState& aState, nsIFrame* aChild,
|
||||
nsBoxSize* aChildBoxSize,
|
||||
nsComputedBoxSize* aChildComputedBoxSize,
|
||||
nsBoxSize* aBoxSizes, nsComputedBoxSize* aComputedBoxSizes,
|
||||
const nsRect& aChildLayoutRect, nsRect& aChildActualRect,
|
||||
nsRect& aContainingRect, int32_t aFlexes, bool& aFinished);
|
||||
|
||||
void AlignChildren(nsIFrame* aBox, nsBoxLayoutState& aState);
|
||||
|
||||
virtual void ComputeChildSizes(nsIFrame* aBox, nsBoxLayoutState& aState,
|
||||
nscoord& aGivenSize, nsBoxSize* aBoxSizes,
|
||||
nsComputedBoxSize*& aComputedBoxSizes);
|
||||
|
||||
virtual void PopulateBoxSizes(nsIFrame* aBox,
|
||||
nsBoxLayoutState& aBoxLayoutState,
|
||||
nsBoxSize*& aBoxSizes, nscoord& aMinSize,
|
||||
nscoord& aMaxSize, int32_t& aFlexes);
|
||||
|
||||
virtual void InvalidateComputedSizes(nsComputedBoxSize* aComputedBoxSizes);
|
||||
|
||||
virtual bool GetDefaultFlex(int32_t& aFlex);
|
||||
|
||||
private:
|
||||
// because the sprocket layout manager has no instance variables. We
|
||||
// can make a static one and reuse it everywhere.
|
||||
static nsBoxLayout* gInstance;
|
||||
};
|
||||
|
||||
#endif
|
@ -33,7 +33,6 @@
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "nsIReflowCallback.h"
|
||||
#include "nsBoxFrame.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "TextDrawTarget.h"
|
||||
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include "nsVariant.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIFrameInlines.h"
|
||||
#include "nsBoxFrame.h"
|
||||
#include "nsBoxLayoutState.h"
|
||||
#include "nsTextBoxFrame.h"
|
||||
#include "nsTreeContentView.h"
|
||||
|
Loading…
Reference in New Issue
Block a user