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/. */
|
1999-02-20 09:05:15 +03:00
|
|
|
#include "nsButtonFrameRenderer.h"
|
1999-02-19 21:23:02 +03:00
|
|
|
#include "nsCSSRendering.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2016-02-24 10:01:11 +03:00
|
|
|
#include "mozilla/StyleSetHandle.h"
|
|
|
|
#include "mozilla/StyleSetHandleInlines.h"
|
2017-08-28 06:29:35 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2007-02-16 04:53:43 +03:00
|
|
|
#include "nsITheme.h"
|
2013-08-28 18:30:02 +04:00
|
|
|
#include "nsFrame.h"
|
2014-04-03 08:18:36 +04:00
|
|
|
#include "mozilla/EventStates.h"
|
2011-07-20 23:18:54 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2017-03-08 19:31:46 +03:00
|
|
|
#include "Layers.h"
|
|
|
|
#include "gfxPrefs.h"
|
|
|
|
#include "gfxUtils.h"
|
2017-10-03 23:31:08 +03:00
|
|
|
#include "mozilla/layers/WebRenderLayerManager.h"
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-03-06 22:43:13 +03:00
|
|
|
#define ACTIVE "active"
|
|
|
|
#define HOVER "hover"
|
|
|
|
#define FOCUS "focus"
|
1999-02-26 11:48:24 +03:00
|
|
|
|
2015-10-23 05:54:48 +03:00
|
|
|
using namespace mozilla;
|
2015-02-10 10:27:40 +03:00
|
|
|
using namespace mozilla::image;
|
2017-03-08 19:31:46 +03:00
|
|
|
using namespace mozilla::layers;
|
2015-02-10 10:27:40 +03:00
|
|
|
|
1999-02-19 21:23:02 +03:00
|
|
|
nsButtonFrameRenderer::nsButtonFrameRenderer()
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_CTOR(nsButtonFrameRenderer);
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
nsButtonFrameRenderer::~nsButtonFrameRenderer()
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_DTOR(nsButtonFrameRenderer);
|
2015-02-18 01:28:53 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (mInnerFocusStyle) {
|
|
|
|
mInnerFocusStyle->FrameRelease();
|
|
|
|
}
|
|
|
|
#endif
|
1999-02-26 09:41:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsButtonFrameRenderer::SetFrame(nsFrame* aFrame, nsPresContext* aPresContext)
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
mFrame = aFrame;
|
|
|
|
ReResolveStyles(aPresContext);
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
|
|
|
|
1999-09-15 02:17:19 +04:00
|
|
|
nsIFrame*
|
|
|
|
nsButtonFrameRenderer::GetFrame()
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
return mFrame;
|
1999-09-15 02:17:19 +04:00
|
|
|
}
|
|
|
|
|
1999-02-26 11:48:24 +03:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsButtonFrameRenderer::SetDisabled(bool aDisabled, bool notify)
|
1999-02-26 11:48:24 +03:00
|
|
|
{
|
1999-03-13 02:47:52 +03:00
|
|
|
if (aDisabled)
|
2006-12-26 20:47:52 +03:00
|
|
|
mFrame->GetContent()->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled, EmptyString(),
|
2003-07-04 16:50:32 +04:00
|
|
|
notify);
|
1999-03-13 02:47:52 +03:00
|
|
|
else
|
2006-12-26 20:47:52 +03:00
|
|
|
mFrame->GetContent()->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, notify);
|
1999-02-26 11:48:24 +03:00
|
|
|
}
|
1999-02-26 09:41:10 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2017-07-06 15:00:35 +03:00
|
|
|
nsButtonFrameRenderer::isDisabled()
|
1999-02-26 11:48:24 +03:00
|
|
|
{
|
2011-06-01 05:46:56 +04:00
|
|
|
return mFrame->GetContent()->AsElement()->
|
2011-06-01 05:46:57 +04:00
|
|
|
State().HasState(NS_EVENT_STATE_DISABLED);
|
1999-02-26 11:48:24 +03:00
|
|
|
}
|
|
|
|
|
2009-02-10 11:45:13 +03:00
|
|
|
class nsDisplayButtonBoxShadowOuter : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayButtonBoxShadowOuter(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsButtonFrameRenderer* aRenderer)
|
2017-03-08 19:31:46 +03:00
|
|
|
: nsDisplayItem(aBuilder, aRenderer->GetFrame()) {
|
2009-02-10 11:45:13 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayButtonBoxShadowOuter);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayButtonBoxShadowOuter() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayButtonBoxShadowOuter);
|
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
#endif
|
|
|
|
|
2017-08-28 06:29:35 +03:00
|
|
|
virtual bool CreateWebRenderCommands(
|
|
|
|
mozilla::wr::DisplayListBuilder& aBuilder,
|
2017-09-14 19:48:55 +03:00
|
|
|
mozilla::wr::IpcResourceUpdateQueue& aResources,
|
2017-08-28 06:29:35 +03:00
|
|
|
const StackingContextHelper& aSc,
|
|
|
|
mozilla::layers::WebRenderLayerManager* aManager,
|
|
|
|
nsDisplayListBuilder* aDisplayListBuilder) override;
|
|
|
|
|
|
|
|
virtual LayerState GetLayerState(
|
|
|
|
nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerLayerParameters& aParameters) override;
|
|
|
|
|
|
|
|
virtual already_AddRefed<Layer> BuildLayer(
|
|
|
|
nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerLayerParameters& aContainerParameters) override;
|
|
|
|
|
|
|
|
bool CanBuildWebRenderDisplayItems();
|
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aCtx) override;
|
2014-02-24 18:41:56 +04:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
|
2017-08-24 18:09:44 +03:00
|
|
|
bool* aSnap) const override;
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("ButtonBoxShadowOuter", TYPE_BUTTON_BOX_SHADOW_OUTER)
|
2009-02-10 11:45:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
nsRect
|
2017-08-24 18:09:44 +03:00
|
|
|
nsDisplayButtonBoxShadowOuter::GetBounds(nsDisplayListBuilder* aBuilder,
|
|
|
|
bool* aSnap) const
|
|
|
|
{
|
2012-04-10 15:24:18 +04:00
|
|
|
*aSnap = false;
|
2011-10-21 21:45:32 +04:00
|
|
|
return mFrame->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame();
|
2009-02-10 11:45:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsDisplayButtonBoxShadowOuter::Paint(nsDisplayListBuilder* aBuilder,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aCtx) {
|
2010-08-13 14:01:58 +04:00
|
|
|
nsRect frameRect = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
2009-02-10 11:45:13 +03:00
|
|
|
|
|
|
|
nsCSSRendering::PaintBoxShadowOuter(mFrame->PresContext(), *aCtx, mFrame,
|
2017-03-08 19:31:46 +03:00
|
|
|
frameRect, mVisibleRect);
|
2009-02-10 11:45:13 +03:00
|
|
|
}
|
|
|
|
|
2017-08-28 06:29:35 +03:00
|
|
|
bool
|
|
|
|
nsDisplayButtonBoxShadowOuter::CanBuildWebRenderDisplayItems()
|
|
|
|
{
|
|
|
|
nsCSSShadowArray* shadows = mFrame->StyleEffects()->mBoxShadow;
|
|
|
|
if (!shadows) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasBorderRadius;
|
|
|
|
bool nativeTheme =
|
|
|
|
nsCSSRendering::HasBoxShadowNativeTheme(mFrame, hasBorderRadius);
|
|
|
|
|
|
|
|
// We don't support native themed things yet like box shadows around
|
|
|
|
// input buttons.
|
|
|
|
if (nativeTheme) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint offset = ToReferenceFrame();
|
|
|
|
nsRect borderRect = mFrame->VisualBorderRectRelativeToSelf() + offset;
|
|
|
|
nsRect frameRect =
|
|
|
|
nsCSSRendering::GetShadowRect(borderRect, nativeTheme, mFrame);
|
|
|
|
|
|
|
|
if (hasBorderRadius) {
|
|
|
|
nscoord twipsRadii[8];
|
|
|
|
nsSize sz = frameRect.Size();
|
|
|
|
hasBorderRadius = mFrame->GetBorderRadii(sz, sz, Sides(), twipsRadii);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
LayerState
|
|
|
|
nsDisplayButtonBoxShadowOuter::GetLayerState(
|
|
|
|
nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerLayerParameters& aParameters)
|
|
|
|
{
|
|
|
|
if (ShouldUseAdvancedLayer(aManager, gfxPrefs::LayersAllowOuterBoxShadow) &&
|
|
|
|
CanBuildWebRenderDisplayItems()) {
|
|
|
|
return LAYER_ACTIVE;
|
|
|
|
}
|
|
|
|
return LAYER_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Layer>
|
|
|
|
nsDisplayButtonBoxShadowOuter::BuildLayer(
|
|
|
|
nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerLayerParameters& aContainerParameters)
|
|
|
|
{
|
|
|
|
return BuildDisplayItemLayer(aBuilder, aManager, aContainerParameters);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsDisplayButtonBoxShadowOuter::CreateWebRenderCommands(
|
|
|
|
mozilla::wr::DisplayListBuilder& aBuilder,
|
2017-09-14 19:48:55 +03:00
|
|
|
mozilla::wr::IpcResourceUpdateQueue& aResources,
|
2017-08-28 06:29:35 +03:00
|
|
|
const StackingContextHelper& aSc,
|
|
|
|
mozilla::layers::WebRenderLayerManager* aManager,
|
|
|
|
nsDisplayListBuilder* aDisplayListBuilder)
|
|
|
|
{
|
2017-10-03 23:31:07 +03:00
|
|
|
ContainerLayerParameters parameter;
|
|
|
|
if (GetLayerState(aDisplayListBuilder, aManager, parameter) !=
|
|
|
|
LAYER_ACTIVE) {
|
|
|
|
return false;
|
2017-08-28 06:29:35 +03:00
|
|
|
}
|
|
|
|
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
nsRect shadowRect = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
|
|
|
LayoutDeviceRect deviceBox =
|
|
|
|
LayoutDeviceRect::FromAppUnits(shadowRect, appUnitsPerDevPixel);
|
2017-08-31 12:59:41 +03:00
|
|
|
wr::LayoutRect deviceBoxRect = aSc.ToRelativeLayoutRect(deviceBox);
|
2017-08-28 06:29:35 +03:00
|
|
|
|
|
|
|
LayoutDeviceRect clipRect =
|
|
|
|
LayoutDeviceRect::FromAppUnits(mVisibleRect, appUnitsPerDevPixel);
|
|
|
|
wr::LayoutRect deviceClipRect = aSc.ToRelativeLayoutRect(clipRect);
|
|
|
|
|
|
|
|
bool hasBorderRadius;
|
|
|
|
Unused << nsCSSRendering::HasBoxShadowNativeTheme(mFrame, hasBorderRadius);
|
|
|
|
|
2017-10-24 09:44:29 +03:00
|
|
|
LayoutDeviceSize zeroSize;
|
|
|
|
wr::BorderRadius borderRadius = wr::ToBorderRadius(zeroSize, zeroSize,
|
|
|
|
zeroSize, zeroSize);
|
2017-08-28 06:29:35 +03:00
|
|
|
if (hasBorderRadius) {
|
|
|
|
mozilla::gfx::RectCornerRadii borderRadii;
|
|
|
|
hasBorderRadius = nsCSSRendering::GetBorderRadii(
|
|
|
|
shadowRect, shadowRect, mFrame, borderRadii);
|
2017-10-24 09:44:29 +03:00
|
|
|
if (hasBorderRadius) {
|
|
|
|
borderRadius = wr::ToBorderRadius(
|
|
|
|
LayoutDeviceSize::FromUnknownSize(borderRadii.TopLeft()),
|
|
|
|
LayoutDeviceSize::FromUnknownSize(borderRadii.TopRight()),
|
|
|
|
LayoutDeviceSize::FromUnknownSize(borderRadii.BottomLeft()),
|
|
|
|
LayoutDeviceSize::FromUnknownSize(borderRadii.BottomRight()));
|
|
|
|
}
|
|
|
|
|
2017-08-28 06:29:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSShadowArray* shadows = mFrame->StyleEffects()->mBoxShadow;
|
|
|
|
MOZ_ASSERT(shadows);
|
|
|
|
|
|
|
|
for (uint32_t i = shadows->Length(); i > 0; i--) {
|
|
|
|
nsCSSShadowItem* shadow = shadows->ShadowAt(i - 1);
|
|
|
|
if (shadow->mInset) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
float blurRadius = float(shadow->mRadius) / float(appUnitsPerDevPixel);
|
|
|
|
gfx::Color shadowColor =
|
|
|
|
nsCSSRendering::GetShadowColor(shadow, mFrame, 1.0);
|
|
|
|
|
2017-10-19 05:25:11 +03:00
|
|
|
LayoutDevicePoint shadowOffset = LayoutDevicePoint::FromAppUnits(
|
|
|
|
nsPoint(shadow->mXOffset, shadow->mYOffset),
|
|
|
|
appUnitsPerDevPixel);
|
2017-08-28 06:29:35 +03:00
|
|
|
|
|
|
|
float spreadRadius = float(shadow->mSpread) / float(appUnitsPerDevPixel);
|
|
|
|
|
|
|
|
aBuilder.PushBoxShadow(deviceBoxRect,
|
|
|
|
deviceClipRect,
|
2017-09-21 09:41:38 +03:00
|
|
|
!BackfaceIsHidden(),
|
2017-08-28 06:29:35 +03:00
|
|
|
deviceBoxRect,
|
|
|
|
wr::ToLayoutVector2D(shadowOffset),
|
|
|
|
wr::ToColorF(shadowColor),
|
|
|
|
blurRadius,
|
|
|
|
spreadRadius,
|
|
|
|
borderRadius,
|
|
|
|
wr::BoxShadowClipMode::Outset);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-04 21:12:23 +03:00
|
|
|
class nsDisplayButtonBorder : public nsDisplayItem {
|
2006-01-26 05:29:17 +03:00
|
|
|
public:
|
2016-05-04 21:12:23 +03:00
|
|
|
nsDisplayButtonBorder(nsDisplayListBuilder* aBuilder,
|
2010-08-13 14:01:13 +04:00
|
|
|
nsButtonFrameRenderer* aRenderer)
|
|
|
|
: nsDisplayItem(aBuilder, aRenderer->GetFrame()), mBFR(aRenderer) {
|
2016-05-04 21:12:23 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayButtonBorder);
|
2006-01-29 21:48:58 +03:00
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
2016-05-04 21:12:23 +03:00
|
|
|
virtual ~nsDisplayButtonBorder() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayButtonBorder);
|
2006-01-29 21:48:58 +03:00
|
|
|
}
|
2016-05-04 21:12:23 +03:00
|
|
|
#endif
|
2017-07-20 12:34:15 +03:00
|
|
|
virtual bool MustPaintOnContentSide() const override { return true; }
|
|
|
|
|
2010-04-08 04:31:26 +04:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
2014-02-24 18:41:56 +04:00
|
|
|
HitTestState* aState,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsTArray<nsIFrame*> *aOutFrames) override {
|
2010-04-08 04:31:26 +04:00
|
|
|
aOutFrames->AppendElement(mFrame);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aCtx) override;
|
2014-02-24 18:41:56 +04:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
|
2017-08-24 18:09:44 +03:00
|
|
|
bool* aSnap) const override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) override;
|
2013-06-26 20:43:26 +04:00
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
2017-08-24 18:09:44 +03:00
|
|
|
nsRegion *aInvalidRegion) const override;
|
2017-03-08 19:31:46 +03:00
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerLayerParameters& aParameters) override;
|
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerLayerParameters& aContainerParameters) override;
|
2017-07-01 03:23:20 +03:00
|
|
|
virtual bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
|
2017-09-14 19:48:55 +03:00
|
|
|
mozilla::wr::IpcResourceUpdateQueue& aResources,
|
2017-05-03 15:48:07 +03:00
|
|
|
const StackingContextHelper& aSc,
|
2017-07-01 03:23:20 +03:00
|
|
|
mozilla::layers::WebRenderLayerManager* aManager,
|
|
|
|
nsDisplayListBuilder* aDisplayListBuilder) override;
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("ButtonBorderBackground", TYPE_BUTTON_BORDER_BACKGROUND)
|
2006-01-26 05:29:17 +03:00
|
|
|
private:
|
|
|
|
nsButtonFrameRenderer* mBFR;
|
2017-03-27 23:09:55 +03:00
|
|
|
Maybe<nsCSSBorderRenderer> mBorderRenderer;
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
2015-10-23 05:54:48 +03:00
|
|
|
nsDisplayItemGeometry*
|
2016-05-04 21:12:23 +03:00
|
|
|
nsDisplayButtonBorder::AllocateGeometry(nsDisplayListBuilder* aBuilder)
|
2015-10-23 05:54:48 +03:00
|
|
|
{
|
|
|
|
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
|
|
|
|
}
|
|
|
|
|
2017-03-08 19:31:46 +03:00
|
|
|
LayerState
|
|
|
|
nsDisplayButtonBorder::GetLayerState(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerLayerParameters& aParameters)
|
|
|
|
{
|
2017-04-21 18:11:38 +03:00
|
|
|
if (ShouldUseAdvancedLayer(aManager, gfxPrefs::LayersAllowDisplayButtonBorder)) {
|
2017-03-27 23:09:55 +03:00
|
|
|
// TODO: Figure out what to do with sync decode images
|
|
|
|
if (aBuilder->ShouldSyncDecodeImages()) {
|
|
|
|
return LAYER_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint offset = ToReferenceFrame();
|
|
|
|
if (!nsDisplayBoxShadowInner::CanCreateWebRenderCommands(aBuilder,
|
|
|
|
mFrame,
|
|
|
|
offset)) {
|
|
|
|
return LAYER_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Maybe<nsCSSBorderRenderer> br =
|
|
|
|
nsCSSRendering::CreateBorderRenderer(mFrame->PresContext(),
|
|
|
|
nullptr,
|
|
|
|
mFrame,
|
|
|
|
nsRect(),
|
|
|
|
nsRect(offset, mFrame->GetSize()),
|
|
|
|
mFrame->StyleContext(),
|
|
|
|
mFrame->GetSkipSides());
|
|
|
|
if (!br) {
|
|
|
|
return LAYER_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!br->CanCreateWebRenderCommands()) {
|
|
|
|
return LAYER_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mBorderRenderer = br;
|
2017-03-08 19:31:46 +03:00
|
|
|
return LAYER_ACTIVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LAYER_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Layer>
|
|
|
|
nsDisplayButtonBorder::BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerLayerParameters& aContainerParameters)
|
|
|
|
{
|
|
|
|
return BuildDisplayItemLayer(aBuilder, aManager, aContainerParameters);
|
|
|
|
}
|
|
|
|
|
2017-07-01 03:23:20 +03:00
|
|
|
bool
|
2017-03-08 19:31:46 +03:00
|
|
|
nsDisplayButtonBorder::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
|
2017-09-14 19:48:55 +03:00
|
|
|
mozilla::wr::IpcResourceUpdateQueue& aResources,
|
2017-05-03 15:48:07 +03:00
|
|
|
const StackingContextHelper& aSc,
|
2017-07-01 03:23:20 +03:00
|
|
|
mozilla::layers::WebRenderLayerManager* aManager,
|
|
|
|
nsDisplayListBuilder* aDisplayListBuilder)
|
2017-03-08 19:31:46 +03:00
|
|
|
{
|
2017-10-03 23:31:07 +03:00
|
|
|
ContainerLayerParameters parameter;
|
|
|
|
if (GetLayerState(aDisplayListBuilder, aManager, parameter) != LAYER_ACTIVE) {
|
|
|
|
return false;
|
2017-07-01 03:23:20 +03:00
|
|
|
}
|
|
|
|
|
2017-03-27 23:09:55 +03:00
|
|
|
MOZ_ASSERT(mBorderRenderer);
|
2017-07-01 03:23:20 +03:00
|
|
|
|
2017-03-08 19:31:46 +03:00
|
|
|
// This is really a combination of paint box shadow inner +
|
|
|
|
// paint border.
|
|
|
|
nsRect buttonRect = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
2017-07-01 03:23:20 +03:00
|
|
|
bool snap;
|
|
|
|
nsRegion visible = GetBounds(aDisplayListBuilder, &snap);
|
2017-03-08 19:31:46 +03:00
|
|
|
nsDisplayBoxShadowInner::CreateInsetBoxShadowWebRenderCommands(aBuilder,
|
2017-05-03 15:48:08 +03:00
|
|
|
aSc,
|
2017-07-01 03:23:20 +03:00
|
|
|
visible,
|
2017-03-08 19:31:46 +03:00
|
|
|
mFrame,
|
|
|
|
buttonRect);
|
2017-09-14 19:48:55 +03:00
|
|
|
mBorderRenderer->CreateWebRenderCommands(aBuilder, aResources, aSc);
|
2017-07-01 03:23:20 +03:00
|
|
|
|
|
|
|
return true;
|
2017-03-08 19:31:46 +03:00
|
|
|
}
|
|
|
|
|
2015-10-23 05:54:48 +03:00
|
|
|
void
|
2017-08-24 18:09:44 +03:00
|
|
|
nsDisplayButtonBorder::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion *aInvalidRegion) const
|
2015-10-23 05:54:48 +03:00
|
|
|
{
|
|
|
|
auto geometry =
|
|
|
|
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
|
|
|
|
|
|
|
|
if (aBuilder->ShouldSyncDecodeImages() &&
|
|
|
|
geometry->ShouldInvalidateToSyncDecodeImages()) {
|
|
|
|
bool snap;
|
|
|
|
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
|
|
|
|
}
|
|
|
|
|
2017-03-08 19:31:46 +03:00
|
|
|
void
|
|
|
|
nsDisplayButtonBorder::Paint(nsDisplayListBuilder* aBuilder,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aCtx)
|
2015-10-23 05:54:48 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mFrame, "No frame?");
|
|
|
|
nsPresContext* pc = mFrame->PresContext();
|
|
|
|
nsRect r = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
2016-05-04 21:12:23 +03:00
|
|
|
|
2015-10-23 05:54:48 +03:00
|
|
|
// draw the border and background inside the focus and outline borders
|
|
|
|
DrawResult result =
|
2016-05-04 21:12:23 +03:00
|
|
|
mBFR->PaintBorder(aBuilder, pc, *aCtx, mVisibleRect, r);
|
2015-10-23 05:54:48 +03:00
|
|
|
|
|
|
|
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
|
|
|
|
}
|
|
|
|
|
2012-08-29 09:39:01 +04:00
|
|
|
nsRect
|
2017-08-24 18:09:44 +03:00
|
|
|
nsDisplayButtonBorder::GetBounds(nsDisplayListBuilder* aBuilder,
|
|
|
|
bool* aSnap) const
|
|
|
|
{
|
2012-08-29 09:39:01 +04:00
|
|
|
*aSnap = false;
|
2012-09-28 15:19:38 +04:00
|
|
|
return aBuilder->IsForEventDelivery() ? nsRect(ToReferenceFrame(), mFrame->GetSize())
|
|
|
|
: mFrame->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame();
|
2012-08-29 09:39:01 +04:00
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
class nsDisplayButtonForeground : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayButtonForeground(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsButtonFrameRenderer* aRenderer)
|
|
|
|
: nsDisplayItem(aBuilder, aRenderer->GetFrame()), mBFR(aRenderer) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayButtonForeground);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayButtonForeground() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayButtonForeground);
|
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
#endif
|
2006-01-29 21:48:58 +03:00
|
|
|
|
2015-10-23 05:54:48 +03:00
|
|
|
nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) override;
|
|
|
|
void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
2017-08-24 18:09:44 +03:00
|
|
|
nsRegion *aInvalidRegion) const override;
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aCtx) override;
|
2017-03-09 11:58:39 +03:00
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerLayerParameters& aParameters) override;
|
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerLayerParameters& aContainerParameters) override;
|
2017-07-01 03:23:20 +03:00
|
|
|
virtual bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
|
2017-09-14 19:48:55 +03:00
|
|
|
mozilla::wr::IpcResourceUpdateQueue& aResources,
|
2017-05-03 15:48:07 +03:00
|
|
|
const StackingContextHelper& aSc,
|
2017-07-01 03:23:20 +03:00
|
|
|
mozilla::layers::WebRenderLayerManager* aManager,
|
|
|
|
nsDisplayListBuilder* aDisplayListBuilder) override;
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("ButtonForeground", TYPE_BUTTON_FOREGROUND)
|
2006-01-26 05:29:17 +03:00
|
|
|
private:
|
|
|
|
nsButtonFrameRenderer* mBFR;
|
2017-03-09 11:58:39 +03:00
|
|
|
Maybe<nsCSSBorderRenderer> mBorderRenderer;
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
1999-03-02 04:25:33 +03:00
|
|
|
|
2015-02-10 10:27:40 +03:00
|
|
|
nsDisplayItemGeometry*
|
2015-10-23 05:54:48 +03:00
|
|
|
nsDisplayButtonForeground::AllocateGeometry(nsDisplayListBuilder* aBuilder)
|
2015-02-10 10:27:40 +03:00
|
|
|
{
|
|
|
|
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
|
|
|
|
}
|
|
|
|
|
2013-06-26 20:43:26 +04:00
|
|
|
void
|
2017-08-24 18:09:44 +03:00
|
|
|
nsDisplayButtonForeground::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion* aInvalidRegion) const
|
2013-06-26 20:43:26 +04:00
|
|
|
{
|
2015-02-10 10:27:40 +03:00
|
|
|
auto geometry =
|
|
|
|
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
|
|
|
|
|
|
|
|
if (aBuilder->ShouldSyncDecodeImages() &&
|
|
|
|
geometry->ShouldInvalidateToSyncDecodeImages()) {
|
|
|
|
bool snap;
|
|
|
|
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
|
|
|
|
}
|
2013-06-26 20:43:26 +04:00
|
|
|
|
|
|
|
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
|
|
|
|
}
|
|
|
|
|
2006-01-29 21:48:58 +03:00
|
|
|
void nsDisplayButtonForeground::Paint(nsDisplayListBuilder* aBuilder,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aCtx)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext *presContext = mFrame->PresContext();
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleDisplay *disp = mFrame->StyleDisplay();
|
2007-02-16 04:53:43 +03:00
|
|
|
if (!mFrame->IsThemed(disp) ||
|
2017-05-21 12:15:00 +03:00
|
|
|
!presContext->GetTheme()->ThemeDrawsFocusForWidget(disp->mAppearance)) {
|
2010-08-13 14:01:58 +04:00
|
|
|
nsRect r = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
2015-10-23 05:54:48 +03:00
|
|
|
|
2016-12-02 09:11:48 +03:00
|
|
|
// Draw the -moz-focus-inner border
|
2015-10-23 05:54:48 +03:00
|
|
|
DrawResult result =
|
2016-12-02 09:11:48 +03:00
|
|
|
mBFR->PaintInnerFocusBorder(aBuilder, presContext, *aCtx, mVisibleRect, r);
|
2015-10-23 05:54:48 +03:00
|
|
|
|
|
|
|
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
|
2007-02-16 04:53:43 +03:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2017-03-09 11:58:39 +03:00
|
|
|
LayerState
|
|
|
|
nsDisplayButtonForeground::GetLayerState(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerLayerParameters& aParameters)
|
|
|
|
{
|
|
|
|
Maybe<nsCSSBorderRenderer> br;
|
|
|
|
|
2017-04-21 18:11:38 +03:00
|
|
|
if (ShouldUseAdvancedLayer(aManager, gfxPrefs::LayersAllowButtonForegroundLayers)) {
|
2017-03-09 11:58:39 +03:00
|
|
|
nsPresContext *presContext = mFrame->PresContext();
|
|
|
|
const nsStyleDisplay *disp = mFrame->StyleDisplay();
|
|
|
|
if (!mFrame->IsThemed(disp) ||
|
2017-05-21 12:15:00 +03:00
|
|
|
!presContext->GetTheme()->ThemeDrawsFocusForWidget(disp->mAppearance)) {
|
2017-03-09 11:58:39 +03:00
|
|
|
nsRect r = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
|
|
|
br = mBFR->CreateInnerFocusBorderRenderer(aBuilder, presContext, nullptr, mVisibleRect, r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-12 11:47:21 +03:00
|
|
|
if (!br || !br->CanCreateWebRenderCommands()) {
|
2017-03-09 11:58:39 +03:00
|
|
|
return LAYER_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mBorderRenderer = br;
|
|
|
|
|
|
|
|
return LAYER_ACTIVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<mozilla::layers::Layer>
|
|
|
|
nsDisplayButtonForeground::BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerLayerParameters& aContainerParameters)
|
|
|
|
{
|
|
|
|
return BuildDisplayItemLayer(aBuilder, aManager, aContainerParameters);
|
|
|
|
}
|
|
|
|
|
2017-07-01 03:23:20 +03:00
|
|
|
bool
|
|
|
|
nsDisplayButtonForeground::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
|
2017-09-14 19:48:55 +03:00
|
|
|
mozilla::wr::IpcResourceUpdateQueue& aResources,
|
2017-05-03 15:48:07 +03:00
|
|
|
const StackingContextHelper& aSc,
|
2017-07-01 03:23:20 +03:00
|
|
|
mozilla::layers::WebRenderLayerManager* aManager,
|
|
|
|
nsDisplayListBuilder* aDisplayListBuilder)
|
2017-03-09 11:58:39 +03:00
|
|
|
{
|
2017-10-03 23:31:07 +03:00
|
|
|
ContainerLayerParameters parameter;
|
|
|
|
if (GetLayerState(aDisplayListBuilder, aManager, parameter) != LAYER_ACTIVE) {
|
|
|
|
return false;
|
2017-07-01 03:23:20 +03:00
|
|
|
}
|
|
|
|
|
2017-09-14 19:48:55 +03:00
|
|
|
mBorderRenderer->CreateWebRenderCommands(aBuilder, aResources, aSc);
|
2017-07-01 03:23:20 +03:00
|
|
|
return true;
|
2017-03-09 11:58:39 +03:00
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsresult
|
|
|
|
nsButtonFrameRenderer::DisplayButton(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayList* aBackground,
|
|
|
|
nsDisplayList* aForeground)
|
|
|
|
{
|
2016-04-12 08:52:42 +03:00
|
|
|
if (mFrame->StyleEffects()->mBoxShadow) {
|
2013-02-14 15:08:08 +04:00
|
|
|
aBackground->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayButtonBoxShadowOuter(aBuilder, this));
|
2009-02-10 11:45:13 +03:00
|
|
|
}
|
|
|
|
|
2017-03-08 19:31:46 +03:00
|
|
|
nsRect buttonRect = mFrame->GetRectRelativeToSelf();
|
2016-05-04 21:12:23 +03:00
|
|
|
|
|
|
|
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
|
|
|
|
aBuilder, mFrame, buttonRect, aBackground);
|
|
|
|
|
2013-02-14 15:08:08 +04:00
|
|
|
aBackground->AppendNewToTop(new (aBuilder)
|
2016-05-04 21:12:23 +03:00
|
|
|
nsDisplayButtonBorder(aBuilder, this));
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2013-03-22 06:17:27 +04:00
|
|
|
// Only display focus rings if we actually have them. Since at most one
|
|
|
|
// button would normally display a focus ring, most buttons won't have them.
|
2016-10-21 19:19:03 +03:00
|
|
|
if (mInnerFocusStyle && mInnerFocusStyle->StyleBorder()->HasBorder()) {
|
2013-03-22 06:17:27 +04:00
|
|
|
aForeground->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayButtonForeground(aBuilder, this));
|
|
|
|
}
|
2013-02-14 15:08:08 +04:00
|
|
|
return NS_OK;
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
|
|
|
|
2016-12-02 09:11:48 +03:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& aResult)
|
|
|
|
{
|
2017-03-08 19:31:46 +03:00
|
|
|
aResult = aRect;
|
2016-12-02 09:11:48 +03:00
|
|
|
aResult.Deflate(mFrame->GetUsedBorderAndPadding());
|
|
|
|
|
|
|
|
nsMargin innerFocusPadding(0,0,0,0);
|
|
|
|
if (mInnerFocusStyle) {
|
|
|
|
mInnerFocusStyle->StylePadding()->GetPadding(innerFocusPadding);
|
|
|
|
}
|
|
|
|
aResult.Inflate(innerFocusPadding);
|
|
|
|
}
|
|
|
|
|
2015-10-23 05:54:48 +03:00
|
|
|
DrawResult
|
2016-12-02 09:11:48 +03:00
|
|
|
nsButtonFrameRenderer::PaintInnerFocusBorder(
|
2015-10-23 05:54:48 +03:00
|
|
|
nsDisplayListBuilder* aBuilder,
|
|
|
|
nsPresContext* aPresContext,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext& aRenderingContext,
|
2015-10-23 05:54:48 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsRect& aRect)
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
2016-12-02 09:11:48 +03:00
|
|
|
// we draw the -moz-focus-inner border just inside the button's
|
|
|
|
// normal border and padding, to match Windows themes.
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
nsRect rect;
|
1999-02-19 21:23:02 +03:00
|
|
|
|
2015-10-23 05:54:48 +03:00
|
|
|
PaintBorderFlags flags = aBuilder->ShouldSyncDecodeImages()
|
|
|
|
? PaintBorderFlags::SYNC_DECODE_IMAGES
|
|
|
|
: PaintBorderFlags();
|
|
|
|
|
|
|
|
DrawResult result = DrawResult::SUCCESS;
|
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
if (mInnerFocusStyle) {
|
2002-04-06 19:31:53 +04:00
|
|
|
GetButtonInnerFocusRect(aRect, rect);
|
1999-02-19 21:23:02 +03:00
|
|
|
|
2015-10-23 05:54:48 +03:00
|
|
|
result &=
|
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
|
|
|
aDirtyRect, rect, mInnerFocusStyle, flags);
|
1999-10-09 00:41:19 +04:00
|
|
|
}
|
2015-10-23 05:54:48 +03:00
|
|
|
|
|
|
|
return result;
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
|
|
|
|
2017-03-09 11:58:39 +03:00
|
|
|
Maybe<nsCSSBorderRenderer>
|
|
|
|
nsButtonFrameRenderer::CreateInnerFocusBorderRenderer(
|
|
|
|
nsDisplayListBuilder* aBuilder,
|
|
|
|
nsPresContext* aPresContext,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aRenderingContext,
|
2017-03-09 11:58:39 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsRect& aRect)
|
|
|
|
{
|
|
|
|
if (mInnerFocusStyle) {
|
|
|
|
nsRect rect;
|
|
|
|
GetButtonInnerFocusRect(aRect, rect);
|
|
|
|
|
|
|
|
gfx::DrawTarget* dt = aRenderingContext ? aRenderingContext->GetDrawTarget() : nullptr;
|
|
|
|
return nsCSSRendering::CreateBorderRenderer(aPresContext,
|
|
|
|
dt,
|
|
|
|
mFrame,
|
|
|
|
aDirtyRect,
|
|
|
|
rect,
|
|
|
|
mInnerFocusStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
|
2015-02-10 10:27:40 +03:00
|
|
|
DrawResult
|
2016-05-04 21:12:23 +03:00
|
|
|
nsButtonFrameRenderer::PaintBorder(
|
2015-10-23 05:54:48 +03:00
|
|
|
nsDisplayListBuilder* aBuilder,
|
|
|
|
nsPresContext* aPresContext,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext& aRenderingContext,
|
2015-10-23 05:54:48 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsRect& aRect)
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
// get the button rect this is inside the focus and outline rects
|
2017-03-08 19:31:46 +03:00
|
|
|
nsRect buttonRect = aRect;
|
2013-02-16 09:38:33 +04:00
|
|
|
nsStyleContext* context = mFrame->StyleContext();
|
1999-02-19 21:23:02 +03:00
|
|
|
|
2015-10-23 05:54:48 +03:00
|
|
|
PaintBorderFlags borderFlags = aBuilder->ShouldSyncDecodeImages()
|
|
|
|
? PaintBorderFlags::SYNC_DECODE_IMAGES
|
|
|
|
: PaintBorderFlags();
|
|
|
|
|
2009-02-10 11:45:13 +03:00
|
|
|
nsCSSRendering::PaintBoxShadowInner(aPresContext, aRenderingContext,
|
2016-01-06 03:08:17 +03:00
|
|
|
mFrame, buttonRect);
|
2015-10-23 05:54:48 +03:00
|
|
|
|
2016-05-04 21:12:23 +03:00
|
|
|
DrawResult result =
|
2015-10-23 05:54:48 +03:00
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
|
|
|
aDirtyRect, buttonRect, context, borderFlags);
|
2015-02-10 10:27:40 +03:00
|
|
|
|
|
|
|
return result;
|
1999-02-26 09:41:10 +03:00
|
|
|
}
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-05-13 05:35:16 +04:00
|
|
|
/**
|
|
|
|
* Call this when styles change
|
|
|
|
*/
|
2007-05-24 00:32:56 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsButtonFrameRenderer::ReResolveStyles(nsPresContext* aPresContext)
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
// get all the styles
|
2013-02-16 09:38:33 +04:00
|
|
|
nsStyleContext* context = mFrame->StyleContext();
|
2016-02-24 10:01:11 +03:00
|
|
|
StyleSetHandle styleSet = aPresContext->StyleSet();
|
1999-02-26 09:41:10 +03:00
|
|
|
|
2015-02-18 01:28:53 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (mInnerFocusStyle) {
|
|
|
|
mInnerFocusStyle->FrameRelease();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-12-02 09:11:48 +03:00
|
|
|
// get styles assigned to -moz-inner-focus (ie dotted border on Windows)
|
2009-12-11 10:37:40 +03:00
|
|
|
mInnerFocusStyle =
|
2010-04-30 17:12:06 +04:00
|
|
|
styleSet->ProbePseudoElementStyle(mFrame->GetContent()->AsElement(),
|
2016-02-17 01:07:00 +03:00
|
|
|
CSSPseudoElementType::mozFocusInner,
|
2009-12-11 10:37:40 +03:00
|
|
|
context);
|
1999-10-09 00:41:19 +04:00
|
|
|
|
2015-02-18 01:28:53 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (mInnerFocusStyle) {
|
|
|
|
mInnerFocusStyle->FrameAddRef();
|
|
|
|
}
|
|
|
|
#endif
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
1999-09-04 03:36:32 +04:00
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext*
|
2012-08-22 19:56:38 +04:00
|
|
|
nsButtonFrameRenderer::GetStyleContext(int32_t aIndex) const
|
1999-09-04 03:36:32 +04:00
|
|
|
{
|
|
|
|
switch (aIndex) {
|
|
|
|
case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX:
|
2003-02-22 03:32:13 +03:00
|
|
|
return mInnerFocusStyle;
|
1999-09-21 11:56:18 +04:00
|
|
|
default:
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
1999-09-04 03:36:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsButtonFrameRenderer::SetStyleContext(int32_t aIndex, nsStyleContext* aStyleContext)
|
1999-09-04 03:36:32 +04:00
|
|
|
{
|
|
|
|
switch (aIndex) {
|
|
|
|
case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX:
|
2015-02-18 01:28:53 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (mInnerFocusStyle) {
|
|
|
|
mInnerFocusStyle->FrameRelease();
|
|
|
|
}
|
|
|
|
#endif
|
1999-09-04 03:36:32 +04:00
|
|
|
mInnerFocusStyle = aStyleContext;
|
|
|
|
break;
|
|
|
|
}
|
2015-02-18 01:28:53 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
aStyleContext->FrameAddRef();
|
|
|
|
#endif
|
1999-09-04 03:36:32 +04:00
|
|
|
}
|