2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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
|
|
|
|
*/
|
|
|
|
|
2016-11-30 06:14:29 +03:00
|
|
|
#include "mozilla/ViewportFrame.h"
|
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
#include "mozilla/ComputedStyleInlines.h"
|
2019-04-06 09:02:28 +03:00
|
|
|
#include "mozilla/PresShell.h"
|
2018-04-05 22:12:37 +03:00
|
|
|
#include "mozilla/RestyleManager.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"
|
2016-12-01 01:51:12 +03:00
|
|
|
#include "nsPlaceholderFrame.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
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
ViewportFrame* NS_NewViewportFrame(PresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aStyle) {
|
2019-02-05 19:45:54 +03:00
|
|
|
return new (aPresShell) ViewportFrame(aStyle, aPresShell->GetPresContext());
|
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)
|
2018-12-07 23:00:18 +03:00
|
|
|
NS_QUERYFRAME_ENTRY(ViewportFrame)
|
2013-04-24 20:17:55 +04:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
void ViewportFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) {
|
2016-04-18 09:32:45 +03:00
|
|
|
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2017-03-21 03:22:13 +03:00
|
|
|
// No need to call CreateView() here - the frame ctor will call SetView()
|
|
|
|
// with the ViewManager's root view, so we'll assign it in SetViewInternal().
|
2012-08-29 09:39:01 +04:00
|
|
|
|
|
|
|
nsIFrame* parent = nsLayoutUtils::GetCrossDocParentFrame(this);
|
|
|
|
if (parent) {
|
|
|
|
nsFrameState state = parent->GetStateBits();
|
|
|
|
|
2017-08-24 14:09:42 +03:00
|
|
|
AddStateBits(state & (NS_FRAME_IN_POPUP));
|
2012-08-29 09:39:01 +04: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
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
void ViewportFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) {
|
2019-02-16 20:38:23 +03:00
|
|
|
AUTO_PROFILER_LABEL("ViewportFrame::BuildDisplayList",
|
|
|
|
GRAPHICS_DisplayListBuilding);
|
2014-05-24 01:12:29 +04:00
|
|
|
|
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.
|
2017-08-07 05:23:35 +03:00
|
|
|
BuildDisplayListForChild(aBuilder, kid, aLists);
|
2015-10-07 06:04:32 +03:00
|
|
|
}
|
|
|
|
}
|
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);
|
2016-10-15 04:46:26 +03:00
|
|
|
if (browserFrame && browserFrame->GetReallyIsBrowser()) {
|
2015-10-07 06:04:32 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
|
2015-10-19 03:56:13 +03:00
|
|
|
static void BuildDisplayListForTopLayerFrame(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsDisplayList* aList) {
|
2017-10-04 04:28:38 +03:00
|
|
|
nsRect visible;
|
2015-10-19 03:56:13 +03:00
|
|
|
nsRect dirty;
|
2016-04-06 11:48:31 +03:00
|
|
|
DisplayListClipState::AutoClipMultiple clipState(aBuilder);
|
2017-02-01 01:07:35 +03:00
|
|
|
nsDisplayListBuilder::AutoCurrentActiveScrolledRootSetter asrSetter(aBuilder);
|
2015-10-19 03:56:13 +03:00
|
|
|
nsDisplayListBuilder::OutOfFlowDisplayData* savedOutOfFlowData =
|
|
|
|
nsDisplayListBuilder::GetOutOfFlowData(aFrame);
|
|
|
|
if (savedOutOfFlowData) {
|
2017-03-01 02:09:43 +03:00
|
|
|
visible =
|
|
|
|
savedOutOfFlowData->GetVisibleRectForFrame(aBuilder, aFrame, &dirty);
|
2017-01-27 19:33:53 +03:00
|
|
|
// This function is called after we've finished building display items for
|
|
|
|
// the root scroll frame. That means that the content clip from the root
|
|
|
|
// scroll frame is no longer on aBuilder. However, we need to make sure
|
|
|
|
// that the display items we build in this function have finite clipped
|
|
|
|
// bounds with respect to the root ASR, so we restore the *combined clip*
|
|
|
|
// that we saved earlier. The combined clip will include the clip from the
|
|
|
|
// root scroll frame.
|
2017-02-01 01:07:35 +03:00
|
|
|
clipState.SetClipChainForContainingBlockDescendants(
|
2017-01-27 19:33:53 +03:00
|
|
|
savedOutOfFlowData->mCombinedClipChain);
|
2017-02-01 01:07:35 +03:00
|
|
|
clipState.ClipContainingBlockDescendantsExtra(
|
2017-10-24 23:57:36 +03:00
|
|
|
visible + aBuilder->ToReferenceFrame(aFrame), nullptr);
|
2017-02-01 01:07:35 +03:00
|
|
|
asrSetter.SetCurrentActiveScrolledRoot(
|
|
|
|
savedOutOfFlowData->mContainingBlockActiveScrolledRoot);
|
2015-10-19 03:56:13 +03:00
|
|
|
}
|
2017-08-07 05:23:35 +03:00
|
|
|
nsDisplayListBuilder::AutoBuildingDisplayList buildingForChild(
|
2019-04-15 18:15:49 +03:00
|
|
|
aBuilder, aFrame, visible, dirty);
|
2017-08-07 05:23:35 +03:00
|
|
|
|
2017-11-16 06:09:28 +03:00
|
|
|
nsDisplayList list;
|
2017-08-07 05:23:35 +03:00
|
|
|
aFrame->BuildDisplayListForStackingContext(aBuilder, &list);
|
2015-10-19 03:56:13 +03:00
|
|
|
aList->AppendToTop(&list);
|
|
|
|
}
|
|
|
|
|
2015-10-07 06:04:32 +03:00
|
|
|
void ViewportFrame::BuildDisplayListForTopLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayList* aList) {
|
2019-01-02 16:05:23 +03:00
|
|
|
nsTArray<Element*> fullscreenStack =
|
|
|
|
PresContext()->Document()->GetFullscreenStack();
|
2015-10-07 06:04:32 +03:00
|
|
|
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(),
|
2018-12-05 21:44:05 +03:00
|
|
|
"HTML element should always be out-of-flow if in the top "
|
|
|
|
"layer");
|
2015-10-07 06:04:32 +03:00
|
|
|
continue;
|
|
|
|
}
|
2016-01-28 02:11:00 +03:00
|
|
|
if (nsIFrame* backdropPh =
|
|
|
|
frame->GetChildList(kBackdropList).FirstChild()) {
|
2017-04-30 18:30:08 +03:00
|
|
|
MOZ_ASSERT(backdropPh->IsPlaceholderFrame());
|
2017-11-10 21:28:05 +03:00
|
|
|
MOZ_ASSERT(!backdropPh->GetNextSibling(), "more than one ::backdrop?");
|
|
|
|
MOZ_ASSERT(backdropPh->HasAnyStateBits(NS_FRAME_FIRST_REFLOW),
|
|
|
|
"did you intend to reflow ::backdrop placeholders?");
|
2016-01-28 02:11:00 +03:00
|
|
|
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
|
|
|
|
2019-04-06 09:02:28 +03:00
|
|
|
if (nsCanvasFrame* canvasFrame = PresShell()->GetCanvasFrame()) {
|
2015-10-19 03:56:13 +03:00
|
|
|
if (Element* container = canvasFrame->GetCustomContentContainer()) {
|
|
|
|
if (nsIFrame* frame = container->GetPrimaryFrame()) {
|
2018-06-11 05:45:10 +03:00
|
|
|
MOZ_ASSERT(frame->StyleDisplay()->mTopLayer != NS_STYLE_TOP_LAYER_NONE,
|
|
|
|
"ua.css should ensure this");
|
|
|
|
MOZ_ASSERT(frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW);
|
|
|
|
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
|
2011-08-25 00:54:30 +04:00
|
|
|
void ViewportFrame::AppendFrames(ChildListID aListID, nsFrameList& aFrameList) {
|
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
|
|
|
}
|
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
void ViewportFrame::InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList) {
|
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
|
|
|
}
|
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
void ViewportFrame::RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) {
|
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
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
nscoord ViewportFrame::GetMinISize(gfxContext* 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;
|
2018-09-12 15:35:47 +03:00
|
|
|
DISPLAY_MIN_INLINE_SIZE(this, result);
|
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 (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;
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
nscoord ViewportFrame::GetPrefISize(gfxContext* 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;
|
2018-09-12 15:35:47 +03:00
|
|
|
DISPLAY_PREF_INLINE_SIZE(this, result);
|
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 (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;
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
nsPoint ViewportFrame::AdjustReflowInputForScrollbars(
|
|
|
|
ReflowInput* aReflowInput) 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) {
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode wm = aReflowInput->GetWritingMode();
|
2016-05-18 23:07:54 +03:00
|
|
|
LogicalMargin scrollbars(wm, scrollingFrame->GetActualScrollbarSizes());
|
2016-07-21 13:36:39 +03:00
|
|
|
aReflowInput->SetComputedISize(aReflowInput->ComputedISize() -
|
2016-05-18 23:07:54 +03:00
|
|
|
scrollbars.IStartEnd(wm));
|
2016-07-21 13:36:39 +03:00
|
|
|
aReflowInput->AvailableISize() -= scrollbars.IStartEnd(wm);
|
|
|
|
aReflowInput->SetComputedBSizeWithoutResettingResizeFlags(
|
|
|
|
aReflowInput->ComputedBSize() - scrollbars.BStartEnd(wm));
|
2016-05-18 23:07:54 +03:00
|
|
|
return nsPoint(scrollbars.Left(wm), scrollbars.Top(wm));
|
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
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
nsRect ViewportFrame::AdjustReflowInputAsContainingBlock(
|
|
|
|
ReflowInput* aReflowInput) const {
|
2013-04-24 20:17:55 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsPoint offset =
|
|
|
|
#endif
|
2016-07-21 13:36:39 +03:00
|
|
|
AdjustReflowInputForScrollbars(aReflowInput);
|
2013-04-24 20:17:55 +04: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");
|
|
|
|
|
2018-07-04 23:10:04 +03:00
|
|
|
// Layout fixed position elements to the visual viewport size if and only if
|
|
|
|
// it has been set and it is larger than the computed size, otherwise use the
|
|
|
|
// computed size.
|
2018-07-20 21:40:51 +03:00
|
|
|
nsRect rect(0, 0, aReflowInput->ComputedWidth(),
|
|
|
|
aReflowInput->ComputedHeight());
|
2019-04-06 09:02:28 +03:00
|
|
|
mozilla::PresShell* presShell = PresShell();
|
|
|
|
if (presShell->IsVisualViewportSizeSet() &&
|
|
|
|
rect.Size() < presShell->GetVisualViewportSize()) {
|
|
|
|
rect.SizeTo(presShell->GetVisualViewportSize());
|
2018-07-20 21:40:51 +03:00
|
|
|
}
|
2019-02-07 08:39:33 +03:00
|
|
|
// Expand the size to the layout viewport size if necessary.
|
2019-04-06 09:02:28 +03:00
|
|
|
const nsSize layoutViewportSize = presShell->GetLayoutViewportSize();
|
2019-02-07 08:39:33 +03:00
|
|
|
if (rect.Size() < layoutViewportSize) {
|
|
|
|
rect.SizeTo(layoutViewportSize);
|
|
|
|
}
|
2018-07-20 21:40:51 +03:00
|
|
|
return rect;
|
2013-04-24 20:17:55 +04:00
|
|
|
}
|
|
|
|
|
2008-10-30 03:41:56 +03:00
|
|
|
void ViewportFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
1999-01-26 03:05:21 +03:00
|
|
|
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");
|
2016-07-21 13:36:39 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
2017-09-13 13:00:25 +03:00
|
|
|
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
|
1999-01-26 03:05:21 +03:00
|
|
|
NS_FRAME_TRACE_REFLOW_IN("ViewportFrame::Reflow");
|
|
|
|
|
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.
|
2016-07-21 13:36:39 +03:00
|
|
|
SetSize(nsSize(aReflowInput.ComputedWidth(), aReflowInput.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;
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode wm = aReflowInput.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.
|
2016-07-21 13:36:39 +03:00
|
|
|
if (aReflowInput.ShouldReflowAllKids() || aReflowInput.IsBResize() ||
|
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();
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowOutput kidDesiredSize(aReflowInput);
|
2014-07-24 12:28:46 +04:00
|
|
|
WritingMode wm = kidFrame->GetWritingMode();
|
2016-07-21 13:36:39 +03:00
|
|
|
LogicalSize availableSpace = aReflowInput.AvailableSize(wm);
|
|
|
|
ReflowInput kidReflowInput(aPresContext, aReflowInput, kidFrame,
|
2002-05-10 22:22:41 +04:00
|
|
|
availableSpace);
|
|
|
|
|
|
|
|
// Reflow the frame
|
2016-07-21 13:36:39 +03:00
|
|
|
kidReflowInput.SetComputedBSize(aReflowInput.ComputedBSize());
|
|
|
|
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowInput, 0, 0,
|
2014-05-13 04:47:52 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:39 +03: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 08:38:33 +03:00
|
|
|
"shouldn't happen anymore");
|
|
|
|
|
|
|
|
// Return the max size as our desired size
|
2016-07-21 13:36:39 +03:00
|
|
|
LogicalSize maxSize(wm, aReflowInput.AvailableISize(),
|
2014-07-24 12:30:07 +04:00
|
|
|
// Being flowed initially at an unconstrained block size
|
|
|
|
// means we should return our child's intrinsic size.
|
2016-07-21 13:36:39 +03:00
|
|
|
aReflowInput.ComputedBSize() != NS_UNCONSTRAINEDSIZE
|
|
|
|
? aReflowInput.ComputedBSize()
|
2014-07-24 12:30:07 +04:00
|
|
|
: 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()) {
|
2019-04-11 23:27:37 +03:00
|
|
|
// Make a copy of the reflow input and change the computed width and height
|
2012-10-23 05:48:12 +04:00
|
|
|
// to reflect the available space for the fixed items
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowInput reflowInput(aReflowInput);
|
2012-10-23 05:48:12 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
if (reflowInput.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.
|
2016-07-21 13:36:39 +03:00
|
|
|
reflowInput.AvailableBSize() = maxSize.BSize(wm);
|
2012-10-23 05:48:12 +04:00
|
|
|
// Not having border/padding simplifies things
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_ASSERTION(
|
|
|
|
reflowInput.ComputedPhysicalBorderPadding() == nsMargin(0, 0, 0, 0),
|
2012-10-23 05:48:12 +04:00
|
|
|
"Viewports can't have border/padding");
|
2016-07-21 13:36:39 +03:00
|
|
|
reflowInput.SetComputedBSize(maxSize.BSize(wm));
|
2012-10-23 05:48:12 +04:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
nsRect rect = AdjustReflowInputAsContainingBlock(&reflowInput);
|
2015-12-23 01:03:16 +03:00
|
|
|
AbsPosReflowFlags flags =
|
|
|
|
AbsPosReflowFlags::eCBWidthAndHeightChanged; // XXX could be optimized
|
2018-11-21 23:06:15 +03:00
|
|
|
GetAbsoluteContainingBlock()->Reflow(this, aPresContext, reflowInput,
|
|
|
|
aStatus, rect, flags,
|
|
|
|
/* aOverflowAreas = */ nullptr);
|
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.
|
2018-11-21 23:06:15 +03:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
2007-01-25 05:01:07 +03:00
|
|
|
|
1999-01-26 03:05:21 +03:00
|
|
|
NS_FRAME_TRACE_REFLOW_OUT("ViewportFrame::Reflow", aStatus);
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
1999-01-26 03:05:21 +03:00
|
|
|
}
|
|
|
|
|
2017-06-21 00:21:27 +03:00
|
|
|
void ViewportFrame::UpdateStyle(ServoRestyleState& aRestyleState) {
|
2018-03-25 13:23:00 +03:00
|
|
|
RefPtr<ComputedStyle> newStyle =
|
2019-02-19 16:44:33 +03:00
|
|
|
aRestyleState.StyleSet().ResolveInheritingAnonymousBoxStyle(
|
|
|
|
Style()->GetPseudoType(), nullptr);
|
2017-06-21 18:45:12 +03:00
|
|
|
|
|
|
|
MOZ_ASSERT(!GetNextContinuation(), "Viewport has continuations?");
|
2018-03-25 13:23:00 +03:00
|
|
|
SetComputedStyle(newStyle);
|
2017-06-21 18:45:12 +03:00
|
|
|
|
2017-06-21 00:21:27 +03:00
|
|
|
UpdateStyleOfOwnedAnonBoxes(aRestyleState);
|
2017-06-21 18:45:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ViewportFrame::AppendDirectlyOwnedAnonBoxes(
|
|
|
|
nsTArray<OwnedAnonBox>& aResult) {
|
|
|
|
if (mFrames.NotEmpty()) {
|
|
|
|
aResult.AppendElement(mFrames.FirstChild());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsresult ViewportFrame::GetFrameName(nsAString& aResult) const {
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Viewport"), aResult);
|
1999-01-26 03:05:21 +03:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|