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"
|
|
|
|
|
2017-06-21 00:21:27 +03:00
|
|
|
#include "mozilla/ServoRestyleManager.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"
|
2017-07-17 21:42:12 +03:00
|
|
|
#include "mozilla/ServoStyleContextInlines.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);
|
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
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
ViewportFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists)
|
2000-03-22 05:43:08 +03:00
|
|
|
{
|
Bug 1375392 - Tweak the PROFILER_LABEL* macros. r=mstange.
This patch makes the following changes to the macros.
- Removes PROFILER_LABEL_FUNC. It's only suitable for use in functions outside
classes, due to PROFILER_FUNCTION_NAME not getting class names, and it was
mostly misused.
- Removes PROFILER_FUNCTION_NAME. It's no longer used, and __func__ is
universally available now anyway.
- Combines the first two string literal arguments of PROFILER_LABEL and
PROFILER_LABEL_DYNAMIC into a single argument. There was no good reason for
them to be separate, and it forced a '::' in the label, which isn't always
appropriate. Also, the meaning of the "name_space" argument was interpreted
in an interesting variety of ways.
- Adds an "AUTO_" prefix to PROFILER_LABEL and PROFILER_LABEL_DYNAMIC, to make
it clearer they construct RAII objects rather than just being function calls.
(I myself have screwed up the scoping because of this in the past.)
- Fills in the 'js::ProfileEntry::Category::' qualifier within the macro, so
the caller doesn't need to. This makes a *lot* more of the uses fit onto a
single line.
The patch also makes the following changes to the macro uses (beyond those
required by the changes described above).
- Fixes a bunch of labels that had gotten out of sync with the name of the
class and/or function that encloses them.
- Removes a useless PROFILER_LABEL use within a trivial scope in
EventStateManager::DispatchMouseOrPointerEvent(). It clearly wasn't serving
any useful purpose. It also serves as extra evidence that the AUTO_ prefix is
a good idea.
- Tweaks DecodePool::SyncRunIf{Preferred,Possible} so that the labelling is
done within them, instead of at their callsites, because that's a more
standard way of doing things.
--HG--
extra : rebase_source : 318d1bc6fc1425a94aacbf489dd46e4f83211de4
2017-06-22 10:08:53 +03:00
|
|
|
AUTO_PROFILER_LABEL("ViewportFrame::BuildDisplayList", GRAPHICS);
|
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
|
|
|
}
|
|
|
|
|
2017-11-16 06:09:28 +03:00
|
|
|
nsDisplayList topLayerList;
|
2015-10-07 06:04:32 +03:00
|
|
|
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 =
|
2018-02-13 03:43:28 +03:00
|
|
|
MakeDisplayItem<nsDisplayWrapList>(aBuilder, this, &topLayerList);
|
2015-10-07 06:04:32 +03:00
|
|
|
wrapList->SetOverrideZIndex(
|
|
|
|
std::numeric_limits<decltype(wrapList->ZIndex())>::max());
|
2017-12-13 20:23:04 +03:00
|
|
|
aLists.PositionedDescendants()->AppendToTop(wrapList);
|
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
|
2017-10-04 04:28:38 +03:00
|
|
|
buildingForChild(aBuilder, aFrame, visible, dirty,
|
2017-08-07 05:23:35 +03:00
|
|
|
aBuilder->IsAtRootOfPseudoStackingContext());
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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()) {
|
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
|
|
|
|
2017-11-09 05:00:48 +03:00
|
|
|
nsIPresShell* shell = PresShell();
|
2015-10-19 03:56:13 +03:00
|
|
|
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
|
2017-06-09 22:14:53 +03:00
|
|
|
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;
|
|
|
|
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
|
2017-06-09 22:14:53 +03:00
|
|
|
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;
|
|
|
|
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
|
2016-07-21 13:36:39 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-04-24 20:17:55 +04:00
|
|
|
nsRect
|
2016-07-21 13:36:39 +03:00
|
|
|
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");
|
|
|
|
|
|
|
|
// 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 13:36:39 +03:00
|
|
|
nsRect rect(0, 0, aReflowInput->ComputedWidth(), aReflowInput->ComputedHeight());
|
2017-11-09 05:00:48 +03:00
|
|
|
nsIPresShell* ps = PresShell();
|
2013-04-24 20:17:55 +04:00
|
|
|
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,
|
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,
|
2002-05-10 22:22:41 +04:00
|
|
|
kidFrame, availableSpace);
|
|
|
|
|
|
|
|
// Reflow the frame
|
2016-07-21 13:36:39 +03:00
|
|
|
kidReflowInput.SetComputedBSize(aReflowInput.ComputedBSize());
|
|
|
|
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowInput,
|
2014-05-13 04:47:52 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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()) {
|
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
|
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-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
|
2016-07-21 13:36:39 +03:00
|
|
|
GetAbsoluteContainingBlock()->Reflow(this, aPresContext, reflowInput, 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()) {
|
2017-11-09 05:00:48 +03:00
|
|
|
container->PresShell()->
|
2011-12-05 16:38:46 +04:00
|
|
|
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);
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
1999-01-26 03:05:21 +03:00
|
|
|
}
|
|
|
|
|
2014-09-23 17:44:00 +04:00
|
|
|
bool
|
2016-05-04 03:27:43 +03:00
|
|
|
ViewportFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas)
|
2014-09-23 17:44:00 +04:00
|
|
|
{
|
|
|
|
nsIScrollableFrame* rootScrollFrame =
|
2017-11-09 05:00:48 +03:00
|
|
|
PresShell()->GetRootScrollFrameAsScrollable();
|
2014-09-23 17:44:00 +04:00
|
|
|
if (rootScrollFrame && !rootScrollFrame->IsIgnoringViewportClipping()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-04 03:27:43 +03:00
|
|
|
return nsContainerFrame::ComputeCustomOverflow(aOverflowAreas);
|
2014-09-23 17:44:00 +04:00
|
|
|
}
|
|
|
|
|
2017-06-21 18:45:12 +03:00
|
|
|
void
|
2017-06-21 00:21:27 +03:00
|
|
|
ViewportFrame::UpdateStyle(ServoRestyleState& aRestyleState)
|
2017-06-21 18:45:12 +03:00
|
|
|
{
|
2017-06-28 04:34:06 +03:00
|
|
|
ServoStyleContext* oldContext = StyleContext()->AsServo();
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* pseudo = oldContext->GetPseudo();
|
2017-06-28 04:34:06 +03:00
|
|
|
RefPtr<ServoStyleContext> newContext =
|
2017-06-21 00:21:27 +03:00
|
|
|
aRestyleState.StyleSet().ResolveInheritingAnonymousBoxStyle(pseudo, nullptr);
|
2017-06-21 18:45:12 +03:00
|
|
|
|
|
|
|
// We're special because we have a null GetContent(), so don't call things
|
|
|
|
// like UpdateStyleOfOwnedChildFrame that try to append changes for the
|
|
|
|
// content to the change list. Nor do we computed a changehint, since we have
|
|
|
|
// no way to apply it anyway.
|
2017-07-21 06:42:43 +03:00
|
|
|
newContext->ResolveSameStructsAs(oldContext);
|
2017-06-21 18:45:12 +03:00
|
|
|
|
|
|
|
MOZ_ASSERT(!GetNextContinuation(), "Viewport has continuations?");
|
|
|
|
SetStyleContext(newContext);
|
|
|
|
|
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
|
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
|