Bug 944200 part 1 - [css-ui] Make TextOverflow::CanHaveTextOverflow not take a nsDisplayListBuilder so we can use it in Reflow; cache the value in BlockReflowInput::mCanHaveTextOverflow. r=dholbert
MozReview-Commit-ID: DjHRQDHOKN
--- a/layout/generic/BlockReflowInput.cpp
+++ b/layout/generic/BlockReflowInput.cpp
@@ -3,25 +3,26 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* state used in reflow of block frames */
#include "BlockReflowInput.h"
+#include <algorithm>
#include "LayoutLogging.h"
#include "nsBlockFrame.h"
#include "nsLineLayout.h"
#include "nsPresContext.h"
#include "nsIFrameInlines.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Preferences.h"
-#include <algorithm>
+#include "TextOverflow.h"
#ifdef DEBUG
#include "nsBlockDebugFlags.h"
#endif
using namespace mozilla;
using namespace mozilla::layout;
@@ -91,16 +92,17 @@ BlockReflowInput::BlockReflowInput(const
}
if ((aBEndMarginRoot && !logicalSkipSides.BEnd()) ||
0 != mBorderPadding.BEnd(wm)) {
mFlags.mIsBEndMarginRoot = true;
}
if (aBlockNeedsFloatManager) {
mFlags.mBlockNeedsFloatManager = true;
}
+ mFlags.mCanHaveTextOverflow = css::TextOverflow::CanHaveTextOverflow(mBlock);
MOZ_ASSERT(FloatManager(),
"Float manager should be valid when creating BlockReflowInput!");
// Save the coordinate system origin for later.
FloatManager()->GetTranslation(mFloatManagerI, mFloatManagerB);
FloatManager()->PushState(&mFloatManagerStateBefore); // never popped
--- a/layout/generic/BlockReflowInput.h
+++ b/layout/generic/BlockReflowInput.h
@@ -97,16 +97,19 @@ class BlockReflowInput {
bool mIsOverflowContainer : 1;
// Set when our mPushedFloats list is stored on the block's property table.
bool mIsFloatListInBlockPropertyTable : 1;
// Set when the pref layout.float-fragments-inside-column.enabled is true.
bool mFloatFragmentsInsideColumnEnabled : 1;
+
+ // Set when we need text-overflow processing.
+ bool mCanHaveTextOverflow : 1;
};
public:
BlockReflowInput(const ReflowInput& aReflowInput,
nsPresContext* aPresContext,
nsBlockFrame* aFrame,
bool aBStartMarginRoot, bool aBEndMarginRoot,
bool aBlockNeedsFloatManager,
--- a/layout/generic/TextOverflow.cpp
+++ b/layout/generic/TextOverflow.cpp
@@ -320,17 +320,20 @@ TextOverflow::TextOverflow(nsDisplayList
// The left/right marker string is setup in ExamineLineFrames when a line
// has overflow on that side.
}
/* static */ TextOverflow*
TextOverflow::WillProcessLines(nsDisplayListBuilder* aBuilder,
nsIFrame* aBlockFrame)
{
- if (!CanHaveTextOverflow(aBuilder, aBlockFrame)) {
+ // Ignore 'text-overflow' for event and frame visibility processing.
+ if (aBuilder->IsForEventDelivery() ||
+ aBuilder->IsForFrameVisibility() ||
+ !CanHaveTextOverflow(aBlockFrame)) {
return nullptr;
}
nsIScrollableFrame* scrollableFrame = nsLayoutUtils::GetScrollableFrameFor(aBlockFrame);
if (scrollableFrame && scrollableFrame->IsTransformingByAPZ()) {
// If the APZ is actively scrolling this, don't bother with markers.
return nullptr;
}
return new TextOverflow(aBuilder, aBlockFrame);
@@ -712,25 +715,21 @@ TextOverflow::PruneDisplayListContents(n
TextOverflow::HasClippedOverflow(nsIFrame* aBlockFrame)
{
const nsStyleTextReset* style = aBlockFrame->StyleTextReset();
return style->mTextOverflow.mLeft.mType == NS_STYLE_TEXT_OVERFLOW_CLIP &&
style->mTextOverflow.mRight.mType == NS_STYLE_TEXT_OVERFLOW_CLIP;
}
/* static */ bool
-TextOverflow::CanHaveTextOverflow(nsDisplayListBuilder* aBuilder,
- nsIFrame* aBlockFrame)
+TextOverflow::CanHaveTextOverflow(nsIFrame* aBlockFrame)
{
- // Nothing to do for text-overflow:clip or if 'overflow-x/y:visible' or if
- // we're just building items for event processing or frame visibility.
+ // Nothing to do for text-overflow:clip or if 'overflow-x/y:visible'.
if (HasClippedOverflow(aBlockFrame) ||
- IsInlineAxisOverflowVisible(aBlockFrame) ||
- aBuilder->IsForEventDelivery() ||
- aBuilder->IsForFrameVisibility()) {
+ IsInlineAxisOverflowVisible(aBlockFrame)) {
return false;
}
// Skip ComboboxControlFrame because it would clip the drop-down arrow.
// Its anon block inherits 'text-overflow' and does what is expected.
if (aBlockFrame->GetType() == nsGkAtoms::comboboxControlFrame) {
return false;
}
--- a/layout/generic/TextOverflow.h
+++ b/layout/generic/TextOverflow.h
@@ -48,18 +48,17 @@ class TextOverflow {
/**
* @return true if aBlockFrmae has text-overflow:clip on both sides.
*/
static bool HasClippedOverflow(nsIFrame* aBlockFrame);
/**
* @return true if aBlockFrame needs analysis for text overflow.
*/
- static bool CanHaveTextOverflow(nsDisplayListBuilder* aBuilder,
- nsIFrame* aBlockFrame);
+ static bool CanHaveTextOverflow(nsIFrame* aBlockFrame);
typedef nsTHashtable<nsPtrHashKey<nsIFrame> > FrameHashtable;
protected:
TextOverflow(nsDisplayListBuilder* aBuilder,
nsIFrame* aBlockFrame);
typedef mozilla::WritingMode WritingMode;