From ba11ee5becb5de0a3496346f241708465db174f0 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Wed, 5 May 2004 02:49:57 +0000 Subject: [PATCH] Bug 232540. List controls should not scroll an item into view if it is only outside the list in the horizontal direction. git-svn-id: svn://10.0.0.236/trunk@155968 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/forms/nsListControlFrame.cpp | 8 +++++--- mozilla/layout/html/forms/src/nsListControlFrame.cpp | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index 83773008cc0..3f83e7ad1aa 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -3092,10 +3092,12 @@ nsListControlFrame::ScrollToFrame(nsIContent* aOptElement) } fRect.y += optRect.y; - // see if the selected frame is inside the scrolled area - if (!rect.Contains(fRect)) { + // See if the selected frame (fRect) is inside the scrolled + // area (rect). Check only the vertical dimension. Don't + // scroll just because there's horizontal overflow. + if (!(rect.y <= fRect.y && fRect.YMost() <= rect.YMost())) { // figure out which direction we are going - if (fRect.y+fRect.height >= rect.y+rect.height) { + if (fRect.YMost() > rect.YMost()) { y = fRect.y-(rect.height-fRect.height); } else { y = fRect.y; diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index 83773008cc0..3f83e7ad1aa 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -3092,10 +3092,12 @@ nsListControlFrame::ScrollToFrame(nsIContent* aOptElement) } fRect.y += optRect.y; - // see if the selected frame is inside the scrolled area - if (!rect.Contains(fRect)) { + // See if the selected frame (fRect) is inside the scrolled + // area (rect). Check only the vertical dimension. Don't + // scroll just because there's horizontal overflow. + if (!(rect.y <= fRect.y && fRect.YMost() <= rect.YMost())) { // figure out which direction we are going - if (fRect.y+fRect.height >= rect.y+rect.height) { + if (fRect.YMost() > rect.YMost()) { y = fRect.y-(rect.height-fRect.height); } else { y = fRect.y;