Files
roytam1 2828386673 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1247182 - Add an nsCSSRuleProcessor constructor that takes ownership of the given sheet array. r=birtles (07fd64f305)
- Bug 1260983 - Update animation properties when the style context changes; r=heycam (f68f67fc24)
- Bug 1160342 - Implement marquee using mutation observers, r=smaug (f8be96bfd8)
- Bug 1219842 - Enable a bunch of mochitest-plain tests under e10s. r=mrbkap (40aa7c1fce)
- Bug 1249061 - Improve property/attribute handling for marquees. r=smaug (1189869b3d)
- Bug 1266324 - Rename style const macro for unicode-bidi:bidi-override to be consistent with other style consts. r=jfkthame (24ded3fb69)
- Bug 1189894 - remove Atomics.h IntrinsicAddSub hack; r=erahm (d68fcf1801)
- Bug 1247338 - really make Atomic's constructor constexpr; r=Waldo (948c372b36)
- Bug 1266294 - Remove unnecessary compiler version checks for gcc <= 4.8.0 in mfbt. r=froydnj (8739fa352b)
- Bug 1260247. In chaos mode randomly decide to start a new image load even if the image is in the image cache when allowed by spec. r=seth (0d9dd4a1e9)
- Bug 1266294 - Remove unnecessary compiler version checks for gcc <= 4.8.0 in mfbt. r=froydnj (c230e51053)
- Bug 1209100 - Back out bug 1165185 on inbound. (af5f585393)
- Bug 1263342 - don't use REFCOUNTED_VIRTUAL_TYPENAME for mfbt FunctionImplBase. r=froydnj (f02a160c0b)
- Bug 1262577 - allow comparing mozilla::function with nullptr. r=froydnj (515a90b79a)
- Bug 1232418 - Allow mozilla::Tuple to support equality comparison; r=Waldo (1e8cb10660)
- Bug 1262663 - Clean up UniquePtr return documentation. r=Waldo (e92392b74e)
- Bug 1254831 - Fix compiler errors when SHOW_BOUNDING_BOX #ifdef is enabled. r=fredw (c0982211e8)
- Bug 1161169: Clean up usage of mContentParent and clearly identify it as specifically for async plugin init; r=billm,jimm (2ed3b9f96d)
- Bug 1164931 - Clear hangs when they're over (r=mrbkap) (f8de731e19)
- Bug 1250046 - Remove Shumway references from IPC. r=jmathies (7d7305c309)
- Bug 1254831 - Invalidate mfracs when linethickness changes. r=fredw (ff3d2bf6d0)
- Bug 1256943: Ensure that BLOCKED_ON_PLUGIN_MODULE_INIT_MS is being recorded in e10s chrome; r=jimm (ab879d7aec)
- Bug 1248821 - Force Flash to windowless mode regardless of sandbox level. r=jimm (007d45d5ef)
- Bug 1253434 - Avoid trying to capture plugin windows that have a zero width or height and a positive value for the other dim. r=aklotz (7a4995e8a5)
- Bug 1254829 - Calling TerminateProcess for WindowsXP to bypass DLL detach handler, r=bsmedberg (c04377e7b9)
- Bug 1263499 - unify the QuickExit function, r=bsmedberg (eeefdd7c2b)
- Bug 1246763 - Refactor GMP info file parsing into helper class. r=gerald (b4544c7370)
- Bug 1247556 - Use GMPInfoFileParser in GMPParent::ReadGMPMetaData(). r=gerald (6369ea568b)
- Bug 1247763 - Remove info file parsing from GMP child process. r=gerald (4454d25162)
- Bug 1258220 - Disable Adobe GMP if SSE2 isn't supported. r=gerald (55aba6b28a)
- Bug 1245789 - Make GMPParent::Init() return a promise, so it can be async. r=gerald (34ecae588a)
- Bug 1245789 - Add GMPAdapter which can be passed to GMPLoader to adapt non GMP library to GMP API. r=gerald (11f1734a6a)
- Bug 1245789 - Send name of GMPAdapter over to GMP process in StartPlugin message. r=gerald (a7b2df2c0d)
- Bug 1231633 - give scalar mLoadReplace a default value. r=bz (a7d1293b26)
- Bug 1245743 - Don't push new timeline markers while popping markers. r=vporof (f6efe5651e)
- Bug 1255459 - Use AutoRestore in ObservedDocShell::PopMarkers. r=smaug (d5fa90046e)
- Bug 1244897 - Use TimerlineConsumers in PopProfileTimelineMarkers to ensure that all methods acquire TimelineConsumers Mutex. r=vporof (39485ada73)
- Bug 1253516 - Do not acquire a lock that protects data that is not used; r=vporof (773337acce)
- Bug 1262970 - Change PRINCIPAL_HANDLE_NONE to a nullptr #define. r=froydnj (df470bc91c)
- Bug 1068596 - Pass SHARE_DELETE when opening a file so the file can be deleted without waiting for GC. r=roc (5b7d146cb8)
- Bug 1262970 - Allow nsMainThreadPtrHandle to be constructed by and compared to nullptr. r=froydnj (dbf01e5191)
- Bug 1249904: Use content-range values to determine length if content-length is unknown. r=roc (38a1388ea5)
- Bug 1251044: P1. Use content-range values to determine content's length. r=roc (72fb7f2a37)
- Bug 1251044: P2. Remove dead code and generalise the use of content-range header. r=roc (81d8dbf6f0)
- Bug 1228677 - Do not enforce CORS when loading file for MediaResource. r=cpearce (7d042fd6c2)
- Bug 1142272 - platformAPI memory leak, delete on return false. r=erahm (a7932ba850)
- Bug 1149616 - Fix the calculation of slots count in Read/WriteBuffer. r=bechen (6a2d010b3b)
- Bug 1262473 - don't needlessly construct nsAutoCString temporaries when serializing GMPVideoCodec; r=cpearce (7734560bb5)
- Bug 1245789 - Handle unencrypted samples in encrypted media. r=gerald Some encrypted MP4 files lack subsample info for some samples, so we need this check to prevent us crashing on such files. (6cf556699c)
- Bug 1245789 - Load Widevine CDM with sandbox level USER_RESTRICTED instead of USER_LOCKDOWN. r=bobowen (fd1ffd40a4)
- Bug 1245789 - Store GMPCapabilities by value, rather than on the heap. r=gerald (06c1737a4b)
- non-EME bits of Bug 1245789 - Parse Chrome CDM manifest in GMPService.addPluginDir (4116c843bd)
- Bug 1245789 - Whitelist functions needed by Widevine CDM in GMP child processes. r=jed (e525178fe5)
- Bug 1245789 - Ensure Widevine's nodeId are always unique and not permitted persistent storage. r=gerald (562e5b389b)
- Bug 1245789 - Push detection of WMF decoding for clearkey into GMPParent to simplify request media key system access logic. r=gerald (feffe136ba)
- Bug 1245789 - Make XPCOMThreadWrapper::GetCurrent() work. r=bholley (4e04f099cc)
- Bug 1245789 - Change GMPParent::InitPromise to instead use GenericPromise as defined in MozPromise.h. r=gerald (7c7c0f15d4)
- Bug 1158773: Use the same initial and delayed integrity level for Windows content sandbox level 0. r=tabraldes (2d6607e8a8)
- Bug 1219369: In Windows debug builds allow write access to TEMP for logging purposes. r=tabraldes (61737cff53)
- Bug 1166669: Enable process-level mitigations for the Windows content process sandbox. r=tabraldes (da06c34ceb)
- Bug 1197943: Turn off MITIGATION_STRICT_HANDLE_CHECKS for NPAPI process sandbox for causing hangs. r=aklotz (d31b767cd0)
- Bug 1245789 - Ensure GMPs have finished loading from MOZ_GMP_PATH before GMPServiceParent::GetContentParentFrom returns. r=gerald (361156a95b)
- Bug 1245789 - Ensure GMP service has added all plugins before running GMP remove tests. r=gerald (53616c6f09)
- Bug 1245789 - Expose AsyncAddPluginDirectory on GMPServiceParent. r=gerald (2a0fcd39ee)
- Bug 1183433 - Remove G-M-PServiceParent::AbortAsyncShutdown declaration, as it's not defined nor used anywhere. r=cpearce (b8f29f61dd)
- bit of Bug 1185392 - Use a separate mutex to protect mAsyncShutdownPluginStatesMutex, as mMutex could already be held when trying to update the states. r=cpearce (2be59fc7c9)
2024-06-18 09:37:48 +08:00

382 lines
12 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/. */
#ifndef nsMathMLFrame_h___
#define nsMathMLFrame_h___
#include "mozilla/Attributes.h"
#include "nsFontMetrics.h"
#include "nsMathMLOperators.h"
#include "nsIMathMLFrame.h"
#include "nsLayoutUtils.h"
#include "nsBoundingMetrics.h"
#include "nsIFrame.h"
class nsMathMLChar;
class nsCSSValue;
class nsDisplayListSet;
// Concrete base class with default methods that derived MathML frames can override
class nsMathMLFrame : public nsIMathMLFrame {
public:
// nsIMathMLFrame ---
virtual bool
IsSpaceLike() override {
return NS_MATHML_IS_SPACE_LIKE(mPresentationData.flags);
}
NS_IMETHOD
GetBoundingMetrics(nsBoundingMetrics& aBoundingMetrics) override {
aBoundingMetrics = mBoundingMetrics;
return NS_OK;
}
NS_IMETHOD
SetBoundingMetrics(const nsBoundingMetrics& aBoundingMetrics) override {
mBoundingMetrics = aBoundingMetrics;
return NS_OK;
}
NS_IMETHOD
SetReference(const nsPoint& aReference) override {
mReference = aReference;
return NS_OK;
}
virtual eMathMLFrameType GetMathMLFrameType() override;
NS_IMETHOD
Stretch(mozilla::gfx::DrawTarget* aDrawTarget,
nsStretchDirection aStretchDirection,
nsBoundingMetrics& aContainerSize,
nsHTMLReflowMetrics& aDesiredStretchSize) override
{
return NS_OK;
}
NS_IMETHOD
GetEmbellishData(nsEmbellishData& aEmbellishData) override {
aEmbellishData = mEmbellishData;
return NS_OK;
}
NS_IMETHOD
GetPresentationData(nsPresentationData& aPresentationData) override {
aPresentationData = mPresentationData;
return NS_OK;
}
NS_IMETHOD
InheritAutomaticData(nsIFrame* aParent) override;
NS_IMETHOD
TransmitAutomaticData() override
{
return NS_OK;
}
NS_IMETHOD
UpdatePresentationData(uint32_t aFlagsValues,
uint32_t aFlagsToUpdate) override;
NS_IMETHOD
UpdatePresentationDataFromChildAt(int32_t aFirstIndex,
int32_t aLastIndex,
uint32_t aFlagsValues,
uint32_t aFlagsToUpdate) override
{
return NS_OK;
}
uint8_t
ScriptIncrement(nsIFrame* aFrame) override
{
return 0;
}
bool
IsMrowLike() override
{
return false;
}
// helper to give a style context suitable for doing the stretching to the
// MathMLChar. Frame classes that use this should make the extra style contexts
// accessible to the Style System via Get/Set AdditionalStyleContext.
static void
ResolveMathMLCharStyle(nsPresContext* aPresContext,
nsIContent* aContent,
nsStyleContext* aParenStyleContext,
nsMathMLChar* aMathMLChar);
// helper to get the mEmbellishData of a frame
// The MathML REC precisely defines an "embellished operator" as:
// - an <mo> element;
// - or one of the elements <msub>, <msup>, <msubsup>, <munder>, <mover>,
// <munderover>, <mmultiscripts>, <mfrac>, or <semantics>, whose first
// argument exists and is an embellished operator;
//- or one of the elements <mstyle>, <mphantom>, or <mpadded>, such that
// an <mrow> containing the same arguments would be an embellished
// operator;
// - or an <maction> element whose selected subexpression exists and is an
// embellished operator;
// - or an <mrow> whose arguments consist (in any order) of one embellished
// operator and zero or more spacelike elements.
static void
GetEmbellishDataFrom(nsIFrame* aFrame,
nsEmbellishData& aEmbellishData);
// helper to get the presentation data of a frame. If aClimbTree is
// set to true and the frame happens to be surrounded by non-MathML
// helper frames needed for its support, we walk up the frame hierarchy
// until we reach a MathML ancestor or the <root> math element.
static void
GetPresentationDataFrom(nsIFrame* aFrame,
nsPresentationData& aPresentationData,
bool aClimbTree = true);
// utilities to parse and retrieve numeric values in CSS units
// All values are stored in twips.
// @pre aLengthValue is the default length value of the attribute.
// @post aLengthValue is the length value computed from the attribute.
static void ParseNumericValue(const nsString& aString,
nscoord* aLengthValue,
uint32_t aFlags,
nsPresContext* aPresContext,
nsStyleContext* aStyleContext,
float aFontSizeInflation);
static nscoord
CalcLength(nsPresContext* aPresContext,
nsStyleContext* aStyleContext,
const nsCSSValue& aCSSValue,
float aFontSizeInflation);
static eMathMLFrameType
GetMathMLFrameTypeFor(nsIFrame* aFrame)
{
if (aFrame->IsFrameOfType(nsIFrame::eMathML)) {
nsIMathMLFrame* mathMLFrame = do_QueryFrame(aFrame);
if (mathMLFrame)
return mathMLFrame->GetMathMLFrameType();
}
return eMathMLFrameType_UNKNOWN;
}
// estimate of the italic correction
static void
GetItalicCorrection(nsBoundingMetrics& aBoundingMetrics,
nscoord& aItalicCorrection)
{
aItalicCorrection = aBoundingMetrics.rightBearing - aBoundingMetrics.width;
if (0 > aItalicCorrection) {
aItalicCorrection = 0;
}
}
static void
GetItalicCorrection(nsBoundingMetrics& aBoundingMetrics,
nscoord& aLeftItalicCorrection,
nscoord& aRightItalicCorrection)
{
aRightItalicCorrection = aBoundingMetrics.rightBearing - aBoundingMetrics.width;
if (0 > aRightItalicCorrection) {
aRightItalicCorrection = 0;
}
aLeftItalicCorrection = -aBoundingMetrics.leftBearing;
if (0 > aLeftItalicCorrection) {
aLeftItalicCorrection = 0;
}
}
// helper methods for getting sup/subdrop's from a child
static void
GetSubDropFromChild(nsIFrame* aChild,
nscoord& aSubDrop,
float aFontSizeInflation)
{
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetFontMetricsForFrame(aChild, aFontSizeInflation);
GetSubDrop(fm, aSubDrop);
}
static void
GetSupDropFromChild(nsIFrame* aChild,
nscoord& aSupDrop,
float aFontSizeInflation)
{
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetFontMetricsForFrame(aChild, aFontSizeInflation);
GetSupDrop(fm, aSupDrop);
}
static void
GetSkewCorrectionFromChild(nsIFrame* aChild,
nscoord& aSkewCorrection)
{
// default is 0
// individual classes should over-ride this method if necessary
aSkewCorrection = 0;
}
// 2 levels of subscript shifts
static void
GetSubScriptShifts(nsFontMetrics* fm,
nscoord& aSubScriptShift1,
nscoord& aSubScriptShift2)
{
nscoord xHeight = fm->XHeight();
aSubScriptShift1 = NSToCoordRound(150.000f/430.556f * xHeight);
aSubScriptShift2 = NSToCoordRound(247.217f/430.556f * xHeight);
}
// 3 levels of superscript shifts
static void
GetSupScriptShifts(nsFontMetrics* fm,
nscoord& aSupScriptShift1,
nscoord& aSupScriptShift2,
nscoord& aSupScriptShift3)
{
nscoord xHeight = fm->XHeight();
aSupScriptShift1 = NSToCoordRound(412.892f/430.556f * xHeight);
aSupScriptShift2 = NSToCoordRound(362.892f/430.556f * xHeight);
aSupScriptShift3 = NSToCoordRound(288.889f/430.556f * xHeight);
}
// these are TeX specific params not found in ordinary fonts
static void
GetSubDrop(nsFontMetrics* fm,
nscoord& aSubDrop)
{
nscoord xHeight = fm->XHeight();
aSubDrop = NSToCoordRound(50.000f/430.556f * xHeight);
}
static void
GetSupDrop(nsFontMetrics* fm,
nscoord& aSupDrop)
{
nscoord xHeight = fm->XHeight();
aSupDrop = NSToCoordRound(386.108f/430.556f * xHeight);
}
static void
GetNumeratorShifts(nsFontMetrics* fm,
nscoord& numShift1,
nscoord& numShift2,
nscoord& numShift3)
{
nscoord xHeight = fm->XHeight();
numShift1 = NSToCoordRound(676.508f/430.556f * xHeight);
numShift2 = NSToCoordRound(393.732f/430.556f * xHeight);
numShift3 = NSToCoordRound(443.731f/430.556f * xHeight);
}
static void
GetDenominatorShifts(nsFontMetrics* fm,
nscoord& denShift1,
nscoord& denShift2)
{
nscoord xHeight = fm->XHeight();
denShift1 = NSToCoordRound(685.951f/430.556f * xHeight);
denShift2 = NSToCoordRound(344.841f/430.556f * xHeight);
}
static void
GetEmHeight(nsFontMetrics* fm,
nscoord& emHeight)
{
#if 0
// should switch to this API in order to scale with changes of TextZoom
emHeight = fm->EmHeight();
#else
emHeight = NSToCoordRound(float(fm->Font().size));
#endif
}
static void
GetAxisHeight (nsFontMetrics* fm,
nscoord& axisHeight)
{
axisHeight = NSToCoordRound(250.000f/430.556f * fm->XHeight());
}
static void
GetBigOpSpacings(nsFontMetrics* fm,
nscoord& bigOpSpacing1,
nscoord& bigOpSpacing2,
nscoord& bigOpSpacing3,
nscoord& bigOpSpacing4,
nscoord& bigOpSpacing5)
{
nscoord xHeight = fm->XHeight();
bigOpSpacing1 = NSToCoordRound(111.111f/430.556f * xHeight);
bigOpSpacing2 = NSToCoordRound(166.667f/430.556f * xHeight);
bigOpSpacing3 = NSToCoordRound(200.000f/430.556f * xHeight);
bigOpSpacing4 = NSToCoordRound(600.000f/430.556f * xHeight);
bigOpSpacing5 = NSToCoordRound(100.000f/430.556f * xHeight);
}
static void
GetRuleThickness(nsFontMetrics* fm,
nscoord& ruleThickness)
{
nscoord xHeight = fm->XHeight();
ruleThickness = NSToCoordRound(40.000f/430.556f * xHeight);
}
// Some parameters are not accurately obtained using the x-height.
// Here are some slower variants to obtain the desired metrics
// by actually measuring some characters
static void
GetRuleThickness(mozilla::gfx::DrawTarget* aDrawTarget,
nsFontMetrics* aFontMetrics,
nscoord& aRuleThickness);
static void
GetAxisHeight(mozilla::gfx::DrawTarget* aDrawTarget,
nsFontMetrics* aFontMetrics,
nscoord& aAxisHeight);
static void
GetRadicalParameters(nsFontMetrics* aFontMetrics,
bool aDisplayStyle,
nscoord& aRadicalRuleThickness,
nscoord& aRadicalExtraAscender,
nscoord& aRadicalVerticalGap);
protected:
#if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
void DisplayBoundingMetrics(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, const nsPoint& aPt,
const nsBoundingMetrics& aMetrics,
const nsDisplayListSet& aLists);
#endif
/**
* Display a solid rectangle in the frame's text color. Used for drawing
* fraction separators and root/sqrt overbars.
*/
void DisplayBar(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, const nsRect& aRect,
const nsDisplayListSet& aLists);
// information about the presentation policy of the frame
nsPresentationData mPresentationData;
// information about a container that is an embellished operator
nsEmbellishData mEmbellishData;
// Metrics that _exactly_ enclose the text of the frame
nsBoundingMetrics mBoundingMetrics;
// Reference point of the frame: mReference.y is the baseline
nsPoint mReference;
};
#endif /* nsMathMLFrame_h___ */