2014-07-23 06:08:01 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code is subject to the terms of the Mozilla Public License
|
|
|
|
* version 2.0 (the "License"). You can obtain a copy of the License at
|
|
|
|
* http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
/* rendering object for CSS "display: ruby-text" */
|
|
|
|
|
|
|
|
#include "nsRubyTextFrame.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"
|
|
|
|
#include "nsStyleContext.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,
|
|
|
|
nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsRubyTextFrame(aContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// nsRubyTextFrame Method Implementations
|
|
|
|
// ======================================
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsRubyTextFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::rubyTextFrame;
|
|
|
|
}
|
|
|
|
|
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 nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2015-03-11 02:28:21 +03:00
|
|
|
if (IsAutoHidden()) {
|
2014-12-15 06:37:15 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-18 09:15:03 +03:00
|
|
|
nsRubyContentFrame::BuildDisplayList(aBuilder, aDirtyRect, 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();
|
|
|
|
}
|
|
|
|
}
|