2004-02-24 00:29:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2000-03-28 14:15:19 +04:00
|
|
|
|
2013-08-31 01:37:12 +04:00
|
|
|
#include "nsMathMLmtableFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
2000-03-28 14:15:19 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsRenderingContext.h"
|
2013-12-13 21:42:43 +04:00
|
|
|
#include "nsCSSRendering.h"
|
2014-06-18 14:57:00 +04:00
|
|
|
#include "nsMathMLElement.h"
|
2000-03-28 14:15:19 +04:00
|
|
|
|
2009-02-03 17:42:18 +03:00
|
|
|
#include "nsTArray.h"
|
2002-01-25 10:03:43 +03:00
|
|
|
#include "nsTableFrame.h"
|
2008-07-16 19:02:18 +04:00
|
|
|
#include "celldata.h"
|
2000-05-16 17:18:42 +04:00
|
|
|
|
2013-08-20 02:55:18 +04:00
|
|
|
#include "RestyleManager.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2000-03-28 14:15:19 +04:00
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
#include "nsIScriptError.h"
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
|
2010-03-29 05:46:55 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2000-03-28 14:15:19 +04:00
|
|
|
//
|
|
|
|
// <mtable> -- table or matrix - implementation
|
|
|
|
//
|
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
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)
|
2000-05-16 17:18:42 +04:00
|
|
|
{
|
2013-12-13 21:42:43 +04:00
|
|
|
nsTArray<int8_t>* styleArray = nullptr;
|
2000-05-16 17:18:42 +04:00
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* start = aString.BeginReading();
|
|
|
|
const char16_t* end = aString.EndReading();
|
2000-05-16 17:18:42 +04:00
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
int32_t startIndex = 0;
|
|
|
|
int32_t count = 0;
|
2000-05-16 17:18:42 +04:00
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
while (start < end) {
|
|
|
|
// Skip leading spaces.
|
|
|
|
while ((start < end) && nsCRT::IsAsciiSpace(*start)) {
|
2000-05-16 17:18:42 +04:00
|
|
|
start++;
|
2013-12-13 21:42:43 +04:00
|
|
|
startIndex++;
|
2000-05-16 17:18:42 +04:00
|
|
|
}
|
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
// Look for the end of the string, or another space.
|
|
|
|
while ((start < end) && !nsCRT::IsAsciiSpace(*start)) {
|
|
|
|
start++;
|
|
|
|
count++;
|
2000-05-16 17:18:42 +04:00
|
|
|
}
|
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
// 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);
|
2000-05-16 17:18:42 +04:00
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
startIndex += count;
|
|
|
|
count = 0;
|
|
|
|
}
|
2000-05-16 17:18:42 +04:00
|
|
|
}
|
2013-12-13 21:42:43 +04:00
|
|
|
return styleArray;
|
2000-05-16 17:18:42 +04:00
|
|
|
}
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
static nsresult ReportParseError(nsIFrame* aFrame, const char16_t* aAttribute,
|
|
|
|
const char16_t* aValue)
|
2000-05-16 17:18:42 +04:00
|
|
|
{
|
2013-12-13 21:42:43 +04:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2000-05-16 17:18:42 +04:00
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* params[] =
|
2013-12-13 21:42:43 +04:00
|
|
|
{ aValue, aAttribute, content->Tag()->GetUTF16String() };
|
|
|
|
|
|
|
|
return nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
|
|
|
|
NS_LITERAL_CSTRING("MathML"),
|
|
|
|
content->OwnerDoc(),
|
|
|
|
nsContentUtils::eMATHML_PROPERTIES,
|
|
|
|
"AttributeParsingError", params, 3);
|
|
|
|
}
|
2000-05-16 17:18:42 +04:00
|
|
|
|
|
|
|
// Each rowalign='top bottom' or columnalign='left right center' (from
|
2013-12-13 21:42:43 +04:00
|
|
|
// <mtable> or <mtr>) is split once into an nsTArray<int8_t> which is
|
2006-09-07 07:45:45 +04:00
|
|
|
// stored in the property table. Row/Cell frames query the property table
|
2000-05-16 17:18:42 +04:00
|
|
|
// to see what values apply to them.
|
|
|
|
|
|
|
|
static void
|
2013-12-13 21:42:43 +04:00
|
|
|
DestroyStylePropertyList(void* aPropertyValue)
|
2000-05-16 17:18:42 +04:00
|
|
|
{
|
2013-12-13 21:42:43 +04:00
|
|
|
delete static_cast<nsTArray<int8_t>*>(aPropertyValue);
|
2000-05-16 17:18:42 +04:00
|
|
|
}
|
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(RowAlignProperty, DestroyStylePropertyList)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(RowLinesProperty, DestroyStylePropertyList)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(ColumnAlignProperty, DestroyStylePropertyList)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(ColumnLinesProperty, DestroyStylePropertyList)
|
2010-03-29 05:46:55 +04:00
|
|
|
|
|
|
|
static const FramePropertyDescriptor*
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
/* 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* aFrameProperty)
|
|
|
|
{
|
|
|
|
const nsIFrame* currentFrame = aCellFrame;
|
|
|
|
nsTArray<int8_t>* propertyData = nullptr;
|
|
|
|
|
|
|
|
while (currentFrame) {
|
|
|
|
FrameProperties props = currentFrame->Properties();
|
|
|
|
propertyData = static_cast<nsTArray<int8_t>*>(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
|
2000-05-16 17:18:42 +04:00
|
|
|
}
|
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
return propertyData;
|
2008-01-09 05:14:35 +03:00
|
|
|
}
|
|
|
|
|
2014-03-03 19:37:08 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-18 14:57:00 +04:00
|
|
|
static nsMargin
|
|
|
|
ComputeBorderOverflow(nsMathMLmtdFrame* aFrame, nsStyleBorder aStyleBorder)
|
|
|
|
{
|
|
|
|
nsMargin overflow;
|
|
|
|
int32_t rowIndex;
|
|
|
|
int32_t columnIndex;
|
|
|
|
nsMathMLmtableFrame* mathMLmtableFrame =
|
|
|
|
static_cast<nsMathMLmtableFrame*>(nsTableFrame::GetTableFrame(aFrame));
|
|
|
|
aFrame->GetCellIndexes(rowIndex, columnIndex);
|
|
|
|
if (!columnIndex) {
|
|
|
|
overflow.left = mathMLmtableFrame->GetCellSpacingX(-1);
|
|
|
|
overflow.right = mathMLmtableFrame->GetCellSpacingX(0) / 2;
|
|
|
|
} else if (columnIndex == mathMLmtableFrame->GetColCount() - 1) {
|
|
|
|
overflow.left = mathMLmtableFrame->GetCellSpacingX(columnIndex - 1) / 2;
|
|
|
|
overflow.right = mathMLmtableFrame->GetCellSpacingX(columnIndex + 1);
|
|
|
|
} else {
|
|
|
|
overflow.left = mathMLmtableFrame->GetCellSpacingX(columnIndex - 1) / 2;
|
|
|
|
overflow.right = mathMLmtableFrame->GetCellSpacingX(columnIndex) / 2;
|
|
|
|
}
|
|
|
|
if (!rowIndex) {
|
|
|
|
overflow.top = mathMLmtableFrame->GetCellSpacingY(-1);
|
|
|
|
overflow.bottom = mathMLmtableFrame->GetCellSpacingY(0) / 2;
|
|
|
|
} else if (rowIndex == mathMLmtableFrame->GetRowCount() - 1) {
|
|
|
|
overflow.top = mathMLmtableFrame->GetCellSpacingY(rowIndex - 1) / 2;
|
|
|
|
overflow.bottom = mathMLmtableFrame->GetCellSpacingY(rowIndex + 1);
|
|
|
|
} else {
|
|
|
|
overflow.top = mathMLmtableFrame->GetCellSpacingY(rowIndex - 1) / 2;
|
|
|
|
overflow.bottom = mathMLmtableFrame->GetCellSpacingY(rowIndex) / 2;
|
|
|
|
}
|
|
|
|
return overflow;
|
|
|
|
}
|
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
{
|
2002-01-25 10:03:43 +03:00
|
|
|
}
|
2006-09-07 07:45:45 +04:00
|
|
|
|
2014-03-03 19:37:08 +04:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE
|
2013-12-13 21:42:43 +04:00
|
|
|
{
|
|
|
|
nsStyleBorder styleBorder = *mFrame->StyleBorder();
|
2014-06-18 14:57:00 +04:00
|
|
|
nsMathMLmtdFrame* frame = static_cast<nsMathMLmtdFrame*>(mFrame);
|
|
|
|
ApplyBorderToStyle(frame, styleBorder);
|
|
|
|
nsRect bounds = CalculateBounds(styleBorder);
|
|
|
|
nsMargin overflow = ComputeBorderOverflow(frame, styleBorder);
|
|
|
|
bounds.Inflate(overflow);
|
|
|
|
return bounds;
|
2014-03-03 19:37:08 +04:00
|
|
|
}
|
2000-05-16 17:18:42 +04:00
|
|
|
|
2014-03-03 19:37:08 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
nsStyleBorder styleBorder = *mFrame->StyleBorder();
|
2014-06-18 14:57:00 +04:00
|
|
|
nsMathMLmtdFrame* frame = static_cast<nsMathMLmtdFrame*>(mFrame);
|
|
|
|
ApplyBorderToStyle(frame, styleBorder);
|
|
|
|
|
|
|
|
nsRect bounds = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
|
|
|
nsMargin overflow = ComputeBorderOverflow(frame, styleBorder);
|
|
|
|
bounds.Inflate(overflow);
|
2013-12-13 21:42:43 +04:00
|
|
|
|
|
|
|
nsCSSRendering::PaintBorderWithStyleBorder(mFrame->PresContext(), *aCtx,
|
|
|
|
mFrame, mVisibleRect,
|
2014-06-18 14:57:00 +04:00
|
|
|
bounds,
|
2013-12-13 21:42:43 +04:00
|
|
|
styleBorder,
|
|
|
|
mFrame->StyleContext(),
|
|
|
|
mFrame->GetSkipSides());
|
2002-01-25 10:03:43 +03:00
|
|
|
}
|
2013-12-13 21:42:43 +04:00
|
|
|
};
|
2006-09-07 07:45:45 +04:00
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
#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());
|
2000-05-16 17:18:42 +04:00
|
|
|
}
|
|
|
|
}
|
2006-09-07 07:45:45 +04:00
|
|
|
}
|
2000-05-16 17:18:42 +04:00
|
|
|
|
2014-06-18 14:57:00 +04:00
|
|
|
// 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)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
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
|
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm));
|
|
|
|
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);
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2006-09-07 07:45:45 +04:00
|
|
|
// 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
|
2014-06-18 14:57:00 +04:00
|
|
|
MapAllAttributesIntoCSS(nsMathMLmtableFrame* aTableFrame)
|
2006-09-07 07:45:45 +04:00
|
|
|
{
|
2013-12-13 21:42:43 +04:00
|
|
|
// 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);
|
|
|
|
|
2014-06-18 14:57:00 +04:00
|
|
|
// Map mtable rowspacing, columnspacing & framespacing
|
|
|
|
ParseSpacingAttributes(aTableFrame);
|
|
|
|
|
2006-09-19 08:43:14 +04:00
|
|
|
// mtable is simple and only has one (pseudo) row-group
|
2011-08-25 00:54:30 +04:00
|
|
|
nsIFrame* rgFrame = aTableFrame->GetFirstPrincipalChild();
|
2006-10-10 11:38:50 +04:00
|
|
|
if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame)
|
|
|
|
return;
|
2006-09-19 08:43:14 +04:00
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
nsIFrame* rowFrame = rgFrame->GetFirstPrincipalChild();
|
2006-09-19 08:43:14 +04:00
|
|
|
for ( ; rowFrame; rowFrame = rowFrame->GetNextSibling()) {
|
|
|
|
DEBUG_VERIFY_THAT_FRAME_IS(rowFrame, TABLE_ROW);
|
|
|
|
if (rowFrame->GetType() == nsGkAtoms::tableRowFrame) {
|
2013-12-13 21:42:43 +04:00
|
|
|
// Map row rowalign.
|
|
|
|
ParseFrameAttribute(rowFrame, nsGkAtoms::rowalign_, false);
|
|
|
|
// Map row columnalign.
|
|
|
|
ParseFrameAttribute(rowFrame, nsGkAtoms::columnalign_, true);
|
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
nsIFrame* cellFrame = rowFrame->GetFirstPrincipalChild();
|
2006-09-19 08:43:14 +04:00
|
|
|
for ( ; cellFrame; cellFrame = cellFrame->GetNextSibling()) {
|
|
|
|
DEBUG_VERIFY_THAT_FRAME_IS(cellFrame, TABLE_CELL);
|
|
|
|
if (IS_TABLE_CELL(cellFrame->GetType())) {
|
2013-12-13 21:42:43 +04:00
|
|
|
// Map cell rowalign.
|
|
|
|
ParseFrameAttribute(cellFrame, nsGkAtoms::rowalign_, false);
|
|
|
|
// Map row columnalign.
|
|
|
|
ParseFrameAttribute(cellFrame, nsGkAtoms::columnalign_, false);
|
2006-09-07 07:45:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-05-16 17:18:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-25 10:03:43 +03:00
|
|
|
// the align attribute of mtable can have a row number which indicates
|
2012-07-27 05:17:23 +04:00
|
|
|
// 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
|
2002-01-25 10:03:43 +03:00
|
|
|
|
|
|
|
enum eAlign {
|
|
|
|
eAlign_top,
|
|
|
|
eAlign_bottom,
|
|
|
|
eAlign_center,
|
|
|
|
eAlign_baseline,
|
|
|
|
eAlign_axis
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2012-08-22 19:56:38 +04:00
|
|
|
ParseAlignAttribute(nsString& aValue, eAlign& aAlign, int32_t& aRowIndex)
|
2002-01-25 10:03:43 +03:00
|
|
|
{
|
|
|
|
// by default, the table is centered about the axis
|
|
|
|
aRowIndex = 0;
|
|
|
|
aAlign = eAlign_axis;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t len = 0;
|
2012-07-27 05:17:23 +04:00
|
|
|
|
|
|
|
// we only have to remove the leading spaces because
|
|
|
|
// ToInteger ignores the whitespaces around the number
|
|
|
|
aValue.CompressWhitespace(true, false);
|
|
|
|
|
2002-01-25 10:03:43 +03:00
|
|
|
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) {
|
2012-07-27 17:59:29 +04:00
|
|
|
nsresult error;
|
2002-01-25 10:03:43 +03:00
|
|
|
aValue.Cut(0, len); // aValue is not a const here
|
|
|
|
aRowIndex = aValue.ToInteger(&error);
|
2012-08-13 17:49:48 +04:00
|
|
|
if (NS_FAILED(error))
|
2002-01-25 10:03:43 +03:00
|
|
|
aRowIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-10 11:38:50 +04:00
|
|
|
#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->Tag() == nsGkAtoms::math || c->Tag() == nsGkAtoms::body)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!f) f = atLeast;
|
2009-08-21 01:52:48 +04:00
|
|
|
f->List(stdout, 0);
|
2006-10-10 11:38:50 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-03-28 14:15:19 +04:00
|
|
|
// --------
|
|
|
|
// implementation of nsMathMLmtableOuterFrame
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsMathMLmtableOuterFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIMathMLFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsTableOuterFrame)
|
2001-02-23 19:10:51 +03:00
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
nsContainerFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewMathMLmtableOuterFrame (nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2000-03-28 14:15:19 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsMathMLmtableOuterFrame(aContext);
|
2000-03-28 14:15:19 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtableOuterFrame)
|
2010-03-29 05:46:55 +04:00
|
|
|
|
2000-03-28 14:15:19 +04:00
|
|
|
nsMathMLmtableOuterFrame::~nsMathMLmtableOuterFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsMathMLmtableOuterFrame::AttributeChanged(int32_t aNameSpaceID,
|
2006-09-19 08:43:14 +04:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
2002-02-01 18:10:50 +03:00
|
|
|
{
|
2006-09-19 08:43:14 +04:00
|
|
|
// Attributes specific to <mtable>:
|
|
|
|
// frame : in mathml.css
|
2014-06-18 14:57:00 +04:00
|
|
|
// framespacing : here
|
2006-09-19 08:43:14 +04:00
|
|
|
// groupalign : not yet supported
|
|
|
|
// equalrows : not yet supported
|
|
|
|
// equalcolumns : not yet supported
|
2014-01-14 18:39:50 +04:00
|
|
|
// displaystyle : here and in mathml.css
|
2006-09-19 08:43:14 +04:00
|
|
|
// align : in reflow
|
|
|
|
// rowalign : here
|
|
|
|
// rowlines : here
|
2014-06-18 14:57:00 +04:00
|
|
|
// rowspacing : here
|
2006-09-19 08:43:14 +04:00
|
|
|
// columnalign : here
|
|
|
|
// columnlines : here
|
2014-06-18 14:57:00 +04:00
|
|
|
// columnspacing : here
|
2006-09-19 08:43:14 +04:00
|
|
|
|
|
|
|
// mtable is simple and only has one (pseudo) row-group inside our inner-table
|
|
|
|
nsIFrame* tableFrame = mFrames.FirstChild();
|
2011-09-12 20:08:07 +04:00
|
|
|
NS_ASSERTION(tableFrame && tableFrame->GetType() == nsGkAtoms::tableFrame,
|
|
|
|
"should always have an inner table frame");
|
2011-08-25 00:54:30 +04:00
|
|
|
nsIFrame* rgFrame = tableFrame->GetFirstPrincipalChild();
|
2006-10-10 11:38:50 +04:00
|
|
|
if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame)
|
|
|
|
return NS_OK;
|
2006-09-19 08:43:14 +04:00
|
|
|
|
|
|
|
// align - just need to issue a dirty (resize) reflow command
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 23:16:51 +04:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eResize, NS_FRAME_IS_DIRTY);
|
2006-09-19 08:43:14 +04:00
|
|
|
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
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::displaystyle_) {
|
2014-05-25 02:20:41 +04:00
|
|
|
nsMathMLContainerFrame::RebuildAutomaticDataForChildren(GetParent());
|
2007-05-07 02:50:21 +04:00
|
|
|
// Need to reflow the parent, not us, because this can actually
|
|
|
|
// affect siblings.
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->
|
2014-05-25 02:20:41 +04:00
|
|
|
FrameNeedsReflow(GetParent(), nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
|
2006-09-19 08:43:14 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ...and the other attributes affect rows or columns in one way or another
|
2013-12-13 21:42:43 +04:00
|
|
|
|
2014-06-18 14:57:00 +04:00
|
|
|
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.
|
2006-09-19 08:43:14 +04:00
|
|
|
return NS_OK;
|
2013-12-13 21:42:43 +04:00
|
|
|
}
|
2006-09-19 08:43:14 +04:00
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
// Explicitly request a reflow in our subtree to pick up any changes
|
|
|
|
presContext->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
|
2006-09-19 08:43:14 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
2000-03-28 14:15:19 +04:00
|
|
|
}
|
|
|
|
|
2002-01-25 10:03:43 +03:00
|
|
|
nsIFrame*
|
2004-08-01 03:15:21 +04:00
|
|
|
nsMathMLmtableOuterFrame::GetRowFrameAt(nsPresContext* aPresContext,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aRowIndex)
|
2002-01-25 10:03:43 +03:00
|
|
|
{
|
2012-08-08 17:05:17 +04:00
|
|
|
int32_t rowCount = GetRowCount();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
// Negative indices mean to find upwards from the end.
|
2002-01-25 10:03:43 +03:00
|
|
|
if (aRowIndex < 0) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
aRowIndex = rowCount + aRowIndex;
|
2011-08-07 09:29:00 +04:00
|
|
|
} else {
|
|
|
|
// aRowIndex is 1-based, so convert it to a 0-based index
|
|
|
|
--aRowIndex;
|
2002-01-25 10:03:43 +03:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2002-01-25 10:03:43 +03:00
|
|
|
// if our inner table says that the index is valid, find the row now
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (0 <= aRowIndex && aRowIndex <= rowCount) {
|
2006-10-10 11:38:50 +04:00
|
|
|
nsIFrame* tableFrame = mFrames.FirstChild();
|
2011-09-12 20:08:07 +04:00
|
|
|
NS_ASSERTION(tableFrame && tableFrame->GetType() == nsGkAtoms::tableFrame,
|
|
|
|
"should always have an inner table frame");
|
2011-08-25 00:54:30 +04:00
|
|
|
nsIFrame* rgFrame = tableFrame->GetFirstPrincipalChild();
|
2006-10-10 11:38:50 +04:00
|
|
|
if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsTableIterator rowIter(*rgFrame);
|
2006-10-10 11:38:50 +04:00
|
|
|
nsIFrame* rowFrame = rowIter.First();
|
|
|
|
for ( ; rowFrame; rowFrame = rowIter.Next()) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (aRowIndex == 0) {
|
2006-10-10 11:38:50 +04:00
|
|
|
DEBUG_VERIFY_THAT_FRAME_IS(rowFrame, TABLE_ROW);
|
|
|
|
if (rowFrame->GetType() != nsGkAtoms::tableRowFrame)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-10-10 11:38:50 +04:00
|
|
|
|
|
|
|
return rowFrame;
|
2002-01-25 10:03:43 +03:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
--aRowIndex;
|
2002-01-25 10:03:43 +03:00
|
|
|
}
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2002-01-25 10:03:43 +03:00
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsMathMLmtableOuterFrame::Reflow(nsPresContext* aPresContext,
|
2000-03-28 14:15:19 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2002-01-25 10:03:43 +03:00
|
|
|
nsAutoString value;
|
|
|
|
// we want to return a table that is anchored according to the align attribute
|
2001-05-19 14:00:01 +04:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
nsTableOuterFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2013-12-27 21:59:52 +04:00
|
|
|
NS_ASSERTION(aDesiredSize.Height() >= 0, "illegal height for mtable");
|
|
|
|
NS_ASSERTION(aDesiredSize.Width() >= 0, "illegal width for mtable");
|
2000-03-28 14:15:19 +04:00
|
|
|
|
2000-05-08 11:23:22 +04:00
|
|
|
// see if the user has set the align attribute on the <mtable>
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowIndex = 0;
|
2002-01-25 10:03:43 +03:00
|
|
|
eAlign tableAlign = eAlign_axis;
|
2014-01-15 19:07:06 +04:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::align, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2002-01-25 10:03:43 +03:00
|
|
|
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;
|
2014-06-11 13:45:31 +04:00
|
|
|
WritingMode wm = aDesiredSize.GetWritingMode();
|
|
|
|
nscoord blockSize = aDesiredSize.BSize(wm);
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIFrame* rowFrame = nullptr;
|
2002-01-25 10:03:43 +03:00
|
|
|
if (rowIndex) {
|
|
|
|
rowFrame = GetRowFrameAt(aPresContext, rowIndex);
|
|
|
|
if (rowFrame) {
|
2014-06-11 13:45:31 +04:00
|
|
|
// translate the coordinates to be relative to us and in our writing mode
|
2002-01-25 10:03:43 +03:00
|
|
|
nsIFrame* frame = rowFrame;
|
2014-06-11 13:45:31 +04:00
|
|
|
LogicalRect frameRect(wm, frame->GetRect(), aReflowState.ComputedWidth());
|
|
|
|
blockSize = frameRect.BSize(wm);
|
2002-01-25 10:03:43 +03:00
|
|
|
do {
|
2014-06-11 13:45:31 +04:00
|
|
|
dy += frameRect.BStart(wm);
|
2003-07-08 15:00:00 +04:00
|
|
|
frame = frame->GetParent();
|
2002-01-25 10:03:43 +03:00
|
|
|
} while (frame != this);
|
2000-05-08 11:23:22 +04:00
|
|
|
}
|
2002-01-25 10:03:43 +03:00
|
|
|
}
|
|
|
|
switch (tableAlign) {
|
|
|
|
case eAlign_top:
|
2014-06-11 13:45:31 +04:00
|
|
|
aDesiredSize.SetBlockStartAscent(dy);
|
2002-01-25 10:03:43 +03:00
|
|
|
break;
|
|
|
|
case eAlign_bottom:
|
2014-06-11 13:45:31 +04:00
|
|
|
aDesiredSize.SetBlockStartAscent(dy + blockSize);
|
2002-01-25 10:03:43 +03:00
|
|
|
break;
|
|
|
|
case eAlign_center:
|
2014-06-11 13:45:31 +04:00
|
|
|
aDesiredSize.SetBlockStartAscent(dy + blockSize / 2);
|
2002-01-25 10:03:43 +03:00
|
|
|
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'
|
2014-06-11 13:45:31 +04:00
|
|
|
aDesiredSize.SetBlockStartAscent(dy + rowAscent);
|
2002-01-25 10:03:43 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// in other situations, fallback to center
|
2014-06-11 13:45:31 +04:00
|
|
|
aDesiredSize.SetBlockStartAscent(dy + blockSize / 2);
|
2002-01-25 10:03:43 +03:00
|
|
|
break;
|
|
|
|
case eAlign_axis:
|
|
|
|
default: {
|
|
|
|
// XXX should instead use style data from the row of reference here ?
|
2011-08-14 21:08:04 +04:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
|
|
|
|
aReflowState.rendContext->SetFont(fm);
|
2002-01-25 10:03:43 +03:00
|
|
|
nscoord axisHeight;
|
2011-04-08 05:04:40 +04:00
|
|
|
GetAxisHeight(*aReflowState.rendContext,
|
|
|
|
aReflowState.rendContext->FontMetrics(),
|
|
|
|
axisHeight);
|
2002-01-25 10:03:43 +03:00
|
|
|
if (rowFrame) {
|
2002-01-27 22:26:42 +03:00
|
|
|
// anchor the table on the axis of the row of reference
|
2002-01-25 10:03:43 +03:00
|
|
|
// XXX fallback to baseline because it is a hard problem
|
2002-01-27 22:26:42 +03:00
|
|
|
// XXX need to fetch the axis of the row; would need rowalign=axis to work better
|
2002-01-25 10:03:43 +03:00
|
|
|
nscoord rowAscent = ((nsTableRowFrame*)rowFrame)->GetMaxCellAscent();
|
|
|
|
if (rowAscent) { // the row has at least one cell with 'vertical-align: baseline'
|
2014-06-11 13:45:31 +04:00
|
|
|
aDesiredSize.SetBlockStartAscent(dy + rowAscent);
|
2002-01-25 10:03:43 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// in other situations, fallback to using half of the height
|
2014-06-11 13:45:31 +04:00
|
|
|
aDesiredSize.SetBlockStartAscent(dy + blockSize / 2 + axisHeight);
|
2000-05-08 11:23:22 +04:00
|
|
|
}
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2002-01-25 10:03:43 +03:00
|
|
|
mReference.x = 0;
|
2014-06-11 13:45:31 +04:00
|
|
|
mReference.y = aDesiredSize.BlockStartAscent();
|
2000-03-28 14:15:19 +04:00
|
|
|
|
|
|
|
// just make-up a bounding metrics
|
2011-04-08 05:04:40 +04:00
|
|
|
mBoundingMetrics = nsBoundingMetrics();
|
2014-06-11 13:45:31 +04:00
|
|
|
mBoundingMetrics.ascent = aDesiredSize.BlockStartAscent();
|
|
|
|
mBoundingMetrics.descent = aDesiredSize.Height() -
|
|
|
|
aDesiredSize.BlockStartAscent();
|
2013-12-27 21:59:52 +04:00
|
|
|
mBoundingMetrics.width = aDesiredSize.Width();
|
2000-03-28 14:15:19 +04:00
|
|
|
mBoundingMetrics.leftBearing = 0;
|
2013-12-27 21:59:52 +04:00
|
|
|
mBoundingMetrics.rightBearing = aDesiredSize.Width();
|
2000-03-28 14:15:19 +04:00
|
|
|
|
|
|
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
2000-03-28 14:15:19 +04:00
|
|
|
}
|
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
nsContainerFrame*
|
2006-09-07 07:45:45 +04:00
|
|
|
NS_NewMathMLmtableFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsMathMLmtableFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtableFrame)
|
|
|
|
|
2006-09-07 07:45:45 +04:00
|
|
|
nsMathMLmtableFrame::~nsMathMLmtableFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsMathMLmtableFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList)
|
2006-09-07 07:45:45 +04:00
|
|
|
{
|
2014-05-28 23:36:58 +04:00
|
|
|
nsTableFrame::SetInitialChildList(aListID, aChildList);
|
2006-09-07 07:45:45 +04:00
|
|
|
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
|
2013-07-20 23:14:25 +04:00
|
|
|
PresContext()->RestyleManager()->
|
2010-06-18 20:23:05 +04:00
|
|
|
PostRestyleEvent(mContent->AsElement(), eRestyle_Subtree,
|
2012-09-08 02:57:06 +04:00
|
|
|
nsChangeHint_AllReflowHints);
|
2006-09-07 07:45:45 +04:00
|
|
|
}
|
|
|
|
|
2014-06-18 14:57:00 +04:00
|
|
|
nscoord
|
|
|
|
nsMathMLmtableFrame::GetCellSpacingX(int32_t aColIndex)
|
|
|
|
{
|
|
|
|
if (mUseCSSSpacing) {
|
|
|
|
return nsTableFrame::GetCellSpacingX(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::GetCellSpacingX(int32_t aStartColIndex,
|
|
|
|
int32_t aEndColIndex)
|
|
|
|
{
|
|
|
|
if (mUseCSSSpacing) {
|
|
|
|
return nsTableFrame::GetCellSpacingX(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::GetCellSpacingY(int32_t aRowIndex)
|
|
|
|
{
|
|
|
|
if (mUseCSSSpacing) {
|
|
|
|
return nsTableFrame::GetCellSpacingY(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::GetCellSpacingY(int32_t aStartRowIndex,
|
|
|
|
int32_t aEndRowIndex)
|
|
|
|
{
|
|
|
|
if (mUseCSSSpacing) {
|
|
|
|
return nsTableFrame::GetCellSpacingY(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)
|
|
|
|
|
2006-09-07 07:45:45 +04:00
|
|
|
// --------
|
|
|
|
// implementation of nsMathMLmtrFrame
|
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
nsContainerFrame*
|
2006-09-07 07:45:45 +04:00
|
|
|
NS_NewMathMLmtrFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsMathMLmtrFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtrFrame)
|
|
|
|
|
2006-09-07 07:45:45 +04:00
|
|
|
nsMathMLmtrFrame::~nsMathMLmtrFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsMathMLmtrFrame::AttributeChanged(int32_t aNameSpaceID,
|
2006-09-07 07:45:45 +04:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
2006-09-07 07:45:45 +04:00
|
|
|
{
|
|
|
|
// Attributes specific to <mtr>:
|
|
|
|
// groupalign : Not yet supported.
|
2013-12-13 21:42:43 +04:00
|
|
|
// rowalign : Here
|
|
|
|
// columnalign : Here
|
2006-09-07 07:45:45 +04:00
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
nsPresContext* presContext = PresContext();
|
2006-09-07 07:45:45 +04:00
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
if (aAttribute != nsGkAtoms::rowalign_ &&
|
|
|
|
aAttribute != nsGkAtoms::columnalign_) {
|
2006-09-07 07:45:45 +04:00
|
|
|
return NS_OK;
|
2013-12-13 21:42:43 +04:00
|
|
|
}
|
2006-09-07 07:45:45 +04:00
|
|
|
|
2010-03-29 05:46:55 +04:00
|
|
|
presContext->PropertyTable()->Delete(this, AttributeToProperty(aAttribute));
|
2006-09-07 07:45:45 +04:00
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
bool allowMultiValues = (aAttribute == nsGkAtoms::columnalign_);
|
2006-09-07 07:45:45 +04:00
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
// 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);
|
2006-09-07 07:45:45 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-01-25 10:03:43 +03:00
|
|
|
// --------
|
|
|
|
// implementation of nsMathMLmtdFrame
|
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
nsContainerFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewMathMLmtdFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2002-01-25 10:03:43 +03:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsMathMLmtdFrame(aContext);
|
2002-01-25 10:03:43 +03:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtdFrame)
|
|
|
|
|
2002-01-25 10:03:43 +03:00
|
|
|
nsMathMLmtdFrame::~nsMathMLmtdFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
2002-01-25 10:03:43 +03:00
|
|
|
nsMathMLmtdFrame::GetRowSpan()
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowspan = 1;
|
2007-02-19 23:46:31 +03:00
|
|
|
|
2008-01-26 19:32:16 +03:00
|
|
|
// Don't look at the content's rowspan if we're not an mtd or a pseudo cell.
|
2013-02-16 09:38:33 +04:00
|
|
|
if ((mContent->Tag() == nsGkAtoms::mtd_) && !StyleContext()->GetPseudo()) {
|
2007-02-19 23:46:31 +03:00
|
|
|
nsAutoString value;
|
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::rowspan, value);
|
|
|
|
if (!value.IsEmpty()) {
|
2012-07-27 17:59:29 +04:00
|
|
|
nsresult error;
|
2007-02-19 23:46:31 +03:00
|
|
|
rowspan = value.ToInteger(&error);
|
2012-08-13 17:49:48 +04:00
|
|
|
if (NS_FAILED(error) || rowspan < 0)
|
2007-02-19 23:46:31 +03:00
|
|
|
rowspan = 1;
|
2013-01-15 16:22:03 +04:00
|
|
|
rowspan = std::min(rowspan, MAX_ROWSPAN);
|
2007-02-19 23:46:31 +03:00
|
|
|
}
|
2002-01-25 10:03:43 +03:00
|
|
|
}
|
|
|
|
return rowspan;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
2002-01-25 10:03:43 +03:00
|
|
|
nsMathMLmtdFrame::GetColSpan()
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colspan = 1;
|
2007-02-19 23:46:31 +03:00
|
|
|
|
2008-01-26 19:32:16 +03:00
|
|
|
// Don't look at the content's colspan if we're not an mtd or a pseudo cell.
|
2013-02-16 09:38:33 +04:00
|
|
|
if ((mContent->Tag() == nsGkAtoms::mtd_) && !StyleContext()->GetPseudo()) {
|
2007-02-19 23:46:31 +03:00
|
|
|
nsAutoString value;
|
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::columnspan_, value);
|
|
|
|
if (!value.IsEmpty()) {
|
2012-07-27 17:59:29 +04:00
|
|
|
nsresult error;
|
2007-02-19 23:46:31 +03:00
|
|
|
colspan = value.ToInteger(&error);
|
2012-08-13 17:49:48 +04:00
|
|
|
if (NS_FAILED(error) || colspan < 0 || colspan > MAX_COLSPAN)
|
2007-02-19 23:46:31 +03:00
|
|
|
colspan = 1;
|
|
|
|
}
|
2002-01-25 10:03:43 +03:00
|
|
|
}
|
|
|
|
return colspan;
|
|
|
|
}
|
2000-05-16 17:18:42 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsMathMLmtdFrame::AttributeChanged(int32_t aNameSpaceID,
|
2006-09-07 07:45:45 +04:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
2006-09-07 07:45:45 +04:00
|
|
|
{
|
|
|
|
// Attributes specific to <mtd>:
|
|
|
|
// groupalign : Not yet supported
|
2013-12-13 21:42:43 +04:00
|
|
|
// rowalign : here
|
2006-09-07 07:45:45 +04:00
|
|
|
// columnalign : here
|
|
|
|
// rowspan : here
|
|
|
|
// columnspan : here
|
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
if (aAttribute == nsGkAtoms::rowalign_ ||
|
|
|
|
aAttribute == nsGkAtoms::columnalign_) {
|
|
|
|
|
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
presContext->PropertyTable()->Delete(this, AttributeToProperty(aAttribute));
|
|
|
|
|
|
|
|
// Reparse the attribute.
|
|
|
|
ParseFrameAttribute(this, aAttribute, false);
|
2006-09-07 07:45:45 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::rowspan ||
|
|
|
|
aAttribute == nsGkAtoms::columnspan_) {
|
2006-09-07 07:45:45 +04:00
|
|
|
// use the naming expected by the base class
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::columnspan_)
|
|
|
|
aAttribute = nsGkAtoms::colspan;
|
2006-09-07 07:45:45 +04:00
|
|
|
return nsTableCellFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
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;
|
|
|
|
}
|
2014-03-03 19:37:08 +04:00
|
|
|
|
|
|
|
nsMargin*
|
|
|
|
nsMathMLmtdFrame::GetBorderWidth(nsMargin& aBorder) const
|
|
|
|
{
|
|
|
|
nsStyleBorder styleBorder = *StyleBorder();
|
|
|
|
ApplyBorderToStyle(this, styleBorder);
|
|
|
|
aBorder = styleBorder.GetComputedBorder();
|
|
|
|
return &aBorder;
|
|
|
|
}
|
|
|
|
|
2014-06-18 14:57:00 +04:00
|
|
|
nsMargin
|
|
|
|
nsMathMLmtdFrame::GetBorderOverflow()
|
|
|
|
{
|
|
|
|
nsStyleBorder styleBorder = *StyleBorder();
|
|
|
|
ApplyBorderToStyle(this, styleBorder);
|
|
|
|
nsMargin overflow = ComputeBorderOverflow(this, styleBorder);
|
|
|
|
return overflow;
|
|
|
|
}
|
|
|
|
|
2000-03-28 14:15:19 +04:00
|
|
|
// --------
|
2001-05-19 14:00:01 +04:00
|
|
|
// implementation of nsMathMLmtdInnerFrame
|
2000-03-28 14:15:19 +04:00
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsMathMLmtdInnerFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIMathMLFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
2001-02-23 19:10:51 +03:00
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
nsContainerFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewMathMLmtdInnerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2000-03-28 14:15:19 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsMathMLmtdInnerFrame(aContext);
|
2000-03-28 14:15:19 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtdInnerFrame)
|
|
|
|
|
2013-12-13 21:42:43 +04:00
|
|
|
nsMathMLmtdInnerFrame::nsMathMLmtdInnerFrame(nsStyleContext* aContext)
|
|
|
|
: nsBlockFrame(aContext)
|
|
|
|
{
|
|
|
|
// Make a copy of the parent nsStyleText for later modificaiton.
|
|
|
|
mUniqueStyleText = new (PresContext()) nsStyleText(*StyleText());
|
|
|
|
}
|
|
|
|
|
2001-05-19 14:00:01 +04:00
|
|
|
nsMathMLmtdInnerFrame::~nsMathMLmtdInnerFrame()
|
2000-03-28 14:15:19 +04:00
|
|
|
{
|
2013-12-13 21:42:43 +04:00
|
|
|
mUniqueStyleText->Destroy(PresContext());
|
2000-03-28 14:15:19 +04:00
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsMathMLmtdInnerFrame::Reflow(nsPresContext* aPresContext,
|
2001-05-19 14:00:01 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
2000-03-28 14:15:19 +04:00
|
|
|
{
|
|
|
|
// Let the base class do the reflow
|
2014-05-13 04:47:52 +04:00
|
|
|
nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2000-03-28 14:15:19 +04:00
|
|
|
|
|
|
|
// more about <maligngroup/> and <malignmark/> later
|
|
|
|
// ...
|
|
|
|
}
|
2013-12-13 21:42:43 +04:00
|
|
|
|
|
|
|
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());
|
|
|
|
}
|