mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-27 05:30:15 +00:00
7d2b02d5fd
- Bug 1233109 - Refactor module parsing to instantiate ModuleBuilder earlier r=shu (ae6693165a) - Bug 1233109 - Call into the ModuleBuilder as we parse rather than traversing the AST again afterwards r=shu (c28f785d33) - Bug 1233109 - Check for duplicate exported names using the data in the ModuleBuilder and remove ModuleBox::exportNames r=shu (03999c3ebf) - Bug 1233109 - Make the getters in Import/ExportEntryObject const r=shu (ed6c2e5dca) - Bug 1228211 (part 1) - Rearrange nsDisplayCanvasBackgroundImage::Paint(). r=dholbert. (00f3aacb07) - Bug 1228211 (part 2) - Remove unused functions in nsRenderingContext. r=dholbert. (86d9983e82) - Bug 1231550 - Use DrawTarget instead of gfxContext and/or nsRenderingContext in many places in font/text code. r=jfkthame. (b0962c9b17) - Bug 1234418 - Not trust glyph run starts from a cluster start character. r=jfkthame (b0920d8072) - more of Bug 1222166 - use gcc/clang warning f (690640c6c7) - Bug 1064843 part 1 - Make nsImageFrame inherit nsContainerFrame. r=dholbert (bd5efe0a93) - Bug 1238660 part 1 - Make mWinsInCascade initially false; r=hiro (8420017e68) - Bug 1238660 part 2 - Preserve "wins in cascade" state when updating animations; r=hiro (348a8ef769) - Bug 1230408 - Move suppress line break check out from control of SkipParentDisplayBasedStyleFixup. r=dbaron (ca853b3162) - Bug 1238660 part 3 - Add crashtest; r=hiro (ab4daba520) - Bug 1230005: Factor out relocation style decision; r=jolesen (03ea0e9ba0) - Bug 1230005: Hide specifics of the LDR instruction; r=jolesen (92b0396f81) - Bug 1230005: Flush the assembler buffer at the end of asm.js compilation; r=luke (06e0911bfb) - Bug 1230005: Delay buffer flushing in asm.js until the last minute; r=luke (d3be91cca5) - Bug 1233111 - Share method lists for SIMD types. r=bbouvier (70ec039259) - Bug 1229642 - Fix unified build duplicate static name error (rs=jandem) (eb05c13fec) - Bug 1231338 - SAB gating test cases. r=luke (a8c6740745) - Bug 1233111 - Remove geometry altering SIMD conversions. r=bbouvier (a9c93d7694) - Bug 1233111 - Add unsigned SIMD types to interpreter. r=bbouvier (6187dc7a1e) - Bug 1233111 - Add ecma_7 shift tests. r=bbouvier (17c612dac5) - Bug 1233111 - Implement SIMD shiftRightByScalar(). r=bbouvie (b9b0c848b7) - Bug 1233111 - Add a new ToUint8() function. r=efaust (f1bc50a229) - ug 1233111 - Implement saturating arithmetic for SIMD. r=bbouvier (42a98a07d6) - Bug 1229642 - Factor out StringToNewUTF8CharsZ (r=jandem) (3c4f71214b) - revert PM modification to setProfilingEnabled (4a05202975) - Bug 1229642 - Split wasm::Module out of AsmJSModule (r=bbouvier) (75a1832b1a) - Bug 1229642 - change to AsmJSActivation to WasmActivation (r=bbouvier) (a2e8513369) - Bug 1229642 - Factor AsmJSLink.cpp into wasm/asm.js and consolidate AsmJS* into AsmJS.cpp (r=bbouvier) (3a489c6410)
213 lines
7.5 KiB
C++
213 lines
7.5 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* 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/. */
|
|
|
|
#include "nsMathMLTokenFrame.h"
|
|
#include "nsPresContext.h"
|
|
#include "nsContentUtils.h"
|
|
#include "nsTextFrame.h"
|
|
#include "RestyleManager.h"
|
|
#include <algorithm>
|
|
|
|
using namespace mozilla;
|
|
|
|
nsIFrame*
|
|
NS_NewMathMLTokenFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
{
|
|
return new (aPresShell) nsMathMLTokenFrame(aContext);
|
|
}
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLTokenFrame)
|
|
|
|
nsMathMLTokenFrame::~nsMathMLTokenFrame()
|
|
{
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMathMLTokenFrame::InheritAutomaticData(nsIFrame* aParent)
|
|
{
|
|
// let the base class get the default from our parent
|
|
nsMathMLContainerFrame::InheritAutomaticData(aParent);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
eMathMLFrameType
|
|
nsMathMLTokenFrame::GetMathMLFrameType()
|
|
{
|
|
// treat everything other than <mi> as ordinary...
|
|
if (!mContent->IsMathMLElement(nsGkAtoms::mi_)) {
|
|
return eMathMLFrameType_Ordinary;
|
|
}
|
|
|
|
uint8_t mathVariant = StyleFont()->mMathVariant;
|
|
if ((mathVariant == NS_MATHML_MATHVARIANT_NONE &&
|
|
(StyleFont()->mFont.style == NS_STYLE_FONT_STYLE_ITALIC ||
|
|
HasAnyStateBits(NS_FRAME_IS_IN_SINGLE_CHAR_MI))) ||
|
|
mathVariant == NS_MATHML_MATHVARIANT_ITALIC ||
|
|
mathVariant == NS_MATHML_MATHVARIANT_BOLD_ITALIC ||
|
|
mathVariant == NS_MATHML_MATHVARIANT_SANS_SERIF_ITALIC ||
|
|
mathVariant == NS_MATHML_MATHVARIANT_SANS_SERIF_BOLD_ITALIC) {
|
|
return eMathMLFrameType_ItalicIdentifier;
|
|
}
|
|
return eMathMLFrameType_UprightIdentifier;
|
|
}
|
|
|
|
void
|
|
nsMathMLTokenFrame::MarkTextFramesAsTokenMathML()
|
|
{
|
|
nsIFrame* child = nullptr;
|
|
uint32_t childCount = 0;
|
|
|
|
// Set flags on child text frames
|
|
// - to force them to trim their leading and trailing whitespaces.
|
|
// - Indicate which frames are suitable for mathvariant
|
|
// - flag single character <mi> frames for special italic treatment
|
|
for (nsIFrame* childFrame = GetFirstPrincipalChild(); childFrame;
|
|
childFrame = childFrame->GetNextSibling()) {
|
|
for (nsIFrame* childFrame2 = childFrame->GetFirstPrincipalChild();
|
|
childFrame2; childFrame2 = childFrame2->GetNextSibling()) {
|
|
if (childFrame2->GetType() == nsGkAtoms::textFrame) {
|
|
childFrame2->AddStateBits(TEXT_IS_IN_TOKEN_MATHML);
|
|
child = childFrame2;
|
|
childCount++;
|
|
}
|
|
}
|
|
}
|
|
if (mContent->IsMathMLElement(nsGkAtoms::mi_) && childCount == 1) {
|
|
nsAutoString data;
|
|
nsContentUtils::GetNodeTextContent(mContent, false, data);
|
|
|
|
data.CompressWhitespace();
|
|
int32_t length = data.Length();
|
|
|
|
bool isSingleCharacter = length == 1 ||
|
|
(length == 2 && NS_IS_HIGH_SURROGATE(data[0]));
|
|
|
|
if (isSingleCharacter) {
|
|
child->AddStateBits(NS_FRAME_IS_IN_SINGLE_CHAR_MI);
|
|
AddStateBits(NS_FRAME_IS_IN_SINGLE_CHAR_MI);
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
nsMathMLTokenFrame::SetInitialChildList(ChildListID aListID,
|
|
nsFrameList& aChildList)
|
|
{
|
|
// First, let the base class do its work
|
|
nsMathMLContainerFrame::SetInitialChildList(aListID, aChildList);
|
|
MarkTextFramesAsTokenMathML();
|
|
}
|
|
|
|
void
|
|
nsMathMLTokenFrame::AppendFrames(ChildListID aListID,
|
|
nsFrameList& aChildList)
|
|
{
|
|
nsMathMLContainerFrame::AppendFrames(aListID, aChildList);
|
|
MarkTextFramesAsTokenMathML();
|
|
}
|
|
|
|
void
|
|
nsMathMLTokenFrame::InsertFrames(ChildListID aListID,
|
|
nsIFrame* aPrevFrame,
|
|
nsFrameList& aChildList)
|
|
{
|
|
nsMathMLContainerFrame::InsertFrames(aListID, aPrevFrame, aChildList);
|
|
MarkTextFramesAsTokenMathML();
|
|
}
|
|
|
|
void
|
|
nsMathMLTokenFrame::Reflow(nsPresContext* aPresContext,
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
const nsHTMLReflowState& aReflowState,
|
|
nsReflowStatus& aStatus)
|
|
{
|
|
MarkInReflow();
|
|
mPresentationData.flags &= ~NS_MATHML_ERROR;
|
|
|
|
// initializations needed for empty markup like <mtag></mtag>
|
|
aDesiredSize.ClearSize();
|
|
aDesiredSize.SetBlockStartAscent(0);
|
|
aDesiredSize.mBoundingMetrics = nsBoundingMetrics();
|
|
|
|
nsIFrame* childFrame = GetFirstPrincipalChild();
|
|
while (childFrame) {
|
|
// ask our children to compute their bounding metrics
|
|
nsHTMLReflowMetrics childDesiredSize(aReflowState.GetWritingMode(),
|
|
aDesiredSize.mFlags
|
|
| NS_REFLOW_CALC_BOUNDING_METRICS);
|
|
WritingMode wm = childFrame->GetWritingMode();
|
|
LogicalSize availSize = aReflowState.ComputedSize(wm);
|
|
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
|
|
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
|
|
childFrame, availSize);
|
|
ReflowChild(childFrame, aPresContext, childDesiredSize,
|
|
childReflowState, aStatus);
|
|
//NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
|
|
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
|
|
childDesiredSize.mBoundingMetrics);
|
|
|
|
childFrame = childFrame->GetNextSibling();
|
|
}
|
|
|
|
// place and size children
|
|
FinalizeReflow(aReflowState.rendContext->GetDrawTarget(), aDesiredSize);
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
|
}
|
|
|
|
// For token elements, mBoundingMetrics is computed at the ReflowToken
|
|
// pass, it is not computed here because our children may be text frames
|
|
// that do not implement the GetBoundingMetrics() interface.
|
|
/* virtual */ nsresult
|
|
nsMathMLTokenFrame::Place(DrawTarget* aDrawTarget,
|
|
bool aPlaceOrigin,
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
|
{
|
|
mBoundingMetrics = nsBoundingMetrics();
|
|
for (nsIFrame* childFrame = GetFirstPrincipalChild(); childFrame;
|
|
childFrame = childFrame->GetNextSibling()) {
|
|
nsHTMLReflowMetrics childSize(aDesiredSize.GetWritingMode());
|
|
GetReflowAndBoundingMetricsFor(childFrame, childSize,
|
|
childSize.mBoundingMetrics, nullptr);
|
|
// compute and cache the bounding metrics
|
|
mBoundingMetrics += childSize.mBoundingMetrics;
|
|
}
|
|
|
|
RefPtr<nsFontMetrics> fm;
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
|
|
nsLayoutUtils::
|
|
FontSizeInflationFor(this));
|
|
nscoord ascent = fm->MaxAscent();
|
|
nscoord descent = fm->MaxDescent();
|
|
|
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
|
aDesiredSize.Width() = mBoundingMetrics.width;
|
|
aDesiredSize.SetBlockStartAscent(std::max(mBoundingMetrics.ascent, ascent));
|
|
aDesiredSize.Height() = aDesiredSize.BlockStartAscent() +
|
|
std::max(mBoundingMetrics.descent, descent);
|
|
|
|
if (aPlaceOrigin) {
|
|
nscoord dy, dx = 0;
|
|
for (nsIFrame* childFrame = GetFirstPrincipalChild(); childFrame;
|
|
childFrame = childFrame->GetNextSibling()) {
|
|
nsHTMLReflowMetrics childSize(aDesiredSize.GetWritingMode());
|
|
GetReflowAndBoundingMetricsFor(childFrame, childSize,
|
|
childSize.mBoundingMetrics);
|
|
|
|
// place and size the child; (dx,0) makes the caret happy - bug 188146
|
|
dy = childSize.Height() == 0 ? 0 : aDesiredSize.BlockStartAscent() - childSize.BlockStartAscent();
|
|
FinishReflowChild(childFrame, PresContext(), childSize, nullptr, dx, dy, 0);
|
|
dx += childSize.Width();
|
|
}
|
|
}
|
|
|
|
SetReference(nsPoint(0, aDesiredSize.BlockStartAscent()));
|
|
|
|
return NS_OK;
|
|
}
|
|
|