mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-07-20 22:19:49 +00:00
c7f8abfdb0
- Show APZ wheel support in about:support on Mac OS X. (bug 1155881, r=mstange) (57d9cf325) - Bug 1153603 - SMIL/SVG event type-> Event Handler mapping shouldn't affect to Event.type. r=heycam (d9e552735) - Bug 1145910 - Cross ShadowRoot boundary when updating ancestor state in event state manager. r=smaug (69f2b8ca0) - Don't route wheel events through APZ if they require custom deltas. (bug 1146674, r=kats) (fc3c488f7) - Bug 969250 - Part 1: Implement scroll snapping for scrollbars (v7 Patch),r=roc (6b9a9e6cd) - Bug 1150308 - Use flattened tree parent when settings event state on ancestors. r=smaug (f3cd95474) - Fix wheel events being misrouted in APZ-less widgets when APZ is enabled. (bug 1154734, r=kats) (a3b6db5ef) - Bug 1018639 - Reset the cursor on WM_SETCURSOR message when pointer is over content. r=jimm (86523f46d) - Bug 1151136 - Always initialize the aSeqno result from TabParent::RecvNotifyIMEFocus. r=masayuki (5136a9699) - Bug 1121905 - Reorder frame loading sequence to send content process the URL earlier. r=kanru (3ee7d41da) - Bug 1088180 - Swap nsIBrowserDOMWindows when swapping remote frame loaders. r=smaug. (4885fbe74) - Bug 1127727 - Swap callbacks in the Compositor when dragging tabs between windows. r=billm (7ce3217fd) - Bug 1132072 - Handle RequestNotifyLayerTreeReady when RenderFrameParent not ready (r=dvander) (76055c0ab) - Bug 1018639 - Maintain separate cursors in chrome and client processes. r=roc (f3a1dfdbd) - Bug 1155207 - Change comparison of warning with aTargetContent and aTargetFrame. r=smaug (a544f2bca) - Bug 1083365 - Tag NS_MOUSE_EXIT messages as eTopLevel when sending to child process. (r=smaug) (a05a10f98) - Bug 1134245 - Improve formatting of devicemanager getInfo() data; r=bc (2b98e7571) - Bug 1137339 - [manifestparser] implement a chunk_by_runtime filter, r=jmaher (8cfbeaa79) - Bug 1131098 - Make mochitest use manifestparser's chunking algorithms and remove JS based ones, r=jmaher (669f8f37a) - Bug 1142050 - Add --chunk-by-runtime option to mochitest, r=jmaher (53fc49915) - Bug 1146871 - Make xpcshell use manifestparser's chunking algorithm, r=jmaher (16be8981e) - Bug 987360 - Add ability to tag tests with arbitrary strings and run them, r=chmanchester (e7e8187c9) - goanna -> gecko (df1f2be50) - Bug 1147129 - upgrade mochitest from optparse to argparse and move android cli to mochitest_options.py, r=chmanchester (e979c6a56) - Bug 1147283 - Replace mozpack.path with mozpath. r=mshal (98737f234) - Bug 1046992 - Consolidate desktop/b2g/b2g desktop mochitest mach commands, r=gbrown (7f9c7cf81) - Bug 1152864 - Disable unsafe CPOW warnings when running mochitests by default, and add option to re-enable. r=ahal. (42e0bb9e1) - Bug 1152864 - Add DISABLE_UNSAFE_CPOW_WARNINGS environment variable for our test harnesses. r=jimm. (90ecb1b50) - Bug 1154396 - Remove a debug printf in plugin code. No bug. r=jimm (c31b2b3af) - Bug 1138520 - Diagnostic patch for shutdown hangs (r=jchen) (626eed2d1) - Bug 1138520 follow-up: Fix the build bustage on configurations that disable the crash reporter (97d2d79b2)
295 lines
8.1 KiB
C++
295 lines
8.1 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
//
|
|
// Eric Vaughan
|
|
// Netscape Communications
|
|
//
|
|
// See documentation in associated header file
|
|
//
|
|
|
|
#include "nsScrollbarButtonFrame.h"
|
|
#include "nsPresContext.h"
|
|
#include "nsIContent.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsNameSpaceManager.h"
|
|
#include "nsGkAtoms.h"
|
|
#include "nsSliderFrame.h"
|
|
#include "nsScrollbarFrame.h"
|
|
#include "nsIScrollbarMediator.h"
|
|
#include "nsRepeatService.h"
|
|
#include "mozilla/LookAndFeel.h"
|
|
#include "mozilla/MouseEvents.h"
|
|
|
|
using namespace mozilla;
|
|
|
|
//
|
|
// NS_NewToolbarFrame
|
|
//
|
|
// Creates a new Toolbar frame and returns it
|
|
//
|
|
nsIFrame*
|
|
NS_NewScrollbarButtonFrame (nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
{
|
|
return new (aPresShell) nsScrollbarButtonFrame(aContext);
|
|
}
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsScrollbarButtonFrame)
|
|
|
|
nsresult
|
|
nsScrollbarButtonFrame::HandleEvent(nsPresContext* aPresContext,
|
|
WidgetGUIEvent* aEvent,
|
|
nsEventStatus* aEventStatus)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
|
|
|
// If a web page calls event.preventDefault() we still want to
|
|
// scroll when scroll arrow is clicked. See bug 511075.
|
|
if (!mContent->IsInNativeAnonymousSubtree() &&
|
|
nsEventStatus_eConsumeNoDefault == *aEventStatus) {
|
|
return NS_OK;
|
|
}
|
|
|
|
switch (aEvent->message) {
|
|
case NS_MOUSE_BUTTON_DOWN:
|
|
mCursorOnThis = true;
|
|
// if we didn't handle the press ourselves, pass it on to the superclass
|
|
if (HandleButtonPress(aPresContext, aEvent, aEventStatus)) {
|
|
return NS_OK;
|
|
}
|
|
break;
|
|
case NS_MOUSE_BUTTON_UP:
|
|
HandleRelease(aPresContext, aEvent, aEventStatus);
|
|
break;
|
|
case NS_MOUSE_EXIT_SYNTH:
|
|
mCursorOnThis = false;
|
|
break;
|
|
case NS_MOUSE_MOVE: {
|
|
nsPoint cursor =
|
|
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
|
|
nsRect frameRect(nsPoint(0, 0), GetSize());
|
|
mCursorOnThis = frameRect.Contains(cursor);
|
|
break;
|
|
}
|
|
}
|
|
|
|
return nsButtonBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
|
}
|
|
|
|
bool
|
|
nsScrollbarButtonFrame::HandleButtonPress(nsPresContext* aPresContext,
|
|
WidgetGUIEvent* aEvent,
|
|
nsEventStatus* aEventStatus)
|
|
{
|
|
// Get the desired action for the scrollbar button.
|
|
LookAndFeel::IntID tmpAction;
|
|
uint16_t button = aEvent->AsMouseEvent()->button;
|
|
if (button == WidgetMouseEvent::eLeftButton) {
|
|
tmpAction = LookAndFeel::eIntID_ScrollButtonLeftMouseButtonAction;
|
|
} else if (button == WidgetMouseEvent::eMiddleButton) {
|
|
tmpAction = LookAndFeel::eIntID_ScrollButtonMiddleMouseButtonAction;
|
|
} else if (button == WidgetMouseEvent::eRightButton) {
|
|
tmpAction = LookAndFeel::eIntID_ScrollButtonRightMouseButtonAction;
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
// Get the button action metric from the pres. shell.
|
|
int32_t pressedButtonAction;
|
|
if (NS_FAILED(LookAndFeel::GetInt(tmpAction, &pressedButtonAction))) {
|
|
return false;
|
|
}
|
|
|
|
// get the scrollbar control
|
|
nsIFrame* scrollbar;
|
|
GetParentWithTag(nsGkAtoms::scrollbar, this, scrollbar);
|
|
|
|
if (scrollbar == nullptr)
|
|
return false;
|
|
|
|
static nsIContent::AttrValuesArray strings[] = { &nsGkAtoms::increment,
|
|
&nsGkAtoms::decrement,
|
|
nullptr };
|
|
int32_t index = mContent->FindAttrValueIn(kNameSpaceID_None,
|
|
nsGkAtoms::type,
|
|
strings, eCaseMatters);
|
|
int32_t direction;
|
|
if (index == 0)
|
|
direction = 1;
|
|
else if (index == 1)
|
|
direction = -1;
|
|
else
|
|
return false;
|
|
|
|
bool repeat = pressedButtonAction != 2;
|
|
// set this attribute so we can style it later
|
|
nsWeakFrame weakFrame(this);
|
|
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::active, NS_LITERAL_STRING("true"), true);
|
|
|
|
nsIPresShell::SetCapturingContent(mContent, CAPTURE_IGNOREALLOWED);
|
|
|
|
if (!weakFrame.IsAlive()) {
|
|
return false;
|
|
}
|
|
|
|
nsScrollbarFrame* sb = do_QueryFrame(scrollbar);
|
|
if (sb) {
|
|
nsIScrollbarMediator* m = sb->GetScrollbarMediator();
|
|
switch (pressedButtonAction) {
|
|
case 0:
|
|
sb->SetIncrementToLine(direction);
|
|
if (m) {
|
|
m->ScrollByLine(sb, direction, nsIScrollbarMediator::ENABLE_SNAP);
|
|
}
|
|
break;
|
|
case 1:
|
|
sb->SetIncrementToPage(direction);
|
|
if (m) {
|
|
m->ScrollByPage(sb, direction, nsIScrollbarMediator::ENABLE_SNAP);
|
|
}
|
|
break;
|
|
case 2:
|
|
sb->SetIncrementToWhole(direction);
|
|
if (m) {
|
|
m->ScrollByWhole(sb, direction, nsIScrollbarMediator::ENABLE_SNAP);
|
|
}
|
|
break;
|
|
case 3:
|
|
default:
|
|
// We were told to ignore this click, or someone assigned a non-standard
|
|
// value to the button's action.
|
|
return false;
|
|
}
|
|
if (!weakFrame.IsAlive()) {
|
|
return false;
|
|
}
|
|
if (!m) {
|
|
sb->MoveToNewPosition();
|
|
if (!weakFrame.IsAlive()) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
if (repeat) {
|
|
StartRepeat();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsScrollbarButtonFrame::HandleRelease(nsPresContext* aPresContext,
|
|
WidgetGUIEvent* aEvent,
|
|
nsEventStatus* aEventStatus)
|
|
{
|
|
nsIPresShell::SetCapturingContent(nullptr, 0);
|
|
// we're not active anymore
|
|
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::active, true);
|
|
StopRepeat();
|
|
nsIFrame* scrollbar;
|
|
GetParentWithTag(nsGkAtoms::scrollbar, this, scrollbar);
|
|
nsScrollbarFrame* sb = do_QueryFrame(scrollbar);
|
|
if (sb) {
|
|
nsIScrollbarMediator* m = sb->GetScrollbarMediator();
|
|
if (m) {
|
|
m->ScrollbarReleased(sb);
|
|
}
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
void nsScrollbarButtonFrame::Notify()
|
|
{
|
|
if (mCursorOnThis ||
|
|
LookAndFeel::GetInt(
|
|
LookAndFeel::eIntID_ScrollbarButtonAutoRepeatBehavior, 0)) {
|
|
// get the scrollbar control
|
|
nsIFrame* scrollbar;
|
|
GetParentWithTag(nsGkAtoms::scrollbar, this, scrollbar);
|
|
nsScrollbarFrame* sb = do_QueryFrame(scrollbar);
|
|
if (sb) {
|
|
nsIScrollbarMediator* m = sb->GetScrollbarMediator();
|
|
if (m) {
|
|
m->RepeatButtonScroll(sb);
|
|
} else {
|
|
sb->MoveToNewPosition();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
nsScrollbarButtonFrame::MouseClicked(nsPresContext* aPresContext,
|
|
WidgetGUIEvent* aEvent)
|
|
{
|
|
nsButtonBoxFrame::MouseClicked(aPresContext, aEvent);
|
|
//MouseClicked();
|
|
}
|
|
|
|
nsresult
|
|
nsScrollbarButtonFrame::GetChildWithTag(nsPresContext* aPresContext,
|
|
nsIAtom* atom, nsIFrame* start,
|
|
nsIFrame*& result)
|
|
{
|
|
// recursively search our children
|
|
nsIFrame* childFrame = start->GetFirstPrincipalChild();
|
|
while (nullptr != childFrame)
|
|
{
|
|
// get the content node
|
|
nsIContent* child = childFrame->GetContent();
|
|
|
|
if (child) {
|
|
// see if it is the child
|
|
if (child->IsXULElement(atom))
|
|
{
|
|
result = childFrame;
|
|
|
|
return NS_OK;
|
|
}
|
|
}
|
|
|
|
// recursive search the child
|
|
GetChildWithTag(aPresContext, atom, childFrame, result);
|
|
if (result != nullptr)
|
|
return NS_OK;
|
|
|
|
childFrame = childFrame->GetNextSibling();
|
|
}
|
|
|
|
result = nullptr;
|
|
return NS_OK;
|
|
}
|
|
|
|
nsresult
|
|
nsScrollbarButtonFrame::GetParentWithTag(nsIAtom* toFind, nsIFrame* start,
|
|
nsIFrame*& result)
|
|
{
|
|
while (start)
|
|
{
|
|
start = start->GetParent();
|
|
|
|
if (start) {
|
|
// get the content node
|
|
nsIContent* child = start->GetContent();
|
|
|
|
if (child && child->IsXULElement(toFind)) {
|
|
result = start;
|
|
return NS_OK;
|
|
}
|
|
}
|
|
}
|
|
|
|
result = nullptr;
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
nsScrollbarButtonFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
|
{
|
|
// Ensure our repeat service isn't going... it's possible that a scrollbar can disappear out
|
|
// from under you while you're in the process of scrolling.
|
|
StopRepeat();
|
|
nsButtonBoxFrame::DestroyFrom(aDestructRoot);
|
|
}
|