Bug 684266 - Suppress ellipsing when scrolling further isn't possible in that direction. r=roc a=blizzard
authorMats Palmgren <matspal@gmail.com>
Fri, 14 Oct 2011 00:11:42 +0200
changeset 79092 0b682734b597c4a0dd89bc0ff90bc4e4abf7ebbf
parent 79091 b8a8b530e833789890fb7303c35c55056296f7dd
child 79093 218c4fca33964597538d6d0e6ff5c8e73f15e004
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, blizzard
bugs684266
milestone9.0a2
Bug 684266 - Suppress ellipsing when scrolling further isn't possible in that direction. r=roc a=blizzard
layout/generic/TextOverflow.cpp
--- a/layout/generic/TextOverflow.cpp
+++ b/layout/generic/TextOverflow.cpp
@@ -275,18 +275,18 @@ TextOverflow::WillProcessLines(nsDisplay
   if (scroll) {
     textOverflow->mCanHaveHorizontalScrollbar =
       scroll->GetScrollbarStyles().mHorizontal != NS_STYLE_OVERFLOW_HIDDEN;
     textOverflow->mContentArea.MoveBy(scroll->GetScrollPosition());
   }
   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.
 
   return textOverflow.forget();
 }
 
 void
 TextOverflow::DidProcessLines()
@@ -400,16 +400,29 @@ TextOverflow::AnalyzeMarkerEdges(nsIFram
 void
 TextOverflow::ExamineLineFrames(nsLineBox*      aLine,
                                 FrameHashtable* aFramesToHide,
                                 AlignmentEdges* aAlignmentEdges)
 {
   // 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
   // outward to avoid triggering a text-overflow marker for such overflow.
   nsRect contentArea = mContentArea;
   const nscoord scrollAdjust = mCanHaveHorizontalScrollbar ?
     mBlock->PresContext()->AppUnitsPerDevPixel() : 0;
   InflateLeft(&contentArea, suppressLeft, scrollAdjust);