Bug 953438 - Change nsIFrame::HasTerminalNewline to HasSignificantTerminalNewline since it doesn't make sense to check for a newline that gets converted to regular whitespace. r=jfkthame
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 02 Jan 2014 16:22:12 -0500
changeset 178015 cdbbbb3a99b4ea1b2e1e54070272ca23715dbdb6
parent 178014 211e9db554c899060ecc3ce18db84e1811c54a08
child 178016 fe4eba8fc092cb71a4f438e37677ba460b5d61f5
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs953438
milestone29.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 953438 - Change nsIFrame::HasTerminalNewline to HasSignificantTerminalNewline since it doesn't make sense to check for a newline that gets converted to regular whitespace. r=jfkthame
layout/generic/nsBlockFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsIFrame.h
layout/generic/nsTextFrame.cpp
layout/generic/nsTextFrame.h
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -4774,18 +4774,17 @@ ShouldPutNextSiblingOnNewLine(nsIFrame* 
 {
   nsIAtom* type = aLastFrame->GetType();
   if (type == nsGkAtoms::brFrame) {
     return true;
   }
   // XXX the IS_DIRTY check is a wallpaper for bug 822910.
   if (type == nsGkAtoms::textFrame &&
       !(aLastFrame->GetStateBits() & NS_FRAME_IS_DIRTY)) {
-    return aLastFrame->HasTerminalNewline() &&
-      aLastFrame->StyleText()->NewlineIsSignificant();
+    return aLastFrame->HasSignificantTerminalNewline();
   }
   return false;
 }
 
 void
 nsBlockFrame::AddFrames(nsFrameList& aFrameList, nsIFrame* aPrevSibling)
 {
   // Clear our line cursor, since our lines may change.
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -5979,18 +5979,17 @@ FindBlockFrameOrBR(nsIFrame* aFrame, nsD
     NS_ASSERTION(result.mContent, "Unexpected orphan content");
     if (result.mContent)
       result.mOffset = result.mContent->IndexOf(content) + 
         (aDirection == eDirPrevious ? 1 : 0);
     return result;
   }
 
   // If this is a preformatted text frame, see if it ends with a newline
-  if (aFrame->HasTerminalNewline() &&
-      aFrame->StyleText()->NewlineIsSignificant()) {
+  if (aFrame->HasSignificantTerminalNewline()) {
     int32_t startOffset, endOffset;
     aFrame->GetOffsets(startOffset, endOffset);
     result.mContent = aFrame->GetContent();
     result.mOffset = endOffset - (aDirection == eDirPrevious ? 0 : 1);
     return result;
   }
 
   // Iterate over children and call ourselves recursively
@@ -6140,18 +6139,17 @@ nsIFrame::PeekOffset(nsPeekOffsetStruct*
       aPos->mResultContent = range.content;
       // Output offset is relative to content, not frame
       aPos->mContentOffset = offset < 0 ? range.end : range.start + offset;
       // If we're dealing with a text frame and moving backward positions us at
       // the end of that line, decrease the offset by one to make sure that
       // we're placed before the linefeed character on the previous line.
       if (offset < 0 && jumpedLine &&
           aPos->mDirection == eDirPrevious &&
-          current->StyleText()->NewlineIsSignificant() &&
-          current->HasTerminalNewline()) {
+          current->HasSignificantTerminalNewline()) {
         --aPos->mContentOffset;
       }
       
       break;
     }
     case eSelectWordNoSpace:
       // eSelectWordNoSpace means that we should not be eating any whitespace when
       // moving to the adjacent word.  This means that we should set aPos->
@@ -6213,18 +6211,17 @@ nsIFrame::PeekOffset(nsPeekOffsetStruct*
           // We can't jump lines if we're looking for whitespace following
           // non-whitespace, and we already encountered non-whitespace.
           if (NS_FAILED(result) ||
               (jumpedLine && !wordSelectEatSpace && state.mSawBeforeType)) {
             done = true;
             // If we've crossed the line boundary, check to make sure that we
             // have not consumed a trailing newline as whitesapce if it's significant.
             if (jumpedLine && wordSelectEatSpace &&
-                current->HasTerminalNewline() &&
-                current->StyleText()->NewlineIsSignificant()) {
+                current->HasSignificantTerminalNewline()) {
               offsetAdjustment = -1;
             }
           } else {
             if (jumpedLine) {
               state.mContext.Truncate();
             }
             current = nextFrame;
             offset = nextFrameOffset;
@@ -6390,17 +6387,17 @@ nsIFrame::PeekOffset(nsPeekOffsetStruct*
       }
       if (!baseFrame)
         return NS_ERROR_FAILURE;
       FrameTarget targetFrame = DrillDownToSelectionFrame(baseFrame,
                                                           endOfLine, 0);
       FrameContentRange range = GetRangeForFrame(targetFrame.frame);
       aPos->mResultContent = range.content;
       aPos->mContentOffset = endOfLine ? range.end : range.start;
-      if (endOfLine && targetFrame.frame->HasTerminalNewline()) {
+      if (endOfLine && targetFrame.frame->HasSignificantTerminalNewline()) {
         // Do not position the caret after the terminating newline if we're
         // trying to move to the end of line (see bug 596506)
         --aPos->mContentOffset;
       }
       aPos->mResultFrame = targetFrame.frame;
       aPos->mAttachForward = (aPos->mContentOffset == range.start);
       if (!range.content)
         return NS_ERROR_FAILURE;
@@ -7360,21 +7357,21 @@ nsIFrame::IsFocusable(int32_t *aTabIndex
 
   if (aTabIndex) {
     *aTabIndex = tabIndex;
   }
   return isFocusable;
 }
 
 /**
- * @return true if this text frame ends with a newline character.  It
- * should return false if this is not a text frame.
+ * @return true if this text frame ends with a newline character which is
+ * treated as preformatted. It should return false if this is not a text frame.
  */
 bool
-nsIFrame::HasTerminalNewline() const
+nsIFrame::HasSignificantTerminalNewline() const
 {
   return false;
 }
 
 static uint8_t
 ConvertSVGDominantBaselineToVerticalAlign(uint8_t aDominantBaseline)
 {
   // Most of these are approximate mappings.
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -2823,17 +2823,17 @@ NS_PTR_TO_INT32(frame->Properties().Get(
 
   NS_IMETHOD DumpBox(FILE* out)=0;
 #endif
 
   /**
    * @return true if this text frame ends with a newline character.  It
    * should return false if this is not a text frame.
    */
-  virtual bool HasTerminalNewline() const;
+  virtual bool HasSignificantTerminalNewline() const;
 
   static bool AddCSSPrefSize(nsIFrame* aBox, nsSize& aSize, bool& aWidth, bool& aHeightSet);
   static bool AddCSSMinSize(nsBoxLayoutState& aState, nsIFrame* aBox,
                             nsSize& aSize, bool& aWidth, bool& aHeightSet);
   static bool AddCSSMaxSize(nsIFrame* aBox, nsSize& aSize, bool& aWidth, bool& aHeightSet);
   static bool AddCSSFlex(nsBoxLayoutState& aState, nsIFrame* aBox, nscoord& aFlex);
 
   // END OF BOX LAYOUT METHODS
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -6245,18 +6245,17 @@ nsTextFrame::GetCharacterOffsetAtFramePo
     // caused characters to move backwards. We can't really handle that
     // in the current frame system because frames can't have negative
     // intrinsic widths.
     selectedOffset =
         provider.GetStart().GetOriginalOffset() + provider.GetOriginalLength();
     // If we're at the end of a preformatted line which has a terminating
     // linefeed, we want to reduce the offset by one to make sure that the
     // selection is placed before the linefeed character.
-    if (StyleText()->NewlineIsSignificant() &&
-        HasTerminalNewline()) {
+    if (HasSignificantTerminalNewline()) {
       --selectedOffset;
     }
   }
 
   offsets.content = GetContent();
   offsets.offset = offsets.secondaryOffset = selectedOffset;
   offsets.associateWithNext = mContentOffset == offsets.offset;
   return offsets;
@@ -7473,18 +7472,17 @@ nsTextFrame::SetLength(int32_t aLength, 
   if (aLineLayout &&
       (end != f->mContentOffset || (f->GetStateBits() & NS_FRAME_IS_DIRTY))) {
     aLineLayout->SetDirtyNextLine();
   }
 
   if (end < f->mContentOffset) {
     // Our frame is shrinking. Give the text to our next in flow.
     if (aLineLayout &&
-        StyleText()->WhiteSpaceIsSignificant() &&
-        HasTerminalNewline() &&
+        HasSignificantTerminalNewline() &&
         GetParent()->GetType() != nsGkAtoms::letterFrame &&
         (aSetLengthFlags & ALLOW_FRAME_CREATION_AND_DESTRUCTION)) {
       // Whatever text we hand to our next-in-flow will end up in a frame all of
       // its own, since it ends in a forced linebreak.  Might as well just put
       // it in a separate frame now.  This is important to prevent text run
       // churn; if we did not do that, then we'd likely end up rebuilding
       // textruns for all our following continuations.
       // We skip this optimization when the parent is a first-letter frame
@@ -8557,19 +8555,19 @@ nsTextFrame::AdjustOffsetsForBidi(int32_
   }
 }
 
 /**
  * @return true if this text frame ends with a newline character.  It should return
  * false if it is not a text frame.
  */
 bool
-nsTextFrame::HasTerminalNewline() const
-{
-  return ::HasTerminalNewline(this);
+nsTextFrame::HasSignificantTerminalNewline() const
+{
+  return ::HasTerminalNewline(this) && StyleText()->NewlineIsSignificant();
 }
 
 bool
 nsTextFrame::IsAtEndOfLine() const
 {
   return (GetStateBits() & TEXT_END_OF_LINE) != 0;
 }
 
--- a/layout/generic/nsTextFrame.h
+++ b/layout/generic/nsTextFrame.h
@@ -178,21 +178,17 @@ public:
                                             nsIFrame*               *outChildFrame) MOZ_OVERRIDE;
   
   virtual bool IsVisibleInSelection(nsISelection* aSelection) MOZ_OVERRIDE;
   
   virtual bool IsEmpty() MOZ_OVERRIDE;
   virtual bool IsSelfEmpty() MOZ_OVERRIDE { return IsEmpty(); }
   virtual nscoord GetBaseline() const MOZ_OVERRIDE;
   
-  /**
-   * @return true if this text frame ends with a newline character.  It
-   * should return false if this is not a text frame.
-   */
-  virtual bool HasTerminalNewline() const MOZ_OVERRIDE;
+  virtual bool HasSignificantTerminalNewline() const MOZ_OVERRIDE;
 
   /**
    * Returns true if this text frame is logically adjacent to the end of the
    * line.
    */
   bool IsAtEndOfLine() const;
   
   /**