зеркало из https://github.com/mozilla/pjs.git
Bug 698232 - s/IsInside/GetArea to simplify the code, r=mats
This commit is contained in:
Родитель
5795eeb8b4
Коммит
ea9f2a5db4
|
@ -1563,11 +1563,9 @@ nsImageFrame::GetContentForEvent(nsEvent* aEvent,
|
||||||
TranslateEventCoords(
|
TranslateEventCoords(
|
||||||
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this), p);
|
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this), p);
|
||||||
bool inside = false;
|
bool inside = false;
|
||||||
nsCOMPtr<nsIContent> area;
|
nsCOMPtr<nsIContent> area = map->GetArea(p.x, p.y);
|
||||||
inside = map->IsInside(p.x, p.y, getter_AddRefs(area));
|
if (area) {
|
||||||
if (inside && area) {
|
area.swap(*aContent);
|
||||||
*aContent = area;
|
|
||||||
NS_ADDREF(*aContent);
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1601,8 +1599,7 @@ nsImageFrame::HandleEvent(nsPresContext* aPresContext,
|
||||||
// (in case we deal with a case of both client-side and
|
// (in case we deal with a case of both client-side and
|
||||||
// sever-side on the same image - it happens!)
|
// sever-side on the same image - it happens!)
|
||||||
if (nsnull != map) {
|
if (nsnull != map) {
|
||||||
nsCOMPtr<nsIContent> area;
|
inside = !!map->GetArea(p.x, p.y);
|
||||||
inside = map->IsInside(p.x, p.y, getter_AddRefs(area));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inside && isServerMap) {
|
if (!inside && isServerMap) {
|
||||||
|
@ -1649,8 +1646,8 @@ nsImageFrame::GetCursor(const nsPoint& aPoint,
|
||||||
if (nsnull != map) {
|
if (nsnull != map) {
|
||||||
nsIntPoint p;
|
nsIntPoint p;
|
||||||
TranslateEventCoords(aPoint, p);
|
TranslateEventCoords(aPoint, p);
|
||||||
nsCOMPtr<nsIContent> area;
|
nsCOMPtr<nsIContent> area = map->GetArea(p.x, p.y);
|
||||||
if (map->IsInside(p.x, p.y, getter_AddRefs(area))) {
|
if (area) {
|
||||||
// Use the cursor from the style of the *area* element.
|
// Use the cursor from the style of the *area* element.
|
||||||
// XXX Using the image as the parent style context isn't
|
// XXX Using the image as the parent style context isn't
|
||||||
// technically correct, but it's probably the right thing to do
|
// technically correct, but it's probably the right thing to do
|
||||||
|
|
|
@ -878,22 +878,19 @@ nsImageMap::AddArea(nsIContent* aArea)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
nsIContent*
|
||||||
nsImageMap::IsInside(nscoord aX, nscoord aY,
|
nsImageMap::GetArea(nscoord aX, nscoord aY) const
|
||||||
nsIContent** aContent) const
|
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mMap, "Not initialized");
|
NS_ASSERTION(mMap, "Not initialized");
|
||||||
PRUint32 i, n = mAreas.Length();
|
PRUint32 i, n = mAreas.Length();
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
Area* area = mAreas.ElementAt(i);
|
Area* area = mAreas.ElementAt(i);
|
||||||
if (area->IsInside(aX, aY)) {
|
if (area->IsInside(aX, aY)) {
|
||||||
NS_ADDREF(*aContent = area->mArea);
|
return area->mArea;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -61,13 +61,10 @@ public:
|
||||||
nsresult Init(nsImageFrame* aImageFrame, nsIContent* aMap);
|
nsresult Init(nsImageFrame* aImageFrame, nsIContent* aMap);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See if the given aX,aY <b>pixel</b> coordinates are in the image
|
* Return the first area element (in content order) for the given aX,aY pixel
|
||||||
* map. If they are then true is returned and aContent points to the
|
* coordinate or nsnull if the coordinate is outside all areas.
|
||||||
* found area. If the coordinates are not in the map then false
|
|
||||||
* is returned.
|
|
||||||
*/
|
*/
|
||||||
bool IsInside(nscoord aX, nscoord aY,
|
nsIContent* GetArea(nscoord aX, nscoord aY) const;
|
||||||
nsIContent** aContent) const;
|
|
||||||
|
|
||||||
void Draw(nsIFrame* aFrame, nsRenderingContext& aRC);
|
void Draw(nsIFrame* aFrame, nsRenderingContext& aRC);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче