2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-08-20 02:16:23 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-08-20 02:16:23 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-08-20 02:16:23 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2004-04-18 18:30:37 +04:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2010-04-27 20:15:02 +04:00
|
|
|
* Mats Palmgren <matspal@gmail.com>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-29 22:29:03 +04:00
|
|
|
|
|
|
|
/* rendering object to wrap rendering objects that should be scrollable */
|
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsHTMLParts.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2000-01-25 09:35:27 +03:00
|
|
|
#include "nsIServiceManager.h"
|
1999-08-20 02:16:23 +04:00
|
|
|
#include "nsIView.h"
|
2004-09-05 03:03:04 +04:00
|
|
|
#include "nsIScrollable.h"
|
1999-08-20 02:16:23 +04:00
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsHTMLContainerFrame.h"
|
|
|
|
#include "nsGfxScrollFrame.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1999-08-20 02:16:23 +04:00
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsIDocument.h"
|
2011-04-08 05:05:49 +04:00
|
|
|
#include "nsFontMetrics.h"
|
1999-10-12 04:16:06 +04:00
|
|
|
#include "nsIDocumentObserver.h"
|
|
|
|
#include "nsIDocument.h"
|
2000-03-31 11:02:06 +04:00
|
|
|
#include "nsBoxLayoutState.h"
|
2000-05-10 17:13:39 +04:00
|
|
|
#include "nsINodeInfo.h"
|
2011-07-11 18:05:09 +04:00
|
|
|
#include "nsScrollbarFrame.h"
|
2000-07-14 03:00:59 +04:00
|
|
|
#include "nsIScrollbarMediator.h"
|
2002-07-27 00:57:24 +04:00
|
|
|
#include "nsITextControlFrame.h"
|
2004-09-04 07:17:18 +04:00
|
|
|
#include "nsIDOMHTMLTextAreaElement.h"
|
2004-06-25 16:26:02 +04:00
|
|
|
#include "nsNodeInfoManager.h"
|
2002-01-23 05:53:02 +03:00
|
|
|
#include "nsIURI.h"
|
2002-06-21 01:47:59 +04:00
|
|
|
#include "nsGUIEvent.h"
|
2004-06-25 16:26:02 +04:00
|
|
|
#include "nsContentCreatorFunctions.h"
|
2004-09-13 06:10:29 +04:00
|
|
|
#include "nsISupportsPrimitives.h"
|
2005-01-28 01:52:53 +03:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsPresState.h"
|
2005-08-25 04:10:37 +04:00
|
|
|
#include "nsDocShellCID.h"
|
2008-02-19 21:47:34 +03:00
|
|
|
#include "nsIHTMLDocument.h"
|
2006-03-07 20:08:51 +03:00
|
|
|
#include "nsEventDispatcher.h"
|
2007-02-18 20:34:09 +03:00
|
|
|
#include "nsContentUtils.h"
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
#include "nsLayoutUtils.h"
|
2004-09-01 18:58:34 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2011-01-28 07:38:14 +03:00
|
|
|
#include "nsAccessibilityService.h"
|
2004-09-01 18:58:34 +04:00
|
|
|
#endif
|
2006-03-26 04:48:03 +04:00
|
|
|
#include "nsBidiUtils.h"
|
2009-09-30 02:18:20 +04:00
|
|
|
#include "nsFrameManager.h"
|
2011-06-12 06:30:16 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2011-09-09 06:27:13 +04:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2010-05-05 22:18:05 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2011-02-10 11:58:11 +03:00
|
|
|
#include "FrameLayerBuilder.h"
|
2011-03-26 07:30:19 +03:00
|
|
|
#include "nsSMILKeySpline.h"
|
2010-04-30 17:12:05 +04:00
|
|
|
|
2011-02-10 11:58:11 +03:00
|
|
|
using namespace mozilla;
|
2010-04-30 17:12:05 +04:00
|
|
|
using namespace mozilla::dom;
|
2005-08-22 03:37:13 +04:00
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2004-06-18 06:08:19 +04:00
|
|
|
//----------nsHTMLScrollFrame-------------------------------------------
|
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_NewHTMLScrollFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, bool aIsRoot)
|
2004-06-18 06:08:19 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsHTMLScrollFrame(aPresShell, aContext, aIsRoot);
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsHTMLScrollFrame)
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
nsHTMLScrollFrame::nsHTMLScrollFrame(nsIPresShell* aShell, nsStyleContext* aContext, bool aIsRoot)
|
2006-03-27 01:30:36 +04:00
|
|
|
: nsHTMLContainerFrame(aContext),
|
2011-02-07 10:59:20 +03:00
|
|
|
mInner(this, aIsRoot)
|
2004-06-18 06:08:19 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
nsresult
|
2011-05-07 00:04:44 +04:00
|
|
|
nsHTMLScrollFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
2004-06-18 06:08:19 +04:00
|
|
|
{
|
2007-02-18 20:34:09 +03:00
|
|
|
return mInner.CreateAnonymousContent(aElements);
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
|
|
|
|
2010-02-11 20:34:01 +03:00
|
|
|
void
|
2010-10-15 19:34:35 +04:00
|
|
|
nsHTMLScrollFrame::AppendAnonymousContentTo(nsBaseContentList& aElements,
|
|
|
|
PRUint32 aFilter)
|
2010-02-11 20:34:01 +03:00
|
|
|
{
|
2010-10-15 19:34:35 +04:00
|
|
|
mInner.AppendAnonymousContentTo(aElements, aFilter);
|
2010-02-11 20:34:01 +03:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsHTMLScrollFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2004-06-18 06:08:19 +04:00
|
|
|
{
|
2007-02-18 20:34:09 +03:00
|
|
|
mInner.Destroy();
|
2011-05-12 03:53:34 +04:00
|
|
|
DestroyAbsoluteFrames(aDestructRoot);
|
2009-12-24 08:21:15 +03:00
|
|
|
nsHTMLContainerFrame::DestroyFrom(aDestructRoot);
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsHTMLScrollFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList)
|
2004-06-18 06:08:19 +04:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
nsresult rv = nsHTMLContainerFrame::SetInitialChildList(aListID, aChildList);
|
2004-06-18 06:08:19 +04:00
|
|
|
mInner.ReloadChildFrames();
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsHTMLScrollFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2005-02-07 04:58:25 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "Only main list supported");
|
2005-04-29 01:57:22 +04:00
|
|
|
mFrames.AppendFrames(nsnull, aFrameList);
|
2004-06-18 06:08:19 +04:00
|
|
|
mInner.ReloadChildFrames();
|
2005-04-29 01:57:22 +04:00
|
|
|
return NS_OK;
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsHTMLScrollFrame::InsertFrames(ChildListID aListID,
|
2005-04-29 01:57:22 +04:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2005-02-07 04:58:25 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "Only main list supported");
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
2005-04-29 01:57:22 +04:00
|
|
|
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
|
2004-06-18 06:08:19 +04:00
|
|
|
mInner.ReloadChildFrames();
|
2005-04-29 01:57:22 +04:00
|
|
|
return NS_OK;
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsHTMLScrollFrame::RemoveFrame(ChildListID aListID,
|
2005-04-29 01:57:22 +04:00
|
|
|
nsIFrame* aOldFrame)
|
2005-02-07 04:58:25 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "Only main list supported");
|
2007-11-19 01:24:21 +03:00
|
|
|
mFrames.DestroyFrame(aOldFrame);
|
2004-06-18 06:08:19 +04:00
|
|
|
mInner.ReloadChildFrames();
|
2005-04-29 01:57:22 +04:00
|
|
|
return NS_OK;
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
|
|
|
|
2006-12-20 06:52:34 +03:00
|
|
|
nsSplittableType
|
|
|
|
nsHTMLScrollFrame::GetSplittableType() const
|
2006-08-24 09:22:16 +04:00
|
|
|
{
|
2006-12-20 06:52:34 +03:00
|
|
|
return NS_FRAME_NOT_SPLITTABLE;
|
2006-08-24 09:22:16 +04:00
|
|
|
}
|
2004-06-18 06:08:19 +04:00
|
|
|
|
|
|
|
PRIntn
|
|
|
|
nsHTMLScrollFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsHTMLScrollFrame::GetType() const
|
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::scrollFrame;
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
|
|
|
|
2008-07-14 02:21:11 +04:00
|
|
|
void
|
|
|
|
nsHTMLScrollFrame::InvalidateInternal(const nsRect& aDamageRect,
|
|
|
|
nscoord aX, nscoord aY, nsIFrame* aForChild,
|
2008-09-18 13:47:21 +04:00
|
|
|
PRUint32 aFlags)
|
2008-07-14 02:21:11 +04:00
|
|
|
{
|
2009-07-27 01:29:01 +04:00
|
|
|
if (aForChild) {
|
|
|
|
if (aForChild == mInner.mScrolledFrame) {
|
|
|
|
nsRect damage = aDamageRect + nsPoint(aX, aY);
|
2010-12-20 04:37:43 +03:00
|
|
|
// This is the damage rect that we're going to pass up to our parent.
|
|
|
|
nsRect parentDamage;
|
2011-03-12 02:12:11 +03:00
|
|
|
// If we're using a displayport, we might be displaying an area
|
|
|
|
// different than our scroll port and the damage needs to be
|
|
|
|
// clipped to that instead.
|
2011-03-10 00:35:27 +03:00
|
|
|
nsRect displayport;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool usingDisplayport = nsLayoutUtils::GetDisplayPort(GetContent(),
|
2011-03-10 00:35:27 +03:00
|
|
|
&displayport);
|
|
|
|
if (usingDisplayport) {
|
|
|
|
parentDamage.IntersectRect(damage, displayport);
|
2011-03-12 02:12:11 +03:00
|
|
|
} else {
|
|
|
|
parentDamage.IntersectRect(damage, mInner.mScrollPort);
|
|
|
|
}
|
2010-12-20 04:37:43 +03:00
|
|
|
|
|
|
|
if (IsScrollingActive()) {
|
|
|
|
// This is the damage rect that we're going to pass up and
|
|
|
|
// only request invalidation of ThebesLayers for.
|
|
|
|
// damage is now in our coordinate system, which means it was
|
|
|
|
// translated using the current scroll position. Adjust it to
|
|
|
|
// reflect the scroll position at last paint, since that's what
|
|
|
|
// the ThebesLayers are currently set up for.
|
|
|
|
// This should not be clipped to the scrollport since ThebesLayers
|
|
|
|
// can contain content outside the scrollport that may need to be
|
|
|
|
// invalidated.
|
|
|
|
nsRect thebesLayerDamage = damage + GetScrollPosition() - mInner.mScrollPosAtLastPaint;
|
2011-04-19 07:07:23 +04:00
|
|
|
if (parentDamage.IsEqualInterior(thebesLayerDamage)) {
|
2010-12-20 04:37:43 +03:00
|
|
|
// This single call will take care of both rects
|
|
|
|
nsHTMLContainerFrame::InvalidateInternal(parentDamage, 0, 0, aForChild, aFlags);
|
|
|
|
} else {
|
|
|
|
// Invalidate rects separately
|
|
|
|
if (!(aFlags & INVALIDATE_NO_THEBES_LAYERS)) {
|
|
|
|
nsHTMLContainerFrame::InvalidateInternal(thebesLayerDamage, 0, 0, aForChild,
|
|
|
|
aFlags | INVALIDATE_ONLY_THEBES_LAYERS);
|
|
|
|
}
|
|
|
|
if (!(aFlags & INVALIDATE_ONLY_THEBES_LAYERS) && !parentDamage.IsEmpty()) {
|
|
|
|
nsHTMLContainerFrame::InvalidateInternal(parentDamage, 0, 0, aForChild,
|
|
|
|
aFlags | INVALIDATE_NO_THEBES_LAYERS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!parentDamage.IsEmpty()) {
|
|
|
|
nsHTMLContainerFrame::InvalidateInternal(parentDamage, 0, 0, aForChild, aFlags);
|
|
|
|
}
|
2010-10-15 05:03:46 +04:00
|
|
|
}
|
2010-12-20 04:37:43 +03:00
|
|
|
|
2011-04-19 07:07:23 +04:00
|
|
|
if (mInner.mIsRoot && !parentDamage.IsEqualInterior(damage)) {
|
2009-07-27 01:29:01 +04:00
|
|
|
// Make sure we notify our prescontext about invalidations outside
|
|
|
|
// viewport clipping.
|
|
|
|
// This is important for things that are snapshotting the viewport,
|
|
|
|
// possibly outside the scrolled bounds.
|
|
|
|
// We don't need to propagate this any further up, though. Anyone who
|
|
|
|
// cares about scrolled-out-of-view invalidates had better be listening
|
|
|
|
// to our window directly.
|
2009-09-04 08:49:18 +04:00
|
|
|
PresContext()->NotifyInvalidation(damage, aFlags);
|
2009-07-27 01:29:01 +04:00
|
|
|
}
|
2009-07-22 04:44:49 +04:00
|
|
|
return;
|
2009-07-27 01:29:01 +04:00
|
|
|
} else if (aForChild == mInner.mHScrollbarBox) {
|
|
|
|
if (!mInner.mHasHorizontalScrollbar) {
|
|
|
|
// Our scrollbars may send up invalidations even when they're collapsed,
|
|
|
|
// because we just size a collapsed scrollbar to empty and some
|
|
|
|
// descendants may be non-empty. Suppress that invalidation here.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (aForChild == mInner.mVScrollbarBox) {
|
|
|
|
if (!mInner.mHasVerticalScrollbar) {
|
|
|
|
// Our scrollbars may send up invalidations even when they're collapsed,
|
|
|
|
// because we just size a collapsed scrollbar to empty and some
|
|
|
|
// descendants may be non-empty. Suppress that invalidation here.
|
|
|
|
return;
|
|
|
|
}
|
2008-07-14 02:21:11 +04:00
|
|
|
}
|
|
|
|
}
|
2009-07-22 04:44:49 +04:00
|
|
|
|
2008-09-18 13:47:21 +04:00
|
|
|
nsHTMLContainerFrame::InvalidateInternal(aDamageRect, aX, aY, aForChild, aFlags);
|
2008-07-14 02:21:11 +04:00
|
|
|
}
|
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
/**
|
|
|
|
HTML scrolling implementation
|
2005-04-04 01:00:41 +04:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
All other things being equal, we prefer layouts with fewer scrollbars showing.
|
|
|
|
*/
|
2004-06-18 06:08:19 +04:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
struct ScrollReflowState {
|
|
|
|
const nsHTMLReflowState& mReflowState;
|
|
|
|
nsBoxLayoutState mBoxState;
|
|
|
|
nsGfxScrollFrameInner::ScrollbarStyles mStyles;
|
2005-05-03 02:49:44 +04:00
|
|
|
nsMargin mComputedBorder;
|
2005-04-29 01:57:22 +04:00
|
|
|
|
2007-12-05 06:05:57 +03:00
|
|
|
// === Filled in by ReflowScrolledFrame ===
|
2009-10-08 07:01:15 +04:00
|
|
|
nsRect mContentsOverflowArea;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mReflowedContentsWithHScrollbar;
|
|
|
|
bool mReflowedContentsWithVScrollbar;
|
2007-12-05 06:05:57 +03:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
// === Filled in when TryLayout succeeds ===
|
|
|
|
// The size of the inside-border area
|
|
|
|
nsSize mInsideBorderSize;
|
|
|
|
// Whether we decided to show the horizontal scrollbar
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mShowHScrollbar;
|
2005-04-29 01:57:22 +04:00
|
|
|
// Whether we decided to show the vertical scrollbar
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mShowVScrollbar;
|
2005-04-29 01:57:22 +04:00
|
|
|
|
|
|
|
ScrollReflowState(nsIScrollableFrame* aFrame,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
const nsHTMLReflowState& aState) :
|
2005-04-29 01:57:22 +04:00
|
|
|
mReflowState(aState),
|
2008-04-10 08:39:41 +04:00
|
|
|
// mBoxState is just used for scrollbars so we don't need to
|
|
|
|
// worry about the reflow depth here
|
|
|
|
mBoxState(aState.frame->PresContext(), aState.rendContext, 0),
|
2005-04-29 01:57:22 +04:00
|
|
|
mStyles(aFrame->GetScrollbarStyles()) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// XXXldb Can this go away?
|
2005-04-29 01:57:22 +04:00
|
|
|
static nsSize ComputeInsideBorderSize(ScrollReflowState* aState,
|
2005-05-03 02:49:44 +04:00
|
|
|
const nsSize& aDesiredInsideBorderSize)
|
2005-04-29 01:57:22 +04:00
|
|
|
{
|
2005-05-03 02:49:44 +04:00
|
|
|
// aDesiredInsideBorderSize is the frame size; i.e., it includes
|
|
|
|
// borders and padding (but the scrolled child doesn't have
|
|
|
|
// borders). The scrolled child has the same padding as us.
|
2007-01-26 03:05:12 +03:00
|
|
|
nscoord contentWidth = aState->mReflowState.ComputedWidth();
|
2005-05-03 02:49:44 +04:00
|
|
|
if (contentWidth == NS_UNCONSTRAINEDSIZE) {
|
|
|
|
contentWidth = aDesiredInsideBorderSize.width -
|
|
|
|
aState->mReflowState.mComputedPadding.LeftRight();
|
2005-04-29 01:57:22 +04:00
|
|
|
}
|
2007-08-02 22:08:05 +04:00
|
|
|
nscoord contentHeight = aState->mReflowState.ComputedHeight();
|
2005-05-03 02:49:44 +04:00
|
|
|
if (contentHeight == NS_UNCONSTRAINEDSIZE) {
|
|
|
|
contentHeight = aDesiredInsideBorderSize.height -
|
|
|
|
aState->mReflowState.mComputedPadding.TopBottom();
|
2005-04-29 01:57:22 +04:00
|
|
|
}
|
2005-05-03 02:49:44 +04:00
|
|
|
|
|
|
|
aState->mReflowState.ApplyMinMaxConstraints(&contentWidth, &contentHeight);
|
|
|
|
return nsSize(contentWidth + aState->mReflowState.mComputedPadding.LeftRight(),
|
|
|
|
contentHeight + aState->mReflowState.mComputedPadding.TopBottom());
|
2005-04-29 01:57:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-05-09 02:33:40 +04:00
|
|
|
GetScrollbarMetrics(nsBoxLayoutState& aState, nsIBox* aBox, nsSize* aMin,
|
2011-09-29 10:19:26 +04:00
|
|
|
nsSize* aPref, bool aVertical)
|
2005-04-29 01:57:22 +04:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
NS_ASSERTION(aState.GetRenderingContext(),
|
|
|
|
"Must have rendering context in layout state for size "
|
|
|
|
"computations");
|
|
|
|
|
2005-05-09 02:33:40 +04:00
|
|
|
if (aMin) {
|
2007-01-08 05:57:59 +03:00
|
|
|
*aMin = aBox->GetMinSize(aState);
|
2010-04-03 02:25:40 +04:00
|
|
|
nsBox::AddMargin(aBox, *aMin);
|
2005-05-09 02:33:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aPref) {
|
2007-01-08 05:57:59 +03:00
|
|
|
*aPref = aBox->GetPrefSize(aState);
|
2010-04-03 02:25:40 +04:00
|
|
|
nsBox::AddMargin(aBox, *aPref);
|
2005-04-29 01:57:22 +04:00
|
|
|
}
|
|
|
|
}
|
2004-06-18 06:08:19 +04:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
/**
|
|
|
|
* Assuming that we know the metrics for our wrapped frame and
|
|
|
|
* whether the horizontal and/or vertical scrollbars are present,
|
2011-10-17 18:59:28 +04:00
|
|
|
* compute the resulting layout and return true if the layout is
|
2005-04-29 01:57:22 +04:00
|
|
|
* consistent. If the layout is consistent then we fill in the
|
|
|
|
* computed fields of the ScrollReflowState.
|
|
|
|
*
|
|
|
|
* The layout is consistent when both scrollbars are showing if and only
|
|
|
|
* if they should be showing. A horizontal scrollbar should be showing if all
|
|
|
|
* following conditions are met:
|
|
|
|
* 1) the style is not HIDDEN
|
|
|
|
* 2) our inside-border height is at least the scrollbar height (i.e., the
|
|
|
|
* scrollbar fits vertically)
|
|
|
|
* 3) our scrollport width (the inside-border width minus the width allocated for a
|
|
|
|
* vertical scrollbar, if showing) is at least the scrollbar's min-width
|
|
|
|
* (i.e., the scrollbar fits horizontally)
|
|
|
|
* 4) the style is SCROLL, or the kid's overflow-area XMost is
|
|
|
|
* greater than the scrollport width
|
|
|
|
*
|
2011-10-17 18:59:28 +04:00
|
|
|
* @param aForce if true, then we just assume the layout is consistent.
|
2005-04-29 01:57:22 +04:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2005-04-29 01:57:22 +04:00
|
|
|
nsHTMLScrollFrame::TryLayout(ScrollReflowState* aState,
|
2007-12-05 06:05:57 +03:00
|
|
|
nsHTMLReflowMetrics* aKidMetrics,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aAssumeHScroll, bool aAssumeVScroll,
|
|
|
|
bool aForce, nsresult* aResult)
|
2005-04-29 01:57:22 +04:00
|
|
|
{
|
2007-12-05 06:05:57 +03:00
|
|
|
*aResult = NS_OK;
|
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
if ((aState->mStyles.mVertical == NS_STYLE_OVERFLOW_HIDDEN && aAssumeVScroll) ||
|
|
|
|
(aState->mStyles.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN && aAssumeHScroll)) {
|
|
|
|
NS_ASSERTION(!aForce, "Shouldn't be forcing a hidden scrollbar to show!");
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
2007-12-05 06:05:57 +03:00
|
|
|
|
|
|
|
if (aAssumeVScroll != aState->mReflowedContentsWithVScrollbar ||
|
2008-02-23 13:15:59 +03:00
|
|
|
(aAssumeHScroll != aState->mReflowedContentsWithHScrollbar &&
|
|
|
|
ScrolledContentDependsOnHeight(aState))) {
|
2007-12-05 06:05:57 +03:00
|
|
|
nsresult rv = ReflowScrolledFrame(aState, aAssumeHScroll, aAssumeVScroll,
|
2011-10-17 18:59:28 +04:00
|
|
|
aKidMetrics, false);
|
2007-12-05 06:05:57 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
*aResult = rv;
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2007-12-05 06:05:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
nsSize vScrollbarMinSize(0, 0);
|
2005-05-09 02:33:40 +04:00
|
|
|
nsSize vScrollbarPrefSize(0, 0);
|
2005-04-29 01:57:22 +04:00
|
|
|
if (mInner.mVScrollbarBox) {
|
|
|
|
GetScrollbarMetrics(aState->mBoxState, mInner.mVScrollbarBox,
|
2005-05-09 02:33:40 +04:00
|
|
|
&vScrollbarMinSize,
|
2011-10-17 18:59:28 +04:00
|
|
|
aAssumeVScroll ? &vScrollbarPrefSize : nsnull, true);
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
2005-05-09 02:33:40 +04:00
|
|
|
nscoord vScrollbarDesiredWidth = aAssumeVScroll ? vScrollbarPrefSize.width : 0;
|
2008-02-25 04:21:08 +03:00
|
|
|
nscoord vScrollbarMinHeight = aAssumeVScroll ? vScrollbarMinSize.height : 0;
|
2004-06-18 06:08:19 +04:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
nsSize hScrollbarMinSize(0, 0);
|
2005-05-09 02:33:40 +04:00
|
|
|
nsSize hScrollbarPrefSize(0, 0);
|
2005-04-29 01:57:22 +04:00
|
|
|
if (mInner.mHScrollbarBox) {
|
|
|
|
GetScrollbarMetrics(aState->mBoxState, mInner.mHScrollbarBox,
|
2005-05-09 02:33:40 +04:00
|
|
|
&hScrollbarMinSize,
|
2011-10-17 18:59:28 +04:00
|
|
|
aAssumeHScroll ? &hScrollbarPrefSize : nsnull, false);
|
2005-04-29 01:57:22 +04:00
|
|
|
}
|
2005-05-09 02:33:40 +04:00
|
|
|
nscoord hScrollbarDesiredHeight = aAssumeHScroll ? hScrollbarPrefSize.height : 0;
|
2008-02-25 04:21:08 +03:00
|
|
|
nscoord hScrollbarMinWidth = aAssumeHScroll ? hScrollbarMinSize.width : 0;
|
2005-04-29 01:57:22 +04:00
|
|
|
|
|
|
|
// First, compute our inside-border size and scrollport size
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// XXXldb Can we depend more on ComputeSize here?
|
2005-04-29 01:57:22 +04:00
|
|
|
nsSize desiredInsideBorderSize;
|
2005-05-09 02:33:40 +04:00
|
|
|
desiredInsideBorderSize.width = vScrollbarDesiredWidth +
|
2009-09-16 19:01:36 +04:00
|
|
|
NS_MAX(aKidMetrics->width, hScrollbarMinWidth);
|
2005-05-09 02:33:40 +04:00
|
|
|
desiredInsideBorderSize.height = hScrollbarDesiredHeight +
|
2009-09-16 19:01:36 +04:00
|
|
|
NS_MAX(aKidMetrics->height, vScrollbarMinHeight);
|
2005-04-29 01:57:22 +04:00
|
|
|
aState->mInsideBorderSize =
|
2005-05-03 02:49:44 +04:00
|
|
|
ComputeInsideBorderSize(aState, desiredInsideBorderSize);
|
2009-09-16 19:01:36 +04:00
|
|
|
nsSize scrollPortSize = nsSize(NS_MAX(0, aState->mInsideBorderSize.width - vScrollbarDesiredWidth),
|
|
|
|
NS_MAX(0, aState->mInsideBorderSize.height - hScrollbarDesiredHeight));
|
2005-05-09 02:33:40 +04:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
if (!aForce) {
|
2009-10-08 07:01:15 +04:00
|
|
|
nsRect scrolledRect =
|
|
|
|
mInner.GetScrolledRectInternal(aState->mContentsOverflowArea, scrollPortSize);
|
2008-04-24 12:14:06 +04:00
|
|
|
nscoord oneDevPixel = aState->mBoxState.PresContext()->DevPixelsToAppUnits(1);
|
2006-03-15 19:55:19 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
// If the style is HIDDEN then we already know that aAssumeHScroll is false
|
2005-04-29 01:57:22 +04:00
|
|
|
if (aState->mStyles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool wantHScrollbar =
|
2006-03-15 19:55:19 +03:00
|
|
|
aState->mStyles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL ||
|
2008-04-24 12:14:06 +04:00
|
|
|
scrolledRect.XMost() >= scrollPortSize.width + oneDevPixel ||
|
|
|
|
scrolledRect.x <= -oneDevPixel;
|
2005-04-29 01:57:22 +04:00
|
|
|
if (aState->mInsideBorderSize.height < hScrollbarMinSize.height ||
|
|
|
|
scrollPortSize.width < hScrollbarMinSize.width)
|
2011-10-17 18:59:28 +04:00
|
|
|
wantHScrollbar = false;
|
2005-04-29 01:57:22 +04:00
|
|
|
if (wantHScrollbar != aAssumeHScroll)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
// If the style is HIDDEN then we already know that aAssumeVScroll is false
|
2005-04-29 01:57:22 +04:00
|
|
|
if (aState->mStyles.mVertical != NS_STYLE_OVERFLOW_HIDDEN) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool wantVScrollbar =
|
2006-03-15 19:55:19 +03:00
|
|
|
aState->mStyles.mVertical == NS_STYLE_OVERFLOW_SCROLL ||
|
2008-04-24 12:14:06 +04:00
|
|
|
scrolledRect.YMost() >= scrollPortSize.height + oneDevPixel ||
|
|
|
|
scrolledRect.y <= -oneDevPixel;
|
2005-04-29 01:57:22 +04:00
|
|
|
if (aState->mInsideBorderSize.width < vScrollbarMinSize.width ||
|
|
|
|
scrollPortSize.height < vScrollbarMinSize.height)
|
2011-10-17 18:59:28 +04:00
|
|
|
wantVScrollbar = false;
|
2005-04-29 01:57:22 +04:00
|
|
|
if (wantVScrollbar != aAssumeVScroll)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2005-04-29 01:57:22 +04:00
|
|
|
}
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
|
|
|
|
2005-05-09 02:33:40 +04:00
|
|
|
nscoord vScrollbarActualWidth = aState->mInsideBorderSize.width - scrollPortSize.width;
|
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
aState->mShowHScrollbar = aAssumeHScroll;
|
|
|
|
aState->mShowVScrollbar = aAssumeVScroll;
|
2005-05-03 02:49:44 +04:00
|
|
|
nsPoint scrollPortOrigin(aState->mComputedBorder.left,
|
|
|
|
aState->mComputedBorder.top);
|
2005-04-29 01:57:22 +04:00
|
|
|
if (!mInner.IsScrollbarOnRight()) {
|
|
|
|
scrollPortOrigin.x += vScrollbarActualWidth;
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
2009-10-08 07:01:15 +04:00
|
|
|
mInner.mScrollPort = nsRect(scrollPortOrigin, scrollPortSize);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2005-04-29 01:57:22 +04:00
|
|
|
}
|
2004-06-18 06:08:19 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2008-02-23 13:15:59 +03:00
|
|
|
nsHTMLScrollFrame::ScrolledContentDependsOnHeight(ScrollReflowState* aState)
|
|
|
|
{
|
|
|
|
// Return true if ReflowScrolledFrame is going to do something different
|
|
|
|
// based on the presence of a horizontal scrollbar.
|
|
|
|
return (mInner.mScrolledFrame->GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_HEIGHT) ||
|
|
|
|
aState->mReflowState.ComputedHeight() != NS_UNCONSTRAINEDSIZE ||
|
|
|
|
aState->mReflowState.mComputedMinHeight > 0 ||
|
|
|
|
aState->mReflowState.mComputedMaxHeight != NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
nsresult
|
2007-12-05 06:05:57 +03:00
|
|
|
nsHTMLScrollFrame::ReflowScrolledFrame(ScrollReflowState* aState,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aAssumeHScroll,
|
|
|
|
bool aAssumeVScroll,
|
2005-04-29 01:57:22 +04:00
|
|
|
nsHTMLReflowMetrics* aMetrics,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aFirstPass)
|
2005-04-29 01:57:22 +04:00
|
|
|
{
|
2009-09-16 19:01:36 +04:00
|
|
|
// these could be NS_UNCONSTRAINEDSIZE ... NS_MIN arithmetic should
|
2005-04-29 01:57:22 +04:00
|
|
|
// be OK
|
2007-12-05 06:05:57 +03:00
|
|
|
nscoord paddingLR = aState->mReflowState.mComputedPadding.LeftRight();
|
|
|
|
|
|
|
|
nscoord availWidth = aState->mReflowState.ComputedWidth() + paddingLR;
|
|
|
|
|
|
|
|
nscoord computedHeight = aState->mReflowState.ComputedHeight();
|
|
|
|
nscoord computedMinHeight = aState->mReflowState.mComputedMinHeight;
|
|
|
|
nscoord computedMaxHeight = aState->mReflowState.mComputedMaxHeight;
|
2007-12-07 03:10:31 +03:00
|
|
|
if (!ShouldPropagateComputedHeightToScrolledContent()) {
|
|
|
|
computedHeight = NS_UNCONSTRAINEDSIZE;
|
|
|
|
computedMinHeight = 0;
|
|
|
|
computedMaxHeight = NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
2007-12-05 06:05:57 +03:00
|
|
|
if (aAssumeHScroll) {
|
|
|
|
nsSize hScrollbarPrefSize =
|
|
|
|
mInner.mHScrollbarBox->GetPrefSize(const_cast<nsBoxLayoutState&>(aState->mBoxState));
|
|
|
|
if (computedHeight != NS_UNCONSTRAINEDSIZE)
|
2009-09-16 19:01:36 +04:00
|
|
|
computedHeight = NS_MAX(0, computedHeight - hScrollbarPrefSize.height);
|
|
|
|
computedMinHeight = NS_MAX(0, computedMinHeight - hScrollbarPrefSize.height);
|
2007-12-05 06:05:57 +03:00
|
|
|
if (computedMaxHeight != NS_UNCONSTRAINEDSIZE)
|
2009-09-16 19:01:36 +04:00
|
|
|
computedMaxHeight = NS_MAX(0, computedMaxHeight - hScrollbarPrefSize.height);
|
2007-12-05 06:05:57 +03:00
|
|
|
}
|
2007-12-07 03:10:31 +03:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (aAssumeVScroll) {
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize vScrollbarPrefSize =
|
2007-12-05 06:05:57 +03:00
|
|
|
mInner.mVScrollbarBox->GetPrefSize(const_cast<nsBoxLayoutState&>(aState->mBoxState));
|
2009-09-16 19:01:36 +04:00
|
|
|
availWidth = NS_MAX(0, availWidth - vScrollbarPrefSize.width);
|
2005-04-29 01:57:22 +04:00
|
|
|
}
|
2007-03-23 02:01:14 +03:00
|
|
|
|
2010-03-29 05:46:55 +04:00
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
// Pass false for aInit so we can pass in the correct padding.
|
2007-12-05 06:05:57 +03:00
|
|
|
nsHTMLReflowState kidReflowState(presContext, aState->mReflowState,
|
2005-04-29 01:57:22 +04:00
|
|
|
mInner.mScrolledFrame,
|
2006-12-12 18:18:40 +03:00
|
|
|
nsSize(availWidth, NS_UNCONSTRAINEDSIZE),
|
2011-10-17 18:59:28 +04:00
|
|
|
-1, -1, false);
|
2006-12-12 18:18:40 +03:00
|
|
|
kidReflowState.Init(presContext, -1, -1, nsnull,
|
2007-12-05 06:05:57 +03:00
|
|
|
&aState->mReflowState.mComputedPadding);
|
2005-10-18 09:00:24 +04:00
|
|
|
kidReflowState.mFlags.mAssumingHScrollbar = aAssumeHScroll;
|
|
|
|
kidReflowState.mFlags.mAssumingVScrollbar = aAssumeVScroll;
|
2007-12-05 06:05:57 +03:00
|
|
|
kidReflowState.SetComputedHeight(computedHeight);
|
|
|
|
kidReflowState.mComputedMinHeight = computedMinHeight;
|
|
|
|
kidReflowState.mComputedMaxHeight = computedMaxHeight;
|
2005-05-03 02:49:44 +04:00
|
|
|
|
2010-01-14 16:00:00 +03:00
|
|
|
// Temporarily set mHasHorizontalScrollbar/mHasVerticalScrollbar to
|
|
|
|
// reflect our assumptions while we reflow the child.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool didHaveHorizontalScrollbar = mInner.mHasHorizontalScrollbar;
|
|
|
|
bool didHaveVerticalScrollbar = mInner.mHasVerticalScrollbar;
|
2010-01-14 16:00:00 +03:00
|
|
|
mInner.mHasHorizontalScrollbar = aAssumeHScroll;
|
|
|
|
mInner.mHasVerticalScrollbar = aAssumeVScroll;
|
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
nsReflowStatus status;
|
2006-12-12 18:18:40 +03:00
|
|
|
nsresult rv = ReflowChild(mInner.mScrolledFrame, presContext, *aMetrics,
|
2005-04-29 01:57:22 +04:00
|
|
|
kidReflowState, 0, 0,
|
|
|
|
NS_FRAME_NO_MOVE_FRAME | NS_FRAME_NO_MOVE_VIEW, status);
|
2010-01-14 16:00:00 +03:00
|
|
|
|
2010-02-17 18:43:39 +03:00
|
|
|
mInner.mHasHorizontalScrollbar = didHaveHorizontalScrollbar;
|
2010-01-14 16:00:00 +03:00
|
|
|
mInner.mHasVerticalScrollbar = didHaveVerticalScrollbar;
|
|
|
|
|
2009-10-08 07:01:15 +04:00
|
|
|
// Don't resize or position the view (if any) because we're going to resize
|
2005-05-09 02:17:03 +04:00
|
|
|
// it to the correct size anyway in PlaceScrollArea. Allowing it to
|
|
|
|
// resize here would size it to the natural height of the frame,
|
|
|
|
// which will usually be different from the scrollport height;
|
|
|
|
// invalidating the difference will cause unnecessary repainting.
|
2006-12-12 18:18:40 +03:00
|
|
|
FinishReflowChild(mInner.mScrolledFrame, presContext,
|
2005-04-29 01:57:22 +04:00
|
|
|
&kidReflowState, *aMetrics, 0, 0,
|
2005-05-09 02:17:03 +04:00
|
|
|
NS_FRAME_NO_MOVE_FRAME | NS_FRAME_NO_MOVE_VIEW | NS_FRAME_NO_SIZE_VIEW);
|
2005-04-29 01:57:22 +04:00
|
|
|
|
|
|
|
// XXX Some frames (e.g., nsObjectFrame, nsFrameFrame, nsTextFrame) don't bother
|
|
|
|
// setting their mOverflowArea. This is wrong because every frame should
|
|
|
|
// always set mOverflowArea. In fact nsObjectFrame and nsFrameFrame don't
|
|
|
|
// support the 'outline' property because of this. Rather than fix the world
|
2005-06-16 06:57:23 +04:00
|
|
|
// right now, just fix up the overflow area if necessary. Note that we don't
|
2009-04-06 04:31:50 +04:00
|
|
|
// check HasOverflowRect() because it could be set even though the
|
2005-06-16 06:57:23 +04:00
|
|
|
// overflow area doesn't include the frame bounds.
|
2010-10-07 08:25:46 +04:00
|
|
|
aMetrics->UnionOverflowAreasWithDesiredBounds();
|
2004-06-18 06:08:19 +04:00
|
|
|
|
2010-10-07 08:25:47 +04:00
|
|
|
aState->mContentsOverflowArea = aMetrics->ScrollableOverflow();
|
2007-12-05 06:05:57 +03:00
|
|
|
aState->mReflowedContentsWithHScrollbar = aAssumeHScroll;
|
|
|
|
aState->mReflowedContentsWithVScrollbar = aAssumeVScroll;
|
|
|
|
|
2004-06-18 06:08:19 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2008-02-23 13:15:59 +03:00
|
|
|
nsHTMLScrollFrame::GuessHScrollbarNeeded(const ScrollReflowState& aState)
|
|
|
|
{
|
|
|
|
if (aState.mStyles.mHorizontal != NS_STYLE_OVERFLOW_AUTO)
|
|
|
|
// no guessing required
|
|
|
|
return aState.mStyles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL;
|
|
|
|
|
|
|
|
return mInner.mHasHorizontalScrollbar;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2005-08-25 04:10:37 +04:00
|
|
|
nsHTMLScrollFrame::GuessVScrollbarNeeded(const ScrollReflowState& aState)
|
2004-06-18 06:08:19 +04:00
|
|
|
{
|
2005-08-25 04:10:37 +04:00
|
|
|
if (aState.mStyles.mVertical != NS_STYLE_OVERFLOW_AUTO)
|
|
|
|
// no guessing required
|
|
|
|
return aState.mStyles.mVertical == NS_STYLE_OVERFLOW_SCROLL;
|
2004-06-18 06:08:19 +04:00
|
|
|
|
2005-08-25 04:10:37 +04:00
|
|
|
// If we've had at least one non-initial reflow, then just assume
|
|
|
|
// the state of the vertical scrollbar will be what we determined
|
|
|
|
// last time.
|
|
|
|
if (mInner.mHadNonInitialReflow) {
|
|
|
|
return mInner.mHasVerticalScrollbar;
|
2005-04-29 01:57:22 +04:00
|
|
|
}
|
2004-06-18 06:08:19 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
// If this is the initial reflow, guess false because usually
|
2005-08-25 04:10:37 +04:00
|
|
|
// we have very little content by then.
|
2007-04-26 06:29:21 +04:00
|
|
|
if (InInitialReflow())
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2005-08-25 04:10:37 +04:00
|
|
|
|
|
|
|
if (mInner.mIsRoot) {
|
2010-05-30 20:38:42 +04:00
|
|
|
// Assume that there will be a scrollbar; it seems to me
|
2005-08-25 04:10:37 +04:00
|
|
|
// that 'most pages' do have a scrollbar, and anyway, it's cheaper
|
|
|
|
// to do an extra reflow for the pages that *don't* need a
|
|
|
|
// scrollbar (because on average they will have less content).
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2005-08-25 04:10:37 +04:00
|
|
|
}
|
2005-04-29 01:57:22 +04:00
|
|
|
|
2005-08-25 04:10:37 +04:00
|
|
|
// For non-viewports, just guess that we don't need a scrollbar.
|
|
|
|
// XXX I wonder if statistically this is the right idea; I'm
|
|
|
|
// basically guessing that there are a lot of overflow:auto DIVs
|
|
|
|
// that get their intrinsic size and don't overflow
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2005-08-25 04:10:37 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2007-04-26 06:29:21 +04:00
|
|
|
nsHTMLScrollFrame::InInitialReflow() const
|
|
|
|
{
|
|
|
|
// We're in an initial reflow if NS_FRAME_FIRST_REFLOW is set, unless we're a
|
2007-05-01 21:15:08 +04:00
|
|
|
// root scrollframe. In that case we want to skip this clause altogether.
|
|
|
|
// The guess here is that there are lots of overflow:auto divs out there that
|
|
|
|
// end up auto-sizing so they don't overflow, and that the root basically
|
|
|
|
// always needs a scrollbar if it did last time we loaded this page (good
|
|
|
|
// assumption, because our initial reflow is no longer synchronous).
|
|
|
|
return !mInner.mIsRoot && (GetStateBits() & NS_FRAME_FIRST_REFLOW);
|
2007-04-26 06:29:21 +04:00
|
|
|
}
|
|
|
|
|
2005-08-25 04:10:37 +04:00
|
|
|
nsresult
|
|
|
|
nsHTMLScrollFrame::ReflowContents(ScrollReflowState* aState,
|
|
|
|
const nsHTMLReflowMetrics& aDesiredSize)
|
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsHTMLReflowMetrics kidDesiredSize(aDesiredSize.mFlags);
|
2008-02-23 13:15:59 +03:00
|
|
|
nsresult rv = ReflowScrolledFrame(aState, GuessHScrollbarNeeded(*aState),
|
2011-10-17 18:59:28 +04:00
|
|
|
GuessVScrollbarNeeded(*aState), &kidDesiredSize, true);
|
2007-12-05 06:05:57 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2005-04-29 01:57:22 +04:00
|
|
|
|
|
|
|
// There's an important special case ... if the child appears to fit
|
|
|
|
// in the inside-border rect (but overflows the scrollport), we
|
|
|
|
// should try laying it out without a vertical scrollbar. It will
|
|
|
|
// usually fit because making the available-width wider will not
|
|
|
|
// normally make the child taller. (The only situation I can think
|
|
|
|
// of is when you have a line containing %-width inline replaced
|
|
|
|
// elements whose percentages sum to more than 100%, so increasing
|
|
|
|
// the available width makes the line break where it was fitting
|
|
|
|
// before.) If we don't treat this case specially, then we will
|
|
|
|
// decide that showing scrollbars is OK because the content
|
|
|
|
// overflows when we're showing scrollbars and we won't try to
|
|
|
|
// remove the vertical scrollbar.
|
|
|
|
|
|
|
|
// Detecting when we enter this special case is important for when
|
|
|
|
// people design layouts that exactly fit the container "most of the
|
|
|
|
// time".
|
2007-12-05 06:05:57 +03:00
|
|
|
|
|
|
|
// XXX Is this check really sufficient to catch all the incremental cases
|
|
|
|
// where the ideal case doesn't have a scrollbar?
|
|
|
|
if ((aState->mReflowedContentsWithHScrollbar || aState->mReflowedContentsWithVScrollbar) &&
|
2005-04-29 01:57:22 +04:00
|
|
|
aState->mStyles.mVertical != NS_STYLE_OVERFLOW_SCROLL &&
|
|
|
|
aState->mStyles.mHorizontal != NS_STYLE_OVERFLOW_SCROLL) {
|
|
|
|
nsSize insideBorderSize =
|
2005-05-03 02:49:44 +04:00
|
|
|
ComputeInsideBorderSize(aState,
|
|
|
|
nsSize(kidDesiredSize.width, kidDesiredSize.height));
|
2009-10-08 07:01:15 +04:00
|
|
|
nsRect scrolledRect =
|
2010-10-07 08:25:47 +04:00
|
|
|
mInner.GetScrolledRectInternal(kidDesiredSize.ScrollableOverflow(),
|
|
|
|
insideBorderSize);
|
2006-03-15 19:55:19 +03:00
|
|
|
if (nsRect(nsPoint(0, 0), insideBorderSize).Contains(scrolledRect)) {
|
2007-12-05 06:05:57 +03:00
|
|
|
// Let's pretend we had no scrollbars coming in here
|
2011-10-17 18:59:28 +04:00
|
|
|
rv = ReflowScrolledFrame(aState, false, false,
|
|
|
|
&kidDesiredSize, false);
|
2007-12-05 06:05:57 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2005-04-29 01:57:22 +04:00
|
|
|
}
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
2005-04-29 01:57:22 +04:00
|
|
|
|
2007-12-05 06:05:57 +03:00
|
|
|
// Try vertical scrollbar settings that leave the vertical scrollbar unchanged.
|
|
|
|
// Do this first because changing the vertical scrollbar setting is expensive,
|
|
|
|
// forcing a reflow always.
|
|
|
|
|
2008-02-23 13:15:59 +03:00
|
|
|
// Try leaving the horizontal scrollbar unchanged first. This will be more
|
|
|
|
// efficient.
|
|
|
|
if (TryLayout(aState, &kidDesiredSize, aState->mReflowedContentsWithHScrollbar,
|
2011-10-17 18:59:28 +04:00
|
|
|
aState->mReflowedContentsWithVScrollbar, false, &rv))
|
2007-12-01 14:49:13 +03:00
|
|
|
return NS_OK;
|
2008-02-23 13:15:59 +03:00
|
|
|
if (TryLayout(aState, &kidDesiredSize, !aState->mReflowedContentsWithHScrollbar,
|
2011-10-17 18:59:28 +04:00
|
|
|
aState->mReflowedContentsWithVScrollbar, false, &rv))
|
2007-12-01 14:49:13 +03:00
|
|
|
return NS_OK;
|
2005-04-29 01:57:22 +04:00
|
|
|
|
2007-12-05 06:05:57 +03:00
|
|
|
// OK, now try toggling the vertical scrollbar. The performance advantage
|
2008-02-23 13:15:59 +03:00
|
|
|
// of trying the status-quo horizontal scrollbar state
|
2007-12-05 06:05:57 +03:00
|
|
|
// does not exist here (we'll have to reflow due to the vertical scrollbar
|
|
|
|
// change), so always try no horizontal scrollbar first.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool newVScrollbarState = !aState->mReflowedContentsWithVScrollbar;
|
2011-10-17 18:59:28 +04:00
|
|
|
if (TryLayout(aState, &kidDesiredSize, false, newVScrollbarState, false, &rv))
|
2007-12-05 06:05:57 +03:00
|
|
|
return NS_OK;
|
2011-10-17 18:59:28 +04:00
|
|
|
if (TryLayout(aState, &kidDesiredSize, true, newVScrollbarState, false, &rv))
|
2007-12-05 06:05:57 +03:00
|
|
|
return NS_OK;
|
2007-12-01 13:38:09 +03:00
|
|
|
|
2007-12-12 05:28:50 +03:00
|
|
|
// OK, we're out of ideas. Try again enabling whatever scrollbars we can
|
|
|
|
// enable and force the layout to stick even if it's inconsistent.
|
|
|
|
// This just happens sometimes.
|
|
|
|
TryLayout(aState, &kidDesiredSize,
|
|
|
|
aState->mStyles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN,
|
|
|
|
aState->mStyles.mVertical != NS_STYLE_OVERFLOW_HIDDEN,
|
2011-10-17 18:59:28 +04:00
|
|
|
true, &rv);
|
2007-12-05 06:05:57 +03:00
|
|
|
return rv;
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
void
|
2009-10-08 07:01:15 +04:00
|
|
|
nsHTMLScrollFrame::PlaceScrollArea(const ScrollReflowState& aState,
|
|
|
|
const nsPoint& aScrollPosition)
|
2004-06-18 06:08:19 +04:00
|
|
|
{
|
2006-03-15 19:55:19 +03:00
|
|
|
nsIFrame *scrolledFrame = mInner.mScrolledFrame;
|
2009-10-08 07:01:15 +04:00
|
|
|
// Set the x,y of the scrolled frame to the correct value
|
|
|
|
scrolledFrame->SetPosition(mInner.mScrollPort.TopLeft() - aScrollPosition);
|
2006-03-15 19:55:19 +03:00
|
|
|
|
|
|
|
nsRect scrolledArea;
|
2008-02-27 12:46:22 +03:00
|
|
|
// Preserve the width or height of empty rects
|
2009-10-08 07:01:15 +04:00
|
|
|
nsSize portSize = mInner.mScrollPort.Size();
|
|
|
|
nsRect scrolledRect = mInner.GetScrolledRectInternal(aState.mContentsOverflowArea, portSize);
|
2011-04-19 07:07:23 +04:00
|
|
|
scrolledArea.UnionRectEdges(scrolledRect,
|
|
|
|
nsRect(nsPoint(0,0), portSize));
|
2006-03-15 19:55:19 +03:00
|
|
|
|
2005-12-19 04:07:41 +03:00
|
|
|
// Store the new overflow area. Note that this changes where an outline
|
|
|
|
// of the scrolled frame would be painted, but scrolled frames can't have
|
|
|
|
// outlines (the outline would go on this scrollframe instead).
|
2009-04-06 04:31:50 +04:00
|
|
|
// Using FinishAndStoreOverflow is needed so the overflow rect
|
2006-03-27 02:12:54 +04:00
|
|
|
// gets set correctly. It also messes with the overflow rect in the
|
|
|
|
// -moz-hidden-unscrollable case, but scrolled frames can't have
|
|
|
|
// 'overflow' either.
|
2006-03-30 08:26:36 +04:00
|
|
|
// This needs to happen before SyncFrameViewAfterReflow so
|
2009-04-06 04:31:50 +04:00
|
|
|
// HasOverflowRect() will return the correct value.
|
2010-10-07 08:25:45 +04:00
|
|
|
nsOverflowAreas overflow(scrolledArea, scrolledArea);
|
|
|
|
scrolledFrame->FinishAndStoreOverflow(overflow,
|
2006-03-27 02:12:54 +04:00
|
|
|
scrolledFrame->GetSize());
|
2005-12-19 04:07:41 +03:00
|
|
|
|
2006-03-30 08:26:36 +04:00
|
|
|
// Note that making the view *exactly* the size of the scrolled area
|
|
|
|
// is critical, since the view scrolling code uses the size of the
|
|
|
|
// scrolled view to clamp scroll requests.
|
2009-10-08 07:01:15 +04:00
|
|
|
// Normally the scrolledFrame won't have a view but in some cases it
|
|
|
|
// might create its own.
|
2007-03-31 01:11:41 +04:00
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(scrolledFrame->PresContext(),
|
2006-03-30 08:26:36 +04:00
|
|
|
scrolledFrame,
|
2009-10-08 07:01:15 +04:00
|
|
|
scrolledFrame->GetView(),
|
2010-10-07 08:25:46 +04:00
|
|
|
scrolledArea,
|
2009-10-08 07:01:15 +04:00
|
|
|
0);
|
2008-02-28 23:37:06 +03:00
|
|
|
}
|
|
|
|
|
2008-02-28 23:37:06 +03:00
|
|
|
nscoord
|
2011-04-08 05:04:40 +04:00
|
|
|
nsHTMLScrollFrame::GetIntrinsicVScrollbarWidth(nsRenderingContext *aRenderingContext)
|
2008-02-28 23:37:06 +03:00
|
|
|
{
|
|
|
|
nsGfxScrollFrameInner::ScrollbarStyles ss = GetScrollbarStyles();
|
|
|
|
if (ss.mVertical != NS_STYLE_OVERFLOW_SCROLL || !mInner.mVScrollbarBox)
|
|
|
|
return 0;
|
|
|
|
|
2008-04-10 08:39:41 +04:00
|
|
|
// Don't need to worry about reflow depth here since it's
|
|
|
|
// just for scrollbars
|
|
|
|
nsBoxLayoutState bls(PresContext(), aRenderingContext, 0);
|
2008-02-28 23:37:06 +03:00
|
|
|
nsSize vScrollbarPrefSize(0, 0);
|
|
|
|
GetScrollbarMetrics(bls, mInner.mVScrollbarBox,
|
2011-10-17 18:59:28 +04:00
|
|
|
nsnull, &vScrollbarPrefSize, true);
|
2008-02-28 23:37:06 +03:00
|
|
|
return vScrollbarPrefSize.width;
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
/* virtual */ nscoord
|
2011-04-08 05:04:40 +04:00
|
|
|
nsHTMLScrollFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
{
|
2007-12-05 01:03:16 +03:00
|
|
|
nscoord result = mInner.mScrolledFrame->GetMinWidth(aRenderingContext);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
2008-02-28 23:37:06 +03:00
|
|
|
return result + GetIntrinsicVScrollbarWidth(aRenderingContext);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2011-04-08 05:04:40 +04:00
|
|
|
nsHTMLScrollFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
{
|
2008-02-28 23:37:06 +03:00
|
|
|
nscoord result = mInner.mScrolledFrame->GetPrefWidth(aRenderingContext);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
2008-02-28 23:37:06 +03:00
|
|
|
return NSCoordSaturatingAdd(result, GetIntrinsicVScrollbarWidth(aRenderingContext));
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLScrollFrame::GetPadding(nsMargin& aMargin)
|
|
|
|
{
|
|
|
|
// Our padding hangs out on the inside of the scrollframe, but XUL doesn't
|
|
|
|
// reaize that. If we're stuck inside a XUL box, we need to claim no
|
|
|
|
// padding.
|
|
|
|
// @see also nsXULScrollFrame::GetPadding.
|
|
|
|
aMargin.SizeTo(0,0,0,0);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2007-02-03 03:08:19 +03:00
|
|
|
nsHTMLScrollFrame::IsCollapsed(nsBoxLayoutState& aBoxLayoutState)
|
2007-01-22 07:27:31 +03:00
|
|
|
{
|
|
|
|
// We're never collapsed in the box sense.
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2007-01-22 07:27:31 +03:00
|
|
|
}
|
|
|
|
|
2011-01-17 17:35:32 +03:00
|
|
|
// Return the <browser> if the scrollframe is for the root frame directly
|
|
|
|
// inside a <browser>.
|
|
|
|
static nsIContent*
|
|
|
|
GetBrowserRoot(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
if (aContent) {
|
|
|
|
nsIDocument* doc = aContent->GetCurrentDoc();
|
|
|
|
nsPIDOMWindow* win = doc->GetWindow();
|
|
|
|
if (win) {
|
|
|
|
nsCOMPtr<nsIContent> frameContent =
|
|
|
|
do_QueryInterface(win->GetFrameElementInternal());
|
|
|
|
if (frameContent &&
|
|
|
|
frameContent->NodeInfo()->Equals(nsGkAtoms::browser, kNameSpaceID_XUL))
|
|
|
|
return frameContent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-18 06:08:19 +04:00
|
|
|
NS_IMETHODIMP
|
2005-04-29 01:57:22 +04:00
|
|
|
nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
2004-06-18 06:08:19 +04:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLScrollFrame");
|
2004-06-18 06:08:19 +04:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
ScrollReflowState state(this, aReflowState);
|
2005-04-29 01:57:22 +04:00
|
|
|
// sanity check: ensure that if we have no scrollbar, we treat it
|
|
|
|
// as hidden.
|
|
|
|
if (!mInner.mVScrollbarBox || mInner.mNeverHasVerticalScrollbar)
|
|
|
|
state.mStyles.mVertical = NS_STYLE_OVERFLOW_HIDDEN;
|
|
|
|
if (!mInner.mHScrollbarBox || mInner.mNeverHasHorizontalScrollbar)
|
|
|
|
state.mStyles.mHorizontal = NS_STYLE_OVERFLOW_HIDDEN;
|
|
|
|
|
|
|
|
//------------ Handle Incremental Reflow -----------------
|
2011-09-29 10:19:26 +04:00
|
|
|
bool reflowContents = true; // XXX Ignored
|
|
|
|
bool reflowHScrollbar = true;
|
|
|
|
bool reflowVScrollbar = true;
|
|
|
|
bool reflowScrollCorner = true;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (!aReflowState.ShouldReflowAllKids()) {
|
|
|
|
#define NEEDS_REFLOW(frame_) \
|
2007-05-06 23:16:51 +04:00
|
|
|
((frame_) && NS_SUBTREE_DIRTY(frame_))
|
2005-04-29 01:57:22 +04:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
reflowContents = NEEDS_REFLOW(mInner.mScrolledFrame);
|
|
|
|
reflowHScrollbar = NEEDS_REFLOW(mInner.mHScrollbarBox);
|
|
|
|
reflowVScrollbar = NEEDS_REFLOW(mInner.mVScrollbarBox);
|
2011-01-17 17:35:32 +03:00
|
|
|
reflowScrollCorner = NEEDS_REFLOW(mInner.mScrollCornerBox) ||
|
|
|
|
NEEDS_REFLOW(mInner.mResizerBox);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
#undef NEEDS_REFLOW
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
|
|
|
|
2011-01-17 17:35:32 +03:00
|
|
|
if (mInner.mIsRoot) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mInner.mCollapsedResizer = true;
|
2011-01-17 17:35:32 +03:00
|
|
|
|
|
|
|
nsIContent* browserRoot = GetBrowserRoot(mContent);
|
|
|
|
if (browserRoot) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool showResizer = browserRoot->HasAttr(kNameSpaceID_None, nsGkAtoms::showresizer);
|
2011-01-17 17:35:32 +03:00
|
|
|
reflowScrollCorner = showResizer == mInner.mCollapsedResizer;
|
|
|
|
mInner.mCollapsedResizer = !showResizer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-08 07:01:15 +04:00
|
|
|
nsRect oldScrollAreaBounds = mInner.mScrollPort;
|
|
|
|
nsRect oldScrolledAreaBounds =
|
2010-10-07 08:25:47 +04:00
|
|
|
mInner.mScrolledFrame->GetScrollableOverflowRectRelativeToParent();
|
2009-10-08 07:01:15 +04:00
|
|
|
// Adjust to a multiple of device pixels to restore the invariant that
|
|
|
|
// oldScrollPosition is a multiple of device pixels. This could have been
|
|
|
|
// thrown out by a zoom change.
|
|
|
|
nsIntPoint ptDevPx;
|
2010-03-29 05:46:59 +04:00
|
|
|
nsPoint oldScrollPosition = mInner.GetScrollPosition();
|
2009-10-08 07:01:15 +04:00
|
|
|
|
2005-05-03 02:49:44 +04:00
|
|
|
state.mComputedBorder = aReflowState.mComputedBorderPadding -
|
|
|
|
aReflowState.mComputedPadding;
|
2004-06-18 06:08:19 +04:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
nsresult rv = ReflowContents(&state, aDesiredSize);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2010-03-29 05:46:59 +04:00
|
|
|
|
|
|
|
// Restore the old scroll position, for now, even if that's not valid anymore
|
|
|
|
// because we changed size. We'll fix it up in a post-reflow callback, because
|
|
|
|
// our current size may only be temporary (e.g. we're compute XUL desired sizes).
|
2009-10-08 07:01:15 +04:00
|
|
|
PlaceScrollArea(state, oldScrollPosition);
|
2009-06-24 05:35:00 +04:00
|
|
|
if (!mInner.mPostedReflowCallback) {
|
|
|
|
// Make sure we'll try scrolling to restored position
|
|
|
|
PresContext()->PresShell()->PostReflowCallback(&mInner);
|
2011-10-17 18:59:28 +04:00
|
|
|
mInner.mPostedReflowCallback = true;
|
2009-06-24 05:35:00 +04:00
|
|
|
}
|
2005-04-29 01:57:22 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool didHaveHScrollbar = mInner.mHasHorizontalScrollbar;
|
|
|
|
bool didHaveVScrollbar = mInner.mHasVerticalScrollbar;
|
2007-01-19 21:01:10 +03:00
|
|
|
mInner.mHasHorizontalScrollbar = state.mShowHScrollbar;
|
|
|
|
mInner.mHasVerticalScrollbar = state.mShowVScrollbar;
|
2009-10-08 07:01:15 +04:00
|
|
|
nsRect newScrollAreaBounds = mInner.mScrollPort;
|
|
|
|
nsRect newScrolledAreaBounds =
|
2010-10-07 08:25:47 +04:00
|
|
|
mInner.mScrolledFrame->GetScrollableOverflowRectRelativeToParent();
|
2007-01-19 21:01:10 +03:00
|
|
|
if (mInner.mSkippedScrollbarLayout ||
|
|
|
|
reflowHScrollbar || reflowVScrollbar || reflowScrollCorner ||
|
|
|
|
(GetStateBits() & NS_FRAME_IS_DIRTY) ||
|
|
|
|
didHaveHScrollbar != state.mShowHScrollbar ||
|
|
|
|
didHaveVScrollbar != state.mShowVScrollbar ||
|
2011-04-19 07:07:23 +04:00
|
|
|
!oldScrollAreaBounds.IsEqualEdges(newScrollAreaBounds) ||
|
|
|
|
!oldScrolledAreaBounds.IsEqualEdges(newScrolledAreaBounds)) {
|
2007-01-19 21:01:10 +03:00
|
|
|
if (!mInner.mSupppressScrollbarUpdate) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mInner.mSkippedScrollbarLayout = false;
|
2005-07-26 03:23:53 +04:00
|
|
|
mInner.SetScrollbarVisibility(mInner.mHScrollbarBox, state.mShowHScrollbar);
|
|
|
|
mInner.SetScrollbarVisibility(mInner.mVScrollbarBox, state.mShowVScrollbar);
|
|
|
|
// place and reflow scrollbars
|
|
|
|
nsRect insideBorderArea =
|
|
|
|
nsRect(nsPoint(state.mComputedBorder.left, state.mComputedBorder.top),
|
|
|
|
state.mInsideBorderSize);
|
|
|
|
mInner.LayoutScrollbars(state.mBoxState, insideBorderArea,
|
2009-10-08 07:01:15 +04:00
|
|
|
oldScrollAreaBounds);
|
2007-01-19 21:01:10 +03:00
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
mInner.mSkippedScrollbarLayout = true;
|
2005-04-29 01:57:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aDesiredSize.width = state.mInsideBorderSize.width +
|
2005-05-03 02:49:44 +04:00
|
|
|
state.mComputedBorder.LeftRight();
|
2005-04-29 01:57:22 +04:00
|
|
|
aDesiredSize.height = state.mInsideBorderSize.height +
|
2005-05-03 02:49:44 +04:00
|
|
|
state.mComputedBorder.TopBottom();
|
2005-04-29 01:57:22 +04:00
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
2009-12-14 06:40:55 +03:00
|
|
|
|
|
|
|
CheckInvalidateSizeChange(aDesiredSize);
|
|
|
|
|
2011-05-12 03:53:34 +04:00
|
|
|
FinishReflowWithAbsoluteFrames(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2005-04-29 01:57:22 +04:00
|
|
|
|
2007-04-26 06:29:21 +04:00
|
|
|
if (!InInitialReflow() && !mInner.mHadNonInitialReflow) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mInner.mHadNonInitialReflow = true;
|
2005-08-25 04:10:37 +04:00
|
|
|
}
|
|
|
|
|
2011-04-19 07:07:23 +04:00
|
|
|
if (mInner.mIsRoot && !oldScrolledAreaBounds.IsEqualEdges(newScrolledAreaBounds)) {
|
2010-01-12 00:45:19 +03:00
|
|
|
mInner.PostScrolledAreaEvent();
|
2009-09-12 03:13:56 +04:00
|
|
|
}
|
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2004-06-18 06:08:19 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
2007-10-08 12:42:43 +04:00
|
|
|
mInner.PostOverflowEvent();
|
2004-06-18 06:08:19 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2009-09-12 03:13:56 +04:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2004-06-18 06:08:19 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLScrollFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("HTMLScroll"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-09-01 18:58:34 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 16:02:03 +04:00
|
|
|
already_AddRefed<nsAccessible>
|
|
|
|
nsHTMLScrollFrame::CreateAccessible()
|
2004-09-01 18:58:34 +04:00
|
|
|
{
|
|
|
|
if (!IsFocusable()) {
|
2010-06-28 16:02:03 +04:00
|
|
|
return nsnull;
|
2004-09-01 18:58:34 +04:00
|
|
|
}
|
|
|
|
// Focusable via CSS, so needs to be in accessibility hierarchy
|
2011-01-28 07:38:14 +03:00
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
2004-09-01 18:58:34 +04:00
|
|
|
if (accService) {
|
2010-06-28 16:02:03 +04:00
|
|
|
return accService->CreateHyperTextAccessible(mContent,
|
|
|
|
PresContext()->PresShell());
|
2004-09-01 18:58:34 +04:00
|
|
|
}
|
|
|
|
|
2010-06-28 16:02:03 +04:00
|
|
|
return nsnull;
|
2004-09-01 18:58:34 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsHTMLScrollFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIScrollableFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIStatefulFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame)
|
2004-06-18 06:08:19 +04:00
|
|
|
|
|
|
|
//----------nsXULScrollFrame-------------------------------------------
|
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_NewXULScrollFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, bool aIsRoot)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsXULScrollFrame(aPresShell, aContext, aIsRoot);
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsXULScrollFrame)
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
nsXULScrollFrame::nsXULScrollFrame(nsIPresShell* aShell, nsStyleContext* aContext, bool aIsRoot)
|
2006-03-27 01:30:36 +04:00
|
|
|
: nsBoxFrame(aShell, aContext, aIsRoot),
|
2011-02-07 10:59:20 +03:00
|
|
|
mInner(this, aIsRoot)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
SetLayoutManager(nsnull);
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
nsMargin nsGfxScrollFrameInner::GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
NS_ASSERTION(aState && aState->GetRenderingContext(),
|
|
|
|
"Must have rendering context in layout state for size "
|
|
|
|
"computations");
|
|
|
|
|
2004-01-09 22:21:20 +03:00
|
|
|
nsMargin result(0, 0, 0, 0);
|
2003-04-22 05:33:14 +04:00
|
|
|
|
2005-10-18 09:00:24 +04:00
|
|
|
if (mVScrollbarBox) {
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize size = mVScrollbarBox->GetPrefSize(*aState);
|
2010-04-03 02:25:40 +04:00
|
|
|
nsBox::AddMargin(mVScrollbarBox, size);
|
2005-04-29 01:57:22 +04:00
|
|
|
if (IsScrollbarOnRight())
|
2004-01-09 22:21:20 +03:00
|
|
|
result.left = size.width;
|
|
|
|
else
|
|
|
|
result.right = size.width;
|
2001-12-18 01:51:39 +03:00
|
|
|
}
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2005-10-18 09:00:24 +04:00
|
|
|
if (mHScrollbarBox) {
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize size = mHScrollbarBox->GetPrefSize(*aState);
|
2010-04-03 02:25:40 +04:00
|
|
|
nsBox::AddMargin(mHScrollbarBox, size);
|
2004-01-09 22:21:20 +03:00
|
|
|
// We don't currently support any scripts that would require a scrollbar
|
|
|
|
// at the top. (Are there any?)
|
|
|
|
result.bottom = size.height;
|
2001-12-18 01:51:39 +03:00
|
|
|
}
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2004-01-09 22:21:20 +03:00
|
|
|
return result;
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
nsresult
|
2011-05-07 00:04:44 +04:00
|
|
|
nsXULScrollFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2007-02-18 20:34:09 +03:00
|
|
|
return mInner.CreateAnonymousContent(aElements);
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2010-02-11 20:34:01 +03:00
|
|
|
void
|
2010-10-15 19:34:35 +04:00
|
|
|
nsXULScrollFrame::AppendAnonymousContentTo(nsBaseContentList& aElements,
|
|
|
|
PRUint32 aFilter)
|
2010-02-11 20:34:01 +03:00
|
|
|
{
|
2010-10-15 19:34:35 +04:00
|
|
|
mInner.AppendAnonymousContentTo(aElements, aFilter);
|
2010-02-11 20:34:01 +03:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsXULScrollFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2007-02-18 20:34:09 +03:00
|
|
|
mInner.Destroy();
|
2009-12-24 08:21:15 +03:00
|
|
|
nsBoxFrame::DestroyFrom(aDestructRoot);
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsXULScrollFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
nsresult rv = nsBoxFrame::SetInitialChildList(aListID, aChildList);
|
2004-05-05 06:32:27 +04:00
|
|
|
mInner.ReloadChildFrames();
|
1999-10-12 04:16:06 +04:00
|
|
|
return rv;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsXULScrollFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2005-02-07 04:58:25 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
nsresult rv = nsBoxFrame::AppendFrames(aListID, aFrameList);
|
2004-05-05 06:32:27 +04:00
|
|
|
mInner.ReloadChildFrames();
|
2003-04-09 00:50:57 +04:00
|
|
|
return rv;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsXULScrollFrame::InsertFrames(ChildListID aListID,
|
2005-02-07 04:58:25 +03:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2005-02-07 04:58:25 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
nsresult rv = nsBoxFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
|
2004-05-05 06:32:27 +04:00
|
|
|
mInner.ReloadChildFrames();
|
2003-04-09 00:50:57 +04:00
|
|
|
return rv;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsXULScrollFrame::RemoveFrame(ChildListID aListID,
|
2005-02-07 04:58:25 +03:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
nsresult rv = nsBoxFrame::RemoveFrame(aListID, aOldFrame);
|
2004-05-05 06:32:27 +04:00
|
|
|
mInner.ReloadChildFrames();
|
2003-04-09 00:50:57 +04:00
|
|
|
return rv;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2006-12-20 06:52:34 +03:00
|
|
|
nsSplittableType
|
|
|
|
nsXULScrollFrame::GetSplittableType() const
|
2006-08-24 09:22:16 +04:00
|
|
|
{
|
2006-12-20 06:52:34 +03:00
|
|
|
return NS_FRAME_NOT_SPLITTABLE;
|
2006-08-24 09:22:16 +04:00
|
|
|
}
|
2000-05-15 08:12:31 +04:00
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
NS_IMETHODIMP
|
2004-06-18 06:08:19 +04:00
|
|
|
nsXULScrollFrame::GetPadding(nsMargin& aMargin)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
aMargin.SizeTo(0,0,0,0);
|
|
|
|
return NS_OK;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
PRIntn
|
2004-06-18 06:08:19 +04:00
|
|
|
nsXULScrollFrame::GetSkipSides() const
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
2004-06-18 06:08:19 +04:00
|
|
|
nsXULScrollFrame::GetType() const
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::scrollFrame;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2008-07-14 02:21:11 +04:00
|
|
|
void
|
|
|
|
nsXULScrollFrame::InvalidateInternal(const nsRect& aDamageRect,
|
|
|
|
nscoord aX, nscoord aY, nsIFrame* aForChild,
|
2008-09-18 13:47:21 +04:00
|
|
|
PRUint32 aFlags)
|
2008-07-14 02:21:11 +04:00
|
|
|
{
|
|
|
|
if (aForChild == mInner.mScrolledFrame) {
|
2010-12-20 04:37:43 +03:00
|
|
|
nsRect damage = aDamageRect + nsPoint(aX, aY);
|
|
|
|
// This is the damage rect that we're going to pass up to our parent.
|
|
|
|
nsRect parentDamage;
|
2011-03-12 02:12:11 +03:00
|
|
|
// If we're using a displayport, we might be displaying an area
|
|
|
|
// different than our scroll port and the damage needs to be
|
|
|
|
// clipped to that instead.
|
2011-03-10 00:35:27 +03:00
|
|
|
nsRect displayport;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool usingDisplayport = nsLayoutUtils::GetDisplayPort(GetContent(),
|
2011-03-10 00:35:27 +03:00
|
|
|
&displayport);
|
|
|
|
if (usingDisplayport) {
|
|
|
|
parentDamage.IntersectRect(damage, displayport);
|
2011-03-12 02:12:11 +03:00
|
|
|
} else {
|
|
|
|
parentDamage.IntersectRect(damage, mInner.mScrollPort);
|
|
|
|
}
|
2010-12-20 04:37:43 +03:00
|
|
|
|
|
|
|
if (IsScrollingActive()) {
|
|
|
|
// This is the damage rect that we're going to pass up and
|
|
|
|
// only request invalidation of ThebesLayers for.
|
|
|
|
// damage is now in our coordinate system, which means it was
|
|
|
|
// translated using the current scroll position. Adjust it to
|
|
|
|
// reflect the scroll position at last paint, since that's what
|
|
|
|
// the ThebesLayers are currently set up for.
|
|
|
|
// This should not be clipped to the scrollport since ThebesLayers
|
|
|
|
// can contain content outside the scrollport that may need to be
|
|
|
|
// invalidated.
|
|
|
|
nsRect thebesLayerDamage = damage + GetScrollPosition() - mInner.mScrollPosAtLastPaint;
|
2011-04-19 07:07:23 +04:00
|
|
|
if (parentDamage.IsEqualInterior(thebesLayerDamage)) {
|
2010-12-20 04:37:43 +03:00
|
|
|
// This single call will take care of both rects
|
|
|
|
nsBoxFrame::InvalidateInternal(parentDamage, 0, 0, aForChild, aFlags);
|
|
|
|
} else {
|
|
|
|
// Invalidate rects separately
|
|
|
|
if (!(aFlags & INVALIDATE_NO_THEBES_LAYERS)) {
|
|
|
|
nsBoxFrame::InvalidateInternal(thebesLayerDamage, 0, 0, aForChild,
|
|
|
|
aFlags | INVALIDATE_ONLY_THEBES_LAYERS);
|
|
|
|
}
|
|
|
|
if (!(aFlags & INVALIDATE_ONLY_THEBES_LAYERS) && !parentDamage.IsEmpty()) {
|
|
|
|
nsBoxFrame::InvalidateInternal(parentDamage, 0, 0, aForChild,
|
|
|
|
aFlags | INVALIDATE_NO_THEBES_LAYERS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!parentDamage.IsEmpty()) {
|
|
|
|
nsBoxFrame::InvalidateInternal(parentDamage, 0, 0, aForChild, aFlags);
|
|
|
|
}
|
2008-07-14 02:21:11 +04:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-09-18 13:47:21 +04:00
|
|
|
nsBoxFrame::InvalidateInternal(aDamageRect, aX, aY, aForChild, aFlags);
|
2008-07-14 02:21:11 +04:00
|
|
|
}
|
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
nscoord
|
|
|
|
nsXULScrollFrame::GetBoxAscent(nsBoxLayoutState& aState)
|
2000-05-15 08:12:31 +04:00
|
|
|
{
|
2005-04-04 01:00:41 +04:00
|
|
|
if (!mInner.mScrolledFrame)
|
2007-01-31 19:02:42 +03:00
|
|
|
return 0;
|
2005-04-04 01:00:41 +04:00
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
nscoord ascent = mInner.mScrolledFrame->GetBoxAscent(aState);
|
2000-05-15 08:12:31 +04:00
|
|
|
nsMargin m(0,0,0,0);
|
|
|
|
GetBorderAndPadding(m);
|
2007-01-31 19:02:42 +03:00
|
|
|
ascent += m.top;
|
2000-05-15 08:12:31 +04:00
|
|
|
GetMargin(m);
|
2007-01-31 19:02:42 +03:00
|
|
|
ascent += m.top;
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
return ascent;
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize
|
|
|
|
nsXULScrollFrame::GetPrefSize(nsBoxLayoutState& aState)
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 11:02:06 +04:00
|
|
|
PropagateDebug(aState);
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize pref = mInner.mScrolledFrame->GetPrefSize(aState);
|
|
|
|
|
2004-05-05 06:32:27 +04:00
|
|
|
nsGfxScrollFrameInner::ScrollbarStyles styles = GetScrollbarStyles();
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
// scrolled frames don't have their own margins
|
|
|
|
|
2004-05-05 06:32:27 +04:00
|
|
|
if (mInner.mVScrollbarBox &&
|
2003-05-22 05:46:13 +04:00
|
|
|
styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize vSize = mInner.mVScrollbarBox->GetPrefSize(aState);
|
2010-04-03 02:25:40 +04:00
|
|
|
nsBox::AddMargin(mInner.mVScrollbarBox, vSize);
|
2007-01-08 05:57:59 +03:00
|
|
|
pref.width += vSize.width;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2004-05-05 06:32:27 +04:00
|
|
|
if (mInner.mHScrollbarBox &&
|
2003-05-22 05:46:13 +04:00
|
|
|
styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) {
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize hSize = mInner.mHScrollbarBox->GetPrefSize(aState);
|
2010-04-03 02:25:40 +04:00
|
|
|
nsBox::AddMargin(mInner.mHScrollbarBox, hSize);
|
2007-01-08 05:57:59 +03:00
|
|
|
pref.height += hSize.height;
|
2002-10-01 05:23:47 +04:00
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
AddBorderAndPadding(pref);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool widthSet, heightSet;
|
2010-03-18 22:58:15 +03:00
|
|
|
nsIBox::AddCSSPrefSize(this, pref, widthSet, heightSet);
|
2007-01-08 05:57:59 +03:00
|
|
|
return pref;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize
|
|
|
|
nsXULScrollFrame::GetMinSize(nsBoxLayoutState& aState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 11:02:06 +04:00
|
|
|
PropagateDebug(aState);
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize min = mInner.mScrolledFrame->GetMinSizeForScrollArea(aState);
|
2003-05-22 05:46:13 +04:00
|
|
|
|
2004-05-05 06:32:27 +04:00
|
|
|
nsGfxScrollFrameInner::ScrollbarStyles styles = GetScrollbarStyles();
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-05-05 06:32:27 +04:00
|
|
|
if (mInner.mVScrollbarBox &&
|
2003-05-22 05:46:13 +04:00
|
|
|
styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize vSize = mInner.mVScrollbarBox->GetMinSize(aState);
|
2010-04-03 02:25:40 +04:00
|
|
|
AddMargin(mInner.mVScrollbarBox, vSize);
|
2007-01-08 05:57:59 +03:00
|
|
|
min.width += vSize.width;
|
|
|
|
if (min.height < vSize.height)
|
|
|
|
min.height = vSize.height;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2004-05-05 06:32:27 +04:00
|
|
|
if (mInner.mHScrollbarBox &&
|
2003-05-22 05:46:13 +04:00
|
|
|
styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) {
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize hSize = mInner.mHScrollbarBox->GetMinSize(aState);
|
2010-04-03 02:25:40 +04:00
|
|
|
AddMargin(mInner.mHScrollbarBox, hSize);
|
2007-01-08 05:57:59 +03:00
|
|
|
min.height += hSize.height;
|
|
|
|
if (min.width < hSize.width)
|
|
|
|
min.width = hSize.width;
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
AddBorderAndPadding(min);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool widthSet, heightSet;
|
2010-03-18 22:58:15 +03:00
|
|
|
nsIBox::AddCSSMinSize(aState, this, min, widthSet, heightSet);
|
2007-01-08 05:57:59 +03:00
|
|
|
return min;
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize
|
|
|
|
nsXULScrollFrame::GetMaxSize(nsBoxLayoutState& aState)
|
1999-11-18 22:40:52 +03:00
|
|
|
{
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 11:02:06 +04:00
|
|
|
PropagateDebug(aState);
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2008-02-27 04:51:57 +03:00
|
|
|
nsSize maxSize(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
|
1999-11-18 22:40:52 +03:00
|
|
|
|
2008-02-27 04:51:57 +03:00
|
|
|
AddBorderAndPadding(maxSize);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool widthSet, heightSet;
|
2010-03-18 22:58:15 +03:00
|
|
|
nsIBox::AddCSSMaxSize(this, maxSize, widthSet, heightSet);
|
2008-02-27 04:51:57 +03:00
|
|
|
return maxSize;
|
1999-11-18 22:40:52 +03:00
|
|
|
}
|
1999-10-12 04:16:06 +04:00
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef NS_DEBUG
|
1999-10-12 04:16:06 +04:00
|
|
|
NS_IMETHODIMP
|
2004-06-18 06:08:19 +04:00
|
|
|
nsXULScrollFrame::GetFrameName(nsAString& aResult) const
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
2004-06-18 06:08:19 +04:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("XULScroll"), aResult);
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2004-06-18 06:08:19 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULScrollFrame::DoLayout(nsBoxLayoutState& aState)
|
|
|
|
{
|
2004-06-22 06:55:04 +04:00
|
|
|
PRUint32 flags = aState.LayoutFlags();
|
2005-04-29 01:57:22 +04:00
|
|
|
nsresult rv = Layout(aState);
|
2004-06-22 06:55:04 +04:00
|
|
|
aState.SetLayoutFlags(flags);
|
2004-06-18 06:08:19 +04:00
|
|
|
|
2004-06-22 06:55:04 +04:00
|
|
|
nsBox::DoLayout(aState);
|
|
|
|
return rv;
|
2004-06-18 06:08:19 +04:00
|
|
|
}
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsXULScrollFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIScrollableFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIStatefulFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame)
|
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
//-------------------- Inner ----------------------
|
|
|
|
|
2009-10-08 07:01:15 +04:00
|
|
|
#define SMOOTH_SCROLL_PREF_NAME "general.smoothScroll"
|
|
|
|
|
2011-03-26 07:30:19 +03:00
|
|
|
const double kCurrentVelocityWeighting = 0.25;
|
|
|
|
const double kStopDecelerationWeighting = 0.4;
|
|
|
|
const double kSmoothScrollAnimationDuration = 150; // milliseconds
|
|
|
|
|
2009-10-08 07:01:15 +04:00
|
|
|
class nsGfxScrollFrameInner::AsyncScroll {
|
|
|
|
public:
|
2011-03-26 07:30:19 +03:00
|
|
|
typedef mozilla::TimeStamp TimeStamp;
|
|
|
|
typedef mozilla::TimeDuration TimeDuration;
|
|
|
|
|
2009-10-08 07:01:15 +04:00
|
|
|
AsyncScroll() {}
|
|
|
|
~AsyncScroll() {
|
|
|
|
if (mScrollTimer) mScrollTimer->Cancel();
|
|
|
|
}
|
|
|
|
|
2011-03-26 07:30:19 +03:00
|
|
|
nsPoint PositionAt(TimeStamp aTime);
|
|
|
|
nsSize VelocityAt(TimeStamp aTime); // In nscoords per second
|
|
|
|
|
|
|
|
void InitSmoothScroll(TimeStamp aTime, nsPoint aCurrentPos,
|
|
|
|
nsSize aCurrentVelocity, nsPoint aDestination);
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsFinished(TimeStamp aTime) {
|
2011-03-26 07:30:19 +03:00
|
|
|
return aTime > mStartTime + mDuration; // XXX or if we've hit the wall
|
|
|
|
}
|
|
|
|
|
2009-10-08 07:01:15 +04:00
|
|
|
nsCOMPtr<nsITimer> mScrollTimer;
|
2011-03-26 07:30:19 +03:00
|
|
|
TimeStamp mStartTime;
|
|
|
|
TimeDuration mDuration;
|
|
|
|
nsPoint mStartPos;
|
|
|
|
nsPoint mDestination;
|
|
|
|
nsSMILKeySpline mTimingFunctionX;
|
|
|
|
nsSMILKeySpline mTimingFunctionY;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsSmoothScroll;
|
2011-03-26 07:30:19 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
double ProgressAt(TimeStamp aTime) {
|
2011-10-28 22:33:28 +04:00
|
|
|
return clamped((aTime - mStartTime) / mDuration, 0.0, 1.0);
|
2011-03-26 07:30:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord VelocityComponent(double aTimeProgress,
|
|
|
|
nsSMILKeySpline& aTimingFunction,
|
|
|
|
nscoord aStart, nscoord aDestination);
|
|
|
|
|
|
|
|
// Initializes the timing function in such a way that the current velocity is
|
|
|
|
// preserved.
|
|
|
|
void InitTimingFunction(nsSMILKeySpline& aTimingFunction,
|
|
|
|
nscoord aCurrentPos, nscoord aCurrentVelocity,
|
|
|
|
nscoord aDestination);
|
2009-10-08 07:01:15 +04:00
|
|
|
};
|
|
|
|
|
2011-03-26 07:30:19 +03:00
|
|
|
nsPoint
|
|
|
|
nsGfxScrollFrameInner::AsyncScroll::PositionAt(TimeStamp aTime) {
|
|
|
|
double progressX = mTimingFunctionX.GetSplineValue(ProgressAt(aTime));
|
|
|
|
double progressY = mTimingFunctionY.GetSplineValue(ProgressAt(aTime));
|
|
|
|
return nsPoint((1 - progressX) * mStartPos.x + progressX * mDestination.x,
|
|
|
|
(1 - progressY) * mStartPos.y + progressY * mDestination.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSize
|
|
|
|
nsGfxScrollFrameInner::AsyncScroll::VelocityAt(TimeStamp aTime) {
|
|
|
|
double timeProgress = ProgressAt(aTime);
|
|
|
|
return nsSize(VelocityComponent(timeProgress, mTimingFunctionX,
|
|
|
|
mStartPos.x, mDestination.x),
|
|
|
|
VelocityComponent(timeProgress, mTimingFunctionY,
|
|
|
|
mStartPos.y, mDestination.y));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::AsyncScroll::InitSmoothScroll(TimeStamp aTime,
|
|
|
|
nsPoint aCurrentPos,
|
|
|
|
nsSize aCurrentVelocity,
|
|
|
|
nsPoint aDestination) {
|
|
|
|
mStartTime = aTime;
|
|
|
|
mStartPos = aCurrentPos;
|
|
|
|
mDestination = aDestination;
|
|
|
|
mDuration = TimeDuration::FromMilliseconds(kSmoothScrollAnimationDuration);
|
|
|
|
InitTimingFunction(mTimingFunctionX, mStartPos.x, aCurrentVelocity.width, aDestination.x);
|
|
|
|
InitTimingFunction(mTimingFunctionY, mStartPos.y, aCurrentVelocity.height, aDestination.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsGfxScrollFrameInner::AsyncScroll::VelocityComponent(double aTimeProgress,
|
|
|
|
nsSMILKeySpline& aTimingFunction,
|
|
|
|
nscoord aStart,
|
|
|
|
nscoord aDestination)
|
2009-10-08 07:01:15 +04:00
|
|
|
{
|
2011-03-26 07:30:19 +03:00
|
|
|
double dt, dxy;
|
|
|
|
aTimingFunction.GetSplineDerivativeValues(aTimeProgress, dt, dxy);
|
|
|
|
if (dt == 0)
|
|
|
|
return dxy >= 0 ? nscoord_MAX : nscoord_MIN;
|
|
|
|
|
|
|
|
const TimeDuration oneSecond = TimeDuration::FromSeconds(1);
|
|
|
|
double slope = dxy / dt;
|
|
|
|
return (slope * (aDestination - aStart) / (mDuration / oneSecond));
|
|
|
|
}
|
2009-10-08 07:01:15 +04:00
|
|
|
|
2011-03-26 07:30:19 +03:00
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::AsyncScroll::InitTimingFunction(nsSMILKeySpline& aTimingFunction,
|
|
|
|
nscoord aCurrentPos,
|
|
|
|
nscoord aCurrentVelocity,
|
|
|
|
nscoord aDestination)
|
|
|
|
{
|
|
|
|
if (aDestination == aCurrentPos || kCurrentVelocityWeighting == 0) {
|
|
|
|
aTimingFunction.Init(0, 0, 1 - kStopDecelerationWeighting, 1);
|
|
|
|
return;
|
2009-10-08 07:01:15 +04:00
|
|
|
}
|
2011-03-26 07:30:19 +03:00
|
|
|
|
|
|
|
const TimeDuration oneSecond = TimeDuration::FromSeconds(1);
|
|
|
|
double slope = aCurrentVelocity * (mDuration / oneSecond) / (aDestination - aCurrentPos);
|
|
|
|
double normalization = sqrt(1.0 + slope * slope);
|
|
|
|
double dt = 1.0 / normalization * kCurrentVelocityWeighting;
|
|
|
|
double dxy = slope / normalization * kCurrentVelocityWeighting;
|
|
|
|
aTimingFunction.Init(dt, dxy, 1 - kStopDecelerationWeighting, 1);
|
2009-10-08 07:01:15 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool
|
2009-10-08 07:01:15 +04:00
|
|
|
IsSmoothScrollingEnabled()
|
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
return Preferences::GetBool(SMOOTH_SCROLL_PREF_NAME, false);
|
2009-10-08 07:01:15 +04:00
|
|
|
}
|
|
|
|
|
2010-07-16 01:08:05 +04:00
|
|
|
class ScrollFrameActivityTracker : public nsExpirationTracker<nsGfxScrollFrameInner,4> {
|
|
|
|
public:
|
2010-09-02 13:18:39 +04:00
|
|
|
// Wait for 3-4s between scrolls before we remove our layers.
|
|
|
|
// That's 4 generations of 1s each.
|
|
|
|
enum { TIMEOUT_MS = 1000 };
|
2010-07-16 01:08:05 +04:00
|
|
|
ScrollFrameActivityTracker()
|
|
|
|
: nsExpirationTracker<nsGfxScrollFrameInner,4>(TIMEOUT_MS) {}
|
|
|
|
~ScrollFrameActivityTracker() {
|
|
|
|
AgeAllGenerations();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void NotifyExpired(nsGfxScrollFrameInner *aObject) {
|
|
|
|
RemoveObject(aObject);
|
2011-01-04 11:46:59 +03:00
|
|
|
aObject->MarkInactive();
|
2010-07-16 01:08:05 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static ScrollFrameActivityTracker *gScrollFrameActivityTracker = nsnull;
|
|
|
|
|
2006-03-15 19:55:19 +03:00
|
|
|
nsGfxScrollFrameInner::nsGfxScrollFrameInner(nsContainerFrame* aOuter,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsRoot)
|
2011-03-10 00:35:27 +03:00
|
|
|
: mHScrollbarBox(nsnull)
|
|
|
|
, mVScrollbarBox(nsnull)
|
|
|
|
, mScrolledFrame(nsnull)
|
|
|
|
, mScrollCornerBox(nsnull)
|
|
|
|
, mResizerBox(nsnull)
|
|
|
|
, mOuter(aOuter)
|
|
|
|
, mAsyncScroll(nsnull)
|
|
|
|
, mDestination(0, 0)
|
|
|
|
, mScrollPosAtLastPaint(0, 0)
|
|
|
|
, mRestorePos(-1, -1)
|
|
|
|
, mLastPos(-1, -1)
|
2011-10-17 18:59:28 +04:00
|
|
|
, mNeverHasVerticalScrollbar(false)
|
|
|
|
, mNeverHasHorizontalScrollbar(false)
|
|
|
|
, mHasVerticalScrollbar(false)
|
|
|
|
, mHasHorizontalScrollbar(false)
|
|
|
|
, mFrameIsUpdatingScrollbar(false)
|
|
|
|
, mDidHistoryRestore(false)
|
2011-03-10 00:35:27 +03:00
|
|
|
, mIsRoot(aIsRoot)
|
2011-10-17 18:59:28 +04:00
|
|
|
, mSupppressScrollbarUpdate(false)
|
|
|
|
, mSkippedScrollbarLayout(false)
|
|
|
|
, mHadNonInitialReflow(false)
|
|
|
|
, mHorizontalOverflow(false)
|
|
|
|
, mVerticalOverflow(false)
|
|
|
|
, mPostedReflowCallback(false)
|
|
|
|
, mMayHaveDirtyFixedChildren(false)
|
|
|
|
, mUpdateScrollbarAttributes(false)
|
|
|
|
, mCollapsedResizer(false)
|
|
|
|
, mShouldBuildLayer(false)
|
2004-05-05 06:32:27 +04:00
|
|
|
{
|
2010-10-21 16:07:55 +04:00
|
|
|
// lookup if we're allowed to overlap the content from the look&feel object
|
2011-09-09 06:27:13 +04:00
|
|
|
mScrollbarsCanOverlapContent =
|
|
|
|
LookAndFeel::GetInt(LookAndFeel::eIntID_ScrollbarsCanOverlapContent) != 0;
|
2011-01-04 11:46:56 +03:00
|
|
|
mScrollingActive = IsAlwaysActive();
|
2004-05-05 06:32:27 +04:00
|
|
|
}
|
|
|
|
|
2005-08-22 03:37:13 +04:00
|
|
|
nsGfxScrollFrameInner::~nsGfxScrollFrameInner()
|
|
|
|
{
|
2010-07-16 01:08:05 +04:00
|
|
|
if (mActivityExpirationState.IsTracked()) {
|
|
|
|
gScrollFrameActivityTracker->RemoveObject(this);
|
|
|
|
}
|
|
|
|
if (gScrollFrameActivityTracker &&
|
|
|
|
gScrollFrameActivityTracker->IsEmpty()) {
|
|
|
|
delete gScrollFrameActivityTracker;
|
|
|
|
gScrollFrameActivityTracker = nsnull;
|
|
|
|
}
|
2009-10-08 07:01:15 +04:00
|
|
|
delete mAsyncScroll;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nscoord
|
|
|
|
Clamp(nscoord aLower, nscoord aVal, nscoord aUpper)
|
|
|
|
{
|
|
|
|
if (aVal < aLower)
|
|
|
|
return aLower;
|
|
|
|
if (aVal > aUpper)
|
|
|
|
return aUpper;
|
|
|
|
return aVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint
|
|
|
|
nsGfxScrollFrameInner::ClampScrollPosition(const nsPoint& aPt) const
|
|
|
|
{
|
|
|
|
nsRect range = GetScrollRange();
|
|
|
|
return nsPoint(Clamp(range.x, aPt.x, range.XMost()),
|
|
|
|
Clamp(range.y, aPt.y, range.YMost()));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Callback function from timer used in nsGfxScrollFrameInner::ScrollTo
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::AsyncScrollCallback(nsITimer *aTimer, void* anInstance)
|
|
|
|
{
|
|
|
|
nsGfxScrollFrameInner* self = static_cast<nsGfxScrollFrameInner*>(anInstance);
|
|
|
|
if (!self || !self->mAsyncScroll)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (self->mAsyncScroll->mIsSmoothScroll) {
|
2011-03-26 07:30:19 +03:00
|
|
|
TimeStamp now = TimeStamp::Now();
|
|
|
|
nsPoint destination = self->mAsyncScroll->PositionAt(now);
|
|
|
|
if (self->mAsyncScroll->IsFinished(now)) {
|
2009-10-08 07:01:15 +04:00
|
|
|
delete self->mAsyncScroll;
|
|
|
|
self->mAsyncScroll = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->ScrollToImpl(destination);
|
|
|
|
} else {
|
|
|
|
delete self->mAsyncScroll;
|
|
|
|
self->mAsyncScroll = nsnull;
|
|
|
|
|
|
|
|
self->ScrollToImpl(self->mDestination);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* this method wraps calls to ScrollToImpl(), either in one shot or incrementally,
|
|
|
|
* based on the setting of the smooth scroll pref
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::ScrollTo(nsPoint aScrollPosition,
|
|
|
|
nsIScrollableFrame::ScrollMode aMode)
|
|
|
|
{
|
|
|
|
mDestination = ClampScrollPosition(aScrollPosition);
|
|
|
|
|
|
|
|
if (aMode == nsIScrollableFrame::INSTANT) {
|
|
|
|
// Asynchronous scrolling is not allowed, so we'll kill any existing
|
|
|
|
// async-scrolling process and do an instant scroll
|
|
|
|
delete mAsyncScroll;
|
|
|
|
mAsyncScroll = nsnull;
|
|
|
|
ScrollToImpl(mDestination);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-26 07:30:19 +03:00
|
|
|
TimeStamp now = TimeStamp::Now();
|
|
|
|
nsPoint currentPosition = GetScrollPosition();
|
|
|
|
nsSize currentVelocity(0, 0);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isSmoothScroll = (aMode == nsIScrollableFrame::SMOOTH) &&
|
2011-02-04 11:00:06 +03:00
|
|
|
IsSmoothScrollingEnabled();
|
2009-10-08 07:01:15 +04:00
|
|
|
|
|
|
|
if (mAsyncScroll) {
|
|
|
|
if (mAsyncScroll->mIsSmoothScroll) {
|
2011-03-26 07:30:19 +03:00
|
|
|
currentPosition = mAsyncScroll->PositionAt(now);
|
|
|
|
currentVelocity = mAsyncScroll->VelocityAt(now);
|
2009-10-08 07:01:15 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mAsyncScroll = new AsyncScroll;
|
2011-04-29 09:02:16 +04:00
|
|
|
mAsyncScroll->mScrollTimer = do_CreateInstance("@mozilla.org/timer;1");
|
|
|
|
if (!mAsyncScroll->mScrollTimer) {
|
|
|
|
delete mAsyncScroll;
|
|
|
|
mAsyncScroll = nsnull;
|
|
|
|
// allocation failed. Scroll the normal way.
|
2009-10-08 07:01:15 +04:00
|
|
|
ScrollToImpl(mDestination);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (isSmoothScroll) {
|
|
|
|
mAsyncScroll->mScrollTimer->InitWithFuncCallback(
|
2011-03-26 07:30:19 +03:00
|
|
|
AsyncScrollCallback, this, 1000 / 60,
|
|
|
|
nsITimer::TYPE_REPEATING_SLACK);
|
2009-10-08 07:01:15 +04:00
|
|
|
} else {
|
|
|
|
mAsyncScroll->mScrollTimer->InitWithFuncCallback(
|
|
|
|
AsyncScrollCallback, this, 0, nsITimer::TYPE_ONE_SHOT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mAsyncScroll->mIsSmoothScroll = isSmoothScroll;
|
|
|
|
|
|
|
|
if (isSmoothScroll) {
|
2011-03-26 07:30:19 +03:00
|
|
|
mAsyncScroll->InitSmoothScroll(now, currentPosition, currentVelocity,
|
|
|
|
aScrollPosition);
|
2009-10-08 07:01:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We can't use nsContainerFrame::PositionChildViews here because
|
|
|
|
// we don't want to invalidate views that have moved.
|
2010-10-15 05:03:45 +04:00
|
|
|
static void AdjustViews(nsIFrame* aFrame)
|
2009-10-08 07:01:15 +04:00
|
|
|
{
|
|
|
|
nsIView* view = aFrame->GetView();
|
|
|
|
if (view) {
|
|
|
|
nsPoint pt;
|
|
|
|
aFrame->GetParent()->GetClosestView(&pt);
|
|
|
|
pt += aFrame->GetPosition();
|
|
|
|
view->SetPosition(pt.x, pt.y);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(aFrame->GetStateBits() & NS_FRAME_HAS_CHILD_WITH_VIEW)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-08-25 00:54:29 +04:00
|
|
|
// Call AdjustViews recursively for all child frames except the popup list as
|
|
|
|
// the views for popups are not scrolled.
|
|
|
|
nsIFrame::ChildListIterator lists(aFrame);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
if (lists.CurrentID() == nsIFrame::kPopupList) {
|
|
|
|
continue;
|
2009-10-08 07:01:15 +04:00
|
|
|
}
|
2011-08-25 00:54:29 +04:00
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
AdjustViews(childFrames.get());
|
|
|
|
}
|
|
|
|
}
|
2005-08-22 03:37:13 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool
|
2011-01-04 11:46:56 +03:00
|
|
|
CanScrollWithBlitting(nsIFrame* aFrame)
|
2009-10-08 07:01:15 +04:00
|
|
|
{
|
2011-10-21 05:41:36 +04:00
|
|
|
if (aFrame->GetStateBits() & NS_SCROLLFRAME_INVALIDATE_CONTENTS_ON_SCROLL)
|
|
|
|
return false;
|
|
|
|
|
2010-04-23 06:41:38 +04:00
|
|
|
for (nsIFrame* f = aFrame; f;
|
2010-07-16 01:08:02 +04:00
|
|
|
f = nsLayoutUtils::GetCrossDocParentFrame(f)) {
|
2009-10-08 07:01:15 +04:00
|
|
|
if (nsSVGIntegrationUtils::UsingEffectsForFrame(f) ||
|
|
|
|
f->IsFrameOfType(nsIFrame::eSVG)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-10-08 07:01:15 +04:00
|
|
|
}
|
2011-01-04 11:46:59 +03:00
|
|
|
nsIScrollableFrame* sf = do_QueryFrame(f);
|
|
|
|
if (sf && nsLayoutUtils::HasNonZeroCorner(f->GetStyleBorder()->mBorderRadius))
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-01-04 11:46:56 +03:00
|
|
|
if (nsLayoutUtils::IsPopup(f))
|
2010-04-23 06:41:38 +04:00
|
|
|
break;
|
2009-10-08 07:01:15 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-10-08 07:01:15 +04:00
|
|
|
}
|
|
|
|
|
2010-07-16 01:08:02 +04:00
|
|
|
static void
|
|
|
|
InvalidateFixedBackgroundFramesFromList(nsDisplayListBuilder* aBuilder,
|
2010-08-13 13:54:37 +04:00
|
|
|
nsIFrame* aMovingFrame,
|
2010-07-16 01:08:02 +04:00
|
|
|
const nsDisplayList& aList)
|
|
|
|
{
|
|
|
|
for (nsDisplayItem* item = aList.GetBottom(); item; item = item->GetAbove()) {
|
|
|
|
nsDisplayList* sublist = item->GetList();
|
|
|
|
if (sublist) {
|
2010-08-13 13:54:37 +04:00
|
|
|
InvalidateFixedBackgroundFramesFromList(aBuilder, aMovingFrame, *sublist);
|
2010-07-16 01:08:12 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
nsIFrame* f = item->GetUnderlyingFrame();
|
2010-08-13 13:54:37 +04:00
|
|
|
if (f &&
|
|
|
|
item->IsVaryingRelativeToMovingFrame(aBuilder, aMovingFrame)) {
|
2011-02-10 11:58:11 +03:00
|
|
|
if (FrameLayerBuilder::NeedToInvalidateFixedDisplayItem(aBuilder, item)) {
|
|
|
|
// FrameLayerBuilder does not take care of scrolling this one
|
2010-08-13 14:01:58 +04:00
|
|
|
f->Invalidate(item->GetVisibleRect() - item->ToReferenceFrame());
|
2010-07-16 01:08:06 +04:00
|
|
|
}
|
2010-07-16 01:08:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
InvalidateFixedBackgroundFrames(nsIFrame* aRootFrame,
|
|
|
|
nsIFrame* aMovingFrame,
|
|
|
|
const nsRect& aUpdateRect)
|
|
|
|
{
|
|
|
|
if (!aMovingFrame->PresContext()->MayHaveFixedBackgroundFrames())
|
|
|
|
return;
|
|
|
|
|
|
|
|
NS_ASSERTION(aRootFrame != aMovingFrame,
|
|
|
|
"The root frame shouldn't be the one that's moving, that makes no sense");
|
|
|
|
|
|
|
|
// Build the 'after' display list over the whole area of interest.
|
2011-10-17 18:59:28 +04:00
|
|
|
nsDisplayListBuilder builder(aRootFrame, nsDisplayListBuilder::OTHER, true);
|
2010-07-16 01:08:02 +04:00
|
|
|
builder.EnterPresShell(aRootFrame, aUpdateRect);
|
|
|
|
nsDisplayList list;
|
|
|
|
nsresult rv =
|
|
|
|
aRootFrame->BuildDisplayListForStackingContext(&builder, aUpdateRect, &list);
|
|
|
|
builder.LeavePresShell(aRootFrame, aUpdateRect);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsRegion visibleRegion(aUpdateRect);
|
2010-08-28 03:15:08 +04:00
|
|
|
list.ComputeVisibilityForRoot(&builder, &visibleRegion);
|
2010-07-16 01:08:02 +04:00
|
|
|
|
2010-08-13 13:54:37 +04:00
|
|
|
InvalidateFixedBackgroundFramesFromList(&builder, aMovingFrame, list);
|
2010-07-16 01:08:12 +04:00
|
|
|
list.DeleteAll();
|
2010-07-16 01:08:02 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsGfxScrollFrameInner::IsAlwaysActive() const
|
2010-07-16 01:08:05 +04:00
|
|
|
{
|
|
|
|
// The root scrollframe for a non-chrome document which is the direct
|
|
|
|
// child of a chrome document is always treated as "active".
|
2010-07-16 01:08:05 +04:00
|
|
|
// XXX maybe we should extend this so that IFRAMEs which are fill the
|
|
|
|
// entire viewport (like GMail!) are always active
|
2010-09-11 22:24:50 +04:00
|
|
|
return mIsRoot && mOuter->PresContext()->IsRootContentDocument();
|
2010-07-16 01:08:05 +04:00
|
|
|
}
|
|
|
|
|
2011-01-04 11:46:59 +03:00
|
|
|
void nsGfxScrollFrameInner::MarkInactive()
|
|
|
|
{
|
|
|
|
if (IsAlwaysActive() || !mScrollingActive)
|
|
|
|
return;
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mScrollingActive = false;
|
2011-01-04 11:46:59 +03:00
|
|
|
mOuter->InvalidateFrameSubtree();
|
|
|
|
}
|
|
|
|
|
2010-07-16 01:08:05 +04:00
|
|
|
void nsGfxScrollFrameInner::MarkActive()
|
|
|
|
{
|
|
|
|
if (IsAlwaysActive())
|
|
|
|
return;
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mScrollingActive = true;
|
2010-07-16 01:08:05 +04:00
|
|
|
if (mActivityExpirationState.IsTracked()) {
|
|
|
|
gScrollFrameActivityTracker->MarkUsed(this);
|
|
|
|
} else {
|
|
|
|
if (!gScrollFrameActivityTracker) {
|
|
|
|
gScrollFrameActivityTracker = new ScrollFrameActivityTracker();
|
|
|
|
}
|
|
|
|
gScrollFrameActivityTracker->AddObject(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-15 05:03:45 +04:00
|
|
|
void nsGfxScrollFrameInner::ScrollVisual()
|
2009-10-08 07:01:15 +04:00
|
|
|
{
|
2010-07-16 01:08:08 +04:00
|
|
|
nsRootPresContext* rootPresContext = mOuter->PresContext()->GetRootPresContext();
|
2010-01-26 16:10:12 +03:00
|
|
|
if (!rootPresContext) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-08 07:01:15 +04:00
|
|
|
|
2010-07-16 01:08:08 +04:00
|
|
|
rootPresContext->RequestUpdatePluginGeometry(mOuter);
|
2009-10-08 07:01:15 +04:00
|
|
|
|
2010-10-15 05:03:45 +04:00
|
|
|
AdjustViews(mScrolledFrame);
|
|
|
|
// We need to call this after fixing up the view positions
|
|
|
|
// to be consistent with the frame hierarchy.
|
2010-07-16 01:08:02 +04:00
|
|
|
PRUint32 flags = nsIFrame::INVALIDATE_REASON_SCROLL_REPAINT;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool canScrollWithBlitting = CanScrollWithBlitting(mOuter);
|
2011-10-21 05:41:36 +04:00
|
|
|
mOuter->RemoveStateBits(NS_SCROLLFRAME_INVALIDATE_CONTENTS_ON_SCROLL);
|
2011-01-04 11:46:59 +03:00
|
|
|
if (IsScrollingActive()) {
|
|
|
|
if (!canScrollWithBlitting) {
|
|
|
|
MarkInactive();
|
|
|
|
} else {
|
|
|
|
flags |= nsIFrame::INVALIDATE_NO_THEBES_LAYERS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (canScrollWithBlitting) {
|
|
|
|
MarkActive();
|
2010-07-16 01:08:02 +04:00
|
|
|
}
|
2011-03-10 00:35:27 +03:00
|
|
|
|
|
|
|
nsRect invalidateRect, displayport;
|
|
|
|
invalidateRect =
|
|
|
|
(nsLayoutUtils::GetDisplayPort(mOuter->GetContent(), &displayport)) ?
|
|
|
|
displayport : mScrollPort;
|
|
|
|
|
|
|
|
mOuter->InvalidateWithFlags(invalidateRect, flags);
|
2009-10-08 07:01:15 +04:00
|
|
|
|
2010-07-16 01:08:02 +04:00
|
|
|
if (flags & nsIFrame::INVALIDATE_NO_THEBES_LAYERS) {
|
2011-01-04 11:46:56 +03:00
|
|
|
nsIFrame* displayRoot = nsLayoutUtils::GetDisplayRootFrame(mOuter);
|
2010-08-08 22:49:07 +04:00
|
|
|
nsRect update =
|
|
|
|
GetScrollPortRect() + mOuter->GetOffsetToCrossDoc(displayRoot);
|
|
|
|
update = update.ConvertAppUnitsRoundOut(
|
|
|
|
mOuter->PresContext()->AppUnitsPerDevPixel(),
|
|
|
|
displayRoot->PresContext()->AppUnitsPerDevPixel());
|
|
|
|
InvalidateFixedBackgroundFrames(displayRoot, mScrolledFrame, update);
|
2009-10-08 07:01:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static PRInt32
|
|
|
|
ClampInt(nscoord aLower, nscoord aVal, nscoord aUpper, nscoord aAppUnitsPerPixel)
|
|
|
|
{
|
|
|
|
PRInt32 low = NSToIntCeil(float(aLower)/aAppUnitsPerPixel);
|
|
|
|
PRInt32 high = NSToIntFloor(float(aUpper)/aAppUnitsPerPixel);
|
|
|
|
PRInt32 v = NSToIntRound(float(aVal)/aAppUnitsPerPixel);
|
|
|
|
NS_ASSERTION(low <= high, "No integers in range; 0 is supposed to be in range");
|
|
|
|
if (v < low)
|
|
|
|
return low;
|
|
|
|
if (v > high)
|
|
|
|
return high;
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint
|
|
|
|
nsGfxScrollFrameInner::ClampAndRestrictToDevPixels(const nsPoint& aPt,
|
|
|
|
nsIntPoint* aPtDevPx) const
|
|
|
|
{
|
|
|
|
nsPresContext* presContext = mOuter->PresContext();
|
|
|
|
nscoord appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
|
|
|
|
// Convert to device pixels so we scroll to an integer offset of device
|
|
|
|
// pixels. But we also need to make sure that our position remains
|
|
|
|
// inside the allowed region.
|
|
|
|
nsRect scrollRange = GetScrollRange();
|
|
|
|
*aPtDevPx = nsIntPoint(ClampInt(scrollRange.x, aPt.x, scrollRange.XMost(), appUnitsPerDevPixel),
|
|
|
|
ClampInt(scrollRange.y, aPt.y, scrollRange.YMost(), appUnitsPerDevPixel));
|
|
|
|
return nsPoint(NSIntPixelsToAppUnits(aPtDevPx->x, appUnitsPerDevPixel),
|
|
|
|
NSIntPixelsToAppUnits(aPtDevPx->y, appUnitsPerDevPixel));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::ScrollToImpl(nsPoint aPt)
|
|
|
|
{
|
|
|
|
nsPresContext* presContext = mOuter->PresContext();
|
|
|
|
nscoord appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
|
|
|
|
nsIntPoint ptDevPx;
|
|
|
|
nsPoint pt = ClampAndRestrictToDevPixels(aPt, &ptDevPx);
|
|
|
|
|
|
|
|
nsPoint curPos = GetScrollPosition();
|
|
|
|
if (pt == curPos) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsIntPoint curPosDevPx(NSAppUnitsToIntPixels(curPos.x, appUnitsPerDevPixel),
|
|
|
|
NSAppUnitsToIntPixels(curPos.y, appUnitsPerDevPixel));
|
|
|
|
// We maintain the invariant that the scroll position is a multiple of device
|
|
|
|
// pixels.
|
|
|
|
NS_ASSERTION(curPosDevPx.x*appUnitsPerDevPixel == curPos.x,
|
|
|
|
"curPos.x not a multiple of device pixels");
|
|
|
|
NS_ASSERTION(curPosDevPx.y*appUnitsPerDevPixel == curPos.y,
|
|
|
|
"curPos.y not a multiple of device pixels");
|
|
|
|
|
|
|
|
// notify the listeners.
|
2010-05-02 16:56:00 +04:00
|
|
|
for (PRUint32 i = 0; i < mListeners.Length(); i++) {
|
2009-10-08 07:01:15 +04:00
|
|
|
mListeners[i]->ScrollPositionWillChange(pt.x, pt.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update frame position for scrolling
|
|
|
|
mScrolledFrame->SetPosition(mScrollPort.TopLeft() - pt);
|
|
|
|
|
|
|
|
// We pass in the amount to move visually
|
2010-10-15 05:03:45 +04:00
|
|
|
ScrollVisual();
|
2009-10-08 07:01:15 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
presContext->PresShell()->SynthesizeMouseMove(true);
|
2009-10-08 07:01:15 +04:00
|
|
|
UpdateScrollbarPosition();
|
|
|
|
PostScrollEvent();
|
|
|
|
|
|
|
|
// notify the listeners.
|
2010-05-02 16:56:00 +04:00
|
|
|
for (PRUint32 i = 0; i < mListeners.Length(); i++) {
|
2009-10-08 07:01:15 +04:00
|
|
|
mListeners[i]->ScrollPositionDidChange(pt.x, pt.y);
|
|
|
|
}
|
|
|
|
}
|
2004-05-05 06:32:27 +04:00
|
|
|
|
2010-07-16 01:08:03 +04:00
|
|
|
static void
|
|
|
|
AppendToTop(nsDisplayListBuilder* aBuilder, nsDisplayList* aDest,
|
2011-09-29 10:19:26 +04:00
|
|
|
nsDisplayList* aSource, nsIFrame* aSourceFrame, bool aOwnLayer)
|
2010-07-16 01:08:03 +04:00
|
|
|
{
|
2011-05-31 03:12:06 +04:00
|
|
|
if (aSource->IsEmpty())
|
|
|
|
return;
|
2010-07-16 01:08:03 +04:00
|
|
|
if (aOwnLayer) {
|
2010-08-13 14:01:13 +04:00
|
|
|
aDest->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayOwnLayer(aBuilder, aSourceFrame, aSource));
|
2010-07-16 01:08:03 +04:00
|
|
|
} else {
|
|
|
|
aDest->AppendToTop(aSource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-21 16:07:55 +04:00
|
|
|
nsresult
|
|
|
|
nsGfxScrollFrameInner::AppendScrollPartsTo(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists,
|
|
|
|
const nsDisplayListCollection& aDest,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool& aCreateLayer)
|
2010-10-21 16:07:55 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool hasResizer = HasResizer();
|
2011-08-25 00:54:30 +04:00
|
|
|
for (nsIFrame* kid = mOuter->GetFirstPrincipalChild(); kid; kid = kid->GetNextSibling()) {
|
2010-10-21 16:07:55 +04:00
|
|
|
if (kid != mScrolledFrame) {
|
2011-01-17 17:35:32 +03:00
|
|
|
if (kid == mResizerBox && hasResizer) {
|
2010-10-21 16:07:55 +04:00
|
|
|
// skip the resizer as this will be drawn later on top of the scrolled content
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
rv = mOuter->BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aDest,
|
|
|
|
nsIFrame::DISPLAY_CHILD_FORCE_STACKING_CONTEXT);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
// DISPLAY_CHILD_FORCE_STACKING_CONTEXT put everything into the
|
|
|
|
// PositionedDescendants list.
|
|
|
|
::AppendToTop(aBuilder, aLists.BorderBackground(),
|
|
|
|
aDest.PositionedDescendants(), kid,
|
|
|
|
aCreateLayer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-03-10 00:35:27 +03:00
|
|
|
nsGfxScrollFrameInner::ShouldBuildLayer() const
|
|
|
|
{
|
|
|
|
return mShouldBuildLayer;
|
|
|
|
}
|
|
|
|
|
2011-05-02 05:53:01 +04:00
|
|
|
class ScrollLayerWrapper : public nsDisplayWrapper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ScrollLayerWrapper(nsIFrame* aScrollFrame, nsIFrame* aScrolledFrame)
|
|
|
|
: mCount(0)
|
|
|
|
, mProps(aScrolledFrame->Properties())
|
|
|
|
, mScrollFrame(aScrollFrame)
|
|
|
|
, mScrolledFrame(aScrolledFrame)
|
|
|
|
{
|
|
|
|
SetCount(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual nsDisplayItem* WrapList(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsDisplayList* aList) {
|
|
|
|
SetCount(++mCount);
|
2011-05-02 05:53:58 +04:00
|
|
|
return new (aBuilder) nsDisplayScrollLayer(aBuilder, aList, mScrolledFrame, mScrolledFrame, mScrollFrame);
|
2011-05-02 05:53:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual nsDisplayItem* WrapItem(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayItem* aItem) {
|
|
|
|
|
|
|
|
SetCount(++mCount);
|
|
|
|
return new (aBuilder) nsDisplayScrollLayer(aBuilder, aItem, aItem->GetUnderlyingFrame(), mScrolledFrame, mScrollFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void SetCount(PRWord aCount) {
|
|
|
|
mProps.Set(nsIFrame::ScrollLayerCount(), reinterpret_cast<void*>(aCount));
|
|
|
|
}
|
|
|
|
|
|
|
|
PRWord mCount;
|
|
|
|
FrameProperties mProps;
|
|
|
|
nsIFrame* mScrollFrame;
|
|
|
|
nsIFrame* mScrolledFrame;
|
|
|
|
};
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsresult
|
|
|
|
nsGfxScrollFrameInner::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
nsresult rv = mOuter->DisplayBorderBackgroundOutline(aBuilder, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2010-03-19 14:49:34 +03:00
|
|
|
|
2010-07-16 01:08:02 +04:00
|
|
|
if (aBuilder->IsPaintingToWindow()) {
|
|
|
|
mScrollPosAtLastPaint = GetScrollPosition();
|
2011-01-04 11:46:59 +03:00
|
|
|
if (IsScrollingActive() && !CanScrollWithBlitting(mOuter)) {
|
|
|
|
MarkInactive();
|
|
|
|
}
|
2010-07-16 01:08:02 +04:00
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
if (aBuilder->GetIgnoreScrollFrame() == mOuter) {
|
|
|
|
// Don't clip the scrolled child, and don't paint scrollbars/scrollcorner.
|
|
|
|
// The scrolled frame shouldn't have its own background/border, so we
|
2009-03-30 04:29:36 +04:00
|
|
|
// can just pass aLists directly.
|
|
|
|
return mOuter->BuildDisplayListForChild(aBuilder, mScrolledFrame,
|
|
|
|
aDirtyRect, aLists);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2010-07-16 01:08:03 +04:00
|
|
|
// We put scrollbars in their own layers when this is the root scroll
|
|
|
|
// frame and we are a toplevel content document. In this situation, the
|
|
|
|
// scrollbar(s) would normally be assigned their own layer anyway, since
|
|
|
|
// they're not scrolled with the rest of the document. But when both
|
|
|
|
// scrollbars are visible, the layer's visible rectangle would be the size
|
|
|
|
// of the viewport, so most layer implementations would create a layer buffer
|
|
|
|
// that's much larger than necessary. Creating independent layers for each
|
|
|
|
// scrollbar works around the problem.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool createLayersForScrollbars = mIsRoot &&
|
2010-09-11 22:24:50 +04:00
|
|
|
mOuter->PresContext()->IsRootContentDocument();
|
2010-07-16 01:08:03 +04:00
|
|
|
|
2010-10-21 16:07:55 +04:00
|
|
|
nsDisplayListCollection scrollParts;
|
|
|
|
if (!mScrollbarsCanOverlapContent) {
|
|
|
|
// Now display the scrollbars and scrollcorner. These parts are drawn
|
|
|
|
// in the border-background layer, on top of our own background and
|
|
|
|
// borders and underneath borders and backgrounds of later elements
|
|
|
|
// in the tree.
|
|
|
|
AppendScrollPartsTo(aBuilder, aDirtyRect, aLists,
|
|
|
|
scrollParts, createLayersForScrollbars);
|
|
|
|
}
|
2009-02-26 10:00:36 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
// Overflow clipping can never clip frames outside our subtree, so there
|
|
|
|
// is no need to worry about whether we are a moving frame that might clip
|
|
|
|
// non-moving frames.
|
|
|
|
nsRect dirtyRect;
|
|
|
|
// Not all our descendants will be clipped by overflow clipping, but all
|
|
|
|
// the ones that aren't clipped will be out of flow frames that have already
|
|
|
|
// had dirty rects saved for them by their parent frames calling
|
|
|
|
// MarkOutOfFlowChildrenForDisplayList, so it's safe to restrict our
|
|
|
|
// dirty rect here.
|
2011-03-16 02:20:19 +03:00
|
|
|
dirtyRect.IntersectRect(aDirtyRect, mScrollPort);
|
|
|
|
|
2011-03-10 00:35:27 +03:00
|
|
|
// Override the dirty rectangle if the displayport has been set.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool usingDisplayport =
|
2011-04-12 00:53:01 +04:00
|
|
|
nsLayoutUtils::GetDisplayPort(mOuter->GetContent(), &dirtyRect);
|
2010-10-21 16:07:55 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsDisplayListCollection set;
|
2011-05-02 05:53:01 +04:00
|
|
|
rv = mOuter->BuildDisplayListForChild(aBuilder, mScrolledFrame, dirtyRect, set);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2011-03-16 02:20:19 +03:00
|
|
|
|
|
|
|
// Since making new layers is expensive, only use nsDisplayScrollLayer
|
|
|
|
// if the area is scrollable.
|
|
|
|
nsRect scrollRange = GetScrollRange();
|
2011-03-16 23:18:35 +03:00
|
|
|
ScrollbarStyles styles = GetScrollbarStylesFromFrame();
|
2011-03-10 00:35:27 +03:00
|
|
|
mShouldBuildLayer =
|
2011-03-16 02:20:19 +03:00
|
|
|
(XRE_GetProcessType() == GeckoProcessType_Content &&
|
2011-03-16 23:18:35 +03:00
|
|
|
(styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN ||
|
|
|
|
styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN) &&
|
2011-04-13 21:45:00 +04:00
|
|
|
(scrollRange.width > 0 ||
|
|
|
|
scrollRange.height > 0) &&
|
2011-04-12 00:53:01 +04:00
|
|
|
(!mIsRoot || !mOuter->PresContext()->IsRootContentDocument()));
|
2011-03-16 02:20:19 +03:00
|
|
|
|
2011-03-10 00:35:27 +03:00
|
|
|
if (ShouldBuildLayer()) {
|
2011-05-02 05:53:01 +04:00
|
|
|
// ScrollLayerWrapper must always be created because it initializes the
|
|
|
|
// scroll layer count. The display lists depend on this.
|
|
|
|
ScrollLayerWrapper wrapper(mOuter, mScrolledFrame);
|
|
|
|
|
2011-04-12 00:53:01 +04:00
|
|
|
if (usingDisplayport) {
|
|
|
|
// Once a displayport is set, assume that scrolling needs to be fast
|
|
|
|
// so create a layer with all the content inside. The compositor
|
|
|
|
// process will be able to scroll the content asynchronously.
|
2011-05-02 05:53:01 +04:00
|
|
|
wrapper.WrapListsInPlace(aBuilder, mOuter, set);
|
2011-04-30 08:01:29 +04:00
|
|
|
}
|
2011-05-02 05:53:01 +04:00
|
|
|
|
|
|
|
// In case we are not using displayport or the nsDisplayScrollLayers are
|
|
|
|
// flattened during visibility computation, we still need to export the
|
|
|
|
// metadata about this scroll box to the compositor process.
|
|
|
|
nsDisplayScrollInfoLayer* layerItem = new (aBuilder) nsDisplayScrollInfoLayer(
|
|
|
|
aBuilder, mScrolledFrame, mOuter);
|
2011-06-14 20:20:29 +04:00
|
|
|
set.BorderBackground()->AppendNewToBottom(layerItem);
|
2011-03-16 02:20:19 +03:00
|
|
|
}
|
|
|
|
|
2011-01-13 20:45:14 +03:00
|
|
|
nsRect clip;
|
2011-03-16 02:20:19 +03:00
|
|
|
clip = mScrollPort + aBuilder->ToReferenceFrame(mOuter);
|
2011-01-13 20:45:14 +03:00
|
|
|
|
2010-09-09 19:21:46 +04:00
|
|
|
nscoord radii[8];
|
|
|
|
// Our override of GetBorderRadii ensures we never have a radius at
|
|
|
|
// the corners where we have a scrollbar.
|
|
|
|
mOuter->GetPaddingBoxBorderRadii(radii);
|
2011-03-16 02:20:19 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
// mScrolledFrame may have given us a background, e.g., the scrolled canvas
|
2006-02-05 23:52:13 +03:00
|
|
|
// frame below the viewport. If so, we want it to be clipped. We also want
|
|
|
|
// to end up on our BorderBackground list.
|
2006-01-26 05:29:17 +03:00
|
|
|
// If we are the viewport scrollframe, then clip all our descendants (to ensure
|
|
|
|
// that fixed-pos elements get clipped by us).
|
2010-09-09 19:21:46 +04:00
|
|
|
rv = mOuter->OverflowClip(aBuilder, set, aLists, clip, radii,
|
2011-10-17 18:59:28 +04:00
|
|
|
true, mIsRoot);
|
2006-01-26 05:29:17 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2010-10-21 16:07:55 +04:00
|
|
|
if (mScrollbarsCanOverlapContent) {
|
|
|
|
AppendScrollPartsTo(aBuilder, aDirtyRect, aLists,
|
|
|
|
scrollParts, createLayersForScrollbars);
|
|
|
|
}
|
|
|
|
|
2011-02-11 01:38:37 +03:00
|
|
|
if (HasResizer()) {
|
2011-01-17 17:35:32 +03:00
|
|
|
rv = mOuter->BuildDisplayListForChild(aBuilder, mResizerBox, aDirtyRect, scrollParts,
|
2010-06-28 04:28:47 +04:00
|
|
|
nsIFrame::DISPLAY_CHILD_FORCE_STACKING_CONTEXT);
|
2010-03-19 14:49:34 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2010-06-28 04:28:47 +04:00
|
|
|
// DISPLAY_CHILD_FORCE_STACKING_CONTEXT puts everything into the
|
|
|
|
// PositionedDescendants list.
|
2011-02-11 01:38:37 +03:00
|
|
|
// The resizer is positioned and has maximum z-index; we put it in
|
|
|
|
// PositionedDescendants() for the root frame to ensure that it appears
|
|
|
|
// above all content, bug 631337.
|
|
|
|
::AppendToTop(aBuilder,
|
|
|
|
mIsRoot ? aLists.PositionedDescendants() : aLists.Content(),
|
2011-01-17 17:35:32 +03:00
|
|
|
scrollParts.PositionedDescendants(), mResizerBox,
|
2010-07-16 01:08:03 +04:00
|
|
|
createLayersForScrollbars);
|
2010-03-19 14:49:34 +03:00
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-09-05 03:03:04 +04:00
|
|
|
static void HandleScrollPref(nsIScrollable *aScrollable, PRInt32 aOrientation,
|
|
|
|
PRUint8& aValue)
|
|
|
|
{
|
|
|
|
PRInt32 pref;
|
|
|
|
aScrollable->GetDefaultScrollbarPreferences(aOrientation, &pref);
|
|
|
|
switch (pref) {
|
|
|
|
case nsIScrollable::Scrollbar_Auto:
|
|
|
|
// leave |aValue| untouched
|
|
|
|
break;
|
|
|
|
case nsIScrollable::Scrollbar_Never:
|
|
|
|
aValue = NS_STYLE_OVERFLOW_HIDDEN;
|
|
|
|
break;
|
|
|
|
case nsIScrollable::Scrollbar_Always:
|
|
|
|
aValue = NS_STYLE_OVERFLOW_SCROLL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-05 06:32:27 +04:00
|
|
|
nsGfxScrollFrameInner::ScrollbarStyles
|
|
|
|
nsGfxScrollFrameInner::GetScrollbarStylesFromFrame() const
|
|
|
|
{
|
2004-09-05 03:03:04 +04:00
|
|
|
ScrollbarStyles result;
|
2006-04-11 05:48:48 +04:00
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext* presContext = mOuter->PresContext();
|
2006-04-12 05:55:25 +04:00
|
|
|
if (!presContext->IsDynamic() &&
|
|
|
|
!(mIsRoot && presContext->HasPaginatedScrolling())) {
|
2006-04-11 05:48:48 +04:00
|
|
|
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN);
|
|
|
|
}
|
|
|
|
|
2005-04-04 02:40:25 +04:00
|
|
|
if (mIsRoot) {
|
2004-09-05 04:04:04 +04:00
|
|
|
result = presContext->GetViewportOverflowOverride();
|
2004-09-05 03:03:04 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> container = presContext->GetContainer();
|
2007-02-24 03:23:42 +03:00
|
|
|
nsCOMPtr<nsIScrollable> scrollable = do_QueryInterface(container);
|
|
|
|
if (scrollable) {
|
2004-09-29 05:46:55 +04:00
|
|
|
HandleScrollPref(scrollable, nsIScrollable::ScrollOrientation_X,
|
|
|
|
result.mHorizontal);
|
|
|
|
HandleScrollPref(scrollable, nsIScrollable::ScrollOrientation_Y,
|
|
|
|
result.mVertical);
|
2011-03-18 01:48:47 +03:00
|
|
|
// XXX EVIL COMPILER BUG BE CAREFUL WHEN CHANGING
|
|
|
|
// There is a bug in the Android compiler :(
|
|
|
|
// It seems that the compiler optimizes something out and uses
|
|
|
|
// a bad value for result if we don't directly return here.
|
|
|
|
return result;
|
2004-09-29 05:46:55 +04:00
|
|
|
}
|
2004-05-05 06:32:27 +04:00
|
|
|
} else {
|
2004-09-05 04:04:04 +04:00
|
|
|
const nsStyleDisplay *disp = mOuter->GetStyleDisplay();
|
|
|
|
result.mHorizontal = disp->mOverflowX;
|
|
|
|
result.mVertical = disp->mOverflowY;
|
2004-05-05 06:32:27 +04:00
|
|
|
}
|
|
|
|
|
2004-09-05 03:03:04 +04:00
|
|
|
return result;
|
2004-08-27 05:26:55 +04:00
|
|
|
}
|
|
|
|
|
2009-09-01 08:11:11 +04:00
|
|
|
static nscoord
|
|
|
|
AlignToDevPixelRoundingToZero(nscoord aVal, PRInt32 aAppUnitsPerDevPixel)
|
|
|
|
{
|
|
|
|
return (aVal/aAppUnitsPerDevPixel)*aAppUnitsPerDevPixel;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect
|
|
|
|
nsGfxScrollFrameInner::GetScrollRange() const
|
|
|
|
{
|
2009-10-08 07:01:15 +04:00
|
|
|
nsRect range = GetScrolledRect();
|
|
|
|
range.width -= mScrollPort.width;
|
|
|
|
range.height -= mScrollPort.height;
|
2009-09-01 08:11:11 +04:00
|
|
|
|
|
|
|
nsPresContext* presContext = mOuter->PresContext();
|
|
|
|
PRInt32 appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
|
|
|
|
range.width =
|
|
|
|
AlignToDevPixelRoundingToZero(range.XMost(), appUnitsPerDevPixel) - range.x;
|
|
|
|
range.height =
|
|
|
|
AlignToDevPixelRoundingToZero(range.YMost(), appUnitsPerDevPixel) - range.y;
|
|
|
|
range.x = AlignToDevPixelRoundingToZero(range.x, appUnitsPerDevPixel);
|
|
|
|
range.y = AlignToDevPixelRoundingToZero(range.y, appUnitsPerDevPixel);
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
AdjustForWholeDelta(PRInt32 aDelta, nscoord* aCoord)
|
|
|
|
{
|
|
|
|
if (aDelta < 0) {
|
|
|
|
*aCoord = nscoord_MIN;
|
|
|
|
} else if (aDelta > 0) {
|
|
|
|
*aCoord = nscoord_MAX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::ScrollBy(nsIntPoint aDelta,
|
|
|
|
nsIScrollableFrame::ScrollUnit aUnit,
|
|
|
|
nsIScrollableFrame::ScrollMode aMode,
|
|
|
|
nsIntPoint* aOverflow)
|
|
|
|
{
|
2009-10-08 07:01:15 +04:00
|
|
|
nsSize deltaMultiplier;
|
2009-09-01 08:11:11 +04:00
|
|
|
switch (aUnit) {
|
|
|
|
case nsIScrollableFrame::DEVICE_PIXELS: {
|
2009-10-08 07:01:15 +04:00
|
|
|
nscoord appUnitsPerDevPixel =
|
|
|
|
mOuter->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
deltaMultiplier = nsSize(appUnitsPerDevPixel, appUnitsPerDevPixel);
|
2009-09-01 08:11:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case nsIScrollableFrame::LINES: {
|
2009-10-08 07:01:15 +04:00
|
|
|
deltaMultiplier = GetLineScrollAmount();
|
2009-09-01 08:11:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case nsIScrollableFrame::PAGES: {
|
2009-10-08 07:01:15 +04:00
|
|
|
deltaMultiplier = GetPageScrollAmount();
|
2009-09-01 08:11:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case nsIScrollableFrame::WHOLE: {
|
|
|
|
nsPoint pos = GetScrollPosition();
|
|
|
|
AdjustForWholeDelta(aDelta.x, &pos.x);
|
|
|
|
AdjustForWholeDelta(aDelta.y, &pos.y);
|
|
|
|
ScrollTo(pos, aMode);
|
2009-10-08 07:01:15 +04:00
|
|
|
if (aOverflow) {
|
|
|
|
*aOverflow = nsIntPoint(0, 0);
|
|
|
|
}
|
|
|
|
return;
|
2009-09-01 08:11:11 +04:00
|
|
|
}
|
2009-10-08 07:01:15 +04:00
|
|
|
default:
|
|
|
|
NS_ERROR("Invalid scroll mode");
|
|
|
|
return;
|
2009-09-01 08:11:11 +04:00
|
|
|
}
|
|
|
|
|
2009-10-08 07:01:15 +04:00
|
|
|
nsPoint newPos = mDestination +
|
|
|
|
nsPoint(aDelta.x*deltaMultiplier.width, aDelta.y*deltaMultiplier.height);
|
|
|
|
ScrollTo(newPos, aMode);
|
|
|
|
|
2009-09-01 08:11:11 +04:00
|
|
|
if (aOverflow) {
|
2009-10-08 07:01:15 +04:00
|
|
|
nsPoint clampAmount = mDestination - newPos;
|
|
|
|
float appUnitsPerDevPixel = mOuter->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
*aOverflow = nsIntPoint(
|
2011-06-25 18:06:02 +04:00
|
|
|
NSAppUnitsToIntPixels(NS_ABS(clampAmount.x), appUnitsPerDevPixel),
|
|
|
|
NSAppUnitsToIntPixels(NS_ABS(clampAmount.y), appUnitsPerDevPixel));
|
2009-09-01 08:11:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSize
|
|
|
|
nsGfxScrollFrameInner::GetLineScrollAmount() const
|
|
|
|
{
|
2011-08-14 21:08:04 +04:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
2011-11-24 06:48:23 +04:00
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(mOuter, getter_AddRefs(fm),
|
|
|
|
nsLayoutUtils::FontSizeInflationFor(mOuter));
|
2009-10-08 07:01:15 +04:00
|
|
|
NS_ASSERTION(fm, "FontMetrics is null, assuming fontHeight == 1 appunit");
|
|
|
|
nscoord fontHeight = 1;
|
|
|
|
if (fm) {
|
2011-04-08 08:18:43 +04:00
|
|
|
fontHeight = fm->MaxHeight();
|
2009-10-08 07:01:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsSize(fontHeight, fontHeight);
|
2009-09-01 08:11:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsSize
|
|
|
|
nsGfxScrollFrameInner::GetPageScrollAmount() const
|
|
|
|
{
|
2009-10-08 07:01:15 +04:00
|
|
|
nsSize lineScrollAmount = GetLineScrollAmount();
|
|
|
|
// The page increment is the size of the page, minus the smaller of
|
|
|
|
// 10% of the size or 2 lines.
|
|
|
|
return nsSize(
|
|
|
|
mScrollPort.width - NS_MIN(mScrollPort.width/10, 2*lineScrollAmount.width),
|
|
|
|
mScrollPort.height - NS_MIN(mScrollPort.height/10, 2*lineScrollAmount.height));
|
2009-09-01 08:11:11 +04:00
|
|
|
}
|
|
|
|
|
2004-09-13 06:10:29 +04:00
|
|
|
/**
|
|
|
|
* this code is resposible for restoring the scroll position back to some
|
2005-11-21 01:05:24 +03:00
|
|
|
* saved position. if the user has not moved the scroll position manually
|
|
|
|
* we keep scrolling down until we get to our original position. keep in
|
2004-09-13 06:10:29 +04:00
|
|
|
* mind that content could incrementally be coming in. we only want to stop
|
|
|
|
* when we reach our new position.
|
|
|
|
*/
|
2004-07-24 01:39:47 +04:00
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::ScrollToRestoredPosition()
|
|
|
|
{
|
2009-10-08 07:01:15 +04:00
|
|
|
if (mRestorePos.y == -1 || mLastPos.x == -1 || mLastPos.y == -1) {
|
2004-09-13 06:10:29 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// make sure our scroll position did not change for where we last put
|
|
|
|
// it. if it does then the user must have moved it, and we no longer
|
|
|
|
// need to restore.
|
2011-02-07 10:59:20 +03:00
|
|
|
//
|
|
|
|
// In the RTL case, we check whether the scroll position changed using the
|
|
|
|
// logical scroll position, but we scroll to the physical scroll position in
|
|
|
|
// all cases
|
2004-09-13 06:10:29 +04:00
|
|
|
|
|
|
|
// if we didn't move, we still need to restore
|
2011-02-07 10:59:20 +03:00
|
|
|
if (GetLogicalScrollPosition() == mLastPos) {
|
2009-10-08 07:01:15 +04:00
|
|
|
// if our desired position is different to the scroll position, scroll.
|
2004-09-13 06:10:29 +04:00
|
|
|
// remember that we could be incrementally loading so we may enter
|
|
|
|
// and scroll many times.
|
2011-03-28 10:37:57 +04:00
|
|
|
if (mRestorePos != mLastPos /* GetLogicalScrollPosition() */) {
|
|
|
|
nsPoint scrollToPos = mRestorePos;
|
|
|
|
if (!IsLTR())
|
|
|
|
// convert from logical to physical scroll position
|
|
|
|
scrollToPos.x = mScrollPort.x -
|
|
|
|
(mScrollPort.XMost() - scrollToPos.x - mScrolledFrame->GetRect().width);
|
|
|
|
ScrollTo(scrollToPos, nsIScrollableFrame::INSTANT);
|
2009-10-08 07:01:15 +04:00
|
|
|
// Re-get the scroll position, it might not be exactly equal to
|
|
|
|
// mRestorePos due to rounding and clamping.
|
2011-02-07 10:59:20 +03:00
|
|
|
mLastPos = GetLogicalScrollPosition();
|
2004-09-13 06:10:29 +04:00
|
|
|
} else {
|
|
|
|
// if we reached the position then stop
|
2009-10-08 07:01:15 +04:00
|
|
|
mRestorePos.y = -1;
|
2004-09-13 06:10:29 +04:00
|
|
|
mLastPos.x = -1;
|
|
|
|
mLastPos.y = -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// user moved the position, so we won't need to restore
|
|
|
|
mLastPos.x = -1;
|
|
|
|
mLastPos.y = -1;
|
|
|
|
}
|
2004-07-24 01:39:47 +04:00
|
|
|
}
|
|
|
|
|
2007-01-28 01:50:18 +03:00
|
|
|
nsresult
|
|
|
|
nsGfxScrollFrameInner::FireScrollPortEvent()
|
2006-12-15 03:23:39 +03:00
|
|
|
{
|
2007-01-28 01:50:18 +03:00
|
|
|
mAsyncScrollPortEvent.Forget();
|
2007-10-08 12:42:43 +04:00
|
|
|
|
|
|
|
// Keep this in sync with PostOverflowEvent().
|
2009-10-08 07:01:15 +04:00
|
|
|
nsSize scrollportSize = mScrollPort.Size();
|
|
|
|
nsSize childSize = GetScrolledRect().Size();
|
2007-01-28 01:50:18 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool newVerticalOverflow = childSize.height > scrollportSize.height;
|
|
|
|
bool vertChanged = mVerticalOverflow != newVerticalOverflow;
|
2007-01-28 01:50:18 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool newHorizontalOverflow = childSize.width > scrollportSize.width;
|
|
|
|
bool horizChanged = mHorizontalOverflow != newHorizontalOverflow;
|
2006-12-15 03:23:39 +03:00
|
|
|
|
2007-01-28 01:50:18 +03:00
|
|
|
if (!vertChanged && !horizChanged) {
|
2006-12-15 03:23:39 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-01-28 01:50:18 +03:00
|
|
|
// If both either overflowed or underflowed then we dispatch only one
|
|
|
|
// DOM event.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool both = vertChanged && horizChanged &&
|
2007-01-28 01:50:18 +03:00
|
|
|
newVerticalOverflow == newHorizontalOverflow;
|
|
|
|
nsScrollPortEvent::orientType orient;
|
|
|
|
if (both) {
|
|
|
|
orient = nsScrollPortEvent::both;
|
|
|
|
mHorizontalOverflow = newHorizontalOverflow;
|
|
|
|
mVerticalOverflow = newVerticalOverflow;
|
|
|
|
}
|
|
|
|
else if (vertChanged) {
|
|
|
|
orient = nsScrollPortEvent::vertical;
|
|
|
|
mVerticalOverflow = newVerticalOverflow;
|
|
|
|
if (horizChanged) {
|
|
|
|
// We need to dispatch a separate horizontal DOM event. Do that the next
|
|
|
|
// time around since dispatching the vertical DOM event might destroy
|
|
|
|
// the frame.
|
|
|
|
PostOverflowEvent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
orient = nsScrollPortEvent::horizontal;
|
|
|
|
mHorizontalOverflow = newHorizontalOverflow;
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
nsScrollPortEvent event(true,
|
2007-01-28 01:50:18 +03:00
|
|
|
(orient == nsScrollPortEvent::horizontal ?
|
|
|
|
mHorizontalOverflow : mVerticalOverflow) ?
|
|
|
|
NS_SCROLLPORT_OVERFLOW : NS_SCROLLPORT_UNDERFLOW,
|
|
|
|
nsnull);
|
|
|
|
event.orient = orient;
|
|
|
|
return nsEventDispatcher::Dispatch(mOuter->GetContent(),
|
2007-03-31 01:11:41 +04:00
|
|
|
mOuter->PresContext(), &event);
|
2005-04-04 01:00:41 +04:00
|
|
|
}
|
|
|
|
|
2004-07-24 01:39:47 +04:00
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::ReloadChildFrames()
|
2004-05-05 06:32:27 +04:00
|
|
|
{
|
2005-04-04 01:00:41 +04:00
|
|
|
mScrolledFrame = nsnull;
|
2004-05-05 06:32:27 +04:00
|
|
|
mHScrollbarBox = nsnull;
|
|
|
|
mVScrollbarBox = nsnull;
|
|
|
|
mScrollCornerBox = nsnull;
|
2011-01-17 17:35:32 +03:00
|
|
|
mResizerBox = nsnull;
|
2004-05-05 06:32:27 +04:00
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
nsIFrame* frame = mOuter->GetFirstPrincipalChild();
|
2004-05-05 06:32:27 +04:00
|
|
|
while (frame) {
|
2005-04-04 01:00:41 +04:00
|
|
|
nsIContent* content = frame->GetContent();
|
|
|
|
if (content == mOuter->GetContent()) {
|
|
|
|
NS_ASSERTION(!mScrolledFrame, "Already found the scrolled frame");
|
|
|
|
mScrolledFrame = frame;
|
|
|
|
} else {
|
|
|
|
nsAutoString value;
|
2006-12-26 20:47:52 +03:00
|
|
|
content->GetAttr(kNameSpaceID_None, nsGkAtoms::orient, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2005-04-04 01:00:41 +04:00
|
|
|
// probably a scrollbar then
|
|
|
|
if (value.LowerCaseEqualsLiteral("horizontal")) {
|
|
|
|
NS_ASSERTION(!mHScrollbarBox, "Found multiple horizontal scrollbars?");
|
|
|
|
mHScrollbarBox = frame;
|
|
|
|
} else {
|
|
|
|
NS_ASSERTION(!mVScrollbarBox, "Found multiple vertical scrollbars?");
|
|
|
|
mVScrollbarBox = frame;
|
2005-03-31 22:04:50 +04:00
|
|
|
}
|
2011-01-17 17:35:32 +03:00
|
|
|
} else if (content->Tag() == nsGkAtoms::resizer) {
|
|
|
|
NS_ASSERTION(!mResizerBox, "Found multiple resizers");
|
|
|
|
mResizerBox = frame;
|
2005-04-04 01:00:41 +04:00
|
|
|
} else {
|
|
|
|
// probably a scrollcorner
|
|
|
|
NS_ASSERTION(!mScrollCornerBox, "Found multiple scrollcorners");
|
|
|
|
mScrollCornerBox = frame;
|
2004-05-05 06:32:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
frame = frame->GetNextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
nsresult
|
2011-05-07 00:04:44 +04:00
|
|
|
nsGfxScrollFrameInner::CreateAnonymousContent(
|
|
|
|
nsTArray<nsIAnonymousContentCreator::ContentInfo>& aElements)
|
2004-05-05 06:32:27 +04:00
|
|
|
{
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext* presContext = mOuter->PresContext();
|
2004-05-05 06:32:27 +04:00
|
|
|
nsIFrame* parent = mOuter->GetParent();
|
|
|
|
|
2010-11-19 19:56:06 +03:00
|
|
|
// Don't create scrollbars if we're an SVG document being used as an image,
|
|
|
|
// or if we're printing/print previewing.
|
|
|
|
// (In the printing case, we allow scrollbars if this is the child of the
|
|
|
|
// viewport & paginated scrolling is enabled, because then we must be the
|
|
|
|
// scroll frame for the print preview window, & that does need scrollbars.)
|
|
|
|
if (presContext->Document()->IsBeingUsedAsImage() ||
|
|
|
|
(!presContext->IsDynamic() &&
|
|
|
|
!(mIsRoot && presContext->HasPaginatedScrolling()))) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mNeverHasVerticalScrollbar = mNeverHasHorizontalScrollbar = true;
|
2010-11-19 19:56:06 +03:00
|
|
|
return NS_OK;
|
2004-05-05 06:32:27 +04:00
|
|
|
}
|
|
|
|
|
2010-03-19 14:49:34 +03:00
|
|
|
// Check if the frame is resizable.
|
2010-03-23 20:14:47 +03:00
|
|
|
PRInt8 resizeStyle = mOuter->GetStyleDisplay()->mResize;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isResizable = resizeStyle != NS_STYLE_RESIZE_NONE;
|
2010-03-19 14:49:34 +03:00
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIScrollableFrame *scrollable = do_QueryFrame(mOuter);
|
2004-08-27 05:26:55 +04:00
|
|
|
|
2010-03-09 03:30:02 +03:00
|
|
|
// If we're the scrollframe for the root, then we want to construct
|
|
|
|
// our scrollbar frames no matter what. That way later dynamic
|
|
|
|
// changes to propagated overflow styles will show or hide
|
|
|
|
// scrollbars on the viewport without requiring frame reconstruction
|
|
|
|
// of the viewport (good!).
|
2011-09-29 10:19:26 +04:00
|
|
|
bool canHaveHorizontal;
|
|
|
|
bool canHaveVertical;
|
2010-03-09 03:30:02 +03:00
|
|
|
if (!mIsRoot) {
|
2010-04-07 00:01:34 +04:00
|
|
|
ScrollbarStyles styles = scrollable->GetScrollbarStyles();
|
2010-03-09 03:30:02 +03:00
|
|
|
canHaveHorizontal = styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN;
|
|
|
|
canHaveVertical = styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN;
|
|
|
|
if (!canHaveHorizontal && !canHaveVertical && !isResizable) {
|
|
|
|
// Nothing to do.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
canHaveHorizontal = true;
|
|
|
|
canHaveVertical = true;
|
2007-02-18 20:34:09 +03:00
|
|
|
}
|
2004-06-25 16:26:02 +04:00
|
|
|
|
2004-09-04 07:17:18 +04:00
|
|
|
// The anonymous <div> used by <inputs> never gets scrollbars.
|
2009-01-12 22:20:59 +03:00
|
|
|
nsITextControlFrame* textFrame = do_QueryFrame(parent);
|
2004-09-04 07:17:18 +04:00
|
|
|
if (textFrame) {
|
|
|
|
// Make sure we are not a text area.
|
|
|
|
nsCOMPtr<nsIDOMHTMLTextAreaElement> textAreaElement(do_QueryInterface(parent->GetContent()));
|
|
|
|
if (!textAreaElement) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mNeverHasVerticalScrollbar = mNeverHasHorizontalScrollbar = true;
|
2007-02-18 20:34:09 +03:00
|
|
|
return NS_OK;
|
2004-09-04 07:17:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-04 03:57:42 +04:00
|
|
|
nsNodeInfoManager *nodeInfoManager =
|
2006-05-19 14:26:44 +04:00
|
|
|
presContext->Document()->NodeInfoManager();
|
2004-05-05 06:32:27 +04:00
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
2008-09-13 02:32:18 +04:00
|
|
|
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::scrollbar, nsnull,
|
2011-06-14 11:56:49 +04:00
|
|
|
kNameSpaceID_XUL,
|
|
|
|
nsIDOMNode::ELEMENT_NODE);
|
2008-09-26 02:46:52 +04:00
|
|
|
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
2004-06-25 16:26:02 +04:00
|
|
|
|
2004-05-05 06:32:27 +04:00
|
|
|
if (canHaveHorizontal) {
|
2010-07-23 13:49:57 +04:00
|
|
|
nsCOMPtr<nsINodeInfo> ni = nodeInfo;
|
2010-08-20 03:12:46 +04:00
|
|
|
NS_TrustedNewXULElement(getter_AddRefs(mHScrollbarContent), ni.forget());
|
2007-02-18 20:34:09 +03:00
|
|
|
mHScrollbarContent->SetAttr(kNameSpaceID_None, nsGkAtoms::orient,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("horizontal"), false);
|
2010-07-16 17:01:39 +04:00
|
|
|
mHScrollbarContent->SetAttr(kNameSpaceID_None, nsGkAtoms::clickthrough,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("always"), false);
|
2007-02-18 20:34:09 +03:00
|
|
|
if (!aElements.AppendElement(mHScrollbarContent))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2004-05-05 06:32:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canHaveVertical) {
|
2010-07-23 13:49:57 +04:00
|
|
|
nsCOMPtr<nsINodeInfo> ni = nodeInfo;
|
2010-08-20 03:12:46 +04:00
|
|
|
NS_TrustedNewXULElement(getter_AddRefs(mVScrollbarContent), ni.forget());
|
2007-02-18 20:34:09 +03:00
|
|
|
mVScrollbarContent->SetAttr(kNameSpaceID_None, nsGkAtoms::orient,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("vertical"), false);
|
2010-07-16 17:01:39 +04:00
|
|
|
mVScrollbarContent->SetAttr(kNameSpaceID_None, nsGkAtoms::clickthrough,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("always"), false);
|
2007-02-18 20:34:09 +03:00
|
|
|
if (!aElements.AppendElement(mVScrollbarContent))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2004-05-05 06:32:27 +04:00
|
|
|
}
|
|
|
|
|
2010-03-19 14:49:34 +03:00
|
|
|
if (isResizable) {
|
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
|
|
|
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::resizer, nsnull,
|
2011-06-14 11:56:49 +04:00
|
|
|
kNameSpaceID_XUL,
|
|
|
|
nsIDOMNode::ELEMENT_NODE);
|
2010-03-19 14:49:34 +03:00
|
|
|
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
2011-01-17 17:35:32 +03:00
|
|
|
NS_TrustedNewXULElement(getter_AddRefs(mResizerContent), nodeInfo.forget());
|
2010-03-19 14:49:34 +03:00
|
|
|
|
|
|
|
nsAutoString dir;
|
2010-03-23 20:14:47 +03:00
|
|
|
switch (resizeStyle) {
|
2010-03-19 14:49:34 +03:00
|
|
|
case NS_STYLE_RESIZE_HORIZONTAL:
|
|
|
|
if (IsScrollbarOnRight()) {
|
|
|
|
dir.AssignLiteral("right");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dir.AssignLiteral("left");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NS_STYLE_RESIZE_VERTICAL:
|
|
|
|
dir.AssignLiteral("bottom");
|
|
|
|
break;
|
|
|
|
case NS_STYLE_RESIZE_BOTH:
|
|
|
|
dir.AssignLiteral("bottomend");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_WARNING("only resizable types should have resizers");
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
mResizerContent->SetAttr(kNameSpaceID_None, nsGkAtoms::dir, dir, false);
|
2011-01-17 17:35:32 +03:00
|
|
|
|
|
|
|
if (mIsRoot) {
|
|
|
|
nsIContent* browserRoot = GetBrowserRoot(mOuter->GetContent());
|
|
|
|
mCollapsedResizer = !(browserRoot &&
|
|
|
|
browserRoot->HasAttr(kNameSpaceID_None, nsGkAtoms::showresizer));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mResizerContent->SetAttr(kNameSpaceID_None, nsGkAtoms::element,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("_parent"), false);
|
2011-01-17 17:35:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mResizerContent->SetAttr(kNameSpaceID_None, nsGkAtoms::clickthrough,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("always"), false);
|
2010-03-19 14:49:34 +03:00
|
|
|
|
2011-01-17 17:35:32 +03:00
|
|
|
if (!aElements.AppendElement(mResizerContent))
|
2010-03-19 14:49:34 +03:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2011-01-17 17:35:32 +03:00
|
|
|
|
|
|
|
if (canHaveHorizontal && canHaveVertical) {
|
2008-09-13 02:32:18 +04:00
|
|
|
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::scrollcorner, nsnull,
|
2011-06-14 11:56:49 +04:00
|
|
|
kNameSpaceID_XUL,
|
|
|
|
nsIDOMNode::ELEMENT_NODE);
|
2010-08-20 03:12:46 +04:00
|
|
|
NS_TrustedNewXULElement(getter_AddRefs(mScrollCornerContent), nodeInfo.forget());
|
2007-02-18 20:34:09 +03:00
|
|
|
if (!aElements.AppendElement(mScrollCornerContent))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2004-05-05 06:32:27 +04:00
|
|
|
}
|
2007-02-18 20:34:09 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-11 20:34:01 +03:00
|
|
|
void
|
2010-10-15 19:34:35 +04:00
|
|
|
nsGfxScrollFrameInner::AppendAnonymousContentTo(nsBaseContentList& aElements,
|
|
|
|
PRUint32 aFilter)
|
2010-02-11 20:34:01 +03:00
|
|
|
{
|
|
|
|
aElements.MaybeAppendElement(mHScrollbarContent);
|
|
|
|
aElements.MaybeAppendElement(mVScrollbarContent);
|
|
|
|
aElements.MaybeAppendElement(mScrollCornerContent);
|
2011-01-17 17:35:32 +03:00
|
|
|
aElements.MaybeAppendElement(mResizerContent);
|
2010-02-11 20:34:01 +03:00
|
|
|
}
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::Destroy()
|
|
|
|
{
|
|
|
|
// Unbind any content created in CreateAnonymousContent from the tree
|
|
|
|
nsContentUtils::DestroyAnonymousContent(&mHScrollbarContent);
|
|
|
|
nsContentUtils::DestroyAnonymousContent(&mVScrollbarContent);
|
|
|
|
nsContentUtils::DestroyAnonymousContent(&mScrollCornerContent);
|
2011-01-17 17:35:32 +03:00
|
|
|
nsContentUtils::DestroyAnonymousContent(&mResizerContent);
|
2007-03-05 04:39:53 +03:00
|
|
|
|
|
|
|
if (mPostedReflowCallback) {
|
2007-03-31 01:11:41 +04:00
|
|
|
mOuter->PresContext()->PresShell()->CancelReflowCallback(this);
|
2011-10-17 18:59:28 +04:00
|
|
|
mPostedReflowCallback = false;
|
2007-03-05 04:39:53 +03:00
|
|
|
}
|
1999-10-15 08:29:30 +04:00
|
|
|
}
|
|
|
|
|
2003-04-05 15:41:19 +04:00
|
|
|
/**
|
2005-08-22 08:16:38 +04:00
|
|
|
* Called when we want to update the scrollbar position, either because scrolling happened
|
|
|
|
* or the user moved the scrollbar position and we need to undo that (e.g., when the user
|
|
|
|
* clicks to scroll and we're using smooth scrolling, so we need to put the thumb back
|
|
|
|
* to its initial position for the start of the smooth sequence).
|
2003-04-05 15:41:19 +04:00
|
|
|
*/
|
|
|
|
void
|
2009-10-08 07:01:15 +04:00
|
|
|
nsGfxScrollFrameInner::UpdateScrollbarPosition()
|
2003-04-05 15:41:19 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
mFrameIsUpdatingScrollbar = true;
|
2009-10-08 07:01:15 +04:00
|
|
|
|
|
|
|
nsPoint pt = GetScrollPosition();
|
|
|
|
if (mVScrollbarBox) {
|
2007-03-14 01:11:14 +03:00
|
|
|
SetCoordAttribute(mVScrollbarBox->GetContent(), nsGkAtoms::curpos,
|
2009-10-08 07:01:15 +04:00
|
|
|
pt.y - GetScrolledRect().y);
|
|
|
|
}
|
|
|
|
if (mHScrollbarBox) {
|
2007-03-14 01:11:14 +03:00
|
|
|
SetCoordAttribute(mHScrollbarBox->GetContent(), nsGkAtoms::curpos,
|
2009-10-08 07:01:15 +04:00
|
|
|
pt.x - GetScrolledRect().x);
|
2009-09-30 02:18:20 +04:00
|
|
|
}
|
2008-09-04 01:35:52 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mFrameIsUpdatingScrollbar = false;
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
2006-03-15 19:55:19 +03:00
|
|
|
void nsGfxScrollFrameInner::CurPosAttributeChanged(nsIContent* aContent)
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
2003-05-22 05:46:13 +04:00
|
|
|
NS_ASSERTION(aContent, "aContent must not be null");
|
2006-03-15 19:55:19 +03:00
|
|
|
NS_ASSERTION((mHScrollbarBox && mHScrollbarBox->GetContent() == aContent) ||
|
|
|
|
(mVScrollbarBox && mVScrollbarBox->GetContent() == aContent),
|
|
|
|
"unexpected child");
|
2003-05-22 05:46:13 +04:00
|
|
|
|
2003-04-05 15:41:19 +04:00
|
|
|
// Attribute changes on the scrollbars happen in one of three ways:
|
|
|
|
// 1) The scrollbar changed the attribute in response to some user event
|
|
|
|
// 2) We changed the attribute in response to a ScrollPositionDidChange
|
|
|
|
// callback from the scrolling view
|
|
|
|
// 3) We changed the attribute to adjust the scrollbars for the start
|
|
|
|
// of a smooth scroll operation
|
|
|
|
//
|
2009-10-08 07:01:15 +04:00
|
|
|
// In cases 2 and 3 we do not need to scroll because we're just
|
|
|
|
// updating our scrollbar.
|
|
|
|
if (mFrameIsUpdatingScrollbar)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsRect scrolledRect = GetScrolledRect();
|
2006-03-15 19:55:19 +03:00
|
|
|
|
2011-08-12 02:44:29 +04:00
|
|
|
nsPoint current = GetScrollPosition() - scrolledRect.TopLeft();
|
2011-02-10 07:35:01 +03:00
|
|
|
nsPoint dest;
|
2011-08-12 02:44:29 +04:00
|
|
|
dest.x = GetCoordAttribute(mHScrollbarBox, nsGkAtoms::curpos, current.x) +
|
2011-02-10 07:35:01 +03:00
|
|
|
scrolledRect.x;
|
2011-08-12 02:44:29 +04:00
|
|
|
dest.y = GetCoordAttribute(mVScrollbarBox, nsGkAtoms::curpos, current.y) +
|
2011-02-10 07:35:01 +03:00
|
|
|
scrolledRect.y;
|
|
|
|
|
2011-02-20 23:03:32 +03:00
|
|
|
// If we have an async scroll pending don't stomp on that by calling ScrollTo.
|
|
|
|
if (mAsyncScroll && dest == GetScrollPosition()) {
|
2011-02-10 07:35:01 +03:00
|
|
|
return;
|
|
|
|
}
|
2006-03-15 19:55:19 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isSmooth = aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::smooth);
|
2009-10-08 07:01:15 +04:00
|
|
|
if (isSmooth) {
|
|
|
|
// Make sure an attribute-setting callback occurs even if the view
|
|
|
|
// didn't actually move yet. We need to make sure other listeners
|
|
|
|
// see that the scroll position is not (yet) what they thought it
|
|
|
|
// was.
|
|
|
|
UpdateScrollbarPosition();
|
2004-09-06 06:44:43 +04:00
|
|
|
}
|
2011-02-10 07:35:01 +03:00
|
|
|
ScrollTo(dest,
|
2009-10-08 07:01:15 +04:00
|
|
|
isSmooth ? nsIScrollableFrame::SMOOTH : nsIScrollableFrame::INSTANT);
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
2005-08-22 03:37:13 +04:00
|
|
|
/* ============= Scroll events ========== */
|
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrameInner::ScrollEvent::Run()
|
2005-08-22 03:37:13 +04:00
|
|
|
{
|
2006-05-10 21:30:15 +04:00
|
|
|
if (mInner)
|
|
|
|
mInner->FireScrollEvent();
|
|
|
|
return NS_OK;
|
2005-08-22 03:37:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::FireScrollEvent()
|
|
|
|
{
|
2006-05-10 21:30:15 +04:00
|
|
|
mScrollEvent.Forget();
|
2005-10-07 05:28:27 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
nsScrollbarEvent event(true, NS_SCROLL_EVENT, nsnull);
|
2005-08-22 03:37:13 +04:00
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
2005-10-07 05:28:27 +04:00
|
|
|
nsIContent* content = mOuter->GetContent();
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext* prescontext = mOuter->PresContext();
|
2005-10-07 05:28:27 +04:00
|
|
|
// Fire viewport scroll events at the document (where they
|
|
|
|
// will bubble to the window)
|
|
|
|
if (mIsRoot) {
|
|
|
|
nsIDocument* doc = content->GetCurrentDoc();
|
|
|
|
if (doc) {
|
2006-03-07 20:08:51 +03:00
|
|
|
nsEventDispatcher::Dispatch(doc, prescontext, &event, nsnull, &status);
|
2005-10-07 05:28:27 +04:00
|
|
|
}
|
|
|
|
} else {
|
2006-03-07 20:08:51 +03:00
|
|
|
// scroll events fired at elements don't bubble (although scroll events
|
|
|
|
// fired at documents do, to the window)
|
|
|
|
event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
|
|
|
|
nsEventDispatcher::Dispatch(content, prescontext, &event, nsnull, &status);
|
2005-10-07 05:28:27 +04:00
|
|
|
}
|
2005-08-22 03:37:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::PostScrollEvent()
|
|
|
|
{
|
2006-05-10 21:30:15 +04:00
|
|
|
if (mScrollEvent.IsPending())
|
2005-08-22 03:37:13 +04:00
|
|
|
return;
|
|
|
|
|
2011-10-26 08:14:31 +04:00
|
|
|
nsRootPresContext* rpc = mOuter->PresContext()->GetRootPresContext();
|
|
|
|
if (!rpc)
|
|
|
|
return;
|
|
|
|
mScrollEvent = new ScrollEvent(this);
|
|
|
|
rpc->AddWillPaintObserver(mScrollEvent.get());
|
2005-08-22 03:37:13 +04:00
|
|
|
}
|
|
|
|
|
2007-01-28 01:50:18 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrameInner::AsyncScrollPortEvent::Run()
|
|
|
|
{
|
2007-04-13 18:07:40 +04:00
|
|
|
if (mInner) {
|
|
|
|
mInner->mOuter->PresContext()->GetPresShell()->
|
2009-04-22 03:53:52 +04:00
|
|
|
FlushPendingNotifications(Flush_InterruptibleLayout);
|
2007-04-13 18:07:40 +04:00
|
|
|
}
|
2007-01-28 01:50:18 +03:00
|
|
|
return mInner ? mInner->FireScrollPortEvent() : NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
|
|
|
nsXULScrollFrame::AddHorizontalScrollbar(nsBoxLayoutState& aState, bool aOnBottom)
|
2005-04-29 01:57:22 +04:00
|
|
|
{
|
|
|
|
if (!mInner.mHScrollbarBox)
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2005-04-29 01:57:22 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return AddRemoveScrollbar(aState, aOnBottom, true, true);
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
|
|
|
nsXULScrollFrame::AddVerticalScrollbar(nsBoxLayoutState& aState, bool aOnRight)
|
2000-05-15 08:12:31 +04:00
|
|
|
{
|
2005-04-29 01:57:22 +04:00
|
|
|
if (!mInner.mVScrollbarBox)
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-12-18 01:51:39 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return AddRemoveScrollbar(aState, aOnRight, false, true);
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsXULScrollFrame::RemoveHorizontalScrollbar(nsBoxLayoutState& aState, bool aOnBottom)
|
2000-05-15 08:12:31 +04:00
|
|
|
{
|
2004-03-11 02:52:01 +03:00
|
|
|
// removing a scrollbar should always fit
|
|
|
|
#ifdef DEBUG
|
2011-09-29 10:19:26 +04:00
|
|
|
bool result =
|
2004-03-11 02:52:01 +03:00
|
|
|
#endif
|
2011-10-17 18:59:28 +04:00
|
|
|
AddRemoveScrollbar(aState, aOnBottom, true, false);
|
2004-03-11 02:52:01 +03:00
|
|
|
NS_ASSERTION(result, "Removing horizontal scrollbar failed to fit??");
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsXULScrollFrame::RemoveVerticalScrollbar(nsBoxLayoutState& aState, bool aOnRight)
|
2000-05-15 08:12:31 +04:00
|
|
|
{
|
2004-03-11 02:52:01 +03:00
|
|
|
// removing a scrollbar should always fit
|
|
|
|
#ifdef DEBUG
|
2011-09-29 10:19:26 +04:00
|
|
|
bool result =
|
2004-03-11 02:52:01 +03:00
|
|
|
#endif
|
2011-10-17 18:59:28 +04:00
|
|
|
AddRemoveScrollbar(aState, aOnRight, false, false);
|
2004-03-11 02:52:01 +03:00
|
|
|
NS_ASSERTION(result, "Removing vertical scrollbar failed to fit??");
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-10-08 07:01:15 +04:00
|
|
|
nsXULScrollFrame::AddRemoveScrollbar(nsBoxLayoutState& aState,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aOnRightOrBottom, bool aHorizontal, bool aAdd)
|
2000-05-15 08:12:31 +04:00
|
|
|
{
|
|
|
|
if (aHorizontal) {
|
2005-04-29 01:57:22 +04:00
|
|
|
if (mInner.mNeverHasHorizontalScrollbar || !mInner.mHScrollbarBox)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize hSize = mInner.mHScrollbarBox->GetPrefSize(aState);
|
2010-04-03 02:25:40 +04:00
|
|
|
nsBox::AddMargin(mInner.mHScrollbarBox, hSize);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
mInner.SetScrollbarVisibility(mInner.mHScrollbarBox, aAdd);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool hasHorizontalScrollbar;
|
|
|
|
bool fit = AddRemoveScrollbar(hasHorizontalScrollbar,
|
2009-10-08 07:01:15 +04:00
|
|
|
mInner.mScrollPort.y,
|
|
|
|
mInner.mScrollPort.height,
|
2011-03-04 00:18:42 +03:00
|
|
|
hSize.height, aOnRightOrBottom, aAdd);
|
2011-09-29 10:19:26 +04:00
|
|
|
mInner.mHasHorizontalScrollbar = hasHorizontalScrollbar; // because mHasHorizontalScrollbar is a bool
|
2000-05-15 08:12:31 +04:00
|
|
|
if (!fit)
|
2005-04-29 01:57:22 +04:00
|
|
|
mInner.SetScrollbarVisibility(mInner.mHScrollbarBox, !aAdd);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
|
|
|
return fit;
|
|
|
|
} else {
|
2005-04-29 01:57:22 +04:00
|
|
|
if (mInner.mNeverHasVerticalScrollbar || !mInner.mVScrollbarBox)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize vSize = mInner.mVScrollbarBox->GetPrefSize(aState);
|
2010-04-03 02:25:40 +04:00
|
|
|
nsBox::AddMargin(mInner.mVScrollbarBox, vSize);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
mInner.SetScrollbarVisibility(mInner.mVScrollbarBox, aAdd);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool hasVerticalScrollbar;
|
|
|
|
bool fit = AddRemoveScrollbar(hasVerticalScrollbar,
|
2009-10-08 07:01:15 +04:00
|
|
|
mInner.mScrollPort.x,
|
|
|
|
mInner.mScrollPort.width,
|
2011-03-04 00:18:42 +03:00
|
|
|
vSize.width, aOnRightOrBottom, aAdd);
|
2011-09-29 10:19:26 +04:00
|
|
|
mInner.mHasVerticalScrollbar = hasVerticalScrollbar; // because mHasVerticalScrollbar is a bool
|
2000-05-15 08:12:31 +04:00
|
|
|
if (!fit)
|
2005-04-29 01:57:22 +04:00
|
|
|
mInner.SetScrollbarVisibility(mInner.mVScrollbarBox, !aAdd);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
|
|
|
return fit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
|
|
|
nsXULScrollFrame::AddRemoveScrollbar(bool& aHasScrollbar, nscoord& aXY,
|
2005-04-29 01:57:22 +04:00
|
|
|
nscoord& aSize, nscoord aSbSize,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aOnRightOrBottom, bool aAdd)
|
2000-05-15 08:12:31 +04:00
|
|
|
{
|
1999-10-12 04:16:06 +04:00
|
|
|
nscoord size = aSize;
|
2004-09-27 23:21:41 +04:00
|
|
|
nscoord xy = aXY;
|
1999-10-12 04:16:06 +04:00
|
|
|
|
|
|
|
if (size != NS_INTRINSICSIZE) {
|
2000-04-03 10:26:38 +04:00
|
|
|
if (aAdd) {
|
1999-10-12 04:16:06 +04:00
|
|
|
size -= aSbSize;
|
2011-03-04 00:18:42 +03:00
|
|
|
if (!aOnRightOrBottom && size >= 0)
|
2004-09-27 23:21:41 +04:00
|
|
|
xy += aSbSize;
|
2000-04-03 10:26:38 +04:00
|
|
|
} else {
|
1999-10-12 04:16:06 +04:00
|
|
|
size += aSbSize;
|
2011-03-04 00:18:42 +03:00
|
|
|
if (!aOnRightOrBottom)
|
2004-09-27 23:21:41 +04:00
|
|
|
xy -= aSbSize;
|
2000-04-03 10:26:38 +04:00
|
|
|
}
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
// not enough room? Yes? Return true.
|
2004-09-27 23:21:41 +04:00
|
|
|
if (size >= 0) {
|
1999-10-12 04:16:06 +04:00
|
|
|
aHasScrollbar = aAdd;
|
|
|
|
aSize = size;
|
2004-09-27 23:21:41 +04:00
|
|
|
aXY = xy;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
aHasScrollbar = false;
|
|
|
|
return false;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2005-04-04 01:00:41 +04:00
|
|
|
void
|
2009-10-08 07:01:15 +04:00
|
|
|
nsXULScrollFrame::LayoutScrollArea(nsBoxLayoutState& aState,
|
|
|
|
const nsPoint& aScrollPosition)
|
2005-04-04 01:00:41 +04:00
|
|
|
{
|
|
|
|
PRUint32 oldflags = aState.LayoutFlags();
|
2011-02-13 09:38:29 +03:00
|
|
|
nsRect childRect = nsRect(mInner.mScrollPort.TopLeft() - aScrollPosition,
|
2009-10-08 07:01:15 +04:00
|
|
|
mInner.mScrollPort.Size());
|
2005-04-04 01:00:41 +04:00
|
|
|
PRInt32 flags = NS_FRAME_NO_MOVE_VIEW;
|
|
|
|
|
2010-01-28 07:12:42 +03:00
|
|
|
nsRect originalRect = mInner.mScrolledFrame->GetRect();
|
2010-10-07 08:25:47 +04:00
|
|
|
nsRect originalVisOverflow = mInner.mScrolledFrame->GetVisualOverflowRect();
|
2010-01-28 07:12:42 +03:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize minSize = mInner.mScrolledFrame->GetMinSize(aState);
|
2005-04-29 01:57:22 +04:00
|
|
|
|
2005-08-22 04:22:41 +04:00
|
|
|
if (minSize.height > childRect.height)
|
|
|
|
childRect.height = minSize.height;
|
2005-04-29 01:57:22 +04:00
|
|
|
|
2005-08-22 04:22:41 +04:00
|
|
|
if (minSize.width > childRect.width)
|
|
|
|
childRect.width = minSize.width;
|
2005-04-04 01:00:41 +04:00
|
|
|
|
|
|
|
aState.SetLayoutFlags(flags);
|
2011-02-13 09:38:29 +03:00
|
|
|
ClampAndSetBounds(aState, childRect, aScrollPosition);
|
2005-04-29 01:57:22 +04:00
|
|
|
mInner.mScrolledFrame->Layout(aState);
|
2005-04-04 01:00:41 +04:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
childRect = mInner.mScrolledFrame->GetRect();
|
2005-04-04 01:00:41 +04:00
|
|
|
|
2009-10-08 07:01:15 +04:00
|
|
|
if (childRect.width < mInner.mScrollPort.width ||
|
|
|
|
childRect.height < mInner.mScrollPort.height)
|
2005-04-04 01:00:41 +04:00
|
|
|
{
|
2009-10-08 07:01:15 +04:00
|
|
|
childRect.width = NS_MAX(childRect.width, mInner.mScrollPort.width);
|
|
|
|
childRect.height = NS_MAX(childRect.height, mInner.mScrollPort.height);
|
2005-04-04 01:00:41 +04:00
|
|
|
|
2010-10-07 08:25:47 +04:00
|
|
|
// remove overflow areas when we update the bounds,
|
2005-04-04 01:00:41 +04:00
|
|
|
// because we've already accounted for it
|
2010-10-07 08:25:47 +04:00
|
|
|
// REVIEW: Have we accounted for both?
|
2011-10-17 18:59:28 +04:00
|
|
|
ClampAndSetBounds(aState, childRect, aScrollPosition, true);
|
2011-02-07 10:59:20 +03:00
|
|
|
}
|
|
|
|
|
2010-01-28 07:12:42 +03:00
|
|
|
nsRect finalRect = mInner.mScrolledFrame->GetRect();
|
2010-10-07 08:25:47 +04:00
|
|
|
nsRect finalVisOverflow = mInner.mScrolledFrame->GetVisualOverflowRect();
|
2010-01-28 07:12:42 +03:00
|
|
|
// The position of the scrolled frame shouldn't change, but if it does or
|
|
|
|
// the position of the overflow rect changes just invalidate both the old
|
|
|
|
// and new overflow rect.
|
|
|
|
if (originalRect.TopLeft() != finalRect.TopLeft() ||
|
2010-10-07 08:25:47 +04:00
|
|
|
originalVisOverflow.TopLeft() != finalVisOverflow.TopLeft())
|
2010-01-28 07:12:42 +03:00
|
|
|
{
|
|
|
|
// The old overflow rect needs to be adjusted if the frame's position
|
|
|
|
// changed.
|
|
|
|
mInner.mScrolledFrame->Invalidate(
|
2010-10-07 08:25:47 +04:00
|
|
|
originalVisOverflow + originalRect.TopLeft() - finalRect.TopLeft());
|
|
|
|
mInner.mScrolledFrame->Invalidate(finalVisOverflow);
|
2011-04-19 07:07:23 +04:00
|
|
|
} else if (!originalVisOverflow.IsEqualInterior(finalVisOverflow)) {
|
2010-01-28 07:12:42 +03:00
|
|
|
// If the overflow rect changed then invalidate the difference between the
|
|
|
|
// old and new overflow rects.
|
|
|
|
mInner.mScrolledFrame->CheckInvalidateSizeChange(
|
2010-10-07 08:25:47 +04:00
|
|
|
originalRect, originalVisOverflow, finalRect.Size());
|
2010-01-28 07:12:42 +03:00
|
|
|
mInner.mScrolledFrame->InvalidateRectDifference(
|
2010-10-07 08:25:47 +04:00
|
|
|
originalVisOverflow, finalVisOverflow);
|
2010-01-28 07:12:42 +03:00
|
|
|
}
|
|
|
|
|
2005-04-04 01:00:41 +04:00
|
|
|
aState.SetLayoutFlags(oldflags);
|
|
|
|
|
2005-08-31 04:57:27 +04:00
|
|
|
}
|
2005-04-04 01:00:41 +04:00
|
|
|
|
2007-01-28 01:50:18 +03:00
|
|
|
void nsGfxScrollFrameInner::PostOverflowEvent()
|
2005-08-31 04:57:27 +04:00
|
|
|
{
|
2007-01-28 01:50:18 +03:00
|
|
|
if (mAsyncScrollPortEvent.IsPending())
|
|
|
|
return;
|
2005-04-04 01:00:41 +04:00
|
|
|
|
2007-10-08 12:42:43 +04:00
|
|
|
// Keep this in sync with FireScrollPortEvent().
|
2009-10-08 07:01:15 +04:00
|
|
|
nsSize scrollportSize = mScrollPort.Size();
|
|
|
|
nsSize childSize = GetScrolledRect().Size();
|
2007-10-08 12:42:43 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool newVerticalOverflow = childSize.height > scrollportSize.height;
|
|
|
|
bool vertChanged = mVerticalOverflow != newVerticalOverflow;
|
2007-10-08 12:42:43 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool newHorizontalOverflow = childSize.width > scrollportSize.width;
|
|
|
|
bool horizChanged = mHorizontalOverflow != newHorizontalOverflow;
|
2007-10-08 12:42:43 +04:00
|
|
|
|
|
|
|
if (!vertChanged && !horizChanged) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-28 01:50:18 +03:00
|
|
|
nsRefPtr<AsyncScrollPortEvent> ev = new AsyncScrollPortEvent(this);
|
|
|
|
if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev)))
|
|
|
|
mAsyncScrollPortEvent = ev;
|
2005-04-04 01:00:41 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2006-03-15 19:55:19 +03:00
|
|
|
nsGfxScrollFrameInner::IsLTR() const
|
2005-04-29 01:57:22 +04:00
|
|
|
{
|
|
|
|
//TODO make bidi code set these from preferences
|
2006-03-15 19:55:19 +03:00
|
|
|
|
|
|
|
nsIFrame *frame = mOuter;
|
|
|
|
// XXX This is a bit on the slow side.
|
|
|
|
if (mIsRoot) {
|
|
|
|
// If we're the root scrollframe, we need the root element's style data.
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext *presContext = mOuter->PresContext();
|
2006-05-19 14:26:44 +04:00
|
|
|
nsIDocument *document = presContext->Document();
|
2010-04-30 17:12:05 +04:00
|
|
|
Element *root = document->GetRootElement();
|
2006-03-15 19:55:19 +03:00
|
|
|
|
2010-04-30 17:12:05 +04:00
|
|
|
// But for HTML and XHTML we want the body element.
|
2008-02-19 21:47:34 +03:00
|
|
|
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document);
|
2008-02-19 21:46:21 +03:00
|
|
|
if (htmlDoc) {
|
2010-04-30 17:12:05 +04:00
|
|
|
Element *bodyElement = document->GetBodyElement();
|
|
|
|
if (bodyElement)
|
|
|
|
root = bodyElement; // we can trust the document to hold on to it
|
2006-03-15 19:55:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (root) {
|
2009-12-25 00:20:06 +03:00
|
|
|
nsIFrame *rootsFrame = root->GetPrimaryFrame();
|
2006-03-15 19:55:19 +03:00
|
|
|
if (rootsFrame)
|
|
|
|
frame = rootsFrame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return frame->GetStyleVisibility()->mDirection != NS_STYLE_DIRECTION_RTL;
|
2005-04-29 01:57:22 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2006-03-26 04:48:03 +04:00
|
|
|
nsGfxScrollFrameInner::IsScrollbarOnRight() const
|
|
|
|
{
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext *presContext = mOuter->PresContext();
|
2010-04-08 20:11:14 +04:00
|
|
|
|
|
|
|
// The position of the scrollbar in top-level windows depends on the pref
|
|
|
|
// layout.scrollbar.side. For non-top-level elements, it depends only on the
|
|
|
|
// directionaliy of the element (equivalent to a value of "1" for the pref).
|
|
|
|
if (!mIsRoot)
|
|
|
|
return IsLTR();
|
2006-03-26 04:48:03 +04:00
|
|
|
switch (presContext->GetCachedIntPref(kPresContext_ScrollbarSide)) {
|
|
|
|
default:
|
|
|
|
case 0: // UI directionality
|
|
|
|
return presContext->GetCachedIntPref(kPresContext_BidiDirection)
|
|
|
|
== IBMBIDI_TEXTDIRECTION_LTR;
|
|
|
|
case 1: // Document / content directionality
|
|
|
|
return IsLTR();
|
|
|
|
case 2: // Always right
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2006-03-26 04:48:03 +04:00
|
|
|
case 3: // Always left
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2006-03-26 04:48:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
/**
|
|
|
|
* Reflow the scroll area if it needs it and return its size. Also determine if the reflow will
|
|
|
|
* cause any of the scrollbars to need to be reflowed.
|
|
|
|
*/
|
2000-03-31 11:02:06 +04:00
|
|
|
nsresult
|
2005-04-29 01:57:22 +04:00
|
|
|
nsXULScrollFrame::Layout(nsBoxLayoutState& aState)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool scrollbarRight = mInner.IsScrollbarOnRight();
|
|
|
|
bool scrollbarBottom = true;
|
2001-04-12 03:04:11 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// get the content rect
|
|
|
|
nsRect clientRect(0,0,0,0);
|
2005-04-29 01:57:22 +04:00
|
|
|
GetClientRect(clientRect);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2009-10-08 07:01:15 +04:00
|
|
|
nsRect oldScrollAreaBounds = mInner.mScrollPort;
|
2011-02-07 10:59:20 +03:00
|
|
|
nsPoint oldScrollPosition = mInner.GetLogicalScrollPosition();
|
2009-10-08 07:01:15 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// the scroll area size starts off as big as our content area
|
2009-10-08 07:01:15 +04:00
|
|
|
mInner.mScrollPort = clientRect;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
/**************
|
|
|
|
Our basic strategy here is to first try laying out the content with
|
|
|
|
the scrollbars in their current state. We're hoping that that will
|
|
|
|
just "work"; the content will overflow wherever there's a scrollbar
|
|
|
|
already visible. If that does work, then there's no need to lay out
|
|
|
|
the scrollarea. Otherwise we fix up the scrollbars; first we add a
|
|
|
|
vertical one to scroll the content if necessary, or remove it if
|
|
|
|
it's not needed. Then we reflow the content if the scrollbar
|
|
|
|
changed. Then we add a horizontal scrollbar if necessary (or
|
|
|
|
remove if not needed), and if that changed, we reflow the content
|
|
|
|
again. At this point, any scrollbars that are needed to scroll the
|
|
|
|
content have been added.
|
|
|
|
|
|
|
|
In the second phase we check to see if any scrollbars are too small
|
|
|
|
to display, and if so, we remove them. We check the horizontal
|
|
|
|
scrollbar first; removing it might make room for the vertical
|
|
|
|
scrollbar, and if we have room for just one scrollbar we'll save
|
|
|
|
the vertical one.
|
|
|
|
|
|
|
|
Finally we position and size the scrollbars and scrollcorner (the
|
|
|
|
square that is needed in the corner of the window when two
|
|
|
|
scrollbars are visible), and reflow any fixed position views
|
|
|
|
(if we're the viewport and we added or removed a scrollbar).
|
|
|
|
**************/
|
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
ScrollbarStyles styles = GetScrollbarStyles();
|
2003-05-22 05:46:13 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// Look at our style do we always have vertical or horizontal scrollbars?
|
2003-05-22 05:46:13 +04:00
|
|
|
if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL)
|
2011-10-17 18:59:28 +04:00
|
|
|
mInner.mHasHorizontalScrollbar = true;
|
2003-05-22 05:46:13 +04:00
|
|
|
if (styles.mVertical == NS_STYLE_OVERFLOW_SCROLL)
|
2011-10-17 18:59:28 +04:00
|
|
|
mInner.mHasVerticalScrollbar = true;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
if (mInner.mHasHorizontalScrollbar)
|
2009-10-08 07:01:15 +04:00
|
|
|
AddHorizontalScrollbar(aState, scrollbarBottom);
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
if (mInner.mHasVerticalScrollbar)
|
2009-10-08 07:01:15 +04:00
|
|
|
AddVerticalScrollbar(aState, scrollbarRight);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// layout our the scroll area
|
2009-10-08 07:01:15 +04:00
|
|
|
LayoutScrollArea(aState, oldScrollPosition);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// now look at the content area and see if we need scrollbars or not
|
2011-09-29 10:19:26 +04:00
|
|
|
bool needsLayout = false;
|
2006-03-15 19:55:19 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// if we have 'auto' scrollbars look at the vertical case
|
2003-05-22 05:46:13 +04:00
|
|
|
if (styles.mVertical != NS_STYLE_OVERFLOW_SCROLL) {
|
2007-01-04 07:44:42 +03:00
|
|
|
// These are only good until the call to LayoutScrollArea.
|
2009-10-08 07:01:15 +04:00
|
|
|
nsRect scrolledRect = mInner.GetScrolledRect();
|
2007-01-04 07:44:42 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// There are two cases to consider
|
2011-02-07 10:59:20 +03:00
|
|
|
if (scrolledRect.height <= mInner.mScrollPort.height
|
2003-05-22 05:46:13 +04:00
|
|
|
|| styles.mVertical != NS_STYLE_OVERFLOW_AUTO) {
|
2005-04-29 01:57:22 +04:00
|
|
|
if (mInner.mHasVerticalScrollbar) {
|
2000-03-31 11:02:06 +04:00
|
|
|
// We left room for the vertical scrollbar, but it's not needed;
|
|
|
|
// remove it.
|
2009-10-08 07:01:15 +04:00
|
|
|
RemoveVerticalScrollbar(aState, scrollbarRight);
|
2011-10-17 18:59:28 +04:00
|
|
|
needsLayout = true;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
} else {
|
2005-04-29 01:57:22 +04:00
|
|
|
if (!mInner.mHasVerticalScrollbar) {
|
2000-03-31 11:02:06 +04:00
|
|
|
// We didn't leave room for the vertical scrollbar, but it turns
|
|
|
|
// out we needed it
|
2009-10-08 07:01:15 +04:00
|
|
|
if (AddVerticalScrollbar(aState, scrollbarRight))
|
2011-10-17 18:59:28 +04:00
|
|
|
needsLayout = true;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// ok layout at the right size
|
|
|
|
if (needsLayout) {
|
|
|
|
nsBoxLayoutState resizeState(aState);
|
2009-10-08 07:01:15 +04:00
|
|
|
LayoutScrollArea(resizeState, oldScrollPosition);
|
2011-10-17 18:59:28 +04:00
|
|
|
needsLayout = false;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// if scrollbars are auto look at the horizontal case
|
2003-05-22 05:46:13 +04:00
|
|
|
if (styles.mHorizontal != NS_STYLE_OVERFLOW_SCROLL)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2007-01-04 07:44:42 +03:00
|
|
|
// These are only good until the call to LayoutScrollArea.
|
2009-10-08 07:01:15 +04:00
|
|
|
nsRect scrolledRect = mInner.GetScrolledRect();
|
2007-01-04 07:44:42 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// if the child is wider that the scroll area
|
|
|
|
// and we don't have a scrollbar add one.
|
2011-02-07 10:59:20 +03:00
|
|
|
if ((scrolledRect.width > mInner.mScrollPort.width)
|
2003-05-22 05:46:13 +04:00
|
|
|
&& styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO) {
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
if (!mInner.mHasHorizontalScrollbar) {
|
2000-05-15 08:12:31 +04:00
|
|
|
// no scrollbar?
|
2009-10-08 07:01:15 +04:00
|
|
|
if (AddHorizontalScrollbar(aState, scrollbarBottom))
|
2011-10-17 18:59:28 +04:00
|
|
|
needsLayout = true;
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2008-07-19 09:32:50 +04:00
|
|
|
// if we added a horizontal scrollbar and we did not have a vertical
|
|
|
|
// there is a chance that by adding the horizontal scrollbar we will
|
2000-03-31 11:02:06 +04:00
|
|
|
// suddenly need a vertical scrollbar. Is a special case but its
|
|
|
|
// important.
|
2011-02-07 10:59:20 +03:00
|
|
|
//if (!mHasVerticalScrollbar && scrolledRect.height > scrollAreaRect.height - sbSize.height)
|
2000-10-29 02:17:53 +04:00
|
|
|
// printf("****Gfx Scrollbar Special case hit!!*****\n");
|
2000-04-03 10:26:38 +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
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
} else {
|
|
|
|
// if the area is smaller or equal to and we have a scrollbar then
|
|
|
|
// remove it.
|
2005-04-29 01:57:22 +04:00
|
|
|
if (mInner.mHasHorizontalScrollbar) {
|
2009-10-08 07:01:15 +04:00
|
|
|
RemoveHorizontalScrollbar(aState, scrollbarBottom);
|
2011-10-17 18:59:28 +04:00
|
|
|
needsLayout = true;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// we only need to set the rect. The inner child stays the same size.
|
|
|
|
if (needsLayout) {
|
|
|
|
nsBoxLayoutState resizeState(aState);
|
2009-10-08 07:01:15 +04:00
|
|
|
LayoutScrollArea(resizeState, oldScrollPosition);
|
2011-10-17 18:59:28 +04:00
|
|
|
needsLayout = false;
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
// get the preferred size of the scrollbars
|
2005-04-29 01:57:22 +04:00
|
|
|
nsSize hMinSize(0, 0);
|
|
|
|
if (mInner.mHScrollbarBox && mInner.mHasHorizontalScrollbar) {
|
2011-10-17 18:59:28 +04:00
|
|
|
GetScrollbarMetrics(aState, mInner.mHScrollbarBox, &hMinSize, nsnull, false);
|
2004-03-11 02:52:01 +03:00
|
|
|
}
|
2005-04-29 01:57:22 +04:00
|
|
|
nsSize vMinSize(0, 0);
|
|
|
|
if (mInner.mVScrollbarBox && mInner.mHasVerticalScrollbar) {
|
2011-10-17 18:59:28 +04:00
|
|
|
GetScrollbarMetrics(aState, mInner.mVScrollbarBox, &vMinSize, nsnull, true);
|
2004-03-11 02:52:01 +03:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
// Disable scrollbars that are too small
|
|
|
|
// Disable horizontal scrollbar first. If we have to disable only one
|
|
|
|
// scrollbar, we'd rather keep the vertical scrollbar.
|
2004-03-12 06:35:53 +03:00
|
|
|
// Note that we always give horizontal scrollbars their preferred height,
|
|
|
|
// never their min-height. So check that there's room for the preferred height.
|
2005-04-29 01:57:22 +04:00
|
|
|
if (mInner.mHasHorizontalScrollbar &&
|
|
|
|
(hMinSize.width > clientRect.width - vMinSize.width
|
|
|
|
|| hMinSize.height > clientRect.height)) {
|
2009-10-08 07:01:15 +04:00
|
|
|
RemoveHorizontalScrollbar(aState, scrollbarBottom);
|
2011-10-17 18:59:28 +04:00
|
|
|
needsLayout = true;
|
2004-03-11 02:52:01 +03:00
|
|
|
}
|
|
|
|
// Now disable vertical scrollbar if necessary
|
2005-04-29 01:57:22 +04:00
|
|
|
if (mInner.mHasVerticalScrollbar &&
|
|
|
|
(vMinSize.height > clientRect.height - hMinSize.height
|
|
|
|
|| vMinSize.width > clientRect.width)) {
|
2009-10-08 07:01:15 +04:00
|
|
|
RemoveVerticalScrollbar(aState, scrollbarRight);
|
2011-10-17 18:59:28 +04:00
|
|
|
needsLayout = true;
|
2000-04-25 11:10:48 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
// we only need to set the rect. The inner child stays the same size.
|
|
|
|
if (needsLayout) {
|
|
|
|
nsBoxLayoutState resizeState(aState);
|
2009-10-08 07:01:15 +04:00
|
|
|
LayoutScrollArea(resizeState, oldScrollPosition);
|
2005-04-29 01:57:22 +04:00
|
|
|
}
|
|
|
|
|
2005-07-26 03:23:53 +04:00
|
|
|
if (!mInner.mSupppressScrollbarUpdate) {
|
2009-10-08 07:01:15 +04:00
|
|
|
mInner.LayoutScrollbars(aState, clientRect, oldScrollAreaBounds);
|
2005-07-26 03:23:53 +04:00
|
|
|
}
|
2009-06-24 05:35:00 +04:00
|
|
|
if (!mInner.mPostedReflowCallback) {
|
|
|
|
// Make sure we'll try scrolling to restored position
|
|
|
|
PresContext()->PresShell()->PostReflowCallback(&mInner);
|
2011-10-17 18:59:28 +04:00
|
|
|
mInner.mPostedReflowCallback = true;
|
2009-06-24 05:35:00 +04:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mInner.mHadNonInitialReflow = true;
|
2005-08-25 04:10:37 +04:00
|
|
|
}
|
2007-01-28 01:50:18 +03:00
|
|
|
|
|
|
|
mInner.PostOverflowEvent();
|
2005-04-29 01:57:22 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-14 01:11:14 +03:00
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::FinishReflowForScrollbar(nsIContent* aContent,
|
|
|
|
nscoord aMinXY, nscoord aMaxXY,
|
|
|
|
nscoord aCurPosXY,
|
|
|
|
nscoord aPageIncrement,
|
|
|
|
nscoord aIncrement)
|
|
|
|
{
|
|
|
|
// Scrollbars assume zero is the minimum position, so translate for them.
|
|
|
|
SetCoordAttribute(aContent, nsGkAtoms::curpos, aCurPosXY - aMinXY);
|
|
|
|
SetScrollbarEnabled(aContent, aMaxXY - aMinXY);
|
|
|
|
SetCoordAttribute(aContent, nsGkAtoms::maxpos, aMaxXY - aMinXY);
|
|
|
|
SetCoordAttribute(aContent, nsGkAtoms::pageincrement, aPageIncrement);
|
|
|
|
SetCoordAttribute(aContent, nsGkAtoms::increment, aIncrement);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2007-03-05 04:39:53 +03:00
|
|
|
nsGfxScrollFrameInner::ReflowFinished()
|
2005-04-29 01:57:22 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
mPostedReflowCallback = false;
|
2007-03-05 04:39:53 +03:00
|
|
|
|
2009-06-24 05:35:00 +04:00
|
|
|
ScrollToRestoredPosition();
|
|
|
|
|
2010-03-29 05:46:59 +04:00
|
|
|
// Clamp scroll position
|
|
|
|
ScrollToImpl(GetScrollPosition());
|
|
|
|
|
2009-06-24 05:35:00 +04:00
|
|
|
if (NS_SUBTREE_DIRTY(mOuter) || !mUpdateScrollbarAttributes)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-06-12 05:46:33 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mUpdateScrollbarAttributes = false;
|
2009-06-24 05:35:00 +04:00
|
|
|
|
2009-06-12 05:46:33 +04:00
|
|
|
// Update scrollbar attributes.
|
|
|
|
nsPresContext* presContext = mOuter->PresContext();
|
|
|
|
|
2007-12-21 02:49:46 +03:00
|
|
|
if (mMayHaveDirtyFixedChildren) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mMayHaveDirtyFixedChildren = false;
|
2007-12-21 02:49:46 +03:00
|
|
|
nsIFrame* parentFrame = mOuter->GetParent();
|
|
|
|
for (nsIFrame* fixedChild =
|
2011-08-25 00:54:30 +04:00
|
|
|
parentFrame->GetFirstChild(nsIFrame::kFixedList);
|
2007-12-21 02:49:46 +03:00
|
|
|
fixedChild; fixedChild = fixedChild->GetNextSibling()) {
|
|
|
|
// force a reflow of the fixed child
|
2009-06-12 05:46:33 +04:00
|
|
|
presContext->PresShell()->
|
2007-12-21 02:49:46 +03:00
|
|
|
FrameNeedsReflow(fixedChild, nsIPresShell::eResize,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-08 07:01:15 +04:00
|
|
|
nsRect scrolledContentRect = GetScrolledRect();
|
2006-03-15 19:55:19 +03:00
|
|
|
nscoord minX = scrolledContentRect.x;
|
2009-10-08 07:01:15 +04:00
|
|
|
nscoord maxX = scrolledContentRect.XMost() - mScrollPort.width;
|
2006-03-15 19:55:19 +03:00
|
|
|
nscoord minY = scrolledContentRect.y;
|
2009-10-08 07:01:15 +04:00
|
|
|
nscoord maxY = scrolledContentRect.YMost() - mScrollPort.height;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-03-15 19:55:19 +03:00
|
|
|
// Suppress handling of the curpos attribute changes we make here.
|
2009-10-08 07:01:15 +04:00
|
|
|
NS_ASSERTION(!mFrameIsUpdatingScrollbar, "We shouldn't be reentering here");
|
2011-10-17 18:59:28 +04:00
|
|
|
mFrameIsUpdatingScrollbar = true;
|
2006-03-15 19:55:19 +03:00
|
|
|
|
2007-03-14 01:11:14 +03:00
|
|
|
nsCOMPtr<nsIContent> vScroll =
|
|
|
|
mVScrollbarBox ? mVScrollbarBox->GetContent() : nsnull;
|
|
|
|
nsCOMPtr<nsIContent> hScroll =
|
|
|
|
mHScrollbarBox ? mHScrollbarBox->GetContent() : nsnull;
|
2007-03-05 04:39:53 +03:00
|
|
|
|
2007-03-14 01:11:14 +03:00
|
|
|
// Note, in some cases mOuter may get deleted while finishing reflow
|
|
|
|
// for scrollbars.
|
|
|
|
if (vScroll || hScroll) {
|
|
|
|
nsWeakFrame weakFrame(mOuter);
|
2009-10-08 07:01:15 +04:00
|
|
|
nsPoint scrollPos = GetScrollPosition();
|
|
|
|
// XXX shouldn't we use GetPageScrollAmount/GetLineScrollAmount here?
|
2007-03-14 01:11:14 +03:00
|
|
|
if (vScroll) {
|
2009-10-08 07:01:15 +04:00
|
|
|
nscoord fontHeight = GetLineScrollAmount().height;
|
2008-02-24 10:35:08 +03:00
|
|
|
// We normally use (scrollArea.height - fontHeight) for height
|
|
|
|
// of page scrolling. However, it is too small when
|
|
|
|
// fontHeight is very large. (If fontHeight is larger than
|
|
|
|
// scrollArea.height, direction of scrolling will be opposite).
|
|
|
|
// To avoid it, we use (float(scrollArea.height) * 0.8) as
|
|
|
|
// lower bound value of height of page scrolling. (bug 383267)
|
2009-10-08 07:01:15 +04:00
|
|
|
nscoord pageincrement = nscoord(mScrollPort.height - fontHeight);
|
|
|
|
nscoord pageincrementMin = nscoord(float(mScrollPort.height) * 0.8);
|
|
|
|
FinishReflowForScrollbar(vScroll, minY, maxY, scrollPos.y,
|
2009-09-16 19:01:36 +04:00
|
|
|
NS_MAX(pageincrement,pageincrementMin),
|
2007-03-14 01:11:14 +03:00
|
|
|
fontHeight);
|
|
|
|
}
|
|
|
|
if (hScroll) {
|
2009-10-08 07:01:15 +04:00
|
|
|
FinishReflowForScrollbar(hScroll, minX, maxX, scrollPos.x,
|
|
|
|
nscoord(float(mScrollPort.width) * 0.8),
|
2007-03-14 01:11:14 +03:00
|
|
|
nsPresContext::CSSPixelsToAppUnits(10));
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_ENSURE_TRUE(weakFrame.IsAlive(), false);
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mFrameIsUpdatingScrollbar = false;
|
2006-03-15 19:55:19 +03:00
|
|
|
// We used to rely on the curpos attribute changes above to scroll the
|
|
|
|
// view. However, for scrolling to the left of the viewport, we
|
|
|
|
// rescale the curpos attribute, which means that operations like
|
|
|
|
// resizing the window while it is scrolled all the way to the left
|
|
|
|
// hold the curpos attribute constant at 0 while still requiring
|
|
|
|
// scrolling. So we suppress the effect of the changes above with
|
2009-10-08 07:01:15 +04:00
|
|
|
// mFrameIsUpdatingScrollbar and call CurPosAttributeChanged here.
|
2006-03-15 19:55:19 +03:00
|
|
|
// (It actually even works some of the time without this, thanks to
|
|
|
|
// nsSliderFrame::AttributeChanged's handling of maxpos, but not when
|
|
|
|
// we hide the scrollbar on a large size change, such as
|
|
|
|
// maximization.)
|
2007-03-05 04:39:53 +03:00
|
|
|
if (!mHScrollbarBox && !mVScrollbarBox)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2007-03-05 04:39:53 +03:00
|
|
|
CurPosAttributeChanged(mVScrollbarBox ? mVScrollbarBox->GetContent()
|
|
|
|
: mHScrollbarBox->GetContent());
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2007-03-05 04:39:53 +03:00
|
|
|
}
|
|
|
|
|
2007-12-01 10:22:44 +03:00
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::ReflowCallbackCanceled()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
mPostedReflowCallback = false;
|
2007-12-01 10:22:44 +03:00
|
|
|
}
|
|
|
|
|
2007-03-28 10:24:40 +04:00
|
|
|
static void LayoutAndInvalidate(nsBoxLayoutState& aState,
|
2010-07-16 01:08:03 +04:00
|
|
|
nsIFrame* aBox, const nsRect& aRect,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aScrollbarIsBeingHidden)
|
2007-03-28 10:24:40 +04:00
|
|
|
{
|
|
|
|
// When a child box changes shape of position, the parent
|
|
|
|
// is responsible for invalidation; the overflow rect must be invalidated
|
2010-01-14 05:30:06 +03:00
|
|
|
// to make sure to catch any overflow.
|
|
|
|
// We invalidate the parent (i.e. the scrollframe) directly, because
|
|
|
|
// invalidates coming from scrollbars are suppressed by nsHTMLScrollFrame when
|
|
|
|
// mHasVScrollbar/mHasHScrollbar is false, and this is called after those
|
|
|
|
// flags have been set ... if a scrollbar is being hidden, we still need
|
|
|
|
// to invalidate the scrollbar area here.
|
2010-07-16 01:08:03 +04:00
|
|
|
// But we also need to invalidate the scrollbar itself in case it has
|
|
|
|
// its own layer; we need to ensure that layer is updated.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool rectChanged = !aBox->GetRect().IsEqualInterior(aRect);
|
2010-01-14 05:30:06 +03:00
|
|
|
if (rectChanged) {
|
2010-07-16 01:08:03 +04:00
|
|
|
if (aScrollbarIsBeingHidden) {
|
2010-10-07 08:25:47 +04:00
|
|
|
aBox->GetParent()->Invalidate(aBox->GetVisualOverflowRect() +
|
|
|
|
aBox->GetPosition());
|
2010-07-16 01:08:03 +04:00
|
|
|
} else {
|
2010-08-31 04:49:12 +04:00
|
|
|
aBox->InvalidateFrameSubtree();
|
2010-07-16 01:08:03 +04:00
|
|
|
}
|
2010-01-14 05:30:06 +03:00
|
|
|
}
|
2007-03-28 10:24:40 +04:00
|
|
|
nsBoxFrame::LayoutChildAt(aState, aBox, aRect);
|
2010-01-14 05:30:06 +03:00
|
|
|
if (rectChanged) {
|
2010-07-16 01:08:03 +04:00
|
|
|
if (aScrollbarIsBeingHidden) {
|
2010-10-07 08:25:47 +04:00
|
|
|
aBox->GetParent()->Invalidate(aBox->GetVisualOverflowRect() +
|
|
|
|
aBox->GetPosition());
|
2010-07-16 01:08:03 +04:00
|
|
|
} else {
|
2010-08-31 04:49:12 +04:00
|
|
|
aBox->InvalidateFrameSubtree();
|
2010-07-16 01:08:03 +04:00
|
|
|
}
|
2010-01-14 05:30:06 +03:00
|
|
|
}
|
2007-03-28 10:24:40 +04:00
|
|
|
}
|
|
|
|
|
2010-03-19 14:49:34 +03:00
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::AdjustScrollbarRectForResizer(
|
|
|
|
nsIFrame* aFrame, nsPresContext* aPresContext,
|
2011-09-29 10:19:26 +04:00
|
|
|
nsRect& aRect, bool aHasResizer, bool aVertical)
|
2008-08-08 20:11:54 +04:00
|
|
|
{
|
|
|
|
if ((aVertical ? aRect.width : aRect.height) == 0)
|
|
|
|
return;
|
|
|
|
|
2010-03-19 14:49:34 +03:00
|
|
|
// if a content resizer is present, use its size. Otherwise, check if the
|
|
|
|
// widget has a resizer.
|
|
|
|
nsRect resizerRect;
|
2011-01-17 17:35:32 +03:00
|
|
|
if (aHasResizer) {
|
|
|
|
resizerRect = mResizerBox->GetRect();
|
2010-03-19 14:49:34 +03:00
|
|
|
}
|
|
|
|
else {
|
2010-07-19 06:23:48 +04:00
|
|
|
nsPoint offset;
|
|
|
|
nsIWidget* widget = aFrame->GetNearestWidget(offset);
|
2010-03-19 14:49:34 +03:00
|
|
|
nsIntRect widgetRect;
|
|
|
|
if (!widget || !widget->ShowsResizeIndicator(&widgetRect))
|
|
|
|
return;
|
2008-08-08 20:11:54 +04:00
|
|
|
|
2010-03-23 21:55:35 +03:00
|
|
|
resizerRect = nsRect(aPresContext->DevPixelsToAppUnits(widgetRect.x) - offset.x,
|
|
|
|
aPresContext->DevPixelsToAppUnits(widgetRect.y) - offset.y,
|
|
|
|
aPresContext->DevPixelsToAppUnits(widgetRect.width),
|
|
|
|
aPresContext->DevPixelsToAppUnits(widgetRect.height));
|
2010-03-19 14:49:34 +03:00
|
|
|
}
|
2008-08-08 20:11:54 +04:00
|
|
|
|
2009-10-05 06:14:38 +04:00
|
|
|
if (!resizerRect.Contains(aRect.BottomRight() - nsPoint(1, 1)))
|
2008-08-08 20:11:54 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (aVertical)
|
2009-09-16 19:01:36 +04:00
|
|
|
aRect.height = NS_MAX(0, resizerRect.y - aRect.y);
|
2008-08-08 20:11:54 +04:00
|
|
|
else
|
2009-09-16 19:01:36 +04:00
|
|
|
aRect.width = NS_MAX(0, resizerRect.x - aRect.x);
|
2008-08-08 20:11:54 +04:00
|
|
|
}
|
|
|
|
|
2007-03-05 04:39:53 +03:00
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::LayoutScrollbars(nsBoxLayoutState& aState,
|
|
|
|
const nsRect& aContentArea,
|
2009-10-08 07:01:15 +04:00
|
|
|
const nsRect& aOldScrollArea)
|
2007-03-05 04:39:53 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!mSupppressScrollbarUpdate,
|
|
|
|
"This should have been suppressed");
|
2009-10-08 07:01:15 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool hasResizer = HasResizer();
|
|
|
|
bool scrollbarOnLeft = !IsScrollbarOnRight();
|
2010-03-19 14:49:34 +03:00
|
|
|
|
|
|
|
// place the scrollcorner
|
2011-01-17 17:35:32 +03:00
|
|
|
if (mScrollCornerBox || mResizerBox) {
|
|
|
|
NS_PRECONDITION(!mScrollCornerBox || mScrollCornerBox->IsBoxFrame(), "Must be a box frame!");
|
2010-03-19 14:49:34 +03:00
|
|
|
|
|
|
|
nsRect r(0, 0, 0, 0);
|
|
|
|
if (aContentArea.x != mScrollPort.x || scrollbarOnLeft) {
|
|
|
|
// scrollbar (if any) on left
|
|
|
|
r.x = aContentArea.x;
|
2011-01-17 17:35:32 +03:00
|
|
|
r.width = mScrollPort.x - aContentArea.x;
|
2010-03-19 14:49:34 +03:00
|
|
|
NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect");
|
|
|
|
} else {
|
|
|
|
// scrollbar (if any) on right
|
2011-01-17 17:35:32 +03:00
|
|
|
r.width = aContentArea.XMost() - mScrollPort.XMost();
|
2010-03-19 14:49:34 +03:00
|
|
|
r.x = aContentArea.XMost() - r.width;
|
|
|
|
NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect");
|
|
|
|
}
|
|
|
|
if (aContentArea.y != mScrollPort.y) {
|
|
|
|
NS_ERROR("top scrollbars not supported");
|
|
|
|
} else {
|
|
|
|
// scrollbar (if any) on bottom
|
2011-01-17 17:35:32 +03:00
|
|
|
r.height = aContentArea.YMost() - mScrollPort.YMost();
|
2010-03-19 14:49:34 +03:00
|
|
|
r.y = aContentArea.YMost() - r.height;
|
|
|
|
NS_ASSERTION(r.height >= 0, "Scroll area should be inside client rect");
|
|
|
|
}
|
2011-01-17 17:35:32 +03:00
|
|
|
|
|
|
|
if (mScrollCornerBox) {
|
2011-10-17 18:59:28 +04:00
|
|
|
LayoutAndInvalidate(aState, mScrollCornerBox, r, false);
|
2011-01-17 17:35:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hasResizer) {
|
|
|
|
// if a resizer is present, get its size. Assume a default size of 15 pixels.
|
|
|
|
nsSize resizerSize;
|
|
|
|
nscoord defaultSize = nsPresContext::CSSPixelsToAppUnits(15);
|
|
|
|
resizerSize.width =
|
|
|
|
mVScrollbarBox ? mVScrollbarBox->GetMinSize(aState).width : defaultSize;
|
|
|
|
if (resizerSize.width > r.width) {
|
|
|
|
r.width = resizerSize.width;
|
|
|
|
if (aContentArea.x == mScrollPort.x && !scrollbarOnLeft)
|
|
|
|
r.x = aContentArea.XMost() - r.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
resizerSize.height =
|
|
|
|
mHScrollbarBox ? mHScrollbarBox->GetMinSize(aState).height : defaultSize;
|
|
|
|
if (resizerSize.height > r.height) {
|
|
|
|
r.height = resizerSize.height;
|
|
|
|
if (aContentArea.y == mScrollPort.y)
|
|
|
|
r.y = aContentArea.YMost() - r.height;
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
LayoutAndInvalidate(aState, mResizerBox, r, false);
|
2011-01-17 17:35:32 +03:00
|
|
|
}
|
|
|
|
else if (mResizerBox) {
|
|
|
|
// otherwise lay out the resizer with an empty rectangle
|
2011-10-17 18:59:28 +04:00
|
|
|
LayoutAndInvalidate(aState, mResizerBox, nsRect(), false);
|
2011-01-17 17:35:32 +03:00
|
|
|
}
|
2010-03-19 14:49:34 +03:00
|
|
|
}
|
|
|
|
|
2008-08-08 20:11:54 +04:00
|
|
|
nsPresContext* presContext = mScrolledFrame->PresContext();
|
2007-03-05 04:39:53 +03:00
|
|
|
if (mVScrollbarBox) {
|
|
|
|
NS_PRECONDITION(mVScrollbarBox->IsBoxFrame(), "Must be a box frame!");
|
2009-10-08 07:01:15 +04:00
|
|
|
nsRect vRect(mScrollPort);
|
|
|
|
vRect.width = aContentArea.width - mScrollPort.width;
|
2010-03-19 14:49:34 +03:00
|
|
|
vRect.x = scrollbarOnLeft ? aContentArea.x : mScrollPort.XMost();
|
2007-03-05 04:39:53 +03:00
|
|
|
nsMargin margin;
|
|
|
|
mVScrollbarBox->GetMargin(margin);
|
2010-04-03 02:25:40 +04:00
|
|
|
vRect.Deflate(margin);
|
2011-10-17 18:59:28 +04:00
|
|
|
AdjustScrollbarRectForResizer(mOuter, presContext, vRect, hasResizer, true);
|
2010-07-16 01:08:03 +04:00
|
|
|
LayoutAndInvalidate(aState, mVScrollbarBox, vRect, !mHasVerticalScrollbar);
|
2007-03-05 04:39:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mHScrollbarBox) {
|
|
|
|
NS_PRECONDITION(mHScrollbarBox->IsBoxFrame(), "Must be a box frame!");
|
2009-10-08 07:01:15 +04:00
|
|
|
nsRect hRect(mScrollPort);
|
|
|
|
hRect.height = aContentArea.height - mScrollPort.height;
|
2011-10-17 18:59:28 +04:00
|
|
|
hRect.y = true ? mScrollPort.YMost() : aContentArea.y;
|
2007-03-05 04:39:53 +03:00
|
|
|
nsMargin margin;
|
|
|
|
mHScrollbarBox->GetMargin(margin);
|
2010-04-03 02:25:40 +04:00
|
|
|
hRect.Deflate(margin);
|
2011-10-17 18:59:28 +04:00
|
|
|
AdjustScrollbarRectForResizer(mOuter, presContext, hRect, hasResizer, false);
|
2010-07-16 01:08:03 +04:00
|
|
|
LayoutAndInvalidate(aState, mHScrollbarBox, hRect, !mHasHorizontalScrollbar);
|
2007-03-05 04:39:53 +03:00
|
|
|
}
|
2006-03-15 19:55:19 +03:00
|
|
|
|
2001-04-17 05:45:38 +04:00
|
|
|
// may need to update fixed position children of the viewport,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// if the client area changed size because of an incremental
|
|
|
|
// reflow of a descendant. (If the outer frame is dirty, the fixed
|
|
|
|
// children will be re-laid out anyway)
|
2009-10-08 07:01:15 +04:00
|
|
|
if (aOldScrollArea.Size() != mScrollPort.Size() &&
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
!(mOuter->GetStateBits() & NS_FRAME_IS_DIRTY) &&
|
2005-06-16 06:57:23 +04:00
|
|
|
mIsRoot) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mMayHaveDirtyFixedChildren = true;
|
2001-04-17 05:45:38 +04:00
|
|
|
}
|
2007-03-05 04:39:53 +03:00
|
|
|
|
|
|
|
// post reflow callback to modify scrollbar attributes
|
2011-10-17 18:59:28 +04:00
|
|
|
mUpdateScrollbarAttributes = true;
|
2007-03-05 04:39:53 +03:00
|
|
|
if (!mPostedReflowCallback) {
|
|
|
|
aState.PresContext()->PresShell()->PostReflowCallback(this);
|
2011-10-17 18:59:28 +04:00
|
|
|
mPostedReflowCallback = true;
|
2007-03-05 04:39:53 +03:00
|
|
|
}
|
2001-04-17 05:45:38 +04:00
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2004-09-22 10:33:36 +04:00
|
|
|
void
|
2007-03-14 01:11:14 +03:00
|
|
|
nsGfxScrollFrameInner::SetScrollbarEnabled(nsIContent* aContent, nscoord aMaxPos)
|
2004-09-22 10:33:36 +04:00
|
|
|
{
|
2007-03-05 04:39:53 +03:00
|
|
|
if (aMaxPos) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, true);
|
2007-03-05 04:39:53 +03:00
|
|
|
} else {
|
2007-03-14 01:11:14 +03:00
|
|
|
aContent->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("true"), true);
|
2007-03-05 04:39:53 +03:00
|
|
|
}
|
2004-09-22 10:33:36 +04:00
|
|
|
}
|
|
|
|
|
2007-03-05 04:39:53 +03:00
|
|
|
void
|
2007-03-14 01:11:14 +03:00
|
|
|
nsGfxScrollFrameInner::SetCoordAttribute(nsIContent* aContent, nsIAtom* aAtom,
|
2007-03-05 04:39:53 +03:00
|
|
|
nscoord aSize)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
|
|
|
// convert to pixels
|
2007-02-07 10:46:44 +03:00
|
|
|
aSize = nsPresContext::AppUnitsToIntCSSPixels(aSize);
|
1999-08-20 02:16:23 +04:00
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
// only set the attribute if it changed.
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2006-03-22 10:10:31 +03:00
|
|
|
nsAutoString newValue;
|
|
|
|
newValue.AppendInt(aSize);
|
|
|
|
|
2007-03-14 01:11:14 +03:00
|
|
|
if (aContent->AttrValueIs(kNameSpaceID_None, aAtom, newValue, eCaseMatters))
|
2007-03-05 04:39:53 +03:00
|
|
|
return;
|
2006-03-22 10:10:31 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
aContent->SetAttr(kNameSpaceID_None, aAtom, newValue, true);
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2010-09-08 02:20:35 +04:00
|
|
|
static void
|
|
|
|
ReduceRadii(nscoord aXBorder, nscoord aYBorder,
|
|
|
|
nscoord& aXRadius, nscoord& aYRadius)
|
|
|
|
{
|
|
|
|
// In order to ensure that the inside edge of the border has no
|
|
|
|
// curvature, we need at least one of its radii to be zero.
|
|
|
|
if (aXRadius <= aXBorder || aYRadius <= aYBorder)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// For any corner where we reduce the radii, preserve the corner's shape.
|
|
|
|
double ratio = NS_MAX(double(aXBorder) / aXRadius,
|
|
|
|
double(aYBorder) / aYRadius);
|
|
|
|
aXRadius *= ratio;
|
|
|
|
aYRadius *= ratio;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implement an override for nsIFrame::GetBorderRadii to ensure that
|
|
|
|
* the clipping region for the border radius does not clip the scrollbars.
|
|
|
|
*
|
|
|
|
* In other words, we require that the border radius be reduced until the
|
|
|
|
* inner border radius at the inner edge of the border is 0 wherever we
|
|
|
|
* have scrollbars.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-09-08 02:20:35 +04:00
|
|
|
nsGfxScrollFrameInner::GetBorderRadii(nscoord aRadii[8]) const
|
|
|
|
{
|
|
|
|
if (!mOuter->nsContainerFrame::GetBorderRadii(aRadii))
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-09-08 02:20:35 +04:00
|
|
|
|
|
|
|
// Since we can use GetActualScrollbarSizes (rather than
|
|
|
|
// GetDesiredScrollbarSizes) since this doesn't affect reflow, we
|
|
|
|
// probably should.
|
|
|
|
nsMargin sb = GetActualScrollbarSizes();
|
|
|
|
nsMargin border = mOuter->GetUsedBorder();
|
|
|
|
|
|
|
|
if (sb.left > 0 || sb.top > 0) {
|
|
|
|
ReduceRadii(border.left, border.top,
|
|
|
|
aRadii[NS_CORNER_TOP_LEFT_X],
|
|
|
|
aRadii[NS_CORNER_TOP_LEFT_Y]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sb.top > 0 || sb.right > 0) {
|
|
|
|
ReduceRadii(border.right, border.top,
|
|
|
|
aRadii[NS_CORNER_TOP_RIGHT_X],
|
|
|
|
aRadii[NS_CORNER_TOP_RIGHT_Y]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sb.right > 0 || sb.bottom > 0) {
|
|
|
|
ReduceRadii(border.right, border.bottom,
|
|
|
|
aRadii[NS_CORNER_BOTTOM_RIGHT_X],
|
|
|
|
aRadii[NS_CORNER_BOTTOM_RIGHT_Y]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sb.bottom > 0 || sb.left > 0) {
|
|
|
|
ReduceRadii(border.left, border.bottom,
|
|
|
|
aRadii[NS_CORNER_BOTTOM_LEFT_X],
|
|
|
|
aRadii[NS_CORNER_BOTTOM_LEFT_Y]);
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-09-08 02:20:35 +04:00
|
|
|
}
|
|
|
|
|
2006-03-15 19:55:19 +03:00
|
|
|
nsRect
|
2009-10-08 07:01:15 +04:00
|
|
|
nsGfxScrollFrameInner::GetScrolledRect() const
|
2000-07-08 02:24:06 +04:00
|
|
|
{
|
2009-10-08 07:01:15 +04:00
|
|
|
nsRect result =
|
2010-10-07 08:25:47 +04:00
|
|
|
GetScrolledRectInternal(mScrolledFrame->GetScrollableOverflowRect(),
|
2009-10-08 07:01:15 +04:00
|
|
|
mScrollPort.Size());
|
|
|
|
|
|
|
|
NS_ASSERTION(result.width >= mScrollPort.width,
|
|
|
|
"Scrolled rect smaller than scrollport?");
|
|
|
|
NS_ASSERTION(result.height >= mScrollPort.height,
|
|
|
|
"Scrolled rect smaller than scrollport?");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect
|
|
|
|
nsGfxScrollFrameInner::GetScrolledRectInternal(const nsRect& aScrolledFrameOverflowArea,
|
|
|
|
const nsSize& aScrollPortSize) const
|
|
|
|
{
|
|
|
|
nscoord x1 = aScrolledFrameOverflowArea.x,
|
|
|
|
x2 = aScrolledFrameOverflowArea.XMost(),
|
|
|
|
y1 = aScrolledFrameOverflowArea.y,
|
|
|
|
y2 = aScrolledFrameOverflowArea.YMost();
|
2006-03-15 19:55:19 +03:00
|
|
|
if (y1 < 0)
|
|
|
|
y1 = 0;
|
2011-02-07 10:59:20 +03:00
|
|
|
if (IsLTR()) {
|
2006-03-15 19:55:19 +03:00
|
|
|
if (x1 < 0)
|
|
|
|
x1 = 0;
|
|
|
|
} else {
|
|
|
|
if (x2 > aScrollPortSize.width)
|
|
|
|
x2 = aScrollPortSize.width;
|
2008-07-14 01:50:35 +04:00
|
|
|
// When the scrolled frame chooses a size larger than its available width (because
|
|
|
|
// its padding alone is larger than the available width), we need to keep the
|
|
|
|
// start-edge of the scroll frame anchored to the start-edge of the scrollport.
|
|
|
|
// When the scrolled frame is RTL, this means moving it in our left-based
|
|
|
|
// coordinate system, so we need to compensate for its extra width here by
|
|
|
|
// effectively repositioning the frame.
|
2009-09-16 19:01:36 +04:00
|
|
|
nscoord extraWidth = NS_MAX(0, mScrolledFrame->GetSize().width - aScrollPortSize.width);
|
2008-07-14 01:50:35 +04:00
|
|
|
x2 += extraWidth;
|
2006-03-15 19:55:19 +03:00
|
|
|
}
|
|
|
|
return nsRect(x1, y1, x2 - x1, y2 - y1);
|
2004-09-29 06:08:51 +04:00
|
|
|
}
|
2000-07-08 02:24:06 +04:00
|
|
|
|
2004-09-29 06:08:51 +04:00
|
|
|
nsMargin
|
2010-01-13 15:57:00 +03:00
|
|
|
nsGfxScrollFrameInner::GetActualScrollbarSizes() const
|
|
|
|
{
|
2010-04-03 02:25:40 +04:00
|
|
|
nsRect r = mOuter->GetPaddingRect() - mOuter->GetPosition();
|
|
|
|
|
|
|
|
return nsMargin(mScrollPort.x - r.x, mScrollPort.y - r.y,
|
|
|
|
r.XMost() - mScrollPort.XMost(),
|
|
|
|
r.YMost() - mScrollPort.YMost());
|
2000-07-08 02:24:06 +04:00
|
|
|
}
|
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsGfxScrollFrameInner::SetScrollbarVisibility(nsIBox* aScrollbar, bool aVisible)
|
2000-05-15 08:12:31 +04:00
|
|
|
{
|
2011-07-11 18:05:09 +04:00
|
|
|
nsScrollbarFrame* scrollbar = do_QueryFrame(aScrollbar);
|
2000-07-14 03:00:59 +04:00
|
|
|
if (scrollbar) {
|
|
|
|
// See if we have a mediator.
|
2006-12-07 22:53:41 +03:00
|
|
|
nsIScrollbarMediator* mediator = scrollbar->GetScrollbarMediator();
|
2000-07-14 03:00:59 +04:00
|
|
|
if (mediator) {
|
|
|
|
// Inform the mediator of the visibility change.
|
2009-01-12 22:20:59 +03:00
|
|
|
mediator->VisibilityChanged(aVisible);
|
2000-07-14 03:00:59 +04:00
|
|
|
}
|
|
|
|
}
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
PRInt32
|
2006-03-23 06:45:41 +03:00
|
|
|
nsGfxScrollFrameInner::GetCoordAttribute(nsIBox* aBox, nsIAtom* atom, PRInt32 defaultValue)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2006-03-15 19:55:19 +03:00
|
|
|
if (aBox) {
|
2004-09-28 22:37:50 +04:00
|
|
|
nsIContent* content = aBox->GetContent();
|
1999-08-20 02:16:23 +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())
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
|
|
|
PRInt32 error;
|
1999-08-20 02:16:23 +04:00
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
// convert it to an integer
|
2007-02-07 10:46:44 +03:00
|
|
|
defaultValue = nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
2006-03-15 19:55:19 +03:00
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2006-03-15 19:55:19 +03:00
|
|
|
return defaultValue;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
2004-09-13 06:10:29 +04:00
|
|
|
|
2005-01-28 01:52:53 +03:00
|
|
|
nsPresState*
|
2005-12-07 02:56:17 +03:00
|
|
|
nsGfxScrollFrameInner::SaveState(nsIStatefulFrame::SpecialStateID aStateID)
|
2004-09-13 06:10:29 +04:00
|
|
|
{
|
2005-12-07 02:56:17 +03:00
|
|
|
// Don't save "normal" state for the root scrollframe; that's
|
|
|
|
// handled via the eDocumentScrollState state id
|
|
|
|
if (mIsRoot && aStateID == nsIStatefulFrame::eNoID) {
|
|
|
|
return nsnull;
|
|
|
|
}
|
2006-12-07 22:53:41 +03:00
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIScrollbarMediator* mediator = do_QueryFrame(GetScrolledFrame());
|
2004-09-13 06:10:29 +04:00
|
|
|
if (mediator) {
|
2006-12-19 23:11:27 +03:00
|
|
|
// child handles its own scroll state, so don't bother saving state here
|
2004-09-13 06:10:29 +04:00
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2011-03-28 10:37:57 +04:00
|
|
|
nsPoint scrollPos = GetLogicalScrollPosition();
|
|
|
|
// Don't save scroll position if we are at (0,0)
|
|
|
|
if (scrollPos == nsPoint(0,0)) {
|
|
|
|
return nsnull;
|
|
|
|
}
|
2004-09-13 06:10:29 +04:00
|
|
|
|
2008-12-12 22:25:22 +03:00
|
|
|
nsPresState* state = new nsPresState();
|
2011-04-29 09:02:16 +04:00
|
|
|
|
2009-10-08 07:01:15 +04:00
|
|
|
state->SetScrollState(scrollPos);
|
2004-09-13 06:10:29 +04:00
|
|
|
|
2008-12-12 22:25:22 +03:00
|
|
|
return state;
|
2004-09-13 06:10:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-01-28 01:52:53 +03:00
|
|
|
nsGfxScrollFrameInner::RestoreState(nsPresState* aState)
|
2004-09-13 06:10:29 +04:00
|
|
|
{
|
2009-10-08 07:01:15 +04:00
|
|
|
mRestorePos = aState->GetScrollState();
|
2006-11-06 19:08:20 +03:00
|
|
|
mLastPos.x = -1;
|
|
|
|
mLastPos.y = -1;
|
2011-10-17 18:59:28 +04:00
|
|
|
mDidHistoryRestore = true;
|
2011-02-07 10:59:20 +03:00
|
|
|
mLastPos = mScrolledFrame ? GetLogicalScrollPosition() : nsPoint(0,0);
|
2004-09-13 06:10:29 +04:00
|
|
|
}
|
2009-10-25 10:04:18 +03:00
|
|
|
|
|
|
|
void
|
2010-01-12 00:45:19 +03:00
|
|
|
nsGfxScrollFrameInner::PostScrolledAreaEvent()
|
2009-10-25 10:04:18 +03:00
|
|
|
{
|
2010-01-12 00:45:19 +03:00
|
|
|
if (mScrolledAreaEvent.IsPending()) {
|
2009-10-25 10:04:18 +03:00
|
|
|
return;
|
|
|
|
}
|
2010-01-12 00:45:19 +03:00
|
|
|
mScrolledAreaEvent = new ScrolledAreaEvent(this);
|
2011-03-24 20:41:23 +03:00
|
|
|
nsContentUtils::AddScriptRunner(mScrolledAreaEvent.get());
|
2009-10-25 10:04:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ScrolledArea change event dispatch
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-01-12 00:45:19 +03:00
|
|
|
nsGfxScrollFrameInner::ScrolledAreaEvent::Run()
|
2009-10-25 10:04:18 +03:00
|
|
|
{
|
2010-01-12 00:45:19 +03:00
|
|
|
if (mInner) {
|
|
|
|
mInner->FireScrolledAreaEvent();
|
|
|
|
}
|
2009-10-25 10:04:18 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-01-12 00:45:19 +03:00
|
|
|
nsGfxScrollFrameInner::FireScrolledAreaEvent()
|
2009-10-25 10:04:18 +03:00
|
|
|
{
|
2010-01-12 00:45:19 +03:00
|
|
|
mScrolledAreaEvent.Forget();
|
2009-10-25 10:04:18 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
nsScrollAreaEvent event(true, NS_SCROLLEDAREACHANGED, nsnull);
|
2009-10-25 10:04:18 +03:00
|
|
|
nsPresContext *prescontext = mOuter->PresContext();
|
|
|
|
nsIContent* content = mOuter->GetContent();
|
|
|
|
|
2010-10-07 08:25:47 +04:00
|
|
|
event.mArea = mScrolledFrame->GetScrollableOverflowRectRelativeToParent();
|
2009-10-25 10:04:18 +03:00
|
|
|
|
|
|
|
nsIDocument *doc = content->GetCurrentDoc();
|
|
|
|
if (doc) {
|
|
|
|
nsEventDispatcher::Dispatch(doc, prescontext, &event, nsnull);
|
|
|
|
}
|
|
|
|
}
|