This commit was manufactured by cvs2svn to create branch
'XTF_20040312_BRANCH'. git-svn-id: svn://10.0.0.236/branches/XTF_20040312_BRANCH@159831 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
455
mozilla/content/base/public/nsContentUtils.h
Normal file
455
mozilla/content/base/public/nsContentUtils.h
Normal file
@@ -0,0 +1,455 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* A namespace class for static content utilities. */
|
||||
|
||||
#ifndef nsContentUtils_h___
|
||||
#define nsContentUtils_h___
|
||||
|
||||
#include "jspubtd.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
|
||||
class nsIXPConnect;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIDocShell;
|
||||
class nsINameSpaceManager;
|
||||
class nsIScriptSecurityManager;
|
||||
class nsIThreadJSContextStack;
|
||||
class nsIParserService;
|
||||
class nsIIOService;
|
||||
class nsIURI;
|
||||
class imgIDecoderObserver;
|
||||
class imgIRequest;
|
||||
class imgILoader;
|
||||
class nsIPrefBranch;
|
||||
class nsIPref;
|
||||
|
||||
class nsContentUtils
|
||||
{
|
||||
public:
|
||||
static nsresult Init();
|
||||
|
||||
static nsresult ReparentContentWrapper(nsIContent *aContent,
|
||||
nsIContent *aNewParent,
|
||||
nsIDocument *aNewDocument,
|
||||
nsIDocument *aOldDocument);
|
||||
|
||||
static PRBool IsCallerChrome();
|
||||
|
||||
/*
|
||||
* Returns true if the nodes are both in the same document or
|
||||
* if neither is in a document.
|
||||
* Returns false if the nodes are not in the same document.
|
||||
*/
|
||||
static PRBool InSameDoc(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aOther);
|
||||
|
||||
/**
|
||||
* Do not ever pass null pointers to this method. If one of your
|
||||
* nsIContents is null, you have to decide for yourself what
|
||||
* "IsDescendantOf" really means.
|
||||
*
|
||||
* @param aPossibleDescendant node to test for being a descendant of
|
||||
* aPossibleAncestor
|
||||
* @param aPossibleAncestor node to test for being an ancestor of
|
||||
* aPossibleDescendant
|
||||
* @return PR_TRUE if aPossibleDescendant is a descendant of
|
||||
* aPossibleAncestor (or is aPossibleAncestor). PR_FALSE
|
||||
* otherwise.
|
||||
*/
|
||||
static PRBool ContentIsDescendantOf(nsIContent* aPossibleDescendant,
|
||||
nsIContent* aPossibleAncestor);
|
||||
|
||||
/*
|
||||
* This method fills the |aArray| with all ancestor nodes of |aNode|
|
||||
* including |aNode| at the zero index.
|
||||
*
|
||||
* These elements were |nsIDOMNode*|s before casting to |void*| and must
|
||||
* be cast back to |nsIDOMNode*| on usage, or bad things will happen.
|
||||
*/
|
||||
static nsresult GetAncestors(nsIDOMNode* aNode,
|
||||
nsVoidArray* aArray);
|
||||
|
||||
/*
|
||||
* This method fills |aAncestorNodes| with all ancestor nodes of |aNode|
|
||||
* including |aNode| (QI'd to nsIContent) at the zero index.
|
||||
* For each ancestor, there is a corresponding element in |aAncestorOffsets|
|
||||
* which is the IndexOf the child in relation to its parent.
|
||||
*
|
||||
* The elements of |aAncestorNodes| were |nsIContent*|s before casting to
|
||||
* |void*| and must be cast back to |nsIContent*| on usage, or bad things
|
||||
* will happen.
|
||||
*
|
||||
* This method just sucks.
|
||||
*/
|
||||
static nsresult GetAncestorsAndOffsets(nsIDOMNode* aNode,
|
||||
PRInt32 aOffset,
|
||||
nsVoidArray* aAncestorNodes,
|
||||
nsVoidArray* aAncestorOffsets);
|
||||
|
||||
/*
|
||||
* The out parameter, |aCommonAncestor| will be the closest node, if any,
|
||||
* to both |aNode| and |aOther| which is also an ancestor of each.
|
||||
*/
|
||||
static nsresult GetCommonAncestor(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aOther,
|
||||
nsIDOMNode** aCommonAncestor);
|
||||
|
||||
/*
|
||||
* |aDifferentNodes| will contain up to 3 elements.
|
||||
* The first, if present, is the common ancestor of |aNode| and |aOther|.
|
||||
* The second, if present, is the ancestor node of |aNode| which is
|
||||
* closest to the common ancestor, but not an ancestor of |aOther|.
|
||||
* The third, if present, is the ancestor node of |aOther| which is
|
||||
* closest to the common ancestor, but not an ancestor of |aNode|.
|
||||
*
|
||||
* @throws NS_ERROR_FAILURE if aNode and aOther are disconnected.
|
||||
*/
|
||||
static nsresult GetFirstDifferentAncestors(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aOther,
|
||||
nsCOMArray<nsIDOMNode>& aDifferentNodes);
|
||||
|
||||
/**
|
||||
* Compares the document position of nodes which may have parents.
|
||||
* DO NOT pass in nodes that cannot have a parentNode. In other words:
|
||||
* DO NOT pass in Attr, Document, DocumentFragment, Entity, or Notation!
|
||||
* The results will be completely wrong!
|
||||
*
|
||||
* @param aNode The node to which you are comparing.
|
||||
* @param aOther The reference node to which aNode is compared.
|
||||
*
|
||||
* @return The document position flags of the nodes.
|
||||
*
|
||||
* @see nsIDOMNode
|
||||
* @see nsIDOM3Node
|
||||
*/
|
||||
static PRUint16 ComparePositionWithAncestors(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aOther);
|
||||
|
||||
/**
|
||||
* Reverses the document position flags passed in.
|
||||
*
|
||||
* @param aDocumentPosition The document position flags to be reversed.
|
||||
*
|
||||
* @return The reversed document position flags.
|
||||
*
|
||||
* @see nsIDOMNode
|
||||
* @see nsIDOM3Node
|
||||
*/
|
||||
static PRUint16 ReverseDocumentPosition(PRUint16 aDocumentPosition);
|
||||
|
||||
static PRUint32 CopyNewlineNormalizedUnicodeTo(const nsAString& aSource,
|
||||
PRUint32 aSrcOffset,
|
||||
PRUnichar* aDest,
|
||||
PRUint32 aLength,
|
||||
PRBool& aLastCharCR);
|
||||
|
||||
static PRUint32 CopyNewlineNormalizedUnicodeTo(nsReadingIterator<PRUnichar>& aSrcStart, const nsReadingIterator<PRUnichar>& aSrcEnd, nsAString& aDest);
|
||||
|
||||
static nsISupports *
|
||||
GetClassInfoInstance(nsDOMClassInfoID aID);
|
||||
|
||||
static const nsDependentSubstring TrimCharsInSet(const char* aSet,
|
||||
const nsAString& aValue);
|
||||
|
||||
static const nsDependentSubstring TrimWhitespace(const nsAString& aStr,
|
||||
PRBool aTrimTrailing = PR_TRUE);
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
/**
|
||||
* Checks whether two nodes come from the same origin. aTrustedNode is
|
||||
* considered 'safe' in that a user can operate on it and that it isn't
|
||||
* a js-object that implements nsIDOMNode.
|
||||
* Never call this function with the first node provided by script, it
|
||||
* must always be known to be a 'real' node!
|
||||
*/
|
||||
static nsresult CheckSameOrigin(nsIDOMNode* aTrustedNode,
|
||||
nsIDOMNode* aUnTrustedNode);
|
||||
|
||||
// Check if the (JS) caller can access aNode.
|
||||
static PRBool CanCallerAccess(nsIDOMNode *aNode);
|
||||
|
||||
/**
|
||||
* Get the docshell through the JS context that's currently on the stack.
|
||||
* If there's no JS context currently on the stack aDocShell will be null.
|
||||
*
|
||||
* @param aDocShell The docshell or null if no JS context
|
||||
*/
|
||||
static nsIDocShell *GetDocShellFromCaller();
|
||||
|
||||
/**
|
||||
* Get the document through the JS context that's currently on the stack.
|
||||
* If there's no JS context currently on the stack aDocument will be null.
|
||||
*
|
||||
* @param aDocument The document or null if no JS context
|
||||
*/
|
||||
static nsIDOMDocument *GetDocumentFromCaller();
|
||||
|
||||
// Check if a node is in the document prolog, i.e. before the document
|
||||
// element.
|
||||
static PRBool InProlog(nsIDOMNode *aNode);
|
||||
|
||||
static nsIParserService* GetParserServiceWeakRef();
|
||||
|
||||
static nsINameSpaceManager* GetNSManagerWeakRef()
|
||||
{
|
||||
return sNameSpaceManager;
|
||||
};
|
||||
|
||||
static nsIIOService* GetIOServiceWeakRef()
|
||||
{
|
||||
return sIOService;
|
||||
};
|
||||
|
||||
static nsIScriptSecurityManager* GetSecurityManager()
|
||||
{
|
||||
return sSecurityManager;
|
||||
}
|
||||
|
||||
static nsresult GenerateStateKey(nsIContent* aContent,
|
||||
nsIStatefulFrame::SpecialStateID aID,
|
||||
nsACString& aKey);
|
||||
|
||||
/**
|
||||
* Create a new nsIURI from aSpec, using aBaseURI as the base. The
|
||||
* origin charset of the new nsIURI will be the document charset of
|
||||
* aDocument.
|
||||
*/
|
||||
static nsresult NewURIWithDocumentCharset(nsIURI** aResult,
|
||||
const nsAString& aSpec,
|
||||
nsIDocument* aDocument,
|
||||
nsIURI* aBaseURI);
|
||||
|
||||
/**
|
||||
* Determine whether aContent is in some way associated with aForm. If the
|
||||
* form is a container the only elements that are considered to be associated
|
||||
* with a form are the elements that are contained within the form. If the
|
||||
* form is a leaf element then all elements will be accepted into this list,
|
||||
* since this can happen due to content fixup when a form spans table rows or
|
||||
* table cells.
|
||||
*/
|
||||
static PRBool BelongsInForm(nsIDOMHTMLFormElement *aForm,
|
||||
nsIContent *aContent);
|
||||
|
||||
static nsresult CheckQName(const nsAString& aQualifiedName,
|
||||
PRBool aNamespaceAware = PR_TRUE);
|
||||
|
||||
static nsresult GetNodeInfoFromQName(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsNodeInfoManager* aNodeInfoManager,
|
||||
nsINodeInfo** aNodeInfo);
|
||||
|
||||
static nsAdoptingCString GetCharPref(const char *aPref);
|
||||
static PRPackedBool GetBoolPref(const char *aPref,
|
||||
PRBool aDefault = PR_FALSE);
|
||||
static PRInt32 GetIntPref(const char *aPref, PRInt32 aDefault = 0);
|
||||
static nsAdoptingString GetLocalizedStringPref(const char *aPref);
|
||||
static nsAdoptingString GetStringPref(const char *aPref);
|
||||
static void RegisterPrefCallback(const char *aPref,
|
||||
PrefChangedFunc aCallback,
|
||||
void * aClosure);
|
||||
static void UnregisterPrefCallback(const char *aPref,
|
||||
PrefChangedFunc aCallback,
|
||||
void * aClosure);
|
||||
static nsIPrefBranch *GetPrefBranch()
|
||||
{
|
||||
return sPrefBranch;
|
||||
}
|
||||
|
||||
static nsresult GetDocumentAndPrincipal(nsIDOMNode* aNode,
|
||||
nsIDocument** aDocument,
|
||||
nsIPrincipal** aPrincipal);
|
||||
|
||||
/**
|
||||
* Method to do security and content policy checks on the image URI
|
||||
*
|
||||
* @param aURI uri of the image to be loaded
|
||||
* @param aContext the context the image is loaded in (eg an element)
|
||||
* @param aLoadingDocument the document we belong to
|
||||
* @return PR_TRUE if the load can proceed, or PR_FALSE if it is blocked
|
||||
*/
|
||||
static PRBool CanLoadImage(nsIURI* aURI,
|
||||
nsISupports* aContext,
|
||||
nsIDocument* aLoadingDocument);
|
||||
/**
|
||||
* Method to start an image load. This does not do any security checks.
|
||||
*
|
||||
* @param aURI uri of the image to be loaded
|
||||
* @param aLoadingDocument the document we belong to
|
||||
* @param aObserver the observer for the image load
|
||||
* @param aLoadFlags the load flags to use. See nsIRequest
|
||||
* @return the imgIRequest for the image load
|
||||
*/
|
||||
static nsresult LoadImage(nsIURI* aURI,
|
||||
nsIDocument* aLoadingDocument,
|
||||
nsIURI* aReferrer,
|
||||
imgIDecoderObserver* aObserver,
|
||||
PRInt32 aLoadFlags,
|
||||
imgIRequest** aRequest);
|
||||
|
||||
/**
|
||||
* Convenience method to create a new nodeinfo that differs only by name
|
||||
* from aNodeInfo.
|
||||
*/
|
||||
static nsresult NameChanged(nsINodeInfo *aNodeInfo, nsIAtom *aName,
|
||||
nsINodeInfo** aResult)
|
||||
{
|
||||
nsNodeInfoManager *niMgr = aNodeInfo->NodeInfoManager();
|
||||
|
||||
return niMgr->GetNodeInfo(aName, aNodeInfo->GetPrefixAtom(),
|
||||
aNodeInfo->NamespaceID(), aResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to create a new nodeinfo that differs only by prefix
|
||||
* from aNodeInfo.
|
||||
*/
|
||||
static nsresult PrefixChanged(nsINodeInfo *aNodeInfo, nsIAtom *aPrefix,
|
||||
nsINodeInfo** aResult)
|
||||
{
|
||||
nsNodeInfoManager *niMgr = aNodeInfo->NodeInfoManager();
|
||||
|
||||
return niMgr->GetNodeInfo(aNodeInfo->NameAtom(), aPrefix,
|
||||
aNodeInfo->NamespaceID(), aResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a pointer to the document that owns aNodeInfo.
|
||||
*/
|
||||
static nsIDocument *GetDocument(nsINodeInfo *aNodeInfo)
|
||||
{
|
||||
return aNodeInfo->NodeInfoManager()->GetDocument();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the appropriate event argument name for the specified
|
||||
* namespace. Added because we need to switch between SVG's "evt"
|
||||
* and the rest of the world's "event".
|
||||
*/
|
||||
static const char *GetEventArgName(PRInt32 aNameSpaceID);
|
||||
|
||||
private:
|
||||
static nsresult doReparentContentWrapper(nsIContent *aChild,
|
||||
nsIDocument *aNewDocument,
|
||||
nsIDocument *aOldDocument,
|
||||
JSContext *cx,
|
||||
JSObject *parent_obj);
|
||||
|
||||
|
||||
static nsIDOMScriptObjectFactory *sDOMScriptObjectFactory;
|
||||
|
||||
static nsIXPConnect *sXPConnect;
|
||||
|
||||
static nsIScriptSecurityManager *sSecurityManager;
|
||||
|
||||
static nsIThreadJSContextStack *sThreadJSContextStack;
|
||||
|
||||
static nsIParserService *sParserService;
|
||||
|
||||
static nsINameSpaceManager *sNameSpaceManager;
|
||||
|
||||
static nsIIOService *sIOService;
|
||||
|
||||
static nsIPrefBranch *sPrefBranch;
|
||||
|
||||
static nsIPref *sPref;
|
||||
|
||||
static imgILoader* sImgLoader;
|
||||
|
||||
static PRBool sInitialized;
|
||||
};
|
||||
|
||||
|
||||
class nsCxPusher
|
||||
{
|
||||
public:
|
||||
nsCxPusher(nsISupports *aCurrentTarget)
|
||||
: mScriptIsRunning(PR_FALSE)
|
||||
{
|
||||
if (aCurrentTarget) {
|
||||
Push(aCurrentTarget);
|
||||
}
|
||||
}
|
||||
|
||||
~nsCxPusher()
|
||||
{
|
||||
Pop();
|
||||
}
|
||||
|
||||
void Push(nsISupports *aCurrentTarget);
|
||||
void Pop();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIJSContextStack> mStack;
|
||||
nsCOMPtr<nsIScriptContext> mScx;
|
||||
PRBool mScriptIsRunning;
|
||||
};
|
||||
|
||||
|
||||
#define NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(_class) \
|
||||
if (aIID.Equals(NS_GET_IID(nsIClassInfo))) { \
|
||||
foundInterface = \
|
||||
nsContentUtils::GetClassInfoInstance(eDOMClassInfo_##_class##_id); \
|
||||
if (!foundInterface) { \
|
||||
*aInstancePtr = nsnull; \
|
||||
return NS_ERROR_OUT_OF_MEMORY; \
|
||||
} \
|
||||
} else
|
||||
|
||||
#define NS_INTERFACE_MAP_ENTRY_TEAROFF(_interface, _allocator) \
|
||||
if (aIID.Equals(NS_GET_IID(_interface))) { \
|
||||
foundInterface = NS_STATIC_CAST(_interface *, _allocator); \
|
||||
if (!foundInterface) { \
|
||||
*aInstancePtr = nsnull; \
|
||||
return NS_ERROR_OUT_OF_MEMORY; \
|
||||
} \
|
||||
} else
|
||||
|
||||
#endif /* nsContentUtils_h___ */
|
||||
107
mozilla/content/base/public/nsINameSpaceManager.h
Normal file
107
mozilla/content/base/public/nsINameSpaceManager.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsINameSpaceManager_h___
|
||||
#define nsINameSpaceManager_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsAString.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsString;
|
||||
class nsINameSpace;
|
||||
|
||||
#define kNameSpaceID_Unknown -1
|
||||
#define kNameSpaceID_None 0
|
||||
#define kNameSpaceID_XMLNS 1 // not really a namespace, but it needs to play the game
|
||||
#define kNameSpaceID_XML 2
|
||||
#define kNameSpaceID_XHTML 3
|
||||
#define kNameSpaceID_XLink 4
|
||||
#define kNameSpaceID_XSLT 5
|
||||
#define kNameSpaceID_XBL 6
|
||||
#define kNameSpaceID_MathML 7
|
||||
#define kNameSpaceID_RDF 8
|
||||
#define kNameSpaceID_XUL 9
|
||||
#define kNameSpaceID_SVG 10
|
||||
#define kNameSpaceID_XMLEvents 11
|
||||
|
||||
#define NS_NAMESPACEMANAGER_CONTRACTID "@mozilla.org/content/namespacemanager;1"
|
||||
|
||||
#define NS_INAMESPACEMANAGER_IID \
|
||||
{ 0x409cd4de, 0xb3ca, 0x11d8, \
|
||||
{ 0xb2, 0x67, 0x00, 0x0a, 0x95, 0xdc, 0x23, 0x4c } }
|
||||
|
||||
/**
|
||||
* The Name Space Manager tracks the associtation between a NameSpace
|
||||
* URI and the PRInt32 runtime id. Mappings between NameSpaces and
|
||||
* NameSpace prefixes are managed by nsINameSpaces.
|
||||
*
|
||||
* All NameSpace URIs are stored in a global table so that IDs are
|
||||
* consistent accross the app. NameSpace IDs are only consistent at runtime
|
||||
* ie: they are not guaranteed to be consistent accross app sessions.
|
||||
*
|
||||
* The nsINameSpaceManager needs to have a live reference for as long as
|
||||
* the NameSpace IDs are needed.
|
||||
*
|
||||
* To create a stack of NameSpaces, call CreateRootNameSpace, and then create
|
||||
* child NameSpaces from the root.
|
||||
*
|
||||
*/
|
||||
|
||||
class nsINameSpaceManager : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_INAMESPACEMANAGER_IID)
|
||||
|
||||
NS_IMETHOD CreateRootNameSpace(nsINameSpace** aRootNameSpace) = 0;
|
||||
|
||||
NS_IMETHOD RegisterNameSpace(const nsAString& aURI,
|
||||
PRInt32& aNameSpaceID) = 0;
|
||||
|
||||
NS_IMETHOD GetNameSpaceURI(PRInt32 aNameSpaceID,
|
||||
nsAString& aURI) = 0;
|
||||
NS_IMETHOD GetNameSpaceID(const nsAString& aURI,
|
||||
PRInt32* aNameSpaceID) = 0;
|
||||
|
||||
virtual PRBool HasElementCreator(PRInt32 aNameSpaceID) = 0;
|
||||
};
|
||||
|
||||
nsresult NS_GetNameSpaceManager(nsINameSpaceManager** aInstancePtrResult);
|
||||
|
||||
void NS_NameSpaceManagerShutdown();
|
||||
|
||||
#endif // nsINameSpaceManager_h___
|
||||
1908
mozilla/content/base/src/nsContentUtils.cpp
Normal file
1908
mozilla/content/base/src/nsContentUtils.cpp
Normal file
File diff suppressed because it is too large
Load Diff
48
mozilla/layout/svg/Makefile.in
Normal file
48
mozilla/layout/svg/Makefile.in
Normal file
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla 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/MPL/
|
||||
#
|
||||
# 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 the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = base renderer
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
48
mozilla/layout/svg/base/Makefile.in
Normal file
48
mozilla/layout/svg/base/Makefile.in
Normal file
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla 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/MPL/
|
||||
#
|
||||
# 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 the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
75
mozilla/layout/svg/base/src/libart-incs.h
Normal file
75
mozilla/layout/svg/base/src/libart-incs.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2
|
||||
-*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __LIBART_INCS_H__
|
||||
#define __LIBART_INCS_H__
|
||||
|
||||
#define LIBART_COMPILATION
|
||||
|
||||
#include "art_misc.h"
|
||||
#include "art_vpath.h"
|
||||
#include "art_svp.h"
|
||||
#include "art_svp_vpath.h"
|
||||
#include "art_gray_svp.h"
|
||||
#include "art_rgb_svp.h"
|
||||
#include "art_svp_vpath_stroke.h"
|
||||
#include "art_svp_ops.h"
|
||||
#include "art_affine.h"
|
||||
#include "art_rgb_affine.h"
|
||||
#include "art_rgb_bitmap_affine.h"
|
||||
#include "art_rgb_rgba_affine.h"
|
||||
#include "art_alphagamma.h"
|
||||
#include "art_svp_point.h"
|
||||
#include "art_vpath_dash.h"
|
||||
#include "art_pathcode.h"
|
||||
#include "art_render.h"
|
||||
#include "art_render_gradient.h"
|
||||
#include "art_render_svp.h"
|
||||
#include "art_rgb.h"
|
||||
#include "art_uta.h"
|
||||
#include "art_uta_ops.h"
|
||||
#include "art_uta_rect.h"
|
||||
#include "art_uta_svp.h"
|
||||
#include "art_uta_vpath.h"
|
||||
#include "art_rect_uta.h"
|
||||
#include "art_svp_wind.h"
|
||||
#include "art_bpath.h"
|
||||
#include "art_vpath_bpath.h"
|
||||
|
||||
#endif //__LIBART_INCS_H__
|
||||
66
mozilla/layout/svg/base/src/nsISVGGlyphFragmentLeaf.h
Normal file
66
mozilla/layout/svg/base/src/nsISVGGlyphFragmentLeaf.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_ISVGGLYPHFRAGMENTLEAF_H__
|
||||
#define __NS_ISVGGLYPHFRAGMENTLEAF_H__
|
||||
|
||||
#include "nsISVGGlyphFragmentNode.h"
|
||||
|
||||
class nsISVGRendererGlyphMetrics;
|
||||
|
||||
// {3D47D8F2-BFE9-44FC-847C-8FEFD0AC2624}
|
||||
#define NS_ISVGGLYPHFRAGMENTLEAF_IID \
|
||||
{ 0x3d47d8f2, 0xbfe9, 0x44fc, { 0x84, 0x7c, 0x8f, 0xef, 0xd0, 0xac, 0x26, 0x24 } }
|
||||
|
||||
class nsISVGGlyphFragmentLeaf : public nsISVGGlyphFragmentNode
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISVGGLYPHFRAGMENTLEAF_IID)
|
||||
|
||||
NS_IMETHOD_(void) SetGlyphPosition(float x, float y)=0;
|
||||
NS_IMETHOD_(float) GetGlyphPositionX()=0;
|
||||
NS_IMETHOD_(float) GetGlyphPositionY()=0;
|
||||
NS_IMETHOD GetGlyphMetrics(nsISVGRendererGlyphMetrics** metrics)=0;
|
||||
NS_IMETHOD_(PRBool) IsStartOfChunk()=0; // == is new absolutely positioned chunk.
|
||||
NS_IMETHOD_(void) GetAdjustedPosition(/* inout */ float &x, /* inout */ float &y)=0;
|
||||
NS_IMETHOD_(PRUint32) GetNumberOfChars()=0;
|
||||
NS_IMETHOD_(PRUint32) GetCharNumberOffset()=0;
|
||||
};
|
||||
|
||||
#endif // __NS_ISVGGLYPHFRAGMENTLEAF_H__
|
||||
66
mozilla/layout/svg/base/src/nsISVGGlyphFragmentNode.h
Normal file
66
mozilla/layout/svg/base/src/nsISVGGlyphFragmentNode.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#ifndef __NS_ISVGGLYPHFRAGMENTNODE_H__
|
||||
#define __NS_ISVGGLYPHFRAGMENTNODE_H__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsISVGGlyphFragmentLeaf;
|
||||
|
||||
// {5A3A3929-9F98-4756-8C85-9689EB05983B}
|
||||
#define NS_ISVGGLYPHFRAGMENTNODE_IID \
|
||||
{ 0x5a3a3929, 0x9f98, 0x4756, { 0x8c, 0x85, 0x96, 0x89, 0xeb, 0x05, 0x98, 0x3b } }
|
||||
|
||||
class nsISVGGlyphFragmentNode : public nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISVGGLYPHFRAGMENTNODE_IID)
|
||||
|
||||
NS_IMETHOD_(nsISVGGlyphFragmentLeaf *) GetFirstGlyphFragment()=0;
|
||||
NS_IMETHOD_(nsISVGGlyphFragmentLeaf *) GetNextGlyphFragment()=0;
|
||||
NS_IMETHOD_(PRUint32) BuildGlyphFragmentTree(PRUint32 charNum, PRBool lastBranch)=0;
|
||||
NS_IMETHOD_(void) NotifyMetricsSuspended()=0;
|
||||
NS_IMETHOD_(void) NotifyMetricsUnsuspended()=0;
|
||||
NS_IMETHOD_(void) NotifyGlyphFragmentTreeSuspended()=0;
|
||||
NS_IMETHOD_(void) NotifyGlyphFragmentTreeUnsuspended()=0;
|
||||
};
|
||||
|
||||
#endif // __NS_ISVGGLYPHFRAGMENTNODE_H__
|
||||
62
mozilla/layout/svg/base/src/nsISVGTextContainerFrame.h
Normal file
62
mozilla/layout/svg/base/src/nsISVGTextContainerFrame.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_ISVGTEXTCONTAINERFRAME_H__
|
||||
#define __NS_ISVGTEXTCONTAINERFRAME_H__
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsISVGTextFrame;
|
||||
|
||||
// {1044E336-41E2-414D-9542-FCDBA11C15A8}
|
||||
#define NS_ISVGTEXTCONTAINERFRAME_IID \
|
||||
{ 0x1044e336, 0x41e2, 0x414d, { 0x95, 0x42, 0xfc, 0xdb, 0xa1, 0x1c, 0x15, 0xa8 } }
|
||||
|
||||
class nsISVGTextContainerFrame : public nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISVGTEXTCONTAINERFRAME_IID)
|
||||
|
||||
NS_IMETHOD_(nsISVGTextFrame *) GetTextFrame()=0;
|
||||
NS_IMETHOD_(PRBool) GetAbsolutePositionAdjustmentX(float &x, PRUint32 charNum)=0;
|
||||
NS_IMETHOD_(PRBool) GetAbsolutePositionAdjustmentY(float &y, PRUint32 charNum)=0;
|
||||
NS_IMETHOD_(PRBool) GetRelativePositionAdjustmentX(float &dx, PRUint32 charNum)=0;
|
||||
NS_IMETHOD_(PRBool) GetRelativePositionAdjustmentY(float &dy, PRUint32 charNum)=0;
|
||||
};
|
||||
|
||||
#endif // __NS_ISVGTEXTCONTAINERFRAME_H__
|
||||
188
mozilla/layout/svg/base/src/nsSVGCircleFrame.cpp
Normal file
188
mozilla/layout/svg/base/src/nsSVGCircleFrame.cpp
Normal file
@@ -0,0 +1,188 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSVGPathGeometryFrame.h"
|
||||
#include "nsIDOMSVGAnimatedLength.h"
|
||||
#include "nsIDOMSVGLength.h"
|
||||
#include "nsIDOMSVGPoint.h"
|
||||
#include "nsIDOMSVGCircleElement.h"
|
||||
#include "nsIDOMSVGElement.h"
|
||||
#include "nsIDOMSVGSVGElement.h"
|
||||
//#include "nsASVGPathBuilder.h"
|
||||
#include "nsISVGRendererPathBuilder.h"
|
||||
|
||||
class nsSVGCircleFrame : public nsSVGPathGeometryFrame
|
||||
{
|
||||
protected:
|
||||
friend nsresult
|
||||
NS_NewSVGCircleFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame);
|
||||
|
||||
virtual ~nsSVGCircleFrame();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// nsISVGValueObserver interface:
|
||||
NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable);
|
||||
|
||||
// nsISVGPathGeometrySource interface:
|
||||
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDOMSVGLength> mCx;
|
||||
nsCOMPtr<nsIDOMSVGLength> mCy;
|
||||
nsCOMPtr<nsIDOMSVGLength> mR;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsresult
|
||||
NS_NewSVGCircleFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame)
|
||||
{
|
||||
*aNewFrame = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGCircleElement> circle = do_QueryInterface(aContent);
|
||||
if (!circle) {
|
||||
#ifdef DEBUG
|
||||
printf("warning: trying to construct an SVGCircleFrame for a content element that doesn't support the right interfaces\n");
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsSVGCircleFrame* it = new (aPresShell) nsSVGCircleFrame;
|
||||
if (nsnull == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGCircleFrame::~nsSVGCircleFrame()
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> value;
|
||||
if (mCx && (value = do_QueryInterface(mCx)))
|
||||
value->RemoveObserver(this);
|
||||
if (mCy && (value = do_QueryInterface(mCy)))
|
||||
value->RemoveObserver(this);
|
||||
if (mR && (value = do_QueryInterface(mR)))
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
|
||||
nsresult nsSVGCircleFrame::Init()
|
||||
{
|
||||
nsresult rv = nsSVGPathGeometryFrame::Init();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMSVGCircleElement> circle = do_QueryInterface(mContent);
|
||||
NS_ASSERTION(circle,"wrong content element");
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
circle->GetCx(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mCx));
|
||||
NS_ASSERTION(mCx, "no cx");
|
||||
if (!mCx) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mCx);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
circle->GetCy(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mCy));
|
||||
NS_ASSERTION(mCx, "no cy");
|
||||
if (!mCx) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mCy);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
circle->GetR(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mR));
|
||||
NS_ASSERTION(mCx, "no r");
|
||||
if (!mCx) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mR);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGCircleFrame::DidModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> l = do_QueryInterface(observable);
|
||||
if (l && (mCx==l || mCy==l || mR==l)) {
|
||||
UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH);
|
||||
return NS_OK;
|
||||
}
|
||||
// else
|
||||
return nsSVGPathGeometryFrame::DidModifySVGObservable(observable);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGPathGeometrySource methods:
|
||||
|
||||
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
|
||||
NS_IMETHODIMP nsSVGCircleFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
|
||||
{
|
||||
float x,y,r;
|
||||
|
||||
mCx->GetValue(&x);
|
||||
mCy->GetValue(&y);
|
||||
mR->GetValue(&r);
|
||||
|
||||
// we should be able to build this as a single arc with startpoints
|
||||
// and endpoints infinitesimally separated. Let's use two arcs
|
||||
// though, so that the builder doesn't get confused:
|
||||
pathBuilder->Moveto(x, y-r);
|
||||
pathBuilder->Arcto(x-r, y , r, r, 0.0, 0, 0);
|
||||
pathBuilder->Arcto(x , y-r, r, r, 0.0, 1, 0);
|
||||
pathBuilder->ClosePath(&x,&y);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
197
mozilla/layout/svg/base/src/nsSVGEllipseFrame.cpp
Normal file
197
mozilla/layout/svg/base/src/nsSVGEllipseFrame.cpp
Normal file
@@ -0,0 +1,197 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* William Cook <william.cook@crocodile-clips.com> (original author)
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSVGPathGeometryFrame.h"
|
||||
#include "nsIDOMSVGAnimatedLength.h"
|
||||
#include "nsIDOMSVGLength.h"
|
||||
#include "nsIDOMSVGPoint.h"
|
||||
#include "nsIDOMSVGEllipseElement.h"
|
||||
#include "nsIDOMSVGElement.h"
|
||||
#include "nsIDOMSVGSVGElement.h"
|
||||
#include "nsISVGRendererPathBuilder.h"
|
||||
|
||||
class nsSVGEllipseFrame : public nsSVGPathGeometryFrame
|
||||
{
|
||||
friend nsresult
|
||||
NS_NewSVGEllipseFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame);
|
||||
|
||||
virtual ~nsSVGEllipseFrame();
|
||||
|
||||
virtual nsresult Init();
|
||||
|
||||
// nsISVGValueObserver interface:
|
||||
NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable);
|
||||
|
||||
// nsISVGPathGeometrySource interface:
|
||||
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGLength> mCx;
|
||||
nsCOMPtr<nsIDOMSVGLength> mCy;
|
||||
nsCOMPtr<nsIDOMSVGLength> mRx;
|
||||
nsCOMPtr<nsIDOMSVGLength> mRy;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsresult
|
||||
NS_NewSVGEllipseFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame)
|
||||
{
|
||||
*aNewFrame = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGEllipseElement> ellipse = do_QueryInterface(aContent);
|
||||
if (!ellipse) {
|
||||
#ifdef DEBUG
|
||||
printf("warning: trying to construct an SVGEllipseFrame for a content element that doesn't support the right interfaces\n");
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsSVGEllipseFrame* it = new (aPresShell) nsSVGEllipseFrame;
|
||||
if (nsnull == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGEllipseFrame::~nsSVGEllipseFrame()
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> value;
|
||||
if (mCx && (value = do_QueryInterface(mCx)))
|
||||
value->RemoveObserver(this);
|
||||
if (mCy && (value = do_QueryInterface(mCy)))
|
||||
value->RemoveObserver(this);
|
||||
if (mRx && (value = do_QueryInterface(mRx)))
|
||||
value->RemoveObserver(this);
|
||||
if (mRy && (value = do_QueryInterface(mRy)))
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
|
||||
nsresult nsSVGEllipseFrame::Init()
|
||||
{
|
||||
nsresult rv = nsSVGPathGeometryFrame::Init();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGEllipseElement> ellipse = do_QueryInterface(mContent);
|
||||
NS_ASSERTION(ellipse,"wrong content element");
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
ellipse->GetCx(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mCx));
|
||||
NS_ASSERTION(mCx, "no cx");
|
||||
if (!mCx) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mCx);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
ellipse->GetCy(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mCy));
|
||||
NS_ASSERTION(mCy, "no cy");
|
||||
if (!mCy) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mCy);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
ellipse->GetRx(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mRx));
|
||||
NS_ASSERTION(mRx, "no rx");
|
||||
if (!mRx) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mRx);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
ellipse->GetRy(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mRy));
|
||||
NS_ASSERTION(mRy, "no ry");
|
||||
if (!mRy) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mRy);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGEllipseFrame::DidModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> l = do_QueryInterface(observable);
|
||||
if (l && (mCx==l || mCy==l || mRx==l || mRy==l)) {
|
||||
UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH);
|
||||
return NS_OK;
|
||||
}
|
||||
// else
|
||||
return nsSVGPathGeometryFrame::DidModifySVGObservable(observable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGPathGeometrySource methods:
|
||||
|
||||
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
|
||||
NS_IMETHODIMP nsSVGEllipseFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
|
||||
{
|
||||
float x,y,rx,ry;
|
||||
|
||||
mCx->GetValue(&x);
|
||||
mCy->GetValue(&y);
|
||||
mRx->GetValue(&rx);
|
||||
mRy->GetValue(&ry);
|
||||
|
||||
// build ellipse from two arcs
|
||||
pathBuilder->Moveto(x-rx, y);
|
||||
pathBuilder->Arcto(x+rx, y, rx, ry, 0.0, 0, 0);
|
||||
pathBuilder->Arcto(x-rx, y, rx, ry, 0.0, 1, 0);
|
||||
pathBuilder->ClosePath(&x,&y);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
145
mozilla/layout/svg/base/src/nsSVGGFrame.cpp
Normal file
145
mozilla/layout/svg/base/src/nsSVGGFrame.cpp
Normal file
@@ -0,0 +1,145 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIDOMSVGTransformable.h"
|
||||
#include "nsSVGDefsFrame.h"
|
||||
|
||||
typedef nsSVGDefsFrame nsSVGGFrameBase;
|
||||
|
||||
class nsSVGGFrame : public nsSVGGFrameBase
|
||||
{
|
||||
friend nsresult
|
||||
NS_NewSVGGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame);
|
||||
|
||||
// nsISVGChildFrame interface:
|
||||
NS_IMETHOD Paint(nsISVGRendererCanvas* canvas, const nsRect& dirtyRectTwips);
|
||||
NS_IMETHOD GetFrameForPoint(float x, float y, nsIFrame** hit);
|
||||
NS_IMETHOD_(already_AddRefed<nsISVGRendererRegion>) GetCoveredRegion();
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsresult
|
||||
NS_NewSVGGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame)
|
||||
{
|
||||
*aNewFrame = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGTransformable> transformable = do_QueryInterface(aContent);
|
||||
if (!transformable) {
|
||||
#ifdef DEBUG
|
||||
printf("warning: trying to construct an SVGGFrame for a content element that doesn't support the right interfaces\n");
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsSVGGFrame* it = new (aPresShell) nsSVGGFrame;
|
||||
if (nsnull == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aNewFrame = it;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGChildFrame methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGGFrame::Paint(nsISVGRendererCanvas* canvas, const nsRect& dirtyRectTwips)
|
||||
{
|
||||
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
||||
kid = kid->GetNextSibling()) {
|
||||
nsISVGChildFrame* SVGFrame=nsnull;
|
||||
kid->QueryInterface(NS_GET_IID(nsISVGChildFrame),(void**)&SVGFrame);
|
||||
if (SVGFrame)
|
||||
SVGFrame->Paint(canvas, dirtyRectTwips);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGGFrame::GetFrameForPoint(float x, float y, nsIFrame** hit)
|
||||
{
|
||||
*hit = nsnull;
|
||||
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
||||
kid = kid->GetNextSibling()) {
|
||||
nsISVGChildFrame* SVGFrame=nsnull;
|
||||
kid->QueryInterface(NS_GET_IID(nsISVGChildFrame),(void**)&SVGFrame);
|
||||
if (SVGFrame) {
|
||||
nsIFrame* temp=nsnull;
|
||||
nsresult rv = SVGFrame->GetFrameForPoint(x, y, &temp);
|
||||
if (NS_SUCCEEDED(rv) && temp) {
|
||||
*hit = temp;
|
||||
// return NS_OK; can't return. we need reverse order but only
|
||||
// have a singly linked list...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return *hit ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(already_AddRefed<nsISVGRendererRegion>)
|
||||
nsSVGGFrame::GetCoveredRegion()
|
||||
{
|
||||
nsISVGRendererRegion *accu_region=nsnull;
|
||||
|
||||
nsIFrame* kid = mFrames.FirstChild();
|
||||
while (kid) {
|
||||
nsISVGChildFrame* SVGFrame=0;
|
||||
kid->QueryInterface(NS_GET_IID(nsISVGChildFrame),(void**)&SVGFrame);
|
||||
if (SVGFrame) {
|
||||
nsCOMPtr<nsISVGRendererRegion> dirty_region = SVGFrame->GetCoveredRegion();
|
||||
if (dirty_region) {
|
||||
if (accu_region) {
|
||||
nsCOMPtr<nsISVGRendererRegion> temp = dont_AddRef(accu_region);
|
||||
dirty_region->Combine(temp, &accu_region);
|
||||
}
|
||||
else {
|
||||
accu_region = dirty_region;
|
||||
NS_IF_ADDREF(accu_region);
|
||||
}
|
||||
}
|
||||
}
|
||||
kid = kid->GetNextSibling();
|
||||
}
|
||||
|
||||
return accu_region;
|
||||
}
|
||||
203
mozilla/layout/svg/base/src/nsSVGLineFrame.cpp
Normal file
203
mozilla/layout/svg/base/src/nsSVGLineFrame.cpp
Normal file
@@ -0,0 +1,203 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* William Cook <william.cook@crocodile-clips.com> (original author)
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSVGPathGeometryFrame.h"
|
||||
#include "nsIDOMSVGAnimatedLength.h"
|
||||
#include "nsIDOMSVGLength.h"
|
||||
#include "nsIDOMSVGPoint.h"
|
||||
#include "nsIDOMSVGLineElement.h"
|
||||
#include "nsIDOMSVGElement.h"
|
||||
#include "nsIDOMSVGSVGElement.h"
|
||||
#include "nsISVGRendererPathBuilder.h"
|
||||
|
||||
class nsSVGLineFrame : public nsSVGPathGeometryFrame
|
||||
{
|
||||
protected:
|
||||
friend nsresult
|
||||
NS_NewSVGLineFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame);
|
||||
|
||||
virtual ~nsSVGLineFrame();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// nsISVGValueObserver interface:
|
||||
NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable);
|
||||
|
||||
// nsISVGPathGeometrySource interface:
|
||||
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDOMSVGLength> mX1;
|
||||
nsCOMPtr<nsIDOMSVGLength> mY1;
|
||||
nsCOMPtr<nsIDOMSVGLength> mX2;
|
||||
nsCOMPtr<nsIDOMSVGLength> mY2;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsresult
|
||||
NS_NewSVGLineFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame)
|
||||
{
|
||||
*aNewFrame = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGLineElement> line = do_QueryInterface(aContent);
|
||||
if (!line) {
|
||||
#ifdef DEBUG
|
||||
printf("warning: trying to construct an SVGLineFrame for a content element that doesn't support the right interfaces\n");
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsSVGLineFrame* it = new (aPresShell) nsSVGLineFrame;
|
||||
if (nsnull == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGLineFrame::~nsSVGLineFrame()
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> value;
|
||||
if (mX1 && (value = do_QueryInterface(mX1)))
|
||||
value->RemoveObserver(this);
|
||||
if (mY1 && (value = do_QueryInterface(mY1)))
|
||||
value->RemoveObserver(this);
|
||||
if (mX2 && (value = do_QueryInterface(mX2)))
|
||||
value->RemoveObserver(this);
|
||||
if (mY2 && (value = do_QueryInterface(mY2)))
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
|
||||
nsresult nsSVGLineFrame::Init()
|
||||
{
|
||||
nsresult rv = nsSVGPathGeometryFrame::Init();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGLineElement> line = do_QueryInterface(mContent);
|
||||
NS_ASSERTION(line,"wrong content element");
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
line->GetX1(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mX1));
|
||||
NS_ASSERTION(mX1, "no x1");
|
||||
if (!mX1) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mX1);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
line->GetY1(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mY1));
|
||||
NS_ASSERTION(mY1, "no y1");
|
||||
if (!mY1) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mY1);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
line->GetX2(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mX2));
|
||||
NS_ASSERTION(mX2, "no x2");
|
||||
if (!mX2) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mX2);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
line->GetY2(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mY2));
|
||||
NS_ASSERTION(mY2, "no y2");
|
||||
if (!mY2) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mY2);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGLineFrame::DidModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> l = do_QueryInterface(observable);
|
||||
if (l && (mX1==l || mY1==l || mX2==l || mY2==l)) {
|
||||
UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH);
|
||||
return NS_OK;
|
||||
}
|
||||
// else
|
||||
return nsSVGPathGeometryFrame::DidModifySVGObservable(observable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGPathGeometrySource methods:
|
||||
|
||||
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
|
||||
NS_IMETHODIMP nsSVGLineFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
|
||||
{
|
||||
float x1,y1,x2,y2;
|
||||
|
||||
mX1->GetValue(&x1);
|
||||
mY1->GetValue(&y1);
|
||||
mX2->GetValue(&x2);
|
||||
mY2->GetValue(&y2);
|
||||
|
||||
// move to start coordinates then draw line to end coordinates
|
||||
pathBuilder->Moveto(x1, y1);
|
||||
pathBuilder->Lineto(x2, y2);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// const nsStyleSVG* nsSVGLineFrame::GetStyle()
|
||||
// {
|
||||
// // XXX TODO: strip out any fill color as per svg specs
|
||||
// return nsSVGGraphicFrame::GetStyle();
|
||||
// }
|
||||
478
mozilla/layout/svg/base/src/nsSVGPathFrame.cpp
Normal file
478
mozilla/layout/svg/base/src/nsSVGPathFrame.cpp
Normal file
@@ -0,0 +1,478 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
* Daniele Nicolodi <daniele@grinta.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "nsSVGPathGeometryFrame.h"
|
||||
#include "nsIDOMSVGAnimatedPathData.h"
|
||||
#include "nsIDOMSVGPathSegList.h"
|
||||
#include "nsIDOMSVGPathSeg.h"
|
||||
#include "nsIDOMSVGMatrix.h"
|
||||
#include "nsISVGRendererPathBuilder.h"
|
||||
|
||||
class nsSVGPathFrame : public nsSVGPathGeometryFrame
|
||||
{
|
||||
protected:
|
||||
friend nsresult
|
||||
NS_NewSVGPathFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame);
|
||||
|
||||
~nsSVGPathFrame();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// nsISVGValueObserver interface:
|
||||
NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable);
|
||||
|
||||
// nsISVGPathGeometrySource interface:
|
||||
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDOMSVGPathSegList> mSegments;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame)
|
||||
{
|
||||
*aNewFrame = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGAnimatedPathData> anim_data = do_QueryInterface(aContent);
|
||||
if (!anim_data) {
|
||||
#ifdef DEBUG
|
||||
printf("warning: trying to construct an SVGPathFrame for a content element that doesn't support the right interfaces\n");
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsSVGPathFrame* it = new (aPresShell) nsSVGPathFrame;
|
||||
if (nsnull == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGPathFrame::~nsSVGPathFrame()
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> value;
|
||||
if (mSegments && (value = do_QueryInterface(mSegments)))
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
|
||||
nsresult nsSVGPathFrame::Init()
|
||||
{
|
||||
nsresult rv = nsSVGPathGeometryFrame::Init();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGAnimatedPathData> anim_data = do_QueryInterface(mContent);
|
||||
NS_ASSERTION(anim_data,"wrong content element");
|
||||
anim_data->GetAnimatedPathSegList(getter_AddRefs(mSegments));
|
||||
NS_ASSERTION(mSegments, "no pathseglist");
|
||||
if (!mSegments) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mSegments);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathFrame::DidModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGPathSegList> l = do_QueryInterface(observable);
|
||||
if (l && mSegments==l) {
|
||||
UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH);
|
||||
return NS_OK;
|
||||
}
|
||||
// else
|
||||
return nsSVGPathGeometryFrame::DidModifySVGObservable(observable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGPathGeometrySource methods:
|
||||
|
||||
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
|
||||
NS_IMETHODIMP nsSVGPathFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
|
||||
{
|
||||
PRUint32 count;
|
||||
mSegments->GetNumberOfItems(&count);
|
||||
if (count == 0) return NS_OK;
|
||||
|
||||
float cx = 0.0f; // current point
|
||||
float cy = 0.0f;
|
||||
|
||||
float cx1 = 0.0f; // last controlpoint (for s,S,t,T)
|
||||
float cy1 = 0.0f;
|
||||
|
||||
PRUint16 lastSegmentType = nsIDOMSVGPathSeg::PATHSEG_UNKNOWN;
|
||||
|
||||
PRUint32 i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIDOMSVGPathSeg> segment;
|
||||
mSegments->GetItem(i, getter_AddRefs(segment));
|
||||
|
||||
PRUint16 type = nsIDOMSVGPathSeg::PATHSEG_UNKNOWN;
|
||||
segment->GetPathSegType(&type);
|
||||
|
||||
PRBool absCoords = PR_FALSE;
|
||||
|
||||
switch (type) {
|
||||
case nsIDOMSVGPathSeg::PATHSEG_CLOSEPATH:
|
||||
pathBuilder->ClosePath(&cx,&cy);
|
||||
break;
|
||||
|
||||
case nsIDOMSVGPathSeg::PATHSEG_MOVETO_ABS:
|
||||
absCoords = PR_TRUE;
|
||||
case nsIDOMSVGPathSeg::PATHSEG_MOVETO_REL:
|
||||
{
|
||||
float x, y;
|
||||
if (!absCoords) {
|
||||
nsCOMPtr<nsIDOMSVGPathSegMovetoRel> moveseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(moveseg, "interface not implemented");
|
||||
moveseg->GetX(&x);
|
||||
moveseg->GetY(&y);
|
||||
x += cx;
|
||||
y += cy;
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMSVGPathSegMovetoAbs> moveseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(moveseg, "interface not implemented");
|
||||
moveseg->GetX(&x);
|
||||
moveseg->GetY(&y);
|
||||
}
|
||||
cx = x;
|
||||
cy = y;
|
||||
pathBuilder->Moveto(x,y);
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIDOMSVGPathSeg::PATHSEG_LINETO_ABS:
|
||||
absCoords = PR_TRUE;
|
||||
case nsIDOMSVGPathSeg::PATHSEG_LINETO_REL:
|
||||
{
|
||||
float x, y;
|
||||
if (!absCoords) {
|
||||
nsCOMPtr<nsIDOMSVGPathSegLinetoRel> lineseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(lineseg, "interface not implemented");
|
||||
lineseg->GetX(&x);
|
||||
lineseg->GetY(&y);
|
||||
x += cx;
|
||||
y += cy;
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMSVGPathSegLinetoAbs> lineseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(lineseg, "interface not implemented");
|
||||
lineseg->GetX(&x);
|
||||
lineseg->GetY(&y);
|
||||
}
|
||||
cx = x;
|
||||
cy = y;
|
||||
pathBuilder->Lineto(x,y);
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIDOMSVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS:
|
||||
absCoords = PR_TRUE;
|
||||
case nsIDOMSVGPathSeg::PATHSEG_CURVETO_CUBIC_REL:
|
||||
{
|
||||
float x, y, x1, y1, x2, y2;
|
||||
if (!absCoords) {
|
||||
nsCOMPtr<nsIDOMSVGPathSegCurvetoCubicRel> curveseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(curveseg, "interface not implemented");
|
||||
curveseg->GetX(&x);
|
||||
curveseg->GetY(&y);
|
||||
curveseg->GetX1(&x1);
|
||||
curveseg->GetY1(&y1);
|
||||
curveseg->GetX2(&x2);
|
||||
curveseg->GetY2(&y2);
|
||||
x += cx;
|
||||
y += cy;
|
||||
x1 += cx;
|
||||
y1 += cy;
|
||||
x2 += cx;
|
||||
y2 += cy;
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMSVGPathSegCurvetoCubicAbs> curveseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(curveseg, "interface not implemented");
|
||||
curveseg->GetX(&x);
|
||||
curveseg->GetY(&y);
|
||||
curveseg->GetX1(&x1);
|
||||
curveseg->GetY1(&y1);
|
||||
curveseg->GetX2(&x2);
|
||||
curveseg->GetY2(&y2);
|
||||
}
|
||||
cx = x;
|
||||
cy = y;
|
||||
cx1 = x2;
|
||||
cy1 = y2;
|
||||
pathBuilder->Curveto(x, y, x1, y1, x2, y2);
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIDOMSVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS:
|
||||
absCoords = PR_TRUE;
|
||||
case nsIDOMSVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL:
|
||||
{
|
||||
float x, y, x1, y1, x31, y31, x32, y32;
|
||||
if (!absCoords) {
|
||||
nsCOMPtr<nsIDOMSVGPathSegCurvetoQuadraticRel> curveseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(curveseg, "interface not implemented");
|
||||
curveseg->GetX(&x);
|
||||
curveseg->GetY(&y);
|
||||
curveseg->GetX1(&x1);
|
||||
curveseg->GetY1(&y1);
|
||||
x += cx;
|
||||
y += cy;
|
||||
x1 += cx;
|
||||
y1 += cy;
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMSVGPathSegCurvetoQuadraticAbs> curveseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(curveseg, "interface not implemented");
|
||||
curveseg->GetX(&x);
|
||||
curveseg->GetY(&y);
|
||||
curveseg->GetX1(&x1);
|
||||
curveseg->GetY1(&y1);
|
||||
}
|
||||
|
||||
// conversion of quadratic bezier curve to cubic bezier curve:
|
||||
x31 = cx + (x1 - cx) * 2 / 3;
|
||||
y31 = cy + (y1 - cy) * 2 / 3;
|
||||
x32 = x1 + (x - x1) / 3;
|
||||
y32 = y1 + (y - y1) / 3;
|
||||
|
||||
cx = x;
|
||||
cy = y;
|
||||
cx1 = x1;
|
||||
cy1 = y1;
|
||||
|
||||
pathBuilder->Curveto(x, y, x31, y31, x32, y32);
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIDOMSVGPathSeg::PATHSEG_ARC_ABS:
|
||||
absCoords = PR_TRUE;
|
||||
case nsIDOMSVGPathSeg::PATHSEG_ARC_REL:
|
||||
{
|
||||
float x0, y0, x, y, r1, r2, angle;
|
||||
PRBool largeArcFlag, sweepFlag;
|
||||
|
||||
x0 = cx;
|
||||
y0 = cy;
|
||||
|
||||
if (!absCoords) {
|
||||
nsCOMPtr<nsIDOMSVGPathSegArcRel> arcseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(arcseg, "interface not implemented");
|
||||
arcseg->GetX(&x);
|
||||
arcseg->GetY(&y);
|
||||
arcseg->GetR1(&r1);
|
||||
arcseg->GetR2(&r2);
|
||||
arcseg->GetAngle(&angle);
|
||||
arcseg->GetLargeArcFlag(&largeArcFlag);
|
||||
arcseg->GetSweepFlag(&sweepFlag);
|
||||
|
||||
x += cx;
|
||||
y += cy;
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMSVGPathSegArcAbs> arcseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(arcseg, "interface not implemented");
|
||||
arcseg->GetX(&x);
|
||||
arcseg->GetY(&y);
|
||||
arcseg->GetR1(&r1);
|
||||
arcseg->GetR2(&r2);
|
||||
arcseg->GetAngle(&angle);
|
||||
arcseg->GetLargeArcFlag(&largeArcFlag);
|
||||
arcseg->GetSweepFlag(&sweepFlag);
|
||||
}
|
||||
cx = x;
|
||||
cy = y;
|
||||
|
||||
pathBuilder->Arcto(x, y, r1, r2, angle, largeArcFlag, sweepFlag);
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIDOMSVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS:
|
||||
absCoords = PR_TRUE;
|
||||
case nsIDOMSVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL:
|
||||
{
|
||||
float x;
|
||||
float y = cy;
|
||||
if (!absCoords) {
|
||||
nsCOMPtr<nsIDOMSVGPathSegLinetoHorizontalRel> lineseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(lineseg, "interface not implemented");
|
||||
lineseg->GetX(&x);
|
||||
x += cx;
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMSVGPathSegLinetoHorizontalAbs> lineseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(lineseg, "interface not implemented");
|
||||
lineseg->GetX(&x);
|
||||
}
|
||||
cx = x;
|
||||
pathBuilder->Lineto(x,y);
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIDOMSVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS:
|
||||
absCoords = PR_TRUE;
|
||||
case nsIDOMSVGPathSeg::PATHSEG_LINETO_VERTICAL_REL:
|
||||
{
|
||||
float x = cx;
|
||||
float y;
|
||||
if (!absCoords) {
|
||||
nsCOMPtr<nsIDOMSVGPathSegLinetoVerticalRel> lineseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(lineseg, "interface not implemented");
|
||||
lineseg->GetY(&y);
|
||||
y += cy;
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMSVGPathSegLinetoVerticalAbs> lineseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(lineseg, "interface not implemented");
|
||||
lineseg->GetY(&y);
|
||||
}
|
||||
cy = y;
|
||||
pathBuilder->Lineto(x,y);
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIDOMSVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
|
||||
absCoords = PR_TRUE;
|
||||
case nsIDOMSVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
|
||||
{
|
||||
float x, y, x1, y1, x2, y2;
|
||||
|
||||
if (lastSegmentType == nsIDOMSVGPathSeg::PATHSEG_CURVETO_CUBIC_REL ||
|
||||
lastSegmentType == nsIDOMSVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS ||
|
||||
lastSegmentType == nsIDOMSVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL ||
|
||||
lastSegmentType == nsIDOMSVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS ) {
|
||||
// the first controlpoint is the reflection of the last one about the current point:
|
||||
x1 = 2*cx - cx1;
|
||||
y1 = 2*cy - cy1;
|
||||
}
|
||||
else {
|
||||
// the first controlpoint is equal to the current point:
|
||||
x1 = cx;
|
||||
y1 = cy;
|
||||
}
|
||||
|
||||
if (!absCoords) {
|
||||
nsCOMPtr<nsIDOMSVGPathSegCurvetoCubicSmoothRel> curveseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(curveseg, "interface not implemented");
|
||||
curveseg->GetX(&x);
|
||||
curveseg->GetY(&y);
|
||||
curveseg->GetX2(&x2);
|
||||
curveseg->GetY2(&y2);
|
||||
x += cx;
|
||||
y += cy;
|
||||
x2 += cx;
|
||||
y2 += cy;
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMSVGPathSegCurvetoCubicSmoothAbs> curveseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(curveseg, "interface not implemented");
|
||||
curveseg->GetX(&x);
|
||||
curveseg->GetY(&y);
|
||||
curveseg->GetX2(&x2);
|
||||
curveseg->GetY2(&y2);
|
||||
}
|
||||
cx = x;
|
||||
cy = y;
|
||||
cx1 = x2;
|
||||
cy1 = y2;
|
||||
pathBuilder->Curveto(x, y, x1, y1, x2, y2);
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIDOMSVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
|
||||
absCoords = PR_TRUE;
|
||||
case nsIDOMSVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
|
||||
{
|
||||
float x, y, x1, y1, x31, y31, x32, y32;
|
||||
|
||||
if (lastSegmentType == nsIDOMSVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL ||
|
||||
lastSegmentType == nsIDOMSVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS ||
|
||||
lastSegmentType == nsIDOMSVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL ||
|
||||
lastSegmentType == nsIDOMSVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS ) {
|
||||
// the first controlpoint is the reflection of the last one about the current point:
|
||||
x1 = 2*cx - cx1;
|
||||
y1 = 2*cy - cy1;
|
||||
}
|
||||
else {
|
||||
// the first controlpoint is equal to the current point:
|
||||
x1 = cx;
|
||||
y1 = cy;
|
||||
}
|
||||
|
||||
if (!absCoords) {
|
||||
nsCOMPtr<nsIDOMSVGPathSegCurvetoQuadraticSmoothRel> curveseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(curveseg, "interface not implemented");
|
||||
curveseg->GetX(&x);
|
||||
curveseg->GetY(&y);
|
||||
x += cx;
|
||||
y += cy;
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMSVGPathSegCurvetoQuadraticSmoothAbs> curveseg = do_QueryInterface(segment);
|
||||
NS_ASSERTION(curveseg, "interface not implemented");
|
||||
curveseg->GetX(&x);
|
||||
curveseg->GetY(&y);
|
||||
}
|
||||
|
||||
// conversion of quadratic bezier curve to cubic bezier curve:
|
||||
x31 = cx + (x1 - cx) * 2 / 3;
|
||||
y31 = cy + (y1 - cy) * 2 / 3;
|
||||
x32 = x1 + (x - x1) / 3;
|
||||
y32 = y1 + (y - y1) / 3;
|
||||
|
||||
cx = x;
|
||||
cy = y;
|
||||
cx1 = x1;
|
||||
cy1 = y1;
|
||||
|
||||
pathBuilder->Curveto(x, y, x31, y31, x32, y32);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_ASSERTION(1==0, "unknown path segment");
|
||||
break;
|
||||
}
|
||||
lastSegmentType = type;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
157
mozilla/layout/svg/base/src/nsSVGPolygonFrame.cpp
Normal file
157
mozilla/layout/svg/base/src/nsSVGPolygonFrame.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSVGPathGeometryFrame.h"
|
||||
#include "nsIDOMSVGAnimatedPoints.h"
|
||||
#include "nsIDOMSVGPointList.h"
|
||||
#include "nsIDOMSVGPoint.h"
|
||||
//#include "nsASVGPathBuilder.h"
|
||||
#include "nsISVGRendererPathBuilder.h"
|
||||
|
||||
class nsSVGPolygonFrame : public nsSVGPathGeometryFrame
|
||||
{
|
||||
protected:
|
||||
friend nsresult
|
||||
NS_NewSVGPolygonFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame);
|
||||
|
||||
~nsSVGPolygonFrame();
|
||||
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// nsISVGValueObserver interface:
|
||||
NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable);
|
||||
|
||||
// nsISVGPathGeometrySource interface:
|
||||
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGPointList> mPoints;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPolygonFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedPoints> anim_points = do_QueryInterface(aContent);
|
||||
if (!anim_points) {
|
||||
#ifdef DEBUG
|
||||
printf("warning: trying to construct an SVGPolygonFrame for a content element that doesn't support the right interfaces\n");
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsSVGPolygonFrame* it = new (aPresShell) nsSVGPolygonFrame;
|
||||
if (nsnull == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGPolygonFrame::~nsSVGPolygonFrame()
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> value;
|
||||
if (mPoints && (value = do_QueryInterface(mPoints)))
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
|
||||
nsresult nsSVGPolygonFrame::Init()
|
||||
{
|
||||
nsresult rv = nsSVGPathGeometryFrame::Init();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGAnimatedPoints> anim_points = do_QueryInterface(mContent);
|
||||
NS_ASSERTION(anim_points,"wrong content element");
|
||||
anim_points->GetPoints(getter_AddRefs(mPoints));
|
||||
NS_ASSERTION(mPoints, "no points");
|
||||
if (!mPoints) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mPoints);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPolygonFrame::DidModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGPointList> l = do_QueryInterface(observable);
|
||||
if (l && mPoints==l) {
|
||||
UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH);
|
||||
return NS_OK;
|
||||
}
|
||||
// else
|
||||
return nsSVGPathGeometryFrame::DidModifySVGObservable(observable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGPathGeometrySource methods:
|
||||
|
||||
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
|
||||
NS_IMETHODIMP nsSVGPolygonFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
|
||||
{
|
||||
if (!mPoints) return NS_OK;
|
||||
|
||||
PRUint32 count;
|
||||
mPoints->GetNumberOfItems(&count);
|
||||
if (count == 0) return NS_OK;
|
||||
|
||||
PRUint32 i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIDOMSVGPoint> point;
|
||||
mPoints->GetItem(i, getter_AddRefs(point));
|
||||
|
||||
float x, y;
|
||||
point->GetX(&x);
|
||||
point->GetY(&y);
|
||||
if (i == 0)
|
||||
pathBuilder->Moveto(x, y);
|
||||
else
|
||||
pathBuilder->Lineto(x, y);
|
||||
}
|
||||
// the difference between a polyline and a polygon is that the
|
||||
// polygon is closed:
|
||||
float x,y;
|
||||
pathBuilder->ClosePath(&x,&y);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
154
mozilla/layout/svg/base/src/nsSVGPolylineFrame.cpp
Normal file
154
mozilla/layout/svg/base/src/nsSVGPolylineFrame.cpp
Normal file
@@ -0,0 +1,154 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSVGPathGeometryFrame.h"
|
||||
#include "nsIDOMSVGAnimatedPoints.h"
|
||||
#include "nsIDOMSVGPointList.h"
|
||||
#include "nsIDOMSVGPoint.h"
|
||||
//#include "nsASVGPathBuilder.h"
|
||||
#include "nsISVGRendererPathBuilder.h"
|
||||
|
||||
class nsSVGPolylineFrame : public nsSVGPathGeometryFrame
|
||||
{
|
||||
protected:
|
||||
friend nsresult
|
||||
NS_NewSVGPolylineFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame);
|
||||
|
||||
virtual ~nsSVGPolylineFrame();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// nsISVGValueObserver interface:
|
||||
NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable);
|
||||
|
||||
// nsISVGPathGeometrySource interface:
|
||||
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
|
||||
|
||||
// virtual void ConstructPath(nsASVGPathBuilder* pathBuilder);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGPointList> mPoints;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPolylineFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedPoints> anim_points = do_QueryInterface(aContent);
|
||||
if (!anim_points) {
|
||||
#ifdef DEBUG
|
||||
printf("warning: trying to construct an SVGPolylineFrame for a content element that doesn't support the right interfaces\n");
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsSVGPolylineFrame* it = new (aPresShell) nsSVGPolylineFrame;
|
||||
if (nsnull == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGPolylineFrame::~nsSVGPolylineFrame()
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> value;
|
||||
if (mPoints && (value = do_QueryInterface(mPoints)))
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
|
||||
nsresult nsSVGPolylineFrame::Init()
|
||||
{
|
||||
nsresult rv = nsSVGPathGeometryFrame::Init();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGAnimatedPoints> anim_points = do_QueryInterface(mContent);
|
||||
NS_ASSERTION(anim_points,"wrong content element");
|
||||
anim_points->GetPoints(getter_AddRefs(mPoints));
|
||||
NS_ASSERTION(mPoints, "no points");
|
||||
if (!mPoints) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mPoints);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPolylineFrame::DidModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGPointList> l = do_QueryInterface(observable);
|
||||
if (l && mPoints==l) {
|
||||
UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH);
|
||||
return NS_OK;
|
||||
}
|
||||
// else
|
||||
return nsSVGPathGeometryFrame::DidModifySVGObservable(observable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGPathGeometrySource methods:
|
||||
|
||||
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
|
||||
NS_IMETHODIMP nsSVGPolylineFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
|
||||
{
|
||||
if (!mPoints) return NS_OK;
|
||||
|
||||
PRUint32 count;
|
||||
mPoints->GetNumberOfItems(&count);
|
||||
if (count == 0) return NS_OK;
|
||||
|
||||
PRUint32 i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIDOMSVGPoint> point;
|
||||
mPoints->GetItem(i, getter_AddRefs(point));
|
||||
|
||||
float x, y;
|
||||
point->GetX(&x);
|
||||
point->GetY(&y);
|
||||
if (i == 0)
|
||||
pathBuilder->Moveto(x, y);
|
||||
else
|
||||
pathBuilder->Lineto(x, y);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
257
mozilla/layout/svg/base/src/nsSVGRectFrame.cpp
Normal file
257
mozilla/layout/svg/base/src/nsSVGRectFrame.cpp
Normal file
@@ -0,0 +1,257 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* William Cook <william.cook@crocodile-clips.com> (original author)
|
||||
* Håkan Waara <hwaara@chello.se>
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSVGPathGeometryFrame.h"
|
||||
#include "nsIDOMSVGAnimatedLength.h"
|
||||
#include "nsIDOMSVGLength.h"
|
||||
#include "nsIDOMSVGPoint.h"
|
||||
#include "nsIDOMSVGRectElement.h"
|
||||
#include "nsIDOMSVGElement.h"
|
||||
#include "nsIDOMSVGSVGElement.h"
|
||||
|
||||
#include "nsISVGRendererPathBuilder.h"
|
||||
|
||||
class nsSVGRectFrame : public nsSVGPathGeometryFrame
|
||||
{
|
||||
protected:
|
||||
friend nsresult
|
||||
NS_NewSVGRectFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame);
|
||||
|
||||
virtual ~nsSVGRectFrame();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// nsISVGValueObserver interface:
|
||||
NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable);
|
||||
|
||||
// nsISVGPathGeometrySource interface:
|
||||
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDOMSVGLength> mX;
|
||||
nsCOMPtr<nsIDOMSVGLength> mY;
|
||||
nsCOMPtr<nsIDOMSVGLength> mWidth;
|
||||
nsCOMPtr<nsIDOMSVGLength> mHeight;
|
||||
nsCOMPtr<nsIDOMSVGLength> mRx;
|
||||
nsCOMPtr<nsIDOMSVGLength> mRy;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsresult
|
||||
NS_NewSVGRectFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame)
|
||||
{
|
||||
*aNewFrame = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGRectElement> Rect = do_QueryInterface(aContent);
|
||||
if (!Rect) {
|
||||
#ifdef DEBUG
|
||||
printf("warning: trying to construct an SVGRectFrame for a content element that doesn't support the right interfaces\n");
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsSVGRectFrame* it = new (aPresShell) nsSVGRectFrame;
|
||||
if (nsnull == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGRectFrame::~nsSVGRectFrame()
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> value;
|
||||
if (mX && (value = do_QueryInterface(mX)))
|
||||
value->RemoveObserver(this);
|
||||
if (mY && (value = do_QueryInterface(mY)))
|
||||
value->RemoveObserver(this);
|
||||
if (mWidth && (value = do_QueryInterface(mWidth)))
|
||||
value->RemoveObserver(this);
|
||||
if (mHeight && (value = do_QueryInterface(mHeight)))
|
||||
value->RemoveObserver(this);
|
||||
if (mRx && (value = do_QueryInterface(mRx)))
|
||||
value->RemoveObserver(this);
|
||||
if (mRy && (value = do_QueryInterface(mRy)))
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
|
||||
nsresult nsSVGRectFrame::Init()
|
||||
{
|
||||
nsresult rv = nsSVGPathGeometryFrame::Init();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGRectElement> Rect = do_QueryInterface(mContent);
|
||||
NS_ASSERTION(Rect,"wrong content element");
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
Rect->GetX(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mX));
|
||||
NS_ASSERTION(mX, "no x");
|
||||
if (!mX) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mX);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
Rect->GetY(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mY));
|
||||
NS_ASSERTION(mY, "no y");
|
||||
if (!mY) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mY);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
Rect->GetWidth(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mWidth));
|
||||
NS_ASSERTION(mWidth, "no width");
|
||||
if (!mWidth) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mWidth);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
Rect->GetHeight(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mHeight));
|
||||
NS_ASSERTION(mHeight, "no height");
|
||||
if (!mHeight) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mHeight);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
Rect->GetRx(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mRx));
|
||||
NS_ASSERTION(mRx, "no rx");
|
||||
if (!mRx) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mRx);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> length;
|
||||
Rect->GetRy(getter_AddRefs(length));
|
||||
length->GetBaseVal(getter_AddRefs(mRy));
|
||||
NS_ASSERTION(mRy, "no ry");
|
||||
if (!mRy) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mRy);
|
||||
if (value)
|
||||
value->AddObserver(this);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGRectFrame::DidModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> l = do_QueryInterface(observable);
|
||||
if (l && (mX==l || mY==l || mWidth==l || mHeight==l || mRx==l || mRy==l)) {
|
||||
UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_PATH);
|
||||
return NS_OK;
|
||||
}
|
||||
// else
|
||||
return nsSVGPathGeometryFrame::DidModifySVGObservable(observable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGPathGeometrySource methods:
|
||||
|
||||
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
|
||||
NS_IMETHODIMP nsSVGRectFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
|
||||
{
|
||||
float x, y, width, height, rx, ry;
|
||||
|
||||
mX->GetValue(&x);
|
||||
mY->GetValue(&y);
|
||||
mWidth->GetValue(&width);
|
||||
mHeight->GetValue(&height);
|
||||
mRx->GetValue(&rx);
|
||||
mRy->GetValue(&ry);
|
||||
|
||||
/* In a perfect world, this would be handled by the DOM, and
|
||||
return a DOM exception. */
|
||||
if (width == 0 || height == 0 || ry < 0 || rx < 0)
|
||||
return NS_OK;
|
||||
|
||||
/* If any of the attributes are not set, we need to set it to the corresponding
|
||||
attribute's value (e.g. if rx is not set, assign ry's value to rx). */
|
||||
if (!rx || !ry)
|
||||
{
|
||||
if (rx < ry)
|
||||
rx = ry;
|
||||
else
|
||||
ry = rx;
|
||||
}
|
||||
|
||||
// Rx/ry must not be values higher than half the rectangle's width/height
|
||||
if (rx > (width/2))
|
||||
rx = width/2;
|
||||
|
||||
if (ry > (height/2))
|
||||
ry = height/2;
|
||||
|
||||
pathBuilder->Moveto(x+rx, y);
|
||||
pathBuilder->Lineto(x+width-rx, y);
|
||||
pathBuilder->Arcto(x+width, y+ry , rx, ry, 0.0, 0, 1);
|
||||
pathBuilder->Lineto(x+width, y+height-ry);
|
||||
pathBuilder->Arcto(x+width-rx, y+height , rx, ry, 0.0, 0, 1);
|
||||
pathBuilder->Lineto(x+rx,y+height);
|
||||
pathBuilder->Arcto(x, y+height-ry , rx, ry, 0.0, 0, 1);
|
||||
pathBuilder->Lineto(x,y+ry);
|
||||
pathBuilder->Arcto(x+rx, y, rx, ry, 0.0, 0, 1);
|
||||
pathBuilder->ClosePath(&x,&y);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla 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/MPL/
|
||||
-
|
||||
- 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 the Mozilla SVG project.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Crocodile Clips Ltd.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2002
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
- in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
- of those above. If you wish to allow use of your version of this file only
|
||||
- under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
- use your version of this file under the terms of the MPL, indicate your
|
||||
- decision by deleting the provisions above and replace them with the notice
|
||||
- and other provisions required by the LGPL or the GPL. If you do not delete
|
||||
- the provisions above, a recipient may use your version of this file under
|
||||
- the terms of any one of the MPL, the GPL or the LGPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<bindings id="svgBindings"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" >
|
||||
|
||||
<binding id="a" extends="svg:generic">
|
||||
<content>
|
||||
<svg:g xbl:inherits="style fill fill-opacity fill-rule stroke stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width clip-path clip-rule cursor display filter image-rendering mask opacity pointer-events shape-rendering text-rendering visibility alignment-baseline baseline-shift direction dominant-baseline glyph-orientation-horizontal glyph-orientation-vertical kerning letter-spacing text-anchor text-decoration unicode-bidi word-spacing font-family font-size font-size-adjust font-stretch font-style font-variant font-weight transform" >
|
||||
<children/>
|
||||
</svg:g>
|
||||
</content>
|
||||
<implementation>
|
||||
<property name="href"
|
||||
onget="return this.getAttributeNS('http://www.w3.org/1999/xlink','href');"
|
||||
/>
|
||||
<property name="show"
|
||||
onget="return this.getAttributeNS('http://www.w3.org/1999/xlink','show');"
|
||||
/>
|
||||
</implementation>
|
||||
<handlers>
|
||||
<handler event="mousedown">
|
||||
window.open(this.href, this.show=="new" ? "_blank" : "content", "");
|
||||
</handler>
|
||||
<handler event="mouseover">
|
||||
window.status=this.href;
|
||||
</handler>
|
||||
<handler event="mouseout">
|
||||
window.status=window.defaultStatus;
|
||||
</handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
</bindings>
|
||||
63
mozilla/layout/svg/base/src/svg.css
Normal file
63
mozilla/layout/svg/base/src/svg.css
Normal file
@@ -0,0 +1,63 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
@namespace url(http://www.w3.org/2000/svg);
|
||||
|
||||
a {
|
||||
-moz-binding:url('chrome://svg/content/svgBindings.xml#a');
|
||||
}
|
||||
|
||||
a * {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
svg {
|
||||
/* XXX see bugs #71191 and #172574 before applying xbl binding to
|
||||
either 'svg' or 'svg:not(:root)'
|
||||
*/
|
||||
|
||||
/* give svg elements block display style, so that they reflow
|
||||
correctly when given a relative width/height: */
|
||||
display: block;
|
||||
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
style {
|
||||
display: none;
|
||||
}
|
||||
100
mozilla/layout/svg/renderer/public/nsISVGGlyphMetricsSource.idl
Normal file
100
mozilla/layout/svg/renderer/public/nsISVGGlyphMetricsSource.idl
Normal file
@@ -0,0 +1,100 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
%{C++
|
||||
#include "nsFont.h"
|
||||
%}
|
||||
|
||||
#include "nsISVGGeometrySource.idl"
|
||||
|
||||
native nsFont(nsFont);
|
||||
|
||||
/**
|
||||
* \addtogroup rendering_backend_interfaces Rendering Backend Interfaces
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstracts a description of a 'composite glyph' (character string
|
||||
* with associated font and styling information) in the SVG rendering
|
||||
* backend for use by a rendering engine's nsISVGRendererGlyphMetrics
|
||||
* objects.
|
||||
*
|
||||
* An engine-native glyph metrics object will be informed of changes
|
||||
* in its associated composite glyph with a call to its
|
||||
* nsISVGRendererGlyphMetrics::update() method with an OR-ed
|
||||
* combination of the UPDATEMASK_* constants defined in this interface
|
||||
* (and its base-interface).
|
||||
*
|
||||
* @nosubgrouping
|
||||
*/
|
||||
[scriptable, uuid(8e96a973-c8bb-43a2-8584-4976e75ca478)]
|
||||
interface nsISVGGlyphMetricsSource : nsISVGGeometrySource
|
||||
{
|
||||
/**
|
||||
* @name Font
|
||||
* @{
|
||||
*/
|
||||
[noscript] readonly attribute nsFont font;
|
||||
const unsigned long UPDATEMASK_FONT = 0x00008000;
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Character data
|
||||
* @{
|
||||
*/
|
||||
readonly attribute DOMString characterData;
|
||||
const unsigned long UPDATEMASK_CHARACTER_DATA = 0x00010000;
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Text rendering mode
|
||||
* @{
|
||||
*/
|
||||
/* enums for textRendering */
|
||||
const unsigned short TEXT_RENDERING_AUTO = 0;
|
||||
const unsigned short TEXT_RENDERING_OPTIMIZESPEED = 1;
|
||||
const unsigned short TEXT_RENDERING_OPTIMIZELEGIBILITY = 2;
|
||||
const unsigned short TEXT_RENDERING_GEOMETRICPRECISION = 3;
|
||||
|
||||
readonly attribute unsigned short textRendering;
|
||||
const unsigned long UPDATEMASK_TEXT_RENDERING = 0x00020000;
|
||||
/** @} */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
116
mozilla/layout/svg/renderer/public/nsISVGPathGeometrySource.idl
Normal file
116
mozilla/layout/svg/renderer/public/nsISVGPathGeometrySource.idl
Normal file
@@ -0,0 +1,116 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISVGGeometrySource.idl"
|
||||
|
||||
interface nsISVGRendererPathBuilder;
|
||||
|
||||
/**
|
||||
* \addtogroup rendering_backend_interfaces Rendering Backend Interfaces
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Describes a 'path geometry' object in the SVG rendering backend,
|
||||
* i.e. a graphical object composed of lines, Bezier curves and
|
||||
* elliptical arcs, that can be stroked and filled. The rendering
|
||||
* backend maintains an object implementing this interface for each
|
||||
* rendering engine-native path geometry object.
|
||||
*
|
||||
* An engine-native path geometry object will be informed of changes
|
||||
* in a path geometry's description with a call to its
|
||||
* nsISVGRendererPathGeometry::update() method with an OR-ed
|
||||
* combination of the UPDATEMASK_* constants defined in this interface
|
||||
* (and its base-interface).
|
||||
*
|
||||
* @nosubgrouping
|
||||
*/
|
||||
[scriptable, uuid(73c9350e-6b0b-4458-aa24-aa5333476eff)]
|
||||
interface nsISVGPathGeometrySource : nsISVGGeometrySource
|
||||
{
|
||||
|
||||
/**
|
||||
* @name Path description
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Write a description of the path to the 'pathBuilder'.
|
||||
*
|
||||
* @param pathBuilder Object to write path description to.
|
||||
*/
|
||||
void constructPath(in nsISVGRendererPathBuilder pathBuilder);
|
||||
|
||||
const unsigned long UPDATEMASK_PATH = 0x00008000;
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Hittest mode of operation
|
||||
* @{
|
||||
*/
|
||||
|
||||
const unsigned short HITTEST_MASK_FILL = 0x0001;
|
||||
const unsigned short HITTEST_MASK_STROKE = 0x0002;
|
||||
|
||||
/**
|
||||
* Determines mode of operation expected of the
|
||||
* nsISVGRendererPathGeometry::containsPoint() method. A
|
||||
* combination of the 'HITTEST_MASK_*' constants defined in this
|
||||
* interface.
|
||||
*/
|
||||
readonly attribute unsigned short hittestMask;
|
||||
|
||||
const unsigned long UPDATEMASK_HITTEST_MASK = 0x00010000;
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Shape rendering hints
|
||||
* @{
|
||||
*/
|
||||
|
||||
const unsigned short SHAPE_RENDERING_AUTO = 0;
|
||||
const unsigned short SHAPE_RENDERING_OPTIMIZESPEED = 1;
|
||||
const unsigned short SHAPE_RENDERING_CRISPEDGES = 2;
|
||||
const unsigned short SHAPE_RENDERING_GEOMETRICPRECISION = 3;
|
||||
|
||||
readonly attribute unsigned short shapeRendering;
|
||||
/** @} */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
56
mozilla/layout/svg/renderer/public/nsISVGRectangleSink.idl
Normal file
56
mozilla/layout/svg/renderer/public/nsISVGRectangleSink.idl
Normal file
@@ -0,0 +1,56 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* \addtogroup rendering_backend_interfaces Rendering Backend Interfaces
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface handed to nsISVGRendererRegion::getRectangleScans() to
|
||||
* obtain an approximation of the region with rectangles.
|
||||
*/
|
||||
[scriptable, uuid(0340df1d-1096-445f-bbf9-e1d1e5a10827)]
|
||||
interface nsISVGRectangleSink : nsISupports
|
||||
{
|
||||
void sinkRectangle(in float x, in float y, in float width, in float height);
|
||||
};
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,107 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsISVGRendererRegion;
|
||||
interface nsISVGRendererGlyphMetrics;
|
||||
interface nsISVGRendererCanvas;
|
||||
|
||||
/**
|
||||
* \addtogroup renderer_interfaces Rendering Engine Interfaces
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* One of a number of interfaces (all starting with nsISVGRenderer*)
|
||||
* to be implemented by an SVG rendering engine. See nsISVGRenderer
|
||||
* for more details.
|
||||
*
|
||||
* The SVG rendering backend uses this interface to communicate to the
|
||||
* rendering engine-native glyph objects.
|
||||
*
|
||||
* A glyph object is instantiated by the rendering backend for a given
|
||||
* nsISVGGlyphGeometrySource object with a call to
|
||||
* nsISVGRenderer::createGlyphGeometry(). The glyph object is assumed
|
||||
* to store a reference to its associated source object and provide
|
||||
* glyph rendering and hit-testing for the (composite) glyph described
|
||||
* by the nsISVGGlyphGeometrySource members.
|
||||
*/
|
||||
[scriptable, uuid(cd302675-b093-4018-8081-3e65af962aa8)]
|
||||
interface nsISVGRendererGlyphGeometry : nsISupports
|
||||
{
|
||||
/**
|
||||
* Paint this object.
|
||||
*
|
||||
* @param canvas The canvas to render to.
|
||||
*/
|
||||
void render(in nsISVGRendererCanvas canvas);
|
||||
|
||||
/**
|
||||
* Called by this object's corresponding nsISVGGlyphGeometrySource
|
||||
* as a notification that some of the source's data (identified by
|
||||
* paramter 'updatemask') has changed.
|
||||
*
|
||||
* @param updatemask An OR-ed combination of the UPDATEMASK_*
|
||||
* constants defined in nsISVGGlyphGeometrySource.
|
||||
* @return Region that needs to be redrawn.
|
||||
*/
|
||||
nsISVGRendererRegion update(in unsigned long updatemask);
|
||||
|
||||
/**
|
||||
* Get a region object describing the area covered with paint by
|
||||
* this glyph geometry.
|
||||
*
|
||||
* @return Covered region.
|
||||
*/
|
||||
nsISVGRendererRegion getCoveredRegion();
|
||||
|
||||
/**
|
||||
* Hit-testing method. Does this glyph geometry (with all relevant
|
||||
* transformations applied) contain the point x,y? Should work on a
|
||||
* character-cell basis, rather than the actual character outline.
|
||||
*
|
||||
* @param x X-coordinate of test point. @param y Y-coordinate of
|
||||
* test point.
|
||||
* @return PR_TRUE if the glyph geometry contains the point,
|
||||
* PR_FALSE otherwise.
|
||||
*/
|
||||
boolean containsPoint(in float x, in float y);
|
||||
};
|
||||
|
||||
/** @} */
|
||||
124
mozilla/layout/svg/renderer/public/nsISVGRendererPathBuilder.idl
Normal file
124
mozilla/layout/svg/renderer/public/nsISVGRendererPathBuilder.idl
Normal file
@@ -0,0 +1,124 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* \addtogroup renderer_interfaces Rendering Engine Interfaces
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* One of a number of interfaces (all starting with nsISVGRenderer*)
|
||||
* to be implemented by an SVG rendering engine. See nsISVGRenderer
|
||||
* for more details.
|
||||
*
|
||||
* This interface is used by an nsISVGRendererPathGeometry object in
|
||||
* a call to nsISVGPathGeometrySource::constructPath() to obtain a
|
||||
* native representation of the path described by
|
||||
* nsISVGPathGeometrySource.
|
||||
*/
|
||||
[scriptable, uuid(c3cd294e-39ae-4718-b2bc-87c0fad97a12)]
|
||||
interface nsISVGRendererPathBuilder : nsISupports
|
||||
{
|
||||
/**
|
||||
* Move current position and start new sub-path.
|
||||
*
|
||||
* @param x X-coordinate (untransformed).
|
||||
* @param y Y-coordinate (untransformed).
|
||||
*/
|
||||
void moveto(in float x, in float y);
|
||||
|
||||
/**
|
||||
* Draw a straight line from the current position to (x,y). Advance
|
||||
* current position to (x,y).
|
||||
*
|
||||
* @param x X-coordinate of end point (untransformed).
|
||||
* @param y Y-coordinate of end point (untransformed).
|
||||
*/
|
||||
void lineto(in float x, in float y);
|
||||
|
||||
/**
|
||||
* Draw cubic Bezier curve from the current position to (x,y) using
|
||||
* (x1,y1) as the control point at the beginning og the curve and
|
||||
* (x2,y2) as the control point at the end of the curve. Advance
|
||||
* current position to (x,y).
|
||||
*
|
||||
* @param x X-coordinate of end point (untransformed).
|
||||
* @param y Y-coordinate of end point (untransformed).
|
||||
* @param x1 X-coordinate of first control point (untransformed).
|
||||
* @param y1 Y-coordinate of first control point (untransformed).
|
||||
* @param x2 X-coordinate of second control point (untransformed).
|
||||
* @param y2 Y-coordinate of second control point (untransformed).
|
||||
*/
|
||||
void curveto(in float x, in float y, in float x1, in float y1, in float x2, in float y2);
|
||||
|
||||
/**
|
||||
* Draw an elliptical arc from the current position to
|
||||
* (x,y). Advance current position to (x,y).
|
||||
*
|
||||
* @param x X-coordinate of end point (untransformed).
|
||||
* @param y Y-coordinate of end point (untransformed).
|
||||
* @param r1 Radius of ellipse in X direction (untransformed).
|
||||
* @param r2 Radius of ellipse in Y direction (untransformed).
|
||||
* @param angle Rotation of ellipse as a whole (untransformed).
|
||||
* @param largeArcFlag PR_TRUE: choose the large arc (>=180 degrees),
|
||||
* PR_FALSE: choose the smaller arc (<=180 degrees)
|
||||
* @param sweepFlag PR_TRUE: sweep in positive angle direction,
|
||||
* PR_FALSE: sweep in negative angle direction
|
||||
*/
|
||||
void arcto(in float x, in float y, in float r1, in float r2, in float angle,
|
||||
in boolean largeArcFlag, in boolean sweepFlag);
|
||||
|
||||
/**
|
||||
* Close the current subpath. Move current position back to
|
||||
* beginning of subpath.
|
||||
*
|
||||
* @param newX X-coordinate of new current position (untransformed).
|
||||
* @param newY Y-coordinate of new current position (untransformed).
|
||||
*/
|
||||
void closePath(out float newX, out float newY);
|
||||
|
||||
/**
|
||||
* End the path description. Guaranteed to be the last function
|
||||
* called.
|
||||
*/
|
||||
void endPath();
|
||||
};
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,109 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsISVGRendererRegion;
|
||||
interface nsISVGRendererCanvas;
|
||||
|
||||
/**
|
||||
* \addtogroup renderer_interfaces Rendering Engine Interfaces
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* One of a number of interfaces (all starting with nsISVGRenderer*)
|
||||
* to be implemented by an SVG rendering engine. See nsISVGRenderer
|
||||
* for more details.
|
||||
*
|
||||
* The SVG rendering backend uses this interface to communicate to the
|
||||
* rendering engine-native path objects.
|
||||
*
|
||||
* A path geometry object is instantiated by the rendering backend for
|
||||
* a given nsISVGPathGeometrySource object with a call to
|
||||
* nsISVGRenderer::createPathGeometry(). The path geometry object is
|
||||
* assumed to store a reference to its associated source object and
|
||||
* provide rendering, hit-testing and metrics for the path described
|
||||
* by the nsISVGPathGeometrySource members.
|
||||
*/
|
||||
[scriptable, uuid(86edbfce-7ed8-4ca5-a88e-68447bdac4e9)]
|
||||
interface nsISVGRendererPathGeometry : nsISupports
|
||||
{
|
||||
/**
|
||||
* Paint this object.
|
||||
*
|
||||
* @param canvas The canvas to render to.
|
||||
*/
|
||||
void render(in nsISVGRendererCanvas canvas);
|
||||
|
||||
/**
|
||||
* Called by this object's corresponding nsISVGPathGeometrySource as
|
||||
* a notification that some of the source's data (identified by
|
||||
* paramter 'updatemask') has changed.
|
||||
*
|
||||
* @param updatemask An OR-ed combination of the UPDATEMASK_*
|
||||
* constants defined in nsISVGPathGeometrySource.
|
||||
* @return Region that needs to be redrawn.
|
||||
*/
|
||||
nsISVGRendererRegion update(in unsigned long updatemask);
|
||||
|
||||
/**
|
||||
* Get a region object describing the area covered with paint by
|
||||
* this path geometry.
|
||||
*
|
||||
* @return Covered region.
|
||||
*/
|
||||
nsISVGRendererRegion getCoveredRegion();
|
||||
|
||||
/**
|
||||
* Hit-testing method. Does this path geometry (with all relevant
|
||||
* transformations applied) contain the point x,y? Mode of operation
|
||||
* (e.g. whether to test fill or stroke) is determined by
|
||||
* nsISVGPathGeometrySource::hittestMask.
|
||||
*
|
||||
* @param x X-coordinate of test point. @param y Y-coordinate of
|
||||
* test point.
|
||||
* @return PR_TRUE if the path geometry contains the point,
|
||||
* PR_FALSE otherwise.
|
||||
*/
|
||||
boolean containsPoint(in float x, in float y);
|
||||
|
||||
/* XXX segment at length, point at length */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
77
mozilla/layout/svg/renderer/public/nsISVGRendererRegion.idl
Normal file
77
mozilla/layout/svg/renderer/public/nsISVGRendererRegion.idl
Normal file
@@ -0,0 +1,77 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsISVGRectangleSink;
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup renderer_interfaces Rendering Engine Interfaces
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* One of a number of interfaces (all starting with nsISVGRenderer*)
|
||||
* to be implemented by an SVG rendering engine. See nsISVGRenderer
|
||||
* for more details.
|
||||
*
|
||||
* This interface abstracts a rendering engine-native region object.
|
||||
*/
|
||||
[scriptable, uuid(9356e1c6-66e6-49a0-8c67-7e910270ed1e)]
|
||||
interface nsISVGRendererRegion : nsISupports
|
||||
{
|
||||
/**
|
||||
* Return union of this region with another region.
|
||||
*
|
||||
* @param other Region to combine with.
|
||||
* @return Union region.
|
||||
*/
|
||||
nsISVGRendererRegion combine(in nsISVGRendererRegion other);
|
||||
|
||||
/**
|
||||
* Write a sequence of rectangles approximating this region to the
|
||||
* sink object. The approximation can be crude but should fully
|
||||
* contain the actual region area.
|
||||
*
|
||||
* @param sink Rectangle sink to write to.
|
||||
*/
|
||||
void getRectangleScans(in nsISVGRectangleSink sink);
|
||||
};
|
||||
|
||||
/** @} */
|
||||
70
mozilla/layout/svg/renderer/src/cairo/nsISVGCairoCanvas.h
Normal file
70
mozilla/layout/svg/renderer/src/cairo/nsISVGCairoCanvas.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG Cairo Renderer project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Parts of this file contain code derived from the following files(s)
|
||||
* of the Mozilla SVG project (these parts are Copyright (C) by their
|
||||
* respective copyright-holders):
|
||||
* layout/svg/renderer/src/libart/nsISVGLibartCanvas.h
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_ISVGCAIRO_CANVAS_H__
|
||||
#define __NS_ISVGCAIRO_CANVAS_H__
|
||||
|
||||
#include "nsISVGRendererCanvas.h"
|
||||
#include <cairo.h>
|
||||
|
||||
// {590fdf19-7c06-4719-a17a-3706e2523fbc}
|
||||
#define NS_ISVGCAIROCANVAS_IID \
|
||||
{ 0x590fdf19, 0x7c06, 0x4719, { 0xa1, 0x7a, 0x37, 0x06, 0xe2, 0x52, 0x3f, 0xbc } }
|
||||
|
||||
/**
|
||||
* \addtogroup cairo_renderer Cairo Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 'Private' rendering engine interface
|
||||
*/
|
||||
class nsISVGCairoCanvas : public nsISVGRendererCanvas
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISVGCAIROCANVAS_IID)
|
||||
|
||||
NS_IMETHOD_(cairo_t*) GetContext() = 0;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif //__NS_ISVGCAIRO_CANVAS_H__
|
||||
@@ -0,0 +1,73 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG Cairo Renderer project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Parts of this file contain code derived from the following files(s)
|
||||
* of the Mozilla SVG project (these parts are Copyright (C) by their
|
||||
* respective copyright-holders):
|
||||
* layout/svg/renderer/src/gdiplus/nsSVGGDIPlusGlyphGeometry.cpp
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_ISVGCAIRO_GLYPHMETRICS_H__
|
||||
#define __NS_ISVGCAIRO_GLYPHMETRICS_H__
|
||||
|
||||
#include "nsISVGRendererGlyphMetrics.h"
|
||||
#include <cairo.h>
|
||||
|
||||
// 193e2d48-3898-4bf3-b6bf-d7c00a8aba1f
|
||||
#define NS_ISVGCAIROGLYPHMETRICS_IID \
|
||||
{ 0x193e2d48, 0x3898, 0x4bf3, { 0xb6, 0xbf, 0xd7, 0xc0, 0x0a, 0x8a, 0xba, 0x1f } }
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup gdiplus_renderer Cairo Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* 'Private' rendering engine interface
|
||||
*/
|
||||
class nsISVGCairoGlyphMetrics : public nsISVGRendererGlyphMetrics
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISVGCAIROGLYPHMETRICS_IID)
|
||||
|
||||
NS_IMETHOD_(void) GetSubBoundingBox(PRUint32 charoffset, PRUint32 count, nsIDOMSVGRect * *aBoundingBox)=0;
|
||||
|
||||
NS_IMETHOD_(cairo_font_t*) GetFont() = 0;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif // __NS_ISVGCAIRO_GLYPHMETRICS_H__
|
||||
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG Cairo Renderer project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Parts of this file contain code derived from the following files(s)
|
||||
* of the Mozilla SVG project (these parts are Copyright (C) by their
|
||||
* respective copyright-holders):
|
||||
* layout/svg/renderer/src/gdiplus/nsSVGGDIPlusGlyphGeometry.h
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGCAIRO_GLYPHGEOMETRY_H__
|
||||
#define __NS_SVGCAIRO_GLYPHGEOMETRY_H__
|
||||
|
||||
class nsISVGRendererGlyphGeometry;
|
||||
class nsISVGGlyphGeometrySource;
|
||||
|
||||
nsresult
|
||||
NS_NewSVGCairoGlyphGeometry(nsISVGRendererGlyphGeometry **result,
|
||||
nsISVGGlyphGeometrySource *src);
|
||||
|
||||
#endif // __NS_SVGCAIRO_GLYPHGEOMETRY_H__
|
||||
@@ -0,0 +1,51 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG Cairo Renderer project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Parts of this file contain code derived from the following files(s)
|
||||
* of the Mozilla SVG project (these parts are Copyright (C) by their
|
||||
* respective copyright-holders):
|
||||
* layout/svg/renderer/src/gdiplus/nsSVGGDIPlusGlyphMetrics.h
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGCAIRO_GLYPHMETRICS_H__
|
||||
#define __NS_SVGCAIRO_GLYPHMETRICS_H__
|
||||
|
||||
class nsISVGRendererGlyphMetrics;
|
||||
class nsISVGGlyphMetricsSource;
|
||||
|
||||
nsresult NS_NewSVGCairoGlyphMetrics(nsISVGRendererGlyphMetrics **result,
|
||||
nsISVGGlyphMetricsSource *src);
|
||||
|
||||
#endif // __NS_SVGCAIRO_GLYPHMETRICS_H__
|
||||
271
mozilla/layout/svg/renderer/src/cairo/nsSVGCairoPathBuilder.cpp
Normal file
271
mozilla/layout/svg/renderer/src/cairo/nsSVGCairoPathBuilder.cpp
Normal file
@@ -0,0 +1,271 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG Cairo Renderer project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Parts of this file contain code derived from the following files(s)
|
||||
* of the Mozilla SVG project (these parts are Copyright (C) by their
|
||||
* respective copyright-holders):
|
||||
* layout/svg/renderer/src/libart/nsSVGLibartBPathBuilder.cpp
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISVGRendererPathBuilder.h"
|
||||
#include "nsSVGCairoPathBuilder.h"
|
||||
#include <math.h>
|
||||
#include <cairo.h>
|
||||
|
||||
/**
|
||||
* \addtogroup cairo_renderer Cairo Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Libart path builder implementation
|
||||
*/
|
||||
class nsSVGCairoPathBuilder : public nsISVGRendererPathBuilder
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGCairoPathBuilder(nsISVGRendererPathBuilder **result,
|
||||
cairo_t *ctx);
|
||||
|
||||
nsSVGCairoPathBuilder(cairo_t *ctx);
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsISVGRendererPathBuilder interface:
|
||||
NS_DECL_NSISVGRENDERERPATHBUILDER
|
||||
|
||||
private:
|
||||
|
||||
cairo_t *mCR;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// implementation:
|
||||
|
||||
nsSVGCairoPathBuilder::nsSVGCairoPathBuilder(cairo_t *ctx)
|
||||
: mCR(ctx)
|
||||
{
|
||||
cairo_new_path(mCR);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewSVGCairoPathBuilder(nsISVGRendererPathBuilder **result,
|
||||
cairo_t *ctx)
|
||||
{
|
||||
*result = new nsSVGCairoPathBuilder(ctx);
|
||||
if (!result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*result);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGCairoPathBuilder)
|
||||
NS_IMPL_RELEASE(nsSVGCairoPathBuilder)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGCairoPathBuilder)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGRendererPathBuilder)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGRendererPathBuilder methods:
|
||||
|
||||
/** Implements void moveto(in float x, in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGCairoPathBuilder::Moveto(float x, float y)
|
||||
{
|
||||
cairo_move_to(mCR, x, y);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Implements void lineto(in float x, in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGCairoPathBuilder::Lineto(float x, float y)
|
||||
{
|
||||
cairo_line_to(mCR, x, y);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Implements void curveto(in float x, in float y, in float x1, in float y1, in float x2, in float y2); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGCairoPathBuilder::Curveto(float x, float y, float x1, float y1, float x2, float y2)
|
||||
{
|
||||
cairo_curve_to(mCR, x1, y1, x2, y2, x, y);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* helper for Arcto : */
|
||||
static inline double CalcVectorAngle(double ux, double uy, double vx, double vy)
|
||||
{
|
||||
double ta = atan2(uy, ux);
|
||||
double tb = atan2(vy, vx);
|
||||
if (tb >= ta)
|
||||
return tb-ta;
|
||||
return 6.28318530718 - (ta-tb);
|
||||
}
|
||||
|
||||
|
||||
/** Implements void arcto(in float x, in float y, in float r1, in float r2, in float angle, in boolean largeArcFlag, in boolean sweepFlag); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGCairoPathBuilder::Arcto(float x2, float y2, float rx, float ry, float angle, PRBool largeArcFlag, PRBool sweepFlag)
|
||||
{
|
||||
const double pi = 3.14159265359;
|
||||
const double radPerDeg = pi/180.0;
|
||||
|
||||
double x1=0.0, y1=0.0;
|
||||
cairo_current_point(mCR, &x1, &y1);
|
||||
|
||||
// 1. Treat out-of-range parameters as described in
|
||||
// http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
|
||||
|
||||
// If the endpoints (x1, y1) and (x2, y2) are identical, then this
|
||||
// is equivalent to omitting the elliptical arc segment entirely
|
||||
if (x1 == x2 && y1 == y2) return NS_OK;
|
||||
|
||||
// If rX = 0 or rY = 0 then this arc is treated as a straight line
|
||||
// segment (a "lineto") joining the endpoints.
|
||||
if (rx == 0.0f || ry == 0.0f) {
|
||||
Lineto(x2, y2);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If rX or rY have negative signs, these are dropped; the absolute
|
||||
// value is used instead.
|
||||
if (rx<0.0) rx = -rx;
|
||||
if (ry<0.0) ry = -ry;
|
||||
|
||||
// 2. convert to center parameterization as shown in
|
||||
// http://www.w3.org/TR/SVG/implnote.html
|
||||
double sinPhi = sin(angle*radPerDeg);
|
||||
double cosPhi = cos(angle*radPerDeg);
|
||||
|
||||
double x1dash = cosPhi * (x1-x2)/2.0 + sinPhi * (y1-y2)/2.0;
|
||||
double y1dash = -sinPhi * (x1-x2)/2.0 + cosPhi * (y1-y2)/2.0;
|
||||
|
||||
double root;
|
||||
double numerator = rx*rx*ry*ry - rx*rx*y1dash*y1dash - ry*ry*x1dash*x1dash;
|
||||
|
||||
if (numerator < 0.0) {
|
||||
// If rX , rY and are such that there is no solution (basically,
|
||||
// the ellipse is not big enough to reach from (x1, y1) to (x2,
|
||||
// y2)) then the ellipse is scaled up uniformly until there is
|
||||
// exactly one solution (until the ellipse is just big enough).
|
||||
|
||||
// -> find factor s, such that numerator' with rx'=s*rx and
|
||||
// ry'=s*ry becomes 0 :
|
||||
float s = (float)sqrt(1.0 - numerator/(rx*rx*ry*ry));
|
||||
|
||||
rx *= s;
|
||||
ry *= s;
|
||||
root = 0.0;
|
||||
|
||||
}
|
||||
else {
|
||||
root = (largeArcFlag == sweepFlag ? -1.0 : 1.0) *
|
||||
sqrt( numerator/(rx*rx*y1dash*y1dash+ry*ry*x1dash*x1dash) );
|
||||
}
|
||||
|
||||
double cxdash = root*rx*y1dash/ry;
|
||||
double cydash = -root*ry*x1dash/rx;
|
||||
|
||||
double cx = cosPhi * cxdash - sinPhi * cydash + (x1+x2)/2.0;
|
||||
double cy = sinPhi * cxdash + cosPhi * cydash + (y1+y2)/2.0;
|
||||
double theta1 = CalcVectorAngle(1.0, 0.0, (x1dash-cxdash)/rx, (y1dash-cydash)/ry);
|
||||
double dtheta = CalcVectorAngle((x1dash-cxdash)/rx, (y1dash-cydash)/ry,
|
||||
(-x1dash-cxdash)/rx, (-y1dash-cydash)/ry);
|
||||
if (!sweepFlag && dtheta>0)
|
||||
dtheta -= 2.0*pi;
|
||||
else if (sweepFlag && dtheta<0)
|
||||
dtheta += 2.0*pi;
|
||||
|
||||
// 3. convert into cubic bezier segments <= 90deg
|
||||
int segments = (int)ceil(fabs(dtheta/(pi/2.0)));
|
||||
double delta = dtheta/segments;
|
||||
double t = 8.0/3.0 * sin(delta/4.0) * sin(delta/4.0) / sin(delta/2.0);
|
||||
|
||||
for (int i = 0; i < segments; ++i) {
|
||||
double cosTheta1 = cos(theta1);
|
||||
double sinTheta1 = sin(theta1);
|
||||
double theta2 = theta1 + delta;
|
||||
double cosTheta2 = cos(theta2);
|
||||
double sinTheta2 = sin(theta2);
|
||||
|
||||
// a) calculate endpoint of the segment:
|
||||
double xe = cosPhi * rx*cosTheta2 - sinPhi * ry*sinTheta2 + cx;
|
||||
double ye = sinPhi * rx*cosTheta2 + cosPhi * ry*sinTheta2 + cy;
|
||||
|
||||
// b) calculate gradients at start/end points of segment:
|
||||
double dx1 = t * ( - cosPhi * rx*sinTheta1 - sinPhi * ry*cosTheta1);
|
||||
double dy1 = t * ( - sinPhi * rx*sinTheta1 + cosPhi * ry*cosTheta1);
|
||||
|
||||
double dxe = t * ( cosPhi * rx*sinTheta2 + sinPhi * ry*cosTheta2);
|
||||
double dye = t * ( sinPhi * rx*sinTheta2 - cosPhi * ry*cosTheta2);
|
||||
|
||||
// c) draw the cubic bezier:
|
||||
Curveto((float)xe, (float)ye, (float)(x1+dx1), (float)(y1+dy1),
|
||||
(float)(xe+dxe), (float)(ye+dye));
|
||||
|
||||
// do next segment
|
||||
theta1 = theta2;
|
||||
x1 = (float)xe;
|
||||
y1 = (float)ye;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Implements void closePath(out float newX, out float newY); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGCairoPathBuilder::ClosePath(float *newX, float *newY)
|
||||
{
|
||||
cairo_close_path(mCR);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Implements void endPath(); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGCairoPathBuilder::EndPath()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG Cairo Renderer project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Parts of this file contain code derived from the following files(s)
|
||||
* of the Mozilla SVG project (these parts are Copyright (C) by their
|
||||
* respective copyright-holders):
|
||||
* layout/svg/renderer/src/libart/nsSVGLibartBPathBuilder.h
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGCAIRO_PATHBUILDER_H__
|
||||
#define __NS_SVGCAIRO_PATHBUILDER_H__
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
class nsISVGRendererPathBuilder;
|
||||
class nsISVGPathGeometrySource;
|
||||
|
||||
nsresult NS_NewSVGCairoPathBuilder(nsISVGRendererPathBuilder **result,
|
||||
cairo_t* ctx);
|
||||
|
||||
#endif // __NS_SVGCAIRO_PATHBUILDER_H__
|
||||
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG Cairo Renderer project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Parts of this file contain code derived from the following files(s)
|
||||
* of the Mozilla SVG project (these parts are Copyright (C) by their
|
||||
* respective copyright-holders):
|
||||
* layout/svg/renderer/src/libart/nsSVGLibartPathGeometry.h
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGCAIRO_PATHGEOMETRY_H__
|
||||
#define __NS_SVGCAIRO_PATHGEOMETRY_H__
|
||||
|
||||
class nsISVGRendererPathGeometry;
|
||||
class nsISVGPathGeometrySource;
|
||||
|
||||
nsresult
|
||||
NS_NewSVGCairoPathGeometry(nsISVGRendererPathGeometry **result,
|
||||
nsISVGPathGeometrySource *src);
|
||||
|
||||
#endif // __NS_SVGCAIRO_PATHGEOMETRY_H__
|
||||
116
mozilla/layout/svg/renderer/src/cairo/nsSVGCairoRegion.cpp
Normal file
116
mozilla/layout/svg/renderer/src/cairo/nsSVGCairoRegion.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG Cairo Renderer project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISVGRendererRegion.h"
|
||||
#include "nsISVGRectangleSink.h"
|
||||
#include "nsSVGCairoRegion.h"
|
||||
|
||||
class nsSVGCairoRectRegion : public nsISVGRendererRegion
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGCairoRectRegion(nsISVGRendererRegion** result,
|
||||
float x, float y,
|
||||
float width, float height);
|
||||
nsSVGCairoRectRegion(float x, float y, float w, float h);
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsISVGRendererRegion interface:
|
||||
NS_DECL_NSISVGRENDERERREGION
|
||||
|
||||
private:
|
||||
float mX, mY, mWidth, mHeight;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// implementation:
|
||||
|
||||
nsresult
|
||||
NS_NewSVGCairoRectRegion(nsISVGRendererRegion** result, float x, float y,
|
||||
float width, float height)
|
||||
{
|
||||
*result = new nsSVGCairoRectRegion(x, y, width, height);
|
||||
|
||||
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGCairoRectRegion::nsSVGCairoRectRegion(float x, float y, float w, float h) :
|
||||
mX(x), mY(y), mWidth(w), mHeight(h)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGCairoRectRegion)
|
||||
NS_IMPL_RELEASE(nsSVGCairoRectRegion)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGCairoRectRegion)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGRendererRegion)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGRendererRegion methods:
|
||||
|
||||
/** Implements nsISVGRendererRegion combine(in nsISVGRendererRegion other); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGCairoRectRegion::Combine(nsISVGRendererRegion *other,
|
||||
nsISVGRendererRegion **_retval)
|
||||
{
|
||||
nsSVGCairoRectRegion *_other = static_cast<nsSVGCairoRectRegion*>(other); // ok, i know i'm being bad
|
||||
|
||||
float x1 = PR_MIN(mX, _other->mX);
|
||||
float y1 = PR_MIN(mY, _other->mY);
|
||||
float x2 = PR_MAX(mX+mWidth, _other->mX+_other->mWidth);
|
||||
float y2 = PR_MAX(mY+mHeight, _other->mY+_other->mHeight);
|
||||
|
||||
return NS_NewSVGCairoRectRegion(_retval, x1, y1, x2-x1, y2-y1);
|
||||
}
|
||||
|
||||
/** Implements void getRectangleScans(in nsISVGRectangleSink sink); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGCairoRectRegion::GetRectangleScans(nsISVGRectangleSink *sink)
|
||||
{
|
||||
sink->SinkRectangle(mX, mY, mWidth, mHeight);
|
||||
return NS_OK;
|
||||
}
|
||||
48
mozilla/layout/svg/renderer/src/cairo/nsSVGCairoRegion.h
Normal file
48
mozilla/layout/svg/renderer/src/cairo/nsSVGCairoRegion.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG Cairo Renderer project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGCAIRO_REGION_H__
|
||||
#define __NS_SVGCAIRO_REGION_H__
|
||||
|
||||
class nsISVGRendererRegion;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// region constructors:
|
||||
|
||||
nsresult NS_NewSVGCairoRectRegion(nsISVGRendererRegion** result,
|
||||
float x, float y, float width, float height);
|
||||
|
||||
#endif // __NS_SVGCAIRO_REGION_H__
|
||||
@@ -0,0 +1,77 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_ISVGGDIPLUS_CANVAS_H__
|
||||
#define __NS_ISVGGDIPLUS_CANVAS_H__
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// unknwn.h is needed to build with WIN32_LEAN_AND_MEAN
|
||||
#include <unknwn.h>
|
||||
|
||||
#include <Gdiplus.h>
|
||||
using namespace Gdiplus;
|
||||
|
||||
#include "nsISVGRendererCanvas.h"
|
||||
|
||||
// {D6AFEBFE-819B-46CE-834C-16AE2105925C}
|
||||
#define NS_ISVGGDIPLUSCANVAS_IID \
|
||||
{ 0xd6afebfe, 0x819b, 0x46ce, { 0x83, 0x4c, 0x16, 0xae, 0x21, 0x05, 0x92, 0x5c } }
|
||||
|
||||
/**
|
||||
* \addtogroup gdiplus_renderer GDI+ Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* 'Private' rendering engine interface
|
||||
*/
|
||||
class nsISVGGDIPlusCanvas : public nsISVGRendererCanvas
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISVGGDIPLUSCANVAS_IID)
|
||||
|
||||
/**
|
||||
* Obtain the Gdiplus::Graphics object for this canvas.
|
||||
*/
|
||||
NS_IMETHOD_(Graphics*) GetGraphics()=0;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif //__NS_ISVGGDIPLUS_CANVAS_H__
|
||||
@@ -0,0 +1,88 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_ISVGGDIPLUS_GLYPHMETRICS_H__
|
||||
#define __NS_ISVGGDIPLUS_GLYPHMETRICS_H__
|
||||
|
||||
#include "nsISVGRendererGlyphMetrics.h"
|
||||
|
||||
// {A0B0E2A4-4237-44C8-9FD8-8B1B48F43C93}
|
||||
#define NS_ISVGGDIPLUSGLYPHMETRICS_IID \
|
||||
{ 0xa0b0e2a4, 0x4237, 0x44c8, { 0x9f, 0xd8, 0x8b, 0x1b, 0x48, 0xf4, 0x3c, 0x93 } }
|
||||
|
||||
/**
|
||||
* \addtogroup gdiplus_renderer GDI+ Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* 'Private' rendering engine interface
|
||||
*/
|
||||
class nsISVGGDIPlusGlyphMetrics : public nsISVGRendererGlyphMetrics
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISVGGDIPLUSGLYPHMETRICS_IID)
|
||||
|
||||
/**
|
||||
* Obtain the bounding rectangle of the (composite) glyph as a Gdiplus::RectF.
|
||||
*/
|
||||
NS_IMETHOD_(const RectF*) GetBoundingRect()=0;
|
||||
|
||||
/**
|
||||
* Obtain the bounding rectangle of the glyphs of part of the
|
||||
* character string as a Gdiplus::RectF.
|
||||
*
|
||||
* @param charoffset Offset into nsISVGGlyphMetricsSource::characterData.
|
||||
* @param count Number of characters for which to get bounds.
|
||||
*/
|
||||
NS_IMETHOD_(void) GetSubBoundingRect(PRUint32 charoffset, PRUint32 count, RectF* retval)=0;
|
||||
|
||||
/**
|
||||
* Obtain the Gdiplus::Font object selected for this glyph metrics object.
|
||||
*/
|
||||
NS_IMETHOD_(const Font*) GetFont()=0;
|
||||
|
||||
/**
|
||||
* Obtain the Gdiplus::TextRenderingHint for this glyph metrics object.
|
||||
*/
|
||||
NS_IMETHOD_(TextRenderingHint) GetTextRenderingHint()=0;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif // __NS_ISVGGDIPLUS_GLYPHMETRICS_H__
|
||||
@@ -0,0 +1,84 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_ISVGGDIPLUS_REGION_H__
|
||||
#define __NS_ISVGGDIPLUS_REGION_H__
|
||||
|
||||
// Undefine the following symbol to use native gdi+ regions instead of
|
||||
// rectangles. Due the fine granularity of Region::GetRegionScans(),
|
||||
// native regions are very inefficient at the moment.
|
||||
#define NS_SVG_GDIPLUS_RENDERER_USE_RECT_REGIONS
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// unknwn.h is needed to build with WIN32_LEAN_AND_MEAN
|
||||
#include <unknwn.h>
|
||||
|
||||
#include <Gdiplus.h>
|
||||
using namespace Gdiplus;
|
||||
|
||||
#include "nsISVGRendererRegion.h"
|
||||
|
||||
// {366160B9-98DD-4EC0-83CA-0E474F7A82C2}
|
||||
#define NS_ISVGGDIPLUSREGION_IID \
|
||||
{ 0x366160b9, 0x98dd, 0x4ec0, { 0x83, 0xca, 0x0e, 0x47, 0x4f, 0x7a, 0x82, 0xc2 } }
|
||||
|
||||
/**
|
||||
* \addtogroup gdiplus_renderer GDI+ Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* 'Private' rendering engine interface
|
||||
*/
|
||||
class nsISVGGDIPlusRegion : public nsISVGRendererRegion
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISVGGDIPLUSREGION_IID)
|
||||
|
||||
#ifdef NS_SVG_GDIPLUS_RENDERER_USE_RECT_REGIONS
|
||||
NS_IMETHOD_(const RectF*) GetRect()const=0;
|
||||
#else
|
||||
NS_IMETHOD_(const Region*) GetRegion()const=0;
|
||||
#endif
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif //__NS_ISVGGDIPLUS_REGION_H__
|
||||
@@ -0,0 +1,49 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGGDIPLUS_GLYPHGEOMETRY_H__
|
||||
#define __NS_SVGGDIPLUS_GLYPHGEOMETRY_H__
|
||||
|
||||
class nsISVGRendererGlyphGeometry;
|
||||
class nsISVGGlyphGeometrySource;
|
||||
|
||||
nsresult
|
||||
NS_NewSVGGDIPlusGlyphGeometry(nsISVGRendererGlyphGeometry **result,
|
||||
nsISVGGlyphGeometrySource *src);
|
||||
|
||||
#endif // __NS_SVGGDIPLUS_GLYPHGEOMETRY_H__
|
||||
@@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGGDIPLUS_GLYPHMETRICS_H__
|
||||
#define __NS_SVGGDIPLUS_GLYPHMETRICS_H__
|
||||
|
||||
class nsISVGRendererGlyphMetrics;
|
||||
class nsISVGGlyphMetricsSource;
|
||||
|
||||
nsresult NS_NewSVGGDIPlusGlyphMetrics(nsISVGRendererGlyphMetrics **result,
|
||||
nsISVGGlyphMetricsSource *src);
|
||||
|
||||
#endif // __NS_SVGGDIPLUS_GLYPHMETRICS_H__
|
||||
@@ -0,0 +1,371 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// unknwn.h is needed to build with WIN32_LEAN_AND_MEAN
|
||||
#include <unknwn.h>
|
||||
|
||||
#include <Gdiplus.h>
|
||||
using namespace Gdiplus;
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISVGPathGeometrySource.h"
|
||||
#include "nsISVGRendererPathBuilder.h"
|
||||
#include <math.h>
|
||||
|
||||
/**
|
||||
* \addtogroup gdiplus_renderer GDI+ Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Helper class used by nsSVGGDIPlusPathBuilder
|
||||
*
|
||||
* Maintains a stack of points during the path building process.
|
||||
*/
|
||||
class PointStack
|
||||
{
|
||||
public:
|
||||
PointStack();
|
||||
~PointStack();
|
||||
|
||||
struct PointData {
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
|
||||
void PushPoint(float x, float y);
|
||||
const PointData *PopPoint();
|
||||
private:
|
||||
void Grow();
|
||||
|
||||
PointData mOrigin;
|
||||
PointData *mPoints;
|
||||
int mCapacity;
|
||||
int mSize;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
PointStack::PointStack()
|
||||
: mPoints(0), mCapacity(0), mSize(0)
|
||||
{
|
||||
mOrigin.x = 0.0f;
|
||||
mOrigin.y = 0.0f;
|
||||
}
|
||||
|
||||
PointStack::~PointStack()
|
||||
{
|
||||
if (mPoints) delete[] mPoints;
|
||||
}
|
||||
|
||||
void PointStack::PushPoint(float x, float y)
|
||||
{
|
||||
if (mCapacity-mSize<1)
|
||||
Grow();
|
||||
NS_ASSERTION(mCapacity-mSize>0, "no space in array");
|
||||
mPoints[mSize].x = x;
|
||||
mPoints[mSize].y = y;
|
||||
++mSize;
|
||||
}
|
||||
|
||||
const PointStack::PointData *PointStack::PopPoint()
|
||||
{
|
||||
if (mSize == 0) return &mOrigin;
|
||||
|
||||
return &mPoints[--mSize];
|
||||
}
|
||||
|
||||
void PointStack::Grow()
|
||||
{
|
||||
// nested subpaths are not very common, so we'll just grow linearly
|
||||
PointData *oldPoints = mPoints;
|
||||
mPoints = new PointData[++mCapacity];
|
||||
if (oldPoints) {
|
||||
memcpy(mPoints, oldPoints, sizeof(PointData) * mSize);
|
||||
delete[] oldPoints;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \addtogroup gdiplus_renderer GDI+ Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* GDI+ path builder implementation
|
||||
*/
|
||||
class nsSVGGDIPlusPathBuilder : public nsISVGRendererPathBuilder
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGGDIPlusPathBuilder(nsISVGRendererPathBuilder **result,
|
||||
nsISVGPathGeometrySource *src,
|
||||
GraphicsPath* dest);
|
||||
|
||||
nsSVGGDIPlusPathBuilder(nsISVGPathGeometrySource *src,
|
||||
GraphicsPath* dest);
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsISVGRendererPathBuilder interface:
|
||||
NS_DECL_NSISVGRENDERERPATHBUILDER
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsISVGPathGeometrySource> mSource;
|
||||
GraphicsPath *mPath;
|
||||
PointStack mSubPathStack;
|
||||
PointF mCurrentPoint;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// implementation:
|
||||
|
||||
nsSVGGDIPlusPathBuilder::nsSVGGDIPlusPathBuilder(nsISVGPathGeometrySource *src,
|
||||
GraphicsPath* dest)
|
||||
: mSource(src), mPath(dest)
|
||||
{
|
||||
PRUint16 fillrule;
|
||||
mSource->GetFillRule(&fillrule);
|
||||
mPath->SetFillMode(fillrule==nsISVGGeometrySource::FILL_RULE_NONZERO ?
|
||||
FillModeWinding : FillModeAlternate);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewSVGGDIPlusPathBuilder(nsISVGRendererPathBuilder **result,
|
||||
nsISVGPathGeometrySource *src,
|
||||
GraphicsPath* dest)
|
||||
{
|
||||
*result = new nsSVGGDIPlusPathBuilder(src, dest);
|
||||
if (!result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*result);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGGDIPlusPathBuilder)
|
||||
NS_IMPL_RELEASE(nsSVGGDIPlusPathBuilder)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGGDIPlusPathBuilder)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGRendererPathBuilder)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGRendererPathBuilder methods:
|
||||
|
||||
/** Implements void moveto(in float x, in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGGDIPlusPathBuilder::Moveto(float x, float y)
|
||||
{
|
||||
// mPath->CloseFigure();
|
||||
mPath->StartFigure();
|
||||
mCurrentPoint.X = x;
|
||||
mCurrentPoint.Y = y;
|
||||
mSubPathStack.PushPoint(x, y);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Implements void lineto(in float x, in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGGDIPlusPathBuilder::Lineto(float x, float y)
|
||||
{
|
||||
mPath->AddLine(mCurrentPoint.X, mCurrentPoint.Y, x, y);
|
||||
mCurrentPoint.X = x;
|
||||
mCurrentPoint.Y = y;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Implements void curveto(in float x, in float y, in float x1, in float y1, in float x2, in float y2); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGGDIPlusPathBuilder::Curveto(float x, float y, float x1, float y1, float x2, float y2)
|
||||
{
|
||||
mPath->AddBezier(mCurrentPoint.X, mCurrentPoint.Y, // startpoint
|
||||
x1, y1, x2, y2, // controlpoints
|
||||
x, y); // endpoint
|
||||
mCurrentPoint.X = x;
|
||||
mCurrentPoint.Y = y;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* helper for Arcto : */
|
||||
static inline double CalcVectorAngle(double ux, double uy, double vx, double vy)
|
||||
{
|
||||
double ta = atan2(uy, ux);
|
||||
double tb = atan2(vy, vx);
|
||||
if (tb >= ta)
|
||||
return tb-ta;
|
||||
return 6.28318530718 - (ta-tb);
|
||||
}
|
||||
|
||||
|
||||
/** Implements void arcto(in float x, in float y, in float r1, in float r2, in float angle, in boolean largeArcFlag, in boolean sweepFlag); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGGDIPlusPathBuilder::Arcto(float x2, float y2, float rx, float ry, float angle, PRBool largeArcFlag, PRBool sweepFlag)
|
||||
{
|
||||
const double pi = 3.14159265359;
|
||||
const double radPerDeg = pi/180.0;
|
||||
|
||||
float x1=mCurrentPoint.X, y1=mCurrentPoint.Y;
|
||||
|
||||
// 1. Treat out-of-range parameters as described in
|
||||
// http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
|
||||
|
||||
// If the endpoints (x1, y1) and (x2, y2) are identical, then this
|
||||
// is equivalent to omitting the elliptical arc segment entirely
|
||||
if (x1 == x2 && y1 == y2) return NS_OK;
|
||||
|
||||
// If rX = 0 or rY = 0 then this arc is treated as a straight line
|
||||
// segment (a "lineto") joining the endpoints.
|
||||
if (rx == 0.0f || ry == 0.0f) {
|
||||
return Lineto(x2, y2);
|
||||
}
|
||||
|
||||
// If rX or rY have negative signs, these are dropped; the absolute
|
||||
// value is used instead.
|
||||
if (rx<0.0) rx = -rx;
|
||||
if (ry<0.0) ry = -ry;
|
||||
|
||||
// 2. convert to center parameterization as shown in
|
||||
// http://www.w3.org/TR/SVG/implnote.html
|
||||
double sinPhi = sin(angle*radPerDeg);
|
||||
double cosPhi = cos(angle*radPerDeg);
|
||||
|
||||
double x1dash = cosPhi * (x1-x2)/2.0 + sinPhi * (y1-y2)/2.0;
|
||||
double y1dash = -sinPhi * (x1-x2)/2.0 + cosPhi * (y1-y2)/2.0;
|
||||
|
||||
double root;
|
||||
double numerator = rx*rx*ry*ry - rx*rx*y1dash*y1dash - ry*ry*x1dash*x1dash;
|
||||
|
||||
if (numerator < 0.0) {
|
||||
// If rX , rY and are such that there is no solution (basically,
|
||||
// the ellipse is not big enough to reach from (x1, y1) to (x2,
|
||||
// y2)) then the ellipse is scaled up uniformly until there is
|
||||
// exactly one solution (until the ellipse is just big enough).
|
||||
|
||||
// -> find factor s, such that numerator' with rx'=s*rx and
|
||||
// ry'=s*ry becomes 0 :
|
||||
float s = (float)sqrt(1.0 - numerator/(rx*rx*ry*ry));
|
||||
|
||||
rx *= s;
|
||||
ry *= s;
|
||||
root = 0.0;
|
||||
|
||||
}
|
||||
else {
|
||||
root = (largeArcFlag == sweepFlag ? -1.0 : 1.0) *
|
||||
sqrt( numerator/(rx*rx*y1dash*y1dash+ry*ry*x1dash*x1dash) );
|
||||
}
|
||||
|
||||
double cxdash = root*rx*y1dash/ry;
|
||||
double cydash = -root*ry*x1dash/rx;
|
||||
|
||||
double cx = cosPhi * cxdash - sinPhi * cydash + (x1+x2)/2.0;
|
||||
double cy = sinPhi * cxdash + cosPhi * cydash + (y1+y2)/2.0;
|
||||
double theta1 = CalcVectorAngle(1.0, 0.0, (x1dash-cxdash)/rx, (y1dash-cydash)/ry);
|
||||
double dtheta = CalcVectorAngle((x1dash-cxdash)/rx, (y1dash-cydash)/ry,
|
||||
(-x1dash-cxdash)/rx, (-y1dash-cydash)/ry);
|
||||
if (!sweepFlag && dtheta>0)
|
||||
dtheta -= 2.0*pi;
|
||||
else if (sweepFlag && dtheta<0)
|
||||
dtheta += 2.0*pi;
|
||||
|
||||
// 3. convert into cubic bezier segments <= 90deg
|
||||
int segments = (int)ceil(fabs(dtheta/(pi/2.0)));
|
||||
double delta = dtheta/segments;
|
||||
double t = 8.0/3.0 * sin(delta/4.0) * sin(delta/4.0) / sin(delta/2.0);
|
||||
|
||||
for (int i = 0; i < segments; ++i) {
|
||||
double cosTheta1 = cos(theta1);
|
||||
double sinTheta1 = sin(theta1);
|
||||
double theta2 = theta1 + delta;
|
||||
double cosTheta2 = cos(theta2);
|
||||
double sinTheta2 = sin(theta2);
|
||||
|
||||
// a) calculate endpoint of the segment:
|
||||
double xe = cosPhi * rx*cosTheta2 - sinPhi * ry*sinTheta2 + cx;
|
||||
double ye = sinPhi * rx*cosTheta2 + cosPhi * ry*sinTheta2 + cy;
|
||||
|
||||
// b) calculate gradients at start/end points of segment:
|
||||
double dx1 = t * ( - cosPhi * rx*sinTheta1 - sinPhi * ry*cosTheta1);
|
||||
double dy1 = t * ( - sinPhi * rx*sinTheta1 + cosPhi * ry*cosTheta1);
|
||||
|
||||
double dxe = t * ( cosPhi * rx*sinTheta2 + sinPhi * ry*cosTheta2);
|
||||
double dye = t * ( sinPhi * rx*sinTheta2 - cosPhi * ry*cosTheta2);
|
||||
|
||||
// c) draw the cubic bezier:
|
||||
Curveto((float)xe, (float)ye, (float)(x1+dx1), (float)(y1+dy1),
|
||||
(float)(xe+dxe), (float)(ye+dye));
|
||||
|
||||
// do next segment
|
||||
theta1 = theta2;
|
||||
x1 = (float)xe;
|
||||
y1 = (float)ye;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Implements void closePath(out float newX, out float newY); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGGDIPlusPathBuilder::ClosePath(float *newX, float *newY)
|
||||
{
|
||||
mPath->CloseFigure();
|
||||
const PointStack::PointData *point = mSubPathStack.PopPoint();
|
||||
|
||||
*newX = point->x;
|
||||
*newY = point->y;
|
||||
mCurrentPoint.X = point->x;
|
||||
mCurrentPoint.Y = point->y;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Implements void endPath(); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGGDIPlusPathBuilder::EndPath()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGGDIPLUS_PATHBUILDER_H__
|
||||
#define __NS_SVGGDIPLUS_PATHBUILDER_H__
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// unknwn.h is needed to build with WIN32_LEAN_AND_MEAN
|
||||
#include <unknwn.h>
|
||||
|
||||
#include <Gdiplus.h>
|
||||
using namespace Gdiplus;
|
||||
|
||||
class nsISVGRendererPathBuilder;
|
||||
class nsISVGPathGeometrySource;
|
||||
|
||||
nsresult NS_NewSVGGDIPlusPathBuilder(nsISVGRendererPathBuilder **result,
|
||||
nsISVGPathGeometrySource *src,
|
||||
GraphicsPath* dest);
|
||||
|
||||
#endif // __NS_SVGGDIPLUS_PATHBUILDER_H__
|
||||
@@ -0,0 +1,49 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGGDIPLUS_PATHGEOMETRY_H__
|
||||
#define __NS_SVGGDIPLUS_PATHGEOMETRY_H__
|
||||
|
||||
class nsISVGRendererPathGeometry;
|
||||
class nsISVGPathGeometrySource;
|
||||
|
||||
nsresult
|
||||
NS_NewSVGGDIPlusPathGeometry(nsISVGRendererPathGeometry **result,
|
||||
nsISVGPathGeometrySource *src);
|
||||
|
||||
#endif // __NS_SVGGDIPLUS_PATHGEOMETRY_H__
|
||||
77
mozilla/layout/svg/renderer/src/libart/libart-incs.h
Normal file
77
mozilla/layout/svg/renderer/src/libart/libart-incs.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2
|
||||
-*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __LIBART_INCS_H__
|
||||
#define __LIBART_INCS_H__
|
||||
|
||||
#define LIBART_COMPILATION
|
||||
|
||||
#include "art_misc.h"
|
||||
#include "art_vpath.h"
|
||||
#include "art_svp.h"
|
||||
#include "art_svp_vpath.h"
|
||||
#include "art_gray_svp.h"
|
||||
#include "art_rgb_svp.h"
|
||||
#include "art_svp_vpath_stroke.h"
|
||||
#include "art_svp_ops.h"
|
||||
#include "art_affine.h"
|
||||
#include "art_rgb_affine.h"
|
||||
#include "art_rgb_bitmap_affine.h"
|
||||
#include "art_rgb_rgba_affine.h"
|
||||
#include "art_alphagamma.h"
|
||||
#include "art_svp_point.h"
|
||||
#include "art_vpath_dash.h"
|
||||
#include "art_pathcode.h"
|
||||
#include "art_render.h"
|
||||
#include "art_render_mask.h"
|
||||
#include "art_render_gradient.h"
|
||||
#include "art_render_svp.h"
|
||||
#include "art_rgb.h"
|
||||
#include "art_uta.h"
|
||||
#include "art_uta_ops.h"
|
||||
#include "art_uta_rect.h"
|
||||
#include "art_uta_svp.h"
|
||||
#include "art_uta_vpath.h"
|
||||
#include "art_rect_uta.h"
|
||||
#include "art_svp_wind.h"
|
||||
#include "art_bpath.h"
|
||||
#include "art_vpath_bpath.h"
|
||||
#include "art_vpath_filters.h"
|
||||
|
||||
#endif //__LIBART_INCS_H__
|
||||
91
mozilla/layout/svg/renderer/src/libart/nsISVGLibartCanvas.h
Normal file
91
mozilla/layout/svg/renderer/src/libart/nsISVGLibartCanvas.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Alex Fritze.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex@croczilla.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_ISVGLIBART_CANVAS_H__
|
||||
#define __NS_ISVGLIBART_CANVAS_H__
|
||||
|
||||
#include "nsISVGRendererCanvas.h"
|
||||
#include "libart-incs.h"
|
||||
typedef PRUint32 nscolor;
|
||||
typedef ArtPixMaxDepth ArtColor[3];
|
||||
|
||||
// {6F963B6F-8D8E-4C8D-B4A1-FA87FB825973}
|
||||
#define NS_ISVGLIBARTCANVAS_IID \
|
||||
{ 0x6f963b6f, 0x8d8e, 0x4c8d, { 0xb4, 0xa1, 0xfa, 0x87, 0xfb, 0x82, 0x59, 0x73 } }
|
||||
|
||||
/**
|
||||
* \addtogroup libart_renderer Libart Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 'Private' rendering engine interface
|
||||
*/
|
||||
class nsISVGLibartCanvas : public nsISVGRendererCanvas
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ISVGLIBARTCANVAS_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Deprecated. Use NewRender(int x0, int y0, int x1, int y1).
|
||||
*/
|
||||
NS_IMETHOD_(ArtRender*) NewRender()=0;
|
||||
|
||||
/**
|
||||
* Construct a new render object for the given rect.
|
||||
*
|
||||
* @return New render object or 0 if the requested rect doesn't
|
||||
* overlap the dirty rect or if there is an error.
|
||||
*/
|
||||
NS_IMETHOD_(ArtRender*) NewRender(int x0, int y0, int x1, int y1)=0;
|
||||
|
||||
/**
|
||||
* Invoke the render object previously constructed with a call to
|
||||
* NewRender().
|
||||
*/
|
||||
NS_IMETHOD_(void) InvokeRender(ArtRender* render)=0;
|
||||
|
||||
/**
|
||||
* Convert an rgb value into a libart color value.
|
||||
*/
|
||||
NS_IMETHOD_(void) GetArtColor(nscolor rgb, ArtColor& artColor)=0;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif //__NS_ISVGLIBART_CANVAS_H__
|
||||
@@ -0,0 +1,71 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Leon Sha <leon.sha@sun.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_ISVGLIBART_GLYPHMETRICS_FT_H__
|
||||
#define __NS_ISVGLIBART_GLYPHMETRICS_FT_H__
|
||||
|
||||
#include "nsISVGRendererGlyphMetrics.h"
|
||||
#include "nsIFreeType2.h"
|
||||
|
||||
// {b74698f5-b016-4423-a742-d2a14e5d8c45}
|
||||
#define NS_ISVGLIBARTGLYPHMETRICSFT_IID \
|
||||
{ 0xb74698f5, 0xb016, 0x4423, { 0xa7, 0x42, 0xd2, 0xa1, 0x4e, 0x5d, 0x8c, 0x45 } }
|
||||
|
||||
/**
|
||||
* \addtogroup libart_renderer Libart Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 'Private' rendering engine interface
|
||||
*/
|
||||
class nsISVGLibartGlyphMetricsFT : public nsISVGRendererGlyphMetrics
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISVGLIBARTGLYPHMETRICSFT_IID)
|
||||
NS_IMETHOD_(FT_Face) GetFTFace() = 0;
|
||||
NS_IMETHOD_(float) GetPixelScale() = 0;
|
||||
NS_IMETHOD_(float) GetTwipsToPixels() = 0;
|
||||
NS_IMETHOD_(const FT_BBox*) GetBoundingBox() = 0;
|
||||
NS_IMETHOD_(PRUint32) GetGlyphCount() = 0;
|
||||
NS_IMETHOD_(FT_Glyph) GetGlyphAt(PRUint32 pos) = 0;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif // __NS_ISVGLIBART_GLYPHMETRICS_FT_H__
|
||||
71
mozilla/layout/svg/renderer/src/libart/nsISVGLibartRegion.h
Normal file
71
mozilla/layout/svg/renderer/src/libart/nsISVGLibartRegion.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_ISVGLIBART_REGION_H__
|
||||
#define __NS_ISVGLIBART_REGION_H__
|
||||
|
||||
#include "libart-incs.h"
|
||||
#include "nsISVGRendererRegion.h"
|
||||
|
||||
// {FB7271C1-54ED-418D-8FFF-EF0F64DF015F}
|
||||
#define NS_ISVGLIBARTREGION_IID \
|
||||
{ 0xfb7271c1, 0x54ed, 0x418d, { 0x8f, 0xff, 0xef, 0x0f, 0x64, 0xdf, 0x01, 0x5f } }
|
||||
|
||||
/**
|
||||
* \addtogroup libart_renderer Libart Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 'Private' rendering engine interface
|
||||
*/
|
||||
class nsISVGLibartRegion : public nsISVGRendererRegion
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISVGLIBARTREGION_IID)
|
||||
|
||||
/**
|
||||
* Get region as a libart microtile array.
|
||||
*/
|
||||
NS_IMETHOD_(ArtUta*) GetUta()=0;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
#endif //__NS_ISVGLIBART_REGION_H__
|
||||
170
mozilla/layout/svg/renderer/src/libart/nsSVGFill.cpp
Normal file
170
mozilla/layout/svg/renderer/src/libart/nsSVGFill.cpp
Normal file
@@ -0,0 +1,170 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
* Bradley Baetz <bbaetz@cs.mcgill.ca>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "nsSVGFill.h"
|
||||
#include "nsISVGPathGeometrySource.h"
|
||||
|
||||
// static helper functions
|
||||
|
||||
#define EPSILON 1e-6
|
||||
|
||||
static PRBool ContainsOpenPath(ArtVpath* src)
|
||||
{
|
||||
int pos;
|
||||
for(pos=0;src[pos].code != ART_END;++pos) {
|
||||
if (src[pos].code==ART_MOVETO_OPEN)
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Closes an open path, returning a new one
|
||||
static ArtVpath* CloseOpenPath(ArtVpath* src)
|
||||
{
|
||||
// We need to insert something extra for each open subpath
|
||||
// So we realloc stuff as needed
|
||||
int currSize = 0;
|
||||
int maxSize = 4;
|
||||
ArtVpath *ret = art_new(ArtVpath, maxSize);
|
||||
|
||||
PRBool isOpenSubpath = PR_FALSE;
|
||||
double startX=0;
|
||||
double startY=0;
|
||||
|
||||
int srcPos;
|
||||
for (srcPos=0;src[srcPos].code != ART_END;++srcPos) {
|
||||
if (currSize==maxSize)
|
||||
art_expand(ret, ArtVpath, maxSize);
|
||||
if (src[srcPos].code == ART_MOVETO_OPEN)
|
||||
ret[currSize].code = ART_MOVETO; // close it
|
||||
else
|
||||
ret[currSize].code = src[srcPos].code;
|
||||
ret[currSize].x = src[srcPos].x;
|
||||
ret[currSize].y = src[srcPos].y;
|
||||
++currSize;
|
||||
|
||||
// OK, it was open
|
||||
if (src[srcPos].code == ART_MOVETO_OPEN) {
|
||||
startX = src[srcPos].x;
|
||||
startY = src[srcPos].y;
|
||||
isOpenSubpath = PR_TRUE;
|
||||
} else if (src[srcPos+1].code != ART_LINETO) {
|
||||
if (isOpenSubpath &&
|
||||
((fabs(startX - src[srcPos].x) > EPSILON) ||
|
||||
(fabs(startY - src[srcPos].y) > EPSILON))) {
|
||||
// The next one isn't a line, so lets close this
|
||||
if (currSize == maxSize)
|
||||
art_expand(ret, ArtVpath, maxSize);
|
||||
ret[currSize].code = ART_LINETO;
|
||||
ret[currSize].x = startX;
|
||||
ret[currSize].y = startY;
|
||||
++currSize;
|
||||
}
|
||||
isOpenSubpath = PR_FALSE;
|
||||
}
|
||||
}
|
||||
if (currSize == maxSize)
|
||||
art_expand(ret, ArtVpath, maxSize);
|
||||
ret[currSize].code = ART_END;
|
||||
ret[currSize].x = 0;
|
||||
ret[currSize].y = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// nsSVGFill members
|
||||
|
||||
void
|
||||
nsSVGFill::Build(ArtVpath* path, nsISVGPathGeometrySource* source)
|
||||
{
|
||||
if (mSvp) {
|
||||
art_svp_free(mSvp);
|
||||
mSvp = nsnull;
|
||||
}
|
||||
|
||||
NS_ASSERTION(path, "null vpath");
|
||||
|
||||
// clip
|
||||
ArtVpathArrayIterator src_iter;
|
||||
// ArtVpathPolyRectClipFilter clip_filter;
|
||||
|
||||
art_vpath_array_iterator_init((ArtVpath*)path, &src_iter);
|
||||
// art_vpath_poly_rect_clip_filter_init((ArtVpathIterator*)&src_iter,
|
||||
// canvasSpecs->GetClipRect(),
|
||||
// &clip_filter);
|
||||
|
||||
// path = art_vpath_new_vpath_array((ArtVpathIterator*)&clip_filter);
|
||||
path = art_vpath_new_vpath_array((ArtVpathIterator*)&src_iter);
|
||||
|
||||
|
||||
if (ContainsOpenPath(path)) {
|
||||
ArtVpath* tmp_path = path;
|
||||
path = CloseOpenPath(tmp_path);
|
||||
art_free(tmp_path);
|
||||
}
|
||||
|
||||
ArtVpath* perturbedVP = art_vpath_perturb(path);
|
||||
art_free(path);
|
||||
|
||||
ArtSVP* svp = art_svp_from_vpath(perturbedVP);
|
||||
art_free(perturbedVP);
|
||||
|
||||
ArtSVP* uncrossedSVP = art_svp_uncross(svp);
|
||||
art_svp_free(svp);
|
||||
|
||||
PRUint16 fillrule;
|
||||
source->GetFillRule(&fillrule);
|
||||
ArtWindRule wind;
|
||||
switch (fillrule) {
|
||||
case nsISVGGeometrySource::FILL_RULE_NONZERO:
|
||||
wind = ART_WIND_RULE_NONZERO;
|
||||
break;
|
||||
case nsISVGGeometrySource::FILL_RULE_EVENODD:
|
||||
wind = ART_WIND_RULE_ODDEVEN;
|
||||
break;
|
||||
default:
|
||||
NS_ERROR("not reached");
|
||||
}
|
||||
|
||||
mSvp = art_svp_rewind_uncrossed (uncrossedSVP, wind);
|
||||
art_svp_free (uncrossedSVP);
|
||||
|
||||
}
|
||||
|
||||
60
mozilla/layout/svg/renderer/src/libart/nsSVGFill.h
Normal file
60
mozilla/layout/svg/renderer/src/libart/nsSVGFill.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGFILL_H__
|
||||
#define __NS_SVGFILL_H__
|
||||
|
||||
#include "nsSVGRenderItem.h"
|
||||
#include "libart-incs.h"
|
||||
|
||||
class nsISVGPathGeometrySource;
|
||||
|
||||
/**
|
||||
* \addtogroup libart_renderer Libart Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
|
||||
class nsSVGFill : public nsSVGRenderItem
|
||||
{
|
||||
public:
|
||||
void Build(ArtVpath* path, nsISVGPathGeometrySource* source);
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif // __NS_SVGFILL_H__
|
||||
@@ -0,0 +1,368 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISVGRendererPathBuilder.h"
|
||||
#include "nsSVGLibartBPathBuilder.h"
|
||||
#include <math.h>
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup libart_renderer Libart Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Libart path builder implementation
|
||||
*/
|
||||
class nsSVGLibartBPathBuilder : public nsISVGRendererPathBuilder
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGLibartBPathBuilder(nsISVGRendererPathBuilder **result,
|
||||
ArtBpath** dest);
|
||||
|
||||
nsSVGLibartBPathBuilder(ArtBpath** dest);
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsISVGRendererPathBuilder interface:
|
||||
NS_DECL_NSISVGRENDERERPATHBUILDER
|
||||
|
||||
private:
|
||||
// helpers
|
||||
void EnsureBPathSpace(PRUint32 space=1);
|
||||
void EnsureBPathTerminated();
|
||||
PRInt32 GetLastOpenBPath();
|
||||
|
||||
ArtBpath** mBPath;
|
||||
PRUint32 mBPathSize;
|
||||
PRUint32 mBPathEnd; // one-past-the-end
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// implementation:
|
||||
|
||||
nsSVGLibartBPathBuilder::nsSVGLibartBPathBuilder(ArtBpath** dest)
|
||||
: mBPath(dest),
|
||||
mBPathSize(0),
|
||||
mBPathEnd(0)
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewSVGLibartBPathBuilder(nsISVGRendererPathBuilder **result,
|
||||
ArtBpath** dest)
|
||||
{
|
||||
*result = new nsSVGLibartBPathBuilder(dest);
|
||||
if (!result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*result);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGLibartBPathBuilder)
|
||||
NS_IMPL_RELEASE(nsSVGLibartBPathBuilder)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGLibartBPathBuilder)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGRendererPathBuilder)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGRendererPathBuilder methods:
|
||||
|
||||
/** Implements void moveto(in float x, in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLibartBPathBuilder::Moveto(float x, float y)
|
||||
{
|
||||
EnsureBPathSpace();
|
||||
|
||||
(*mBPath)[mBPathEnd].code = ART_MOVETO_OPEN;
|
||||
(*mBPath)[mBPathEnd].x3 = x;
|
||||
(*mBPath)[mBPathEnd].y3 = y;
|
||||
|
||||
++mBPathEnd;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Implements void lineto(in float x, in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLibartBPathBuilder::Lineto(float x, float y)
|
||||
{
|
||||
EnsureBPathSpace();
|
||||
|
||||
(*mBPath)[mBPathEnd].code = ART_LINETO;
|
||||
(*mBPath)[mBPathEnd].x3 = x;
|
||||
(*mBPath)[mBPathEnd].y3 = y;
|
||||
|
||||
++mBPathEnd;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Implements void curveto(in float x, in float y, in float x1, in float y1, in float x2, in float y2); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLibartBPathBuilder::Curveto(float x, float y, float x1, float y1, float x2, float y2)
|
||||
{
|
||||
EnsureBPathSpace();
|
||||
|
||||
(*mBPath)[mBPathEnd].code = ART_CURVETO;
|
||||
(*mBPath)[mBPathEnd].x1 = x1;
|
||||
(*mBPath)[mBPathEnd].y1 = y1;
|
||||
(*mBPath)[mBPathEnd].x2 = x2;
|
||||
(*mBPath)[mBPathEnd].y2 = y2;
|
||||
(*mBPath)[mBPathEnd].x3 = x;
|
||||
(*mBPath)[mBPathEnd].y3 = y;
|
||||
|
||||
++mBPathEnd;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* helper for Arcto : */
|
||||
static inline double CalcVectorAngle(double ux, double uy, double vx, double vy)
|
||||
{
|
||||
double ta = atan2(uy, ux);
|
||||
double tb = atan2(vy, vx);
|
||||
if (tb >= ta)
|
||||
return tb-ta;
|
||||
return 6.28318530718 - (ta-tb);
|
||||
}
|
||||
|
||||
|
||||
/** Implements void arcto(in float x, in float y, in float r1, in float r2, in float angle, in boolean largeArcFlag, in boolean sweepFlag); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLibartBPathBuilder::Arcto(float x2, float y2, float rx, float ry, float angle, PRBool largeArcFlag, PRBool sweepFlag)
|
||||
{
|
||||
const double pi = 3.14159265359;
|
||||
const double radPerDeg = pi/180.0;
|
||||
|
||||
float x1=0.0f, y1=0.0f;
|
||||
NS_ASSERTION(mBPathEnd > 0, "Arcto needs a start position");
|
||||
if (mBPathEnd > 0) {
|
||||
x1 = (float)((*mBPath)[mBPathEnd-1].x3);
|
||||
y1 = (float)((*mBPath)[mBPathEnd-1].y3);
|
||||
}
|
||||
|
||||
// 1. Treat out-of-range parameters as described in
|
||||
// http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
|
||||
|
||||
// If the endpoints (x1, y1) and (x2, y2) are identical, then this
|
||||
// is equivalent to omitting the elliptical arc segment entirely
|
||||
if (x1 == x2 && y1 == y2) return NS_OK;
|
||||
|
||||
// If rX = 0 or rY = 0 then this arc is treated as a straight line
|
||||
// segment (a "lineto") joining the endpoints.
|
||||
if (rx == 0.0f || ry == 0.0f) {
|
||||
Lineto(x2, y2);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If rX or rY have negative signs, these are dropped; the absolute
|
||||
// value is used instead.
|
||||
if (rx<0.0) rx = -rx;
|
||||
if (ry<0.0) ry = -ry;
|
||||
|
||||
// 2. convert to center parameterization as shown in
|
||||
// http://www.w3.org/TR/SVG/implnote.html
|
||||
double sinPhi = sin(angle*radPerDeg);
|
||||
double cosPhi = cos(angle*radPerDeg);
|
||||
|
||||
double x1dash = cosPhi * (x1-x2)/2.0 + sinPhi * (y1-y2)/2.0;
|
||||
double y1dash = -sinPhi * (x1-x2)/2.0 + cosPhi * (y1-y2)/2.0;
|
||||
|
||||
double root;
|
||||
double numerator = rx*rx*ry*ry - rx*rx*y1dash*y1dash - ry*ry*x1dash*x1dash;
|
||||
|
||||
if (numerator < 0.0) {
|
||||
// If rX , rY and are such that there is no solution (basically,
|
||||
// the ellipse is not big enough to reach from (x1, y1) to (x2,
|
||||
// y2)) then the ellipse is scaled up uniformly until there is
|
||||
// exactly one solution (until the ellipse is just big enough).
|
||||
|
||||
// -> find factor s, such that numerator' with rx'=s*rx and
|
||||
// ry'=s*ry becomes 0 :
|
||||
float s = (float)sqrt(1.0 - numerator/(rx*rx*ry*ry));
|
||||
|
||||
rx *= s;
|
||||
ry *= s;
|
||||
root = 0.0;
|
||||
|
||||
}
|
||||
else {
|
||||
root = (largeArcFlag == sweepFlag ? -1.0 : 1.0) *
|
||||
sqrt( numerator/(rx*rx*y1dash*y1dash+ry*ry*x1dash*x1dash) );
|
||||
}
|
||||
|
||||
double cxdash = root*rx*y1dash/ry;
|
||||
double cydash = -root*ry*x1dash/rx;
|
||||
|
||||
double cx = cosPhi * cxdash - sinPhi * cydash + (x1+x2)/2.0;
|
||||
double cy = sinPhi * cxdash + cosPhi * cydash + (y1+y2)/2.0;
|
||||
double theta1 = CalcVectorAngle(1.0, 0.0, (x1dash-cxdash)/rx, (y1dash-cydash)/ry);
|
||||
double dtheta = CalcVectorAngle((x1dash-cxdash)/rx, (y1dash-cydash)/ry,
|
||||
(-x1dash-cxdash)/rx, (-y1dash-cydash)/ry);
|
||||
if (!sweepFlag && dtheta>0)
|
||||
dtheta -= 2.0*pi;
|
||||
else if (sweepFlag && dtheta<0)
|
||||
dtheta += 2.0*pi;
|
||||
|
||||
// 3. convert into cubic bezier segments <= 90deg
|
||||
int segments = (int)ceil(fabs(dtheta/(pi/2.0)));
|
||||
double delta = dtheta/segments;
|
||||
double t = 8.0/3.0 * sin(delta/4.0) * sin(delta/4.0) / sin(delta/2.0);
|
||||
|
||||
for (int i = 0; i < segments; ++i) {
|
||||
double cosTheta1 = cos(theta1);
|
||||
double sinTheta1 = sin(theta1);
|
||||
double theta2 = theta1 + delta;
|
||||
double cosTheta2 = cos(theta2);
|
||||
double sinTheta2 = sin(theta2);
|
||||
|
||||
// a) calculate endpoint of the segment:
|
||||
double xe = cosPhi * rx*cosTheta2 - sinPhi * ry*sinTheta2 + cx;
|
||||
double ye = sinPhi * rx*cosTheta2 + cosPhi * ry*sinTheta2 + cy;
|
||||
|
||||
// b) calculate gradients at start/end points of segment:
|
||||
double dx1 = t * ( - cosPhi * rx*sinTheta1 - sinPhi * ry*cosTheta1);
|
||||
double dy1 = t * ( - sinPhi * rx*sinTheta1 + cosPhi * ry*cosTheta1);
|
||||
|
||||
double dxe = t * ( cosPhi * rx*sinTheta2 + sinPhi * ry*cosTheta2);
|
||||
double dye = t * ( sinPhi * rx*sinTheta2 - cosPhi * ry*cosTheta2);
|
||||
|
||||
// c) draw the cubic bezier:
|
||||
Curveto((float)xe, (float)ye, (float)(x1+dx1), (float)(y1+dy1),
|
||||
(float)(xe+dxe), (float)(ye+dye));
|
||||
|
||||
// do next segment
|
||||
theta1 = theta2;
|
||||
x1 = (float)xe;
|
||||
y1 = (float)ye;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Implements void closePath(out float newX, out float newY); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLibartBPathBuilder::ClosePath(float *newX, float *newY)
|
||||
{
|
||||
PRInt32 subpath = GetLastOpenBPath();
|
||||
NS_ASSERTION(subpath>=0, "no open subpath");
|
||||
if (subpath<0) return NS_OK;
|
||||
|
||||
// insert closing line if needed:
|
||||
if ((*mBPath)[subpath].x3 != (*mBPath)[mBPathEnd-1].x3 ||
|
||||
(*mBPath)[subpath].y3 != (*mBPath)[mBPathEnd-1].y3) {
|
||||
Lineto((float)(*mBPath)[subpath].x3, (float)(*mBPath)[subpath].y3);
|
||||
}
|
||||
|
||||
(*mBPath)[subpath].code = ART_MOVETO;
|
||||
|
||||
*newX = (float)((*mBPath)[subpath].x3);
|
||||
*newY = (float)((*mBPath)[subpath].y3);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Implements void endPath(); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLibartBPathBuilder::EndPath()
|
||||
{
|
||||
EnsureBPathTerminated();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// helpers
|
||||
|
||||
void
|
||||
nsSVGLibartBPathBuilder::EnsureBPathSpace(PRUint32 space)
|
||||
{
|
||||
const PRInt32 minGrowSize = 10;
|
||||
|
||||
if (mBPathSize - mBPathEnd >= space)
|
||||
return;
|
||||
|
||||
if (space < minGrowSize)
|
||||
space = minGrowSize;
|
||||
|
||||
mBPathSize += space;
|
||||
|
||||
if (!*mBPath) {
|
||||
*mBPath = art_new(ArtBpath, mBPathSize);
|
||||
}
|
||||
else {
|
||||
*mBPath = art_renew(*mBPath, ArtBpath, mBPathSize);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGLibartBPathBuilder::EnsureBPathTerminated()
|
||||
{
|
||||
NS_ASSERTION (*mBPath, "no bpath");
|
||||
NS_ASSERTION (mBPathEnd>0, "trying to terminate empty bpath");
|
||||
|
||||
if (mBPathEnd>0 && (*mBPath)[mBPathEnd-1].code == ART_END) return;
|
||||
|
||||
EnsureBPathSpace(1);
|
||||
(*mBPath)[mBPathEnd++].code = ART_END;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsSVGLibartBPathBuilder::GetLastOpenBPath()
|
||||
{
|
||||
if (!*mBPath) return -1;
|
||||
|
||||
PRInt32 i = mBPathEnd;
|
||||
while (--i >= 0) {
|
||||
if ((*mBPath)[i].code == ART_MOVETO_OPEN)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Alex Fritze.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex@croczilla.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGLIBART_BPATHBUILDER_H__
|
||||
#define __NS_SVGLIBART_BPATHBUILDER_H__
|
||||
|
||||
#include "libart-incs.h"
|
||||
class nsISVGRendererPathBuilder;
|
||||
|
||||
nsresult NS_NewSVGLibartBPathBuilder(nsISVGRendererPathBuilder **result,
|
||||
ArtBpath** dest);
|
||||
|
||||
#endif // __NS_SVGLIBART_BPATHBUILDER_H__
|
||||
@@ -0,0 +1,98 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSVGLibartFreetype.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsArray.h"
|
||||
#include "nsString.h"
|
||||
|
||||
nsCOMPtr<nsIFreeType2> nsSVGLibartFreetype::ft2;
|
||||
nsCOMPtr<nsIFontCatalogService> nsSVGLibartFreetype::fontCatalog;
|
||||
|
||||
PRBool nsSVGLibartFreetype::Init()
|
||||
{
|
||||
NS_ASSERTION(!ft2, "ft2 already initialized");
|
||||
ft2 = do_GetService(NS_FREETYPE2_CONTRACTID);
|
||||
if (!ft2) return PR_FALSE;
|
||||
|
||||
fontCatalog = do_GetService("@mozilla.org/gfx/xfontcatalogservice;1");
|
||||
if (!fontCatalog) {
|
||||
NS_ERROR("Font catalog initialization failure");
|
||||
ft2 = nsnull;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void nsSVGLibartFreetype::Shutdown()
|
||||
{
|
||||
NS_ASSERTION(ft2, "ft2 never initialized");
|
||||
ft2 = nsnull;
|
||||
fontCatalog = nsnull;
|
||||
}
|
||||
|
||||
PRBool nsSVGLibartFreetype::HasSuitableFonts()
|
||||
{
|
||||
NS_ASSERTION(fontCatalog, "freetype not initialized");
|
||||
|
||||
nsCOMPtr<nsIArray> arr;
|
||||
nsCAutoString empty;
|
||||
fontCatalog->GetFontCatalogEntries(empty, empty,
|
||||
nsIFontCatalogService::kFCWeightAny,
|
||||
nsIFontCatalogService::kFCWidthAny,
|
||||
nsIFontCatalogService::kFCSlantAny,
|
||||
nsIFontCatalogService::kFCSpacingAny,
|
||||
getter_AddRefs(arr));
|
||||
PRUint32 count;
|
||||
arr->GetLength(&count);
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Freetype Families available:\n");
|
||||
for (PRUint32 i=0;i<count;++i) {
|
||||
nsCOMPtr<nsITrueTypeFontCatalogEntry> font = do_QueryElementAt(arr, i);
|
||||
nsCAutoString family, style, vendor;
|
||||
font->GetFamilyName(family);
|
||||
font->GetStyleName(style);
|
||||
font->GetVendorID(vendor);
|
||||
printf("* %s, %s, %s\n", family.get(), style.get(), vendor.get());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return (count!=0);
|
||||
}
|
||||
75
mozilla/layout/svg/renderer/src/libart/nsSVGLibartFreetype.h
Normal file
75
mozilla/layout/svg/renderer/src/libart/nsSVGLibartFreetype.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGLIBART_FREETYPE_H__
|
||||
#define __NS_SVGLIBART_FREETYPE_H__
|
||||
|
||||
#include "nsIFreeType2.h"
|
||||
#include "nsIFontCatalogService.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
namespace nsSVGLibartFreetype {
|
||||
/**
|
||||
* Initializes global ft2 and fontcatalog instances.
|
||||
*
|
||||
* @return PR_TRUE if the initialization succeeded, PR_FALSE otherwise.
|
||||
*/
|
||||
PRBool Init();
|
||||
|
||||
/**
|
||||
* Releases global ft2 and fontcatalog instances.
|
||||
*/
|
||||
void Shutdown();
|
||||
|
||||
/**
|
||||
* @return PR_TRUE if there are suitable fonts on the system, PR_FALSE otherwise
|
||||
*/
|
||||
PRBool HasSuitableFonts();
|
||||
|
||||
/**
|
||||
* Global freetype2 instance.
|
||||
*/
|
||||
extern nsCOMPtr<nsIFreeType2> ft2;
|
||||
|
||||
/**
|
||||
* Global fontcatalog instance.
|
||||
*/
|
||||
extern nsCOMPtr<nsIFontCatalogService> fontCatalog;
|
||||
}
|
||||
|
||||
#endif // __NS_SVGLIBART_FREETYPE_H__
|
||||
@@ -0,0 +1,49 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGLIBART_GLYPHGEOMETRYDEFAULT_H__
|
||||
#define __NS_SVGLIBART_GLYPHGEOMETRYDEFAULT_H__
|
||||
|
||||
class nsISVGRendererGlyphGeometry;
|
||||
class nsISVGGlyphGeometrySource;
|
||||
|
||||
nsresult
|
||||
NS_NewSVGLibartGlyphGeometryDefault(nsISVGRendererGlyphGeometry **result,
|
||||
nsISVGGlyphGeometrySource *src);
|
||||
|
||||
#endif // __NS_SVGLIBART_GLYPHGEOMETRYDEFAULT_H__
|
||||
@@ -0,0 +1,49 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGLIBART_GLYPHGEOMETRYFT_H__
|
||||
#define __NS_SVGLIBART_GLYPHGEOMETRYFT_H__
|
||||
|
||||
class nsISVGRendererGlyphGeometry;
|
||||
class nsISVGGlyphGeometrySource;
|
||||
|
||||
nsresult
|
||||
NS_NewSVGLibartGlyphGeometryFT(nsISVGRendererGlyphGeometry **result,
|
||||
nsISVGGlyphGeometrySource *src);
|
||||
|
||||
#endif // __NS_SVGLIBART_GLYPHGEOMETRYFT_H__
|
||||
@@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGLIBART_GLYPHMETRICSDEFAULT_H__
|
||||
#define __NS_SVGLIBART_GLYPHMETRICSDEFAULT_H__
|
||||
|
||||
class nsISVGRendererGlyphMetrics;
|
||||
class nsISVGGlyphMetricsSource;
|
||||
|
||||
nsresult NS_NewSVGLibartGlyphMetricsDefault(nsISVGRendererGlyphMetrics **result,
|
||||
nsISVGGlyphMetricsSource *src);
|
||||
|
||||
#endif // __NS_SVGLIBART_GLYPHMETRICSDEFAULT_H__
|
||||
@@ -0,0 +1,50 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGLIBART_GLYPHMETRICSFT_H__
|
||||
#define __NS_SVGLIBART_GLYPHMETRICSFT_H__
|
||||
|
||||
class nsISVGRendererGlyphMetrics;
|
||||
class nsISVGGlyphMetricsSource;
|
||||
|
||||
nsresult NS_NewSVGLibartGlyphMetricsFT(nsISVGRendererGlyphMetrics **result,
|
||||
nsISVGGlyphMetricsSource *src);
|
||||
void NS_InitSVGLibartGlyphMetricsFTGlobals();
|
||||
void NS_FreeSVGLibartGlyphMetricsFTGlobals();
|
||||
|
||||
#endif // __NS_SVGLIBART_GLYPHMETRICSFT_H__
|
||||
@@ -0,0 +1,49 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Alex Fritze.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex@croczilla.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGLIBART_PATHGEOMETRY_H__
|
||||
#define __NS_SVGLIBART_PATHGEOMETRY_H__
|
||||
|
||||
class nsISVGRendererPathGeometry;
|
||||
class nsISVGPathGeometrySource;
|
||||
|
||||
nsresult
|
||||
NS_NewSVGLibartPathGeometry(nsISVGRendererPathGeometry **result,
|
||||
nsISVGPathGeometrySource *src);
|
||||
|
||||
#endif // __NS_SVGLIBART_PATHGEOMETRY_H__
|
||||
227
mozilla/layout/svg/renderer/src/libart/nsSVGLibartRegion.cpp
Normal file
227
mozilla/layout/svg/renderer/src/libart/nsSVGLibartRegion.cpp
Normal file
@@ -0,0 +1,227 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISVGLibartRegion.h"
|
||||
#include "nsSVGLibartRegion.h"
|
||||
#include "nsISVGRectangleSink.h"
|
||||
#include <math.h>
|
||||
|
||||
/**
|
||||
* \addtogroup libart_renderer Libart Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Libart region implementation
|
||||
*/
|
||||
class nsSVGLibartRegion : public nsISVGLibartRegion // : nsISVGRendererRegion
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGLibartRectRegion(nsISVGRendererRegion** result,
|
||||
float x, float y,
|
||||
float width, float height);
|
||||
friend nsresult NS_NewSVGLibartSVPRegion(nsISVGRendererRegion** result,
|
||||
ArtSVP *path);
|
||||
nsSVGLibartRegion(ArtIRect *rect);
|
||||
nsSVGLibartRegion(ArtSVP* path);
|
||||
nsSVGLibartRegion(ArtUta* uta); // takes ownership
|
||||
|
||||
~nsSVGLibartRegion();
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsISVGLibartRegion interface:
|
||||
NS_IMETHOD_(ArtUta*) GetUta();
|
||||
|
||||
// nsISVGRendererRegion interface:
|
||||
NS_DECL_NSISVGRENDERERREGION
|
||||
|
||||
private:
|
||||
ArtUta* mUta;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// implementation:
|
||||
|
||||
nsSVGLibartRegion::nsSVGLibartRegion(ArtIRect *rect)
|
||||
{
|
||||
mUta = art_uta_from_irect(rect);
|
||||
}
|
||||
|
||||
nsSVGLibartRegion::nsSVGLibartRegion(ArtSVP* path)
|
||||
{
|
||||
mUta = path ? art_uta_from_svp(path) : nsnull;
|
||||
}
|
||||
|
||||
nsSVGLibartRegion::nsSVGLibartRegion(ArtUta* uta)
|
||||
: mUta(uta)
|
||||
{
|
||||
}
|
||||
|
||||
nsSVGLibartRegion::~nsSVGLibartRegion()
|
||||
{
|
||||
if (mUta)
|
||||
art_uta_free(mUta);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewSVGLibartRectRegion(nsISVGRendererRegion** result,
|
||||
float x, float y,
|
||||
float width, float height)
|
||||
{
|
||||
if (width<=0.0f || height<=0.0f) {
|
||||
*result = new nsSVGLibartRegion((ArtUta*)nsnull);
|
||||
}
|
||||
else {
|
||||
ArtIRect irect;
|
||||
irect.x0 = (int)x; // floor(x)
|
||||
irect.y0 = (int)y; // floor(y)
|
||||
irect.x1 = (int)ceil(x+width);
|
||||
irect.y1 = (int)ceil(y+height);
|
||||
NS_ASSERTION(irect.x0!=irect.x1 && irect.y0!=irect.y1, "empty region");
|
||||
*result = new nsSVGLibartRegion(&irect);
|
||||
}
|
||||
|
||||
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewSVGLibartSVPRegion(nsISVGRendererRegion** result,
|
||||
ArtSVP* path)
|
||||
{
|
||||
*result = new nsSVGLibartRegion(path);
|
||||
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGLibartRegion)
|
||||
NS_IMPL_RELEASE(nsSVGLibartRegion)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGLibartRegion)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGLibartRegion)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGRendererRegion)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGLibartRegion interface:
|
||||
|
||||
NS_IMETHODIMP_(ArtUta*)
|
||||
nsSVGLibartRegion::GetUta()
|
||||
{
|
||||
return mUta;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGRendererRegion methods:
|
||||
|
||||
/** Implements nsISVGRendererRegion combine(in nsISVGRendererRegion other); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLibartRegion::Combine(nsISVGRendererRegion *other,
|
||||
nsISVGRendererRegion **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
nsCOMPtr<nsISVGLibartRegion> other2 = do_QueryInterface(other);
|
||||
if (!other2) {
|
||||
NS_WARNING("Union operation on incompatible regions");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsISVGLibartRegion *regions[2];
|
||||
int count = 0;
|
||||
|
||||
if (mUta)
|
||||
regions[count++]=this;
|
||||
|
||||
if (other2->GetUta())
|
||||
regions[count++]=other2;
|
||||
|
||||
switch (count) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
*_retval = regions[0];
|
||||
NS_ADDREF(*_retval);
|
||||
break;
|
||||
case 2:
|
||||
*_retval = new nsSVGLibartRegion(art_uta_union(regions[0]->GetUta(),
|
||||
regions[1]->GetUta()));
|
||||
NS_IF_ADDREF(*_retval);
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Implements void getRectangleScans(in nsISVGRectangleSink sink); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLibartRegion::GetRectangleScans(nsISVGRectangleSink *sink)
|
||||
{
|
||||
if (!mUta) return NS_OK;
|
||||
|
||||
int nRects=0;
|
||||
ArtIRect* rectList = art_rect_list_from_uta(mUta, 200, 200, &nRects);
|
||||
for (int i=0; i<nRects; ++i) {
|
||||
int x,y,w,h;
|
||||
x = PR_MIN(rectList[i].x0,rectList[i].x1)-2;
|
||||
y = PR_MIN(rectList[i].y0,rectList[i].y1)-2;
|
||||
w = PR_ABS(rectList[i].x0-rectList[i].x1)+4;
|
||||
h = PR_ABS(rectList[i].y0-rectList[i].y1)+4;
|
||||
|
||||
sink->SinkRectangle(x,y,w,h);
|
||||
}
|
||||
|
||||
art_free(rectList);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
73
mozilla/layout/svg/renderer/src/libart/nsSVGRenderItem.cpp
Normal file
73
mozilla/layout/svg/renderer/src/libart/nsSVGRenderItem.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSVGRenderItem.h"
|
||||
|
||||
nsSVGRenderItem::nsSVGRenderItem()
|
||||
: mSvp(nsnull)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsSVGRenderItem::~nsSVGRenderItem()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void nsSVGRenderItem::Clear()
|
||||
{
|
||||
if (mSvp)
|
||||
art_svp_free(mSvp);
|
||||
mSvp = nsnull;
|
||||
}
|
||||
|
||||
ArtUta*
|
||||
nsSVGRenderItem::GetUta()
|
||||
{
|
||||
if (!mSvp) return nsnull;
|
||||
return art_uta_from_svp(mSvp);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsSVGRenderItem::Contains(float x, float y)
|
||||
{
|
||||
if (!mSvp) return PR_FALSE;
|
||||
return (art_svp_point_wind(GetSvp(), x, y) != 0);
|
||||
}
|
||||
|
||||
|
||||
73
mozilla/layout/svg/renderer/src/libart/nsSVGRenderItem.h
Normal file
73
mozilla/layout/svg/renderer/src/libart/nsSVGRenderItem.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGRENDERITEM_H__
|
||||
#define __NS_SVGRENDERITEM_H__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "libart-incs.h"
|
||||
|
||||
/**
|
||||
* \addtogroup libart_renderer Libart Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Wraps a libart sorted vector path.
|
||||
*/
|
||||
class nsSVGRenderItem
|
||||
{
|
||||
public:
|
||||
nsSVGRenderItem();
|
||||
virtual ~nsSVGRenderItem();
|
||||
|
||||
void Clear();
|
||||
|
||||
ArtSVP* GetSvp() { return mSvp; }
|
||||
ArtUta* GetUta(); // calculates micro-tile array
|
||||
|
||||
PRBool IsEmpty() { return (mSvp == nsnull); }
|
||||
|
||||
PRBool Contains(float x, float y);
|
||||
|
||||
protected:
|
||||
ArtSVP* mSvp;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif // __NS_SVGRENDERITEM_H__
|
||||
59
mozilla/layout/svg/renderer/src/libart/nsSVGStroke.h
Normal file
59
mozilla/layout/svg/renderer/src/libart/nsSVGStroke.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __NS_SVGSTROKE_H__
|
||||
#define __NS_SVGSTROKE_H__
|
||||
|
||||
#include "nsSVGRenderItem.h"
|
||||
#include "libart-incs.h"
|
||||
|
||||
class nsISVGPathGeometrySource;
|
||||
|
||||
/**
|
||||
* \addtogroup libart_renderer Libart Rendering Engine
|
||||
* @{
|
||||
*/
|
||||
class nsSVGStroke : public nsSVGRenderItem
|
||||
{
|
||||
public:
|
||||
void Build(ArtVpath* path, nsISVGPathGeometrySource* source);
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif // __NS_SVGSTROKE_H__
|
||||
Reference in New Issue
Block a user