Bug 1064843 part 8 - Add frame class for backdrop frame. r=dbaron

--HG--
extra : source : 2418fec124dddb2268e7118e36d002904a1ede34
This commit is contained in:
Xidorn Quan 2016-01-28 10:11:00 +11:00
Родитель ee035ed239
Коммит 3d1329f21c
5 изменённых файлов: 141 добавлений и 0 удалений

Просмотреть файл

@ -126,6 +126,7 @@ GK_ATOM(autoplay, "autoplay")
GK_ATOM(autorepeatbutton, "autorepeatbutton") GK_ATOM(autorepeatbutton, "autorepeatbutton")
GK_ATOM(axis, "axis") GK_ATOM(axis, "axis")
GK_ATOM(b, "b") GK_ATOM(b, "b")
GK_ATOM(backdropFrame, "BackdropFrame")
GK_ATOM(background, "background") GK_ATOM(background, "background")
GK_ATOM(base, "base") GK_ATOM(base, "base")
GK_ATOM(basefont, "basefont") GK_ATOM(basefont, "basefont")

Просмотреть файл

@ -115,6 +115,7 @@ UNIFIED_SOURCES += [
'FrameChildList.cpp', 'FrameChildList.cpp',
'MathMLTextRunFactory.cpp', 'MathMLTextRunFactory.cpp',
'nsAbsoluteContainingBlock.cpp', 'nsAbsoluteContainingBlock.cpp',
'nsBackdropFrame.cpp',
'nsBlockFrame.cpp', 'nsBlockFrame.cpp',
'nsBlockReflowContext.cpp', 'nsBlockReflowContext.cpp',
'nsBlockReflowState.cpp', 'nsBlockReflowState.cpp',

Просмотреть файл

@ -0,0 +1,92 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// vim:cindent:ts=2:et:sw=2:
/* 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"
using namespace mozilla;
NS_IMPL_FRAMEARENA_HELPERS(nsBackdropFrame)
/* virtual */ nsIAtom*
nsBackdropFrame::GetType() const
{
return nsGkAtoms::backdropFrame;
}
#ifdef DEBUG_FRAME_DUMP
nsresult
nsBackdropFrame::GetFrameName(nsAString& aResult) const
{
return MakeFrameName(NS_LITERAL_STRING("Backdrop"), aResult);
}
#endif
/* virtual */ nsStyleContext*
nsBackdropFrame::GetParentStyleContext(nsIFrame** aProviderFrame) const
{
// Style context of backdrop pseudo-element does not inherit from
// any element, per the Fullscreen API spec.
*aProviderFrame = nullptr;
return nullptr;
}
/* virtual */ void
nsBackdropFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists)
{
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;
if (display != NS_STYLE_DISPLAY_NONE &&
display != NS_STYLE_DISPLAY_CONTENTS) {
DisplayBorderBackgroundOutline(aBuilder, aLists);
}
}
/* virtual */ LogicalSize
nsBackdropFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
WritingMode aWM,
const LogicalSize& aCBSize,
nscoord aAvailableISize,
const LogicalSize& aMargin,
const LogicalSize& aBorder,
const LogicalSize& aPadding,
bool aShrinkWrap)
{
// Note that this frame is a child of the viewport frame.
LogicalSize result(aWM, 0xdeadbeef, NS_UNCONSTRAINEDSIZE);
if (aShrinkWrap) {
result.ISize(aWM) = 0;
} else {
result.ISize(aWM) = aAvailableISize - aMargin.ISize(aWM) -
aBorder.ISize(aWM) - aPadding.ISize(aWM);
}
return result;
}
/* virtual */ void
nsBackdropFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsBackdropFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
// Note that this frame is a child of the viewport frame.
WritingMode wm = aReflowState.GetWritingMode();
LogicalMargin borderPadding = aReflowState.ComputedLogicalBorderPadding();
nscoord isize = aReflowState.ComputedISize() + borderPadding.IStartEnd(wm);
nscoord bsize = aReflowState.ComputedBSize() + borderPadding.BStartEnd(wm);
aDesiredSize.SetSize(wm, LogicalSize(wm, isize, bsize));
aStatus = NS_FRAME_COMPLETE;
}

Просмотреть файл

@ -0,0 +1,46 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// vim:cindent:ts=2:et:sw=2:
/* 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" */
#ifndef nsBackdropFrame_h___
#define nsBackdropFrame_h___
#include "nsFrame.h"
class nsBackdropFrame final : public nsFrame
{
public:
NS_DECL_FRAMEARENA_HELPERS
explicit nsBackdropFrame(nsStyleContext* aContext)
: nsFrame(aContext) { }
// nsIFrame overrides
virtual nsIAtom* GetType() const override;
#ifdef DEBUG_FRAME_DUMP
virtual nsresult GetFrameName(nsAString& aResult) const override;
#endif
virtual nsStyleContext*
GetParentStyleContext(nsIFrame** aProviderFrame) const override;
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) override;
virtual LogicalSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
WritingMode aWM,
const LogicalSize& aCBSize,
nscoord aAvailableISize,
const LogicalSize& aMargin,
const LogicalSize& aBorder,
const LogicalSize& aPadding,
bool aShrinkWrap) override;
virtual void Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus) override;
};
#endif // nsBackdropFrame_h___

Просмотреть файл

@ -5,6 +5,7 @@
FRAME_ID(BRFrame) FRAME_ID(BRFrame)
FRAME_ID(nsAutoRepeatBoxFrame) FRAME_ID(nsAutoRepeatBoxFrame)
FRAME_ID(nsBCTableCellFrame) FRAME_ID(nsBCTableCellFrame)
FRAME_ID(nsBackdropFrame)
FRAME_ID(nsBlockFrame) FRAME_ID(nsBlockFrame)
FRAME_ID(nsBox) FRAME_ID(nsBox)
FRAME_ID(nsBoxFrame) FRAME_ID(nsBoxFrame)