2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2006-03-29 22:29:03 +04:00
|
|
|
|
|
|
|
/* code for HTML client-side image maps */
|
|
|
|
|
1999-01-09 03:13:53 +03:00
|
|
|
#include "nsImageMap.h"
|
2011-05-30 15:35:45 +04:00
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
|
|
|
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
|
2017-11-08 18:28:44 +03:00
|
|
|
#include "mozilla/dom/HTMLAreaElement.h"
|
2014-10-16 13:51:14 +04:00
|
|
|
#include "mozilla/gfx/PathHelpers.h"
|
2015-10-29 23:16:13 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsString.h"
|
2001-09-29 12:28:41 +04:00
|
|
|
#include "nsReadableUtils.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2011-10-29 14:44:50 +04:00
|
|
|
#include "nsImageFrame.h"
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
#include "nsCoord.h"
|
2002-08-28 00:49:54 +04:00
|
|
|
#include "nsIScriptError.h"
|
|
|
|
#include "nsIStringBundle.h"
|
2004-06-25 16:26:02 +04:00
|
|
|
#include "nsContentUtils.h"
|
2015-10-23 00:02:14 +03:00
|
|
|
#include "ImageLayers.h"
|
2002-08-28 00:49:54 +04:00
|
|
|
|
2012-03-16 00:16:02 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsAccessibilityService.h"
|
|
|
|
#endif
|
|
|
|
|
2013-11-15 17:19:02 +04:00
|
|
|
using namespace mozilla;
|
2014-10-16 13:51:14 +04:00
|
|
|
using namespace mozilla::gfx;
|
2017-11-08 18:28:44 +03:00
|
|
|
using namespace mozilla::dom;
|
2010-08-24 11:05:56 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
class Area {
|
|
|
|
public:
|
2017-11-08 18:28:44 +03:00
|
|
|
explicit Area(HTMLAreaElement* aArea);
|
1998-04-14 00:24:54 +04:00
|
|
|
virtual ~Area();
|
|
|
|
|
2002-12-13 02:22:17 +03:00
|
|
|
virtual void ParseCoords(const nsAString& aSpec);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool IsInside(nscoord x, nscoord y) const = 0;
|
2014-10-16 13:51:14 +04:00
|
|
|
virtual void Draw(nsIFrame* aFrame, DrawTarget& aDrawTarget,
|
|
|
|
const ColorPattern& aColor,
|
|
|
|
const StrokeOptions& aStrokeOptions) = 0;
|
2008-08-07 18:44:04 +04:00
|
|
|
virtual void GetRect(nsIFrame* aFrame, nsRect& aRect) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
void HasFocus(bool aHasFocus);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2017-11-08 18:28:44 +03:00
|
|
|
RefPtr<HTMLAreaElement> mArea;
|
2015-10-29 23:16:13 +03:00
|
|
|
UniquePtr<nscoord[]> mCoords;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mNumCoords;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mHasFocus;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
2017-11-08 18:28:44 +03:00
|
|
|
Area::Area(HTMLAreaElement* aArea)
|
2004-02-20 22:00:43 +03:00
|
|
|
: mArea(aArea)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_CTOR(Area);
|
2017-11-08 18:28:44 +03:00
|
|
|
MOZ_ASSERT(mArea, "How did that happen?");
|
1998-04-14 00:24:54 +04:00
|
|
|
mNumCoords = 0;
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasFocus = false;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Area::~Area()
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_DTOR(Area);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2001-07-25 09:14:18 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
inline bool
|
2001-07-25 09:14:18 +04:00
|
|
|
is_space(char c)
|
|
|
|
{
|
|
|
|
return (c == ' ' ||
|
|
|
|
c == '\f' ||
|
|
|
|
c == '\n' ||
|
|
|
|
c == '\r' ||
|
|
|
|
c == '\t' ||
|
|
|
|
c == '\v');
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-08-08 18:05:35 +04:00
|
|
|
static void logMessage(nsIContent* aContent,
|
|
|
|
const nsAString& aCoordsSpec,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aFlags,
|
2004-11-23 20:45:37 +03:00
|
|
|
const char* aMessageName) {
|
2011-10-18 14:53:36 +04:00
|
|
|
nsIDocument* doc = aContent->OwnerDoc();
|
2010-12-20 19:21:58 +03:00
|
|
|
|
2004-11-23 20:45:37 +03:00
|
|
|
nsContentUtils::ReportToConsole(
|
2014-08-12 03:52:01 +04:00
|
|
|
aFlags, NS_LITERAL_CSTRING("Layout: ImageMap"), doc,
|
2004-11-23 20:45:37 +03:00
|
|
|
nsContentUtils::eLAYOUT_PROPERTIES,
|
|
|
|
aMessageName,
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr, /* params */
|
2004-11-23 20:45:37 +03:00
|
|
|
0, /* params length */
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr,
|
2004-11-23 20:45:37 +03:00
|
|
|
PromiseFlatString(NS_LITERAL_STRING("coords=\"") +
|
|
|
|
aCoordsSpec +
|
2011-12-15 18:47:03 +04:00
|
|
|
NS_LITERAL_STRING("\""))); /* source line */
|
2004-08-08 18:05:35 +04:00
|
|
|
}
|
|
|
|
|
2008-09-06 19:52:33 +04:00
|
|
|
void Area::ParseCoords(const nsAString& aSpec)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2008-09-06 19:52:33 +04:00
|
|
|
char* cp = ToNewCString(aSpec);
|
|
|
|
if (cp) {
|
|
|
|
char *tptr;
|
|
|
|
char *n_str;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t i, cnt;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/*
|
2008-09-06 19:52:33 +04:00
|
|
|
* Nothing in an empty list
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
2008-09-06 19:52:33 +04:00
|
|
|
mNumCoords = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
mCoords = nullptr;
|
2008-09-06 19:52:33 +04:00
|
|
|
if (*cp == '\0')
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2015-03-27 03:01:12 +03:00
|
|
|
free(cp);
|
2008-09-06 19:52:33 +04:00
|
|
|
return;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-09-06 19:52:33 +04:00
|
|
|
* Skip beginning whitespace, all whitespace is empty list.
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
2008-09-06 19:52:33 +04:00
|
|
|
n_str = cp;
|
|
|
|
while (is_space(*n_str))
|
|
|
|
{
|
|
|
|
n_str++;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
if (*n_str == '\0')
|
|
|
|
{
|
2015-03-27 03:01:12 +03:00
|
|
|
free(cp);
|
2008-09-06 19:52:33 +04:00
|
|
|
return;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-09-06 19:52:33 +04:00
|
|
|
* Make a pass where any two numbers separated by just whitespace
|
|
|
|
* are given a comma separator. Count entries while passing.
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
2008-09-06 19:52:33 +04:00
|
|
|
cnt = 0;
|
|
|
|
while (*n_str != '\0')
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool has_comma;
|
2008-09-06 19:52:33 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip to a separator
|
|
|
|
*/
|
|
|
|
tptr = n_str;
|
|
|
|
while (!is_space(*tptr) && *tptr != ',' && *tptr != '\0')
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2008-09-06 19:52:33 +04:00
|
|
|
tptr++;
|
|
|
|
}
|
|
|
|
n_str = tptr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If no more entries, break out here
|
|
|
|
*/
|
|
|
|
if (*n_str == '\0')
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip to the end of the separator, noting if we have a
|
|
|
|
* comma.
|
|
|
|
*/
|
2011-10-17 18:59:28 +04:00
|
|
|
has_comma = false;
|
2008-09-06 19:52:33 +04:00
|
|
|
while (is_space(*tptr) || *tptr == ',')
|
|
|
|
{
|
|
|
|
if (*tptr == ',')
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2010-02-07 18:52:43 +03:00
|
|
|
if (!has_comma)
|
2008-09-06 19:52:33 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
has_comma = true;
|
2008-09-06 19:52:33 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2008-09-06 19:52:33 +04:00
|
|
|
tptr++;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If this was trailing whitespace we skipped, we are done.
|
|
|
|
*/
|
2010-02-07 18:52:43 +03:00
|
|
|
if ((*tptr == '\0') && !has_comma)
|
2008-09-06 19:52:33 +04:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Else if the separator is all whitespace, and this is not the
|
|
|
|
* end of the string, add a comma to the separator.
|
|
|
|
*/
|
2010-02-07 18:52:43 +03:00
|
|
|
else if (!has_comma)
|
2008-09-06 19:52:33 +04:00
|
|
|
{
|
|
|
|
*n_str = ',';
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2008-09-06 19:52:33 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* count the entry skipped.
|
|
|
|
*/
|
|
|
|
cnt++;
|
|
|
|
|
|
|
|
n_str = tptr;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
/*
|
2008-09-06 19:52:33 +04:00
|
|
|
* count the last entry in the list.
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
2008-09-06 19:52:33 +04:00
|
|
|
cnt++;
|
2009-11-18 09:08:20 +03:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/*
|
2008-09-06 19:52:33 +04:00
|
|
|
* Allocate space for the coordinate array.
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
2015-10-29 23:16:13 +03:00
|
|
|
UniquePtr<nscoord[]> value_list = MakeUnique<nscoord[]>(cnt);
|
2008-09-06 19:52:33 +04:00
|
|
|
if (!value_list)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2015-03-27 03:01:12 +03:00
|
|
|
free(cp);
|
2008-09-06 19:52:33 +04:00
|
|
|
return;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-09-06 19:52:33 +04:00
|
|
|
* Second pass to copy integer values into list.
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
2008-09-06 19:52:33 +04:00
|
|
|
tptr = cp;
|
|
|
|
for (i=0; i<cnt; i++)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2008-09-06 19:52:33 +04:00
|
|
|
char *ptr;
|
2001-07-25 09:14:18 +04:00
|
|
|
|
2008-09-06 19:52:33 +04:00
|
|
|
ptr = strchr(tptr, ',');
|
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
*ptr = '\0';
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Strip whitespace in front of number because I don't
|
|
|
|
* trust atoi to do it on all platforms.
|
|
|
|
*/
|
|
|
|
while (is_space(*tptr))
|
|
|
|
{
|
|
|
|
tptr++;
|
|
|
|
}
|
|
|
|
if (*tptr == '\0')
|
|
|
|
{
|
|
|
|
value_list[i] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value_list[i] = (nscoord) ::atoi(tptr);
|
|
|
|
}
|
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
*ptr = ',';
|
|
|
|
tptr = ptr + 1;
|
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2008-09-06 19:52:33 +04:00
|
|
|
mNumCoords = cnt;
|
2015-10-29 23:16:13 +03:00
|
|
|
mCoords = Move(value_list);
|
2009-11-18 09:08:20 +03:00
|
|
|
|
2015-03-27 03:01:12 +03:00
|
|
|
free(cp);
|
1999-10-28 18:33:34 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
void Area::HasFocus(bool aHasFocus)
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
{
|
|
|
|
mHasFocus = aHasFocus;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class DefaultArea : public Area {
|
|
|
|
public:
|
2017-11-08 18:28:44 +03:00
|
|
|
explicit DefaultArea(HTMLAreaElement* aArea);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsInside(nscoord x, nscoord y) const override;
|
2014-10-16 13:51:14 +04:00
|
|
|
virtual void Draw(nsIFrame* aFrame, DrawTarget& aDrawTarget,
|
|
|
|
const ColorPattern& aColor,
|
2015-03-21 19:28:04 +03:00
|
|
|
const StrokeOptions& aStrokeOptions) override;
|
|
|
|
virtual void GetRect(nsIFrame* aFrame, nsRect& aRect) override;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
2017-11-08 18:28:44 +03:00
|
|
|
DefaultArea::DefaultArea(HTMLAreaElement* aArea)
|
2004-02-20 22:00:43 +03:00
|
|
|
: Area(aArea)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool DefaultArea::IsInside(nscoord x, nscoord y) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2014-10-16 13:51:14 +04:00
|
|
|
void DefaultArea::Draw(nsIFrame* aFrame, DrawTarget& aDrawTarget,
|
|
|
|
const ColorPattern& aColor,
|
|
|
|
const StrokeOptions& aStrokeOptions)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2008-08-07 18:44:04 +04:00
|
|
|
if (mHasFocus) {
|
2014-10-16 13:51:14 +04:00
|
|
|
nsRect r(nsPoint(0, 0), aFrame->GetSize());
|
2008-08-07 18:44:04 +04:00
|
|
|
const nscoord kOnePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
2014-10-16 13:51:14 +04:00
|
|
|
r.width -= kOnePixel;
|
|
|
|
r.height -= kOnePixel;
|
|
|
|
Rect rect =
|
|
|
|
ToRect(nsLayoutUtils::RectToGfxRect(r, aFrame->PresContext()->AppUnitsPerDevPixel()));
|
|
|
|
StrokeSnappedEdgesOfRect(rect, aDrawTarget, aColor, aStrokeOptions);
|
2008-08-07 18:44:04 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2008-08-07 18:44:04 +04:00
|
|
|
void DefaultArea::GetRect(nsIFrame* aFrame, nsRect& aRect)
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
{
|
2008-08-07 18:44:04 +04:00
|
|
|
aRect = aFrame->GetRect();
|
|
|
|
aRect.MoveTo(0, 0);
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class RectArea : public Area {
|
|
|
|
public:
|
2017-11-08 18:28:44 +03:00
|
|
|
explicit RectArea(HTMLAreaElement* aArea);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ParseCoords(const nsAString& aSpec) override;
|
|
|
|
virtual bool IsInside(nscoord x, nscoord y) const override;
|
2014-10-16 13:51:14 +04:00
|
|
|
virtual void Draw(nsIFrame* aFrame, DrawTarget& aDrawTarget,
|
|
|
|
const ColorPattern& aColor,
|
2015-03-21 19:28:04 +03:00
|
|
|
const StrokeOptions& aStrokeOptions) override;
|
|
|
|
virtual void GetRect(nsIFrame* aFrame, nsRect& aRect) override;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
2017-11-08 18:28:44 +03:00
|
|
|
RectArea::RectArea(HTMLAreaElement* aArea)
|
2004-02-20 22:00:43 +03:00
|
|
|
: Area(aArea)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-12-13 02:22:17 +03:00
|
|
|
void RectArea::ParseCoords(const nsAString& aSpec)
|
2002-08-28 00:49:54 +04:00
|
|
|
{
|
|
|
|
Area::ParseCoords(aSpec);
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool saneRect = true;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t flag = nsIScriptError::warningFlag;
|
2002-08-28 00:49:54 +04:00
|
|
|
if (mNumCoords >= 4) {
|
|
|
|
if (mCoords[0] > mCoords[2]) {
|
|
|
|
// x-coords in reversed order
|
|
|
|
nscoord x = mCoords[2];
|
|
|
|
mCoords[2] = mCoords[0];
|
|
|
|
mCoords[0] = x;
|
2011-10-17 18:59:28 +04:00
|
|
|
saneRect = false;
|
2002-08-28 00:49:54 +04:00
|
|
|
}
|
2009-11-18 09:08:20 +03:00
|
|
|
|
2002-08-28 00:49:54 +04:00
|
|
|
if (mCoords[1] > mCoords[3]) {
|
|
|
|
// y-coords in reversed order
|
|
|
|
nscoord y = mCoords[3];
|
|
|
|
mCoords[3] = mCoords[1];
|
|
|
|
mCoords[1] = y;
|
2011-10-17 18:59:28 +04:00
|
|
|
saneRect = false;
|
2002-08-28 00:49:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mNumCoords > 4) {
|
|
|
|
// Someone missed the concept of a rect here
|
2011-10-17 18:59:28 +04:00
|
|
|
saneRect = false;
|
2002-08-28 00:49:54 +04:00
|
|
|
}
|
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
saneRect = false;
|
2002-08-28 00:49:54 +04:00
|
|
|
flag = nsIScriptError::errorFlag;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!saneRect) {
|
2004-11-23 20:45:37 +03:00
|
|
|
logMessage(mArea, aSpec, flag, "ImageMapRectBoundsError");
|
2002-08-28 00:49:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool RectArea::IsInside(nscoord x, nscoord y) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2011-09-07 04:20:35 +04:00
|
|
|
if (mNumCoords >= 4) { // Note: > is for nav compatibility
|
1998-04-14 00:24:54 +04:00
|
|
|
nscoord x1 = mCoords[0];
|
|
|
|
nscoord y1 = mCoords[1];
|
|
|
|
nscoord x2 = mCoords[2];
|
|
|
|
nscoord y2 = mCoords[3];
|
2002-08-28 00:49:54 +04:00
|
|
|
NS_ASSERTION(x1 <= x2 && y1 <= y2,
|
|
|
|
"Someone screwed up RectArea::ParseCoords");
|
1998-04-14 00:24:54 +04:00
|
|
|
if ((x >= x1) && (x <= x2) && (y >= y1) && (y <= y2)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2014-10-16 13:51:14 +04:00
|
|
|
void RectArea::Draw(nsIFrame* aFrame, DrawTarget& aDrawTarget,
|
|
|
|
const ColorPattern& aColor,
|
|
|
|
const StrokeOptions& aStrokeOptions)
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
{
|
|
|
|
if (mHasFocus) {
|
|
|
|
if (mNumCoords >= 4) {
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord x1 = nsPresContext::CSSPixelsToAppUnits(mCoords[0]);
|
|
|
|
nscoord y1 = nsPresContext::CSSPixelsToAppUnits(mCoords[1]);
|
|
|
|
nscoord x2 = nsPresContext::CSSPixelsToAppUnits(mCoords[2]);
|
|
|
|
nscoord y2 = nsPresContext::CSSPixelsToAppUnits(mCoords[3]);
|
2002-08-28 00:49:54 +04:00
|
|
|
NS_ASSERTION(x1 <= x2 && y1 <= y2,
|
|
|
|
"Someone screwed up RectArea::ParseCoords");
|
2014-10-16 13:51:14 +04:00
|
|
|
nsRect r(x1, y1, x2 - x1, y2 - y1);
|
|
|
|
Rect rect =
|
|
|
|
ToRect(nsLayoutUtils::RectToGfxRect(r, aFrame->PresContext()->AppUnitsPerDevPixel()));
|
|
|
|
StrokeSnappedEdgesOfRect(rect, aDrawTarget, aColor, aStrokeOptions);
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-07 18:44:04 +04:00
|
|
|
void RectArea::GetRect(nsIFrame* aFrame, nsRect& aRect)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
if (mNumCoords >= 4) {
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord x1 = nsPresContext::CSSPixelsToAppUnits(mCoords[0]);
|
|
|
|
nscoord y1 = nsPresContext::CSSPixelsToAppUnits(mCoords[1]);
|
|
|
|
nscoord x2 = nsPresContext::CSSPixelsToAppUnits(mCoords[2]);
|
|
|
|
nscoord y2 = nsPresContext::CSSPixelsToAppUnits(mCoords[3]);
|
2002-08-28 00:49:54 +04:00
|
|
|
NS_ASSERTION(x1 <= x2 && y1 <= y2,
|
|
|
|
"Someone screwed up RectArea::ParseCoords");
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
|
2002-12-13 02:22:17 +03:00
|
|
|
aRect.SetRect(x1, y1, x2, y2);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class PolyArea : public Area {
|
|
|
|
public:
|
2017-11-08 18:28:44 +03:00
|
|
|
explicit PolyArea(HTMLAreaElement* aArea);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ParseCoords(const nsAString& aSpec) override;
|
|
|
|
virtual bool IsInside(nscoord x, nscoord y) const override;
|
2014-10-16 13:51:14 +04:00
|
|
|
virtual void Draw(nsIFrame* aFrame, DrawTarget& aDrawTarget,
|
|
|
|
const ColorPattern& aColor,
|
2015-03-21 19:28:04 +03:00
|
|
|
const StrokeOptions& aStrokeOptions) override;
|
|
|
|
virtual void GetRect(nsIFrame* aFrame, nsRect& aRect) override;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
2017-11-08 18:28:44 +03:00
|
|
|
PolyArea::PolyArea(HTMLAreaElement* aArea)
|
2004-02-20 22:00:43 +03:00
|
|
|
: Area(aArea)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-08-08 18:05:35 +04:00
|
|
|
void PolyArea::ParseCoords(const nsAString& aSpec)
|
|
|
|
{
|
|
|
|
Area::ParseCoords(aSpec);
|
|
|
|
|
|
|
|
if (mNumCoords >= 2) {
|
|
|
|
if (mNumCoords & 1U) {
|
|
|
|
logMessage(mArea,
|
|
|
|
aSpec,
|
|
|
|
nsIScriptError::warningFlag,
|
2004-11-23 20:45:37 +03:00
|
|
|
"ImageMapPolyOddNumberOfCoords");
|
2004-08-08 18:05:35 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
logMessage(mArea,
|
|
|
|
aSpec,
|
|
|
|
nsIScriptError::errorFlag,
|
2004-11-23 20:45:37 +03:00
|
|
|
"ImageMapPolyWrongNumberOfCoords");
|
2004-08-08 18:05:35 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool PolyArea::IsInside(nscoord x, nscoord y) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
if (mNumCoords >= 6) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t intersects = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
nscoord wherex = x;
|
|
|
|
nscoord wherey = y;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t totalv = mNumCoords / 2;
|
|
|
|
int32_t totalc = totalv * 2;
|
1998-04-14 00:24:54 +04:00
|
|
|
nscoord xval = mCoords[totalc - 2];
|
|
|
|
nscoord yval = mCoords[totalc - 1];
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t end = totalc;
|
|
|
|
int32_t pointer = 1;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2009-11-18 09:08:20 +03:00
|
|
|
if ((yval >= wherey) != (mCoords[pointer] >= wherey)) {
|
|
|
|
if ((xval >= wherex) == (mCoords[0] >= wherex)) {
|
1998-04-14 00:24:54 +04:00
|
|
|
intersects += (xval >= wherex) ? 1 : 0;
|
2009-11-18 09:08:20 +03:00
|
|
|
} else {
|
1998-04-14 00:24:54 +04:00
|
|
|
intersects += ((xval - (yval - wherey) *
|
|
|
|
(mCoords[0] - xval) /
|
|
|
|
(mCoords[pointer] - yval)) >= wherex) ? 1 : 0;
|
2009-11-18 09:08:20 +03:00
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// XXX I wonder what this is doing; this is a translation of ptinpoly.c
|
|
|
|
while (pointer < end) {
|
|
|
|
yval = mCoords[pointer];
|
|
|
|
pointer += 2;
|
|
|
|
if (yval >= wherey) {
|
|
|
|
while((pointer < end) && (mCoords[pointer] >= wherey))
|
|
|
|
pointer+=2;
|
|
|
|
if (pointer >= end)
|
|
|
|
break;
|
|
|
|
if ((mCoords[pointer-3] >= wherex) ==
|
|
|
|
(mCoords[pointer-1] >= wherex)) {
|
|
|
|
intersects += (mCoords[pointer-3] >= wherex) ? 1 : 0;
|
|
|
|
} else {
|
|
|
|
intersects +=
|
|
|
|
((mCoords[pointer-3] - (mCoords[pointer-2] - wherey) *
|
|
|
|
(mCoords[pointer-1] - mCoords[pointer-3]) /
|
|
|
|
(mCoords[pointer] - mCoords[pointer - 2])) >= wherex) ? 1:0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
while((pointer < end) && (mCoords[pointer] < wherey))
|
|
|
|
pointer+=2;
|
|
|
|
if (pointer >= end)
|
|
|
|
break;
|
|
|
|
if ((mCoords[pointer-3] >= wherex) ==
|
|
|
|
(mCoords[pointer-1] >= wherex)) {
|
|
|
|
intersects += (mCoords[pointer-3] >= wherex) ? 1:0;
|
|
|
|
} else {
|
|
|
|
intersects +=
|
|
|
|
((mCoords[pointer-3] - (mCoords[pointer-2] - wherey) *
|
|
|
|
(mCoords[pointer-1] - mCoords[pointer-3]) /
|
|
|
|
(mCoords[pointer] - mCoords[pointer - 2])) >= wherex) ? 1:0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((intersects & 1) != 0) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2014-10-16 13:51:14 +04:00
|
|
|
void PolyArea::Draw(nsIFrame* aFrame, DrawTarget& aDrawTarget,
|
|
|
|
const ColorPattern& aColor,
|
|
|
|
const StrokeOptions& aStrokeOptions)
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
{
|
|
|
|
if (mHasFocus) {
|
|
|
|
if (mNumCoords >= 6) {
|
2014-10-16 13:51:14 +04:00
|
|
|
// Where possible, we want all horizontal and vertical lines to align on
|
|
|
|
// pixel rows or columns, and to start at pixel boundaries so that one
|
|
|
|
// pixel dashing neatly sits on pixels to give us neat lines. To achieve
|
|
|
|
// that we draw each line segment as a separate path, snapping it to
|
|
|
|
// device pixels if applicable.
|
|
|
|
nsPresContext* pc = aFrame->PresContext();
|
|
|
|
Point p1(pc->CSSPixelsToDevPixels(mCoords[0]),
|
|
|
|
pc->CSSPixelsToDevPixels(mCoords[1]));
|
|
|
|
Point p2, p1snapped, p2snapped;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t i = 2; i < mNumCoords; i += 2) {
|
2014-10-16 13:51:14 +04:00
|
|
|
p2.x = pc->CSSPixelsToDevPixels(mCoords[i]);
|
|
|
|
p2.y = pc->CSSPixelsToDevPixels(mCoords[i+1]);
|
|
|
|
p1snapped = p1;
|
|
|
|
p2snapped = p2;
|
2015-07-07 21:56:23 +03:00
|
|
|
SnapLineToDevicePixelsForStroking(p1snapped, p2snapped, aDrawTarget,
|
|
|
|
aStrokeOptions.mLineWidth);
|
2014-10-16 13:51:14 +04:00
|
|
|
aDrawTarget.StrokeLine(p1snapped, p2snapped, aColor, aStrokeOptions);
|
|
|
|
p1 = p2;
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
}
|
2014-10-16 13:51:14 +04:00
|
|
|
p2.x = pc->CSSPixelsToDevPixels(mCoords[0]);
|
|
|
|
p2.y = pc->CSSPixelsToDevPixels(mCoords[1]);
|
|
|
|
p1snapped = p1;
|
|
|
|
p2snapped = p2;
|
2015-07-07 21:56:23 +03:00
|
|
|
SnapLineToDevicePixelsForStroking(p1snapped, p2snapped, aDrawTarget,
|
|
|
|
aStrokeOptions.mLineWidth);
|
2014-10-16 13:51:14 +04:00
|
|
|
aDrawTarget.StrokeLine(p1snapped, p2snapped, aColor, aStrokeOptions);
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-07 18:44:04 +04:00
|
|
|
void PolyArea::GetRect(nsIFrame* aFrame, nsRect& aRect)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
if (mNumCoords >= 6) {
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
nscoord x1, x2, y1, y2, xtmp, ytmp;
|
2007-02-07 10:46:44 +03:00
|
|
|
x1 = x2 = nsPresContext::CSSPixelsToAppUnits(mCoords[0]);
|
|
|
|
y1 = y2 = nsPresContext::CSSPixelsToAppUnits(mCoords[1]);
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t i = 2; i < mNumCoords; i += 2) {
|
2007-02-07 10:46:44 +03:00
|
|
|
xtmp = nsPresContext::CSSPixelsToAppUnits(mCoords[i]);
|
|
|
|
ytmp = nsPresContext::CSSPixelsToAppUnits(mCoords[i+1]);
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
x1 = x1 < xtmp ? x1 : xtmp;
|
|
|
|
y1 = y1 < ytmp ? y1 : ytmp;
|
|
|
|
x2 = x2 > xtmp ? x2 : xtmp;
|
|
|
|
y2 = y2 > ytmp ? y2 : ytmp;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
|
2002-12-13 02:22:17 +03:00
|
|
|
aRect.SetRect(x1, y1, x2, y2);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class CircleArea : public Area {
|
|
|
|
public:
|
2017-11-08 18:28:44 +03:00
|
|
|
explicit CircleArea(HTMLAreaElement* aArea);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ParseCoords(const nsAString& aSpec) override;
|
|
|
|
virtual bool IsInside(nscoord x, nscoord y) const override;
|
2014-10-16 13:51:14 +04:00
|
|
|
virtual void Draw(nsIFrame* aFrame, DrawTarget& aDrawTarget,
|
|
|
|
const ColorPattern& aColor,
|
2015-03-21 19:28:04 +03:00
|
|
|
const StrokeOptions& aStrokeOptions) override;
|
|
|
|
virtual void GetRect(nsIFrame* aFrame, nsRect& aRect) override;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
2017-11-08 18:28:44 +03:00
|
|
|
CircleArea::CircleArea(HTMLAreaElement* aArea)
|
2004-02-20 22:00:43 +03:00
|
|
|
: Area(aArea)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-08-08 18:05:35 +04:00
|
|
|
void CircleArea::ParseCoords(const nsAString& aSpec)
|
|
|
|
{
|
|
|
|
Area::ParseCoords(aSpec);
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool wrongNumberOfCoords = false;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t flag = nsIScriptError::warningFlag;
|
2004-08-08 18:05:35 +04:00
|
|
|
if (mNumCoords >= 3) {
|
|
|
|
if (mCoords[2] < 0) {
|
|
|
|
logMessage(mArea,
|
|
|
|
aSpec,
|
|
|
|
nsIScriptError::errorFlag,
|
2004-11-23 20:45:37 +03:00
|
|
|
"ImageMapCircleNegativeRadius");
|
2004-08-08 18:05:35 +04:00
|
|
|
}
|
2009-11-18 09:08:20 +03:00
|
|
|
|
2004-08-08 18:05:35 +04:00
|
|
|
if (mNumCoords > 3) {
|
2011-10-17 18:59:28 +04:00
|
|
|
wrongNumberOfCoords = true;
|
2004-08-08 18:05:35 +04:00
|
|
|
}
|
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
wrongNumberOfCoords = true;
|
2004-08-08 18:05:35 +04:00
|
|
|
flag = nsIScriptError::errorFlag;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wrongNumberOfCoords) {
|
|
|
|
logMessage(mArea,
|
|
|
|
aSpec,
|
|
|
|
flag,
|
2004-11-23 20:45:37 +03:00
|
|
|
"ImageMapCircleWrongNumberOfCoords");
|
2004-08-08 18:05:35 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool CircleArea::IsInside(nscoord x, nscoord y) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2011-09-07 04:20:35 +04:00
|
|
|
// Note: > is for nav compatibility
|
1998-04-14 00:24:54 +04:00
|
|
|
if (mNumCoords >= 3) {
|
|
|
|
nscoord x1 = mCoords[0];
|
|
|
|
nscoord y1 = mCoords[1];
|
|
|
|
nscoord radius = mCoords[2];
|
|
|
|
if (radius < 0) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
nscoord dx = x1 - x;
|
|
|
|
nscoord dy = y1 - y;
|
|
|
|
nscoord dist = (dx * dx) + (dy * dy);
|
|
|
|
if (dist <= (radius * radius)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2014-10-16 13:51:14 +04:00
|
|
|
void CircleArea::Draw(nsIFrame* aFrame, DrawTarget& aDrawTarget,
|
|
|
|
const ColorPattern& aColor,
|
|
|
|
const StrokeOptions& aStrokeOptions)
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
{
|
|
|
|
if (mHasFocus) {
|
|
|
|
if (mNumCoords >= 3) {
|
2014-10-16 13:51:14 +04:00
|
|
|
Point center(aFrame->PresContext()->CSSPixelsToDevPixels(mCoords[0]),
|
|
|
|
aFrame->PresContext()->CSSPixelsToDevPixels(mCoords[1]));
|
|
|
|
Float diameter =
|
|
|
|
2 * aFrame->PresContext()->CSSPixelsToDevPixels(mCoords[2]);
|
|
|
|
if (diameter <= 0) {
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
return;
|
|
|
|
}
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PathBuilder> builder = aDrawTarget.CreatePathBuilder();
|
2014-10-16 13:51:14 +04:00
|
|
|
AppendEllipseToPath(builder, center, Size(diameter, diameter));
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Path> circle = builder->Finish();
|
2014-10-16 13:51:14 +04:00
|
|
|
aDrawTarget.Stroke(circle, aColor, aStrokeOptions);
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-07 18:44:04 +04:00
|
|
|
void CircleArea::GetRect(nsIFrame* aFrame, nsRect& aRect)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
if (mNumCoords >= 3) {
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord x1 = nsPresContext::CSSPixelsToAppUnits(mCoords[0]);
|
|
|
|
nscoord y1 = nsPresContext::CSSPixelsToAppUnits(mCoords[1]);
|
|
|
|
nscoord radius = nsPresContext::CSSPixelsToAppUnits(mCoords[2]);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (radius < 0) {
|
|
|
|
return;
|
|
|
|
}
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
|
2002-12-13 02:22:17 +03:00
|
|
|
aRect.SetRect(x1 - radius, y1 - radius, x1 + radius, y1 + radius);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2017-11-08 18:02:05 +03:00
|
|
|
nsImageMap::nsImageMap()
|
|
|
|
: mImageFrame(nullptr)
|
|
|
|
, mConsiderWholeSubtree(false)
|
1999-01-09 03:13:53 +03:00
|
|
|
{
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-01-09 03:13:53 +03:00
|
|
|
nsImageMap::~nsImageMap()
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2009-02-03 17:42:18 +03:00
|
|
|
NS_ASSERTION(mAreas.Length() == 0, "Destroy was not called");
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsImageMap,
|
|
|
|
nsIMutationObserver,
|
|
|
|
nsIDOMEventListener)
|
1999-01-09 03:13:53 +03:00
|
|
|
|
2011-04-27 09:51:13 +04:00
|
|
|
nsresult
|
2017-12-15 19:46:04 +03:00
|
|
|
nsImageMap::GetBoundsForAreaContent(nsIContent *aContent, nsRect& aBounds)
|
2002-08-17 05:46:58 +04:00
|
|
|
{
|
2011-11-27 23:27:10 +04:00
|
|
|
NS_ENSURE_TRUE(aContent && mImageFrame, NS_ERROR_INVALID_ARG);
|
2008-08-07 18:44:04 +04:00
|
|
|
|
2002-08-17 05:46:58 +04:00
|
|
|
// Find the Area struct associated with this content node, and return bounds
|
2017-12-15 19:46:04 +03:00
|
|
|
for (auto& area : mAreas) {
|
2002-08-17 05:46:58 +04:00
|
|
|
if (area->mArea == aContent) {
|
2008-08-07 18:44:04 +04:00
|
|
|
aBounds = nsRect();
|
2011-11-27 23:27:10 +04:00
|
|
|
area->GetRect(mImageFrame, aBounds);
|
2002-08-17 05:46:58 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-01-09 03:13:53 +03:00
|
|
|
void
|
2017-12-15 19:46:04 +03:00
|
|
|
nsImageMap::AreaRemoved(HTMLAreaElement* aArea)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2017-12-15 19:46:04 +03:00
|
|
|
if (aArea->IsInUncomposedDoc()) {
|
|
|
|
NS_ASSERTION(aArea->GetPrimaryFrame() == mImageFrame,
|
|
|
|
"Unexpected primary frame");
|
2012-03-15 00:14:02 +04:00
|
|
|
|
2017-12-15 19:46:04 +03:00
|
|
|
aArea->SetPrimaryFrame(nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
aArea->RemoveSystemEventListener(NS_LITERAL_STRING("focus"), this, false);
|
|
|
|
aArea->RemoveSystemEventListener(NS_LITERAL_STRING("blur"), this, false);
|
|
|
|
}
|
2005-03-29 03:03:47 +04:00
|
|
|
|
2017-12-15 19:46:04 +03:00
|
|
|
void
|
|
|
|
nsImageMap::FreeAreas()
|
|
|
|
{
|
|
|
|
for (UniquePtr<Area>& area : mAreas) {
|
|
|
|
AreaRemoved(area->mArea);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2017-07-03 21:35:14 +03:00
|
|
|
|
1999-01-09 03:13:53 +03:00
|
|
|
mAreas.Clear();
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:35:14 +03:00
|
|
|
void
|
2011-10-29 14:44:50 +04:00
|
|
|
nsImageMap::Init(nsImageFrame* aImageFrame, nsIContent* aMap)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2017-07-03 21:35:14 +03:00
|
|
|
MOZ_ASSERT(aMap);
|
|
|
|
MOZ_ASSERT(aImageFrame);
|
2002-12-13 02:22:17 +03:00
|
|
|
|
2017-07-03 21:35:14 +03:00
|
|
|
mImageFrame = aImageFrame;
|
2011-05-30 15:35:45 +04:00
|
|
|
mMap = aMap;
|
2006-07-02 11:23:10 +04:00
|
|
|
mMap->AddMutationObserver(this);
|
1999-01-09 03:13:53 +03:00
|
|
|
|
|
|
|
// "Compile" the areas in the map into faster access versions
|
2017-07-03 21:35:14 +03:00
|
|
|
UpdateAreas();
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:35:14 +03:00
|
|
|
void
|
2017-11-08 18:28:44 +03:00
|
|
|
nsImageMap::SearchForAreas(nsIContent* aParent)
|
1999-03-01 19:57:35 +03:00
|
|
|
{
|
2017-11-08 18:28:44 +03:00
|
|
|
// Look for <area> elements.
|
|
|
|
for (nsIContent* child = aParent->GetFirstChild();
|
|
|
|
child;
|
|
|
|
child = child->GetNextSibling()) {
|
|
|
|
if (auto* area = HTMLAreaElement::FromContent(child)) {
|
|
|
|
AddArea(area);
|
2015-03-03 14:09:00 +03:00
|
|
|
|
2017-11-08 18:02:05 +03:00
|
|
|
// Continue to next child. This stops mConsiderWholeSubtree from
|
2015-03-03 14:09:00 +03:00
|
|
|
// getting set. It also makes us ignore children of <area>s which
|
|
|
|
// is consistent with how we react to dynamic insertion of such
|
|
|
|
// children.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-04-30 17:12:06 +04:00
|
|
|
if (child->IsElement()) {
|
2017-11-08 18:02:05 +03:00
|
|
|
mConsiderWholeSubtree = true;
|
2017-11-08 18:28:44 +03:00
|
|
|
SearchForAreas(child);
|
1999-03-01 19:57:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-03 21:35:14 +03:00
|
|
|
void
|
1999-01-09 03:13:53 +03:00
|
|
|
nsImageMap::UpdateAreas()
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-01-09 03:13:53 +03:00
|
|
|
// Get rid of old area data
|
|
|
|
FreeAreas();
|
|
|
|
|
2017-11-08 18:02:05 +03:00
|
|
|
mConsiderWholeSubtree = false;
|
2017-11-08 18:28:44 +03:00
|
|
|
SearchForAreas(mMap);
|
1999-03-01 19:57:35 +03:00
|
|
|
|
2012-03-16 00:16:02 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2017-07-03 21:35:14 +03:00
|
|
|
if (nsAccessibilityService* accService = GetAccService()) {
|
|
|
|
accService->UpdateImageMap(mImageFrame);
|
2012-03-16 00:16:02 +04:00
|
|
|
}
|
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:35:14 +03:00
|
|
|
void
|
2017-11-08 18:28:44 +03:00
|
|
|
nsImageMap::AddArea(HTMLAreaElement* aArea)
|
1999-03-01 19:57:35 +03:00
|
|
|
{
|
2006-04-24 09:40:11 +04:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2010-07-03 00:56:09 +04:00
|
|
|
{&nsGkAtoms::rect, &nsGkAtoms::rectangle,
|
|
|
|
&nsGkAtoms::circle, &nsGkAtoms::circ,
|
|
|
|
&nsGkAtoms::_default,
|
|
|
|
&nsGkAtoms::poly, &nsGkAtoms::polygon,
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr};
|
1999-01-09 03:13:53 +03:00
|
|
|
|
2017-12-15 19:46:04 +03:00
|
|
|
UniquePtr<Area> area;
|
2006-12-26 20:47:52 +03:00
|
|
|
switch (aArea->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::shape,
|
2006-04-24 09:40:11 +04:00
|
|
|
strings, eIgnoreCase)) {
|
2010-07-03 00:56:09 +04:00
|
|
|
case nsIContent::ATTR_VALUE_NO_MATCH:
|
|
|
|
case nsIContent::ATTR_MISSING:
|
|
|
|
case 0:
|
|
|
|
case 1:
|
2017-12-15 19:46:04 +03:00
|
|
|
area = MakeUnique<RectArea>(aArea);
|
2010-07-03 00:56:09 +04:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 3:
|
2017-12-15 19:46:04 +03:00
|
|
|
area = MakeUnique<CircleArea>(aArea);
|
2010-07-03 00:56:09 +04:00
|
|
|
break;
|
|
|
|
case 4:
|
2017-12-15 19:46:04 +03:00
|
|
|
area = MakeUnique<DefaultArea>(aArea);
|
2010-07-03 00:56:09 +04:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
case 6:
|
2017-12-15 19:46:04 +03:00
|
|
|
area = MakeUnique<PolyArea>(aArea);
|
2010-07-03 00:56:09 +04:00
|
|
|
break;
|
|
|
|
default:
|
2013-07-18 07:28:23 +04:00
|
|
|
area = nullptr;
|
2017-07-03 21:35:14 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("FindAttrValueIn returned an unexpected value.");
|
2010-07-03 00:56:09 +04:00
|
|
|
break;
|
2002-08-28 00:49:54 +04:00
|
|
|
}
|
2005-03-29 03:03:47 +04:00
|
|
|
|
|
|
|
//Add focus listener to track area focus changes
|
2017-07-03 21:35:14 +03:00
|
|
|
aArea->AddSystemEventListener(NS_LITERAL_STRING("focus"), this, false, false);
|
|
|
|
aArea->AddSystemEventListener(NS_LITERAL_STRING("blur"), this, false, false);
|
2005-03-29 03:03:47 +04:00
|
|
|
|
2008-11-26 04:49:14 +03:00
|
|
|
// This is a nasty hack. It needs to go away: see bug 135040. Once this is
|
2013-07-20 23:14:25 +04:00
|
|
|
// removed, the code added to RestyleManager::RestyleElement,
|
2008-11-26 04:49:14 +03:00
|
|
|
// nsCSSFrameConstructor::ContentRemoved (both hacks there), and
|
2013-07-20 23:14:25 +04:00
|
|
|
// RestyleManager::ProcessRestyledFrames to work around this issue can
|
2008-11-26 04:49:14 +03:00
|
|
|
// be removed.
|
2009-12-25 00:20:05 +03:00
|
|
|
aArea->SetPrimaryFrame(mImageFrame);
|
2005-03-29 03:03:47 +04:00
|
|
|
|
2010-07-03 00:56:09 +04:00
|
|
|
nsAutoString coords;
|
|
|
|
aArea->GetAttr(kNameSpaceID_None, nsGkAtoms::coords, coords);
|
1999-01-09 03:13:53 +03:00
|
|
|
area->ParseCoords(coords);
|
2017-12-15 19:46:04 +03:00
|
|
|
mAreas.AppendElement(Move(area));
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2011-10-30 23:51:19 +04:00
|
|
|
nsIContent*
|
|
|
|
nsImageMap::GetArea(nscoord aX, nscoord aY) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2002-12-13 02:22:17 +03:00
|
|
|
NS_ASSERTION(mMap, "Not initialized");
|
2017-12-15 19:46:04 +03:00
|
|
|
for (const auto& area : mAreas) {
|
2000-02-11 04:24:59 +03:00
|
|
|
if (area->IsInside(aX, aY)) {
|
2011-10-30 23:51:19 +04:00
|
|
|
return area->mArea;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
2002-05-23 04:00:34 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2012-03-16 00:16:02 +04:00
|
|
|
nsIContent*
|
2012-08-22 19:56:38 +04:00
|
|
|
nsImageMap::GetAreaAt(uint32_t aIndex) const
|
2012-03-16 00:16:02 +04:00
|
|
|
{
|
|
|
|
return mAreas.ElementAt(aIndex)->mArea;
|
|
|
|
}
|
|
|
|
|
1999-01-09 03:13:53 +03:00
|
|
|
void
|
2014-10-16 13:51:14 +04:00
|
|
|
nsImageMap::Draw(nsIFrame* aFrame, DrawTarget& aDrawTarget,
|
|
|
|
const ColorPattern& aColor,
|
|
|
|
const StrokeOptions& aStrokeOptions)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2017-12-15 19:46:04 +03:00
|
|
|
for (auto& area : mAreas) {
|
2014-10-16 13:51:14 +04:00
|
|
|
area->Draw(aFrame, aDrawTarget, aColor, aStrokeOptions);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-24 03:46:17 +03:00
|
|
|
void
|
2017-12-15 19:46:04 +03:00
|
|
|
nsImageMap::MaybeUpdateAreas(nsIContent* aContent)
|
2004-01-24 03:46:17 +03:00
|
|
|
{
|
2017-11-08 18:02:05 +03:00
|
|
|
if (aContent == mMap || mConsiderWholeSubtree) {
|
2004-01-24 03:46:17 +03:00
|
|
|
UpdateAreas();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-08-24 11:05:56 +04:00
|
|
|
nsImageMap::AttributeChanged(nsIDocument* aDocument,
|
|
|
|
dom::Element* aElement,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aNameSpaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2015-07-25 09:01:19 +03:00
|
|
|
int32_t aModType,
|
|
|
|
const nsAttrValue* aOldValue)
|
1999-01-09 03:13:53 +03:00
|
|
|
{
|
|
|
|
// If the parent of the changing content node is our map then update
|
2005-08-16 08:47:36 +04:00
|
|
|
// the map. But only do this if the node is an HTML <area> or <a>
|
|
|
|
// and the attribute that's changing is "shape" or "coords" -- those
|
|
|
|
// are the only cases we care about.
|
2010-08-24 11:05:56 +04:00
|
|
|
if ((aElement->NodeInfo()->Equals(nsGkAtoms::area) ||
|
|
|
|
aElement->NodeInfo()->Equals(nsGkAtoms::a)) &&
|
2015-03-03 14:08:59 +03:00
|
|
|
aElement->IsHTMLElement() &&
|
2005-08-16 08:47:36 +04:00
|
|
|
aNameSpaceID == kNameSpaceID_None &&
|
2006-12-26 20:47:52 +03:00
|
|
|
(aAttribute == nsGkAtoms::shape ||
|
|
|
|
aAttribute == nsGkAtoms::coords)) {
|
2010-08-24 11:05:56 +04:00
|
|
|
MaybeUpdateAreas(aElement->GetParent());
|
2011-10-29 14:44:50 +04:00
|
|
|
} else if (aElement == mMap &&
|
|
|
|
aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
(aAttribute == nsGkAtoms::name ||
|
|
|
|
aAttribute == nsGkAtoms::id) &&
|
|
|
|
mImageFrame) {
|
|
|
|
// ID or name has changed. Let ImageFrame recreate ImageMap.
|
|
|
|
mImageFrame->DisconnectMap();
|
2005-08-16 08:47:36 +04:00
|
|
|
}
|
1999-01-09 03:13:53 +03:00
|
|
|
}
|
|
|
|
|
2004-01-24 03:46:17 +03:00
|
|
|
void
|
1999-01-09 03:13:53 +03:00
|
|
|
nsImageMap::ContentAppended(nsIDocument *aDocument,
|
|
|
|
nsIContent* aContainer,
|
2017-07-27 16:49:52 +03:00
|
|
|
nsIContent* aFirstNewContent)
|
1999-01-09 03:13:53 +03:00
|
|
|
{
|
2004-01-24 03:46:17 +03:00
|
|
|
MaybeUpdateAreas(aContainer);
|
1999-01-09 03:13:53 +03:00
|
|
|
}
|
|
|
|
|
2004-01-24 03:46:17 +03:00
|
|
|
void
|
1999-01-09 03:13:53 +03:00
|
|
|
nsImageMap::ContentInserted(nsIDocument *aDocument,
|
|
|
|
nsIContent* aContainer,
|
2017-07-27 16:49:52 +03:00
|
|
|
nsIContent* aChild)
|
1999-01-09 03:13:53 +03:00
|
|
|
{
|
2004-01-24 03:46:17 +03:00
|
|
|
MaybeUpdateAreas(aContainer);
|
1999-01-09 03:13:53 +03:00
|
|
|
}
|
|
|
|
|
2017-12-15 19:46:04 +03:00
|
|
|
static UniquePtr<Area>
|
|
|
|
TakeArea(nsImageMap::AreaList& aAreas, HTMLAreaElement* aArea)
|
|
|
|
{
|
|
|
|
UniquePtr<Area> result;
|
|
|
|
size_t index = 0;
|
|
|
|
for (UniquePtr<Area>& area : aAreas) {
|
|
|
|
if (area->mArea == aArea) {
|
|
|
|
result = Move(area);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
aAreas.RemoveElementAt(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2004-01-24 03:46:17 +03:00
|
|
|
void
|
1999-01-09 03:13:53 +03:00
|
|
|
nsImageMap::ContentRemoved(nsIDocument *aDocument,
|
|
|
|
nsIContent* aContainer,
|
|
|
|
nsIContent* aChild,
|
2010-07-22 02:05:17 +04:00
|
|
|
nsIContent* aPreviousSibling)
|
1999-01-09 03:13:53 +03:00
|
|
|
{
|
2017-12-15 19:46:04 +03:00
|
|
|
if (aContainer != mMap && !mConsiderWholeSubtree) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* areaElement = HTMLAreaElement::FromContent(aChild);
|
|
|
|
if (!areaElement) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
UniquePtr<Area> area = TakeArea(mAreas, areaElement);
|
|
|
|
if (!area) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
AreaRemoved(area->mArea);
|
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
if (nsAccessibilityService* accService = GetAccService()) {
|
|
|
|
accService->UpdateImageMap(mImageFrame);
|
|
|
|
}
|
|
|
|
#endif
|
1999-01-09 03:13:53 +03:00
|
|
|
}
|
|
|
|
|
2011-10-29 14:44:50 +04:00
|
|
|
void
|
|
|
|
nsImageMap::ParentChainChanged(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aContent == mMap,
|
|
|
|
"Unexpected ParentChainChanged notification!");
|
|
|
|
if (mImageFrame) {
|
|
|
|
mImageFrame->DisconnectMap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
nsresult
|
2011-06-28 21:59:14 +04:00
|
|
|
nsImageMap::HandleEvent(nsIDOMEvent* aEvent)
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
{
|
2011-06-28 21:59:14 +04:00
|
|
|
nsAutoString eventType;
|
|
|
|
aEvent->GetType(eventType);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool focus = eventType.EqualsLiteral("focus");
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(focus == !eventType.EqualsLiteral("blur"),
|
|
|
|
"Unexpected event type");
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
|
|
|
|
//Set which one of our areas changed focus
|
2013-04-20 02:18:32 +04:00
|
|
|
nsCOMPtr<nsIContent> targetContent = do_QueryInterface(
|
|
|
|
aEvent->InternalDOMEvent()->GetTarget());
|
|
|
|
if (!targetContent) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2017-12-15 19:46:04 +03:00
|
|
|
|
|
|
|
for (auto& area : mAreas) {
|
2013-04-20 02:18:32 +04:00
|
|
|
if (area->mArea == targetContent) {
|
|
|
|
//Set or Remove internal focus
|
|
|
|
area->HasFocus(focus);
|
|
|
|
//Now invalidate the rect
|
|
|
|
if (mImageFrame) {
|
|
|
|
mImageFrame->InvalidateFrame();
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
}
|
2013-04-20 02:18:32 +04:00
|
|
|
break;
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-09 01:31:05 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-08-12 04:38:22 +04:00
|
|
|
void
|
2017-07-03 21:35:14 +03:00
|
|
|
nsImageMap::Destroy()
|
2000-08-12 04:38:22 +04:00
|
|
|
{
|
2005-03-29 03:03:47 +04:00
|
|
|
FreeAreas();
|
2012-07-30 18:20:58 +04:00
|
|
|
mImageFrame = nullptr;
|
2006-07-02 11:23:10 +04:00
|
|
|
mMap->RemoveMutationObserver(this);
|
2000-08-12 04:38:22 +04:00
|
|
|
}
|