2017-10-27 20:33:53 +03: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 20:09:35 +03: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 06:08:01 +04:00
|
|
|
|
|
|
|
/* rendering object for CSS "display: ruby-text" */
|
|
|
|
|
|
|
|
#include "nsRubyTextFrame.h"
|
2015-03-26 10:29:31 +03:00
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
#include "mozilla/ComputedStyle.h"
|
2015-03-26 10:29:31 +03:00
|
|
|
#include "mozilla/WritingModes.h"
|
|
|
|
#include "nsLineLayout.h"
|
2014-07-23 06:08:01 +04:00
|
|
|
#include "nsPresContext.h"
|
2014-08-15 21:34:20 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2014-07-23 06:08:01 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Frame class boilerplate
|
|
|
|
// =======================
|
|
|
|
|
|
|
|
NS_QUERYFRAME_HEAD(nsRubyTextFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsRubyTextFrame)
|
2016-04-18 09:15:03 +03:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsRubyContentFrame)
|
2014-07-23 06:08:01 +04:00
|
|
|
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsRubyTextFrame)
|
|
|
|
|
|
|
|
nsContainerFrame*
|
|
|
|
NS_NewRubyTextFrame(nsIPresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aStyle)
|
2014-07-23 06:08:01 +04:00
|
|
|
{
|
2018-03-22 21:20:41 +03:00
|
|
|
return new (aPresShell) nsRubyTextFrame(aStyle);
|
2014-07-23 06:08:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// nsRubyTextFrame Method Implementations
|
|
|
|
// ======================================
|
|
|
|
|
2015-02-18 07:20:02 +03:00
|
|
|
/* virtual */ bool
|
|
|
|
nsRubyTextFrame::CanContinueTextRun() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-07-23 06:08:01 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
|
|
|
nsresult
|
|
|
|
nsRubyTextFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("RubyText"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
2014-08-15 21:34:20 +04:00
|
|
|
|
2014-12-15 06:37:15 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsRubyTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2015-03-11 02:28:21 +03:00
|
|
|
if (IsAutoHidden()) {
|
2014-12-15 06:37:15 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-07 05:23:35 +03:00
|
|
|
nsRubyContentFrame::BuildDisplayList(aBuilder, aLists);
|
2014-12-15 06:37:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsRubyTextFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2014-12-15 06:37:15 +03:00
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
// 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 13:36:39 +03:00
|
|
|
nsRubyContentFrame::Reflow(aPresContext, aDesiredSize, aReflowInput, aStatus);
|
2014-12-15 06:37:15 +03:00
|
|
|
|
2015-03-11 02:28:21 +03:00
|
|
|
if (IsAutoHidden()) {
|
2014-12-09 09:47:26 +03:00
|
|
|
// Reset the ISize. The BSize is not changed so that it won't
|
|
|
|
// affect vertical positioning in unexpected way.
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode lineWM = aReflowInput.mLineLayout->GetWritingMode();
|
2014-12-09 09:47:26 +03:00
|
|
|
aDesiredSize.ISize(lineWM) = 0;
|
2014-12-15 06:37:15 +03:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
|
|
|
}
|
|
|
|
}
|