Bug 720126 - Update scroll API to use ScrollAxis parameters (where and when). r=roc

This commit is contained in:
Adam Dane [:hobophobe] 2012-03-19 21:09:50 -05:00
parent 8d0a189c1c
commit 3c986b3780
17 changed files with 388 additions and 289 deletions

View File

@ -277,9 +277,9 @@ nsAccessNode::ScrollTo(PRUint32 aScrollType)
if (!content)
return;
PRInt16 vPercent, hPercent;
nsCoreUtils::ConvertScrollTypeToPercents(aScrollType, &vPercent, &hPercent);
shell->ScrollContentIntoView(content, vPercent, hPercent,
nsIPresShell::ScrollAxis vertical, horizontal;
nsCoreUtils::ConvertScrollTypeToPercents(aScrollType, &vertical, &horizontal);
shell->ScrollContentIntoView(content, vertical, horizontal,
nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
}

View File

@ -2230,8 +2230,9 @@ nsAccessible::DispatchClickEvent(nsIContent *aContent, PRUint32 aActionIndex)
nsIPresShell* presShell = mDoc->PresShell();
// Scroll into view.
presShell->ScrollContentIntoView(aContent, NS_PRESSHELL_SCROLL_ANYWHERE,
NS_PRESSHELL_SCROLL_ANYWHERE,
presShell->ScrollContentIntoView(aContent,
nsIPresShell::ScrollAxis(),
nsIPresShell::ScrollAxis(),
nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
// Fire mouse down and mouse up events.

View File

@ -296,18 +296,19 @@ nsCoreUtils::ScrollSubstringTo(nsIFrame *aFrame,
nsIDOMNode *aEndNode, PRInt32 aEndIndex,
PRUint32 aScrollType)
{
PRInt16 vPercent, hPercent;
ConvertScrollTypeToPercents(aScrollType, &vPercent, &hPercent);
nsIPresShell::ScrollAxis vertical, horizontal;
ConvertScrollTypeToPercents(aScrollType, &vertical, &horizontal);
return ScrollSubstringTo(aFrame, aStartNode, aStartIndex, aEndNode, aEndIndex,
vPercent, hPercent);
vertical, horizontal);
}
nsresult
nsCoreUtils::ScrollSubstringTo(nsIFrame *aFrame,
nsIDOMNode *aStartNode, PRInt32 aStartIndex,
nsIDOMNode *aEndNode, PRInt32 aEndIndex,
PRInt16 aVPercent, PRInt16 aHPercent)
nsIPresShell::ScrollAxis aVertical,
nsIPresShell::ScrollAxis aHorizontal)
{
if (!aFrame || !aStartNode || !aEndNode)
return NS_ERROR_FAILURE;
@ -330,8 +331,9 @@ nsCoreUtils::ScrollSubstringTo(nsIFrame *aFrame,
selection->RemoveAllRanges();
selection->AddRange(scrollToRange);
privSel->ScrollIntoView(nsISelectionController::SELECTION_ANCHOR_REGION,
true, aVPercent, aHPercent);
privSel->ScrollIntoViewInternal(
nsISelectionController::SELECTION_ANCHOR_REGION,
true, aVertical, aHorizontal);
selection->CollapseToStart();
@ -365,39 +367,57 @@ nsCoreUtils::ScrollFrameToPoint(nsIFrame *aScrollableFrame,
void
nsCoreUtils::ConvertScrollTypeToPercents(PRUint32 aScrollType,
PRInt16 *aVPercent,
PRInt16 *aHPercent)
nsIPresShell::ScrollAxis *aVertical,
nsIPresShell::ScrollAxis *aHorizontal)
{
PRInt16 whereY, whereX;
nsIPresShell::WhenToScroll whenY, whenX;
switch (aScrollType)
{
case nsIAccessibleScrollType::SCROLL_TYPE_TOP_LEFT:
*aVPercent = NS_PRESSHELL_SCROLL_TOP;
*aHPercent = NS_PRESSHELL_SCROLL_LEFT;
whereY = nsIPresShell::SCROLL_TOP;
whenY = nsIPresShell::SCROLL_ALWAYS;
whereX = nsIPresShell::SCROLL_LEFT;
whenX = nsIPresShell::SCROLL_ALWAYS;
break;
case nsIAccessibleScrollType::SCROLL_TYPE_BOTTOM_RIGHT:
*aVPercent = NS_PRESSHELL_SCROLL_BOTTOM;
*aHPercent = NS_PRESSHELL_SCROLL_RIGHT;
whereY = nsIPresShell::SCROLL_BOTTOM;
whenY = nsIPresShell::SCROLL_ALWAYS;
whereX = nsIPresShell::SCROLL_RIGHT;
whenX = nsIPresShell::SCROLL_ALWAYS;
break;
case nsIAccessibleScrollType::SCROLL_TYPE_TOP_EDGE:
*aVPercent = NS_PRESSHELL_SCROLL_TOP;
*aHPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
whereY = nsIPresShell::SCROLL_TOP;
whenY = nsIPresShell::SCROLL_ALWAYS;
whereX = nsIPresShell::SCROLL_MINIMUM;
whenX = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
break;
case nsIAccessibleScrollType::SCROLL_TYPE_BOTTOM_EDGE:
*aVPercent = NS_PRESSHELL_SCROLL_BOTTOM;
*aHPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
whereY = nsIPresShell::SCROLL_BOTTOM;
whenY = nsIPresShell::SCROLL_ALWAYS;
whereX = nsIPresShell::SCROLL_MINIMUM;
whenX = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
break;
case nsIAccessibleScrollType::SCROLL_TYPE_LEFT_EDGE:
*aVPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
*aHPercent = NS_PRESSHELL_SCROLL_LEFT;
whereY = nsIPresShell::SCROLL_MINIMUM;
whenY = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
whereX = nsIPresShell::SCROLL_LEFT;
whenX = nsIPresShell::SCROLL_ALWAYS;
break;
case nsIAccessibleScrollType::SCROLL_TYPE_RIGHT_EDGE:
*aVPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
*aHPercent = NS_PRESSHELL_SCROLL_RIGHT;
whereY = nsIPresShell::SCROLL_MINIMUM;
whenY = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
whereX = nsIPresShell::SCROLL_RIGHT;
whenX = nsIPresShell::SCROLL_ALWAYS;
break;
default:
*aVPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
*aHPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
whereY = nsIPresShell::SCROLL_MINIMUM;
whenY = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
whereX = nsIPresShell::SCROLL_MINIMUM;
whenX = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
}
*aVertical = nsIPresShell::ScrollAxis(whereY, whenY);
*aHorizontal = nsIPresShell::ScrollAxis(whereX, whenX);
}
nsIntPoint

View File

@ -181,13 +181,14 @@ public:
* @param aStartOffset an offset inside the start node
* @param aEndNode end node of a range
* @param aEndOffset an offset inside the end node
* @param aVPercent how to align vertically, specified in percents
* @param aHPercent how to align horizontally, specified in percents
* @param aVertical how to align vertically, specified in percents, and when.
* @param aHorizontal how to align horizontally, specified in percents, and when.
*/
static nsresult ScrollSubstringTo(nsIFrame *aFrame,
nsIDOMNode *aStartNode, PRInt32 aStartIndex,
nsIDOMNode *aEndNode, PRInt32 aEndIndex,
PRInt16 aVPercent, PRInt16 aHPercent);
nsIPresShell::ScrollAxis aVertical,
nsIPresShell::ScrollAxis aHorizontal);
/**
* Scrolls the given frame to the point, used for implememntation of
@ -202,11 +203,11 @@ public:
/**
* Converts scroll type constant defined in nsIAccessibleScrollType to
* vertical and horizontal percents.
* vertical and horizontal parameters.
*/
static void ConvertScrollTypeToPercents(PRUint32 aScrollType,
PRInt16 *aVPercent,
PRInt16 *aHPercent);
nsIPresShell::ScrollAxis *aVertical,
nsIPresShell::ScrollAxis *aHorizontal);
/**
* Returns coordinates relative screen for the top level window.

View File

@ -52,6 +52,7 @@ class nsIFrame;
class nsIPresShell;
struct nsTextRangeStyle;
struct nsPoint;
struct ScrollAxis;
#include "nsIFrame.h"
#include "nsTArray.h"
%}
@ -63,8 +64,9 @@ struct nsPoint;
[ref] native constTextRangeStyleRef(const nsTextRangeStyle);
[ref] native nsPointRef(nsPoint);
native nsDirection(nsDirection);
native ScrollAxis(nsIPresShell::ScrollAxis);
[scriptable, uuid(1820a940-6203-4e27-bc94-fa81131722a4)]
[scriptable, uuid(0ced91b9-3e77-4191-943f-95bcde5e2d14)]
interface nsISelectionPrivate : nsISelection
{
const short ENDOFPRECEDINGLINE=0;
@ -174,29 +176,31 @@ interface nsISelectionPrivate : nsISelection
* @param aIsSynchronous - when true, scrolls the selection into view
* before returning. If false, posts a request which
* is processed at some point after the method returns.
* @param aVPercent - how to align the frame vertically. A value of 0
* means the frame's upper edge is aligned with the top edge
* of the visible area. A value of 100 means the frame's
* bottom edge is aligned with the bottom edge of
* the visible area. For values in between, the point
* "aVPercent" down the frame is placed at the point
* "aVPercent" down the visible area. A value of 50 centers
* the frame vertically. A value of -1 means move
* the frame the minimum amount necessary in order for
* the entire frame to be visible vertically (if possible).
* @param aHPercent - how to align the frame horizontally. A value of 0
* means the frame's left edge is aligned with the left
* edge of the visible area. A value of 100 means the
* frame's right edge is aligned with the right edge of
* the visible area. For values in between, the point
* "aHPercent" across the frame is placed at the point
* "aHPercent" across the visible area. A value of 50
* centers the frame horizontally . A value of -1 means
* move the frame the minimum amount necessary in order
* for the entire frame to be visible horizontally
* (if possible).
* @param aVPercent - how to align the frame vertically.
* @param aHPercent - how to align the frame horizontally.
*/
void scrollIntoView(in short aRegion, in boolean aIsSynchronous,
in short aVPercent, in short aHPercent);
in PRInt16 aVPercent,
in PRInt16 aHPercent);
/**
* Scrolls a region of the selection, so that it is visible in
* the scrolled view.
*
* @param aRegion - the region inside the selection to scroll into view
* (see selection region constants defined in
* nsISelectionController).
* @param aIsSynchronous - when true, scrolls the selection into view
* before returning. If false, posts a request which
* is processed at some point after the method returns.
* @param aVertical - how to align the frame vertically and when.
* See nsIPresShell.h:ScrollAxis for details.
* @param aHorizontal - how to align the frame horizontally and when.
* See nsIPresShell.h:ScrollAxis for details.
*/
[noscript] void scrollIntoViewInternal(in short aRegion,
in boolean aIsSynchronous,
in ScrollAxis aVertical,
in ScrollAxis aHorizontal);
};

View File

@ -1109,8 +1109,9 @@ nsContentEventHandler::OnSelectionEvent(nsSelectionEvent* aEvent)
selPrivate->EndBatchChanges();
NS_ENSURE_SUCCESS(rv, rv);
selPrivate->ScrollIntoView(
nsISelectionController::SELECTION_FOCUS_REGION, false, -1, -1);
selPrivate->ScrollIntoViewInternal(
nsISelectionController::SELECTION_FOCUS_REGION,
false, nsIPresShell::ScrollAxis(), nsIPresShell::ScrollAxis());
aEvent->mSucceeded = true;
return NS_OK;
}

View File

@ -983,11 +983,14 @@ nsGenericHTMLElement::ScrollIntoView(bool aTop, PRUint8 optional_argc)
aTop = true;
}
PRIntn vpercent = aTop ? NS_PRESSHELL_SCROLL_TOP :
NS_PRESSHELL_SCROLL_BOTTOM;
PRInt16 vpercent = aTop ? nsIPresShell::SCROLL_TOP :
nsIPresShell::SCROLL_BOTTOM;
presShell->ScrollContentIntoView(this, vpercent,
NS_PRESSHELL_SCROLL_ANYWHERE,
presShell->ScrollContentIntoView(this,
nsIPresShell::ScrollAxis(
vpercent,
nsIPresShell::SCROLL_ALWAYS),
nsIPresShell::ScrollAxis(),
nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
return NS_OK;

View File

@ -1960,8 +1960,12 @@ nsFocusManager::ScrollIntoView(nsIPresShell* aPresShell,
// if the noscroll flag isn't set, scroll the newly focused element into view
if (!(aFlags & FLAG_NOSCROLL))
aPresShell->ScrollContentIntoView(aContent,
NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,
NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,
nsIPresShell::ScrollAxis(
nsIPresShell::SCROLL_MINIMUM,
nsIPresShell::SCROLL_IF_NOT_VISIBLE),
nsIPresShell::ScrollAxis(
nsIPresShell::SCROLL_MINIMUM,
nsIPresShell::SCROLL_IF_NOT_VISIBLE),
nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
}

View File

@ -2705,24 +2705,27 @@ DocumentViewerImpl::GetPrintable(bool *aPrintable)
NS_IMETHODIMP DocumentViewerImpl::ScrollToNode(nsIDOMNode* aNode)
{
NS_ENSURE_ARG(aNode);
NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
nsCOMPtr<nsIPresShell> presShell;
NS_ENSURE_SUCCESS(GetPresShell(getter_AddRefs(presShell)), NS_ERROR_FAILURE);
NS_ENSURE_ARG(aNode);
NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
nsCOMPtr<nsIPresShell> presShell;
NS_ENSURE_SUCCESS(GetPresShell(getter_AddRefs(presShell)), NS_ERROR_FAILURE);
// Get the nsIContent interface, because that's what we need to
// get the primary frame
// Get the nsIContent interface, because that's what we need to
// get the primary frame
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
// Tell the PresShell to scroll to the primary frame of the content.
NS_ENSURE_SUCCESS(presShell->ScrollContentIntoView(content,
NS_PRESSHELL_SCROLL_TOP,
NS_PRESSHELL_SCROLL_ANYWHERE,
nsIPresShell::SCROLL_OVERFLOW_HIDDEN),
NS_ERROR_FAILURE);
return NS_OK;
// Tell the PresShell to scroll to the primary frame of the content.
NS_ENSURE_SUCCESS(
presShell->ScrollContentIntoView(content,
nsIPresShell::ScrollAxis(
nsIPresShell::SCROLL_TOP,
nsIPresShell::SCROLL_ALWAYS),
nsIPresShell::ScrollAxis(),
nsIPresShell::SCROLL_OVERFLOW_HIDDEN),
NS_ERROR_FAILURE);
return NS_OK;
}
void

View File

@ -147,22 +147,13 @@ typedef struct CapturingContentInfo {
{ 0x4dc4db09, 0x03d4, 0x4427, \
{ 0xbe, 0xfb, 0xc9, 0x29, 0xac, 0x5c, 0x62, 0xab } }
// Constants for ScrollContentIntoView() function
#define NS_PRESSHELL_SCROLL_TOP 0
#define NS_PRESSHELL_SCROLL_BOTTOM 100
#define NS_PRESSHELL_SCROLL_LEFT 0
#define NS_PRESSHELL_SCROLL_RIGHT 100
#define NS_PRESSHELL_SCROLL_CENTER 50
#define NS_PRESSHELL_SCROLL_ANYWHERE -1
#define NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE -2
// debug VerifyReflow flags
#define VERIFY_REFLOW_ON 0x01
#define VERIFY_REFLOW_NOISY 0x02
#define VERIFY_REFLOW_ALL 0x04
#define VERIFY_REFLOW_DUMP_COMMANDS 0x08
#define VERIFY_REFLOW_NOISY_RC 0x10
#define VERIFY_REFLOW_REALLY_NOISY_RC 0x20
#define VERIFY_REFLOW_ON 0x01
#define VERIFY_REFLOW_NOISY 0x02
#define VERIFY_REFLOW_ALL 0x04
#define VERIFY_REFLOW_DUMP_COMMANDS 0x08
#define VERIFY_REFLOW_NOISY_RC 0x10
#define VERIFY_REFLOW_REALLY_NOISY_RC 0x20
#define VERIFY_REFLOW_DURING_RESIZE_REFLOW 0x40
#undef NOISY_INTERRUPTIBLE_REFLOW
@ -533,34 +524,68 @@ public:
*/
virtual NS_HIDDEN_(nsresult) ScrollToAnchor() = 0;
enum {
SCROLL_TOP = 0,
SCROLL_BOTTOM = 100,
SCROLL_LEFT = 0,
SCROLL_RIGHT = 100,
SCROLL_CENTER = 50,
SCROLL_MINIMUM = -1
};
enum WhenToScroll {
SCROLL_ALWAYS,
SCROLL_IF_NOT_VISIBLE,
SCROLL_IF_NOT_FULLY_VISIBLE
};
typedef struct ScrollAxis {
PRInt16 mWhereToScroll;
WhenToScroll mWhenToScroll;
/**
* @param aWhere: Either a percentage or a special value.
* nsIPresShell defines:
* * (Default) SCROLL_MINIMUM = -1: The visible area is
* scrolled to show the entire frame. If the frame is too
* large, the top and left edges are given precedence.
* * SCROLL_TOP = 0: The frame's upper edge is aligned with the
* top edge of the visible area.
* * SCROLL_BOTTOM = 100: The frame's bottom edge is aligned
* with the bottom edge of the visible area.
* * SCROLL_LEFT = 0: The frame's left edge is aligned with the
* left edge of the visible area.
* * SCROLL_RIGHT = 100: The frame's right edge is aligned with
* the right edge of the visible area.
* * SCROLL_CENTER = 50: The frame is centered along the axis
* the ScrollAxis is used for.
*
* Other values are treated as a percentage, and the point
* "percent" down the frame is placed at the point "percent"
* down the visible area.
* @param aWhen:
* * (Default) SCROLL_IF_NOT_FULLY_VISIBLE: Move the frame only
* if it is not fully visible (including if it's not visible
* at all). Note that in this case if the frame is too large to
* fit in view, it will only be scrolled if more of it can fit
* than is already in view.
* * SCROLL_IF_NOT_VISIBLE: Move the frame only if none of it
* is visible.
* * SCROLL_ALWAYS: Move the frame regardless of its current
* visibility.
*/
ScrollAxis(PRInt16 aWhere = SCROLL_MINIMUM,
WhenToScroll aWhen = SCROLL_IF_NOT_FULLY_VISIBLE) :
mWhereToScroll(aWhere), mWhenToScroll(aWhen) {}
} ScrollAxis;
/**
* Scrolls the view of the document so that the primary frame of the content
* is displayed in the window. Layout is flushed before scrolling.
*
* @param aContent The content object of which primary frame should be
* scrolled into view.
* @param aVPercent How to align the frame vertically. A value of 0
* (NS_PRESSHELL_SCROLL_TOP) means the frame's upper edge is
* aligned with the top edge of the visible area. A value of
* 100 (NS_PRESSHELL_SCROLL_BOTTOM) means the frame's bottom
* edge is aligned with the bottom edge of the visible area.
* For values in between, the point "aVPercent" down the frame
* is placed at the point "aVPercent" down the visible area. A
* value of 50 (NS_PRESSHELL_SCROLL_CENTER) centers the frame
* vertically. A value of NS_PRESSHELL_SCROLL_ANYWHERE means move
* the frame the minimum amount necessary in order for the entire
* frame to be visible vertically (if possible)
* @param aHPercent How to align the frame horizontally. A value of 0
* (NS_PRESSHELL_SCROLL_LEFT) means the frame's left edge is
* aligned with the left edge of the visible area. A value of
* 100 (NS_PRESSHELL_SCROLL_RIGHT) means the frame's right
* edge is aligned with the right edge of the visible area.
* For values in between, the point "aVPercent" across the frame
* is placed at the point "aVPercent" across the visible area.
* A value of 50 (NS_PRESSHELL_SCROLL_CENTER) centers the frame
* horizontally . A value of NS_PRESSHELL_SCROLL_ANYWHERE means move
* the frame the minimum amount necessary in order for the entire
* frame to be visible horizontally (if possible)
* @param aVertical How to align the frame vertically and when to do so.
* This is a ScrollAxis of Where and When.
* @param aHorizontal How to align the frame horizontally and when to do so.
* This is a ScrollAxis of Where and When.
* @param aFlags If SCROLL_FIRST_ANCESTOR_ONLY is set, only the nearest
* scrollable ancestor is scrolled, otherwise all
* scrollable ancestors may be scrolled if necessary.
@ -573,8 +598,8 @@ public:
* contain this document in a iframe or the like.
*/
virtual NS_HIDDEN_(nsresult) ScrollContentIntoView(nsIContent* aContent,
PRIntn aVPercent,
PRIntn aHPercent,
ScrollAxis aVertical,
ScrollAxis aHorizontal,
PRUint32 aFlags) = 0;
enum {
@ -587,8 +612,8 @@ public:
* is visible, if possible. Layout is not flushed before scrolling.
*
* @param aRect relative to aFrame
* @param aVPercent see ScrollContentIntoView
* @param aHPercent see ScrollContentIntoView
* @param aVertical see ScrollContentIntoView and ScrollAxis
* @param aHorizontal see ScrollContentIntoView and ScrollAxis
* @param aFlags if SCROLL_FIRST_ANCESTOR_ONLY is set, only the
* nearest scrollable ancestor is scrolled, otherwise all
* scrollable ancestors may be scrolled if necessary
@ -602,10 +627,10 @@ public:
* @return true if any scrolling happened, false if no scrolling happened
*/
virtual bool ScrollFrameRectIntoView(nsIFrame* aFrame,
const nsRect& aRect,
PRIntn aVPercent,
PRIntn aHPercent,
PRUint32 aFlags) = 0;
const nsRect& aRect,
ScrollAxis aVertical,
ScrollAxis aHorizontal,
PRUint32 aFlags) = 0;
/**
* Determine if a rectangle specified in the frame's coordinate system

View File

@ -3032,8 +3032,9 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll)
if (content) {
if (aScroll) {
rv = ScrollContentIntoView(content, NS_PRESSHELL_SCROLL_TOP,
NS_PRESSHELL_SCROLL_ANYWHERE,
rv = ScrollContentIntoView(content,
ScrollAxis(SCROLL_TOP, SCROLL_ALWAYS),
ScrollAxis(),
ANCHOR_SCROLL_FLAGS);
NS_ENSURE_SUCCESS(rv, rv);
@ -3122,8 +3123,9 @@ PresShell::ScrollToAnchor()
mLastAnchorScrollPositionY != rootScroll->GetScrollPosition().y)
return NS_OK;
nsresult rv = ScrollContentIntoView(mLastAnchorScrolledTo, NS_PRESSHELL_SCROLL_TOP,
NS_PRESSHELL_SCROLL_ANYWHERE,
nsresult rv = ScrollContentIntoView(mLastAnchorScrolledTo,
ScrollAxis(SCROLL_TOP, SCROLL_ALWAYS),
ScrollAxis(),
ANCHOR_SCROLL_FLAGS);
mLastAnchorScrolledTo = nsnull;
return rv;
@ -3211,6 +3213,58 @@ AccumulateFrameBounds(nsIFrame* aContainerFrame,
}
}
static bool
ComputeNeedToScroll(nsIPresShell::WhenToScroll aWhenToScroll,
nscoord aLineSize,
nscoord aRectMin,
nscoord aRectMax,
nscoord aViewMin,
nscoord aViewMax) {
// See how the rect should be positioned vertically
if (nsIPresShell::SCROLL_ALWAYS == aWhenToScroll) {
// The caller wants the frame as visible as possible
return true;
} else if (nsIPresShell::SCROLL_IF_NOT_VISIBLE == aWhenToScroll) {
// Scroll only if no part of the frame is visible in this view
return aRectMax - aLineSize <= aViewMin ||
aRectMin + aLineSize >= aViewMax;
} else if (nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE == aWhenToScroll) {
// Scroll only if part of the frame is hidden and more can fit in view
return !(aRectMin >= aViewMin && aRectMax <= aViewMax) &&
NS_MIN(aViewMax, aRectMax) - NS_MAX(aRectMin, aViewMin) < aViewMax - aViewMin;
}
return false;
}
static nscoord
ComputeWhereToScroll(PRInt16 aWhereToScroll,
nscoord aOriginalCoord,
nscoord aRectMin,
nscoord aRectMax,
nscoord aViewMin,
nscoord aViewMax) {
nscoord resultCoord = aOriginalCoord;
if (nsIPresShell::SCROLL_MINIMUM == aWhereToScroll) {
if (aRectMin < aViewMin) {
// Scroll up so the frame's top edge is visible
resultCoord = aRectMin;
} else if (aRectMax > aViewMax) {
// Scroll down so the frame's bottom edge is visible. Make sure the
// frame's top edge is still visible
resultCoord = aOriginalCoord + aRectMax - aViewMax;
if (resultCoord > aRectMin) {
resultCoord = aRectMin;
}
}
} else {
nscoord frameAlignCoord =
NSToCoordRound(aRectMin + (aRectMax - aRectMin) * (aWhereToScroll / 100.0f));
resultCoord = NSToCoordRound(frameAlignCoord - (aViewMax - aViewMin) * (
aWhereToScroll / 100.0f));
}
return resultCoord;
}
/**
* This function takes a scrollable frame, a rect in the coordinate system
* of the scrolled frame, and a desired percentage-based scroll
@ -3219,11 +3273,11 @@ AccumulateFrameBounds(nsIFrame* aContainerFrame,
*
* This needs to work even if aRect has a width or height of zero.
*/
static void ScrollToShowRect(nsIScrollableFrame* aScrollFrame,
const nsRect& aRect,
PRIntn aVPercent,
PRIntn aHPercent,
PRUint32 aFlags)
static void ScrollToShowRect(nsIScrollableFrame* aScrollFrame,
const nsRect& aRect,
nsIPresShell::ScrollAxis aVertical,
nsIPresShell::ScrollAxis aHorizontal,
PRUint32 aFlags)
{
nsPoint scrollPt = aScrollFrame->GetScrollPosition();
nsRect visibleRect(scrollPt, aScrollFrame->GetScrollPortRect().Size());
@ -3232,83 +3286,37 @@ static void ScrollToShowRect(nsIScrollableFrame* aScrollFrame,
if ((aFlags & nsIPresShell::SCROLL_OVERFLOW_HIDDEN) ||
ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN) {
// See how the rect should be positioned vertically
if (NS_PRESSHELL_SCROLL_ANYWHERE == aVPercent ||
(NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE == aVPercent &&
aRect.height < lineSize.height)) {
// The caller doesn't care where the frame is positioned vertically,
// so long as it's fully visible
if (aRect.y < visibleRect.y) {
// Scroll up so the frame's top edge is visible
scrollPt.y = aRect.y;
} else if (aRect.YMost() > visibleRect.YMost()) {
// Scroll down so the frame's bottom edge is visible. Make sure the
// frame's top edge is still visible
scrollPt.y += aRect.YMost() - visibleRect.YMost();
if (scrollPt.y > aRect.y) {
scrollPt.y = aRect.y;
}
}
} else if (NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE == aVPercent) {
// Scroll only if no part of the frame is visible in this view
if (aRect.YMost() - lineSize.height < visibleRect.y) {
// Scroll up so the frame's top edge is visible
scrollPt.y = aRect.y;
} else if (aRect.y + lineSize.height > visibleRect.YMost()) {
// Scroll down so the frame's bottom edge is visible. Make sure the
// frame's top edge is still visible
scrollPt.y += aRect.YMost() - visibleRect.YMost();
if (scrollPt.y > aRect.y) {
scrollPt.y = aRect.y;
}
}
} else {
// Align the frame edge according to the specified percentage
nscoord frameAlignY =
NSToCoordRound(aRect.y + aRect.height * (aVPercent / 100.0f));
scrollPt.y =
NSToCoordRound(frameAlignY - visibleRect.height * (aVPercent / 100.0f));
if (ComputeNeedToScroll(aVertical.mWhenToScroll,
lineSize.height,
aRect.y,
aRect.YMost(),
visibleRect.y,
visibleRect.YMost())) {
scrollPt.y = ComputeWhereToScroll(aVertical.mWhereToScroll,
scrollPt.y,
aRect.y,
aRect.YMost(),
visibleRect.y,
visibleRect.YMost());
}
}
if ((aFlags & nsIPresShell::SCROLL_OVERFLOW_HIDDEN) ||
ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) {
// See how the frame should be positioned horizontally
if (NS_PRESSHELL_SCROLL_ANYWHERE == aHPercent ||
(NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE == aHPercent &&
aRect.width < lineSize.width)) {
// The caller doesn't care where the frame is positioned horizontally,
// so long as it's fully visible
if (aRect.x < visibleRect.x) {
// Scroll left so the frame's left edge is visible
scrollPt.x = aRect.x;
} else if (aRect.XMost() > visibleRect.XMost()) {
// Scroll right so the frame's right edge is visible. Make sure the
// frame's left edge is still visible
scrollPt.x += aRect.XMost() - visibleRect.XMost();
if (scrollPt.x > aRect.x) {
scrollPt.x = aRect.x;
}
}
} else if (NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE == aHPercent) {
// Scroll only if no part of the frame is visible in this view
if (aRect.XMost() - lineSize.width < visibleRect.x) {
// Scroll left so the frame's left edge is visible
scrollPt.x = aRect.x;
} else if (aRect.x + lineSize.width > visibleRect.XMost()) {
// Scroll right so the frame's right edge is visible. Make sure the
// frame's left edge is still visible
scrollPt.x += aRect.XMost() - visibleRect.XMost();
if (scrollPt.x > aRect.x) {
scrollPt.x = aRect.x;
}
}
} else {
// Align the frame edge according to the specified percentage
nscoord frameAlignX =
NSToCoordRound(aRect.x + (aRect.width) * (aHPercent / 100.0f));
scrollPt.x =
NSToCoordRound(frameAlignX - visibleRect.width * (aHPercent / 100.0f));
if (ComputeNeedToScroll(aHorizontal.mWhenToScroll,
lineSize.width,
aRect.x,
aRect.XMost(),
visibleRect.x,
visibleRect.XMost())) {
scrollPt.x = ComputeWhereToScroll(aHorizontal.mWhereToScroll,
scrollPt.x,
aRect.x,
aRect.XMost(),
visibleRect.x,
visibleRect.XMost());
}
}
@ -3316,10 +3324,10 @@ static void ScrollToShowRect(nsIScrollableFrame* aScrollFrame,
}
nsresult
PresShell::ScrollContentIntoView(nsIContent* aContent,
PRIntn aVPercent,
PRIntn aHPercent,
PRUint32 aFlags)
PresShell::ScrollContentIntoView(nsIContent* aContent,
nsIPresShell::ScrollAxis aVertical,
nsIPresShell::ScrollAxis aHorizontal,
PRUint32 aFlags)
{
nsCOMPtr<nsIContent> content = aContent; // Keep content alive while flushing.
NS_ENSURE_TRUE(content, NS_ERROR_NULL_POINTER);
@ -3329,8 +3337,8 @@ PresShell::ScrollContentIntoView(nsIContent* aContent,
NS_ASSERTION(mDidInitialReflow, "should have done initial reflow by now");
mContentToScrollTo = aContent;
mContentScrollVPosition = aVPercent;
mContentScrollHPosition = aHPercent;
mContentScrollVAxis = aVertical;
mContentScrollHAxis = aHorizontal;
mContentToScrollToFlags = aFlags;
// Flush layout and attempt to scroll in the process.
@ -3346,16 +3354,16 @@ PresShell::ScrollContentIntoView(nsIContent* aContent,
// than a single best-effort scroll followed by one final scroll on the first
// completed reflow.
if (mContentToScrollTo) {
DoScrollContentIntoView(content, aVPercent, aHPercent, aFlags);
DoScrollContentIntoView(content, aVertical, aHorizontal, aFlags);
}
return NS_OK;
}
void
PresShell::DoScrollContentIntoView(nsIContent* aContent,
PRIntn aVPercent,
PRIntn aHPercent,
PRUint32 aFlags)
PresShell::DoScrollContentIntoView(nsIContent* aContent,
nsIPresShell::ScrollAxis aVertical,
nsIPresShell::ScrollAxis aHorizontal,
PRUint32 aFlags)
{
NS_ASSERTION(mDidInitialReflow, "should have done initial reflow by now");
@ -3391,7 +3399,7 @@ PresShell::DoScrollContentIntoView(nsIContent* aContent,
// even if that assumption was false.)
nsRect frameBounds;
bool haveRect = false;
bool useWholeLineHeightForInlines = aVPercent != NS_PRESSHELL_SCROLL_ANYWHERE;
bool useWholeLineHeightForInlines = aVertical.mWhenToScroll != nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
// Reuse the same line iterator across calls to AccumulateFrameBounds. We set
// it every time we detect a new block (stored in prevBlock).
nsIFrame* prevBlock = nsnull;
@ -3404,16 +3412,16 @@ PresShell::DoScrollContentIntoView(nsIContent* aContent,
frameBounds, haveRect, prevBlock, lines, curLine);
} while ((frame = frame->GetNextContinuation()));
ScrollFrameRectIntoView(container, frameBounds, aVPercent, aHPercent,
ScrollFrameRectIntoView(container, frameBounds, aVertical, aHorizontal,
aFlags);
}
bool
PresShell::ScrollFrameRectIntoView(nsIFrame* aFrame,
const nsRect& aRect,
PRIntn aVPercent,
PRIntn aHPercent,
PRUint32 aFlags)
PresShell::ScrollFrameRectIntoView(nsIFrame* aFrame,
const nsRect& aRect,
nsIPresShell::ScrollAxis aVertical,
nsIPresShell::ScrollAxis aHorizontal,
PRUint32 aFlags)
{
bool didScroll = false;
// This function needs to work even if rect has a width or height of 0.
@ -3426,7 +3434,7 @@ PresShell::ScrollFrameRectIntoView(nsIFrame* aFrame,
if (sf) {
nsPoint oldPosition = sf->GetScrollPosition();
ScrollToShowRect(sf, rect - sf->GetScrolledFrame()->GetPosition(),
aVPercent, aHPercent, aFlags);
aVertical, aHorizontal, aFlags);
nsPoint newPosition = sf->GetScrollPosition();
// If the scroll position increased, that means our content moved up,
// so our rect's offset should decrease
@ -3999,8 +4007,9 @@ PresShell::FlushPendingNotifications(mozFlushType aType)
mViewManager->FlushDelayedResize(true);
if (ProcessReflowCommands(aType < Flush_Layout) && mContentToScrollTo) {
// We didn't get interrupted. Go ahead and scroll to our content
DoScrollContentIntoView(mContentToScrollTo, mContentScrollVPosition,
mContentScrollHPosition,
DoScrollContentIntoView(mContentToScrollTo,
mContentScrollVAxis,
mContentScrollHAxis,
mContentToScrollToFlags);
mContentToScrollTo = nsnull;
}
@ -6878,9 +6887,10 @@ PresShell::PrepareToUseCaretPosition(nsIWidget* aEventWidget, nsIntPoint& aTarge
// problem. The only difference in the result is that if your cursor is in
// an edit box below the current view, you'll get the edit box aligned with
// the top of the window. This is arguably better behavior anyway.
rv = ScrollContentIntoView(content, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,
NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,
SCROLL_OVERFLOW_HIDDEN);
rv = ScrollContentIntoView(content,
ScrollAxis(),
ScrollAxis(),
SCROLL_OVERFLOW_HIDDEN);
NS_ENSURE_SUCCESS(rv, false);
frame = content->GetPrimaryFrame();
NS_WARN_IF_FALSE(frame, "No frame for focused content?");
@ -6942,9 +6952,10 @@ PresShell::GetCurrentItemAndPositionForElement(nsIDOMElement *aCurrentEl,
nsIWidget *aRootWidget)
{
nsCOMPtr<nsIContent> focusedContent(do_QueryInterface(aCurrentEl));
ScrollContentIntoView(focusedContent, NS_PRESSHELL_SCROLL_ANYWHERE,
NS_PRESSHELL_SCROLL_ANYWHERE,
SCROLL_OVERFLOW_HIDDEN);
ScrollContentIntoView(focusedContent,
ScrollAxis(),
ScrollAxis(),
SCROLL_OVERFLOW_HIDDEN);
nsPresContext* presContext = GetPresContext();

View File

@ -248,14 +248,14 @@ public:
virtual NS_HIDDEN_(nsresult) ScrollToAnchor();
virtual NS_HIDDEN_(nsresult) ScrollContentIntoView(nsIContent* aContent,
PRIntn aVPercent,
PRIntn aHPercent,
ScrollAxis aVertical,
ScrollAxis aHorizontal,
PRUint32 aFlags);
virtual bool ScrollFrameRectIntoView(nsIFrame* aFrame,
const nsRect& aRect,
PRIntn aVPercent,
PRIntn aHPercent,
PRUint32 aFlags);
const nsRect& aRect,
ScrollAxis aVertical,
ScrollAxis aHorizontal,
PRUint32 aFlags);
virtual nsRectVisibility GetRectVisibility(nsIFrame *aFrame,
const nsRect &aRect,
nscoord aMinTwips) const;
@ -493,8 +493,8 @@ protected:
// Helper for ScrollContentIntoView
void DoScrollContentIntoView(nsIContent* aContent,
PRIntn aVPercent,
PRIntn aHPercent,
ScrollAxis aVertical,
ScrollAxis aHorizontal,
PRUint32 aFlags);
friend struct AutoRenderingStateSaveRestore;
@ -672,8 +672,8 @@ protected:
// processing all our dirty roots. mContentScrollVPosition and
// mContentScrollHPosition are only used when it's non-null.
nsCOMPtr<nsIContent> mContentToScrollTo;
PRIntn mContentScrollVPosition;
PRIntn mContentScrollHPosition;
ScrollAxis mContentScrollVAxis;
ScrollAxis mContentScrollHAxis;
PRUint32 mContentToScrollToFlags;
class nsDelayedEvent

View File

@ -206,10 +206,11 @@ public:
// The 'position' is a zero-width rectangle.
nsIFrame* GetSelectionEndPointGeometry(SelectionRegion aRegion, nsRect *aRect);
nsresult PostScrollSelectionIntoViewEvent(SelectionRegion aRegion,
bool aFirstAncestorOnly,
PRInt16 aVPercent,
PRInt16 aHPercent);
nsresult PostScrollSelectionIntoViewEvent(
SelectionRegion aRegion,
bool aFirstAncestorOnly,
nsIPresShell::ScrollAxis aVertical,
nsIPresShell::ScrollAxis aHorizontal);
enum {
SCROLL_SYNCHRONOUS = 1<<1,
SCROLL_FIRST_ANCESTOR_ONLY = 1<<2,
@ -218,8 +219,10 @@ public:
// aDoFlush only matters if aIsSynchronous is true. If not, we'll just flush
// when the scroll event fires so we make sure to scroll to the right place.
nsresult ScrollIntoView(SelectionRegion aRegion,
PRInt16 aVPercent = NS_PRESSHELL_SCROLL_ANYWHERE,
PRInt16 aHPercent = NS_PRESSHELL_SCROLL_ANYWHERE,
nsIPresShell::ScrollAxis aVertical =
nsIPresShell::ScrollAxis(),
nsIPresShell::ScrollAxis aHorizontal =
nsIPresShell::ScrollAxis(),
PRInt32 aFlags = 0);
nsresult SubtractRange(RangeData* aRange, nsRange* aSubtract,
nsTArray<RangeData>* aOutput);
@ -286,23 +289,23 @@ private:
NS_DECL_NSIRUNNABLE
ScrollSelectionIntoViewEvent(nsTypedSelection *aTypedSelection,
SelectionRegion aRegion,
PRInt16 aVScroll,
PRInt16 aHScroll,
nsIPresShell::ScrollAxis aVertical,
nsIPresShell::ScrollAxis aHorizontal,
bool aFirstAncestorOnly)
: mTypedSelection(aTypedSelection),
mRegion(aRegion),
mVerticalScroll(aVScroll),
mHorizontalScroll(aHScroll),
mVerticalScroll(aVertical),
mHorizontalScroll(aHorizontal),
mFirstAncestorOnly(aFirstAncestorOnly) {
NS_ASSERTION(aTypedSelection, "null parameter");
}
void Revoke() { mTypedSelection = nsnull; }
private:
nsTypedSelection *mTypedSelection;
SelectionRegion mRegion;
PRInt16 mVerticalScroll;
PRInt16 mHorizontalScroll;
bool mFirstAncestorOnly;
SelectionRegion mRegion;
nsIPresShell::ScrollAxis mVerticalScroll;
nsIPresShell::ScrollAxis mHorizontalScroll;
bool mFirstAncestorOnly;
};
void setAnchorFocusRange(PRInt32 aIndex); // pass in index into mRanges;
@ -1970,7 +1973,7 @@ nsFrameSelection::ScrollSelectionIntoView(SelectionType aType,
if (!mDomSelections[index])
return NS_ERROR_NULL_POINTER;
PRInt16 verticalScroll = PRInt16(NS_PRESSHELL_SCROLL_ANYWHERE);
nsIPresShell::ScrollAxis verticalScroll = nsIPresShell::ScrollAxis();
PRInt32 flags = nsTypedSelection::SCROLL_DO_FLUSH;
if (aFlags & nsISelectionController::SCROLL_SYNCHRONOUS) {
flags |= nsTypedSelection::SCROLL_SYNCHRONOUS;
@ -1978,14 +1981,15 @@ nsFrameSelection::ScrollSelectionIntoView(SelectionType aType,
flags |= nsTypedSelection::SCROLL_FIRST_ANCESTOR_ONLY;
}
if (aFlags & nsISelectionController::SCROLL_CENTER_VERTICALLY) {
verticalScroll = PRInt16(NS_PRESSHELL_SCROLL_CENTER);
verticalScroll = nsIPresShell::ScrollAxis(
nsIPresShell::SCROLL_CENTER, nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE);
}
// After ScrollSelectionIntoView(), the pending notifications might be
// flushed and PresShell/PresContext/Frames may be dead. See bug 418470.
return mDomSelections[index]->ScrollIntoView(aRegion,
verticalScroll,
PRInt16(NS_PRESSHELL_SCROLL_ANYWHERE),
nsIPresShell::ScrollAxis(),
flags);
}
@ -4667,10 +4671,12 @@ nsTypedSelection::DoAutoScroll(nsIFrame *aFrame, nsPoint& aPoint)
// about to do will change the coordinates of aFrame.
nsPoint globalPoint = aPoint + aFrame->GetOffsetToCrossDoc(rootmostFrame);
bool didScroll = presContext->PresShell()->
ScrollFrameRectIntoView(aFrame, nsRect(aPoint, nsSize(1,1)),
NS_PRESSHELL_SCROLL_ANYWHERE,
NS_PRESSHELL_SCROLL_ANYWHERE, 0);
bool didScroll = presContext->PresShell()->ScrollFrameRectIntoView(
aFrame,
nsRect(aPoint, nsSize(1,1)),
nsIPresShell::ScrollAxis(),
nsIPresShell::ScrollAxis(),
0);
//
// Start the AutoScroll timer if necessary.
@ -5540,10 +5546,11 @@ nsTypedSelection::ScrollSelectionIntoViewEvent::Run()
}
nsresult
nsTypedSelection::PostScrollSelectionIntoViewEvent(SelectionRegion aRegion,
bool aFirstAncestorOnly,
PRInt16 aVPercent,
PRInt16 aHPercent)
nsTypedSelection::PostScrollSelectionIntoViewEvent(
SelectionRegion aRegion,
bool aFirstAncestorOnly,
nsIPresShell::ScrollAxis aVertical,
nsIPresShell::ScrollAxis aHorizontal)
{
// If we've already posted an event, revoke it and place a new one at the
// end of the queue to make sure that any new pending reflow events are
@ -5552,7 +5559,7 @@ nsTypedSelection::PostScrollSelectionIntoViewEvent(SelectionRegion aRegion,
mScrollEvent.Revoke();
nsRefPtr<ScrollSelectionIntoViewEvent> ev =
new ScrollSelectionIntoViewEvent(this, aRegion, aVPercent, aHPercent,
new ScrollSelectionIntoViewEvent(this, aRegion, aVertical, aHorizontal,
aFirstAncestorOnly);
nsresult rv = NS_DispatchToCurrentThread(ev);
NS_ENSURE_SUCCESS(rv, rv);
@ -5562,16 +5569,31 @@ nsTypedSelection::PostScrollSelectionIntoViewEvent(SelectionRegion aRegion,
}
NS_IMETHODIMP
nsTypedSelection::ScrollIntoView(SelectionRegion aRegion, bool aIsSynchronous,
PRInt16 aVPercent, PRInt16 aHPercent)
nsTypedSelection::ScrollIntoView(SelectionRegion aRegion,
bool aIsSynchronous,
PRInt16 aVPercent,
PRInt16 aHPercent)
{
return ScrollIntoView(aRegion, aVPercent, aHPercent,
return ScrollIntoViewInternal(aRegion,
aIsSynchronous,
nsIPresShell::ScrollAxis(aVPercent),
nsIPresShell::ScrollAxis(aHPercent));
}
NS_IMETHODIMP
nsTypedSelection::ScrollIntoViewInternal(SelectionRegion aRegion,
bool aIsSynchronous,
nsIPresShell::ScrollAxis aVertical,
nsIPresShell::ScrollAxis aHorizontal)
{
return ScrollIntoView(aRegion, aVertical, aHorizontal,
aIsSynchronous ? nsTypedSelection::SCROLL_SYNCHRONOUS : 0);
}
nsresult
nsTypedSelection::ScrollIntoView(SelectionRegion aRegion,
PRInt16 aVPercent, PRInt16 aHPercent,
nsIPresShell::ScrollAxis aVertical,
nsIPresShell::ScrollAxis aHorizontal,
PRInt32 aFlags)
{
nsresult result;
@ -5584,7 +5606,7 @@ nsTypedSelection::ScrollIntoView(SelectionRegion aRegion,
if (!(aFlags & nsTypedSelection::SCROLL_SYNCHRONOUS))
return PostScrollSelectionIntoViewEvent(aRegion,
!!(aFlags & nsTypedSelection::SCROLL_FIRST_ANCESTOR_ONLY),
aVPercent, aHPercent);
aVertical, aHorizontal);
//
// Shut the caret off before scrolling to avoid
@ -5622,7 +5644,7 @@ nsTypedSelection::ScrollIntoView(SelectionRegion aRegion,
if (!frame)
return NS_ERROR_FAILURE;
presShell->ScrollFrameRectIntoView(frame, rect, aVPercent, aHPercent,
presShell->ScrollFrameRectIntoView(frame, rect, aVertical, aHorizontal,
(aFlags & nsTypedSelection::SCROLL_FIRST_ANCESTOR_ONLY) ? nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY: 0);
return NS_OK;
}

View File

@ -195,8 +195,8 @@ inFlasher::ScrollElementIntoView(nsIDOMElement *aElement)
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
presShell->ScrollContentIntoView(content,
NS_PRESSHELL_SCROLL_ANYWHERE /* VPercent */,
NS_PRESSHELL_SCROLL_ANYWHERE /* HPercent */,
nsIPresShell::ScrollAxis(),
nsIPresShell::ScrollAxis(),
nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
return NS_OK;

View File

@ -1480,13 +1480,13 @@ nsIScrollableFrame* nsMenuPopupFrame::GetScrollFrame(nsIFrame* aStart)
void nsMenuPopupFrame::EnsureMenuItemIsVisible(nsMenuFrame* aMenuItem)
{
if (aMenuItem) {
aMenuItem->PresContext()->PresShell()->
ScrollFrameRectIntoView(aMenuItem,
nsRect(nsPoint(0,0), aMenuItem->GetRect().Size()),
NS_PRESSHELL_SCROLL_ANYWHERE,
NS_PRESSHELL_SCROLL_ANYWHERE,
nsIPresShell::SCROLL_OVERFLOW_HIDDEN |
nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY);
aMenuItem->PresContext()->PresShell()->ScrollFrameRectIntoView(
aMenuItem,
nsRect(nsPoint(0,0), aMenuItem->GetRect().Size()),
nsIPresShell::ScrollAxis(),
nsIPresShell::ScrollAxis(),
nsIPresShell::SCROLL_OVERFLOW_HIDDEN |
nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY);
}
}

View File

@ -263,8 +263,12 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollToElement(nsIDOMElement *child)
nsCOMPtr<nsIContent> content = do_QueryInterface(child);
shell->ScrollContentIntoView(content,
NS_PRESSHELL_SCROLL_TOP,
NS_PRESSHELL_SCROLL_LEFT,
nsIPresShell::ScrollAxis(
nsIPresShell::SCROLL_TOP,
nsIPresShell::SCROLL_ALWAYS),
nsIPresShell::ScrollAxis(
nsIPresShell::SCROLL_LEFT,
nsIPresShell::SCROLL_ALWAYS),
nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY |
nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
return NS_OK;
@ -317,8 +321,8 @@ NS_IMETHODIMP nsScrollBoxObject::EnsureElementIsVisible(nsIDOMElement *child)
nsCOMPtr<nsIContent> content = do_QueryInterface(child);
shell->ScrollContentIntoView(content,
NS_PRESSHELL_SCROLL_ANYWHERE,
NS_PRESSHELL_SCROLL_ANYWHERE,
nsIPresShell::ScrollAxis(),
nsIPresShell::ScrollAxis(),
nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY |
nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
return NS_OK;

View File

@ -335,8 +335,8 @@ nsFormFillController::SetPopupOpen(bool aPopupOpen)
docShell->GetPresShell(getter_AddRefs(presShell));
NS_ENSURE_STATE(presShell);
presShell->ScrollContentIntoView(content,
NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,
NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,
nsIPresShell::ScrollAxis(),
nsIPresShell::ScrollAxis(),
nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
// mFocusedPopup can be destroyed after ScrollContentIntoView, see bug 420089
if (mFocusedPopup)