зеркало из https://github.com/mozilla/pjs.git
Bug 64485 [Linux] Intellimouse Explorer Backwards and Forwards button support
patch by sand@blarg.net r=bryner sr=roc
This commit is contained in:
Родитель
eca67f24ba
Коммит
d73b004d73
|
@ -1599,14 +1599,46 @@ nsEventStateManager::ChangeTextSize(PRInt32 change)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsEventStateManager::DoScrollHistory(PRInt32 direction)
|
||||
{
|
||||
nsCOMPtr<nsISupports> pcContainer(mPresContext->GetContainer());
|
||||
if (pcContainer) {
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(pcContainer));
|
||||
if (webNav) {
|
||||
// negative direction to go back one step, nonneg to go forward
|
||||
if (direction < 0)
|
||||
webNav->GoBack();
|
||||
else
|
||||
webNav->GoForward();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsEventStateManager::DoScrollTextsize(nsIFrame *aTargetFrame,
|
||||
PRInt32 adjustment)
|
||||
{
|
||||
// Exclude form controls and XUL content.
|
||||
nsIContent *content = aTargetFrame->GetContent();
|
||||
if (content &&
|
||||
!content->IsContentOfType(nsIContent::eHTML_FORM_CONTROL) &&
|
||||
!content->IsContentOfType(nsIContent::eXUL))
|
||||
{
|
||||
// positive adjustment to increase text size, non-positive to decrease
|
||||
ChangeTextSize((adjustment > 0) ? 1 : -1);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
nsresult
|
||||
nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsMouseScrollEvent* aMSEvent,
|
||||
PRInt32 aNumLines, PRBool aScrollHorizontal, PRBool aScrollPage,
|
||||
PRBool aUseTargetFrame)
|
||||
nsEventStateManager::DoScrollText(nsIPresContext* aPresContext,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsInputEvent* aEvent,
|
||||
PRInt32 aNumLines,
|
||||
PRBool aScrollHorizontal,
|
||||
PRBool aScrollPage,
|
||||
PRBool aUseTargetFrame)
|
||||
{
|
||||
nsCOMPtr<nsIContent> targetContent = aTargetFrame->GetContent();
|
||||
if (!targetContent)
|
||||
|
@ -1633,11 +1665,13 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
mouseEvent->InitMouseEvent(NS_LITERAL_STRING("DOMMouseScroll"), PR_TRUE, PR_TRUE,
|
||||
mouseEvent->InitMouseEvent(NS_LITERAL_STRING("DOMMouseScroll"),
|
||||
PR_TRUE, PR_TRUE,
|
||||
view, aNumLines,
|
||||
aMSEvent->refPoint.x, aMSEvent->refPoint.y,
|
||||
aMSEvent->point.x, aMSEvent->point.y,
|
||||
aMSEvent->isControl, aMSEvent->isAlt, aMSEvent->isShift, aMSEvent->isMeta,
|
||||
aEvent->refPoint.x, aEvent->refPoint.y,
|
||||
aEvent->point.x, aEvent->point.y,
|
||||
aEvent->isControl, aEvent->isAlt,
|
||||
aEvent->isShift, aEvent->isMeta,
|
||||
0, nsnull);
|
||||
PRBool allowDefault;
|
||||
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(targetContent));
|
||||
|
@ -1655,7 +1689,7 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
|
|||
// Create a mouseout event that we fire to the content before
|
||||
// scrolling, to allow tooltips to disappear, etc.
|
||||
|
||||
nsMouseEvent mouseOutEvent(NS_MOUSE_EXIT, aMSEvent->widget);
|
||||
nsMouseEvent mouseOutEvent(NS_MOUSE_EXIT, aEvent->widget);
|
||||
|
||||
nsIPresShell *presShell = aPresContext->PresShell();
|
||||
|
||||
|
@ -1725,8 +1759,9 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
|
|||
return NS_ERROR_FAILURE;
|
||||
nsRect portRect = portView->GetBounds();
|
||||
|
||||
passToParent = aScrollHorizontal ? (xPos + portRect.width >= scrolledSize.width)
|
||||
: (yPos + portRect.height >= scrolledSize.height);
|
||||
passToParent = (aScrollHorizontal ?
|
||||
(xPos + portRect.width >= scrolledSize.width) :
|
||||
(yPos + portRect.height >= scrolledSize.height));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1759,11 +1794,11 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
|
|||
nsIFrame* newFrame = nsnull;
|
||||
nsCOMPtr<nsIPresContext> newPresContext;
|
||||
|
||||
rv = GetParentScrollingView(aMSEvent, aPresContext, newFrame,
|
||||
rv = GetParentScrollingView(aEvent, aPresContext, newFrame,
|
||||
*getter_AddRefs(newPresContext));
|
||||
if (NS_SUCCEEDED(rv) && newFrame)
|
||||
return DoWheelScroll(newPresContext, newFrame, aMSEvent, aNumLines,
|
||||
aScrollHorizontal, aScrollPage, PR_TRUE);
|
||||
return DoScrollText(newPresContext, newFrame, aEvent, aNumLines,
|
||||
aScrollHorizontal, aScrollPage, PR_TRUE);
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1772,7 +1807,7 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsEventStateManager::GetParentScrollingView(nsMouseScrollEvent *aEvent,
|
||||
nsEventStateManager::GetParentScrollingView(nsInputEvent *aEvent,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIFrame* &targetOuterFrame,
|
||||
nsIPresContext* &presCtxOuter)
|
||||
|
@ -1806,7 +1841,7 @@ nsEventStateManager::GetParentScrollingView(nsMouseScrollEvent *aEvent,
|
|||
get this content node's frame, and use it as the new event target,
|
||||
so the event can be processed in the parent docshell.
|
||||
Note that we don't actually need to translate the event coordinates
|
||||
because they are not used by DoWheelScroll().
|
||||
because they are not used by DoScrollText().
|
||||
*/
|
||||
|
||||
nsIFrame* frameFrame = nsnull;
|
||||
|
@ -1958,56 +1993,60 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
|
|||
rv = getPrefBranch();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Build the preference keys, based on the event properties.
|
||||
nsMouseScrollEvent *msEvent = (nsMouseScrollEvent*) aEvent;
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(prefbase, "mousewheel");
|
||||
NS_NAMED_LITERAL_CSTRING(horizscroll, ".horizscroll");
|
||||
NS_NAMED_LITERAL_CSTRING(withshift, ".withshiftkey");
|
||||
NS_NAMED_LITERAL_CSTRING(withalt, ".withaltkey");
|
||||
NS_NAMED_LITERAL_CSTRING(withcontrol, ".withcontrolkey");
|
||||
NS_NAMED_LITERAL_CSTRING(withno, ".withnokey");
|
||||
NS_NAMED_LITERAL_CSTRING(actionslot, ".action");
|
||||
NS_NAMED_LITERAL_CSTRING(numlinesslot, ".numlines");
|
||||
NS_NAMED_LITERAL_CSTRING(sysnumlinesslot, ".sysnumlines");
|
||||
|
||||
nsCAutoString baseKey(prefbase);
|
||||
if (msEvent->scrollFlags & nsMouseScrollEvent::kIsHorizontal) {
|
||||
baseKey.Append(horizscroll);
|
||||
}
|
||||
if (msEvent->isShift) {
|
||||
baseKey.Append(withshift);
|
||||
} else if (msEvent->isControl) {
|
||||
baseKey.Append(withcontrol);
|
||||
} else if (msEvent->isAlt) {
|
||||
baseKey.Append(withalt);
|
||||
} else {
|
||||
baseKey.Append(withno);
|
||||
}
|
||||
|
||||
// Extract the preferences
|
||||
nsCAutoString actionKey(baseKey);
|
||||
actionKey.Append(actionslot);
|
||||
|
||||
nsCAutoString sysNumLinesKey(baseKey);
|
||||
sysNumLinesKey.Append(sysnumlinesslot);
|
||||
|
||||
PRInt32 action = 0;
|
||||
PRInt32 numLines = 0;
|
||||
PRBool aBool;
|
||||
if (msEvent->isShift) {
|
||||
mPrefBranch->GetIntPref("mousewheel.withshiftkey.action", &action);
|
||||
mPrefBranch->GetBoolPref("mousewheel.withshiftkey.sysnumlines",
|
||||
&aBool);
|
||||
if (aBool) {
|
||||
numLines = msEvent->delta;
|
||||
if (msEvent->scrollFlags & nsMouseScrollEvent::kIsFullPage)
|
||||
action = MOUSE_SCROLL_PAGE;
|
||||
}
|
||||
else
|
||||
mPrefBranch->GetIntPref("mousewheel.withshiftkey.numlines",
|
||||
&numLines);
|
||||
} else if (msEvent->isControl) {
|
||||
mPrefBranch->GetIntPref("mousewheel.withcontrolkey.action", &action);
|
||||
mPrefBranch->GetBoolPref("mousewheel.withcontrolkey.sysnumlines",
|
||||
&aBool);
|
||||
if (aBool) {
|
||||
numLines = msEvent->delta;
|
||||
if (msEvent->scrollFlags & nsMouseScrollEvent::kIsFullPage)
|
||||
action = MOUSE_SCROLL_PAGE;
|
||||
}
|
||||
else
|
||||
mPrefBranch->GetIntPref("mousewheel.withcontrolkey.numlines",
|
||||
&numLines);
|
||||
} else if (msEvent->isAlt) {
|
||||
mPrefBranch->GetIntPref("mousewheel.withaltkey.action", &action);
|
||||
mPrefBranch->GetBoolPref("mousewheel.withaltkey.sysnumlines", &aBool);
|
||||
if (aBool) {
|
||||
numLines = msEvent->delta;
|
||||
if (msEvent->scrollFlags & nsMouseScrollEvent::kIsFullPage)
|
||||
action = MOUSE_SCROLL_PAGE;
|
||||
}
|
||||
else
|
||||
mPrefBranch->GetIntPref("mousewheel.withaltkey.numlines",
|
||||
&numLines);
|
||||
} else {
|
||||
mPrefBranch->GetIntPref("mousewheel.withnokey.action", &action);
|
||||
mPrefBranch->GetBoolPref("mousewheel.withnokey.sysnumlines", &aBool);
|
||||
if (aBool) {
|
||||
numLines = msEvent->delta;
|
||||
if (msEvent->scrollFlags & nsMouseScrollEvent::kIsFullPage)
|
||||
action = MOUSE_SCROLL_PAGE;
|
||||
}
|
||||
else
|
||||
mPrefBranch->GetIntPref("mousewheel.withnokey.numlines", &numLines);
|
||||
PRBool useSysNumLines;
|
||||
|
||||
mPrefBranch->GetIntPref(PromiseFlatCString(actionKey).get(), &action);
|
||||
mPrefBranch->GetBoolPref(PromiseFlatCString(sysNumLinesKey).get(),
|
||||
&useSysNumLines);
|
||||
if (useSysNumLines) {
|
||||
numLines = msEvent->delta;
|
||||
if (msEvent->scrollFlags & nsMouseScrollEvent::kIsFullPage)
|
||||
action = MOUSE_SCROLL_PAGE;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCAutoString numLinesKey(baseKey);
|
||||
numLinesKey.Append(numlinesslot);
|
||||
|
||||
mPrefBranch->GetIntPref(PromiseFlatCString(numLinesKey).get(),
|
||||
&numLines);
|
||||
}
|
||||
|
||||
if ((msEvent->delta < 0) && (numLines > 0))
|
||||
numLines = -numLines;
|
||||
|
@ -2016,41 +2055,27 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
|
|||
case MOUSE_SCROLL_N_LINES:
|
||||
case MOUSE_SCROLL_PAGE:
|
||||
{
|
||||
DoWheelScroll(aPresContext, aTargetFrame, msEvent, numLines,
|
||||
(msEvent->scrollFlags & nsMouseScrollEvent::kIsHorizontal),
|
||||
(action == MOUSE_SCROLL_PAGE), PR_FALSE);
|
||||
|
||||
DoScrollText(aPresContext, aTargetFrame, msEvent, numLines,
|
||||
(msEvent->scrollFlags & nsMouseScrollEvent::kIsHorizontal),
|
||||
(action == MOUSE_SCROLL_PAGE), PR_FALSE);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MOUSE_SCROLL_HISTORY:
|
||||
{
|
||||
nsCOMPtr<nsISupports> pcContainer = mPresContext->GetContainer();
|
||||
if (pcContainer) {
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(pcContainer));
|
||||
if (webNav) {
|
||||
if (msEvent->delta > 0)
|
||||
webNav->GoBack();
|
||||
else
|
||||
webNav->GoForward();
|
||||
}
|
||||
}
|
||||
DoScrollHistory(numLines);
|
||||
}
|
||||
break;
|
||||
|
||||
case MOUSE_SCROLL_TEXTSIZE:
|
||||
{
|
||||
// Exclude form controls and XUL content.
|
||||
nsIContent* content = aTargetFrame->GetContent();
|
||||
if (content &&
|
||||
!content->IsContentOfType(nsIContent::eHTML_FORM_CONTROL) &&
|
||||
!content->IsContentOfType(nsIContent::eXUL))
|
||||
{
|
||||
ChangeTextSize((msEvent->delta > 0) ? 1 : -1);
|
||||
}
|
||||
DoScrollTextsize(aTargetFrame, numLines);
|
||||
}
|
||||
break;
|
||||
|
||||
default: // Including -1 (do nothing)
|
||||
break;
|
||||
}
|
||||
*aStatus = nsEventStatus_eConsumeNoDefault;
|
||||
|
||||
|
|
|
@ -209,16 +209,21 @@ protected:
|
|||
|
||||
// These functions are for mousewheel scrolling
|
||||
nsIScrollableView* GetNearestScrollingView(nsIView* aView);
|
||||
nsresult GetParentScrollingView(nsMouseScrollEvent* aEvent,
|
||||
nsresult GetParentScrollingView(nsInputEvent* aEvent,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIFrame* &targetOuterFrame,
|
||||
nsIPresContext* &presCtxOuter);
|
||||
nsresult DoWheelScroll(nsIPresContext* aPresContext,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsMouseScrollEvent* aMSEvent, PRInt32 aNumLines,
|
||||
PRBool aScrollHorizontal, PRBool aScrollPage, PRBool aUseTargetFrame);
|
||||
nsresult DoScrollText(nsIPresContext* aPresContext,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsInputEvent* aEvent,
|
||||
PRInt32 aNumLines,
|
||||
PRBool aScrollHorizontal,
|
||||
PRBool aScrollPage,
|
||||
PRBool aUseTargetFrame);
|
||||
void ForceViewUpdate(nsIView* aView);
|
||||
nsresult getPrefBranch();
|
||||
void DoScrollHistory(PRInt32 direction);
|
||||
void DoScrollTextsize(nsIFrame *aTargetFrame, PRInt32 adjustment);
|
||||
nsresult ChangeTextSize(PRInt32 change);
|
||||
// end mousewheel functions
|
||||
|
||||
|
|
|
@ -681,6 +681,18 @@ pref("mousewheel.withshiftkey.sysnumlines",false);
|
|||
pref("mousewheel.withaltkey.action",2);
|
||||
pref("mousewheel.withaltkey.numlines",1);
|
||||
pref("mousewheel.withaltkey.sysnumlines",false);
|
||||
pref("mousewheel.horizscroll.withnokey.action",2);
|
||||
pref("mousewheel.horizscroll.withnokey.numlines",-1);
|
||||
pref("mousewheel.horizscroll.withnokey.sysnumlines",true);
|
||||
pref("mousewheel.horizscroll.withcontrolkey.action",0);
|
||||
pref("mousewheel.horizscroll.withcontrolkey.numlines",1);
|
||||
pref("mousewheel.horizscroll.withcontrolkey.sysnumlines",true);
|
||||
pref("mousewheel.horizscroll.withshiftkey.action",0);
|
||||
pref("mousewheel.horizscroll.withshiftkey.numlines",1);
|
||||
pref("mousewheel.horizscroll.withshiftkey.sysnumlines",false);
|
||||
pref("mousewheel.horizscroll.withaltkey.action",2);
|
||||
pref("mousewheel.horizscroll.withaltkey.numlines",-1);
|
||||
pref("mousewheel.horizscroll.withaltkey.sysnumlines",false);
|
||||
|
||||
pref("profile.confirm_automigration",true);
|
||||
// profile.migration_behavior determines how the profiles root is set
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Andrew Wellington <proton@wiretapped.net>
|
||||
* Graham Dennis <u3952328@anu.edu.au>
|
||||
*
|
||||
* 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
|
||||
|
@ -1851,8 +1853,14 @@ nsWidget::OnButtonPressSignal(GdkEventButton * aGdkButtonEvent)
|
|||
|
||||
case 4:
|
||||
case 5:
|
||||
scrollEvent.scrollFlags = nsMouseScrollEvent::kIsVertical;
|
||||
if (aGdkButtonEvent->button == 4)
|
||||
case 6:
|
||||
case 7:
|
||||
if (aGdkButtonEvent->button == 4 || aGdkButtonEvent->button == 5)
|
||||
scrollEvent.scrollFlags = nsMouseScrollEvent::kIsVertical;
|
||||
else
|
||||
scrollEvent.scrollFlags = nsMouseScrollEvent::kIsHorizontal;
|
||||
|
||||
if (aGdkButtonEvent->button == 4 || aGdkButtonEvent->button == 6)
|
||||
scrollEvent.delta = -3;
|
||||
else
|
||||
scrollEvent.delta = 3;
|
||||
|
@ -1938,6 +1946,8 @@ nsWidget::OnButtonReleaseSignal(GdkEventButton * aGdkButtonEvent)
|
|||
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
// We don't really need to do anything here, but we don't want
|
||||
// LEFT_BUTTON_UP to happen
|
||||
return;
|
||||
|
|
Загрузка…
Ссылка в новой задаче