nsStackFrame.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. //
  6. // Eric Vaughan
  7. // Netscape Communications
  8. //
  9. // See documentation in associated header file
  10. //
  11. #include "nsStackFrame.h"
  12. #include "nsStyleContext.h"
  13. #include "nsIContent.h"
  14. #include "nsCOMPtr.h"
  15. #include "nsHTMLParts.h"
  16. #include "nsIPresShell.h"
  17. #include "nsCSSRendering.h"
  18. #include "nsBoxLayoutState.h"
  19. #include "nsStackLayout.h"
  20. #include "nsDisplayList.h"
  21. nsIFrame*
  22. NS_NewStackFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
  23. {
  24. return new (aPresShell) nsStackFrame(aContext);
  25. }
  26. NS_IMPL_FRAMEARENA_HELPERS(nsStackFrame)
  27. nsStackFrame::nsStackFrame(nsStyleContext* aContext):
  28. nsBoxFrame(aContext)
  29. {
  30. nsCOMPtr<nsBoxLayout> layout;
  31. NS_NewStackLayout(layout);
  32. SetXULLayoutManager(layout);
  33. }
  34. // REVIEW: The old code put everything in the background layer. To be more
  35. // consistent with the way other frames work, I'm putting everything in the
  36. // Content() (i.e., foreground) layer (see nsFrame::BuildDisplayListForChild,
  37. // the case for stacking context but non-positioned, non-floating frames).
  38. // This could easily be changed back by hacking nsBoxFrame::BuildDisplayListInternal
  39. // a bit more.
  40. void
  41. nsStackFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
  42. const nsDisplayListSet& aLists)
  43. {
  44. // BuildDisplayListForChild puts stacking contexts into the PositionedDescendants
  45. // list. So we need to map that list to aLists.Content(). This is an easy way to
  46. // do that.
  47. nsDisplayList* content = aLists.Content();
  48. nsDisplayListSet kidLists(content, content, content, content, content, content);
  49. nsIFrame* kid = mFrames.FirstChild();
  50. while (kid) {
  51. // Force each child into its own true stacking context.
  52. BuildDisplayListForChild(aBuilder, kid, kidLists, DISPLAY_CHILD_FORCE_STACKING_CONTEXT);
  53. kid = kid->GetNextSibling();
  54. }
  55. }