bug 591249 - event dragleave not properly dispatched if drag-and-drop aborted with ESC within iframe. r=smaug

This commit is contained in:
Adam Dane [:hobophobe] 2011-09-26 15:55:04 -05:00
parent 6c25ae970c
commit 2c59e05b59
17 changed files with 184 additions and 83 deletions

View File

@ -201,7 +201,7 @@ nsHTMLAreaAccessible::GetBounds(PRInt32 *aX, PRInt32 *aY,
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
nsImageFrame *imageFrame = do_QueryFrame(frame);
nsImageMap* map = imageFrame->GetImageMap(presContext);
nsImageMap* map = imageFrame->GetImageMap();
NS_ENSURE_TRUE(map, NS_ERROR_FAILURE);
nsRect rect;

View File

@ -320,7 +320,7 @@ nsDOMEvent::GetTargetFromFrame()
// get the real content
nsCOMPtr<nsIContent> realEventContent;
targetFrame->GetContentForEvent(mPresContext, mEvent, getter_AddRefs(realEventContent));
targetFrame->GetContentForEvent(mEvent, getter_AddRefs(realEventContent));
return realEventContent.forget();
}

View File

@ -159,6 +159,8 @@ PRInt32 nsEventStateManager::sUserInputEventDepth = 0;
PRBool nsEventStateManager::sNormalLMouseEventInProcess = PR_FALSE;
nsEventStateManager* nsEventStateManager::sActiveESM = nsnull;
nsIDocument* nsEventStateManager::sMouseOverDocument = nsnull;
nsWeakFrame nsEventStateManager::sLastDragOverFrame = nsnull;
nsCOMPtr<nsIContent> nsEventStateManager::sDragOverContent = nsnull;
static PRUint32 gMouseOrKeyboardEventCounter = 0;
static nsITimer* gUserInteractionTimer = nsnull;
@ -773,7 +775,6 @@ nsEventStateManager::nsEventStateManager()
: mLockCursor(0),
mCurrentTarget(nsnull),
mLastMouseOverFrame(nsnull),
mLastDragOverFrame(nsnull),
// init d&d gesture state machine variables
mGestureDownPoint(0,0),
mPresContext(nsnull),
@ -890,6 +891,10 @@ nsEventStateManager::~nsEventStateManager()
}
}
if (sDragOverContent && sDragOverContent->GetOwnerDoc() == mDocument) {
sDragOverContent = nsnull;
}
if (!m_haveShutdown) {
Shutdown();
@ -994,7 +999,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsEventStateManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mLastRightMouseDownContentParent);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mActiveContent);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mHoverContent);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDragOverContent);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mURLTargetContent);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFirstMouseOverEventElement);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFirstMouseOutEventElement);
@ -1015,7 +1019,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsEventStateManager)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mLastRightMouseDownContentParent);
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mActiveContent);
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mHoverContent);
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDragOverContent);
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mURLTargetContent);
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstMouseOverEventElement);
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstMouseOutEventElement);
@ -1969,7 +1972,7 @@ nsEventStateManager::BeginTrackingDragGesture(nsPresContext* aPresContext,
mGestureDownPoint = inDownEvent->refPoint +
inDownEvent->widget->WidgetToScreenOffset();
inDownFrame->GetContentForEvent(aPresContext, inDownEvent,
inDownFrame->GetContentForEvent(inDownEvent,
getter_AddRefs(mGestureDownContent));
mGestureDownFrameOwner = inDownFrame->GetContent();
@ -2082,8 +2085,7 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
PRBool isInEditor = PR_FALSE;
PRBool isSelection = PR_FALSE;
nsCOMPtr<nsIContent> eventContent, targetContent;
mCurrentTarget->GetContentForEvent(aPresContext, aEvent,
getter_AddRefs(eventContent));
mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(eventContent));
if (eventContent)
DetermineDragTarget(aPresContext, eventContent, dataTransfer,
&isSelection, &isInEditor,
@ -3066,7 +3068,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
nsCOMPtr<nsIContent> newFocus;
PRBool suppressBlur = PR_FALSE;
if (mCurrentTarget) {
mCurrentTarget->GetContentForEvent(mPresContext, aEvent, getter_AddRefs(newFocus));
mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(newFocus));
const nsStyleUserInterface* ui = mCurrentTarget->GetStyleUserInterface();
suppressBlur = (ui->mUserFocus == NS_STYLE_USER_FOCUS_IGNORE);
activeContent = mCurrentTarget->GetContent();
@ -3397,7 +3399,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
// now fire the dragdrop event, for compatibility with XUL
if (mCurrentTarget && nsEventStatus_eConsumeNoDefault != *aStatus) {
nsCOMPtr<nsIContent> targetContent;
mCurrentTarget->GetContentForEvent(presContext, aEvent,
mCurrentTarget->GetContentForEvent(aEvent,
getter_AddRefs(targetContent));
nsCOMPtr<nsIWidget> widget = mCurrentTarget->GetNearestWidget();
@ -3469,8 +3471,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
case NS_MOUSE_ENTER:
if (mCurrentTarget) {
nsCOMPtr<nsIContent> targetContent;
mCurrentTarget->GetContentForEvent(presContext, aEvent,
getter_AddRefs(targetContent));
mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(targetContent));
SetContentState(targetContent, NS_EVENT_STATE_HOVER);
}
break;
@ -3479,8 +3480,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
case NS_MOUSE_ACTIVATE:
if (mCurrentTarget) {
nsCOMPtr<nsIContent> targetContent;
mCurrentTarget->GetContentForEvent(presContext, aEvent,
getter_AddRefs(targetContent));
mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(targetContent));
if (!NodeAllowsClickThrough(targetContent)) {
*aStatus = nsEventStatus_eConsumeNoDefault;
}
@ -4067,29 +4067,31 @@ nsEventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
{
// when dragging from one frame to another, events are fired in the
// order: dragexit, dragenter, dragleave
if (mLastDragOverFrame != mCurrentTarget) {
if (sLastDragOverFrame != mCurrentTarget) {
//We'll need the content, too, to check if it changed separately from the frames.
nsCOMPtr<nsIContent> lastContent;
nsCOMPtr<nsIContent> targetContent;
mCurrentTarget->GetContentForEvent(aPresContext, aEvent, getter_AddRefs(targetContent));
mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(targetContent));
if (mLastDragOverFrame) {
if (sLastDragOverFrame) {
//The frame has changed but the content may not have. Check before dispatching to content
mLastDragOverFrame->GetContentForEvent(aPresContext, aEvent, getter_AddRefs(lastContent));
sLastDragOverFrame->GetContentForEvent(aEvent, getter_AddRefs(lastContent));
FireDragEnterOrExit(aPresContext, aEvent, NS_DRAGDROP_EXIT_SYNTH,
targetContent, lastContent, mLastDragOverFrame);
FireDragEnterOrExit(sLastDragOverFrame->PresContext(),
aEvent, NS_DRAGDROP_EXIT_SYNTH,
targetContent, lastContent, sLastDragOverFrame);
}
FireDragEnterOrExit(aPresContext, aEvent, NS_DRAGDROP_ENTER,
lastContent, targetContent, mCurrentTarget);
if (mLastDragOverFrame) {
FireDragEnterOrExit(aPresContext, aEvent, NS_DRAGDROP_LEAVE_SYNTH,
targetContent, lastContent, mLastDragOverFrame);
if (sLastDragOverFrame) {
FireDragEnterOrExit(sLastDragOverFrame->PresContext(),
aEvent, NS_DRAGDROP_LEAVE_SYNTH,
targetContent, lastContent, sLastDragOverFrame);
}
mLastDragOverFrame = mCurrentTarget;
sLastDragOverFrame = mCurrentTarget;
}
}
break;
@ -4097,16 +4099,19 @@ nsEventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
case NS_DRAGDROP_EXIT:
{
//This is actually the window mouse exit event.
if (mLastDragOverFrame) {
if (sLastDragOverFrame) {
nsCOMPtr<nsIContent> lastContent;
mLastDragOverFrame->GetContentForEvent(aPresContext, aEvent, getter_AddRefs(lastContent));
sLastDragOverFrame->GetContentForEvent(aEvent, getter_AddRefs(lastContent));
FireDragEnterOrExit(aPresContext, aEvent, NS_DRAGDROP_EXIT_SYNTH,
nsnull, lastContent, mLastDragOverFrame);
FireDragEnterOrExit(aPresContext, aEvent, NS_DRAGDROP_LEAVE_SYNTH,
nsnull, lastContent, mLastDragOverFrame);
nsRefPtr<nsPresContext> lastDragOverFramePresContext = sLastDragOverFrame->PresContext();
FireDragEnterOrExit(lastDragOverFramePresContext,
aEvent, NS_DRAGDROP_EXIT_SYNTH,
nsnull, lastContent, sLastDragOverFrame);
FireDragEnterOrExit(lastDragOverFramePresContext,
aEvent, NS_DRAGDROP_LEAVE_SYNTH,
nsnull, lastContent, sLastDragOverFrame);
mLastDragOverFrame = nsnull;
sLastDragOverFrame = nsnull;
}
}
break;
@ -4199,7 +4204,7 @@ nsEventStateManager::SetClickCount(nsPresContext* aPresContext,
{
nsCOMPtr<nsIContent> mouseContent;
nsIContent* mouseContentParent = nsnull;
mCurrentTarget->GetContentForEvent(aPresContext, aEvent, getter_AddRefs(mouseContent));
mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(mouseContent));
if (mouseContent) {
if (mouseContent->IsNodeOfType(nsINode::eTEXT)) {
mouseContent = mouseContent->GetParent();
@ -4382,7 +4387,7 @@ nsEventStateManager::GetEventTargetContent(nsEvent* aEvent)
// Some events here may set mCurrentTarget but not set the corresponding
// event target in the PresShell.
if (!content && mCurrentTarget) {
mCurrentTarget->GetContentForEvent(mPresContext, aEvent, &content);
mCurrentTarget->GetContentForEvent(aEvent, &content);
}
return content;
@ -4560,10 +4565,10 @@ nsEventStateManager::SetContentState(nsIContent *aContent, nsEventStates aState)
} else {
updateAncestors = PR_FALSE;
if (aState == NS_EVENT_STATE_DRAGOVER) {
if (aContent != mDragOverContent) {
if (aContent != sDragOverContent) {
notifyContent1 = aContent;
notifyContent2 = mDragOverContent;
mDragOverContent = aContent;
notifyContent2 = sDragOverContent;
sDragOverContent = aContent;
}
} else if (aState == NS_EVENT_STATE_URLTARGET) {
if (aContent != mURLTargetContent) {
@ -4641,9 +4646,10 @@ nsEventStateManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent
SetContentState(aContent->GetParent(), NS_EVENT_STATE_ACTIVE);
}
if (mDragOverContent &&
nsContentUtils::ContentIsDescendantOf(mDragOverContent, aContent)) {
mDragOverContent = nsnull;
if (sDragOverContent &&
sDragOverContent->GetOwnerDoc() == aContent->GetOwnerDoc() &&
nsContentUtils::ContentIsDescendantOf(sDragOverContent, aContent)) {
sDragOverContent = nsnull;
}
if (mLastMouseOverElement &&
@ -4933,6 +4939,9 @@ nsEventStateManager::ClearGlobalActiveContent(nsEventStateManager* aClearer)
{
if (aClearer) {
aClearer->SetContentState(nsnull, NS_EVENT_STATE_ACTIVE);
if (sDragOverContent) {
aClearer->SetContentState(nsnull, NS_EVENT_STATE_DRAGOVER);
}
}
if (sActiveESM && aClearer != sActiveESM) {
sActiveESM->SetContentState(nsnull, NS_EVENT_STATE_ACTIVE);

View File

@ -486,7 +486,7 @@ private:
nsCOMPtr<nsIContent> mCurrentTargetContent;
nsWeakFrame mLastMouseOverFrame;
nsCOMPtr<nsIContent> mLastMouseOverElement;
nsWeakFrame mLastDragOverFrame;
static nsWeakFrame sLastDragOverFrame;
// member variables for the d&d gesture state machine
nsIntPoint mGestureDownPoint; // screen coordinates
@ -511,7 +511,7 @@ private:
nsCOMPtr<nsIContent> mActiveContent;
nsCOMPtr<nsIContent> mHoverContent;
nsCOMPtr<nsIContent> mDragOverContent;
static nsCOMPtr<nsIContent> sDragOverContent;
nsCOMPtr<nsIContent> mURLTargetContent;
// The last element on which we fired a mouseover event, or null if

View File

@ -136,6 +136,8 @@ _CHROME_FILES = \
test_bug415498.xul \
bug415498-doc1.html \
bug415498-doc2.html \
test_bug591249.xul \
bug591249_iframe.xul \
bug602962.xul \
test_bug602962.xul \
test_bug617528.xul \

View File

@ -0,0 +1,33 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=591249
-->
<window title="Mozilla Bug 591249"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<html:style type="text/css">
#drop-target {
width: 50px;
height: 50px;
border: 4px dotted black;
}
#drop-target {
background-color: red;
}
#drop-target:-moz-drag-over {
background-color: yellow;
}
</html:style>
<html:body>
<html:h1 id="iframetext">Iframe for Bug 591249</html:h1>
<html:div id="drop-target"
ondrop="return false;"
ondragenter="return false;"
ondragover="return false;">
</html:div>
</html:body>
</window>

View File

@ -0,0 +1,74 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=591249
-->
<window title="Mozilla Bug 591249" onload="RunTest()"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<body xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=591249">Mozilla Bug 591249</a>
<img id="image"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAG0lEQVR42mP8z0A%2BYKJA76jmUc2jmkc1U0EzACKcASfOgGoMAAAAAElFTkSuQmCC"
ondragstart="event.preventDefault();"/>
<iframe id="iframe" src="chrome://mochitests/content/chrome/content/events/test/bug591249_iframe.xul" style="height: 300px; width: 100%;"></iframe>
</body>
<script class="testbody" type="application/javascript;version=1.8"><![CDATA[
/** Test for Bug 591249 **/
SimpleTest.waitForExplicitFinish();
function completeTest(aBox) {
ok(window.getComputedStyle(aBox).backgroundColor == "rgb(255, 0, 0)", "The -moz-drag-over style should be removed.");
SimpleTest.finish();
}
function fireEvent(target, event) {
var utils =
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils);
utils.dispatchDOMEventViaPresShell(target, event, true);
}
function RunTest() {
var image = document.getElementById("image");
var iframe = document.getElementById("iframe");
var iBox = iframe.contentDocument.getElementById("drop-target");
var insideBoxX = iBox.offsetWidth + 10;
var insideBoxY = iBox.offsetHeight + 10;
var dataTransfer;
var trapDrag = function(event) {
dataTransfer = event.dataTransfer;
dataTransfer.setData("text/plain", "Hello");
dataTransfer.dropEffect = "move";
event.preventDefault();
event.stopPropagation();
}
// need to use real mouse action to get the dataTransfer
window.addEventListener("dragstart", trapDrag, true);
synthesizeMouse(image, 2, 2, { type: "mousedown" });
synthesizeMouse(image, 11, 11, { type: "mousemove" });
synthesizeMouse(image, 20, 20, { type: "mousemove" });
window.removeEventListener("dragstart", trapDrag, true);
synthesizeMouse(image, 20, 20, { type: "mouseup" });
var event = document.createEvent("DragEvents");
event.initDragEvent("dragover", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, iBox, dataTransfer);
fireEvent(iBox, event);
synthesizeMouse(image, 3, 3, { type: "mousedown" });
synthesizeMouse(image, 23, 23, { type: "mousemove" });
synthesizeMouse(iBox, insideBoxX, insideBoxY, { type: "mousemove" });
ok(window.getComputedStyle(iBox).backgroundColor == "rgb(255, 255, 0)", "The -moz-drag-over style should be applied.");
synthesizeMouse(iBox, insideBoxX, insideBoxY, { type: "mouseup" });
window.setTimeout(function () { completeTest(iBox); }, 40);
}
]]></script>
</window>

View File

@ -5453,7 +5453,7 @@ PresShell::GetEventTargetContent(nsEvent* aEvent)
} else {
nsIFrame* currentEventFrame = GetCurrentEventFrame();
if (currentEventFrame) {
currentEventFrame->GetContentForEvent(mPresContext, aEvent, &content);
currentEventFrame->GetContentForEvent(aEvent, &content);
} else {
content = nsnull;
}
@ -6086,7 +6086,7 @@ PresShell::HandlePositionedEvent(nsIView* aView,
if (mCurrentEventFrame) {
nsCOMPtr<nsIContent> targetElement;
mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent,
mCurrentEventFrame->GetContentForEvent(aEvent,
getter_AddRefs(targetElement));
// If there is no content for this frame, target it anyway. Some
@ -6334,7 +6334,7 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView,
}
else {
nsCOMPtr<nsIContent> targetContent;
rv = mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent,
rv = mCurrentEventFrame->GetContentForEvent(aEvent,
getter_AddRefs(targetContent));
if (NS_SUCCEEDED(rv) && targetContent) {
nsEventDispatcher::Dispatch(targetContent, mPresContext, aEvent,

View File

@ -620,19 +620,16 @@ nsCanvasFrame::GetType() const
}
NS_IMETHODIMP
nsCanvasFrame::GetContentForEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
nsIContent** aContent)
nsCanvasFrame::GetContentForEvent(nsEvent* aEvent,
nsIContent** aContent)
{
NS_ENSURE_ARG_POINTER(aContent);
nsresult rv = nsFrame::GetContentForEvent(aPresContext,
aEvent,
nsresult rv = nsFrame::GetContentForEvent(aEvent,
aContent);
if (NS_FAILED(rv) || !*aContent) {
nsIFrame* kid = mFrames.FirstChild();
if (kid) {
rv = kid->GetContentForEvent(aPresContext,
aEvent,
rv = kid->GetContentForEvent(aEvent,
aContent);
}
}

View File

@ -140,8 +140,7 @@ public:
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const;
#endif
NS_IMETHOD GetContentForEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
NS_IMETHOD GetContentForEvent(nsEvent* aEvent,
nsIContent** aContent);
nsRect CanvasArea() const;

View File

@ -1961,8 +1961,7 @@ nsIFrame::WrapReplacedContentForBorderRadius(nsDisplayListBuilder* aBuilder,
}
NS_IMETHODIMP
nsFrame::GetContentForEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
nsFrame::GetContentForEvent(nsEvent* aEvent,
nsIContent** aContent)
{
nsIFrame* f = nsLayoutUtils::GetNonGeneratedAncestor(this);

View File

@ -198,8 +198,7 @@ public:
NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);
NS_IMETHOD GetContentForEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
NS_IMETHOD GetContentForEvent(nsEvent* aEvent,
nsIContent** aContent);
NS_IMETHOD GetCursor(const nsPoint& aPoint,
nsIFrame::Cursor& aCursor);

View File

@ -1240,8 +1240,7 @@ public:
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus) = 0;
NS_IMETHOD GetContentForEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
NS_IMETHOD GetContentForEvent(nsEvent* aEvent,
nsIContent** aContent) = 0;
// This structure keeps track of the content node and offsets associated with

View File

@ -1175,12 +1175,11 @@ static void PaintDebugImageMap(nsIFrame* aFrame, nsRenderingContext* aCtx,
const nsRect& aDirtyRect, nsPoint aPt) {
nsImageFrame* f = static_cast<nsImageFrame*>(aFrame);
nsRect inner = f->GetInnerArea() + aPt;
nsPresContext* pc = f->PresContext();
aCtx->SetColor(NS_RGB(0, 0, 0));
aCtx->PushState();
aCtx->Translate(inner.TopLeft());
f->GetImageMap(pc)->Draw(aFrame, *aCtx);
f->GetImageMap()->Draw(aFrame, *aCtx);
aCtx->PopState();
}
#endif
@ -1284,8 +1283,7 @@ nsImageFrame::PaintImage(nsRenderingContext& aRenderingContext, nsPoint aPt,
nsLayoutUtils::GetGraphicsFilterForFrame(this), dest, aDirtyRect,
aFlags);
nsPresContext* presContext = PresContext();
nsImageMap* map = GetImageMap(presContext);
nsImageMap* map = GetImageMap();
if (nsnull != map) {
aRenderingContext.PushState();
aRenderingContext.SetColor(NS_RGB(0, 0, 0));
@ -1365,7 +1363,7 @@ nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
#ifdef DEBUG
if (GetShowFrameBorders() && GetImageMap(PresContext())) {
if (GetShowFrameBorders() && GetImageMap()) {
rv = aLists.Outlines()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(aBuilder, this, PaintDebugImageMap, "DebugImageMap",
nsDisplayItem::TYPE_DEBUG_IMAGE_MAP));
@ -1445,7 +1443,7 @@ nsImageFrame::ShouldDisplaySelection()
}
nsImageMap*
nsImageFrame::GetImageMap(nsPresContext* aPresContext)
nsImageFrame::GetImageMap()
{
if (!mImageMap) {
nsIDocument* doc = mContent->GetDocument();
@ -1460,7 +1458,7 @@ nsImageFrame::GetImageMap(nsPresContext* aPresContext)
if (map) {
mImageMap = new nsImageMap();
NS_ADDREF(mImageMap);
mImageMap->Init(aPresContext->PresShell(), this, map);
mImageMap->Init(this, map);
}
}
@ -1525,15 +1523,14 @@ nsImageFrame::GetAnchorHREFTargetAndNode(nsIURI** aHref, nsString& aTarget,
}
NS_IMETHODIMP
nsImageFrame::GetContentForEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
nsImageFrame::GetContentForEvent(nsEvent* aEvent,
nsIContent** aContent)
{
NS_ENSURE_ARG_POINTER(aContent);
nsIFrame* f = nsLayoutUtils::GetNonGeneratedAncestor(this);
if (f != this) {
return f->GetContentForEvent(aPresContext, aEvent, aContent);
return f->GetContentForEvent(aEvent, aContent);
}
// XXX We need to make this special check for area element's capturing the
@ -1546,8 +1543,7 @@ nsImageFrame::GetContentForEvent(nsPresContext* aPresContext,
return NS_OK;
}
nsImageMap* map;
map = GetImageMap(aPresContext);
nsImageMap* map = GetImageMap();
if (nsnull != map) {
nsIntPoint p;
@ -1575,13 +1571,12 @@ nsImageFrame::HandleEvent(nsPresContext* aPresContext,
nsEventStatus* aEventStatus)
{
NS_ENSURE_ARG_POINTER(aEventStatus);
nsImageMap* map;
if ((aEvent->eventStructType == NS_MOUSE_EVENT &&
aEvent->message == NS_MOUSE_BUTTON_UP &&
static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton) ||
aEvent->message == NS_MOUSE_MOVE) {
map = GetImageMap(aPresContext);
nsImageMap* map = GetImageMap();
PRBool isServerMap = IsServerImageMap();
if ((nsnull != map) || isServerMap) {
nsIntPoint p;
@ -1637,8 +1632,7 @@ NS_IMETHODIMP
nsImageFrame::GetCursor(const nsPoint& aPoint,
nsIFrame::Cursor& aCursor)
{
nsPresContext* context = PresContext();
nsImageMap* map = GetImageMap(context);
nsImageMap* map = GetImageMap();
if (nsnull != map) {
nsIntPoint p;
TranslateEventCoords(aPoint, p);

View File

@ -128,8 +128,7 @@ public:
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD GetContentForEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
NS_IMETHOD GetContentForEvent(nsEvent* aEvent,
nsIContent** aContent);
NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent,
@ -183,7 +182,7 @@ public:
nsRect GetInnerArea() const;
nsImageMap* GetImageMap(nsPresContext* aPresContext);
nsImageMap* GetImageMap();
virtual void AddInlineMinWidth(nsRenderingContext *aRenderingContext,
InlineMinWidthData *aData);

View File

@ -692,7 +692,6 @@ void CircleArea::GetRect(nsIFrame* aFrame, nsRect& aRect)
nsImageMap::nsImageMap() :
mPresShell(nsnull),
mImageFrame(nsnull),
mContainsBlockContents(PR_FALSE)
{
@ -749,13 +748,12 @@ nsImageMap::FreeAreas()
}
nsresult
nsImageMap::Init(nsIPresShell* aPresShell, nsIFrame* aImageFrame, nsIContent* aMap)
nsImageMap::Init(nsIFrame* aImageFrame, nsIContent* aMap)
{
NS_PRECONDITION(aMap, "null ptr");
if (!aMap) {
return NS_ERROR_NULL_POINTER;
}
mPresShell = aPresShell;
mImageFrame = aImageFrame;
mMap = aMap;

View File

@ -57,7 +57,7 @@ class nsImageMap : public nsStubMutationObserver,
public:
nsImageMap();
nsresult Init(nsIPresShell* aPresShell, nsIFrame* aImageFrame, nsIContent* aMap);
nsresult Init(nsIFrame* aImageFrame, nsIContent* aMap);
/**
* See if the given aX,aY <b>pixel</b> coordinates are in the image
@ -104,7 +104,6 @@ protected:
void MaybeUpdateAreas(nsIContent *aContent);
nsIPresShell* mPresShell; // WEAK - owns the frame that owns us
nsIFrame* mImageFrame; // the frame that owns us
nsCOMPtr<nsIContent> mMap;
nsAutoTArray<Area*, 8> mAreas; // almost always has some entries