зеркало из https://github.com/mozilla/pjs.git
Bug 234615: Remove nsIHTMLContent::GetBaseTarget by cleaning up the imagemap code a bit which was the only client.
r=bryner sr=jst
This commit is contained in:
Родитель
394ebcdd9c
Коммит
580557c74f
|
@ -2263,12 +2263,6 @@ nsGenericElement::GetBaseURI() const
|
|||
return base;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericElement::GetBaseTarget(nsAString& aBaseTarget) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericElement::RangeAdd(nsIDOMRange* aRange)
|
||||
{
|
||||
|
|
|
@ -440,7 +440,6 @@ public:
|
|||
NS_IMETHOD GetHTMLAttribute(nsIAtom* aAttribute,
|
||||
nsHTMLValue& aValue) const;
|
||||
NS_IMETHOD GetAttributeMappingFunction(nsMapRuleToAttributesFunc& aMapRuleFunc) const;
|
||||
NS_IMETHOD GetBaseTarget(nsAString& aBaseTarget) const;
|
||||
|
||||
// nsIDOMNode method implementation
|
||||
NS_IMETHOD GetNodeName(nsAString& aNodeName);
|
||||
|
|
|
@ -101,16 +101,6 @@ public:
|
|||
* @param aMapRuleFunc the mapping function [OUT]
|
||||
*/
|
||||
NS_IMETHOD GetAttributeMappingFunction(nsMapRuleToAttributesFunc& aMapRuleFunc) const = 0;
|
||||
|
||||
/**
|
||||
* Get the base target for any links within this piece
|
||||
* of content. Generally, this is the document's base target,
|
||||
* but certain content carries a local base for backward
|
||||
* compatibility.
|
||||
*
|
||||
* @param aBaseTarget the base target [OUT]
|
||||
*/
|
||||
NS_IMETHOD GetBaseTarget(nsAString& aBaseTarget) const = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIHTMLContent_h___ */
|
||||
|
|
|
@ -2144,13 +2144,13 @@ nsGenericHTMLElement::GetBaseURI() const
|
|||
return nsGenericContainerElement::GetBaseURI();
|
||||
}
|
||||
|
||||
nsresult
|
||||
void
|
||||
nsGenericHTMLElement::GetBaseTarget(nsAString& aBaseTarget) const
|
||||
{
|
||||
const nsAttrValue* val = mAttrsAndChildren.GetAttr(nsHTMLAtoms::_baseTarget);
|
||||
if (val) {
|
||||
val->ToString(aBaseTarget);
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mDocument) {
|
||||
|
@ -2159,8 +2159,6 @@ nsGenericHTMLElement::GetBaseTarget(nsAString& aBaseTarget) const
|
|||
else {
|
||||
aBaseTarget.Truncate();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -213,7 +213,6 @@ public:
|
|||
NS_IMETHOD GetInlineStyleRule(nsICSSStyleRule** aStyleRule);
|
||||
NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify);
|
||||
already_AddRefed<nsIURI> GetBaseURI() const;
|
||||
NS_IMETHOD GetBaseTarget(nsAString& aBaseTarget) const;
|
||||
|
||||
//----------------------------------------
|
||||
/**
|
||||
|
@ -250,6 +249,16 @@ public:
|
|||
NS_IMETHOD_(PRBool) HasAttributeDependentStyle(const nsIAtom* aAttribute) const;
|
||||
NS_IMETHOD GetAttributeMappingFunction(nsMapRuleToAttributesFunc& aMapRuleFunc) const;
|
||||
|
||||
/**
|
||||
* Get the base target for any links within this piece
|
||||
* of content. Generally, this is the document's base target,
|
||||
* but certain content carries a local base for backward
|
||||
* compatibility.
|
||||
*
|
||||
* @param aBaseTarget the base target [OUT]
|
||||
*/
|
||||
void GetBaseTarget(nsAString& aBaseTarget) const;
|
||||
|
||||
#ifdef DEBUG
|
||||
void ListAttributes(FILE* out) const;
|
||||
#endif
|
||||
|
|
|
@ -341,8 +341,8 @@ nsHTMLAnchorElement::GetTarget(nsAString& aValue)
|
|||
|
||||
nsresult rv;
|
||||
rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aValue);
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE && mDocument) {
|
||||
mDocument->GetBaseTarget(aValue);
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE) {
|
||||
GetBaseTarget(aValue);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -197,8 +197,25 @@ NS_IMPL_URI_ATTR(nsHTMLAreaElement, Href, href)
|
|||
NS_IMPL_BOOL_ATTR(nsHTMLAreaElement, NoHref, nohref)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Shape, shape)
|
||||
NS_IMPL_INT_ATTR(nsHTMLAreaElement, TabIndex, tabindex)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Target, target)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::GetTarget(nsAString& aValue)
|
||||
{
|
||||
aValue.Truncate();
|
||||
|
||||
nsresult rv;
|
||||
rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aValue);
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE) {
|
||||
GetBaseTarget(aValue);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::SetTarget(const nsAString& aValue)
|
||||
{
|
||||
return SetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aValue, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
|
|
|
@ -1591,11 +1591,9 @@ nsImageFrame::GetContentForEvent(nsIPresContext* aPresContext,
|
|||
if (nsnull != map) {
|
||||
nsPoint p;
|
||||
TranslateEventCoords(aPresContext, aEvent->point, p);
|
||||
nsAutoString absURL, target, altText;
|
||||
PRBool inside = PR_FALSE;
|
||||
nsCOMPtr<nsIContent> area;
|
||||
inside = map->IsInside(p.x, p.y, getter_AddRefs(area),
|
||||
absURL, target, altText);
|
||||
inside = map->IsInside(p.x, p.y, getter_AddRefs(area));
|
||||
if (inside && area) {
|
||||
*aContent = area;
|
||||
NS_ADDREF(*aContent);
|
||||
|
@ -1626,7 +1624,6 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
if ((nsnull != map) || isServerMap) {
|
||||
nsPoint p;
|
||||
TranslateEventCoords(aPresContext, aEvent->point, p);
|
||||
nsAutoString absURL, target, altText;
|
||||
PRBool inside = PR_FALSE;
|
||||
// Even though client-side image map triggering happens
|
||||
// through content, we need to make sure we're not inside
|
||||
|
@ -1634,8 +1631,7 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
// sever-side on the same image - it happens!)
|
||||
if (nsnull != map) {
|
||||
nsCOMPtr<nsIContent> area;
|
||||
inside = map->IsInside(p.x, p.y, getter_AddRefs(area),
|
||||
absURL, target, altText);
|
||||
inside = map->IsInside(p.x, p.y, getter_AddRefs(area));
|
||||
}
|
||||
|
||||
if (!inside && isServerMap) {
|
||||
|
@ -1643,6 +1639,7 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
// Server side image maps use the href in a containing anchor
|
||||
// element to provide the basis for the destination url.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsAutoString target;
|
||||
if (GetAnchorHREFAndTarget(getter_AddRefs(uri), target)) {
|
||||
// XXX if the mouse is over/clicked in the border/padding area
|
||||
// we should probably just pretend nothing happened. Nav4
|
||||
|
|
|
@ -71,7 +71,7 @@ static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
|||
|
||||
class Area {
|
||||
public:
|
||||
Area(nsIContent* aArea, PRBool aHasURL);
|
||||
Area(nsIContent* aArea);
|
||||
virtual ~Area();
|
||||
|
||||
virtual void ParseCoords(const nsAString& aSpec);
|
||||
|
@ -84,22 +84,18 @@ public:
|
|||
void HasFocus(PRBool aHasFocus);
|
||||
|
||||
void GetHREF(nsAString& aHref) const;
|
||||
void GetTarget(nsAString& aTarget) const;
|
||||
void GetAltText(nsAString& aAltText) const;
|
||||
PRBool GetHasURL() const { return mHasURL; }
|
||||
void GetArea(nsIContent** aArea) const;
|
||||
|
||||
nsCOMPtr<nsIContent> mArea;
|
||||
nscoord* mCoords;
|
||||
PRInt32 mNumCoords;
|
||||
PRPackedBool mHasURL;
|
||||
PRPackedBool mHasFocus;
|
||||
};
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(Area)
|
||||
|
||||
Area::Area(nsIContent* aArea, PRBool aHasURL)
|
||||
: mArea(aArea), mHasURL(aHasURL)
|
||||
Area::Area(nsIContent* aArea)
|
||||
: mArea(aArea)
|
||||
{
|
||||
MOZ_COUNT_CTOR(Area);
|
||||
mCoords = nsnull;
|
||||
|
@ -122,24 +118,6 @@ Area::GetHREF(nsAString& aHref) const
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Area::GetTarget(nsAString& aTarget) const
|
||||
{
|
||||
aTarget.Truncate();
|
||||
if (mArea) {
|
||||
mArea->GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aTarget);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Area::GetAltText(nsAString& aAltText) const
|
||||
{
|
||||
aAltText.Truncate();
|
||||
if (mArea) {
|
||||
mArea->GetAttr(kNameSpaceID_None, nsHTMLAtoms::alt, aAltText);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Area::GetArea(nsIContent** aArea) const
|
||||
{
|
||||
|
@ -332,8 +310,7 @@ void Area::HasFocus(PRBool aHasFocus)
|
|||
|
||||
class DefaultArea : public Area {
|
||||
public:
|
||||
DefaultArea(nsIContent* aArea, PRBool aHasURL);
|
||||
~DefaultArea();
|
||||
DefaultArea(nsIContent* aArea);
|
||||
|
||||
virtual PRBool IsInside(nscoord x, nscoord y) const;
|
||||
virtual void Draw(nsIPresContext* aCX,
|
||||
|
@ -341,12 +318,8 @@ public:
|
|||
virtual void GetRect(nsIPresContext* aCX, nsRect& aRect);
|
||||
};
|
||||
|
||||
DefaultArea::DefaultArea(nsIContent* aArea, PRBool aHasURL)
|
||||
: Area(aArea, aHasURL)
|
||||
{
|
||||
}
|
||||
|
||||
DefaultArea::~DefaultArea()
|
||||
DefaultArea::DefaultArea(nsIContent* aArea)
|
||||
: Area(aArea)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -367,8 +340,7 @@ void DefaultArea::GetRect(nsIPresContext* aCX, nsRect& aRect)
|
|||
|
||||
class RectArea : public Area {
|
||||
public:
|
||||
RectArea(nsIContent* aArea, PRBool aHasURL);
|
||||
~RectArea();
|
||||
RectArea(nsIContent* aArea);
|
||||
|
||||
virtual void ParseCoords(const nsAString& aSpec);
|
||||
virtual PRBool IsInside(nscoord x, nscoord y) const;
|
||||
|
@ -377,12 +349,8 @@ public:
|
|||
virtual void GetRect(nsIPresContext* aCX, nsRect& aRect);
|
||||
};
|
||||
|
||||
RectArea::RectArea(nsIContent* aArea, PRBool aHasURL)
|
||||
: Area(aArea, aHasURL)
|
||||
{
|
||||
}
|
||||
|
||||
RectArea::~RectArea()
|
||||
RectArea::RectArea(nsIContent* aArea)
|
||||
: Area(aArea)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -529,8 +497,7 @@ void RectArea::GetRect(nsIPresContext* aCX, nsRect& aRect)
|
|||
|
||||
class PolyArea : public Area {
|
||||
public:
|
||||
PolyArea(nsIContent* aArea, PRBool aHasURL);
|
||||
~PolyArea();
|
||||
PolyArea(nsIContent* aArea);
|
||||
|
||||
virtual PRBool IsInside(nscoord x, nscoord y) const;
|
||||
virtual void Draw(nsIPresContext* aCX,
|
||||
|
@ -538,12 +505,8 @@ public:
|
|||
virtual void GetRect(nsIPresContext* aCX, nsRect& aRect);
|
||||
};
|
||||
|
||||
PolyArea::PolyArea(nsIContent* aArea, PRBool aHasURL)
|
||||
: Area(aArea, aHasURL)
|
||||
{
|
||||
}
|
||||
|
||||
PolyArea::~PolyArea()
|
||||
PolyArea::PolyArea(nsIContent* aArea)
|
||||
: Area(aArea)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -657,8 +620,7 @@ void PolyArea::GetRect(nsIPresContext* aCX, nsRect& aRect)
|
|||
|
||||
class CircleArea : public Area {
|
||||
public:
|
||||
CircleArea(nsIContent* aArea, PRBool aHasURL);
|
||||
~CircleArea();
|
||||
CircleArea(nsIContent* aArea);
|
||||
|
||||
virtual PRBool IsInside(nscoord x, nscoord y) const;
|
||||
virtual void Draw(nsIPresContext* aCX,
|
||||
|
@ -666,12 +628,8 @@ public:
|
|||
virtual void GetRect(nsIPresContext* aCX, nsRect& aRect);
|
||||
};
|
||||
|
||||
CircleArea::CircleArea(nsIContent* aArea, PRBool aHasURL)
|
||||
: Area(aArea, aHasURL)
|
||||
{
|
||||
}
|
||||
|
||||
CircleArea::~CircleArea()
|
||||
CircleArea::CircleArea(nsIContent* aArea)
|
||||
: Area(aArea)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -894,7 +852,6 @@ nsImageMap::AddArea(nsIContent* aArea)
|
|||
nsAutoString shape, coords;
|
||||
aArea->GetAttr(kNameSpaceID_None, nsHTMLAtoms::shape, shape);
|
||||
aArea->GetAttr(kNameSpaceID_None, nsHTMLAtoms::coords, coords);
|
||||
PRBool hasURL = !aArea->HasAttr(kNameSpaceID_None, nsHTMLAtoms::nohref);
|
||||
|
||||
//Add focus listener to track area focus changes
|
||||
nsCOMPtr<nsIDOMEventReceiver> rec(do_QueryInterface(aArea));
|
||||
|
@ -910,18 +867,18 @@ nsImageMap::AddArea(nsIContent* aArea)
|
|||
if (shape.IsEmpty() ||
|
||||
shape.EqualsIgnoreCase("rect") ||
|
||||
shape.EqualsIgnoreCase("rectangle")) {
|
||||
area = new RectArea(aArea, hasURL);
|
||||
area = new RectArea(aArea);
|
||||
}
|
||||
else if (shape.EqualsIgnoreCase("poly") ||
|
||||
shape.EqualsIgnoreCase("polygon")) {
|
||||
area = new PolyArea(aArea, hasURL);
|
||||
area = new PolyArea(aArea);
|
||||
}
|
||||
else if (shape.EqualsIgnoreCase("circle") ||
|
||||
shape.EqualsIgnoreCase("circ")) {
|
||||
area = new CircleArea(aArea, hasURL);
|
||||
area = new CircleArea(aArea);
|
||||
}
|
||||
else if (shape.EqualsIgnoreCase("default")) {
|
||||
area = new DefaultArea(aArea, hasURL);
|
||||
area = new DefaultArea(aArea);
|
||||
}
|
||||
else {
|
||||
// Unknown area type; bail
|
||||
|
@ -936,35 +893,13 @@ nsImageMap::AddArea(nsIContent* aArea)
|
|||
|
||||
PRBool
|
||||
nsImageMap::IsInside(nscoord aX, nscoord aY,
|
||||
nsIContent** aContent,
|
||||
nsAString& aAbsURL,
|
||||
nsAString& aTarget,
|
||||
nsAString& aAltText) const
|
||||
nsIContent** aContent) const
|
||||
{
|
||||
NS_ASSERTION(mMap, "Not initialized");
|
||||
PRInt32 i, n = mAreas.Count();
|
||||
for (i = 0; i < n; i++) {
|
||||
Area* area = (Area*) mAreas.ElementAt(i);
|
||||
if (area->IsInside(aX, aY)) {
|
||||
if (area->GetHasURL()) {
|
||||
// Set the image loader's source URL and base URL
|
||||
nsCOMPtr<nsIURI> baseUri = mMap->GetBaseURI();
|
||||
|
||||
if (!baseUri) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsAutoString href;
|
||||
area->GetHREF(href);
|
||||
NS_MakeAbsoluteURI(aAbsURL, href, baseUri);
|
||||
}
|
||||
|
||||
area->GetTarget(aTarget);
|
||||
if (aTarget.IsEmpty())
|
||||
mMap->GetBaseTarget(aTarget);
|
||||
|
||||
area->GetAltText(aAltText);
|
||||
|
||||
area->GetArea(aContent);
|
||||
|
||||
return PR_TRUE;
|
||||
|
|
|
@ -64,21 +64,16 @@ public:
|
|||
|
||||
/**
|
||||
* See if the given aX,aY <b>pixel</b> coordinates are in the image
|
||||
* map. If they are then NS_OK is returned and aAbsURL, aTarget, and
|
||||
* aAltText are filled in with the values from the underlying area
|
||||
* element. If the coordinates are not in the map then NS_NOT_INSIDE
|
||||
* map. If they are then PR_TRUE is returned and aContent points to the
|
||||
* found area. If the coordinates are not in the map then PR_FALSE
|
||||
* is returned.
|
||||
*/
|
||||
PRBool IsInside(nscoord aX, nscoord aY,
|
||||
nsIContent** aContent,
|
||||
nsAString& aAbsURL,
|
||||
nsAString& aTarget,
|
||||
nsAString& aAltText) const;
|
||||
nsIContent** aContent) const;
|
||||
|
||||
/**
|
||||
* See if the given aX,aY <b>pixel</b> coordinates are in the image
|
||||
* map. If they are then NS_OK is returned otherwise NS_NOT_INSIDE
|
||||
* is returned.
|
||||
* map.
|
||||
*/
|
||||
PRBool IsInside(nscoord aX, nscoord aY) const;
|
||||
|
||||
|
|
|
@ -1591,11 +1591,9 @@ nsImageFrame::GetContentForEvent(nsIPresContext* aPresContext,
|
|||
if (nsnull != map) {
|
||||
nsPoint p;
|
||||
TranslateEventCoords(aPresContext, aEvent->point, p);
|
||||
nsAutoString absURL, target, altText;
|
||||
PRBool inside = PR_FALSE;
|
||||
nsCOMPtr<nsIContent> area;
|
||||
inside = map->IsInside(p.x, p.y, getter_AddRefs(area),
|
||||
absURL, target, altText);
|
||||
inside = map->IsInside(p.x, p.y, getter_AddRefs(area));
|
||||
if (inside && area) {
|
||||
*aContent = area;
|
||||
NS_ADDREF(*aContent);
|
||||
|
@ -1626,7 +1624,6 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
if ((nsnull != map) || isServerMap) {
|
||||
nsPoint p;
|
||||
TranslateEventCoords(aPresContext, aEvent->point, p);
|
||||
nsAutoString absURL, target, altText;
|
||||
PRBool inside = PR_FALSE;
|
||||
// Even though client-side image map triggering happens
|
||||
// through content, we need to make sure we're not inside
|
||||
|
@ -1634,8 +1631,7 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
// sever-side on the same image - it happens!)
|
||||
if (nsnull != map) {
|
||||
nsCOMPtr<nsIContent> area;
|
||||
inside = map->IsInside(p.x, p.y, getter_AddRefs(area),
|
||||
absURL, target, altText);
|
||||
inside = map->IsInside(p.x, p.y, getter_AddRefs(area));
|
||||
}
|
||||
|
||||
if (!inside && isServerMap) {
|
||||
|
@ -1643,6 +1639,7 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
// Server side image maps use the href in a containing anchor
|
||||
// element to provide the basis for the destination url.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsAutoString target;
|
||||
if (GetAnchorHREFAndTarget(getter_AddRefs(uri), target)) {
|
||||
// XXX if the mouse is over/clicked in the border/padding area
|
||||
// we should probably just pretend nothing happened. Nav4
|
||||
|
|
|
@ -71,7 +71,7 @@ static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
|||
|
||||
class Area {
|
||||
public:
|
||||
Area(nsIContent* aArea, PRBool aHasURL);
|
||||
Area(nsIContent* aArea);
|
||||
virtual ~Area();
|
||||
|
||||
virtual void ParseCoords(const nsAString& aSpec);
|
||||
|
@ -84,22 +84,18 @@ public:
|
|||
void HasFocus(PRBool aHasFocus);
|
||||
|
||||
void GetHREF(nsAString& aHref) const;
|
||||
void GetTarget(nsAString& aTarget) const;
|
||||
void GetAltText(nsAString& aAltText) const;
|
||||
PRBool GetHasURL() const { return mHasURL; }
|
||||
void GetArea(nsIContent** aArea) const;
|
||||
|
||||
nsCOMPtr<nsIContent> mArea;
|
||||
nscoord* mCoords;
|
||||
PRInt32 mNumCoords;
|
||||
PRPackedBool mHasURL;
|
||||
PRPackedBool mHasFocus;
|
||||
};
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(Area)
|
||||
|
||||
Area::Area(nsIContent* aArea, PRBool aHasURL)
|
||||
: mArea(aArea), mHasURL(aHasURL)
|
||||
Area::Area(nsIContent* aArea)
|
||||
: mArea(aArea)
|
||||
{
|
||||
MOZ_COUNT_CTOR(Area);
|
||||
mCoords = nsnull;
|
||||
|
@ -122,24 +118,6 @@ Area::GetHREF(nsAString& aHref) const
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Area::GetTarget(nsAString& aTarget) const
|
||||
{
|
||||
aTarget.Truncate();
|
||||
if (mArea) {
|
||||
mArea->GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aTarget);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Area::GetAltText(nsAString& aAltText) const
|
||||
{
|
||||
aAltText.Truncate();
|
||||
if (mArea) {
|
||||
mArea->GetAttr(kNameSpaceID_None, nsHTMLAtoms::alt, aAltText);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Area::GetArea(nsIContent** aArea) const
|
||||
{
|
||||
|
@ -332,8 +310,7 @@ void Area::HasFocus(PRBool aHasFocus)
|
|||
|
||||
class DefaultArea : public Area {
|
||||
public:
|
||||
DefaultArea(nsIContent* aArea, PRBool aHasURL);
|
||||
~DefaultArea();
|
||||
DefaultArea(nsIContent* aArea);
|
||||
|
||||
virtual PRBool IsInside(nscoord x, nscoord y) const;
|
||||
virtual void Draw(nsIPresContext* aCX,
|
||||
|
@ -341,12 +318,8 @@ public:
|
|||
virtual void GetRect(nsIPresContext* aCX, nsRect& aRect);
|
||||
};
|
||||
|
||||
DefaultArea::DefaultArea(nsIContent* aArea, PRBool aHasURL)
|
||||
: Area(aArea, aHasURL)
|
||||
{
|
||||
}
|
||||
|
||||
DefaultArea::~DefaultArea()
|
||||
DefaultArea::DefaultArea(nsIContent* aArea)
|
||||
: Area(aArea)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -367,8 +340,7 @@ void DefaultArea::GetRect(nsIPresContext* aCX, nsRect& aRect)
|
|||
|
||||
class RectArea : public Area {
|
||||
public:
|
||||
RectArea(nsIContent* aArea, PRBool aHasURL);
|
||||
~RectArea();
|
||||
RectArea(nsIContent* aArea);
|
||||
|
||||
virtual void ParseCoords(const nsAString& aSpec);
|
||||
virtual PRBool IsInside(nscoord x, nscoord y) const;
|
||||
|
@ -377,12 +349,8 @@ public:
|
|||
virtual void GetRect(nsIPresContext* aCX, nsRect& aRect);
|
||||
};
|
||||
|
||||
RectArea::RectArea(nsIContent* aArea, PRBool aHasURL)
|
||||
: Area(aArea, aHasURL)
|
||||
{
|
||||
}
|
||||
|
||||
RectArea::~RectArea()
|
||||
RectArea::RectArea(nsIContent* aArea)
|
||||
: Area(aArea)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -529,8 +497,7 @@ void RectArea::GetRect(nsIPresContext* aCX, nsRect& aRect)
|
|||
|
||||
class PolyArea : public Area {
|
||||
public:
|
||||
PolyArea(nsIContent* aArea, PRBool aHasURL);
|
||||
~PolyArea();
|
||||
PolyArea(nsIContent* aArea);
|
||||
|
||||
virtual PRBool IsInside(nscoord x, nscoord y) const;
|
||||
virtual void Draw(nsIPresContext* aCX,
|
||||
|
@ -538,12 +505,8 @@ public:
|
|||
virtual void GetRect(nsIPresContext* aCX, nsRect& aRect);
|
||||
};
|
||||
|
||||
PolyArea::PolyArea(nsIContent* aArea, PRBool aHasURL)
|
||||
: Area(aArea, aHasURL)
|
||||
{
|
||||
}
|
||||
|
||||
PolyArea::~PolyArea()
|
||||
PolyArea::PolyArea(nsIContent* aArea)
|
||||
: Area(aArea)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -657,8 +620,7 @@ void PolyArea::GetRect(nsIPresContext* aCX, nsRect& aRect)
|
|||
|
||||
class CircleArea : public Area {
|
||||
public:
|
||||
CircleArea(nsIContent* aArea, PRBool aHasURL);
|
||||
~CircleArea();
|
||||
CircleArea(nsIContent* aArea);
|
||||
|
||||
virtual PRBool IsInside(nscoord x, nscoord y) const;
|
||||
virtual void Draw(nsIPresContext* aCX,
|
||||
|
@ -666,12 +628,8 @@ public:
|
|||
virtual void GetRect(nsIPresContext* aCX, nsRect& aRect);
|
||||
};
|
||||
|
||||
CircleArea::CircleArea(nsIContent* aArea, PRBool aHasURL)
|
||||
: Area(aArea, aHasURL)
|
||||
{
|
||||
}
|
||||
|
||||
CircleArea::~CircleArea()
|
||||
CircleArea::CircleArea(nsIContent* aArea)
|
||||
: Area(aArea)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -894,7 +852,6 @@ nsImageMap::AddArea(nsIContent* aArea)
|
|||
nsAutoString shape, coords;
|
||||
aArea->GetAttr(kNameSpaceID_None, nsHTMLAtoms::shape, shape);
|
||||
aArea->GetAttr(kNameSpaceID_None, nsHTMLAtoms::coords, coords);
|
||||
PRBool hasURL = !aArea->HasAttr(kNameSpaceID_None, nsHTMLAtoms::nohref);
|
||||
|
||||
//Add focus listener to track area focus changes
|
||||
nsCOMPtr<nsIDOMEventReceiver> rec(do_QueryInterface(aArea));
|
||||
|
@ -910,18 +867,18 @@ nsImageMap::AddArea(nsIContent* aArea)
|
|||
if (shape.IsEmpty() ||
|
||||
shape.EqualsIgnoreCase("rect") ||
|
||||
shape.EqualsIgnoreCase("rectangle")) {
|
||||
area = new RectArea(aArea, hasURL);
|
||||
area = new RectArea(aArea);
|
||||
}
|
||||
else if (shape.EqualsIgnoreCase("poly") ||
|
||||
shape.EqualsIgnoreCase("polygon")) {
|
||||
area = new PolyArea(aArea, hasURL);
|
||||
area = new PolyArea(aArea);
|
||||
}
|
||||
else if (shape.EqualsIgnoreCase("circle") ||
|
||||
shape.EqualsIgnoreCase("circ")) {
|
||||
area = new CircleArea(aArea, hasURL);
|
||||
area = new CircleArea(aArea);
|
||||
}
|
||||
else if (shape.EqualsIgnoreCase("default")) {
|
||||
area = new DefaultArea(aArea, hasURL);
|
||||
area = new DefaultArea(aArea);
|
||||
}
|
||||
else {
|
||||
// Unknown area type; bail
|
||||
|
@ -936,35 +893,13 @@ nsImageMap::AddArea(nsIContent* aArea)
|
|||
|
||||
PRBool
|
||||
nsImageMap::IsInside(nscoord aX, nscoord aY,
|
||||
nsIContent** aContent,
|
||||
nsAString& aAbsURL,
|
||||
nsAString& aTarget,
|
||||
nsAString& aAltText) const
|
||||
nsIContent** aContent) const
|
||||
{
|
||||
NS_ASSERTION(mMap, "Not initialized");
|
||||
PRInt32 i, n = mAreas.Count();
|
||||
for (i = 0; i < n; i++) {
|
||||
Area* area = (Area*) mAreas.ElementAt(i);
|
||||
if (area->IsInside(aX, aY)) {
|
||||
if (area->GetHasURL()) {
|
||||
// Set the image loader's source URL and base URL
|
||||
nsCOMPtr<nsIURI> baseUri = mMap->GetBaseURI();
|
||||
|
||||
if (!baseUri) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsAutoString href;
|
||||
area->GetHREF(href);
|
||||
NS_MakeAbsoluteURI(aAbsURL, href, baseUri);
|
||||
}
|
||||
|
||||
area->GetTarget(aTarget);
|
||||
if (aTarget.IsEmpty())
|
||||
mMap->GetBaseTarget(aTarget);
|
||||
|
||||
area->GetAltText(aAltText);
|
||||
|
||||
area->GetArea(aContent);
|
||||
|
||||
return PR_TRUE;
|
||||
|
|
|
@ -64,21 +64,16 @@ public:
|
|||
|
||||
/**
|
||||
* See if the given aX,aY <b>pixel</b> coordinates are in the image
|
||||
* map. If they are then NS_OK is returned and aAbsURL, aTarget, and
|
||||
* aAltText are filled in with the values from the underlying area
|
||||
* element. If the coordinates are not in the map then NS_NOT_INSIDE
|
||||
* map. If they are then PR_TRUE is returned and aContent points to the
|
||||
* found area. If the coordinates are not in the map then PR_FALSE
|
||||
* is returned.
|
||||
*/
|
||||
PRBool IsInside(nscoord aX, nscoord aY,
|
||||
nsIContent** aContent,
|
||||
nsAString& aAbsURL,
|
||||
nsAString& aTarget,
|
||||
nsAString& aAltText) const;
|
||||
nsIContent** aContent) const;
|
||||
|
||||
/**
|
||||
* See if the given aX,aY <b>pixel</b> coordinates are in the image
|
||||
* map. If they are then NS_OK is returned otherwise NS_NOT_INSIDE
|
||||
* is returned.
|
||||
* map.
|
||||
*/
|
||||
PRBool IsInside(nscoord aX, nscoord aY) const;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче