2017-10-27 17:33:53 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2017-10-27 17:09:35 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2014-07-23 02:08:01 +00:00
|
|
|
|
|
|
|
/* rendering object for CSS "display: ruby-text" */
|
|
|
|
|
|
|
|
#include "nsRubyTextFrame.h"
|
2015-03-26 07:29:31 +00:00
|
|
|
|
2018-03-22 18:20:41 +00:00
|
|
|
#include "mozilla/ComputedStyle.h"
|
2019-04-16 07:24:49 +00:00
|
|
|
#include "mozilla/PresShell.h"
|
2015-03-26 07:29:31 +00:00
|
|
|
#include "mozilla/WritingModes.h"
|
|
|
|
#include "nsLineLayout.h"
|
2014-07-23 02:08:01 +00:00
|
|
|
#include "nsPresContext.h"
|
2014-08-15 17:34:20 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2014-07-23 02:08:01 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Frame class boilerplate
|
|
|
|
// =======================
|
|
|
|
|
|
|
|
NS_QUERYFRAME_HEAD(nsRubyTextFrame)
|
2018-12-07 20:00:18 +00:00
|
|
|
NS_QUERYFRAME_ENTRY(nsRubyTextFrame)
|
2016-04-18 06:15:03 +00:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsRubyContentFrame)
|
2014-07-23 02:08:01 +00:00
|
|
|
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsRubyTextFrame)
|
|
|
|
|
2019-04-16 07:24:49 +00:00
|
|
|
nsContainerFrame* NS_NewRubyTextFrame(PresShell* aPresShell,
|
2018-03-22 18:20:41 +00:00
|
|
|
ComputedStyle* aStyle) {
|
2019-02-05 16:45:54 +00:00
|
|
|
return new (aPresShell) nsRubyTextFrame(aStyle, aPresShell->GetPresContext());
|
2014-07-23 02:08:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// nsRubyTextFrame Method Implementations
|
|
|
|
// ======================================
|
|
|
|
|
2019-02-25 22:09:24 +00:00
|
|
|
/* virtual */
|
|
|
|
bool nsRubyTextFrame::CanContinueTextRun() const { return false; }
|
2015-02-18 04:20:02 +00:00
|
|
|
|
2014-07-23 02:08:01 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
|
|
|
nsresult nsRubyTextFrame::GetFrameName(nsAString& aResult) const {
|
|
|
|
return MakeFrameName(u"RubyText"_ns, aResult);
|
|
|
|
}
|
|
|
|
#endif
|
2014-08-15 17:34:20 +00:00
|
|
|
|
2019-02-25 22:09:24 +00:00
|
|
|
/* virtual */
|
|
|
|
void nsRubyTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) {
|
2021-03-12 09:28:00 +00:00
|
|
|
if (IsCollapsed()) {
|
2014-12-15 03:37:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-07 02:23:35 +00:00
|
|
|
nsRubyContentFrame::BuildDisplayList(aBuilder, aLists);
|
2014-12-15 03:37:15 +00:00
|
|
|
}
|
|
|
|
|
2019-02-25 22:09:24 +00:00
|
|
|
/* virtual */
|
|
|
|
void nsRubyTextFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
ReflowOutput& aDesiredSize,
|
|
|
|
const ReflowInput& aReflowInput,
|
|
|
|
nsReflowStatus& aStatus) {
|
2014-12-15 03:37:15 +00:00
|
|
|
// Even if we want to hide this frame, we have to reflow it first.
|
|
|
|
// If we leave it dirty, changes to its content will never be
|
|
|
|
// propagated to the ancestors, then it won't be displayed even if
|
|
|
|
// the content is no longer the same, until next reflow triggered by
|
|
|
|
// some other change. In general, we always reflow all the frames we
|
|
|
|
// created. There might be other problems if we don't do that.
|
2016-07-21 10:36:39 +00:00
|
|
|
nsRubyContentFrame::Reflow(aPresContext, aDesiredSize, aReflowInput, aStatus);
|
2014-12-15 03:37:15 +00:00
|
|
|
|
2021-03-12 09:28:00 +00:00
|
|
|
if (IsCollapsed()) {
|
2014-12-09 06:47:26 +00:00
|
|
|
// Reset the ISize. The BSize is not changed so that it won't
|
|
|
|
// affect vertical positioning in unexpected way.
|
2016-07-21 10:36:39 +00:00
|
|
|
WritingMode lineWM = aReflowInput.mLineLayout->GetWritingMode();
|
2014-12-09 06:47:26 +00:00
|
|
|
aDesiredSize.ISize(lineWM) = 0;
|
2014-12-15 03:37:15 +00:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
|
|
|
}
|
|
|
|
}
|