Merge mozilla-central to mozilla-inbound

This commit is contained in:
Ed Morley 2012-06-06 10:24:28 +01:00
Родитель 8c6547e87a 31ad3140c9
Коммит fbe10d4921
91 изменённых файлов: 1144 добавлений и 4647 удалений

Просмотреть файл

@ -92,8 +92,8 @@ class Element;
} // namespace mozilla
#define NS_IDOCUMENT_IID \
{ 0x7bac702d, 0xca67, 0x4ce1, \
{ 0x80, 0x3c, 0x35, 0xde, 0x81, 0x26, 0x04, 0x97 } }
{ 0x077dcff0, 0x400d, 0x4d3c, \
{ 0xbd, 0x4d, 0x5f, 0xd5, 0xe1, 0xa6, 0x63, 0x07 } }
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
@ -501,10 +501,15 @@ public:
*/
virtual Element* FindContentForSubDocument(nsIDocument* aDocument) const = 0;
/**
* Return the doctype for this document.
*/
nsIContent* GetDocumentType() const;
/**
* Return the root element for this document.
*/
Element *GetRootElement() const;
Element* GetRootElement() const;
protected:
virtual Element *GetRootElementInternal() const = 0;

Просмотреть файл

@ -34,6 +34,13 @@ EXPORTS = \
nsTextFragment.h \
mozAutoDocUpdate.h \
nsFrameMessageManager.h \
nsAttrAndChildArray.h \
nsAttrValue.h \
nsCrossSiteListenerProxy.h \
nsDOMAttributeMap.h \
nsGenericElement.h \
nsMappedAttributeElement.h \
nsStyledElement.h \
$(NULL)
EXPORTS_NAMESPACES = mozilla/dom

Просмотреть файл

@ -68,6 +68,7 @@
#include "nsGenericHTMLElement.h"
#include "nsHTMLDNSPrefetch.h"
#include "nsISupportsPrimitives.h"
#include "nsIObserverService.h"
#include "mozilla/Preferences.h"
#include "nsParserConstants.h"

Просмотреть файл

@ -14,7 +14,6 @@
#include "nsString.h"
#include "nsRefPtrHashtable.h"
#include "nsCycleCollectionParticipant.h"
#include "prbit.h"
#include "nsIDOMNode.h"
class nsIAtom;

Просмотреть файл

@ -4295,22 +4295,25 @@ nsDocument::StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
//
// nsIDOMDocument interface
//
nsIContent*
nsIDocument::GetDocumentType() const
{
for (nsIContent* child = GetFirstChild();
child;
child = child->GetNextSibling()) {
if (child->NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE) {
return child;
}
}
return NULL;
}
NS_IMETHODIMP
nsDocument::GetDoctype(nsIDOMDocumentType** aDoctype)
{
NS_ENSURE_ARG_POINTER(aDoctype);
*aDoctype = nsnull;
PRInt32 i, count;
count = mChildren.ChildCount();
for (i = 0; i < count; i++) {
CallQueryInterface(mChildren.ChildAt(i), aDoctype);
if (*aDoctype) {
return NS_OK;
}
}
MOZ_ASSERT(aDoctype);
nsCOMPtr<nsIDOMDocumentType> doctype = do_QueryInterface(GetDocumentType());
doctype.forget(aDoctype);
return NS_OK;
}

Просмотреть файл

@ -159,7 +159,7 @@ nsFrameMessageManager::RemoveDelayedFrameScript(const nsAString& aURL)
}
static JSBool
JSONCreator(const jschar* aBuf, uint32 aLen, void* aData)
JSONCreator(const jschar* aBuf, uint32_t aLen, void* aData)
{
nsAString* result = static_cast<nsAString*>(aData);
result->Append(static_cast<const PRUnichar*>(aBuf),
@ -779,7 +779,7 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
mGlobal->GetJSObject(&global);
JSAutoEnterCompartment ac;
if (global && ac.enter(mCx, global)) {
uint32 oldopts = JS_GetOptions(mCx);
uint32_t oldopts = JS_GetOptions(mCx);
JS_SetOptions(mCx, oldopts | JSOPTION_NO_SCRIPT_RVAL);
JSScript* script =

Просмотреть файл

@ -3960,25 +3960,24 @@ nsGenericElement::SaveSubtreeState()
// latter case it may be null.
static
bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
bool aIsReplace, nsINode* aRefChild)
bool aIsReplace, nsINode* aRefChild)
{
NS_PRECONDITION(aNewChild, "Must have new child");
NS_PRECONDITION(!aIsReplace || aRefChild,
"Must have ref content for replace");
NS_PRECONDITION(aParent->IsNodeOfType(nsINode::eDOCUMENT) ||
aParent->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT) ||
aParent->IsElement(),
"Nodes that are not documents, document fragments or "
"elements can't be parents!");
MOZ_ASSERT(aNewChild, "Must have new child");
MOZ_ASSERT_IF(aIsReplace, aRefChild);
MOZ_ASSERT(aParent);
MOZ_ASSERT(aParent->IsNodeOfType(nsINode::eDOCUMENT) ||
aParent->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT) ||
aParent->IsElement(),
"Nodes that are not documents, document fragments or elements "
"can't be parents!");
// A common case is that aNewChild has no kids, in which case
// aParent can't be a descendant of aNewChild unless they're
// actually equal to each other. Fast-path that case, since aParent
// could be pretty deep in the DOM tree.
if (aParent &&
(aNewChild == aParent ||
(aNewChild->GetFirstChild() &&
nsContentUtils::ContentIsDescendantOf(aParent, aNewChild)))) {
if (aNewChild == aParent ||
(aNewChild->GetFirstChild() &&
nsContentUtils::ContentIsDescendantOf(aParent, aNewChild))) {
return false;
}
@ -3991,8 +3990,8 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
case nsIDOMNode::TEXT_NODE :
case nsIDOMNode::CDATA_SECTION_NODE :
case nsIDOMNode::ENTITY_REFERENCE_NODE :
// Only allowed under elements
return aParent != nsnull;
// Allowed under Elements and DocumentFragments
return aParent->NodeType() != nsIDOMNode::DOCUMENT_NODE;
case nsIDOMNode::ELEMENT_NODE :
{
if (!aParent->IsNodeOfType(nsINode::eDOCUMENT)) {
@ -4000,8 +3999,8 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
return true;
}
Element* rootElement =
static_cast<nsIDocument*>(aParent)->GetRootElement();
nsIDocument* parentDocument = static_cast<nsIDocument*>(aParent);
Element* rootElement = parentDocument->GetRootElement();
if (rootElement) {
// Already have a documentElement, so this is only OK if we're
// replacing it.
@ -4015,13 +4014,7 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
return true;
}
// Now grovel for a doctype
nsCOMPtr<nsIDOMDocument> doc = do_QueryInterface(aParent);
NS_ASSERTION(doc, "Shouldn't happen");
nsCOMPtr<nsIDOMDocumentType> docType;
doc->GetDoctype(getter_AddRefs(docType));
nsCOMPtr<nsIContent> docTypeContent = do_QueryInterface(docType);
nsIContent* docTypeContent = parentDocument->GetDocumentType();
if (!docTypeContent) {
// It's all good.
return true;
@ -4043,11 +4036,8 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
return false;
}
nsCOMPtr<nsIDOMDocument> doc = do_QueryInterface(aParent);
NS_ASSERTION(doc, "Shouldn't happen");
nsCOMPtr<nsIDOMDocumentType> docType;
doc->GetDoctype(getter_AddRefs(docType));
nsCOMPtr<nsIContent> docTypeContent = do_QueryInterface(docType);
nsIDocument* parentDocument = static_cast<nsIDocument*>(aParent);
nsIContent* docTypeContent = parentDocument->GetDocumentType();
if (docTypeContent) {
// Already have a doctype, so this is only OK if we're replacing it
return aIsReplace && docTypeContent == aRefChild;
@ -4055,8 +4045,7 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
// We don't have a doctype yet. Our one remaining constraint is
// that the doctype must come before the documentElement.
Element* rootElement =
static_cast<nsIDocument*>(aParent)->GetRootElement();
Element* rootElement = parentDocument->GetRootElement();
if (!rootElement) {
// It's all good
return true;

Просмотреть файл

@ -549,6 +549,7 @@ _TEST_FILES2 = \
test_bug433662.html \
test_bug749367.html \
test_bug753278.html \
test_bug761120.html \
test_XHR_onuploadprogress.html \
$(NULL)

Просмотреть файл

@ -0,0 +1,41 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=761120
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 761120</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=761120">Mozilla Bug 761120</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 761120 **/
var doc = document.implementation.createHTMLDocument("title");
try {
doc.appendChild(doc.createTextNode("text"));
ok(false, "Didn't throw");
} catch (e) {
is(e.name, "HierarchyRequestError");
}
var el = document.createElement("div");
var text = document.createTextNode("text");
el.appendChild(text);
is(el.firstChild, text);
var df = document.createDocumentFragment();
text = document.createTextNode("text");
df.appendChild(text);
is(df.firstChild, text);
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -6,7 +6,6 @@
#define mozilla_dom_DocumentRendererChild
#include "mozilla/ipc/PDocumentRendererChild.h"
#include "nsICanvasRenderingContextInternal.h"
#include "nsString.h"
#include "gfxContext.h"

Просмотреть файл

@ -6,11 +6,12 @@
#define mozilla_dom_DocumentRendererParent
#include "mozilla/ipc/PDocumentRendererParent.h"
#include "nsICanvasRenderingContextInternal.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "gfxContext.h"
class nsICanvasRenderingContextInternal;
namespace mozilla {
namespace ipc {

Просмотреть файл

@ -9,14 +9,14 @@
#include "nsISupports.h"
#include "nsIInputStream.h"
#include "nsIDocShell.h"
#include "nsHTMLCanvasElement.h"
#include "gfxPattern.h"
#include "mozilla/RefPtr.h"
#define NS_ICANVASRENDERINGCONTEXTINTERNAL_IID \
{ 0xffb42d3c, 0x8281, 0x44c8, \
{ 0xac, 0xba, 0x73, 0x15, 0x31, 0xaa, 0xe5, 0x07 } }
{ 0x8b8da863, 0xd151, 0x4014, \
{ 0x8b, 0xdc, 0x62, 0xb5, 0x0d, 0xc0, 0x2b, 0x62 } }
class nsHTMLCanvasElement;
class gfxContext;
class gfxASurface;
class nsIPropertyBag;
@ -46,9 +46,10 @@ public:
RenderFlagPremultAlpha = 0x1
};
// This method should NOT hold a ref to aParentCanvas; it will be called
// with nsnull when the element is going away.
NS_IMETHOD SetCanvasElement(nsHTMLCanvasElement* aParentCanvas) = 0;
void SetCanvasElement(nsHTMLCanvasElement* aParentCanvas)
{
mCanvasElement = aParentCanvas;
}
// Sets the dimensions of the canvas, in pixels. Called
// whenever the size of the element changes.
@ -119,6 +120,9 @@ public:
// anything into this canvas before changing the shmem state, it will be
// lost.
NS_IMETHOD SetIsIPC(bool isIPC) = 0;
protected:
nsRefPtr<nsHTMLCanvasElement> mCanvasElement;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsICanvasRenderingContextInternal,

Просмотреть файл

@ -128,7 +128,7 @@ JSValToDashArray(JSContext* cx, const jsval& patternArray,
}
bool haveNonzeroElement = false;
for (uint32 i = 0; i < length; ++i) {
for (uint32_t i = 0; i < length; ++i) {
jsval elt;
double d;
if (!JS_GetElement(cx, obj, i, &elt)) {

Просмотреть файл

@ -11,6 +11,7 @@
#include "nsPIDOMWindow.h"
#include "nsIDOMWindow.h"
#include "nsIDOMDocument.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeNode.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocument.h"
@ -36,7 +37,7 @@ bool
DocumentRendererChild::RenderDocument(nsIDOMWindow *window,
const nsRect& documentRect,
const gfxMatrix& transform,
const nsString& bgcolor,
const nsString& aBGColor,
PRUint32 renderFlags,
bool flushLayout,
const nsIntSize& renderSize,
@ -56,13 +57,16 @@ DocumentRendererChild::RenderDocument(nsIDOMWindow *window,
if (!presContext)
return false;
nscolor bgColor;
nsCSSParser parser;
nsresult rv = parser.ParseColorString(bgcolor, nsnull, 0, &bgColor);
if (NS_FAILED(rv))
nsCSSValue bgColorValue;
if (!parser.ParseColorString(aBGColor, nsnull, 0, bgColorValue)) {
return false;
}
nsIPresShell* presShell = presContext->PresShell();
nscolor bgColor;
if (!nsRuleNode::ComputeColor(bgColorValue, presContext, nsnull, bgColor)) {
return false;
}
// Draw directly into the output array.
data.SetLength(renderSize.width * renderSize.height * 4);
@ -75,7 +79,8 @@ DocumentRendererChild::RenderDocument(nsIDOMWindow *window,
nsRefPtr<gfxContext> ctx = new gfxContext(surf);
ctx->SetMatrix(transform);
presShell->RenderDocument(documentRect, renderFlags, bgColor, ctx);
presContext->PresShell()->
RenderDocument(documentRect, renderFlags, bgColor, ctx);
return true;
}

Просмотреть файл

@ -5,6 +5,7 @@
#include "mozilla/ipc/DocumentRendererParent.h"
#include "gfxImageSurface.h"
#include "gfxPattern.h"
#include "nsICanvasRenderingContextInternal.h"
using namespace mozilla::ipc;

Просмотреть файл

@ -35,6 +35,7 @@
#include "prenv.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/Telemetry.h"
#include "nsIObserverService.h"
@ -72,8 +73,7 @@ NS_NewCanvasRenderingContextWebGL(nsIDOMWebGLRenderingContext** aResult)
}
WebGLContext::WebGLContext()
: mCanvasElement(nsnull),
gl(nsnull)
: gl(nsnull)
{
SetIsDOMBinding();
mEnabledExtensions.SetLength(WebGLExtensionID_Max);
@ -242,10 +242,10 @@ WebGLContext::Invalidate()
if (!mCanvasElement)
return;
nsSVGEffects::InvalidateDirectRenderingObservers(HTMLCanvasElement());
nsSVGEffects::InvalidateDirectRenderingObservers(mCanvasElement);
mInvalidated = true;
HTMLCanvasElement()->InvalidateCanvasContent(nsnull);
mCanvasElement->InvalidateCanvasContent(nsnull);
}
/* readonly attribute nsIDOMHTMLCanvasElement canvas; */
@ -261,14 +261,6 @@ WebGLContext::GetCanvas(nsIDOMHTMLCanvasElement **canvas)
// nsICanvasRenderingContextInternal
//
NS_IMETHODIMP
WebGLContext::SetCanvasElement(nsHTMLCanvasElement* aParentCanvas)
{
mCanvasElement = aParentCanvas;
return NS_OK;
}
static bool
GetBoolFromPropertyBag(nsIPropertyBag *bag, const char *propName, bool *boolResult)
{
@ -331,7 +323,7 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
/*** early success return cases ***/
if (mCanvasElement) {
HTMLCanvasElement()->InvalidateCanvas();
mCanvasElement->InvalidateCanvas();
}
if (gl && mWidth == width && mHeight == height)
@ -495,7 +487,7 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
#endif
// try the default provider, whatever that is
if (!gl && useOpenGL) {
if (!gl && useOpenGL) {
GLContext::ContextFlags flag = useMesaLlvmPipe
? GLContext::ContextFlagsMesaLLVMPipe
: GLContext::ContextFlagsNone;
@ -726,7 +718,7 @@ WebGLContext::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
// releasing the reference to the element.
// The userData will receive DidTransactionCallbacks, which flush the
// the invalidation state to indicate that the canvas is up to date.
userData = new WebGLContextUserData(HTMLCanvasElement());
userData = new WebGLContextUserData(mCanvasElement);
canvasLayer->SetDidTransactionCallback(
WebGLContextUserData::DidTransactionCallback, userData);
}
@ -1065,7 +1057,7 @@ WebGLContext::Notify(nsITimer* timer)
{
TerminateContextLossTimer();
if (!HTMLCanvasElement()) {
if (!mCanvasElement) {
// the canvas is gone. That happens when the page was closed before we got
// this timer event. In this case, there's nothing to do here, just don't crash.
return NS_OK;
@ -1075,8 +1067,8 @@ WebGLContext::Notify(nsITimer* timer)
// that now.
if (mContextStatus == ContextLostAwaitingEvent) {
bool defaultAction;
nsContentUtils::DispatchTrustedEvent(HTMLCanvasElement()->OwnerDoc(),
(nsIDOMHTMLCanvasElement*) HTMLCanvasElement(),
nsContentUtils::DispatchTrustedEvent(mCanvasElement->OwnerDoc(),
static_cast<nsIDOMHTMLCanvasElement*>(mCanvasElement),
NS_LITERAL_STRING("webglcontextlost"),
true,
true,
@ -1104,8 +1096,8 @@ WebGLContext::Notify(nsITimer* timer)
return NS_OK;
}
mContextStatus = ContextStable;
nsContentUtils::DispatchTrustedEvent(HTMLCanvasElement()->OwnerDoc(),
(nsIDOMHTMLCanvasElement*) HTMLCanvasElement(),
nsContentUtils::DispatchTrustedEvent(mCanvasElement->OwnerDoc(),
static_cast<nsIDOMHTMLCanvasElement*>(mCanvasElement),
NS_LITERAL_STRING("webglcontextrestored"),
true,
true);
@ -1214,7 +1206,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WebGLContext)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(WebGLContext)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCanvasElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mCanvasElement, nsINode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(mEnabledExtensions)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

Просмотреть файл

@ -483,7 +483,7 @@ public:
nsIDOMWebGLRenderingContext)
nsINode* GetParentObject() {
return HTMLCanvasElement();
return mCanvasElement;
}
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
@ -494,11 +494,6 @@ public:
NS_DECL_NSITIMERCALLBACK
// nsICanvasRenderingContextInternal
NS_IMETHOD SetCanvasElement(nsHTMLCanvasElement* aParentCanvas);
nsHTMLCanvasElement* HTMLCanvasElement() const {
return static_cast<nsHTMLCanvasElement*>(mCanvasElement.get());
}
NS_IMETHOD SetDimensions(PRInt32 width, PRInt32 height);
NS_IMETHOD InitializeWithSurface(nsIDocShell *docShell, gfxASurface *surface, PRInt32 width, PRInt32 height)
{ return NS_ERROR_NOT_IMPLEMENTED; }
@ -619,7 +614,7 @@ public:
// WebIDL WebGLRenderingContext API
nsHTMLCanvasElement* GetCanvas() const {
return HTMLCanvasElement();
return mCanvasElement;
}
WebGLsizei GetDrawingBufferWidth() const {
if (!IsContextStable())
@ -1107,8 +1102,6 @@ protected:
return ((x + y - 1) / y) * y;
}
nsCOMPtr<nsIDOMHTMLCanvasElement> mCanvasElement;
nsRefPtr<gl::GLContext> gl;
CheckedUint32 mGeneration;

Просмотреть файл

@ -3841,7 +3841,7 @@ WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width,
return;
}
if (HTMLCanvasElement()->IsWriteOnly() && !nsContentUtils::IsCallerTrustedForRead()) {
if (mCanvasElement->IsWriteOnly() && !nsContentUtils::IsCallerTrustedForRead()) {
GenerateWarning("readPixels: Not allowed");
return rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
}
@ -4343,7 +4343,7 @@ WebGLContext::SurfaceFromElementResultToImageSurface(nsLayoutUtils::SurfaceFromE
// validated for cross-domain use.
if (!res.mCORSUsed) {
bool subsumes;
nsresult rv = HTMLCanvasElement()->NodePrincipal()->Subsumes(res.mPrincipal, &subsumes);
nsresult rv = mCanvasElement->NodePrincipal()->Subsumes(res.mPrincipal, &subsumes);
if (NS_FAILED(rv) || !subsumes) {
GenerateWarning("It is forbidden to load a WebGL texture from a cross-domain element that has not been validated with CORS. "
"See https://developer.mozilla.org/en/WebGL/Cross-Domain_Textures");

Просмотреть файл

@ -5,8 +5,9 @@
#include "WebGLContext.h"
#include "mozilla/Preferences.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "jsfriendapi.h"
@ -597,7 +598,7 @@ WebGLContext::InitAndValidateGL()
return false;
}
#ifdef ANDROID
#ifdef MOZ_JAVA_COMPOSITOR
// bug 736123, blacklist WebGL on Adreno
bool forceEnabled = Preferences::GetBool("webgl.force-enabled", false);
if (!forceEnabled) {

Просмотреть файл

@ -87,6 +87,7 @@
#include "mozilla/dom/PBrowserParent.h"
#include "mozilla/ipc/DocumentRendererParent.h"
#include "mozilla/ipc/PDocumentRendererParent.h"
#include "mozilla/unused.h"
// windows.h (included by chromium code) defines this, in its infinite wisdom
#undef DrawText
@ -173,12 +174,16 @@ public:
if (!FloatValidate(offset) || offset < 0.0 || offset > 1.0)
return NS_ERROR_DOM_INDEX_SIZE_ERR;
nscolor color;
nsCSSValue value;
nsCSSParser parser;
nsresult rv = parser.ParseColorString(nsString(colorstr),
nsnull, 0, &color);
if (NS_FAILED(rv))
if (!parser.ParseColorString(colorstr, nsnull, 0, value)) {
return NS_ERROR_DOM_SYNTAX_ERR;
}
nscolor color;
if (!nsRuleNode::ComputeColor(value, nsnull, nsnull, color)) {
return NS_ERROR_DOM_SYNTAX_ERR;
}
mPattern->AddColorStop(offset, gfxRGBA(color));
@ -312,7 +317,6 @@ public:
nsresult Redraw();
// nsICanvasRenderingContextInternal
NS_IMETHOD SetCanvasElement(nsHTMLCanvasElement* aParentCanvas);
NS_IMETHOD SetDimensions(PRInt32 width, PRInt32 height);
void Initialize(nsIDocShell *shell, PRInt32 width, PRInt32 height);
NS_IMETHOD InitializeWithSurface(nsIDocShell *shell, gfxASurface *surface, PRInt32 width, PRInt32 height);
@ -403,6 +407,9 @@ protected:
nsresult SetStyleFromStringOrInterface(const nsAString& aStr, nsISupports *aInterface, Style aWhichStyle);
nsresult GetStyleAsStringOrInterface(nsAString& aStr, nsISupports **aInterface, PRInt32 *aType, Style aWhichStyle);
// Returns whether a color was successfully parsed.
bool ParseColor(const nsAString& aString, nscolor* aColor);
void StyleColorToString(const nscolor& aColor, nsAString& aStr);
void DirtyAllStyles();
@ -437,12 +444,6 @@ protected:
bool mResetLayer;
bool mIPC;
// the canvas element we're a context of
nsCOMPtr<nsIDOMHTMLCanvasElement> mCanvasElement;
nsHTMLCanvasElement *HTMLCanvasElement() {
return static_cast<nsHTMLCanvasElement*>(mCanvasElement.get());
}
// Initialize the Thebes rendering context
void CreateThebes();
@ -763,7 +764,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsCanvasRenderingContext2D)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCanvasElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCanvasRenderingContext2D)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCanvasElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mCanvasElement, nsINode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
DOMCI_DATA(CanvasRenderingContext2D, nsCanvasRenderingContext2D)
@ -799,7 +800,6 @@ NS_NewCanvasRenderingContext2DThebes(nsIDOMCanvasRenderingContext2D** aResult)
nsCanvasRenderingContext2D::nsCanvasRenderingContext2D()
: mValid(false), mZero(false), mOpaque(false), mResetLayer(true)
, mIPC(false)
, mCanvasElement(nsnull)
, mSaveCount(0), mIsEntireFrameInvalid(false)
, mPredictManyRedrawCalls(false), mHasPath(false), mInvalidateCount(0)
, mLastStyle(STYLE_MAX), mStyleStack(20)
@ -819,11 +819,41 @@ nsCanvasRenderingContext2D::~nsCanvasRenderingContext2D()
}
}
bool
nsCanvasRenderingContext2D::ParseColor(const nsAString& aString,
nscolor* aColor)
{
nsIDocument* document = mCanvasElement
? mCanvasElement->OwnerDoc()
: nsnull;
// Pass the CSS Loader object to the parser, to allow parser error
// reports to include the outer window ID.
nsCSSParser parser(document ? document->CSSLoader() : nsnull);
nsCSSValue value;
if (!parser.ParseColorString(aString, nsnull, 0, value)) {
return false;
}
nsIPresShell* presShell = GetPresShell();
nsRefPtr<nsStyleContext> parentContext;
if (mCanvasElement && mCanvasElement->IsInDoc()) {
// Inherit from the canvas element.
parentContext = nsComputedDOMStyle::GetStyleContextForElement(
mCanvasElement, nsnull, presShell);
}
unused << nsRuleNode::ComputeColor(
value, presShell ? presShell->GetPresContext() : nsnull, parentContext,
*aColor);
return true;
}
nsresult
nsCanvasRenderingContext2D::Reset()
{
if (mCanvasElement) {
HTMLCanvasElement()->InvalidateCanvas();
mCanvasElement->InvalidateCanvas();
}
// only do this for non-docshell created contexts,
@ -844,19 +874,9 @@ nsCanvasRenderingContext2D::SetStyleFromStringOrInterface(const nsAString& aStr,
nsISupports *aInterface,
Style aWhichStyle)
{
nsresult rv;
nscolor color;
if (!aStr.IsVoid()) {
nsIDocument* document = mCanvasElement ?
HTMLCanvasElement()->OwnerDoc() : nsnull;
// Pass the CSS Loader object to the parser, to allow parser error
// reports to include the outer window ID.
nsCSSParser parser(document ? document->CSSLoader() : nsnull);
rv = parser.ParseColorString(aStr, nsnull, 0, &color);
if (NS_FAILED(rv)) {
// Error reporting happens inside the CSS parser
nscolor color;
if (!ParseColor(aStr, &color)) {
return NS_OK;
}
@ -885,7 +905,7 @@ nsCanvasRenderingContext2D::SetStyleFromStringOrInterface(const nsAString& aStr,
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag,
"Canvas",
mCanvasElement ? HTMLCanvasElement()->OwnerDoc() : nsnull,
mCanvasElement ? mCanvasElement->OwnerDoc() : nsnull,
nsContentUtils::eDOM_PROPERTIES,
"UnexpectedCanvasVariantStyle");
@ -969,7 +989,7 @@ nsCanvasRenderingContext2D::ApplyStyle(Style aWhichStyle,
nsCanvasPattern* pattern = CurrentState().patternStyles[aWhichStyle];
if (pattern) {
if (mCanvasElement)
CanvasUtils::DoDrawImageSecurityCheck(HTMLCanvasElement(),
CanvasUtils::DoDrawImageSecurityCheck(mCanvasElement,
pattern->Principal(),
pattern->GetForceWriteOnly(),
pattern->GetCORSUsed());
@ -1010,9 +1030,9 @@ nsCanvasRenderingContext2D::Redraw()
return NS_OK;
}
nsSVGEffects::InvalidateDirectRenderingObservers(HTMLCanvasElement());
nsSVGEffects::InvalidateDirectRenderingObservers(mCanvasElement);
HTMLCanvasElement()->InvalidateCanvasContent(nsnull);
mCanvasElement->InvalidateCanvasContent(nsnull);
return NS_OK;
}
@ -1035,9 +1055,9 @@ nsCanvasRenderingContext2D::Redraw(const gfxRect& r)
return NS_OK;
}
nsSVGEffects::InvalidateDirectRenderingObservers(HTMLCanvasElement());
nsSVGEffects::InvalidateDirectRenderingObservers(mCanvasElement);
HTMLCanvasElement()->InvalidateCanvasContent(&r);
mCanvasElement->InvalidateCanvasContent(&r);
return NS_OK;
}
@ -1349,14 +1369,6 @@ nsCanvasRenderingContext2D::GetImageFormat() const
// nsCanvasRenderingContext2D impl
//
NS_IMETHODIMP
nsCanvasRenderingContext2D::SetCanvasElement(nsHTMLCanvasElement* aCanvasElement)
{
mCanvasElement = aCanvasElement;
return NS_OK;
}
NS_IMETHODIMP
nsCanvasRenderingContext2D::GetCanvas(nsIDOMHTMLCanvasElement **canvas)
{
@ -1896,18 +1908,10 @@ nsCanvasRenderingContext2D::GetShadowBlur(float *blur)
}
NS_IMETHODIMP
nsCanvasRenderingContext2D::SetShadowColor(const nsAString& colorstr)
nsCanvasRenderingContext2D::SetShadowColor(const nsAString& aColor)
{
nsIDocument* document = mCanvasElement ?
HTMLCanvasElement()->OwnerDoc() : nsnull;
// Pass the CSS Loader object to the parser, to allow parser error reports
// to include the outer window ID.
nsCSSParser parser(document ? document->CSSLoader() : nsnull);
nscolor color;
nsresult rv = parser.ParseColorString(colorstr, nsnull, 0, &color);
if (NS_FAILED(rv)) {
// Error reporting happens inside the CSS parser
if (!ParseColor(aColor, &color)) {
return NS_OK;
}
@ -2452,9 +2456,8 @@ nsCanvasRenderingContext2D::SetFont(const nsAString& font)
* string is equal to the old one.
*/
nsCOMPtr<nsIContent> content = do_QueryInterface(mCanvasElement);
if (!content && !mDocShell) {
NS_WARNING("Canvas element must be an nsIContent and non-null or a docshell must be provided");
if (!mCanvasElement && !mDocShell) {
NS_WARNING("Canvas element must be non-null or a docshell must be provided");
return NS_ERROR_FAILURE;
}
@ -2494,10 +2497,10 @@ nsCanvasRenderingContext2D::SetFont(const nsAString& font)
// values (2em, bolder, etc.)
nsRefPtr<nsStyleContext> parentContext;
if (content && content->IsInDoc()) {
if (mCanvasElement && mCanvasElement->IsInDoc()) {
// inherit from the canvas element
parentContext = nsComputedDOMStyle::GetStyleContextForElement(
content->AsElement(),
mCanvasElement,
nsnull,
presShell);
} else {
@ -2832,9 +2835,8 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
if (aMaxWidth < 0)
return NS_ERROR_INVALID_ARG;
nsCOMPtr<nsIContent> content = do_QueryInterface(mCanvasElement);
if (!content && !mDocShell) {
NS_WARNING("Canvas element must be an nsIContent and non-null or a docshell must be provided");
if (!mCanvasElement && !mDocShell) {
NS_WARNING("Canvas element must be non-null or a docshell must be provided");
return NS_ERROR_FAILURE;
}
@ -2851,10 +2853,10 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
// for now, default to ltr if not in doc
bool isRTL = false;
if (content && content->IsInDoc()) {
if (mCanvasElement && mCanvasElement->IsInDoc()) {
// try to find the closest context
nsRefPtr<nsStyleContext> canvasStyle =
nsComputedDOMStyle::GetStyleContextForElement(content->AsElement(),
nsComputedDOMStyle::GetStyleContextForElement(mCanvasElement,
nsnull,
presShell);
if (!canvasStyle)
@ -3377,7 +3379,7 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
nsRefPtr<gfxPattern> pattern;
gfxIntSize imgSize;
nsRefPtr<gfxASurface> imgsurf =
CanvasImageCache::Lookup(imgElt, HTMLCanvasElement(), &imgSize);
CanvasImageCache::Lookup(imgElt, mCanvasElement, &imgSize);
if (!imgsurf) {
// The canvas spec says that drawImage should draw the first frame
@ -3404,14 +3406,14 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
imgSize = res.mSize;
if (mCanvasElement) {
CanvasUtils::DoDrawImageSecurityCheck(HTMLCanvasElement(),
CanvasUtils::DoDrawImageSecurityCheck(mCanvasElement,
res.mPrincipal,
res.mIsWriteOnly,
res.mCORSUsed);
}
if (res.mImageRequest) {
CanvasImageCache::NotifyDrawImage(imgElt, HTMLCanvasElement(),
CanvasImageCache::NotifyDrawImage(imgElt, mCanvasElement,
res.mImageRequest, imgsurf, imgSize);
}
}
@ -3651,19 +3653,9 @@ nsCanvasRenderingContext2D::DrawWindow(nsIDOMWindow* aWindow, float aX, float aY
return NS_ERROR_FAILURE;
nscolor bgColor;
nsIDocument* elementDoc = mCanvasElement ?
HTMLCanvasElement()->OwnerDoc() : nsnull;
// Pass the CSS Loader object to the parser, to allow parser error reports
// to include the outer window ID.
nsCSSParser parser(elementDoc ? elementDoc->CSSLoader() : nsnull);
nsresult rv = parser.ParseColorString(PromiseFlatString(aBGColor),
nsnull, 0, &bgColor);
NS_ENSURE_SUCCESS(rv, rv);
nsIPresShell* presShell = presContext->PresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
if (!ParseColor(aBGColor, &bgColor)) {
return NS_ERROR_FAILURE;
}
nsRect r(nsPresContext::CSSPixelsToAppUnits(aX),
nsPresContext::CSSPixelsToAppUnits(aY),
@ -3685,7 +3677,8 @@ nsCanvasRenderingContext2D::DrawWindow(nsIDOMWindow* aWindow, float aX, float aY
renderDocFlags |= nsIPresShell::RENDER_ASYNC_DECODE_IMAGES;
}
rv = presShell->RenderDocument(r, renderDocFlags, bgColor, mThebes);
nsresult rv = presContext->PresShell()->
RenderDocument(r, renderDocFlags, bgColor, mThebes);
// get rid of the pattern surface ref, just in case
mThebes->SetColor(gfxRGBA(1,1,1,1));
@ -3823,8 +3816,7 @@ nsCanvasRenderingContext2D::GetImageData(double aSx, double aSy,
// Check only if we have a canvas element; if we were created with a docshell,
// then it's special internal use.
if (mCanvasElement &&
HTMLCanvasElement()->IsWriteOnly() &&
if (mCanvasElement && mCanvasElement->IsWriteOnly() &&
!nsContentUtils::IsCallerTrustedForRead()) {
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
return NS_ERROR_DOM_SECURITY_ERR;
@ -4036,7 +4028,7 @@ nsCanvasRenderingContext2D::PutImageData_explicit(PRInt32 x, PRInt32 y, PRUint32
return NS_ERROR_DOM_INDEX_SIZE_ERR;
dirtyX = checkedDirtyX.value();
dirtyWidth = -(int32)dirtyWidth;
dirtyWidth = -dirtyWidth;
}
if (dirtyHeight < 0) {
@ -4048,7 +4040,7 @@ nsCanvasRenderingContext2D::PutImageData_explicit(PRInt32 x, PRInt32 y, PRUint32
return NS_ERROR_DOM_INDEX_SIZE_ERR;
dirtyY = checkedDirtyY.value();
dirtyHeight = -(int32)dirtyHeight;
dirtyHeight = -dirtyHeight;
}
// bound the dirty rect within the imageData rectangle
@ -4206,7 +4198,7 @@ nsCanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
// releasing the reference to the element.
// The userData will receive DidTransactionCallbacks, which flush the
// the invalidation state to indicate that the canvas is up to date.
userData = new CanvasRenderingContext2DUserData(HTMLCanvasElement());
userData = new CanvasRenderingContext2DUserData(mCanvasElement);
canvasLayer->SetDidTransactionCallback(
CanvasRenderingContext2DUserData::DidTransactionCallback, userData);
}

Просмотреть файл

@ -88,6 +88,7 @@
#include "mozilla/ipc/DocumentRendererParent.h"
#include "mozilla/ipc/PDocumentRendererParent.h"
#include "mozilla/Preferences.h"
#include "mozilla/unused.h"
#ifdef XP_WIN
#include "gfxWindowsPlatform.h"
@ -172,11 +173,14 @@ public:
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
nscolor color;
nsCSSValue value;
nsCSSParser parser;
nsresult rv = parser.ParseColorString(nsString(colorstr),
nsnull, 0, &color);
if (NS_FAILED(rv)) {
if (!parser.ParseColorString(colorstr, nsnull, 0, value)) {
return NS_ERROR_DOM_SYNTAX_ERR;
}
nscolor color;
if (!nsRuleNode::ComputeColor(value, nsnull, nsnull, color)) {
return NS_ERROR_DOM_SYNTAX_ERR;
}
@ -369,7 +373,6 @@ public:
nsresult Redraw();
// nsICanvasRenderingContextInternal
NS_IMETHOD SetCanvasElement(nsHTMLCanvasElement* aParentCanvas);
NS_IMETHOD SetDimensions(PRInt32 width, PRInt32 height);
NS_IMETHOD InitializeWithSurface(nsIDocShell *shell, gfxASurface *surface, PRInt32 width, PRInt32 height)
{ return NS_ERROR_NOT_IMPLEMENTED; }
@ -443,6 +446,9 @@ protected:
nsresult SetStyleFromStringOrInterface(const nsAString& aStr, nsISupports *aInterface, Style aWhichStyle);
nsresult GetStyleAsStringOrInterface(nsAString& aStr, nsISupports **aInterface, PRInt32 *aType, Style aWhichStyle);
// Returns whether a color was successfully parsed.
bool ParseColor(const nsAString& aString, nscolor* aColor);
void StyleColorToString(const nscolor& aColor, nsAString& aStr);
/**
@ -475,10 +481,6 @@ protected:
*/
SurfaceFormat GetSurfaceFormat() const;
nsHTMLCanvasElement *HTMLCanvasElement() {
return static_cast<nsHTMLCanvasElement*>(mCanvasElement.get());
}
// Member vars
PRInt32 mWidth, mHeight;
@ -498,9 +500,6 @@ protected:
// This is needed for drawing in drawAsyncXULElement
bool mIPC;
// the canvas element we're a context of
nsCOMPtr<nsIDOMHTMLCanvasElement> mCanvasElement;
// If mCanvasElement is not provided, then a docshell is
nsCOMPtr<nsIDocShell> mDocShell;
@ -777,7 +776,7 @@ protected:
gradient->mRadius2, gradient->GetGradientStopsForTarget(aRT));
} else if (state.patternStyles[aStyle]) {
if (aCtx->mCanvasElement) {
CanvasUtils::DoDrawImageSecurityCheck(aCtx->HTMLCanvasElement(),
CanvasUtils::DoDrawImageSecurityCheck(aCtx->mCanvasElement,
state.patternStyles[aStyle]->mPrincipal,
state.patternStyles[aStyle]->mForceWriteOnly,
state.patternStyles[aStyle]->mCORSUsed);
@ -941,7 +940,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsCanvasRenderingContext2DAzure)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCanvasElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCanvasRenderingContext2DAzure)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCanvasElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mCanvasElement, nsINode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
// XXX
@ -989,7 +988,6 @@ NS_NewCanvasRenderingContext2DAzure(nsIDOMCanvasRenderingContext2D** aResult)
nsCanvasRenderingContext2DAzure::nsCanvasRenderingContext2DAzure()
: mValid(false), mZero(false), mOpaque(false), mResetLayer(true)
, mIPC(false)
, mCanvasElement(nsnull)
, mIsEntireFrameInvalid(false)
, mPredictManyRedrawCalls(false), mPathTransformWillUpdate(false)
, mInvalidateCount(0)
@ -1009,11 +1007,41 @@ nsCanvasRenderingContext2DAzure::~nsCanvasRenderingContext2DAzure()
}
}
bool
nsCanvasRenderingContext2DAzure::ParseColor(const nsAString& aString,
nscolor* aColor)
{
nsIDocument* document = mCanvasElement
? mCanvasElement->OwnerDoc()
: nsnull;
// Pass the CSS Loader object to the parser, to allow parser error
// reports to include the outer window ID.
nsCSSParser parser(document ? document->CSSLoader() : nsnull);
nsCSSValue value;
if (!parser.ParseColorString(aString, nsnull, 0, value)) {
return false;
}
nsIPresShell* presShell = GetPresShell();
nsRefPtr<nsStyleContext> parentContext;
if (mCanvasElement && mCanvasElement->IsInDoc()) {
// Inherit from the canvas element.
parentContext = nsComputedDOMStyle::GetStyleContextForElement(
mCanvasElement, nsnull, presShell);
}
unused << nsRuleNode::ComputeColor(
value, presShell ? presShell->GetPresContext() : nsnull, parentContext,
*aColor);
return true;
}
nsresult
nsCanvasRenderingContext2DAzure::Reset()
{
if (mCanvasElement) {
HTMLCanvasElement()->InvalidateCanvas();
mCanvasElement->InvalidateCanvas();
}
// only do this for non-docshell created contexts,
@ -1039,19 +1067,9 @@ nsCanvasRenderingContext2DAzure::SetStyleFromStringOrInterface(const nsAString&
nsISupports *aInterface,
Style aWhichStyle)
{
nsresult rv;
nscolor color;
if (!aStr.IsVoid()) {
nsIDocument* document = mCanvasElement ?
HTMLCanvasElement()->OwnerDoc() : nsnull;
// Pass the CSS Loader object to the parser, to allow parser error
// reports to include the outer window ID.
nsCSSParser parser(document ? document->CSSLoader() : nsnull);
rv = parser.ParseColorString(aStr, nsnull, 0, &color);
if (NS_FAILED(rv)) {
// Error reporting happens inside the CSS parser
nscolor color;
if (!ParseColor(aStr, &color)) {
return NS_OK;
}
@ -1076,7 +1094,7 @@ nsCanvasRenderingContext2DAzure::SetStyleFromStringOrInterface(const nsAString&
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag,
"Canvas",
mCanvasElement ? HTMLCanvasElement()->OwnerDoc() : nsnull,
mCanvasElement ? mCanvasElement->OwnerDoc() : nsnull,
nsContentUtils::eDOM_PROPERTIES,
"UnexpectedCanvasVariantStyle");
@ -1149,9 +1167,9 @@ nsCanvasRenderingContext2DAzure::Redraw()
gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mTarget);
mThebesSurface->MarkDirty();
nsSVGEffects::InvalidateDirectRenderingObservers(HTMLCanvasElement());
nsSVGEffects::InvalidateDirectRenderingObservers(mCanvasElement);
HTMLCanvasElement()->InvalidateCanvasContent(nsnull);
mCanvasElement->InvalidateCanvasContent(nsnull);
return NS_OK;
}
@ -1181,10 +1199,10 @@ nsCanvasRenderingContext2DAzure::Redraw(const mgfx::Rect &r)
gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mTarget);
mThebesSurface->MarkDirty();
nsSVGEffects::InvalidateDirectRenderingObservers(HTMLCanvasElement());
nsSVGEffects::InvalidateDirectRenderingObservers(mCanvasElement);
gfxRect tmpR = ThebesRect(r);
HTMLCanvasElement()->InvalidateCanvasContent(&tmpR);
mCanvasElement->InvalidateCanvasContent(&tmpR);
return;
}
@ -1470,14 +1488,6 @@ nsCanvasRenderingContext2DAzure::GetSurfaceFormat() const
// nsCanvasRenderingContext2DAzure impl
//
NS_IMETHODIMP
nsCanvasRenderingContext2DAzure::SetCanvasElement(nsHTMLCanvasElement* aCanvasElement)
{
mCanvasElement = aCanvasElement;
return NS_OK;
}
NS_IMETHODIMP
nsCanvasRenderingContext2DAzure::GetCanvas(nsIDOMHTMLCanvasElement **canvas)
{
@ -2014,20 +2024,13 @@ nsCanvasRenderingContext2DAzure::GetShadowBlur(float *blur)
}
NS_IMETHODIMP
nsCanvasRenderingContext2DAzure::SetShadowColor(const nsAString& colorstr)
nsCanvasRenderingContext2DAzure::SetShadowColor(const nsAString& aColor)
{
nsIDocument* document = mCanvasElement ?
HTMLCanvasElement()->OwnerDoc() : nsnull;
// Pass the CSS Loader object to the parser, to allow parser error reports
// to include the outer window ID.
nsCSSParser parser(document ? document->CSSLoader() : nsnull);
nscolor color;
nsresult rv = parser.ParseColorString(colorstr, nsnull, 0, &color);
if (NS_FAILED(rv)) {
// Error reporting happens inside the CSS parser
if (!ParseColor(aColor, &color)) {
return NS_OK;
}
CurrentState().shadowColor = color;
return NS_OK;
@ -2660,9 +2663,8 @@ nsCanvasRenderingContext2DAzure::SetFont(const nsAString& font)
* string is equal to the old one.
*/
nsCOMPtr<nsIContent> content = do_QueryInterface(mCanvasElement);
if (!content && !mDocShell) {
NS_WARNING("Canvas element must be an nsIContent and non-null or a docshell must be provided");
if (!mCanvasElement && !mDocShell) {
NS_WARNING("Canvas element must be non-null or a docshell must be provided");
return NS_ERROR_FAILURE;
}
@ -2705,10 +2707,10 @@ nsCanvasRenderingContext2DAzure::SetFont(const nsAString& font)
// values (2em, bolder, etc.)
nsRefPtr<nsStyleContext> parentContext;
if (content && content->IsInDoc()) {
if (mCanvasElement && mCanvasElement->IsInDoc()) {
// inherit from the canvas element
parentContext = nsComputedDOMStyle::GetStyleContextForElement(
content->AsElement(),
mCanvasElement,
nsnull,
presShell);
} else {
@ -3148,9 +3150,8 @@ nsCanvasRenderingContext2DAzure::DrawOrMeasureText(const nsAString& aRawText,
if (aMaxWidth < 0)
return NS_ERROR_INVALID_ARG;
nsCOMPtr<nsIContent> content = do_QueryInterface(mCanvasElement);
if (!content && !mDocShell) {
NS_WARNING("Canvas element must be an nsIContent and non-null or a docshell must be provided");
if (!mCanvasElement && !mDocShell) {
NS_WARNING("Canvas element must be non-null or a docshell must be provided");
return NS_ERROR_FAILURE;
}
@ -3167,10 +3168,10 @@ nsCanvasRenderingContext2DAzure::DrawOrMeasureText(const nsAString& aRawText,
// for now, default to ltr if not in doc
bool isRTL = false;
if (content && content->IsInDoc()) {
if (mCanvasElement && mCanvasElement->IsInDoc()) {
// try to find the closest context
nsRefPtr<nsStyleContext> canvasStyle =
nsComputedDOMStyle::GetStyleContextForElement(content->AsElement(),
nsComputedDOMStyle::GetStyleContextForElement(mCanvasElement,
nsnull,
presShell);
if (!canvasStyle) {
@ -3609,7 +3610,7 @@ nsCanvasRenderingContext2DAzure::DrawImage(nsIDOMElement *imgElt, float a1,
if (srcSurf && mCanvasElement) {
// Do security check here.
CanvasUtils::DoDrawImageSecurityCheck(HTMLCanvasElement(),
CanvasUtils::DoDrawImageSecurityCheck(mCanvasElement,
content->NodePrincipal(), canvas->IsWriteOnly(),
false);
imgSize = gfxIntSize(srcSurf->GetSize().width, srcSurf->GetSize().height);
@ -3617,7 +3618,7 @@ nsCanvasRenderingContext2DAzure::DrawImage(nsIDOMElement *imgElt, float a1,
}
} else {
gfxASurface* imgsurf =
CanvasImageCache::Lookup(imgElt, HTMLCanvasElement(), &imgSize);
CanvasImageCache::Lookup(imgElt, mCanvasElement, &imgSize);
if (imgsurf) {
srcSurf = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(mTarget, imgsurf);
}
@ -3643,13 +3644,13 @@ nsCanvasRenderingContext2DAzure::DrawImage(nsIDOMElement *imgElt, float a1,
imgSize = res.mSize;
if (mCanvasElement) {
CanvasUtils::DoDrawImageSecurityCheck(HTMLCanvasElement(),
CanvasUtils::DoDrawImageSecurityCheck(mCanvasElement,
res.mPrincipal, res.mIsWriteOnly,
res.mCORSUsed);
}
if (res.mImageRequest) {
CanvasImageCache::NotifyDrawImage(imgElt, HTMLCanvasElement(),
CanvasImageCache::NotifyDrawImage(imgElt, mCanvasElement,
res.mImageRequest, res.mSurface, imgSize);
}
@ -3788,7 +3789,7 @@ nsCanvasRenderingContext2DAzure::DrawWindow(nsIDOMWindow* aWindow, float aX, flo
// protect against too-large surfaces that will cause allocation
// or overflow issues
if (!gfxASurface::CheckSurfaceSize(gfxIntSize(PRInt32(aW), PRInt32(aH)),
0xffff))
0xffff))
return NS_ERROR_FAILURE;
nsRefPtr<gfxASurface> drawSurf;
@ -3828,19 +3829,9 @@ nsCanvasRenderingContext2DAzure::DrawWindow(nsIDOMWindow* aWindow, float aX, flo
return NS_ERROR_FAILURE;
nscolor bgColor;
nsIDocument* elementDoc = mCanvasElement ?
HTMLCanvasElement()->OwnerDoc() : nsnull;
// Pass the CSS Loader object to the parser, to allow parser error reports
// to include the outer window ID.
nsCSSParser parser(elementDoc ? elementDoc->CSSLoader() : nsnull);
nsresult rv = parser.ParseColorString(PromiseFlatString(aBGColor),
nsnull, 0, &bgColor);
NS_ENSURE_SUCCESS(rv, rv);
nsIPresShell* presShell = presContext->PresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
if (!ParseColor(aBGColor, &bgColor)) {
return NS_ERROR_FAILURE;
}
nsRect r(nsPresContext::CSSPixelsToAppUnits(aX),
nsPresContext::CSSPixelsToAppUnits(aY),
@ -3862,7 +3853,8 @@ nsCanvasRenderingContext2DAzure::DrawWindow(nsIDOMWindow* aWindow, float aX, flo
renderDocFlags |= nsIPresShell::RENDER_ASYNC_DECODE_IMAGES;
}
rv = presShell->RenderDocument(r, renderDocFlags, bgColor, thebes);
unused << presContext->PresShell()->
RenderDocument(r, renderDocFlags, bgColor, thebes);
// note that aX and aY are coordinates in the document that
// we're drawing; aX and aY are drawn to 0,0 in current user
@ -3998,8 +3990,7 @@ nsCanvasRenderingContext2DAzure::GetImageData(double aSx, double aSy,
// Check only if we have a canvas element; if we were created with a docshell,
// then it's special internal use.
if (mCanvasElement &&
HTMLCanvasElement()->IsWriteOnly() &&
if (mCanvasElement && mCanvasElement->IsWriteOnly() &&
!nsContentUtils::IsCallerTrustedForRead())
{
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
@ -4206,7 +4197,7 @@ nsCanvasRenderingContext2DAzure::PutImageData_explicit(PRInt32 x, PRInt32 y, PRU
return NS_ERROR_DOM_INDEX_SIZE_ERR;
dirtyX = checkedDirtyX.value();
dirtyWidth = -(int32)dirtyWidth;
dirtyWidth = -dirtyWidth;
}
if (dirtyHeight < 0) {
@ -4218,7 +4209,7 @@ nsCanvasRenderingContext2DAzure::PutImageData_explicit(PRInt32 x, PRInt32 y, PRU
return NS_ERROR_DOM_INDEX_SIZE_ERR;
dirtyY = checkedDirtyY.value();
dirtyHeight = -(int32)dirtyHeight;
dirtyHeight = -dirtyHeight;
}
// bound the dirty rect within the imageData rectangle
@ -4396,7 +4387,7 @@ nsCanvasRenderingContext2DAzure::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
// releasing the reference to the element.
// The userData will receive DidTransactionCallbacks, which flush the
// the invalidation state to indicate that the canvas is up to date.
userData = new CanvasRenderingContext2DUserData(HTMLCanvasElement());
userData = new CanvasRenderingContext2DUserData(mCanvasElement);
canvasLayer->SetDidTransactionCallback(
CanvasRenderingContext2DUserData::DidTransactionCallback, userData);
}

Просмотреть файл

@ -4120,7 +4120,7 @@ canvas.setAttribute('style', 'color: #0f0');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'currentColor';
ctx.fillRect(0, 0, 100, 50);
todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
@ -4145,7 +4145,7 @@ ctx.fillStyle = '#f00';
ctx.fillStyle = 'currentColor';
canvas.setAttribute('style', 'color: #f00');
ctx.fillRect(0, 0, 100, 50);
todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
@ -4181,7 +4181,7 @@ ctx.drawImage(canvas2, 0, 0);
document.body.parentNode.removeAttribute('style');
document.body.removeAttribute('style');
todo_isPixel(ctx, 50,25, 0,0,0,255, 0);
isPixel(ctx, 50,25, 0,0,0,255, 0);
}

Просмотреть файл

@ -16,14 +16,14 @@
#include "nsDOMError.h"
#include "nsNodeInfoManager.h"
#include "nsICanvasRenderingContextInternal.h"
#include "nsICanvasElementExternal.h"
#include "nsIDOMCanvasRenderingContext2D.h"
#include "nsLayoutUtils.h"
#include "Layers.h"
class nsICanvasRenderingContextInternal;
class nsIDOMFile;
class nsIPropertyBag;
class nsHTMLCanvasElement : public nsGenericHTMLElement,
public nsICanvasElementExternal,

Просмотреть файл

@ -17,8 +17,10 @@ FAIL_ON_WARNINGS = 1
EXPORTS = \
nsGenericHTMLElement.h \
nsClientRect.h \
nsHTMLDNSPrefetch.h \
nsTimeRanges.h \
$(NULL)
CPPSRCS = \

Просмотреть файл

@ -93,12 +93,12 @@
#include "HTMLPropertiesCollection.h"
#include "nsVariant.h"
#include "nsDOMSettableTokenList.h"
#include "nsThreadUtils.h"
using namespace mozilla;
using namespace mozilla::dom;
#include "nsThreadUtils.h"
class nsINodeInfo;
class nsIDOMNodeList;
class nsRuleWalker;

Просмотреть файл

@ -10,11 +10,8 @@
#include "nsIDOMHTMLElement.h"
#include "nsINameSpaceManager.h" // for kNameSpaceID_None
#include "nsIFormControl.h"
#include "nsFrameLoader.h"
#include "nsGkAtoms.h"
#include "nsContentCreatorFunctions.h"
#include "nsDOMSettableTokenList.h"
#include "nsIDOMHTMLPropertiesCollection.h"
class nsIDOMAttr;
class nsIDOMEventListener;
@ -36,6 +33,8 @@ class nsHTMLFormElement;
class nsIDOMDOMStringMap;
class nsIDOMHTMLMenuElement;
class nsIDOMHTMLCollection;
class nsDOMSettableTokenList;
class nsIDOMHTMLPropertiesCollection;
typedef nsMappedAttributeElement nsGenericHTMLElementBase;

Просмотреть файл

@ -6,10 +6,12 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsGenericHTMLElement.h"
#include "nsIDOMHTMLFrameElement.h"
#include "nsIFrameLoader.h"
#include "nsIMozBrowserFrame.h"
#include "nsIDOMEventListener.h"
#include "nsFrameLoader.h"
/**
* A helper class for frame elements
*/

Просмотреть файл

@ -11,6 +11,8 @@
#include "prmem.h"
#include "nsDOMFile.h"
#include "nsICanvasRenderingContextInternal.h"
#include "nsIDOMCanvasRenderingContext2D.h"
#include "nsIScriptSecurityManager.h"
#include "nsIXPConnect.h"
#include "jsapi.h"
@ -453,15 +455,9 @@ nsHTMLCanvasElement::GetContextHelper(const nsAString& aContextId,
return NS_OK;
}
rv = ctx->SetCanvasElement(this);
if (NS_FAILED(rv)) {
*aContext = nsnull;
return rv;
}
ctx->SetCanvasElement(this);
ctx.forget(aContext);
return rv;
return NS_OK;
}
NS_IMETHODIMP

Просмотреть файл

@ -97,9 +97,4 @@ include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
include $(topsrcdir)/config/rules.mk
INCLUDES += \
-I$(srcdir)/../base/src \
-I$(srcdir)/../html/content/src \
$(NULL)
DEFINES += -D_IMPL_NS_LAYOUT

Просмотреть файл

@ -30,8 +30,3 @@ CPPSRCS = \
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
INCLUDES += \
-I$(srcdir)/../../base/src \
-I$(srcdir)/../../html/content/src \
$(NULL)

Просмотреть файл

@ -26,8 +26,3 @@ CPPSRCS = \
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
INCLUDES += \
-I$(srcdir)/../../base/src \
-I$(srcdir)/../../html/content/src \
$(NULL)

Просмотреть файл

@ -28,8 +28,6 @@ FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
INCLUDES += \
-I$(srcdir)/../../base/src \
-I$(srcdir)/../../html/content/src \
LOCAL_INCLUDES = \
$(MOZ_LIBVPX_INCLUDES) \
$(NULL)

Просмотреть файл

@ -157,6 +157,7 @@ interface nsIContentViewer : nsISupports
[noscript] readonly attribute nsIPresShellPtr presShell;
[noscript] readonly attribute nsPresContextPtr presContext;
// aDocument must not be null.
[noscript] void setDocumentInternal(in nsIDocumentPtr aDocument,
in boolean aForceReuseInnerWindow);
/**

Просмотреть файл

@ -320,6 +320,8 @@
#include "nsIDOMXPathNSResolver.h"
#include "nsIDOMXPathResult.h"
#include "nsIDOMMozBrowserFrame.h"
#include "nsIDOMHTMLPropertiesCollection.h"
#include "nsIDOMPropertyNodeList.h"
#include "nsIDOMGetSVGDocument.h"
#include "nsIDOMSVGAElement.h"

Просмотреть файл

@ -260,30 +260,32 @@ static void DestroyNsRect(void* aObject, nsIAtom* aPropertyName,
static void
MaybeReflowForInflationScreenWidthChange(nsPresContext *aPresContext)
{
if (aPresContext &&
nsLayoutUtils::FontSizeInflationEnabled(aPresContext) &&
nsLayoutUtils::FontSizeInflationMinTwips() != 0) {
bool changed;
aPresContext->ScreenWidthInchesForFontInflation(&changed);
if (changed) {
nsCOMPtr<nsISupports> container = aPresContext->GetContainer();
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
if (docShell) {
nsCOMPtr<nsIContentViewer> cv;
docShell->GetContentViewer(getter_AddRefs(cv));
nsCOMPtr<nsIMarkupDocumentViewer> mudv = do_QueryInterface(cv);
if (mudv) {
nsTArray<nsCOMPtr<nsIMarkupDocumentViewer> > array;
mudv->AppendSubtree(array);
for (PRUint32 i = 0, iEnd = array.Length(); i < iEnd; ++i) {
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIContentViewer> cv = do_QueryInterface(array[i]);
cv->GetPresShell(getter_AddRefs(shell));
if (shell) {
nsIFrame *rootFrame = shell->GetRootFrame();
if (rootFrame) {
shell->FrameNeedsReflow(rootFrame, nsIPresShell::eResize,
NS_FRAME_IS_DIRTY);
if (aPresContext) {
nsIPresShell* presShell = aPresContext->GetPresShell();
if (presShell && nsLayoutUtils::FontSizeInflationEnabled(aPresContext) &&
presShell->FontSizeInflationMinTwips() != 0) {
bool changed;
aPresContext->ScreenWidthInchesForFontInflation(&changed);
if (changed) {
nsCOMPtr<nsISupports> container = aPresContext->GetContainer();
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
if (docShell) {
nsCOMPtr<nsIContentViewer> cv;
docShell->GetContentViewer(getter_AddRefs(cv));
nsCOMPtr<nsIMarkupDocumentViewer> mudv = do_QueryInterface(cv);
if (mudv) {
nsTArray<nsCOMPtr<nsIMarkupDocumentViewer> > array;
mudv->AppendSubtree(array);
for (PRUint32 i = 0, iEnd = array.Length(); i < iEnd; ++i) {
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIContentViewer> cv = do_QueryInterface(array[i]);
cv->GetPresShell(getter_AddRefs(shell));
if (shell) {
nsIFrame *rootFrame = shell->GetRootFrame();
if (rootFrame) {
shell->FrameNeedsReflow(rootFrame, nsIPresShell::eResize,
NS_FRAME_IS_DIRTY);
}
}
}
}

Просмотреть файл

@ -49,12 +49,15 @@
#include "nsIDOMNodeFilter.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIPrincipal.h"
#include "mozilla/dom/Element.h"
#include "mozAutoDocUpdate.h"
#include "mozilla/Preferences.h"
#include "mozilla/LookAndFeel.h"
#include "nsFrameLoader.h"
#include "nsIObserverService.h"
#include "nsIScriptError.h"
#include "mozilla/dom/Element.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/Preferences.h"
#ifdef MOZ_XUL
#include "nsIDOMXULTextboxElement.h"
#include "nsIDOMXULMenuListElement.h"

Просмотреть файл

@ -1645,6 +1645,56 @@ nsGlobalWindow::SetOuterObject(JSContext* aCx, JSObject* aOuterObject)
return NS_OK;
}
/**
* Create a new global object that will be used for an inner window.
* Return the native global and an nsISupports 'holder' that can be used
* to manage the lifetime of it.
*/
static nsresult
CreateNativeGlobalForInner(JSContext* aCx,
nsGlobalWindow* aNewInner,
nsIURI* aURI,
bool aIsChrome,
nsIPrincipal* aPrincipal,
JSObject** aNativeGlobal,
nsIXPConnectJSObjectHolder** aHolder)
{
MOZ_ASSERT(aCx);
MOZ_ASSERT(aNewInner);
MOZ_ASSERT(aNewInner->IsInnerWindow());
MOZ_ASSERT(aPrincipal);
MOZ_ASSERT(aNativeGlobal);
MOZ_ASSERT(aHolder);
nsIXPConnect* xpc = nsContentUtils::XPConnect();
PRUint32 flags = aIsChrome ? nsIXPConnect::FLAG_SYSTEM_GLOBAL_OBJECT : 0;
nsCOMPtr<nsIPrincipal> systemPrincipal;
if (aIsChrome) {
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
ssm->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
MOZ_ASSERT(systemPrincipal);
}
nsRefPtr<nsIXPConnectJSObjectHolder> jsholder;
nsresult rv = xpc->InitClassesWithNewWrappedGlobal(
aCx, static_cast<nsIScriptGlobalObject*>(aNewInner),
aIsChrome ? systemPrincipal.get() : aPrincipal, flags,
getter_AddRefs(jsholder));
NS_ENSURE_SUCCESS(rv, rv);
MOZ_ASSERT(jsholder);
jsholder->GetJSObject(aNativeGlobal);
jsholder.forget(aHolder);
// Set the location information for the new global, so that tools like
// about:memory may use that information
MOZ_ASSERT(*aNativeGlobal);
xpc::SetLocationForGlobal(*aNativeGlobal, aURI);
return NS_OK;
}
nsresult
nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
nsISupports* aState,
@ -1654,12 +1704,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
NS_PRECONDITION(mDocumentPrincipal == nsnull,
"mDocumentPrincipal prematurely set!");
if (!aDocument) {
NS_ERROR("SetNewDocument(null) called!");
return NS_ERROR_INVALID_ARG;
}
MOZ_ASSERT(aDocument);
if (IsInnerWindow()) {
if (!mOuterWindow) {
@ -1804,10 +1849,6 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
}
if (!aState) {
// This is redundant if we're restoring from a previous inner window.
nsIScriptGlobalObject *sgo =
(nsIScriptGlobalObject *)newInnerWindow.get();
// Freeze the outer window and null out the inner window so
// that initializing classes on the new inner doesn't end up
// reaching into the old inner window for classes etc.
@ -1824,14 +1865,12 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
mCreatingInnerWindow = true;
// Every script context we are initialized with must create a
// new global.
nsCOMPtr<nsIXPConnectJSObjectHolder> &holder = mInnerWindowHolder;
rv = mContext->CreateNativeGlobalForInner(sgo,
aDocument->GetDocumentURI(),
isChrome,
aDocument->NodePrincipal(),
&newInnerWindow->mJSObject,
getter_AddRefs(holder));
NS_ASSERTION(NS_SUCCEEDED(rv) && newInnerWindow->mJSObject && holder,
rv = CreateNativeGlobalForInner(cx, newInnerWindow,
aDocument->GetDocumentURI(), isChrome,
aDocument->NodePrincipal(),
&newInnerWindow->mJSObject,
getter_AddRefs(mInnerWindowHolder));
NS_ASSERTION(NS_SUCCEEDED(rv) && newInnerWindow->mJSObject && mInnerWindowHolder,
"Failed to get script global and holder");
mCreatingInnerWindow = false;
@ -5936,8 +5975,8 @@ struct StructuredCloneInfo {
static JSObject*
PostMessageReadStructuredClone(JSContext* cx,
JSStructuredCloneReader* reader,
uint32 tag,
uint32 data,
uint32_t tag,
uint32_t data,
void* closure)
{
NS_ASSERTION(closure, "Must have closure!");
@ -10551,11 +10590,11 @@ nsGlobalModalWindow::SetNewDocument(nsIDocument *aDocument,
nsISupports *aState,
bool aForceReuseInnerWindow)
{
MOZ_ASSERT(aDocument);
// If we're loading a new document into a modal dialog, clear the
// return value that was set, if any, by the current document.
if (aDocument) {
mReturnValue = nsnull;
}
mReturnValue = nsnull;
return nsGlobalWindow::SetNewDocument(aDocument, aState,
aForceReuseInnerWindow);

Просмотреть файл

@ -45,8 +45,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptContextPrincipal,
NS_ISCRIPTCONTEXTPRINCIPAL_IID)
#define NS_ISCRIPTCONTEXT_IID \
{ 0xec47ccd4, 0x5f6a, 0x40d6, \
{ 0xbc, 0x2f, 0x5a, 0x1e, 0xd3, 0xe4, 0xb4, 0xff } }
{ 0x9a4df96d, 0xa231, 0x4108, \
{ 0xb5, 0xbc, 0xaf, 0x67, 0x7a, 0x36, 0xa7, 0x44 } }
/* This MUST match JSVERSION_DEFAULT. This version stuff if we don't
know what language we have is a little silly... */
@ -259,30 +259,11 @@ public:
**/
virtual JSObject* GetNativeGlobal() = 0;
/**
* Create a new global object that will be used for an inner window.
* Return the native global and an nsISupports 'holder' that can be used
* to manage the lifetime of it.
*/
virtual nsresult CreateNativeGlobalForInner(
nsIScriptGlobalObject *aNewInner,
nsIURI *aURI,
bool aIsChrome,
nsIPrincipal *aPrincipal,
JSObject** aNativeGlobal,
nsISupports **aHolder) = 0;
/**
* Initialize the context generally. Does not create a global object.
**/
virtual nsresult InitContext() = 0;
/**
* Prepares this context for use with the current inner window for the
* context's global object. This must be called after CreateOuterObject.
*/
virtual nsresult InitOuterWindow() = 0;
/**
* Check to see if context is as yet intialized. Used to prevent
* reentrancy issues during the initialization process.

Просмотреть файл

@ -68,8 +68,8 @@ NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal,
#define NS_ISCRIPTGLOBALOBJECT_IID \
{ 0xd1549969, 0x92df, 0x4a75, \
{ 0x8c, 0x12, 0x35, 0x14, 0xd1, 0x0b, 0xbc, 0x18 } }
{ 0x92569431, 0x6e6e, 0x408a, \
{ 0xa8, 0x8c, 0x45, 0x28, 0x5c, 0x1c, 0x85, 0x73 } }
/**
* The global object which keeps a script context for each supported script

Просмотреть файл

@ -2067,42 +2067,6 @@ nsJSContext::GetNativeGlobal()
return JS_GetGlobalObject(mContext);
}
nsresult
nsJSContext::CreateNativeGlobalForInner(
nsIScriptGlobalObject *aNewInner,
nsIURI *aURI,
bool aIsChrome,
nsIPrincipal *aPrincipal,
JSObject** aNativeGlobal, nsISupports **aHolder)
{
nsIXPConnect *xpc = nsContentUtils::XPConnect();
PRUint32 flags = aIsChrome? nsIXPConnect::FLAG_SYSTEM_GLOBAL_OBJECT : 0;
nsCOMPtr<nsIPrincipal> systemPrincipal;
if (aIsChrome) {
nsIScriptSecurityManager *ssm = nsContentUtils::GetSecurityManager();
ssm->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
}
nsRefPtr<nsIXPConnectJSObjectHolder> jsholder;
nsresult rv = xpc->
InitClassesWithNewWrappedGlobal(mContext, aNewInner,
aIsChrome ? systemPrincipal.get() : aPrincipal,
flags, getter_AddRefs(jsholder));
if (NS_FAILED(rv)) {
return rv;
}
jsholder->GetJSObject(aNativeGlobal);
jsholder.forget(aHolder);
// Set the location information for the new global, so that tools like
// about:memory may use that information
MOZ_ASSERT(aNativeGlobal && *aNativeGlobal);
xpc::SetLocationForGlobal(*aNativeGlobal, aURI);
return NS_OK;
}
JSContext*
nsJSContext::GetNativeContext()
{
@ -2126,17 +2090,6 @@ nsJSContext::InitContext()
return NS_OK;
}
nsresult
nsJSContext::InitOuterWindow()
{
JSObject *global = JS_ObjectToInnerObject(mContext, JS_GetGlobalObject(mContext));
nsresult rv = InitClasses(global); // this will complete global object initialization
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
nsresult
nsJSContext::InitializeExternalClasses()
{

Просмотреть файл

@ -107,15 +107,7 @@ public:
virtual JSContext* GetNativeContext();
virtual JSObject* GetNativeGlobal();
virtual nsresult CreateNativeGlobalForInner(
nsIScriptGlobalObject *aGlobal,
nsIURI *aURI,
bool aIsChrome,
nsIPrincipal *aPrincipal,
JSObject** aNativeGlobal,
nsISupports **aHolder);
virtual nsresult InitContext();
virtual nsresult InitOuterWindow();
virtual bool IsContextInitialized();
virtual void ScriptEvaluated(bool aTerminated);

Просмотреть файл

@ -370,6 +370,8 @@ public:
* called with a pointer to the current document, in that case the
* document remains unchanged, but a new inner window will be
* created.
*
* aDocument must not be null.
*/
virtual nsresult SetNewDocument(nsIDocument *aDocument,
nsISupports *aState,

Просмотреть файл

@ -21,7 +21,6 @@
#include "nsUnicharUtils.h"
#include "nsICommandParams.h"
#include "nsComponentManagerUtils.h"
#include "nsCRT.h"
#include "mozilla/Assertions.h"
@ -1351,10 +1350,11 @@ nsInsertHTMLCommand::GetCommandStateParams(const char *aCommandName,
NS_IMPL_ISUPPORTS_INHERITED0(nsInsertTagCommand, nsBaseComposerCommand)
nsInsertTagCommand::nsInsertTagCommand(const char* aTagName)
nsInsertTagCommand::nsInsertTagCommand(nsIAtom* aTagName)
: nsBaseComposerCommand()
, mTagName(aTagName)
{
MOZ_ASSERT(mTagName);
}
nsInsertTagCommand::~nsInsertTagCommand()
@ -1380,21 +1380,17 @@ nsInsertTagCommand::IsCommandEnabled(const char * aCommandName,
NS_IMETHODIMP
nsInsertTagCommand::DoCommand(const char *aCmdName, nsISupports *refCon)
{
if (0 == nsCRT::strcmp(mTagName, "hr"))
{
nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);
NS_ENSURE_TRUE(editor, NS_ERROR_NOT_IMPLEMENTED);
NS_ENSURE_TRUE(mTagName == nsGkAtoms::hr, NS_ERROR_NOT_IMPLEMENTED);
nsCOMPtr<nsIDOMElement> domElem;
nsresult rv;
rv = editor->CreateElementWithDefaults(NS_ConvertASCIItoUTF16(mTagName),
getter_AddRefs(domElem));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);
NS_ENSURE_TRUE(editor, NS_ERROR_NOT_IMPLEMENTED);
return editor->InsertElementAtSelection(domElem, true);
}
nsCOMPtr<nsIDOMElement> domElem;
nsresult rv = editor->CreateElementWithDefaults(
nsDependentAtomString(mTagName), getter_AddRefs(domElem));
NS_ENSURE_SUCCESS(rv, rv);
return NS_ERROR_NOT_IMPLEMENTED;
return editor->InsertElementAtSelection(domElem, true);
}
NS_IMETHODIMP
@ -1405,8 +1401,9 @@ nsInsertTagCommand::DoCommandParams(const char *aCommandName,
NS_ENSURE_ARG_POINTER(refCon);
// inserting an hr shouldn't have an parameters, just call DoCommand for that
if (0 == nsCRT::strcmp(mTagName, "hr"))
if (mTagName == nsGkAtoms::hr) {
return DoCommand(aCommandName, refCon);
}
NS_ENSURE_ARG_POINTER(aParams);
@ -1424,16 +1421,16 @@ nsInsertTagCommand::DoCommandParams(const char *aCommandName,
// filter out tags we don't know how to insert
nsAutoString attributeType;
if (0 == nsCRT::strcmp(mTagName, "a")) {
if (mTagName == nsGkAtoms::a) {
attributeType.AssignLiteral("href");
} else if (0 == nsCRT::strcmp(mTagName, "img")) {
} else if (mTagName == nsGkAtoms::img) {
attributeType.AssignLiteral("src");
} else {
return NS_ERROR_NOT_IMPLEMENTED;
}
nsCOMPtr<nsIDOMElement> domElem;
rv = editor->CreateElementWithDefaults(NS_ConvertASCIItoUTF16(mTagName),
rv = editor->CreateElementWithDefaults(nsDependentAtomString(mTagName),
getter_AddRefs(domElem));
NS_ENSURE_SUCCESS(rv, rv);
@ -1441,7 +1438,7 @@ nsInsertTagCommand::DoCommandParams(const char *aCommandName,
NS_ENSURE_SUCCESS(rv, rv);
// do actual insertion
if (0 == nsCRT::strcmp(mTagName, "a"))
if (mTagName == nsGkAtoms::a)
return editor->InsertLinkAroundSelection(domElem);
return editor->InsertElementAtSelection(domElem, true);

Просмотреть файл

@ -89,8 +89,7 @@ protected:
class nsInsertTagCommand : public nsBaseComposerCommand
{
public:
nsInsertTagCommand(const char* aTagName);
explicit nsInsertTagCommand(nsIAtom* aTagName);
virtual ~nsInsertTagCommand();
NS_DECL_ISUPPORTS_INHERITED
@ -99,7 +98,7 @@ public:
protected:
const char* mTagName;
nsIAtom* mTagName;
};

Просмотреть файл

@ -124,9 +124,9 @@ nsComposerController::RegisterHTMLEditorCommands(
// Insert content
NS_REGISTER_ONE_COMMAND(nsInsertHTMLCommand, "cmd_insertHTML");
NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertLinkNoUI", "a");
NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertImageNoUI", "img");
NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertHR", "hr");
NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertLinkNoUI", nsGkAtoms::a);
NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertImageNoUI", nsGkAtoms::img);
NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertHR", nsGkAtoms::hr);
NS_REGISTER_ONE_COMMAND(nsAbsolutePositioningCommand, "cmd_absPos");
NS_REGISTER_ONE_COMMAND(nsDecreaseZIndexCommand, "cmd_decreaseZIndex");

Просмотреть файл

@ -11,13 +11,14 @@
#include "nsIDOMElement.h"
#include "nsReadableUtils.h"
//included for new nsEditor::CreateContent()
#include "nsIContent.h"
#include "mozilla/dom/Element.h"
#ifdef NS_DEBUG
static bool gNoisy = false;
#endif
using namespace mozilla;
CreateElementTxn::CreateElementTxn()
: EditTxn()
{
@ -53,14 +54,6 @@ NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor,
mTag = aTag;
mParent = do_QueryInterface(aParent);
mOffsetInParent = aOffsetInParent;
#ifdef NS_DEBUG
{
nsCOMPtr<nsIDOMNodeList> testChildNodes;
nsresult testResult = mParent->GetChildNodes(getter_AddRefs(testChildNodes));
NS_ASSERTION(testChildNodes, "bad parent type, can't have children.");
NS_ASSERTION(NS_SUCCEEDED(testResult), "bad result.");
}
#endif
return NS_OK;
}
@ -80,19 +73,16 @@ NS_IMETHODIMP CreateElementTxn::DoTransaction(void)
NS_ASSERTION(mEditor && mParent, "bad state");
NS_ENSURE_TRUE(mEditor && mParent, NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsIContent> newContent;
nsCOMPtr<dom::Element> newContent;
//new call to use instead to get proper HTML element, bug# 39919
nsresult result = mEditor->CreateHTMLContent(mTag, getter_AddRefs(newContent));
NS_ENSURE_SUCCESS(result, result);
nsCOMPtr<nsIDOMElement>newElement = do_QueryInterface(newContent);
NS_ENSURE_TRUE(newElement, NS_ERROR_NULL_POINTER);
mNewNode = do_QueryInterface(newElement);
NS_ENSURE_STATE(newContent);
mNewNode = newContent->AsDOMNode();
// Try to insert formatting whitespace for the new node:
mEditor->MarkNodeDirty(mNewNode);
NS_ASSERTION(((NS_SUCCEEDED(result)) && (mNewNode)), "could not create element.");
NS_ENSURE_TRUE(mNewNode, NS_ERROR_NULL_POINTER);
#ifdef NS_DEBUG
if (gNoisy)
@ -102,50 +92,43 @@ NS_IMETHODIMP CreateElementTxn::DoTransaction(void)
#endif
// insert the new node
if (CreateElementTxn::eAppend == PRInt32(mOffsetInParent)) {
nsCOMPtr<nsIDOMNode> resultNode;
return mParent->AppendChild(mNewNode, getter_AddRefs(resultNode));
}
nsCOMPtr<nsINode> parent = do_QueryInterface(mParent);
NS_ENSURE_STATE(parent);
mOffsetInParent = NS_MIN(mOffsetInParent, parent->GetChildCount());
// note, it's ok for mRefNode to be null. that means append
nsIContent* refNode = parent->GetChildAt(mOffsetInParent);
mRefNode = refNode ? refNode->AsDOMNode() : nsnull;
nsCOMPtr<nsIDOMNode> resultNode;
if (CreateElementTxn::eAppend==(PRInt32)mOffsetInParent)
{
result = mParent->AppendChild(mNewNode, getter_AddRefs(resultNode));
result = mParent->InsertBefore(mNewNode, mRefNode, getter_AddRefs(resultNode));
NS_ENSURE_SUCCESS(result, result);
// only set selection to insertion point if editor gives permission
bool bAdjustSelection;
mEditor->ShouldTxnSetSelection(&bAdjustSelection);
if (!bAdjustSelection) {
// do nothing - dom range gravity will adjust selection
return NS_OK;
}
else
{
nsCOMPtr<nsIDOMNodeList> childNodes;
result = mParent->GetChildNodes(getter_AddRefs(childNodes));
if ((NS_SUCCEEDED(result)) && (childNodes))
{
PRUint32 count;
childNodes->GetLength(&count);
if (mOffsetInParent>count)
mOffsetInParent = count;
result = childNodes->Item(mOffsetInParent, getter_AddRefs(mRefNode));
NS_ENSURE_SUCCESS(result, result); // note, it's ok for mRefNode to be null. that means append
result = mParent->InsertBefore(mNewNode, mRefNode, getter_AddRefs(resultNode));
NS_ENSURE_SUCCESS(result, result);
nsCOMPtr<nsISelection> selection;
result = mEditor->GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(result, result);
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
// only set selection to insertion point if editor gives permission
bool bAdjustSelection;
mEditor->ShouldTxnSetSelection(&bAdjustSelection);
if (bAdjustSelection)
{
nsCOMPtr<nsISelection> selection;
result = mEditor->GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(result, result);
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIContent> parentContent = do_QueryInterface(mParent);
NS_ENSURE_STATE(parentContent);
PRInt32 offset=0;
result = nsEditor::GetChildOffset(mNewNode, mParent, offset);
NS_ENSURE_SUCCESS(result, result);
result = selection->Collapse(mParent, offset+1);
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after insert.");
}
else
{
// do nothing - dom range gravity will adjust selection
}
}
}
result = selection->CollapseNative(parentContent,
parentContent->IndexOf(newContent) + 1);
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after insert.");
return result;
}

Просмотреть файл

@ -86,44 +86,24 @@ NS_IMETHODIMP DeleteRangeTxn::Init(nsIEditor *aEditor,
return NS_ERROR_FAILURE;
}
#ifdef NS_DEBUG
#ifdef DEBUG
{
PRUint32 count;
nsCOMPtr<nsIDOMCharacterData> textNode = do_QueryInterface(mStartParent);
if (textNode)
textNode->GetLength(&count);
else
{
nsCOMPtr<nsIDOMNodeList> children;
result = mStartParent->GetChildNodes(getter_AddRefs(children));
NS_ASSERTION(((NS_SUCCEEDED(result)) && children), "bad start child list");
children->GetLength(&count);
}
NS_ASSERTION(mStartOffset<=(PRInt32)count, "bad start offset");
nsCOMPtr<nsINode> start = do_QueryInterface(mStartParent);
MOZ_ASSERT(start);
NS_ASSERTION(mStartOffset <= PRInt32(start->Length()), "bad start offset");
textNode = do_QueryInterface(mEndParent);
if (textNode)
textNode->GetLength(&count);
else
{
nsCOMPtr<nsIDOMNodeList> children;
result = mEndParent->GetChildNodes(getter_AddRefs(children));
NS_ASSERTION(((NS_SUCCEEDED(result)) && children), "bad end child list");
children->GetLength(&count);
}
NS_ASSERTION(mEndOffset<=(PRInt32)count, "bad end offset");
nsCOMPtr<nsINode> end = do_QueryInterface(mEndParent);
MOZ_ASSERT(end);
NS_ASSERTION(mEndOffset <= PRInt32(end->Length()), "bad end offset");
#ifdef NS_DEBUG
if (gNoisy)
{
if (gNoisy) {
printf ("DeleteRange: %d of %p to %d of %p\n",
mStartOffset, (void *)mStartParent, mEndOffset, (void *)mEndParent);
}
#endif
}
#endif
return result;
#endif // DEBUG
return NS_OK;
}
NS_IMETHODIMP DeleteRangeTxn::DoTransaction(void)
@ -220,50 +200,40 @@ DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent,
PRUint32 aStartOffset,
PRUint32 aEndOffset)
{
nsresult result = NS_OK;
// see what kind of node we have
nsCOMPtr<nsIDOMCharacterData> textNode = do_QueryInterface(aStartParent);
if (textNode)
{ // if the node is a text node, then delete text content
if (textNode) {
// if the node is a text node, then delete text content
nsRefPtr<DeleteTextTxn> txn = new DeleteTextTxn();
NS_ENSURE_TRUE(txn, NS_ERROR_OUT_OF_MEMORY);
PRInt32 numToDel;
if (aStartOffset==aEndOffset)
numToDel = 1;
else
numToDel = aEndOffset-aStartOffset;
result = txn->Init(mEditor, textNode, aStartOffset, numToDel, mRangeUpdater);
nsresult rv = txn->Init(mEditor, textNode, aStartOffset, numToDel, mRangeUpdater);
NS_ENSURE_SUCCESS(rv, rv);
AppendChild(txn);
return NS_OK;
}
nsCOMPtr<nsINode> startParent = do_QueryInterface(aStartParent);
NS_ENSURE_STATE(startParent);
NS_ASSERTION(aEndOffset <= startParent->GetChildCount(), "bad aEndOffset");
nsCOMPtr<nsIContent> child = startParent->GetChildAt(aStartOffset);
NS_ENSURE_STATE(child);
nsresult result = NS_OK;
for (PRUint32 i = aStartOffset; i < aEndOffset; ++i) {
nsRefPtr<DeleteElementTxn> txn = new DeleteElementTxn();
result = txn->Init(mEditor, child->AsDOMNode(), mRangeUpdater);
if (NS_SUCCEEDED(result))
AppendChild(txn);
}
else
{
nsCOMPtr<nsIDOMNodeList> children;
result = aStartParent->GetChildNodes(getter_AddRefs(children));
NS_ENSURE_SUCCESS(result, result);
NS_ENSURE_TRUE(children, NS_ERROR_NULL_POINTER);
#ifdef DEBUG
PRUint32 childCount;
children->GetLength(&childCount);
NS_ASSERTION(aEndOffset<=childCount, "bad aEndOffset");
#endif
PRUint32 i;
for (i=aStartOffset; i<aEndOffset; i++)
{
nsCOMPtr<nsIDOMNode> child;
result = children->Item(i, getter_AddRefs(child));
NS_ENSURE_SUCCESS(result, result);
NS_ENSURE_TRUE(child, NS_ERROR_NULL_POINTER);
nsRefPtr<DeleteElementTxn> txn = new DeleteElementTxn();
NS_ENSURE_TRUE(txn, NS_ERROR_OUT_OF_MEMORY);
result = txn->Init(mEditor, child, mRangeUpdater);
if (NS_SUCCEEDED(result))
AppendChild(txn);
}
child = child->GetNextSibling();
}
return result;
}

Просмотреть файл

@ -75,26 +75,23 @@ NS_IMETHODIMP InsertElementTxn::DoTransaction(void)
NS_ENSURE_TRUE(mNode && mParent, NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsIDOMNodeList> childNodes;
nsresult result = mParent->GetChildNodes(getter_AddRefs(childNodes));
NS_ENSURE_SUCCESS(result, result);
nsCOMPtr<nsIDOMNode>refNode;
if (childNodes)
{
PRUint32 count;
childNodes->GetLength(&count);
if (mOffset>(PRInt32)count) mOffset = count;
nsCOMPtr<nsINode> parent = do_QueryInterface(mParent);
NS_ENSURE_STATE(parent);
PRUint32 count = parent->GetChildCount();
if (mOffset > PRInt32(count) || mOffset == -1) {
// -1 is sentinel value meaning "append at end"
if (mOffset == -1) mOffset = count;
result = childNodes->Item(mOffset, getter_AddRefs(refNode));
NS_ENSURE_SUCCESS(result, result);
// note, it's ok for mRefNode to be null. that means append
mOffset = count;
}
nsIContent* refContent = parent->GetChildAt(mOffset);
// note, it's ok for refNode to be null. that means append
nsCOMPtr<nsIDOMNode> refNode = refContent ? refContent->AsDOMNode() : nsnull;
mEditor->MarkNodeDirty(mNode);
nsCOMPtr<nsIDOMNode> resultNode;
result = mParent->InsertBefore(mNode, refNode, getter_AddRefs(resultNode));
nsresult result = mParent->InsertBefore(mNode, refNode, getter_AddRefs(resultNode));
NS_ENSURE_SUCCESS(result, result);
NS_ENSURE_TRUE(resultNode, NS_ERROR_NULL_POINTER);

Просмотреть файл

@ -69,55 +69,39 @@ NS_IMETHODIMP JoinElementTxn::DoTransaction(void)
NS_PRECONDITION((mEditor && mLeftNode && mRightNode), "null arg");
if (!mEditor || !mLeftNode || !mRightNode) { return NS_ERROR_NOT_INITIALIZED; }
nsCOMPtr<nsINode> leftNode = do_QueryInterface(mLeftNode);
NS_ENSURE_STATE(leftNode);
nsCOMPtr<nsINode> rightNode = do_QueryInterface(mRightNode);
NS_ENSURE_STATE(rightNode);
// get the parent node
nsCOMPtr<nsIDOMNode>leftParent;
nsresult result = mLeftNode->GetParentNode(getter_AddRefs(leftParent));
NS_ENSURE_SUCCESS(result, result);
nsCOMPtr<nsINode> leftParent = leftNode->GetNodeParent();
NS_ENSURE_TRUE(leftParent, NS_ERROR_NULL_POINTER);
// verify that mLeftNode and mRightNode have the same parent
nsCOMPtr<nsIDOMNode>rightParent;
result = mRightNode->GetParentNode(getter_AddRefs(rightParent));
NS_ENSURE_SUCCESS(result, result);
nsCOMPtr<nsINode> rightParent = rightNode->GetNodeParent();
NS_ENSURE_TRUE(rightParent, NS_ERROR_NULL_POINTER);
if (leftParent==rightParent)
{
mParent= do_QueryInterface(leftParent); // set this instance mParent.
// Other methods will see a non-null mParent and know all is well
nsCOMPtr<nsIDOMCharacterData> leftNodeAsText = do_QueryInterface(mLeftNode);
if (leftNodeAsText)
{
leftNodeAsText->GetLength(&mOffset);
}
else
{
nsCOMPtr<nsIDOMNodeList> childNodes;
result = mLeftNode->GetChildNodes(getter_AddRefs(childNodes));
NS_ENSURE_SUCCESS(result, result);
if (childNodes)
{
childNodes->GetLength(&mOffset);
}
}
result = mEditor->JoinNodesImpl(mRightNode, mLeftNode, mParent, false);
#ifdef NS_DEBUG
if (NS_SUCCEEDED(result))
{
if (gNoisy)
{
printf(" left node = %p removed\n",
static_cast<void*>(mLeftNode.get()));
}
}
#endif
}
else
{
if (leftParent != rightParent) {
NS_ASSERTION(false, "2 nodes do not have same parent");
return NS_ERROR_INVALID_ARG;
}
return result;
// set this instance mParent.
// Other methods will see a non-null mParent and know all is well
mParent = leftParent->AsDOMNode();
mOffset = leftNode->Length();
nsresult rv = mEditor->JoinNodesImpl(mRightNode, mLeftNode, mParent, false);
#ifdef DEBUG
if (NS_SUCCEEDED(rv) && gNoisy) {
printf(" left node = %p removed\n", static_cast<void*>(mLeftNode.get()));
}
#endif
return rv;
}
//XXX: what if instead of split, we just deleted the unneeded children of mRight

Просмотреть файл

@ -1534,55 +1534,73 @@ nsEditor::ReplaceContainer(nsIDOMNode *inNode,
bool aCloneAttributes)
{
NS_ENSURE_TRUE(inNode && outNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> parent;
PRInt32 offset;
nsresult res = GetNodeLocation(inNode, address_of(parent), &offset);
NS_ENSURE_SUCCESS(res, res);
nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
NS_ENSURE_STATE(node);
nsCOMPtr<dom::Element> element;
nsresult rv = ReplaceContainer(node, getter_AddRefs(element), aNodeType,
aAttribute, aValue, aCloneAttributes);
*outNode = element ? element->AsDOMNode() : nsnull;
return rv;
}
nsresult
nsEditor::ReplaceContainer(nsINode* aNode,
dom::Element** outNode,
const nsAString& aNodeType,
const nsAString* aAttribute,
const nsAString* aValue,
bool aCloneAttributes)
{
MOZ_ASSERT(aNode);
MOZ_ASSERT(outNode);
*outNode = nsnull;
nsCOMPtr<nsIContent> parent = aNode->GetParent();
NS_ENSURE_STATE(parent);
PRInt32 offset = parent->IndexOf(aNode);
// create new container
nsCOMPtr<nsIContent> newContent;
//new call to use instead to get proper HTML element, bug# 39919
res = CreateHTMLContent(aNodeType, getter_AddRefs(newContent));
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(newContent);
nsresult res = CreateHTMLContent(aNodeType, outNode);
NS_ENSURE_SUCCESS(res, res);
*outNode = do_QueryInterface(elem);
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(*outNode);
nsIDOMNode* inNode = aNode->AsDOMNode();
// set attribute if needed
if (aAttribute && aValue && !aAttribute->IsEmpty())
{
if (aAttribute && aValue && !aAttribute->IsEmpty()) {
res = elem->SetAttribute(*aAttribute, *aValue);
NS_ENSURE_SUCCESS(res, res);
}
if (aCloneAttributes)
{
nsCOMPtr<nsIDOMNode>newNode = do_QueryInterface(elem);
res = CloneAttributes(newNode, inNode);
if (aCloneAttributes) {
res = CloneAttributes(elem, inNode);
NS_ENSURE_SUCCESS(res, res);
}
// notify our internal selection state listener
// (Note: A nsAutoSelectionReset object must be created
// before calling this to initialize mRangeUpdater)
nsAutoReplaceContainerSelNotify selStateNotify(mRangeUpdater, inNode, *outNode);
nsAutoReplaceContainerSelNotify selStateNotify(mRangeUpdater, inNode, elem);
{
nsAutoTxnsConserveSelection conserveSelection(this);
nsCOMPtr<nsIDOMNode> child;
bool bHasMoreChildren;
inNode->HasChildNodes(&bHasMoreChildren);
while (bHasMoreChildren)
{
inNode->GetFirstChild(getter_AddRefs(child));
while (aNode->HasChildren()) {
nsCOMPtr<nsIDOMNode> child = aNode->GetFirstChild()->AsDOMNode();
res = DeleteNode(child);
NS_ENSURE_SUCCESS(res, res);
res = InsertNode(child, *outNode, -1);
res = InsertNode(child, elem, -1);
NS_ENSURE_SUCCESS(res, res);
inNode->HasChildNodes(&bHasMoreChildren);
}
}
// insert new container into tree
res = InsertNode( *outNode, parent, offset);
res = InsertNode(elem, parent->AsDOMNode(), offset);
NS_ENSURE_SUCCESS(res, res);
// delete old container
@ -1594,47 +1612,39 @@ nsEditor::ReplaceContainer(nsIDOMNode *inNode,
// the parent of inNode
//
nsresult
nsEditor::RemoveContainer(nsINode* aNode)
nsEditor::RemoveContainer(nsIDOMNode* aNode)
{
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode);
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
return RemoveContainer(node);
}
nsresult
nsEditor::RemoveContainer(nsIDOMNode *inNode)
nsEditor::RemoveContainer(nsINode* aNode)
{
NS_ENSURE_TRUE(inNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> parent;
PRInt32 offset;
nsresult res = GetNodeLocation(inNode, address_of(parent), &offset);
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
nsINode* parent = aNode->GetNodeParent();
NS_ENSURE_STATE(parent);
PRInt32 offset = parent->IndexOf(aNode);
// loop through the child nodes of inNode and promote them
// into inNode's parent.
bool bHasMoreChildren;
inNode->HasChildNodes(&bHasMoreChildren);
nsCOMPtr<nsIDOMNodeList> nodeList;
res = inNode->GetChildNodes(getter_AddRefs(nodeList));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(nodeList, NS_ERROR_NULL_POINTER);
PRUint32 nodeOrigLen;
nodeList->GetLength(&nodeOrigLen);
PRUint32 nodeOrigLen = aNode->GetChildCount();
// notify our internal selection state listener
nsAutoRemoveContainerSelNotify selNotify(mRangeUpdater, inNode, parent, offset, nodeOrigLen);
nsAutoRemoveContainerSelNotify selNotify(mRangeUpdater, aNode, parent, offset, nodeOrigLen);
nsCOMPtr<nsIDOMNode> child;
while (bHasMoreChildren)
{
inNode->GetLastChild(getter_AddRefs(child));
res = DeleteNode(child);
NS_ENSURE_SUCCESS(res, res);
res = InsertNode(child, parent, offset);
NS_ENSURE_SUCCESS(res, res);
inNode->HasChildNodes(&bHasMoreChildren);
while (aNode->HasChildren()) {
nsIContent* child = aNode->GetLastChild();
nsresult rv = DeleteNode(child->AsDOMNode());
NS_ENSURE_SUCCESS(rv, rv);
rv = InsertNode(child->AsDOMNode(), parent->AsDOMNode(), offset);
NS_ENSURE_SUCCESS(rv, rv);
}
return DeleteNode(inNode);
return DeleteNode(aNode->AsDOMNode());
}
@ -1652,24 +1662,41 @@ nsEditor::InsertContainerAbove( nsIDOMNode *inNode,
const nsAString *aValue)
{
NS_ENSURE_TRUE(inNode && outNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> parent;
PRInt32 offset;
nsresult res = GetNodeLocation(inNode, address_of(parent), &offset);
NS_ENSURE_SUCCESS(res, res);
nsCOMPtr<nsIContent> node = do_QueryInterface(inNode);
NS_ENSURE_STATE(node);
nsCOMPtr<dom::Element> element;
nsresult rv = InsertContainerAbove(node, getter_AddRefs(element), aNodeType,
aAttribute, aValue);
*outNode = element ? element->AsDOMNode() : nsnull;
return rv;
}
nsresult
nsEditor::InsertContainerAbove(nsIContent* aNode,
dom::Element** aOutNode,
const nsAString& aNodeType,
const nsAString* aAttribute,
const nsAString* aValue)
{
MOZ_ASSERT(aNode);
nsCOMPtr<nsIContent> parent = aNode->GetParent();
NS_ENSURE_STATE(parent);
PRInt32 offset = parent->IndexOf(aNode);
// create new container
nsCOMPtr<nsIContent> newContent;
nsCOMPtr<dom::Element> newContent;
//new call to use instead to get proper HTML element, bug# 39919
res = CreateHTMLContent(aNodeType, getter_AddRefs(newContent));
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(newContent);
nsresult res = CreateHTMLContent(aNodeType, getter_AddRefs(newContent));
NS_ENSURE_SUCCESS(res, res);
*outNode = do_QueryInterface(elem);
// set attribute if needed
if (aAttribute && aValue && !aAttribute->IsEmpty())
{
res = elem->SetAttribute(*aAttribute, *aValue);
if (aAttribute && aValue && !aAttribute->IsEmpty()) {
nsIDOMNode* elem = newContent->AsDOMNode();
res = static_cast<nsIDOMElement*>(elem)->SetAttribute(*aAttribute, *aValue);
NS_ENSURE_SUCCESS(res, res);
}
@ -1677,17 +1704,19 @@ nsEditor::InsertContainerAbove( nsIDOMNode *inNode,
nsAutoInsertContainerSelNotify selNotify(mRangeUpdater);
// put inNode in new parent, outNode
res = DeleteNode(inNode);
res = DeleteNode(aNode->AsDOMNode());
NS_ENSURE_SUCCESS(res, res);
{
nsAutoTxnsConserveSelection conserveSelection(this);
res = InsertNode(inNode, *outNode, 0);
res = InsertNode(aNode->AsDOMNode(), newContent->AsDOMNode(), 0);
NS_ENSURE_SUCCESS(res, res);
}
// put new parent in doc
return InsertNode(*outNode, parent, offset);
res = InsertNode(newContent->AsDOMNode(), parent->AsDOMNode(), offset);
newContent.forget(aOutNode);
return res;
}
///////////////////////////////////////////////////////////////////////////
@ -3756,40 +3785,19 @@ nsEditor::IsMozEditorBogusNode(nsIContent *element)
kMOZEditorBogusNodeValue, eCaseMatters);
}
nsresult
nsEditor::CountEditableChildren(nsIDOMNode *aNode, PRUint32 &outCount)
PRUint32
nsEditor::CountEditableChildren(nsINode* aNode)
{
outCount = 0;
if (!aNode) { return NS_ERROR_NULL_POINTER; }
nsresult res=NS_OK;
bool hasChildNodes;
aNode->HasChildNodes(&hasChildNodes);
if (hasChildNodes)
{
nsCOMPtr<nsIDOMNodeList>nodeList;
res = aNode->GetChildNodes(getter_AddRefs(nodeList));
if (NS_SUCCEEDED(res) && nodeList)
{
PRUint32 i;
PRUint32 len;
nodeList->GetLength(&len);
for (i=0 ; i<len; i++)
{
nsCOMPtr<nsIDOMNode> child;
res = nodeList->Item((PRInt32)i, getter_AddRefs(child));
if ((NS_SUCCEEDED(res)) && (child))
{
if (IsEditable(child))
{
outCount++;
}
}
}
MOZ_ASSERT(aNode);
PRUint32 count = 0;
for (nsIContent* child = aNode->GetFirstChild();
child;
child = child->GetNextSibling()) {
if (IsEditable(child)) {
++count;
}
else if (!nodeList)
res = NS_ERROR_NULL_POINTER;
}
return res;
return count;
}
//END nsEditor static utility methods
@ -5034,7 +5042,7 @@ nsresult nsEditor::ClearSelection()
}
nsresult
nsEditor::CreateHTMLContent(const nsAString& aTag, nsIContent** aContent)
nsEditor::CreateHTMLContent(const nsAString& aTag, dom::Element** aContent)
{
nsCOMPtr<nsIDocument> doc = GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
@ -5047,7 +5055,8 @@ nsEditor::CreateHTMLContent(const nsAString& aTag, nsIContent** aContent)
return NS_ERROR_FAILURE;
}
return doc->CreateElem(aTag, nsnull, kNameSpaceID_XHTML, aContent);
return doc->CreateElem(aTag, nsnull, kNameSpaceID_XHTML,
reinterpret_cast<nsIContent**>(aContent));
}
nsresult

Просмотреть файл

@ -178,6 +178,12 @@ public:
nsIDOMNode ** aNewNode);
/* helper routines for node/parent manipulations */
nsresult ReplaceContainer(nsINode* inNode,
mozilla::dom::Element** outNode,
const nsAString& aNodeType,
const nsAString* aAttribute = nsnull,
const nsAString* aValue = nsnull,
bool aCloneAttributes = false);
nsresult ReplaceContainer(nsIDOMNode *inNode,
nsCOMPtr<nsIDOMNode> *outNode,
const nsAString &aNodeType,
@ -187,6 +193,11 @@ public:
nsresult RemoveContainer(nsINode* aNode);
nsresult RemoveContainer(nsIDOMNode *inNode);
nsresult InsertContainerAbove(nsIContent* aNode,
mozilla::dom::Element** aOutNode,
const nsAString& aNodeType,
const nsAString* aAttribute = nsnull,
const nsAString* aValue = nsnull);
nsresult InsertContainerAbove(nsIDOMNode *inNode,
nsCOMPtr<nsIDOMNode> *outNode,
const nsAString &aNodeType,
@ -201,7 +212,8 @@ public:
nsString& aTag - tag you want
nsIContent** aContent - returned Content that was created with above namespace.
*/
nsresult CreateHTMLContent(const nsAString& aTag, nsIContent** aContent);
nsresult CreateHTMLContent(const nsAString& aTag,
mozilla::dom::Element** aContent);
// IME event handlers
virtual nsresult BeginIMEComposition();
@ -523,14 +535,6 @@ public:
return GetTag(aNode) == aTag;
}
// we should get rid of this method if we can
static inline bool NodeIsTypeString(nsIDOMNode *aNode, const nsAString &aTag)
{
nsIAtom *nodeAtom = GetTag(aNode);
return nodeAtom && nodeAtom->Equals(aTag);
}
/** returns true if aParent can contain a child of type aTag */
bool CanContain(nsIDOMNode* aParent, nsIDOMNode* aChild);
bool CanContainTag(nsIDOMNode* aParent, nsIAtom* aTag);
@ -564,7 +568,7 @@ public:
bool IsMozEditorBogusNode(nsIContent *aNode);
/** counts number of editable child nodes */
nsresult CountEditableChildren(nsIDOMNode *aNode, PRUint32 &outCount);
PRUint32 CountEditableChildren(nsINode* aNode);
/** Find the deep first and last children. */
nsINode* GetFirstEditableNode(nsINode* aRoot);

Просмотреть файл

@ -11,6 +11,7 @@
#include "nsIDOMNode.h"
#include "nsIDOMRange.h"
#include "nsCycleCollectionParticipant.h"
#include "nsINode.h"
class nsIDOMCharacterData;
class nsISelection;
@ -181,16 +182,16 @@ class NS_STACK_CLASS nsAutoRemoveContainerSelNotify
PRUint32 mNodeOrigLen;
public:
nsAutoRemoveContainerSelNotify(nsRangeUpdater &aRangeUpdater,
nsIDOMNode *aNode,
nsIDOMNode *aParent,
PRInt32 aOffset,
PRUint32 aNodeOrigLen) :
mRU(aRangeUpdater)
,mNode(aNode)
,mParent(aParent)
,mOffset(aOffset)
,mNodeOrigLen(aNodeOrigLen)
nsAutoRemoveContainerSelNotify(nsRangeUpdater& aRangeUpdater,
nsINode* aNode,
nsINode* aParent,
PRInt32 aOffset,
PRUint32 aNodeOrigLen)
: mRU(aRangeUpdater)
, mNode(aNode->AsDOMNode())
, mParent(aParent->AsDOMNode())
, mOffset(aOffset)
, mNodeOrigLen(aNodeOrigLen)
{
mRU.WillRemoveContainer();
}

Просмотреть файл

@ -27,6 +27,8 @@
#include "nsUnicharUtils.h"
#include "nsContentUtils.h"
using namespace mozilla;
// retrieve an integer stored into a CSS computed float value
static PRInt32 GetCSSFloatValue(nsIDOMCSSStyleDeclaration * aDecl,
const nsAString & aProperty)
@ -123,7 +125,7 @@ nsHTMLEditor::CreateAnonymousElement(const nsAString & aTag, nsIDOMNode * aPare
NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
// Create a new node through the element factory
nsCOMPtr<nsIContent> newContent;
nsCOMPtr<dom::Element> newContent;
nsresult res = CreateHTMLContent(aTag, getter_AddRefs(newContent));
NS_ENSURE_SUCCESS(res, res);

Просмотреть файл

@ -663,10 +663,10 @@ nsHTMLEditRules::GetListState(bool *aMixed, bool *aOL, bool *aUL, bool *aDL)
} else if (curElement->IsHTML(nsGkAtoms::ol)) {
*aOL = true;
} else if (curElement->IsHTML(nsGkAtoms::li)) {
if (nsINode* parent = curElement->GetElementParent()) {
if (parent->AsElement()->IsHTML(nsGkAtoms::ul)) {
if (dom::Element* parent = curElement->GetElementParent()) {
if (parent->IsHTML(nsGkAtoms::ul)) {
*aUL = true;
} else if (parent->AsElement()->IsHTML(nsGkAtoms::ol)) {
} else if (parent->IsHTML(nsGkAtoms::ol)) {
*aOL = true;
}
}
@ -2589,7 +2589,7 @@ nsHTMLEditRules::JoinBlocks(nsCOMPtr<nsIDOMNode> *aLeftBlock,
// special rule here: if we are trying to join list items, and they are in different lists,
// join the lists instead.
bool bMergeLists = false;
nsAutoString existingListStr;
nsIAtom* existingList = nsGkAtoms::_empty;
PRInt32 theOffset;
nsCOMPtr<nsIDOMNode> leftList, rightList;
if (nsHTMLEditUtils::IsListItem(*aLeftBlock) && nsHTMLEditUtils::IsListItem(*aRightBlock))
@ -2608,8 +2608,7 @@ nsHTMLEditRules::JoinBlocks(nsCOMPtr<nsIDOMNode> *aLeftBlock,
*aLeftBlock = leftList;
*aRightBlock = rightList;
bMergeLists = true;
mHTMLEditor->GetTagString(leftList, existingListStr);
ToLowerCase(existingListStr);
existingList = mHTMLEditor->GetTag(leftList);
}
}
}
@ -2706,7 +2705,8 @@ nsHTMLEditRules::JoinBlocks(nsCOMPtr<nsIDOMNode> *aLeftBlock,
if (NS_SUCCEEDED(res) && bMergeLists)
{
nsCOMPtr<nsIDOMNode> newBlock;
res = ConvertListType(*aRightBlock, address_of(newBlock), existingListStr, NS_LITERAL_STRING("li"));
res = ConvertListType(*aRightBlock, address_of(newBlock),
existingList, nsGkAtoms::li);
}
}
else
@ -2898,6 +2898,7 @@ nsHTMLEditRules::WillMakeList(nsISelection* aSelection,
return NS_ERROR_NULL_POINTER;
}
nsCOMPtr<nsIAtom> listTypeAtom = do_GetAtom(*aListType);
NS_ENSURE_TRUE(listTypeAtom, NS_ERROR_OUT_OF_MEMORY);
nsresult res = WillInsert(aSelection, aCancel);
NS_ENSURE_SUCCESS(res, res);
@ -2908,13 +2909,14 @@ nsHTMLEditRules::WillMakeList(nsISelection* aSelection,
*aHandled = false;
// deduce what tag to use for list items
nsAutoString itemType;
if (aItemType) {
itemType = *aItemType;
nsCOMPtr<nsIAtom> itemType;
if (aItemType) {
itemType = do_GetAtom(*aItemType);
NS_ENSURE_TRUE(itemType, NS_ERROR_OUT_OF_MEMORY);
} else if (listTypeAtom == nsGkAtoms::dl) {
itemType.AssignLiteral("dd");
itemType = nsGkAtoms::dd;
} else {
itemType.AssignLiteral("li");
itemType = nsGkAtoms::li;
}
// convert the selection ranges into "promoted" selection ranges:
@ -2974,7 +2976,7 @@ nsHTMLEditRules::WillMakeList(nsISelection* aSelection,
res = mHTMLEditor->CreateNode(*aListType, parent, offset,
getter_AddRefs(theList));
NS_ENSURE_SUCCESS(res, res);
res = mHTMLEditor->CreateNode(itemType, theList, 0,
res = mHTMLEditor->CreateNode(nsDependentAtomString(itemType), theList, 0,
getter_AddRefs(theListItem));
NS_ENSURE_SUCCESS(res, res);
// remember our new block for postprocessing
@ -3042,15 +3044,15 @@ nsHTMLEditRules::WillMakeList(nsISelection* aSelection,
// needed
res = mHTMLEditor->MoveNode(curNode, curList, -1);
NS_ENSURE_SUCCESS(res, res);
res = ConvertListType(curNode, address_of(newBlock),
*aListType, itemType);
res = ConvertListType(curNode, address_of(newBlock), listTypeAtom,
itemType);
NS_ENSURE_SUCCESS(res, res);
res = mHTMLEditor->RemoveBlockContainer(newBlock);
NS_ENSURE_SUCCESS(res, res);
} else {
// replace list with new list type
res = ConvertListType(curNode, address_of(newBlock),
*aListType, itemType);
res = ConvertListType(curNode, address_of(newBlock), listTypeAtom,
itemType);
NS_ENSURE_SUCCESS(res, res);
curList = newBlock;
}
@ -3079,9 +3081,9 @@ nsHTMLEditRules::WillMakeList(nsISelection* aSelection,
res = mHTMLEditor->MoveNode(curNode, curList, -1);
NS_ENSURE_SUCCESS(res, res);
// convert list item type if needed
if (!mHTMLEditor->NodeIsTypeString(curNode, itemType)) {
if (!mHTMLEditor->NodeIsType(curNode, itemType)) {
res = mHTMLEditor->ReplaceContainer(curNode, address_of(newBlock),
itemType);
nsDependentAtomString(itemType));
NS_ENSURE_SUCCESS(res, res);
}
} else {
@ -3094,9 +3096,9 @@ nsHTMLEditRules::WillMakeList(nsISelection* aSelection,
res = mHTMLEditor->MoveNode(curNode, curList, -1);
NS_ENSURE_SUCCESS(res, res);
}
if (!mHTMLEditor->NodeIsTypeString(curNode, itemType)) {
if (!mHTMLEditor->NodeIsType(curNode, itemType)) {
res = mHTMLEditor->ReplaceContainer(curNode, address_of(newBlock),
itemType);
nsDependentAtomString(itemType));
NS_ENSURE_SUCCESS(res, res);
}
}
@ -3149,11 +3151,10 @@ nsHTMLEditRules::WillMakeList(nsISelection* aSelection,
// don't wrap li around a paragraph. instead replace paragraph with li
if (nsHTMLEditUtils::IsParagraph(curNode)) {
res = mHTMLEditor->ReplaceContainer(curNode, address_of(listItem),
itemType);
nsDependentAtomString(itemType));
} else {
res = mHTMLEditor->InsertContainerAbove(curNode,
address_of(listItem),
itemType);
res = mHTMLEditor->InsertContainerAbove(curNode, address_of(listItem),
nsDependentAtomString(itemType));
}
NS_ENSURE_SUCCESS(res, res);
if (IsInlineNode(curNode)) {
@ -4230,39 +4231,68 @@ nsHTMLEditRules::OutdentPartOfBlock(nsIDOMNode *aBlock,
// ConvertListType: convert list type and list item type.
//
//
nsresult
nsHTMLEditRules::ConvertListType(nsIDOMNode *aList,
nsCOMPtr<nsIDOMNode> *outList,
const nsAString& aListType,
const nsAString& aItemType)
nsresult
nsHTMLEditRules::ConvertListType(nsIDOMNode* aList,
nsCOMPtr<nsIDOMNode>* outList,
nsIAtom* aListType,
nsIAtom* aItemType)
{
MOZ_ASSERT(aListType);
MOZ_ASSERT(aItemType);
NS_ENSURE_TRUE(aList && outList, NS_ERROR_NULL_POINTER);
*outList = aList; // we might not need to change the list
nsresult res = NS_OK;
nsCOMPtr<nsIDOMNode> child, temp;
aList->GetFirstChild(getter_AddRefs(child));
nsCOMPtr<nsINode> list = do_QueryInterface(aList);
NS_ENSURE_STATE(list);
nsCOMPtr<dom::Element> outNode;
nsresult rv = ConvertListType(list, getter_AddRefs(outNode), aListType, aItemType);
*outList = outNode ? outNode->AsDOMNode() : nsnull;
return rv;
}
nsresult
nsHTMLEditRules::ConvertListType(nsINode* aList,
dom::Element** aOutList,
nsIAtom* aListType,
nsIAtom* aItemType)
{
MOZ_ASSERT(aList);
MOZ_ASSERT(aOutList);
MOZ_ASSERT(aListType);
MOZ_ASSERT(aItemType);
nsCOMPtr<nsINode> child = aList->GetFirstChild();
while (child)
{
if (nsHTMLEditUtils::IsListItem(child) && !nsEditor::NodeIsTypeString(child, aItemType))
{
res = mHTMLEditor->ReplaceContainer(child, address_of(temp), aItemType);
NS_ENSURE_SUCCESS(res, res);
child = temp;
if (child->IsElement()) {
dom::Element* element = child->AsElement();
if (nsHTMLEditUtils::IsListItem(element) && !element->IsHTML(aItemType)) {
nsCOMPtr<dom::Element> temp;
nsresult rv =
mHTMLEditor->ReplaceContainer(child, getter_AddRefs(temp),
nsDependentAtomString(aItemType));
NS_ENSURE_SUCCESS(rv, rv);
child = temp.forget();
} else if (nsHTMLEditUtils::IsList(element) &&
!element->IsHTML(aListType)) {
nsCOMPtr<dom::Element> temp;
nsresult rv =
ConvertListType(child, getter_AddRefs(temp), aListType, aItemType);
NS_ENSURE_SUCCESS(rv, rv);
child = temp.forget();
}
}
else if (nsHTMLEditUtils::IsList(child) && !nsEditor::NodeIsTypeString(child, aListType))
{
res = ConvertListType(child, address_of(temp), aListType, aItemType);
NS_ENSURE_SUCCESS(res, res);
child = temp;
}
child->GetNextSibling(getter_AddRefs(temp));
child = temp;
child = child->GetNextSibling();
}
if (!nsEditor::NodeIsTypeString(aList, aListType))
{
res = mHTMLEditor->ReplaceContainer(aList, outList, aListType);
if (aList->IsElement() && aList->AsElement()->IsHTML(aListType)) {
nsCOMPtr<dom::Element> list = aList->AsElement();
list.forget(aOutList);
return NS_OK;
}
return res;
return mHTMLEditor->ReplaceContainer(aList, aOutList,
nsDependentAtomString(aListType));
}
@ -5875,50 +5905,54 @@ nsHTMLEditRules::LookInsideDivBQandList(nsCOMArray<nsIDOMNode>& aNodeArray)
{
// if there is only one node in the array, and it is a list, div, or blockquote,
// then look inside of it until we find inner list or content.
nsresult res = NS_OK;
PRInt32 listCount = aNodeArray.Count();
if (listCount == 1)
{
nsCOMPtr<nsIDOMNode> curNode = aNodeArray[0];
while (nsHTMLEditUtils::IsDiv(curNode)
|| nsHTMLEditUtils::IsList(curNode)
|| nsHTMLEditUtils::IsBlockquote(curNode))
{
// dive as long as there is only one child, and it is a list, div, blockquote
PRUint32 numChildren;
res = mHTMLEditor->CountEditableChildren(curNode, numChildren);
NS_ENSURE_SUCCESS(res, res);
if (numChildren == 1)
{
// keep diving
nsCOMPtr <nsIDOMNode> tmpNode = nsEditor::GetChildAt(curNode, 0);
if (nsHTMLEditUtils::IsDiv(tmpNode)
|| nsHTMLEditUtils::IsList(tmpNode)
|| nsHTMLEditUtils::IsBlockquote(tmpNode))
{
// check editablility XXX floppy moose
curNode = tmpNode;
}
else break;
}
else break;
}
// we've found innermost list/blockquote/div:
// replace the one node in the array with these nodes
aNodeArray.RemoveObjectAt(0);
if ((nsHTMLEditUtils::IsDiv(curNode) || nsHTMLEditUtils::IsBlockquote(curNode)))
{
PRInt32 j=0;
res = GetInnerContent(curNode, aNodeArray, &j, false, false);
}
else
{
aNodeArray.AppendObject(curNode);
}
if (listCount != 1) {
return NS_OK;
}
return res;
nsCOMPtr<nsINode> curNode = do_QueryInterface(aNodeArray[0]);
NS_ENSURE_STATE(curNode);
while (curNode->IsElement() &&
(curNode->AsElement()->IsHTML(nsGkAtoms::div) ||
nsHTMLEditUtils::IsList(curNode->AsElement()) ||
curNode->AsElement()->IsHTML(nsGkAtoms::blockquote))) {
// dive as long as there is only one child, and it is a list, div, blockquote
PRUint32 numChildren = mHTMLEditor->CountEditableChildren(curNode);
if (numChildren != 1) {
break;
}
// keep diving
// XXX One would expect to dive into the one editable node.
nsIContent* tmp = curNode->GetFirstChild();
if (!tmp->IsElement()) {
break;
}
dom::Element* element = tmp->AsElement();
if (!element->IsHTML(nsGkAtoms::div) &&
!nsHTMLEditUtils::IsList(element) &&
!element->IsHTML(nsGkAtoms::blockquote)) {
break;
}
// check editablility XXX floppy moose
curNode = tmp;
}
// we've found innermost list/blockquote/div:
// replace the one node in the array with these nodes
aNodeArray.RemoveObjectAt(0);
if (curNode->IsElement() &&
(curNode->AsElement()->IsHTML(nsGkAtoms::div) ||
curNode->AsElement()->IsHTML(nsGkAtoms::blockquote))) {
PRInt32 j = 0;
return GetInnerContent(curNode->AsDOMNode(), aNodeArray, &j, false, false);
}
aNodeArray.AppendObject(curNode->AsDOMNode());
return NS_OK;
}
@ -6766,24 +6800,16 @@ nsHTMLEditRules::RemoveBlockStyle(nsCOMArray<nsIDOMNode>& arrayOfNodes)
nsresult res = NS_OK;
nsCOMPtr<nsIDOMNode> curNode, curParent, curBlock, firstNode, lastNode;
PRInt32 offset;
nsCOMPtr<nsIDOMNode> curBlock, firstNode, lastNode;
PRInt32 listCount = arrayOfNodes.Count();
PRInt32 i;
for (i=0; i<listCount; i++)
{
for (PRInt32 i = 0; i < listCount; ++i) {
// get the node to act on, and its location
curNode = arrayOfNodes[i];
res = nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset);
NS_ENSURE_SUCCESS(res, res);
nsAutoString curNodeTag, curBlockTag;
nsEditor::GetTagString(curNode, curNodeTag);
ToLowerCase(curNodeTag);
nsCOMPtr<nsIDOMNode> curNode = arrayOfNodes[i];
nsCOMPtr<dom::Element> curElement = do_QueryInterface(curNode);
// if curNode is a address, p, header, address, or pre, remove it
if (nsHTMLEditUtils::IsFormatNode(curNode))
{
if (curElement && nsHTMLEditUtils::IsFormatNode(curElement)) {
// process any partial progress saved
if (curBlock)
{
@ -6794,16 +6820,15 @@ nsHTMLEditRules::RemoveBlockStyle(nsCOMArray<nsIDOMNode>& arrayOfNodes)
// remove curent block
res = mHTMLEditor->RemoveBlockContainer(curNode);
NS_ENSURE_SUCCESS(res, res);
}
else if (nsHTMLEditUtils::IsTable(curNode) ||
nsHTMLEditUtils::IsTableRow(curNode) ||
(curNodeTag.EqualsLiteral("tbody")) ||
(curNodeTag.EqualsLiteral("td")) ||
nsHTMLEditUtils::IsList(curNode) ||
(curNodeTag.EqualsLiteral("li")) ||
nsHTMLEditUtils::IsBlockquote(curNode) ||
nsHTMLEditUtils::IsDiv(curNode))
{
} else if (curElement &&
(curElement->IsHTML(nsGkAtoms::table) ||
curElement->IsHTML(nsGkAtoms::tr) ||
curElement->IsHTML(nsGkAtoms::tbody) ||
curElement->IsHTML(nsGkAtoms::td) ||
nsHTMLEditUtils::IsList(curElement) ||
curElement->IsHTML(nsGkAtoms::li) ||
curElement->IsHTML(nsGkAtoms::blockquote) ||
curElement->IsHTML(nsGkAtoms::div))) {
// process any partial progress saved
if (curBlock)
{

Просмотреть файл

@ -185,7 +185,16 @@ protected:
bool aIsBlockIndentedWithCSS,
nsCOMPtr<nsIDOMNode> *aLeftNode = 0,
nsCOMPtr<nsIDOMNode> *aRightNode = 0);
nsresult ConvertListType(nsIDOMNode *aList, nsCOMPtr<nsIDOMNode> *outList, const nsAString& aListType, const nsAString& aItemType);
nsresult ConvertListType(nsIDOMNode* aList,
nsCOMPtr<nsIDOMNode>* outList,
nsIAtom* aListType,
nsIAtom* aItemType);
nsresult ConvertListType(nsINode* aList,
mozilla::dom::Element** aOutList,
nsIAtom* aListType,
nsIAtom* aItemType);
nsresult CreateStyleForInsertText(nsISelection *aSelection, nsIDOMDocument *aDoc);
nsresult IsEmptyBlock(nsIDOMNode *aNode,
bool *outIsEmptyBlock,

Просмотреть файл

@ -2088,11 +2088,11 @@ nsHTMLEditor::GetHTMLBackgroundColorState(bool *aMixed, nsAString &aOutColor)
getter_AddRefs(domElement));
NS_ENSURE_SUCCESS(res, res);
nsCOMPtr<nsINode> element = do_QueryInterface(domElement);
nsCOMPtr<dom::Element> element = do_QueryInterface(domElement);
while (element) {
// We are in a cell or selected table
element->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::bgcolor, aOutColor);
element->GetAttr(kNameSpaceID_None, nsGkAtoms::bgcolor, aOutColor);
// Done if we have a color explicitly set
if (!aOutColor.IsEmpty()) {
@ -2100,7 +2100,7 @@ nsHTMLEditor::GetHTMLBackgroundColorState(bool *aMixed, nsAString &aOutColor)
}
// Once we hit the body, we're done
if (element->AsElement()->IsHTML(nsGkAtoms::body)) {
if (element->IsHTML(nsGkAtoms::body)) {
return NS_OK;
}
@ -2856,7 +2856,7 @@ nsHTMLEditor::CreateElementWithDefaults(const nsAString& aTagName, nsIDOMElement
// go through the transaction system
nsCOMPtr<nsIDOMElement>newElement;
nsCOMPtr<nsIContent> newContent;
nsCOMPtr<dom::Element> newContent;
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
@ -3769,13 +3769,6 @@ nsHTMLEditor::TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag)
return nsHTMLEditUtils::CanContain(parentTagEnum, childTagEnum);
}
bool
nsHTMLEditor::IsContainer(nsINode* aNode)
{
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode);
return IsContainer(node);
}
bool
nsHTMLEditor::IsContainer(nsIDOMNode *aNode)
{
@ -4691,7 +4684,7 @@ nsHTMLEditor::IsEmptyNodeImpl(nsINode* aNode,
// anchors are containers, named anchors are "empty" but we don't
// want to treat them as such. Also, don't call ListItems or table
// cells empty if caller desires. Form Widgets not empty.
if (!IsContainer(aNode) ||
if (!IsContainer(aNode->AsDOMNode()) ||
(aNode->IsElement() &&
(nsHTMLEditUtils::IsNamedAnchor(aNode->AsElement()) ||
nsHTMLEditUtils::IsFormWidget(aNode->AsElement()) ||

Просмотреть файл

@ -277,7 +277,6 @@ public:
virtual bool TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag);
/** returns true if aNode is a container */
virtual bool IsContainer(nsINode* aNode);
virtual bool IsContainer(nsIDOMNode *aNode);
/** make the given selection span the entire document */
@ -454,7 +453,7 @@ protected:
bool AllCellsInRowSelected(nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 aNumberOfColumns);
bool AllCellsInColumnSelected(nsIDOMElement *aTable, PRInt32 aColIndex, PRInt32 aNumberOfRows);
bool IsEmptyCell(nsIDOMElement *aCell);
bool IsEmptyCell(mozilla::dom::Element* aCell);
// Most insert methods need to get the same basic context data
// Any of the pointers may be null if you don't need that datum (for more efficiency)

Просмотреть файл

@ -284,16 +284,16 @@ nsHTMLEditor::IsSimpleModifiableNode(nsIContent* aContent,
// "text-decoration: underline", which decomposes into four different text-*
// properties. So for now, we just create a span, add the desired style, and
// see if it matches.
nsCOMPtr<nsIContent> newSpan;
nsCOMPtr<dom::Element> newSpan;
nsresult res = CreateHTMLContent(NS_LITERAL_STRING("span"),
getter_AddRefs(newSpan));
NS_ASSERTION(NS_SUCCEEDED(res), "CreateHTMLContent failed");
NS_ENSURE_SUCCESS(res, false);
mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(newSpan->AsElement(), aProperty,
mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(newSpan, aProperty,
aAttribute, aValue,
/*suppress transaction*/ true);
return mHTMLCSSUtils->ElementsSameStyle(newSpan->AsElement(), element);
return mHTMLCSSUtils->ElementsSameStyle(newSpan, element);
}
@ -386,10 +386,6 @@ nsHTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent* aNode,
MOZ_ASSERT(aNode && aProperty);
MOZ_ASSERT(aValue);
nsAutoString tag;
aProperty->ToString(tag);
ToLowerCase(tag);
// If this is an element that can't be contained in a span, we have to
// recurse to its children.
if (!TagCanContain(nsGkAtoms::span, aNode->AsDOMNode())) {
@ -454,21 +450,24 @@ nsHTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent* aNode,
aAttribute->EqualsLiteral("bgcolor");
if (useCSS) {
nsCOMPtr<nsIDOMNode> tmp = aNode->AsDOMNode();
nsCOMPtr<dom::Element> tmp;
// We only add style="" to <span>s with no attributes (bug 746515). If we
// don't have one, we need to make one.
if (!aNode->IsElement() || !aNode->AsElement()->IsHTML(nsGkAtoms::span) ||
aNode->AsElement()->GetAttrCount()) {
res = InsertContainerAbove(aNode->AsDOMNode(), address_of(tmp),
if (aNode->IsElement() && aNode->AsElement()->IsHTML(nsGkAtoms::span) &&
!aNode->AsElement()->GetAttrCount()) {
tmp = aNode->AsElement();
} else {
res = InsertContainerAbove(aNode, getter_AddRefs(tmp),
NS_LITERAL_STRING("span"),
nsnull, nsnull);
NS_ENSURE_SUCCESS(res, res);
}
// Add the CSS styles corresponding to the HTML style request
PRInt32 count;
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(tmp, aProperty,
aAttribute, aValue,
&count, false);
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(tmp->AsDOMNode(),
aProperty, aAttribute,
aValue, &count, false);
NS_ENSURE_SUCCESS(res, res);
return NS_OK;
}
@ -481,6 +480,9 @@ nsHTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent* aNode,
}
// ok, chuck it in its very own container
nsAutoString tag;
aProperty->ToString(tag);
ToLowerCase(tag);
nsCOMPtr<nsIDOMNode> tmp;
return InsertContainerAbove(aNode->AsDOMNode(), address_of(tmp), tag,
aAttribute, aValue);

Просмотреть файл

@ -2320,65 +2320,48 @@ nsHTMLEditor::MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell,
nsCOMPtr<nsIDOMElement> aCellToMerge,
bool aDeleteCellToMerge)
{
NS_ENSURE_TRUE(aTargetCell && aCellToMerge, NS_ERROR_NULL_POINTER);
nsresult res = NS_OK;
nsCOMPtr<dom::Element> targetCell = do_QueryInterface(aTargetCell);
nsCOMPtr<dom::Element> cellToMerge = do_QueryInterface(aCellToMerge);
NS_ENSURE_TRUE(targetCell && cellToMerge, NS_ERROR_NULL_POINTER);
// Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, kOpDeleteNode, nsIEditor::eNext);
// Don't need to merge if cell is empty
if (!IsEmptyCell(aCellToMerge))
{
if (!IsEmptyCell(cellToMerge)) {
// Get index of last child in target cell
nsCOMPtr<nsIDOMNodeList> childNodes;
nsCOMPtr<nsIDOMNode> cellChild;
res = aTargetCell->GetChildNodes(getter_AddRefs(childNodes));
// If we fail or don't have children,
// we insert at index 0
PRInt32 insertIndex = 0;
if ((NS_SUCCEEDED(res)) && (childNodes))
{
// Start inserting just after last child
PRUint32 len;
res = childNodes->GetLength(&len);
// Start inserting just after last child
PRUint32 len = targetCell->GetChildCount();
if (len == 1 && IsEmptyCell(targetCell)) {
// Delete the empty node
nsIContent* cellChild = targetCell->GetFirstChild();
nsresult res = DeleteNode(cellChild->AsDOMNode());
NS_ENSURE_SUCCESS(res, res);
if (len == 1 && IsEmptyCell(aTargetCell))
{
// Delete the empty node
nsCOMPtr<nsIDOMNode> tempNode;
res = childNodes->Item(0, getter_AddRefs(cellChild));
NS_ENSURE_SUCCESS(res, res);
res = DeleteNode(cellChild);
NS_ENSURE_SUCCESS(res, res);
insertIndex = 0;
}
else
insertIndex = (PRInt32)len;
insertIndex = 0;
} else {
insertIndex = (PRInt32)len;
}
// Move the contents
bool hasChild;
aCellToMerge->HasChildNodes(&hasChild);
while (hasChild)
{
aCellToMerge->GetLastChild(getter_AddRefs(cellChild));
res = DeleteNode(cellChild);
while (cellToMerge->HasChildren()) {
nsCOMPtr<nsIDOMNode> cellChild = cellToMerge->GetLastChild()->AsDOMNode();
nsresult res = DeleteNode(cellChild);
NS_ENSURE_SUCCESS(res, res);
res = InsertNode(cellChild, aTargetCell, insertIndex);
NS_ENSURE_SUCCESS(res, res);
aCellToMerge->HasChildNodes(&hasChild);
}
}
// Delete cells whose contents were moved
if (aDeleteCellToMerge)
res = DeleteNode(aCellToMerge);
return DeleteNode(aCellToMerge);
return res;
return NS_OK;
}
@ -3408,12 +3391,12 @@ nsHTMLEditor::AllCellsInColumnSelected(nsIDOMElement *aTable, PRInt32 aColIndex,
}
bool
nsHTMLEditor::IsEmptyCell(nsIDOMElement *aCell)
nsHTMLEditor::IsEmptyCell(dom::Element* aCell)
{
nsCOMPtr<dom::Element> cell = do_QueryInterface(aCell);
MOZ_ASSERT(aCell);
// Check if target only contains empty text node or <br>
nsCOMPtr<nsINode> cellChild = cell->GetFirstChild();
nsCOMPtr<nsINode> cellChild = aCell->GetFirstChild();
if (!cellChild) {
return false;
}

Просмотреть файл

@ -1116,7 +1116,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsISelection *aSelection)
}
// Create a br.
nsCOMPtr<nsIContent> newContent;
nsCOMPtr<dom::Element> newContent;
nsresult rv = mEditor->CreateHTMLContent(NS_LITERAL_STRING("br"), getter_AddRefs(newContent));
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -2550,32 +2550,17 @@ nsTextServicesDocument::GetSelection(nsITextServicesDocument::TSDBlockSelectionS
nsresult
nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockSelectionStatus *aSelStatus, PRInt32 *aSelOffset, PRInt32 *aSelLength)
{
nsresult result;
nsCOMPtr<nsISelection> selection;
result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
nsresult result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
NS_ENSURE_SUCCESS(result, result);
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
// The calling function should have done the GetIsCollapsed()
// check already. Just assume it's collapsed!
nsCOMPtr<nsIDOMRange> range;
OffsetEntry *entry;
nsCOMPtr<nsIDOMNode> parent;
PRInt32 offset, tableCount, i;
PRInt32 e1s1, e2s1;
OffsetEntry *eStart, *eEnd;
PRInt32 eStartOffset, eEndOffset;
*aSelStatus = nsITextServicesDocument::eBlockOutside;
*aSelOffset = *aSelLength = -1;
tableCount = mOffsetTable.Length();
PRInt32 tableCount = mOffsetTable.Length();
if (tableCount == 0)
return NS_OK;
@ -2583,54 +2568,51 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
// Get pointers to the first and last offset entries
// in the table.
eStart = mOffsetTable[0];
OffsetEntry* eStart = mOffsetTable[0];
OffsetEntry* eEnd;
if (tableCount > 1)
eEnd = mOffsetTable[tableCount - 1];
else
eEnd = eStart;
eStartOffset = eStart->mNodeOffset;
eEndOffset = eEnd->mNodeOffset + eEnd->mLength;
PRInt32 eStartOffset = eStart->mNodeOffset;
PRInt32 eEndOffset = eEnd->mNodeOffset + eEnd->mLength;
nsCOMPtr<nsIDOMRange> range;
result = selection->GetRangeAt(0, getter_AddRefs(range));
NS_ENSURE_SUCCESS(result, result);
result = range->GetStartContainer(getter_AddRefs(parent));
nsCOMPtr<nsIDOMNode> domParent;
result = range->GetStartContainer(getter_AddRefs(domParent));
NS_ENSURE_SUCCESS(result, result);
nsCOMPtr<nsINode> parent = do_QueryInterface(domParent);
MOZ_ASSERT(parent);
PRInt32 offset;
result = range->GetStartOffset(&offset);
NS_ENSURE_SUCCESS(result, result);
e1s1 = nsContentUtils::ComparePoints(eStart->mNode, eStartOffset,
parent, offset);
e2s1 = nsContentUtils::ComparePoints(eEnd->mNode, eEndOffset,
parent, offset);
if (e1s1 > 0 || e2s1 < 0)
{
// We're done if the caret is outside the
// current text block.
PRInt32 e1s1 = nsContentUtils::ComparePoints(eStart->mNode, eStartOffset,
domParent, offset);
PRInt32 e2s1 = nsContentUtils::ComparePoints(eEnd->mNode, eEndOffset,
domParent, offset);
if (e1s1 > 0 || e2s1 < 0) {
// We're done if the caret is outside the current text block.
return NS_OK;
}
if (IsTextNode(parent))
{
if (parent->NodeType() == nsIDOMNode::TEXT_NODE) {
// Good news, the caret is in a text node. Look
// through the offset table for the entry that
// matches its parent and offset.
for (i = 0; i < tableCount; i++)
{
entry = mOffsetTable[i];
for (PRInt32 i = 0; i < tableCount; i++) {
OffsetEntry* entry = mOffsetTable[i];
NS_ENSURE_TRUE(entry, NS_ERROR_FAILURE);
if (entry->mNode == parent.get() &&
if (entry->mNode == domParent.get() &&
entry->mNodeOffset <= offset && offset <= (entry->mNodeOffset + entry->mLength))
{
*aSelStatus = nsITextServicesDocument::eBlockContains;
@ -2654,25 +2636,15 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
// child of this non-text node. Then look for the closest text
// node.
nsCOMPtr<nsIDOMNode> node, saveNode;
nsCOMPtr<nsIDOMNodeList> children;
nsCOMPtr<nsIContentIterator> iter;
bool hasChildren;
result = CreateRange(eStart->mNode, eStartOffset, eEnd->mNode, eEndOffset, getter_AddRefs(range));
NS_ENSURE_SUCCESS(result, result);
nsCOMPtr<nsIContentIterator> iter;
result = CreateContentIterator(range, getter_AddRefs(iter));
NS_ENSURE_SUCCESS(result, result);
result = parent->HasChildNodes(&hasChildren);
NS_ENSURE_SUCCESS(result, result);
if (hasChildren)
{
nsIContent* saveNode;
if (parent->HasChildren()) {
// XXX: We need to make sure that all of parent's
// children are in the text block.
@ -2681,139 +2653,90 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
PRUint32 childIndex = (PRUint32)offset;
result = parent->GetChildNodes(getter_AddRefs(children));
NS_ENSURE_SUCCESS(result, result);
NS_ENSURE_TRUE(children, NS_ERROR_FAILURE);
if (childIndex > 0)
{
PRUint32 numChildren;
result = children->GetLength(&numChildren);
NS_ENSURE_SUCCESS(result, result);
if (childIndex > 0) {
PRUint32 numChildren = parent->GetChildCount();
NS_ASSERTION(childIndex <= numChildren, "Invalid selection offset!");
if (childIndex > numChildren)
if (childIndex > numChildren) {
childIndex = numChildren;
}
childIndex -= 1;
}
result = children->Item(childIndex, getter_AddRefs(saveNode));
NS_ENSURE_SUCCESS(result, result);
nsCOMPtr<nsIContent> content(do_QueryInterface(saveNode));
nsIContent* content = parent->GetChildAt(childIndex);
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
result = iter->PositionAt(content);
NS_ENSURE_SUCCESS(result, result);
}
else
{
saveNode = content;
} else {
// The parent has no children, so position the iterator
// on the parent.
nsCOMPtr<nsIContent> content(do_QueryInterface(parent));
nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
result = iter->PositionAt(content);
NS_ENSURE_SUCCESS(result, result);
saveNode = parent;
saveNode = content;
}
// Now iterate to the left, towards the beginning of
// the text block, to find the first text node you
// come across.
while (!iter->IsDone())
{
nsCOMPtr<nsIContent> content = do_QueryInterface(iter->GetCurrentNode());
if (IsTextNode(content))
{
node = do_QueryInterface(content);
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
nsIContent* node = nsnull;
while (!iter->IsDone()) {
nsINode* current = iter->GetCurrentNode();
if (current->NodeType() == nsIDOMNode::TEXT_NODE) {
node = static_cast<nsIContent*>(current);
break;
}
node = nsnull;
iter->Prev();
}
if (node)
{
if (node) {
// We found a node, now set the offset to the end
// of the text node.
nsAutoString str;
result = node->GetNodeValue(str);
NS_ENSURE_SUCCESS(result, result);
offset = str.Length();
}
else
{
offset = node->TextLength();
} else {
// We should never really get here, but I'm paranoid.
// We didn't find a text node above, so iterate to
// the right, towards the end of the text block, looking
// for a text node.
{
nsCOMPtr<nsIContent> content(do_QueryInterface(saveNode));
result = iter->PositionAt(saveNode);
NS_ENSURE_SUCCESS(result, result);
result = iter->PositionAt(content);
NS_ENSURE_SUCCESS(result, result);
}
while (!iter->IsDone())
{
nsCOMPtr<nsIContent> content = do_QueryInterface(iter->GetCurrentNode());
if (IsTextNode(content))
{
node = do_QueryInterface(content);
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
node = nsnull;
while (!iter->IsDone()) {
nsINode* current = iter->GetCurrentNode();
if (current->NodeType() == nsIDOMNode::TEXT_NODE) {
node = static_cast<nsIContent*>(current);
break;
}
node = nsnull;
iter->Next();
}
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
// We found a text node, so set the offset to
// the begining of the node.
// the beginning of the node.
offset = 0;
}
for (i = 0; i < tableCount; i++)
{
entry = mOffsetTable[i];
for (PRInt32 i = 0; i < tableCount; i++) {
OffsetEntry* entry = mOffsetTable[i];
NS_ENSURE_TRUE(entry, NS_ERROR_FAILURE);
if (entry->mNode == node.get() &&
if (entry->mNode == node->AsDOMNode() &&
entry->mNodeOffset <= offset && offset <= (entry->mNodeOffset + entry->mLength))
{
*aSelStatus = nsITextServicesDocument::eBlockContains;

Просмотреть файл

@ -1949,7 +1949,7 @@ GLContextProviderEGL::CreateForNativePixmapSurface(gfxASurface* aSurface)
GLContext *
GLContextProviderEGL::GetGlobalContext(const ContextFlags)
{
#ifdef ANDROID
#ifdef MOZ_JAVA_COMPOSITOR
return nsnull;
#endif

Просмотреть файл

@ -63,7 +63,7 @@ typedef struct gif_struct {
PRUint8 firstchar;
int count; /* Remaining # bytes in sub-block */
int bits; /* Number of unread bits in "datum" */
int32 datum; /* 32-bit input buffer */
PRInt32 datum; /* 32-bit input buffer */
/* Output state machine */
int ipass; /* Interlace pass; Ranges 1-4 if interlaced. */

Просмотреть файл

@ -30,7 +30,6 @@ endif # }
vpath %.cc \
$(srcdir)/src/base \
$(srcdir)/src/base/third_party/nspr \
$(srcdir)/src/chrome/common \
$(NULL)
@ -43,7 +42,6 @@ include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
CPPSRCS += \
prtime.cc \
at_exit.cc \
base_paths.cc \
base_switches.cc \

Просмотреть файл

@ -31,9 +31,6 @@
#include "obsolete/protypes.h"
#define _INT32
#define _UINT32
#ifdef _WIN32_SAVE
#undef _WIN32_SAVE
#define _WIN32
@ -50,37 +47,6 @@
#include <stdint.h> // For intptr_t.
#endif
typedef signed char schar;
typedef signed char int8;
typedef short int16;
// TODO(mbelshe) Remove these type guards. These are
// temporary to avoid conflicts with npapi.h.
#ifndef _INT32
#define _INT32
typedef int int32;
#endif
#ifndef PROTYPES_H
typedef long long int64;
#endif
// NOTE: unsigned types are DANGEROUS in loops and other arithmetical
// places. Use the signed types unless your variable represents a bit
// pattern (eg a hash value) or you really need the extra bit. Do NOT
// use 'unsigned' to express "this value should always be positive";
// use assertions for this.
typedef unsigned char uint8;
typedef unsigned short uint16;
// TODO(mbelshe) Remove these type guards. These are
// temporary to avoid conflicts with npapi.h.
#ifndef _UINT32
#define _UINT32
typedef unsigned int uint32;
#endif
#ifndef PROTYPES_H
typedef unsigned long long uint64;
#endif
// A type to represent a Unicode code-point value. As of Unicode 4.0,
// such values require up to 21 bits.
// (For type-checking on pointers, make this explicitly signed,

Просмотреть файл

@ -1,2 +0,0 @@
The original code is the Netscape Portable Runtime (NSPR), licensed under
the MPL/GPL/LGPL tri-license (http://www.mozilla.org/MPL/).

Просмотреть файл

@ -1,45 +0,0 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef BASE_THIRD_PARTY_NSPR_PRCPUCFG_H__
#define BASE_THIRD_PARTY_NSPR_PRCPUCFG_H__
#if defined(WIN32)
#include "base/third_party/nspr/prcpucfg_win.h"
#elif defined(__APPLE__)
#include "base/third_party/nspr/prcpucfg_mac.h"
#elif defined(__linux__) || defined(ANDROID)
#include "base/third_party/nspr/prcpucfg_linux.h"
#elif defined(__OpenBSD__)
#include "base/third_party/nspr/prcpucfg_openbsd.h"
#else
#error Provide a prcpucfg.h appropriate for your platform
#endif
#endif // BASE_THIRD_PARTY_NSPR_PRCPUCFG_H__

Просмотреть файл

@ -1,675 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef LINUX
#define LINUX
#endif
#define PR_AF_INET6 10 /* same as AF_INET6 */
#ifdef __powerpc64__
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__powerpc__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__alpha)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__ia64__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__x86_64__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__mc68000__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 2
#define PR_ALIGN_OF_LONG 2
#define PR_ALIGN_OF_INT64 2
#define PR_ALIGN_OF_FLOAT 2
#define PR_ALIGN_OF_DOUBLE 2
#define PR_ALIGN_OF_POINTER 2
#define PR_ALIGN_OF_WORD 2
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__sparc__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__i386__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__mips__)
#ifdef __MIPSEB__
#define IS_BIG_ENDIAN 1
#undef IS_LITTLE_ENDIAN
#elif defined(__MIPSEL__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#else
#error "Unknown MIPS endianness."
#endif
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__arm__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__hppa__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__s390x__)
#define IS_BIG_ENDIAN 1
#undef IS_LITTLE_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__s390__)
#define IS_BIG_ENDIAN 1
#undef IS_LITTLE_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#else
#error "Unknown CPU architecture"
#endif
#define HAVE_LONG_LONG
#if PR_ALIGN_OF_DOUBLE == 8
#define HAVE_ALIGNED_DOUBLES
#endif
#if PR_ALIGN_OF_INT64 == 8
#define HAVE_ALIGNED_LONGLONGS
#endif
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

Просмотреть файл

@ -1,113 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#define PR_AF_INET6 30 /* same as AF_INET6 */
#if defined(i386)
#undef IS_BIG_ENDIAN
#define IS_LITTLE_ENDIAN 1
#else
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#endif
#define HAVE_LONG_LONG
#undef HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS 1
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

Просмотреть файл

@ -1,405 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef OPENBSD
#define OPENBSD
#endif
#define PR_AF_INET6 24 /* same as AF_INET6 */
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#if defined(__i386__) || defined(__arm__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#elif defined(__amd64__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#elif defined(__sparc_v9__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__sparc__) || defined(__hppa__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#elif defined(__alpha__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__powerpc__) || defined(__m68k__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__mips__)
#ifdef __MIPSEB__
#define IS_BIG_ENDIAN 1
#undef IS_LITTLE_ENDIAN
#elif defined(__MIPSEL__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#else
#error "Unknown MIPS endianness."
#endif
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#else
#error Must define constants for type sizes here.
#endif
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

Просмотреть файл

@ -1,268 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_PC
#define XP_PC
#endif
#ifndef WIN32
#define WIN32
#endif
#ifndef WIN95
#define WIN95
#endif
#define PR_AF_INET6 23 /* same as AF_INET6 */
#if defined(_M_IX86) || defined(_X86_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 5
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 4
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 2
#elif defined(_ALPHA_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#elif defined(_AMD64_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 6
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 8
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(_IA64_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 6
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 8
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#else /* defined(_M_IX86) || defined(_X86_) */
#error unknown processor architecture
#endif /* defined(_M_IX86) || defined(_X86_) */
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

1213
ipc/chromium/src/base/third_party/nspr/prtime.cc поставляемый

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,206 +0,0 @@
/* Portions are Copyright (C) 2007 Google Inc */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
*---------------------------------------------------------------------------
*
* prtime.h --
*
* NSPR date and time functions
* CVS revision 3.10
* This file contains definitions of NSPR's basic types required by
* prtime.cc. These types have been copied over from the following NSPR
* files prtime.h, prtypes.h(CVS revision 3.35), prlong.h(CVS revision 3.13)
*
*---------------------------------------------------------------------------
*/
#ifndef BASE_PRTIME_H__
#define BASE_PRTIME_H__
#include "base/logging.h"
#include "base/third_party/nspr/prtypes.h"
PR_BEGIN_EXTERN_C
#define LL_I2L(l, i) ((l) = (PRInt64)(i))
#define LL_MUL(r, a, b) ((r) = (a) * (b))
/**********************************************************************/
/************************* TYPES AND CONSTANTS ************************/
/**********************************************************************/
#define PR_MSEC_PER_SEC 1000UL
#define PR_USEC_PER_SEC 1000000UL
#define PR_NSEC_PER_SEC 1000000000UL
#define PR_USEC_PER_MSEC 1000UL
#define PR_NSEC_PER_MSEC 1000000UL
/*
* PRTime --
*
* NSPR represents basic time as 64-bit signed integers relative
* to midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT).
* (GMT is also known as Coordinated Universal Time, UTC.)
* The units of time are in microseconds. Negative times are allowed
* to represent times prior to the January 1970 epoch. Such values are
* intended to be exported to other systems or converted to human
* readable form.
*
* Notes on porting: PRTime corresponds to time_t in ANSI C. NSPR 1.0
* simply uses PRInt64.
*/
typedef PRInt64 PRTime;
/*
* Time zone and daylight saving time corrections applied to GMT to
* obtain the local time of some geographic location
*/
typedef struct PRTimeParameters {
PRInt32 tp_gmt_offset; /* the offset from GMT in seconds */
PRInt32 tp_dst_offset; /* contribution of DST in seconds */
} PRTimeParameters;
/*
* PRExplodedTime --
*
* Time broken down into human-readable components such as year, month,
* day, hour, minute, second, and microsecond. Time zone and daylight
* saving time corrections may be applied. If they are applied, the
* offsets from the GMT must be saved in the 'tm_params' field so that
* all the information is available to reconstruct GMT.
*
* Notes on porting: PRExplodedTime corrresponds to struct tm in
* ANSI C, with the following differences:
* - an additional field tm_usec;
* - replacing tm_isdst by tm_params;
* - the month field is spelled tm_month, not tm_mon;
* - we use absolute year, AD, not the year since 1900.
* The corresponding type in NSPR 1.0 is called PRTime. Below is
* a table of date/time type correspondence in the three APIs:
* API time since epoch time in components
* ANSI C time_t struct tm
* NSPR 1.0 PRInt64 PRTime
* NSPR 2.0 PRTime PRExplodedTime
*/
typedef struct PRExplodedTime {
PRInt32 tm_usec; /* microseconds past tm_sec (0-99999) */
PRInt32 tm_sec; /* seconds past tm_min (0-61, accomodating
up to two leap seconds) */
PRInt32 tm_min; /* minutes past tm_hour (0-59) */
PRInt32 tm_hour; /* hours past tm_day (0-23) */
PRInt32 tm_mday; /* days past tm_mon (1-31, note that it
starts from 1) */
PRInt32 tm_month; /* months past tm_year (0-11, Jan = 0) */
PRInt16 tm_year; /* absolute year, AD (note that we do not
count from 1900) */
PRInt8 tm_wday; /* calculated day of the week
(0-6, Sun = 0) */
PRInt16 tm_yday; /* calculated day of the year
(0-365, Jan 1 = 0) */
PRTimeParameters tm_params; /* time parameters used by conversion */
} PRExplodedTime;
/*
* PRTimeParamFn --
*
* A function of PRTimeParamFn type returns the time zone and
* daylight saving time corrections for some geographic location,
* given the current time in GMT. The input argument gmt should
* point to a PRExplodedTime that is in GMT, i.e., whose
* tm_params contains all 0's.
*
* For any time zone other than GMT, the computation is intended to
* consist of two steps:
* - Figure out the time zone correction, tp_gmt_offset. This number
* usually depends on the geographic location only. But it may
* also depend on the current time. For example, all of China
* is one time zone right now. But this situation may change
* in the future.
* - Figure out the daylight saving time correction, tp_dst_offset.
* This number depends on both the geographic location and the
* current time. Most of the DST rules are expressed in local
* current time. If so, one should apply the time zone correction
* to GMT before applying the DST rules.
*/
typedef PRTimeParameters (PR_CALLBACK *PRTimeParamFn)(const PRExplodedTime *gmt);
PR_END_EXTERN_C
namespace nspr {
/**********************************************************************/
/****************************** FUNCTIONS *****************************/
/**********************************************************************/
PRTime
PR_ImplodeTime(const PRExplodedTime *exploded);
/*
* Adjust exploded time to normalize field overflows after manipulation.
* Note that the following fields of PRExplodedTime should not be
* manipulated:
* - tm_month and tm_year: because the number of days in a month and
* number of days in a year are not constant, it is ambiguous to
* manipulate the month and year fields, although one may be tempted
* to. For example, what does "a month from January 31st" mean?
* - tm_wday and tm_yday: these fields are calculated by NSPR. Users
* should treat them as "read-only".
*/
void PR_NormalizeTime(PRExplodedTime *exploded, PRTimeParamFn params);
/**********************************************************************/
/*********************** TIME PARAMETER FUNCTIONS *********************/
/**********************************************************************/
/* Time parameters that represent Greenwich Mean Time */
PRTimeParameters PR_GMTParameters(const PRExplodedTime *gmt);
/*
* This parses a time/date string into a PRTime
* (microseconds after "1-Jan-1970 00:00:00 GMT").
* It returns PR_SUCCESS on success, and PR_FAILURE
* if the time/date string can't be parsed.
*
* Many formats are handled, including:
*
* 14 Apr 89 03:20:12
* 14 Apr 89 03:20 GMT
* Fri, 17 Mar 89 4:01:33
* Fri, 17 Mar 89 4:01 GMT
* Mon Jan 16 16:12 PDT 1989
* Mon Jan 16 16:12 +0130 1989
* 6 May 1992 16:41-JST (Wednesday)
* 22-AUG-1993 10:59:12.82
* 22-AUG-1993 10:59pm
* 22-AUG-1993 12:59am
* 22-AUG-1993 12:59 PM
* Friday, August 04, 1995 3:54 PM
* 06/21/95 04:24:34 PM
* 20/06/95 21:07
* 95-06-08 19:32:48 EDT
*
* If the input string doesn't contain a description of the timezone,
* we consult the `default_to_gmt' to decide whether the string should
* be interpreted relative to the local time zone (PR_FALSE) or GMT (PR_TRUE).
* The correct value for this argument depends on what standard specified
* the time string which you are parsing.
*/
PRStatus PR_ParseTimeString (
const char *string,
bool default_to_gmt,
PRTime *result);
} // namespace nspr
#endif // BASE_PRTIME_H__

Просмотреть файл

@ -1,527 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** File: prtypes.h
** Description: Definitions of NSPR's basic types
**
** Prototypes and macros used to make up for deficiencies that we have found
** in ANSI environments.
**
** Since we do not wrap <stdlib.h> and all the other standard headers, authors
** of portable code will not know in general that they need these definitions.
** Instead of requiring these authors to find the dependent uses in their code
** and take the following steps only in those C files, we take steps once here
** for all C files.
**/
#ifndef prtypes_h___
#define prtypes_h___
#include "build/build_config.h"
#ifdef OS_WIN
// This files assumes windows.h has been included first since it expects _X86_
// or _AMD64_ to be defined.
#include <windows.h>
#endif // OS_WIN
#ifdef MDCPUCFG
#include MDCPUCFG
#else
#include "base/third_party/nspr/prcpucfg.h"
#endif
#include <stddef.h>
/***********************************************************************
** MACROS: PR_EXTERN
** PR_IMPLEMENT
** DESCRIPTION:
** These are only for externally visible routines and globals. For
** internal routines, just use "extern" for type checking and that
** will not export internal cross-file or forward-declared symbols.
** Define a macro for declaring procedures return types. We use this to
** deal with windoze specific type hackery for DLL definitions. Use
** PR_EXTERN when the prototype for the method is declared. Use
** PR_IMPLEMENT for the implementation of the method.
**
** Example:
** in dowhim.h
** PR_EXTERN( void ) DoWhatIMean( void );
** in dowhim.c
** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; }
**
**
***********************************************************************/
#if defined(WIN32)
#define PR_EXPORT(__type) extern __declspec(dllexport) __type
#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPORT(__type) extern __type
#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
#define PR_EXTERN(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT(__type) __type
#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#elif defined(XP_BEOS)
#define PR_EXPORT(__type) extern __declspec(dllexport) __type
#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPORT(__type) extern __declspec(dllexport) __type
#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
#define PR_EXTERN(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#elif defined(WIN16)
#define PR_CALLBACK_DECL __cdecl
#if defined(_WINDLL)
#define PR_EXPORT(__type) extern __type _cdecl _export _loadds
#define PR_IMPORT(__type) extern __type _cdecl _export _loadds
#define PR_EXPORT_DATA(__type) extern __type _export
#define PR_IMPORT_DATA(__type) extern __type _export
#define PR_EXTERN(__type) extern __type _cdecl _export _loadds
#define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
#define PR_EXTERN_DATA(__type) extern __type _export
#define PR_IMPLEMENT_DATA(__type) __type _export
#define PR_CALLBACK __cdecl __loadds
#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
#else /* this must be .EXE */
#define PR_EXPORT(__type) extern __type _cdecl _export
#define PR_IMPORT(__type) extern __type _cdecl _export
#define PR_EXPORT_DATA(__type) extern __type _export
#define PR_IMPORT_DATA(__type) extern __type _export
#define PR_EXTERN(__type) extern __type _cdecl _export
#define PR_IMPLEMENT(__type) __type _cdecl _export
#define PR_EXTERN_DATA(__type) extern __type _export
#define PR_IMPLEMENT_DATA(__type) __type _export
#define PR_CALLBACK __cdecl __loadds
#define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
#endif /* _WINDLL */
#elif defined(XP_OS2) && defined(__declspec)
#define PR_EXPORT(__type) extern __declspec(dllexport) __type
#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPORT(__type) extern __declspec(dllimport) __type
#define PR_IMPORT_DATA(__type) extern __declspec(dllimport) __type
#define PR_EXTERN(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#elif defined(XP_OS2_VACPP)
#define PR_EXPORT(__type) extern __type
#define PR_EXPORT_DATA(__type) extern __type
#define PR_IMPORT(__type) extern __type
#define PR_IMPORT_DATA(__type) extern __type
#define PR_EXTERN(__type) extern __type
#define PR_IMPLEMENT(__type) __type
#define PR_EXTERN_DATA(__type) extern __type
#define PR_IMPLEMENT_DATA(__type) __type
#define PR_CALLBACK _Optlink
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
#else /* Unix */
/* GCC 3.3 and later support the visibility attribute. */
#if (__GNUC__ >= 4) || \
(__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
#define PR_VISIBILITY_DEFAULT __attribute__((visibility("default")))
#else
#define PR_VISIBILITY_DEFAULT
#endif
#define PR_EXPORT(__type) extern PR_VISIBILITY_DEFAULT __type
#define PR_EXPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
#define PR_IMPORT(__type) extern PR_VISIBILITY_DEFAULT __type
#define PR_IMPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
#define PR_EXTERN(__type) extern PR_VISIBILITY_DEFAULT __type
#define PR_IMPLEMENT(__type) PR_VISIBILITY_DEFAULT __type
#define PR_EXTERN_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
#define PR_IMPLEMENT_DATA(__type) PR_VISIBILITY_DEFAULT __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#endif
#if defined(_NSPR_BUILD_)
#define NSPR_API(__type) PR_EXPORT(__type)
#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
#else
#define NSPR_API(__type) PR_IMPORT(__type)
#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
#endif
/***********************************************************************
** MACROS: PR_BEGIN_MACRO
** PR_END_MACRO
** DESCRIPTION:
** Macro body brackets so that macros with compound statement definitions
** behave syntactically more like functions when called.
***********************************************************************/
#define PR_BEGIN_MACRO do {
#define PR_END_MACRO } while (0)
/***********************************************************************
** MACROS: PR_BEGIN_EXTERN_C
** PR_END_EXTERN_C
** DESCRIPTION:
** Macro shorthands for conditional C++ extern block delimiters.
***********************************************************************/
#ifdef __cplusplus
#define PR_BEGIN_EXTERN_C extern "C" {
#define PR_END_EXTERN_C }
#else
#define PR_BEGIN_EXTERN_C
#define PR_END_EXTERN_C
#endif
/***********************************************************************
** MACROS: PR_BIT
** PR_BITMASK
** DESCRIPTION:
** Bit masking macros. XXX n must be <= 31 to be portable
***********************************************************************/
#define PR_BIT(n) ((PRUint32)1 << (n))
#define PR_BITMASK(n) (PR_BIT(n) - 1)
/***********************************************************************
** MACROS: PR_ROUNDUP
** PR_MIN
** PR_MAX
** PR_ABS
** DESCRIPTION:
** Commonly used macros for operations on compatible types.
***********************************************************************/
#define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y))
#define PR_MIN(x,y) ((x)<(y)?(x):(y))
#define PR_MAX(x,y) ((x)>(y)?(x):(y))
#define PR_ABS(x) ((x)<0?-(x):(x))
PR_BEGIN_EXTERN_C
/************************************************************************
** TYPES: PRUint8
** PRInt8
** DESCRIPTION:
** The int8 types are known to be 8 bits each. There is no type that
** is equivalent to a plain "char".
************************************************************************/
#if PR_BYTES_PER_BYTE == 1
typedef unsigned char PRUint8;
/*
** Some cfront-based C++ compilers do not like 'signed char' and
** issue the warning message:
** warning: "signed" not implemented (ignored)
** For these compilers, we have to define PRInt8 as plain 'char'.
** Make sure that plain 'char' is indeed signed under these compilers.
*/
#if (defined(HPUX) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus < 199707L) \
|| (defined(SCO) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus == 1L)
typedef char PRInt8;
#else
typedef signed char PRInt8;
#endif
#else
#error No suitable type for PRInt8/PRUint8
#endif
/************************************************************************
* MACROS: PR_INT8_MAX
* PR_INT8_MIN
* PR_UINT8_MAX
* DESCRIPTION:
* The maximum and minimum values of a PRInt8 or PRUint8.
************************************************************************/
#define PR_INT8_MAX 127
#define PR_INT8_MIN (-128)
#define PR_UINT8_MAX 255U
/************************************************************************
** TYPES: PRUint16
** PRInt16
** DESCRIPTION:
** The int16 types are known to be 16 bits each.
************************************************************************/
#if PR_BYTES_PER_SHORT == 2
typedef unsigned short PRUint16;
typedef short PRInt16;
#else
#error No suitable type for PRInt16/PRUint16
#endif
/************************************************************************
* MACROS: PR_INT16_MAX
* PR_INT16_MIN
* PR_UINT16_MAX
* DESCRIPTION:
* The maximum and minimum values of a PRInt16 or PRUint16.
************************************************************************/
#define PR_INT16_MAX 32767
#define PR_INT16_MIN (-32768)
#define PR_UINT16_MAX 65535U
/************************************************************************
** TYPES: PRUint32
** PRInt32
** DESCRIPTION:
** The int32 types are known to be 32 bits each.
************************************************************************/
#if PR_BYTES_PER_INT == 4
typedef unsigned int PRUint32;
typedef int PRInt32;
#define PR_INT32(x) x
#define PR_UINT32(x) x ## U
#elif PR_BYTES_PER_LONG == 4
typedef unsigned long PRUint32;
typedef long PRInt32;
#define PR_INT32(x) x ## L
#define PR_UINT32(x) x ## UL
#else
#error No suitable type for PRInt32/PRUint32
#endif
/************************************************************************
* MACROS: PR_INT32_MAX
* PR_INT32_MIN
* PR_UINT32_MAX
* DESCRIPTION:
* The maximum and minimum values of a PRInt32 or PRUint32.
************************************************************************/
#define PR_INT32_MAX PR_INT32(2147483647)
#define PR_INT32_MIN (-PR_INT32_MAX - 1)
#define PR_UINT32_MAX PR_UINT32(4294967295)
/************************************************************************
** TYPES: PRUint64
** PRInt64
** DESCRIPTION:
** The int64 types are known to be 64 bits each. Care must be used when
** declaring variables of type PRUint64 or PRInt64. Different hardware
** architectures and even different compilers have varying support for
** 64 bit values. The only guaranteed portability requires the use of
** the LL_ macros (see prlong.h).
************************************************************************/
#ifdef HAVE_LONG_LONG
#if PR_BYTES_PER_LONG == 8
typedef long PRInt64;
typedef unsigned long PRUint64;
#elif defined(WIN16)
typedef __int64 PRInt64;
typedef unsigned __int64 PRUint64;
#elif defined(WIN32) && !defined(__GNUC__)
typedef __int64 PRInt64;
typedef unsigned __int64 PRUint64;
#else
typedef long long PRInt64;
typedef unsigned long long PRUint64;
#endif /* PR_BYTES_PER_LONG == 8 */
#else /* !HAVE_LONG_LONG */
typedef struct {
#ifdef IS_LITTLE_ENDIAN
PRUint32 lo, hi;
#else
PRUint32 hi, lo;
#endif
} PRInt64;
typedef PRInt64 PRUint64;
#endif /* !HAVE_LONG_LONG */
/************************************************************************
** TYPES: PRUintn
** PRIntn
** DESCRIPTION:
** The PRIntn types are most appropriate for automatic variables. They are
** guaranteed to be at least 16 bits, though various architectures may
** define them to be wider (e.g., 32 or even 64 bits). These types are
** never valid for fields of a structure.
************************************************************************/
#if PR_BYTES_PER_INT >= 2
typedef int PRIntn;
typedef unsigned int PRUintn;
#else
#error 'sizeof(int)' not sufficient for platform use
#endif
/************************************************************************
** TYPES: PRFloat64
** DESCRIPTION:
** NSPR's floating point type is always 64 bits.
************************************************************************/
typedef double PRFloat64;
/************************************************************************
** TYPES: PRSize
** DESCRIPTION:
** A type for representing the size of objects.
************************************************************************/
typedef size_t PRSize;
/************************************************************************
** TYPES: PROffset32, PROffset64
** DESCRIPTION:
** A type for representing byte offsets from some location.
************************************************************************/
typedef PRInt32 PROffset32;
typedef PRInt64 PROffset64;
/************************************************************************
** TYPES: PRPtrDiff
** DESCRIPTION:
** A type for pointer difference. Variables of this type are suitable
** for storing a pointer or pointer subtraction.
************************************************************************/
typedef ptrdiff_t PRPtrdiff;
/************************************************************************
** TYPES: PRUptrdiff
** DESCRIPTION:
** A type for pointer difference. Variables of this type are suitable
** for storing a pointer or pointer sutraction.
************************************************************************/
#ifdef _WIN64
typedef unsigned __int64 PRUptrdiff;
#else
typedef unsigned long PRUptrdiff;
#endif
/************************************************************************
** TYPES: PRBool
** DESCRIPTION:
** Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE
** for clarity of target type in assignments and actual arguments. Use
** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans
** just as you would C int-valued conditions.
************************************************************************/
typedef PRIntn PRBool;
#define PR_TRUE 1
#define PR_FALSE 0
/************************************************************************
** TYPES: PRPackedBool
** DESCRIPTION:
** Use PRPackedBool within structs where bitfields are not desirable
** but minimum and consistant overhead matters.
************************************************************************/
typedef PRUint8 PRPackedBool;
/*
** Status code used by some routines that have a single point of failure or
** special status return.
*/
typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
#ifndef __PRUNICHAR__
#define __PRUNICHAR__
#if defined(WIN32)
typedef wchar_t PRUnichar;
#else
typedef PRUint16 PRUnichar;
#endif
#endif
/*
** WARNING: The undocumented data types PRWord and PRUword are
** only used in the garbage collection and arena code. Do not
** use PRWord and PRUword in new code.
**
** A PRWord is an integer that is the same size as a void*.
** It implements the notion of a "word" in the Java Virtual
** Machine. (See Sec. 3.4 "Words", The Java Virtual Machine
** Specification, Addison-Wesley, September 1996.
** http://java.sun.com/docs/books/vmspec/index.html.)
*/
#ifdef _WIN64
typedef __int64 PRWord;
typedef unsigned __int64 PRUword;
#else
typedef long PRWord;
typedef unsigned long PRUword;
#endif
#if defined(NO_NSPR_10_SUPPORT)
#else
/********* ???????????????? FIX ME ??????????????????????????? *****/
/********************** Some old definitions until pr=>ds transition is done ***/
/********************** Also, we are still using NSPR 1.0. GC ******************/
/*
** Fundamental NSPR macros, used nearly everywhere.
*/
#define PR_PUBLIC_API PR_IMPLEMENT
/*
** Macro body brackets so that macros with compound statement definitions
** behave syntactically more like functions when called.
*/
#define NSPR_BEGIN_MACRO do {
#define NSPR_END_MACRO } while (0)
/*
** Macro shorthands for conditional C++ extern block delimiters.
*/
#ifdef NSPR_BEGIN_EXTERN_C
#undef NSPR_BEGIN_EXTERN_C
#endif
#ifdef NSPR_END_EXTERN_C
#undef NSPR_END_EXTERN_C
#endif
#ifdef __cplusplus
#define NSPR_BEGIN_EXTERN_C extern "C" {
#define NSPR_END_EXTERN_C }
#else
#define NSPR_BEGIN_EXTERN_C
#define NSPR_END_EXTERN_C
#endif
/********* ????????????? End Fix me ?????????????????????????????? *****/
#endif /* NO_NSPR_10_SUPPORT */
PR_END_EXTERN_C
#if !defined(NO_NSPR_10_SUPPORT)
#include "base/basictypes.h"
#endif
#endif /* prtypes_h___ */

Просмотреть файл

@ -5,12 +5,10 @@
#include "base/time.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "base/third_party/nspr/prtime.h"
#include "prtime.h"
#include "base/logging.h"
using namespace nspr;
namespace base {
// TimeDelta ------------------------------------------------------------------

Просмотреть файл

@ -1713,6 +1713,7 @@ NS_IMETHODIMP
DocumentViewerImpl::SetDocumentInternal(nsIDocument* aDocument,
bool aForceReuseInnerWindow)
{
MOZ_ASSERT(aDocument);
// Set new container
nsCOMPtr<nsISupports> container = do_QueryReferent(mContainer);

Просмотреть файл

@ -1236,6 +1236,21 @@ public:
size_t *aTextRunsSize,
size_t *aPresContextSize) const = 0;
/**
* Methods that retrieve the cached font inflation preferences.
*/
PRUint32 FontSizeInflationEmPerLine() const {
return mFontSizeInflationEmPerLine;
}
PRUint32 FontSizeInflationMinTwips() const {
return mFontSizeInflationMinTwips;
}
PRUint32 FontSizeInflationLineThreshold() const {
return mFontSizeInflationLineThreshold;
}
/**
* Refresh observer management.
*/
@ -1362,6 +1377,12 @@ protected:
bool mScrollPositionClampingScrollPortSizeSet : 1;
static nsIContent* gKeyDownTarget;
// Cached font inflation values. This is done to prevent changing of font
// inflation until a page is reloaded.
PRUint32 mFontSizeInflationEmPerLine;
PRUint32 mFontSizeInflationMinTwips;
PRUint32 mFontSizeInflationLineThreshold;
};
/**

Просмотреть файл

@ -4707,8 +4707,10 @@ nsReflowFrameRunnable::Run()
static nscoord
MinimumFontSizeFor(nsPresContext* aPresContext, nscoord aContainerWidth)
{
PRUint32 emPerLine = nsLayoutUtils::FontSizeInflationEmPerLine();
PRUint32 minTwips = nsLayoutUtils::FontSizeInflationMinTwips();
nsIPresShell* presShell = aPresContext->PresShell();
PRUint32 emPerLine = presShell->FontSizeInflationEmPerLine();
PRUint32 minTwips = presShell->FontSizeInflationMinTwips();
if (emPerLine == 0 && minTwips == 0) {
return 0;
}
@ -4859,8 +4861,11 @@ nsLayoutUtils::FontSizeInflationFor(const nsIFrame *aFrame)
/* static */ bool
nsLayoutUtils::FontSizeInflationEnabled(nsPresContext *aPresContext)
{
if ((sFontSizeInflationEmPerLine == 0 &&
sFontSizeInflationMinTwips == 0) ||
nsIPresShell* presShell = aPresContext->GetPresShell();
if (!presShell ||
(presShell->FontSizeInflationEmPerLine() == 0 &&
presShell->FontSizeInflationMinTwips() == 0) ||
aPresContext->IsChrome()) {
return false;
}

Просмотреть файл

@ -109,18 +109,20 @@ private:
} // anonymous namespace
static nscolor
MakeColorPref(const nsString& aColor)
nscolor
nsPresContext::MakeColorPref(const nsString& aColor)
{
nscolor color;
nsCSSParser parser;
nsresult rv =
parser.ParseColorString(aColor, nsnull, 0, &color);
if (NS_FAILED(rv)) {
nsCSSValue value;
if (!parser.ParseColorString(aColor, nsnull, 0, value)) {
// Any better choices?
color = NS_RGB(0, 0, 0);
return NS_RGB(0, 0, 0);
}
return color;
nscolor color;
return nsRuleNode::ComputeColor(value, this, nsnull, color)
? color
: NS_RGB(0, 0, 0);
}
int

Просмотреть файл

@ -1247,6 +1247,8 @@ protected:
eDefaultFont_COUNT
};
nscolor MakeColorPref(const nsString& aColor);
#ifdef DEBUG
private:
friend struct nsAutoLayoutPhase;

Просмотреть файл

@ -872,6 +872,9 @@ PresShell::Init(nsIDocument* aDocument,
// Get our activeness from the docShell.
QueryIsActive();
// Setup our font inflation preferences.
SetupFontInflation();
return NS_OK;
}
@ -8957,3 +8960,11 @@ nsIPresShell::SetScrollPositionClampingScrollPortSize(nscoord aWidth, nscoord aH
mScrollPositionClampingScrollPortSize.width = aWidth;
mScrollPositionClampingScrollPortSize.height = aHeight;
}
void
PresShell::SetupFontInflation()
{
mFontSizeInflationEmPerLine = nsLayoutUtils::FontSizeInflationEmPerLine();
mFontSizeInflationMinTwips = nsLayoutUtils::FontSizeInflationMinTwips();
mFontSizeInflationLineThreshold = nsLayoutUtils::FontSizeInflationLineThreshold();
}

Просмотреть файл

@ -378,6 +378,15 @@ protected:
// Helper for ScrollContentIntoView
void DoScrollContentIntoView();
/**
* Initialize cached font inflation preference values.
*
* @see nsLayoutUtils::sFontSizeInflationEmPerLine
* @see nsLayoutUtils::sFontSizeInflationMinTwips
* @see nsLayoutUtils::sFontSizeInflationLineThreshold
*/
void SetupFontInflation();
friend struct AutoRenderingStateSaveRestore;
friend struct RenderingState;

Просмотреть файл

@ -339,6 +339,7 @@ _TEST_FILES += \
test_bug570378-persian-5g.html \
bug570378-persian-5.html \
bug570378-persian-5-ref.html \
test_bug749186.html \
$(NULL)
# THESE TESTS (ABOVE AND BELOW) DO NOT RUN ON WINDOWS
_TEST_FILES += \

Просмотреть файл

@ -0,0 +1,50 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=749186
Note that this is a crashtest, but because of the special privileges
required, it needs to be run as a mochitest. Thus, the expected
behavior of this test is that it actually loads and doesn't crash the
browser.
-->
<head>
<title>Test for Bug 749186 (Crashtest)</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script>
function endTest() {
ok(true, 'test finished without crashing');
SimpleTest.finish();
}
function setEmPerLineTo0() {
SpecialPowers.setIntPref("font.size.inflation.emPerLine", 0);
setTimeout(endTest, 100);
}
function removeBoldStyle() {
document.getElementById('b').removeAttribute('style');
setTimeout(setEmPerLineTo0, 100);
}
function setEmPerLineTo8() {
SpecialPowers.setIntPref("font.size.inflation.emPerLine", 8);
setTimeout(removeBoldStyle, 100);
}
function startTest() {
SimpleTest.waitForExplicitFinish();
setTimeout(setEmPerLineTo8, 100);
}
startTest();
</script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=749186">Bug 749186</a>
<iframe id="a" style="display: none;"></iframe>
<div id="b" style="display: inline;"></div>
</body>
</html>

Просмотреть файл

@ -199,7 +199,8 @@ nsFontInflationData::UpdateWidth(const nsHTMLReflowState &aReflowState)
// See comment above "font.size.inflation.lineThreshold" in
// modules/libpref/src/init/all.js .
PRUint32 lineThreshold = nsLayoutUtils::FontSizeInflationLineThreshold();
nsIPresShell* presShell = bfc->PresContext()->PresShell();
PRUint32 lineThreshold = presShell->FontSizeInflationLineThreshold();
nscoord newTextThreshold = (newNCAWidth * lineThreshold) / 100;
if (mTextThreshold <= mTextAmount && mTextAmount < newTextThreshold) {

Просмотреть файл

@ -209,10 +209,10 @@ public:
nsMediaList* aMediaList,
bool aHTMLMode);
nsresult ParseColorString(const nsSubstring& aBuffer,
nsIURI* aURL, // for error reporting
PRUint32 aLineNumber, // for error reporting
nscolor* aColor);
bool ParseColorString(const nsSubstring& aBuffer,
nsIURI* aURL, // for error reporting
PRUint32 aLineNumber, // for error reporting
nsCSSValue& aValue);
nsresult ParseSelectorString(const nsSubstring& aSelectorString,
nsIURI* aURL, // for error reporting
@ -1167,58 +1167,20 @@ CSSParserImpl::ParseMediaList(const nsSubstring& aBuffer,
return NS_OK;
}
nsresult
bool
CSSParserImpl::ParseColorString(const nsSubstring& aBuffer,
nsIURI* aURI, // for error reporting
PRUint32 aLineNumber, // for error reporting
nscolor* aColor)
nsCSSValue& aValue)
{
AssertInitialState();
InitScanner(aBuffer, aURI, aLineNumber, aURI, nsnull);
nsCSSValue value;
// Parse a color, and check that there's nothing else after it.
bool colorParsed = ParseColor(value) && !GetToken(true);
bool colorParsed = ParseColor(aValue) && !GetToken(true);
OUTPUT_ERROR();
ReleaseScanner();
if (!colorParsed) {
return NS_ERROR_FAILURE;
}
switch (value.GetUnit()) {
case eCSSUnit_Color:
*aColor = value.GetColorValue();
return NS_OK;
case eCSSUnit_Ident: {
nsDependentString id(value.GetStringBufferValue());
if (!NS_ColorNameToRGB(id, aColor)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
case eCSSUnit_EnumColor: {
PRInt32 val = value.GetIntValue();
if (val < 0) {
// XXX - negative numbers are NS_COLOR_CURRENTCOLOR,
// NS_COLOR_MOZ_HYPERLINKTEXT, etc. which we don't handle.
// Should remove this limitation at some point.
return NS_ERROR_FAILURE;
}
nscolor rgba;
nsresult rv = LookAndFeel::GetColor(LookAndFeel::ColorID(val), &rgba);
if (NS_FAILED(rv)) {
return rv;
}
*aColor = rgba;
return NS_OK;
}
default:
return NS_ERROR_FAILURE;
}
return colorParsed;
}
nsresult
@ -9526,14 +9488,14 @@ nsCSSParser::ParseMediaList(const nsSubstring& aBuffer,
ParseMediaList(aBuffer, aURI, aLineNumber, aMediaList, aHTMLMode);
}
nsresult
bool
nsCSSParser::ParseColorString(const nsSubstring& aBuffer,
nsIURI* aURI,
PRUint32 aLineNumber,
nscolor* aColor)
nsCSSValue& aValue)
{
return static_cast<CSSParserImpl*>(mImpl)->
ParseColorString(aBuffer, aURI, aLineNumber, aColor);
ParseColorString(aBuffer, aURI, aLineNumber, aValue);
}
nsresult

Просмотреть файл

@ -23,6 +23,7 @@ class nsIURI;
struct nsCSSSelectorList;
class nsMediaList;
class nsCSSKeyframeRule;
class nsCSSValue;
namespace mozilla {
namespace css {
@ -136,18 +137,15 @@ public:
bool aHTMLMode);
/**
* Parse aBuffer into a nscolor |aColor|. The alpha component of the
* resulting aColor may vary due to rgba()/hsla(). Will return
* NS_ERROR_FAILURE if aBuffer is not a valid CSS color specification.
*
* Will also currently return NS_ERROR_FAILURE if it is not
* self-contained (i.e. doesn't reference any external style state,
* such as "initial" or "inherit").
* Parse aBuffer into a nsCSSValue |aValue|. Will return false
* if aBuffer is not a valid CSS color specification.
* One can use nsRuleNode::ComputeColor to compute an nscolor from
* the returned nsCSSValue.
*/
nsresult ParseColorString(const nsSubstring& aBuffer,
nsIURI* aURL,
PRUint32 aLineNumber,
nscolor* aColor);
bool ParseColorString(const nsSubstring& aBuffer,
nsIURI* aURL,
PRUint32 aLineNumber,
nsCSSValue& aValue);
/**
* Parse aBuffer into a selector list. On success, caller must

Просмотреть файл

@ -13,7 +13,6 @@
#include "nscore.h"
#include "nsIServiceManager.h"
#include "nsIWidget.h"
#include "mozilla/LookAndFeel.h"
#include "nsIPresShell.h"
#include "nsFontMetrics.h"
#include "gfxFont.h"
@ -36,9 +35,12 @@
#include "nsCSSProps.h"
#include "nsTArray.h"
#include "nsContentUtils.h"
#include "mozilla/dom/Element.h"
#include "CSSCalc.h"
#include "nsPrintfCString.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/Element.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/Util.h"
#if defined(_MSC_VER) || defined(__MINGW32__)
@ -733,33 +735,52 @@ static bool SetColor(const nsCSSValue& aValue, const nscolor aParentColor,
}
}
else {
aResult = NS_RGB(0, 0, 0);
result = false;
switch (intValue) {
case NS_COLOR_MOZ_HYPERLINKTEXT:
aResult = aPresContext->DefaultLinkColor();
if (aPresContext) {
aResult = aPresContext->DefaultLinkColor();
result = true;
}
break;
case NS_COLOR_MOZ_VISITEDHYPERLINKTEXT:
aResult = aPresContext->DefaultVisitedLinkColor();
if (aPresContext) {
aResult = aPresContext->DefaultVisitedLinkColor();
result = true;
}
break;
case NS_COLOR_MOZ_ACTIVEHYPERLINKTEXT:
aResult = aPresContext->DefaultActiveLinkColor();
if (aPresContext) {
aResult = aPresContext->DefaultActiveLinkColor();
result = true;
}
break;
case NS_COLOR_CURRENTCOLOR:
// The data computed from this can't be shared in the rule tree
// because they could be used on a node with a different color
aCanStoreInRuleTree = false;
aResult = aContext->GetStyleColor()->mColor;
if (aContext) {
aResult = aContext->GetStyleColor()->mColor;
result = true;
}
break;
case NS_COLOR_MOZ_DEFAULT_COLOR:
aResult = aPresContext->DefaultColor();
if (aPresContext) {
aResult = aPresContext->DefaultColor();
result = true;
}
break;
case NS_COLOR_MOZ_DEFAULT_BACKGROUND_COLOR:
aResult = aPresContext->DefaultBackgroundColor();
if (aPresContext) {
aResult = aPresContext->DefaultBackgroundColor();
result = true;
}
break;
default:
NS_NOTREACHED("Should never have an unknown negative colorID.");
break;
}
result = true;
}
}
else if (eCSSUnit_Inherit == unit) {
@ -7714,3 +7735,20 @@ nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
return false;
}
/* static */
bool
nsRuleNode::ComputeColor(const nsCSSValue& aValue, nsPresContext* aPresContext,
nsStyleContext* aStyleContext, nscolor& aResult)
{
MOZ_ASSERT(aValue.GetUnit() != eCSSUnit_Inherit,
"aValue shouldn't have eCSSUnit_Inherit");
MOZ_ASSERT(aValue.GetUnit() != eCSSUnit_Initial,
"aValue shouldn't have eCSSUnit_Initial");
bool canStoreInRuleTree;
bool ok = SetColor(aValue, NS_RGB(0, 0, 0), aPresContext, aStyleContext,
aResult, canStoreInRuleTree);
MOZ_ASSERT(ok || !(aPresContext && aStyleContext));
return ok;
}

Просмотреть файл

@ -734,6 +734,24 @@ public:
static nscoord FindNextLargerFontSize(nscoord aFontSize, PRInt32 aBasePointSize,
nsPresContext* aPresContext,
nsFontSizeType aFontSizeType = eFontSize_HTML);
/**
* @param aValue The color value, returned from nsCSSParser::ParseColorString
* @param aPresContext Presentation context whose preferences are used
* for certain enumerated colors
* @param aStyleContext Style context whose color is used for 'currentColor'
*
* @note aPresContext and aStyleContext may be null, but in that case, fully
* opaque black will be returned for the values that rely on these
* objects to compute the color. (For example, -moz-hyperlinktext.)
*
* @return false if we fail to extract a color; this will not happen if both
* aPresContext and aStyleContext are non-null
*/
static bool ComputeColor(const nsCSSValue& aValue,
nsPresContext* aPresContext,
nsStyleContext* aStyleContext,
nscolor& aResult);
};
#endif

Просмотреть файл

@ -35,7 +35,6 @@ LOCAL_INCLUDES += -I$(topsrcdir)/base/src
LOCAL_INCLUDES += -I$(topsrcdir)/nsprpub/lib/ds
LOCAL_INCLUDES += -I$(topsrcdir)/nsprpub/lib/libc/include
LOCAL_INCLUDES += -I$(topsrcdir)/nsprpub/pr/include
LOCAL_INCLUDES += -I$(topsrcdir)/ipc/chromium/src/base/third_party/nspr
LOCAL_INCLUDES += -I$(topsrcdir)/ipc/chromium/src
LOCAL_INCLUDES += -I$(topsrcdir)/security/nss/lib/nss
LOCAL_INCLUDES += -I$(topsrcdir)/security/nss/lib/util
@ -64,3 +63,12 @@ endif
EXPORTS = APKOpen.h
include $(topsrcdir)/config/rules.mk
prcpucfg.h: $(topsrcdir)/nsprpub/pr/include/md/_linux.cfg
cp $< $@
$(OBJS): prcpucfg.h
GARBAGE += \
prcpucfg.h \
$(NULL)

Просмотреть файл

@ -380,13 +380,13 @@ JSHistogram_Add(JSContext *cx, unsigned argc, jsval *vp)
}
jsval v = JS_ARGV(cx, vp)[0];
int32 value;
if (!(JSVAL_IS_NUMBER(v) || JSVAL_IS_BOOLEAN(v))) {
JS_ReportError(cx, "Not a number");
return JS_FALSE;
}
int32_t value;
if (!JS_ValueToECMAInt32(cx, v, &value)) {
return JS_FALSE;
}