mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
8a0a002cf2
- Bug 1148708: Add missing 'override' annotations in DocAccessibleChild.h. rs=ehsan (d606358545)
- Bug 1210408 - make nsMaiInterfaceAction work with proxies, r=tbsaunde (f7c819c6ae)
- Bug 1210407 - teach nsMaiInterfaceTable to use proxies, r=tbsaunde (4ca4f10b5f)
- bug 1185157 make sure we don't send an event to a destroyed ipc document r=billm (23acf53f75)
- bug 1214864 - make SetCarretOffset() async r=davidb (e3079e9b2d)
- missing of Bug 1139972 - IPC Proxy for charAt, r=tbsaunde (e9593ed752)
- bug 1191598 - Pass MOZ_CURRENT_PROJECT in environment when running post-build automation steps for universal mac builds. r=gps (fc342c6ced)
- Bug 1164596 - Add mach android-emulator command; r=ahal (afeb9b27d1)
- Bug 1223149 - Add basic usage documentation for mach build; r=glandium (bfb802d175)
- Bug 1182301 - Improve 'mach build' notifications. r=gps (2c65a122d1)
- Bug 1184696 - Add clobber targets to |mach clobber|; Ability to clobber compiled python files, r=gps (35d8be292e)
- Bug 1117958 - Allow any debugging options to the run or gtest mach subcommands to automatically enable debugging. r=gps (32f986af4b)
- Bug 1180081 - Properly rebuild gtest/libxul before running gtests. r=gps (80db9a3d49)
- Bug 1171647, part 1 - Define a new function to convert the mode to a string. r=njn (61ad16f5ba)
- Bug 1171647, part 2 - Remove redundant assertion for dark matter mode. r=njn (b5ac9519f3)
- Bug 1058178, part 1 - Implement DMD heap scanning mode. r=njn (60e1079536)
- Bug 1058178, part 2 - Implement address clamping analysis for DMD scan logs. r=njn (45c0326b93)
- Bug 1102388 - Fix DMD static constructor ordering dependency. r=mccr8 (59b87897a1)
- Bug 1128705 - Don't redefine PAGE_SIZE in DMD if it's already defined. r=erahm (49216348ee)
- Bug 1179042 - Add a script for analyzing memory blocks using a heap scan DMD log. r=njn DONTBUILD (1c08d2d66e)
- Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat (1c999d139b)
- Bug 1158772 - fix non-idiomatic memset call in nsDeque.cpp; r=erahm (de6b555245)
- Bug 1199400 - Part 1: Use CheckedInt when growing nsDeque capacity. r=froydnj (dfdf6814a3)
- Bug 1199400 - Part 0: Remove unused nsDequeIterator. r=froydnj (38d69d7f47)
- Bug 1199400 - Part 2: Add tests for possible nsDeque corner cases. r=froydnj (931baff195)
- Bug 1201997 - Part 1 - Converted compiled test to gtest for nsDeque class. Added tests to test untested methods. r=froydn (e893916651)
- Bug 1201997 - Part 2 - Removing unused methods from the nsDeque class. r=froydn (41595a90ac)
- Bug 1201997 - Part 3 - Make internally used methods private. r=froydn (8cd3afd96f)
- Bug 1201997 - Part 4 - Change size and offset variables to size_t.r=froydn (73eabc8d60)
- Bug 1215140 P1 Add an nsIConsoleReportCollector interface to support navigation channel logging. r=bz (8a41535e2b)
- Bug 1215140 P2 Make HttpBaseChannel implement nsIConsoleReportCollector. r=bz (75fca301f2)
- Bug 1197679 - If nsUnknownDecoder is involved in e10s DivertToParent can break. r=jduell (5d94a12504)
- Bug 1178991 - smartptr for http converter r=hurley (8e7fbc8443)
- bug 366559 - patch 2, fix nsHTTPCompressConv indentation r=bagder (ba762da587)
- bug 366559 - patch 3, fix nsHTTPCompressConv bracing style r=bagder (54195ab451)
- bits of bug 366559 - patch 7, content-encoding brotli for http (f0b4051022)
- Bug 1205112 - Make PushEvent.data nullable. r=mt,smaug (775db32856)
- Bug 1193414 - SharedWorkers thread should be kept alive also when the SharedWorker object is CCed, r=khuey (b77ea8125c)
- Bug 1206520: Add about:config prefs to enable throwing on asm.js validation failures; r=bz (c42126665d)
- Bug 1193414 - Telemetry for SharedWorker spawning. r=bkelly (77984b7bcc)
- Bug 1205676 - Enable WPT service-worker/unregister-then-register-new-script.https.html in e10s, r=nsm (ec24939cf6)
- Bug 1193133 - Throw when calling postMessage from a Service Worker dom object with no global. r=bkelly (526dcacfab)
- Bug 1181871 P1 Only enforce Cache Context shared data destruction on target thread after init. r=ehsan (cdbf3ed3a8)
- Bug 1181871 P2 Fix ServiceWorkerManager usage of stack-based ErrorResult. r=ehsan (c449195d90)
- minor cleanup and missing bit of 1198230 (02f459db05)
- Bug 1143717 - Implement the ServiceWorkerMessageEvent interface. r=baku (027b3465f2)
- fix misspatch (708eee4e84)
- Bug 1188545 - Disentangle service workers from shared workers and refactor event dispatching code into a separate class. r=nsm,mrbkap (fb5b5341c9)
- Bug 1205228 - Change PackagedAppVerifier to notify the verification result asynchronously. r=valentin. (9edda0fa00)
- Bug 1178518 - Packaged App Utils. r=valentin (f60f3b7a93)
- Bug 1213150 - Part 1: Add a nsContentUtils::IsNonSubresourceRequest helper; r=jdm (b509cc3cc9)
- Bug 1213150 - Part 2: Rework ShouldPrepareForIntercept() in terms of subresource requests; r=jdm (2e92fe8780)
- Bug 1213150 - Part 3: Remove nsIInterceptedChannel.isNavigation; r=jdm (becf1cc12f)
- Bug 1213150 follow-up: fix build bustage (8d73d6ca73)
- Bug 1198394 - Part 1: Allow interception of HSTS upgraded connections in non-e10s mode; r=mcmanus (f504c5be08)
- Bug 1198394 - Part 2: Add a test for interception of HSTS upgraded connections; r=jdm (054e984eef)
- Bug 1187011 - Don't allow response body with null body status. r=bkelly (b1860741d1)
- missing bit of 1140788 (29d319712e)
- Bug 1213436 - Reject core dumps with node IDs that don't fit in an IEEE 754 double; r=sfink (3c1f6fdda0)
- Bug 1211006 - Add Debugger.Source.prototype.canonicalId; r=ejpbruel (eef7b79fce)
- Bug 1199218 - Implement JS::ubi::Node::size for js::LazyScript referents; r=sfink (098a48d240)
- Bug 1220031 - Add JS::ubi::Node::scriptFilename; r=sfink (6b824ae680)
- Bug 1143575. Remove unused MediaQueue::Empty. r=cpearce (de737f3433)
- Bug 1209933 - Make sure all parent runtime pointers are the topmost parent, r=billm. (fe824d967d)
- Bug 1197012 - Fix ThrowTypeError in Notification. r=mccr8 (0b1a097526)
- Bug 1197893 - Check the number of arguments for ThrowTypeError() and ThrowRangeError() at compile time. r=peterv (d98c7d78a0)
- Bug 1142083 - Add test for IDN Unicode domain redirect. r=mcmanus (0c8961fe17)
- Bug 1187159 - Add mochitest for loading packaged apps (iframe+fetch+mozapp) r=jduell (ce90ea561b)
- Bug 1186290 - Notify TabParent to switch process when loading a signed package. r=honzab, r=kanru. (c58a14554a)
- fix (15e2df75eb)
- Bug 1206124 P1 Fix "same-origin" CORS credentials in FetchDriver. r=ehsan (fae1bb6ab3)
- Bug 1206124 P2 Test fetch() with credentials and redirects. r=ehsan (ffc6254112)
- Bug 1211751: Remove nsIChannelEventSink-forwarding from EventSource and FetchDriver. It's never needed. r=smaug (adafe5737a)
- Bug 1212433 Fail fetch() calls that require preflight and also redirect. r=sicking a=abillings (c0d6742b9e)
- Bug 1193128 - Fix base64 decoding when fetching data URIs. r=baku (80bafa291a)
- Bug 1195167 part 1: Let necko handle all protocols. r=bkelly (bb932b0ada)
- Bug 1195167 part 2: Remove redundant aCORSFlag argument and instead use mCORSFlagEverSet. r=bkelly (beadafcad0)
- Bug 1195167 part 3: Remove more scheme-specific handling from FetchDriver. r=bkelly (d00b38db9e)
- Bug 1195167 part 4: Remove FetchDriver::BasicFetch since it is empty. r=bkelly (c5ed097267)
- Bug 1210413 P2 Test CORS credentials on cross-origin redirects. r=sicking a=dveditz (b4eeb8aac0)
- Bug 1210413 P1 Propagate new channel load flags from child to parent on redirect. r=jduell a=dveditz (8b329af4fa)
- Bug 1195167 part 5: Make FetchDriver use AsyncOpen2. r=bkelly (cc217c4cc1)
- Bug 1195167 part 6: Some code simplification since necko handles fetch recursion. r=bkelly (f3b6da2262)
- Bug 1195167: Followup to fix test which I forgot to change (81e7439a2e)
- Bug 1215746: Remove RequestMode::Cors_with_forced_preflight. r=bkelly (0336e812b6)
- Bug 1211000: Move CORS preflight logic from nsCORSListenerProxy to nsCORSPreflightListener. r=ehsan (bf2f71cf22)
- missing bit of Bug 1211443 - Drop scheduled update if decoder initialization isn't done yet. r=jya (f6bc074e33)
- Bug 1182571: Fix nsILoadInfo->GetContentPolicyType API to be less ambigious. Audit and fix all users of it. r=ckerschb (5af6fa7442)
- fix (e40c8e7625)
- Bug 1173811 - Part 1: Propagate the response URL to intercepted channels when necessary (non-e10s). r=mayhemer,bkelly (26f4f13c28)
- Bug 1173811 - Part 2: Propagate the response URL to intercepted channels when necessary (e10s). r=mayhemer,bkelly (a603fe1df2)
- Bug 1154309 - Add New Resource Timing Fields r=bz,hurley (1d14eb6bef)
- Bug 1175685 - add OriginAttribute to LoadInfo. r=jonas, r=ckerschb, r=michal (a5d18bb637)
- Bug 1175685 - add OriginAttribute to LoadInfo. r=jonas, r=ckerschb, r=michal (fb07d2c8aa)
- Bug 1212904 P1 Add a LoadTainting enumeration. r=jduell (a1db8a3e99)
- Bug 1212904 P2 Add LoadTainting information to nsILoadInfo. r=jduell (2482e5e334)
- Bug 1221151 - use [infallible] in nsILoadInfo.idl instead of manual %{C++ blocks; r=jduell (aae73129b6)
- Bug 1045891 - CSP 2 child-src implementation r=ckerschb (792920aeb9)
- Bug 1219931 - CSP: Don't allow removing a policy (r=sicking) (9daaab4186)
- Bug 1208661 - Dump client-side layer textures. r=BenWa (1f2d17d515)
653 lines
24 KiB
C++
653 lines
24 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 "nsMathMLmfracFrame.h"
|
|
|
|
#include "gfxUtils.h"
|
|
#include "mozilla/gfx/2D.h"
|
|
#include "mozilla/RefPtr.h"
|
|
#include "nsLayoutUtils.h"
|
|
#include "nsPresContext.h"
|
|
#include "nsRenderingContext.h"
|
|
#include "nsDisplayList.h"
|
|
#include "gfxContext.h"
|
|
#include "nsMathMLElement.h"
|
|
#include <algorithm>
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::gfx;
|
|
|
|
//
|
|
// <mfrac> -- form a fraction from two subexpressions - implementation
|
|
//
|
|
|
|
// various fraction line thicknesses (multiplicative values of the default rule thickness)
|
|
|
|
#define THIN_FRACTION_LINE 0.5f
|
|
#define THIN_FRACTION_LINE_MINIMUM_PIXELS 1 // minimum of 1 pixel
|
|
|
|
#define THICK_FRACTION_LINE 2.0f
|
|
#define THICK_FRACTION_LINE_MINIMUM_PIXELS 2 // minimum of 2 pixels
|
|
|
|
nsIFrame*
|
|
NS_NewMathMLmfracFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
{
|
|
return new (aPresShell) nsMathMLmfracFrame(aContext);
|
|
}
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmfracFrame)
|
|
|
|
nsMathMLmfracFrame::~nsMathMLmfracFrame()
|
|
{
|
|
}
|
|
|
|
eMathMLFrameType
|
|
nsMathMLmfracFrame::GetMathMLFrameType()
|
|
{
|
|
// frac is "inner" in TeXBook, Appendix G, rule 15e. See also page 170.
|
|
return eMathMLFrameType_Inner;
|
|
}
|
|
|
|
uint8_t
|
|
nsMathMLmfracFrame::ScriptIncrement(nsIFrame* aFrame)
|
|
{
|
|
if (!StyleFont()->mMathDisplay &&
|
|
aFrame && (mFrames.FirstChild() == aFrame ||
|
|
mFrames.LastChild() == aFrame)) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMathMLmfracFrame::TransmitAutomaticData()
|
|
{
|
|
// The TeXbook (Ch 17. p.141) says the numerator inherits the compression
|
|
// while the denominator is compressed
|
|
UpdatePresentationDataFromChildAt(1, 1,
|
|
NS_MATHML_COMPRESSED,
|
|
NS_MATHML_COMPRESSED);
|
|
|
|
// If displaystyle is false, then scriptlevel is incremented, so notify the
|
|
// children of this.
|
|
if (!StyleFont()->mMathDisplay) {
|
|
PropagateFrameFlagFor(mFrames.FirstChild(),
|
|
NS_FRAME_MATHML_SCRIPT_DESCENDANT);
|
|
PropagateFrameFlagFor(mFrames.LastChild(),
|
|
NS_FRAME_MATHML_SCRIPT_DESCENDANT);
|
|
}
|
|
|
|
// if our numerator is an embellished operator, let its state bubble to us
|
|
GetEmbellishDataFrom(mFrames.FirstChild(), mEmbellishData);
|
|
if (NS_MATHML_IS_EMBELLISH_OPERATOR(mEmbellishData.flags)) {
|
|
// even when embellished, we need to record that <mfrac> won't fire
|
|
// Stretch() on its embellished child
|
|
mEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
nscoord
|
|
nsMathMLmfracFrame::CalcLineThickness(nsPresContext* aPresContext,
|
|
nsStyleContext* aStyleContext,
|
|
nsString& aThicknessAttribute,
|
|
nscoord onePixel,
|
|
nscoord aDefaultRuleThickness,
|
|
float aFontSizeInflation)
|
|
{
|
|
nscoord defaultThickness = aDefaultRuleThickness;
|
|
nscoord lineThickness = aDefaultRuleThickness;
|
|
nscoord minimumThickness = onePixel;
|
|
|
|
// linethickness
|
|
//
|
|
// "Specifies the thickness of the horizontal 'fraction bar', or 'rule'. The
|
|
// default value is 'medium', 'thin' is thinner, but visible, 'thick' is
|
|
// thicker; the exact thickness of these is left up to the rendering agent."
|
|
//
|
|
// values: length | "thin" | "medium" | "thick"
|
|
// default: medium
|
|
//
|
|
if (!aThicknessAttribute.IsEmpty()) {
|
|
if (aThicknessAttribute.EqualsLiteral("thin")) {
|
|
lineThickness = NSToCoordFloor(defaultThickness * THIN_FRACTION_LINE);
|
|
minimumThickness = onePixel * THIN_FRACTION_LINE_MINIMUM_PIXELS;
|
|
// should visually decrease by at least one pixel, if default is not a pixel
|
|
if (defaultThickness > onePixel && lineThickness > defaultThickness - onePixel)
|
|
lineThickness = defaultThickness - onePixel;
|
|
}
|
|
else if (aThicknessAttribute.EqualsLiteral("medium")) {
|
|
// medium is default
|
|
}
|
|
else if (aThicknessAttribute.EqualsLiteral("thick")) {
|
|
lineThickness = NSToCoordCeil(defaultThickness * THICK_FRACTION_LINE);
|
|
minimumThickness = onePixel * THICK_FRACTION_LINE_MINIMUM_PIXELS;
|
|
// should visually increase by at least one pixel
|
|
if (lineThickness < defaultThickness + onePixel)
|
|
lineThickness = defaultThickness + onePixel;
|
|
}
|
|
else {
|
|
// length value
|
|
lineThickness = defaultThickness;
|
|
ParseNumericValue(aThicknessAttribute, &lineThickness,
|
|
nsMathMLElement::PARSE_ALLOW_UNITLESS,
|
|
aPresContext, aStyleContext, aFontSizeInflation);
|
|
}
|
|
}
|
|
|
|
// use minimum if the lineThickness is a non-zero value less than minimun
|
|
if (lineThickness && lineThickness < minimumThickness)
|
|
lineThickness = minimumThickness;
|
|
|
|
return lineThickness;
|
|
}
|
|
|
|
void
|
|
nsMathMLmfracFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
const nsRect& aDirtyRect,
|
|
const nsDisplayListSet& aLists)
|
|
{
|
|
/////////////
|
|
// paint the numerator and denominator
|
|
nsMathMLContainerFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
|
|
|
/////////////
|
|
// paint the fraction line
|
|
if (mIsBevelled) {
|
|
DisplaySlash(aBuilder, this, mLineRect, mLineThickness, aLists);
|
|
} else {
|
|
DisplayBar(aBuilder, this, mLineRect, aLists);
|
|
}
|
|
}
|
|
|
|
/* virtual */ nsresult
|
|
nsMathMLmfracFrame::MeasureForWidth(nsRenderingContext& aRenderingContext,
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
|
{
|
|
return PlaceInternal(aRenderingContext,
|
|
false,
|
|
aDesiredSize,
|
|
true);
|
|
}
|
|
|
|
nscoord
|
|
nsMathMLmfracFrame::FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
|
|
{
|
|
nscoord gap = nsMathMLContainerFrame::FixInterFrameSpacing(aDesiredSize);
|
|
if (!gap) return 0;
|
|
|
|
mLineRect.MoveBy(gap, 0);
|
|
return gap;
|
|
}
|
|
|
|
/* virtual */ nsresult
|
|
nsMathMLmfracFrame::Place(nsRenderingContext& aRenderingContext,
|
|
bool aPlaceOrigin,
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
|
{
|
|
return PlaceInternal(aRenderingContext,
|
|
aPlaceOrigin,
|
|
aDesiredSize,
|
|
false);
|
|
}
|
|
|
|
nsresult
|
|
nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
|
bool aPlaceOrigin,
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
bool aWidthOnly)
|
|
{
|
|
////////////////////////////////////
|
|
// Get the children's desired sizes
|
|
nsBoundingMetrics bmNum, bmDen;
|
|
nsHTMLReflowMetrics sizeNum(aDesiredSize.GetWritingMode());
|
|
nsHTMLReflowMetrics sizeDen(aDesiredSize.GetWritingMode());
|
|
nsIFrame* frameDen = nullptr;
|
|
nsIFrame* frameNum = mFrames.FirstChild();
|
|
if (frameNum)
|
|
frameDen = frameNum->GetNextSibling();
|
|
if (!frameNum || !frameDen || frameDen->GetNextSibling()) {
|
|
// report an error, encourage people to get their markups in order
|
|
if (aPlaceOrigin) {
|
|
ReportChildCountError();
|
|
}
|
|
return ReflowError(aRenderingContext, aDesiredSize);
|
|
}
|
|
GetReflowAndBoundingMetricsFor(frameNum, sizeNum, bmNum);
|
|
GetReflowAndBoundingMetricsFor(frameDen, sizeDen, bmDen);
|
|
|
|
nsPresContext* presContext = PresContext();
|
|
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
|
|
|
float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this);
|
|
RefPtr<nsFontMetrics> fm;
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
|
|
fontSizeInflation);
|
|
|
|
nscoord defaultRuleThickness, axisHeight;
|
|
nscoord oneDevPixel = fm->AppUnitsPerDevPixel();
|
|
gfxFont* mathFont = fm->GetThebesFontGroup()->GetFirstMathFont();
|
|
if (mathFont) {
|
|
defaultRuleThickness =
|
|
mathFont->GetMathConstant(gfxFontEntry::FractionRuleThickness,
|
|
oneDevPixel);
|
|
} else {
|
|
GetRuleThickness(aRenderingContext, fm, defaultRuleThickness);
|
|
}
|
|
GetAxisHeight(aRenderingContext, fm, axisHeight);
|
|
|
|
bool outermostEmbellished = false;
|
|
if (mEmbellishData.coreFrame) {
|
|
nsEmbellishData parentData;
|
|
GetEmbellishDataFrom(GetParent(), parentData);
|
|
outermostEmbellished = parentData.coreFrame != mEmbellishData.coreFrame;
|
|
}
|
|
|
|
// see if the linethickness attribute is there
|
|
nsAutoString value;
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::linethickness_, value);
|
|
mLineThickness = CalcLineThickness(presContext, mStyleContext, value,
|
|
onePixel, defaultRuleThickness,
|
|
fontSizeInflation);
|
|
|
|
// bevelled attribute
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::bevelled_, value);
|
|
mIsBevelled = value.EqualsLiteral("true");
|
|
|
|
bool displayStyle = StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK;
|
|
|
|
if (!mIsBevelled) {
|
|
mLineRect.height = mLineThickness;
|
|
|
|
// by default, leave at least one-pixel padding at either end, and add
|
|
// lspace & rspace that may come from <mo> if we are an outermost
|
|
// embellished container (we fetch values from the core since they may use
|
|
// units that depend on style data, and style changes could have occurred
|
|
// in the core since our last visit there)
|
|
nscoord leftSpace = onePixel;
|
|
nscoord rightSpace = onePixel;
|
|
if (outermostEmbellished) {
|
|
nsEmbellishData coreData;
|
|
GetEmbellishDataFrom(mEmbellishData.coreFrame, coreData);
|
|
leftSpace += StyleVisibility()->mDirection ?
|
|
coreData.trailingSpace : coreData.leadingSpace;
|
|
rightSpace += StyleVisibility()->mDirection ?
|
|
coreData.leadingSpace : coreData.trailingSpace;
|
|
}
|
|
|
|
nscoord actualRuleThickness = mLineThickness;
|
|
|
|
//////////////////
|
|
// Get shifts
|
|
nscoord numShift = 0;
|
|
nscoord denShift = 0;
|
|
|
|
// Rule 15b, App. G, TeXbook
|
|
nscoord numShift1, numShift2, numShift3;
|
|
nscoord denShift1, denShift2;
|
|
|
|
GetNumeratorShifts(fm, numShift1, numShift2, numShift3);
|
|
GetDenominatorShifts(fm, denShift1, denShift2);
|
|
|
|
if (0 == actualRuleThickness) {
|
|
numShift = displayStyle ? numShift1 : numShift3;
|
|
denShift = displayStyle ? denShift1 : denShift2;
|
|
if (mathFont) {
|
|
numShift = mathFont->
|
|
GetMathConstant(displayStyle ?
|
|
gfxFontEntry::StackTopDisplayStyleShiftUp :
|
|
gfxFontEntry::StackTopShiftUp,
|
|
oneDevPixel);
|
|
denShift = mathFont->
|
|
GetMathConstant(displayStyle ?
|
|
gfxFontEntry::StackBottomDisplayStyleShiftDown :
|
|
gfxFontEntry::StackBottomShiftDown,
|
|
oneDevPixel);
|
|
}
|
|
} else {
|
|
numShift = displayStyle ? numShift1 : numShift2;
|
|
denShift = displayStyle ? denShift1 : denShift2;
|
|
if (mathFont) {
|
|
numShift = mathFont->
|
|
GetMathConstant(displayStyle ?
|
|
gfxFontEntry::FractionNumeratorDisplayStyleShiftUp :
|
|
gfxFontEntry::FractionNumeratorShiftUp,
|
|
oneDevPixel);
|
|
denShift = mathFont->
|
|
GetMathConstant(
|
|
displayStyle ?
|
|
gfxFontEntry::FractionDenominatorDisplayStyleShiftDown :
|
|
gfxFontEntry::FractionDenominatorShiftDown,
|
|
oneDevPixel);
|
|
}
|
|
}
|
|
|
|
if (0 == actualRuleThickness) {
|
|
// Rule 15c, App. G, TeXbook
|
|
|
|
// min clearance between numerator and denominator
|
|
nscoord minClearance = displayStyle ?
|
|
7 * defaultRuleThickness : 3 * defaultRuleThickness;
|
|
if (mathFont) {
|
|
minClearance =
|
|
mathFont->GetMathConstant(displayStyle ?
|
|
gfxFontEntry::StackDisplayStyleGapMin :
|
|
gfxFontEntry::StackGapMin,
|
|
oneDevPixel);
|
|
}
|
|
nscoord actualClearance =
|
|
(numShift - bmNum.descent) - (bmDen.ascent - denShift);
|
|
// actualClearance should be >= minClearance
|
|
if (actualClearance < minClearance) {
|
|
nscoord halfGap = (minClearance - actualClearance)/2;
|
|
numShift += halfGap;
|
|
denShift += halfGap;
|
|
}
|
|
}
|
|
else {
|
|
// Rule 15d, App. G, TeXbook
|
|
|
|
// min clearance between numerator or denominator and middle of bar
|
|
|
|
// TeX has a different interpretation of the thickness.
|
|
// Try $a \above10pt b$ to see. Here is what TeX does:
|
|
// minClearance = displayStyle ?
|
|
// 3 * actualRuleThickness : actualRuleThickness;
|
|
|
|
// we slightly depart from TeX here. We use the defaultRuleThickness instead
|
|
// of the value coming from the linethickness attribute, i.e., we recover what
|
|
// TeX does if the user hasn't set linethickness. But when the linethickness
|
|
// is set, we avoid the wide gap problem.
|
|
nscoord minClearanceNum = displayStyle ?
|
|
3 * defaultRuleThickness : defaultRuleThickness + onePixel;
|
|
nscoord minClearanceDen = minClearanceNum;
|
|
if (mathFont) {
|
|
minClearanceNum = mathFont->
|
|
GetMathConstant(displayStyle ?
|
|
gfxFontEntry::FractionNumDisplayStyleGapMin :
|
|
gfxFontEntry::FractionNumeratorGapMin,
|
|
oneDevPixel);
|
|
minClearanceDen = mathFont->
|
|
GetMathConstant(displayStyle ?
|
|
gfxFontEntry::FractionDenomDisplayStyleGapMin :
|
|
gfxFontEntry::FractionDenominatorGapMin,
|
|
oneDevPixel);
|
|
}
|
|
|
|
// adjust numShift to maintain minClearanceNum if needed
|
|
nscoord actualClearanceNum =
|
|
(numShift - bmNum.descent) - (axisHeight + actualRuleThickness/2);
|
|
if (actualClearanceNum < minClearanceNum) {
|
|
numShift += (minClearanceNum - actualClearanceNum);
|
|
}
|
|
// adjust denShift to maintain minClearanceDen if needed
|
|
nscoord actualClearanceDen =
|
|
(axisHeight - actualRuleThickness/2) - (bmDen.ascent - denShift);
|
|
if (actualClearanceDen < minClearanceDen) {
|
|
denShift += (minClearanceDen - actualClearanceDen);
|
|
}
|
|
}
|
|
|
|
//////////////////
|
|
// Place Children
|
|
|
|
// XXX Need revisiting the width. TeX uses the exact width
|
|
// e.g. in $$\huge\frac{\displaystyle\int}{i}$$
|
|
nscoord width = std::max(bmNum.width, bmDen.width);
|
|
nscoord dxNum = leftSpace + (width - sizeNum.Width())/2;
|
|
nscoord dxDen = leftSpace + (width - sizeDen.Width())/2;
|
|
width += leftSpace + rightSpace;
|
|
|
|
// see if the numalign attribute is there
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::numalign_, value);
|
|
if (value.EqualsLiteral("left"))
|
|
dxNum = leftSpace;
|
|
else if (value.EqualsLiteral("right"))
|
|
dxNum = width - rightSpace - sizeNum.Width();
|
|
|
|
// see if the denomalign attribute is there
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::denomalign_, value);
|
|
if (value.EqualsLiteral("left"))
|
|
dxDen = leftSpace;
|
|
else if (value.EqualsLiteral("right"))
|
|
dxDen = width - rightSpace - sizeDen.Width();
|
|
|
|
mBoundingMetrics.rightBearing =
|
|
std::max(dxNum + bmNum.rightBearing, dxDen + bmDen.rightBearing);
|
|
if (mBoundingMetrics.rightBearing < width - rightSpace)
|
|
mBoundingMetrics.rightBearing = width - rightSpace;
|
|
mBoundingMetrics.leftBearing =
|
|
std::min(dxNum + bmNum.leftBearing, dxDen + bmDen.leftBearing);
|
|
if (mBoundingMetrics.leftBearing > leftSpace)
|
|
mBoundingMetrics.leftBearing = leftSpace;
|
|
mBoundingMetrics.ascent = bmNum.ascent + numShift;
|
|
mBoundingMetrics.descent = bmDen.descent + denShift;
|
|
mBoundingMetrics.width = width;
|
|
|
|
aDesiredSize.SetBlockStartAscent(sizeNum.BlockStartAscent() + numShift);
|
|
aDesiredSize.Height() = aDesiredSize.BlockStartAscent() +
|
|
sizeDen.Height() - sizeDen.BlockStartAscent() + denShift;
|
|
aDesiredSize.Width() = mBoundingMetrics.width;
|
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
|
|
|
mReference.x = 0;
|
|
mReference.y = aDesiredSize.BlockStartAscent();
|
|
|
|
if (aPlaceOrigin) {
|
|
nscoord dy;
|
|
// place numerator
|
|
dy = 0;
|
|
FinishReflowChild(frameNum, presContext, sizeNum, nullptr, dxNum, dy, 0);
|
|
// place denominator
|
|
dy = aDesiredSize.Height() - sizeDen.Height();
|
|
FinishReflowChild(frameDen, presContext, sizeDen, nullptr, dxDen, dy, 0);
|
|
// place the fraction bar - dy is top of bar
|
|
dy = aDesiredSize.BlockStartAscent() - (axisHeight + actualRuleThickness/2);
|
|
mLineRect.SetRect(leftSpace, dy, width - (leftSpace + rightSpace),
|
|
actualRuleThickness);
|
|
}
|
|
} else {
|
|
nscoord numShift = 0.0;
|
|
nscoord denShift = 0.0;
|
|
nscoord padding = 3 * defaultRuleThickness;
|
|
nscoord slashRatio = 3;
|
|
|
|
// Define the constant used in the expression of the maximum width
|
|
nscoord em = fm->EmHeight();
|
|
nscoord slashMaxWidthConstant = 2 * em;
|
|
|
|
// For large line thicknesses the minimum slash height is limited to the
|
|
// largest expected height of a fraction
|
|
nscoord slashMinHeight = slashRatio *
|
|
std::min(2 * mLineThickness, slashMaxWidthConstant);
|
|
|
|
nscoord leadingSpace = padding;
|
|
nscoord trailingSpace = padding;
|
|
if (outermostEmbellished) {
|
|
nsEmbellishData coreData;
|
|
GetEmbellishDataFrom(mEmbellishData.coreFrame, coreData);
|
|
leadingSpace += coreData.leadingSpace;
|
|
trailingSpace += coreData.trailingSpace;
|
|
}
|
|
nscoord delta;
|
|
|
|
// ___________
|
|
// | | /
|
|
// {|-NUMERATOR-| /
|
|
// {|___________| S
|
|
// { L
|
|
// numShift{ A
|
|
// ------------------------------------------------------- baseline
|
|
// S _____________ } denShift
|
|
// H | |}
|
|
// / |-DENOMINATOR-|}
|
|
// / |_____________|
|
|
//
|
|
|
|
// first, ensure that the top of the numerator is at least as high as the
|
|
// top of the denominator (and the reverse for the bottoms)
|
|
delta = std::max(bmDen.ascent - bmNum.ascent,
|
|
bmNum.descent - bmDen.descent) / 2;
|
|
if (delta > 0) {
|
|
numShift += delta;
|
|
denShift += delta;
|
|
}
|
|
|
|
if (StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK) {
|
|
delta = std::min(bmDen.ascent + bmDen.descent,
|
|
bmNum.ascent + bmNum.descent) / 2;
|
|
numShift += delta;
|
|
denShift += delta;
|
|
} else {
|
|
nscoord xHeight = fm->XHeight();
|
|
numShift += xHeight / 2;
|
|
denShift += xHeight / 4;
|
|
}
|
|
|
|
// Set the ascent/descent of our BoundingMetrics.
|
|
mBoundingMetrics.ascent = bmNum.ascent + numShift;
|
|
mBoundingMetrics.descent = bmDen.descent + denShift;
|
|
|
|
// At this point the height of the slash is
|
|
// mBoundingMetrics.ascent + mBoundingMetrics.descent
|
|
// Ensure that it is greater than slashMinHeight
|
|
delta = (slashMinHeight -
|
|
(mBoundingMetrics.ascent + mBoundingMetrics.descent)) / 2;
|
|
if (delta > 0) {
|
|
mBoundingMetrics.ascent += delta;
|
|
mBoundingMetrics.descent += delta;
|
|
}
|
|
|
|
// Set the width of the slash
|
|
if (aWidthOnly) {
|
|
mLineRect.width = mLineThickness + slashMaxWidthConstant;
|
|
} else {
|
|
mLineRect.width = mLineThickness +
|
|
std::min(slashMaxWidthConstant,
|
|
(mBoundingMetrics.ascent + mBoundingMetrics.descent) /
|
|
slashRatio);
|
|
}
|
|
|
|
// Set horizontal bounding metrics
|
|
if (StyleVisibility()->mDirection) {
|
|
mBoundingMetrics.leftBearing = trailingSpace + bmDen.leftBearing;
|
|
mBoundingMetrics.rightBearing = trailingSpace + bmDen.width + mLineRect.width + bmNum.rightBearing;
|
|
} else {
|
|
mBoundingMetrics.leftBearing = leadingSpace + bmNum.leftBearing;
|
|
mBoundingMetrics.rightBearing = leadingSpace + bmNum.width + mLineRect.width + bmDen.rightBearing;
|
|
}
|
|
mBoundingMetrics.width =
|
|
leadingSpace + bmNum.width + mLineRect.width + bmDen.width +
|
|
trailingSpace;
|
|
|
|
// Set aDesiredSize
|
|
aDesiredSize.SetBlockStartAscent(mBoundingMetrics.ascent + padding);
|
|
aDesiredSize.Height() =
|
|
mBoundingMetrics.ascent + mBoundingMetrics.descent + 2 * padding;
|
|
aDesiredSize.Width() = mBoundingMetrics.width;
|
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
|
|
|
mReference.x = 0;
|
|
mReference.y = aDesiredSize.BlockStartAscent();
|
|
|
|
if (aPlaceOrigin) {
|
|
nscoord dx, dy;
|
|
|
|
// place numerator
|
|
dx = MirrorIfRTL(aDesiredSize.Width(), sizeNum.Width(),
|
|
leadingSpace);
|
|
dy = aDesiredSize.BlockStartAscent() - numShift - sizeNum.BlockStartAscent();
|
|
FinishReflowChild(frameNum, presContext, sizeNum, nullptr, dx, dy, 0);
|
|
|
|
// place the fraction bar
|
|
dx = MirrorIfRTL(aDesiredSize.Width(), mLineRect.width,
|
|
leadingSpace + bmNum.width);
|
|
dy = aDesiredSize.BlockStartAscent() - mBoundingMetrics.ascent;
|
|
mLineRect.SetRect(dx, dy,
|
|
mLineRect.width, aDesiredSize.Height() - 2 * padding);
|
|
|
|
// place denominator
|
|
dx = MirrorIfRTL(aDesiredSize.Width(), sizeDen.Width(),
|
|
leadingSpace + bmNum.width + mLineRect.width);
|
|
dy = aDesiredSize.BlockStartAscent() + denShift - sizeDen.BlockStartAscent();
|
|
FinishReflowChild(frameDen, presContext, sizeDen, nullptr, dx, dy, 0);
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
class nsDisplayMathMLSlash : public nsDisplayItem {
|
|
public:
|
|
nsDisplayMathMLSlash(nsDisplayListBuilder* aBuilder,
|
|
nsIFrame* aFrame, const nsRect& aRect,
|
|
nscoord aThickness, bool aRTL)
|
|
: nsDisplayItem(aBuilder, aFrame), mRect(aRect), mThickness(aThickness),
|
|
mRTL(aRTL) {
|
|
MOZ_COUNT_CTOR(nsDisplayMathMLSlash);
|
|
}
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
virtual ~nsDisplayMathMLSlash() {
|
|
MOZ_COUNT_DTOR(nsDisplayMathMLSlash);
|
|
}
|
|
#endif
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx) override;
|
|
NS_DISPLAY_DECL_NAME("MathMLSlash", TYPE_MATHML_SLASH)
|
|
|
|
private:
|
|
nsRect mRect;
|
|
nscoord mThickness;
|
|
bool mRTL;
|
|
};
|
|
|
|
void nsDisplayMathMLSlash::Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx)
|
|
{
|
|
DrawTarget& aDrawTarget = *aCtx->GetDrawTarget();
|
|
|
|
// get the gfxRect
|
|
nsPresContext* presContext = mFrame->PresContext();
|
|
Rect rect = NSRectToRect(mRect + ToReferenceFrame(),
|
|
presContext->AppUnitsPerDevPixel());
|
|
|
|
ColorPattern color(ToDeviceColor(
|
|
mFrame->GetVisitedDependentColor(eCSSProperty_color)));
|
|
|
|
// draw the slash as a parallelogram
|
|
Point delta = Point(presContext->AppUnitsToGfxUnits(mThickness), 0);
|
|
RefPtr<PathBuilder> builder = aDrawTarget.CreatePathBuilder();
|
|
if (mRTL) {
|
|
builder->MoveTo(rect.TopLeft());
|
|
builder->LineTo(rect.TopLeft() + delta);
|
|
builder->LineTo(rect.BottomRight());
|
|
builder->LineTo(rect.BottomRight() - delta);
|
|
} else {
|
|
builder->MoveTo(rect.BottomLeft());
|
|
builder->LineTo(rect.BottomLeft() + delta);
|
|
builder->LineTo(rect.TopRight());
|
|
builder->LineTo(rect.TopRight() - delta);
|
|
}
|
|
RefPtr<Path> path = builder->Finish();
|
|
aDrawTarget.Fill(path, color);
|
|
}
|
|
|
|
void
|
|
nsMathMLmfracFrame::DisplaySlash(nsDisplayListBuilder* aBuilder,
|
|
nsIFrame* aFrame, const nsRect& aRect,
|
|
nscoord aThickness,
|
|
const nsDisplayListSet& aLists) {
|
|
if (!aFrame->StyleVisibility()->IsVisible() || aRect.IsEmpty())
|
|
return;
|
|
|
|
aLists.Content()->AppendNewToTop(new (aBuilder)
|
|
nsDisplayMathMLSlash(aBuilder, aFrame, aRect, aThickness,
|
|
StyleVisibility()->mDirection));
|
|
}
|