2017-10-27 10:33:53 -07: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 12:12:37 +01: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 18:29:03 +00:00
|
|
|
|
|
|
|
/* rendering object for list-item bullets */
|
|
|
|
|
1998-12-01 16:13:49 +00:00
|
|
|
#ifndef nsBulletFrame_h___
|
|
|
|
#define nsBulletFrame_h___
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
1999-04-13 21:49:58 +00:00
|
|
|
#include "nsFrame.h"
|
1998-12-01 16:13:49 +00:00
|
|
|
|
2015-02-04 13:50:56 -08:00
|
|
|
#include "imgIContainer.h"
|
2012-10-12 12:11:22 -04:00
|
|
|
#include "imgINotificationObserver.h"
|
2001-08-09 20:22:39 +00:00
|
|
|
|
2013-06-22 11:30:57 -05:00
|
|
|
class imgIContainer;
|
2012-10-12 08:43:01 -04:00
|
|
|
class imgRequestProxy;
|
|
|
|
|
2011-12-24 09:28:23 +01:00
|
|
|
class nsBulletFrame;
|
2017-01-24 16:53:42 +08:00
|
|
|
class BulletRenderer;
|
2011-12-24 09:28:23 +01:00
|
|
|
|
2017-11-01 06:59:10 -04:00
|
|
|
class nsBulletListener final : public imgINotificationObserver {
|
2011-12-24 09:28:23 +01:00
|
|
|
public:
|
|
|
|
nsBulletListener();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
2012-10-12 12:11:22 -04:00
|
|
|
NS_DECL_IMGINOTIFICATIONOBSERVER
|
2011-12-24 09:28:23 +01:00
|
|
|
|
|
|
|
void SetFrame(nsBulletFrame* frame) { mFrame = frame; }
|
|
|
|
|
|
|
|
private:
|
2014-06-23 18:40:01 -04:00
|
|
|
virtual ~nsBulletListener();
|
|
|
|
|
2011-12-24 09:28:23 +01:00
|
|
|
nsBulletFrame* mFrame;
|
|
|
|
};
|
|
|
|
|
1998-12-01 16:13:49 +00:00
|
|
|
/**
|
|
|
|
* A simple class that manages the layout and rendering of html bullets.
|
|
|
|
* This class also supports the CSS list-style properties.
|
|
|
|
*/
|
2015-03-21 12:28:04 -04:00
|
|
|
class nsBulletFrame final : public nsFrame {
|
2017-12-11 15:37:59 +00:00
|
|
|
typedef mozilla::image::ImgDrawResult ImgDrawResult;
|
2015-02-04 13:50:56 -08:00
|
|
|
|
1998-12-01 16:13:49 +00:00
|
|
|
public:
|
2017-05-26 12:11:11 +02:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsBulletFrame)
|
2014-01-18 18:08:22 +11:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_DECL_QUERYFRAME
|
|
|
|
#endif
|
2009-09-12 17:49:24 +01:00
|
|
|
|
2019-02-05 17:45:54 +01:00
|
|
|
explicit nsBulletFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
|
|
|
|
: nsFrame(aStyle, aPresContext, kClassID),
|
2014-07-24 01:30:07 -07:00
|
|
|
mPadding(GetWritingMode()),
|
|
|
|
mIntrinsicSize(GetWritingMode()),
|
2014-11-10 13:37:49 -08:00
|
|
|
mRequestRegistered(false) {}
|
2017-04-30 17:30:08 +02:00
|
|
|
|
1998-12-01 16:13:49 +00:00
|
|
|
virtual ~nsBulletFrame();
|
|
|
|
|
2020-03-12 04:25:34 +00:00
|
|
|
void Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect* aData);
|
2012-10-12 12:11:22 -04:00
|
|
|
|
1998-12-01 16:13:49 +00:00
|
|
|
// nsIFrame
|
2017-11-07 01:20:33 +01:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot,
|
|
|
|
PostDestroyData& aPostDestroyData) override;
|
2013-02-15 00:12:27 +13:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
2015-03-21 12:28:04 -04:00
|
|
|
const nsDisplayListSet& aLists) override;
|
2018-03-22 19:20:41 +01:00
|
|
|
virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 12:28:04 -04:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override;
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-12-01 16:13:49 +00:00
|
|
|
|
2014-05-13 00:47:52 +00:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics,
|
2016-07-21 18:36:39 +08:00
|
|
|
const ReflowInput& aReflowInput,
|
2015-03-21 12:28:04 -04:00
|
|
|
nsReflowStatus& aStatus) override;
|
2017-06-09 15:14:53 -04:00
|
|
|
virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;
|
|
|
|
virtual nscoord GetPrefISize(gfxContext* aRenderingContext) override;
|
|
|
|
void AddInlineMinISize(gfxContext* aRenderingContext,
|
2016-04-14 01:32:12 +02:00
|
|
|
nsIFrame::InlineMinISizeData* aData) override;
|
2017-06-09 15:14:53 -04:00
|
|
|
void AddInlinePrefISize(gfxContext* aRenderingContext,
|
2016-04-14 01:32:12 +02:00
|
|
|
nsIFrame::InlinePrefISizeData* aData) override;
|
1998-12-01 16:13:49 +00:00
|
|
|
|
2017-10-18 12:38:17 +13:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const override {
|
2018-08-07 15:02:07 -07:00
|
|
|
if (aFlags & (eSupportsCSSTransforms | eSupportsContainLayoutAndPaint)) {
|
2017-10-18 12:38:17 +13:00
|
|
|
return false;
|
|
|
|
}
|
2019-03-24 23:13:53 +01:00
|
|
|
return nsFrame::IsFrameOfType(aFlags & ~nsIFrame::eLineParticipant);
|
2017-10-18 12:38:17 +13:00
|
|
|
}
|
|
|
|
|
1998-12-01 16:13:49 +00:00
|
|
|
// nsBulletFrame
|
|
|
|
|
2014-06-11 21:13:00 -04:00
|
|
|
/* get list item text, with prefix & suffix */
|
2019-02-02 19:41:44 +01:00
|
|
|
static void GetListItemText(mozilla::CounterStyle*, mozilla::WritingMode,
|
|
|
|
int32_t aOrdinal, nsAString& aResult);
|
2014-06-11 21:12:00 -04:00
|
|
|
|
2019-04-08 21:49:20 +02:00
|
|
|
#ifdef ACCESSIBILITY
|
2014-06-11 21:12:00 -04:00
|
|
|
void GetSpokenText(nsAString& aText);
|
2019-04-08 21:49:20 +02:00
|
|
|
#endif
|
2017-01-24 16:53:42 +08:00
|
|
|
|
2017-06-09 15:14:53 -04:00
|
|
|
Maybe<BulletRenderer> CreateBulletRenderer(gfxContext& aRenderingContext,
|
|
|
|
nsPoint aPt);
|
2017-12-11 15:37:59 +00:00
|
|
|
ImgDrawResult PaintBullet(gfxContext& aRenderingContext, nsPoint aPt,
|
2016-05-31 14:56:22 -04:00
|
|
|
const nsRect& aDirtyRect, uint32_t aFlags,
|
|
|
|
bool aDisableSubpixelAA);
|
2017-01-24 16:53:42 +08:00
|
|
|
|
2015-03-21 12:28:04 -04:00
|
|
|
virtual bool IsEmpty() override;
|
|
|
|
virtual bool IsSelfEmpty() override;
|
2019-04-17 18:21:21 +02:00
|
|
|
|
|
|
|
// XXXmats note that this method returns a non-standard baseline that includes
|
|
|
|
// the ::marker block-start margin. New code should probably use
|
|
|
|
// GetNaturalBaselineBOffset instead, which returns a normal baseline offset
|
|
|
|
// as documented in nsIFrame.h.
|
2015-03-21 12:28:04 -04:00
|
|
|
virtual nscoord GetLogicalBaseline(
|
|
|
|
mozilla::WritingMode aWritingMode) const override;
|
2004-06-04 19:28:36 +00:00
|
|
|
|
2019-04-25 23:03:04 +00:00
|
|
|
bool GetNaturalBaselineBOffset(mozilla::WritingMode aWM,
|
2019-04-17 18:21:21 +02:00
|
|
|
BaselineSharingGroup aBaselineGroup,
|
|
|
|
nscoord* aBaseline) const override;
|
|
|
|
|
2011-11-23 18:48:23 -08:00
|
|
|
float GetFontSizeInflation() const;
|
|
|
|
bool HasFontSizeInflation() const {
|
|
|
|
return (GetStateBits() & BULLET_FRAME_HAS_FONT_INFLATION) != 0;
|
|
|
|
}
|
|
|
|
void SetFontSizeInflation(float aInflation);
|
|
|
|
|
2019-05-21 17:30:42 +00:00
|
|
|
int32_t Ordinal() const { return mOrdinal; }
|
|
|
|
void SetOrdinal(int32_t aOrdinal, bool aNotify);
|
2012-12-21 22:09:23 +13:00
|
|
|
|
2013-06-22 11:30:57 -05:00
|
|
|
already_AddRefed<imgIContainer> GetImage() const;
|
|
|
|
|
1998-12-01 16:13:49 +00:00
|
|
|
protected:
|
2020-03-12 04:25:34 +00:00
|
|
|
void OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
|
2012-10-12 12:11:22 -04:00
|
|
|
|
2015-03-12 20:53:54 +11:00
|
|
|
void AppendSpacingToPadding(nsFontMetrics* aFontMetrics,
|
|
|
|
mozilla::LogicalMargin* aPadding);
|
2004-07-31 23:15:21 +00:00
|
|
|
void GetDesiredSize(nsPresContext* aPresContext,
|
2017-06-09 15:14:53 -04:00
|
|
|
gfxContext* aRenderingContext, ReflowOutput& aMetrics,
|
2015-03-12 20:53:54 +11:00
|
|
|
float aFontSizeInflation,
|
|
|
|
mozilla::LogicalMargin* aPadding);
|
1998-12-01 16:13:49 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void GetLoadGroup(nsPresContext* aPresContext, nsILoadGroup** aLoadGroup);
|
2019-01-02 14:05:23 +01:00
|
|
|
mozilla::dom::Document* GetOurCurrentDoc() const;
|
1999-04-13 21:49:58 +00:00
|
|
|
|
2014-07-24 01:30:07 -07:00
|
|
|
mozilla::LogicalMargin mPadding;
|
2015-10-18 01:24:48 -04:00
|
|
|
RefPtr<imgRequestProxy> mImageRequest;
|
|
|
|
RefPtr<nsBulletListener> mListener;
|
2001-08-09 20:22:39 +00:00
|
|
|
|
2014-07-24 01:30:07 -07:00
|
|
|
mozilla::LogicalSize mIntrinsicSize;
|
2013-12-02 12:51:25 -05:00
|
|
|
|
2011-11-09 13:39:16 -08:00
|
|
|
private:
|
2019-02-02 19:41:44 +01:00
|
|
|
mozilla::CounterStyle* ResolveCounterStyle();
|
|
|
|
nscoord GetListStyleAscent() const;
|
2014-11-10 13:37:49 -08:00
|
|
|
void RegisterImageRequest(bool aKnownToBeAnimated);
|
|
|
|
void DeregisterAndCancelImageRequest();
|
2011-11-09 13:39:16 -08:00
|
|
|
|
2019-05-21 17:30:42 +00:00
|
|
|
// Requires being set via SetOrdinal.
|
|
|
|
int32_t mOrdinal = 0;
|
|
|
|
|
2011-11-09 13:39:16 -08:00
|
|
|
// This is a boolean flag indicating whether or not the current image request
|
|
|
|
// has been registered with the refresh driver.
|
2014-11-10 13:37:49 -08:00
|
|
|
bool mRequestRegistered : 1;
|
1998-12-01 16:13:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsBulletFrame_h___ */
|