mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
049b3235ac
- Bug 1207494 - Part 8: Remove use of expression closure from dom/identity/. r=ferjm (34fac889f8) - minor crash thing (13fe2827c2) - Bug 1243359 - initialize mScrollSeriesNumber in all ScrollWheelInput constructors. r=roc (94163d8eca) - fix misspatch (b380a7bbe4) - Bug 1207412 - Make SystemTimeConverter use TimeStamp::Now() when converting times; r=karlt (f408549605) - Bug 1212102 - Drop unnecessary assertion comparing timestamps in SystemTimeConverter; r=karlt (1efaa04b3f) - Bug 1241302 - Slightly modernize this code. r=jst (c1e97bc069) - bug 1216916 clean up when InvokeDragSessionWithImage/Selection() fails r=roc (9cdf71b717) - Bug 1231329 - run ConvertToUnscaledDevPixels if *aPresContext is valid. r=roc (d10f23633b) - Bug 1245927: Innerize before creating DOM files from the file picker. r=baku (8754128362) - Bug 1155214 - Mark nsIBidiKeyboard as builtinclass; r=mrbkap (2d00326d2b) - reorder (c3c1ba92c9) - Bug 1236566 - add override declarations for widget/windows/GfxInfo.h; r=roc (940b40ed91) - Bug 1242659: Part 1. More information on the mismatches. r=jrmuizel (78331ddad2) - Block some Radeon drivers that crash on D3D9. (bug 1213107, r=jrmuizel) (482b66d313) - Bug 1203199 - Blacklist DXVA on some older intel drivers for causing crashes. r=jrmuizel (f1827d4498) - Bug 1203199 - Fix driver range with blacklist to avoid blacklisting other OSes. (2c2d547296) - Bug 1203199 - Bustage fix. CLOSED TREE (3233d407f3) - Bug 1178385. Enable DXVA on the G45 r=ajones (3c59a58a15) - Bug 1188442 IMMHandler::GetSelection() should use static Selection instance when IME doesn't have focus and return its or mSelection's reference r=emk (5cc4b30433) - Bug 1238899 Create hidden native caret for ATOK at composing in windowless plugin r=m_kato (40ef5bb4aa) - Bug 1257919 part 1. Kill off nsIXSLTException. r=khuey (11f37643f2) - Bug 1242072 - Change implementation of BaseProxyHandler::get() to follow ES6 [[Get]] specification. r=jorendorff (094a67f284) - Bug 489636 - Add a GC u-bench test for property tree splitting via deletion; r=sfink (9282fec25f) - Bug 1257919 part 2. Make nsIException and nsIStackFrame builtinclass, so we can start using [implicit_jscontext] on them. r=khuey (0e65fb8554) - Bug 1257919 part 3. Make the various toString methods on exceptions take an explicit JSContext. r=khuey (b342fb4930) - Bug 1257919 part 4. Stop returning StackFrame instances from exceptions::CreateStack. C++ callers of GetCurrentJSStack or exceptions::CreateStack always check for null anyway, and none of them seem to want this non-JS thing. r=khuey (d34036ccf9) - Bug 1257919 part 5. Get rid of the now-unused StackFrame class. r=khuey (aa13af0dfe) - Bug 1141222 - Create ScriptError with stack from Cu.reportError. r=bholley (b83ad26aa0) - Bug 1208641 - Extract stack from DOM/XPC exception. r=bholley (e382b5f48c) - Bug 1254380 part 1. Find the relevant window when the compartment we've got is an addon sandbox compartment in AutoJSAPI exception/warning reporting code. r=bholley (4b1f6c64a9) - Bug 1250630 - remove PBackgroundTest and ifdef ENABLE_TEST blocks. r=khuey (d7b36860a3) - Bug 1250963 part 1. Change NotifyRunnable::Dispatch to not require a JSContext. r=khuey (48e03c2fc2) - Bug 1250963 part 2. Remove the unused JSContext argument of WorkerPrivate::ModifyBusyCount. r=khuey (0f5ca42be1) - Bug 1250291 part 1. Stop pretending to report exceptions in MainThreadStopSyncLoopRunnable::PostDispatch. r=khuey (6e1c81cc06) - Bug 1250291 part 2. Stop pretending to report exceptions in MainThreadWorkerSyncRunnable::PostDispatch. r=khuey (f3d846ea31) - Bug 1250291 part 3. Stop pretending to report exceptions in WorkerDebuggerRunnable::PostDispatch. r=khuey (10bc1710d1) - Bug 1250975. Stop passing a JSContext argument to WorkerRunnable::PreDispatch and its overrides. r=khuey (71ab9046f0) - Bug 1255298. Just pass through the JSContext when passing through the NotificationOptions in notification code. r=wchen (552ae8e33e) - Bug 1250185 part 2. Remove some JSContext stuff that's no longer needed in Notification code. r=khuey (20b99ef28b) - Bug 1251045 part 8. Remove the JSContext argument from some nsINotificationStorageCallback methods. r=khuey (170c4afabc) - Bug 1227015 P7 Supress unused ErrorResult exception if the worker runnable failed to dispatch. r=catalinb (23a3cc6f45) - Bug 1251045 part 3. Remove the JSContext argument of WorkerRunnable::PostDispatch and its overrides. r=khuey (6a666d1a4a) - Bug 1251045 part 2. Remove the JSContext argument of ModifyBusyCountFromWorker. r=khuey (105bc4f59e) - Bug 1252130. Remove unnecessary JSContext argument from NotificationWorkerRunnable::WorkerRunInternal. r=khuey (642727f6f6) - Bug 1252127. Remove unnecessary JSContext argument from PromiseWorkerProxy::CleanUp. r=khuey (339e1157d1) - Bug 1251045 part 1. Make it possible to dispatch a ModifyBusyCountRunnable without a JSContext. r=khuey (665c1f81b4) - Bug 1251045 part 4. Remove the JSContext argument of WorkerRunnable::Dispatch. r=khuey (6c5cdab2b7) - Bug 1250185 part 1. nsIStructuredCloneContainer.initFromBase64 doesn't need a JSContext argument. r=khuey (d63a219209) - fix (773c0393aa) - Bug 1251045 part 5. Remove the JSContext argument from WorkerPrivateParent::Freeze/Thaw. r=khuey (cd419bfd2c) - Bug 1251045 part 6. Remove the JSContext argument from some worker debugger methods that no longer need it. r=khuey (abcc437cb9) - Bug 1251045 part 7. Remove the JSContext argument from some worker methods that no longer need it. r=khuey (3ddcbca08c) - Bug 1249652 part 1. Add a method on ErrorResult to steal an exception, if any, from a JSContext. r=khuey (9c07f5044b) - Bug 1229071 - importScripts should throw the correct error result in case the loading of one of scripts fails, r=bz (cd37645d76) - Bug 1229970 Abort script loading start requests if a load has been canceled. r=khuey (a44d9128ca) - Bug 1233171 Cancel channel when ScriptLoader is aborted during service worker script load. r=khuey (3b6ceafec7) - Bug 1249351 part 1. When doing importScripts of multiple scripts in a service worker, make sure to track the cache streams per-loadinfo, instead of trying to make them all wait on the same stream. r=bkelly (e1ccea9685) - Bug 1157544 - Fix a typo in the test; r=baku (8c0bf8f504) - Bug 1249351 part 2. Clean up test_importscript.html and add multiple-url importScript() case. r=bz (52b0a31032) - Bug 1249652 part 2. ScriptExecutorRunnable::WorkerRun should immediately move JS exceptions to its ErrorResult instead of allowing them to linger on the JSContext. r=baku,khuey (f628d3c8ba) - Bug 1249652 part 3. Simplify way we handle canceling when ScriptLoaderRunnable::RunInternal fails by canceling things with its actual failure code, so we don't have to guess which failed loads are actual failures and which are just canceled via this mechanism. r=baku,khuey (388543fbc3) - Bug 1251369. Use an AutoJSAPI that reports its own exceptions around the main runloop in workers. r=khuey (28b33287cd) - Bug 1251518. Fix js::ErrorReportToString to make a bit more sense, and change worker code to not use it anyway, so it matches the mainthread code. r=bholley,terrence (a48a40de90) - Bug 1254380 part 2. Go ahead and log the stack from our exception in AutoJSAPI::ReportException even if we don't have a window. r=bholley (64532b6017) - Bug 1212328 - Clean up some JSErrorReport-related code. r=Waldo,bz (d5aa611edc) - Bug 1255192 part 1. Remove the JSContext argument of JS::ExceptionStackOrNull. r=bholley (39b631d5ad) - bug 1252687 - make the ctor for CycleCollectorStats constexpr r=mccr8 (9e8168d8ac) - Bug 1254380 part 3. Skip firing error events for mainthread out of memory exceptions via AutoJSAPI::ReportException. r=bholley (d5e4e7dc29) - Bug 1254230 kinda-fix. Make sure to never send script errors with stacks attached to the console service if the associated windows have already had FreeInnerObjects called on them. r=bholley (8c379fe0e0) - Bug 1255192 part 2. Clean up the JSContext usage around xpc::FindExceptionStackForConsoleReport now that it just needs a JSContext for rooting. r=bholley (cade862491) - Bug 1255201. Improve the stack handling in nsXPCComponents_Utils::ReportError for the DOMException case to include the stack from the DOMException. r=bholley (fc6c065284) - Bug 1257919 part 6. Make the filename getter on JSStackFrame take an explicit JSContext. r=khuey (cde115b789) - Bug 1257919 part 7. Make the name getter on JSStackFrame take an explicit JSContext. r=khuey (d7466e9eab) - Bug 1257919 part 8. Make the line/column number getters on JSStackFrame take an explicit JSContext. r=khuey (b8766b98b2) - Bug 1257919 part 9. Make the asyncCause/asyncCaller getters on JSStackFrame take an explicit JSContext. r=khuey (b776ff9c6d) - Bug 1257919 part 10. Make the caller and formattedStack getters on JSStackFrame take an explicit JSContext. r=khuey (dc4d3d9091) - Bug 1252091. Add/RemoveFeature don't need a JSContext argument. r=khuey (5be6253a67) - Bug 1252123. Remove some unnecessary JSContext arguments from worker ScriptLoader methods. r=khuey (1657a35268) - Bug 1255181. Remove AutoJSAPI::InitWithLegacyErrorReporting. r=bholley (5ee7ac506e) - Bug 1254847 part 1. Take ownership of error reporting on the AutoEntryScript in nsXPCWrappedJSClass::DelegatedQueryInterface. r=bholley (62d987b030) - make style wrong again.... (fa4e6cfbc1) - Bug 1254847 part 2. Change nsJSNPRuntime to always use AutoEntryScript and always take ownership of error reporting. r=bholley (d24cb80622) - Bug 1251655 - Remove support for JavaScript-global-constructor-prototype-alias. r=bz. (2b354ea423) - Bug 1251655 - Remove support for JavaScript-DOM-class and JavaScript-DOM-interface. r=bz. (dd6786ea57) - Bug 1251275. Switch to using an AutoEntryScript in WorkerPrivate::RunExpiredTimeouts. r=khuey (f10d1b0dec) - Bug 1072144 part 1. Just release-assert that Promise::Resolve does not fail in service worker code. It can only do that on OOM or overrecursion anyway, and overrecursion is not likely if we're coming right off a runnable. r=khuey (ba4c89a3bc) - Bug 1072144 part 2. When UnregisterWorker tries to ScheduleWorker and that throws, just suppress the exception: there is no good place to report it anyway. r=khuey (ca563ec5cd) - Bug 1072144 part 3. Hoist the exception reporting out of WorkerRunnable::PostRun into WorkerRunnable::Run and make it unconditional. r=khuey (9914acd4a6) - Bug 1252221. When GetOrCreateGlobalScope fails while trying to run a ScriptExecutorRunnable::WorkerRun, just suppress the exception, because there is no way to report it without a compartment to work with. r=khuey (abcc9df148) - Bug 1072144 part 4. Add a WorkerRunnable::PreRun so that we can move worker global creation to it and always have an AutoEntryScript by the time we're evaluating the main worker script. r=khuey (007b528868) - Bug 1251276 part 1. Change WorkerPrivate::CancelAllTimeouts to no longer call RunExpiredTimeouts. r=khuey (6b937370a1) - Bug 1251276 part 2. Remove the JSContext argument of WorkerPrivate::CancelAllTimeouts. r=khuey (336b788e03) - Bug 1251380. Change things so that WorkerPrivate::NotifyInternal (hopefully) never throws. r=khuey (1d4863f83a) - Bug 1254846. Add an AutoEntryScript constructor that takes a JSObject instead of an nsIGlobalObject, for convenience. r=bholley (693857f9b0) - Bug 1255706 part 1. Remove JSContext argument from WorkerPrivate constructor. r=khuey (0486bdb01c) - Bug 1255706 part 2. Remove JSContext argument from WorkerPrivate::Terminate. r=khuey (f0b62de092) - Bug 1257568. Remove the JSContext argument of WorkerPrivate::Kill. r=khuey (ebe7d247b5) - Bug 1252189. Remove the unnecessary JSContext argument from WorkerPrivate::FreezeInternal/ThawInternal. r=khuey (22b137b05e) - Bug 1119490 - Expose the URL constructor to WorkerDebuggerGlobalScope;r=khuey (6f4fc13e1e) - Bug 1241841 - Clear the worker's debugger event queue before destroying its context;r=khuey (a1e8dd4b2d) - Bug 1249950 - Add Performance Markers for MessagePort - patch 1 - remove non-useful 'explicit', r=smaug (8a014b53e6) - Bug 1249950 - Add Performance Markers for MessagePort - patch 2, r=smaug, r=vporof (560caf0ae1) - bug 1250486 - make the ComponentsSH ctor constexpr r=bz (1c441dbb0f) - Bug 1257032: Make files in dom/workers actually build without unification. r=baku (6ab4ae0b65) - Bug 1241522 - handle OOM in nsExpatDriver::HandleCharacterData; r=hsivonen (b652220cdc) - Bug 1219482: Replace PRLogModuleInfo with LazyLogModule in various files.r=benjamin (5fd5e8dbc8) - Bug 1238545 - Remove nsISimpleUnicharStreamFactory; r=froydnj (f0018c5b16) - Bug 1257335. Replace some AutoSafeJSContext uses with AutoJSAPI or AutoJSContext uses. r=bholley (7baf79deb7) - Bug 1247635 - Unify PostMessageRunnable and DispatchEventRunnable in MessagePort.cpp, r=smaug (df2765c215) - Bug 1250572 - Force a parent object in MessagePort/Channel and in StructuredCloneHolder, r=smaug (2a929d59d1) - Bug 1255375 - MessagePort should not leak if DispatchMessage() fails, r=smaug (0a5cdebfb0) - Bug 1251272. Remove the dead code in ReportErrorRunnable::ReportError that could fail, and make it infallible. r=khuey (89e80694d0) - Bug 1072144 part 5. Stop fiddling with compartments on the JSContext before calling PostRun in WorkerRunnable::Run. Add some documentation explaining what's going on. r=khuey (91f4bb6a7c) - Bug 1072144 part 6. Switch WorkerRunnable::Run to calling TakeOwnershipOfErrorReporting on its AutoJSAPI/AutoEntryScript and remove the remaining JS_ReportPendingException callers in worker code. r=khuey (405d9e0282) - Bug 1179548 - Close the windows opened in private browsing worker tests; r=baku (acf3430b69) - Bug 1179753 - Use pushPrefEnv more in worker tests; r=baku (4bfd949c72) - Bug 1134224 - More test for test_bug1132395.html, r=ehsan (626eb100cd) - Bug 1134224 - onerror for test_bug1132395.html, r=ehsan (147195f57e) - Bug 1207635 - get rid of dom.workers.sharedWorkers.enabled pref, r=khuey (22fe2965c6) - Bug 1252592. JS warnings should not trigger error events on shared workers. r=khuey (7f05c2c00d) - Bug 1251308; r=luke (3cbec95738) - Bug 1246838 - Handle const qualifiers and references better in Variant. r=waldo (30da6e3ebf) - Bug 1254565 - Allow passing matchers as rvalues to Variant::match. r=froydnj (1dd799fb0a) - Bug 1246841 - Allow construction of Variant values using type inference. r=waldo (6ba3e6704c) - Bug 1250666 - Forward Variant's move constructor argument correctly to the underlying variant type. r=waldo (7353a53bf0) - Bug 1252185. Remove the dead "target" variable from CloseEventRunnable::WorkerRun. r=khuey (be172da10b) - Bug 1253059: Use fallible allocation in the worker error reporter. r=baku (963222bdd4) - Bug 1253199 - MessagePort should handle the dispatching a message when the parent window is gone, r=smaug (d552e3cd9e) - Bug 1252839 - Remove some if stmt after allocation with 'new' - patch 2, r=bz (3c7eb959bc) - Bug 1252839 - Remove some if stmt after allocation with 'new' - patch 1, r=bz (85067dbfb6) - Bug 1254855. Switch AutoEntryScripts in nsDirectoryViewer to take ownership of error reporting. r=bholley (8c10532323) - Bug 1252565 part 1. Push the script environment preparer bits up from XPCJSRuntime to CycleCollectedJSRuntime, because we need them on workers to do ctypes on workers properly. r=bholley (aecf2595dd) - Bug 1252565 part 2. Make dom::WarningOnlyErrorReporter handle workers. r=bholley (f415b8868b) - Bug 1244222 - Check for function interfaces in DelegatedQueryInterface. r=bz (d213eec83c) - Bug 1254393. Take ownership of error reporting on the AutoEntryScript in nsXPCWrappedJSClass::CallMethod. r=bholley (4765b501c0) - Bug 1251769 - Remove remaining references to MOZILLA_XPCOMRT_API from mfbt. r=froydnj (236adc1d4c) - Bug 1247835 (part 0) - Minor comment and style tweaks in BinarySearch.h. r=luke. (db04793721) - Bug 1244074 - Part 1: Move SheetParsingMode to a separate file. r=dholbert (290adaadea) - Bug 1244074 - Part 2: Add HandleRefPtr for refcounting StyleSheetHandles. r=dholbert r=waldo (8549b24392) - Bug 1244068 - Part 1: Add enum to represent the style system backend type. r=dholbert (c2e53feaf2) - Bug 1244068 - Part 2: Add skeleton ServoStyleSet and a StyleSetHandle smart pointer. r=dholbert (71a5c28629) - Bug 1244068 - Part 3: Factor out nsStyleSet getting in RestyleManager/ElementRestyler. r=dholbert (9e9f4f2e80) - Bug 1245406: In ReflowBlockFrame, use Maybe<> to destroy & reconstruct a stack-allocated object, instead of an explicit call to destructor & placement 'new'. r=dbaron (d36858b818) - Bug 1244068 - Part 4: Use StyleSetHandle instead of concrete style set class in most places. r=dholbert (93f9bcf799) - Bug 1244074 - Part 3: Add skeleton ServoStyleSheet and a StyleSheetHandle smart pointer. r=dholbert (5b4fbdce38) - Bug 1195173 - Apply CSP to preloaded styles within layout/style/Loader.cpp (r=bz) (d1ba920fd3) - Bug 1245681 - Fix addOverrideStyleSheet. r=bz (64099eac73) - Bug 1244074 - Part 4: Use StyleSheetHandle instead of concrete style sheet class in most places. r=dholberti (867470ac83) - Bug 1246013 (part 1) - Store a copy of the ETLDEntry directly in DomainEntry instead of a pointer to it. r=jduell. (587b3a9fb7) - Bug 1246013 (part 2) - Change "explicit/xpcom/effective-TLD-service" path to the more sensible "explicit/network/effective-TLD-service". r=jduell. (2e0df6f28f) - Bug 1247835 (part 1) - Use binary search instead of a hash table in nsEffectiveTLDService. r=jduell. (685dae01c0) - Bug 1257121 part 1 - Use struct for passing some params of font metrics. r=jfkthame (1dfd7a7429) - Bug 1257121 part 2 - Merge nsFontMetrics::Init to the constructor and remove unused failure handling code. r=jfkthame (0cdc441511) - Bug 1257121 part 3 - Add GetInflatedFontMetricsForFrame function to simplify a common use pattern. r=jfkthame (d9630ebd1b) - Bug 1257121 part 4 - Use return value rather than out param to retur font metrics. r=jfkthame (c9a5b1d1dd) - Bug 1257121 part 5 - Make nsDeviceContext::mFontCache a RefPtr. r=jfkthame (9c53238a6a)
1355 lines
44 KiB
C++
1355 lines
44 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 "nsMathMLmtableFrame.h"
|
|
#include "nsPresContext.h"
|
|
#include "nsStyleContext.h"
|
|
#include "nsStyleConsts.h"
|
|
#include "nsNameSpaceManager.h"
|
|
#include "nsRenderingContext.h"
|
|
#include "nsCSSRendering.h"
|
|
#include "nsMathMLElement.h"
|
|
|
|
#include "nsTArray.h"
|
|
#include "nsTableFrame.h"
|
|
#include "celldata.h"
|
|
|
|
#include "RestyleManager.h"
|
|
#include <algorithm>
|
|
|
|
#include "nsIScriptError.h"
|
|
#include "nsContentUtils.h"
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::image;
|
|
|
|
//
|
|
// <mtable> -- table or matrix - implementation
|
|
//
|
|
|
|
static int8_t
|
|
ParseStyleValue(nsIAtom* aAttribute, const nsAString& aAttributeValue)
|
|
{
|
|
if (aAttribute == nsGkAtoms::rowalign_) {
|
|
if (aAttributeValue.EqualsLiteral("top"))
|
|
return NS_STYLE_VERTICAL_ALIGN_TOP;
|
|
else if (aAttributeValue.EqualsLiteral("bottom"))
|
|
return NS_STYLE_VERTICAL_ALIGN_BOTTOM;
|
|
else if (aAttributeValue.EqualsLiteral("center"))
|
|
return NS_STYLE_VERTICAL_ALIGN_MIDDLE;
|
|
else
|
|
return NS_STYLE_VERTICAL_ALIGN_BASELINE;
|
|
} else if (aAttribute == nsGkAtoms::columnalign_) {
|
|
if (aAttributeValue.EqualsLiteral("left"))
|
|
return NS_STYLE_TEXT_ALIGN_LEFT;
|
|
else if (aAttributeValue.EqualsLiteral("right"))
|
|
return NS_STYLE_TEXT_ALIGN_RIGHT;
|
|
else
|
|
return NS_STYLE_TEXT_ALIGN_CENTER;
|
|
} else if (aAttribute == nsGkAtoms::rowlines_ ||
|
|
aAttribute == nsGkAtoms::columnlines_) {
|
|
if (aAttributeValue.EqualsLiteral("solid"))
|
|
return NS_STYLE_BORDER_STYLE_SOLID;
|
|
else if (aAttributeValue.EqualsLiteral("dashed"))
|
|
return NS_STYLE_BORDER_STYLE_DASHED;
|
|
else
|
|
return NS_STYLE_BORDER_STYLE_NONE;
|
|
} else {
|
|
MOZ_CRASH("Unrecognized attribute.");
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
static nsTArray<int8_t>*
|
|
ExtractStyleValues(const nsAString& aString, nsIAtom* aAttribute,
|
|
bool aAllowMultiValues)
|
|
{
|
|
nsTArray<int8_t>* styleArray = nullptr;
|
|
|
|
const char16_t* start = aString.BeginReading();
|
|
const char16_t* end = aString.EndReading();
|
|
|
|
int32_t startIndex = 0;
|
|
int32_t count = 0;
|
|
|
|
while (start < end) {
|
|
// Skip leading spaces.
|
|
while ((start < end) && nsCRT::IsAsciiSpace(*start)) {
|
|
start++;
|
|
startIndex++;
|
|
}
|
|
|
|
// Look for the end of the string, or another space.
|
|
while ((start < end) && !nsCRT::IsAsciiSpace(*start)) {
|
|
start++;
|
|
count++;
|
|
}
|
|
|
|
// Grab the value found and process it.
|
|
if (count > 0) {
|
|
if (!styleArray)
|
|
styleArray = new nsTArray<int8_t>();
|
|
|
|
// We want to return a null array if an attribute gives multiple values,
|
|
// but multiple values aren't allowed.
|
|
if (styleArray->Length() > 1 && !aAllowMultiValues) {
|
|
delete styleArray;
|
|
return nullptr;
|
|
}
|
|
|
|
nsDependentSubstring valueString(aString, startIndex, count);
|
|
int8_t styleValue = ParseStyleValue(aAttribute, valueString);
|
|
styleArray->AppendElement(styleValue);
|
|
|
|
startIndex += count;
|
|
count = 0;
|
|
}
|
|
}
|
|
return styleArray;
|
|
}
|
|
|
|
static nsresult ReportParseError(nsIFrame* aFrame, const char16_t* aAttribute,
|
|
const char16_t* aValue)
|
|
{
|
|
nsIContent* content = aFrame->GetContent();
|
|
|
|
const char16_t* params[] =
|
|
{ aValue, aAttribute, content->NodeInfo()->NameAtom()->GetUTF16String() };
|
|
|
|
return nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
|
|
NS_LITERAL_CSTRING("Layout: MathML"),
|
|
content->OwnerDoc(),
|
|
nsContentUtils::eMATHML_PROPERTIES,
|
|
"AttributeParsingError", params, 3);
|
|
}
|
|
|
|
// Each rowalign='top bottom' or columnalign='left right center' (from
|
|
// <mtable> or <mtr>) is split once into an nsTArray<int8_t> which is
|
|
// stored in the property table. Row/Cell frames query the property table
|
|
// to see what values apply to them.
|
|
|
|
NS_DECLARE_FRAME_PROPERTY_DELETABLE(RowAlignProperty, nsTArray<int8_t>)
|
|
NS_DECLARE_FRAME_PROPERTY_DELETABLE(RowLinesProperty, nsTArray<int8_t>)
|
|
NS_DECLARE_FRAME_PROPERTY_DELETABLE(ColumnAlignProperty, nsTArray<int8_t>)
|
|
NS_DECLARE_FRAME_PROPERTY_DELETABLE(ColumnLinesProperty, nsTArray<int8_t>)
|
|
|
|
static const FramePropertyDescriptor<nsTArray<int8_t>>*
|
|
AttributeToProperty(nsIAtom* aAttribute)
|
|
{
|
|
if (aAttribute == nsGkAtoms::rowalign_)
|
|
return RowAlignProperty();
|
|
if (aAttribute == nsGkAtoms::rowlines_)
|
|
return RowLinesProperty();
|
|
if (aAttribute == nsGkAtoms::columnalign_)
|
|
return ColumnAlignProperty();
|
|
NS_ASSERTION(aAttribute == nsGkAtoms::columnlines_, "Invalid attribute");
|
|
return ColumnLinesProperty();
|
|
}
|
|
|
|
/* This method looks for a property that applies to a cell, but it looks
|
|
* recursively because some cell properties can come from the cell, a row,
|
|
* a table, etc. This function searches through the heirarchy for a property
|
|
* and returns its value. The function stops searching after checking a <mtable>
|
|
* frame.
|
|
*/
|
|
static nsTArray<int8_t>*
|
|
FindCellProperty(const nsIFrame* aCellFrame,
|
|
const FramePropertyDescriptor<nsTArray<int8_t>>* aFrameProperty)
|
|
{
|
|
const nsIFrame* currentFrame = aCellFrame;
|
|
nsTArray<int8_t>* propertyData = nullptr;
|
|
|
|
while (currentFrame) {
|
|
FrameProperties props = currentFrame->Properties();
|
|
propertyData = props.Get(aFrameProperty);
|
|
bool frameIsTable = (currentFrame->GetType() == nsGkAtoms::tableFrame);
|
|
|
|
if (propertyData || frameIsTable)
|
|
currentFrame = nullptr; // A null frame pointer exits the loop
|
|
else
|
|
currentFrame = currentFrame->GetParent(); // Go to the parent frame
|
|
}
|
|
|
|
return propertyData;
|
|
}
|
|
|
|
static void
|
|
ApplyBorderToStyle(const nsMathMLmtdFrame* aFrame,
|
|
nsStyleBorder& aStyleBorder)
|
|
{
|
|
int32_t rowIndex;
|
|
int32_t columnIndex;
|
|
aFrame->GetRowIndex(rowIndex);
|
|
aFrame->GetColIndex(columnIndex);
|
|
|
|
nscoord borderWidth =
|
|
aFrame->PresContext()->GetBorderWidthTable()[NS_STYLE_BORDER_WIDTH_THIN];
|
|
|
|
nsTArray<int8_t>* rowLinesList =
|
|
FindCellProperty(aFrame, RowLinesProperty());
|
|
|
|
nsTArray<int8_t>* columnLinesList =
|
|
FindCellProperty(aFrame, ColumnLinesProperty());
|
|
|
|
// We don't place a row line on top of the first row
|
|
if (rowIndex > 0 && rowLinesList) {
|
|
// If the row number is greater than the number of provided rowline
|
|
// values, we simply repeat the last value.
|
|
int32_t listLength = rowLinesList->Length();
|
|
if (rowIndex < listLength) {
|
|
aStyleBorder.SetBorderStyle(NS_SIDE_TOP,
|
|
rowLinesList->ElementAt(rowIndex - 1));
|
|
} else {
|
|
aStyleBorder.SetBorderStyle(NS_SIDE_TOP,
|
|
rowLinesList->ElementAt(listLength - 1));
|
|
}
|
|
aStyleBorder.SetBorderWidth(NS_SIDE_TOP, borderWidth);
|
|
}
|
|
|
|
// We don't place a column line on the left of the first column.
|
|
if (columnIndex > 0 && columnLinesList) {
|
|
// If the column number is greater than the number of provided columline
|
|
// values, we simply repeat the last value.
|
|
int32_t listLength = columnLinesList->Length();
|
|
if (columnIndex < listLength) {
|
|
aStyleBorder.SetBorderStyle(NS_SIDE_LEFT,
|
|
columnLinesList->ElementAt(columnIndex - 1));
|
|
} else {
|
|
aStyleBorder.SetBorderStyle(NS_SIDE_LEFT,
|
|
columnLinesList->ElementAt(listLength - 1));
|
|
}
|
|
aStyleBorder.SetBorderWidth(NS_SIDE_LEFT, borderWidth);
|
|
}
|
|
}
|
|
|
|
static nsMargin
|
|
ComputeBorderOverflow(nsMathMLmtdFrame* aFrame, nsStyleBorder aStyleBorder)
|
|
{
|
|
nsMargin overflow;
|
|
int32_t rowIndex;
|
|
int32_t columnIndex;
|
|
nsTableFrame* table = aFrame->GetTableFrame();
|
|
aFrame->GetCellIndexes(rowIndex, columnIndex);
|
|
if (!columnIndex) {
|
|
overflow.left = table->GetColSpacing(-1);
|
|
overflow.right = table->GetColSpacing(0) / 2;
|
|
} else if (columnIndex == table->GetColCount() - 1) {
|
|
overflow.left = table->GetColSpacing(columnIndex - 1) / 2;
|
|
overflow.right = table->GetColSpacing(columnIndex + 1);
|
|
} else {
|
|
overflow.left = table->GetColSpacing(columnIndex - 1) / 2;
|
|
overflow.right = table->GetColSpacing(columnIndex) / 2;
|
|
}
|
|
if (!rowIndex) {
|
|
overflow.top = table->GetRowSpacing(-1);
|
|
overflow.bottom = table->GetRowSpacing(0) / 2;
|
|
} else if (rowIndex == table->GetRowCount() - 1) {
|
|
overflow.top = table->GetRowSpacing(rowIndex - 1) / 2;
|
|
overflow.bottom = table->GetRowSpacing(rowIndex + 1);
|
|
} else {
|
|
overflow.top = table->GetRowSpacing(rowIndex - 1) / 2;
|
|
overflow.bottom = table->GetRowSpacing(rowIndex) / 2;
|
|
}
|
|
return overflow;
|
|
}
|
|
|
|
/*
|
|
* A variant of the nsDisplayBorder contains special code to render a border
|
|
* around a nsMathMLmtdFrame based on the rowline and columnline properties
|
|
* set on the cell frame.
|
|
*/
|
|
class nsDisplaymtdBorder : public nsDisplayBorder {
|
|
public:
|
|
nsDisplaymtdBorder(nsDisplayListBuilder* aBuilder, nsMathMLmtdFrame* aFrame)
|
|
: nsDisplayBorder(aBuilder, aFrame)
|
|
{
|
|
}
|
|
|
|
nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) override
|
|
{
|
|
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
|
|
}
|
|
|
|
void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
nsRegion* aInvalidRegion) override
|
|
{
|
|
auto geometry =
|
|
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
|
|
|
|
if (aBuilder->ShouldSyncDecodeImages() &&
|
|
geometry->ShouldInvalidateToSyncDecodeImages()) {
|
|
bool snap;
|
|
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
|
|
}
|
|
|
|
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
|
|
}
|
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) override
|
|
{
|
|
*aSnap = true;
|
|
nsStyleBorder styleBorder = *mFrame->StyleBorder();
|
|
nsMathMLmtdFrame* frame = static_cast<nsMathMLmtdFrame*>(mFrame);
|
|
ApplyBorderToStyle(frame, styleBorder);
|
|
nsRect bounds = CalculateBounds(styleBorder);
|
|
nsMargin overflow = ComputeBorderOverflow(frame, styleBorder);
|
|
bounds.Inflate(overflow);
|
|
return bounds;
|
|
}
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) override
|
|
{
|
|
nsStyleBorder styleBorder = *mFrame->StyleBorder();
|
|
nsMathMLmtdFrame* frame = static_cast<nsMathMLmtdFrame*>(mFrame);
|
|
ApplyBorderToStyle(frame, styleBorder);
|
|
|
|
nsRect bounds = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
|
nsMargin overflow = ComputeBorderOverflow(frame, styleBorder);
|
|
bounds.Inflate(overflow);
|
|
|
|
PaintBorderFlags flags = aBuilder->ShouldSyncDecodeImages()
|
|
? PaintBorderFlags::SYNC_DECODE_IMAGES
|
|
: PaintBorderFlags();
|
|
|
|
DrawResult result =
|
|
nsCSSRendering::PaintBorderWithStyleBorder(mFrame->PresContext(), *aCtx,
|
|
mFrame, mVisibleRect,
|
|
bounds,
|
|
styleBorder,
|
|
mFrame->StyleContext(),
|
|
flags,
|
|
mFrame->GetSkipSides());
|
|
|
|
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
|
|
}
|
|
};
|
|
|
|
#ifdef DEBUG
|
|
#define DEBUG_VERIFY_THAT_FRAME_IS(_frame, _expected) \
|
|
NS_ASSERTION(NS_STYLE_DISPLAY_##_expected == _frame->StyleDisplay()->mDisplay, "internal error");
|
|
#else
|
|
#define DEBUG_VERIFY_THAT_FRAME_IS(_frame, _expected)
|
|
#endif
|
|
|
|
static void
|
|
ParseFrameAttribute(nsIFrame* aFrame, nsIAtom* aAttribute,
|
|
bool aAllowMultiValues)
|
|
{
|
|
nsAutoString attrValue;
|
|
|
|
nsIContent* frameContent = aFrame->GetContent();
|
|
frameContent->GetAttr(kNameSpaceID_None, aAttribute, attrValue);
|
|
|
|
if (!attrValue.IsEmpty()) {
|
|
nsTArray<int8_t>* valueList =
|
|
ExtractStyleValues(attrValue, aAttribute, aAllowMultiValues);
|
|
|
|
// If valueList is null, that indicates a problem with the attribute value.
|
|
// Only set properties on a valid attribute value.
|
|
if (valueList) {
|
|
// The code reading the property assumes that this list is nonempty.
|
|
NS_ASSERTION(valueList->Length() >= 1, "valueList should not be empty!");
|
|
FrameProperties props = aFrame->Properties();
|
|
props.Set(AttributeToProperty(aAttribute), valueList);
|
|
} else {
|
|
ReportParseError(aFrame, aAttribute->GetUTF16String(), attrValue.get());
|
|
}
|
|
}
|
|
}
|
|
|
|
// rowspacing
|
|
//
|
|
// Specifies the distance between successive rows in an mtable. Multiple
|
|
// lengths can be specified, each corresponding to its respective position
|
|
// between rows. For example:
|
|
//
|
|
// [ROW_0]
|
|
// rowspace_0
|
|
// [ROW_1]
|
|
// rowspace_1
|
|
// [ROW_2]
|
|
//
|
|
// If the number of row gaps exceeds the number of lengths specified, the final
|
|
// specified length is repeated. Additional lengths are ignored.
|
|
//
|
|
// values: (length)+
|
|
// default: 1.0ex
|
|
//
|
|
// Unitless values are permitted and provide a multiple of the default value
|
|
// Negative values are forbidden.
|
|
//
|
|
|
|
// columnspacing
|
|
//
|
|
// Specifies the distance between successive columns in an mtable. Multiple
|
|
// lengths can be specified, each corresponding to its respective position
|
|
// between columns. For example:
|
|
//
|
|
// [COLUMN_0] columnspace_0 [COLUMN_1] columnspace_1 [COLUMN_2]
|
|
//
|
|
// If the number of column gaps exceeds the number of lengths specified, the
|
|
// final specified length is repeated. Additional lengths are ignored.
|
|
//
|
|
// values: (length)+
|
|
// default: 0.8em
|
|
//
|
|
// Unitless values are permitted and provide a multiple of the default value
|
|
// Negative values are forbidden.
|
|
//
|
|
|
|
// framespacing
|
|
//
|
|
// Specifies the distance between the mtable and its frame (if any). The
|
|
// first value specified provides the spacing between the left and right edge
|
|
// of the table and the frame, the second value determines the spacing between
|
|
// the top and bottom edges and the frame.
|
|
//
|
|
// An error is reported if only one length is passed. Any additional lengths
|
|
// are ignored
|
|
//
|
|
// values: length length
|
|
// default: 0em 0ex If frame attribute is "none" or not specified,
|
|
// 0.4em 0.5ex otherwise
|
|
//
|
|
// Unitless values are permitted and provide a multiple of the default value
|
|
// Negative values are forbidden.
|
|
//
|
|
|
|
static const float kDefaultRowspacingEx = 1.0f;
|
|
static const float kDefaultColumnspacingEm = 0.8f;
|
|
static const float kDefaultFramespacingArg0Em = 0.4f;
|
|
static const float kDefaultFramespacingArg1Ex = 0.5f;
|
|
|
|
static void
|
|
ExtractSpacingValues(const nsAString& aString,
|
|
nsIAtom* aAttribute,
|
|
nsTArray<nscoord>& aSpacingArray,
|
|
nsIFrame* aFrame,
|
|
nscoord aDefaultValue0,
|
|
nscoord aDefaultValue1,
|
|
float aFontSizeInflation)
|
|
{
|
|
nsPresContext* presContext = aFrame->PresContext();
|
|
nsStyleContext* styleContext = aFrame->StyleContext();
|
|
|
|
const char16_t* start = aString.BeginReading();
|
|
const char16_t* end = aString.EndReading();
|
|
|
|
int32_t startIndex = 0;
|
|
int32_t count = 0;
|
|
int32_t elementNum = 0;
|
|
|
|
while (start < end) {
|
|
// Skip leading spaces.
|
|
while ((start < end) && nsCRT::IsAsciiSpace(*start)) {
|
|
start++;
|
|
startIndex++;
|
|
}
|
|
|
|
// Look for the end of the string, or another space.
|
|
while ((start < end) && !nsCRT::IsAsciiSpace(*start)) {
|
|
start++;
|
|
count++;
|
|
}
|
|
|
|
// Grab the value found and process it.
|
|
if (count > 0) {
|
|
const nsAString& str = Substring(aString, startIndex, count);
|
|
nsAutoString valueString;
|
|
valueString.Assign(str);
|
|
nscoord newValue;
|
|
if (aAttribute == nsGkAtoms::framespacing_ && elementNum) {
|
|
newValue = aDefaultValue1;
|
|
} else {
|
|
newValue = aDefaultValue0;
|
|
}
|
|
nsMathMLFrame::ParseNumericValue(valueString, &newValue,
|
|
nsMathMLElement::PARSE_ALLOW_UNITLESS,
|
|
presContext, styleContext,
|
|
aFontSizeInflation);
|
|
aSpacingArray.AppendElement(newValue);
|
|
|
|
startIndex += count;
|
|
count = 0;
|
|
elementNum++;
|
|
}
|
|
}
|
|
}
|
|
|
|
static void
|
|
ParseSpacingAttribute(nsMathMLmtableFrame* aFrame, nsIAtom* aAttribute)
|
|
{
|
|
NS_ASSERTION(aAttribute == nsGkAtoms::rowspacing_ ||
|
|
aAttribute == nsGkAtoms::columnspacing_ ||
|
|
aAttribute == nsGkAtoms::framespacing_,
|
|
"Non spacing attribute passed");
|
|
|
|
nsAutoString attrValue;
|
|
nsIContent* frameContent = aFrame->GetContent();
|
|
frameContent->GetAttr(kNameSpaceID_None, aAttribute, attrValue);
|
|
|
|
if (nsGkAtoms::framespacing_ == aAttribute) {
|
|
nsAutoString frame;
|
|
frameContent->GetAttr(kNameSpaceID_None, nsGkAtoms::frame, frame);
|
|
if (frame.IsEmpty() || frame.EqualsLiteral("none")) {
|
|
aFrame->SetFrameSpacing(0, 0);
|
|
return;
|
|
}
|
|
}
|
|
|
|
nscoord value;
|
|
nscoord value2;
|
|
// Set defaults
|
|
float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(aFrame);
|
|
RefPtr<nsFontMetrics> fm =
|
|
nsLayoutUtils::GetFontMetricsForFrame(aFrame, fontSizeInflation);
|
|
if (nsGkAtoms::rowspacing_ == aAttribute) {
|
|
value = kDefaultRowspacingEx * fm->XHeight();
|
|
value2 = 0;
|
|
} else if (nsGkAtoms::columnspacing_ == aAttribute) {
|
|
value = kDefaultColumnspacingEm * fm->EmHeight();
|
|
value2 = 0;
|
|
} else {
|
|
value = kDefaultFramespacingArg0Em * fm->EmHeight();
|
|
value2 = kDefaultFramespacingArg1Ex * fm->XHeight();
|
|
}
|
|
|
|
nsTArray<nscoord> valueList;
|
|
ExtractSpacingValues(attrValue, aAttribute, valueList, aFrame, value, value2,
|
|
fontSizeInflation);
|
|
if (valueList.Length() == 0) {
|
|
if (frameContent->HasAttr(kNameSpaceID_None, aAttribute)) {
|
|
ReportParseError(aFrame, aAttribute->GetUTF16String(),
|
|
attrValue.get());
|
|
}
|
|
valueList.AppendElement(value);
|
|
}
|
|
if (aAttribute == nsGkAtoms::framespacing_) {
|
|
if (valueList.Length() == 1) {
|
|
if(frameContent->HasAttr(kNameSpaceID_None, aAttribute)) {
|
|
ReportParseError(aFrame, aAttribute->GetUTF16String(),
|
|
attrValue.get());
|
|
}
|
|
valueList.AppendElement(value2);
|
|
} else if (valueList.Length() != 2) {
|
|
ReportParseError(aFrame, aAttribute->GetUTF16String(),
|
|
attrValue.get());
|
|
}
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::rowspacing_) {
|
|
aFrame->SetRowSpacingArray(valueList);
|
|
} else if (aAttribute == nsGkAtoms::columnspacing_) {
|
|
aFrame->SetColSpacingArray(valueList);
|
|
} else {
|
|
aFrame->SetFrameSpacing(valueList.ElementAt(0),
|
|
valueList.ElementAt(1));
|
|
}
|
|
}
|
|
|
|
static void ParseSpacingAttributes(nsMathMLmtableFrame* aTableFrame)
|
|
{
|
|
ParseSpacingAttribute(aTableFrame, nsGkAtoms::rowspacing_);
|
|
ParseSpacingAttribute(aTableFrame, nsGkAtoms::columnspacing_);
|
|
ParseSpacingAttribute(aTableFrame, nsGkAtoms::framespacing_);
|
|
aTableFrame->SetUseCSSSpacing();
|
|
}
|
|
|
|
// map all attribues within a table -- requires the indices of rows and cells.
|
|
// so it can only happen after they are made ready by the table base class.
|
|
static void
|
|
MapAllAttributesIntoCSS(nsMathMLmtableFrame* aTableFrame)
|
|
{
|
|
// Map mtable rowalign & rowlines.
|
|
ParseFrameAttribute(aTableFrame, nsGkAtoms::rowalign_, true);
|
|
ParseFrameAttribute(aTableFrame, nsGkAtoms::rowlines_, true);
|
|
|
|
// Map mtable columnalign & columnlines.
|
|
ParseFrameAttribute(aTableFrame, nsGkAtoms::columnalign_, true);
|
|
ParseFrameAttribute(aTableFrame, nsGkAtoms::columnlines_, true);
|
|
|
|
// Map mtable rowspacing, columnspacing & framespacing
|
|
ParseSpacingAttributes(aTableFrame);
|
|
|
|
// mtable is simple and only has one (pseudo) row-group
|
|
nsIFrame* rgFrame = aTableFrame->PrincipalChildList().FirstChild();
|
|
if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame)
|
|
return;
|
|
|
|
for (nsIFrame* rowFrame : rgFrame->PrincipalChildList()) {
|
|
DEBUG_VERIFY_THAT_FRAME_IS(rowFrame, TABLE_ROW);
|
|
if (rowFrame->GetType() == nsGkAtoms::tableRowFrame) {
|
|
// Map row rowalign.
|
|
ParseFrameAttribute(rowFrame, nsGkAtoms::rowalign_, false);
|
|
// Map row columnalign.
|
|
ParseFrameAttribute(rowFrame, nsGkAtoms::columnalign_, true);
|
|
|
|
for (nsIFrame* cellFrame : rowFrame->PrincipalChildList()) {
|
|
DEBUG_VERIFY_THAT_FRAME_IS(cellFrame, TABLE_CELL);
|
|
if (IS_TABLE_CELL(cellFrame->GetType())) {
|
|
// Map cell rowalign.
|
|
ParseFrameAttribute(cellFrame, nsGkAtoms::rowalign_, false);
|
|
// Map row columnalign.
|
|
ParseFrameAttribute(cellFrame, nsGkAtoms::columnalign_, false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// the align attribute of mtable can have a row number which indicates
|
|
// from where to anchor the table, e.g., top 5 means anchor the table at
|
|
// the top of the 5th row, axis -1 means anchor the table on the axis of
|
|
// the last row
|
|
|
|
// The REC says that the syntax is
|
|
// '\s*(top|bottom|center|baseline|axis)(\s+-?[0-9]+)?\s*'
|
|
// the parsing could have been simpler with that syntax
|
|
// but for backward compatibility we make optional
|
|
// the whitespaces between the alignment name and the row number
|
|
|
|
enum eAlign {
|
|
eAlign_top,
|
|
eAlign_bottom,
|
|
eAlign_center,
|
|
eAlign_baseline,
|
|
eAlign_axis
|
|
};
|
|
|
|
static void
|
|
ParseAlignAttribute(nsString& aValue, eAlign& aAlign, int32_t& aRowIndex)
|
|
{
|
|
// by default, the table is centered about the axis
|
|
aRowIndex = 0;
|
|
aAlign = eAlign_axis;
|
|
int32_t len = 0;
|
|
|
|
// we only have to remove the leading spaces because
|
|
// ToInteger ignores the whitespaces around the number
|
|
aValue.CompressWhitespace(true, false);
|
|
|
|
if (0 == aValue.Find("top")) {
|
|
len = 3; // 3 is the length of 'top'
|
|
aAlign = eAlign_top;
|
|
}
|
|
else if (0 == aValue.Find("bottom")) {
|
|
len = 6; // 6 is the length of 'bottom'
|
|
aAlign = eAlign_bottom;
|
|
}
|
|
else if (0 == aValue.Find("center")) {
|
|
len = 6; // 6 is the length of 'center'
|
|
aAlign = eAlign_center;
|
|
}
|
|
else if (0 == aValue.Find("baseline")) {
|
|
len = 8; // 8 is the length of 'baseline'
|
|
aAlign = eAlign_baseline;
|
|
}
|
|
else if (0 == aValue.Find("axis")) {
|
|
len = 4; // 4 is the length of 'axis'
|
|
aAlign = eAlign_axis;
|
|
}
|
|
if (len) {
|
|
nsresult error;
|
|
aValue.Cut(0, len); // aValue is not a const here
|
|
aRowIndex = aValue.ToInteger(&error);
|
|
if (NS_FAILED(error))
|
|
aRowIndex = 0;
|
|
}
|
|
}
|
|
|
|
#ifdef DEBUG_rbs_off
|
|
// call ListMathMLTree(mParent) to get the big picture
|
|
static void
|
|
ListMathMLTree(nsIFrame* atLeast)
|
|
{
|
|
// climb up to <math> or <body> if <math> isn't there
|
|
nsIFrame* f = atLeast;
|
|
for ( ; f; f = f->GetParent()) {
|
|
nsIContent* c = f->GetContent();
|
|
if (!c || c->IsMathMLElement(nsGkAtoms::math) ||
|
|
c->NodeInfo()->NameAtom(nsGkAtoms::body)) // XXXbaku which kind of body tag?
|
|
break;
|
|
}
|
|
if (!f) f = atLeast;
|
|
f->List(stdout, 0);
|
|
}
|
|
#endif
|
|
|
|
// --------
|
|
// implementation of nsMathMLmtableOuterFrame
|
|
|
|
NS_QUERYFRAME_HEAD(nsMathMLmtableOuterFrame)
|
|
NS_QUERYFRAME_ENTRY(nsIMathMLFrame)
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsTableOuterFrame)
|
|
|
|
nsContainerFrame*
|
|
NS_NewMathMLmtableOuterFrame (nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
{
|
|
return new (aPresShell) nsMathMLmtableOuterFrame(aContext);
|
|
}
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtableOuterFrame)
|
|
|
|
nsMathMLmtableOuterFrame::~nsMathMLmtableOuterFrame()
|
|
{
|
|
}
|
|
|
|
nsresult
|
|
nsMathMLmtableOuterFrame::AttributeChanged(int32_t aNameSpaceID,
|
|
nsIAtom* aAttribute,
|
|
int32_t aModType)
|
|
{
|
|
// Attributes specific to <mtable>:
|
|
// frame : in mathml.css
|
|
// framespacing : here
|
|
// groupalign : not yet supported
|
|
// equalrows : not yet supported
|
|
// equalcolumns : not yet supported
|
|
// displaystyle : here and in mathml.css
|
|
// align : in reflow
|
|
// rowalign : here
|
|
// rowlines : here
|
|
// rowspacing : here
|
|
// columnalign : here
|
|
// columnlines : here
|
|
// columnspacing : here
|
|
|
|
// mtable is simple and only has one (pseudo) row-group inside our inner-table
|
|
nsIFrame* tableFrame = mFrames.FirstChild();
|
|
NS_ASSERTION(tableFrame && tableFrame->GetType() == nsGkAtoms::tableFrame,
|
|
"should always have an inner table frame");
|
|
nsIFrame* rgFrame = tableFrame->PrincipalChildList().FirstChild();
|
|
if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame)
|
|
return NS_OK;
|
|
|
|
// align - just need to issue a dirty (resize) reflow command
|
|
if (aAttribute == nsGkAtoms::align) {
|
|
PresContext()->PresShell()->
|
|
FrameNeedsReflow(this, nsIPresShell::eResize, NS_FRAME_IS_DIRTY);
|
|
return NS_OK;
|
|
}
|
|
|
|
// displaystyle - may seem innocuous, but it is actually very harsh --
|
|
// like changing an unit. Blow away and recompute all our automatic
|
|
// presentational data, and issue a style-changed reflow request
|
|
if (aAttribute == nsGkAtoms::displaystyle_) {
|
|
nsMathMLContainerFrame::RebuildAutomaticDataForChildren(GetParent());
|
|
// Need to reflow the parent, not us, because this can actually
|
|
// affect siblings.
|
|
PresContext()->PresShell()->
|
|
FrameNeedsReflow(GetParent(), nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
|
|
return NS_OK;
|
|
}
|
|
|
|
// ...and the other attributes affect rows or columns in one way or another
|
|
|
|
nsPresContext* presContext = tableFrame->PresContext();
|
|
if (aAttribute == nsGkAtoms::rowspacing_ ||
|
|
aAttribute == nsGkAtoms::columnspacing_ ||
|
|
aAttribute == nsGkAtoms::framespacing_ ) {
|
|
nsMathMLmtableFrame* mathMLmtableFrame = do_QueryFrame(tableFrame);
|
|
if (mathMLmtableFrame) {
|
|
ParseSpacingAttribute(mathMLmtableFrame, aAttribute);
|
|
mathMLmtableFrame->SetUseCSSSpacing();
|
|
}
|
|
} else if (aAttribute == nsGkAtoms::rowalign_ ||
|
|
aAttribute == nsGkAtoms::rowlines_ ||
|
|
aAttribute == nsGkAtoms::columnalign_ ||
|
|
aAttribute == nsGkAtoms::columnlines_) {
|
|
// clear any cached property list for this table
|
|
presContext->PropertyTable()->
|
|
Delete(tableFrame, AttributeToProperty(aAttribute));
|
|
// Reparse the new attribute on the table.
|
|
ParseFrameAttribute(tableFrame, aAttribute, true);
|
|
} else {
|
|
// Ignore attributes that do not affect layout.
|
|
return NS_OK;
|
|
}
|
|
|
|
// Explicitly request a reflow in our subtree to pick up any changes
|
|
presContext->PresShell()->
|
|
FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
nsIFrame*
|
|
nsMathMLmtableOuterFrame::GetRowFrameAt(int32_t aRowIndex)
|
|
{
|
|
int32_t rowCount = GetRowCount();
|
|
|
|
// Negative indices mean to find upwards from the end.
|
|
if (aRowIndex < 0) {
|
|
aRowIndex = rowCount + aRowIndex;
|
|
} else {
|
|
// aRowIndex is 1-based, so convert it to a 0-based index
|
|
--aRowIndex;
|
|
}
|
|
|
|
// if our inner table says that the index is valid, find the row now
|
|
if (0 <= aRowIndex && aRowIndex <= rowCount) {
|
|
nsIFrame* tableFrame = mFrames.FirstChild();
|
|
NS_ASSERTION(tableFrame && tableFrame->GetType() == nsGkAtoms::tableFrame,
|
|
"should always have an inner table frame");
|
|
nsIFrame* rgFrame = tableFrame->PrincipalChildList().FirstChild();
|
|
if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame)
|
|
return nullptr;
|
|
for (nsIFrame* rowFrame : rgFrame->PrincipalChildList()) {
|
|
if (aRowIndex == 0) {
|
|
DEBUG_VERIFY_THAT_FRAME_IS(rowFrame, TABLE_ROW);
|
|
if (rowFrame->GetType() != nsGkAtoms::tableRowFrame)
|
|
return nullptr;
|
|
|
|
return rowFrame;
|
|
}
|
|
--aRowIndex;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
void
|
|
nsMathMLmtableOuterFrame::Reflow(nsPresContext* aPresContext,
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
const nsHTMLReflowState& aReflowState,
|
|
nsReflowStatus& aStatus)
|
|
{
|
|
nsAutoString value;
|
|
// we want to return a table that is anchored according to the align attribute
|
|
|
|
nsTableOuterFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
NS_ASSERTION(aDesiredSize.Height() >= 0, "illegal height for mtable");
|
|
NS_ASSERTION(aDesiredSize.Width() >= 0, "illegal width for mtable");
|
|
|
|
// see if the user has set the align attribute on the <mtable>
|
|
int32_t rowIndex = 0;
|
|
eAlign tableAlign = eAlign_axis;
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::align, value);
|
|
if (!value.IsEmpty()) {
|
|
ParseAlignAttribute(value, tableAlign, rowIndex);
|
|
}
|
|
|
|
// adjustments if there is a specified row from where to anchor the table
|
|
// (conceptually: when there is no row of reference, picture the table as if
|
|
// it is wrapped in a single big fictional row at dy = 0, this way of
|
|
// doing so allows us to have a single code path for all cases).
|
|
nscoord dy = 0;
|
|
WritingMode wm = aDesiredSize.GetWritingMode();
|
|
nscoord blockSize = aDesiredSize.BSize(wm);
|
|
nsIFrame* rowFrame = nullptr;
|
|
if (rowIndex) {
|
|
rowFrame = GetRowFrameAt(rowIndex);
|
|
if (rowFrame) {
|
|
// translate the coordinates to be relative to us and in our writing mode
|
|
nsIFrame* frame = rowFrame;
|
|
LogicalRect rect(wm, frame->GetRect(),
|
|
aReflowState.ComputedSizeAsContainerIfConstrained());
|
|
blockSize = rect.BSize(wm);
|
|
do {
|
|
dy += rect.BStart(wm);
|
|
frame = frame->GetParent();
|
|
} while (frame != this);
|
|
}
|
|
}
|
|
switch (tableAlign) {
|
|
case eAlign_top:
|
|
aDesiredSize.SetBlockStartAscent(dy);
|
|
break;
|
|
case eAlign_bottom:
|
|
aDesiredSize.SetBlockStartAscent(dy + blockSize);
|
|
break;
|
|
case eAlign_center:
|
|
aDesiredSize.SetBlockStartAscent(dy + blockSize / 2);
|
|
break;
|
|
case eAlign_baseline:
|
|
if (rowFrame) {
|
|
// anchor the table on the baseline of the row of reference
|
|
nscoord rowAscent = ((nsTableRowFrame*)rowFrame)->GetMaxCellAscent();
|
|
if (rowAscent) { // the row has at least one cell with 'vertical-align: baseline'
|
|
aDesiredSize.SetBlockStartAscent(dy + rowAscent);
|
|
break;
|
|
}
|
|
}
|
|
// in other situations, fallback to center
|
|
aDesiredSize.SetBlockStartAscent(dy + blockSize / 2);
|
|
break;
|
|
case eAlign_axis:
|
|
default: {
|
|
// XXX should instead use style data from the row of reference here ?
|
|
RefPtr<nsFontMetrics> fm =
|
|
nsLayoutUtils::GetInflatedFontMetricsForFrame(this);
|
|
nscoord axisHeight;
|
|
GetAxisHeight(aReflowState.rendContext->GetDrawTarget(), fm, axisHeight);
|
|
if (rowFrame) {
|
|
// anchor the table on the axis of the row of reference
|
|
// XXX fallback to baseline because it is a hard problem
|
|
// XXX need to fetch the axis of the row; would need rowalign=axis to work better
|
|
nscoord rowAscent = ((nsTableRowFrame*)rowFrame)->GetMaxCellAscent();
|
|
if (rowAscent) { // the row has at least one cell with 'vertical-align: baseline'
|
|
aDesiredSize.SetBlockStartAscent(dy + rowAscent);
|
|
break;
|
|
}
|
|
}
|
|
// in other situations, fallback to using half of the height
|
|
aDesiredSize.SetBlockStartAscent(dy + blockSize / 2 + axisHeight);
|
|
}
|
|
}
|
|
|
|
mReference.x = 0;
|
|
mReference.y = aDesiredSize.BlockStartAscent();
|
|
|
|
// just make-up a bounding metrics
|
|
mBoundingMetrics = nsBoundingMetrics();
|
|
mBoundingMetrics.ascent = aDesiredSize.BlockStartAscent();
|
|
mBoundingMetrics.descent = aDesiredSize.Height() -
|
|
aDesiredSize.BlockStartAscent();
|
|
mBoundingMetrics.width = aDesiredSize.Width();
|
|
mBoundingMetrics.leftBearing = 0;
|
|
mBoundingMetrics.rightBearing = aDesiredSize.Width();
|
|
|
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
|
}
|
|
|
|
nsContainerFrame*
|
|
NS_NewMathMLmtableFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
{
|
|
return new (aPresShell) nsMathMLmtableFrame(aContext);
|
|
}
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtableFrame)
|
|
|
|
nsMathMLmtableFrame::~nsMathMLmtableFrame()
|
|
{
|
|
}
|
|
|
|
void
|
|
nsMathMLmtableFrame::SetInitialChildList(ChildListID aListID,
|
|
nsFrameList& aChildList)
|
|
{
|
|
nsTableFrame::SetInitialChildList(aListID, aChildList);
|
|
MapAllAttributesIntoCSS(this);
|
|
}
|
|
|
|
void
|
|
nsMathMLmtableFrame::RestyleTable()
|
|
{
|
|
// re-sync MathML specific style data that may have changed
|
|
MapAllAttributesIntoCSS(this);
|
|
|
|
// Explicitly request a re-resolve and reflow in our subtree to pick up any changes
|
|
PresContext()->RestyleManager()->
|
|
PostRestyleEvent(mContent->AsElement(), eRestyle_Subtree,
|
|
nsChangeHint_AllReflowHints);
|
|
}
|
|
|
|
nscoord
|
|
nsMathMLmtableFrame::GetColSpacing(int32_t aColIndex)
|
|
{
|
|
if (mUseCSSSpacing) {
|
|
return nsTableFrame::GetColSpacing(aColIndex);
|
|
}
|
|
if (!mColSpacing.Length()) {
|
|
NS_ERROR("mColSpacing should not be empty");
|
|
return 0;
|
|
}
|
|
if (aColIndex < 0 || aColIndex >= GetColCount()) {
|
|
NS_ASSERTION(aColIndex == -1 || aColIndex == GetColCount(),
|
|
"Desired column beyond bounds of table and border");
|
|
return mFrameSpacingX;
|
|
}
|
|
if ((uint32_t) aColIndex >= mColSpacing.Length()) {
|
|
return mColSpacing.LastElement();
|
|
}
|
|
return mColSpacing.ElementAt(aColIndex);
|
|
}
|
|
|
|
nscoord
|
|
nsMathMLmtableFrame::GetColSpacing(int32_t aStartColIndex,
|
|
int32_t aEndColIndex)
|
|
{
|
|
if (mUseCSSSpacing) {
|
|
return nsTableFrame::GetColSpacing(aStartColIndex, aEndColIndex);
|
|
}
|
|
if (aStartColIndex == aEndColIndex) {
|
|
return 0;
|
|
}
|
|
if (!mColSpacing.Length()) {
|
|
NS_ERROR("mColSpacing should not be empty");
|
|
return 0;
|
|
}
|
|
nscoord space = 0;
|
|
if (aStartColIndex < 0) {
|
|
NS_ASSERTION(aStartColIndex == -1,
|
|
"Desired column beyond bounds of table and border");
|
|
space += mFrameSpacingX;
|
|
aStartColIndex = 0;
|
|
}
|
|
if (aEndColIndex >= GetColCount()) {
|
|
NS_ASSERTION(aEndColIndex == GetColCount(),
|
|
"Desired column beyond bounds of table and border");
|
|
space += mFrameSpacingX;
|
|
aEndColIndex = GetColCount();
|
|
}
|
|
// Only iterate over column spacing when there is the potential to vary
|
|
int32_t min = std::min(aEndColIndex, (int32_t) mColSpacing.Length());
|
|
for (int32_t i = aStartColIndex; i < min; i++) {
|
|
space += mColSpacing.ElementAt(i);
|
|
}
|
|
// The remaining values are constant. Note that if there are more
|
|
// column spacings specified than there are columns, LastElement() will be
|
|
// multiplied by 0, so it is still safe to use.
|
|
space += (aEndColIndex - min) * mColSpacing.LastElement();
|
|
return space;
|
|
}
|
|
|
|
nscoord
|
|
nsMathMLmtableFrame::GetRowSpacing(int32_t aRowIndex)
|
|
{
|
|
if (mUseCSSSpacing) {
|
|
return nsTableFrame::GetRowSpacing(aRowIndex);
|
|
}
|
|
if (!mRowSpacing.Length()) {
|
|
NS_ERROR("mRowSpacing should not be empty");
|
|
return 0;
|
|
}
|
|
if (aRowIndex < 0 || aRowIndex >= GetRowCount()) {
|
|
NS_ASSERTION(aRowIndex == -1 || aRowIndex == GetRowCount(),
|
|
"Desired row beyond bounds of table and border");
|
|
return mFrameSpacingY;
|
|
}
|
|
if ((uint32_t) aRowIndex >= mRowSpacing.Length()) {
|
|
return mRowSpacing.LastElement();
|
|
}
|
|
return mRowSpacing.ElementAt(aRowIndex);
|
|
}
|
|
|
|
nscoord
|
|
nsMathMLmtableFrame::GetRowSpacing(int32_t aStartRowIndex,
|
|
int32_t aEndRowIndex)
|
|
{
|
|
if (mUseCSSSpacing) {
|
|
return nsTableFrame::GetRowSpacing(aStartRowIndex, aEndRowIndex);
|
|
}
|
|
if (aStartRowIndex == aEndRowIndex) {
|
|
return 0;
|
|
}
|
|
if (!mRowSpacing.Length()) {
|
|
NS_ERROR("mRowSpacing should not be empty");
|
|
return 0;
|
|
}
|
|
nscoord space = 0;
|
|
if (aStartRowIndex < 0) {
|
|
NS_ASSERTION(aStartRowIndex == -1,
|
|
"Desired row beyond bounds of table and border");
|
|
space += mFrameSpacingY;
|
|
aStartRowIndex = 0;
|
|
}
|
|
if (aEndRowIndex >= GetRowCount()) {
|
|
NS_ASSERTION(aEndRowIndex == GetRowCount(),
|
|
"Desired row beyond bounds of table and border");
|
|
space += mFrameSpacingY;
|
|
aEndRowIndex = GetRowCount();
|
|
}
|
|
// Only iterate over row spacing when there is the potential to vary
|
|
int32_t min = std::min(aEndRowIndex, (int32_t) mRowSpacing.Length());
|
|
for (int32_t i = aStartRowIndex; i < min; i++) {
|
|
space += mRowSpacing.ElementAt(i);
|
|
}
|
|
// The remaining values are constant. Note that if there are more
|
|
// row spacings specified than there are row, LastElement() will be
|
|
// multiplied by 0, so it is still safe to use.
|
|
space += (aEndRowIndex - min) * mRowSpacing.LastElement();
|
|
return space;
|
|
}
|
|
|
|
void
|
|
nsMathMLmtableFrame::SetUseCSSSpacing()
|
|
{
|
|
mUseCSSSpacing =
|
|
!(mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::rowspacing_) ||
|
|
mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::columnspacing_) ||
|
|
mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::framespacing_));
|
|
}
|
|
|
|
NS_QUERYFRAME_HEAD(nsMathMLmtableFrame)
|
|
NS_QUERYFRAME_ENTRY(nsMathMLmtableFrame)
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsTableFrame)
|
|
|
|
// --------
|
|
// implementation of nsMathMLmtrFrame
|
|
|
|
nsContainerFrame*
|
|
NS_NewMathMLmtrFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
{
|
|
return new (aPresShell) nsMathMLmtrFrame(aContext);
|
|
}
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtrFrame)
|
|
|
|
nsMathMLmtrFrame::~nsMathMLmtrFrame()
|
|
{
|
|
}
|
|
|
|
nsresult
|
|
nsMathMLmtrFrame::AttributeChanged(int32_t aNameSpaceID,
|
|
nsIAtom* aAttribute,
|
|
int32_t aModType)
|
|
{
|
|
// Attributes specific to <mtr>:
|
|
// groupalign : Not yet supported.
|
|
// rowalign : Here
|
|
// columnalign : Here
|
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
if (aAttribute != nsGkAtoms::rowalign_ &&
|
|
aAttribute != nsGkAtoms::columnalign_) {
|
|
return NS_OK;
|
|
}
|
|
|
|
presContext->PropertyTable()->Delete(this, AttributeToProperty(aAttribute));
|
|
|
|
bool allowMultiValues = (aAttribute == nsGkAtoms::columnalign_);
|
|
|
|
// Reparse the new attribute.
|
|
ParseFrameAttribute(this, aAttribute, allowMultiValues);
|
|
|
|
// Explicitly request a reflow in our subtree to pick up any changes
|
|
presContext->PresShell()->
|
|
FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
// --------
|
|
// implementation of nsMathMLmtdFrame
|
|
|
|
nsContainerFrame*
|
|
NS_NewMathMLmtdFrame(nsIPresShell* aPresShell, nsStyleContext* aContext,
|
|
nsTableFrame* aTableFrame)
|
|
{
|
|
return new (aPresShell) nsMathMLmtdFrame(aContext, aTableFrame);
|
|
}
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtdFrame)
|
|
|
|
nsMathMLmtdFrame::~nsMathMLmtdFrame()
|
|
{
|
|
}
|
|
|
|
void
|
|
nsMathMLmtdFrame::Init(nsIContent* aContent,
|
|
nsContainerFrame* aParent,
|
|
nsIFrame* aPrevInFlow)
|
|
{
|
|
nsTableCellFrame::Init(aContent, aParent, aPrevInFlow);
|
|
|
|
// We want to use the ancestor <math> element's font inflation to avoid
|
|
// individual cells having their own varying font inflation.
|
|
RemoveStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT);
|
|
}
|
|
|
|
int32_t
|
|
nsMathMLmtdFrame::GetRowSpan()
|
|
{
|
|
int32_t rowspan = 1;
|
|
|
|
// Don't look at the content's rowspan if we're not an mtd or a pseudo cell.
|
|
if (mContent->IsMathMLElement(nsGkAtoms::mtd_) &&
|
|
!StyleContext()->GetPseudo()) {
|
|
nsAutoString value;
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::rowspan, value);
|
|
if (!value.IsEmpty()) {
|
|
nsresult error;
|
|
rowspan = value.ToInteger(&error);
|
|
if (NS_FAILED(error) || rowspan < 0)
|
|
rowspan = 1;
|
|
rowspan = std::min(rowspan, MAX_ROWSPAN);
|
|
}
|
|
}
|
|
return rowspan;
|
|
}
|
|
|
|
int32_t
|
|
nsMathMLmtdFrame::GetColSpan()
|
|
{
|
|
int32_t colspan = 1;
|
|
|
|
// Don't look at the content's colspan if we're not an mtd or a pseudo cell.
|
|
if (mContent->IsMathMLElement(nsGkAtoms::mtd_) &&
|
|
!StyleContext()->GetPseudo()) {
|
|
nsAutoString value;
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::columnspan_, value);
|
|
if (!value.IsEmpty()) {
|
|
nsresult error;
|
|
colspan = value.ToInteger(&error);
|
|
if (NS_FAILED(error) || colspan <= 0 || colspan > MAX_COLSPAN)
|
|
colspan = 1;
|
|
}
|
|
}
|
|
return colspan;
|
|
}
|
|
|
|
nsresult
|
|
nsMathMLmtdFrame::AttributeChanged(int32_t aNameSpaceID,
|
|
nsIAtom* aAttribute,
|
|
int32_t aModType)
|
|
{
|
|
// Attributes specific to <mtd>:
|
|
// groupalign : Not yet supported
|
|
// rowalign : here
|
|
// columnalign : here
|
|
// rowspan : here
|
|
// columnspan : here
|
|
|
|
if (aAttribute == nsGkAtoms::rowalign_ ||
|
|
aAttribute == nsGkAtoms::columnalign_) {
|
|
|
|
nsPresContext* presContext = PresContext();
|
|
presContext->PropertyTable()->Delete(this, AttributeToProperty(aAttribute));
|
|
|
|
// Reparse the attribute.
|
|
ParseFrameAttribute(this, aAttribute, false);
|
|
return NS_OK;
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::rowspan ||
|
|
aAttribute == nsGkAtoms::columnspan_) {
|
|
// use the naming expected by the base class
|
|
if (aAttribute == nsGkAtoms::columnspan_)
|
|
aAttribute = nsGkAtoms::colspan;
|
|
return nsTableCellFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
uint8_t
|
|
nsMathMLmtdFrame::GetVerticalAlign() const
|
|
{
|
|
// Set the default alignment in case no alignment was specified
|
|
uint8_t alignment = nsTableCellFrame::GetVerticalAlign();
|
|
|
|
nsTArray<int8_t>* alignmentList = FindCellProperty(this, RowAlignProperty());
|
|
|
|
if (alignmentList) {
|
|
int32_t rowIndex;
|
|
GetRowIndex(rowIndex);
|
|
|
|
// If the row number is greater than the number of provided rowalign values,
|
|
// we simply repeat the last value.
|
|
if (rowIndex < (int32_t)alignmentList->Length())
|
|
alignment = alignmentList->ElementAt(rowIndex);
|
|
else
|
|
alignment = alignmentList->ElementAt(alignmentList->Length() - 1);
|
|
}
|
|
|
|
return alignment;
|
|
}
|
|
|
|
nsresult
|
|
nsMathMLmtdFrame::ProcessBorders(nsTableFrame* aFrame,
|
|
nsDisplayListBuilder* aBuilder,
|
|
const nsDisplayListSet& aLists)
|
|
{
|
|
aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
|
nsDisplaymtdBorder(aBuilder, this));
|
|
return NS_OK;
|
|
}
|
|
|
|
LogicalMargin
|
|
nsMathMLmtdFrame::GetBorderWidth(WritingMode aWM) const
|
|
{
|
|
nsStyleBorder styleBorder = *StyleBorder();
|
|
ApplyBorderToStyle(this, styleBorder);
|
|
return LogicalMargin(aWM, styleBorder.GetComputedBorder());
|
|
}
|
|
|
|
nsMargin
|
|
nsMathMLmtdFrame::GetBorderOverflow()
|
|
{
|
|
nsStyleBorder styleBorder = *StyleBorder();
|
|
ApplyBorderToStyle(this, styleBorder);
|
|
nsMargin overflow = ComputeBorderOverflow(this, styleBorder);
|
|
return overflow;
|
|
}
|
|
|
|
// --------
|
|
// implementation of nsMathMLmtdInnerFrame
|
|
|
|
NS_QUERYFRAME_HEAD(nsMathMLmtdInnerFrame)
|
|
NS_QUERYFRAME_ENTRY(nsIMathMLFrame)
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
|
|
|
nsContainerFrame*
|
|
NS_NewMathMLmtdInnerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
{
|
|
return new (aPresShell) nsMathMLmtdInnerFrame(aContext);
|
|
}
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtdInnerFrame)
|
|
|
|
nsMathMLmtdInnerFrame::nsMathMLmtdInnerFrame(nsStyleContext* aContext)
|
|
: nsBlockFrame(aContext)
|
|
{
|
|
// Make a copy of the parent nsStyleText for later modificaiton.
|
|
mUniqueStyleText = new (PresContext()) nsStyleText(*StyleText());
|
|
}
|
|
|
|
nsMathMLmtdInnerFrame::~nsMathMLmtdInnerFrame()
|
|
{
|
|
mUniqueStyleText->Destroy(PresContext());
|
|
}
|
|
|
|
void
|
|
nsMathMLmtdInnerFrame::Reflow(nsPresContext* aPresContext,
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
const nsHTMLReflowState& aReflowState,
|
|
nsReflowStatus& aStatus)
|
|
{
|
|
// Let the base class do the reflow
|
|
nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
// more about <maligngroup/> and <malignmark/> later
|
|
// ...
|
|
}
|
|
|
|
const
|
|
nsStyleText* nsMathMLmtdInnerFrame::StyleTextForLineLayout()
|
|
{
|
|
// Set the default alignment in case nothing was specified
|
|
uint8_t alignment = StyleText()->mTextAlign;
|
|
|
|
nsTArray<int8_t>* alignmentList =
|
|
FindCellProperty(this, ColumnAlignProperty());
|
|
|
|
if (alignmentList) {
|
|
nsMathMLmtdFrame* cellFrame = (nsMathMLmtdFrame*)GetParent();
|
|
int32_t columnIndex;
|
|
cellFrame->GetColIndex(columnIndex);
|
|
|
|
// If the column number is greater than the number of provided columalign
|
|
// values, we simply repeat the last value.
|
|
if (columnIndex < (int32_t)alignmentList->Length())
|
|
alignment = alignmentList->ElementAt(columnIndex);
|
|
else
|
|
alignment = alignmentList->ElementAt(alignmentList->Length() - 1);
|
|
}
|
|
|
|
mUniqueStyleText->mTextAlign = alignment;
|
|
return mUniqueStyleText;
|
|
}
|
|
|
|
/* virtual */ void
|
|
nsMathMLmtdInnerFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
|
{
|
|
nsBlockFrame::DidSetStyleContext(aOldStyleContext);
|
|
mUniqueStyleText->Destroy(PresContext());
|
|
mUniqueStyleText = new (PresContext()) nsStyleText(*StyleText());
|
|
}
|