зеркало из https://github.com/mozilla/pjs.git
Initial checkin of SVG prototype code for Dean Jackson (not in build)
This commit is contained in:
Родитель
5fdb266f31
Коммит
516366fdbd
|
@ -259,6 +259,10 @@ CFLAGS = $(CFLAGS) -DUSE_STRING2
|
|||
CFLAGS=$(CFLAGS) -DMOZ_MATHML
|
||||
!endif
|
||||
|
||||
!ifdef MOZ_SVG
|
||||
CFLAGS=$(CFLAGS) -DMOZ_SVG
|
||||
!endif
|
||||
|
||||
|
||||
#//-----------------------------------------------------------------------
|
||||
#//
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = content base
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
DIRS=public src
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
|
@ -0,0 +1,30 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
EXPORTS = \
|
||||
nsISVGFrame.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
|
@ -0,0 +1,43 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsISVGFrame_h__
|
||||
#define nsISVGFrame_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsCoord.h"
|
||||
|
||||
|
||||
#define NS_ISVGFRAME_IID \
|
||||
{0x84957983, 0x712, 0x11d4, \
|
||||
{ 0x97, 0x7, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 }}
|
||||
|
||||
class nsISVGFrame : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISVGFRAME_IID)
|
||||
|
||||
NS_IMETHOD GetXY(nscoord* aX, nscoord* aY) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,58 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = layout
|
||||
LIBRARY_NAME = raptorsvgbase_s
|
||||
|
||||
CPPSRCS = \
|
||||
nsSVGContainerFrame.cpp \
|
||||
nsPolygonFrame.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_HTML
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/../../../base/src \
|
||||
-I$(srcdir)/../../../html/table/src \
|
||||
-I$(srcdir)/../../../html/style/src \
|
||||
-I$(srcdir)/../../../html/base/src \
|
||||
-I$(srcdir)/../../../html/forms/src \
|
||||
-I$(srcdir)/../../content/src \
|
||||
-I$(srcdir)/../../../html/content/src \
|
||||
-I$(srcdir)/../../../xml/content/src \
|
||||
-I$(srcdir)/../../../base/public \
|
||||
$(NULL)
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
LIBRARY_NAME=raptorsvgbase_s
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor pref
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPPSRCS= \
|
||||
nsSVGContainerFrame.cpp \
|
||||
nsPolygonFrame.cpp \
|
||||
nsPolylineFrame.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsSVGContainerFrame.obj \
|
||||
.\$(OBJDIR)\nsPolygonFrame.obj \
|
||||
.\$(OBJDIR)\nsPolylineFrame.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
||||
-I..\..\..\html\style\src -I..\..\..\html\base\src -I$(PUBLIC)\dom \
|
||||
-I..\..\..\html\document\src \
|
||||
-I..\..\..\html\content\src \
|
||||
-I..\..\..\html\table\src \
|
||||
-I..\..\content\src \
|
||||
-I..\..\..\html\forms\src \
|
||||
-I$(PUBLIC)\netlib -I..\..\..\base\src -I$(PUBLIC)\pref \
|
||||
-I..\..\..\xml\content\src \
|
||||
-I..\..\..\base\public
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
|
@ -0,0 +1,361 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
|
||||
#include "nsPolygonFrame.h"
|
||||
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsPoint.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
//#include "nsPolygonCID.h"
|
||||
//
|
||||
// NS_NewPolygonFrame
|
||||
//
|
||||
// Wrapper for creating a new color picker
|
||||
//
|
||||
nsresult
|
||||
NS_NewPolygonFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsPolygonFrame* it = new (aPresShell) nsPolygonFrame;
|
||||
if ( !it )
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static NS_DEFINE_IID(kDefPolygonCID, NS_DEFCOLORPICKER_CID);
|
||||
|
||||
//
|
||||
// nsPolygonFrame cntr
|
||||
//
|
||||
nsPolygonFrame::nsPolygonFrame() :
|
||||
mPnts(nsnull),
|
||||
mNumPnts(0),
|
||||
mX(0),
|
||||
mY(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsPolygonFrame::~nsPolygonFrame()
|
||||
{
|
||||
if (mPnts) {
|
||||
delete [] mPnts;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPolygonFrame::Init(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIStyleContext* aContext,
|
||||
nsIFrame* aPrevInFlow)
|
||||
{
|
||||
|
||||
nsresult rv = nsLeafFrame::Init(aPresContext, aContent, aParent, aContext,
|
||||
aPrevInFlow);
|
||||
|
||||
|
||||
nsAutoString type;
|
||||
mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, type);
|
||||
|
||||
if (type.EqualsIgnoreCase("swatch") || type.Equals(""))
|
||||
{
|
||||
//mPolygon = new nsStdPolygon();
|
||||
//mPolygon->Init(mContent);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Frames are not refcounted, no need to AddRef
|
||||
NS_IMETHODIMP
|
||||
nsPolygonFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsISVGFrame))) {
|
||||
*aInstancePtr = (void*) ((nsISVGFrame*) this);
|
||||
return NS_OK;
|
||||
}
|
||||
return nsLeafFrame::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//-- Main Reflow for the Polygon
|
||||
//-------------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsPolygonFrame::Reflow(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
|
||||
nsCOMPtr<nsIDeviceContext> dx;
|
||||
aPresContext->GetDeviceContext(getter_AddRefs(dx));
|
||||
float p2t = 1.0;
|
||||
float scale = 1.0;
|
||||
if (dx) {
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
dx->GetCanonicalPixelScale(scale);
|
||||
}
|
||||
|
||||
nsAutoString coordStr;
|
||||
nsresult res = mContent->GetAttribute(kNameSpaceID_None, nsSVGAtoms::x, coordStr);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
char * s = coordStr.ToNewCString();
|
||||
mX = NSIntPixelsToTwips(atoi(s), p2t*scale);
|
||||
delete [] s;
|
||||
}
|
||||
|
||||
res = mContent->GetAttribute(kNameSpaceID_None, nsSVGAtoms::y, coordStr);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
char * s = coordStr.ToNewCString();
|
||||
mY = NSIntPixelsToTwips(atoi(s), p2t*scale);
|
||||
delete [] s;
|
||||
}
|
||||
|
||||
if (mPoints.Count() == 0) {
|
||||
GetPoints();
|
||||
}
|
||||
nscoord maxWidth = 0;
|
||||
nscoord maxHeight = 0;
|
||||
for (PRInt32 i=0;i<mNumPnts;i++) {
|
||||
maxWidth = PR_MAX(maxWidth, NSIntPixelsToTwips(mPnts[i].x, p2t*scale));
|
||||
maxHeight = PR_MAX(maxHeight, NSIntPixelsToTwips(mPnts[i].y, p2t*scale));
|
||||
}
|
||||
|
||||
aDesiredSize.width = maxWidth + nscoord(p2t*scale);
|
||||
aDesiredSize.height = maxHeight + nscoord(p2t*scale);
|
||||
aDesiredSize.ascent = aDesiredSize.height;
|
||||
aDesiredSize.descent = 0;
|
||||
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
||||
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPolygonFrame::HandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEventStatus);
|
||||
*aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN)
|
||||
HandleMouseDownEvent(aPresContext, aEvent, aEventStatus);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPolygonFrame::HandleMouseDownEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX - Quick and Dirty impl to get somethinf working
|
||||
// this should be rewritten
|
||||
NS_METHOD
|
||||
nsPolygonFrame::GetPoints()
|
||||
{
|
||||
nsAutoString pointsStr;
|
||||
nsresult res = mContent->GetAttribute(kNameSpaceID_None, nsSVGAtoms::points, pointsStr);
|
||||
|
||||
char * ps = pointsStr.ToNewCString();
|
||||
char seps[] = " ";
|
||||
char *token = strtok(ps, seps);
|
||||
PRInt32 cnt = 0;
|
||||
nsPoint * pnt = nsnull;
|
||||
while (token != NULL) {
|
||||
if (cnt % 2 == 0) {
|
||||
pnt = new nsPoint;
|
||||
mPoints.AppendElement((void*)pnt);
|
||||
pnt->x = atoi(token);
|
||||
} else {
|
||||
pnt->y = atoi(token);
|
||||
}
|
||||
token = strtok( NULL, seps );
|
||||
cnt++;
|
||||
}
|
||||
|
||||
delete [] ps;
|
||||
|
||||
mNumPnts = mPoints.Count()+1;
|
||||
mPnts = new nsPoint[mNumPnts];
|
||||
for (cnt=0;cnt<mNumPnts-1;cnt++) {
|
||||
nsPoint * pnt = (nsPoint*)mPoints.ElementAt(cnt);
|
||||
mPnts[cnt] = *pnt;
|
||||
delete pnt;
|
||||
}
|
||||
mPnts[mNumPnts-1] = mPnts[0];
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPolygonFrame::SetProperty(nsIPresContext* aPresContext,
|
||||
nsIAtom* aName,
|
||||
const nsString& aValue)
|
||||
{
|
||||
if (aName == nsSVGAtoms::points) {
|
||||
} else if (aName == nsSVGAtoms::x) {
|
||||
} else if (aName == nsSVGAtoms::y) {
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPolygonFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint)
|
||||
{
|
||||
return nsLeafFrame::AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aHint);
|
||||
}
|
||||
|
||||
NS_METHOD nsPolygonFrame::RenderPoints(nsIRenderingContext& aRenderingContext,
|
||||
const nsPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
//nsAutoString fillStr;
|
||||
//nsresult res = mContent->GetAttribute(kNameSpaceID_None, nsSVGAtoms::fill, fillStr);
|
||||
//if (NS_SUCCEEDED(res)) {
|
||||
aRenderingContext.FillPolygon(aPoints, aNumPoints);
|
||||
//} else {
|
||||
// aRenderingContext.DrawPolygon(aPoints, aNumPoints);
|
||||
//}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// Paint
|
||||
//
|
||||
//
|
||||
NS_METHOD
|
||||
nsPolygonFrame::Paint(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// if we aren't visible then we are done.
|
||||
if (!disp->IsVisibleOrCollapsed())
|
||||
return NS_OK;
|
||||
|
||||
// if we are visible then tell our superclass to paint
|
||||
nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
|
||||
aWhichLayer);
|
||||
|
||||
// get our border
|
||||
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
||||
nsMargin border(0,0,0,0);
|
||||
spacing->CalcBorderFor(this, border);
|
||||
|
||||
|
||||
// XXX - Color needs to comes from new style property fill
|
||||
// and not mColor
|
||||
const nsStyleColor* colorStyle = (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
nscolor color = colorStyle->mColor;
|
||||
|
||||
|
||||
aRenderingContext.PushState();
|
||||
|
||||
// set the clip region
|
||||
nsRect rect;
|
||||
|
||||
PRBool clipState;
|
||||
GetRect(rect);
|
||||
|
||||
// Clip so we don't render outside the inner rect
|
||||
aRenderingContext.SetClipRect(rect, nsClipCombine_kReplace, clipState);
|
||||
aRenderingContext.SetColor(color);
|
||||
|
||||
///////////////////////////////////////////
|
||||
// XXX - This is all just a quick hack
|
||||
// needs to be rewritten
|
||||
nsCOMPtr<nsIDeviceContext> dx;
|
||||
aPresContext->GetDeviceContext(getter_AddRefs(dx));
|
||||
float p2t = 1.0;
|
||||
float scale = 1.0;
|
||||
if (dx) {
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
dx->GetCanonicalPixelScale(scale);
|
||||
}
|
||||
|
||||
nsPoint points[256];
|
||||
for (PRInt32 i=0;i<mNumPnts;i++) {
|
||||
points[i] = mPnts[i];
|
||||
points[i].x = NSIntPixelsToTwips(points[i].x, p2t*scale)+mX;
|
||||
points[i].y = NSIntPixelsToTwips(points[i].y, p2t*scale)+mY;
|
||||
//printf("%p Draw Poly: %d,%d\n", this, points[i].x, points[i].y);
|
||||
}
|
||||
// XXX - down to here
|
||||
|
||||
RenderPoints(aRenderingContext, points, mNumPnts);
|
||||
|
||||
aRenderingContext.PopState(clipState);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetDesiredSize
|
||||
//
|
||||
// For now, be as big as CSS wants us to be, or some small default size.
|
||||
//
|
||||
void
|
||||
nsPolygonFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredSize)
|
||||
{
|
||||
NS_ASSERTION(0, "Who called this? and Why?");
|
||||
} // GetDesiredSize
|
|
@ -0,0 +1,120 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
//
|
||||
// nsPolygonFrame
|
||||
//
|
||||
|
||||
#ifndef nsPolygonFrame_h__
|
||||
#define nsPolygonFrame_h__
|
||||
|
||||
|
||||
#include "nsLeafFrame.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsISVGFrame.h"
|
||||
|
||||
class nsString;
|
||||
|
||||
|
||||
nsresult NS_NewPolygonFrame(nsIPresShell* aPresShell, nsIFrame** aResult) ;
|
||||
|
||||
|
||||
// XXX - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
// This should NOT be derived from nsLeafFrame
|
||||
// we really want to create our own container class from the nsIFrame
|
||||
// interface and not derive from any HTML Frames
|
||||
// XXX - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
class nsPolygonFrame : public nsLeafFrame, public nsISVGFrame
|
||||
{
|
||||
public:
|
||||
nsPolygonFrame();
|
||||
virtual ~nsPolygonFrame();
|
||||
|
||||
NS_IMETHOD Init(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIStyleContext* aContext,
|
||||
nsIFrame* aPrevInFlow);
|
||||
|
||||
NS_IMETHOD Reflow(nsIPresContext* aCX,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus);
|
||||
// nsISVGFrame
|
||||
NS_IMETHOD GetXY(nscoord* aX, nscoord* aY) { *aX = mX; *aY = mY; return NS_OK; }
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD GetFrameName(nsString& aResult) const {
|
||||
return MakeFrameName("PolygonFrame", aResult);
|
||||
}
|
||||
#endif
|
||||
|
||||
// nsIFrame overrides
|
||||
NS_IMETHOD HandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus* aEventStatus);
|
||||
nsresult HandleMouseDownEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus* aEventStatus);
|
||||
|
||||
NS_IMETHOD Paint(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
|
||||
NS_IMETHOD RenderPoints(nsIRenderingContext& aRenderingContext,
|
||||
const nsPoint aPoints[], PRInt32 aNumPoints);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint);
|
||||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsString& aValue);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD GetPoints();
|
||||
|
||||
virtual void GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredSize) ;
|
||||
|
||||
|
||||
nsVoidArray mPoints;
|
||||
|
||||
nsPoint * mPnts;
|
||||
PRInt32 mNumPnts;
|
||||
nscoord mX;
|
||||
nscoord mY;
|
||||
|
||||
private:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
|
||||
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
|
||||
}; // class nsPolygonFrame
|
||||
|
||||
#endif
|
|
@ -0,0 +1,65 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
|
||||
#include "nsPolylineFrame.h"
|
||||
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsPoint.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
//#include "nsPolylineCID.h"
|
||||
//
|
||||
// NS_NewPolylineFrame
|
||||
//
|
||||
// Wrapper for creating a new color picker
|
||||
//
|
||||
nsresult
|
||||
NS_NewPolylineFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsPolylineFrame* it = new (aPresShell) nsPolylineFrame;
|
||||
if ( !it )
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsPolylineFrame::RenderPoints(nsIRenderingContext& aRenderingContext,
|
||||
const nsPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
aRenderingContext.DrawPolyline(aPoints, aNumPoints-1);
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
//
|
||||
// nsPolylineFrame
|
||||
//
|
||||
|
||||
#ifndef nsPolylineFrame_h__
|
||||
#define nsPolylineFrame_h__
|
||||
|
||||
|
||||
#include "nsPolygonFrame.h"
|
||||
|
||||
class nsString;
|
||||
|
||||
|
||||
nsresult NS_NewPolylineFrame(nsIPresShell* aPresShell, nsIFrame** aResult) ;
|
||||
|
||||
|
||||
// XXX - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
// This should NOT be derived from nsLeafFrame
|
||||
// we really want to create our own container class from the nsIFrame
|
||||
// interface and not derive from any HTML Frames
|
||||
// XXX - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
class nsPolylineFrame : public nsPolygonFrame
|
||||
{
|
||||
NS_IMETHOD RenderPoints(nsIRenderingContext& aRenderingContext,
|
||||
const nsPoint aPoints[], PRInt32 aNumPoints);
|
||||
|
||||
}; // class nsPolylineFrame
|
||||
|
||||
#endif
|
|
@ -0,0 +1,483 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsSVGContainerFrame.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsUnitConversion.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsIReflowCommand.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsSpaceManager.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "nsISelfScrollingFrame.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISVGFrame.h"
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewSVGContainerFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRBool aIsRoot)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsSVGContainerFrame* it = new (aPresShell) nsSVGContainerFrame(aPresShell, aIsRoot);
|
||||
if (nsnull == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
|
||||
} // NS_NewSVGContainerFrame
|
||||
|
||||
nsSVGContainerFrame::nsSVGContainerFrame(nsIPresShell* aPresShell, PRBool aIsRoot)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsSVGContainerFrame::~nsSVGContainerFrame()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
||||
nsIAtom* aListName,
|
||||
nsIFrame* aChildList)
|
||||
{
|
||||
|
||||
nsresult r = nsHTMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize us.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame::Init(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIStyleContext* aContext,
|
||||
nsIFrame* aPrevInFlow)
|
||||
{
|
||||
nsresult rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
||||
|
||||
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
|
||||
{
|
||||
// if we are not dirty mark ourselves dirty and tell our parent we are dirty too.
|
||||
if (!(mState & NS_FRAME_IS_DIRTY)) {
|
||||
// Mark yourself as dirty
|
||||
mState |= NS_FRAME_IS_DIRTY;
|
||||
return mParent->ReflowDirtyChild(aPresShell, this);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Ok what we want to do here is get all the children, figure out
|
||||
* their flexibility, preferred, min, max sizes and then stretch or
|
||||
* shrink them to fit in the given space.
|
||||
*
|
||||
* So we will have 3 passes.
|
||||
* 1) get our min,max,preferred size.
|
||||
* 2) flow all our children to fit into the size we are given layout in
|
||||
* 3) move all the children to the right locations.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame::Reflow(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
|
||||
nscoord maxWidth = 0;
|
||||
nscoord maxHeight = 0;
|
||||
|
||||
nsIFrame * child = mFrames.FirstChild();
|
||||
|
||||
while (child != nsnull) {
|
||||
|
||||
nsSize availSize(aReflowState.availableWidth, aReflowState.availableHeight);
|
||||
nsHTMLReflowMetrics kidSize(&availSize);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, child, availSize);
|
||||
|
||||
child->WillReflow(aPresContext);
|
||||
child->MoveTo(aPresContext, aReflowState.mComputedBorderPadding.left, aReflowState.mComputedBorderPadding.top);
|
||||
nsIView* view;
|
||||
child->GetView(aPresContext, &view);
|
||||
if (view) {
|
||||
//nsHTMLContainerFrame::PositionFrameView(aPresContext, child, view);
|
||||
}
|
||||
nsReflowStatus status;
|
||||
nsresult rv = child->Reflow(aPresContext, kidSize, kidReflowState, status);
|
||||
|
||||
nsRect rect;
|
||||
child->GetRect(rect);
|
||||
nsCOMPtr<nsISVGFrame> svgFrame = do_QueryInterface(child);
|
||||
if (svgFrame) {
|
||||
svgFrame->GetXY(&rect.x, &rect.y);
|
||||
}
|
||||
rect.width = kidSize.width;
|
||||
rect.height = kidSize.height;
|
||||
maxWidth = PR_MAX(maxWidth, rect.x+rect.width);
|
||||
maxHeight = PR_MAX(maxHeight, rect.y+rect.height);
|
||||
|
||||
child->SetRect(aPresContext, rect);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = child->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
child->GetNextSibling(&child);
|
||||
}
|
||||
|
||||
|
||||
aDesiredSize.width = maxWidth;
|
||||
aDesiredSize.height = maxHeight;
|
||||
aDesiredSize.ascent = aDesiredSize.height;
|
||||
aDesiredSize.descent = 0;
|
||||
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
||||
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame::DidReflow(nsIPresContext* aPresContext,
|
||||
nsDidReflowStatus aStatus)
|
||||
{
|
||||
nsresult rv = nsHTMLContainerFrame::DidReflow(aPresContext, aStatus);
|
||||
NS_ASSERTION(rv == NS_OK,"DidReflow failed");
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// Marks the frame as dirty and generates an incremental reflow
|
||||
// command targeted at this frame
|
||||
nsresult
|
||||
nsSVGContainerFrame::GenerateDirtyReflowCommand(nsIPresContext* aPresContext,
|
||||
nsIPresShell& aPresShell)
|
||||
{
|
||||
if (mState & NS_FRAME_IS_DIRTY)
|
||||
return NS_OK;
|
||||
|
||||
// ask out parent to dirty things.
|
||||
mState |= NS_FRAME_IS_DIRTY;
|
||||
return mParent->ReflowDirtyChild(&aPresShell, this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame::RemoveFrame(nsIPresContext* aPresContext,
|
||||
nsIPresShell& aPresShell,
|
||||
nsIAtom* aListName,
|
||||
nsIFrame* aOldFrame)
|
||||
{
|
||||
|
||||
// remove the child frame
|
||||
mFrames.DestroyFrame(aPresContext, aOldFrame);
|
||||
|
||||
// mark us dirty and generate a reflow command
|
||||
return GenerateDirtyReflowCommand(aPresContext, aPresShell);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame::Destroy(nsIPresContext* aPresContext)
|
||||
{
|
||||
|
||||
return nsHTMLContainerFrame::Destroy(aPresContext);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame::InsertFrames(nsIPresContext* aPresContext,
|
||||
nsIPresShell& aPresShell,
|
||||
nsIAtom* aListName,
|
||||
nsIFrame* aPrevFrame,
|
||||
nsIFrame* aFrameList)
|
||||
{
|
||||
// insert the frames in out regular frame list
|
||||
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
|
||||
|
||||
// mark us dirty and generate a reflow command
|
||||
return GenerateDirtyReflowCommand(aPresContext, aPresShell);
|
||||
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame::AppendFrames(nsIPresContext* aPresContext,
|
||||
nsIPresShell& aPresShell,
|
||||
nsIAtom* aListName,
|
||||
nsIFrame* aFrameList)
|
||||
{
|
||||
// append in regular frames
|
||||
mFrames.AppendFrames(this, aFrameList);
|
||||
|
||||
// mark us dirty and generate a reflow command
|
||||
return GenerateDirtyReflowCommand(aPresContext, aPresShell);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint)
|
||||
{
|
||||
nsresult rv = nsHTMLContainerFrame::AttributeChanged(aPresContext, aChild,
|
||||
aNameSpaceID, aAttribute, aHint);
|
||||
#if 0
|
||||
if (aAttribute == nsHTMLAtoms::width ||
|
||||
aAttribute == nsHTMLAtoms::height ||
|
||||
aAttribute == nsHTMLAtoms::align ||
|
||||
aAttribute == nsHTMLAtoms::valign ||
|
||||
aAttribute == nsXULAtoms::flex ||
|
||||
aAttribute == nsXULAtoms::orient ||
|
||||
aAttribute == nsXULAtoms::autostretch) {
|
||||
|
||||
if (aAttribute == nsXULAtoms::orient || aAttribute == nsXULAtoms::debug || aAttribute == nsHTMLAtoms::align || aAttribute == nsHTMLAtoms::valign) {
|
||||
mInner->mValign = nsSVGContainerFrame::vAlign_Top;
|
||||
mInner->mHalign = nsSVGContainerFrame::hAlign_Left;
|
||||
|
||||
GetInitialVAlignment(mInner->mValign);
|
||||
GetInitialHAlignment(mInner->mHalign);
|
||||
|
||||
PRBool orient = mState & NS_STATE_IS_HORIZONTAL;
|
||||
GetInitialOrientation(orient);
|
||||
if (orient)
|
||||
mState |= NS_STATE_IS_HORIZONTAL;
|
||||
else
|
||||
mState &= ~NS_STATE_IS_HORIZONTAL;
|
||||
|
||||
PRBool debug = mState & NS_STATE_SET_TO_DEBUG;
|
||||
PRBool debugSet = mInner->GetInitialDebug(debug);
|
||||
if (debugSet) {
|
||||
mState |= NS_STATE_DEBUG_WAS_SET;
|
||||
if (debug)
|
||||
mState |= NS_STATE_SET_TO_DEBUG;
|
||||
else
|
||||
mState &= ~NS_STATE_SET_TO_DEBUG;
|
||||
} else {
|
||||
mState &= ~NS_STATE_DEBUG_WAS_SET;
|
||||
}
|
||||
|
||||
|
||||
PRBool autostretch = mState & NS_STATE_AUTO_STRETCH;
|
||||
GetInitialAutoStretch(autostretch);
|
||||
if (autostretch)
|
||||
mState |= NS_STATE_AUTO_STRETCH;
|
||||
else
|
||||
mState &= ~NS_STATE_AUTO_STRETCH;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
aPresContext->GetShell(getter_AddRefs(shell));
|
||||
GenerateDirtyReflowCommand(aPresContext, *shell);
|
||||
}
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame :: Paint ( nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// if we aren't visible then we are done.
|
||||
if (!disp->IsVisibleOrCollapsed())
|
||||
return NS_OK;
|
||||
|
||||
// if we are visible then tell our superclass to paint
|
||||
nsresult r = nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
|
||||
aWhichLayer);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// Paint one child frame
|
||||
void
|
||||
nsSVGContainerFrame::PaintChild(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsIFrame* aFrame,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
const nsStyleDisplay* disp;
|
||||
aFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)disp));
|
||||
|
||||
// if collapsed don't paint the child.
|
||||
if (disp->mVisible == NS_STYLE_VISIBILITY_COLLAPSE)
|
||||
return;
|
||||
|
||||
nsHTMLContainerFrame::PaintChild(aPresContext, aRenderingContext, aDirtyRect, aFrame, aWhichLayer);
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGContainerFrame::PaintChildren(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// Child elements have the opportunity to override the visibility property
|
||||
// of their parent and display even if the parent is hidden
|
||||
PRBool clipState;
|
||||
|
||||
nsRect r(0,0,mRect.width, mRect.height);
|
||||
PRBool hasClipped = PR_FALSE;
|
||||
|
||||
// If overflow is hidden then set the clip rect so that children
|
||||
// don't leak out of us
|
||||
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
|
||||
//nsMargin dm(0,0,0,0);
|
||||
//mInner->GetDebugInset(dm);
|
||||
nsMargin im(0,0,0,0);
|
||||
GetInset(im);
|
||||
nsMargin border(0,0,0,0);
|
||||
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
||||
spacing->GetBorderPadding(border);
|
||||
r.Deflate(im);
|
||||
//r.Deflate(dm);
|
||||
r.Deflate(border);
|
||||
}
|
||||
|
||||
nsIFrame* kid = mFrames.FirstChild();
|
||||
while (nsnull != kid) {
|
||||
if (!hasClipped && NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
|
||||
// if we haven't already clipped and we should
|
||||
// check to see if the child is in out bounds. If not then
|
||||
// we begin clipping.
|
||||
nsRect cr(0,0,0,0);
|
||||
kid->GetRect(cr);
|
||||
|
||||
// if our rect does not contain the childs then begin clipping
|
||||
if (!r.Contains(cr)) {
|
||||
aRenderingContext.PushState();
|
||||
aRenderingContext.SetClipRect(r,
|
||||
nsClipCombine_kIntersect, clipState);
|
||||
hasClipped = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
PaintChild(aPresContext, aRenderingContext, aDirtyRect, kid, aWhichLayer);
|
||||
kid->GetNextSibling(&kid);
|
||||
}
|
||||
|
||||
if (hasClipped) {
|
||||
aRenderingContext.PopState(clipState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsSVGContainerFrame::AddRef(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsSVGContainerFrame::Release(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame::GetFrameName(nsString& aResult) const
|
||||
{
|
||||
aResult = "nsSVGContainerFrame";
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
||||
const nsPoint& aPoint,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
nsIFrame** aFrame)
|
||||
{
|
||||
// this should act like a block, so we need to override
|
||||
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGContainerFrame::GetCursor(nsIPresContext* aPresContext,
|
||||
nsPoint& aPoint,
|
||||
PRInt32& aCursor)
|
||||
{
|
||||
|
||||
return nsHTMLContainerFrame::GetCursor(aPresContext, aPoint, aCursor);
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGContainerFrame::GetInset(nsMargin& margin)
|
||||
{
|
||||
margin.top = 0;
|
||||
margin.left = 0;
|
||||
margin.right = 0;
|
||||
margin.bottom = 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsSVGContainerFrame_h___
|
||||
#define nsSVGContainerFrame_h___
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsHTMLContainerFrame.h"
|
||||
#include "nsISpaceManager.h"
|
||||
|
||||
class nsHTMLReflowCommand;
|
||||
class nsHTMLInfo;
|
||||
|
||||
// XXX - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
// This should be NOT derived from nsHTMLContainerFrame
|
||||
// we really want to create our own container class from the nsIFrame
|
||||
// interface and not derive from any HTML Frames
|
||||
// XXX - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
class nsSVGContainerFrame : public nsHTMLContainerFrame
|
||||
{
|
||||
public:
|
||||
|
||||
friend nsresult NS_NewSVGContainerFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRBool aIsRoot = PR_FALSE);
|
||||
|
||||
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
|
||||
const nsPoint& aPoint,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
nsIFrame** aFrame);
|
||||
|
||||
NS_IMETHOD GetCursor(nsIPresContext* aPresContext,
|
||||
nsPoint& aPoint,
|
||||
PRInt32& aCursor);
|
||||
|
||||
|
||||
NS_IMETHOD DidReflow(nsIPresContext* aPresContext,
|
||||
nsDidReflowStatus aStatus);
|
||||
|
||||
NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild);
|
||||
|
||||
NS_IMETHOD Init(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIStyleContext* aContext,
|
||||
nsIFrame* asPrevInFlow);
|
||||
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint);
|
||||
|
||||
NS_IMETHOD Paint ( nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
|
||||
|
||||
|
||||
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus);
|
||||
|
||||
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
|
||||
nsIPresShell& aPresShell,
|
||||
nsIAtom* aListName,
|
||||
nsIFrame* aFrameList);
|
||||
|
||||
NS_IMETHOD InsertFrames(nsIPresContext* aPresContext,
|
||||
nsIPresShell& aPresShell,
|
||||
nsIAtom* aListName,
|
||||
nsIFrame* aPrevFrame,
|
||||
nsIFrame* aFrameList);
|
||||
|
||||
NS_IMETHOD RemoveFrame(nsIPresContext* aPresContext,
|
||||
nsIPresShell& aPresShell,
|
||||
nsIAtom* aListName,
|
||||
nsIFrame* aOldFrame);
|
||||
|
||||
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
|
||||
nsIAtom* aListName,
|
||||
nsIFrame* aChildList);
|
||||
|
||||
|
||||
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
virtual ~nsSVGContainerFrame();
|
||||
|
||||
virtual PRIntn GetSkipSides() const { return 0; }
|
||||
virtual void GetInset(nsMargin& margin);
|
||||
NS_IMETHOD Destroy(nsIPresContext* aPresContext);
|
||||
|
||||
|
||||
protected:
|
||||
nsSVGContainerFrame(nsIPresShell* aPresShell, PRBool aIsRoot = PR_FALSE);
|
||||
|
||||
// Paint one child frame
|
||||
virtual void PaintChild(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsIFrame* aFrame,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
|
||||
virtual void PaintChildren(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
|
||||
|
||||
nsresult GenerateDirtyReflowCommand(nsIPresContext* aPresContext,
|
||||
nsIPresShell& aPresShell);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
}; // class nsSVGContainerFrame
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = layout
|
||||
LIBRARY_NAME = raptorsvgcontent_s
|
||||
|
||||
REQUIRES = xpcom raptor dom
|
||||
|
||||
CPPSRCS = nsSVGAtoms.cpp
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_HTML
|
||||
|
||||
INCLUDES += -I$(srcdir)/../../../base/src -I$(DIST)/public/raptor
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
LIBRARY_NAME=raptorsvgcontent_s
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor pref
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPPSRCS= \
|
||||
nsSVGAtoms.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsSVGAtoms.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
||||
-I..\..\..\html\style\src -I..\..\..\html\base\src -I$(PUBLIC)\dom \
|
||||
-I..\..\..\html\document\src \
|
||||
-I$(PUBLIC)\netlib -I..\..\..\base\src -I$(PUBLIC)\pref
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
|
@ -0,0 +1,57 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Rod Spears (rods@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/******
|
||||
|
||||
This file contains the list of all SVG nsIAtoms and their values
|
||||
|
||||
It is designed to be used as inline input to nsSVGAtoms.cpp *only*
|
||||
through the magic of C preprocessing.
|
||||
|
||||
All entires must be enclosed in the macro SVG_ATOM which will have cruel
|
||||
and unusual things done to it
|
||||
|
||||
It is recommended (but not strictly necessary) to keep all entries
|
||||
in alphabetical order
|
||||
|
||||
The first argument to SVG_ATOM is the C++ identifier of the atom
|
||||
The second argument is the string value of the atom
|
||||
|
||||
******/
|
||||
|
||||
// tags
|
||||
SVG_ATOM(polygon, "polygon")
|
||||
SVG_ATOM(polyline, "polyline")
|
||||
SVG_ATOM(rect, "rect")
|
||||
SVG_ATOM(circle, "circle")
|
||||
SVG_ATOM(ellipse, "ellipse")
|
||||
SVG_ATOM(line, "line")
|
||||
SVG_ATOM(svg, "svg")
|
||||
SVG_ATOM(g, "g")
|
||||
|
||||
// properties
|
||||
SVG_ATOM(points, "points")
|
||||
SVG_ATOM(x, "x")
|
||||
SVG_ATOM(y, "y")
|
||||
SVG_ATOM(fill, "fill")
|
|
@ -0,0 +1,74 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Rod Spears (rods@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
|
||||
static const char kSVGNameSpace[] = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.svg";
|
||||
|
||||
PRInt32 nsSVGAtoms::nameSpaceID;
|
||||
|
||||
// define storage for all atoms
|
||||
#define SVG_ATOM(_name, _value) nsIAtom* nsSVGAtoms::_name;
|
||||
#include "nsSVGAtomList.h"
|
||||
#undef SVG_ATOM
|
||||
|
||||
|
||||
static nsrefcnt gRefCnt = 0;
|
||||
static nsINameSpaceManager* gNameSpaceManager;
|
||||
|
||||
void nsSVGAtoms::AddRefAtoms() {
|
||||
|
||||
if (gRefCnt == 0) {
|
||||
/* SVG Atoms registers the SVG name space ID because it's a convenient
|
||||
place to do this, if you don't want a permanent, "well-known" ID.
|
||||
*/
|
||||
if (NS_SUCCEEDED(NS_NewNameSpaceManager(&gNameSpaceManager))) {
|
||||
// gNameSpaceManager->CreateRootNameSpace(namespace);
|
||||
nsAutoString nameSpace(kSVGNameSpace);
|
||||
gNameSpaceManager->RegisterNameSpace(nameSpace, nameSpaceID);
|
||||
} else {
|
||||
NS_ASSERTION(0, "failed to create SVG atoms namespace manager");
|
||||
}
|
||||
|
||||
// now register the atoms
|
||||
#define SVG_ATOM(_name, _value) _name = NS_NewAtom(_value);
|
||||
#include "nsSVGAtomList.h"
|
||||
#undef SVG_ATOM
|
||||
}
|
||||
++gRefCnt;
|
||||
}
|
||||
|
||||
void nsSVGAtoms::ReleaseAtoms() {
|
||||
|
||||
NS_PRECONDITION(gRefCnt != 0, "bad release of SVG atoms");
|
||||
if (--gRefCnt == 0) {
|
||||
#define SVG_ATOM(_name, _value) NS_RELEASE(_name);
|
||||
#include "nsSVGAtomList.h"
|
||||
#undef SVG_ATOM
|
||||
|
||||
NS_IF_RELEASE(gNameSpaceManager);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Rod Spears (rods@netscape.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsSVGAtoms_h___
|
||||
#define nsSVGAtoms_h___
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
class nsINameSpaceManager;
|
||||
|
||||
/**
|
||||
* This class wraps up the creation and destruction of the standard
|
||||
* set of SVG atoms used during normal SVG handling. This object
|
||||
* is created when the first SVG content object is created, and
|
||||
* destroyed when the last such content object is destroyed.
|
||||
*/
|
||||
class nsSVGAtoms {
|
||||
public:
|
||||
|
||||
static void AddRefAtoms();
|
||||
static void ReleaseAtoms();
|
||||
|
||||
// XUL namespace ID, good for the life of the nsSVGAtoms object
|
||||
static PRInt32 nameSpaceID;
|
||||
|
||||
/* Declare all atoms
|
||||
|
||||
The atom names and values are stored in nsCSSAtomList.h and
|
||||
are brought to you by the magic of C preprocessing
|
||||
|
||||
Add new atoms to nsCSSAtomList and all support logic will be auto-generated
|
||||
*/
|
||||
#define SVG_ATOM(_name, _value) static nsIAtom* _name;
|
||||
#include "nsSVGAtomList.h"
|
||||
#undef SVG_ATOM
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsSVGAtoms_h___ */
|
|
@ -0,0 +1,26 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
DIRS = base content
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
Загрузка…
Ссылка в новой задаче