Skip to content

Commit

Permalink
#442: M1381157
Browse files Browse the repository at this point in the history
  • Loading branch information
classilla committed Oct 18, 2017
1 parent 84bfb83 commit ffbe7ea
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 9 deletions.
9 changes: 3 additions & 6 deletions dom/base/nsIContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -870,12 +870,9 @@ class nsIContent : public nsINode {
{
return (IsInDoc() || IsInShadowTree()) ? mPrimaryFrame : nullptr;
}
void SetPrimaryFrame(nsIFrame* aFrame) {
MOZ_ASSERT(IsInDoc() || IsInShadowTree(), "This will end badly!");
NS_PRECONDITION(!aFrame || !mPrimaryFrame || aFrame == mPrimaryFrame,
"Losing track of existing primary frame");
mPrimaryFrame = aFrame;
}

// Defined in nsIContentInlines.h because it needs nsIFrame.
inline void SetPrimaryFrame(nsIFrame* aFrame);

nsresult LookupNamespaceURIInternal(const nsAString& aNamespacePrefix,
nsAString& aNamespaceURI) const;
Expand Down
18 changes: 18 additions & 0 deletions dom/base/nsIContentInlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@

#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsContentUtils.h"
#include "nsIFrame.h"

inline bool
nsIContent::IsInHTMLDocument() const
{
return OwnerDoc()->IsHTMLDocument();
}

inline void
nsIContent::SetPrimaryFrame(nsIFrame* aFrame)
{
MOZ_ASSERT(IsInUncomposedDoc() || IsInShadowTree(), "This will end badly!");
NS_PRECONDITION(!aFrame || !mPrimaryFrame || aFrame == mPrimaryFrame,
"Losing track of existing primary frame");

if (aFrame) {
aFrame->SetIsPrimaryFrame(true);
} else if (nsIFrame* currentPrimaryFrame = GetPrimaryFrame()) {
currentPrimaryFrame->SetIsPrimaryFrame(false);
}

mPrimaryFrame = aFrame;
}

#endif // nsIContentInlines_h
1 change: 1 addition & 0 deletions layout/base/nsCSSFrameConstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
#include "nsRuleProcessorData.h"
#include "nsTextNode.h"
#include "ActiveLayerTracker.h"
#include "nsIContentInlines.h"

using namespace mozilla;
using namespace mozilla::dom;
Expand Down
1 change: 1 addition & 0 deletions layout/forms/nsComboboxControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "mozilla/MouseEvents.h"
#include "mozilla/unused.h"
#include "gfx2DGlue.h"
#include "nsIContentInlines.h"

#ifdef XP_WIN
#define COMBOBOX_ROLLUP_CONSUME_EVENT 0
Expand Down
1 change: 1 addition & 0 deletions layout/forms/nsGfxButtonControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "nsIDOMHTMLInputElement.h"
#include "nsTextNode.h"
#include "nsIContentInlines.h"

using namespace mozilla;

Expand Down
15 changes: 12 additions & 3 deletions layout/generic/nsFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "nsFrameList.h"
#include "nsPlaceholderFrame.h"
#include "nsIContent.h"
#include "nsIContentInlines.h"
#include "nsContentUtils.h"
#include "nsIAtom.h"
#include "nsString.h"
Expand Down Expand Up @@ -398,6 +399,7 @@ nsFrame::nsFrame(nsStyleContext* aContext)
mState = NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY;
mMayHaveRoundedCorners = false;
mReflowRequestedForCharDataChange = false;
mIsPrimaryFrame = false;
mStyleContext = aContext;
mStyleContext->AddRef();
#ifdef DEBUG
Expand Down Expand Up @@ -663,6 +665,13 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot)
}
}

// from bug 1381157
// XXXneerja All instances of 'mContent->GetPrimaryFrame() == this' have been
// replaced with IsPrimaryFrame() except for this one. The reason is that
// for native anonymous content our subclass Destroy method has already
// called UnbindFromTree so nsINode::mSubtreeRoot might be in use here and
// we don't want to call mContent->SetPrimaryFrame(nullptr) in that case.
// (bug 1400618 will fix that order)
bool isPrimaryFrame = (mContent && mContent->GetPrimaryFrame() == this);
if (isPrimaryFrame) {
// This needs to happen before shell->NotifyDestroyingFrame because
Expand Down Expand Up @@ -1096,7 +1105,7 @@ nsIFrame::IsTransformed() const
EffectCompositor::HasAnimationsForCompositor(
this, eCSSProperty_transform) &&
IsFrameOfType(eSupportsCSSTransforms) &&
mContent->GetPrimaryFrame() == this)));
IsPrimaryFrame())));
}

bool
Expand All @@ -1109,7 +1118,7 @@ nsIFrame::HasOpacityInternal(float aThreshold) const
(mContent &&
EffectCompositor::HasAnimationsForCompositor(
this, eCSSProperty_opacity) &&
mContent->GetPrimaryFrame() == this);
IsPrimaryFrame());
}

bool
Expand Down Expand Up @@ -8285,7 +8294,7 @@ nsFrame::DoGetParentStyleContext(nsIFrame** aProviderFrame) const
// Ensure that we don't return the display:contents style
// of the parent content for pseudos that have the same content
// as their primary frame (like -moz-list-bullets do):
mContent->GetPrimaryFrame() == this) ||
IsPrimaryFrame()) ||
/* if next is true then it's really a request for the table frame's
parent context, see nsTable[Outer]Frame::GetParentStyleContext. */
pseudo == nsCSSAnonBoxes::tableOuter) {
Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsFrameSetFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "mozilla/LookAndFeel.h"
#include "mozilla/MouseEvents.h"
#include "nsSubDocumentFrame.h"
#include "nsIContentInlines.h"

using namespace mozilla;
using namespace mozilla::dom;
Expand Down
15 changes: 15 additions & 0 deletions layout/generic/nsIFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,13 @@ class nsIFrame : public nsQueryFrame
return mState & aBits;
}

/**
* Return true if this frame is the primary frame for mContent.
*/
bool IsPrimaryFrame() const { return mIsPrimaryFrame; }

void SetIsPrimaryFrame(bool aIsPrimary) { mIsPrimaryFrame = aIsPrimary; }

/**
* This call is invoked on the primary frame for a character data content
* node, when it is changed in the content tree.
Expand Down Expand Up @@ -3171,6 +3178,14 @@ NS_PTR_TO_INT32(frame->Properties().Get(nsIFrame::ParagraphDepthProperty()))
*/
bool mReflowRequestedForCharDataChange : 1;

private:
/**
* True if this is the primary frame for mContent.
*/
bool mIsPrimaryFrame : 1;

protected:

// Helpers
/**
* Can we stop inside this frame when we're skipping non-rendered whitespace?
Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsImageMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "nsIStringBundle.h"
#include "nsContentUtils.h"
#include "ImageLayers.h"
#include "nsIContentInlines.h"

#ifdef ACCESSIBILITY
#include "nsAccessibilityService.h"
Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsSubDocumentFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "nsIPermissionManager.h"
#include "nsServiceManagerUtils.h"
#include "nsIDOMMutationEvent.h"
#include "nsIContentInlines.h"

using namespace mozilla;
using mozilla::layout::RenderFrameParent;
Expand Down

0 comments on commit ffbe7ea

Please sign in to comment.