Bug 677582 - Implement CSS3 text-overflow: <left> <right> in layout. r=roc
authorMats Palmgren <matspal@gmail.com>
Sat, 20 Aug 2011 22:41:39 +0200
changeset 76918 0f6660f35a46c304de105d504453273354665b7e
parent 76917 f700f4ef73b9ea8d2480c87934bc825dea6a5395
child 76919 1e2e4aa817cd4d39767739ffa07c7c695f35ef5c
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
bugs677582
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 677582 - Implement CSS3 text-overflow: <left> <right> in layout. r=roc
layout/base/nsCaret.cpp
layout/generic/TextOverflow.cpp
layout/generic/TextOverflow.h
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -638,17 +638,18 @@ void nsCaret::InvalidateTextOverflowBloc
   // invalidate it.
   if (mLastContent) {
     nsIFrame* caretFrame = mLastContent->GetPrimaryFrame();
     if (caretFrame) {
       nsIFrame* block = nsLayoutUtils::GetAsBlock(caretFrame) ? caretFrame :
         nsLayoutUtils::FindNearestBlockAncestor(caretFrame);
       if (block) {
         const nsStyleTextReset* style = block->GetStyleTextReset();
-        if (style->mTextOverflow.mType != NS_STYLE_TEXT_OVERFLOW_CLIP) {
+        if (style->mTextOverflow.mLeft.mType != NS_STYLE_TEXT_OVERFLOW_CLIP ||
+            style->mTextOverflow.mRight.mType != NS_STYLE_TEXT_OVERFLOW_CLIP) {
           block->InvalidateOverflowRect();
         }
       }
     }
   }
 }
 
 //-----------------------------------------------------------------------------
--- 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());
   }
   textOverflow->mBlockIsRTL =
     aBlockFrame->GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
   const nsStyleTextReset* style = aBlockFrame->GetStyleTextReset();
-  textOverflow->mLeft.Init(style->mTextOverflow);
-  textOverflow->mRight.Init(style->mTextOverflow);
+  textOverflow->mLeft.Init(style->mTextOverflow.mLeft);
+  textOverflow->mRight.Init(style->mTextOverflow.mRight);
   // The left/right marker string is setup in ExamineLineFrames when a line
   // has overflow on that side.
 
   return textOverflow.forget();
 }
 
 void
 TextOverflow::DidProcessLines()
@@ -424,21 +424,21 @@ TextOverflow::ExamineLineFrames(nsLineBo
 
   PRUint32 pass = 0;
   bool guessLeft =
     mLeft.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP && leftOverflow;
   bool guessRight =
     mRight.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP && rightOverflow;
   do {
     // Setup marker strings as needed.
-    if (guessLeft || guessRight) {
+    if (guessLeft) {
       mLeft.SetupString(mBlock);
-      mRight.mMarkerString = mLeft.mMarkerString;
-      mRight.mWidth = mLeft.mWidth;
-      mRight.mInitialized = mLeft.mInitialized;
+    }
+    if (guessRight) {
+      mRight.SetupString(mBlock);
     }
     
     // If there is insufficient space for both markers then keep the one on the
     // end side per the block's 'direction'.
     nscoord rightMarkerWidth = mRight.mWidth;
     nscoord leftMarkerWidth = mLeft.mWidth;
     if (leftOverflow && rightOverflow &&
         leftMarkerWidth + rightMarkerWidth > contentArea.width) {
@@ -583,17 +583,18 @@ TextOverflow::PruneDisplayListContents(n
 
 /* static */ bool
 TextOverflow::CanHaveTextOverflow(nsDisplayListBuilder* aBuilder,
                                   nsIFrame*             aBlockFrame)
 {
   const nsStyleTextReset* style = aBlockFrame->GetStyleTextReset();
   // Nothing to do for text-overflow:clip or if 'overflow-x:visible'
   // or if we're just building items for event processing.
-  if ((style->mTextOverflow.mType == NS_STYLE_TEXT_OVERFLOW_CLIP) ||
+  if ((style->mTextOverflow.mLeft.mType == NS_STYLE_TEXT_OVERFLOW_CLIP &&
+       style->mTextOverflow.mRight.mType == NS_STYLE_TEXT_OVERFLOW_CLIP) ||
       IsHorizontalOverflowVisible(aBlockFrame) ||
       aBuilder->IsForEventDelivery()) {
     return false;
   }
 
   // Inhibit the markers if a descendant content owns the caret.
   nsRefPtr<nsCaret> caret = aBlockFrame->PresContext()->PresShell()->GetCaret();
   PRBool visible = PR_FALSE;
--- a/layout/generic/TextOverflow.h
+++ b/layout/generic/TextOverflow.h
@@ -183,17 +183,17 @@ class TextOverflow {
   nsDisplayListBuilder*  mBuilder;
   nsIFrame*              mBlock;
   nsDisplayList*         mMarkerList;
   bool                   mBlockIsRTL;
   bool                   mCanHaveHorizontalScrollbar;
 
   class Marker {
   public:
-    void Init(const nsStyleTextOverflow& aStyle) {
+    void Init(const nsStyleTextOverflowSide& aStyle) {
       mInitialized = false;
       mWidth = 0;
       mStyle = &aStyle;
     }
 
     /**
      * Setup the marker string and calculate its size, if not done already.
      */
@@ -206,17 +206,17 @@ class TextOverflow {
       mHasOverflow = false;
     }
 
     // The intrinsic width of the marker string.
     nscoord                        mWidth;
     // The marker text.
     nsString                       mMarkerString;
     // The style for this side.
-    const nsStyleTextOverflow*     mStyle;
+    const nsStyleTextOverflowSide* mStyle;
     // True if there is visible overflowing inline content on this side.
     bool                           mHasOverflow;
     // True if mMarkerString and mWidth have been setup from style.
     bool                           mInitialized;
   };
 
   Marker mLeft;  // the horizontal left marker
   Marker mRight; // the horizontal right marker