Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=2 et sw=2 tw=80: */
3 : /* This Source Code is subject to the terms of the Mozilla Public License
4 : * version 2.0 (the "License"). You can obtain a copy of the License at
5 : * 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 0 : NS_QUERYFRAME_HEAD(nsRubyTextFrame)
24 0 : NS_QUERYFRAME_ENTRY(nsRubyTextFrame)
25 0 : NS_QUERYFRAME_TAIL_INHERITING(nsRubyContentFrame)
26 :
27 0 : NS_IMPL_FRAMEARENA_HELPERS(nsRubyTextFrame)
28 :
29 : nsContainerFrame*
30 0 : NS_NewRubyTextFrame(nsIPresShell* aPresShell,
31 : nsStyleContext* aContext)
32 : {
33 0 : return new (aPresShell) nsRubyTextFrame(aContext);
34 : }
35 :
36 :
37 : //----------------------------------------------------------------------
38 :
39 : // nsRubyTextFrame Method Implementations
40 : // ======================================
41 :
42 : /* virtual */ bool
43 0 : nsRubyTextFrame::CanContinueTextRun() const
44 : {
45 0 : return false;
46 : }
47 :
48 : #ifdef DEBUG_FRAME_DUMP
49 : nsresult
50 0 : nsRubyTextFrame::GetFrameName(nsAString& aResult) const
51 : {
52 0 : return MakeFrameName(NS_LITERAL_STRING("RubyText"), aResult);
53 : }
54 : #endif
55 :
56 :
57 :
58 : /* virtual */ void
59 0 : nsRubyTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
60 : const nsRect& aDirtyRect,
61 : const nsDisplayListSet& aLists)
62 : {
63 0 : if (IsAutoHidden()) {
64 0 : return;
65 : }
66 :
67 0 : nsRubyContentFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
68 : }
69 :
70 : /* virtual */ void
71 0 : nsRubyTextFrame::Reflow(nsPresContext* aPresContext,
72 : ReflowOutput& aDesiredSize,
73 : const ReflowInput& aReflowInput,
74 : nsReflowStatus& aStatus)
75 : {
76 : // Even if we want to hide this frame, we have to reflow it first.
77 : // If we leave it dirty, changes to its content will never be
78 : // propagated to the ancestors, then it won't be displayed even if
79 : // the content is no longer the same, until next reflow triggered by
80 : // some other change. In general, we always reflow all the frames we
81 : // created. There might be other problems if we don't do that.
82 0 : nsRubyContentFrame::Reflow(aPresContext, aDesiredSize, aReflowInput, aStatus);
83 :
84 0 : if (IsAutoHidden()) {
85 : // Reset the ISize. The BSize is not changed so that it won't
86 : // affect vertical positioning in unexpected way.
87 0 : WritingMode lineWM = aReflowInput.mLineLayout->GetWritingMode();
88 0 : aDesiredSize.ISize(lineWM) = 0;
89 0 : aDesiredSize.SetOverflowAreasToDesiredBounds();
90 : }
91 0 : }
|