mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-05 00:02:37 +00:00
cleaned up some code
add method to get the absolute rect of the combobox frame for hit detectio now drop downs drop down under the select
This commit is contained in:
parent
7832f1619c
commit
fea9cdf36b
@ -601,25 +601,6 @@ nsComboboxControlFrame::GetAbsoluteFramePosition(nsIPresContext& aPresContext,
|
||||
}
|
||||
aAbsoluteTwipsRect.x += viewOffset.x;
|
||||
aAbsoluteTwipsRect.y += viewOffset.y;
|
||||
|
||||
// Addin the containing view's offset form it's containing widget
|
||||
/*nsIWidget* widget = nsnull;
|
||||
nscoord widgetx = 0;
|
||||
nscoord widgety = 0;
|
||||
rv = containingView->GetOffsetFromWidget(&widgetx, &widgety, widget);
|
||||
if (NS_SUCCEEDED(rv) && (nsnull != widget)) {
|
||||
aAbsoluteTwipsRect.x += widgetx;
|
||||
aAbsoluteTwipsRect.y += widgety;
|
||||
|
||||
// Add in the absolute offset of the widget.
|
||||
nsRect absBounds;
|
||||
//XXX: Remove this widget->GetAbsoluteBounds(absBounds);
|
||||
|
||||
// Convert widget coordinates to twips
|
||||
aAbsoluteTwipsRect.x += NSIntPixelsToTwips(absBounds.x, p2t);
|
||||
aAbsoluteTwipsRect.y += NSIntPixelsToTwips(absBounds.y, p2t);
|
||||
NS_RELEASE(widget);
|
||||
}*/
|
||||
}
|
||||
|
||||
// convert to pixel coordinates
|
||||
@ -789,7 +770,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext& aPresContext,
|
||||
|
||||
nsRect absoluteTwips;
|
||||
nsRect absolutePixels;
|
||||
GetAbsoluteFramePosition(aPresContext, displayFrame, absoluteTwips, absolutePixels);
|
||||
GetAbsoluteFramePosition(aPresContext, this, absoluteTwips, absolutePixels);
|
||||
PositionDropdown(aPresContext, aDesiredSize.height, absoluteTwips, absolutePixels);
|
||||
|
||||
return rv;
|
||||
@ -885,21 +866,14 @@ nsComboboxControlFrame::GetFrameName(nsString& aResult) const
|
||||
nsresult
|
||||
nsComboboxControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
/*if (nsFormFrame::GetDisabled(this)) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsRect absoluteTwips;
|
||||
nsRect absolutePixels;
|
||||
nsIFrame * displayFrame = GetDisplayFrame(*mPresContext);
|
||||
nsRect displayRect;
|
||||
// Get the current sizes of the combo box child frames
|
||||
displayFrame->GetRect(displayRect);
|
||||
GetAbsoluteFramePosition(*mPresContext, displayFrame, absoluteTwips, absolutePixels);
|
||||
PositionDropdown(*mPresContext, displayRect.height, absoluteTwips, absolutePixels);
|
||||
|
||||
ToggleList(mPresContext);
|
||||
//mIgnoreMouseUp = PR_TRUE;
|
||||
*/
|
||||
/*PRBool isDroppedDown;
|
||||
IsDroppedDown(&isDroppedDown);
|
||||
if (isDroppedDown) {
|
||||
ShowDropDown(!isDroppedDown);
|
||||
if (isDroppedDown) {
|
||||
mListControlFrame->CaptureMouseEvents(PR_FALSE);
|
||||
}
|
||||
}*/
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -914,14 +888,6 @@ nsComboboxControlFrame::ShowDropDown(PRBool aDoDropDown)
|
||||
}
|
||||
|
||||
if (!mDroppedDown && aDoDropDown) {
|
||||
//nsRect absoluteTwips;
|
||||
//nsRect absolutePixels;
|
||||
//nsIFrame * displayFrame = GetDisplayFrame(*mPresContext);
|
||||
//nsRect displayRect;
|
||||
// Get the current sizes of the combo box child frames
|
||||
//displayFrame->GetRect(displayRect);
|
||||
//GetAbsoluteFramePosition(*mPresContext, displayFrame, absoluteTwips, absolutePixels);
|
||||
//PositionDropdown(*mPresContext, displayRect.height, absoluteTwips, absolutePixels);
|
||||
if (mListControlFrame) {
|
||||
mListControlFrame->SyncViewWithFrame();
|
||||
}
|
||||
@ -1018,12 +984,23 @@ nsComboboxControlFrame::AbsolutelyPositionDropDown()
|
||||
nsRect absolutePixels;
|
||||
nsIFrame* displayFrame = GetDisplayFrame(*mPresContext);
|
||||
nsRect rect;
|
||||
displayFrame->GetRect(rect);
|
||||
GetAbsoluteFramePosition(*mPresContext, displayFrame, absoluteTwips, absolutePixels);
|
||||
this->GetRect(rect);
|
||||
GetAbsoluteFramePosition(*mPresContext, this, absoluteTwips, absolutePixels);
|
||||
PositionDropdown(*mPresContext, rect.height, absoluteTwips, absolutePixels);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::GetAbsoluteRect(nsRect* aRect)
|
||||
{
|
||||
nsRect absoluteTwips;
|
||||
nsRect rect;
|
||||
this->GetRect(rect);
|
||||
GetAbsoluteFramePosition(*mPresContext, this, absoluteTwips, *aRect);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1244,7 +1221,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsISupportsArray& aChildList)
|
||||
//displayReciever->AddEventListenerByIID((nsIDOMFocusListener *)this, nsCOMTypeInfo<nsIDOMFocusListener>::GetIID());
|
||||
|
||||
// get the reciever interface from the select's content
|
||||
nsCOMPtr<nsIDOMEventReceiver> selectReciever(do_QueryInterface(mContent));
|
||||
//nsCOMPtr<nsIDOMEventReceiver> selectReciever(do_QueryInterface(mContent));
|
||||
|
||||
// we shouldn't have to unregister this listener because when
|
||||
// our frame goes away all these content node go away as well
|
||||
|
@ -134,6 +134,7 @@ public:
|
||||
NS_IMETHOD ListWasSelected(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUpdate, PRInt32 aNewIndex);
|
||||
NS_IMETHOD AbsolutelyPositionDropDown();
|
||||
NS_IMETHOD GetAbsoluteRect(nsRect* aRect);
|
||||
|
||||
// nsISelectControlFrame
|
||||
NS_IMETHOD AddOption(PRInt32 index);
|
||||
|
@ -88,6 +88,11 @@ public:
|
||||
*/
|
||||
NS_IMETHOD AbsolutelyPositionDropDown() = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetAbsoluteRect(nsRect* aRect) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@ -2040,7 +2040,16 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||
stateManager->GetEventTarget(&frame);
|
||||
nsCOMPtr<nsIListControlFrame> listFrame(do_QueryInterface(frame));
|
||||
if (listFrame) {
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIDOMUIEvent> uiEvent(do_QueryInterface(aMouseEvent));
|
||||
PRInt32 scrX;
|
||||
PRInt32 scrY;
|
||||
uiEvent->GetScreenX(&scrX);
|
||||
uiEvent->GetScreenY(&scrY);
|
||||
nsRect rect;
|
||||
mComboboxFrame->GetAbsoluteRect(&rect);
|
||||
if (!rect.Contains(scrX, scrY)) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
|
@ -88,6 +88,11 @@ public:
|
||||
*/
|
||||
NS_IMETHOD AbsolutelyPositionDropDown() = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetAbsoluteRect(nsRect* aRect) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@ -601,25 +601,6 @@ nsComboboxControlFrame::GetAbsoluteFramePosition(nsIPresContext& aPresContext,
|
||||
}
|
||||
aAbsoluteTwipsRect.x += viewOffset.x;
|
||||
aAbsoluteTwipsRect.y += viewOffset.y;
|
||||
|
||||
// Addin the containing view's offset form it's containing widget
|
||||
/*nsIWidget* widget = nsnull;
|
||||
nscoord widgetx = 0;
|
||||
nscoord widgety = 0;
|
||||
rv = containingView->GetOffsetFromWidget(&widgetx, &widgety, widget);
|
||||
if (NS_SUCCEEDED(rv) && (nsnull != widget)) {
|
||||
aAbsoluteTwipsRect.x += widgetx;
|
||||
aAbsoluteTwipsRect.y += widgety;
|
||||
|
||||
// Add in the absolute offset of the widget.
|
||||
nsRect absBounds;
|
||||
//XXX: Remove this widget->GetAbsoluteBounds(absBounds);
|
||||
|
||||
// Convert widget coordinates to twips
|
||||
aAbsoluteTwipsRect.x += NSIntPixelsToTwips(absBounds.x, p2t);
|
||||
aAbsoluteTwipsRect.y += NSIntPixelsToTwips(absBounds.y, p2t);
|
||||
NS_RELEASE(widget);
|
||||
}*/
|
||||
}
|
||||
|
||||
// convert to pixel coordinates
|
||||
@ -789,7 +770,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext& aPresContext,
|
||||
|
||||
nsRect absoluteTwips;
|
||||
nsRect absolutePixels;
|
||||
GetAbsoluteFramePosition(aPresContext, displayFrame, absoluteTwips, absolutePixels);
|
||||
GetAbsoluteFramePosition(aPresContext, this, absoluteTwips, absolutePixels);
|
||||
PositionDropdown(aPresContext, aDesiredSize.height, absoluteTwips, absolutePixels);
|
||||
|
||||
return rv;
|
||||
@ -885,21 +866,14 @@ nsComboboxControlFrame::GetFrameName(nsString& aResult) const
|
||||
nsresult
|
||||
nsComboboxControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
/*if (nsFormFrame::GetDisabled(this)) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsRect absoluteTwips;
|
||||
nsRect absolutePixels;
|
||||
nsIFrame * displayFrame = GetDisplayFrame(*mPresContext);
|
||||
nsRect displayRect;
|
||||
// Get the current sizes of the combo box child frames
|
||||
displayFrame->GetRect(displayRect);
|
||||
GetAbsoluteFramePosition(*mPresContext, displayFrame, absoluteTwips, absolutePixels);
|
||||
PositionDropdown(*mPresContext, displayRect.height, absoluteTwips, absolutePixels);
|
||||
|
||||
ToggleList(mPresContext);
|
||||
//mIgnoreMouseUp = PR_TRUE;
|
||||
*/
|
||||
/*PRBool isDroppedDown;
|
||||
IsDroppedDown(&isDroppedDown);
|
||||
if (isDroppedDown) {
|
||||
ShowDropDown(!isDroppedDown);
|
||||
if (isDroppedDown) {
|
||||
mListControlFrame->CaptureMouseEvents(PR_FALSE);
|
||||
}
|
||||
}*/
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -914,14 +888,6 @@ nsComboboxControlFrame::ShowDropDown(PRBool aDoDropDown)
|
||||
}
|
||||
|
||||
if (!mDroppedDown && aDoDropDown) {
|
||||
//nsRect absoluteTwips;
|
||||
//nsRect absolutePixels;
|
||||
//nsIFrame * displayFrame = GetDisplayFrame(*mPresContext);
|
||||
//nsRect displayRect;
|
||||
// Get the current sizes of the combo box child frames
|
||||
//displayFrame->GetRect(displayRect);
|
||||
//GetAbsoluteFramePosition(*mPresContext, displayFrame, absoluteTwips, absolutePixels);
|
||||
//PositionDropdown(*mPresContext, displayRect.height, absoluteTwips, absolutePixels);
|
||||
if (mListControlFrame) {
|
||||
mListControlFrame->SyncViewWithFrame();
|
||||
}
|
||||
@ -1018,12 +984,23 @@ nsComboboxControlFrame::AbsolutelyPositionDropDown()
|
||||
nsRect absolutePixels;
|
||||
nsIFrame* displayFrame = GetDisplayFrame(*mPresContext);
|
||||
nsRect rect;
|
||||
displayFrame->GetRect(rect);
|
||||
GetAbsoluteFramePosition(*mPresContext, displayFrame, absoluteTwips, absolutePixels);
|
||||
this->GetRect(rect);
|
||||
GetAbsoluteFramePosition(*mPresContext, this, absoluteTwips, absolutePixels);
|
||||
PositionDropdown(*mPresContext, rect.height, absoluteTwips, absolutePixels);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::GetAbsoluteRect(nsRect* aRect)
|
||||
{
|
||||
nsRect absoluteTwips;
|
||||
nsRect rect;
|
||||
this->GetRect(rect);
|
||||
GetAbsoluteFramePosition(*mPresContext, this, absoluteTwips, *aRect);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1244,7 +1221,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsISupportsArray& aChildList)
|
||||
//displayReciever->AddEventListenerByIID((nsIDOMFocusListener *)this, nsCOMTypeInfo<nsIDOMFocusListener>::GetIID());
|
||||
|
||||
// get the reciever interface from the select's content
|
||||
nsCOMPtr<nsIDOMEventReceiver> selectReciever(do_QueryInterface(mContent));
|
||||
//nsCOMPtr<nsIDOMEventReceiver> selectReciever(do_QueryInterface(mContent));
|
||||
|
||||
// we shouldn't have to unregister this listener because when
|
||||
// our frame goes away all these content node go away as well
|
||||
|
@ -134,6 +134,7 @@ public:
|
||||
NS_IMETHOD ListWasSelected(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUpdate, PRInt32 aNewIndex);
|
||||
NS_IMETHOD AbsolutelyPositionDropDown();
|
||||
NS_IMETHOD GetAbsoluteRect(nsRect* aRect);
|
||||
|
||||
// nsISelectControlFrame
|
||||
NS_IMETHOD AddOption(PRInt32 index);
|
||||
|
@ -2040,7 +2040,16 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||
stateManager->GetEventTarget(&frame);
|
||||
nsCOMPtr<nsIListControlFrame> listFrame(do_QueryInterface(frame));
|
||||
if (listFrame) {
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIDOMUIEvent> uiEvent(do_QueryInterface(aMouseEvent));
|
||||
PRInt32 scrX;
|
||||
PRInt32 scrY;
|
||||
uiEvent->GetScreenX(&scrX);
|
||||
uiEvent->GetScreenY(&scrY);
|
||||
nsRect rect;
|
||||
mComboboxFrame->GetAbsoluteRect(&rect);
|
||||
if (!rect.Contains(scrX, scrY)) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user