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: */
|
2016-01-28 02:11:00 +03: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/. */
|
|
|
|
|
|
|
|
/* rendering object for CSS "::backdrop" */
|
|
|
|
|
|
|
|
#include "nsBackdropFrame.h"
|
|
|
|
|
2016-09-03 01:01:09 +03:00
|
|
|
#include "nsDisplayList.h"
|
|
|
|
|
2016-01-28 02:11:00 +03:00
|
|
|
using namespace mozilla;
|
|
|
|
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsBackdropFrame)
|
|
|
|
|
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
|
|
|
nsresult nsBackdropFrame::GetFrameName(nsAString& aResult) const {
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Backdrop"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
ComputedStyle* nsBackdropFrame::GetParentComputedStyle(
|
2018-03-22 21:20:41 +03:00
|
|
|
nsIFrame** aProviderFrame) const {
|
2016-01-28 02:11:00 +03:00
|
|
|
// Style context of backdrop pseudo-element does not inherit from
|
|
|
|
// any element, per the Fullscreen API spec.
|
|
|
|
*aProviderFrame = nullptr;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
void nsBackdropFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) {
|
2016-01-28 02:11:00 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsBackdropFrame");
|
|
|
|
// We want this frame to always be there even if its display value is
|
|
|
|
// none or contents so that we can respond to style change on it. To
|
|
|
|
// support those values, we skip painting ourselves in those cases.
|
|
|
|
auto display = StyleDisplay()->mDisplay;
|
2016-09-03 21:46:58 +03:00
|
|
|
if (display == mozilla::StyleDisplay::None ||
|
2016-08-28 05:31:50 +03:00
|
|
|
display == mozilla::StyleDisplay::Contents) {
|
2016-02-12 22:14:05 +03:00
|
|
|
return;
|
2016-01-28 02:11:00 +03:00
|
|
|
}
|
2016-02-12 22:14:05 +03:00
|
|
|
|
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
2016-01-28 02:11:00 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
LogicalSize nsBackdropFrame::ComputeAutoSize(
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
|
2016-11-05 04:57:06 +03:00
|
|
|
nscoord aAvailableISize, const LogicalSize& aMargin,
|
|
|
|
const LogicalSize& aBorder, const LogicalSize& aPadding,
|
|
|
|
ComputeSizeFlags aFlags) {
|
2016-01-28 02:11:00 +03:00
|
|
|
// Note that this frame is a child of the viewport frame.
|
|
|
|
LogicalSize result(aWM, 0xdeadbeef, NS_UNCONSTRAINEDSIZE);
|
2016-11-05 04:57:06 +03:00
|
|
|
if (aFlags & ComputeSizeFlags::eShrinkWrap) {
|
2016-01-28 02:11:00 +03:00
|
|
|
result.ISize(aWM) = 0;
|
|
|
|
} else {
|
|
|
|
result.ISize(aWM) = aAvailableISize - aMargin.ISize(aWM) -
|
|
|
|
aBorder.ISize(aWM) - aPadding.ISize(aWM);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
void nsBackdropFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
ReflowOutput& aDesiredSize,
|
|
|
|
const ReflowInput& aReflowInput,
|
|
|
|
nsReflowStatus& aStatus) {
|
2016-01-28 02:11:00 +03:00
|
|
|
MarkInReflow();
|
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsBackdropFrame");
|
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!");
|
2016-01-28 02:11:00 +03:00
|
|
|
|
|
|
|
// Note that this frame is a child of the viewport frame.
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode wm = aReflowInput.GetWritingMode();
|
|
|
|
LogicalMargin borderPadding = aReflowInput.ComputedLogicalBorderPadding();
|
|
|
|
nscoord isize = aReflowInput.ComputedISize() + borderPadding.IStartEnd(wm);
|
|
|
|
nscoord bsize = aReflowInput.ComputedBSize() + borderPadding.BStartEnd(wm);
|
2016-01-28 02:11:00 +03:00
|
|
|
aDesiredSize.SetSize(wm, LogicalSize(wm, isize, bsize));
|
|
|
|
}
|