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 75607 0f6660f35a46c304de105d504453273354665b7e
parent 75606 f700f4ef73b9ea8d2480c87934bc825dea6a5395
child 75608 1e2e4aa817cd4d39767739ffa07c7c695f35ef5c
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersroc
bugs677582
milestone9.0a1
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