2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2006-03-29 18:29:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* rendering object that is the root of the frame tree, which contains
|
|
|
|
* the document's scrollbars and contains fixed-positioned elements
|
|
|
|
*/
|
|
|
|
|
2003-01-20 18:04:34 +00:00
|
|
|
#include "nsViewportFrame.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2001-04-17 01:45:38 +00:00
|
|
|
#include "nsIScrollableFrame.h"
|
2011-12-05 12:38:46 +00:00
|
|
|
#include "nsSubDocumentFrame.h"
|
2015-10-19 00:56:13 +00:00
|
|
|
#include "nsCanvasFrame.h"
|
2011-04-29 23:02:33 +00:00
|
|
|
#include "nsAbsoluteContainingBlock.h"
|
2013-03-18 14:25:50 +00:00
|
|
|
#include "GeckoProfiler.h"
|
2015-10-07 03:04:32 +00:00
|
|
|
#include "nsIMozBrowserFrame.h"
|
2010-08-08 18:49:06 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2015-12-22 22:03:16 +00:00
|
|
|
typedef nsAbsoluteContainingBlock::AbsPosReflowFlags AbsPosReflowFlags;
|
1999-01-26 00:05:21 +00:00
|
|
|
|
2014-05-24 22:20:40 +00:00
|
|
|
ViewportFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewViewportFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-01-26 00:05:21 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) ViewportFrame(aContext);
|
1999-01-26 00:05:21 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(ViewportFrame)
|
2013-04-24 16:17:55 +00:00
|
|
|
NS_QUERYFRAME_HEAD(ViewportFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(ViewportFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
2009-09-12 16:49:24 +00:00
|
|
|
|
2013-03-20 01:47:48 +00:00
|
|
|
void
|
2014-05-24 22:20:40 +00:00
|
|
|
ViewportFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
2016-04-18 06:32:45 +00:00
|
|
|
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2012-08-29 05:39:01 +00:00
|
|
|
|
|
|
|
nsIFrame* parent = nsLayoutUtils::GetCrossDocParentFrame(this);
|
|
|
|
if (parent) {
|
|
|
|
nsFrameState state = parent->GetStateBits();
|
|
|
|
|
|
|
|
mState |= state & (NS_FRAME_IN_POPUP);
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
2006-01-26 02:29:17 +00:00
|
|
|
ViewportFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2000-03-22 02:43:08 +00:00
|
|
|
{
|
2014-05-23 21:12:29 +00:00
|
|
|
PROFILER_LABEL("ViewportFrame", "BuildDisplayList",
|
|
|
|
js::ProfileEntry::Category::GRAPHICS);
|
|
|
|
|
2015-10-07 03:04:32 +00:00
|
|
|
if (nsIFrame* kid = mFrames.FirstChild()) {
|
|
|
|
// make the kid's BorderBackground our own. This ensures that the canvas
|
|
|
|
// frame's background becomes our own background and therefore appears
|
|
|
|
// below negative z-index elements.
|
|
|
|
BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDisplayList topLayerList;
|
|
|
|
BuildDisplayListForTopLayer(aBuilder, &topLayerList);
|
|
|
|
if (!topLayerList.IsEmpty()) {
|
|
|
|
// Wrap the whole top layer in a single item with maximum z-index,
|
|
|
|
// and append it at the very end, so that it stays at the topmost.
|
|
|
|
nsDisplayWrapList* wrapList =
|
|
|
|
new (aBuilder) nsDisplayWrapList(aBuilder, this, &topLayerList);
|
|
|
|
wrapList->SetOverrideZIndex(
|
|
|
|
std::numeric_limits<decltype(wrapList->ZIndex())>::max());
|
|
|
|
aLists.PositionedDescendants()->AppendNewToTop(wrapList);
|
|
|
|
}
|
|
|
|
}
|
2006-04-27 02:45:03 +00:00
|
|
|
|
2015-10-07 03:04:32 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/**
|
|
|
|
* Returns whether we are going to put an element in the top layer for
|
|
|
|
* fullscreen. This function should matches the CSS rule in ua.css.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
ShouldInTopLayerForFullscreen(Element* aElement)
|
|
|
|
{
|
|
|
|
if (!aElement->GetParent()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(aElement);
|
|
|
|
if (browserFrame && browserFrame->GetReallyIsBrowserOrApp()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
|
2015-10-19 00:56:13 +00:00
|
|
|
static void
|
|
|
|
BuildDisplayListForTopLayerFrame(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsDisplayList* aList)
|
|
|
|
{
|
|
|
|
nsRect dirty;
|
2016-04-06 08:48:31 +00:00
|
|
|
DisplayListClipState::AutoClipMultiple clipState(aBuilder);
|
2015-10-19 00:56:13 +00:00
|
|
|
nsDisplayListBuilder::OutOfFlowDisplayData*
|
|
|
|
savedOutOfFlowData = nsDisplayListBuilder::GetOutOfFlowData(aFrame);
|
|
|
|
if (savedOutOfFlowData) {
|
|
|
|
dirty = savedOutOfFlowData->mDirtyRect;
|
2016-04-06 08:48:31 +00:00
|
|
|
clipState.SetClipForContainingBlockDescendants(
|
|
|
|
&savedOutOfFlowData->mContainingBlockClip);
|
|
|
|
clipState.SetScrollClipForContainingBlockDescendants(
|
2016-07-13 20:05:53 +00:00
|
|
|
aBuilder, savedOutOfFlowData->mContainingBlockScrollClip);
|
2015-10-19 00:56:13 +00:00
|
|
|
}
|
|
|
|
nsDisplayList list;
|
|
|
|
aFrame->BuildDisplayListForStackingContext(aBuilder, dirty, &list);
|
|
|
|
aList->AppendToTop(&list);
|
|
|
|
}
|
|
|
|
|
2015-10-07 03:04:32 +00:00
|
|
|
void
|
|
|
|
ViewportFrame::BuildDisplayListForTopLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayList* aList)
|
|
|
|
{
|
|
|
|
nsIDocument* doc = PresContext()->Document();
|
|
|
|
nsTArray<Element*> fullscreenStack = doc->GetFullscreenStack();
|
|
|
|
for (Element* elem : fullscreenStack) {
|
|
|
|
if (nsIFrame* frame = elem->GetPrimaryFrame()) {
|
|
|
|
// There are two cases where an element in fullscreen is not in
|
|
|
|
// the top layer:
|
|
|
|
// 1. When building display list for purpose other than painting,
|
|
|
|
// it is possible that there is inconsistency between the style
|
|
|
|
// info and the content tree.
|
|
|
|
// 2. This is an element which we are not going to put in the top
|
|
|
|
// layer for fullscreen. See ShouldInTopLayerForFullscreen().
|
|
|
|
// In both cases, we want to skip the frame here and paint it in
|
|
|
|
// the normal path.
|
|
|
|
if (frame->StyleDisplay()->mTopLayer == NS_STYLE_TOP_LAYER_NONE) {
|
|
|
|
MOZ_ASSERT(!aBuilder->IsForPainting() ||
|
|
|
|
!ShouldInTopLayerForFullscreen(elem));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(ShouldInTopLayerForFullscreen(elem));
|
|
|
|
// Inner SVG, MathML elements, as well as children of some XUL
|
|
|
|
// elements are not allowed to be out-of-flow. They should not
|
|
|
|
// be handled as top layer element here.
|
|
|
|
if (!(frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
|
|
|
|
MOZ_ASSERT(!elem->GetParent()->IsHTMLElement(), "HTML element "
|
|
|
|
"should always be out-of-flow if in the top layer");
|
|
|
|
continue;
|
|
|
|
}
|
2016-01-27 23:11:00 +00:00
|
|
|
if (nsIFrame* backdropPh =
|
|
|
|
frame->GetChildList(kBackdropList).FirstChild()) {
|
|
|
|
MOZ_ASSERT(backdropPh->GetType() == nsGkAtoms::placeholderFrame);
|
|
|
|
nsIFrame* backdropFrame =
|
|
|
|
static_cast<nsPlaceholderFrame*>(backdropPh)->GetOutOfFlowFrame();
|
|
|
|
MOZ_ASSERT(backdropFrame);
|
|
|
|
BuildDisplayListForTopLayerFrame(aBuilder, backdropFrame, aList);
|
|
|
|
}
|
2015-10-19 00:56:13 +00:00
|
|
|
BuildDisplayListForTopLayerFrame(aBuilder, frame, aList);
|
|
|
|
}
|
|
|
|
}
|
2015-10-07 03:04:32 +00:00
|
|
|
|
2015-10-19 00:56:13 +00:00
|
|
|
nsIPresShell* shell = PresContext()->PresShell();
|
|
|
|
if (nsCanvasFrame* canvasFrame = shell->GetCanvasFrame()) {
|
|
|
|
if (Element* container = canvasFrame->GetCustomContentContainer()) {
|
|
|
|
if (nsIFrame* frame = container->GetPrimaryFrame()) {
|
|
|
|
BuildDisplayListForTopLayerFrame(aBuilder, frame, aList);
|
2015-10-07 03:04:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-22 02:43:08 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 19:36:59 +00:00
|
|
|
#ifdef DEBUG
|
2014-05-28 19:36:58 +00:00
|
|
|
void
|
2011-08-24 20:54:30 +00:00
|
|
|
ViewportFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-07-24 03:59:47 +00:00
|
|
|
{
|
2014-05-28 19:36:59 +00:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
|
|
|
NS_ASSERTION(GetChildList(aListID).IsEmpty(), "Shouldn't have any kids!");
|
2014-05-28 19:36:58 +00:00
|
|
|
nsContainerFrame::AppendFrames(aListID, aFrameList);
|
1999-07-24 03:59:47 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 19:36:58 +00:00
|
|
|
void
|
2011-08-24 20:54:30 +00:00
|
|
|
ViewportFrame::InsertFrames(ChildListID aListID,
|
2003-01-20 18:04:34 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-07-24 03:59:47 +00:00
|
|
|
{
|
2014-05-28 19:36:59 +00:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
|
|
|
NS_ASSERTION(GetChildList(aListID).IsEmpty(), "Shouldn't have any kids!");
|
2014-05-28 19:36:58 +00:00
|
|
|
nsContainerFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
|
1999-07-24 03:59:47 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 19:36:58 +00:00
|
|
|
void
|
2011-08-24 20:54:30 +00:00
|
|
|
ViewportFrame::RemoveFrame(ChildListID aListID,
|
2003-01-20 18:04:34 +00:00
|
|
|
nsIFrame* aOldFrame)
|
1999-07-24 03:59:47 +00:00
|
|
|
{
|
2014-05-28 19:36:59 +00:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2014-05-28 19:36:58 +00:00
|
|
|
nsContainerFrame::RemoveFrame(aListID, aOldFrame);
|
1999-01-28 17:14:13 +00:00
|
|
|
}
|
2014-05-28 19:36:59 +00:00
|
|
|
#endif
|
1999-01-28 17:14:13 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ nscoord
|
2014-07-24 17:03:25 +00:00
|
|
|
ViewportFrame::GetMinISize(nsRenderingContext *aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
if (mFrames.IsEmpty())
|
|
|
|
result = 0;
|
|
|
|
else
|
2014-07-24 17:03:25 +00:00
|
|
|
result = mFrames.FirstChild()->GetMinISize(aRenderingContext);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2014-07-24 17:03:25 +00:00
|
|
|
ViewportFrame::GetPrefISize(nsRenderingContext *aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
if (mFrames.IsEmpty())
|
|
|
|
result = 0;
|
|
|
|
else
|
2014-07-24 17:03:25 +00:00
|
|
|
result = mFrames.FirstChild()->GetPrefISize(aRenderingContext);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2004-01-09 19:21:20 +00:00
|
|
|
nsPoint
|
2016-07-21 10:36:39 +00:00
|
|
|
ViewportFrame::AdjustReflowInputForScrollbars(ReflowInput* aReflowInput) const
|
1999-02-03 17:01:51 +00:00
|
|
|
{
|
|
|
|
// Get our prinicpal child frame and see if we're scrollable
|
|
|
|
nsIFrame* kidFrame = mFrames.FirstChild();
|
2013-04-24 16:17:55 +00:00
|
|
|
nsIScrollableFrame* scrollingFrame = do_QueryFrame(kidFrame);
|
2001-04-17 01:45:38 +00:00
|
|
|
|
|
|
|
if (scrollingFrame) {
|
2016-07-21 10:36:39 +00:00
|
|
|
WritingMode wm = aReflowInput->GetWritingMode();
|
2016-05-18 20:07:54 +00:00
|
|
|
LogicalMargin scrollbars(wm, scrollingFrame->GetActualScrollbarSizes());
|
2016-07-21 10:36:39 +00:00
|
|
|
aReflowInput->SetComputedISize(aReflowInput->ComputedISize() -
|
2016-05-18 20:07:54 +00:00
|
|
|
scrollbars.IStartEnd(wm));
|
2016-07-21 10:36:39 +00:00
|
|
|
aReflowInput->AvailableISize() -= scrollbars.IStartEnd(wm);
|
|
|
|
aReflowInput->SetComputedBSizeWithoutResettingResizeFlags(
|
|
|
|
aReflowInput->ComputedBSize() - scrollbars.BStartEnd(wm));
|
2016-05-18 20:07:54 +00:00
|
|
|
return nsPoint(scrollbars.Left(wm), scrollbars.Top(wm));
|
1999-02-03 17:01:51 +00:00
|
|
|
}
|
2004-01-09 19:21:20 +00:00
|
|
|
return nsPoint(0, 0);
|
1999-02-03 17:01:51 +00:00
|
|
|
}
|
|
|
|
|
2013-04-24 16:17:55 +00:00
|
|
|
nsRect
|
2016-07-21 10:36:39 +00:00
|
|
|
ViewportFrame::AdjustReflowInputAsContainingBlock(ReflowInput* aReflowInput) const
|
2013-04-24 16:17:55 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsPoint offset =
|
|
|
|
#endif
|
2016-07-21 10:36:39 +00:00
|
|
|
AdjustReflowInputForScrollbars(aReflowInput);
|
2013-04-24 16:17:55 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(GetAbsoluteContainingBlock()->GetChildList().IsEmpty() ||
|
|
|
|
(offset.x == 0 && offset.y == 0),
|
|
|
|
"We don't handle correct positioning of fixed frames with "
|
|
|
|
"scrollbars in odd positions");
|
|
|
|
|
|
|
|
// If a scroll position clamping scroll-port size has been set, layout
|
|
|
|
// fixed position elements to this size instead of the computed size.
|
2016-07-21 10:36:39 +00:00
|
|
|
nsRect rect(0, 0, aReflowInput->ComputedWidth(), aReflowInput->ComputedHeight());
|
2013-04-24 16:17:55 +00:00
|
|
|
nsIPresShell* ps = PresContext()->PresShell();
|
|
|
|
if (ps->IsScrollPositionClampingScrollPortSizeSet()) {
|
|
|
|
rect.SizeTo(ps->GetScrollPositionClampingScrollPortSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
2014-05-13 00:47:52 +00:00
|
|
|
void
|
2008-10-30 00:41:56 +00:00
|
|
|
ViewportFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 10:36:38 +00:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 10:36:39 +00:00
|
|
|
const ReflowInput& aReflowInput,
|
1999-01-26 00:05:21 +00:00
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2015-03-29 22:38:40 +00:00
|
|
|
MarkInReflow();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("ViewportFrame");
|
2016-07-21 10:36:39 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
1999-01-26 00:05:21 +00:00
|
|
|
NS_FRAME_TRACE_REFLOW_IN("ViewportFrame::Reflow");
|
|
|
|
|
2003-01-20 18:04:34 +00:00
|
|
|
// Initialize OUT parameters
|
1999-01-26 00:05:21 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
2015-06-18 06:33:50 +00:00
|
|
|
// Because |Reflow| sets ComputedBSize() on the child to our
|
|
|
|
// ComputedBSize().
|
|
|
|
AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
|
2010-08-05 21:59:36 +00:00
|
|
|
|
|
|
|
// Set our size up front, since some parts of reflow depend on it
|
|
|
|
// being already set. Note that the computed height may be
|
|
|
|
// unconstrained; that's ok. Consumers should watch out for that.
|
2016-07-21 10:36:39 +00:00
|
|
|
SetSize(nsSize(aReflowInput.ComputedWidth(), aReflowInput.ComputedHeight()));
|
2014-09-23 13:44:00 +00:00
|
|
|
|
2003-02-22 20:13:12 +00:00
|
|
|
// Reflow the main content first so that the placeholders of the
|
|
|
|
// fixed-position frames will be in the right places on an initial
|
|
|
|
// reflow.
|
2014-07-24 08:30:07 +00:00
|
|
|
nscoord kidBSize = 0;
|
2016-07-21 10:36:39 +00:00
|
|
|
WritingMode wm = aReflowInput.GetWritingMode();
|
1999-07-04 04:09:54 +00:00
|
|
|
|
2002-05-10 18:22:41 +00:00
|
|
|
if (mFrames.NotEmpty()) {
|
|
|
|
// Deal with a non-incremental reflow or an incremental reflow
|
|
|
|
// targeted at our one-and-only principal child frame.
|
2016-07-21 10:36:39 +00:00
|
|
|
if (aReflowInput.ShouldReflowAllKids() ||
|
|
|
|
aReflowInput.IsBResize() ||
|
2007-05-06 19:16:51 +00:00
|
|
|
NS_SUBTREE_DIRTY(mFrames.FirstChild())) {
|
2002-05-10 18:22:41 +00:00
|
|
|
// Reflow our one-and-only principal child frame
|
|
|
|
nsIFrame* kidFrame = mFrames.FirstChild();
|
2016-07-21 10:36:39 +00:00
|
|
|
ReflowOutput kidDesiredSize(aReflowInput);
|
2014-07-24 08:28:46 +00:00
|
|
|
WritingMode wm = kidFrame->GetWritingMode();
|
2016-07-21 10:36:39 +00:00
|
|
|
LogicalSize availableSpace = aReflowInput.AvailableSize(wm);
|
|
|
|
ReflowInput kidReflowInput(aPresContext, aReflowInput,
|
2002-05-10 18:22:41 +00:00
|
|
|
kidFrame, availableSpace);
|
|
|
|
|
|
|
|
// Reflow the frame
|
2016-07-21 10:36:39 +00:00
|
|
|
kidReflowInput.SetComputedBSize(aReflowInput.ComputedBSize());
|
|
|
|
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowInput,
|
2014-05-13 00:47:52 +00:00
|
|
|
0, 0, 0, aStatus);
|
2014-07-24 08:30:07 +00:00
|
|
|
kidBSize = kidDesiredSize.BSize(wm);
|
2002-05-10 18:22:41 +00:00
|
|
|
|
2014-01-17 01:34:44 +00:00
|
|
|
FinishReflowChild(kidFrame, aPresContext, kidDesiredSize, nullptr, 0, 0, 0);
|
2008-03-12 22:04:45 +00:00
|
|
|
} else {
|
2014-07-24 08:30:07 +00:00
|
|
|
kidBSize = LogicalSize(wm, mFrames.FirstChild()->GetSize()).BSize(wm);
|
2002-05-10 18:22:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 10:36:39 +00:00
|
|
|
NS_ASSERTION(aReflowInput.AvailableISize() != NS_UNCONSTRAINEDSIZE,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
"shouldn't happen anymore");
|
|
|
|
|
|
|
|
// Return the max size as our desired size
|
2016-07-21 10:36:39 +00:00
|
|
|
LogicalSize maxSize(wm, aReflowInput.AvailableISize(),
|
2014-07-24 08:30:07 +00:00
|
|
|
// Being flowed initially at an unconstrained block size
|
|
|
|
// means we should return our child's intrinsic size.
|
2016-07-21 10:36:39 +00:00
|
|
|
aReflowInput.ComputedBSize() != NS_UNCONSTRAINEDSIZE
|
|
|
|
? aReflowInput.ComputedBSize()
|
2014-07-24 08:30:07 +00:00
|
|
|
: kidBSize);
|
|
|
|
aDesiredSize.SetSize(wm, maxSize);
|
2011-12-05 12:39:14 +00:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
|
|
|
|
2015-01-06 09:27:56 +00:00
|
|
|
if (HasAbsolutelyPositionedChildren()) {
|
2012-10-23 01:48:12 +00:00
|
|
|
// Make a copy of the reflow state and change the computed width and height
|
|
|
|
// to reflect the available space for the fixed items
|
2016-07-21 10:36:39 +00:00
|
|
|
ReflowInput reflowInput(aReflowInput);
|
2012-10-23 01:48:12 +00:00
|
|
|
|
2016-07-21 10:36:39 +00:00
|
|
|
if (reflowInput.AvailableBSize() == NS_UNCONSTRAINEDSIZE) {
|
2012-10-23 01:48:12 +00:00
|
|
|
// We have an intrinsic-height document with abs-pos/fixed-pos children.
|
|
|
|
// Set the available height and mComputedHeight to our chosen height.
|
2016-07-21 10:36:39 +00:00
|
|
|
reflowInput.AvailableBSize() = maxSize.BSize(wm);
|
2012-10-23 01:48:12 +00:00
|
|
|
// Not having border/padding simplifies things
|
2016-07-21 10:36:39 +00:00
|
|
|
NS_ASSERTION(reflowInput.ComputedPhysicalBorderPadding() == nsMargin(0,0,0,0),
|
2012-10-23 01:48:12 +00:00
|
|
|
"Viewports can't have border/padding");
|
2016-07-21 10:36:39 +00:00
|
|
|
reflowInput.SetComputedBSize(maxSize.BSize(wm));
|
2012-10-23 01:48:12 +00:00
|
|
|
}
|
|
|
|
|
2016-07-21 10:36:39 +00:00
|
|
|
nsRect rect = AdjustReflowInputAsContainingBlock(&reflowInput);
|
2015-01-06 09:27:56 +00:00
|
|
|
nsOverflowAreas* overflowAreas = &aDesiredSize.mOverflowAreas;
|
2014-09-23 13:44:00 +00:00
|
|
|
nsIScrollableFrame* rootScrollFrame =
|
|
|
|
aPresContext->PresShell()->GetRootScrollFrameAsScrollable();
|
|
|
|
if (rootScrollFrame && !rootScrollFrame->IsIgnoringViewportClipping()) {
|
2015-01-06 09:27:56 +00:00
|
|
|
overflowAreas = nullptr;
|
2014-09-23 13:44:00 +00:00
|
|
|
}
|
2015-12-22 22:03:16 +00:00
|
|
|
AbsPosReflowFlags flags =
|
|
|
|
AbsPosReflowFlags::eCBWidthAndHeightChanged; // XXX could be optimized
|
2016-07-21 10:36:39 +00:00
|
|
|
GetAbsoluteContainingBlock()->Reflow(this, aPresContext, reflowInput, aStatus,
|
2015-12-22 22:03:16 +00:00
|
|
|
rect, flags, overflowAreas);
|
2014-09-23 13:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mFrames.NotEmpty()) {
|
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, mFrames.FirstChild());
|
2011-04-29 23:02:33 +00:00
|
|
|
}
|
2003-02-22 20:13:12 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// If we were dirty then do a repaint
|
|
|
|
if (GetStateBits() & NS_FRAME_IS_DIRTY) {
|
2012-08-29 05:39:31 +00:00
|
|
|
InvalidateFrame();
|
1999-07-24 15:18:24 +00:00
|
|
|
}
|
|
|
|
|
2011-12-05 12:38:46 +00:00
|
|
|
// Clipping is handled by the document container (e.g., nsSubDocumentFrame),
|
|
|
|
// so we don't need to change our overflow areas.
|
|
|
|
bool overflowChanged = FinishAndStoreOverflow(&aDesiredSize);
|
|
|
|
if (overflowChanged) {
|
|
|
|
// We may need to alert our container to get it to pick up the
|
|
|
|
// overflow change.
|
|
|
|
nsSubDocumentFrame* container = static_cast<nsSubDocumentFrame*>
|
|
|
|
(nsLayoutUtils::GetCrossDocParentFrame(this));
|
|
|
|
if (container && !container->ShouldClipSubdocument()) {
|
|
|
|
container->PresContext()->PresShell()->
|
|
|
|
FrameNeedsReflow(container, nsIPresShell::eResize, NS_FRAME_IS_DIRTY);
|
|
|
|
}
|
|
|
|
}
|
2007-01-25 02:01:07 +00:00
|
|
|
|
1999-01-26 00:05:21 +00:00
|
|
|
NS_FRAME_TRACE_REFLOW_OUT("ViewportFrame::Reflow", aStatus);
|
2016-07-21 10:36:39 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
1999-01-26 00:05:21 +00:00
|
|
|
}
|
|
|
|
|
2014-09-23 13:44:00 +00:00
|
|
|
bool
|
2016-05-04 00:27:43 +00:00
|
|
|
ViewportFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas)
|
2014-09-23 13:44:00 +00:00
|
|
|
{
|
|
|
|
nsIScrollableFrame* rootScrollFrame =
|
|
|
|
PresContext()->PresShell()->GetRootScrollFrameAsScrollable();
|
|
|
|
if (rootScrollFrame && !rootScrollFrame->IsIgnoringViewportClipping()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-04 00:27:43 +00:00
|
|
|
return nsContainerFrame::ComputeCustomOverflow(aOverflowAreas);
|
2014-09-23 13:44:00 +00:00
|
|
|
}
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
ViewportFrame::GetType() const
|
1999-02-14 03:47:33 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::viewportFrame;
|
1999-02-14 03:47:33 +00:00
|
|
|
}
|
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2001-11-14 01:33:42 +00:00
|
|
|
ViewportFrame::GetFrameName(nsAString& aResult) const
|
1999-01-26 00:05:21 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Viewport"), aResult);
|
1999-01-26 00:05:21 +00:00
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
#endif
|