Attachment #8493956: part 2 of the Fctor changes - the main part, except XBL/Shadow tree fixes for bug #907396

View | Details | Raw Unified | Return to bug 907396
Collapse All | Expand All

(-)a/layout/base/RestyleManager.cpp (+32 lines)
Line     Link Here 
 Lines 3522-3530   RestyleManager::ComputeStyleChangeFor(ns Link Here 
3522
        NS_ASSERTION(!cont->GetPrevContinuation(),
3522
        NS_ASSERTION(!cont->GetPrevContinuation(),
3523
                     "continuing frame had more severe impact than first-in-flow");
3523
                     "continuing frame had more severe impact than first-in-flow");
3524
        return;
3524
        return;
3525
      }
3525
      }
3526
    }
3526
    }
3527
  }
3527
  }
3528
}
3528
}
3529
3529
3530
AutoDisplayContentsAncestorPusher::AutoDisplayContentsAncestorPusher(
3531
  TreeMatchContext& aTreeMatchContext, nsPresContext* aPresContext,
3532
  nsIContent* aParent)
3533
  : mTreeMatchContext(aTreeMatchContext)
3534
  , mPresContext(aPresContext)
3535
{
3536
  if (aParent && mTreeMatchContext.mAncestorFilter.HasFilter()) {
3537
    nsFrameManager* fm = mPresContext->FrameManager();
3538
    // Push display:contents mAncestors onto mTreeMatchContext.
3539
    for (nsIContent* p = aParent; p && fm->GetDisplayContentsStyleFor(p);
3540
         p = p->GetParent()) {
3541
      mAncestors.AppendElement(p->AsElement());
3542
    }
3543
    nsTArray<mozilla::dom::Element*>::size_type i = mAncestors.Length();
3544
    while (i--) {
3545
      mTreeMatchContext.mAncestorFilter.PushAncestor(mAncestors[i]);
3546
      mTreeMatchContext.PushStyleScope(mAncestors[i]);
3547
    }
3548
  }
3549
3550
}
3551
3552
AutoDisplayContentsAncestorPusher::~AutoDisplayContentsAncestorPusher()
3553
{
3554
  // Pop the ancestors we pushed in the CTOR, if any.
3555
  nsTArray<mozilla::dom::Element*>::size_type i = mAncestors.Length();
3556
  while (i--) {
3557
    mTreeMatchContext.mAncestorFilter.PopAncestor();
3558
    mTreeMatchContext.PopStyleScope(mAncestors[i]);
3559
  }
3560
}
3561
3530
} // namespace mozilla
3562
} // namespace mozilla
(-)a/layout/base/RestyleManager.h (-2 / +25 lines)
Line     Link Here 
 Lines 25-41   struct TreeMatchContext; Link Here 
25
25
26
namespace mozilla {
26
namespace mozilla {
27
  class EventStates;
27
  class EventStates;
28
28
29
namespace dom {
29
namespace dom {
30
  class Element;
30
  class Element;
31
} // namespace dom
31
} // namespace dom
32
32
33
class RestyleManager MOZ_FINAL {
33
class RestyleManager MOZ_FINAL
34
{
34
public:
35
public:
35
  friend class ::nsRefreshDriver;
36
  friend class ::nsRefreshDriver;
36
  friend class RestyleTracker;
37
  friend class RestyleTracker;
37
38
38
  typedef mozilla::dom::Element Element;
39
  typedef mozilla::dom::Element Element;
39
40
40
  explicit RestyleManager(nsPresContext* aPresContext);
41
  explicit RestyleManager(nsPresContext* aPresContext);
41
42
 Lines 394-410   private: Link Here 
394
  RestyleTracker mPendingRestyles;
395
  RestyleTracker mPendingRestyles;
395
  RestyleTracker mPendingAnimationRestyles;
396
  RestyleTracker mPendingAnimationRestyles;
396
};
397
};
397
398
398
/**
399
/**
399
 * An ElementRestyler is created for *each* element in a subtree that we
400
 * An ElementRestyler is created for *each* element in a subtree that we
400
 * recompute styles for.
401
 * recompute styles for.
401
 */
402
 */
402
class ElementRestyler MOZ_FINAL {
403
class ElementRestyler MOZ_FINAL
404
{
403
public:
405
public:
404
  typedef mozilla::dom::Element Element;
406
  typedef mozilla::dom::Element Element;
405
407
406
  // Construct for the root of the subtree that we're restyling.
408
  // Construct for the root of the subtree that we're restyling.
407
  ElementRestyler(nsPresContext* aPresContext,
409
  ElementRestyler(nsPresContext* aPresContext,
408
                  nsIFrame* aFrame,
410
                  nsIFrame* aFrame,
409
                  nsStyleChangeList* aChangeList,
411
                  nsStyleChangeList* aChangeList,
410
                  nsChangeHint aHintsHandledByAncestors,
412
                  nsChangeHint aHintsHandledByAncestors,
 Lines 544-554   private: Link Here 
544
  const DesiredA11yNotifications mDesiredA11yNotifications;
546
  const DesiredA11yNotifications mDesiredA11yNotifications;
545
  DesiredA11yNotifications mKidsDesiredA11yNotifications;
547
  DesiredA11yNotifications mKidsDesiredA11yNotifications;
546
  A11yNotificationType mOurA11yNotification;
548
  A11yNotificationType mOurA11yNotification;
547
  nsTArray<nsIContent*>& mVisibleKidsOfHiddenElement;
549
  nsTArray<nsIContent*>& mVisibleKidsOfHiddenElement;
548
  bool mWasFrameVisible;
550
  bool mWasFrameVisible;
549
#endif
551
#endif
550
};
552
};
551
553
554
/**
555
 * This pushes any display:contents nodes onto a TreeMatchContext.
556
 * Use it before resolving style for kids of aParent where aParent
557
 * (and further ancestors) may be display:contents nodes which have
558
 * not yet been pushed onto TreeMatchContext.
559
 */
560
class MOZ_STACK_CLASS AutoDisplayContentsAncestorPusher MOZ_FINAL
561
{
562
 public:
563
  typedef mozilla::dom::Element Element;
564
  AutoDisplayContentsAncestorPusher(TreeMatchContext& aTreeMatchContext,
565
                                    nsPresContext*    aPresContext,
566
                                    nsIContent*       aParent);
567
  ~AutoDisplayContentsAncestorPusher();
568
  bool IsEmpty() const { return mAncestors.Length() == 0; }
569
private:
570
  TreeMatchContext& mTreeMatchContext;
571
  nsPresContext* const mPresContext;
572
  nsAutoTArray<mozilla::dom::Element*, 4> mAncestors;
573
};
574
552
} // namespace mozilla
575
} // namespace mozilla
553
576
554
#endif /* mozilla_RestyleManager_h */
577
#endif /* mozilla_RestyleManager_h */
(-)a/layout/base/RestyleTracker.cpp (-3 / +8 lines)
Line     Link Here 
 Lines 4-22    Link Here 
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
5
6
/**
6
/**
7
 * A class which manages pending restyles.  This handles keeping track
7
 * A class which manages pending restyles.  This handles keeping track
8
 * of what nodes restyles need to happen on and so forth.
8
 * of what nodes restyles need to happen on and so forth.
9
 */
9
 */
10
10
11
#include "RestyleTracker.h"
11
#include "RestyleTracker.h"
12
13
#include "GeckoProfiler.h"
14
#include "nsFrameManager.h"
15
#include "nsIDocument.h"
12
#include "nsStyleChangeList.h"
16
#include "nsStyleChangeList.h"
13
#include "RestyleManager.h"
17
#include "RestyleManager.h"
14
#include "GeckoProfiler.h"
15
18
16
namespace mozilla {
19
namespace mozilla {
17
20
18
inline nsIDocument*
21
inline nsIDocument*
19
RestyleTracker::Document() const {
22
RestyleTracker::Document() const {
20
  return mRestyleManager->PresContext()->Document();
23
  return mRestyleManager->PresContext()->Document();
21
}
24
}
22
25
 Lines 74-91   CollectRestyles(nsISupports* aElement, Link Here 
74
  if (element->GetCrossShadowCurrentDoc() != collector->tracker->Document() ||
77
  if (element->GetCrossShadowCurrentDoc() != collector->tracker->Document() ||
75
      !element->HasFlag(collector->tracker->RestyleBit())) {
78
      !element->HasFlag(collector->tracker->RestyleBit())) {
76
    return PL_DHASH_NEXT;
79
    return PL_DHASH_NEXT;
77
  }
80
  }
78
81
79
  NS_ASSERTION(!element->HasFlag(collector->tracker->RootBit()) ||
82
  NS_ASSERTION(!element->HasFlag(collector->tracker->RootBit()) ||
80
               // Maybe we're just not reachable via the frame tree?
83
               // Maybe we're just not reachable via the frame tree?
81
               (element->GetFlattenedTreeParent() &&
84
               (element->GetFlattenedTreeParent() &&
82
                (!element->GetFlattenedTreeParent()->GetPrimaryFrame()||
85
                (!element->GetFlattenedTreeParent()->GetPrimaryFrame() ||
83
                 element->GetFlattenedTreeParent()->GetPrimaryFrame()->IsLeaf())) ||
86
                 element->GetFlattenedTreeParent()->GetPrimaryFrame()->IsLeaf() ||
87
                 element->GetCurrentDoc()->GetShell()->FrameManager()
88
                   ->GetDisplayContentsStyleFor(element))) ||
84
               // Or not reachable due to an async reinsert we have
89
               // Or not reachable due to an async reinsert we have
85
               // pending?  If so, we'll have a reframe hint around.
90
               // pending?  If so, we'll have a reframe hint around.
86
               // That incidentally makes it safe that we still have
91
               // That incidentally makes it safe that we still have
87
               // the bit, since any descendants that didn't get added
92
               // the bit, since any descendants that didn't get added
88
               // to the roots list because we had the bits will be
93
               // to the roots list because we had the bits will be
89
               // completely restyled in a moment.
94
               // completely restyled in a moment.
90
               (aData->mChangeHint & nsChangeHint_ReconstructFrame),
95
               (aData->mChangeHint & nsChangeHint_ReconstructFrame),
91
               "Why did this not get handled while processing mRestyleRoots?");
96
               "Why did this not get handled while processing mRestyleRoots?");
(-)a/layout/base/nsCSSFrameConstructor.cpp (-108 / +292 lines)
Line     Link Here 
 Lines 606-645   FindFirstNonBlock(const nsFrameList& aLi Link Here 
606
inline void
606
inline void
607
SetInitialSingleChild(nsContainerFrame* aParent, nsIFrame* aFrame)
607
SetInitialSingleChild(nsContainerFrame* aParent, nsIFrame* aFrame)
608
{
608
{
609
  NS_PRECONDITION(!aFrame->GetNextSibling(), "Should be using a frame list");
609
  NS_PRECONDITION(!aFrame->GetNextSibling(), "Should be using a frame list");
610
  nsFrameList temp(aFrame, aFrame);
610
  nsFrameList temp(aFrame, aFrame);
611
  aParent->SetInitialChildList(kPrincipalList, temp);
611
  aParent->SetInitialChildList(kPrincipalList, temp);
612
}
612
}
613
613
614
static nsContainerFrame*
615
GetContentInsertionFrameFor(nsIContent* aContent)
616
{
617
  // Get the primary frame associated with the content
618
  nsIFrame* frame = aContent->GetPrimaryFrame();
619
620
  if (!frame)
621
    return nullptr;
622
623
  // If the content of the frame is not the desired content then this is not
624
  // really a frame for the desired content.
625
  // XXX This check is needed due to bug 135040. Remove it once that's fixed.
626
  if (frame->GetContent() != aContent) {
627
    return nullptr;
628
  }
629
630
  nsContainerFrame* insertionFrame = frame->GetContentInsertionFrame();
631
632
  NS_ASSERTION(!insertionFrame || insertionFrame == frame || !frame->IsLeaf(),
633
    "The insertion frame is the primary frame or the primary frame isn't a leaf");
634
635
  return insertionFrame;
636
}
637
638
// -----------------------------------------------------------
614
// -----------------------------------------------------------
639
615
640
// Structure used when constructing formatting object trees.
616
// Structure used when constructing formatting object trees.
641
struct nsFrameItems : public nsFrameList
617
struct nsFrameItems : public nsFrameList
642
{
618
{
643
  // Appends the frame to the end of the list
619
  // Appends the frame to the end of the list
644
  void AddChild(nsIFrame* aChild);
620
  void AddChild(nsIFrame* aChild);
645
};
621
};
 Lines 2283-2300   NeedFrameFor(const nsFrameConstructorSta Link Here 
2283
  // whitespace.
2259
  // whitespace.
2284
2260
2285
  // We could handle all this in CreateNeededPseudos or some other place
2261
  // We could handle all this in CreateNeededPseudos or some other place
2286
  // after we build our frame construction items, but that would involve
2262
  // after we build our frame construction items, but that would involve
2287
  // creating frame construction items for whitespace kids of
2263
  // creating frame construction items for whitespace kids of
2288
  // eExcludesIgnorableWhitespace frames, where we know we'll be dropping them
2264
  // eExcludesIgnorableWhitespace frames, where we know we'll be dropping them
2289
  // all anyway, and involve an extra walk down the frame construction item
2265
  // all anyway, and involve an extra walk down the frame construction item
2290
  // list.
2266
  // list.
2291
  if (!aParentFrame->IsFrameOfType(nsIFrame::eExcludesIgnorableWhitespace) ||
2267
  if ((aParentFrame &&
2292
      aParentFrame->IsGeneratedContentFrame() ||
2268
       (!aParentFrame->IsFrameOfType(nsIFrame::eExcludesIgnorableWhitespace) ||
2269
        aParentFrame->IsGeneratedContentFrame())) ||
2293
      !aChildContent->IsNodeOfType(nsINode::eTEXT)) {
2270
      !aChildContent->IsNodeOfType(nsINode::eTEXT)) {
2294
    return true;
2271
    return true;
2295
  }
2272
  }
2296
2273
2297
  aChildContent->SetFlags(NS_CREATE_FRAME_IF_NON_WHITESPACE |
2274
  aChildContent->SetFlags(NS_CREATE_FRAME_IF_NON_WHITESPACE |
2298
                          NS_REFRAME_IF_WHITESPACE);
2275
                          NS_REFRAME_IF_WHITESPACE);
2299
  return !aChildContent->TextIsOnlyWhitespace();
2276
  return !aChildContent->TextIsOnlyWhitespace();
2300
}
2277
}
 Lines 2583-2599   nsCSSFrameConstructor::ConstructDocEleme Link Here 
2583
    // if the document is a table then just populate it.
2560
    // if the document is a table then just populate it.
2584
    contentFrame = static_cast<nsContainerFrame*>(
2561
    contentFrame = static_cast<nsContainerFrame*>(
2585
      ConstructTable(state, item, mDocElementContainingBlock,
2562
      ConstructTable(state, item, mDocElementContainingBlock,
2586
                     styleContext->StyleDisplay(),
2563
                     styleContext->StyleDisplay(),
2587
                     frameItems));
2564
                     frameItems));
2588
    newFrame = frameItems.FirstChild();
2565
    newFrame = frameItems.FirstChild();
2589
    NS_ASSERTION(frameItems.OnlyChild(), "multiple root element frames");
2566
    NS_ASSERTION(frameItems.OnlyChild(), "multiple root element frames");
2590
  } else {
2567
  } else {
2591
    MOZ_ASSERT(display->mDisplay == NS_STYLE_DISPLAY_BLOCK,
2568
    MOZ_ASSERT(display->mDisplay == NS_STYLE_DISPLAY_BLOCK ||
2569
               display->mDisplay == NS_STYLE_DISPLAY_CONTENTS,
2592
               "Unhandled display type for root element");
2570
               "Unhandled display type for root element");
2593
    contentFrame = NS_NewBlockFormattingContext(mPresShell, styleContext);
2571
    contentFrame = NS_NewBlockFormattingContext(mPresShell, styleContext);
2594
    nsFrameItems frameItems;
2572
    nsFrameItems frameItems;
2595
    // Use a null PendingBinding, since our binding is not in fact pending.
2573
    // Use a null PendingBinding, since our binding is not in fact pending.
2596
    ConstructBlock(state, display, aDocElement,
2574
    ConstructBlock(state, display, aDocElement,
2597
                   state.GetGeometricParent(display,
2575
                   state.GetGeometricParent(display,
2598
                                            mDocElementContainingBlock),
2576
                                            mDocElementContainingBlock),
2599
                   mDocElementContainingBlock, styleContext,
2577
                   mDocElementContainingBlock, styleContext,
 Lines 3690-3718   nsCSSFrameConstructor::ConstructFrameFro Link Here 
3690
3668
3691
  // Don't create a subdocument frame for iframes if we're creating extra frames
3669
  // Don't create a subdocument frame for iframes if we're creating extra frames
3692
  if (aState.mCreatingExtraFrames && aItem.mContent->IsHTML() &&
3670
  if (aState.mCreatingExtraFrames && aItem.mContent->IsHTML() &&
3693
      aItem.mContent->Tag() == nsGkAtoms::iframe)
3671
      aItem.mContent->Tag() == nsGkAtoms::iframe)
3694
  {
3672
  {
3695
    return;
3673
    return;
3696
  }
3674
  }
3697
3675
3698
  nsStyleContext* const styleContext = aItem.mStyleContext;
3699
  const nsStyleDisplay* display = styleContext->StyleDisplay();
3700
  nsIContent* const content = aItem.mContent;
3676
  nsIContent* const content = aItem.mContent;
3677
  nsIContent* parent = content->GetParent();
3678
3679
  // Push display:contents ancestors.
3680
  AutoDisplayContentsAncestorPusher adcp(aState.mTreeMatchContext,
3681
                                         aState.mPresContext, parent);
3701
3682
3702
  // Get the parent of the content and check if it is a XBL children element.
3683
  // Get the parent of the content and check if it is a XBL children element.
3703
  // Push the children element as an ancestor here because it does
3684
  // Push the children element as an ancestor here because it does
3704
  // not have a frame and would not otherwise be pushed as an ancestor. It is
3685
  // not have a frame and would not otherwise be pushed as an ancestor. It is
3705
  // necessary to do so in order to correctly handle style resolution on
3686
  // necessary to do so in order to correctly handle style resolution on
3706
  // descendants.
3687
  // descendants.
3707
  nsIContent* parent = content->GetParent();
3708
  TreeMatchContext::AutoAncestorPusher
3688
  TreeMatchContext::AutoAncestorPusher
3709
    insertionPointPusher(aState.mTreeMatchContext);
3689
    insertionPointPusher(aState.mTreeMatchContext);
3710
  if (parent && nsContentUtils::IsContentInsertionPoint(parent)) {
3690
  if (adcp.IsEmpty() && parent && nsContentUtils::IsContentInsertionPoint(parent)) {
3711
    if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) {
3691
    if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) {
3712
      insertionPointPusher.PushAncestorAndStyleScope(parent);
3692
      insertionPointPusher.PushAncestorAndStyleScope(parent);
3713
    } else {
3693
    } else {
3714
      insertionPointPusher.PushStyleScope(parent);
3694
      insertionPointPusher.PushStyleScope(parent);
3715
    }
3695
    }
3716
  }
3696
  }
3717
3697
3718
  // Push the content as a style ancestor now, so we don't have to do
3698
  // Push the content as a style ancestor now, so we don't have to do
 Lines 3728-3743   nsCSSFrameConstructor::ConstructFrameFro Link Here 
3728
  if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) {
3708
  if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) {
3729
    ancestorPusher.PushAncestorAndStyleScope(content);
3709
    ancestorPusher.PushAncestorAndStyleScope(content);
3730
  } else {
3710
  } else {
3731
    ancestorPusher.PushStyleScope(content);
3711
    ancestorPusher.PushStyleScope(content);
3732
  }
3712
  }
3733
3713
3734
  nsIFrame* newFrame;
3714
  nsIFrame* newFrame;
3735
  nsIFrame* primaryFrame;
3715
  nsIFrame* primaryFrame;
3716
  nsStyleContext* const styleContext = aItem.mStyleContext;
3717
  const nsStyleDisplay* display = styleContext->StyleDisplay();
3736
  if (bits & FCDATA_FUNC_IS_FULL_CTOR) {
3718
  if (bits & FCDATA_FUNC_IS_FULL_CTOR) {
3737
    newFrame =
3719
    newFrame =
3738
      (this->*(data->mFullConstructor))(aState, aItem, aParentFrame,
3720
      (this->*(data->mFullConstructor))(aState, aItem, aParentFrame,
3739
                                        display, aFrameItems);
3721
                                        display, aFrameItems);
3740
    MOZ_ASSERT(newFrame, "Full constructor failed");
3722
    MOZ_ASSERT(newFrame, "Full constructor failed");
3741
    primaryFrame = newFrame;
3723
    primaryFrame = newFrame;
3742
  } else {
3724
  } else {
3743
    newFrame =
3725
    newFrame =
 Lines 4495-4511   nsCSSFrameConstructor::FindDisplayData(c Link Here 
4495
                                       nsStyleContext* aStyleContext)
4477
                                       nsStyleContext* aStyleContext)
4496
{
4478
{
4497
  PR_STATIC_ASSERT(eParentTypeCount < (1 << (32 - FCDATA_PARENT_TYPE_OFFSET)));
4479
  PR_STATIC_ASSERT(eParentTypeCount < (1 << (32 - FCDATA_PARENT_TYPE_OFFSET)));
4498
4480
4499
  // The style system ensures that floated and positioned frames are
4481
  // The style system ensures that floated and positioned frames are
4500
  // block-level.
4482
  // block-level.
4501
  NS_ASSERTION(!(aDisplay->IsFloatingStyle() ||
4483
  NS_ASSERTION(!(aDisplay->IsFloatingStyle() ||
4502
                 aDisplay->IsAbsolutelyPositionedStyle()) ||
4484
                 aDisplay->IsAbsolutelyPositionedStyle()) ||
4503
               aDisplay->IsBlockOutsideStyle(),
4485
               aDisplay->IsBlockOutsideStyle() ||
4486
               aDisplay->mDisplay == NS_STYLE_DISPLAY_CONTENTS,
4504
               "Style system did not apply CSS2.1 section 9.7 fixups");
4487
               "Style system did not apply CSS2.1 section 9.7 fixups");
4505
4488
4506
  // If this is "body", try propagating its scroll style to the viewport
4489
  // If this is "body", try propagating its scroll style to the viewport
4507
  // Note that we need to do this even if the body is NOT scrollable;
4490
  // Note that we need to do this even if the body is NOT scrollable;
4508
  // it might have dynamically changed from scrollable to not scrollable,
4491
  // it might have dynamically changed from scrollable to not scrollable,
4509
  // and that might need to be propagated.
4492
  // and that might need to be propagated.
4510
  // XXXbz is this the right place to do this?  If this code moves,
4493
  // XXXbz is this the right place to do this?  If this code moves,
4511
  // make this function static.
4494
  // make this function static.
 Lines 4636-4654   nsCSSFrameConstructor::FindDisplayData(c Link Here 
4636
                       &nsCSSFrameConstructor::ConstructTableCol) },
4619
                       &nsCSSFrameConstructor::ConstructTableCol) },
4637
    { NS_STYLE_DISPLAY_TABLE_ROW,
4620
    { NS_STYLE_DISPLAY_TABLE_ROW,
4638
      FULL_CTOR_FCDATA(FCDATA_IS_TABLE_PART |
4621
      FULL_CTOR_FCDATA(FCDATA_IS_TABLE_PART |
4639
                       FCDATA_DESIRED_PARENT_TYPE_TO_BITS(eTypeRowGroup),
4622
                       FCDATA_DESIRED_PARENT_TYPE_TO_BITS(eTypeRowGroup),
4640
                       &nsCSSFrameConstructor::ConstructTableRowOrRowGroup) },
4623
                       &nsCSSFrameConstructor::ConstructTableRowOrRowGroup) },
4641
    { NS_STYLE_DISPLAY_TABLE_CELL,
4624
    { NS_STYLE_DISPLAY_TABLE_CELL,
4642
      FULL_CTOR_FCDATA(FCDATA_IS_TABLE_PART |
4625
      FULL_CTOR_FCDATA(FCDATA_IS_TABLE_PART |
4643
                       FCDATA_DESIRED_PARENT_TYPE_TO_BITS(eTypeRow),
4626
                       FCDATA_DESIRED_PARENT_TYPE_TO_BITS(eTypeRow),
4644
                       &nsCSSFrameConstructor::ConstructTableCell) }
4627
                       &nsCSSFrameConstructor::ConstructTableCell) },
4628
    { NS_STYLE_DISPLAY_CONTENTS,
4629
      FULL_CTOR_FCDATA(FCDATA_IS_CONTENTS, nullptr/*never called*/) }
4645
  };
4630
  };
4646
4631
4632
  // See the mDisplay fixup code in nsRuleNode::ComputeDisplayData.
4633
  MOZ_ASSERT(aDisplay->mDisplay != NS_STYLE_DISPLAY_CONTENTS ||
4634
             !aElement->IsRootOfNativeAnonymousSubtree(),
4635
             "display:contents on anonymous content is unsupported");
4636
4647
  return FindDataByInt(aDisplay->mDisplay,
4637
  return FindDataByInt(aDisplay->mDisplay,
4648
                       aElement, aStyleContext, sDisplayData,
4638
                       aElement, aStyleContext, sDisplayData,
4649
                       ArrayLength(sDisplayData));
4639
                       ArrayLength(sDisplayData));
4650
}
4640
}
4651
4641
4652
nsIFrame*
4642
nsIFrame*
4653
nsCSSFrameConstructor::ConstructScrollableBlock(nsFrameConstructorState& aState,
4643
nsCSSFrameConstructor::ConstructScrollableBlock(nsFrameConstructorState& aState,
4654
                                                FrameConstructionItem&   aItem,
4644
                                                FrameConstructionItem&   aItem,
 Lines 4756-4786   nsCSSFrameConstructor::InitAndRestoreFra Link Here 
4756
}
4746
}
4757
4747
4758
already_AddRefed<nsStyleContext>
4748
already_AddRefed<nsStyleContext>
4759
nsCSSFrameConstructor::ResolveStyleContext(nsIFrame*         aParentFrame,
4749
nsCSSFrameConstructor::ResolveStyleContext(nsIFrame*         aParentFrame,
4760
                                           nsIContent*       aContainer,
4750
                                           nsIContent*       aContainer,
4761
                                           nsIContent*       aChild,
4751
                                           nsIContent*       aChild,
4762
                                           nsFrameConstructorState* aState)
4752
                                           nsFrameConstructorState* aState)
4763
{
4753
{
4764
  nsStyleContext* parentStyleContext = nullptr;
4754
  nsIContent* container = aChild->GetParent();
4765
  NS_ASSERTION(aChild->GetParent(), "Must have parent here");
4755
  NS_ASSERTION(container, "Must have parent here");
4766
4756
  nsStyleContext* parentStyleContext = GetDisplayContentsStyleFor(container);
4767
  aParentFrame = nsFrame::CorrectStyleParentFrame(aParentFrame, nullptr);
4757
  if (MOZ_LIKELY(!parentStyleContext)) {
4768
4758
    aParentFrame = nsFrame::CorrectStyleParentFrame(aParentFrame, nullptr);
4769
  if (aParentFrame) {
4759
    if (aParentFrame) {
4770
    // Resolve the style context based on the content object and the parent
4760
      // Resolve the style context based on the content object and the parent
4771
    // style context
4761
      // style context
4772
    parentStyleContext = aParentFrame->StyleContext();
4762
      parentStyleContext = aParentFrame->StyleContext();
4773
  } else {
4763
    } else {
4774
    // Perhaps aParentFrame is a canvasFrame and we're replicating
4764
      // Perhaps aParentFrame is a canvasFrame and we're replicating
4775
    // fixed-pos frames.
4765
      // fixed-pos frames.
4776
    // XXX should we create a way to tell ConstructFrame which style
4766
      // XXX should we create a way to tell ConstructFrame which style
4777
    // context to use, and pass it the style context for the
4767
      // context to use, and pass it the style context for the
4778
    // previous page's fixed-pos frame?
4768
      // previous page's fixed-pos frame?
4769
    }
4779
  }
4770
  }
4780
4771
4781
  return ResolveStyleContext(parentStyleContext, aChild, aState);
4772
  return ResolveStyleContext(parentStyleContext, aChild, aState);
4782
}
4773
}
4783
4774
4784
already_AddRefed<nsStyleContext>
4775
already_AddRefed<nsStyleContext>
4785
nsCSSFrameConstructor::ResolveStyleContext(nsIFrame*          aParentFrame,
4776
nsCSSFrameConstructor::ResolveStyleContext(nsIFrame*          aParentFrame,
4786
                                           nsIContent*              aChild,
4777
                                           nsIContent*              aChild,
 Lines 5308-5329   nsCSSFrameConstructor::AddPageBreakItem( Link Here 
5308
5299
5309
  // Lie about the tag and namespace so we don't trigger anything
5300
  // Lie about the tag and namespace so we don't trigger anything
5310
  // interesting during frame construction.
5301
  // interesting during frame construction.
5311
  aItems.AppendItem(&sPageBreakData, aContent, nsCSSAnonBoxes::pageBreak,
5302
  aItems.AppendItem(&sPageBreakData, aContent, nsCSSAnonBoxes::pageBreak,
5312
                    kNameSpaceID_None, nullptr, pseudoStyle.forget(),
5303
                    kNameSpaceID_None, nullptr, pseudoStyle.forget(),
5313
                    true, nullptr);
5304
                    true, nullptr);
5314
}
5305
}
5315
5306
5316
void
5307
bool
5317
nsCSSFrameConstructor::AddFrameConstructionItems(nsFrameConstructorState& aState,
5308
nsCSSFrameConstructor::ShouldCreateItemsForChild(nsFrameConstructorState& aState,
5318
                                                 nsIContent* aContent,
5309
                                                 nsIContent* aContent,
5319
                                                 bool aSuppressWhiteSpaceOptimizations,
5310
                                                 nsContainerFrame* aParentFrame)
5320
                                                 const InsertionPoint& aInsertion,
5321
                                                 FrameConstructionItemList& aItems)
5322
{
5311
{
5323
  aContent->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
5312
  aContent->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
5324
  if (aContent->IsElement()) {
5313
  if (aContent->IsElement()) {
5325
    // We can't just remove our pending restyle flags, since we may
5314
    // We can't just remove our pending restyle flags, since we may
5326
    // have restyle-later-siblings set on us.  But we _can_ remove the
5315
    // have restyle-later-siblings set on us.  But we _can_ remove the
5327
    // "is possible restyle root" flags, and need to.  Otherwise we can
5316
    // "is possible restyle root" flags, and need to.  Otherwise we can
5328
    // end up with stale such flags (e.g. if we used to have a
5317
    // end up with stale such flags (e.g. if we used to have a
5329
    // display:none parent when our last restyle was posted and
5318
    // display:none parent when our last restyle was posted and
 Lines 5334-5384   nsCSSFrameConstructor::AddFrameConstruct Link Here 
5334
5323
5335
  // XXX the GetContent() != aContent check is needed due to bug 135040.
5324
  // XXX the GetContent() != aContent check is needed due to bug 135040.
5336
  // Remove it once that's fixed.
5325
  // Remove it once that's fixed.
5337
  if (aContent->GetPrimaryFrame() &&
5326
  if (aContent->GetPrimaryFrame() &&
5338
      aContent->GetPrimaryFrame()->GetContent() == aContent &&
5327
      aContent->GetPrimaryFrame()->GetContent() == aContent &&
5339
      !aState.mCreatingExtraFrames) {
5328
      !aState.mCreatingExtraFrames) {
5340
    NS_ERROR("asked to create frame construction item for a node that already "
5329
    NS_ERROR("asked to create frame construction item for a node that already "
5341
             "has a frame");
5330
             "has a frame");
5342
    return;
5331
    return false;
5343
  }
5332
  }
5344
5333
5345
  // don't create a whitespace frame if aParent doesn't want it
5334
  // don't create a whitespace frame if aParent doesn't want it
5346
  nsContainerFrame* aParentFrame = aInsertion.mParentFrame;
5347
  if (!NeedFrameFor(aState, aParentFrame, aContent)) {
5335
  if (!NeedFrameFor(aState, aParentFrame, aContent)) {
5348
    return;
5336
    return false;
5349
  }
5337
  }
5350
5338
5351
  // never create frames for comments or PIs
5339
  // never create frames for comments or PIs
5352
  if (aContent->IsNodeOfType(nsINode::eCOMMENT) ||
5340
  if (aContent->IsNodeOfType(nsINode::eCOMMENT) ||
5353
      aContent->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION))
5341
      aContent->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
5354
    return;
5342
    return false;
5355
5343
  }
5356
  nsRefPtr<nsStyleContext> styleContext;
5344
5357
  styleContext = ResolveStyleContext(aParentFrame, aContent, &aState);
5345
  return true;
5358
5346
}
5347
5348
void
5349
nsCSSFrameConstructor::DoAddFrameConstructionItems(nsFrameConstructorState& aState,
5350
                                                   nsIContent* aContent,
5351
                                                   nsStyleContext* aStyleContext,
5352
                                                   bool aSuppressWhiteSpaceOptimizations,
5353
                                                   nsContainerFrame* aParentFrame,
5354
                                                   nsTArray<nsIAnonymousContentCreator::ContentInfo>* aAnonChildren,
5355
                                                   FrameConstructionItemList& aItems)
5356
{
5359
  uint32_t flags = ITEM_ALLOW_XBL_BASE | ITEM_ALLOW_PAGE_BREAK;
5357
  uint32_t flags = ITEM_ALLOW_XBL_BASE | ITEM_ALLOW_PAGE_BREAK;
5360
  if (aParentFrame->IsSVGText()) {
5358
  if (aParentFrame) {
5361
    flags |= ITEM_IS_WITHIN_SVG_TEXT;
5359
    if (aParentFrame->IsSVGText()) {
5362
  }
5360
      flags |= ITEM_IS_WITHIN_SVG_TEXT;
5363
  if (aParentFrame->GetType() == nsGkAtoms::blockFrame &&
5361
    }
5364
      aParentFrame->GetParent() &&
5362
    if (aParentFrame->GetType() == nsGkAtoms::blockFrame &&
5365
      aParentFrame->GetParent()->GetType() == nsGkAtoms::svgTextFrame) {
5363
        aParentFrame->GetParent() &&
5366
    flags |= ITEM_ALLOWS_TEXT_PATH_CHILD;
5364
        aParentFrame->GetParent()->GetType() == nsGkAtoms::svgTextFrame) {
5365
      flags |= ITEM_ALLOWS_TEXT_PATH_CHILD;
5366
    }
5367
  }
5367
  }
5368
  AddFrameConstructionItemsInternal(aState, aContent, aParentFrame,
5368
  AddFrameConstructionItemsInternal(aState, aContent, aParentFrame,
5369
                                    aContent->Tag(), aContent->GetNameSpaceID(),
5369
                                    aContent->Tag(), aContent->GetNameSpaceID(),
5370
                                    aSuppressWhiteSpaceOptimizations,
5370
                                    aSuppressWhiteSpaceOptimizations,
5371
                                    styleContext,
5371
                                    aStyleContext,
5372
                                    flags, nullptr,
5372
                                    flags, aAnonChildren,
5373
                                    aItems);
5373
                                    aItems);
5374
}
5374
}
5375
5375
5376
void
5376
void
5377
nsCSSFrameConstructor::AddFrameConstructionItems(nsFrameConstructorState& aState,
5378
                                                 nsIContent* aContent,
5379
                                                 bool aSuppressWhiteSpaceOptimizations,
5380
                                                 const InsertionPoint& aInsertion,
5381
                                                 FrameConstructionItemList& aItems)
5382
{
5383
  nsContainerFrame* parentFrame = aInsertion.mParentFrame;
5384
  if (!ShouldCreateItemsForChild(aState, aContent, parentFrame)) {
5385
    return;
5386
  }
5387
  nsRefPtr<nsStyleContext> styleContext =
5388
    ResolveStyleContext(parentFrame, aContent, &aState);
5389
  DoAddFrameConstructionItems(aState, aContent, styleContext,
5390
                              aSuppressWhiteSpaceOptimizations, parentFrame,
5391
                              nullptr, aItems);
5392
}
5393
5394
void
5377
nsCSSFrameConstructor::SetAsUndisplayedContent(nsFrameConstructorState& aState,
5395
nsCSSFrameConstructor::SetAsUndisplayedContent(nsFrameConstructorState& aState,
5378
                                               FrameConstructionItemList& aList,
5396
                                               FrameConstructionItemList& aList,
5379
                                               nsIContent* aContent,
5397
                                               nsIContent* aContent,
5380
                                               nsStyleContext* aStyleContext,
5398
                                               nsStyleContext* aStyleContext,
5381
                                               bool aIsGeneratedContent)
5399
                                               bool aIsGeneratedContent)
5382
{
5400
{
5383
  if (aStyleContext->GetPseudo()) {
5401
  if (aStyleContext->GetPseudo()) {
5384
    if (aIsGeneratedContent) {
5402
    if (aIsGeneratedContent) {
 Lines 5577-5592   nsCSSFrameConstructor::AddFrameConstruct Link Here 
5577
    !display->IsAbsolutelyPositionedStyle() &&
5595
    !display->IsAbsolutelyPositionedStyle() &&
5578
    !(bits & FCDATA_IS_TABLE_PART) &&
5596
    !(bits & FCDATA_IS_TABLE_PART) &&
5579
    !(bits & FCDATA_IS_SVG_TEXT);
5597
    !(bits & FCDATA_IS_SVG_TEXT);
5580
5598
5581
  if (canHavePageBreak && display->mBreakBefore) {
5599
  if (canHavePageBreak && display->mBreakBefore) {
5582
    AddPageBreakItem(aContent, aStyleContext, aItems);
5600
    AddPageBreakItem(aContent, aStyleContext, aItems);
5583
  }
5601
  }
5584
5602
5603
  if (MOZ_UNLIKELY(bits & FCDATA_IS_CONTENTS)) {
5604
    if (!GetDisplayContentsStyleFor(aContent)) {
5605
      MOZ_ASSERT(styleContext->GetPseudo() || !isGeneratedContent,
5606
                 "Should have had pseudo type");
5607
      aState.mFrameManager->SetDisplayContents(aContent, styleContext);
5608
    } else {
5609
      aState.mFrameManager->ChangeDisplayContents(aContent, styleContext);
5610
    }
5611
5612
    TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext);
5613
    if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) {
5614
      ancestorPusher.PushAncestorAndStyleScope(aContent->AsElement());
5615
    } else {
5616
      ancestorPusher.PushStyleScope(aContent->AsElement());
5617
    }
5618
5619
    if (aParentFrame) {
5620
      aParentFrame->AddStateBits(NS_FRAME_MAY_HAVE_GENERATED_CONTENT);
5621
    }
5622
    CreateGeneratedContentItem(aState, aParentFrame, aContent, styleContext,
5623
                               nsCSSPseudoElements::ePseudo_before, aItems);
5624
5625
    FlattenedChildIterator iter(aContent);
5626
    for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
5627
      if (!ShouldCreateItemsForChild(aState, child, aParentFrame)) {
5628
        continue;
5629
      }
5630
5631
      // Get the parent of the content and check if it is a XBL children element
5632
      // (if the content is a children element then parent != aContent because the
5633
      // FlattenedChildIterator will transitively iterate through <xbl:children>
5634
      // for default content). Push the children element as an ancestor here because
5635
      // it does not have a frame and would not otherwise be pushed as an ancestor.
5636
      nsIContent* parent = child->GetParent();
5637
      MOZ_ASSERT(parent, "Parent must be non-null because we are iterating children.");
5638
      TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext);
5639
      if (parent != aContent && parent->IsElement()) {
5640
        if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) {
5641
          ancestorPusher.PushAncestorAndStyleScope(parent->AsElement());
5642
        } else {
5643
          ancestorPusher.PushStyleScope(parent->AsElement());
5644
        }
5645
      }
5646
5647
      nsRefPtr<nsStyleContext> childContext =
5648
        ResolveStyleContext(styleContext, child, nullptr);
5649
      DoAddFrameConstructionItems(aState, child, childContext,
5650
                                  aSuppressWhiteSpaceOptimizations,
5651
                                  aParentFrame, aAnonChildren, aItems);
5652
    }
5653
    aItems.SetParentHasNoXBLChildren(!iter.XBLInvolved());
5654
5655
    CreateGeneratedContentItem(aState, aParentFrame, aContent, styleContext,
5656
                               nsCSSPseudoElements::ePseudo_after, aItems);
5657
    if (canHavePageBreak && display->mBreakAfter) {
5658
      AddPageBreakItem(aContent, aStyleContext, aItems);
5659
    }
5660
    return;
5661
  }
5662
5585
  FrameConstructionItem* item =
5663
  FrameConstructionItem* item =
5586
    aItems.AppendItem(data, aContent, aTag, aNameSpaceID,
5664
    aItems.AppendItem(data, aContent, aTag, aNameSpaceID,
5587
                      pendingBinding, styleContext.forget(),
5665
                      pendingBinding, styleContext.forget(),
5588
                      aSuppressWhiteSpaceOptimizations, aAnonChildren);
5666
                      aSuppressWhiteSpaceOptimizations, aAnonChildren);
5589
  if (!item) {
5667
  if (!item) {
5590
    if (isGeneratedContent) {
5668
    if (isGeneratedContent) {
5591
      aContent->UnbindFromTree();
5669
      aContent->UnbindFromTree();
5592
    }
5670
    }
 Lines 5939-5969   nsCSSFrameConstructor::GetFloatContainin Link Here 
5939
6017
5940
/**
6018
/**
5941
 * This function will check whether aContainer has :after generated content.
6019
 * This function will check whether aContainer has :after generated content.
5942
 * If so, appending to it should actually insert.  The return value is the
6020
 * If so, appending to it should actually insert.  The return value is the
5943
 * parent to use for newly-appended content.  *aAfterFrame points to the :after
6021
 * parent to use for newly-appended content.  *aAfterFrame points to the :after
5944
 * frame before which appended content should go, if there is one.
6022
 * frame before which appended content should go, if there is one.
5945
 */
6023
 */
5946
static nsContainerFrame*
6024
static nsContainerFrame*
5947
AdjustAppendParentForAfterContent(nsPresContext* aPresContext,
6025
AdjustAppendParentForAfterContent(nsFrameManager* aFrameManager,
5948
                                  nsIContent* aContainer,
6026
                                  nsIContent* aContainer,
5949
                                  nsContainerFrame* aParentFrame,
6027
                                  nsContainerFrame* aParentFrame,
6028
                                  nsIContent* aChild,
5950
                                  nsIFrame** aAfterFrame)
6029
                                  nsIFrame** aAfterFrame)
5951
{
6030
{
5952
  // See if the parent has an :after pseudo-element.  Check for the presence
6031
  // If the parent frame has any pseudo-elements or aContainer is a
5953
  // of style first, since nsLayoutUtils::GetAfterFrame is sorta expensive.
6032
  // display:contents node then we need to walk through the child
5954
  nsStyleContext* parentStyle = aParentFrame->StyleContext();
6033
  // frames to find the first one that is either a ::after frame for an
5955
  if (nsLayoutUtils::HasPseudoStyle(aContainer, parentStyle,
6034
  // ancestor of aChild or a frame that is for a node later in the
6035
  // document than aChild and return that in aAfterFrame.
6036
  if (GetGenConPseudos(aParentFrame) ||
6037
      nsLayoutUtils::HasPseudoStyle(aContainer, aParentFrame->StyleContext(),
5956
                                    nsCSSPseudoElements::ePseudo_after,
6038
                                    nsCSSPseudoElements::ePseudo_after,
5957
                                    aPresContext)) {
6039
                                    aParentFrame->PresContext()) ||
5958
    // Ensure that the :after frame is on the principal child list.
6040
      aFrameManager->GetDisplayContentsStyleFor(aContainer)) {
5959
    aParentFrame->DrainSelfOverflowList();
6041
    nsIFrame* afterFrame = nullptr;
5960
6042
    nsContainerFrame* parent =
5961
    nsIFrame* afterFrame = nsLayoutUtils::GetAfterFrame(aParentFrame);
6043
      static_cast<nsContainerFrame*>(aParentFrame->LastContinuation());
6044
    bool done = false;
6045
    while (!done && parent) {
6046
      // Ensure that all normal flow children are on the principal child list.
6047
      parent->DrainSelfOverflowList();
6048
6049
      nsIFrame* child = parent->GetLastChild(nsIFrame::kPrincipalList);
6050
      if (child && child->IsPseudoFrame(aContainer) &&
6051
          !child->IsGeneratedContentFrame()) {
6052
        // Drill down into non-generated pseudo frames of aContainer.
6053
        parent = nsLayoutUtils::LastContinuationWithChild(do_QueryFrame(child));
6054
        continue;
6055
      }
6056
6057
      for (; child; child = child->GetPrevSibling()) {
6058
        nsIContent* c = child->GetContent();
6059
        if (child->IsGeneratedContentFrame()) {
6060
          nsIContent* p = c->GetParent();
6061
          if (c->Tag() == nsGkAtoms::mozgeneratedcontentafter) {
6062
            if (!nsContentUtils::ContentIsDescendantOf(aChild, p) &&
6063
                p != aContainer &&
6064
                nsContentUtils::PositionIsBefore(p, aChild)) {
6065
              // ::after generated content for content earlier in the doc and not
6066
              // for an ancestor.  "p != aContainer" may seem redundant but it
6067
              // checks if the ::after belongs to the XBL insertion point we're
6068
              // inserting aChild into (in which case ContentIsDescendantOf is
6069
              // false even though p == aContainer).
6070
              // See layout/reftests/bugs/482592-1a.xhtml for an example of that.
6071
              done = true;
6072
              break;
6073
            }
6074
          } else if (nsContentUtils::PositionIsBefore(p, aChild)) {
6075
            // Non-::after generated content for content earlier in the doc.
6076
            done = true;
6077
            break;
6078
          }
6079
        } else if (nsContentUtils::PositionIsBefore(c, aChild)) {
6080
          // Content is before aChild.
6081
          done = true;
6082
          break;
6083
        }
6084
        afterFrame = child;
6085
      }
6086
6087
      parent = static_cast<nsContainerFrame*>(parent->GetPrevContinuation());
6088
    }
5962
    if (afterFrame) {
6089
    if (afterFrame) {
5963
      *aAfterFrame = afterFrame;
6090
      *aAfterFrame = afterFrame;
5964
      return afterFrame->GetParent();
6091
      return afterFrame->GetParent();
5965
    }
6092
    }
5966
  }
6093
  }
5967
6094
5968
  *aAfterFrame = nullptr;
6095
  *aAfterFrame = nullptr;
5969
6096
 Lines 6333-6349   nsCSSFrameConstructor::GetInsertionPrevS Link Here 
6333
  NS_PRECONDITION(aInsertion->mParentFrame, "Must have parent frame to start with");
6460
  NS_PRECONDITION(aInsertion->mParentFrame, "Must have parent frame to start with");
6334
6461
6335
  *aIsAppend = false;
6462
  *aIsAppend = false;
6336
6463
6337
  // Find the frame that precedes the insertion point. Walk backwards
6464
  // Find the frame that precedes the insertion point. Walk backwards
6338
  // from the parent frame to get the parent content, because if an
6465
  // from the parent frame to get the parent content, because if an
6339
  // XBL insertion point is involved, we'll need to use _that_ to find
6466
  // XBL insertion point is involved, we'll need to use _that_ to find
6340
  // the preceding frame.
6467
  // the preceding frame.
6341
  nsIContent* container = aInsertion->mParentFrame->GetContent();
6468
  const bool boxContents = GetDisplayContentsStyleFor(aInsertion->mContainer);
6469
  nsIContent* container = boxContents ? aInsertion->mContainer : aInsertion->mParentFrame->GetContent();
6342
6470
6343
  FlattenedChildIterator iter(container);
6471
  FlattenedChildIterator iter(container);
6344
  bool xblCase = iter.XBLInvolved() || container != aInsertion->mContainer;
6472
  bool xblCase = iter.XBLInvolved() || container != aInsertion->mContainer;
6345
  if (xblCase || !aChild->IsRootOfAnonymousSubtree()) {
6473
  if (xblCase || !aChild->IsRootOfAnonymousSubtree()) {
6346
    // The check for IsRootOfAnonymousSubtree() is because editor is
6474
    // The check for IsRootOfAnonymousSubtree() is because editor is
6347
    // severely broken and calls us directly for native anonymous
6475
    // severely broken and calls us directly for native anonymous
6348
    // nodes that it creates.
6476
    // nodes that it creates.
6349
    if (aStartSkipChild) {
6477
    if (aStartSkipChild) {
 Lines 6363-6391   nsCSSFrameConstructor::GetInsertionPrevS Link Here 
6363
  uint8_t childDisplay = UNSET_DISPLAY;
6491
  uint8_t childDisplay = UNSET_DISPLAY;
6364
  nsIFrame* prevSibling = FindPreviousSibling(iter, childDisplay);
6492
  nsIFrame* prevSibling = FindPreviousSibling(iter, childDisplay);
6365
6493
6366
  // Now, find the geometric parent so that we can handle
6494
  // Now, find the geometric parent so that we can handle
6367
  // continuations properly. Use the prev sibling if we have it;
6495
  // continuations properly. Use the prev sibling if we have it;
6368
  // otherwise use the next sibling.
6496
  // otherwise use the next sibling.
6369
  if (prevSibling) {
6497
  if (prevSibling) {
6370
    aInsertion->mParentFrame = prevSibling->GetParent()->GetContentInsertionFrame();
6498
    aInsertion->mParentFrame = prevSibling->GetParent()->GetContentInsertionFrame();
6371
  }
6499
  } else {
6372
  else {
6373
    // If there is no previous sibling, then find the frame that follows
6500
    // If there is no previous sibling, then find the frame that follows
6374
    if (aEndSkipChild) {
6501
    if (aEndSkipChild) {
6375
      iter.Seek(aEndSkipChild);
6502
      iter.Seek(aEndSkipChild);
6376
      iter.GetPreviousChild();
6503
      iter.GetPreviousChild();
6377
    }
6504
    }
6378
    nsIFrame* nextSibling = FindNextSibling(iter, childDisplay);
6505
    nsIFrame* nextSibling = FindNextSibling(iter, childDisplay);
6379
6506
    if (boxContents) {
6507
      if (nextSibling) {
6508
        aInsertion->mParentFrame = nextSibling->GetParent()->GetContentInsertionFrame();
6509
        return nextSibling->GetPrevSibling();
6510
      }
6511
      nsIContent* child = aInsertion->mContainer;
6512
      InsertionPoint fakeInsertion(aInsertion->mParentFrame, child->GetParent());
6513
      nsIFrame* result = GetInsertionPrevSibling(&fakeInsertion, child, aIsAppend,
6514
                                                 aIsRangeInsertSafe, nullptr, nullptr);
6515
      aInsertion->mParentFrame = fakeInsertion.mParentFrame;
6516
      return result;
6517
    }
6380
    if (nextSibling) {
6518
    if (nextSibling) {
6381
      aInsertion->mParentFrame = nextSibling->GetParent()->GetContentInsertionFrame();
6519
      aInsertion->mParentFrame = nextSibling->GetParent()->GetContentInsertionFrame();
6382
    }
6520
    } else {
6383
    else {
6384
      // No previous or next sibling, so treat this like an appended frame.
6521
      // No previous or next sibling, so treat this like an appended frame.
6385
      *aIsAppend = true;
6522
      *aIsAppend = true;
6386
      if (IsFramePartOfIBSplit(aInsertion->mParentFrame)) {
6523
      if (IsFramePartOfIBSplit(aInsertion->mParentFrame)) {
6387
        // Since we're appending, we'll walk to the last anonymous frame
6524
        // Since we're appending, we'll walk to the last anonymous frame
6388
        // that was created for the broken inline frame.  But don't walk
6525
        // that was created for the broken inline frame.  But don't walk
6389
        // to the trailing inline if it's empty; stop at the block.
6526
        // to the trailing inline if it's empty; stop at the block.
6390
        aInsertion->mParentFrame =
6527
        aInsertion->mParentFrame =
6391
          GetLastIBSplitSibling(aInsertion->mParentFrame, false);
6528
          GetLastIBSplitSibling(aInsertion->mParentFrame, false);
 Lines 6396-6422   nsCSSFrameConstructor::GetInsertionPrevS Link Here 
6396
        nsLayoutUtils::LastContinuationWithChild(aInsertion->mParentFrame);
6533
        nsLayoutUtils::LastContinuationWithChild(aInsertion->mParentFrame);
6397
      // Deal with fieldsets
6534
      // Deal with fieldsets
6398
      aInsertion->mParentFrame =
6535
      aInsertion->mParentFrame =
6399
        ::GetAdjustedParentFrame(aInsertion->mParentFrame,
6536
        ::GetAdjustedParentFrame(aInsertion->mParentFrame,
6400
                                 aInsertion->mParentFrame->GetType(),
6537
                                 aInsertion->mParentFrame->GetType(),
6401
                                 aChild);
6538
                                 aChild);
6402
      nsIFrame* appendAfterFrame;
6539
      nsIFrame* appendAfterFrame;
6403
      aInsertion->mParentFrame =
6540
      aInsertion->mParentFrame =
6404
        ::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(),
6541
        ::AdjustAppendParentForAfterContent(this, container,
6405
                                            container, aInsertion->mParentFrame,
6542
                                            aInsertion->mParentFrame,
6406
                                            &appendAfterFrame);
6543
                                            aChild, &appendAfterFrame);
6407
      prevSibling = ::FindAppendPrevSibling(aInsertion->mParentFrame, appendAfterFrame);
6544
      prevSibling = ::FindAppendPrevSibling(aInsertion->mParentFrame, appendAfterFrame);
6408
    }
6545
    }
6409
  }
6546
  }
6410
6547
6411
  *aIsRangeInsertSafe = (childDisplay == UNSET_DISPLAY);
6548
  *aIsRangeInsertSafe = (childDisplay == UNSET_DISPLAY);
6412
  return prevSibling;
6549
  return prevSibling;
6413
}
6550
}
6414
6551
6552
nsContainerFrame*
6553
nsCSSFrameConstructor::GetContentInsertionFrameFor(nsIContent* aContent)
6554
{
6555
  // Get the primary frame associated with the content
6556
  nsIFrame* frame = aContent->GetPrimaryFrame();
6557
6558
  if (!frame) {
6559
    if (GetDisplayContentsStyleFor(aContent)) {
6560
      nsIContent* parent = aContent->GetParent();
6561
      frame = parent ? GetContentInsertionFrameFor(parent) : nullptr;
6562
    }
6563
    if (!frame) {
6564
      return nullptr;
6565
    }
6566
  } else {
6567
    // If the content of the frame is not the desired content then this is not
6568
    // really a frame for the desired content.
6569
    // XXX This check is needed due to bug 135040. Remove it once that's fixed.
6570
    if (frame->GetContent() != aContent) {
6571
      return nullptr;
6572
    }
6573
  }
6574
6575
  nsContainerFrame* insertionFrame = frame->GetContentInsertionFrame();
6576
6577
  NS_ASSERTION(!insertionFrame || insertionFrame == frame || !frame->IsLeaf(),
6578
    "The insertion frame is the primary frame or the primary frame isn't a leaf");
6579
6580
  return insertionFrame;
6581
}
6582
6415
static bool
6583
static bool
6416
IsSpecialFramesetChild(nsIContent* aContent)
6584
IsSpecialFramesetChild(nsIContent* aContent)
6417
{
6585
{
6418
  // IMPORTANT: This must match the conditions in nsHTMLFramesetFrame::Init.
6586
  // IMPORTANT: This must match the conditions in nsHTMLFramesetFrame::Init.
6419
  return aContent->IsHTML() &&
6587
  return aContent->IsHTML() &&
6420
    (aContent->Tag() == nsGkAtoms::frameset ||
6588
    (aContent->Tag() == nsGkAtoms::frameset ||
6421
     aContent->Tag() == nsGkAtoms::frame);
6589
     aContent->Tag() == nsGkAtoms::frame);
6422
}
6590
}
 Lines 6544-6559   nsCSSFrameConstructor::MaybeConstructLaz Link Here 
6544
    }
6712
    }
6545
    if (!noPrimaryFrame && !content->GetPrimaryFrame()) {
6713
    if (!noPrimaryFrame && !content->GetPrimaryFrame()) {
6546
      noPrimaryFrame = true;
6714
      noPrimaryFrame = true;
6547
    }
6715
    }
6548
    if (!needsFrameBitSet && content->HasFlag(NODE_NEEDS_FRAME)) {
6716
    if (!needsFrameBitSet && content->HasFlag(NODE_NEEDS_FRAME)) {
6549
      needsFrameBitSet = true;
6717
      needsFrameBitSet = true;
6550
    }
6718
    }
6551
#endif
6719
#endif
6720
    // XXXmats no lazy frames for display:contents descendants yet (bug 979782).
6721
    if (GetDisplayContentsStyleFor(content)) {
6722
      return false;
6723
    }
6552
    content->SetFlags(NODE_DESCENDANTS_NEED_FRAMES);
6724
    content->SetFlags(NODE_DESCENDANTS_NEED_FRAMES);
6553
    content = content->GetFlattenedTreeParent();
6725
    content = content->GetFlattenedTreeParent();
6554
  }
6726
  }
6555
#ifdef DEBUG
6727
#ifdef DEBUG
6556
  if (content && content->GetPrimaryFrame() &&
6728
  if (content && content->GetPrimaryFrame() &&
6557
      content->GetPrimaryFrame()->IsLeaf()) {
6729
      content->GetPrimaryFrame()->IsLeaf()) {
6558
    noPrimaryFrame = needsFrameBitSet = false;
6730
    noPrimaryFrame = needsFrameBitSet = false;
6559
  }
6731
  }
 Lines 6666-6683   void Link Here 
6666
nsCSSFrameConstructor::IssueSingleInsertNofications(nsIContent* aContainer,
6838
nsCSSFrameConstructor::IssueSingleInsertNofications(nsIContent* aContainer,
6667
                                                    nsIContent* aStartChild,
6839
                                                    nsIContent* aStartChild,
6668
                                                    nsIContent* aEndChild,
6840
                                                    nsIContent* aEndChild,
6669
                                                    bool aAllowLazyConstruction)
6841
                                                    bool aAllowLazyConstruction)
6670
{
6842
{
6671
  for (nsIContent* child = aStartChild;
6843
  for (nsIContent* child = aStartChild;
6672
       child != aEndChild;
6844
       child != aEndChild;
6673
       child = child->GetNextSibling()) {
6845
       child = child->GetNextSibling()) {
6674
    if ((child->GetPrimaryFrame() ||
6846
    if ((child->GetPrimaryFrame() || GetUndisplayedContent(child) ||
6675
         GetUndisplayedContent(child))
6847
         GetDisplayContentsStyleFor(child))
6676
#ifdef MOZ_XUL
6848
#ifdef MOZ_XUL
6677
        //  Except listboxes suck, so do NOT skip anything here if
6849
        //  Except listboxes suck, so do NOT skip anything here if
6678
        //  we plan to notify a listbox.
6850
        //  we plan to notify a listbox.
6679
        && !MaybeGetListBoxBodyFrame(aContainer, child)
6851
        && !MaybeGetListBoxBodyFrame(aContainer, child)
6680
#endif
6852
#endif
6681
        ) {
6853
        ) {
6682
      // Already have a frame or undisplayed entry for this content; a
6854
      // Already have a frame or undisplayed entry for this content; a
6683
      // previous ContentInserted in this loop must have reconstructed
6855
      // previous ContentInserted in this loop must have reconstructed
 Lines 6829-6845   nsCSSFrameConstructor::ContentAppended(n Link Here 
6829
    nsIContent* bindingParent = aContainer->GetBindingParent();
7001
    nsIContent* bindingParent = aContainer->GetBindingParent();
6830
    LAYOUT_PHASE_TEMP_EXIT();
7002
    LAYOUT_PHASE_TEMP_EXIT();
6831
    nsresult rv = RecreateFramesForContent(bindingParent, false);
7003
    nsresult rv = RecreateFramesForContent(bindingParent, false);
6832
    LAYOUT_PHASE_TEMP_REENTER();
7004
    LAYOUT_PHASE_TEMP_REENTER();
6833
    return rv;
7005
    return rv;
6834
  }
7006
  }
6835
7007
6836
  // Get the frame associated with the content
7008
  // Get the frame associated with the content
6837
  nsContainerFrame* parentFrame = ::GetContentInsertionFrameFor(aContainer);
7009
  nsContainerFrame* parentFrame = GetContentInsertionFrameFor(aContainer);
6838
7010
6839
  // See comment in ContentRangeInserted for why this is necessary.
7011
  // See comment in ContentRangeInserted for why this is necessary.
6840
  if (!parentFrame && !aContainer->IsActiveChildrenElement()) {
7012
  if (!parentFrame && !aContainer->IsActiveChildrenElement()) {
6841
    return NS_OK;
7013
    return NS_OK;
6842
  }
7014
  }
6843
7015
6844
  if (aAllowLazyConstruction &&
7016
  if (aAllowLazyConstruction &&
6845
      MaybeConstructLazily(CONTENTAPPEND, aContainer, aFirstNewContent)) {
7017
      MaybeConstructLazily(CONTENTAPPEND, aContainer, aFirstNewContent)) {
 Lines 6903-6921   nsCSSFrameConstructor::ContentAppended(n Link Here 
6903
  // We should never get here with fieldsets, since they have multiple
7075
  // We should never get here with fieldsets, since they have multiple
6904
  // insertion points.
7076
  // insertion points.
6905
  NS_ASSERTION(parentFrame->GetType() != nsGkAtoms::fieldSetFrame,
7077
  NS_ASSERTION(parentFrame->GetType() != nsGkAtoms::fieldSetFrame,
6906
               "Unexpected parent");
7078
               "Unexpected parent");
6907
7079
6908
  // Deal with possible :after generated content on the parent
7080
  // Deal with possible :after generated content on the parent
6909
  nsIFrame* parentAfterFrame;
7081
  nsIFrame* parentAfterFrame;
6910
  parentFrame =
7082
  parentFrame =
6911
    ::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(),
7083
    ::AdjustAppendParentForAfterContent(this, insertion.mContainer, parentFrame,
6912
                                        insertion.mContainer, parentFrame,
7084
                                        aFirstNewContent, &parentAfterFrame);
6913
                                        &parentAfterFrame);
6914
7085
6915
  // Create some new frames
7086
  // Create some new frames
6916
  nsFrameConstructorState state(mPresShell,
7087
  nsFrameConstructorState state(mPresShell,
6917
                                GetAbsoluteContainingBlock(parentFrame, FIXED_POS),
7088
                                GetAbsoluteContainingBlock(parentFrame, FIXED_POS),
6918
                                GetAbsoluteContainingBlock(parentFrame, ABS_POS),
7089
                                GetAbsoluteContainingBlock(parentFrame, ABS_POS),
6919
                                GetFloatContainingBlock(parentFrame));
7090
                                GetFloatContainingBlock(parentFrame));
6920
  state.mTreeMatchContext.InitAncestors(aContainer->AsElement());
7091
  state.mTreeMatchContext.InitAncestors(aContainer->AsElement());
6921
7092
 Lines 7269-7295   nsCSSFrameConstructor::ContentRangeInser Link Here 
7269
    nsIContent* bindingParent = aContainer->GetBindingParent();
7440
    nsIContent* bindingParent = aContainer->GetBindingParent();
7270
    LAYOUT_PHASE_TEMP_EXIT();
7441
    LAYOUT_PHASE_TEMP_EXIT();
7271
    nsresult rv = RecreateFramesForContent(bindingParent, false);
7442
    nsresult rv = RecreateFramesForContent(bindingParent, false);
7272
    LAYOUT_PHASE_TEMP_REENTER();
7443
    LAYOUT_PHASE_TEMP_REENTER();
7273
    return rv;
7444
    return rv;
7274
  }
7445
  }
7275
7446
7276
  {
7447
  {
7277
    nsContainerFrame* parentFrame = ::GetContentInsertionFrameFor(aContainer);
7448
    nsContainerFrame* parentFrame = GetContentInsertionFrameFor(aContainer);
7278
    // The xbl:children element won't have a frame, but default content can have the children as
7449
    // The xbl:children element won't have a frame, but default content can have the children as
7279
    // a parent. While its uncommon to change the structure of the default content itself, a label,
7450
    // a parent. While its uncommon to change the structure of the default content itself, a label,
7280
    // for example, can be reframed by having its value attribute set or removed.
7451
    // for example, can be reframed by having its value attribute set or removed.
7281
    if (!parentFrame && !aContainer->IsActiveChildrenElement()) {
7452
    if (!parentFrame && !aContainer->IsActiveChildrenElement()) {
7282
      return NS_OK;
7453
      return NS_OK;
7283
    }
7454
    }
7284
7455
7285
    // Otherwise, we've got parent content. Find its frame.
7456
    // Otherwise, we've got parent content. Find its frame.
7286
    NS_ASSERTION(!parentFrame || parentFrame->GetContent() == aContainer,
7457
    NS_ASSERTION(!parentFrame || parentFrame->GetContent() == aContainer ||
7287
                 "New XBL code is possibly wrong!");
7458
                 GetDisplayContentsStyleFor(aContainer), "New XBL code is possibly wrong!");
7288
7459
7289
    if (aAllowLazyConstruction &&
7460
    if (aAllowLazyConstruction &&
7290
        MaybeConstructLazily(CONTENTINSERT, aContainer, aStartChild)) {
7461
        MaybeConstructLazily(CONTENTINSERT, aContainer, aStartChild)) {
7291
      return NS_OK;
7462
      return NS_OK;
7292
    }
7463
    }
7293
  }
7464
  }
7294
7465
7295
  InsertionPoint insertion;
7466
  InsertionPoint insertion;
 Lines 7566-7585   nsCSSFrameConstructor::ContentRangeInser Link Here 
7566
                 frame1->GetType() == nsGkAtoms::fieldSetFrame ||
7737
                 frame1->GetType() == nsGkAtoms::fieldSetFrame ||
7567
                 (frame1->GetParent() &&
7738
                 (frame1->GetParent() &&
7568
                  frame1->GetParent()->GetType() == nsGkAtoms::fieldSetFrame),
7739
                  frame1->GetParent()->GetType() == nsGkAtoms::fieldSetFrame),
7569
                 "Unexpected frame types");
7740
                 "Unexpected frame types");
7570
#endif
7741
#endif
7571
    isAppend = true;
7742
    isAppend = true;
7572
    nsIFrame* appendAfterFrame;
7743
    nsIFrame* appendAfterFrame;
7573
    insertion.mParentFrame =
7744
    insertion.mParentFrame =
7574
      ::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(),
7745
      ::AdjustAppendParentForAfterContent(this, container,
7575
                                          container,
7576
                                          frameItems.FirstChild()->GetParent(),
7746
                                          frameItems.FirstChild()->GetParent(),
7577
                                          &appendAfterFrame);
7747
                                          aStartChild, &appendAfterFrame);
7578
    prevSibling = ::FindAppendPrevSibling(insertion.mParentFrame, appendAfterFrame);
7748
    prevSibling = ::FindAppendPrevSibling(insertion.mParentFrame, appendAfterFrame);
7579
  }
7749
  }
7580
7750
7581
  if (haveFirstLineStyle && insertion.mParentFrame == containingBlock) {
7751
  if (haveFirstLineStyle && insertion.mParentFrame == containingBlock) {
7582
    // It's possible that the new frame goes into a first-line
7752
    // It's possible that the new frame goes into a first-line
7583
    // frame. Look at it and see...
7753
    // frame. Look at it and see...
7584
    if (isAppend) {
7754
    if (isAppend) {
7585
      // Use append logic when appending
7755
      // Use append logic when appending
 Lines 7710-7737   nsCSSFrameConstructor::ContentRemoved(ns Link Here 
7710
           static_cast<void*>(aChild),
7880
           static_cast<void*>(aChild),
7711
           static_cast<void*>(aOldNextSibling));
7881
           static_cast<void*>(aOldNextSibling));
7712
    if (gReallyNoisyContentUpdates) {
7882
    if (gReallyNoisyContentUpdates) {
7713
      aContainer->List(stdout, 0);
7883
      aContainer->List(stdout, 0);
7714
    }
7884
    }
7715
  }
7885
  }
7716
#endif
7886
#endif
7717
7887
7718
  nsPresContext *presContext = mPresShell->GetPresContext();
7888
  nsresult rv = NS_OK;
7719
  nsresult                  rv = NS_OK;
7720
7721
  // Find the child frame that maps the content
7722
  nsIFrame* childFrame = aChild->GetPrimaryFrame();
7889
  nsIFrame* childFrame = aChild->GetPrimaryFrame();
7723
7724
  if (!childFrame || childFrame->GetContent() != aChild) {
7890
  if (!childFrame || childFrame->GetContent() != aChild) {
7725
    // XXXbz the GetContent() != aChild check is needed due to bug 135040.
7891
    // XXXbz the GetContent() != aChild check is needed due to bug 135040.
7726
    // Remove it once that's fixed.
7892
    // Remove it once that's fixed.
7727
    ClearUndisplayedContentIn(aChild, aContainer);
7893
    ClearUndisplayedContentIn(aChild, aContainer);
7728
  }
7894
  }
7729
7895
  MOZ_ASSERT(!childFrame || !GetDisplayContentsStyleFor(aChild),
7896
             "display:contents nodes shouldn't have a frame");
7897
  if (!childFrame && GetDisplayContentsStyleFor(aChild)) {
7898
    FlattenedChildIterator iter(aChild);
7899
    for (nsIContent* c = iter.GetNextChild(); c; c = iter.GetNextChild()) {
7900
      if (c->GetPrimaryFrame() || GetDisplayContentsStyleFor(c)) {
7901
        LAYOUT_PHASE_TEMP_EXIT();
7902
        rv = ContentRemoved(aChild, c, nullptr, aFlags, aDidReconstruct);
7903
        LAYOUT_PHASE_TEMP_REENTER();
7904
        NS_ENSURE_SUCCESS(rv, rv);
7905
        if (*aDidReconstruct) {
7906
          return rv;
7907
        }
7908
      }
7909
    }
7910
    ClearDisplayContentsIn(aChild, aContainer);
7911
  }
7912
7913
  nsPresContext* presContext = mPresShell->GetPresContext();
7730
#ifdef MOZ_XUL
7914
#ifdef MOZ_XUL
7731
  if (NotifyListBoxBody(presContext, aContainer, aChild, aOldNextSibling,
7915
  if (NotifyListBoxBody(presContext, aContainer, aChild, aOldNextSibling,
7732
                        mDocument, childFrame, CONTENT_REMOVED))
7916
                        mDocument, childFrame, CONTENT_REMOVED))
7733
    return NS_OK;
7917
    return NS_OK;
7734
7918
7735
#endif // MOZ_XUL
7919
#endif // MOZ_XUL
7736
7920
7737
  // If we're removing the root, then make sure to remove things starting at
7921
  // If we're removing the root, then make sure to remove things starting at
(-)a/layout/base/nsCSSFrameConstructor.h (+27 lines)
Line     Link Here 
 Lines 320-335   private: Link Here 
320
  // may suppress the construction of white-space-only text frames
320
  // may suppress the construction of white-space-only text frames
321
  // must be skipped for these items and items around them.
321
  // must be skipped for these items and items around them.
322
  void AddFrameConstructionItems(nsFrameConstructorState& aState,
322
  void AddFrameConstructionItems(nsFrameConstructorState& aState,
323
                                 nsIContent*              aContent,
323
                                 nsIContent*              aContent,
324
                                 bool                     aSuppressWhiteSpaceOptimizations,
324
                                 bool                     aSuppressWhiteSpaceOptimizations,
325
                                 const InsertionPoint&    aInsertion,
325
                                 const InsertionPoint&    aInsertion,
326
                                 FrameConstructionItemList& aItems);
326
                                 FrameConstructionItemList& aItems);
327
327
328
  // Helper method for AddFrameConstructionItems etc.
329
  // Unsets the need-frame/restyle bits on aContent.
330
  // return true iff we should attempt to create frames for aContent.
331
  bool ShouldCreateItemsForChild(nsFrameConstructorState& aState,
332
                                 nsIContent* aContent,
333
                                 nsContainerFrame* aParentFrame);
334
335
  // Helper method for AddFrameConstructionItems etc.
336
  // Make sure ShouldCreateItemsForChild() returned true before calling this.
337
  void DoAddFrameConstructionItems(nsFrameConstructorState& aState,
338
                                   nsIContent* aContent,
339
                                   nsStyleContext* aStyleContext,
340
                                   bool aSuppressWhiteSpaceOptimizations,
341
                                   nsContainerFrame* aParentFrame,
342
                                   nsTArray<nsIAnonymousContentCreator::ContentInfo>* aAnonChildren,
343
                                   FrameConstructionItemList& aItems);
344
328
  // Construct the frames for the document element.  This can return null if the
345
  // Construct the frames for the document element.  This can return null if the
329
  // document element is display:none, or if the document element has a
346
  // document element is display:none, or if the document element has a
330
  // not-yet-loaded XBL binding, or if it's an SVG element that's not <svg>.
347
  // not-yet-loaded XBL binding, or if it's an SVG element that's not <svg>.
331
  nsIFrame* ConstructDocElementFrame(Element*                 aDocElement,
348
  nsIFrame* ConstructDocElementFrame(Element*                 aDocElement,
332
                                     nsILayoutHistoryState*   aFrameState);
349
                                     nsILayoutHistoryState*   aFrameState);
333
350
334
  // Set up our mDocElementContainingBlock correctly for the given root
351
  // Set up our mDocElementContainingBlock correctly for the given root
335
  // content.
352
  // content.
 Lines 611-626   private: Link Here 
611
  /* If FCDATA_CREATE_BLOCK_WRAPPER_FOR_ALL_KIDS is set, then create a
628
  /* If FCDATA_CREATE_BLOCK_WRAPPER_FOR_ALL_KIDS is set, then create a
612
     block formatting context wrapper around the kids of this frame
629
     block formatting context wrapper around the kids of this frame
613
     using the FrameConstructionData's mPseudoAtom for its anonymous
630
     using the FrameConstructionData's mPseudoAtom for its anonymous
614
     box type. */
631
     box type. */
615
#define FCDATA_CREATE_BLOCK_WRAPPER_FOR_ALL_KIDS 0x40000
632
#define FCDATA_CREATE_BLOCK_WRAPPER_FOR_ALL_KIDS 0x40000
616
  /* If FCDATA_IS_SVG_TEXT is set, then this text frame is a descendant of
633
  /* If FCDATA_IS_SVG_TEXT is set, then this text frame is a descendant of
617
     an SVG text frame. */
634
     an SVG text frame. */
618
#define FCDATA_IS_SVG_TEXT 0x80000
635
#define FCDATA_IS_SVG_TEXT 0x80000
636
  /**
637
   * display:contents
638
   */
639
#define FCDATA_IS_CONTENTS 0x100000
619
640
620
  /* Structure representing information about how a frame should be
641
  /* Structure representing information about how a frame should be
621
     constructed.  */
642
     constructed.  */
622
  struct FrameConstructionData {
643
  struct FrameConstructionData {
623
    // Flag bits that can modify the way the construction happens
644
    // Flag bits that can modify the way the construction happens
624
    uint32_t mBits;
645
    uint32_t mBits;
625
    // We have exactly one of three types of functions, so use a union for
646
    // We have exactly one of three types of functions, so use a union for
626
    // better cache locality for the ones that aren't pointer-to-member.  That
647
    // better cache locality for the ones that aren't pointer-to-member.  That
 Lines 1780-1795   private: Link Here 
1780
  // insertion points.
1801
  // insertion points.
1781
  nsIFrame* GetInsertionPrevSibling(InsertionPoint* aInsertion, // inout
1802
  nsIFrame* GetInsertionPrevSibling(InsertionPoint* aInsertion, // inout
1782
                                    nsIContent* aChild,
1803
                                    nsIContent* aChild,
1783
                                    bool* aIsAppend,
1804
                                    bool* aIsAppend,
1784
                                    bool* aIsRangeInsertSafe,
1805
                                    bool* aIsRangeInsertSafe,
1785
                                    nsIContent* aStartSkipChild = nullptr,
1806
                                    nsIContent* aStartSkipChild = nullptr,
1786
                                    nsIContent *aEndSkipChild = nullptr);
1807
                                    nsIContent *aEndSkipChild = nullptr);
1787
1808
1809
  /**
1810
   * Return the insertion frame of the primary frame of aContent, or its nearest
1811
   * ancestor that isn't display:contents.
1812
   */
1813
  nsContainerFrame* GetContentInsertionFrameFor(nsIContent* aContent);
1814
1788
  // see if aContent and aSibling are legitimate siblings due to restrictions
1815
  // see if aContent and aSibling are legitimate siblings due to restrictions
1789
  // imposed by table columns
1816
  // imposed by table columns
1790
  // XXXbz this code is generally wrong, since the frame for aContent
1817
  // XXXbz this code is generally wrong, since the frame for aContent
1791
  // may be constructed based on tag, not based on aDisplay!
1818
  // may be constructed based on tag, not based on aDisplay!
1792
  bool IsValidSibling(nsIFrame*              aSibling,
1819
  bool IsValidSibling(nsIFrame*              aSibling,
1793
                        nsIContent*            aContent,
1820
                        nsIContent*            aContent,
1794
                        uint8_t&               aDisplay);
1821
                        uint8_t&               aDisplay);
1795
1822

Return to bug 907396