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/. */
|
2006-03-29 22:29:03 +04:00
|
|
|
|
|
|
|
/* rendering object for list-item bullets */
|
|
|
|
|
1998-12-01 19:13:49 +03:00
|
|
|
#include "nsBulletFrame.h"
|
2013-09-25 05:43:43 +04:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2005-01-12 22:45:38 +03:00
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-09-30 20:40:24 +04:00
|
|
|
#include "nsAttrValueInlines.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1998-12-01 19:13:49 +03:00
|
|
|
#include "nsIPresShell.h"
|
1999-01-15 04:57:58 +03:00
|
|
|
#include "nsIDocument.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsRenderingContext.h"
|
1998-12-01 19:13:49 +03:00
|
|
|
#include "prprf.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2013-02-22 22:13:37 +04:00
|
|
|
#include "nsCounterManager.h"
|
1998-12-01 19:13:49 +03:00
|
|
|
|
2001-08-10 00:22:39 +04:00
|
|
|
#include "imgIContainer.h"
|
2012-10-12 16:43:01 +04:00
|
|
|
#include "imgRequestProxy.h"
|
2013-09-07 17:01:08 +04:00
|
|
|
#include "nsIURI.h"
|
2001-08-10 00:22:39 +04:00
|
|
|
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2001-08-10 00:22:39 +04:00
|
|
|
|
2011-03-28 17:59:54 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsAccessibilityService.h"
|
|
|
|
#endif
|
|
|
|
|
2011-11-24 06:48:23 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(FontSizeInflationProperty, nullptr)
|
2010-08-31 22:54:44 +04:00
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsBulletFrame)
|
2001-08-10 00:22:39 +04:00
|
|
|
|
1998-12-01 19:13:49 +03:00
|
|
|
nsBulletFrame::~nsBulletFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsBulletFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
1998-12-01 19:13:49 +03:00
|
|
|
{
|
1999-04-14 01:49:58 +04:00
|
|
|
// Stop image loading first
|
2001-08-10 00:22:39 +04:00
|
|
|
if (mImageRequest) {
|
2011-11-10 01:39:16 +04:00
|
|
|
// Deregister our image request from the refresh driver
|
|
|
|
nsLayoutUtils::DeregisterImageRequest(PresContext(),
|
|
|
|
mImageRequest,
|
|
|
|
&mRequestRegistered);
|
2009-05-17 01:16:33 +04:00
|
|
|
mImageRequest->CancelAndForgetObserver(NS_ERROR_FAILURE);
|
2012-07-30 18:20:58 +04:00
|
|
|
mImageRequest = nullptr;
|
2001-08-10 00:22:39 +04:00
|
|
|
}
|
|
|
|
|
2011-12-24 12:28:23 +04:00
|
|
|
if (mListener) {
|
2012-07-30 18:20:58 +04:00
|
|
|
mListener->SetFrame(nullptr);
|
2011-12-24 12:28:23 +04:00
|
|
|
}
|
1999-04-14 01:49:58 +04:00
|
|
|
|
|
|
|
// Let base class do the rest
|
2009-12-24 08:21:15 +03:00
|
|
|
nsFrame::DestroyFrom(aDestructRoot);
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
|
|
|
|
2012-06-25 23:59:42 +04:00
|
|
|
#ifdef DEBUG
|
1999-04-14 01:49:58 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-05 01:18:20 +04:00
|
|
|
nsBulletFrame::GetFrameName(nsAString& aResult) const
|
1999-04-14 01:49:58 +04:00
|
|
|
{
|
2004-08-05 01:18:20 +04:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Bullet"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsBulletFrame::GetType() const
|
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::bulletFrame;
|
2004-08-05 01:18:20 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2008-03-12 03:46:18 +03:00
|
|
|
nsBulletFrame::IsEmpty()
|
|
|
|
{
|
|
|
|
return IsSelfEmpty();
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2008-03-12 03:46:18 +03:00
|
|
|
nsBulletFrame::IsSelfEmpty()
|
|
|
|
{
|
2013-02-17 01:51:02 +04:00
|
|
|
return StyleList()->mListStyleType == NS_STYLE_LIST_STYLE_NONE;
|
2008-03-12 03:46:18 +03:00
|
|
|
}
|
|
|
|
|
2008-10-14 02:03:28 +04:00
|
|
|
/* virtual */ void
|
2008-10-26 13:11:34 +03:00
|
|
|
nsBulletFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
2004-08-05 01:18:20 +04:00
|
|
|
{
|
2008-10-26 13:11:34 +03:00
|
|
|
nsFrame::DidSetStyleContext(aOldStyleContext);
|
2008-10-14 02:03:28 +04:00
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
imgRequestProxy *newRequest = StyleList()->GetListStyleImage();
|
2004-08-05 01:18:20 +04:00
|
|
|
|
|
|
|
if (newRequest) {
|
1999-04-14 01:49:58 +04:00
|
|
|
|
2001-08-10 00:22:39 +04:00
|
|
|
if (!mListener) {
|
2011-12-24 12:28:23 +04:00
|
|
|
mListener = new nsBulletListener();
|
|
|
|
mListener->SetFrame(this);
|
1999-04-14 01:49:58 +04:00
|
|
|
}
|
2001-08-10 00:22:39 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool needNewRequest = true;
|
2004-08-05 01:18:20 +04:00
|
|
|
|
|
|
|
if (mImageRequest) {
|
|
|
|
// Reload the image, maybe...
|
|
|
|
nsCOMPtr<nsIURI> oldURI;
|
|
|
|
mImageRequest->GetURI(getter_AddRefs(oldURI));
|
|
|
|
nsCOMPtr<nsIURI> newURI;
|
|
|
|
newRequest->GetURI(getter_AddRefs(newURI));
|
|
|
|
if (oldURI && newURI) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool same;
|
2004-08-05 01:18:20 +04:00
|
|
|
newURI->Equals(oldURI, &same);
|
|
|
|
if (same) {
|
2011-10-17 18:59:28 +04:00
|
|
|
needNewRequest = false;
|
2004-08-05 01:18:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needNewRequest) {
|
2013-04-12 21:05:57 +04:00
|
|
|
nsRefPtr<imgRequestProxy> oldRequest = mImageRequest;
|
2004-08-05 01:18:20 +04:00
|
|
|
newRequest->Clone(mListener, getter_AddRefs(mImageRequest));
|
2013-04-12 21:05:57 +04:00
|
|
|
|
|
|
|
// Deregister the old request. We wait until after Clone is done in case
|
|
|
|
// the old request and the new request are the same underlying image
|
|
|
|
// accessed via different URLs.
|
|
|
|
if (oldRequest) {
|
|
|
|
nsLayoutUtils::DeregisterImageRequest(PresContext(), oldRequest,
|
|
|
|
&mRequestRegistered);
|
|
|
|
oldRequest->CancelAndForgetObserver(NS_ERROR_FAILURE);
|
|
|
|
oldRequest = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Register the new request.
|
2011-11-10 01:39:16 +04:00
|
|
|
if (mImageRequest) {
|
|
|
|
nsLayoutUtils::RegisterImageRequestIfAnimated(PresContext(),
|
|
|
|
mImageRequest,
|
|
|
|
&mRequestRegistered);
|
|
|
|
}
|
2004-08-05 01:18:20 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// No image request on the new style context
|
|
|
|
if (mImageRequest) {
|
2011-11-10 01:39:16 +04:00
|
|
|
nsLayoutUtils::DeregisterImageRequest(PresContext(), mImageRequest,
|
|
|
|
&mRequestRegistered);
|
|
|
|
|
2012-11-28 19:30:05 +04:00
|
|
|
mImageRequest->CancelAndForgetObserver(NS_ERROR_FAILURE);
|
2012-07-30 18:20:58 +04:00
|
|
|
mImageRequest = nullptr;
|
2004-08-05 01:18:20 +04:00
|
|
|
}
|
1999-04-14 01:49:58 +04:00
|
|
|
}
|
2011-03-28 17:59:54 +04:00
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
// Update the list bullet accessible. If old style list isn't available then
|
|
|
|
// no need to update the accessible tree because it's not created yet.
|
|
|
|
if (aOldStyleContext) {
|
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
|
|
|
if (accService) {
|
|
|
|
const nsStyleList* oldStyleList = aOldStyleContext->PeekStyleList();
|
|
|
|
if (oldStyleList) {
|
|
|
|
bool hadBullet = oldStyleList->GetListStyleImage() ||
|
|
|
|
oldStyleList->mListStyleType != NS_STYLE_LIST_STYLE_NONE;
|
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleList* newStyleList = StyleList();
|
2011-03-28 17:59:54 +04:00
|
|
|
bool hasBullet = newStyleList->GetListStyleImage() ||
|
|
|
|
newStyleList->mListStyleType != NS_STYLE_LIST_STYLE_NONE;
|
|
|
|
|
|
|
|
if (hadBullet != hasBullet) {
|
|
|
|
accService->UpdateListBullet(PresContext()->GetPresShell(), mContent,
|
|
|
|
hasBullet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
1999-04-14 01:49:58 +04:00
|
|
|
}
|
|
|
|
|
2012-12-21 13:09:23 +04:00
|
|
|
class nsDisplayBulletGeometry : public nsDisplayItemGenericGeometry
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsDisplayBulletGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder)
|
|
|
|
: nsDisplayItemGenericGeometry(aItem, aBuilder)
|
|
|
|
{
|
2013-04-19 16:02:13 +04:00
|
|
|
nsBulletFrame* f = static_cast<nsBulletFrame*>(aItem->Frame());
|
2012-12-21 13:09:23 +04:00
|
|
|
mOrdinal = f->GetOrdinal();
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t mOrdinal;
|
|
|
|
};
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
class nsDisplayBullet : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayBullet(nsDisplayListBuilder* aBuilder, nsBulletFrame* aFrame) :
|
|
|
|
nsDisplayItem(aBuilder, aFrame) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayBullet);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayBullet() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayBullet);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-04-10 15:24:18 +04:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap)
|
2011-01-03 04:48:09 +03:00
|
|
|
{
|
2012-04-10 15:24:18 +04:00
|
|
|
*aSnap = false;
|
2011-10-21 21:45:32 +04:00
|
|
|
return mFrame->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame();
|
2011-01-03 04:48:09 +03:00
|
|
|
}
|
2010-04-08 04:31:26 +04:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) {
|
|
|
|
aOutFrames->AppendElement(mFrame);
|
|
|
|
}
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aCtx);
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("Bullet", TYPE_BULLET)
|
2010-10-11 04:58:20 +04:00
|
|
|
|
2011-01-03 04:48:09 +03:00
|
|
|
virtual nsRect GetComponentAlphaBounds(nsDisplayListBuilder* aBuilder)
|
|
|
|
{
|
2012-04-10 15:24:18 +04:00
|
|
|
bool snap;
|
|
|
|
return GetBounds(aBuilder, &snap);
|
2011-01-03 04:48:09 +03:00
|
|
|
}
|
2012-12-21 13:09:23 +04:00
|
|
|
|
|
|
|
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder)
|
|
|
|
{
|
|
|
|
return new nsDisplayBulletGeometry(this, aBuilder);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion *aInvalidRegion)
|
|
|
|
{
|
|
|
|
const nsDisplayBulletGeometry* geometry = static_cast<const nsDisplayBulletGeometry*>(aGeometry);
|
|
|
|
nsBulletFrame* f = static_cast<nsBulletFrame*>(mFrame);
|
|
|
|
|
|
|
|
if (f->GetOrdinal() != geometry->mOrdinal) {
|
|
|
|
bool snap;
|
|
|
|
aInvalidRegion->Or(geometry->mBounds, GetBounds(aBuilder, &snap));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-22 20:30:57 +04:00
|
|
|
nsCOMPtr<imgIContainer> image = f->GetImage();
|
|
|
|
if (aBuilder->ShouldSyncDecodeImages() && image && !image->IsDecoded()) {
|
|
|
|
// If we are going to do a sync decode and we are not decoded then we are
|
|
|
|
// going to be drawing something different from what is currently there,
|
|
|
|
// so we add our bounds to the invalid region.
|
|
|
|
bool snap;
|
|
|
|
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
|
|
|
|
}
|
|
|
|
|
2012-12-21 13:09:23 +04:00
|
|
|
return nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
|
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
void nsDisplayBullet::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aCtx)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2013-05-30 03:23:31 +04:00
|
|
|
uint32_t flags = imgIContainer::FLAG_NONE;
|
|
|
|
if (aBuilder->ShouldSyncDecodeImages()) {
|
|
|
|
flags |= imgIContainer::FLAG_SYNC_DECODE;
|
|
|
|
}
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsBulletFrame*>(mFrame)->
|
2013-05-30 03:23:31 +04:00
|
|
|
PaintBullet(*aCtx, ToReferenceFrame(), mVisibleRect, flags);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsBulletFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
1998-12-01 19:13:49 +03:00
|
|
|
{
|
2006-01-26 05:29:17 +03:00
|
|
|
if (!IsVisibleForPainting(aBuilder))
|
2013-02-14 15:12:27 +04:00
|
|
|
return;
|
2006-09-19 08:26:20 +04:00
|
|
|
|
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsBulletFrame");
|
|
|
|
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.Content()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayBullet(aBuilder, this));
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
1998-12-18 18:54:23 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
void
|
2011-04-08 05:04:40 +04:00
|
|
|
nsBulletFrame::PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt,
|
2013-05-30 03:23:31 +04:00
|
|
|
const nsRect& aDirtyRect, uint32_t aFlags)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleList* myList = StyleList();
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t listStyleType = myList->mListStyleType;
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2009-12-11 07:02:13 +03:00
|
|
|
if (myList->GetListStyleImage() && mImageRequest) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t status;
|
2006-01-26 05:29:17 +03:00
|
|
|
mImageRequest->GetImageStatus(&status);
|
|
|
|
if (status & imgIRequest::STATUS_LOAD_COMPLETE &&
|
|
|
|
!(status & imgIRequest::STATUS_ERROR)) {
|
|
|
|
nsCOMPtr<imgIContainer> imageCon;
|
|
|
|
mImageRequest->GetImage(getter_AddRefs(imageCon));
|
|
|
|
if (imageCon) {
|
2007-03-20 03:58:20 +03:00
|
|
|
nsRect dest(mPadding.left, mPadding.top,
|
|
|
|
mRect.width - (mPadding.left + mPadding.right),
|
|
|
|
mRect.height - (mPadding.top + mPadding.bottom));
|
2009-04-05 13:52:14 +04:00
|
|
|
nsLayoutUtils::DrawSingleImage(&aRenderingContext,
|
|
|
|
imageCon, nsLayoutUtils::GetGraphicsFilterForFrame(this),
|
2013-05-30 03:23:31 +04:00
|
|
|
dest + aPt, aDirtyRect, nullptr, aFlags);
|
2006-01-26 05:29:17 +03:00
|
|
|
return;
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
1998-12-01 19:13:49 +03:00
|
|
|
|
2011-04-08 05:05:49 +04:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
2011-08-09 19:14:36 +04:00
|
|
|
aRenderingContext.SetColor(nsLayoutUtils::GetColor(this, eCSSProperty_color));
|
1998-12-01 19:13:49 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mTextIsRTL = false;
|
2001-03-09 06:29:00 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsAutoString text;
|
|
|
|
switch (listStyleType) {
|
|
|
|
case NS_STYLE_LIST_STYLE_NONE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case NS_STYLE_LIST_STYLE_DISC:
|
|
|
|
aRenderingContext.FillEllipse(mPadding.left + aPt.x, mPadding.top + aPt.y,
|
|
|
|
mRect.width - (mPadding.left + mPadding.right),
|
|
|
|
mRect.height - (mPadding.top + mPadding.bottom));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_CIRCLE:
|
|
|
|
aRenderingContext.DrawEllipse(mPadding.left + aPt.x, mPadding.top + aPt.y,
|
|
|
|
mRect.width - (mPadding.left + mPadding.right),
|
|
|
|
mRect.height - (mPadding.top + mPadding.bottom));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_SQUARE:
|
2010-02-18 20:26:54 +03:00
|
|
|
{
|
2011-04-19 07:07:22 +04:00
|
|
|
nsRect rect(aPt, mRect.Size());
|
|
|
|
rect.Deflate(mPadding);
|
|
|
|
|
2010-02-18 20:26:54 +03:00
|
|
|
// Snap the height and the width of the rectangle to device pixels,
|
|
|
|
// and then center the result within the original rectangle, so that
|
|
|
|
// all square bullets at the same font size have the same visual
|
|
|
|
// size (bug 376690).
|
|
|
|
// FIXME: We should really only do this if we're not transformed
|
|
|
|
// (like gfxContext::UserToDevicePixelSnapped does).
|
|
|
|
nsPresContext *pc = PresContext();
|
|
|
|
nsRect snapRect(rect.x, rect.y,
|
|
|
|
pc->RoundAppUnitsToNearestDevPixels(rect.width),
|
|
|
|
pc->RoundAppUnitsToNearestDevPixels(rect.height));
|
|
|
|
snapRect.MoveBy((rect.width - snapRect.width) / 2,
|
|
|
|
(rect.height - snapRect.height) / 2);
|
|
|
|
aRenderingContext.FillRect(snapRect.x, snapRect.y,
|
|
|
|
snapRect.width, snapRect.height);
|
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_DECIMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_DECIMAL_LEADING_ZERO:
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_CJK_DECIMAL:
|
2006-01-26 05:29:17 +03:00
|
|
|
case NS_STYLE_LIST_STYLE_LOWER_ROMAN:
|
|
|
|
case NS_STYLE_LIST_STYLE_UPPER_ROMAN:
|
|
|
|
case NS_STYLE_LIST_STYLE_LOWER_ALPHA:
|
|
|
|
case NS_STYLE_LIST_STYLE_UPPER_ALPHA:
|
|
|
|
case NS_STYLE_LIST_STYLE_LOWER_GREEK:
|
|
|
|
case NS_STYLE_LIST_STYLE_HEBREW:
|
|
|
|
case NS_STYLE_LIST_STYLE_ARMENIAN:
|
|
|
|
case NS_STYLE_LIST_STYLE_GEORGIAN:
|
|
|
|
case NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC:
|
|
|
|
case NS_STYLE_LIST_STYLE_HIRAGANA:
|
|
|
|
case NS_STYLE_LIST_STYLE_KATAKANA:
|
|
|
|
case NS_STYLE_LIST_STYLE_HIRAGANA_IROHA:
|
|
|
|
case NS_STYLE_LIST_STYLE_KATAKANA_IROHA:
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
|
2006-01-26 05:29:17 +03:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_CJK_HEAVENLY_STEM:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_CJK_EARTHLY_BRANCH:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ARABIC_INDIC:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_PERSIAN:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_URDU:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_DEVANAGARI:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_GURMUKHI:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_GUJARATI:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ORIYA:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_KANNADA:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_MALAYALAM:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_BENGALI:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TAMIL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TELUGU:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_THAI:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_LAO:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_MYANMAR:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_KHMER:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_HANGUL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_HANGUL_CONSONANT:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_NUMERIC:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_AM:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET:
|
2011-11-24 06:48:23 +04:00
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
|
|
|
|
GetFontSizeInflation());
|
2006-01-26 05:29:17 +03:00
|
|
|
GetListItemText(*myList, text);
|
|
|
|
aRenderingContext.SetFont(fm);
|
2011-04-08 08:18:43 +04:00
|
|
|
nscoord ascent = fm->MaxAscent();
|
2008-02-13 11:21:59 +03:00
|
|
|
aRenderingContext.SetTextRunRTL(mTextIsRTL);
|
2006-06-27 02:18:23 +04:00
|
|
|
aRenderingContext.DrawString(text, mPadding.left + aPt.x,
|
|
|
|
mPadding.top + aPt.y + ascent);
|
2006-01-26 05:29:17 +03:00
|
|
|
break;
|
|
|
|
}
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
|
|
|
nsBulletFrame::SetListItemOrdinal(int32_t aNextOrdinal,
|
2012-09-08 06:30:24 +04:00
|
|
|
bool* aChanged,
|
|
|
|
int32_t aIncrement)
|
1998-12-01 19:13:49 +03:00
|
|
|
{
|
2012-09-08 06:30:24 +04:00
|
|
|
MOZ_ASSERT(aIncrement == 1 || aIncrement == -1,
|
|
|
|
"We shouldn't have weird increments here");
|
|
|
|
|
1999-09-16 23:56:00 +04:00
|
|
|
// Assume that the ordinal comes from the caller
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t oldOrdinal = mOrdinal;
|
1998-12-01 19:13:49 +03:00
|
|
|
mOrdinal = aNextOrdinal;
|
|
|
|
|
|
|
|
// Try to get value directly from the list-item, if it specifies a
|
|
|
|
// value attribute. Note: we do this with our parent's content
|
|
|
|
// because our parent is the list-item.
|
2003-09-23 21:05:29 +04:00
|
|
|
nsIContent* parentContent = mParent->GetContent();
|
1999-09-16 23:56:00 +04:00
|
|
|
if (parentContent) {
|
2005-01-12 22:45:38 +03:00
|
|
|
nsGenericHTMLElement *hc =
|
|
|
|
nsGenericHTMLElement::FromContent(parentContent);
|
1999-09-16 23:56:00 +04:00
|
|
|
if (hc) {
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* attr = hc->GetParsedAttr(nsGkAtoms::value);
|
2005-01-25 03:02:58 +03:00
|
|
|
if (attr && attr->Type() == nsAttrValue::eInteger) {
|
|
|
|
// Use ordinal specified by the value attribute
|
|
|
|
mOrdinal = attr->GetIntegerValue();
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-09-16 23:56:00 +04:00
|
|
|
|
|
|
|
*aChanged = oldOrdinal != mOrdinal;
|
1998-12-01 19:13:49 +03:00
|
|
|
|
2013-02-22 22:13:37 +04:00
|
|
|
return nsCounterManager::IncrementCounter(mOrdinal, aIncrement);
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
|
|
|
|
1999-04-05 22:25:26 +04:00
|
|
|
|
|
|
|
// XXX change roman/alpha to use unsigned math so that maxint and
|
|
|
|
// maxnegint will work
|
|
|
|
|
2002-11-09 21:33:37 +03:00
|
|
|
/**
|
2011-10-17 18:59:28 +04:00
|
|
|
* For all functions below, a return value of true means that we
|
|
|
|
* could represent mOrder in the desired numbering system. false
|
2002-11-09 21:33:37 +03:00
|
|
|
* means we had to fall back to decimal
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
static bool DecimalToText(int32_t ordinal, nsString& result)
|
1999-04-05 22:25:26 +04:00
|
|
|
{
|
|
|
|
char cbuf[40];
|
|
|
|
PR_snprintf(cbuf, sizeof(cbuf), "%ld", ordinal);
|
2004-07-25 16:18:04 +04:00
|
|
|
result.AppendASCII(cbuf);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1999-04-05 22:25:26 +04:00
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
static bool DecimalLeadingZeroToText(int32_t ordinal, nsString& result)
|
1999-04-05 22:25:26 +04:00
|
|
|
{
|
|
|
|
char cbuf[40];
|
|
|
|
PR_snprintf(cbuf, sizeof(cbuf), "%02ld", ordinal);
|
2004-07-25 16:18:04 +04:00
|
|
|
result.AppendASCII(cbuf);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1999-04-05 22:25:26 +04:00
|
|
|
}
|
2014-01-04 19:02:17 +04:00
|
|
|
static bool OtherDecimalToText(int32_t ordinal, char16_t zeroChar, nsString& result)
|
2000-04-21 12:05:29 +04:00
|
|
|
{
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t diff = zeroChar - char16_t('0');
|
2013-06-08 06:45:46 +04:00
|
|
|
// We're going to be appending to whatever is in "result" already, so make
|
|
|
|
// sure to only munge the new bits. Note that we can't just grab the pointer
|
|
|
|
// to the new stuff here, since appending to the string can realloc.
|
|
|
|
size_t offset = result.Length();
|
2002-11-09 21:33:37 +03:00
|
|
|
DecimalToText(ordinal, result);
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t* p = result.BeginWriting() + offset;
|
2002-11-09 21:33:37 +03:00
|
|
|
if (ordinal < 0) {
|
|
|
|
// skip the leading '-'
|
|
|
|
++p;
|
|
|
|
}
|
2012-07-20 15:16:17 +04:00
|
|
|
for(; '\0' != *p ; p++)
|
2000-04-21 12:05:29 +04:00
|
|
|
*p += diff;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2000-04-21 12:05:29 +04:00
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
static bool TamilToText(int32_t ordinal, nsString& result)
|
2000-04-21 12:05:29 +04:00
|
|
|
{
|
2013-12-02 21:51:25 +04:00
|
|
|
if (ordinal < 1 || ordinal > 9999) {
|
|
|
|
// Can't do those in this system.
|
|
|
|
return false;
|
|
|
|
}
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t diff = 0x0BE6 - char16_t('0');
|
2013-06-08 06:45:46 +04:00
|
|
|
// We're going to be appending to whatever is in "result" already, so make
|
|
|
|
// sure to only munge the new bits. Note that we can't just grab the pointer
|
|
|
|
// to the new stuff here, since appending to the string can realloc.
|
|
|
|
size_t offset = result.Length();
|
2000-04-21 12:05:29 +04:00
|
|
|
DecimalToText(ordinal, result);
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t* p = result.BeginWriting() + offset;
|
2012-07-20 15:16:17 +04:00
|
|
|
for(; '\0' != *p ; p++)
|
2014-01-04 19:02:17 +04:00
|
|
|
if(*p != char16_t('0'))
|
2000-04-21 12:05:29 +04:00
|
|
|
*p += diff;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2000-04-21 12:05:29 +04:00
|
|
|
}
|
1999-04-05 22:25:26 +04:00
|
|
|
|
|
|
|
|
2003-05-27 07:52:33 +04:00
|
|
|
static const char gLowerRomanCharsA[] = "ixcm";
|
|
|
|
static const char gUpperRomanCharsA[] = "IXCM";
|
2003-06-20 22:34:34 +04:00
|
|
|
static const char gLowerRomanCharsB[] = "vld";
|
|
|
|
static const char gUpperRomanCharsB[] = "VLD";
|
1999-04-05 22:25:26 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static bool RomanToText(int32_t ordinal, nsString& result, const char* achars, const char* bchars)
|
1999-04-05 22:25:26 +04:00
|
|
|
{
|
2003-06-20 22:34:34 +04:00
|
|
|
if (ordinal < 1 || ordinal > 3999) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1999-04-05 22:25:26 +04:00
|
|
|
}
|
|
|
|
nsAutoString addOn, decStr;
|
2000-04-16 01:18:29 +04:00
|
|
|
decStr.AppendInt(ordinal, 10);
|
2012-08-09 11:09:40 +04:00
|
|
|
int len = decStr.Length();
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* dp = decStr.get();
|
|
|
|
const char16_t* end = dp + len;
|
2012-08-09 11:09:40 +04:00
|
|
|
int romanPos = len;
|
|
|
|
int n;
|
1999-04-05 22:25:26 +04:00
|
|
|
|
|
|
|
for (; dp < end; dp++) {
|
|
|
|
romanPos--;
|
|
|
|
addOn.SetLength(0);
|
|
|
|
switch(*dp) {
|
2010-12-20 06:38:00 +03:00
|
|
|
case '3':
|
2014-01-04 19:02:17 +04:00
|
|
|
addOn.Append(char16_t(achars[romanPos]));
|
2010-12-20 06:38:00 +03:00
|
|
|
// FALLTHROUGH
|
|
|
|
case '2':
|
2014-01-04 19:02:17 +04:00
|
|
|
addOn.Append(char16_t(achars[romanPos]));
|
2010-12-20 06:38:00 +03:00
|
|
|
// FALLTHROUGH
|
|
|
|
case '1':
|
2014-01-04 19:02:17 +04:00
|
|
|
addOn.Append(char16_t(achars[romanPos]));
|
1999-04-05 22:25:26 +04:00
|
|
|
break;
|
|
|
|
case '4':
|
2014-01-04 19:02:17 +04:00
|
|
|
addOn.Append(char16_t(achars[romanPos]));
|
1999-04-05 22:25:26 +04:00
|
|
|
// FALLTHROUGH
|
|
|
|
case '5': case '6':
|
2010-12-20 06:38:00 +03:00
|
|
|
case '7': case '8':
|
2014-01-04 19:02:17 +04:00
|
|
|
addOn.Append(char16_t(bchars[romanPos]));
|
2009-08-05 06:39:05 +04:00
|
|
|
for(n=0;'5'+n<*dp;n++) {
|
2014-01-04 19:02:17 +04:00
|
|
|
addOn.Append(char16_t(achars[romanPos]));
|
1999-04-05 22:25:26 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '9':
|
2014-01-04 19:02:17 +04:00
|
|
|
addOn.Append(char16_t(achars[romanPos]));
|
|
|
|
addOn.Append(char16_t(achars[romanPos+1]));
|
1999-04-05 22:25:26 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
result.Append(addOn);
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1999-04-05 22:25:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ALPHA_SIZE 26
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gLowerAlphaChars[ALPHA_SIZE] =
|
1999-04-05 22:25:26 +04:00
|
|
|
{
|
|
|
|
0x0061, 0x0062, 0x0063, 0x0064, 0x0065, // A B C D E
|
|
|
|
0x0066, 0x0067, 0x0068, 0x0069, 0x006A, // F G H I J
|
|
|
|
0x006B, 0x006C, 0x006D, 0x006E, 0x006F, // K L M N O
|
|
|
|
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, // P Q R S T
|
|
|
|
0x0075, 0x0076, 0x0077, 0x0078, 0x0079, // U V W X Y
|
|
|
|
0x007A // Z
|
|
|
|
};
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gUpperAlphaChars[ALPHA_SIZE] =
|
1999-04-05 22:25:26 +04:00
|
|
|
{
|
|
|
|
0x0041, 0x0042, 0x0043, 0x0044, 0x0045, // A B C D E
|
|
|
|
0x0046, 0x0047, 0x0048, 0x0049, 0x004A, // F G H I J
|
|
|
|
0x004B, 0x004C, 0x004D, 0x004E, 0x004F, // K L M N O
|
|
|
|
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, // P Q R S T
|
|
|
|
0x0055, 0x0056, 0x0057, 0x0058, 0x0059, // U V W X Y
|
|
|
|
0x005A // Z
|
|
|
|
};
|
1998-12-01 19:13:49 +03:00
|
|
|
|
1999-03-09 04:56:02 +03:00
|
|
|
|
1999-03-26 04:37:27 +03:00
|
|
|
#define KATAKANA_CHARS_SIZE 48
|
1999-03-09 04:56:02 +03:00
|
|
|
// Page 94 Writing Systems of The World
|
1999-03-26 04:37:27 +03:00
|
|
|
// after modification by momoi
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gKatakanaChars[KATAKANA_CHARS_SIZE] =
|
1999-03-09 04:56:02 +03:00
|
|
|
{
|
1999-03-26 04:37:27 +03:00
|
|
|
0x30A2, 0x30A4, 0x30A6, 0x30A8, 0x30AA, // a i u e o
|
|
|
|
0x30AB, 0x30AD, 0x30AF, 0x30B1, 0x30B3, // ka ki ku ke ko
|
|
|
|
0x30B5, 0x30B7, 0x30B9, 0x30BB, 0x30BD, // sa shi su se so
|
|
|
|
0x30BF, 0x30C1, 0x30C4, 0x30C6, 0x30C8, // ta chi tsu te to
|
|
|
|
0x30CA, 0x30CB, 0x30CC, 0x30CD, 0x30CE, // na ni nu ne no
|
|
|
|
0x30CF, 0x30D2, 0x30D5, 0x30D8, 0x30DB, // ha hi hu he ho
|
|
|
|
0x30DE, 0x30DF, 0x30E0, 0x30E1, 0x30E2, // ma mi mu me mo
|
|
|
|
0x30E4, 0x30E6, 0x30E8, // ya yu yo
|
|
|
|
0x30E9, 0x30EA, 0x30EB, 0x30EC, 0x30ED, // ra ri ru re ro
|
|
|
|
0x30EF, 0x30F0, 0x30F1, 0x30F2, // wa (w)i (w)e (w)o
|
1999-04-14 01:49:58 +04:00
|
|
|
0x30F3 // n
|
1999-03-09 04:56:02 +03:00
|
|
|
};
|
|
|
|
|
1999-03-26 04:37:27 +03:00
|
|
|
#define HIRAGANA_CHARS_SIZE 48
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gHiraganaChars[HIRAGANA_CHARS_SIZE] =
|
1999-03-09 04:56:02 +03:00
|
|
|
{
|
1999-03-26 04:37:27 +03:00
|
|
|
0x3042, 0x3044, 0x3046, 0x3048, 0x304A, // a i u e o
|
|
|
|
0x304B, 0x304D, 0x304F, 0x3051, 0x3053, // ka ki ku ke ko
|
|
|
|
0x3055, 0x3057, 0x3059, 0x305B, 0x305D, // sa shi su se so
|
|
|
|
0x305F, 0x3061, 0x3064, 0x3066, 0x3068, // ta chi tsu te to
|
|
|
|
0x306A, 0x306B, 0x306C, 0x306D, 0x306E, // na ni nu ne no
|
|
|
|
0x306F, 0x3072, 0x3075, 0x3078, 0x307B, // ha hi hu he ho
|
|
|
|
0x307E, 0x307F, 0x3080, 0x3081, 0x3082, // ma mi mu me mo
|
|
|
|
0x3084, 0x3086, 0x3088, // ya yu yo
|
|
|
|
0x3089, 0x308A, 0x308B, 0x308C, 0x308D, // ra ri ru re ro
|
|
|
|
0x308F, 0x3090, 0x3091, 0x3092, // wa (w)i (w)e (w)o
|
|
|
|
0x3093 // n
|
1999-03-09 04:56:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define HIRAGANA_IROHA_CHARS_SIZE 47
|
|
|
|
// Page 94 Writing Systems of The World
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gHiraganaIrohaChars[HIRAGANA_IROHA_CHARS_SIZE] =
|
1999-03-09 04:56:02 +03:00
|
|
|
{
|
1999-03-26 04:37:27 +03:00
|
|
|
0x3044, 0x308D, 0x306F, 0x306B, 0x307B, // i ro ha ni ho
|
|
|
|
0x3078, 0x3068, 0x3061, 0x308A, 0x306C, // he to chi ri nu
|
|
|
|
0x308B, 0x3092, 0x308F, 0x304B, 0x3088, // ru (w)o wa ka yo
|
|
|
|
0x305F, 0x308C, 0x305D, 0x3064, 0x306D, // ta re so tsu ne
|
|
|
|
0x306A, 0x3089, 0x3080, 0x3046, 0x3090, // na ra mu u (w)i
|
|
|
|
0x306E, 0x304A, 0x304F, 0x3084, 0x307E, // no o ku ya ma
|
|
|
|
0x3051, 0x3075, 0x3053, 0x3048, 0x3066, // ke hu ko e te
|
|
|
|
0x3042, 0x3055, 0x304D, 0x3086, 0x3081, // a sa ki yu me
|
|
|
|
0x307F, 0x3057, 0x3091, 0x3072, 0x3082, // mi shi (w)e hi mo
|
|
|
|
0x305B, 0x3059 // se su
|
1999-03-09 04:56:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#define KATAKANA_IROHA_CHARS_SIZE 47
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gKatakanaIrohaChars[KATAKANA_IROHA_CHARS_SIZE] =
|
1999-03-09 04:56:02 +03:00
|
|
|
{
|
1999-03-26 04:37:27 +03:00
|
|
|
0x30A4, 0x30ED, 0x30CF, 0x30CB, 0x30DB, // i ro ha ni ho
|
|
|
|
0x30D8, 0x30C8, 0x30C1, 0x30EA, 0x30CC, // he to chi ri nu
|
|
|
|
0x30EB, 0x30F2, 0x30EF, 0x30AB, 0x30E8, // ru (w)o wa ka yo
|
|
|
|
0x30BF, 0x30EC, 0x30BD, 0x30C4, 0x30CD, // ta re so tsu ne
|
|
|
|
0x30CA, 0x30E9, 0x30E0, 0x30A6, 0x30F0, // na ra mu u (w)i
|
|
|
|
0x30CE, 0x30AA, 0x30AF, 0x30E4, 0x30DE, // no o ku ya ma
|
|
|
|
0x30B1, 0x30D5, 0x30B3, 0x30A8, 0x30C6, // ke hu ko e te
|
|
|
|
0x30A2, 0x30B5, 0x30AD, 0x30E6, 0x30E1, // a sa ki yu me
|
|
|
|
0x30DF, 0x30B7, 0x30F1, 0x30D2, 0x30E2, // mi shi (w)e hi mo
|
|
|
|
0x30BB, 0x30B9 // se su
|
1999-03-09 04:56:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#define LOWER_GREEK_CHARS_SIZE 24
|
|
|
|
// Note: 0x03C2 GREEK FINAL SIGMA is not used in here....
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gLowerGreekChars[LOWER_GREEK_CHARS_SIZE] =
|
1999-03-09 04:56:02 +03:00
|
|
|
{
|
|
|
|
0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, // alpha beta gamma delta epsilon
|
|
|
|
0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, // zeta eta theta iota kappa
|
|
|
|
0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, // lamda mu nu xi omicron
|
|
|
|
0x03C0, 0x03C1, 0x03C3, 0x03C4, 0x03C5, // pi rho sigma tau upsilon
|
|
|
|
0x03C6, 0x03C7, 0x03C8, 0x03C9 // phi chi psi omega
|
|
|
|
};
|
|
|
|
|
2000-04-21 12:05:29 +04:00
|
|
|
#define CJK_HEAVENLY_STEM_CHARS_SIZE 10
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gCJKHeavenlyStemChars[CJK_HEAVENLY_STEM_CHARS_SIZE] =
|
2000-04-21 12:05:29 +04:00
|
|
|
{
|
|
|
|
0x7532, 0x4e59, 0x4e19, 0x4e01, 0x620a,
|
|
|
|
0x5df1, 0x5e9a, 0x8f9b, 0x58ec, 0x7678
|
|
|
|
};
|
|
|
|
#define CJK_EARTHLY_BRANCH_CHARS_SIZE 12
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gCJKEarthlyBranchChars[CJK_EARTHLY_BRANCH_CHARS_SIZE] =
|
2000-04-21 12:05:29 +04:00
|
|
|
{
|
|
|
|
0x5b50, 0x4e11, 0x5bc5, 0x536f, 0x8fb0, 0x5df3,
|
|
|
|
0x5348, 0x672a, 0x7533, 0x9149, 0x620c, 0x4ea5
|
|
|
|
};
|
2001-07-04 06:05:59 +04:00
|
|
|
#define HANGUL_CHARS_SIZE 14
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gHangulChars[HANGUL_CHARS_SIZE] =
|
2001-07-04 06:05:59 +04:00
|
|
|
{
|
|
|
|
0xac00, 0xb098, 0xb2e4, 0xb77c, 0xb9c8, 0xbc14,
|
|
|
|
0xc0ac, 0xc544, 0xc790, 0xcc28, 0xce74, 0xd0c0,
|
|
|
|
0xd30c, 0xd558
|
|
|
|
};
|
|
|
|
#define HANGUL_CONSONANT_CHARS_SIZE 14
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gHangulConsonantChars[HANGUL_CONSONANT_CHARS_SIZE] =
|
2001-07-04 06:05:59 +04:00
|
|
|
{
|
|
|
|
0x3131, 0x3134, 0x3137, 0x3139, 0x3141, 0x3142,
|
|
|
|
0x3145, 0x3147, 0x3148, 0x314a, 0x314b, 0x314c,
|
|
|
|
0x314d, 0x314e
|
|
|
|
};
|
|
|
|
|
2002-02-15 12:21:08 +03:00
|
|
|
// Ge'ez set of Ethiopic ordered list. There are other locale-dependent sets.
|
|
|
|
// For the time being, let's implement two Ge'ez sets only
|
|
|
|
// per Momoi san's suggestion in bug 102252.
|
|
|
|
// For details, refer to http://www.ethiopic.org/Collation/OrderedLists.html.
|
|
|
|
#define ETHIOPIC_HALEHAME_CHARS_SIZE 26
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gEthiopicHalehameChars[ETHIOPIC_HALEHAME_CHARS_SIZE] =
|
2002-02-15 12:21:08 +03:00
|
|
|
{
|
|
|
|
0x1200, 0x1208, 0x1210, 0x1218, 0x1220, 0x1228,
|
|
|
|
0x1230, 0x1240, 0x1260, 0x1270, 0x1280, 0x1290,
|
|
|
|
0x12a0, 0x12a8, 0x12c8, 0x12d0, 0x12d8, 0x12e8,
|
|
|
|
0x12f0, 0x1308, 0x1320, 0x1330, 0x1338, 0x1340,
|
|
|
|
0x1348, 0x1350
|
|
|
|
};
|
2002-07-13 00:46:19 +04:00
|
|
|
#define ETHIOPIC_HALEHAME_AM_CHARS_SIZE 33
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gEthiopicHalehameAmChars[ETHIOPIC_HALEHAME_AM_CHARS_SIZE] =
|
2002-07-13 00:46:19 +04:00
|
|
|
{
|
|
|
|
0x1200, 0x1208, 0x1210, 0x1218, 0x1220, 0x1228,
|
|
|
|
0x1230, 0x1238, 0x1240, 0x1260, 0x1270, 0x1278,
|
|
|
|
0x1280, 0x1290, 0x1298, 0x12a0, 0x12a8, 0x12b8,
|
|
|
|
0x12c8, 0x12d0, 0x12d8, 0x12e0, 0x12e8, 0x12f0,
|
|
|
|
0x1300, 0x1308, 0x1320, 0x1328, 0x1330, 0x1338,
|
|
|
|
0x1340, 0x1348, 0x1350
|
|
|
|
};
|
|
|
|
#define ETHIOPIC_HALEHAME_TI_ER_CHARS_SIZE 31
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gEthiopicHalehameTiErChars[ETHIOPIC_HALEHAME_TI_ER_CHARS_SIZE] =
|
2002-07-13 00:46:19 +04:00
|
|
|
{
|
|
|
|
0x1200, 0x1208, 0x1210, 0x1218, 0x1228, 0x1230,
|
|
|
|
0x1238, 0x1240, 0x1250, 0x1260, 0x1270, 0x1278,
|
|
|
|
0x1290, 0x1298, 0x12a0, 0x12a8, 0x12b8, 0x12c8,
|
|
|
|
0x12d0, 0x12d8, 0x12e0, 0x12e8, 0x12f0, 0x1300,
|
|
|
|
0x1308, 0x1320, 0x1328, 0x1330, 0x1338, 0x1348,
|
|
|
|
0x1350
|
|
|
|
};
|
|
|
|
#define ETHIOPIC_HALEHAME_TI_ET_CHARS_SIZE 34
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gEthiopicHalehameTiEtChars[ETHIOPIC_HALEHAME_TI_ET_CHARS_SIZE] =
|
2002-07-13 00:46:19 +04:00
|
|
|
{
|
|
|
|
0x1200, 0x1208, 0x1210, 0x1218, 0x1220, 0x1228,
|
|
|
|
0x1230, 0x1238, 0x1240, 0x1250, 0x1260, 0x1270,
|
|
|
|
0x1278, 0x1280, 0x1290, 0x1298, 0x12a0, 0x12a8,
|
|
|
|
0x12b8, 0x12c8, 0x12d0, 0x12d8, 0x12e0, 0x12e8,
|
|
|
|
0x12f0, 0x1300, 0x1308, 0x1320, 0x1328, 0x1330,
|
|
|
|
0x1338, 0x1340, 0x1348, 0x1350
|
|
|
|
};
|
2002-02-15 12:21:08 +03:00
|
|
|
|
|
|
|
|
1999-04-05 22:25:26 +04:00
|
|
|
// We know cjk-ideographic need 31 characters to display 99,999,999,999,999,999
|
2002-11-09 21:33:37 +03:00
|
|
|
// georgian needs 6 at most
|
|
|
|
// armenian needs 12 at most
|
1999-04-05 22:25:26 +04:00
|
|
|
// hebrew may need more...
|
|
|
|
|
|
|
|
#define NUM_BUF_SIZE 34
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
static bool CharListToText(int32_t ordinal, nsString& result, const char16_t* chars, int32_t aBase)
|
1999-04-05 22:25:26 +04:00
|
|
|
{
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t buf[NUM_BUF_SIZE];
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t idx = NUM_BUF_SIZE;
|
2002-11-09 21:33:37 +03:00
|
|
|
if (ordinal < 1) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1999-04-05 22:25:26 +04:00
|
|
|
}
|
|
|
|
do {
|
1999-04-14 01:49:58 +04:00
|
|
|
ordinal--; // a == 0
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t cur = ordinal % aBase;
|
1999-04-14 01:49:58 +04:00
|
|
|
buf[--idx] = chars[cur];
|
|
|
|
ordinal /= aBase ;
|
1999-04-05 22:25:26 +04:00
|
|
|
} while ( ordinal > 0);
|
|
|
|
result.Append(buf+idx,NUM_BUF_SIZE-idx);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1999-04-05 22:25:26 +04:00
|
|
|
}
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gCJKDecimalChars[10] =
|
2013-12-02 21:51:26 +04:00
|
|
|
{
|
|
|
|
0x3007, 0x4e00, 0x4e8c, 0x4e09, 0x56db,
|
|
|
|
0x4e94, 0x516d, 0x4e03, 0x516b, 0x4e5d
|
|
|
|
};
|
2014-01-04 19:02:17 +04:00
|
|
|
static bool CharListDecimalToText(int32_t ordinal, nsString& result, const char16_t* chars)
|
2013-12-02 21:51:26 +04:00
|
|
|
{
|
|
|
|
if (ordinal < 0) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t buf[NUM_BUF_SIZE];
|
2013-12-02 21:51:26 +04:00
|
|
|
int32_t idx = NUM_BUF_SIZE;
|
|
|
|
do {
|
|
|
|
buf[--idx] = chars[ordinal % 10];
|
|
|
|
ordinal /= 10;
|
|
|
|
} while (ordinal > 0);
|
|
|
|
result.Append(buf + idx, NUM_BUF_SIZE - idx);
|
|
|
|
return true;
|
|
|
|
}
|
1999-04-05 22:25:26 +04:00
|
|
|
|
2013-12-02 21:51:26 +04:00
|
|
|
enum CJKIdeographicLang {
|
|
|
|
CHINESE, KOREAN, JAPANESE
|
1999-04-05 22:25:26 +04:00
|
|
|
};
|
2013-12-02 21:51:26 +04:00
|
|
|
struct CJKIdeographicData {
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *negative;
|
|
|
|
char16_t digit[10];
|
|
|
|
char16_t unit[3];
|
|
|
|
char16_t unit10K[2];
|
2013-12-02 21:51:26 +04:00
|
|
|
uint8_t lang;
|
|
|
|
bool informal;
|
2000-04-21 12:05:29 +04:00
|
|
|
};
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gJapaneseNegative[] = {
|
2013-12-02 21:51:26 +04:00
|
|
|
0x30de, 0x30a4, 0x30ca, 0x30b9, 0x0000
|
2000-04-21 12:05:29 +04:00
|
|
|
};
|
2013-12-02 21:51:26 +04:00
|
|
|
static const CJKIdeographicData gDataJapaneseInformal = {
|
|
|
|
gJapaneseNegative, // negative
|
|
|
|
{ // digit
|
|
|
|
0x3007, 0x4e00, 0x4e8c, 0x4e09, 0x56db,
|
|
|
|
0x4e94, 0x516d, 0x4e03, 0x516b, 0x4e5d
|
|
|
|
},
|
|
|
|
{ 0x5341, 0x767e, 0x5343 }, // unit
|
|
|
|
{ 0x4e07, 0x5104 }, // unit10K
|
|
|
|
JAPANESE, // lang
|
|
|
|
true // informal
|
1999-04-05 22:25:26 +04:00
|
|
|
};
|
2013-12-02 21:51:26 +04:00
|
|
|
static const CJKIdeographicData gDataJapaneseFormal = {
|
|
|
|
gJapaneseNegative, // negative
|
|
|
|
{ // digit
|
|
|
|
0x96f6, 0x58f1, 0x5f10, 0x53c2, 0x56db,
|
|
|
|
0x4f0d, 0x516d, 0x4e03, 0x516b, 0x4e5d
|
|
|
|
},
|
|
|
|
{ 0x62fe, 0x767e, 0x9621 }, // unit
|
|
|
|
{ 0x842c, 0x5104 }, // unit10K
|
|
|
|
JAPANESE, // lang
|
|
|
|
false // informal
|
2000-04-21 12:05:29 +04:00
|
|
|
};
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gKoreanNegative[] = {
|
2013-12-02 21:51:26 +04:00
|
|
|
0xb9c8, 0xc774, 0xb108, 0xc2a4, 0x0020, 0x0000
|
1999-04-05 22:25:26 +04:00
|
|
|
};
|
2013-12-02 21:51:26 +04:00
|
|
|
static const CJKIdeographicData gDataKoreanHangulFormal = {
|
|
|
|
gKoreanNegative, // negative
|
|
|
|
{ // digit
|
|
|
|
0xc601, 0xc77c, 0xc774, 0xc0bc, 0xc0ac,
|
|
|
|
0xc624, 0xc721, 0xce60, 0xd314, 0xad6c
|
|
|
|
},
|
|
|
|
{ 0xc2ed, 0xbc31, 0xcc9c }, // unit
|
|
|
|
{ 0xb9cc, 0xc5b5 }, // unit10K
|
|
|
|
KOREAN, // lang
|
|
|
|
false // informal
|
2000-04-21 12:05:29 +04:00
|
|
|
};
|
2013-12-02 21:51:26 +04:00
|
|
|
static const CJKIdeographicData gDataKoreanHanjaInformal = {
|
|
|
|
gKoreanNegative, // negative
|
|
|
|
{ // digit
|
|
|
|
0x96f6, 0x4e00, 0x4e8c, 0x4e09, 0x56db,
|
|
|
|
0x4e94, 0x516d, 0x4e03, 0x516b, 0x4e5d
|
|
|
|
},
|
|
|
|
{ 0x5341, 0x767e, 0x5343 }, // unit
|
|
|
|
{ 0x842c, 0x5104 }, // unit10K
|
|
|
|
KOREAN, // lang
|
|
|
|
true // informal
|
|
|
|
};
|
|
|
|
static const CJKIdeographicData gDataKoreanHanjaFormal = {
|
|
|
|
gKoreanNegative, // negative
|
|
|
|
{ // digit
|
|
|
|
0x96f6, 0x58f9, 0x8cb3, 0x53c3, 0x56db,
|
|
|
|
0x4e94, 0x516d, 0x4e03, 0x516b, 0x4e5d
|
|
|
|
},
|
|
|
|
{ 0x62fe, 0x767e, 0x4edf }, // unit
|
|
|
|
{ 0x842c, 0x5104 }, // unit10K
|
|
|
|
KOREAN, // lang
|
|
|
|
false // informal
|
|
|
|
};
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gSimpChineseNegative[] = {
|
2013-12-02 21:51:26 +04:00
|
|
|
0x8d1f, 0x0000
|
|
|
|
};
|
|
|
|
static const CJKIdeographicData gDataSimpChineseInformal = {
|
|
|
|
gSimpChineseNegative, // negative
|
|
|
|
{ // digit
|
|
|
|
0x96f6, 0x4e00, 0x4e8c, 0x4e09, 0x56db,
|
|
|
|
0x4e94, 0x516d, 0x4e03, 0x516b, 0x4e5d
|
|
|
|
},
|
|
|
|
{ 0x5341, 0x767e, 0x5343 }, // unit
|
|
|
|
{ 0x4e07, 0x4ebf }, // unit10K
|
|
|
|
CHINESE, // lang
|
|
|
|
true // informal
|
|
|
|
};
|
|
|
|
static const CJKIdeographicData gDataSimpChineseFormal = {
|
|
|
|
gSimpChineseNegative, // negative
|
|
|
|
{ // digit
|
|
|
|
0x96f6, 0x58f9, 0x8d30, 0x53c1, 0x8086,
|
|
|
|
0x4f0d, 0x9646, 0x67d2, 0x634c, 0x7396
|
|
|
|
},
|
|
|
|
{ 0x62fe, 0x4f70, 0x4edf }, // unit
|
|
|
|
{ 0x4e07, 0x4ebf }, // unit10K
|
|
|
|
CHINESE, // lang
|
|
|
|
false // informal
|
|
|
|
};
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gTradChineseNegative[] = {
|
2013-12-02 21:51:26 +04:00
|
|
|
0x8ca0, 0x0000
|
|
|
|
};
|
|
|
|
static const CJKIdeographicData gDataTradChineseInformal = {
|
|
|
|
gTradChineseNegative, // negative
|
|
|
|
{ // digit
|
|
|
|
0x96f6, 0x4e00, 0x4e8c, 0x4e09, 0x56db,
|
|
|
|
0x4e94, 0x516d, 0x4e03, 0x516b, 0x4e5d
|
|
|
|
},
|
|
|
|
{ 0x5341, 0x767e, 0x5343 }, // unit
|
|
|
|
{ 0x842c, 0x5104 }, // unit10K
|
|
|
|
CHINESE, // lang
|
|
|
|
true // informal
|
|
|
|
};
|
|
|
|
static const CJKIdeographicData gDataTradChineseFormal = {
|
|
|
|
gTradChineseNegative, // negative
|
|
|
|
{ // digit
|
|
|
|
0x96f6, 0x58f9, 0x8cb3, 0x53c3, 0x8086,
|
|
|
|
0x4f0d, 0x9678, 0x67d2, 0x634c, 0x7396
|
|
|
|
},
|
|
|
|
{ 0x62fe, 0x4f70, 0x4edf }, // unit
|
|
|
|
{ 0x842c, 0x5104 }, // unit10K
|
|
|
|
CHINESE, // lang
|
|
|
|
false // informal
|
2000-04-21 12:05:29 +04:00
|
|
|
};
|
1999-04-05 22:25:26 +04:00
|
|
|
|
2013-12-02 21:51:26 +04:00
|
|
|
static const bool CJKIdeographicToText(int32_t ordinal, nsString& result,
|
|
|
|
const CJKIdeographicData& data)
|
1999-04-05 22:25:26 +04:00
|
|
|
{
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t buf[NUM_BUF_SIZE];
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t idx = NUM_BUF_SIZE;
|
2013-12-02 21:51:26 +04:00
|
|
|
int32_t pos = 0;
|
|
|
|
bool isNegative = (ordinal < 0);
|
|
|
|
bool needZero = (ordinal == 0);
|
|
|
|
int32_t unitidx = 0, unit10Kidx = 0;
|
|
|
|
if (isNegative) {
|
|
|
|
ordinal = -ordinal;
|
|
|
|
}
|
1999-04-14 01:49:58 +04:00
|
|
|
do {
|
2013-12-02 21:51:26 +04:00
|
|
|
unitidx = pos % 4;
|
|
|
|
if (unitidx == 0) {
|
|
|
|
unit10Kidx = pos / 4;
|
1999-04-14 01:49:58 +04:00
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t cur = ordinal % 10;
|
2013-12-02 21:51:26 +04:00
|
|
|
if (cur == 0) {
|
|
|
|
if (needZero) {
|
|
|
|
needZero = false;
|
|
|
|
buf[--idx] = data.digit[0];
|
1999-04-14 01:49:58 +04:00
|
|
|
}
|
2013-12-02 21:51:26 +04:00
|
|
|
} else {
|
|
|
|
if (data.lang == CHINESE) {
|
|
|
|
needZero = true;
|
|
|
|
}
|
|
|
|
if (unit10Kidx != 0) {
|
|
|
|
if (data.lang == KOREAN) {
|
|
|
|
buf[--idx] = ' ';
|
|
|
|
}
|
|
|
|
buf[--idx] = data.unit10K[unit10Kidx - 1];
|
|
|
|
}
|
|
|
|
if (unitidx != 0) {
|
|
|
|
buf[--idx] = data.unit[unitidx - 1];
|
|
|
|
}
|
|
|
|
if (cur != 1) {
|
|
|
|
buf[--idx] = data.digit[cur];
|
|
|
|
} else {
|
|
|
|
bool needOne = true;
|
|
|
|
if (data.informal) {
|
|
|
|
switch (data.lang) {
|
|
|
|
case CHINESE:
|
|
|
|
if (unitidx == 1 &&
|
|
|
|
(ordinal == 1 || (pos > 4 && ordinal % 1000 == 1))) {
|
|
|
|
needOne = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case JAPANESE:
|
|
|
|
if (unitidx > 0 &&
|
|
|
|
(unitidx != 3 || (pos == 3 && ordinal == 1))) {
|
|
|
|
needOne = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KOREAN:
|
|
|
|
if (unitidx > 0 || (pos == 4 && (ordinal % 1000) == 1)) {
|
|
|
|
needOne = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (needOne) {
|
|
|
|
buf[--idx] = data.digit[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unit10Kidx = 0;
|
1999-04-14 01:49:58 +04:00
|
|
|
}
|
|
|
|
ordinal /= 10;
|
2013-12-02 21:51:26 +04:00
|
|
|
pos++;
|
|
|
|
} while (ordinal > 0);
|
|
|
|
if (isNegative) {
|
|
|
|
result.Append(data.negative);
|
|
|
|
}
|
|
|
|
result.Append(buf + idx, NUM_BUF_SIZE - idx);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1999-04-05 22:25:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define HEBREW_GERESH 0x05F3
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gHebrewDigit[22] =
|
1999-04-05 22:25:26 +04:00
|
|
|
{
|
|
|
|
// 1 2 3 4 5 6 7 8 9
|
|
|
|
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8,
|
|
|
|
// 10 20 30 40 50 60 70 80 90
|
|
|
|
0x05D9, 0x05DB, 0x05DC, 0x05DE, 0x05E0, 0x05E1, 0x05E2, 0x05E4, 0x05E6,
|
|
|
|
// 100 200 300 400
|
|
|
|
0x05E7, 0x05E8, 0x05E9, 0x05EA
|
|
|
|
};
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static bool HebrewToText(int32_t ordinal, nsString& result)
|
1999-04-05 22:25:26 +04:00
|
|
|
{
|
2008-02-13 11:21:59 +03:00
|
|
|
if (ordinal < 1 || ordinal > 999999) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2002-11-09 21:33:37 +03:00
|
|
|
}
|
2011-09-29 10:19:26 +04:00
|
|
|
bool outputSep = false;
|
2008-02-13 11:21:59 +03:00
|
|
|
nsAutoString allText, thousandsGroup;
|
1999-04-14 01:49:58 +04:00
|
|
|
do {
|
2008-02-13 11:21:59 +03:00
|
|
|
thousandsGroup.Truncate();
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t n3 = ordinal % 1000;
|
1999-04-14 01:49:58 +04:00
|
|
|
// Process digit for 100 - 900
|
2012-08-22 19:56:38 +04:00
|
|
|
for(int32_t n1 = 400; n1 > 0; )
|
1999-04-14 01:49:58 +04:00
|
|
|
{
|
|
|
|
if( n3 >= n1)
|
|
|
|
{
|
|
|
|
n3 -= n1;
|
2008-02-13 11:21:59 +03:00
|
|
|
thousandsGroup.Append(gHebrewDigit[(n1/100)-1+18]);
|
1999-04-14 01:49:58 +04:00
|
|
|
} else {
|
|
|
|
n1 -= 100;
|
|
|
|
} // if
|
|
|
|
} // for
|
|
|
|
|
|
|
|
// Process digit for 10 - 90
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t n2;
|
1999-04-14 01:49:58 +04:00
|
|
|
if( n3 >= 10 )
|
|
|
|
{
|
|
|
|
// Special process for 15 and 16
|
|
|
|
if(( 15 == n3 ) || (16 == n3)) {
|
|
|
|
// Special rule for religious reason...
|
|
|
|
// 15 is represented by 9 and 6, not 10 and 5
|
|
|
|
// 16 is represented by 9 and 7, not 10 and 6
|
|
|
|
n2 = 9;
|
2008-02-13 11:21:59 +03:00
|
|
|
thousandsGroup.Append(gHebrewDigit[ n2 - 1]);
|
1999-04-14 01:49:58 +04:00
|
|
|
} else {
|
|
|
|
n2 = n3 - (n3 % 10);
|
2008-02-13 11:21:59 +03:00
|
|
|
thousandsGroup.Append(gHebrewDigit[(n2/10)-1+9]);
|
1999-04-14 01:49:58 +04:00
|
|
|
} // if
|
|
|
|
n3 -= n2;
|
|
|
|
} // if
|
|
|
|
|
|
|
|
// Process digit for 1 - 9
|
|
|
|
if ( n3 > 0)
|
2008-02-13 11:21:59 +03:00
|
|
|
thousandsGroup.Append(gHebrewDigit[n3-1]);
|
|
|
|
if (outputSep)
|
2014-01-04 19:02:17 +04:00
|
|
|
thousandsGroup.Append((char16_t)HEBREW_GERESH);
|
2008-02-13 11:21:59 +03:00
|
|
|
if (allText.IsEmpty())
|
|
|
|
allText = thousandsGroup;
|
|
|
|
else
|
|
|
|
allText = thousandsGroup + allText;
|
1999-04-14 01:49:58 +04:00
|
|
|
ordinal /= 1000;
|
2011-10-17 18:59:28 +04:00
|
|
|
outputSep = true;
|
1999-04-14 01:49:58 +04:00
|
|
|
} while (ordinal >= 1);
|
2008-02-13 11:21:59 +03:00
|
|
|
|
|
|
|
result.Append(allText);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1999-04-05 22:25:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static bool ArmenianToText(int32_t ordinal, nsString& result)
|
1999-04-05 22:25:26 +04:00
|
|
|
{
|
2002-11-09 21:33:37 +03:00
|
|
|
if (ordinal < 1 || ordinal > 9999) { // zero or reach the limit of Armenian numbering system
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1999-04-14 01:49:58 +04:00
|
|
|
}
|
2002-11-09 21:33:37 +03:00
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t buf[NUM_BUF_SIZE];
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t idx = NUM_BUF_SIZE;
|
|
|
|
int32_t d = 0;
|
2002-11-09 21:33:37 +03:00
|
|
|
do {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t cur = ordinal % 10;
|
2002-11-09 21:33:37 +03:00
|
|
|
if (cur > 0)
|
|
|
|
{
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t u = 0x0530 + (d * 9) + cur;
|
2002-11-09 21:33:37 +03:00
|
|
|
buf[--idx] = u;
|
|
|
|
}
|
|
|
|
++d;
|
|
|
|
ordinal /= 10;
|
|
|
|
} while (ordinal > 0);
|
|
|
|
result.Append(buf + idx, NUM_BUF_SIZE - idx);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1999-04-05 22:25:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t gGeorgianValue [ 37 ] = { // 4 * 9 + 1 = 37
|
1999-04-05 22:25:26 +04:00
|
|
|
// 1 2 3 4 5 6 7 8 9
|
2005-03-23 02:27:03 +03:00
|
|
|
0x10D0, 0x10D1, 0x10D2, 0x10D3, 0x10D4, 0x10D5, 0x10D6, 0x10F1, 0x10D7,
|
1999-04-05 22:25:26 +04:00
|
|
|
// 10 20 30 40 50 60 70 80 90
|
2005-03-23 02:27:03 +03:00
|
|
|
0x10D8, 0x10D9, 0x10DA, 0x10DB, 0x10DC, 0x10F2, 0x10DD, 0x10DE, 0x10DF,
|
1999-04-05 22:25:26 +04:00
|
|
|
// 100 200 300 400 500 600 700 800 900
|
2005-03-23 03:26:28 +03:00
|
|
|
0x10E0, 0x10E1, 0x10E2, 0x10F3, 0x10E4, 0x10E5, 0x10E6, 0x10E7, 0x10E8,
|
1999-04-05 22:25:26 +04:00
|
|
|
// 1000 2000 3000 4000 5000 6000 7000 8000 9000
|
2005-03-23 03:26:28 +03:00
|
|
|
0x10E9, 0x10EA, 0x10EB, 0x10EC, 0x10ED, 0x10EE, 0x10F4, 0x10EF, 0x10F0,
|
1999-04-05 22:25:26 +04:00
|
|
|
// 10000
|
2005-03-23 03:26:28 +03:00
|
|
|
0x10F5
|
1999-04-05 22:25:26 +04:00
|
|
|
};
|
2012-08-22 19:56:38 +04:00
|
|
|
static bool GeorgianToText(int32_t ordinal, nsString& result)
|
1999-04-05 22:25:26 +04:00
|
|
|
{
|
2002-11-09 21:33:37 +03:00
|
|
|
if (ordinal < 1 || ordinal > 19999) { // zero or reach the limit of Georgian numbering system
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1999-04-14 01:49:58 +04:00
|
|
|
}
|
2002-11-09 21:33:37 +03:00
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t buf[NUM_BUF_SIZE];
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t idx = NUM_BUF_SIZE;
|
|
|
|
int32_t d = 0;
|
2002-11-09 21:33:37 +03:00
|
|
|
do {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t cur = ordinal % 10;
|
2002-11-09 21:33:37 +03:00
|
|
|
if (cur > 0)
|
|
|
|
{
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t u = gGeorgianValue[(d * 9 ) + ( cur - 1)];
|
2002-11-09 21:33:37 +03:00
|
|
|
buf[--idx] = u;
|
|
|
|
}
|
|
|
|
++d;
|
|
|
|
ordinal /= 10;
|
|
|
|
} while (ordinal > 0);
|
|
|
|
result.Append(buf + idx, NUM_BUF_SIZE - idx);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1999-04-05 22:25:26 +04:00
|
|
|
}
|
|
|
|
|
2002-02-15 12:21:08 +03:00
|
|
|
// Convert ordinal to Ethiopic numeric representation.
|
|
|
|
// The detail is available at http://www.ethiopic.org/Numerals/
|
2003-06-26 23:46:51 +04:00
|
|
|
// The algorithm used here is based on the pseudo-code put up there by
|
|
|
|
// Daniel Yacob <yacob@geez.org>.
|
|
|
|
// Another reference is Unicode 3.0 standard section 11.1.
|
|
|
|
#define ETHIOPIC_ONE 0x1369
|
|
|
|
#define ETHIOPIC_TEN 0x1372
|
|
|
|
#define ETHIOPIC_HUNDRED 0x137B
|
|
|
|
#define ETHIOPIC_TEN_THOUSAND 0x137C
|
2002-02-15 12:21:08 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static bool EthiopicToText(int32_t ordinal, nsString& result)
|
2003-06-26 23:46:51 +04:00
|
|
|
{
|
2002-11-09 21:33:37 +03:00
|
|
|
if (ordinal < 1) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2002-11-09 21:33:37 +03:00
|
|
|
}
|
2013-12-02 21:51:25 +04:00
|
|
|
nsAutoString asciiNumberString; // decimal string representation of ordinal
|
|
|
|
DecimalToText(ordinal, asciiNumberString);
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t asciiStringLength = asciiNumberString.Length();
|
2003-06-26 23:46:51 +04:00
|
|
|
|
|
|
|
// If number length is odd, add a leading "0"
|
|
|
|
// the leading "0" preconditions the string to always have the
|
|
|
|
// leading tens place populated, this avoids a check within the loop.
|
|
|
|
// If we didn't add the leading "0", decrement asciiStringLength so
|
|
|
|
// it will be equivalent to a zero-based index in both cases.
|
|
|
|
if (asciiStringLength & 1) {
|
|
|
|
asciiNumberString.Insert(NS_LITERAL_STRING("0"), 0);
|
|
|
|
} else {
|
|
|
|
asciiStringLength--;
|
|
|
|
}
|
2002-02-15 12:21:08 +03:00
|
|
|
|
2003-06-26 23:46:51 +04:00
|
|
|
// Iterate from the highest digits to lowest
|
|
|
|
// indexFromLeft indexes digits (0 = most significant)
|
|
|
|
// groupIndexFromRight indexes pairs of digits (0 = least significant)
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint8_t indexFromLeft = 0, groupIndexFromRight = asciiStringLength >> 1;
|
2003-06-26 23:46:51 +04:00
|
|
|
indexFromLeft <= asciiStringLength;
|
|
|
|
indexFromLeft += 2, groupIndexFromRight--) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t tensValue = asciiNumberString.CharAt(indexFromLeft) & 0x0F;
|
|
|
|
uint8_t unitsValue = asciiNumberString.CharAt(indexFromLeft + 1) & 0x0F;
|
|
|
|
uint8_t groupValue = tensValue * 10 + unitsValue;
|
2003-06-26 23:46:51 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool oddGroup = (groupIndexFromRight & 1);
|
2003-06-26 23:46:51 +04:00
|
|
|
|
|
|
|
// we want to clear ETHIOPIC_ONE when it is superfluous
|
|
|
|
if (ordinal > 1 &&
|
|
|
|
groupValue == 1 && // one without a leading ten
|
|
|
|
(oddGroup || indexFromLeft == 0)) { // preceding (100) or leading the sequence
|
|
|
|
unitsValue = 0;
|
|
|
|
}
|
2002-02-15 12:21:08 +03:00
|
|
|
|
2003-06-26 23:46:51 +04:00
|
|
|
// put it all together...
|
|
|
|
if (tensValue) {
|
|
|
|
// map onto Ethiopic "tens":
|
2014-01-04 19:02:17 +04:00
|
|
|
result.Append((char16_t) (tensValue + ETHIOPIC_TEN - 1));
|
2003-06-26 23:46:51 +04:00
|
|
|
}
|
|
|
|
if (unitsValue) {
|
|
|
|
//map onto Ethiopic "units":
|
2014-01-04 19:02:17 +04:00
|
|
|
result.Append((char16_t) (unitsValue + ETHIOPIC_ONE - 1));
|
2003-06-26 23:46:51 +04:00
|
|
|
}
|
|
|
|
// Add a separator for all even groups except the last,
|
|
|
|
// and for odd groups with non-zero value.
|
|
|
|
if (oddGroup) {
|
|
|
|
if (groupValue) {
|
2014-01-04 19:02:17 +04:00
|
|
|
result.Append((char16_t) ETHIOPIC_HUNDRED);
|
2002-02-15 12:21:08 +03:00
|
|
|
}
|
2003-06-26 23:46:51 +04:00
|
|
|
} else {
|
|
|
|
if (groupIndexFromRight) {
|
2014-01-04 19:02:17 +04:00
|
|
|
result.Append((char16_t) ETHIOPIC_TEN_THOUSAND);
|
2002-02-15 12:21:08 +03:00
|
|
|
}
|
|
|
|
}
|
2002-11-09 21:33:37 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2002-02-15 12:21:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-02 21:51:25 +04:00
|
|
|
/* static */ void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsBulletFrame::AppendCounterText(int32_t aListStyleType,
|
|
|
|
int32_t aOrdinal,
|
2013-12-02 21:51:25 +04:00
|
|
|
nsString& result,
|
|
|
|
bool& isRTL)
|
1998-12-01 19:13:49 +03:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool success = true;
|
2013-12-02 21:51:25 +04:00
|
|
|
int32_t fallback = NS_STYLE_LIST_STYLE_DECIMAL;
|
|
|
|
isRTL = false;
|
2005-04-02 03:07:00 +04:00
|
|
|
|
|
|
|
switch (aListStyleType) {
|
|
|
|
case NS_STYLE_LIST_STYLE_NONE: // used by counters code only
|
|
|
|
break;
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2005-04-02 03:07:00 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_DISC: // used by counters code only
|
|
|
|
// XXX We really need to do this the same way we do list bullets.
|
2014-01-04 19:02:17 +04:00
|
|
|
result.Append(char16_t(0x2022));
|
2005-04-02 03:07:00 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_CIRCLE: // used by counters code only
|
|
|
|
// XXX We really need to do this the same way we do list bullets.
|
2014-01-04 19:02:17 +04:00
|
|
|
result.Append(char16_t(0x25E6));
|
2005-04-02 03:07:00 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_SQUARE: // used by counters code only
|
|
|
|
// XXX We really need to do this the same way we do list bullets.
|
2014-01-04 19:02:17 +04:00
|
|
|
result.Append(char16_t(0x25FE));
|
2005-04-02 03:07:00 +04:00
|
|
|
break;
|
2001-03-09 06:29:00 +03:00
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
case NS_STYLE_LIST_STYLE_DECIMAL:
|
1999-04-14 01:49:58 +04:00
|
|
|
default: // CSS2 say "A users agent that does not recognize a numbering system
|
|
|
|
// should use 'decimal'
|
2005-04-02 03:07:00 +04:00
|
|
|
success = DecimalToText(aOrdinal, result);
|
2013-12-02 21:51:25 +04:00
|
|
|
NS_ASSERTION(success, "DecimalToText must never fail");
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1998-12-01 19:13:49 +03:00
|
|
|
|
1999-03-26 04:37:27 +03:00
|
|
|
case NS_STYLE_LIST_STYLE_DECIMAL_LEADING_ZERO:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = DecimalLeadingZeroToText(aOrdinal, result);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1999-03-26 04:37:27 +03:00
|
|
|
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_CJK_DECIMAL:
|
|
|
|
success = CharListDecimalToText(aOrdinal, result, gCJKDecimalChars);
|
|
|
|
break;
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
case NS_STYLE_LIST_STYLE_LOWER_ROMAN:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = RomanToText(aOrdinal, result,
|
2002-11-09 21:33:37 +03:00
|
|
|
gLowerRomanCharsA, gLowerRomanCharsB);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1999-02-12 20:45:58 +03:00
|
|
|
case NS_STYLE_LIST_STYLE_UPPER_ROMAN:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = RomanToText(aOrdinal, result,
|
2002-11-09 21:33:37 +03:00
|
|
|
gUpperRomanCharsA, gUpperRomanCharsB);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1998-12-01 19:13:49 +03:00
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
case NS_STYLE_LIST_STYLE_LOWER_ALPHA:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gLowerAlphaChars, ALPHA_SIZE);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1999-04-05 22:25:26 +04:00
|
|
|
|
1999-04-14 01:49:58 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_UPPER_ALPHA:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gUpperAlphaChars, ALPHA_SIZE);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1998-12-01 19:13:49 +03:00
|
|
|
|
1999-03-09 04:56:02 +03:00
|
|
|
case NS_STYLE_LIST_STYLE_KATAKANA:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gKatakanaChars,
|
2002-11-09 21:33:37 +03:00
|
|
|
KATAKANA_CHARS_SIZE);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1999-03-09 04:56:02 +03:00
|
|
|
|
1999-04-05 22:25:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_HIRAGANA:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gHiraganaChars,
|
2002-11-09 21:33:37 +03:00
|
|
|
HIRAGANA_CHARS_SIZE);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1999-04-05 22:25:26 +04:00
|
|
|
|
1999-04-14 01:49:58 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_KATAKANA_IROHA:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gKatakanaIrohaChars,
|
2002-11-09 21:33:37 +03:00
|
|
|
KATAKANA_IROHA_CHARS_SIZE);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_HIRAGANA_IROHA:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gHiraganaIrohaChars,
|
2002-11-09 21:33:37 +03:00
|
|
|
HIRAGANA_IROHA_CHARS_SIZE);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1999-03-09 04:56:02 +03:00
|
|
|
|
1999-04-05 22:25:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_LOWER_GREEK:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gLowerGreekChars ,
|
2002-11-09 21:33:37 +03:00
|
|
|
LOWER_GREEK_CHARS_SIZE);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1999-04-05 22:25:26 +04:00
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC:
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL:
|
2013-12-02 21:51:26 +04:00
|
|
|
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
|
2013-12-02 21:51:26 +04:00
|
|
|
success =
|
|
|
|
CJKIdeographicToText(aOrdinal, result, gDataTradChineseInformal);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL:
|
2013-12-02 21:51:26 +04:00
|
|
|
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
|
2013-12-02 21:51:26 +04:00
|
|
|
success = CJKIdeographicToText(aOrdinal, result, gDataTradChineseFormal);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL:
|
2013-12-02 21:51:26 +04:00
|
|
|
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
|
2013-12-02 21:51:26 +04:00
|
|
|
success =
|
|
|
|
CJKIdeographicToText(aOrdinal, result, gDataSimpChineseInformal);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL:
|
2013-12-02 21:51:26 +04:00
|
|
|
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
|
2013-12-02 21:51:26 +04:00
|
|
|
success = CJKIdeographicToText(aOrdinal, result, gDataSimpChineseFormal);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL:
|
2013-12-02 21:51:26 +04:00
|
|
|
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
|
2013-12-02 21:51:26 +04:00
|
|
|
success = CJKIdeographicToText(aOrdinal, result, gDataJapaneseInformal);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL:
|
2013-12-02 21:51:26 +04:00
|
|
|
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
|
2013-12-02 21:51:26 +04:00
|
|
|
success = CJKIdeographicToText(aOrdinal, result, gDataJapaneseFormal);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
|
|
|
|
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
|
|
|
|
success =
|
|
|
|
CJKIdeographicToText(aOrdinal, result, gDataKoreanHangulFormal);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
|
|
|
|
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
|
|
|
|
success =
|
|
|
|
CJKIdeographicToText(aOrdinal, result, gDataKoreanHanjaInformal);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
|
|
|
|
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
|
|
|
|
success = CJKIdeographicToText(aOrdinal, result, gDataKoreanHanjaFormal);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1999-04-05 22:25:26 +04:00
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_HEBREW:
|
2013-12-02 21:51:25 +04:00
|
|
|
isRTL = true;
|
2005-04-02 03:07:00 +04:00
|
|
|
success = HebrewToText(aOrdinal, result);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1999-04-05 22:25:26 +04:00
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_ARMENIAN:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = ArmenianToText(aOrdinal, result);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1999-04-05 22:25:26 +04:00
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_GEORGIAN:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = GeorgianToText(aOrdinal, result);
|
1999-04-14 01:49:58 +04:00
|
|
|
break;
|
1999-04-05 22:25:26 +04:00
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ARABIC_INDIC:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x0660, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_PERSIAN:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_URDU:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x06f0, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_DEVANAGARI:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x0966, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_GURMUKHI:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x0a66, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_GUJARATI:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x0AE6, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ORIYA:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x0B66, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_KANNADA:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x0CE6, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_MALAYALAM:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x0D66, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_THAI:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x0E50, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_LAO:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x0ED0, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_MYANMAR:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x1040, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_KHMER:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x17E0, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_BENGALI:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x09E6, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TELUGU:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = OtherDecimalToText(aOrdinal, 0x0C66, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TAMIL:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = TamilToText(aOrdinal, result);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_CJK_HEAVENLY_STEM:
|
2013-12-02 21:51:26 +04:00
|
|
|
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gCJKHeavenlyStemChars,
|
2002-11-09 21:33:37 +03:00
|
|
|
CJK_HEAVENLY_STEM_CHARS_SIZE);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
|
|
|
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_CJK_EARTHLY_BRANCH:
|
2013-12-02 21:51:26 +04:00
|
|
|
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gCJKEarthlyBranchChars,
|
2002-11-09 21:33:37 +03:00
|
|
|
CJK_EARTHLY_BRANCH_CHARS_SIZE);
|
2000-04-21 12:05:29 +04:00
|
|
|
break;
|
2001-07-04 06:05:59 +04:00
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_HANGUL:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gHangulChars, HANGUL_CHARS_SIZE);
|
2001-07-04 06:05:59 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_HANGUL_CONSONANT:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gHangulConsonantChars,
|
2002-11-09 21:33:37 +03:00
|
|
|
HANGUL_CONSONANT_CHARS_SIZE);
|
2001-07-04 06:05:59 +04:00
|
|
|
break;
|
2002-02-15 12:21:08 +03:00
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gEthiopicHalehameChars,
|
2002-11-09 21:33:37 +03:00
|
|
|
ETHIOPIC_HALEHAME_CHARS_SIZE);
|
2002-02-15 12:21:08 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_NUMERIC:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = EthiopicToText(aOrdinal, result);
|
2002-02-15 12:21:08 +03:00
|
|
|
break;
|
2002-07-13 00:46:19 +04:00
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_AM:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gEthiopicHalehameAmChars,
|
2002-11-09 21:33:37 +03:00
|
|
|
ETHIOPIC_HALEHAME_AM_CHARS_SIZE);
|
2002-07-13 00:46:19 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gEthiopicHalehameTiErChars,
|
2002-11-09 21:33:37 +03:00
|
|
|
ETHIOPIC_HALEHAME_TI_ER_CHARS_SIZE);
|
2002-07-13 00:46:19 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET:
|
2005-04-02 03:07:00 +04:00
|
|
|
success = CharListToText(aOrdinal, result, gEthiopicHalehameTiEtChars,
|
2002-11-09 21:33:37 +03:00
|
|
|
ETHIOPIC_HALEHAME_TI_ET_CHARS_SIZE);
|
2002-07-13 00:46:19 +04:00
|
|
|
break;
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
2013-12-02 21:51:25 +04:00
|
|
|
if (!success) {
|
|
|
|
AppendCounterText(fallback, aOrdinal, result, isRTL);
|
|
|
|
}
|
2005-04-02 03:07:00 +04:00
|
|
|
}
|
|
|
|
|
2013-12-02 21:51:25 +04:00
|
|
|
/* static */ void
|
|
|
|
nsBulletFrame::GetListItemSuffix(int32_t aListStyleType,
|
|
|
|
nsString& aResult,
|
|
|
|
bool& aSuppressPadding)
|
|
|
|
{
|
|
|
|
aResult = '.';
|
|
|
|
aSuppressPadding = false;
|
|
|
|
|
|
|
|
switch (aListStyleType) {
|
|
|
|
case NS_STYLE_LIST_STYLE_NONE: // used by counters code only
|
|
|
|
case NS_STYLE_LIST_STYLE_DISC: // used by counters code only
|
|
|
|
case NS_STYLE_LIST_STYLE_CIRCLE: // used by counters code only
|
|
|
|
case NS_STYLE_LIST_STYLE_SQUARE: // used by counters code only
|
|
|
|
aResult.Truncate();
|
|
|
|
break;
|
|
|
|
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_CJK_DECIMAL:
|
2013-12-02 21:51:25 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC:
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
|
2013-12-02 21:51:25 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_CJK_HEAVENLY_STEM:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_CJK_EARTHLY_BRANCH:
|
|
|
|
aResult = 0x3001;
|
|
|
|
aSuppressPadding = true;
|
|
|
|
break;
|
|
|
|
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
|
2013-12-02 21:51:25 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_HANGUL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_HANGUL_CONSONANT:
|
|
|
|
aResult = ',';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-04-02 03:07:00 +04:00
|
|
|
nsBulletFrame::GetListItemText(const nsStyleList& aListStyle,
|
|
|
|
nsString& result)
|
|
|
|
{
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleVisibility* vis = StyleVisibility();
|
2005-04-02 03:07:00 +04:00
|
|
|
|
|
|
|
NS_ASSERTION(aListStyle.mListStyleType != NS_STYLE_LIST_STYLE_NONE &&
|
|
|
|
aListStyle.mListStyleType != NS_STYLE_LIST_STYLE_DISC &&
|
|
|
|
aListStyle.mListStyleType != NS_STYLE_LIST_STYLE_CIRCLE &&
|
|
|
|
aListStyle.mListStyleType != NS_STYLE_LIST_STYLE_SQUARE,
|
|
|
|
"we should be using specialized code for these types");
|
|
|
|
|
2013-12-02 21:51:25 +04:00
|
|
|
result.Truncate();
|
|
|
|
AppendCounterText(aListStyle.mListStyleType, mOrdinal, result, mTextIsRTL);
|
|
|
|
|
|
|
|
nsAutoString suffix;
|
|
|
|
GetListItemSuffix(aListStyle.mListStyleType, suffix, mSuppressPadding);
|
2008-02-13 11:21:59 +03:00
|
|
|
|
|
|
|
// We're not going to do proper Bidi reordering on the list item marker, but
|
|
|
|
// just display the whole thing as RTL or LTR, so we fake reordering by
|
|
|
|
// appending the suffix to the end of the list item marker if the
|
|
|
|
// directionality of the characters is the same as the style direction or
|
|
|
|
// prepending it to the beginning if they are different.
|
|
|
|
result = (mTextIsRTL == (vis->mDirection == NS_STYLE_DIRECTION_RTL)) ?
|
|
|
|
result + suffix : suffix + result;
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
|
|
|
|
2005-06-21 01:25:41 +04:00
|
|
|
#define MIN_BULLET_SIZE 1
|
1998-12-01 19:13:49 +03:00
|
|
|
|
2001-08-10 00:22:39 +04:00
|
|
|
|
1998-12-01 19:13:49 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsBulletFrame::GetDesiredSize(nsPresContext* aCX,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext *aRenderingContext,
|
2011-11-24 06:48:23 +04:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
float aFontSizeInflation)
|
1998-12-01 19:13:49 +03:00
|
|
|
{
|
2004-04-01 23:48:55 +04:00
|
|
|
// Reset our padding. If we need it, we'll set it below.
|
|
|
|
mPadding.SizeTo(0, 0, 0, 0);
|
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleList* myList = StyleList();
|
1998-12-01 19:13:49 +03:00
|
|
|
nscoord ascent;
|
|
|
|
|
2010-08-31 22:54:44 +04:00
|
|
|
RemoveStateBits(BULLET_FRAME_IMAGE_LOADING);
|
|
|
|
|
2009-12-11 07:02:13 +03:00
|
|
|
if (myList->GetListStyleImage() && mImageRequest) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t status;
|
2002-11-06 04:58:22 +03:00
|
|
|
mImageRequest->GetImageStatus(&status);
|
|
|
|
if (status & imgIRequest::STATUS_SIZE_AVAILABLE &&
|
|
|
|
!(status & imgIRequest::STATUS_ERROR)) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// auto size the image
|
2013-12-27 21:59:52 +04:00
|
|
|
aMetrics.Width() = mIntrinsicSize.width;
|
|
|
|
aMetrics.SetTopAscent(aMetrics.Height() = mIntrinsicSize.height);
|
2002-11-06 04:58:22 +03:00
|
|
|
|
2010-08-31 22:54:44 +04:00
|
|
|
AddStateBits(BULLET_FRAME_IMAGE_LOADING);
|
|
|
|
|
1998-12-01 19:13:49 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-02 18:35:32 +04:00
|
|
|
// If we're getting our desired size and don't have an image, reset
|
|
|
|
// mIntrinsicSize to (0,0). Otherwise, if we used to have an image, it
|
|
|
|
// changed, and the new one is coming in, but we're reflowing before it's
|
|
|
|
// fully there, we'll end up with mIntrinsicSize not matching our size, but
|
|
|
|
// won't trigger a reflow in OnStartContainer (because mIntrinsicSize will
|
|
|
|
// match the image size).
|
|
|
|
mIntrinsicSize.SizeTo(0, 0);
|
|
|
|
|
2011-04-08 05:05:49 +04:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
2011-11-24 06:48:23 +04:00
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
|
|
|
|
aFontSizeInflation);
|
1998-12-01 19:13:49 +03:00
|
|
|
nscoord bulletSize;
|
|
|
|
|
|
|
|
nsAutoString text;
|
|
|
|
switch (myList->mListStyleType) {
|
1999-07-03 02:27:03 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_NONE:
|
2013-12-27 21:59:52 +04:00
|
|
|
aMetrics.Width() = aMetrics.Height() = 0;
|
|
|
|
aMetrics.SetTopAscent(0);
|
1999-07-03 02:27:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_DISC:
|
|
|
|
case NS_STYLE_LIST_STYLE_CIRCLE:
|
|
|
|
case NS_STYLE_LIST_STYLE_SQUARE:
|
2011-04-08 08:18:43 +04:00
|
|
|
ascent = fm->MaxAscent();
|
2013-01-15 16:22:03 +04:00
|
|
|
bulletSize = std::max(nsPresContext::CSSPixelsToAppUnits(MIN_BULLET_SIZE),
|
2007-02-07 10:46:44 +03:00
|
|
|
NSToCoordRound(0.8f * (float(ascent) / 2.0f)));
|
|
|
|
mPadding.bottom = NSToCoordRound(float(ascent) / 8.0f);
|
2013-12-27 21:59:52 +04:00
|
|
|
aMetrics.Width() = aMetrics.Height() = bulletSize;
|
|
|
|
aMetrics.SetTopAscent(bulletSize + mPadding.bottom);
|
1999-07-03 02:27:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case NS_STYLE_LIST_STYLE_DECIMAL_LEADING_ZERO:
|
|
|
|
case NS_STYLE_LIST_STYLE_DECIMAL:
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_CJK_DECIMAL:
|
1999-07-03 02:27:03 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_LOWER_ROMAN:
|
|
|
|
case NS_STYLE_LIST_STYLE_UPPER_ROMAN:
|
|
|
|
case NS_STYLE_LIST_STYLE_LOWER_ALPHA:
|
|
|
|
case NS_STYLE_LIST_STYLE_UPPER_ALPHA:
|
|
|
|
case NS_STYLE_LIST_STYLE_KATAKANA:
|
|
|
|
case NS_STYLE_LIST_STYLE_HIRAGANA:
|
|
|
|
case NS_STYLE_LIST_STYLE_KATAKANA_IROHA:
|
|
|
|
case NS_STYLE_LIST_STYLE_HIRAGANA_IROHA:
|
|
|
|
case NS_STYLE_LIST_STYLE_LOWER_GREEK:
|
|
|
|
case NS_STYLE_LIST_STYLE_HEBREW:
|
|
|
|
case NS_STYLE_LIST_STYLE_ARMENIAN:
|
|
|
|
case NS_STYLE_LIST_STYLE_GEORGIAN:
|
|
|
|
case NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC:
|
2013-12-02 21:51:26 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
|
2001-07-04 06:05:59 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_CJK_HEAVENLY_STEM:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_CJK_EARTHLY_BRANCH:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ARABIC_INDIC:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_PERSIAN:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_URDU:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_DEVANAGARI:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_GURMUKHI:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_GUJARATI:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ORIYA:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_KANNADA:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_MALAYALAM:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_BENGALI:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TAMIL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_TELUGU:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_THAI:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_LAO:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_MYANMAR:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_KHMER:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_HANGUL:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_HANGUL_CONSONANT:
|
2002-02-15 12:21:08 +03:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME:
|
2002-07-13 00:46:19 +04:00
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_NUMERIC:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_AM:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER:
|
|
|
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET:
|
2005-04-02 03:07:00 +04:00
|
|
|
GetListItemText(*myList, text);
|
2013-12-27 21:59:52 +04:00
|
|
|
aMetrics.Height() = fm->MaxHeight();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
aRenderingContext->SetFont(fm);
|
2013-12-27 21:59:52 +04:00
|
|
|
aMetrics.Width() =
|
2011-04-08 08:18:43 +04:00
|
|
|
nsLayoutUtils::GetStringWidth(this, aRenderingContext,
|
|
|
|
text.get(), text.Length());
|
2013-12-27 21:59:52 +04:00
|
|
|
aMetrics.SetTopAscent(fm->MaxAscent());
|
1999-07-03 02:27:03 +04:00
|
|
|
break;
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsBulletFrame::Reflow(nsPresContext* aPresContext,
|
1998-12-01 19:13:49 +03:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsBulletFrame");
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
|
2002-05-10 22:22:41 +04:00
|
|
|
|
2012-05-21 09:18:28 +04:00
|
|
|
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
|
2011-11-24 06:48:23 +04:00
|
|
|
SetFontSizeInflation(inflation);
|
|
|
|
|
1998-12-01 19:13:49 +03:00
|
|
|
// Get the base size
|
2013-12-02 21:51:25 +04:00
|
|
|
// This will also set mSuppressPadding appropriately (via GetListItemText())
|
|
|
|
// for the builtin counter styles with ideographic comma as suffix where the
|
|
|
|
// default padding from ua.css is not desired.
|
2011-11-24 06:48:23 +04:00
|
|
|
GetDesiredSize(aPresContext, aReflowState.rendContext, aMetrics, inflation);
|
1998-12-01 19:13:49 +03:00
|
|
|
|
|
|
|
// Add in the border and padding; split the top/bottom between the
|
|
|
|
// ascent and descent to make things look nice
|
2013-12-27 21:59:21 +04:00
|
|
|
const nsMargin& borderPadding = aReflowState.ComputedPhysicalBorderPadding();
|
2013-12-02 21:51:25 +04:00
|
|
|
if (!mSuppressPadding ||
|
|
|
|
aPresContext->HasAuthorSpecifiedRules(this,
|
|
|
|
NS_AUTHOR_SPECIFIED_PADDING)) {
|
|
|
|
mPadding.top += NSToCoordRound(borderPadding.top * inflation);
|
|
|
|
mPadding.right += NSToCoordRound(borderPadding.right * inflation);
|
|
|
|
mPadding.bottom += NSToCoordRound(borderPadding.bottom * inflation);
|
|
|
|
mPadding.left += NSToCoordRound(borderPadding.left * inflation);
|
|
|
|
}
|
2013-12-27 21:59:52 +04:00
|
|
|
aMetrics.Width() += mPadding.left + mPadding.right;
|
|
|
|
aMetrics.Height() += mPadding.top + mPadding.bottom;
|
|
|
|
aMetrics.SetTopAscent(aMetrics.TopAscent() + mPadding.top);
|
1998-12-01 19:13:49 +03:00
|
|
|
|
2007-09-24 06:19:14 +04:00
|
|
|
// XXX this is a bit of a hack, we're assuming that no glyphs used for bullets
|
|
|
|
// overflow their font-boxes. It'll do for now; to fix it for real, we really
|
|
|
|
// should rewrite all the text-handling code here to use gfxTextRun (bug
|
|
|
|
// 397294).
|
2010-10-07 08:25:46 +04:00
|
|
|
aMetrics.SetOverflowAreasToDesiredBounds();
|
|
|
|
|
1998-12-01 19:13:49 +03:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
|
1998-12-01 19:13:49 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-08-10 00:22:39 +04:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
/* virtual */ nscoord
|
2011-04-08 05:04:40 +04:00
|
|
|
nsBulletFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
{
|
2013-12-27 21:59:52 +04:00
|
|
|
nsHTMLReflowMetrics metrics(GetWritingMode());
|
|
|
|
DISPLAY_MIN_WIDTH(this, metrics.Width());
|
2011-11-24 06:48:23 +04:00
|
|
|
GetDesiredSize(PresContext(), aRenderingContext, metrics, 1.0f);
|
2013-12-27 21:59:52 +04:00
|
|
|
return metrics.Width();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2011-04-08 05:04:40 +04:00
|
|
|
nsBulletFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
{
|
2013-12-27 21:59:52 +04:00
|
|
|
nsHTMLReflowMetrics metrics(GetWritingMode());
|
|
|
|
DISPLAY_PREF_WIDTH(this, metrics.Width());
|
2011-11-24 06:48:23 +04:00
|
|
|
GetDesiredSize(PresContext(), aRenderingContext, metrics, 1.0f);
|
2013-12-27 21:59:52 +04:00
|
|
|
return metrics.Width();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
2012-10-12 20:11:22 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBulletFrame::Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect* aData)
|
|
|
|
{
|
2012-10-12 20:11:23 +04:00
|
|
|
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
|
2012-10-12 20:11:22 +04:00
|
|
|
nsCOMPtr<imgIContainer> image;
|
|
|
|
aRequest->GetImage(getter_AddRefs(image));
|
|
|
|
return OnStartContainer(aRequest, image);
|
|
|
|
}
|
|
|
|
|
2012-10-12 20:11:23 +04:00
|
|
|
if (aType == imgINotificationObserver::FRAME_UPDATE) {
|
2012-10-12 20:11:22 +04:00
|
|
|
// The image has changed.
|
|
|
|
// Invalidate the entire content area. Maybe it's not optimal but it's simple and
|
|
|
|
// always correct, and I'll be a stunned mullet if it ever matters for performance
|
|
|
|
InvalidateFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aType == imgINotificationObserver::IS_ANIMATED) {
|
|
|
|
// Register the image request with the refresh driver now that we know it's
|
|
|
|
// animated.
|
|
|
|
if (aRequest == mImageRequest) {
|
|
|
|
nsLayoutUtils::RegisterImageRequest(PresContext(), mImageRequest,
|
|
|
|
&mRequestRegistered);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-08-10 00:22:39 +04:00
|
|
|
|
2012-10-12 20:11:22 +04:00
|
|
|
nsresult nsBulletFrame::OnStartContainer(imgIRequest *aRequest,
|
|
|
|
imgIContainer *aImage)
|
2001-08-10 00:22:39 +04:00
|
|
|
{
|
|
|
|
if (!aImage) return NS_ERROR_INVALID_ARG;
|
2002-11-06 04:58:22 +03:00
|
|
|
if (!aRequest) return NS_ERROR_INVALID_ARG;
|
2001-08-10 00:22:39 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t status;
|
2002-11-06 04:58:22 +03:00
|
|
|
aRequest->GetImageStatus(&status);
|
|
|
|
if (status & imgIRequest::STATUS_ERROR) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-08-10 00:22:39 +04:00
|
|
|
nscoord w, h;
|
|
|
|
aImage->GetWidth(&w);
|
|
|
|
aImage->GetHeight(&h);
|
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext* presContext = PresContext();
|
2001-08-10 00:22:39 +04:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
nsSize newsize(nsPresContext::CSSPixelsToAppUnits(w),
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(h));
|
2001-08-10 00:22:39 +04:00
|
|
|
|
|
|
|
if (mIntrinsicSize != newsize) {
|
|
|
|
mIntrinsicSize = newsize;
|
|
|
|
|
|
|
|
// Now that the size is available (or an error occurred), trigger
|
|
|
|
// a reflow of the bullet frame.
|
2004-08-05 01:18:20 +04:00
|
|
|
nsIPresShell *shell = presContext->GetPresShell();
|
2003-12-21 08:36:36 +03:00
|
|
|
if (shell) {
|
2007-05-06 23:16:51 +04:00
|
|
|
shell->FrameNeedsReflow(this, nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
2001-08-10 00:22:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-08 21:29:28 +03:00
|
|
|
// Handle animations
|
2004-08-05 01:18:20 +04:00
|
|
|
aImage->SetAnimationMode(presContext->ImageAnimationMode());
|
2010-09-08 04:33:02 +04:00
|
|
|
// Ensure the animation (if any) is started. Note: There is no
|
|
|
|
// corresponding call to Decrement for this. This Increment will be
|
|
|
|
// 'cleaned up' by the Request when it is destroyed, but only then.
|
|
|
|
aRequest->IncrementAnimationConsumers();
|
2004-01-08 21:29:28 +03:00
|
|
|
|
2001-08-10 00:22:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsBulletFrame::GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGroup)
|
2001-08-10 00:22:39 +04:00
|
|
|
{
|
|
|
|
if (!aPresContext)
|
|
|
|
return;
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_PRECONDITION(nullptr != aLoadGroup, "null OUT parameter pointer");
|
2001-08-10 00:22:39 +04:00
|
|
|
|
2003-12-21 08:36:36 +03:00
|
|
|
nsIPresShell *shell = aPresContext->GetPresShell();
|
2001-08-10 00:22:39 +04:00
|
|
|
|
|
|
|
if (!shell)
|
|
|
|
return;
|
|
|
|
|
2004-08-02 08:52:55 +04:00
|
|
|
nsIDocument *doc = shell->GetDocument();
|
2001-08-10 00:22:39 +04:00
|
|
|
if (!doc)
|
|
|
|
return;
|
|
|
|
|
2003-10-22 10:09:48 +04:00
|
|
|
*aLoadGroup = doc->GetDocumentLoadGroup().get(); // already_AddRefed
|
2001-08-10 00:22:39 +04:00
|
|
|
}
|
|
|
|
|
2011-11-24 06:48:23 +04:00
|
|
|
union VoidPtrOrFloat {
|
2012-07-30 18:20:58 +04:00
|
|
|
VoidPtrOrFloat() : p(nullptr) {}
|
2011-11-24 06:48:23 +04:00
|
|
|
|
|
|
|
void *p;
|
|
|
|
float f;
|
|
|
|
};
|
|
|
|
|
|
|
|
float
|
|
|
|
nsBulletFrame::GetFontSizeInflation() const
|
|
|
|
{
|
|
|
|
if (!HasFontSizeInflation()) {
|
|
|
|
return 1.0f;
|
|
|
|
}
|
|
|
|
VoidPtrOrFloat u;
|
|
|
|
u.p = Properties().Get(FontSizeInflationProperty());
|
|
|
|
return u.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBulletFrame::SetFontSizeInflation(float aInflation)
|
|
|
|
{
|
|
|
|
if (aInflation == 1.0f) {
|
|
|
|
if (HasFontSizeInflation()) {
|
|
|
|
RemoveStateBits(BULLET_FRAME_HAS_FONT_INFLATION);
|
|
|
|
Properties().Delete(FontSizeInflationProperty());
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
AddStateBits(BULLET_FRAME_HAS_FONT_INFLATION);
|
|
|
|
VoidPtrOrFloat u;
|
|
|
|
u.f = aInflation;
|
|
|
|
Properties().Set(FontSizeInflationProperty(), u.p);
|
|
|
|
}
|
|
|
|
|
2013-06-22 20:30:57 +04:00
|
|
|
already_AddRefed<imgIContainer>
|
|
|
|
nsBulletFrame::GetImage() const
|
|
|
|
{
|
|
|
|
if (mImageRequest && StyleList()->GetListStyleImage()) {
|
|
|
|
nsCOMPtr<imgIContainer> imageCon;
|
|
|
|
mImageRequest->GetImage(getter_AddRefs(imageCon));
|
|
|
|
return imageCon.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2010-08-31 22:54:44 +04:00
|
|
|
nscoord
|
|
|
|
nsBulletFrame::GetBaseline() const
|
|
|
|
{
|
|
|
|
nscoord ascent = 0, bottomPadding;
|
|
|
|
if (GetStateBits() & BULLET_FRAME_IMAGE_LOADING) {
|
|
|
|
ascent = GetRect().height;
|
|
|
|
} else {
|
2011-04-08 05:05:49 +04:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
2011-11-24 06:48:23 +04:00
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
|
|
|
|
GetFontSizeInflation());
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleList* myList = StyleList();
|
2010-08-31 22:54:44 +04:00
|
|
|
switch (myList->mListStyleType) {
|
|
|
|
case NS_STYLE_LIST_STYLE_NONE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_LIST_STYLE_DISC:
|
|
|
|
case NS_STYLE_LIST_STYLE_CIRCLE:
|
|
|
|
case NS_STYLE_LIST_STYLE_SQUARE:
|
2011-04-08 08:18:43 +04:00
|
|
|
ascent = fm->MaxAscent();
|
2010-08-31 22:54:44 +04:00
|
|
|
bottomPadding = NSToCoordRound(float(ascent) / 8.0f);
|
2013-01-15 16:22:03 +04:00
|
|
|
ascent = std::max(nsPresContext::CSSPixelsToAppUnits(MIN_BULLET_SIZE),
|
2010-08-31 22:54:44 +04:00
|
|
|
NSToCoordRound(0.8f * (float(ascent) / 2.0f)));
|
|
|
|
ascent += bottomPadding;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-04-08 08:18:43 +04:00
|
|
|
ascent = fm->MaxAscent();
|
2010-08-31 22:54:44 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ascent + GetUsedBorderAndPadding().top;
|
|
|
|
}
|
|
|
|
|
2001-08-10 00:22:39 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-12 20:11:22 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsBulletListener, imgINotificationObserver)
|
2001-08-10 00:22:39 +04:00
|
|
|
|
|
|
|
nsBulletListener::nsBulletListener() :
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrame(nullptr)
|
2001-08-10 00:22:39 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBulletListener::~nsBulletListener()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-10-12 20:11:22 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBulletListener::Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect* aData)
|
2001-08-10 00:22:39 +04:00
|
|
|
{
|
|
|
|
if (!mFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
2012-10-12 20:11:22 +04:00
|
|
|
return mFrame->Notify(aRequest, aType, aData);
|
2001-08-10 00:22:39 +04:00
|
|
|
}
|