From c80a49e8ed3ec8fd7a86e5ac824f76e18ee7bf97 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Wed, 12 Oct 2011 18:20:46 +0200 Subject: [PATCH] Bug 684266 - Suppress ellipsing when scrolling further isn't possible in that direction. r=roc --- layout/generic/TextOverflow.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index fa660cfd4695..2e230010a845 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -280,8 +280,8 @@ TextOverflow::WillProcessLines(nsDisplayListBuilder* aBuilder, PRUint8 direction = aBlockFrame->GetStyleVisibility()->mDirection; textOverflow->mBlockIsRTL = direction == NS_STYLE_DIRECTION_RTL; const nsStyleTextReset* style = aBlockFrame->GetStyleTextReset(); - textOverflow->mLeft.Init(*style->mTextOverflow.GetLeft(direction)); - textOverflow->mRight.Init(*style->mTextOverflow.GetRight(direction)); + textOverflow->mLeft.Init(style->mTextOverflow.GetLeft(direction)); + textOverflow->mRight.Init(style->mTextOverflow.GetRight(direction)); // The left/right marker string is setup in ExamineLineFrames when a line // has overflow on that side. @@ -405,6 +405,19 @@ TextOverflow::ExamineLineFrames(nsLineBox* aLine, // No ellipsing for 'clip' style. bool suppressLeft = mLeft.mStyle->mType == NS_STYLE_TEXT_OVERFLOW_CLIP; bool suppressRight = mRight.mStyle->mType == NS_STYLE_TEXT_OVERFLOW_CLIP; + if (mCanHaveHorizontalScrollbar) { + nsIScrollableFrame* scroll = nsLayoutUtils::GetScrollableFrameFor(mBlock); + nsPoint pos = scroll->GetScrollPosition(); + nsRect scrollRange = scroll->GetScrollRange(); + // No ellipsing when nothing to scroll to on that side (this includes + // overflow:auto that doesn't trigger a horizontal scrollbar). + if (pos.x <= scrollRange.x) { + suppressLeft = true; + } + if (pos.x >= scrollRange.XMost()) { + suppressRight = true; + } + } // Scrolling to the end position can leave some text still overflowing due to // pixel snapping behaviour in our scrolling code so we move the edges 1px