2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
1999-04-21 01:39:52 +04:00
|
|
|
|
1999-06-15 08:02:43 +04:00
|
|
|
//
|
|
|
|
// Eric Vaughan
|
|
|
|
// Netscape Communications
|
|
|
|
//
|
|
|
|
// See documentation in associated header file
|
|
|
|
//
|
1999-04-21 01:39:52 +04:00
|
|
|
|
1999-04-21 01:43:09 +04:00
|
|
|
#include "nsSliderFrame.h"
|
2016-03-08 00:25:00 +03:00
|
|
|
|
|
|
|
#include "gfxPrefs.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1999-06-15 08:02:43 +04:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1999-06-15 08:02:43 +04:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsCSSRendering.h"
|
2016-03-18 21:46:54 +03:00
|
|
|
#include "nsIDOMEvent.h"
|
1999-11-03 10:11:45 +03:00
|
|
|
#include "nsIDOMMouseEvent.h"
|
1999-06-15 08:02:43 +04:00
|
|
|
#include "nsScrollbarButtonFrame.h"
|
2009-01-14 21:21:58 +03:00
|
|
|
#include "nsISliderListener.h"
|
2015-09-29 00:00:25 +03:00
|
|
|
#include "nsIScrollableFrame.h"
|
2000-06-07 03:13:05 +04:00
|
|
|
#include "nsIScrollbarMediator.h"
|
2016-03-18 21:46:54 +03:00
|
|
|
#include "nsISupportsImpl.h"
|
2011-07-11 18:05:09 +04:00
|
|
|
#include "nsScrollbarFrame.h"
|
1999-08-20 02:16:23 +04:00
|
|
|
#include "nsRepeatService.h"
|
2000-03-31 11:02:06 +04:00
|
|
|
#include "nsBoxLayoutState.h"
|
2000-05-23 03:23:04 +04:00
|
|
|
#include "nsSprocketLayout.h"
|
2000-06-03 06:07:52 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2004-04-30 03:34:19 +04:00
|
|
|
#include "nsContentUtils.h"
|
2005-08-23 07:57:07 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2017-01-04 21:42:36 +03:00
|
|
|
#include "nsRefreshDriver.h" // for nsAPostRefreshObserver
|
2016-03-18 21:46:54 +03:00
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT
|
2011-05-25 10:31:59 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2011-09-09 06:27:13 +04:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2013-09-25 15:21:18 +04:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2016-02-06 00:21:54 +03:00
|
|
|
#include "mozilla/Telemetry.h"
|
2016-03-18 21:46:54 +03:00
|
|
|
#include "mozilla/layers/APZCCallbackHelper.h"
|
2015-09-29 00:00:25 +03:00
|
|
|
#include "mozilla/layers/AsyncDragMetrics.h"
|
|
|
|
#include "mozilla/layers/InputAPZContext.h"
|
2016-02-06 00:21:54 +03:00
|
|
|
#include "mozilla/layers/ScrollInputMethods.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2011-05-25 10:31:59 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2016-03-18 21:46:54 +03:00
|
|
|
using mozilla::layers::APZCCallbackHelper;
|
2015-09-29 00:00:25 +03:00
|
|
|
using mozilla::layers::AsyncDragMetrics;
|
|
|
|
using mozilla::layers::InputAPZContext;
|
2016-02-06 00:21:54 +03:00
|
|
|
using mozilla::layers::ScrollInputMethod;
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsSliderFrame::gMiddlePref = false;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t nsSliderFrame::gSnapMultiplier;
|
2004-01-27 08:19:57 +03:00
|
|
|
|
2002-11-27 00:38:18 +03:00
|
|
|
// Turn this on if you want to debug slider frames.
|
|
|
|
#undef DEBUG_SLIDER
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2003-06-02 06:39:26 +04:00
|
|
|
static already_AddRefed<nsIContent>
|
2012-08-06 07:00:57 +04:00
|
|
|
GetContentOfBox(nsIFrame *aBox)
|
2003-06-02 06:39:26 +04:00
|
|
|
{
|
2013-04-22 15:15:59 +04:00
|
|
|
nsCOMPtr<nsIContent> content = aBox->GetContent();
|
|
|
|
return content.forget();
|
2003-06-02 06:39:26 +04:00
|
|
|
}
|
|
|
|
|
2005-10-27 01:46:39 +04:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewSliderFrame (nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-04-21 01:39:52 +04:00
|
|
|
{
|
2015-01-06 12:27:56 +03:00
|
|
|
return new (aPresShell) nsSliderFrame(aContext);
|
2009-09-12 20:49:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSliderFrame)
|
1999-04-21 01:39:52 +04:00
|
|
|
|
2014-02-05 05:30:34 +04:00
|
|
|
NS_QUERYFRAME_HEAD(nsSliderFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsSliderFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame)
|
|
|
|
|
2015-01-06 12:27:56 +03:00
|
|
|
nsSliderFrame::nsSliderFrame(nsStyleContext* aContext):
|
|
|
|
nsBoxFrame(aContext),
|
2016-12-01 11:06:50 +03:00
|
|
|
mRatio(0.0f),
|
2006-03-27 01:30:36 +04:00
|
|
|
mCurPos(0),
|
2009-01-14 21:21:58 +03:00
|
|
|
mChange(0),
|
2014-08-04 09:00:00 +04:00
|
|
|
mDragFinished(true),
|
2015-10-26 23:06:49 +03:00
|
|
|
mUserChanged(false),
|
2016-03-18 21:46:54 +03:00
|
|
|
mScrollingWithAPZ(false),
|
|
|
|
mSuppressionActive(false)
|
1999-04-21 01:39:52 +04:00
|
|
|
{
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
1999-04-21 01:39:52 +04:00
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
// stop timer
|
|
|
|
nsSliderFrame::~nsSliderFrame()
|
|
|
|
{
|
2016-03-18 21:46:54 +03:00
|
|
|
if (mSuppressionActive) {
|
|
|
|
APZCCallbackHelper::SuppressDisplayport(false, PresContext() ?
|
|
|
|
PresContext()->PresShell() :
|
|
|
|
nullptr);
|
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2014-05-25 02:20:40 +04:00
|
|
|
nsSliderFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1999-04-21 01:39:52 +04:00
|
|
|
{
|
2013-03-20 05:47:48 +04:00
|
|
|
nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
|
2001-07-15 04:05:20 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool gotPrefs = false;
|
2004-01-27 08:19:57 +03:00
|
|
|
if (!gotPrefs) {
|
2011-10-17 18:59:28 +04:00
|
|
|
gotPrefs = true;
|
2004-04-30 03:34:19 +04:00
|
|
|
|
2011-05-25 10:31:59 +04:00
|
|
|
gMiddlePref = Preferences::GetBool("middlemouse.scrollbarPosition");
|
2011-05-25 10:32:00 +04:00
|
|
|
gSnapMultiplier = Preferences::GetInt("slider.snapMultiplier");
|
2001-07-19 03:19:42 +04:00
|
|
|
}
|
2000-06-03 06:07:52 +04:00
|
|
|
|
2009-05-04 18:55:41 +04:00
|
|
|
mCurPos = GetCurrentPosition(aContent);
|
1999-04-21 01:39:52 +04:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsSliderFrame::RemoveFrame(ChildListID aListID,
|
2005-02-07 04:58:25 +03:00
|
|
|
nsIFrame* aOldFrame)
|
2001-01-11 04:56:27 +03:00
|
|
|
{
|
2014-05-28 23:36:58 +04:00
|
|
|
nsBoxFrame::RemoveFrame(aListID, aOldFrame);
|
2007-05-23 07:48:43 +04:00
|
|
|
if (mFrames.IsEmpty())
|
2001-01-11 04:56:27 +03:00
|
|
|
RemoveListener();
|
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsSliderFrame::InsertFrames(ChildListID aListID,
|
2005-02-07 04:58:25 +03:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2001-01-11 04:56:27 +03:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool wasEmpty = mFrames.IsEmpty();
|
2014-05-28 23:36:58 +04:00
|
|
|
nsBoxFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
|
2007-05-23 07:48:43 +04:00
|
|
|
if (wasEmpty)
|
2001-01-11 04:56:27 +03:00
|
|
|
AddListener();
|
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsSliderFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2001-01-11 04:56:27 +03:00
|
|
|
{
|
|
|
|
// if we have no children and on was added then make sure we add the
|
|
|
|
// listener
|
2011-09-29 10:19:26 +04:00
|
|
|
bool wasEmpty = mFrames.IsEmpty();
|
2014-05-28 23:36:58 +04:00
|
|
|
nsBoxFrame::AppendFrames(aListID, aFrameList);
|
2007-05-23 07:48:43 +04:00
|
|
|
if (wasEmpty)
|
2001-01-11 04:56:27 +03:00
|
|
|
AddListener();
|
2001-07-15 04:05:20 +04:00
|
|
|
}
|
2001-01-11 04:56:27 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
1999-06-15 08:02:43 +04:00
|
|
|
nsSliderFrame::GetCurrentPosition(nsIContent* content)
|
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return GetIntegerAttribute(content, nsGkAtoms::curpos, 0);
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
2006-05-30 17:50:48 +04:00
|
|
|
nsSliderFrame::GetMinPosition(nsIContent* content)
|
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return GetIntegerAttribute(content, nsGkAtoms::minpos, 0);
|
2006-05-30 17:50:48 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
1999-06-15 08:02:43 +04:00
|
|
|
nsSliderFrame::GetMaxPosition(nsIContent* content)
|
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return GetIntegerAttribute(content, nsGkAtoms::maxpos, 100);
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
1999-06-15 08:02:43 +04:00
|
|
|
nsSliderFrame::GetIncrement(nsIContent* content)
|
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return GetIntegerAttribute(content, nsGkAtoms::increment, 1);
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
1999-06-15 08:02:43 +04:00
|
|
|
nsSliderFrame::GetPageIncrement(nsIContent* content)
|
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return GetIntegerAttribute(content, nsGkAtoms::pageincrement, 10);
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
|
|
|
nsSliderFrame::GetIntegerAttribute(nsIContent* content, nsIAtom* atom, int32_t defaultValue)
|
1999-06-15 08:02:43 +04:00
|
|
|
{
|
Landing changes Vidur made while the tree was closed for beta1 work, here's a list of the changes. r=me
[1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner
[2] Cutting down the size of content. Made nsITextContent inherit from nsIContent.
[3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done.
dom/public/nsDOMPropEnums.h,v - bug 12559
dom/public/nsIJSScriptObject.h,v - [1]
dom/public/html/MANIFEST,v - bug 12559
dom/public/html/Makefile.in,v - bug 12559
dom/public/html/makefile.win,v - bug 12559
dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544
dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559
dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559
dom/public/idl/html/HTMLInputElement.idl,v - bug 17544
dom/src/base/nsGlobalWindow.cpp,v - bug 30700
dom/src/base/nsGlobalWindow.h,v - [1]
dom/src/base/nsLocation.cpp,v - [1]
dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544
layout/base/public/nsIDocument.h,v - bug 27953
layout/base/public/nsITextContent.h,v - [2]
layout/base/src/nsCommentNode.cpp,v - [2]
layout/base/src/nsDocument.cpp,v - bug 27953
layout/base/src/nsDocument.h,v - bug 27953
layout/base/src/nsDocumentViewer.cpp,v - bug 27953
layout/base/src/nsGenericDOMDataNode.cpp,v - [3]
layout/base/src/nsGenericDOMDataNode.h,v - [3]
layout/base/src/nsGenericElement.cpp,v - [3]
layout/base/src/nsGenericElement.h,v - [3]
layout/base/src/nsNameSpaceManager.cpp,v - bug 7834
layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow
layout/base/src/nsTextNode.cpp,v - [2]
layout/events/src/nsEventListenerManager.cpp,v - [3]
layout/events/src/nsEventListenerManager.h,v - [3]
layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString
layout/html/content/src/nsAttributeContent.cpp,v - [2]
layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLModElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3]
layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953
layout/html/document/src/nsHTMLDocument.h,v - bug 27953
layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2]
layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2]
layout/xml/content/src/nsXMLElement.h,v - [1][2]
layout/xml/content/src/nsXMLEntity.cpp,v - [1][2]
layout/xml/content/src/nsXMLNotation.cpp,v - [1][2]
layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2]
layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString
layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString
netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString
rdf/content/src/nsXULDocument.cpp,v - bug 27953
rdf/content/src/nsXULDocument.h,v - bug 27953
rdf/content/src/nsXULElement.h,v - [1]
xpcom/base/IIDS.h,v - bug 12559
2000-03-17 16:27:00 +03:00
|
|
|
nsAutoString value;
|
2005-10-28 15:25:24 +04:00
|
|
|
content->GetAttr(kNameSpaceID_None, atom, value);
|
|
|
|
if (!value.IsEmpty()) {
|
2012-07-27 17:59:29 +04:00
|
|
|
nsresult error;
|
1999-06-15 08:02:43 +04:00
|
|
|
|
|
|
|
// convert it to an integer
|
|
|
|
defaultValue = value.ToInteger(&error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class nsValueChangedRunnable : public Runnable
|
2009-01-14 21:21:58 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsValueChangedRunnable(nsISliderListener* aListener,
|
|
|
|
nsIAtom* aWhich,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aValue,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aUserChanged)
|
2009-01-14 21:21:58 +03:00
|
|
|
: mListener(aListener), mWhich(aWhich),
|
|
|
|
mValue(aValue), mUserChanged(aUserChanged)
|
|
|
|
{}
|
|
|
|
|
2016-08-08 05:18:10 +03:00
|
|
|
NS_IMETHOD Run() override
|
2009-01-14 21:21:58 +03:00
|
|
|
{
|
2010-03-08 18:45:00 +03:00
|
|
|
return mListener->ValueChanged(nsDependentAtomString(mWhich),
|
|
|
|
mValue, mUserChanged);
|
2009-01-14 21:21:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsISliderListener> mListener;
|
|
|
|
nsCOMPtr<nsIAtom> mWhich;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mValue;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mUserChanged;
|
2009-01-14 21:21:58 +03:00
|
|
|
};
|
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class nsDragStateChangedRunnable : public Runnable
|
2009-05-21 09:27:01 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsDragStateChangedRunnable(nsISliderListener* aListener,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aDragBeginning)
|
2009-05-21 09:27:01 +04:00
|
|
|
: mListener(aListener),
|
|
|
|
mDragBeginning(aDragBeginning)
|
|
|
|
{}
|
|
|
|
|
2016-08-08 05:18:10 +03:00
|
|
|
NS_IMETHOD Run() override
|
2009-05-21 09:27:01 +04:00
|
|
|
{
|
|
|
|
return mListener->DragStateChanged(mDragBeginning);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsISliderListener> mListener;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDragBeginning;
|
2009-05-21 09:27:01 +04:00
|
|
|
};
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSliderFrame::AttributeChanged(int32_t aNameSpaceID,
|
2004-12-31 04:13:27 +03:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
1999-06-15 08:02:43 +04:00
|
|
|
{
|
2005-09-07 20:49:21 +04:00
|
|
|
nsresult rv = nsBoxFrame::AttributeChanged(aNameSpaceID, aAttribute,
|
|
|
|
aModType);
|
1999-06-15 08:02:43 +04:00
|
|
|
// if the current position changes
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::curpos) {
|
2013-02-27 20:56:00 +04:00
|
|
|
CurrentPositionChanged();
|
2006-12-26 20:47:52 +03:00
|
|
|
} else if (aAttribute == nsGkAtoms::minpos ||
|
|
|
|
aAttribute == nsGkAtoms::maxpos) {
|
1999-10-12 04:16:06 +04:00
|
|
|
// bounds check it.
|
|
|
|
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* scrollbarBox = GetScrollbar();
|
2000-04-03 07:55:38 +04:00
|
|
|
nsCOMPtr<nsIContent> scrollbar;
|
2003-06-02 06:39:26 +04:00
|
|
|
scrollbar = GetContentOfBox(scrollbarBox);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t current = GetCurrentPosition(scrollbar);
|
|
|
|
int32_t min = GetMinPosition(scrollbar);
|
|
|
|
int32_t max = GetMaxPosition(scrollbar);
|
2009-01-14 21:21:58 +03:00
|
|
|
|
|
|
|
// inform the parent <scale> that the minimum or maximum changed
|
|
|
|
nsIFrame* parent = GetParent();
|
|
|
|
if (parent) {
|
|
|
|
nsCOMPtr<nsISliderListener> sliderListener = do_QueryInterface(parent->GetContent());
|
|
|
|
if (sliderListener) {
|
|
|
|
nsContentUtils::AddScriptRunner(
|
|
|
|
new nsValueChangedRunnable(sliderListener, aAttribute,
|
2011-10-17 18:59:28 +04:00
|
|
|
aAttribute == nsGkAtoms::minpos ? min : max, false));
|
2009-01-14 21:21:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-30 17:50:48 +04:00
|
|
|
if (current < min || current > max)
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
2014-02-05 05:30:34 +04:00
|
|
|
int32_t direction = 0;
|
|
|
|
if (current < min || max < min) {
|
|
|
|
current = min;
|
|
|
|
direction = -1;
|
|
|
|
} else if (current > max) {
|
|
|
|
current = max;
|
|
|
|
direction = 1;
|
|
|
|
}
|
2000-08-29 06:03:59 +04:00
|
|
|
|
2003-04-14 18:34:45 +04:00
|
|
|
// set the new position and notify observers
|
2011-07-11 18:05:09 +04:00
|
|
|
nsScrollbarFrame* scrollbarFrame = do_QueryFrame(scrollbarBox);
|
2000-08-29 06:03:59 +04:00
|
|
|
if (scrollbarFrame) {
|
2006-12-07 22:53:41 +03:00
|
|
|
nsIScrollbarMediator* mediator = scrollbarFrame->GetScrollbarMediator();
|
2014-02-05 05:30:34 +04:00
|
|
|
scrollbarFrame->SetIncrementToWhole(direction);
|
2000-08-29 06:03:59 +04:00
|
|
|
if (mediator) {
|
2015-03-25 21:40:31 +03:00
|
|
|
mediator->ScrollByWhole(scrollbarFrame, direction,
|
|
|
|
nsIScrollbarMediator::ENABLE_SNAP);
|
2000-08-29 06:03:59 +04:00
|
|
|
}
|
|
|
|
}
|
2014-02-05 05:30:34 +04:00
|
|
|
// 'this' might be destroyed here
|
2001-07-15 04:05:20 +04:00
|
|
|
|
2008-04-15 03:59:21 +04:00
|
|
|
nsContentUtils::AddScriptRunner(
|
2010-05-03 17:23:36 +04:00
|
|
|
new nsSetAttrRunnable(scrollbar, nsGkAtoms::curpos, current));
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
}
|
2001-07-15 04:05:20 +04:00
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::minpos ||
|
|
|
|
aAttribute == nsGkAtoms::maxpos ||
|
|
|
|
aAttribute == nsGkAtoms::pageincrement ||
|
|
|
|
aAttribute == nsGkAtoms::increment) {
|
2001-07-15 04:05:20 +04:00
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 23:16:51 +04:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsSliderFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
if (aBuilder->IsForEventDelivery() && isDraggingThumb()) {
|
|
|
|
// This is EVIL, we shouldn't be messing with event delivery just to get
|
|
|
|
// thumb mouse drag events to arrive at the slider!
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.Outlines()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayEventReceiver(aBuilder, this));
|
2013-02-14 15:12:27 +04:00
|
|
|
return;
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:08:08 +04:00
|
|
|
nsBoxFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsSliderFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
1999-06-15 08:02:43 +04:00
|
|
|
{
|
1999-08-20 02:16:23 +04:00
|
|
|
// if we are too small to have a thumb don't paint it.
|
2016-04-21 07:28:32 +03:00
|
|
|
nsIFrame* thumb = nsBox::GetChildXULBox(this);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2001-01-11 04:56:27 +03:00
|
|
|
if (thumb) {
|
2004-09-28 22:37:50 +04:00
|
|
|
nsRect thumbRect(thumb->GetRect());
|
2001-01-11 04:56:27 +03:00
|
|
|
nsMargin m;
|
2016-04-21 07:28:33 +03:00
|
|
|
thumb->GetXULMargin(m);
|
2001-01-11 04:56:27 +03:00
|
|
|
thumbRect.Inflate(m);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2001-01-11 04:56:27 +03:00
|
|
|
nsRect crect;
|
2016-04-21 07:28:33 +03:00
|
|
|
GetXULClientRect(crect);
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2001-01-11 04:56:27 +03:00
|
|
|
if (crect.width < thumbRect.width || crect.height < thumbRect.height)
|
2013-02-14 15:12:27 +04:00
|
|
|
return;
|
2015-04-21 22:22:28 +03:00
|
|
|
|
|
|
|
// If this scrollbar is the scrollbar of an actively scrolled scroll frame,
|
|
|
|
// layerize the scrollbar thumb, wrap it in its own ContainerLayer and
|
|
|
|
// attach scrolling information to it.
|
|
|
|
// We do this here and not in the thumb's nsBoxFrame::BuildDisplayList so
|
|
|
|
// that the event region that gets created for the thumb is included in
|
|
|
|
// the nsDisplayOwnLayer contents.
|
|
|
|
|
|
|
|
uint32_t flags = 0;
|
|
|
|
mozilla::layers::FrameMetrics::ViewID scrollTargetId =
|
|
|
|
mozilla::layers::FrameMetrics::NULL_SCROLL_ID;
|
|
|
|
aBuilder->GetScrollbarInfo(&scrollTargetId, &flags);
|
|
|
|
bool thumbGetsLayer = (scrollTargetId != layers::FrameMetrics::NULL_SCROLL_ID);
|
|
|
|
nsLayoutUtils::SetScrollbarThumbLayerization(thumb, thumbGetsLayer);
|
|
|
|
|
|
|
|
if (thumbGetsLayer) {
|
|
|
|
nsDisplayListCollection tempLists;
|
|
|
|
nsBoxFrame::BuildDisplayListForChildren(aBuilder, aDirtyRect, tempLists);
|
|
|
|
|
|
|
|
// This is a bit of a hack. Collect up all descendant display items
|
|
|
|
// and merge them into a single Content() list.
|
|
|
|
nsDisplayList masterList;
|
|
|
|
masterList.AppendToTop(tempLists.BorderBackground());
|
|
|
|
masterList.AppendToTop(tempLists.BlockBorderBackgrounds());
|
|
|
|
masterList.AppendToTop(tempLists.Floats());
|
|
|
|
masterList.AppendToTop(tempLists.Content());
|
|
|
|
masterList.AppendToTop(tempLists.PositionedDescendants());
|
|
|
|
masterList.AppendToTop(tempLists.Outlines());
|
|
|
|
|
|
|
|
// Wrap the list to make it its own layer.
|
|
|
|
aLists.Content()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayOwnLayer(aBuilder, this, &masterList, flags, scrollTargetId,
|
2015-04-27 21:59:17 +03:00
|
|
|
GetThumbRatio()));
|
2015-04-21 22:22:28 +03:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
nsBoxFrame::BuildDisplayListForChildren(aBuilder, aDirtyRect, aLists);
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
1999-04-21 01:39:52 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_IMETHODIMP
|
2016-04-21 07:28:35 +03:00
|
|
|
nsSliderFrame::DoXULLayout(nsBoxLayoutState& aState)
|
1999-06-15 08:02:43 +04:00
|
|
|
{
|
2001-01-11 04:56:27 +03:00
|
|
|
// get the thumb should be our only child
|
2016-04-21 07:28:32 +03:00
|
|
|
nsIFrame* thumbBox = nsBox::GetChildXULBox(this);
|
2001-01-11 04:56:27 +03:00
|
|
|
|
|
|
|
if (!thumbBox) {
|
|
|
|
SyncLayout(aState);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
EnsureOrient();
|
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 11:02:06 +04:00
|
|
|
if (mState & NS_STATE_DEBUG_WAS_SET) {
|
|
|
|
if (mState & NS_STATE_SET_TO_DEBUG)
|
2016-04-21 07:28:34 +03:00
|
|
|
SetXULDebug(aState, true);
|
2000-03-31 11:02:06 +04:00
|
|
|
else
|
2016-04-21 07:28:34 +03:00
|
|
|
SetXULDebug(aState, false);
|
1999-04-21 01:39:52 +04:00
|
|
|
}
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// get the content area inside our borders
|
2009-09-04 01:33:55 +04:00
|
|
|
nsRect clientRect;
|
2016-04-21 07:28:33 +03:00
|
|
|
GetXULClientRect(clientRect);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// get the scrollbar
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* scrollbarBox = GetScrollbar();
|
2000-04-03 07:55:38 +04:00
|
|
|
nsCOMPtr<nsIContent> scrollbar;
|
2003-06-02 06:39:26 +04:00
|
|
|
scrollbar = GetContentOfBox(scrollbarBox);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// get the thumb's pref size
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize thumbSize = thumbBox->GetXULPrefSize(aState);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
if (IsXULHorizontal())
|
2000-03-31 11:02:06 +04:00
|
|
|
thumbSize.height = clientRect.height;
|
|
|
|
else
|
|
|
|
thumbSize.width = clientRect.width;
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t curPos = GetCurrentPosition(scrollbar);
|
|
|
|
int32_t minPos = GetMinPosition(scrollbar);
|
|
|
|
int32_t maxPos = GetMaxPosition(scrollbar);
|
|
|
|
int32_t pageIncrement = GetPageIncrement(scrollbar);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2013-01-15 16:22:03 +04:00
|
|
|
maxPos = std::max(minPos, maxPos);
|
2011-10-28 22:33:28 +04:00
|
|
|
curPos = clamped(curPos, minPos, maxPos);
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
nscoord& availableLength = IsXULHorizontal() ? clientRect.width : clientRect.height;
|
|
|
|
nscoord& thumbLength = IsXULHorizontal() ? thumbSize.width : thumbSize.height;
|
2001-09-01 00:37:56 +04:00
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
if ((pageIncrement + maxPos - minPos) > 0 && thumbBox->GetXULFlex() > 0) {
|
2009-09-04 01:33:55 +04:00
|
|
|
float ratio = float(pageIncrement) / float(maxPos - minPos + pageIncrement);
|
2013-01-15 16:22:03 +04:00
|
|
|
thumbLength = std::max(thumbLength, NSToCoordRound(availableLength * ratio));
|
1999-04-21 01:39:52 +04:00
|
|
|
}
|
2004-03-05 19:29:23 +03:00
|
|
|
|
2009-09-04 01:34:31 +04:00
|
|
|
// Round the thumb's length to device pixels.
|
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
thumbLength = presContext->DevPixelsToAppUnits(
|
|
|
|
presContext->AppUnitsToDevPixels(thumbLength));
|
|
|
|
|
2009-09-04 01:33:55 +04:00
|
|
|
// mRatio translates the thumb position in app units to the value.
|
|
|
|
mRatio = (minPos != maxPos) ? float(availableLength - thumbLength) / float(maxPos - minPos) : 1;
|
2004-03-05 19:29:23 +03:00
|
|
|
|
2007-04-10 02:39:57 +04:00
|
|
|
// in reverse mode, curpos is reversed such that lower values are to the
|
|
|
|
// right or bottom and increase leftwards or upwards. In this case, use the
|
|
|
|
// offset from the end instead of the beginning.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool reverse = mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir,
|
2007-04-10 02:39:57 +04:00
|
|
|
nsGkAtoms::reverse, eCaseMatters);
|
2009-09-04 01:33:55 +04:00
|
|
|
nscoord pos = reverse ? (maxPos - curPos) : (curPos - minPos);
|
2007-04-10 02:39:57 +04:00
|
|
|
|
|
|
|
// set the thumb's coord to be the current pos * the ratio.
|
2000-03-31 11:02:06 +04:00
|
|
|
nsRect thumbRect(clientRect.x, clientRect.y, thumbSize.width, thumbSize.height);
|
2016-04-21 07:28:34 +03:00
|
|
|
int32_t& thumbPos = (IsXULHorizontal() ? thumbRect.x : thumbRect.y);
|
2009-09-04 01:33:55 +04:00
|
|
|
thumbPos += NSToCoordRound(pos * mRatio);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
nsRect oldThumbRect(thumbBox->GetRect());
|
2000-04-25 11:10:48 +04:00
|
|
|
LayoutChildAt(aState, thumbBox, thumbRect);
|
|
|
|
|
|
|
|
SyncLayout(aState);
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2009-09-04 01:33:55 +04:00
|
|
|
// Redraw only if thumb changed size.
|
2011-04-19 07:07:23 +04:00
|
|
|
if (!oldThumbRect.IsEqualInterior(thumbRect))
|
2016-04-21 07:28:34 +03:00
|
|
|
XULRedraw(aState);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
1999-06-15 08:02:43 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
1999-06-15 08:02:43 +04:00
|
|
|
{
|
2009-02-27 13:48:25 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
2010-04-12 17:59:16 +04:00
|
|
|
|
|
|
|
// 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) {
|
2009-02-27 13:48:25 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-08-04 09:00:00 +04:00
|
|
|
if (!mDragFinished && !isDraggingThumb()) {
|
|
|
|
StopDrag();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* scrollbarBox = GetScrollbar();
|
2000-04-03 07:55:38 +04:00
|
|
|
nsCOMPtr<nsIContent> scrollbar;
|
2003-06-02 06:39:26 +04:00
|
|
|
scrollbar = GetContentOfBox(scrollbarBox);
|
2016-04-21 07:28:34 +03:00
|
|
|
bool isHorizontal = IsXULHorizontal();
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2003-09-14 05:25:04 +04:00
|
|
|
if (isDraggingThumb())
|
1999-06-15 08:02:43 +04:00
|
|
|
{
|
2015-08-22 04:34:51 +03:00
|
|
|
switch (aEvent->mMessage) {
|
2015-09-14 18:14:35 +03:00
|
|
|
case eTouchMove:
|
2015-08-29 02:58:29 +03:00
|
|
|
case eMouseMove: {
|
2015-10-26 23:06:49 +03:00
|
|
|
if (mScrollingWithAPZ) {
|
|
|
|
break;
|
|
|
|
}
|
2012-07-09 20:55:35 +04:00
|
|
|
nsPoint eventPoint;
|
|
|
|
if (!GetEventPoint(aEvent, eventPoint)) {
|
|
|
|
break;
|
|
|
|
}
|
2005-02-16 12:22:00 +03:00
|
|
|
if (mChange) {
|
2014-07-31 10:03:00 +04:00
|
|
|
// On Linux the destination point is determined by the initial click
|
|
|
|
// on the scrollbar track and doesn't change until the mouse button
|
|
|
|
// is released.
|
|
|
|
#ifndef MOZ_WIDGET_GTK
|
|
|
|
// On the other platforms we need to update the destination point now.
|
2005-08-23 07:57:07 +04:00
|
|
|
mDestinationPoint = eventPoint;
|
2008-02-15 05:04:34 +03:00
|
|
|
StopRepeat();
|
|
|
|
StartRepeat();
|
2014-07-31 10:03:00 +04:00
|
|
|
#endif
|
2005-02-16 12:22:00 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-02-07 08:28:15 +03:00
|
|
|
nscoord pos = isHorizontal ? eventPoint.x : eventPoint.y;
|
|
|
|
|
|
|
|
nsIFrame* thumbFrame = mFrames.FirstChild();
|
|
|
|
if (!thumbFrame) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-02-06 00:21:54 +03:00
|
|
|
mozilla::Telemetry::Accumulate(mozilla::Telemetry::SCROLL_INPUT_METHODS,
|
|
|
|
(uint32_t) ScrollInputMethod::MainThreadScrollbarDrag);
|
|
|
|
|
2008-02-07 08:28:15 +03:00
|
|
|
// take our current position and subtract the start location
|
|
|
|
pos -= mDragStart;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isMouseOutsideThumb = false;
|
2008-02-07 08:28:15 +03:00
|
|
|
if (gSnapMultiplier) {
|
|
|
|
nsSize thumbSize = thumbFrame->GetSize();
|
|
|
|
if (isHorizontal) {
|
|
|
|
// horizontal scrollbar - check if mouse is above or below thumb
|
|
|
|
// XXXbz what about looking at the .y of the thumb's rect? Is that
|
|
|
|
// always zero here?
|
|
|
|
if (eventPoint.y < -gSnapMultiplier * thumbSize.height ||
|
|
|
|
eventPoint.y > thumbSize.height +
|
|
|
|
gSnapMultiplier * thumbSize.height)
|
2011-10-17 18:59:28 +04:00
|
|
|
isMouseOutsideThumb = true;
|
2008-02-07 08:28:15 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// vertical scrollbar - check if mouse is left or right of thumb
|
|
|
|
if (eventPoint.x < -gSnapMultiplier * thumbSize.width ||
|
|
|
|
eventPoint.x > thumbSize.width +
|
|
|
|
gSnapMultiplier * thumbSize.width)
|
2011-10-17 18:59:28 +04:00
|
|
|
isMouseOutsideThumb = true;
|
2008-02-07 08:28:15 +03:00
|
|
|
}
|
|
|
|
}
|
2014-08-04 09:28:53 +04:00
|
|
|
if (aEvent->mClass == eTouchEventClass) {
|
2012-07-09 20:55:35 +04:00
|
|
|
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
|
|
|
}
|
2008-02-07 08:28:15 +03:00
|
|
|
if (isMouseOutsideThumb)
|
|
|
|
{
|
2013-02-27 01:26:41 +04:00
|
|
|
SetCurrentThumbPosition(scrollbar, mThumbStart, false, false);
|
2008-02-07 08:28:15 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set it
|
2013-02-27 01:26:41 +04:00
|
|
|
SetCurrentThumbPosition(scrollbar, pos, false, true); // with snapping
|
2001-07-15 04:05:20 +04:00
|
|
|
}
|
1999-06-15 08:02:43 +04:00
|
|
|
break;
|
|
|
|
|
2015-09-14 18:14:35 +03:00
|
|
|
case eTouchEnd:
|
2015-08-29 02:58:30 +03:00
|
|
|
case eMouseUp:
|
2013-06-11 16:05:28 +04:00
|
|
|
if (ShouldScrollForEvent(aEvent)) {
|
2014-08-04 09:00:00 +04:00
|
|
|
StopDrag();
|
2007-05-25 14:09:29 +04:00
|
|
|
//we MUST call nsFrame HandleEvent for mouse ups to maintain the selection state and capture state.
|
2006-11-17 00:35:39 +03:00
|
|
|
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
2005-02-16 12:22:00 +03:00
|
|
|
}
|
2015-11-23 08:33:47 +03:00
|
|
|
break;
|
2015-08-26 15:56:59 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
//return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
|
|
|
return NS_OK;
|
2013-06-11 16:05:28 +04:00
|
|
|
} else if (ShouldScrollToClickForEvent(aEvent)) {
|
2012-07-09 20:55:35 +04:00
|
|
|
nsPoint eventPoint;
|
|
|
|
if (!GetEventPoint(aEvent, eventPoint)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-04-18 09:20:32 +04:00
|
|
|
nscoord pos = isHorizontal ? eventPoint.x : eventPoint.y;
|
|
|
|
|
2008-02-07 08:28:15 +03:00
|
|
|
// adjust so that the middle of the thumb is placed under the click
|
2000-06-03 06:07:52 +04:00
|
|
|
nsIFrame* thumbFrame = mFrames.FirstChild();
|
2006-12-22 00:44:10 +03:00
|
|
|
if (!thumbFrame) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2003-08-04 16:39:51 +04:00
|
|
|
nsSize thumbSize = thumbFrame->GetSize();
|
2000-06-03 06:07:52 +04:00
|
|
|
nscoord thumbLength = isHorizontal ? thumbSize.width : thumbSize.height;
|
|
|
|
|
2016-02-06 00:21:54 +03:00
|
|
|
mozilla::Telemetry::Accumulate(mozilla::Telemetry::SCROLL_INPUT_METHODS,
|
|
|
|
(uint32_t) ScrollInputMethod::MainThreadScrollbarTrackClick);
|
|
|
|
|
2000-06-03 06:07:52 +04:00
|
|
|
// set it
|
2007-05-25 14:09:29 +04:00
|
|
|
nsWeakFrame weakFrame(this);
|
2011-10-17 18:59:28 +04:00
|
|
|
// should aMaySnap be true here?
|
2013-02-27 01:26:41 +04:00
|
|
|
SetCurrentThumbPosition(scrollbar, pos - thumbLength/2, false, false);
|
2007-05-25 14:09:29 +04:00
|
|
|
NS_ENSURE_TRUE(weakFrame.IsAlive(), NS_OK);
|
2000-06-03 06:07:52 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
DragThumb(true);
|
2014-08-13 14:02:00 +04:00
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
nsCOMPtr<nsIContent> thumb = thumbFrame->GetContent();
|
|
|
|
thumb->SetAttr(kNameSpaceID_None, nsGkAtoms::active, NS_LITERAL_STRING("true"), true);
|
|
|
|
#endif
|
|
|
|
|
2014-08-04 09:28:53 +04:00
|
|
|
if (aEvent->mClass == eTouchEventClass) {
|
2012-07-09 20:55:35 +04:00
|
|
|
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
|
|
|
}
|
2001-07-15 04:05:20 +04:00
|
|
|
|
2000-06-03 06:07:52 +04:00
|
|
|
if (isHorizontal)
|
2003-08-04 16:39:51 +04:00
|
|
|
mThumbStart = thumbFrame->GetPosition().x;
|
2000-06-03 06:07:52 +04:00
|
|
|
else
|
2003-08-04 16:39:51 +04:00
|
|
|
mThumbStart = thumbFrame->GetPosition().y;
|
2000-06-03 06:07:52 +04:00
|
|
|
|
2004-08-28 15:41:02 +04:00
|
|
|
mDragStart = pos - mThumbStart;
|
2000-06-03 06:07:52 +04:00
|
|
|
}
|
2014-08-10 13:05:51 +04:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
else if (ShouldScrollForEvent(aEvent) &&
|
|
|
|
aEvent->mClass == eMouseEventClass &&
|
|
|
|
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eRightButton) {
|
|
|
|
// HandlePress and HandleRelease are usually called via
|
|
|
|
// nsFrame::HandleEvent, but only for the left mouse button.
|
2015-08-29 02:58:30 +03:00
|
|
|
if (aEvent->mMessage == eMouseDown) {
|
2014-08-10 13:05:51 +04:00
|
|
|
HandlePress(aPresContext, aEvent, aEventStatus);
|
2015-08-29 02:58:30 +03:00
|
|
|
} else if (aEvent->mMessage == eMouseUp) {
|
2014-08-10 13:05:51 +04:00
|
|
|
HandleRelease(aPresContext, aEvent, aEventStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
1999-06-15 08:02:43 +04:00
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
// XXX hack until handle release is actually called in nsframe.
|
2015-08-29 02:58:32 +03:00
|
|
|
// if (aEvent->mMessage == eMouseOut ||
|
2015-08-22 04:34:51 +03:00
|
|
|
// aEvent->mMessage == NS_MOUSE_RIGHT_BUTTON_UP ||
|
|
|
|
// aEvent->mMessage == NS_MOUSE_LEFT_BUTTON_UP) {
|
|
|
|
// HandleRelease(aPresContext, aEvent, aEventStatus);
|
|
|
|
// }
|
2000-04-26 08:00:29 +04:00
|
|
|
|
2015-08-29 02:58:32 +03:00
|
|
|
if (aEvent->mMessage == eMouseOut && mChange)
|
2011-08-03 07:39:02 +04:00
|
|
|
HandleRelease(aPresContext, aEvent, aEventStatus);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
|
|
|
|
2009-03-31 22:11:35 +04:00
|
|
|
// Helper function to collect the "scroll to click" metric. Beware of
|
|
|
|
// caching this, users expect to be able to change the system preference
|
|
|
|
// and see the browser change its behavior immediately.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-03-31 22:11:35 +04:00
|
|
|
nsSliderFrame::GetScrollToClick()
|
|
|
|
{
|
2013-06-11 16:05:28 +04:00
|
|
|
if (GetScrollbar() != this) {
|
|
|
|
return LookAndFeel::GetInt(LookAndFeel::eIntID_ScrollToClick, false);
|
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2013-06-11 16:05:28 +04:00
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::movetoclick,
|
|
|
|
nsGkAtoms::_true, eCaseMatters)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::movetoclick,
|
|
|
|
nsGkAtoms::_false, eCaseMatters)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
return true;
|
2009-03-31 22:11:35 +04:00
|
|
|
#else
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-03-31 22:11:35 +04:00
|
|
|
#endif
|
|
|
|
}
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame*
|
2000-03-31 11:02:06 +04:00
|
|
|
nsSliderFrame::GetScrollbar()
|
1999-06-15 08:02:43 +04:00
|
|
|
{
|
|
|
|
// if we are in a scrollbar then return the scrollbar's content node
|
|
|
|
// if we are not then return ours.
|
|
|
|
nsIFrame* scrollbar;
|
2006-12-26 20:47:52 +03:00
|
|
|
nsScrollbarButtonFrame::GetParentWithTag(nsGkAtoms::scrollbar, this, scrollbar);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
if (scrollbar == nullptr)
|
2000-03-31 11:02:06 +04:00
|
|
|
return this;
|
|
|
|
|
2016-04-21 07:28:30 +03:00
|
|
|
return scrollbar->IsXULBoxFrame() ? scrollbar : this;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-06-15 08:02:43 +04:00
|
|
|
|
|
|
|
void
|
2007-04-10 02:39:57 +04:00
|
|
|
nsSliderFrame::PageUpDown(nscoord change)
|
2001-07-15 04:05:20 +04:00
|
|
|
{
|
1999-06-15 08:02:43 +04:00
|
|
|
// on a page up or down get our page increment. We get this by getting the scrollbar we are in and
|
|
|
|
// asking it for the current position and the page increment. If we are not in a scrollbar we will
|
|
|
|
// get the values from our own node.
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* scrollbarBox = GetScrollbar();
|
2000-04-03 07:55:38 +04:00
|
|
|
nsCOMPtr<nsIContent> scrollbar;
|
2003-06-02 06:39:26 +04:00
|
|
|
scrollbar = GetContentOfBox(scrollbarBox);
|
2001-07-15 04:05:20 +04:00
|
|
|
|
1999-06-15 08:02:43 +04:00
|
|
|
nscoord pageIncrement = GetPageIncrement(scrollbar);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t curpos = GetCurrentPosition(scrollbar);
|
|
|
|
int32_t minpos = GetMinPosition(scrollbar);
|
|
|
|
int32_t maxpos = GetMaxPosition(scrollbar);
|
2007-04-10 02:39:57 +04:00
|
|
|
|
|
|
|
// get the new position and make sure it is in bounds
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t newpos = curpos + change * pageIncrement;
|
2007-04-10 02:39:57 +04:00
|
|
|
if (newpos < minpos || maxpos < minpos)
|
|
|
|
newpos = minpos;
|
|
|
|
else if (newpos > maxpos)
|
|
|
|
newpos = maxpos;
|
|
|
|
|
2013-02-27 01:26:41 +04:00
|
|
|
SetCurrentPositionInternal(scrollbar, newpos, true);
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// called when the current position changed and we need to update the thumb's location
|
2013-02-27 20:56:00 +04:00
|
|
|
void
|
2013-02-27 20:55:59 +04:00
|
|
|
nsSliderFrame::CurrentPositionChanged()
|
1999-06-15 08:02:43 +04:00
|
|
|
{
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* scrollbarBox = GetScrollbar();
|
2000-04-03 07:55:38 +04:00
|
|
|
nsCOMPtr<nsIContent> scrollbar;
|
2003-06-02 06:39:26 +04:00
|
|
|
scrollbar = GetContentOfBox(scrollbarBox);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2007-04-10 02:39:57 +04:00
|
|
|
// get the current position
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t curPos = GetCurrentPosition(scrollbar);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2007-04-10 02:39:57 +04:00
|
|
|
// do nothing if the position did not change
|
2009-09-04 01:33:55 +04:00
|
|
|
if (mCurPos == curPos)
|
2013-02-27 20:56:00 +04:00
|
|
|
return;
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2007-04-10 02:39:57 +04:00
|
|
|
// get our current min and max position from our content node
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t minPos = GetMinPosition(scrollbar);
|
|
|
|
int32_t maxPos = GetMaxPosition(scrollbar);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2013-01-15 16:22:03 +04:00
|
|
|
maxPos = std::max(minPos, maxPos);
|
2011-10-28 22:33:28 +04:00
|
|
|
curPos = clamped(curPos, minPos, maxPos);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2007-04-10 02:39:57 +04:00
|
|
|
// get the thumb's rect
|
|
|
|
nsIFrame* thumbFrame = mFrames.FirstChild();
|
|
|
|
if (!thumbFrame)
|
2013-02-27 20:56:00 +04:00
|
|
|
return; // The thumb may stream in asynchronously via XBL.
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2007-04-10 02:39:57 +04:00
|
|
|
nsRect thumbRect = thumbFrame->GetRect();
|
2001-06-02 02:48:05 +04:00
|
|
|
|
2007-04-10 02:39:57 +04:00
|
|
|
nsRect clientRect;
|
2016-04-21 07:28:33 +03:00
|
|
|
GetXULClientRect(clientRect);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2007-04-10 02:39:57 +04:00
|
|
|
// figure out the new rect
|
|
|
|
nsRect newThumbRect(thumbRect);
|
2001-07-15 04:05:20 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool reverse = mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir,
|
2007-04-10 02:39:57 +04:00
|
|
|
nsGkAtoms::reverse, eCaseMatters);
|
2009-09-04 01:33:55 +04:00
|
|
|
nscoord pos = reverse ? (maxPos - curPos) : (curPos - minPos);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
if (IsXULHorizontal())
|
2009-09-04 01:33:55 +04:00
|
|
|
newThumbRect.x = clientRect.x + NSToCoordRound(pos * mRatio);
|
2007-04-10 02:39:57 +04:00
|
|
|
else
|
2009-09-04 01:33:55 +04:00
|
|
|
newThumbRect.y = clientRect.y + NSToCoordRound(pos * mRatio);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2014-03-14 22:48:07 +04:00
|
|
|
// avoid putting the scroll thumb at subpixel positions which cause needless invalidations
|
|
|
|
nscoord appUnitsPerPixel = PresContext()->AppUnitsPerDevPixel();
|
2015-06-18 19:57:00 +03:00
|
|
|
nsPoint snappedThumbLocation = ToAppUnits(
|
|
|
|
newThumbRect.TopLeft().ToNearestPixels(appUnitsPerPixel),
|
|
|
|
appUnitsPerPixel);
|
2016-04-21 07:28:34 +03:00
|
|
|
if (IsXULHorizontal()) {
|
2015-06-18 19:57:00 +03:00
|
|
|
newThumbRect.x = snappedThumbLocation.x;
|
2014-09-18 12:52:38 +04:00
|
|
|
} else {
|
2015-06-18 19:57:00 +03:00
|
|
|
newThumbRect.y = snappedThumbLocation.y;
|
2014-09-18 12:52:38 +04:00
|
|
|
}
|
2014-05-28 14:52:13 +04:00
|
|
|
|
2007-04-10 02:39:57 +04:00
|
|
|
// set the rect
|
|
|
|
thumbFrame->SetRect(newThumbRect);
|
2001-07-15 04:05:20 +04:00
|
|
|
|
2016-03-10 06:57:15 +03:00
|
|
|
// Request a repaint of the scrollbar
|
|
|
|
nsScrollbarFrame* scrollbarFrame = do_QueryFrame(scrollbarBox);
|
|
|
|
nsIScrollbarMediator* mediator = scrollbarFrame
|
|
|
|
? scrollbarFrame->GetScrollbarMediator() : nullptr;
|
|
|
|
if (!mediator || !mediator->ShouldSuppressScrollbarRepaints()) {
|
2015-08-07 22:37:56 +03:00
|
|
|
SchedulePaint();
|
|
|
|
}
|
2008-02-07 11:56:38 +03:00
|
|
|
|
2009-09-04 01:33:55 +04:00
|
|
|
mCurPos = curPos;
|
1999-06-23 21:00:17 +04:00
|
|
|
|
2009-01-14 21:21:58 +03:00
|
|
|
// inform the parent <scale> if it exists that the value changed
|
|
|
|
nsIFrame* parent = GetParent();
|
|
|
|
if (parent) {
|
|
|
|
nsCOMPtr<nsISliderListener> sliderListener = do_QueryInterface(parent->GetContent());
|
|
|
|
if (sliderListener) {
|
|
|
|
nsContentUtils::AddScriptRunner(
|
|
|
|
new nsValueChangedRunnable(sliderListener, nsGkAtoms::curpos, mCurPos, mUserChanged));
|
|
|
|
}
|
|
|
|
}
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static void UpdateAttribute(nsIContent* aScrollbar, nscoord aNewPos, bool aNotify, bool aIsSmooth) {
|
2003-03-24 08:29:45 +03:00
|
|
|
nsAutoString str;
|
|
|
|
str.AppendInt(aNewPos);
|
|
|
|
|
|
|
|
if (aIsSmooth) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aScrollbar->SetAttr(kNameSpaceID_None, nsGkAtoms::smooth, NS_LITERAL_STRING("true"), false);
|
2003-03-24 08:29:45 +03:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
aScrollbar->SetAttr(kNameSpaceID_None, nsGkAtoms::curpos, str, aNotify);
|
2003-03-24 08:29:45 +03:00
|
|
|
if (aIsSmooth) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aScrollbar->UnsetAttr(kNameSpaceID_None, nsGkAtoms::smooth, false);
|
2003-03-24 08:29:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-07 08:28:15 +03:00
|
|
|
// Use this function when you want to set the scroll position via the position
|
|
|
|
// of the scrollbar thumb, e.g. when dragging the slider. This function scrolls
|
2009-09-04 01:33:55 +04:00
|
|
|
// the content in such a way that thumbRect.x/.y becomes aNewThumbPos.
|
2008-02-07 08:28:15 +03:00
|
|
|
void
|
2009-09-04 01:33:55 +04:00
|
|
|
nsSliderFrame::SetCurrentThumbPosition(nsIContent* aScrollbar, nscoord aNewThumbPos,
|
2013-02-27 01:26:41 +04:00
|
|
|
bool aIsSmooth, bool aMaySnap)
|
2008-02-07 08:28:15 +03:00
|
|
|
{
|
|
|
|
nsRect crect;
|
2016-04-21 07:28:33 +03:00
|
|
|
GetXULClientRect(crect);
|
2016-04-21 07:28:34 +03:00
|
|
|
nscoord offset = IsXULHorizontal() ? crect.x : crect.y;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t newPos = NSToIntRound((aNewThumbPos - offset) / mRatio);
|
2008-02-07 08:28:15 +03:00
|
|
|
|
|
|
|
if (aMaySnap && mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::snap,
|
|
|
|
nsGkAtoms::_true, eCaseMatters)) {
|
|
|
|
// If snap="true", then the slider may only be set to min + (increment * x).
|
|
|
|
// Otherwise, the slider may be set to any positive integer.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t increment = GetIncrement(aScrollbar);
|
2009-09-04 01:33:55 +04:00
|
|
|
newPos = NSToIntRound(newPos / float(increment)) * increment;
|
2008-02-07 08:28:15 +03:00
|
|
|
}
|
|
|
|
|
2013-02-27 01:26:41 +04:00
|
|
|
SetCurrentPosition(aScrollbar, newPos, aIsSmooth);
|
2008-02-07 08:28:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Use this function when you know the target scroll position of the scrolled content.
|
|
|
|
// aNewPos should be passed to this function as a position as if the minpos is 0.
|
2007-04-10 02:39:57 +04:00
|
|
|
// That is, the minpos will be added to the position by this function. In a reverse
|
|
|
|
// direction slider, the newpos should be the distance from the end.
|
1999-06-15 08:02:43 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSliderFrame::SetCurrentPosition(nsIContent* aScrollbar, int32_t aNewPos,
|
2013-02-27 01:26:41 +04:00
|
|
|
bool aIsSmooth)
|
1999-06-15 08:02:43 +04:00
|
|
|
{
|
2007-04-10 02:39:57 +04:00
|
|
|
// get min and max position from our content node
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t minpos = GetMinPosition(aScrollbar);
|
|
|
|
int32_t maxpos = GetMaxPosition(aScrollbar);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2007-04-10 02:39:57 +04:00
|
|
|
// in reverse direction sliders, flip the value so that it goes from
|
|
|
|
// right to left, or bottom to top.
|
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir,
|
|
|
|
nsGkAtoms::reverse, eCaseMatters))
|
2008-02-07 08:28:15 +03:00
|
|
|
aNewPos = maxpos - aNewPos;
|
2007-04-10 02:39:57 +04:00
|
|
|
else
|
2008-02-07 08:28:15 +03:00
|
|
|
aNewPos += minpos;
|
2006-05-30 17:50:48 +04:00
|
|
|
|
1999-06-15 08:02:43 +04:00
|
|
|
// get the new position and make sure it is in bounds
|
2008-02-07 08:28:15 +03:00
|
|
|
if (aNewPos < minpos || maxpos < minpos)
|
|
|
|
aNewPos = minpos;
|
|
|
|
else if (aNewPos > maxpos)
|
|
|
|
aNewPos = maxpos;
|
2007-04-10 02:39:57 +04:00
|
|
|
|
2013-02-27 01:26:41 +04:00
|
|
|
SetCurrentPositionInternal(aScrollbar, aNewPos, aIsSmooth);
|
2007-04-10 02:39:57 +04:00
|
|
|
}
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2007-04-10 02:39:57 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSliderFrame::SetCurrentPositionInternal(nsIContent* aScrollbar, int32_t aNewPos,
|
2013-02-27 01:26:41 +04:00
|
|
|
bool aIsSmooth)
|
2007-04-10 02:39:57 +04:00
|
|
|
{
|
2007-05-25 14:09:29 +04:00
|
|
|
nsCOMPtr<nsIContent> scrollbar = aScrollbar;
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* scrollbarBox = GetScrollbar();
|
2014-02-05 05:30:34 +04:00
|
|
|
nsWeakFrame weakFrame(this);
|
2009-01-14 21:21:58 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mUserChanged = true;
|
2009-01-14 21:21:58 +03:00
|
|
|
|
2011-07-11 18:05:09 +04:00
|
|
|
nsScrollbarFrame* scrollbarFrame = do_QueryFrame(scrollbarBox);
|
2000-06-07 03:13:05 +04:00
|
|
|
if (scrollbarFrame) {
|
|
|
|
// See if we have a mediator.
|
2006-12-07 22:53:41 +03:00
|
|
|
nsIScrollbarMediator* mediator = scrollbarFrame->GetScrollbarMediator();
|
2000-06-07 03:13:05 +04:00
|
|
|
if (mediator) {
|
2014-02-05 05:30:34 +04:00
|
|
|
nscoord oldPos = nsPresContext::CSSPixelsToAppUnits(GetCurrentPosition(scrollbar));
|
|
|
|
nscoord newPos = nsPresContext::CSSPixelsToAppUnits(aNewPos);
|
|
|
|
mediator->ThumbMoved(scrollbarFrame, oldPos, newPos);
|
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
return;
|
2007-05-25 14:09:29 +04:00
|
|
|
}
|
2014-02-05 05:30:34 +04:00
|
|
|
CurrentPositionChanged();
|
2011-10-17 18:59:28 +04:00
|
|
|
mUserChanged = false;
|
2000-06-07 03:13:05 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
UpdateAttribute(scrollbar, aNewPos, true, aIsSmooth);
|
2014-02-05 05:30:34 +04:00
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
mUserChanged = false;
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2002-11-27 00:38:18 +03:00
|
|
|
#ifdef DEBUG_SLIDER
|
2008-02-07 08:28:15 +03:00
|
|
|
printf("Current Pos=%d\n",aNewPos);
|
2002-11-27 00:38:18 +03:00
|
|
|
#endif
|
2001-07-15 04:05:20 +04:00
|
|
|
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
|
|
|
|
2007-05-25 14:09:29 +04:00
|
|
|
nsIAtom*
|
|
|
|
nsSliderFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::sliderFrame;
|
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsSliderFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList)
|
1999-06-15 08:02:43 +04:00
|
|
|
{
|
2014-05-28 23:36:58 +04:00
|
|
|
nsBoxFrame::SetInitialChildList(aListID, aChildList);
|
2016-01-28 02:11:00 +03:00
|
|
|
if (aListID == kPrincipalList) {
|
|
|
|
AddListener();
|
|
|
|
}
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
|
|
|
|
2000-04-26 08:00:29 +04:00
|
|
|
nsresult
|
2011-06-28 21:59:14 +04:00
|
|
|
nsSliderMediator::HandleEvent(nsIDOMEvent* aEvent)
|
2000-04-26 08:00:29 +04:00
|
|
|
{
|
2003-09-14 05:25:04 +04:00
|
|
|
// Only process the event if the thumb is not being dragged.
|
|
|
|
if (mSlider && !mSlider->isDraggingThumb())
|
2012-07-09 20:55:35 +04:00
|
|
|
return mSlider->StartDrag(aEvent);
|
2003-09-14 05:25:04 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
2000-04-26 08:00:29 +04:00
|
|
|
}
|
|
|
|
|
2017-01-04 21:42:36 +03:00
|
|
|
class AsyncScrollbarDragStarter : public nsAPostRefreshObserver {
|
|
|
|
public:
|
|
|
|
AsyncScrollbarDragStarter(nsIPresShell* aPresShell,
|
|
|
|
nsIWidget* aWidget,
|
|
|
|
const AsyncDragMetrics& aDragMetrics)
|
|
|
|
: mPresShell(aPresShell)
|
|
|
|
, mWidget(aWidget)
|
|
|
|
, mDragMetrics(aDragMetrics)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
virtual ~AsyncScrollbarDragStarter() {}
|
|
|
|
|
|
|
|
void DidRefresh() override {
|
|
|
|
if (!mPresShell) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Post-refresh observer fired again after failed attempt at unregistering it");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mWidget->StartAsyncScrollbarDrag(mDragMetrics);
|
|
|
|
|
|
|
|
if (!mPresShell->RemovePostRefreshObserver(this)) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Unable to unregister post-refresh observer! Leaking it instead of leaving garbage registered");
|
|
|
|
// Graceful handling, just in case...
|
|
|
|
mPresShell = nullptr;
|
|
|
|
mWidget = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
RefPtr<nsIPresShell> mPresShell;
|
|
|
|
RefPtr<nsIWidget> mWidget;
|
|
|
|
AsyncDragMetrics mDragMetrics;
|
|
|
|
};
|
|
|
|
|
2015-09-29 00:00:25 +03:00
|
|
|
bool
|
2016-12-23 11:49:38 +03:00
|
|
|
nsSliderFrame::StartAPZDrag(WidgetGUIEvent* aEvent)
|
2015-09-29 00:00:25 +03:00
|
|
|
{
|
2016-12-23 11:49:38 +03:00
|
|
|
if (!aEvent->mFlags.mHandledByAPZ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-09-29 00:00:25 +03:00
|
|
|
if (!gfxPlatform::GetPlatform()->SupportsApzDragInput()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-11-28 04:48:08 +03:00
|
|
|
nsContainerFrame* scrollFrame = GetScrollbar()->GetParent();
|
|
|
|
if (!scrollFrame) {
|
2015-09-29 00:00:25 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-11-28 04:48:08 +03:00
|
|
|
nsIContent* scrollableContent = scrollFrame->GetContent();
|
2015-09-29 00:00:25 +03:00
|
|
|
if (!scrollableContent) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-11-28 04:48:08 +03:00
|
|
|
nsIScrollableFrame* scrollFrameAsScrollable = do_QueryFrame(scrollFrame);
|
|
|
|
if (!scrollFrameAsScrollable) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-09-29 00:00:25 +03:00
|
|
|
mozilla::layers::FrameMetrics::ViewID scrollTargetId;
|
|
|
|
bool hasID = nsLayoutUtils::FindIDFor(scrollableContent, &scrollTargetId);
|
|
|
|
bool hasAPZView = hasID && (scrollTargetId != layers::FrameMetrics::NULL_SCROLL_ID);
|
|
|
|
|
|
|
|
if (!hasAPZView) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* scrollbarBox = GetScrollbar();
|
|
|
|
nsCOMPtr<nsIContent> scrollbar = GetContentOfBox(scrollbarBox);
|
|
|
|
|
2016-11-28 04:48:08 +03:00
|
|
|
nsRect sliderTrack;
|
|
|
|
GetXULClientRect(sliderTrack);
|
|
|
|
|
2015-09-29 00:00:25 +03:00
|
|
|
// This rect is the range in which the scroll thumb can slide in.
|
2016-11-28 04:48:08 +03:00
|
|
|
sliderTrack = sliderTrack + GetRect().TopLeft() + scrollbarBox->GetPosition() -
|
|
|
|
scrollFrameAsScrollable->GetScrollPortRect().TopLeft();
|
|
|
|
CSSRect sliderTrackCSS = CSSRect::FromAppUnits(sliderTrack);
|
2015-09-29 00:00:25 +03:00
|
|
|
|
2017-01-04 21:42:36 +03:00
|
|
|
nsIPresShell* shell = PresContext()->PresShell();
|
2015-09-29 00:00:25 +03:00
|
|
|
uint64_t inputblockId = InputAPZContext::GetInputBlockId();
|
2017-01-04 21:42:36 +03:00
|
|
|
uint32_t presShellId = shell->GetPresShellId();
|
2015-09-29 00:00:25 +03:00
|
|
|
AsyncDragMetrics dragMetrics(scrollTargetId, presShellId, inputblockId,
|
2016-11-28 04:48:08 +03:00
|
|
|
NSAppUnitsToFloatPixels(mDragStart,
|
2015-09-29 00:00:25 +03:00
|
|
|
float(AppUnitsPerCSSPixel())),
|
|
|
|
sliderTrackCSS,
|
2016-04-21 07:28:34 +03:00
|
|
|
IsXULHorizontal() ? AsyncDragMetrics::HORIZONTAL :
|
|
|
|
AsyncDragMetrics::VERTICAL);
|
2015-09-29 00:00:25 +03:00
|
|
|
|
2015-12-17 01:22:23 +03:00
|
|
|
if (!nsLayoutUtils::HasDisplayPort(scrollableContent)) {
|
2015-11-23 21:59:14 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-09-29 00:00:25 +03:00
|
|
|
// When we start an APZ drag, we wont get mouse events for the drag.
|
|
|
|
// APZ will consume them all and only notify us of the new scroll position.
|
2017-01-04 21:42:36 +03:00
|
|
|
bool waitForRefresh = InputAPZContext::HavePendingLayerization();
|
|
|
|
nsIWidget* widget = this->GetNearestWidget();
|
|
|
|
if (waitForRefresh) {
|
|
|
|
waitForRefresh = shell->AddPostRefreshObserver(
|
|
|
|
new AsyncScrollbarDragStarter(shell, widget, dragMetrics));
|
|
|
|
}
|
|
|
|
if (!waitForRefresh) {
|
|
|
|
widget->StartAsyncScrollbarDrag(dragMetrics);
|
|
|
|
}
|
2015-09-29 00:00:25 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
1999-06-15 08:02:43 +04:00
|
|
|
nsresult
|
2012-07-09 20:55:35 +04:00
|
|
|
nsSliderFrame::StartDrag(nsIDOMEvent* aEvent)
|
1999-06-15 08:02:43 +04:00
|
|
|
{
|
2008-02-07 08:28:15 +03:00
|
|
|
#ifdef DEBUG_SLIDER
|
|
|
|
printf("Begin dragging\n");
|
|
|
|
#endif
|
2006-12-26 20:47:52 +03:00
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
|
|
|
|
nsGkAtoms::_true, eCaseMatters))
|
2006-05-30 17:50:48 +04:00
|
|
|
return NS_OK;
|
|
|
|
|
2016-02-12 18:40:07 +03:00
|
|
|
WidgetGUIEvent* event = aEvent->WidgetEventPtr()->AsGUIEvent();
|
2012-07-09 20:55:35 +04:00
|
|
|
|
2013-06-11 16:05:28 +04:00
|
|
|
if (!ShouldScrollForEvent(event)) {
|
|
|
|
return NS_OK;
|
2012-07-09 20:55:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint pt;
|
|
|
|
if (!GetEventPoint(event, pt)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-04-21 07:28:34 +03:00
|
|
|
bool isHorizontal = IsXULHorizontal();
|
2007-08-03 05:17:24 +04:00
|
|
|
nscoord pos = isHorizontal ? pt.x : pt.y;
|
2005-04-18 09:20:32 +04:00
|
|
|
|
2013-06-11 16:05:28 +04:00
|
|
|
// If we should scroll-to-click, first place the middle of the slider thumb
|
|
|
|
// under the mouse.
|
2007-05-25 14:09:29 +04:00
|
|
|
nsCOMPtr<nsIContent> scrollbar;
|
2008-02-07 08:28:15 +03:00
|
|
|
nscoord newpos = pos;
|
2013-06-11 16:05:28 +04:00
|
|
|
bool scrollToClick = ShouldScrollToClickForEvent(event);
|
2003-11-25 02:52:49 +03:00
|
|
|
if (scrollToClick) {
|
2000-06-03 06:07:52 +04:00
|
|
|
// adjust so that the middle of the thumb is placed under the click
|
|
|
|
nsIFrame* thumbFrame = mFrames.FirstChild();
|
2006-12-22 00:44:10 +03:00
|
|
|
if (!thumbFrame) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2003-08-04 16:39:51 +04:00
|
|
|
nsSize thumbSize = thumbFrame->GetSize();
|
2000-06-03 06:07:52 +04:00
|
|
|
nscoord thumbLength = isHorizontal ? thumbSize.width : thumbSize.height;
|
|
|
|
|
2008-02-07 08:28:15 +03:00
|
|
|
newpos -= (thumbLength/2);
|
2000-06-03 06:07:52 +04:00
|
|
|
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* scrollbarBox = GetScrollbar();
|
2003-06-02 06:39:26 +04:00
|
|
|
scrollbar = GetContentOfBox(scrollbarBox);
|
2000-06-03 06:07:52 +04:00
|
|
|
}
|
2000-04-26 08:00:29 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
DragThumb(true);
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2008-04-25 04:25:15 +04:00
|
|
|
if (scrollToClick) {
|
2011-10-17 18:59:28 +04:00
|
|
|
// should aMaySnap be true here?
|
2013-02-27 01:26:41 +04:00
|
|
|
SetCurrentThumbPosition(scrollbar, newpos, false, false);
|
2008-04-25 04:25:15 +04:00
|
|
|
}
|
|
|
|
|
1999-06-15 08:02:43 +04:00
|
|
|
nsIFrame* thumbFrame = mFrames.FirstChild();
|
2006-12-22 00:44:10 +03:00
|
|
|
if (!thumbFrame) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2014-08-13 14:02:00 +04:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
nsCOMPtr<nsIContent> thumb = thumbFrame->GetContent();
|
|
|
|
thumb->SetAttr(kNameSpaceID_None, nsGkAtoms::active, NS_LITERAL_STRING("true"), true);
|
|
|
|
#endif
|
|
|
|
|
1999-06-15 08:02:43 +04:00
|
|
|
if (isHorizontal)
|
2008-04-25 04:25:15 +04:00
|
|
|
mThumbStart = thumbFrame->GetPosition().x;
|
1999-06-15 08:02:43 +04:00
|
|
|
else
|
2008-04-25 04:25:15 +04:00
|
|
|
mThumbStart = thumbFrame->GetPosition().y;
|
2001-07-15 04:05:20 +04:00
|
|
|
|
2004-08-28 15:41:02 +04:00
|
|
|
mDragStart = pos - mThumbStart;
|
2008-02-07 08:28:15 +03:00
|
|
|
|
2016-12-23 11:49:38 +03:00
|
|
|
mScrollingWithAPZ = StartAPZDrag(event);
|
2015-09-29 00:00:25 +03:00
|
|
|
|
2008-02-07 08:28:15 +03:00
|
|
|
#ifdef DEBUG_SLIDER
|
|
|
|
printf("Pressed mDragStart=%d\n",mDragStart);
|
|
|
|
#endif
|
2001-07-15 04:05:20 +04:00
|
|
|
|
2016-03-18 21:46:54 +03:00
|
|
|
if (!mScrollingWithAPZ && !mSuppressionActive) {
|
|
|
|
MOZ_ASSERT(PresContext()->PresShell());
|
|
|
|
APZCCallbackHelper::SuppressDisplayport(true, PresContext()->PresShell());
|
|
|
|
mSuppressionActive = true;
|
|
|
|
}
|
|
|
|
|
1999-06-15 08:02:43 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-08-04 09:00:00 +04:00
|
|
|
nsresult
|
|
|
|
nsSliderFrame::StopDrag()
|
|
|
|
{
|
|
|
|
AddListener();
|
|
|
|
DragThumb(false);
|
2014-08-13 14:02:00 +04:00
|
|
|
|
2015-10-26 23:06:49 +03:00
|
|
|
mScrollingWithAPZ = false;
|
|
|
|
|
2016-03-18 21:46:54 +03:00
|
|
|
if (mSuppressionActive) {
|
|
|
|
MOZ_ASSERT(PresContext()->PresShell());
|
|
|
|
APZCCallbackHelper::SuppressDisplayport(false, PresContext()->PresShell());
|
|
|
|
mSuppressionActive = false;
|
|
|
|
}
|
|
|
|
|
2014-08-13 14:02:00 +04:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
nsIFrame* thumbFrame = mFrames.FirstChild();
|
|
|
|
if (thumbFrame) {
|
|
|
|
nsCOMPtr<nsIContent> thumb = thumbFrame->GetContent();
|
|
|
|
thumb->UnsetAttr(kNameSpaceID_None, nsGkAtoms::active, true);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-08-04 09:00:00 +04:00
|
|
|
if (mChange) {
|
|
|
|
StopRepeat();
|
|
|
|
mChange = 0;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-09-14 05:25:04 +04:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsSliderFrame::DragThumb(bool aGrabMouseEvents)
|
1999-06-15 08:02:43 +04:00
|
|
|
{
|
2014-08-04 09:00:00 +04:00
|
|
|
mDragFinished = !aGrabMouseEvents;
|
|
|
|
|
2009-05-21 09:27:01 +04:00
|
|
|
// inform the parent <scale> that a drag is beginning or ending
|
|
|
|
nsIFrame* parent = GetParent();
|
|
|
|
if (parent) {
|
|
|
|
nsCOMPtr<nsISliderListener> sliderListener = do_QueryInterface(parent->GetContent());
|
|
|
|
if (sliderListener) {
|
|
|
|
nsContentUtils::AddScriptRunner(
|
|
|
|
new nsDragStateChangedRunnable(sliderListener, aGrabMouseEvents));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIPresShell::SetCapturingContent(aGrabMouseEvents ? GetContent() : nullptr,
|
2009-09-13 17:13:16 +04:00
|
|
|
aGrabMouseEvents ? CAPTURE_IGNOREALLOWED : 0);
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2003-09-14 05:25:04 +04:00
|
|
|
nsSliderFrame::isDraggingThumb()
|
1999-06-15 08:02:43 +04:00
|
|
|
{
|
2009-09-13 17:13:16 +04:00
|
|
|
return (nsIPresShell::GetCapturingContent() == GetContent());
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSliderFrame::AddListener()
|
|
|
|
{
|
2000-04-26 08:00:29 +04:00
|
|
|
if (!mMediator) {
|
|
|
|
mMediator = new nsSliderMediator(this);
|
|
|
|
}
|
|
|
|
|
1999-06-15 08:02:43 +04:00
|
|
|
nsIFrame* thumbFrame = mFrames.FirstChild();
|
2011-11-25 05:09:58 +04:00
|
|
|
if (!thumbFrame) {
|
|
|
|
return;
|
2001-01-11 04:56:27 +03:00
|
|
|
}
|
2011-11-25 05:09:58 +04:00
|
|
|
thumbFrame->GetContent()->
|
|
|
|
AddSystemEventListener(NS_LITERAL_STRING("mousedown"), mMediator,
|
|
|
|
false, false);
|
2012-07-09 20:55:35 +04:00
|
|
|
thumbFrame->GetContent()->
|
|
|
|
AddSystemEventListener(NS_LITERAL_STRING("touchstart"), mMediator,
|
|
|
|
false, false);
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSliderFrame::RemoveListener()
|
|
|
|
{
|
2000-04-26 08:00:29 +04:00
|
|
|
NS_ASSERTION(mMediator, "No listener was ever added!!");
|
|
|
|
|
1999-06-15 08:02:43 +04:00
|
|
|
nsIFrame* thumbFrame = mFrames.FirstChild();
|
2001-12-18 01:51:39 +03:00
|
|
|
if (!thumbFrame)
|
|
|
|
return;
|
|
|
|
|
2007-05-14 13:11:38 +04:00
|
|
|
thumbFrame->GetContent()->
|
2011-11-25 05:09:58 +04:00
|
|
|
RemoveSystemEventListener(NS_LITERAL_STRING("mousedown"), mMediator, false);
|
1999-06-15 08:02:43 +04:00
|
|
|
}
|
1999-06-23 21:00:17 +04:00
|
|
|
|
2013-06-11 16:05:28 +04:00
|
|
|
bool
|
2013-10-02 07:46:03 +04:00
|
|
|
nsSliderFrame::ShouldScrollForEvent(WidgetGUIEvent* aEvent)
|
2013-06-11 16:05:28 +04:00
|
|
|
{
|
2015-08-22 04:34:51 +03:00
|
|
|
switch (aEvent->mMessage) {
|
2015-09-14 18:14:34 +03:00
|
|
|
case eTouchStart:
|
2015-09-14 18:14:35 +03:00
|
|
|
case eTouchEnd:
|
2013-06-11 16:05:28 +04:00
|
|
|
return true;
|
2015-08-29 02:58:30 +03:00
|
|
|
case eMouseDown:
|
2015-08-29 02:58:30 +03:00
|
|
|
case eMouseUp: {
|
2013-10-22 12:55:20 +04:00
|
|
|
uint16_t button = aEvent->AsMouseEvent()->button;
|
2014-08-10 13:05:51 +04:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
return (button == WidgetMouseEvent::eLeftButton) ||
|
|
|
|
(button == WidgetMouseEvent::eRightButton && GetScrollToClick()) ||
|
|
|
|
(button == WidgetMouseEvent::eMiddleButton && gMiddlePref && !GetScrollToClick());
|
|
|
|
#else
|
2013-10-02 10:38:27 +04:00
|
|
|
return (button == WidgetMouseEvent::eLeftButton) ||
|
|
|
|
(button == WidgetMouseEvent::eMiddleButton && gMiddlePref);
|
2014-08-10 13:05:51 +04:00
|
|
|
#endif
|
2013-06-11 16:05:28 +04:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-10-02 07:46:03 +04:00
|
|
|
nsSliderFrame::ShouldScrollToClickForEvent(WidgetGUIEvent* aEvent)
|
2013-06-11 16:05:28 +04:00
|
|
|
{
|
|
|
|
if (!ShouldScrollForEvent(aEvent)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-09-14 18:14:34 +03:00
|
|
|
if (aEvent->mMessage == eTouchStart) {
|
2013-06-11 16:05:28 +04:00
|
|
|
return GetScrollToClick();
|
|
|
|
}
|
|
|
|
|
2015-08-29 02:58:30 +03:00
|
|
|
if (aEvent->mMessage != eMouseDown) {
|
2013-06-11 16:05:28 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-10 13:05:51 +04:00
|
|
|
#if defined(XP_MACOSX) || defined(MOZ_WIDGET_GTK)
|
|
|
|
// On Mac and Linux, clicking the scrollbar thumb should never scroll to click.
|
2013-06-11 16:05:28 +04:00
|
|
|
if (IsEventOverThumb(aEvent)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-10-22 12:55:20 +04:00
|
|
|
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
|
2013-10-02 10:38:27 +04:00
|
|
|
if (mouseEvent->button == WidgetMouseEvent::eLeftButton) {
|
2013-06-11 16:05:28 +04:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
bool invertPref = mouseEvent->IsAlt();
|
|
|
|
#else
|
|
|
|
bool invertPref = mouseEvent->IsShift();
|
|
|
|
#endif
|
|
|
|
return GetScrollToClick() != invertPref;
|
|
|
|
}
|
|
|
|
|
2014-08-10 13:05:51 +04:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
if (mouseEvent->button == WidgetMouseEvent::eRightButton) {
|
|
|
|
return !GetScrollToClick();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-06-11 16:05:28 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-10-02 07:46:03 +04:00
|
|
|
nsSliderFrame::IsEventOverThumb(WidgetGUIEvent* aEvent)
|
2013-06-11 16:05:28 +04:00
|
|
|
{
|
|
|
|
nsIFrame* thumbFrame = mFrames.FirstChild();
|
|
|
|
if (!thumbFrame) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint eventPoint;
|
|
|
|
if (!GetEventPoint(aEvent, eventPoint)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect thumbRect = thumbFrame->GetRect();
|
2016-01-07 07:55:00 +03:00
|
|
|
#if defined(MOZ_WIDGET_GTK)
|
|
|
|
/* Scrollbar track can have padding, so it's better to check that eventPoint
|
|
|
|
* is inside of actual thumb, not just its one axis. The part of the scrollbar
|
|
|
|
* track adjacent to thumb can actually receive events in GTK3 */
|
|
|
|
return eventPoint.x >= thumbRect.x && eventPoint.x < thumbRect.XMost() &&
|
|
|
|
eventPoint.y >= thumbRect.y && eventPoint.y < thumbRect.YMost();
|
|
|
|
#else
|
2016-04-21 07:28:34 +03:00
|
|
|
bool isHorizontal = IsXULHorizontal();
|
2013-06-11 16:05:28 +04:00
|
|
|
nscoord eventPos = isHorizontal ? eventPoint.x : eventPoint.y;
|
|
|
|
nscoord thumbStart = isHorizontal ? thumbRect.x : thumbRect.y;
|
|
|
|
nscoord thumbEnd = isHorizontal ? thumbRect.XMost() : thumbRect.YMost();
|
|
|
|
|
|
|
|
return eventPos >= thumbStart && eventPos < thumbEnd;
|
2016-01-07 07:55:00 +03:00
|
|
|
#endif
|
2013-06-11 16:05:28 +04:00
|
|
|
}
|
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsSliderFrame::HandlePress(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2013-06-11 16:05:28 +04:00
|
|
|
if (!ShouldScrollForEvent(aEvent) || ShouldScrollToClickForEvent(aEvent)) {
|
2012-07-09 20:55:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-06-11 16:05:28 +04:00
|
|
|
if (IsEventOverThumb(aEvent)) {
|
|
|
|
return NS_OK;
|
2012-07-09 20:55:35 +04:00
|
|
|
}
|
2003-11-25 02:52:49 +03:00
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
nsIFrame* thumbFrame = mFrames.FirstChild();
|
2002-11-23 08:20:05 +03:00
|
|
|
if (!thumbFrame) // display:none?
|
|
|
|
return NS_OK;
|
2006-05-30 17:50:48 +04:00
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
|
|
|
|
nsGkAtoms::_true, eCaseMatters))
|
2006-05-30 17:50:48 +04:00
|
|
|
return NS_OK;
|
2002-11-23 08:20:05 +03:00
|
|
|
|
2003-08-04 16:39:51 +04:00
|
|
|
nsRect thumbRect = thumbFrame->GetRect();
|
2002-11-23 08:20:05 +03:00
|
|
|
|
|
|
|
nscoord change = 1;
|
2012-07-09 20:55:35 +04:00
|
|
|
nsPoint eventPoint;
|
|
|
|
if (!GetEventPoint(aEvent, eventPoint)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-11-18 21:01:56 +03:00
|
|
|
|
|
|
|
mozilla::Telemetry::Accumulate(mozilla::Telemetry::SCROLL_INPUT_METHODS,
|
|
|
|
(uint32_t) ScrollInputMethod::MainThreadScrollbarTrackClick);
|
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
if (IsXULHorizontal() ? eventPoint.x < thumbRect.x
|
|
|
|
: eventPoint.y < thumbRect.y)
|
2002-11-23 08:20:05 +03:00
|
|
|
change = -1;
|
|
|
|
|
|
|
|
mChange = change;
|
2011-10-17 18:59:28 +04:00
|
|
|
DragThumb(true);
|
2014-07-31 10:03:00 +04:00
|
|
|
// On Linux we want to keep scrolling in the direction indicated by |change|
|
|
|
|
// until the mouse is released. On the other platforms we want to stop
|
|
|
|
// scrolling as soon as the scrollbar thumb has reached the current mouse
|
|
|
|
// position.
|
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
nsRect clientRect;
|
2016-04-21 07:28:33 +03:00
|
|
|
GetXULClientRect(clientRect);
|
2014-07-31 10:03:00 +04:00
|
|
|
|
|
|
|
// Set the destination point to the very end of the scrollbar so that
|
|
|
|
// scrolling doesn't stop halfway through.
|
|
|
|
if (change > 0) {
|
|
|
|
mDestinationPoint = nsPoint(clientRect.width, clientRect.height);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mDestinationPoint = nsPoint(0, 0);
|
|
|
|
}
|
|
|
|
#else
|
2005-04-18 09:20:32 +04:00
|
|
|
mDestinationPoint = eventPoint;
|
2014-07-31 10:03:00 +04:00
|
|
|
#endif
|
2008-02-15 05:04:34 +03:00
|
|
|
StartRepeat();
|
2014-02-05 05:30:34 +04:00
|
|
|
PageScroll(change);
|
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-07-15 04:05:20 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsSliderFrame::HandleRelease(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2008-02-15 05:04:34 +03:00
|
|
|
StopRepeat();
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2015-03-25 21:40:31 +03:00
|
|
|
nsIFrame* scrollbar = GetScrollbar();
|
|
|
|
nsScrollbarFrame* sb = do_QueryFrame(scrollbar);
|
|
|
|
if (sb) {
|
|
|
|
nsIScrollbarMediator* m = sb->GetScrollbarMediator();
|
|
|
|
if (m) {
|
|
|
|
m->ScrollbarReleased(sb);
|
|
|
|
}
|
|
|
|
}
|
2011-08-03 07:39:02 +04:00
|
|
|
return NS_OK;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsSliderFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
1999-08-29 14:51:15 +04:00
|
|
|
{
|
2000-04-26 08:00:29 +04:00
|
|
|
// tell our mediator if we have one we are gone.
|
|
|
|
if (mMediator) {
|
2012-07-30 18:20:58 +04:00
|
|
|
mMediator->SetSlider(nullptr);
|
|
|
|
mMediator = nullptr;
|
2000-04-26 08:00:29 +04:00
|
|
|
}
|
2008-02-15 05:04:34 +03:00
|
|
|
StopRepeat();
|
2000-04-26 08:00:29 +04:00
|
|
|
|
1999-12-14 02:33:17 +03:00
|
|
|
// call base class Destroy()
|
2009-12-24 08:21:15 +03:00
|
|
|
nsBoxFrame::DestroyFrom(aDestructRoot);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSliderFrame::GetXULPrefSize(nsBoxLayoutState& aState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
|
|
|
EnsureOrient();
|
2016-04-21 07:28:31 +03:00
|
|
|
return nsBoxFrame::GetXULPrefSize(aState);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSliderFrame::GetXULMinSize(nsBoxLayoutState& aState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
|
|
|
EnsureOrient();
|
|
|
|
|
|
|
|
// our min size is just our borders and padding
|
2016-04-21 07:28:31 +03:00
|
|
|
return nsBox::GetXULMinSize(aState);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSliderFrame::GetXULMaxSize(nsBoxLayoutState& aState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
|
|
|
EnsureOrient();
|
2016-04-21 07:28:31 +03:00
|
|
|
return nsBoxFrame::GetXULMaxSize(aState);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSliderFrame::EnsureOrient()
|
|
|
|
{
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* scrollbarBox = GetScrollbar();
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHorizontal = (scrollbarBox->GetStateBits() & NS_STATE_IS_HORIZONTAL) != 0;
|
2000-03-31 11:02:06 +04:00
|
|
|
if (isHorizontal)
|
|
|
|
mState |= NS_STATE_IS_HORIZONTAL;
|
|
|
|
else
|
|
|
|
mState &= ~NS_STATE_IS_HORIZONTAL;
|
1999-08-29 14:51:15 +04:00
|
|
|
}
|
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2014-02-05 05:30:34 +04:00
|
|
|
void
|
|
|
|
nsSliderFrame::Notify(void)
|
2001-07-15 04:05:20 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool stop = false;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
|
|
|
nsIFrame* thumbFrame = mFrames.FirstChild();
|
2006-12-22 00:44:10 +03:00
|
|
|
if (!thumbFrame) {
|
2008-02-15 05:04:34 +03:00
|
|
|
StopRepeat();
|
2006-12-22 00:44:10 +03:00
|
|
|
return;
|
|
|
|
}
|
2003-08-04 16:39:51 +04:00
|
|
|
nsRect thumbRect = thumbFrame->GetRect();
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
bool isHorizontal = IsXULHorizontal();
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2004-01-27 08:19:57 +03:00
|
|
|
// See if the thumb has moved past our destination point.
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
// if it has we want to stop.
|
|
|
|
if (isHorizontal) {
|
|
|
|
if (mChange < 0) {
|
2004-01-27 08:19:57 +03:00
|
|
|
if (thumbRect.x < mDestinationPoint.x)
|
2011-10-17 18:59:28 +04:00
|
|
|
stop = true;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
} else {
|
2004-01-27 08:19:57 +03:00
|
|
|
if (thumbRect.x + thumbRect.width > mDestinationPoint.x)
|
2011-10-17 18:59:28 +04:00
|
|
|
stop = true;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (mChange < 0) {
|
2004-01-27 08:19:57 +03:00
|
|
|
if (thumbRect.y < mDestinationPoint.y)
|
2011-10-17 18:59:28 +04:00
|
|
|
stop = true;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
} else {
|
2004-01-27 08:19:57 +03:00
|
|
|
if (thumbRect.y + thumbRect.height > mDestinationPoint.y)
|
2011-10-17 18:59:28 +04:00
|
|
|
stop = true;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (stop) {
|
2008-02-15 05:04:34 +03:00
|
|
|
StopRepeat();
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
} else {
|
2014-02-05 05:30:34 +04:00
|
|
|
PageScroll(mChange);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2014-02-05 05:30:34 +04:00
|
|
|
void
|
|
|
|
nsSliderFrame::PageScroll(nscoord aChange)
|
|
|
|
{
|
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir,
|
|
|
|
nsGkAtoms::reverse, eCaseMatters)) {
|
|
|
|
aChange = -aChange;
|
|
|
|
}
|
|
|
|
nsIFrame* scrollbar = GetScrollbar();
|
|
|
|
nsScrollbarFrame* sb = do_QueryFrame(scrollbar);
|
|
|
|
if (sb) {
|
|
|
|
nsIScrollbarMediator* m = sb->GetScrollbarMediator();
|
|
|
|
sb->SetIncrementToPage(aChange);
|
|
|
|
if (m) {
|
2015-03-25 21:40:31 +03:00
|
|
|
m->ScrollByPage(sb, aChange, nsIScrollbarMediator::ENABLE_SNAP);
|
2014-02-05 05:30:34 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PageUpDown(aChange);
|
|
|
|
}
|
|
|
|
|
2015-04-13 06:03:02 +03:00
|
|
|
float
|
|
|
|
nsSliderFrame::GetThumbRatio() const
|
|
|
|
{
|
|
|
|
// mRatio is in thumb app units per scrolled css pixels. Convert it to a
|
2015-04-29 14:22:27 +03:00
|
|
|
// ratio of the thumb's CSS pixels per scrolled CSS pixels. (Note the thumb
|
|
|
|
// is in the scrollframe's parent's space whereas the scrolled CSS pixels
|
|
|
|
// are in the scrollframe's space).
|
2015-04-13 06:03:02 +03:00
|
|
|
return mRatio / mozilla::AppUnitsPerCSSPixel();
|
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsSliderMediator,
|
|
|
|
nsIDOMEventListener)
|