2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-03-29 22:29:03 +04: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 21:04:34 +03:00
|
|
|
#include "nsViewportFrame.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2001-04-17 05:45:38 +04:00
|
|
|
#include "nsIScrollableFrame.h"
|
2011-12-05 16:38:46 +04:00
|
|
|
#include "nsSubDocumentFrame.h"
|
2015-10-19 03:56:13 +03:00
|
|
|
#include "nsCanvasFrame.h"
|
2011-04-30 03:02:33 +04:00
|
|
|
#include "nsAbsoluteContainingBlock.h"
|
2013-03-18 18:25:50 +04:00
|
|
|
#include "GeckoProfiler.h"
|
2015-10-07 06:04:32 +03:00
|
|
|
#include "nsIMozBrowserFrame.h"
|
2010-08-08 22:49:06 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2015-12-23 01:03:16 +03:00
|
|
|
typedef nsAbsoluteContainingBlock::AbsPosReflowFlags AbsPosReflowFlags;
|
1999-01-26 03:05:21 +03:00
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
ViewportFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewViewportFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-01-26 03:05:21 +03:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) ViewportFrame(aContext);
|
1999-01-26 03:05:21 +03:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(ViewportFrame)
|
2013-04-24 20:17:55 +04:00
|
|
|
NS_QUERYFRAME_HEAD(ViewportFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(ViewportFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2014-05-25 02:20:40 +04: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 08:38:33 +03:00
|
|
|
{
|
2016-04-18 09:32:45 +03:00
|
|
|
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2012-08-29 09:39:01 +04: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 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
ViewportFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2000-03-22 05:43:08 +03:00
|
|
|
{
|
2014-05-24 01:12:29 +04:00
|
|
|
PROFILER_LABEL("ViewportFrame", "BuildDisplayList",
|
|
|
|
js::ProfileEntry::Category::GRAPHICS);
|
|
|
|
|
2015-10-07 06:04:32 +03: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 06:45:03 +04:00
|
|
|
|
2015-10-07 06:04:32 +03: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 03:56:13 +03:00
|
|
|
static void
|
|
|
|
BuildDisplayListForTopLayerFrame(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsDisplayList* aList)
|
|
|
|
{
|
|
|
|
nsRect dirty;
|
2016-04-06 11:48:31 +03:00
|
|
|
DisplayListClipState::AutoClipMultiple clipState(aBuilder);
|
2015-10-19 03:56:13 +03:00
|
|
|
nsDisplayListBuilder::OutOfFlowDisplayData*
|
|
|
|
savedOutOfFlowData = nsDisplayListBuilder::GetOutOfFlowData(aFrame);
|
|
|
|
if (savedOutOfFlowData) {
|
|
|
|
dirty = savedOutOfFlowData->mDirtyRect;
|
2016-04-06 11:48:31 +03:00
|
|
|
clipState.SetClipForContainingBlockDescendants(
|
|
|
|
&savedOutOfFlowData->mContainingBlockClip);
|
|
|
|
clipState.SetScrollClipForContainingBlockDescendants(
|
|
|
|
savedOutOfFlowData->mContainingBlockScrollClip);
|
2015-10-19 03:56:13 +03:00
|
|
|
}
|
|
|
|
nsDisplayList list;
|
|
|
|
aFrame->BuildDisplayListForStackingContext(aBuilder, dirty, &list);
|
|
|
|
aList->AppendToTop(&list);
|
|
|
|
}
|
|
|
|
|
2015-10-07 06:04:32 +03: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-28 02:11:00 +03: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 03:56:13 +03:00
|
|
|
BuildDisplayListForTopLayerFrame(aBuilder, frame, aList);
|
|
|
|
}
|
|
|
|
}
|
2015-10-07 06:04:32 +03:00
|
|
|
|
2015-10-19 03:56:13 +03: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 06:04:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-22 05:43:08 +03:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:59 +04:00
|
|
|
#ifdef DEBUG
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
ViewportFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
1999-07-24 07:59:47 +04:00
|
|
|
{
|
2014-05-28 23:36:59 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
|
|
|
NS_ASSERTION(GetChildList(aListID).IsEmpty(), "Shouldn't have any kids!");
|
2014-05-28 23:36:58 +04:00
|
|
|
nsContainerFrame::AppendFrames(aListID, aFrameList);
|
1999-07-24 07:59:47 +04:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
ViewportFrame::InsertFrames(ChildListID aListID,
|
2003-01-20 21:04:34 +03:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
1999-07-24 07:59:47 +04:00
|
|
|
{
|
2014-05-28 23:36:59 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
|
|
|
NS_ASSERTION(GetChildList(aListID).IsEmpty(), "Shouldn't have any kids!");
|
2014-05-28 23:36:58 +04:00
|
|
|
nsContainerFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
|
1999-07-24 07:59:47 +04:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
ViewportFrame::RemoveFrame(ChildListID aListID,
|
2003-01-20 21:04:34 +03:00
|
|
|
nsIFrame* aOldFrame)
|
1999-07-24 07:59:47 +04:00
|
|
|
{
|
2014-05-28 23:36:59 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2014-05-28 23:36:58 +04:00
|
|
|
nsContainerFrame::RemoveFrame(aListID, aOldFrame);
|
1999-01-28 20:14:13 +03:00
|
|
|
}
|
2014-05-28 23:36:59 +04:00
|
|
|
#endif
|
1999-01-28 20:14:13 +03: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 08:38:33 +03:00
|
|
|
/* virtual */ nscoord
|
2014-07-24 21:03:25 +04: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 08:38:33 +03:00
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
if (mFrames.IsEmpty())
|
|
|
|
result = 0;
|
|
|
|
else
|
2014-07-24 21:03:25 +04: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 08:38:33 +03:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2014-07-24 21:03:25 +04: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 08:38:33 +03:00
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
if (mFrames.IsEmpty())
|
|
|
|
result = 0;
|
|
|
|
else
|
2014-07-24 21:03:25 +04: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 08:38:33 +03:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2004-01-09 22:21:20 +03:00
|
|
|
nsPoint
|
2008-10-30 03:41:56 +03:00
|
|
|
ViewportFrame::AdjustReflowStateForScrollbars(nsHTMLReflowState* aReflowState) const
|
1999-02-03 20:01:51 +03:00
|
|
|
{
|
|
|
|
// Get our prinicpal child frame and see if we're scrollable
|
|
|
|
nsIFrame* kidFrame = mFrames.FirstChild();
|
2013-04-24 20:17:55 +04:00
|
|
|
nsIScrollableFrame* scrollingFrame = do_QueryFrame(kidFrame);
|
2001-04-17 05:45:38 +04:00
|
|
|
|
|
|
|
if (scrollingFrame) {
|
2004-01-09 22:21:20 +03:00
|
|
|
nsMargin scrollbars = scrollingFrame->GetActualScrollbarSizes();
|
2007-01-26 03:05:12 +03:00
|
|
|
aReflowState->SetComputedWidth(aReflowState->ComputedWidth() -
|
2007-08-02 22:08:05 +04:00
|
|
|
scrollbars.LeftRight());
|
2013-12-27 21:59:21 +04:00
|
|
|
aReflowState->AvailableWidth() -= scrollbars.LeftRight();
|
2009-01-29 23:39:22 +03:00
|
|
|
aReflowState->SetComputedHeightWithoutResettingResizeFlags(
|
|
|
|
aReflowState->ComputedHeight() - scrollbars.TopBottom());
|
2004-01-09 22:21:20 +03:00
|
|
|
return nsPoint(scrollbars.left, scrollbars.top);
|
1999-02-03 20:01:51 +03:00
|
|
|
}
|
2004-01-09 22:21:20 +03:00
|
|
|
return nsPoint(0, 0);
|
1999-02-03 20:01:51 +03:00
|
|
|
}
|
|
|
|
|
2013-04-24 20:17:55 +04:00
|
|
|
nsRect
|
|
|
|
ViewportFrame::AdjustReflowStateAsContainingBlock(nsHTMLReflowState* aReflowState) const
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsPoint offset =
|
|
|
|
#endif
|
|
|
|
AdjustReflowStateForScrollbars(aReflowState);
|
|
|
|
|
|
|
|
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.
|
|
|
|
nsRect rect(0, 0, aReflowState->ComputedWidth(), aReflowState->ComputedHeight());
|
|
|
|
nsIPresShell* ps = PresContext()->PresShell();
|
|
|
|
if (ps->IsScrollPositionClampingScrollPortSizeSet()) {
|
|
|
|
rect.SizeTo(ps->GetScrollPositionClampingScrollPortSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2008-10-30 03:41:56 +03:00
|
|
|
ViewportFrame::Reflow(nsPresContext* aPresContext,
|
1999-01-26 03:05:21 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2015-03-30 01:38:40 +03: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 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("ViewportFrame");
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1999-01-26 03:05:21 +03:00
|
|
|
NS_FRAME_TRACE_REFLOW_IN("ViewportFrame::Reflow");
|
|
|
|
|
2003-01-20 21:04:34 +03:00
|
|
|
// Initialize OUT parameters
|
1999-01-26 03:05:21 +03:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
2015-06-18 09:33:50 +03:00
|
|
|
// Because |Reflow| sets ComputedBSize() on the child to our
|
|
|
|
// ComputedBSize().
|
|
|
|
AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
|
2010-08-06 01:59:36 +04: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.
|
|
|
|
SetSize(nsSize(aReflowState.ComputedWidth(), aReflowState.ComputedHeight()));
|
2014-09-23 17:44:00 +04:00
|
|
|
|
2003-02-22 23:13:12 +03: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 12:30:07 +04:00
|
|
|
nscoord kidBSize = 0;
|
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
1999-07-04 08:09:54 +04:00
|
|
|
|
2002-05-10 22:22:41 +04:00
|
|
|
if (mFrames.NotEmpty()) {
|
|
|
|
// Deal with a non-incremental reflow or an incremental reflow
|
|
|
|
// targeted at our one-and-only principal child frame.
|
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 08:38:33 +03:00
|
|
|
if (aReflowState.ShouldReflowAllKids() ||
|
2014-11-28 12:44:02 +03:00
|
|
|
aReflowState.IsVResize() ||
|
2007-05-06 23:16:51 +04:00
|
|
|
NS_SUBTREE_DIRTY(mFrames.FirstChild())) {
|
2002-05-10 22:22:41 +04:00
|
|
|
// Reflow our one-and-only principal child frame
|
|
|
|
nsIFrame* kidFrame = mFrames.FirstChild();
|
2013-12-31 17:50:31 +04:00
|
|
|
nsHTMLReflowMetrics kidDesiredSize(aReflowState);
|
2014-07-24 12:28:46 +04:00
|
|
|
WritingMode wm = kidFrame->GetWritingMode();
|
|
|
|
LogicalSize availableSpace = aReflowState.AvailableSize(wm);
|
2002-05-10 22:22:41 +04:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
|
|
|
|
kidFrame, availableSpace);
|
|
|
|
|
|
|
|
// Reflow the frame
|
2014-12-16 12:45:11 +03:00
|
|
|
kidReflowState.SetComputedBSize(aReflowState.ComputedBSize());
|
2014-05-13 04:47:52 +04:00
|
|
|
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
|
|
|
|
0, 0, 0, aStatus);
|
2014-07-24 12:30:07 +04:00
|
|
|
kidBSize = kidDesiredSize.BSize(wm);
|
2002-05-10 22:22:41 +04:00
|
|
|
|
2014-01-17 05:34:44 +04:00
|
|
|
FinishReflowChild(kidFrame, aPresContext, kidDesiredSize, nullptr, 0, 0, 0);
|
2008-03-13 01:04:45 +03:00
|
|
|
} else {
|
2014-07-24 12:30:07 +04:00
|
|
|
kidBSize = LogicalSize(wm, mFrames.FirstChild()->GetSize()).BSize(wm);
|
2002-05-10 22:22:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-16 12:45:11 +03:00
|
|
|
NS_ASSERTION(aReflowState.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 08:38:33 +03:00
|
|
|
"shouldn't happen anymore");
|
|
|
|
|
|
|
|
// Return the max size as our desired size
|
2014-07-24 12:30:07 +04:00
|
|
|
LogicalSize maxSize(wm, aReflowState.AvailableISize(),
|
|
|
|
// Being flowed initially at an unconstrained block size
|
|
|
|
// means we should return our child's intrinsic size.
|
|
|
|
aReflowState.ComputedBSize() != NS_UNCONSTRAINEDSIZE
|
|
|
|
? aReflowState.ComputedBSize()
|
|
|
|
: kidBSize);
|
|
|
|
aDesiredSize.SetSize(wm, maxSize);
|
2011-12-05 16:39:14 +04:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
|
|
|
|
2015-01-06 12:27:56 +03:00
|
|
|
if (HasAbsolutelyPositionedChildren()) {
|
2012-10-23 05:48:12 +04:00
|
|
|
// Make a copy of the reflow state and change the computed width and height
|
|
|
|
// to reflect the available space for the fixed items
|
|
|
|
nsHTMLReflowState reflowState(aReflowState);
|
|
|
|
|
2014-07-24 12:30:07 +04:00
|
|
|
if (reflowState.AvailableBSize() == NS_UNCONSTRAINEDSIZE) {
|
2012-10-23 05:48:12 +04:00
|
|
|
// We have an intrinsic-height document with abs-pos/fixed-pos children.
|
|
|
|
// Set the available height and mComputedHeight to our chosen height.
|
2014-07-24 12:30:07 +04:00
|
|
|
reflowState.AvailableBSize() = maxSize.BSize(wm);
|
2012-10-23 05:48:12 +04:00
|
|
|
// Not having border/padding simplifies things
|
2013-12-27 21:59:21 +04:00
|
|
|
NS_ASSERTION(reflowState.ComputedPhysicalBorderPadding() == nsMargin(0,0,0,0),
|
2012-10-23 05:48:12 +04:00
|
|
|
"Viewports can't have border/padding");
|
2014-07-24 12:30:07 +04:00
|
|
|
reflowState.SetComputedBSize(maxSize.BSize(wm));
|
2012-10-23 05:48:12 +04:00
|
|
|
}
|
|
|
|
|
2013-04-24 20:17:55 +04:00
|
|
|
nsRect rect = AdjustReflowStateAsContainingBlock(&reflowState);
|
2015-01-06 12:27:56 +03:00
|
|
|
nsOverflowAreas* overflowAreas = &aDesiredSize.mOverflowAreas;
|
2014-09-23 17:44:00 +04:00
|
|
|
nsIScrollableFrame* rootScrollFrame =
|
|
|
|
aPresContext->PresShell()->GetRootScrollFrameAsScrollable();
|
|
|
|
if (rootScrollFrame && !rootScrollFrame->IsIgnoringViewportClipping()) {
|
2015-01-06 12:27:56 +03:00
|
|
|
overflowAreas = nullptr;
|
2014-09-23 17:44:00 +04:00
|
|
|
}
|
2015-12-23 01:03:16 +03:00
|
|
|
AbsPosReflowFlags flags =
|
|
|
|
AbsPosReflowFlags::eCBWidthAndHeightChanged; // XXX could be optimized
|
2015-01-06 12:27:56 +03:00
|
|
|
GetAbsoluteContainingBlock()->Reflow(this, aPresContext, reflowState, aStatus,
|
2015-12-23 01:03:16 +03:00
|
|
|
rect, flags, overflowAreas);
|
2014-09-23 17:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mFrames.NotEmpty()) {
|
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, mFrames.FirstChild());
|
2011-04-30 03:02:33 +04:00
|
|
|
}
|
2003-02-22 23:13:12 +03: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 08:38:33 +03:00
|
|
|
// If we were dirty then do a repaint
|
|
|
|
if (GetStateBits() & NS_FRAME_IS_DIRTY) {
|
2012-08-29 09:39:31 +04:00
|
|
|
InvalidateFrame();
|
1999-07-24 19:18:24 +04:00
|
|
|
}
|
|
|
|
|
2011-12-05 16:38:46 +04: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 05:01:07 +03:00
|
|
|
|
1999-01-26 03:05:21 +03:00
|
|
|
NS_FRAME_TRACE_REFLOW_OUT("ViewportFrame::Reflow", aStatus);
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1999-01-26 03:05:21 +03:00
|
|
|
}
|
|
|
|
|
2014-09-23 17:44:00 +04:00
|
|
|
bool
|
|
|
|
ViewportFrame::UpdateOverflow()
|
|
|
|
{
|
|
|
|
nsIScrollableFrame* rootScrollFrame =
|
|
|
|
PresContext()->PresShell()->GetRootScrollFrameAsScrollable();
|
|
|
|
if (rootScrollFrame && !rootScrollFrame->IsIgnoringViewportClipping()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsFrame::UpdateOverflow();
|
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
ViewportFrame::GetType() const
|
1999-02-14 06:47:33 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::viewportFrame;
|
1999-02-14 06:47:33 +03:00
|
|
|
}
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2001-11-14 04:33:42 +03:00
|
|
|
ViewportFrame::GetFrameName(nsAString& aResult) const
|
1999-01-26 03:05:21 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Viewport"), aResult);
|
1999-01-26 03:05:21 +03:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|