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/. */
6
7 /* rendering object for CSS "display: ruby-text" */
8
9 #include "nsRubyTextFrame.h"
10
11 #include "mozilla/WritingModes.h"
12 #include "nsLineLayout.h"
13 #include "nsPresContext.h"
14 #include "nsStyleContext.h"
15
16 using namespace mozilla;
17
18 //----------------------------------------------------------------------
19
20 // Frame class boilerplate
21 // =======================
22
23 NS_QUERYFRAME_HEAD(nsRubyTextFrame)
NS_QUERYFRAME_ENTRY(nsRubyTextFrame)24 NS_QUERYFRAME_ENTRY(nsRubyTextFrame)
25 NS_QUERYFRAME_TAIL_INHERITING(nsRubyContentFrame)
26
27 NS_IMPL_FRAMEARENA_HELPERS(nsRubyTextFrame)
28
29 nsContainerFrame* NS_NewRubyTextFrame(nsIPresShell* aPresShell,
30 nsStyleContext* aContext) {
31 return new (aPresShell) nsRubyTextFrame(aContext);
32 }
33
34 //----------------------------------------------------------------------
35
36 // nsRubyTextFrame Method Implementations
37 // ======================================
38
CanContinueTextRun() const39 /* virtual */ bool nsRubyTextFrame::CanContinueTextRun() const { return false; }
40
41 #ifdef DEBUG_FRAME_DUMP
GetFrameName(nsAString & aResult) const42 nsresult nsRubyTextFrame::GetFrameName(nsAString& aResult) const {
43 return MakeFrameName(NS_LITERAL_STRING("RubyText"), aResult);
44 }
45 #endif
46
BuildDisplayList(nsDisplayListBuilder * aBuilder,const nsDisplayListSet & aLists)47 /* virtual */ void nsRubyTextFrame::BuildDisplayList(
48 nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) {
49 if (IsAutoHidden()) {
50 return;
51 }
52
53 nsRubyContentFrame::BuildDisplayList(aBuilder, aLists);
54 }
55
Reflow(nsPresContext * aPresContext,ReflowOutput & aDesiredSize,const ReflowInput & aReflowInput,nsReflowStatus & aStatus)56 /* virtual */ void nsRubyTextFrame::Reflow(nsPresContext* aPresContext,
57 ReflowOutput& aDesiredSize,
58 const ReflowInput& aReflowInput,
59 nsReflowStatus& aStatus) {
60 // Even if we want to hide this frame, we have to reflow it first.
61 // If we leave it dirty, changes to its content will never be
62 // propagated to the ancestors, then it won't be displayed even if
63 // the content is no longer the same, until next reflow triggered by
64 // some other change. In general, we always reflow all the frames we
65 // created. There might be other problems if we don't do that.
66 nsRubyContentFrame::Reflow(aPresContext, aDesiredSize, aReflowInput, aStatus);
67
68 if (IsAutoHidden()) {
69 // Reset the ISize. The BSize is not changed so that it won't
70 // affect vertical positioning in unexpected way.
71 WritingMode lineWM = aReflowInput.mLineLayout->GetWritingMode();
72 aDesiredSize.ISize(lineWM) = 0;
73 aDesiredSize.SetOverflowAreasToDesiredBounds();
74 }
75 }
76