nsRubyTextFrame.cpp (2792B)
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/ComputedStyle.h" 12 #include "mozilla/PresShell.h" 13 #include "mozilla/WritingModes.h" 14 #include "nsLineLayout.h" 15 #include "nsPresContext.h" 16 17 using namespace mozilla; 18 19 //---------------------------------------------------------------------- 20 21 // Frame class boilerplate 22 // ======================= 23 24 NS_QUERYFRAME_HEAD(nsRubyTextFrame) 25 NS_QUERYFRAME_ENTRY(nsRubyTextFrame) 26 NS_QUERYFRAME_TAIL_INHERITING(nsRubyContentFrame) 27 28 NS_IMPL_FRAMEARENA_HELPERS(nsRubyTextFrame) 29 30 nsContainerFrame* NS_NewRubyTextFrame(PresShell* aPresShell, 31 ComputedStyle* aStyle) { 32 return new (aPresShell) nsRubyTextFrame(aStyle, aPresShell->GetPresContext()); 33 } 34 35 //---------------------------------------------------------------------- 36 37 // nsRubyTextFrame Method Implementations 38 // ====================================== 39 40 /* virtual */ 41 bool nsRubyTextFrame::CanContinueTextRun() const { return false; } 42 43 #ifdef DEBUG_FRAME_DUMP 44 nsresult nsRubyTextFrame::GetFrameName(nsAString& aResult) const { 45 return MakeFrameName(u"RubyText"_ns, aResult); 46 } 47 #endif 48 49 /* virtual */ 50 void nsRubyTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, 51 const nsDisplayListSet& aLists) { 52 if (IsCollapsed()) { 53 return; 54 } 55 56 nsRubyContentFrame::BuildDisplayList(aBuilder, aLists); 57 } 58 59 /* virtual */ 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); 71 72 if (IsCollapsed()) { 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(); 78 } 79 }