mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
2828386673
- 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)
430 lines
15 KiB
C++
430 lines
15 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 "nsMathMLFrame.h"
|
|
|
|
#include "gfxUtils.h"
|
|
#include "mozilla/gfx/2D.h"
|
|
#include "nsLayoutUtils.h"
|
|
#include "nsNameSpaceManager.h"
|
|
#include "nsMathMLChar.h"
|
|
#include "nsCSSPseudoElements.h"
|
|
#include "nsMathMLElement.h"
|
|
|
|
// used to map attributes into CSS rules
|
|
#include "mozilla/StyleSetHandle.h"
|
|
#include "mozilla/StyleSetHandleInlines.h"
|
|
#include "nsAutoPtr.h"
|
|
#include "nsDisplayList.h"
|
|
#include "nsRenderingContext.h"
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::gfx;
|
|
|
|
eMathMLFrameType
|
|
nsMathMLFrame::GetMathMLFrameType()
|
|
{
|
|
// see if it is an embellished operator (mapped to 'Op' in TeX)
|
|
if (mEmbellishData.coreFrame)
|
|
return GetMathMLFrameTypeFor(mEmbellishData.coreFrame);
|
|
|
|
// if it has a prescribed base, fetch the type from there
|
|
if (mPresentationData.baseFrame)
|
|
return GetMathMLFrameTypeFor(mPresentationData.baseFrame);
|
|
|
|
// everything else is treated as ordinary (mapped to 'Ord' in TeX)
|
|
return eMathMLFrameType_Ordinary;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMathMLFrame::InheritAutomaticData(nsIFrame* aParent)
|
|
{
|
|
mEmbellishData.flags = 0;
|
|
mEmbellishData.coreFrame = nullptr;
|
|
mEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED;
|
|
mEmbellishData.leadingSpace = 0;
|
|
mEmbellishData.trailingSpace = 0;
|
|
|
|
mPresentationData.flags = 0;
|
|
mPresentationData.baseFrame = nullptr;
|
|
|
|
// by default, just inherit the display of our parent
|
|
nsPresentationData parentData;
|
|
GetPresentationDataFrom(aParent, parentData);
|
|
|
|
#if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
|
|
mPresentationData.flags |= NS_MATHML_SHOW_BOUNDING_METRICS;
|
|
#endif
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMathMLFrame::UpdatePresentationData(uint32_t aFlagsValues,
|
|
uint32_t aWhichFlags)
|
|
{
|
|
NS_ASSERTION(NS_MATHML_IS_COMPRESSED(aWhichFlags) ||
|
|
NS_MATHML_IS_DTLS_SET(aWhichFlags),
|
|
"aWhichFlags should only be compression or dtls flag");
|
|
|
|
if (NS_MATHML_IS_COMPRESSED(aWhichFlags)) {
|
|
// updating the compression flag is allowed
|
|
if (NS_MATHML_IS_COMPRESSED(aFlagsValues)) {
|
|
// 'compressed' means 'prime' style in App. G, TeXbook
|
|
mPresentationData.flags |= NS_MATHML_COMPRESSED;
|
|
}
|
|
// no else. the flag is sticky. it retains its value once it is set
|
|
}
|
|
// These flags determine whether the dtls font feature settings should
|
|
// be applied.
|
|
if (NS_MATHML_IS_DTLS_SET(aWhichFlags)) {
|
|
if (NS_MATHML_IS_DTLS_SET(aFlagsValues)) {
|
|
mPresentationData.flags |= NS_MATHML_DTLS;
|
|
} else {
|
|
mPresentationData.flags &= ~NS_MATHML_DTLS;
|
|
}
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
// Helper to give a style context suitable for doing the stretching of
|
|
// a MathMLChar. Frame classes that use this should ensure that the
|
|
// extra leaf style contexts given to the MathMLChars are accessible to
|
|
// the Style System via the Get/Set AdditionalStyleContext() APIs.
|
|
/* static */ void
|
|
nsMathMLFrame::ResolveMathMLCharStyle(nsPresContext* aPresContext,
|
|
nsIContent* aContent,
|
|
nsStyleContext* aParentStyleContext,
|
|
nsMathMLChar* aMathMLChar)
|
|
{
|
|
CSSPseudoElementType pseudoType =
|
|
CSSPseudoElementType::mozMathAnonymous; // savings
|
|
RefPtr<nsStyleContext> newStyleContext;
|
|
newStyleContext = aPresContext->StyleSet()->
|
|
ResolvePseudoElementStyle(aContent->AsElement(), pseudoType,
|
|
aParentStyleContext, nullptr);
|
|
|
|
aMathMLChar->SetStyleContext(newStyleContext);
|
|
}
|
|
|
|
/* static */ void
|
|
nsMathMLFrame::GetEmbellishDataFrom(nsIFrame* aFrame,
|
|
nsEmbellishData& aEmbellishData)
|
|
{
|
|
// initialize OUT params
|
|
aEmbellishData.flags = 0;
|
|
aEmbellishData.coreFrame = nullptr;
|
|
aEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED;
|
|
aEmbellishData.leadingSpace = 0;
|
|
aEmbellishData.trailingSpace = 0;
|
|
|
|
if (aFrame && aFrame->IsFrameOfType(nsIFrame::eMathML)) {
|
|
nsIMathMLFrame* mathMLFrame = do_QueryFrame(aFrame);
|
|
if (mathMLFrame) {
|
|
mathMLFrame->GetEmbellishData(aEmbellishData);
|
|
}
|
|
}
|
|
}
|
|
|
|
// helper to get the presentation data of a frame, by possibly walking up
|
|
// the frame hierarchy if we happen to be surrounded by non-MathML frames.
|
|
/* static */ void
|
|
nsMathMLFrame::GetPresentationDataFrom(nsIFrame* aFrame,
|
|
nsPresentationData& aPresentationData,
|
|
bool aClimbTree)
|
|
{
|
|
// initialize OUT params
|
|
aPresentationData.flags = 0;
|
|
aPresentationData.baseFrame = nullptr;
|
|
|
|
nsIFrame* frame = aFrame;
|
|
while (frame) {
|
|
if (frame->IsFrameOfType(nsIFrame::eMathML)) {
|
|
nsIMathMLFrame* mathMLFrame = do_QueryFrame(frame);
|
|
if (mathMLFrame) {
|
|
mathMLFrame->GetPresentationData(aPresentationData);
|
|
break;
|
|
}
|
|
}
|
|
// stop if the caller doesn't want to lookup beyond the frame
|
|
if (!aClimbTree) {
|
|
break;
|
|
}
|
|
// stop if we reach the root <math> tag
|
|
nsIContent* content = frame->GetContent();
|
|
NS_ASSERTION(content || !frame->GetParent(), // no assert for the root
|
|
"dangling frame without a content node");
|
|
if (!content)
|
|
break;
|
|
|
|
if (content->IsMathMLElement(nsGkAtoms::math)) {
|
|
break;
|
|
}
|
|
frame = frame->GetParent();
|
|
}
|
|
NS_WARN_IF_FALSE(frame && frame->GetContent(),
|
|
"bad MathML markup - could not find the top <math> element");
|
|
}
|
|
|
|
/* static */ void
|
|
nsMathMLFrame::GetRuleThickness(DrawTarget* aDrawTarget,
|
|
nsFontMetrics* aFontMetrics,
|
|
nscoord& aRuleThickness)
|
|
{
|
|
nscoord xHeight = aFontMetrics->XHeight();
|
|
char16_t overBar = 0x00AF;
|
|
nsBoundingMetrics bm =
|
|
nsLayoutUtils::AppUnitBoundsOfString(&overBar, 1, *aFontMetrics,
|
|
aDrawTarget);
|
|
aRuleThickness = bm.ascent + bm.descent;
|
|
if (aRuleThickness <= 0 || aRuleThickness >= xHeight) {
|
|
// fall-back to the other version
|
|
GetRuleThickness(aFontMetrics, aRuleThickness);
|
|
}
|
|
}
|
|
|
|
/* static */ void
|
|
nsMathMLFrame::GetAxisHeight(DrawTarget* aDrawTarget,
|
|
nsFontMetrics* aFontMetrics,
|
|
nscoord& aAxisHeight)
|
|
{
|
|
gfxFont* mathFont = aFontMetrics->GetThebesFontGroup()->GetFirstMathFont();
|
|
if (mathFont) {
|
|
aAxisHeight =
|
|
mathFont->GetMathConstant(gfxFontEntry::AxisHeight,
|
|
aFontMetrics->AppUnitsPerDevPixel());
|
|
return;
|
|
}
|
|
|
|
nscoord xHeight = aFontMetrics->XHeight();
|
|
char16_t minus = 0x2212; // not '-', but official Unicode minus sign
|
|
nsBoundingMetrics bm =
|
|
nsLayoutUtils::AppUnitBoundsOfString(&minus, 1, *aFontMetrics, aDrawTarget);
|
|
aAxisHeight = bm.ascent - (bm.ascent + bm.descent)/2;
|
|
if (aAxisHeight <= 0 || aAxisHeight >= xHeight) {
|
|
// fall-back to the other version
|
|
GetAxisHeight(aFontMetrics, aAxisHeight);
|
|
}
|
|
}
|
|
|
|
/* static */ nscoord
|
|
nsMathMLFrame::CalcLength(nsPresContext* aPresContext,
|
|
nsStyleContext* aStyleContext,
|
|
const nsCSSValue& aCSSValue,
|
|
float aFontSizeInflation)
|
|
{
|
|
NS_ASSERTION(aCSSValue.IsLengthUnit(), "not a length unit");
|
|
|
|
if (aCSSValue.IsFixedLengthUnit()) {
|
|
return aCSSValue.GetFixedLength(aPresContext);
|
|
}
|
|
if (aCSSValue.IsPixelLengthUnit()) {
|
|
return aCSSValue.GetPixelLength();
|
|
}
|
|
|
|
nsCSSUnit unit = aCSSValue.GetUnit();
|
|
|
|
if (eCSSUnit_EM == unit) {
|
|
const nsStyleFont* font = aStyleContext->StyleFont();
|
|
return NSToCoordRound(aCSSValue.GetFloatValue() * (float)font->mFont.size);
|
|
}
|
|
else if (eCSSUnit_XHeight == unit) {
|
|
aPresContext->SetUsesExChUnits(true);
|
|
RefPtr<nsFontMetrics> fm = nsLayoutUtils::
|
|
GetFontMetricsForStyleContext(aStyleContext, aFontSizeInflation);
|
|
nscoord xHeight = fm->XHeight();
|
|
return NSToCoordRound(aCSSValue.GetFloatValue() * (float)xHeight);
|
|
}
|
|
|
|
// MathML doesn't specify other CSS units such as rem or ch
|
|
NS_ERROR("Unsupported unit");
|
|
return 0;
|
|
}
|
|
|
|
/* static */ void
|
|
nsMathMLFrame::ParseNumericValue(const nsString& aString,
|
|
nscoord* aLengthValue,
|
|
uint32_t aFlags,
|
|
nsPresContext* aPresContext,
|
|
nsStyleContext* aStyleContext,
|
|
float aFontSizeInflation)
|
|
{
|
|
nsCSSValue cssValue;
|
|
|
|
if (!nsMathMLElement::ParseNumericValue(aString, cssValue, aFlags,
|
|
aPresContext->Document())) {
|
|
// Invalid attribute value. aLengthValue remains unchanged, so the default
|
|
// length value is used.
|
|
return;
|
|
}
|
|
|
|
nsCSSUnit unit = cssValue.GetUnit();
|
|
|
|
if (unit == eCSSUnit_Percent || unit == eCSSUnit_Number) {
|
|
// Relative units. A multiple of the default length value is used.
|
|
*aLengthValue = NSToCoordRound(*aLengthValue * (unit == eCSSUnit_Percent ?
|
|
cssValue.GetPercentValue() :
|
|
cssValue.GetFloatValue()));
|
|
return;
|
|
}
|
|
|
|
// Absolute units.
|
|
*aLengthValue = CalcLength(aPresContext, aStyleContext, cssValue,
|
|
aFontSizeInflation);
|
|
}
|
|
|
|
// ================
|
|
// Utils to map attributes into CSS rules (work-around to bug 69409 which
|
|
// is not scheduled to be fixed anytime soon)
|
|
//
|
|
|
|
struct
|
|
nsCSSMapping {
|
|
int32_t compatibility;
|
|
const nsIAtom* attrAtom;
|
|
const char* cssProperty;
|
|
};
|
|
|
|
#if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
|
|
class nsDisplayMathMLBoundingMetrics : public nsDisplayItem {
|
|
public:
|
|
nsDisplayMathMLBoundingMetrics(nsDisplayListBuilder* aBuilder,
|
|
nsIFrame* aFrame, const nsRect& aRect)
|
|
: nsDisplayItem(aBuilder, aFrame), mRect(aRect) {
|
|
MOZ_COUNT_CTOR(nsDisplayMathMLBoundingMetrics);
|
|
}
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
virtual ~nsDisplayMathMLBoundingMetrics() {
|
|
MOZ_COUNT_DTOR(nsDisplayMathMLBoundingMetrics);
|
|
}
|
|
#endif
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx) override;
|
|
NS_DISPLAY_DECL_NAME("MathMLBoundingMetrics", TYPE_MATHML_BOUNDING_METRICS)
|
|
private:
|
|
nsRect mRect;
|
|
};
|
|
|
|
void nsDisplayMathMLBoundingMetrics::Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx)
|
|
{
|
|
DrawTarget* drawTarget = aCtx->GetDrawTarget();
|
|
Rect r = NSRectToRect(mRect + ToReferenceFrame(),
|
|
mFrame->PresContext()->AppUnitsPerDevPixel());
|
|
ColorPattern blue(ToDeviceColor(Color(0.f, 0.f, 1.f, 1.f)));
|
|
drawTarget->StrokeRect(r, blue);
|
|
}
|
|
|
|
void
|
|
nsMathMLFrame::DisplayBoundingMetrics(nsDisplayListBuilder* aBuilder,
|
|
nsIFrame* aFrame, const nsPoint& aPt,
|
|
const nsBoundingMetrics& aMetrics,
|
|
const nsDisplayListSet& aLists) {
|
|
if (!NS_MATHML_PAINT_BOUNDING_METRICS(mPresentationData.flags))
|
|
return;
|
|
|
|
nscoord x = aPt.x + aMetrics.leftBearing;
|
|
nscoord y = aPt.y - aMetrics.ascent;
|
|
nscoord w = aMetrics.rightBearing - aMetrics.leftBearing;
|
|
nscoord h = aMetrics.ascent + aMetrics.descent;
|
|
|
|
aLists.Content()->AppendNewToTop(new (aBuilder)
|
|
nsDisplayMathMLBoundingMetrics(aBuilder, aFrame, nsRect(x,y,w,h)));
|
|
}
|
|
#endif
|
|
|
|
class nsDisplayMathMLBar : public nsDisplayItem {
|
|
public:
|
|
nsDisplayMathMLBar(nsDisplayListBuilder* aBuilder,
|
|
nsIFrame* aFrame, const nsRect& aRect)
|
|
: nsDisplayItem(aBuilder, aFrame), mRect(aRect) {
|
|
MOZ_COUNT_CTOR(nsDisplayMathMLBar);
|
|
}
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
virtual ~nsDisplayMathMLBar() {
|
|
MOZ_COUNT_DTOR(nsDisplayMathMLBar);
|
|
}
|
|
#endif
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx) override;
|
|
NS_DISPLAY_DECL_NAME("MathMLBar", TYPE_MATHML_BAR)
|
|
private:
|
|
nsRect mRect;
|
|
};
|
|
|
|
void nsDisplayMathMLBar::Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx)
|
|
{
|
|
// paint the bar with the current text color
|
|
DrawTarget* drawTarget = aCtx->GetDrawTarget();
|
|
Rect rect =
|
|
NSRectToNonEmptySnappedRect(mRect + ToReferenceFrame(),
|
|
mFrame->PresContext()->AppUnitsPerDevPixel(),
|
|
*drawTarget);
|
|
nsCSSProperty colorProp = mFrame->StyleContext()->GetTextFillColorProp();
|
|
ColorPattern color(ToDeviceColor(
|
|
mFrame->GetVisitedDependentColor(colorProp)));
|
|
drawTarget->FillRect(rect, color);
|
|
}
|
|
|
|
void
|
|
nsMathMLFrame::DisplayBar(nsDisplayListBuilder* aBuilder,
|
|
nsIFrame* aFrame, const nsRect& aRect,
|
|
const nsDisplayListSet& aLists) {
|
|
if (!aFrame->StyleVisibility()->IsVisible() || aRect.IsEmpty())
|
|
return;
|
|
|
|
aLists.Content()->AppendNewToTop(new (aBuilder)
|
|
nsDisplayMathMLBar(aBuilder, aFrame, aRect));
|
|
}
|
|
|
|
void
|
|
nsMathMLFrame::GetRadicalParameters(nsFontMetrics* aFontMetrics,
|
|
bool aDisplayStyle,
|
|
nscoord& aRadicalRuleThickness,
|
|
nscoord& aRadicalExtraAscender,
|
|
nscoord& aRadicalVerticalGap)
|
|
{
|
|
nscoord oneDevPixel = aFontMetrics->AppUnitsPerDevPixel();
|
|
gfxFont* mathFont = aFontMetrics->GetThebesFontGroup()->GetFirstMathFont();
|
|
|
|
// get the radical rulethickness
|
|
if (mathFont) {
|
|
aRadicalRuleThickness =
|
|
mathFont->GetMathConstant(gfxFontEntry::RadicalRuleThickness,
|
|
oneDevPixel);
|
|
} else {
|
|
GetRuleThickness(aFontMetrics, aRadicalRuleThickness);
|
|
}
|
|
|
|
// get the leading to be left at the top of the resulting frame
|
|
if (mathFont) {
|
|
aRadicalExtraAscender =
|
|
mathFont->GetMathConstant(gfxFontEntry::RadicalExtraAscender,
|
|
oneDevPixel);
|
|
} else {
|
|
// This seems more reliable than using aFontMetrics->GetLeading() on
|
|
// suspicious fonts.
|
|
nscoord em;
|
|
GetEmHeight(aFontMetrics, em);
|
|
aRadicalExtraAscender = nscoord(0.2f * em);
|
|
}
|
|
|
|
// get the clearance between rule and content
|
|
if (mathFont) {
|
|
aRadicalVerticalGap =
|
|
mathFont->GetMathConstant(aDisplayStyle ?
|
|
gfxFontEntry::RadicalDisplayStyleVerticalGap :
|
|
gfxFontEntry::RadicalVerticalGap,
|
|
oneDevPixel);
|
|
} else {
|
|
// Rule 11, App. G, TeXbook
|
|
aRadicalVerticalGap = aRadicalRuleThickness +
|
|
(aDisplayStyle ? aFontMetrics->XHeight() : aRadicalRuleThickness) / 4;
|
|
}
|
|
}
|