зеркало из https://github.com/mozilla/pjs.git
Part of fix for bug 13718 -- API for natural dimensions of image. Extend the netscape nsIDOMImage interface. r=jst
This commit is contained in:
Родитель
8cb56670ff
Коммит
af6a256dca
|
@ -1,98 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Norris Boyd
|
||||
#
|
||||
|
||||
open(IN, "nsDOMPropEnums.h") ||
|
||||
die("Error opening 'nsDOMPropEnums.h': $!\n");
|
||||
|
||||
open(OUT, ">nsDOMPropNames.h") ||
|
||||
die("Error opening 'nsDOMPropNames.h': $!\n");
|
||||
|
||||
while (<IN>) {
|
||||
if (/^enum nsDOMProp/) {
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
print OUT <<'EOF';
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
*/
|
||||
|
||||
/* nsDOMPropNames.h -- an definition of all DOM property names used to provide
|
||||
** per-property security policies.
|
||||
** AUTOMATICALLY GENERATED -- See genPropNames.pl
|
||||
*/
|
||||
|
||||
#ifndef nsDOMPropNames_h__
|
||||
#define nsDOMPropNames_h__
|
||||
|
||||
#define NS_DOM_PROP_NAMES \
|
||||
EOF
|
||||
|
||||
$last = "";
|
||||
|
||||
while (<IN>) {
|
||||
if (/NS_DOM_PROP_MAX/) {
|
||||
last;
|
||||
}
|
||||
$save = $_;
|
||||
s/,.*/", \\/;
|
||||
s/NS_DOM_PROP_/"/;
|
||||
s/_/./;
|
||||
$_ = lc($_);
|
||||
print OUT $_;
|
||||
# Check order of names and make sure they are sorted.
|
||||
# It's important we check after the subsitution of '.' for '_'
|
||||
# since it's the sort order of the names we care about and '.'
|
||||
# and '_' sort differently with respect to letters.
|
||||
if ($last ne "" && ($last gt $_)) {
|
||||
die "Name $lastsave and $save are out of order in nsDOMPropEnums.h.\n";
|
||||
}
|
||||
$last = $_;
|
||||
$lastsave = $save;
|
||||
}
|
||||
|
||||
print OUT <<EOF;
|
||||
|
||||
#endif // nsDOMPropNames_h__
|
||||
EOF
|
||||
|
|
@ -56,6 +56,10 @@ public:
|
|||
|
||||
NS_IMETHOD GetWidth(PRInt32* aWidth)=0;
|
||||
NS_IMETHOD SetWidth(PRInt32 aWidth)=0;
|
||||
|
||||
NS_IMETHOD GetNaturalHeight(PRInt32* aNaturalHeight)=0;
|
||||
|
||||
NS_IMETHOD GetNaturalWidth(PRInt32* aNaturalWidth)=0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -73,6 +77,8 @@ public:
|
|||
NS_IMETHOD SetVspace(PRInt32 aVspace); \
|
||||
NS_IMETHOD GetWidth(PRInt32* aWidth); \
|
||||
NS_IMETHOD SetWidth(PRInt32 aWidth); \
|
||||
NS_IMETHOD GetNaturalHeight(PRInt32* aNaturalHeight); \
|
||||
NS_IMETHOD GetNaturalWidth(PRInt32* aNaturalWidth); \
|
||||
|
||||
|
||||
|
||||
|
@ -90,6 +96,8 @@ public:
|
|||
NS_IMETHOD SetVspace(PRInt32 aVspace) { return _to SetVspace(aVspace); } \
|
||||
NS_IMETHOD GetWidth(PRInt32* aWidth) { return _to GetWidth(aWidth); } \
|
||||
NS_IMETHOD SetWidth(PRInt32 aWidth) { return _to SetWidth(aWidth); } \
|
||||
NS_IMETHOD GetNaturalHeight(PRInt32* aNaturalHeight) { return _to GetNaturalHeight(aNaturalHeight); } \
|
||||
NS_IMETHOD GetNaturalWidth(PRInt32* aNaturalWidth) { return _to GetNaturalWidth(aNaturalWidth); } \
|
||||
|
||||
|
||||
#endif // nsIDOMImage_h__
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
interface HTMLImageElement : HTMLElement {
|
||||
/* IID: { 0xa6cf90ab, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } */
|
||||
|
||||
void HTMLImageElement();
|
||||
|
||||
attribute DOMString lowSrc;
|
||||
attribute DOMString name;
|
||||
attribute DOMString align;
|
||||
attribute DOMString alt;
|
||||
noscript attribute DOMString border;
|
||||
noscript attribute DOMString height;
|
||||
noscript attribute DOMString hspace;
|
||||
attribute boolean isMap;
|
||||
attribute DOMString longDesc;
|
||||
noscript attribute DOMString src;
|
||||
noscript attribute DOMString vspace;
|
||||
noscript attribute DOMString width;
|
||||
attribute DOMString useMap;
|
||||
};
|
||||
|
||||
interface Image {
|
||||
/* IID: { 0xa6cf90c7, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } */
|
||||
|
||||
void Image();
|
||||
attribute DOMString lowsrc;
|
||||
readonly attribute boolean complete;
|
||||
|
||||
/* Needed for backwards compatibility */
|
||||
attribute long border;
|
||||
attribute long height;
|
||||
attribute long hspace;
|
||||
attribute long vspace;
|
||||
attribute long width;
|
||||
};
|
|
@ -664,6 +664,8 @@ enum nsDOMProp {
|
|||
NS_DOM_PROP_IMAGE_HEIGHT,
|
||||
NS_DOM_PROP_IMAGE_HSPACE,
|
||||
NS_DOM_PROP_IMAGE_LOWSRC,
|
||||
NS_DOM_PROP_IMAGE_NATURALHEIGHT,
|
||||
NS_DOM_PROP_IMAGE_NATURALWIDTH,
|
||||
NS_DOM_PROP_IMAGE_VSPACE,
|
||||
NS_DOM_PROP_IMAGE_WIDTH,
|
||||
NS_DOM_PROP_JAVASCRIPT_ENABLED,
|
||||
|
|
|
@ -662,6 +662,8 @@
|
|||
"image.height", \
|
||||
"image.hspace", \
|
||||
"image.lowsrc", \
|
||||
"image.naturalheight", \
|
||||
"image.naturalwidth", \
|
||||
"image.vspace", \
|
||||
"image.width", \
|
||||
"javascript.enabled", \
|
||||
|
|
|
@ -65,7 +65,9 @@ enum HTMLImageElement_slots {
|
|||
IMAGE_HEIGHT = -11,
|
||||
IMAGE_HSPACE = -12,
|
||||
IMAGE_VSPACE = -13,
|
||||
IMAGE_WIDTH = -14
|
||||
IMAGE_WIDTH = -14,
|
||||
IMAGE_NATURALHEIGHT = -15,
|
||||
IMAGE_NATURALWIDTH = -16
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -305,6 +307,44 @@ GetHTMLImageElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case IMAGE_NATURALHEIGHT:
|
||||
{
|
||||
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_IMAGE_NATURALHEIGHT, PR_FALSE);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRInt32 prop;
|
||||
nsIDOMImage* b;
|
||||
if (NS_OK == a->QueryInterface(kIImageIID, (void **)&b)) {
|
||||
rv = b->GetNaturalHeight(&prop);
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
}
|
||||
NS_RELEASE(b);
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_DOM_WRONG_TYPE_ERR;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IMAGE_NATURALWIDTH:
|
||||
{
|
||||
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_IMAGE_NATURALWIDTH, PR_FALSE);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRInt32 prop;
|
||||
nsIDOMImage* b;
|
||||
if (NS_OK == a->QueryInterface(kIImageIID, (void **)&b)) {
|
||||
rv = b->GetNaturalWidth(&prop);
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
}
|
||||
NS_RELEASE(b);
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_DOM_WRONG_TYPE_ERR;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp);
|
||||
}
|
||||
|
@ -663,6 +703,8 @@ static JSPropertySpec HTMLImageElementProperties[] =
|
|||
{"hspace", IMAGE_HSPACE, JSPROP_ENUMERATE},
|
||||
{"vspace", IMAGE_VSPACE, JSPROP_ENUMERATE},
|
||||
{"width", IMAGE_WIDTH, JSPROP_ENUMERATE},
|
||||
{"naturalHeight", IMAGE_NATURALHEIGHT, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"naturalWidth", IMAGE_NATURALWIDTH, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
|
||||
#include "MacPrefix_debug.h"
|
||||
|
Загрузка…
Ссылка в новой задаче