зеркало из https://github.com/mozilla/gecko-dev.git
bug 370371 - remove nsIImageControlFrame, have the frame set the last clicked point as a property on its mContent instead.
r+sr=roc
This commit is contained in:
Родитель
0e04a8b0f2
Коммит
e70812ddff
|
@ -390,6 +390,7 @@ GK_ATOM(ignorecase, "ignorecase")
|
|||
GK_ATOM(ignorekeys, "ignorekeys")
|
||||
GK_ATOM(ilayer, "ilayer")
|
||||
GK_ATOM(image, "image")
|
||||
GK_ATOM(imageClickedPoint, "image-clicked-point")
|
||||
GK_ATOM(img, "img")
|
||||
GK_ATOM(implementation, "implementation")
|
||||
GK_ATOM(implements, "implements")
|
||||
|
|
|
@ -81,7 +81,6 @@
|
|||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsICheckboxControlFrame.h"
|
||||
#include "nsIImageControlFrame.h"
|
||||
#include "nsLinebreakConverter.h" //to strip out carriage returns
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
@ -2284,33 +2283,18 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission,
|
|||
// Submit .x, .y for input type=image
|
||||
//
|
||||
if (mType == NS_FORM_INPUT_IMAGE) {
|
||||
// Go to the frame to find out where it was clicked. This is the only
|
||||
// case where I can actually see using the frame, because you're talking
|
||||
// about a value--mouse click--that is rightfully the domain of the frame.
|
||||
//
|
||||
// If the frame isn't there or isn't an ImageControlFrame, then we're not
|
||||
// submitting these values no matter *how* nicely you ask.
|
||||
PRInt32 clickedX;
|
||||
PRInt32 clickedY;
|
||||
nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE);
|
||||
|
||||
nsIImageControlFrame* imageControlFrame = nsnull;
|
||||
if (formControlFrame) {
|
||||
CallQueryInterface(formControlFrame, &imageControlFrame);
|
||||
}
|
||||
|
||||
// Get a property set by the frame to find out where it was clicked.
|
||||
nsAutoString xVal;
|
||||
nsAutoString yVal;
|
||||
|
||||
if (imageControlFrame) {
|
||||
imageControlFrame->GetClickedX(&clickedX);
|
||||
imageControlFrame->GetClickedY(&clickedY);
|
||||
|
||||
nsIntPoint* lastClickedPoint =
|
||||
NS_STATIC_CAST(nsIntPoint*, GetProperty(nsGkAtoms::imageClickedPoint));
|
||||
if (lastClickedPoint) {
|
||||
// Convert the values to strings for submission
|
||||
xVal.AppendInt(clickedX);
|
||||
yVal.AppendInt(clickedY);
|
||||
xVal.AppendInt(lastClickedPoint->x);
|
||||
yVal.AppendInt(lastClickedPoint->y);
|
||||
}
|
||||
|
||||
|
||||
if (!name.IsEmpty()) {
|
||||
aFormSubmission->AddNameValuePair(this,
|
||||
name + NS_LITERAL_STRING(".x"), xVal);
|
||||
|
@ -2318,7 +2302,7 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission,
|
|||
name + NS_LITERAL_STRING(".y"), yVal);
|
||||
} else {
|
||||
// If the Image Element has no name, simply return x and y
|
||||
// to Nav and IE compatability.
|
||||
// to Nav and IE compatibility.
|
||||
aFormSubmission->AddNameValuePair(this, NS_LITERAL_STRING("x"), xVal);
|
||||
aFormSubmission->AddNameValuePair(this, NS_LITERAL_STRING("y"), yVal);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,6 @@ REQUIRES = xpcom \
|
|||
|
||||
EXPORTS = \
|
||||
nsIListControlFrame.h \
|
||||
nsIImageControlFrame.h \
|
||||
nsIComboboxControlFrame.h \
|
||||
nsIFormControlFrame.h \
|
||||
nsIRadioControlFrame.h \
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* John B. Keiser.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIListControlFrame_h___
|
||||
#define nsIListControlFrame_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsAString;
|
||||
|
||||
// IID for the nsIImageControlFrame class
|
||||
#define NS_ILISTCONTROLFRAME_IID \
|
||||
{ 0x85603274, 0x1dd2, 0x11b2, \
|
||||
{ 0xba, 0x7a, 0xec, 0x7d, 0x65, 0x8d, 0x98, 0xe2 } }
|
||||
|
||||
/**
|
||||
* nsIImageControlFrame is the external interface for ImageControlFrame
|
||||
*/
|
||||
class nsIImageControlFrame : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILISTCONTROLFRAME_IID)
|
||||
|
||||
/**
|
||||
* Get the place the user last clicked on the image (esp. for submits)
|
||||
*/
|
||||
NS_IMETHOD GetClickedX(PRInt32* aX) = 0;
|
||||
|
||||
/**
|
||||
* Get the place the user last clicked on the image (esp. for submits)
|
||||
*/
|
||||
NS_IMETHOD GetClickedY(PRInt32* aY) = 0;
|
||||
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIImageControlFrame, NS_ILISTCONTROLFRAME_IID)
|
||||
|
||||
#endif
|
||||
|
|
@ -35,7 +35,6 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIImageControlFrame.h"
|
||||
#include "nsImageFrame.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
#include "nsIFormControl.h"
|
||||
|
@ -61,16 +60,27 @@
|
|||
#include "nsIAccessibilityService.h"
|
||||
#endif
|
||||
|
||||
void
|
||||
IntPointDtorFunc(void *aObject, nsIAtom *aPropertyName,
|
||||
void *aPropertyValue, void *aData)
|
||||
{
|
||||
nsIntPoint *propertyValue = NS_STATIC_CAST(nsIntPoint*, aPropertyValue);
|
||||
delete propertyValue;
|
||||
}
|
||||
|
||||
|
||||
#define nsImageControlFrameSuper nsImageFrame
|
||||
class nsImageControlFrame : public nsImageControlFrameSuper,
|
||||
public nsIFormControlFrame,
|
||||
public nsIImageControlFrame
|
||||
public nsIFormControlFrame
|
||||
{
|
||||
public:
|
||||
nsImageControlFrame(nsStyleContext* aContext);
|
||||
~nsImageControlFrame();
|
||||
|
||||
virtual void Destroy();
|
||||
NS_IMETHOD Init(nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIFrame* aPrevInFlow);
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
||||
|
@ -102,22 +112,15 @@ public:
|
|||
virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue);
|
||||
virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const;
|
||||
|
||||
// nsIImageControlFrame
|
||||
NS_IMETHOD GetClickedX(PRInt32* aX);
|
||||
NS_IMETHOD GetClickedY(PRInt32* aY);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
nsPoint mLastClickPoint;
|
||||
};
|
||||
|
||||
|
||||
nsImageControlFrame::nsImageControlFrame(nsStyleContext* aContext):
|
||||
nsImageControlFrameSuper(aContext)
|
||||
{
|
||||
mLastClickPoint = nsPoint(0,0);
|
||||
}
|
||||
|
||||
nsImageControlFrame::~nsImageControlFrame()
|
||||
|
@ -137,6 +140,21 @@ NS_NewImageControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|||
return new (aPresShell) nsImageControlFrame(aContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::Init(nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIFrame* aPrevInFlow)
|
||||
{
|
||||
nsresult rv = nsImageControlFrameSuper::Init(aContent, aParent, aPrevInFlow);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// nsIntPoint allocation can fail, in which case we just set the property
|
||||
// to null, which is safe
|
||||
return mContent->SetProperty(nsGkAtoms::imageClickedPoint,
|
||||
new nsIntPoint(0, 0),
|
||||
IntPointDtorFunc);
|
||||
}
|
||||
|
||||
// Frames are not refcounted, no need to AddRef
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
|
@ -149,10 +167,6 @@ nsImageControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIImageControlFrame))) {
|
||||
*aInstancePtr = (void*) ((nsIImageControlFrame*) this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsImageControlFrameSuper::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
@ -239,10 +253,16 @@ nsImageControlFrame::HandleEvent(nsPresContext* aPresContext,
|
|||
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
|
||||
aEvent->message == NS_MOUSE_BUTTON_UP &&
|
||||
NS_STATIC_CAST(nsMouseEvent*, aEvent)->button == nsMouseEvent::eLeftButton) {
|
||||
// Store click point for GetNamesValues
|
||||
// Store click point for nsHTMLInputElement::SubmitNamesValues
|
||||
// Do this on MouseUp because the specs don't say and that's what IE does
|
||||
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
|
||||
TranslateEventCoords(pt, mLastClickPoint);
|
||||
nsIntPoint* lastClickPoint =
|
||||
NS_STATIC_CAST(nsIntPoint*,
|
||||
mContent->GetProperty(nsGkAtoms::imageClickedPoint));
|
||||
if (lastClickPoint) {
|
||||
// normally lastClickedPoint is not null, as it's allocated in Init()
|
||||
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
|
||||
TranslateEventCoords(pt, *lastClickPoint);
|
||||
}
|
||||
}
|
||||
return nsImageControlFrameSuper::HandleEvent(aPresContext, aEvent,
|
||||
aEventStatus);
|
||||
|
@ -282,17 +302,3 @@ nsImageControlFrame::GetFormProperty(nsIAtom* aName,
|
|||
aValue.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::GetClickedX(PRInt32* aX)
|
||||
{
|
||||
*aX = mLastClickPoint.x;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::GetClickedY(PRInt32* aY)
|
||||
{
|
||||
*aY = mLastClickPoint.y;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1455,7 +1455,7 @@ nsImageFrame::IsServerImageMap()
|
|||
// content area of this frame (inside the border+padding).
|
||||
void
|
||||
nsImageFrame::TranslateEventCoords(const nsPoint& aPoint,
|
||||
nsPoint& aResult)
|
||||
nsIntPoint& aResult)
|
||||
{
|
||||
nscoord x = aPoint.x;
|
||||
nscoord y = aPoint.y;
|
||||
|
@ -1508,7 +1508,7 @@ nsImageFrame::GetContentForEvent(nsPresContext* aPresContext,
|
|||
map = GetImageMap(aPresContext);
|
||||
|
||||
if (nsnull != map) {
|
||||
nsPoint p;
|
||||
nsIntPoint p;
|
||||
TranslateEventCoords(
|
||||
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this), p);
|
||||
PRBool inside = PR_FALSE;
|
||||
|
@ -1542,7 +1542,7 @@ nsImageFrame::HandleEvent(nsPresContext* aPresContext,
|
|||
map = GetImageMap(aPresContext);
|
||||
PRBool isServerMap = IsServerImageMap();
|
||||
if ((nsnull != map) || isServerMap) {
|
||||
nsPoint p;
|
||||
nsIntPoint p;
|
||||
TranslateEventCoords(
|
||||
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this), p);
|
||||
PRBool inside = PR_FALSE;
|
||||
|
@ -1597,7 +1597,7 @@ nsImageFrame::GetCursor(const nsPoint& aPoint,
|
|||
nsPresContext* context = GetPresContext();
|
||||
nsImageMap* map = GetImageMap(context);
|
||||
if (nsnull != map) {
|
||||
nsPoint p;
|
||||
nsIntPoint p;
|
||||
TranslateEventCoords(aPoint, p);
|
||||
nsCOMPtr<nsIContent> area;
|
||||
if (map->IsInside(p.x, p.y, getter_AddRefs(area))) {
|
||||
|
|
|
@ -186,7 +186,7 @@ protected:
|
|||
PRBool IsServerImageMap();
|
||||
|
||||
void TranslateEventCoords(const nsPoint& aPoint,
|
||||
nsPoint& aResult);
|
||||
nsIntPoint& aResult);
|
||||
|
||||
PRBool GetAnchorHREFTargetAndNode(nsIURI** aHref, nsString& aTarget,
|
||||
nsINode** aNode);
|
||||
|
|
Загрузка…
Ссылка в новой задаче