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___
|
|
|
|
|
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsStyleContext.h"
|
|
|
|
|
|
|
|
#include "imgIRequest.h"
|
|
|
|
#include "imgIDecoderObserver.h"
|
2011-12-24 00:28:23 -08:00
|
|
|
#include "nsStubImageDecoderObserver.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;
|
|
|
|
|
|
|
|
class nsBulletListener : public nsStubImageDecoderObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsBulletListener();
|
|
|
|
virtual ~nsBulletListener();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
// imgIDecoderObserver (override nsStubImageDecoderObserver)
|
|
|
|
NS_IMETHOD OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage);
|
|
|
|
NS_IMETHOD OnDataAvailable(imgIRequest *aRequest, bool aCurrentFrame,
|
|
|
|
const nsIntRect *aRect);
|
|
|
|
NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult status,
|
|
|
|
const PRUnichar *statusArg);
|
|
|
|
NS_IMETHOD OnImageIsAnimated(imgIRequest *aRequest);
|
|
|
|
|
|
|
|
// imgIContainerObserver (override nsStubImageDecoderObserver)
|
2012-01-06 04:32:38 -08:00
|
|
|
NS_IMETHOD FrameChanged(imgIRequest *aRequest,
|
|
|
|
imgIContainer *aContainer,
|
2011-12-24 00:28:23 -08:00
|
|
|
const nsIntRect *dirtyRect);
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
virtual nsIAtom* GetType() const;
|
2008-10-26 03:11:34 -07:00
|
|
|
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// nsIHTMLReflow
|
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
2011-04-07 18:04:40 -07:00
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext);
|
|
|
|
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext);
|
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
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHOD OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage);
|
|
|
|
NS_IMETHOD OnDataAvailable(imgIRequest *aRequest,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCurrentFrame,
|
2009-01-14 19:27:09 -08:00
|
|
|
const nsIntRect *aRect);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD OnStopDecode(imgIRequest *aRequest,
|
|
|
|
nsresult aStatus,
|
|
|
|
const PRUnichar *aStatusArg);
|
2011-11-09 13:39:16 -08:00
|
|
|
NS_IMETHOD OnImageIsAnimated(imgIRequest *aRequest);
|
2012-01-06 04:32:38 -08:00
|
|
|
NS_IMETHOD FrameChanged(imgIRequest *aRequest,
|
|
|
|
imgIContainer *aContainer,
|
2010-08-13 21:09:48 -07:00
|
|
|
const nsIntRect *aDirtyRect);
|
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
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsEmpty();
|
|
|
|
virtual bool IsSelfEmpty();
|
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:
|
|
|
|
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___ */
|