зеркало из https://github.com/mozilla/pjs.git
Fix for bug 25161 -- allow editor to handle pages with forms by implementing user-select and user-input for form controls. r=rods, pierre, mjudge.
This commit is contained in:
Родитель
59ee00ee6a
Коммит
a19bcfbde3
|
@ -148,6 +148,7 @@ public:
|
|||
NS_IMETHOD GetEnumerator(nsIEnumerator **aIterator);
|
||||
|
||||
NS_IMETHOD ToString(const nsString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsString& aReturn);
|
||||
|
||||
NS_IMETHOD SetHint(PRBool aHintRight);
|
||||
NS_IMETHOD GetHint(PRBool *aHintRight);
|
||||
|
||||
|
@ -288,6 +289,10 @@ public:
|
|||
NS_IMETHOD ScrollSelectionIntoView(SelectionType aType, SelectionRegion aRegion);
|
||||
NS_IMETHOD RepaintSelection(nsIPresContext* aPresContext, SelectionType aType);
|
||||
NS_IMETHOD GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset);
|
||||
|
||||
NS_IMETHOD AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
|
||||
nsIContent** outContent, PRInt32* outStartOffset, PRInt32* outEndOffset);
|
||||
|
||||
NS_IMETHOD SetHint(HINT aHintRight);
|
||||
NS_IMETHOD GetHint(HINT *aHintRight);
|
||||
NS_IMETHOD CharacterMove(PRBool aForward, PRBool aExtend);
|
||||
|
@ -345,6 +350,8 @@ private:
|
|||
|
||||
nsresult NotifySelectionListeners(SelectionType aType); // add parameters to say collapsed etc?
|
||||
|
||||
// utility method to lookup frame style
|
||||
nsresult FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSelectionStyle, nsIFrame* *foundFrame);
|
||||
|
||||
nsDOMSelection *mDomSelections[nsISelectionController::NUM_SELECTIONTYPES];
|
||||
nsIScrollableView *GetScrollView(){return mScrollView;}
|
||||
|
@ -1631,7 +1638,21 @@ nsSelection::HandleDrag(nsIPresContext *aPresContext, nsIFrame *aFrame, nsPoint&
|
|||
|
||||
result = newFrame->GetContentAndOffsetsFromPoint(aPresContext, newPoint,
|
||||
getter_AddRefs(newContent),
|
||||
startPos, contentOffsetEnd,beginOfContent);
|
||||
startPos, contentOffsetEnd, beginOfContent);
|
||||
|
||||
// do we have CSS that changes selection behaviour?
|
||||
{
|
||||
PRBool changeSelection;
|
||||
nsCOMPtr<nsIContent> selectContent;
|
||||
PRInt32 newStart, newEnd;
|
||||
if (NS_SUCCEEDED(AdjustOffsetsFromStyle(newFrame, &changeSelection, getter_AddRefs(selectContent), &newStart, &newEnd))
|
||||
&& changeSelection)
|
||||
{
|
||||
newContent = selectContent;
|
||||
startPos = newStart;
|
||||
contentOffsetEnd = newEnd;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
|
@ -2046,7 +2067,6 @@ nsSelection::StartBatchChanges()
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelection::EndBatchChanges()
|
||||
|
@ -2061,8 +2081,7 @@ nsSelection::EndBatchChanges()
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsSelection::NotifySelectionListeners(SelectionType aType)
|
||||
{
|
||||
|
@ -2074,6 +2093,30 @@ nsSelection::NotifySelectionListeners(SelectionType aType)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSelection::FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSelectionStyle, nsIFrame* *foundFrame)
|
||||
{
|
||||
nsIFrame* thisFrame = aFrame;
|
||||
|
||||
while (thisFrame)
|
||||
{
|
||||
const nsStyleUserInterface* userinterface;
|
||||
thisFrame->GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct*&)userinterface);
|
||||
|
||||
if (userinterface->mUserSelect == aSelectionStyle)
|
||||
{
|
||||
*foundFrame = thisFrame;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
thisFrame->GetParent(&thisFrame);
|
||||
}
|
||||
|
||||
*foundFrame = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Start of Table Selection methods
|
||||
|
||||
static PRBool IsCell(nsIContent *aContent)
|
||||
|
@ -2888,6 +2931,65 @@ nsSelection::CreateAndAddRange(nsIDOMNode *aParentNode, PRInt32 aOffset)
|
|||
|
||||
// End of Table Selection
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelection::AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
|
||||
nsIContent** outContent, PRInt32* outStartOffset, PRInt32* outEndOffset)
|
||||
{
|
||||
|
||||
*changeSelection = PR_FALSE;
|
||||
*outContent = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
nsIFrame* selectAllFrame;
|
||||
rv = FrameOrParentHasSpecialSelectionStyle(aFrame, NS_STYLE_USER_SELECT_ALL, &selectAllFrame);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!selectAllFrame)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIContent> selectAllContent;
|
||||
selectAllFrame->GetContent(getter_AddRefs(selectAllContent));
|
||||
if (selectAllContent)
|
||||
{
|
||||
nsCOMPtr<nsIContent> parentContent;
|
||||
rv = selectAllContent->GetParent(*getter_AddRefs(parentContent));
|
||||
if (parentContent)
|
||||
{
|
||||
PRInt32 startOffset;
|
||||
rv = parentContent->IndexOf(selectAllContent, startOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (startOffset < 0)
|
||||
{
|
||||
// hrmm, this is probably anonymous content. Let's go up another level
|
||||
// do we need to do this if we get the right frameSelection to start with?
|
||||
nsCOMPtr<nsIContent> superParent;
|
||||
parentContent->GetParent(*getter_AddRefs(superParent));
|
||||
if (superParent)
|
||||
{
|
||||
PRInt32 superStartOffset;
|
||||
rv = superParent->IndexOf(parentContent, superStartOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (superStartOffset < 0)
|
||||
return NS_ERROR_FAILURE; // give up
|
||||
|
||||
parentContent = superParent;
|
||||
startOffset = superStartOffset;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*outContent = parentContent);
|
||||
|
||||
*outStartOffset = startOffset;
|
||||
*outEndOffset = startOffset + 1;
|
||||
|
||||
*changeSelection = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelection::SetHint(HINT aHintRight)
|
||||
{
|
||||
|
|
|
@ -70,6 +70,7 @@ static NS_DEFINE_IID(kIFormIID, NS_IFORM_IID);
|
|||
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
|
||||
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
||||
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
|
||||
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
|
||||
|
||||
#ifdef ENDER_LITE
|
||||
typedef nsIGfxTextControlFrame2 textControlPlace;
|
||||
|
@ -817,6 +818,21 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
if (NS_FAILED(rv) || disabled) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame, PR_FALSE);
|
||||
nsIFrame* formFrame = nsnull;
|
||||
|
||||
if (formControlFrame && NS_SUCCEEDED(formControlFrame->QueryInterface(kIFrameIID, (void **)&formFrame) && formFrame))
|
||||
{
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
formFrame->GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
|
||||
uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// If we're a file input we have anonymous content underneath
|
||||
// that we need to hide. We need to set the event target now
|
||||
|
@ -866,8 +882,6 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
// That way if the event is cancelled then the checkbox will not flash.
|
||||
//
|
||||
// So get the Frame for the checkbox and tell it we are processing an onclick event
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame, PR_FALSE);
|
||||
nsCOMPtr<nsICheckboxControlFrame> chkBx;
|
||||
nsCOMPtr<nsIRadioControlFrame> radio;
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
|
|
@ -30,8 +30,11 @@
|
|||
#include "nsIMutableStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLOptGroupElementIID, NS_IDOMHTMLOPTGROUPELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
|
||||
|
||||
class nsHTMLOptGroupElement : public nsIDOMHTMLOptGroupElement,
|
||||
public nsIJSScriptObject,
|
||||
|
@ -190,6 +193,21 @@ nsHTMLOptGroupElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
|
||||
nsIFrame* formFrame = nsnull;
|
||||
|
||||
if (formControlFrame && NS_SUCCEEDED(formControlFrame->QueryInterface(kIFrameIID, (void **)&formFrame) && formFrame))
|
||||
{
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
formFrame->GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
|
||||
uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
|
|||
static NS_DEFINE_IID(kIFormIID, NS_IFORM_IID);
|
||||
static NS_DEFINE_IID(kISelectElementIID, NS_ISELECTELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
||||
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
|
||||
|
||||
class nsHTMLSelectElement;
|
||||
|
||||
|
@ -1284,6 +1285,21 @@ nsHTMLSelectElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
|
||||
nsIFrame* formFrame = nsnull;
|
||||
|
||||
if (formControlFrame && NS_SUCCEEDED(formControlFrame->QueryInterface(kIFrameIID, (void **)&formFrame) && formFrame))
|
||||
{
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
formFrame->GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
|
||||
uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
|
|
@ -47,12 +47,15 @@
|
|||
#include "nsLinebreakConverter.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLTextAreaElementIID, NS_IDOMHTMLTEXTAREAELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
|
||||
static NS_DEFINE_IID(kIFormIID, NS_IFORM_IID);
|
||||
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
|
||||
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
|
||||
|
||||
class nsHTMLTextAreaElement : public nsIDOMHTMLTextAreaElement,
|
||||
public nsIDOMNSHTMLTextAreaElement,
|
||||
|
@ -530,6 +533,21 @@ nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
|
||||
nsIFrame* formFrame = nsnull;
|
||||
|
||||
if (formControlFrame && NS_SUCCEEDED(formControlFrame->QueryInterface(kIFrameIID, (void **)&formFrame) && formFrame))
|
||||
{
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
formFrame->GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
|
||||
uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
|
|
@ -272,6 +272,18 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset)=0;
|
||||
|
||||
/** AdjustOffsetsFromStyle. Called after detecting that a click or drag will
|
||||
* select the frame, this function looks for user-select style on that frame or a parent
|
||||
* frame, and adjust the content and offsets accordingly.
|
||||
* @param aFrame the frame that was clicked
|
||||
* @param outContent content node to be selected
|
||||
* @param outStartOffset selection start offset
|
||||
* @param outEndOffset selection end offset
|
||||
*/
|
||||
NS_IMETHOD AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
|
||||
nsIContent** outContent, PRInt32* outStartOffset, PRInt32* outEndOffset)=0;
|
||||
|
||||
|
||||
NS_IMETHOD GetHint(HINT *aHint)=0;
|
||||
NS_IMETHOD SetHint(HINT aHint)=0;
|
||||
|
||||
|
|
|
@ -1007,7 +1007,16 @@ public:
|
|||
|
||||
NS_IMETHOD GetSelected(PRBool *aSelected) const = 0;
|
||||
|
||||
NS_IMETHOD IsSelectable(PRBool& aSelectable) const = 0;
|
||||
/**
|
||||
* called to discover where this frame, or a parent frame has user-select style
|
||||
* applied, which affects that way that it is selected.
|
||||
*
|
||||
* @param aIsSelectable out param. Set to true if the frame can be selected
|
||||
* (i.e. is not affected by user-select: none)
|
||||
* @param aSelectStyle out param. Returns the type of selection style found
|
||||
* (using values defined in nsStyleConsts.h).
|
||||
*/
|
||||
NS_IMETHOD IsSelectable(PRBool* aIsSelectable, PRUint8* aSelectStyle) const = 0;
|
||||
|
||||
/**
|
||||
* Called to retrieve the SelectionController associated with the frame.
|
||||
|
|
|
@ -272,6 +272,18 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset)=0;
|
||||
|
||||
/** AdjustOffsetsFromStyle. Called after detecting that a click or drag will
|
||||
* select the frame, this function looks for user-select style on that frame or a parent
|
||||
* frame, and adjust the content and offsets accordingly.
|
||||
* @param aFrame the frame that was clicked
|
||||
* @param outContent content node to be selected
|
||||
* @param outStartOffset selection start offset
|
||||
* @param outEndOffset selection end offset
|
||||
*/
|
||||
NS_IMETHOD AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
|
||||
nsIContent** outContent, PRInt32* outStartOffset, PRInt32* outEndOffset)=0;
|
||||
|
||||
|
||||
NS_IMETHOD GetHint(HINT *aHint)=0;
|
||||
NS_IMETHOD SetHint(HINT aHint)=0;
|
||||
|
||||
|
|
|
@ -148,6 +148,7 @@ public:
|
|||
NS_IMETHOD GetEnumerator(nsIEnumerator **aIterator);
|
||||
|
||||
NS_IMETHOD ToString(const nsString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsString& aReturn);
|
||||
|
||||
NS_IMETHOD SetHint(PRBool aHintRight);
|
||||
NS_IMETHOD GetHint(PRBool *aHintRight);
|
||||
|
||||
|
@ -288,6 +289,10 @@ public:
|
|||
NS_IMETHOD ScrollSelectionIntoView(SelectionType aType, SelectionRegion aRegion);
|
||||
NS_IMETHOD RepaintSelection(nsIPresContext* aPresContext, SelectionType aType);
|
||||
NS_IMETHOD GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset);
|
||||
|
||||
NS_IMETHOD AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
|
||||
nsIContent** outContent, PRInt32* outStartOffset, PRInt32* outEndOffset);
|
||||
|
||||
NS_IMETHOD SetHint(HINT aHintRight);
|
||||
NS_IMETHOD GetHint(HINT *aHintRight);
|
||||
NS_IMETHOD CharacterMove(PRBool aForward, PRBool aExtend);
|
||||
|
@ -345,6 +350,8 @@ private:
|
|||
|
||||
nsresult NotifySelectionListeners(SelectionType aType); // add parameters to say collapsed etc?
|
||||
|
||||
// utility method to lookup frame style
|
||||
nsresult FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSelectionStyle, nsIFrame* *foundFrame);
|
||||
|
||||
nsDOMSelection *mDomSelections[nsISelectionController::NUM_SELECTIONTYPES];
|
||||
nsIScrollableView *GetScrollView(){return mScrollView;}
|
||||
|
@ -1631,7 +1638,21 @@ nsSelection::HandleDrag(nsIPresContext *aPresContext, nsIFrame *aFrame, nsPoint&
|
|||
|
||||
result = newFrame->GetContentAndOffsetsFromPoint(aPresContext, newPoint,
|
||||
getter_AddRefs(newContent),
|
||||
startPos, contentOffsetEnd,beginOfContent);
|
||||
startPos, contentOffsetEnd, beginOfContent);
|
||||
|
||||
// do we have CSS that changes selection behaviour?
|
||||
{
|
||||
PRBool changeSelection;
|
||||
nsCOMPtr<nsIContent> selectContent;
|
||||
PRInt32 newStart, newEnd;
|
||||
if (NS_SUCCEEDED(AdjustOffsetsFromStyle(newFrame, &changeSelection, getter_AddRefs(selectContent), &newStart, &newEnd))
|
||||
&& changeSelection)
|
||||
{
|
||||
newContent = selectContent;
|
||||
startPos = newStart;
|
||||
contentOffsetEnd = newEnd;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
|
@ -2046,7 +2067,6 @@ nsSelection::StartBatchChanges()
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelection::EndBatchChanges()
|
||||
|
@ -2061,8 +2081,7 @@ nsSelection::EndBatchChanges()
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsSelection::NotifySelectionListeners(SelectionType aType)
|
||||
{
|
||||
|
@ -2074,6 +2093,30 @@ nsSelection::NotifySelectionListeners(SelectionType aType)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSelection::FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSelectionStyle, nsIFrame* *foundFrame)
|
||||
{
|
||||
nsIFrame* thisFrame = aFrame;
|
||||
|
||||
while (thisFrame)
|
||||
{
|
||||
const nsStyleUserInterface* userinterface;
|
||||
thisFrame->GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct*&)userinterface);
|
||||
|
||||
if (userinterface->mUserSelect == aSelectionStyle)
|
||||
{
|
||||
*foundFrame = thisFrame;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
thisFrame->GetParent(&thisFrame);
|
||||
}
|
||||
|
||||
*foundFrame = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Start of Table Selection methods
|
||||
|
||||
static PRBool IsCell(nsIContent *aContent)
|
||||
|
@ -2888,6 +2931,65 @@ nsSelection::CreateAndAddRange(nsIDOMNode *aParentNode, PRInt32 aOffset)
|
|||
|
||||
// End of Table Selection
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelection::AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
|
||||
nsIContent** outContent, PRInt32* outStartOffset, PRInt32* outEndOffset)
|
||||
{
|
||||
|
||||
*changeSelection = PR_FALSE;
|
||||
*outContent = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
nsIFrame* selectAllFrame;
|
||||
rv = FrameOrParentHasSpecialSelectionStyle(aFrame, NS_STYLE_USER_SELECT_ALL, &selectAllFrame);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!selectAllFrame)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIContent> selectAllContent;
|
||||
selectAllFrame->GetContent(getter_AddRefs(selectAllContent));
|
||||
if (selectAllContent)
|
||||
{
|
||||
nsCOMPtr<nsIContent> parentContent;
|
||||
rv = selectAllContent->GetParent(*getter_AddRefs(parentContent));
|
||||
if (parentContent)
|
||||
{
|
||||
PRInt32 startOffset;
|
||||
rv = parentContent->IndexOf(selectAllContent, startOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (startOffset < 0)
|
||||
{
|
||||
// hrmm, this is probably anonymous content. Let's go up another level
|
||||
// do we need to do this if we get the right frameSelection to start with?
|
||||
nsCOMPtr<nsIContent> superParent;
|
||||
parentContent->GetParent(*getter_AddRefs(superParent));
|
||||
if (superParent)
|
||||
{
|
||||
PRInt32 superStartOffset;
|
||||
rv = superParent->IndexOf(parentContent, superStartOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (superStartOffset < 0)
|
||||
return NS_ERROR_FAILURE; // give up
|
||||
|
||||
parentContent = superParent;
|
||||
startOffset = superStartOffset;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*outContent = parentContent);
|
||||
|
||||
*outStartOffset = startOffset;
|
||||
*outEndOffset = startOffset + 1;
|
||||
|
||||
*changeSelection = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelection::SetHint(HINT aHintRight)
|
||||
{
|
||||
|
|
|
@ -2048,7 +2048,9 @@ nsComboboxControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
// Have to feed event down to nsFrame::HandleEvent so that
|
||||
// selection takes place when appropriate.
|
||||
return nsAreaFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2518,7 +2520,8 @@ nsComboboxControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
// Call to the base class to draw selection borders when appropriate
|
||||
return nsFrame::Paint(aPresContext,aRenderingContext,aDirtyRect,aWhichLayer);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -441,8 +441,8 @@ nsFormControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
nsresult rv = nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
|
||||
aWhichLayer);
|
||||
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer){
|
||||
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer)
|
||||
{
|
||||
nsRect rect(0, 0, mRect.width, mRect.height);
|
||||
PaintSpecialBorder(aPresContext,
|
||||
aRenderingContext,
|
||||
|
@ -782,6 +782,12 @@ nsFormControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Check for user-input:none style
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
|
||||
// if not native then use the NS_MOUSE_LEFT_CLICK to see if pressed
|
||||
// unfortunately native widgets don't seem to handle this right.
|
||||
// so use the old code for native stuff. -EDV
|
||||
|
|
|
@ -585,8 +585,13 @@ nsGfxButtonControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
// Do nothing here, nsHTMLInputElement::HandleDOMEvent
|
||||
// takes cares of calling MouseClicked for us.
|
||||
|
||||
// do we have user-input style?
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -415,10 +415,11 @@ nsGfxCheckboxControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
PaintCheckBox(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
// Call to the base class to draw selection borders when appropriate
|
||||
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
nsGfxCheckboxControlFrame::CheckState
|
||||
nsGfxCheckboxControlFrame::GetCheckboxState ( )
|
||||
|
|
|
@ -252,6 +252,21 @@ nsGfxRadioControlFrame::Reset(nsIPresContext* aPresContext)
|
|||
SetCurrentCheckState(checked);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxRadioControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
// Check for user-input:none style
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
|
||||
// otherwise, do nothing. Events are handled by the DOM.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void
|
||||
nsGfxRadioControlFrame::PaintRadioButton(nsIPresContext* aPresContext,
|
||||
|
@ -309,7 +324,9 @@ nsGfxRadioControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
||||
PaintRadioButton(aPresContext, aRenderingContext, aDirtyRect);
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
// Call to the base class to draw selection borders when appropriate
|
||||
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -63,11 +63,9 @@ public:
|
|||
NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex,
|
||||
nsIStyleContext* aStyleContext);
|
||||
|
||||
// overrides base class HandleEvent to do nothing
|
||||
// events are handled by the DOM
|
||||
NS_IMETHOD HandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus* aEventStatus) { return NS_OK; }
|
||||
nsEventStatus* aEventStatus);
|
||||
//
|
||||
// XXX: The following paint methods are TEMPORARY. It is being used to get printing working
|
||||
// under windows. Later it may be used to GFX-render the controls to the display.
|
||||
|
|
|
@ -480,7 +480,8 @@ nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
// to draw border when selected in editor
|
||||
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
|
||||
// XXX a hack until the reflow state does this correctly
|
||||
|
|
|
@ -280,6 +280,13 @@ nsImageControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEventStatus);
|
||||
|
||||
// do we have user-input style?
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
|
||||
if (nsFormFrame::GetDisabled(this)) { // XXX cache disabled
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1340,6 +1340,13 @@ nsListControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
if (nsEventStatus_eConsumeNoDefault == *aEventStatus)
|
||||
return NS_OK;
|
||||
|
||||
// do we have style that affects how we are selected?
|
||||
// do we have user-input style?
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
|
||||
if (nsFormFrame::GetDisabled(this))
|
||||
return NS_OK;
|
||||
|
||||
|
@ -1359,8 +1366,7 @@ nsListControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
break;
|
||||
}
|
||||
|
||||
return(nsScrollFrame::HandleEvent(aPresContext, aEvent, aEventStatus));
|
||||
|
||||
return nsScrollFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -260,9 +260,11 @@ public:
|
|||
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
|
||||
NS_IMETHOD VerifyTree() const;
|
||||
#endif
|
||||
|
||||
NS_IMETHOD SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread);
|
||||
NS_IMETHOD GetSelected(PRBool *aSelected) const;
|
||||
NS_IMETHOD IsSelectable(PRBool& aSelectable) const;
|
||||
NS_IMETHOD IsSelectable(PRBool* aIsSelectable, PRUint8* aSelectStyle) const;
|
||||
|
||||
NS_IMETHOD GetSelectionController(nsIPresContext *aPresContext, nsISelectionController **aSelCon);
|
||||
NS_IMETHOD PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) ;
|
||||
NS_IMETHOD CheckVisibility(nsIPresContext* aContext, PRInt32 aStartIndex, PRInt32 aEndIndex, PRBool aRecurse, PRBool *aFinished, PRBool *_retval);
|
||||
|
@ -409,7 +411,7 @@ protected:
|
|||
virtual ~nsFrame();
|
||||
|
||||
PRInt16 DisplaySelection(nsIPresContext* aPresContext, PRBool isOkToTurnOn = PR_FALSE);
|
||||
|
||||
|
||||
//this will modify aPos and return the next frame ect.
|
||||
NS_IMETHOD GetFrameFromDirection(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos);
|
||||
|
||||
|
|
|
@ -98,7 +98,9 @@ nsHTMLContainerFrame::Paint(nsIPresContext* aPresContext,
|
|||
// hidden
|
||||
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
return NS_OK;
|
||||
|
||||
// see if we have to draw a selection frame around this container
|
||||
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1007,7 +1007,16 @@ public:
|
|||
|
||||
NS_IMETHOD GetSelected(PRBool *aSelected) const = 0;
|
||||
|
||||
NS_IMETHOD IsSelectable(PRBool& aSelectable) const = 0;
|
||||
/**
|
||||
* called to discover where this frame, or a parent frame has user-select style
|
||||
* applied, which affects that way that it is selected.
|
||||
*
|
||||
* @param aIsSelectable out param. Set to true if the frame can be selected
|
||||
* (i.e. is not affected by user-select: none)
|
||||
* @param aSelectStyle out param. Returns the type of selection style found
|
||||
* (using values defined in nsStyleConsts.h).
|
||||
*/
|
||||
NS_IMETHOD IsSelectable(PRBool* aIsSelectable, PRUint8* aSelectStyle) const = 0;
|
||||
|
||||
/**
|
||||
* Called to retrieve the SelectionController associated with the frame.
|
||||
|
|
|
@ -148,6 +148,7 @@ public:
|
|||
NS_IMETHOD GetEnumerator(nsIEnumerator **aIterator);
|
||||
|
||||
NS_IMETHOD ToString(const nsString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsString& aReturn);
|
||||
|
||||
NS_IMETHOD SetHint(PRBool aHintRight);
|
||||
NS_IMETHOD GetHint(PRBool *aHintRight);
|
||||
|
||||
|
@ -288,6 +289,10 @@ public:
|
|||
NS_IMETHOD ScrollSelectionIntoView(SelectionType aType, SelectionRegion aRegion);
|
||||
NS_IMETHOD RepaintSelection(nsIPresContext* aPresContext, SelectionType aType);
|
||||
NS_IMETHOD GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset);
|
||||
|
||||
NS_IMETHOD AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
|
||||
nsIContent** outContent, PRInt32* outStartOffset, PRInt32* outEndOffset);
|
||||
|
||||
NS_IMETHOD SetHint(HINT aHintRight);
|
||||
NS_IMETHOD GetHint(HINT *aHintRight);
|
||||
NS_IMETHOD CharacterMove(PRBool aForward, PRBool aExtend);
|
||||
|
@ -345,6 +350,8 @@ private:
|
|||
|
||||
nsresult NotifySelectionListeners(SelectionType aType); // add parameters to say collapsed etc?
|
||||
|
||||
// utility method to lookup frame style
|
||||
nsresult FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSelectionStyle, nsIFrame* *foundFrame);
|
||||
|
||||
nsDOMSelection *mDomSelections[nsISelectionController::NUM_SELECTIONTYPES];
|
||||
nsIScrollableView *GetScrollView(){return mScrollView;}
|
||||
|
@ -1631,7 +1638,21 @@ nsSelection::HandleDrag(nsIPresContext *aPresContext, nsIFrame *aFrame, nsPoint&
|
|||
|
||||
result = newFrame->GetContentAndOffsetsFromPoint(aPresContext, newPoint,
|
||||
getter_AddRefs(newContent),
|
||||
startPos, contentOffsetEnd,beginOfContent);
|
||||
startPos, contentOffsetEnd, beginOfContent);
|
||||
|
||||
// do we have CSS that changes selection behaviour?
|
||||
{
|
||||
PRBool changeSelection;
|
||||
nsCOMPtr<nsIContent> selectContent;
|
||||
PRInt32 newStart, newEnd;
|
||||
if (NS_SUCCEEDED(AdjustOffsetsFromStyle(newFrame, &changeSelection, getter_AddRefs(selectContent), &newStart, &newEnd))
|
||||
&& changeSelection)
|
||||
{
|
||||
newContent = selectContent;
|
||||
startPos = newStart;
|
||||
contentOffsetEnd = newEnd;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
|
@ -2046,7 +2067,6 @@ nsSelection::StartBatchChanges()
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelection::EndBatchChanges()
|
||||
|
@ -2061,8 +2081,7 @@ nsSelection::EndBatchChanges()
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsSelection::NotifySelectionListeners(SelectionType aType)
|
||||
{
|
||||
|
@ -2074,6 +2093,30 @@ nsSelection::NotifySelectionListeners(SelectionType aType)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSelection::FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSelectionStyle, nsIFrame* *foundFrame)
|
||||
{
|
||||
nsIFrame* thisFrame = aFrame;
|
||||
|
||||
while (thisFrame)
|
||||
{
|
||||
const nsStyleUserInterface* userinterface;
|
||||
thisFrame->GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct*&)userinterface);
|
||||
|
||||
if (userinterface->mUserSelect == aSelectionStyle)
|
||||
{
|
||||
*foundFrame = thisFrame;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
thisFrame->GetParent(&thisFrame);
|
||||
}
|
||||
|
||||
*foundFrame = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Start of Table Selection methods
|
||||
|
||||
static PRBool IsCell(nsIContent *aContent)
|
||||
|
@ -2888,6 +2931,65 @@ nsSelection::CreateAndAddRange(nsIDOMNode *aParentNode, PRInt32 aOffset)
|
|||
|
||||
// End of Table Selection
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelection::AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
|
||||
nsIContent** outContent, PRInt32* outStartOffset, PRInt32* outEndOffset)
|
||||
{
|
||||
|
||||
*changeSelection = PR_FALSE;
|
||||
*outContent = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
nsIFrame* selectAllFrame;
|
||||
rv = FrameOrParentHasSpecialSelectionStyle(aFrame, NS_STYLE_USER_SELECT_ALL, &selectAllFrame);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!selectAllFrame)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIContent> selectAllContent;
|
||||
selectAllFrame->GetContent(getter_AddRefs(selectAllContent));
|
||||
if (selectAllContent)
|
||||
{
|
||||
nsCOMPtr<nsIContent> parentContent;
|
||||
rv = selectAllContent->GetParent(*getter_AddRefs(parentContent));
|
||||
if (parentContent)
|
||||
{
|
||||
PRInt32 startOffset;
|
||||
rv = parentContent->IndexOf(selectAllContent, startOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (startOffset < 0)
|
||||
{
|
||||
// hrmm, this is probably anonymous content. Let's go up another level
|
||||
// do we need to do this if we get the right frameSelection to start with?
|
||||
nsCOMPtr<nsIContent> superParent;
|
||||
parentContent->GetParent(*getter_AddRefs(superParent));
|
||||
if (superParent)
|
||||
{
|
||||
PRInt32 superStartOffset;
|
||||
rv = superParent->IndexOf(parentContent, superStartOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (superStartOffset < 0)
|
||||
return NS_ERROR_FAILURE; // give up
|
||||
|
||||
parentContent = superParent;
|
||||
startOffset = superStartOffset;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*outContent = parentContent);
|
||||
|
||||
*outStartOffset = startOffset;
|
||||
*outEndOffset = startOffset + 1;
|
||||
|
||||
*changeSelection = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSelection::SetHint(HINT aHintRight)
|
||||
{
|
||||
|
|
|
@ -2844,7 +2844,7 @@ nsTextFrame::SetSelected(nsIPresContext* aPresContext,
|
|||
|
||||
// check whether style allows selection
|
||||
PRBool selectable;
|
||||
IsSelectable(selectable);
|
||||
IsSelectable(&selectable, nsnull);
|
||||
if (!selectable)
|
||||
return NS_OK;//do not continue no selection for this frame.
|
||||
|
||||
|
|
|
@ -260,9 +260,11 @@ public:
|
|||
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
|
||||
NS_IMETHOD VerifyTree() const;
|
||||
#endif
|
||||
|
||||
NS_IMETHOD SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread);
|
||||
NS_IMETHOD GetSelected(PRBool *aSelected) const;
|
||||
NS_IMETHOD IsSelectable(PRBool& aSelectable) const;
|
||||
NS_IMETHOD IsSelectable(PRBool* aIsSelectable, PRUint8* aSelectStyle) const;
|
||||
|
||||
NS_IMETHOD GetSelectionController(nsIPresContext *aPresContext, nsISelectionController **aSelCon);
|
||||
NS_IMETHOD PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) ;
|
||||
NS_IMETHOD CheckVisibility(nsIPresContext* aContext, PRInt32 aStartIndex, PRInt32 aEndIndex, PRBool aRecurse, PRBool *aFinished, PRBool *_retval);
|
||||
|
@ -409,7 +411,7 @@ protected:
|
|||
virtual ~nsFrame();
|
||||
|
||||
PRInt16 DisplaySelection(nsIPresContext* aPresContext, PRBool isOkToTurnOn = PR_FALSE);
|
||||
|
||||
|
||||
//this will modify aPos and return the next frame ect.
|
||||
NS_IMETHOD GetFrameFromDirection(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos);
|
||||
|
||||
|
|
|
@ -98,7 +98,9 @@ nsHTMLContainerFrame::Paint(nsIPresContext* aPresContext,
|
|||
// hidden
|
||||
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
return NS_OK;
|
||||
|
||||
// see if we have to draw a selection frame around this container
|
||||
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -963,8 +963,11 @@ nsScrollFrame::Paint(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
// Paint our children
|
||||
return nsContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
|
||||
nsresult rv = nsContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
|
||||
aWhichLayer);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -2844,7 +2844,7 @@ nsTextFrame::SetSelected(nsIPresContext* aPresContext,
|
|||
|
||||
// check whether style allows selection
|
||||
PRBool selectable;
|
||||
IsSelectable(selectable);
|
||||
IsSelectable(&selectable, nsnull);
|
||||
if (!selectable)
|
||||
return NS_OK;//do not continue no selection for this frame.
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ static NS_DEFINE_IID(kIFormIID, NS_IFORM_IID);
|
|||
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
|
||||
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
||||
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
|
||||
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
|
||||
|
||||
#ifdef ENDER_LITE
|
||||
typedef nsIGfxTextControlFrame2 textControlPlace;
|
||||
|
@ -817,6 +818,21 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
if (NS_FAILED(rv) || disabled) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame, PR_FALSE);
|
||||
nsIFrame* formFrame = nsnull;
|
||||
|
||||
if (formControlFrame && NS_SUCCEEDED(formControlFrame->QueryInterface(kIFrameIID, (void **)&formFrame) && formFrame))
|
||||
{
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
formFrame->GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
|
||||
uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// If we're a file input we have anonymous content underneath
|
||||
// that we need to hide. We need to set the event target now
|
||||
|
@ -866,8 +882,6 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
// That way if the event is cancelled then the checkbox will not flash.
|
||||
//
|
||||
// So get the Frame for the checkbox and tell it we are processing an onclick event
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame, PR_FALSE);
|
||||
nsCOMPtr<nsICheckboxControlFrame> chkBx;
|
||||
nsCOMPtr<nsIRadioControlFrame> radio;
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
|
|
@ -30,8 +30,11 @@
|
|||
#include "nsIMutableStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLOptGroupElementIID, NS_IDOMHTMLOPTGROUPELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
|
||||
|
||||
class nsHTMLOptGroupElement : public nsIDOMHTMLOptGroupElement,
|
||||
public nsIJSScriptObject,
|
||||
|
@ -190,6 +193,21 @@ nsHTMLOptGroupElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
|
||||
nsIFrame* formFrame = nsnull;
|
||||
|
||||
if (formControlFrame && NS_SUCCEEDED(formControlFrame->QueryInterface(kIFrameIID, (void **)&formFrame) && formFrame))
|
||||
{
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
formFrame->GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
|
||||
uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
|
|||
static NS_DEFINE_IID(kIFormIID, NS_IFORM_IID);
|
||||
static NS_DEFINE_IID(kISelectElementIID, NS_ISELECTELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
||||
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
|
||||
|
||||
class nsHTMLSelectElement;
|
||||
|
||||
|
@ -1284,6 +1285,21 @@ nsHTMLSelectElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
|
||||
nsIFrame* formFrame = nsnull;
|
||||
|
||||
if (formControlFrame && NS_SUCCEEDED(formControlFrame->QueryInterface(kIFrameIID, (void **)&formFrame) && formFrame))
|
||||
{
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
formFrame->GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
|
||||
uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
|
|
@ -47,12 +47,15 @@
|
|||
#include "nsLinebreakConverter.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLTextAreaElementIID, NS_IDOMHTMLTEXTAREAELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
|
||||
static NS_DEFINE_IID(kIFormIID, NS_IFORM_IID);
|
||||
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
|
||||
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
|
||||
|
||||
class nsHTMLTextAreaElement : public nsIDOMHTMLTextAreaElement,
|
||||
public nsIDOMNSHTMLTextAreaElement,
|
||||
|
@ -530,6 +533,21 @@ nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
|
||||
nsIFrame* formFrame = nsnull;
|
||||
|
||||
if (formControlFrame && NS_SUCCEEDED(formControlFrame->QueryInterface(kIFrameIID, (void **)&formFrame) && formFrame))
|
||||
{
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
formFrame->GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
|
||||
uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
|
|
@ -2048,7 +2048,9 @@ nsComboboxControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
// Have to feed event down to nsFrame::HandleEvent so that
|
||||
// selection takes place when appropriate.
|
||||
return nsAreaFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2518,7 +2520,8 @@ nsComboboxControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
// Call to the base class to draw selection borders when appropriate
|
||||
return nsFrame::Paint(aPresContext,aRenderingContext,aDirtyRect,aWhichLayer);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -441,8 +441,8 @@ nsFormControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
nsresult rv = nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
|
||||
aWhichLayer);
|
||||
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer){
|
||||
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer)
|
||||
{
|
||||
nsRect rect(0, 0, mRect.width, mRect.height);
|
||||
PaintSpecialBorder(aPresContext,
|
||||
aRenderingContext,
|
||||
|
@ -782,6 +782,12 @@ nsFormControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Check for user-input:none style
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
|
||||
// if not native then use the NS_MOUSE_LEFT_CLICK to see if pressed
|
||||
// unfortunately native widgets don't seem to handle this right.
|
||||
// so use the old code for native stuff. -EDV
|
||||
|
|
|
@ -585,8 +585,13 @@ nsGfxButtonControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
// Do nothing here, nsHTMLInputElement::HandleDOMEvent
|
||||
// takes cares of calling MouseClicked for us.
|
||||
|
||||
// do we have user-input style?
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -415,10 +415,11 @@ nsGfxCheckboxControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
PaintCheckBox(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
// Call to the base class to draw selection borders when appropriate
|
||||
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
nsGfxCheckboxControlFrame::CheckState
|
||||
nsGfxCheckboxControlFrame::GetCheckboxState ( )
|
||||
|
|
|
@ -252,6 +252,21 @@ nsGfxRadioControlFrame::Reset(nsIPresContext* aPresContext)
|
|||
SetCurrentCheckState(checked);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxRadioControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
// Check for user-input:none style
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
|
||||
// otherwise, do nothing. Events are handled by the DOM.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void
|
||||
nsGfxRadioControlFrame::PaintRadioButton(nsIPresContext* aPresContext,
|
||||
|
@ -309,7 +324,9 @@ nsGfxRadioControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
||||
PaintRadioButton(aPresContext, aRenderingContext, aDirtyRect);
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
// Call to the base class to draw selection borders when appropriate
|
||||
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -63,11 +63,9 @@ public:
|
|||
NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex,
|
||||
nsIStyleContext* aStyleContext);
|
||||
|
||||
// overrides base class HandleEvent to do nothing
|
||||
// events are handled by the DOM
|
||||
NS_IMETHOD HandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus* aEventStatus) { return NS_OK; }
|
||||
nsEventStatus* aEventStatus);
|
||||
//
|
||||
// XXX: The following paint methods are TEMPORARY. It is being used to get printing working
|
||||
// under windows. Later it may be used to GFX-render the controls to the display.
|
||||
|
|
|
@ -555,6 +555,8 @@ public:
|
|||
NS_IMETHOD GetTableCellSelection(PRBool *aState);
|
||||
NS_IMETHOD GetTableCellSelectionStyleColor(const nsStyleColor **aStyleColor);
|
||||
NS_IMETHOD GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset);
|
||||
NS_IMETHOD AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
|
||||
nsIContent** outContent, PRInt32* outStartOffset, PRInt32* outEndOffset);
|
||||
NS_IMETHOD GetHint(nsIFrameSelection::HINT *aHint);
|
||||
NS_IMETHOD SetHint(nsIFrameSelection::HINT aHint);
|
||||
NS_IMETHOD SetScrollableView(nsIScrollableView *aScrollableView);
|
||||
|
@ -946,6 +948,13 @@ nsTextInputSelectionImpl::GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffs
|
|||
return mFrameSelection->GetFrameForNodeOffset(aNode, aOffset, aHint,aReturnFrame,aReturnOffset);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextInputSelectionImpl::AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
|
||||
nsIContent** outContent, PRInt32* outStartOffset, PRInt32* outEndOffset)
|
||||
{
|
||||
return mFrameSelection->AdjustOffsetsFromStyle(aFrame, changeSelection, outContent, outStartOffset, outEndOffset);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTextInputSelectionImpl::GetHint(nsIFrameSelection::HINT *aHint)
|
||||
{
|
||||
return mFrameSelection->GetHint(aHint);
|
||||
|
|
|
@ -480,7 +480,8 @@ nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
// to draw border when selected in editor
|
||||
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
|
||||
// XXX a hack until the reflow state does this correctly
|
||||
|
|
|
@ -280,6 +280,13 @@ nsImageControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEventStatus);
|
||||
|
||||
// do we have user-input style?
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
|
||||
if (nsFormFrame::GetDisabled(this)) { // XXX cache disabled
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1340,6 +1340,13 @@ nsListControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
if (nsEventStatus_eConsumeNoDefault == *aEventStatus)
|
||||
return NS_OK;
|
||||
|
||||
// do we have style that affects how we are selected?
|
||||
// do we have user-input style?
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
GetStyleData(eStyleStruct_UserInterface, (const nsStyleUserInterface *&)uiStyle);
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
|
||||
if (nsFormFrame::GetDisabled(this))
|
||||
return NS_OK;
|
||||
|
||||
|
@ -1359,8 +1366,7 @@ nsListControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
break;
|
||||
}
|
||||
|
||||
return(nsScrollFrame::HandleEvent(aPresContext, aEvent, aEventStatus));
|
||||
|
||||
return nsScrollFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -573,7 +573,8 @@ nsScrollBoxFrame::Paint(nsIPresContext* aPresContext,
|
|||
nsresult rv = nsBoxFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
|
||||
aWhichLayer);
|
||||
|
||||
return rv;
|
||||
// Call nsFrame::Paint to draw selection border when appropriate
|
||||
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
|
||||
PRIntn
|
||||
|
|
Загрузка…
Ссылка в новой задаче