1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* rendering object for CSS "display: ruby-text" */
9 #include "nsRubyTextFrame.h"
11 #include "mozilla/ComputedStyle.h"
12 #include "mozilla/PresShell.h"
13 #include "mozilla/WritingModes.h"
14 #include "nsLineLayout.h"
15 #include "nsPresContext.h"
17 using namespace mozilla
;
19 //----------------------------------------------------------------------
21 // Frame class boilerplate
22 // =======================
24 NS_QUERYFRAME_HEAD(nsRubyTextFrame
)
25 NS_QUERYFRAME_ENTRY(nsRubyTextFrame
)
26 NS_QUERYFRAME_TAIL_INHERITING(nsRubyContentFrame
)
28 NS_IMPL_FRAMEARENA_HELPERS(nsRubyTextFrame
)
30 nsContainerFrame
* NS_NewRubyTextFrame(PresShell
* aPresShell
,
31 ComputedStyle
* aStyle
) {
32 return new (aPresShell
) nsRubyTextFrame(aStyle
, aPresShell
->GetPresContext());
35 //----------------------------------------------------------------------
37 // nsRubyTextFrame Method Implementations
38 // ======================================
41 bool nsRubyTextFrame::CanContinueTextRun() const { return false; }
43 #ifdef DEBUG_FRAME_DUMP
44 nsresult
nsRubyTextFrame::GetFrameName(nsAString
& aResult
) const {
45 return MakeFrameName(u
"RubyText"_ns
, aResult
);
50 void nsRubyTextFrame::BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
51 const nsDisplayListSet
& aLists
) {
56 nsRubyContentFrame::BuildDisplayList(aBuilder
, aLists
);
60 void nsRubyTextFrame::Reflow(nsPresContext
* aPresContext
,
61 ReflowOutput
& aDesiredSize
,
62 const ReflowInput
& aReflowInput
,
63 nsReflowStatus
& aStatus
) {
64 // Even if we want to hide this frame, we have to reflow it first.
65 // If we leave it dirty, changes to its content will never be
66 // propagated to the ancestors, then it won't be displayed even if
67 // the content is no longer the same, until next reflow triggered by
68 // some other change. In general, we always reflow all the frames we
69 // created. There might be other problems if we don't do that.
70 nsRubyContentFrame::Reflow(aPresContext
, aDesiredSize
, aReflowInput
, aStatus
);
73 // Reset the ISize. The BSize is not changed so that it won't
74 // affect vertical positioning in unexpected way.
75 WritingMode lineWM
= aReflowInput
.mLineLayout
->GetWritingMode();
76 aDesiredSize
.ISize(lineWM
) = 0;
77 aDesiredSize
.SetOverflowAreasToDesiredBounds();