2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* rendering object for list-item bullets */
|
|
|
|
|
|
|
|
#ifndef nsBulletFrame_h___
|
|
|
|
#define nsBulletFrame_h___
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsStyleContext.h"
|
|
|
|
|
|
|
|
#include "imgIRequest.h"
|
|
|
|
#include "imgIDecoderObserver.h"
|
2012-10-12 09:11:22 -07:00
|
|
|
#include "imgINotificationObserver.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-23 18:48:23 -08:00
|
|
|
#define BULLET_FRAME_IMAGE_LOADING NS_FRAME_STATE_BIT(63)
|
|
|
|
#define BULLET_FRAME_HAS_FONT_INFLATION NS_FRAME_STATE_BIT(62)
|
|
|
|
|
2011-12-24 00:28:23 -08:00
|
|
|
class nsBulletFrame;
|
|
|
|
|
2012-10-12 09:11:22 -07:00
|
|
|
class nsBulletListener : public imgINotificationObserver
|
2011-12-24 00:28:23 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsBulletListener();
|
|
|
|
virtual ~nsBulletListener();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
2012-10-12 09:11:22 -07:00
|
|
|
NS_DECL_IMGINOTIFICATIONOBSERVER
|
2011-12-24 00:28:23 -08:00
|
|
|
|
|
|
|
void SetFrame(nsBulletFrame *frame) { mFrame = frame; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsBulletFrame *mFrame;
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* A simple class that manages the layout and rendering of html bullets.
|
|
|
|
* This class also supports the CSS list-style properties.
|
|
|
|
*/
|
|
|
|
class nsBulletFrame : public nsFrame {
|
|
|
|
public:
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2011-11-23 18:48:23 -08:00
|
|
|
nsBulletFrame(nsStyleContext* aContext)
|
|
|
|
: nsFrame(aContext)
|
|
|
|
{
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~nsBulletFrame();
|
|
|
|
|
2012-10-12 09:11:22 -07:00
|
|
|
NS_IMETHOD Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect* aData);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIFrame
|
2009-12-23 21:21:15 -08:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
|
|
|
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2012-09-14 09:10:08 -07:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// nsIHTMLReflow
|
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2012-09-14 09:10:08 -07:00
|
|
|
nsReflowStatus& aStatus) MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsBulletFrame
|
2012-09-07 19:30:24 -07:00
|
|
|
int32_t SetListItemOrdinal(int32_t aNextOrdinal, bool* aChanged,
|
|
|
|
int32_t aIncrement);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
/* get list item text, without '.' */
|
2012-08-22 08:56:38 -07:00
|
|
|
static bool AppendCounterText(int32_t aListStyleType,
|
|
|
|
int32_t aOrdinal,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsString& aResult);
|
|
|
|
|
|
|
|
/* get list item text, with '.' */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetListItemText(const nsStyleList& aStyleList,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsString& aResult);
|
|
|
|
|
2011-04-07 18:04:40 -07:00
|
|
|
void PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRect& aDirtyRect);
|
2008-03-11 17:46:18 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual bool IsEmpty() MOZ_OVERRIDE;
|
|
|
|
virtual bool IsSelfEmpty() MOZ_OVERRIDE;
|
2010-08-31 11:54:44 -07:00
|
|
|
virtual nscoord GetBaseline() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
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);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2012-10-12 09:11:22 -07:00
|
|
|
nsresult OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void GetDesiredSize(nsPresContext* aPresContext,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext *aRenderingContext,
|
2011-11-23 18:48:23 -08:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
float aFontSizeInflation);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGroup);
|
|
|
|
|
|
|
|
nsMargin mPadding;
|
|
|
|
nsCOMPtr<imgIRequest> mImageRequest;
|
2011-12-24 00:28:23 -08:00
|
|
|
nsRefPtr<nsBulletListener> mListener;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsSize mIntrinsicSize;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mOrdinal;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mTextIsRTL;
|
2011-11-09 13:39:16 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// This is a boolean flag indicating whether or not the current image request
|
|
|
|
// has been registered with the refresh driver.
|
|
|
|
bool mRequestRegistered;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsBulletFrame_h___ */
|