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)
870 lines
30 KiB
C++
870 lines
30 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 "nsMathMLmencloseFrame.h"
|
|
|
|
#include "gfx2DGlue.h"
|
|
#include "gfxUtils.h"
|
|
#include "mozilla/gfx/2D.h"
|
|
#include "mozilla/gfx/PathHelpers.h"
|
|
#include "nsPresContext.h"
|
|
#include "nsRenderingContext.h"
|
|
#include "nsWhitespaceTokenizer.h"
|
|
|
|
#include "nsDisplayList.h"
|
|
#include "gfxContext.h"
|
|
#include "nsMathMLChar.h"
|
|
#include <algorithm>
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::gfx;
|
|
|
|
//
|
|
// <menclose> -- enclose content with a stretching symbol such
|
|
// as a long division sign. - implementation
|
|
|
|
// longdiv:
|
|
// Unicode 5.1 assigns U+27CC to LONG DIVISION, but a right parenthesis
|
|
// renders better with current font support.
|
|
static const char16_t kLongDivChar = ')';
|
|
|
|
// radical: 'SQUARE ROOT'
|
|
static const char16_t kRadicalChar = 0x221A;
|
|
|
|
// updiagonalstrike
|
|
static const uint8_t kArrowHeadSize = 10;
|
|
|
|
// phasorangle
|
|
static const uint8_t kPhasorangleWidth = 8;
|
|
|
|
nsIFrame*
|
|
NS_NewMathMLmencloseFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
{
|
|
return new (aPresShell) nsMathMLmencloseFrame(aContext);
|
|
}
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmencloseFrame)
|
|
|
|
nsMathMLmencloseFrame::nsMathMLmencloseFrame(nsStyleContext* aContext) :
|
|
nsMathMLContainerFrame(aContext), mNotationsToDraw(0),
|
|
mLongDivCharIndex(-1), mRadicalCharIndex(-1), mContentWidth(0)
|
|
{
|
|
}
|
|
|
|
nsMathMLmencloseFrame::~nsMathMLmencloseFrame()
|
|
{
|
|
}
|
|
|
|
nsresult nsMathMLmencloseFrame::AllocateMathMLChar(nsMencloseNotation mask)
|
|
{
|
|
// Is the char already allocated?
|
|
if ((mask == NOTATION_LONGDIV && mLongDivCharIndex >= 0) ||
|
|
(mask == NOTATION_RADICAL && mRadicalCharIndex >= 0))
|
|
return NS_OK;
|
|
|
|
// No need to track the style context given to our MathML chars.
|
|
// The Style System will use Get/SetAdditionalStyleContext() to keep it
|
|
// up-to-date if dynamic changes arise.
|
|
uint32_t i = mMathMLChar.Length();
|
|
nsAutoString Char;
|
|
|
|
if (!mMathMLChar.AppendElement())
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
if (mask == NOTATION_LONGDIV) {
|
|
Char.Assign(kLongDivChar);
|
|
mLongDivCharIndex = i;
|
|
} else if (mask == NOTATION_RADICAL) {
|
|
Char.Assign(kRadicalChar);
|
|
mRadicalCharIndex = i;
|
|
}
|
|
|
|
nsPresContext *presContext = PresContext();
|
|
mMathMLChar[i].SetData(presContext, Char);
|
|
ResolveMathMLCharStyle(presContext, mContent, mStyleContext, &mMathMLChar[i]);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
/*
|
|
* Add a notation to draw, if the argument is the name of a known notation.
|
|
* @param aNotation string name of a notation
|
|
*/
|
|
nsresult nsMathMLmencloseFrame::AddNotation(const nsAString& aNotation)
|
|
{
|
|
nsresult rv;
|
|
|
|
if (aNotation.EqualsLiteral("longdiv")) {
|
|
rv = AllocateMathMLChar(NOTATION_LONGDIV);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
mNotationsToDraw |= NOTATION_LONGDIV;
|
|
} else if (aNotation.EqualsLiteral("actuarial")) {
|
|
mNotationsToDraw |= (NOTATION_RIGHT | NOTATION_TOP);
|
|
} else if (aNotation.EqualsLiteral("radical")) {
|
|
rv = AllocateMathMLChar(NOTATION_RADICAL);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
mNotationsToDraw |= NOTATION_RADICAL;
|
|
} else if (aNotation.EqualsLiteral("box")) {
|
|
mNotationsToDraw |= (NOTATION_LEFT | NOTATION_RIGHT |
|
|
NOTATION_TOP | NOTATION_BOTTOM);
|
|
} else if (aNotation.EqualsLiteral("roundedbox")) {
|
|
mNotationsToDraw |= NOTATION_ROUNDEDBOX;
|
|
} else if (aNotation.EqualsLiteral("circle")) {
|
|
mNotationsToDraw |= NOTATION_CIRCLE;
|
|
} else if (aNotation.EqualsLiteral("left")) {
|
|
mNotationsToDraw |= NOTATION_LEFT;
|
|
} else if (aNotation.EqualsLiteral("right")) {
|
|
mNotationsToDraw |= NOTATION_RIGHT;
|
|
} else if (aNotation.EqualsLiteral("top")) {
|
|
mNotationsToDraw |= NOTATION_TOP;
|
|
} else if (aNotation.EqualsLiteral("bottom")) {
|
|
mNotationsToDraw |= NOTATION_BOTTOM;
|
|
} else if (aNotation.EqualsLiteral("updiagonalstrike")) {
|
|
mNotationsToDraw |= NOTATION_UPDIAGONALSTRIKE;
|
|
} else if (aNotation.EqualsLiteral("updiagonalarrow")) {
|
|
mNotationsToDraw |= NOTATION_UPDIAGONALARROW;
|
|
} else if (aNotation.EqualsLiteral("downdiagonalstrike")) {
|
|
mNotationsToDraw |= NOTATION_DOWNDIAGONALSTRIKE;
|
|
} else if (aNotation.EqualsLiteral("verticalstrike")) {
|
|
mNotationsToDraw |= NOTATION_VERTICALSTRIKE;
|
|
} else if (aNotation.EqualsLiteral("horizontalstrike")) {
|
|
mNotationsToDraw |= NOTATION_HORIZONTALSTRIKE;
|
|
} else if (aNotation.EqualsLiteral("madruwb")) {
|
|
mNotationsToDraw |= (NOTATION_RIGHT | NOTATION_BOTTOM);
|
|
} else if (aNotation.EqualsLiteral("phasorangle")) {
|
|
mNotationsToDraw |= (NOTATION_BOTTOM | NOTATION_PHASORANGLE);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
/*
|
|
* Initialize the list of notations to draw
|
|
*/
|
|
void nsMathMLmencloseFrame::InitNotations()
|
|
{
|
|
mNotationsToDraw = 0;
|
|
mLongDivCharIndex = mRadicalCharIndex = -1;
|
|
mMathMLChar.Clear();
|
|
|
|
nsAutoString value;
|
|
|
|
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::notation_, value)) {
|
|
// parse the notation attribute
|
|
nsWhitespaceTokenizer tokenizer(value);
|
|
|
|
while (tokenizer.hasMoreTokens())
|
|
AddNotation(tokenizer.nextToken());
|
|
|
|
if (IsToDraw(NOTATION_UPDIAGONALARROW)) {
|
|
// For <menclose notation="updiagonalstrike updiagonalarrow">, if
|
|
// the two notations are drawn then the strike line may cause the point of
|
|
// the arrow to be too wide. Hence we will only draw the updiagonalarrow
|
|
// and the arrow shaft may be thought to be the updiagonalstrike.
|
|
mNotationsToDraw &= ~NOTATION_UPDIAGONALSTRIKE;
|
|
}
|
|
} else {
|
|
// default: longdiv
|
|
if (NS_FAILED(AllocateMathMLChar(NOTATION_LONGDIV)))
|
|
return;
|
|
mNotationsToDraw = NOTATION_LONGDIV;
|
|
}
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMathMLmencloseFrame::InheritAutomaticData(nsIFrame* aParent)
|
|
{
|
|
// let the base class get the default from our parent
|
|
nsMathMLContainerFrame::InheritAutomaticData(aParent);
|
|
|
|
mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY;
|
|
|
|
InitNotations();
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMathMLmencloseFrame::TransmitAutomaticData()
|
|
{
|
|
if (IsToDraw(NOTATION_RADICAL)) {
|
|
// The TeXBook (Ch 17. p.141) says that \sqrt is cramped
|
|
UpdatePresentationDataFromChildAt(0, -1,
|
|
NS_MATHML_COMPRESSED,
|
|
NS_MATHML_COMPRESSED);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
nsMathMLmencloseFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
const nsRect& aDirtyRect,
|
|
const nsDisplayListSet& aLists)
|
|
{
|
|
/////////////
|
|
// paint the menclosed content
|
|
nsMathMLContainerFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
|
|
|
if (NS_MATHML_HAS_ERROR(mPresentationData.flags))
|
|
return;
|
|
|
|
nsRect mencloseRect = nsIFrame::GetRect();
|
|
mencloseRect.x = mencloseRect.y = 0;
|
|
|
|
if (IsToDraw(NOTATION_RADICAL)) {
|
|
mMathMLChar[mRadicalCharIndex].Display(aBuilder, this, aLists, 0);
|
|
|
|
nsRect rect;
|
|
mMathMLChar[mRadicalCharIndex].GetRect(rect);
|
|
rect.MoveBy(StyleVisibility()->mDirection ? -mContentWidth : rect.width, 0);
|
|
rect.SizeTo(mContentWidth, mRadicalRuleThickness);
|
|
DisplayBar(aBuilder, this, rect, aLists);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_PHASORANGLE)) {
|
|
DisplayNotation(aBuilder, this, mencloseRect, aLists,
|
|
mRuleThickness, NOTATION_PHASORANGLE);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_LONGDIV)) {
|
|
mMathMLChar[mLongDivCharIndex].Display(aBuilder, this, aLists, 1);
|
|
|
|
nsRect rect;
|
|
mMathMLChar[mLongDivCharIndex].GetRect(rect);
|
|
rect.SizeTo(rect.width + mContentWidth, mRuleThickness);
|
|
DisplayBar(aBuilder, this, rect, aLists);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_TOP)) {
|
|
nsRect rect(0, 0, mencloseRect.width, mRuleThickness);
|
|
DisplayBar(aBuilder, this, rect, aLists);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_BOTTOM)) {
|
|
nsRect rect(0, mencloseRect.height - mRuleThickness,
|
|
mencloseRect.width, mRuleThickness);
|
|
DisplayBar(aBuilder, this, rect, aLists);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_LEFT)) {
|
|
nsRect rect(0, 0, mRuleThickness, mencloseRect.height);
|
|
DisplayBar(aBuilder, this, rect, aLists);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_RIGHT)) {
|
|
nsRect rect(mencloseRect.width - mRuleThickness, 0,
|
|
mRuleThickness, mencloseRect.height);
|
|
DisplayBar(aBuilder, this, rect, aLists);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_ROUNDEDBOX)) {
|
|
DisplayNotation(aBuilder, this, mencloseRect, aLists,
|
|
mRuleThickness, NOTATION_ROUNDEDBOX);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_CIRCLE)) {
|
|
DisplayNotation(aBuilder, this, mencloseRect, aLists,
|
|
mRuleThickness, NOTATION_CIRCLE);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_UPDIAGONALSTRIKE)) {
|
|
DisplayNotation(aBuilder, this, mencloseRect, aLists,
|
|
mRuleThickness, NOTATION_UPDIAGONALSTRIKE);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_UPDIAGONALARROW)) {
|
|
DisplayNotation(aBuilder, this, mencloseRect, aLists,
|
|
mRuleThickness, NOTATION_UPDIAGONALARROW);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_DOWNDIAGONALSTRIKE)) {
|
|
DisplayNotation(aBuilder, this, mencloseRect, aLists,
|
|
mRuleThickness, NOTATION_DOWNDIAGONALSTRIKE);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_HORIZONTALSTRIKE)) {
|
|
nsRect rect(0, mencloseRect.height / 2 - mRuleThickness / 2,
|
|
mencloseRect.width, mRuleThickness);
|
|
DisplayBar(aBuilder, this, rect, aLists);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_VERTICALSTRIKE)) {
|
|
nsRect rect(mencloseRect.width / 2 - mRuleThickness / 2, 0,
|
|
mRuleThickness, mencloseRect.height);
|
|
DisplayBar(aBuilder, this, rect, aLists);
|
|
}
|
|
}
|
|
|
|
/* virtual */ nsresult
|
|
nsMathMLmencloseFrame::MeasureForWidth(nsRenderingContext& aRenderingContext,
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
|
{
|
|
return PlaceInternal(aRenderingContext, false, aDesiredSize, true);
|
|
}
|
|
|
|
/* virtual */ nsresult
|
|
nsMathMLmencloseFrame::Place(nsRenderingContext& aRenderingContext,
|
|
bool aPlaceOrigin,
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
|
{
|
|
return PlaceInternal(aRenderingContext, aPlaceOrigin, aDesiredSize, false);
|
|
}
|
|
|
|
/* virtual */ nsresult
|
|
nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
|
bool aPlaceOrigin,
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
bool aWidthOnly)
|
|
{
|
|
///////////////
|
|
// Measure the size of our content using the base class to format like an
|
|
// inferred mrow.
|
|
nsHTMLReflowMetrics baseSize(aDesiredSize.GetWritingMode());
|
|
nsresult rv =
|
|
nsMathMLContainerFrame::Place(aRenderingContext, false, baseSize);
|
|
|
|
if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) {
|
|
DidReflowChildren(GetFirstPrincipalChild());
|
|
return rv;
|
|
}
|
|
|
|
nsBoundingMetrics bmBase = baseSize.mBoundingMetrics;
|
|
nscoord dx_left = 0, dx_right = 0;
|
|
nsBoundingMetrics bmLongdivChar, bmRadicalChar;
|
|
nscoord radicalAscent = 0, radicalDescent = 0;
|
|
nscoord longdivAscent = 0, longdivDescent = 0;
|
|
nscoord psi = 0;
|
|
nscoord leading = 0;
|
|
|
|
///////////////
|
|
// Thickness of bars and font metrics
|
|
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
|
|
|
float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this);
|
|
RefPtr<nsFontMetrics> fm;
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
|
|
fontSizeInflation);
|
|
GetRuleThickness(aRenderingContext, fm, mRuleThickness);
|
|
if (mRuleThickness < onePixel) {
|
|
mRuleThickness = onePixel;
|
|
}
|
|
|
|
char16_t one = '1';
|
|
nsBoundingMetrics bmOne =
|
|
nsLayoutUtils::AppUnitBoundsOfString(&one, 1, *fm, aRenderingContext);
|
|
|
|
///////////////
|
|
// General rules: the menclose element takes the size of the enclosed content.
|
|
// We add a padding when needed.
|
|
|
|
// determine padding & psi
|
|
nscoord padding = 3 * mRuleThickness;
|
|
nscoord delta = padding % onePixel;
|
|
if (delta)
|
|
padding += onePixel - delta; // round up
|
|
|
|
if (IsToDraw(NOTATION_LONGDIV) || IsToDraw(NOTATION_RADICAL)) {
|
|
GetRadicalParameters(fm, StyleFont()->mMathDisplay ==
|
|
NS_MATHML_DISPLAYSTYLE_BLOCK,
|
|
mRadicalRuleThickness, leading, psi);
|
|
|
|
// make sure that the rule appears on on screen
|
|
if (mRadicalRuleThickness < onePixel) {
|
|
mRadicalRuleThickness = onePixel;
|
|
}
|
|
|
|
// adjust clearance psi to get an exact number of pixels -- this
|
|
// gives a nicer & uniform look on stacked radicals (bug 130282)
|
|
delta = psi % onePixel;
|
|
if (delta) {
|
|
psi += onePixel - delta; // round up
|
|
}
|
|
}
|
|
|
|
// Set horizontal parameters
|
|
if (IsToDraw(NOTATION_ROUNDEDBOX) ||
|
|
IsToDraw(NOTATION_TOP) ||
|
|
IsToDraw(NOTATION_LEFT) ||
|
|
IsToDraw(NOTATION_BOTTOM) ||
|
|
IsToDraw(NOTATION_CIRCLE))
|
|
dx_left = padding;
|
|
|
|
if (IsToDraw(NOTATION_ROUNDEDBOX) ||
|
|
IsToDraw(NOTATION_TOP) ||
|
|
IsToDraw(NOTATION_RIGHT) ||
|
|
IsToDraw(NOTATION_BOTTOM) ||
|
|
IsToDraw(NOTATION_CIRCLE))
|
|
dx_right = padding;
|
|
|
|
// Set vertical parameters
|
|
if (IsToDraw(NOTATION_RIGHT) ||
|
|
IsToDraw(NOTATION_LEFT) ||
|
|
IsToDraw(NOTATION_UPDIAGONALSTRIKE) ||
|
|
IsToDraw(NOTATION_UPDIAGONALARROW) ||
|
|
IsToDraw(NOTATION_DOWNDIAGONALSTRIKE) ||
|
|
IsToDraw(NOTATION_VERTICALSTRIKE) ||
|
|
IsToDraw(NOTATION_CIRCLE) ||
|
|
IsToDraw(NOTATION_ROUNDEDBOX) ||
|
|
IsToDraw(NOTATION_RADICAL) ||
|
|
IsToDraw(NOTATION_LONGDIV) ||
|
|
IsToDraw(NOTATION_PHASORANGLE)) {
|
|
// set a minimal value for the base height
|
|
bmBase.ascent = std::max(bmOne.ascent, bmBase.ascent);
|
|
bmBase.descent = std::max(0, bmBase.descent);
|
|
}
|
|
|
|
mBoundingMetrics.ascent = bmBase.ascent;
|
|
mBoundingMetrics.descent = bmBase.descent;
|
|
|
|
if (IsToDraw(NOTATION_ROUNDEDBOX) ||
|
|
IsToDraw(NOTATION_TOP) ||
|
|
IsToDraw(NOTATION_LEFT) ||
|
|
IsToDraw(NOTATION_RIGHT) ||
|
|
IsToDraw(NOTATION_CIRCLE))
|
|
mBoundingMetrics.ascent += padding;
|
|
|
|
if (IsToDraw(NOTATION_ROUNDEDBOX) ||
|
|
IsToDraw(NOTATION_LEFT) ||
|
|
IsToDraw(NOTATION_RIGHT) ||
|
|
IsToDraw(NOTATION_BOTTOM) ||
|
|
IsToDraw(NOTATION_CIRCLE))
|
|
mBoundingMetrics.descent += padding;
|
|
|
|
///////////////
|
|
// phasorangle notation
|
|
if (IsToDraw(NOTATION_PHASORANGLE)) {
|
|
nscoord phasorangleWidth = kPhasorangleWidth * mRuleThickness;
|
|
// Update horizontal parameters
|
|
dx_left = std::max(dx_left, phasorangleWidth);
|
|
}
|
|
|
|
///////////////
|
|
// updiagonal arrow notation. We need enough space at the top right corner to
|
|
// draw the arrow head.
|
|
if (IsToDraw(NOTATION_UPDIAGONALARROW)) {
|
|
// This is an estimate, see nsDisplayNotation::Paint for the exact head size
|
|
nscoord arrowHeadSize = kArrowHeadSize * mRuleThickness;
|
|
|
|
// We want that the arrow shaft strikes the menclose content and that the
|
|
// arrow head does not overlap with that content. Hence we add some space
|
|
// on the right. We don't add space on the top but only ensure that the
|
|
// ascent is large enough.
|
|
dx_right = std::max(dx_right, arrowHeadSize);
|
|
mBoundingMetrics.ascent = std::max(mBoundingMetrics.ascent, arrowHeadSize);
|
|
}
|
|
|
|
///////////////
|
|
// circle notation: we don't want the ellipse to overlap the enclosed
|
|
// content. Hence, we need to increase the size of the bounding box by a
|
|
// factor of at least sqrt(2).
|
|
if (IsToDraw(NOTATION_CIRCLE)) {
|
|
double ratio = (sqrt(2.0) - 1.0) / 2.0;
|
|
nscoord padding2;
|
|
|
|
// Update horizontal parameters
|
|
padding2 = ratio * bmBase.width;
|
|
|
|
dx_left = std::max(dx_left, padding2);
|
|
dx_right = std::max(dx_right, padding2);
|
|
|
|
// Update vertical parameters
|
|
padding2 = ratio * (bmBase.ascent + bmBase.descent);
|
|
|
|
mBoundingMetrics.ascent = std::max(mBoundingMetrics.ascent,
|
|
bmBase.ascent + padding2);
|
|
mBoundingMetrics.descent = std::max(mBoundingMetrics.descent,
|
|
bmBase.descent + padding2);
|
|
}
|
|
|
|
///////////////
|
|
// longdiv notation:
|
|
if (IsToDraw(NOTATION_LONGDIV)) {
|
|
if (aWidthOnly) {
|
|
nscoord longdiv_width = mMathMLChar[mLongDivCharIndex].
|
|
GetMaxWidth(PresContext(), aRenderingContext, fontSizeInflation);
|
|
|
|
// Update horizontal parameters
|
|
dx_left = std::max(dx_left, longdiv_width);
|
|
} else {
|
|
// Stretch the parenthesis to the appropriate height if it is not
|
|
// big enough.
|
|
nsBoundingMetrics contSize = bmBase;
|
|
contSize.ascent = mRuleThickness;
|
|
contSize.descent = bmBase.ascent + bmBase.descent + psi;
|
|
|
|
// height(longdiv) should be >= height(base) + psi + mRuleThickness
|
|
mMathMLChar[mLongDivCharIndex].Stretch(PresContext(), aRenderingContext,
|
|
fontSizeInflation,
|
|
NS_STRETCH_DIRECTION_VERTICAL,
|
|
contSize, bmLongdivChar,
|
|
NS_STRETCH_LARGER, false);
|
|
mMathMLChar[mLongDivCharIndex].GetBoundingMetrics(bmLongdivChar);
|
|
|
|
// Update horizontal parameters
|
|
dx_left = std::max(dx_left, bmLongdivChar.width);
|
|
|
|
// Update vertical parameters
|
|
longdivAscent = bmBase.ascent + psi + mRuleThickness;
|
|
longdivDescent = std::max(bmBase.descent,
|
|
(bmLongdivChar.ascent + bmLongdivChar.descent -
|
|
longdivAscent));
|
|
|
|
mBoundingMetrics.ascent = std::max(mBoundingMetrics.ascent,
|
|
longdivAscent);
|
|
mBoundingMetrics.descent = std::max(mBoundingMetrics.descent,
|
|
longdivDescent);
|
|
}
|
|
}
|
|
|
|
///////////////
|
|
// radical notation:
|
|
if (IsToDraw(NOTATION_RADICAL)) {
|
|
nscoord *dx_leading = StyleVisibility()->mDirection ? &dx_right : &dx_left;
|
|
|
|
if (aWidthOnly) {
|
|
nscoord radical_width = mMathMLChar[mRadicalCharIndex].
|
|
GetMaxWidth(PresContext(), aRenderingContext, fontSizeInflation);
|
|
|
|
// Update horizontal parameters
|
|
*dx_leading = std::max(*dx_leading, radical_width);
|
|
} else {
|
|
// Stretch the radical symbol to the appropriate height if it is not
|
|
// big enough.
|
|
nsBoundingMetrics contSize = bmBase;
|
|
contSize.ascent = mRadicalRuleThickness;
|
|
contSize.descent = bmBase.ascent + bmBase.descent + psi;
|
|
|
|
// height(radical) should be >= height(base) + psi + mRadicalRuleThickness
|
|
mMathMLChar[mRadicalCharIndex].Stretch(PresContext(), aRenderingContext,
|
|
fontSizeInflation,
|
|
NS_STRETCH_DIRECTION_VERTICAL,
|
|
contSize, bmRadicalChar,
|
|
NS_STRETCH_LARGER,
|
|
StyleVisibility()->mDirection);
|
|
mMathMLChar[mRadicalCharIndex].GetBoundingMetrics(bmRadicalChar);
|
|
|
|
// Update horizontal parameters
|
|
*dx_leading = std::max(*dx_leading, bmRadicalChar.width);
|
|
|
|
// Update vertical parameters
|
|
radicalAscent = bmBase.ascent + psi + mRadicalRuleThickness;
|
|
radicalDescent = std::max(bmBase.descent,
|
|
(bmRadicalChar.ascent + bmRadicalChar.descent -
|
|
radicalAscent));
|
|
|
|
mBoundingMetrics.ascent = std::max(mBoundingMetrics.ascent,
|
|
radicalAscent);
|
|
mBoundingMetrics.descent = std::max(mBoundingMetrics.descent,
|
|
radicalDescent);
|
|
}
|
|
}
|
|
|
|
///////////////
|
|
//
|
|
if (IsToDraw(NOTATION_CIRCLE) ||
|
|
IsToDraw(NOTATION_ROUNDEDBOX) ||
|
|
(IsToDraw(NOTATION_LEFT) && IsToDraw(NOTATION_RIGHT))) {
|
|
// center the menclose around the content (horizontally)
|
|
dx_left = dx_right = std::max(dx_left, dx_right);
|
|
}
|
|
|
|
///////////////
|
|
// The maximum size is now computed: set the remaining parameters
|
|
mBoundingMetrics.width = dx_left + bmBase.width + dx_right;
|
|
|
|
mBoundingMetrics.leftBearing = std::min(0, dx_left + bmBase.leftBearing);
|
|
mBoundingMetrics.rightBearing =
|
|
std::max(mBoundingMetrics.width, dx_left + bmBase.rightBearing);
|
|
|
|
aDesiredSize.Width() = mBoundingMetrics.width;
|
|
|
|
aDesiredSize.SetBlockStartAscent(std::max(mBoundingMetrics.ascent,
|
|
baseSize.BlockStartAscent()));
|
|
aDesiredSize.Height() = aDesiredSize.BlockStartAscent() +
|
|
std::max(mBoundingMetrics.descent,
|
|
baseSize.Height() - baseSize.BlockStartAscent());
|
|
|
|
if (IsToDraw(NOTATION_LONGDIV) || IsToDraw(NOTATION_RADICAL)) {
|
|
nscoord desiredSizeAscent = aDesiredSize.BlockStartAscent();
|
|
nscoord desiredSizeDescent = aDesiredSize.Height() -
|
|
aDesiredSize.BlockStartAscent();
|
|
|
|
if (IsToDraw(NOTATION_LONGDIV)) {
|
|
desiredSizeAscent = std::max(desiredSizeAscent,
|
|
longdivAscent + leading);
|
|
desiredSizeDescent = std::max(desiredSizeDescent,
|
|
longdivDescent + mRuleThickness);
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_RADICAL)) {
|
|
desiredSizeAscent = std::max(desiredSizeAscent,
|
|
radicalAscent + leading);
|
|
desiredSizeDescent = std::max(desiredSizeDescent,
|
|
radicalDescent + mRadicalRuleThickness);
|
|
}
|
|
|
|
aDesiredSize.SetBlockStartAscent(desiredSizeAscent);
|
|
aDesiredSize.Height() = desiredSizeAscent + desiredSizeDescent;
|
|
}
|
|
|
|
if (IsToDraw(NOTATION_CIRCLE) ||
|
|
IsToDraw(NOTATION_ROUNDEDBOX) ||
|
|
(IsToDraw(NOTATION_TOP) && IsToDraw(NOTATION_BOTTOM))) {
|
|
// center the menclose around the content (vertically)
|
|
nscoord dy = std::max(aDesiredSize.BlockStartAscent() - bmBase.ascent,
|
|
aDesiredSize.Height() -
|
|
aDesiredSize.BlockStartAscent() - bmBase.descent);
|
|
|
|
aDesiredSize.SetBlockStartAscent(bmBase.ascent + dy);
|
|
aDesiredSize.Height() = aDesiredSize.BlockStartAscent() + bmBase.descent + dy;
|
|
}
|
|
|
|
// Update mBoundingMetrics ascent/descent
|
|
if (IsToDraw(NOTATION_TOP) ||
|
|
IsToDraw(NOTATION_RIGHT) ||
|
|
IsToDraw(NOTATION_LEFT) ||
|
|
IsToDraw(NOTATION_UPDIAGONALSTRIKE) ||
|
|
IsToDraw(NOTATION_UPDIAGONALARROW) ||
|
|
IsToDraw(NOTATION_DOWNDIAGONALSTRIKE) ||
|
|
IsToDraw(NOTATION_VERTICALSTRIKE) ||
|
|
IsToDraw(NOTATION_CIRCLE) ||
|
|
IsToDraw(NOTATION_ROUNDEDBOX))
|
|
mBoundingMetrics.ascent = aDesiredSize.BlockStartAscent();
|
|
|
|
if (IsToDraw(NOTATION_BOTTOM) ||
|
|
IsToDraw(NOTATION_RIGHT) ||
|
|
IsToDraw(NOTATION_LEFT) ||
|
|
IsToDraw(NOTATION_UPDIAGONALSTRIKE) ||
|
|
IsToDraw(NOTATION_UPDIAGONALARROW) ||
|
|
IsToDraw(NOTATION_DOWNDIAGONALSTRIKE) ||
|
|
IsToDraw(NOTATION_VERTICALSTRIKE) ||
|
|
IsToDraw(NOTATION_CIRCLE) ||
|
|
IsToDraw(NOTATION_ROUNDEDBOX))
|
|
mBoundingMetrics.descent = aDesiredSize.Height() - aDesiredSize.BlockStartAscent();
|
|
|
|
// phasorangle notation:
|
|
// move up from the bottom by the angled line height
|
|
if (IsToDraw(NOTATION_PHASORANGLE))
|
|
mBoundingMetrics.ascent = std::max(mBoundingMetrics.ascent, 2 * kPhasorangleWidth * mRuleThickness - mBoundingMetrics.descent);
|
|
|
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
|
|
|
mReference.x = 0;
|
|
mReference.y = aDesiredSize.BlockStartAscent();
|
|
|
|
if (aPlaceOrigin) {
|
|
//////////////////
|
|
// Set position and size of MathMLChars
|
|
if (IsToDraw(NOTATION_LONGDIV))
|
|
mMathMLChar[mLongDivCharIndex].SetRect(nsRect(dx_left -
|
|
bmLongdivChar.width,
|
|
aDesiredSize.BlockStartAscent() -
|
|
longdivAscent,
|
|
bmLongdivChar.width,
|
|
bmLongdivChar.ascent +
|
|
bmLongdivChar.descent));
|
|
|
|
if (IsToDraw(NOTATION_RADICAL)) {
|
|
nscoord dx = (StyleVisibility()->mDirection ?
|
|
dx_left + bmBase.width : dx_left - bmRadicalChar.width);
|
|
|
|
mMathMLChar[mRadicalCharIndex].SetRect(nsRect(dx,
|
|
aDesiredSize.BlockStartAscent() -
|
|
radicalAscent,
|
|
bmRadicalChar.width,
|
|
bmRadicalChar.ascent +
|
|
bmRadicalChar.descent));
|
|
}
|
|
|
|
mContentWidth = bmBase.width;
|
|
|
|
//////////////////
|
|
// Finish reflowing child frames
|
|
PositionRowChildFrames(dx_left, aDesiredSize.BlockStartAscent());
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
nscoord
|
|
nsMathMLmencloseFrame::FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
|
|
{
|
|
nscoord gap = nsMathMLContainerFrame::FixInterFrameSpacing(aDesiredSize);
|
|
if (!gap)
|
|
return 0;
|
|
|
|
// Move the MathML characters
|
|
nsRect rect;
|
|
for (uint32_t i = 0; i < mMathMLChar.Length(); i++) {
|
|
mMathMLChar[i].GetRect(rect);
|
|
rect.MoveBy(gap, 0);
|
|
mMathMLChar[i].SetRect(rect);
|
|
}
|
|
|
|
return gap;
|
|
}
|
|
|
|
nsresult
|
|
nsMathMLmencloseFrame::AttributeChanged(int32_t aNameSpaceID,
|
|
nsIAtom* aAttribute,
|
|
int32_t aModType)
|
|
{
|
|
if (aAttribute == nsGkAtoms::notation_) {
|
|
InitNotations();
|
|
}
|
|
|
|
return nsMathMLContainerFrame::
|
|
AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
|
}
|
|
|
|
//////////////////
|
|
// the Style System will use these to pass the proper style context to our
|
|
// MathMLChar
|
|
nsStyleContext*
|
|
nsMathMLmencloseFrame::GetAdditionalStyleContext(int32_t aIndex) const
|
|
{
|
|
int32_t len = mMathMLChar.Length();
|
|
if (aIndex >= 0 && aIndex < len)
|
|
return mMathMLChar[aIndex].GetStyleContext();
|
|
else
|
|
return nullptr;
|
|
}
|
|
|
|
void
|
|
nsMathMLmencloseFrame::SetAdditionalStyleContext(int32_t aIndex,
|
|
nsStyleContext* aStyleContext)
|
|
{
|
|
int32_t len = mMathMLChar.Length();
|
|
if (aIndex >= 0 && aIndex < len)
|
|
mMathMLChar[aIndex].SetStyleContext(aStyleContext);
|
|
}
|
|
|
|
class nsDisplayNotation : public nsDisplayItem
|
|
{
|
|
public:
|
|
nsDisplayNotation(nsDisplayListBuilder* aBuilder,
|
|
nsIFrame* aFrame, const nsRect& aRect,
|
|
nscoord aThickness, nsMencloseNotation aType)
|
|
: nsDisplayItem(aBuilder, aFrame), mRect(aRect),
|
|
mThickness(aThickness), mType(aType) {
|
|
MOZ_COUNT_CTOR(nsDisplayNotation);
|
|
}
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
virtual ~nsDisplayNotation() {
|
|
MOZ_COUNT_DTOR(nsDisplayNotation);
|
|
}
|
|
#endif
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx) override;
|
|
NS_DISPLAY_DECL_NAME("MathMLMencloseNotation", TYPE_MATHML_MENCLOSE_NOTATION)
|
|
|
|
private:
|
|
nsRect mRect;
|
|
nscoord mThickness;
|
|
nsMencloseNotation mType;
|
|
};
|
|
|
|
void nsDisplayNotation::Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx)
|
|
{
|
|
DrawTarget& aDrawTarget = *aCtx->GetDrawTarget();
|
|
nsPresContext* presContext = mFrame->PresContext();
|
|
|
|
Float strokeWidth = presContext->AppUnitsToGfxUnits(mThickness);
|
|
|
|
Rect rect = NSRectToRect(mRect + ToReferenceFrame(),
|
|
presContext->AppUnitsPerDevPixel());
|
|
rect.Deflate(strokeWidth / 2.f);
|
|
|
|
ColorPattern color(ToDeviceColor(
|
|
mFrame->GetVisitedDependentColor(eCSSProperty_color)));
|
|
|
|
StrokeOptions strokeOptions(strokeWidth);
|
|
|
|
switch(mType)
|
|
{
|
|
case NOTATION_CIRCLE: {
|
|
RefPtr<Path> ellipse =
|
|
MakePathForEllipse(aDrawTarget, rect.Center(), rect.Size());
|
|
aDrawTarget.Stroke(ellipse, color, strokeOptions);
|
|
return;
|
|
}
|
|
case NOTATION_ROUNDEDBOX: {
|
|
Float radius = 3 * strokeWidth;
|
|
RectCornerRadii radii(radius, radius);
|
|
RefPtr<Path> roundedRect =
|
|
MakePathForRoundedRect(aDrawTarget, rect, radii, true);
|
|
aDrawTarget.Stroke(roundedRect, color, strokeOptions);
|
|
return;
|
|
}
|
|
case NOTATION_UPDIAGONALSTRIKE: {
|
|
aDrawTarget.StrokeLine(rect.BottomLeft(), rect.TopRight(),
|
|
color, strokeOptions);
|
|
return;
|
|
}
|
|
case NOTATION_DOWNDIAGONALSTRIKE: {
|
|
aDrawTarget.StrokeLine(rect.TopLeft(), rect.BottomRight(),
|
|
color, strokeOptions);
|
|
return;
|
|
}
|
|
case NOTATION_UPDIAGONALARROW: {
|
|
// Compute some parameters to draw the updiagonalarrow. The values below
|
|
// are taken from MathJax's HTML-CSS output.
|
|
Float W = rect.Width(); gfxFloat H = rect.Height();
|
|
Float l = sqrt(W*W + H*H);
|
|
Float f = Float(kArrowHeadSize) * strokeWidth / l;
|
|
Float w = W * f; gfxFloat h = H * f;
|
|
|
|
// Draw the arrow shaft
|
|
aDrawTarget.StrokeLine(rect.BottomLeft(),
|
|
rect.TopRight() + Point(-.7*w, .7*h),
|
|
color, strokeOptions);
|
|
|
|
// Draw the arrow head
|
|
RefPtr<PathBuilder> builder = aDrawTarget.CreatePathBuilder();
|
|
builder->MoveTo(rect.TopRight());
|
|
builder->LineTo(rect.TopRight() + Point(-w -.4*h, std::max(-strokeWidth / 2.0, h - .4*w)));
|
|
builder->LineTo(rect.TopRight() + Point(-.7*w, .7*h));
|
|
builder->LineTo(rect.TopRight() + Point(std::min(strokeWidth / 2.0, -w + .4*h), h + .4*w));
|
|
builder->Close();
|
|
RefPtr<Path> path = builder->Finish();
|
|
aDrawTarget.Fill(path, color);
|
|
return;
|
|
}
|
|
case NOTATION_PHASORANGLE: {
|
|
// Compute some parameters to draw the angled line,
|
|
// that uses a slope of 2 (angle = tan^-1(2)).
|
|
// H = w * tan(angle) = w * 2
|
|
Float w = Float(kPhasorangleWidth) * strokeWidth;
|
|
Float H = 2 * w;
|
|
|
|
// Draw the angled line
|
|
aDrawTarget.StrokeLine(rect.BottomLeft(),
|
|
rect.BottomLeft() + Point(w, -H),
|
|
color, strokeOptions);
|
|
return;
|
|
}
|
|
default:
|
|
NS_NOTREACHED("This notation can not be drawn using nsDisplayNotation");
|
|
}
|
|
}
|
|
|
|
void
|
|
nsMathMLmencloseFrame::DisplayNotation(nsDisplayListBuilder* aBuilder,
|
|
nsIFrame* aFrame, const nsRect& aRect,
|
|
const nsDisplayListSet& aLists,
|
|
nscoord aThickness,
|
|
nsMencloseNotation aType)
|
|
{
|
|
if (!aFrame->StyleVisibility()->IsVisible() || aRect.IsEmpty() ||
|
|
aThickness <= 0)
|
|
return;
|
|
|
|
aLists.Content()->AppendNewToTop(new (aBuilder)
|
|
nsDisplayNotation(aBuilder, aFrame, aRect, aThickness, aType));
|
|
}
|