2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-30 14:37:12 -07:00
|
|
|
#include "nsMathMLmtableFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
2011-04-07 18:04:40 -07:00
|
|
|
#include "nsRenderingContext.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-02-03 06:42:18 -08:00
|
|
|
#include "nsTArray.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsTableFrame.h"
|
2008-07-16 08:02:18 -07:00
|
|
|
#include "celldata.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-19 15:55:18 -07:00
|
|
|
#include "RestyleManager.h"
|
2013-01-15 04:22:03 -08:00
|
|
|
#include <algorithm>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-28 18:46:55 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//
|
|
|
|
// <mtable> -- table or matrix - implementation
|
|
|
|
//
|
|
|
|
|
|
|
|
// helper function to perform an in-place split of a space-delimited string,
|
|
|
|
// and return an array of pointers for the beginning of each segment, i.e.,
|
|
|
|
// aOffset[0] is the first string, aOffset[1] is the second string, etc.
|
|
|
|
// Used to parse attributes like columnalign='left right', rowalign='top bottom'
|
|
|
|
static void
|
2009-02-03 06:42:18 -08:00
|
|
|
SplitString(nsString& aString, // [IN/OUT]
|
|
|
|
nsTArray<PRUnichar*>& aOffset) // [OUT]
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
static const PRUnichar kNullCh = PRUnichar('\0');
|
|
|
|
|
|
|
|
aString.Append(kNullCh); // put an extra null at the end
|
|
|
|
|
|
|
|
PRUnichar* start = aString.BeginWriting();
|
|
|
|
PRUnichar* end = start;
|
|
|
|
|
|
|
|
while (kNullCh != *start) {
|
|
|
|
while ((kNullCh != *start) && nsCRT::IsAsciiSpace(*start)) { // skip leading space
|
|
|
|
start++;
|
|
|
|
}
|
|
|
|
end = start;
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
while ((kNullCh != *end) && (false == nsCRT::IsAsciiSpace(*end))) { // look for space or end
|
2007-03-22 10:30:00 -07:00
|
|
|
end++;
|
|
|
|
}
|
|
|
|
*end = kNullCh; // end string here
|
|
|
|
|
|
|
|
if (start < end) {
|
|
|
|
aOffset.AppendElement(start); // record the beginning of this segment
|
|
|
|
}
|
|
|
|
|
|
|
|
start = ++end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct nsValueList
|
|
|
|
{
|
2009-02-03 06:42:18 -08:00
|
|
|
nsString mData;
|
|
|
|
nsTArray<PRUnichar*> mArray;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsValueList(nsString& aData) {
|
|
|
|
mData.Assign(aData);
|
|
|
|
SplitString(mData, mArray);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Each rowalign='top bottom' or columnalign='left right center' (from
|
|
|
|
// <mtable> or <mtr>) is split once (lazily) into a nsValueList which is
|
|
|
|
// stored in the property table. Row/Cell frames query the property table
|
|
|
|
// to see what values apply to them.
|
|
|
|
|
|
|
|
// XXX See bug 69409 - MathML attributes are not mapped to style.
|
|
|
|
|
|
|
|
static void
|
2010-03-28 18:46:55 -07:00
|
|
|
DestroyValueList(void* aPropertyValue)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-07-08 00:08:04 -07:00
|
|
|
delete static_cast<nsValueList*>(aPropertyValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-03-28 18:46:55 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(RowAlignProperty, DestroyValueList)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(RowLinesProperty, DestroyValueList)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(ColumnAlignProperty, DestroyValueList)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(ColumnLinesProperty, DestroyValueList)
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static PRUnichar*
|
2010-03-28 18:46:55 -07:00
|
|
|
GetValueAt(nsIFrame* aTableOrRowFrame,
|
|
|
|
const FramePropertyDescriptor* aProperty,
|
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aRowOrColIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-03-28 18:46:55 -07:00
|
|
|
FrameProperties props = aTableOrRowFrame->Properties();
|
|
|
|
nsValueList* valueList = static_cast<nsValueList*>(props.Get(aProperty));
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!valueList) {
|
|
|
|
// The property isn't there yet, so set it
|
|
|
|
nsAutoString values;
|
|
|
|
aTableOrRowFrame->GetContent()->GetAttr(kNameSpaceID_None, aAttribute, values);
|
|
|
|
if (!values.IsEmpty())
|
|
|
|
valueList = new nsValueList(values);
|
2009-02-03 06:42:18 -08:00
|
|
|
if (!valueList || !valueList->mArray.Length()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
delete valueList; // ok either way, delete is null safe
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-03-28 18:46:55 -07:00
|
|
|
props.Set(aProperty, valueList);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t count = valueList->mArray.Length();
|
2007-03-22 10:30:00 -07:00
|
|
|
return (aRowOrColIndex < count)
|
2009-02-03 06:42:18 -08:00
|
|
|
? valueList->mArray[aRowOrColIndex]
|
|
|
|
: valueList->mArray[count-1];
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool
|
2012-08-22 08:56:38 -07:00
|
|
|
IsTable(uint8_t aDisplay)
|
2008-01-08 18:14:35 -08:00
|
|
|
{
|
|
|
|
if ((aDisplay == NS_STYLE_DISPLAY_TABLE) ||
|
|
|
|
(aDisplay == NS_STYLE_DISPLAY_INLINE_TABLE))
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
|
|
|
return false;
|
2008-01-08 18:14:35 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#define DEBUG_VERIFY_THAT_FRAME_IS(_frame, _expected) \
|
2013-02-16 13:51:02 -08:00
|
|
|
NS_ASSERTION(NS_STYLE_DISPLAY_##_expected == _frame->StyleDisplay()->mDisplay, "internal error");
|
2008-01-08 18:14:35 -08:00
|
|
|
#define DEBUG_VERIFY_THAT_FRAME_IS_TABLE(_frame) \
|
2013-02-16 13:51:02 -08:00
|
|
|
NS_ASSERTION(IsTable(_frame->StyleDisplay()->mDisplay), "internal error");
|
2007-03-22 10:30:00 -07:00
|
|
|
#else
|
|
|
|
#define DEBUG_VERIFY_THAT_FRAME_IS(_frame, _expected)
|
2008-01-08 18:14:35 -08:00
|
|
|
#define DEBUG_VERIFY_THAT_FRAME_IS_TABLE(_frame)
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// map attributes that depend on the index of the row:
|
|
|
|
// rowalign, rowlines, XXX need rowspacing too
|
|
|
|
static void
|
|
|
|
MapRowAttributesIntoCSS(nsIFrame* aTableFrame,
|
|
|
|
nsIFrame* aRowFrame)
|
|
|
|
{
|
2008-01-08 18:14:35 -08:00
|
|
|
DEBUG_VERIFY_THAT_FRAME_IS_TABLE(aTableFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
DEBUG_VERIFY_THAT_FRAME_IS(aRowFrame, TABLE_ROW);
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t rowIndex = ((nsTableRowFrame*)aRowFrame)->GetRowIndex();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIContent* rowContent = aRowFrame->GetContent();
|
|
|
|
PRUnichar* attr;
|
|
|
|
|
|
|
|
// see if the rowalign attribute is not already set
|
|
|
|
if (!rowContent->HasAttr(kNameSpaceID_None, nsGkAtoms::rowalign_) &&
|
2010-03-10 04:49:33 -08:00
|
|
|
!rowContent->HasAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_rowalign_)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// see if the rowalign attribute was specified on the table
|
2010-03-28 18:46:55 -07:00
|
|
|
attr = GetValueAt(aTableFrame, RowAlignProperty(),
|
|
|
|
nsGkAtoms::rowalign_, rowIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (attr) {
|
2010-03-10 04:49:33 -08:00
|
|
|
// set our special _moz attribute on the row without notifying a reflow
|
|
|
|
rowContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_rowalign_,
|
2011-10-17 07:59:28 -07:00
|
|
|
nsDependentString(attr), false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we are not on the first row, see if |rowlines| was specified on the table.
|
|
|
|
// Note that we pass 'rowIndex-1' because the CSS rule in mathml.css is associated
|
|
|
|
// to 'border-top', and it is as if we draw the line on behalf of the previous cell.
|
|
|
|
// This way of doing so allows us to handle selective lines, [row]\hline[row][row]',
|
|
|
|
// and cases of spanning cells without further complications.
|
|
|
|
if (rowIndex > 0 &&
|
2010-03-10 04:49:33 -08:00
|
|
|
!rowContent->HasAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_rowline_)) {
|
2010-03-28 18:46:55 -07:00
|
|
|
attr = GetValueAt(aTableFrame, RowLinesProperty(),
|
|
|
|
nsGkAtoms::rowlines_, rowIndex-1);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (attr) {
|
2010-03-10 04:49:33 -08:00
|
|
|
// set our special _moz attribute on the row without notifying a reflow
|
|
|
|
rowContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_rowline_,
|
2011-10-17 07:59:28 -07:00
|
|
|
nsDependentString(attr), false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// map attributes that depend on the index of the column:
|
|
|
|
// columnalign, columnlines, XXX need columnwidth and columnspacing too
|
|
|
|
static void
|
|
|
|
MapColAttributesIntoCSS(nsIFrame* aTableFrame,
|
|
|
|
nsIFrame* aRowFrame,
|
|
|
|
nsIFrame* aCellFrame)
|
|
|
|
{
|
2008-01-08 18:14:35 -08:00
|
|
|
DEBUG_VERIFY_THAT_FRAME_IS_TABLE(aTableFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
DEBUG_VERIFY_THAT_FRAME_IS(aRowFrame, TABLE_ROW);
|
|
|
|
DEBUG_VERIFY_THAT_FRAME_IS(aCellFrame, TABLE_CELL);
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t rowIndex, colIndex;
|
2007-03-22 10:30:00 -07:00
|
|
|
((nsTableCellFrame*)aCellFrame)->GetCellIndexes(rowIndex, colIndex);
|
|
|
|
nsIContent* cellContent = aCellFrame->GetContent();
|
|
|
|
PRUnichar* attr;
|
|
|
|
|
|
|
|
// see if the columnalign attribute is not already set
|
|
|
|
if (!cellContent->HasAttr(kNameSpaceID_None, nsGkAtoms::columnalign_) &&
|
2010-03-10 04:49:33 -08:00
|
|
|
!cellContent->HasAttr(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::_moz_math_columnalign_)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// see if the columnalign attribute was specified on the row
|
2010-03-28 18:46:55 -07:00
|
|
|
attr = GetValueAt(aRowFrame, ColumnAlignProperty(),
|
|
|
|
nsGkAtoms::columnalign_, colIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!attr) {
|
|
|
|
// see if the columnalign attribute was specified on the table
|
2010-03-28 18:46:55 -07:00
|
|
|
attr = GetValueAt(aTableFrame, ColumnAlignProperty(),
|
|
|
|
nsGkAtoms::columnalign_, colIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (attr) {
|
2010-03-10 04:49:33 -08:00
|
|
|
// set our special _moz attribute without notifying a reflow
|
|
|
|
cellContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_columnalign_,
|
2011-10-17 07:59:28 -07:00
|
|
|
nsDependentString(attr), false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we are not on the first column, see if |columnlines| was specified on
|
|
|
|
// the table. Note that we pass 'colIndex-1' because the CSS rule in mathml.css
|
|
|
|
// is associated to 'border-left', and it is as if we draw the line on behalf
|
|
|
|
// of the previous cell. This way of doing so allows us to handle selective lines,
|
|
|
|
// e.g., 'r|cl', and cases of spanning cells without further complications.
|
|
|
|
if (colIndex > 0 &&
|
2010-03-10 04:49:33 -08:00
|
|
|
!cellContent->HasAttr(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::_moz_math_columnline_)) {
|
2010-03-28 18:46:55 -07:00
|
|
|
attr = GetValueAt(aTableFrame, ColumnLinesProperty(),
|
|
|
|
nsGkAtoms::columnlines_, colIndex-1);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (attr) {
|
2010-03-10 04:49:33 -08:00
|
|
|
// set our special _moz attribute without notifying a reflow
|
|
|
|
cellContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_columnline_,
|
2011-10-17 07:59:28 -07:00
|
|
|
nsDependentString(attr), false);
|
2007-03-22 10:30:00 -07: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
|
|
|
|
MapAllAttributesIntoCSS(nsIFrame* aTableFrame)
|
|
|
|
{
|
|
|
|
// mtable is simple and only has one (pseudo) row-group
|
2011-08-24 13:54:30 -07:00
|
|
|
nsIFrame* rgFrame = aTableFrame->GetFirstPrincipalChild();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame)
|
|
|
|
return;
|
|
|
|
|
2011-08-24 13:54:30 -07:00
|
|
|
nsIFrame* rowFrame = rgFrame->GetFirstPrincipalChild();
|
2007-03-22 10:30:00 -07:00
|
|
|
for ( ; rowFrame; rowFrame = rowFrame->GetNextSibling()) {
|
|
|
|
DEBUG_VERIFY_THAT_FRAME_IS(rowFrame, TABLE_ROW);
|
|
|
|
if (rowFrame->GetType() == nsGkAtoms::tableRowFrame) {
|
|
|
|
MapRowAttributesIntoCSS(aTableFrame, rowFrame);
|
2011-08-24 13:54:30 -07:00
|
|
|
nsIFrame* cellFrame = rowFrame->GetFirstPrincipalChild();
|
2007-03-22 10:30:00 -07:00
|
|
|
for ( ; cellFrame; cellFrame = cellFrame->GetNextSibling()) {
|
|
|
|
DEBUG_VERIFY_THAT_FRAME_IS(cellFrame, TABLE_CELL);
|
|
|
|
if (IS_TABLE_CELL(cellFrame->GetType())) {
|
|
|
|
MapColAttributesIntoCSS(aTableFrame, rowFrame, cellFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// the align attribute of mtable can have a row number which indicates
|
2012-07-26 18:17:23 -07: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
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
enum eAlign {
|
|
|
|
eAlign_top,
|
|
|
|
eAlign_bottom,
|
|
|
|
eAlign_center,
|
|
|
|
eAlign_baseline,
|
|
|
|
eAlign_axis
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2012-08-22 08:56:38 -07:00
|
|
|
ParseAlignAttribute(nsString& aValue, eAlign& aAlign, int32_t& aRowIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// by default, the table is centered about the axis
|
|
|
|
aRowIndex = 0;
|
|
|
|
aAlign = eAlign_axis;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t len = 0;
|
2012-07-26 18:17:23 -07:00
|
|
|
|
|
|
|
// we only have to remove the leading spaces because
|
|
|
|
// ToInteger ignores the whitespaces around the number
|
|
|
|
aValue.CompressWhitespace(true, false);
|
|
|
|
|
2007-03-22 10:30:00 -07: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 06:59:29 -07:00
|
|
|
nsresult error;
|
2007-03-22 10:30:00 -07:00
|
|
|
aValue.Cut(0, len); // aValue is not a const here
|
|
|
|
aRowIndex = aValue.ToInteger(&error);
|
2012-08-13 06:49:48 -07:00
|
|
|
if (NS_FAILED(error))
|
2007-03-22 10:30:00 -07:00
|
|
|
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->Tag() == nsGkAtoms::math || c->Tag() == nsGkAtoms::body)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!f) f = atLeast;
|
2009-08-20 14:52:48 -07:00
|
|
|
f->List(stdout, 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// --------
|
|
|
|
// implementation of nsMathMLmtableOuterFrame
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_HEAD(nsMathMLmtableOuterFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIMathMLFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsTableOuterFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
NS_NewMathMLmtableOuterFrame (nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsMathMLmtableOuterFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtableOuterFrame)
|
2010-03-28 18:46:55 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsMathMLmtableOuterFrame::~nsMathMLmtableOuterFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMathMLmtableOuterFrame::InheritAutomaticData(nsIFrame* aParent)
|
|
|
|
{
|
|
|
|
// XXX the REC says that by default, displaystyle=false in <mtable>
|
|
|
|
|
2008-01-09 01:38:28 -08:00
|
|
|
// let the base class inherit the displaystyle from our parent
|
2007-03-22 10:30:00 -07:00
|
|
|
nsMathMLFrame::InheritAutomaticData(aParent);
|
|
|
|
|
|
|
|
// see if the displaystyle attribute is there and let it override what we inherited
|
|
|
|
if (mContent->Tag() == nsGkAtoms::mtable_)
|
|
|
|
nsMathMLFrame::FindAttrDisplaystyle(mContent, mPresentationData);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// displaystyle is special in mtable...
|
|
|
|
// Since UpdatePresentation() and UpdatePresentationDataFromChildAt() can be called
|
|
|
|
// by a parent, ensure that the displaystyle attribute of mtable takes precedence
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsMathMLmtableOuterFrame::UpdatePresentationData(uint32_t aFlagsValues,
|
|
|
|
uint32_t aWhichFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (NS_MATHML_HAS_EXPLICIT_DISPLAYSTYLE(mPresentationData.flags)) {
|
|
|
|
// our current state takes precedence, disallow updating the displastyle
|
|
|
|
aWhichFlags &= ~NS_MATHML_DISPLAYSTYLE;
|
|
|
|
aFlagsValues &= ~NS_MATHML_DISPLAYSTYLE;
|
|
|
|
}
|
|
|
|
|
2008-01-09 01:38:28 -08:00
|
|
|
return nsMathMLFrame::UpdatePresentationData(aFlagsValues, aWhichFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsMathMLmtableOuterFrame::UpdatePresentationDataFromChildAt(int32_t aFirstIndex,
|
|
|
|
int32_t aLastIndex,
|
|
|
|
uint32_t aFlagsValues,
|
|
|
|
uint32_t aWhichFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (NS_MATHML_HAS_EXPLICIT_DISPLAYSTYLE(mPresentationData.flags)) {
|
|
|
|
// our current state takes precedence, disallow updating the displastyle
|
|
|
|
aWhichFlags &= ~NS_MATHML_DISPLAYSTYLE;
|
|
|
|
aFlagsValues &= ~NS_MATHML_DISPLAYSTYLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(this,
|
2008-01-09 01:38:28 -08:00
|
|
|
aFirstIndex, aLastIndex, aFlagsValues, aWhichFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsMathMLmtableOuterFrame::AttributeChanged(int32_t aNameSpaceID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Attributes specific to <mtable>:
|
|
|
|
// frame : in mathml.css
|
|
|
|
// framespacing : not yet supported
|
|
|
|
// groupalign : not yet supported
|
|
|
|
// equalrows : not yet supported
|
|
|
|
// equalcolumns : not yet supported
|
|
|
|
// displaystyle : here
|
|
|
|
// align : in reflow
|
|
|
|
// rowalign : here
|
|
|
|
// rowlines : here
|
|
|
|
// rowspacing : not yet supported
|
|
|
|
// columnalign : here
|
|
|
|
// columnlines : here
|
|
|
|
// columnspacing : not yet supported
|
|
|
|
|
|
|
|
// mtable is simple and only has one (pseudo) row-group inside our inner-table
|
|
|
|
nsIFrame* tableFrame = mFrames.FirstChild();
|
2011-09-12 09:08:07 -07:00
|
|
|
NS_ASSERTION(tableFrame && tableFrame->GetType() == nsGkAtoms::tableFrame,
|
|
|
|
"should always have an inner table frame");
|
2011-08-24 13:54:30 -07:00
|
|
|
nsIFrame* rgFrame = tableFrame->GetFirstPrincipalChild();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// align - just need to issue a dirty (resize) reflow command
|
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
2007-03-30 14:11:41 -07:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 12:16:51 -07:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eResize, NS_FRAME_IS_DIRTY);
|
2007-03-22 10:30:00 -07: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
|
|
|
|
if (aAttribute == nsGkAtoms::displaystyle_) {
|
|
|
|
nsMathMLContainerFrame::RebuildAutomaticDataForChildren(mParent);
|
2007-05-06 15:50:21 -07:00
|
|
|
// Need to reflow the parent, not us, because this can actually
|
|
|
|
// affect siblings.
|
2007-03-30 14:11:41 -07:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 12:16:51 -07:00
|
|
|
FrameNeedsReflow(mParent, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ...and the other attributes affect rows or columns in one way or another
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIAtom* MOZrowAtom = nullptr;
|
|
|
|
nsIAtom* MOZcolAtom = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aAttribute == nsGkAtoms::rowalign_)
|
2010-03-10 04:49:33 -08:00
|
|
|
MOZrowAtom = nsGkAtoms::_moz_math_rowalign_;
|
2007-03-22 10:30:00 -07:00
|
|
|
else if (aAttribute == nsGkAtoms::rowlines_)
|
2010-03-10 04:49:33 -08:00
|
|
|
MOZrowAtom = nsGkAtoms::_moz_math_rowline_;
|
2007-03-22 10:30:00 -07:00
|
|
|
else if (aAttribute == nsGkAtoms::columnalign_)
|
2010-03-10 04:49:33 -08:00
|
|
|
MOZcolAtom = nsGkAtoms::_moz_math_columnalign_;
|
2007-03-22 10:30:00 -07:00
|
|
|
else if (aAttribute == nsGkAtoms::columnlines_)
|
2010-03-10 04:49:33 -08:00
|
|
|
MOZcolAtom = nsGkAtoms::_moz_math_columnline_;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (!MOZrowAtom && !MOZcolAtom)
|
|
|
|
return NS_OK;
|
|
|
|
|
2010-03-28 18:46:55 -07:00
|
|
|
nsPresContext* presContext = tableFrame->PresContext();
|
2007-03-22 10:30:00 -07:00
|
|
|
// clear any cached nsValueList for this table
|
2010-03-28 18:46:55 -07:00
|
|
|
presContext->PropertyTable()->
|
|
|
|
Delete(tableFrame, AttributeToProperty(aAttribute));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-10 04:49:33 -08:00
|
|
|
// unset any _moz attribute that we may have set earlier, and re-sync
|
2011-08-24 13:54:30 -07:00
|
|
|
nsIFrame* rowFrame = rgFrame->GetFirstPrincipalChild();
|
2007-03-22 10:30:00 -07:00
|
|
|
for ( ; rowFrame; rowFrame = rowFrame->GetNextSibling()) {
|
|
|
|
if (rowFrame->GetType() == nsGkAtoms::tableRowFrame) {
|
|
|
|
if (MOZrowAtom) { // let rows do the work
|
2011-10-17 07:59:28 -07:00
|
|
|
rowFrame->GetContent()->UnsetAttr(kNameSpaceID_None, MOZrowAtom, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
MapRowAttributesIntoCSS(tableFrame, rowFrame);
|
|
|
|
} else { // let cells do the work
|
2011-08-24 13:54:30 -07:00
|
|
|
nsIFrame* cellFrame = rowFrame->GetFirstPrincipalChild();
|
2007-03-22 10:30:00 -07:00
|
|
|
for ( ; cellFrame; cellFrame = cellFrame->GetNextSibling()) {
|
|
|
|
if (IS_TABLE_CELL(cellFrame->GetType())) {
|
2011-10-17 07:59:28 -07:00
|
|
|
cellFrame->GetContent()->UnsetAttr(kNameSpaceID_None, MOZcolAtom, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
MapColAttributesIntoCSS(tableFrame, rowFrame, cellFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Explicitly request a re-resolve and reflow in our subtree to pick up any changes
|
2013-07-20 12:14:25 -07:00
|
|
|
presContext->RestyleManager()->
|
2010-06-18 09:23:05 -07:00
|
|
|
PostRestyleEvent(mContent->AsElement(), eRestyle_Subtree,
|
2012-09-07 15:57:06 -07:00
|
|
|
nsChangeHint_AllReflowHints);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
nsMathMLmtableOuterFrame::GetRowFrameAt(nsPresContext* aPresContext,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aRowIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-08 06:05:17 -07:00
|
|
|
int32_t rowCount = GetRowCount();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Negative indices mean to find upwards from the end.
|
|
|
|
if (aRowIndex < 0) {
|
|
|
|
aRowIndex = rowCount + aRowIndex;
|
2011-08-06 22:29:00 -07:00
|
|
|
} else {
|
|
|
|
// aRowIndex is 1-based, so convert it to a 0-based index
|
|
|
|
--aRowIndex;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// if our inner table says that the index is valid, find the row now
|
|
|
|
if (0 <= aRowIndex && aRowIndex <= rowCount) {
|
|
|
|
nsIFrame* tableFrame = mFrames.FirstChild();
|
2011-09-12 09:08:07 -07:00
|
|
|
NS_ASSERTION(tableFrame && tableFrame->GetType() == nsGkAtoms::tableFrame,
|
|
|
|
"should always have an inner table frame");
|
2011-08-24 13:54:30 -07:00
|
|
|
nsIFrame* rgFrame = tableFrame->GetFirstPrincipalChild();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTableIterator rowIter(*rgFrame);
|
|
|
|
nsIFrame* rowFrame = rowIter.First();
|
|
|
|
for ( ; rowFrame; rowFrame = rowIter.Next()) {
|
|
|
|
if (aRowIndex == 0) {
|
|
|
|
DEBUG_VERIFY_THAT_FRAME_IS(rowFrame, TABLE_ROW);
|
|
|
|
if (rowFrame->GetType() != nsGkAtoms::tableRowFrame)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return rowFrame;
|
|
|
|
}
|
|
|
|
--aRowIndex;
|
|
|
|
}
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMathMLmtableOuterFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsAutoString value;
|
|
|
|
// we want to return a table that is anchored according to the align attribute
|
|
|
|
|
|
|
|
rv = 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>
|
|
|
|
// XXX should we also check <mstyle> ?
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t rowIndex = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
eAlign tableAlign = eAlign_axis;
|
2012-07-30 07:20:58 -07:00
|
|
|
GetAttribute(mContent, nullptr, nsGkAtoms::align, value);
|
2007-03-22 10:30:00 -07:00
|
|
|
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;
|
|
|
|
nscoord height = aDesiredSize.height;
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame* rowFrame = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (rowIndex) {
|
|
|
|
rowFrame = GetRowFrameAt(aPresContext, rowIndex);
|
|
|
|
if (rowFrame) {
|
|
|
|
// translate the coordinates to be relative to us
|
|
|
|
nsIFrame* frame = rowFrame;
|
|
|
|
height = frame->GetSize().height;
|
|
|
|
do {
|
|
|
|
dy += frame->GetPosition().y;
|
|
|
|
frame = frame->GetParent();
|
|
|
|
} while (frame != this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (tableAlign) {
|
|
|
|
case eAlign_top:
|
|
|
|
aDesiredSize.ascent = dy;
|
|
|
|
break;
|
|
|
|
case eAlign_bottom:
|
|
|
|
aDesiredSize.ascent = dy + height;
|
|
|
|
break;
|
|
|
|
case eAlign_center:
|
|
|
|
aDesiredSize.ascent = dy + height/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.ascent = dy + rowAscent;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// in other situations, fallback to center
|
|
|
|
aDesiredSize.ascent = dy + height/2;
|
|
|
|
break;
|
|
|
|
case eAlign_axis:
|
|
|
|
default: {
|
|
|
|
// XXX should instead use style data from the row of reference here ?
|
2011-08-14 10:08:04 -07:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
|
|
|
|
aReflowState.rendContext->SetFont(fm);
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord axisHeight;
|
2011-04-07 18:04:40 -07:00
|
|
|
GetAxisHeight(*aReflowState.rendContext,
|
|
|
|
aReflowState.rendContext->FontMetrics(),
|
|
|
|
axisHeight);
|
2007-03-22 10:30:00 -07:00
|
|
|
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.ascent = dy + rowAscent;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// in other situations, fallback to using half of the height
|
|
|
|
aDesiredSize.ascent = dy + height/2 + axisHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mReference.x = 0;
|
|
|
|
mReference.y = aDesiredSize.ascent;
|
|
|
|
|
|
|
|
// just make-up a bounding metrics
|
2011-04-07 18:04:40 -07:00
|
|
|
mBoundingMetrics = nsBoundingMetrics();
|
2007-03-22 10:30:00 -07:00
|
|
|
mBoundingMetrics.ascent = aDesiredSize.ascent;
|
|
|
|
mBoundingMetrics.descent = aDesiredSize.height - aDesiredSize.ascent;
|
|
|
|
mBoundingMetrics.width = aDesiredSize.width;
|
|
|
|
mBoundingMetrics.leftBearing = 0;
|
|
|
|
mBoundingMetrics.rightBearing = aDesiredSize.width;
|
|
|
|
|
|
|
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
NS_NewMathMLmtableFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsMathMLmtableFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtableFrame)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsMathMLmtableFrame::~nsMathMLmtableFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 13:54:30 -07:00
|
|
|
nsMathMLmtableFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 05:53:20 -07:00
|
|
|
nsFrameList& aChildList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-08-24 13:54:30 -07:00
|
|
|
nsresult rv = nsTableFrame::SetInitialChildList(aListID, aChildList);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
MapAllAttributesIntoCSS(this);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 12:14:25 -07:00
|
|
|
PresContext()->RestyleManager()->
|
2010-06-18 09:23:05 -07:00
|
|
|
PostRestyleEvent(mContent->AsElement(), eRestyle_Subtree,
|
2012-09-07 15:57:06 -07:00
|
|
|
nsChangeHint_AllReflowHints);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------
|
|
|
|
// implementation of nsMathMLmtrFrame
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
NS_NewMathMLmtrFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsMathMLmtrFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtrFrame)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsMathMLmtrFrame::~nsMathMLmtrFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsMathMLmtrFrame::AttributeChanged(int32_t aNameSpaceID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Attributes specific to <mtr>:
|
|
|
|
// groupalign : Not yet supported.
|
|
|
|
// rowalign : Fully specified in mathml.css, and so HasAttributeDependentStyle() will
|
2013-07-20 12:14:25 -07:00
|
|
|
// pick it up and RestyleManager will issue a PostRestyleEvent().
|
2007-03-22 10:30:00 -07:00
|
|
|
// columnalign : Need an explicit re-style call.
|
|
|
|
|
|
|
|
if (aAttribute == nsGkAtoms::rowalign_) {
|
2010-03-10 04:49:33 -08:00
|
|
|
// unset any _moz attribute that we may have set earlier, and re-sync
|
|
|
|
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_rowalign_,
|
2011-10-17 07:59:28 -07:00
|
|
|
false);
|
2007-03-22 10:30:00 -07:00
|
|
|
MapRowAttributesIntoCSS(nsTableFrame::GetTableFrame(this), this);
|
|
|
|
// That's all - see comment above.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aAttribute != nsGkAtoms::columnalign_)
|
|
|
|
return NS_OK;
|
|
|
|
|
2010-03-28 18:46:55 -07:00
|
|
|
nsPresContext* presContext = PresContext();
|
2007-03-22 10:30:00 -07:00
|
|
|
// Clear any cached columnalign's nsValueList for this row
|
2010-03-28 18:46:55 -07:00
|
|
|
presContext->PropertyTable()->Delete(this, AttributeToProperty(aAttribute));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-10 04:49:33 -08:00
|
|
|
// Clear any internal _moz attribute that we may have set earlier
|
2007-03-22 10:30:00 -07:00
|
|
|
// in our cells and re-sync their columnalign attribute
|
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2011-08-24 13:54:30 -07:00
|
|
|
nsIFrame* cellFrame = GetFirstPrincipalChild();
|
2007-03-22 10:30:00 -07:00
|
|
|
for ( ; cellFrame; cellFrame = cellFrame->GetNextSibling()) {
|
|
|
|
if (IS_TABLE_CELL(cellFrame->GetType())) {
|
|
|
|
cellFrame->GetContent()->
|
2010-03-10 04:49:33 -08:00
|
|
|
UnsetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_columnalign_,
|
2011-10-17 07:59:28 -07:00
|
|
|
false);
|
2007-03-22 10:30:00 -07:00
|
|
|
MapColAttributesIntoCSS(tableFrame, this, cellFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Explicitly request a re-resolve and reflow in our subtree to pick up any changes
|
2013-07-20 12:14:25 -07:00
|
|
|
presContext->RestyleManager()->
|
2010-06-18 09:23:05 -07:00
|
|
|
PostRestyleEvent(mContent->AsElement(), eRestyle_Subtree,
|
2012-09-07 15:57:06 -07:00
|
|
|
nsChangeHint_AllReflowHints);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------
|
|
|
|
// implementation of nsMathMLmtdFrame
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
NS_NewMathMLmtdFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsMathMLmtdFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtdFrame)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsMathMLmtdFrame::~nsMathMLmtdFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
2007-03-22 10:30:00 -07:00
|
|
|
nsMathMLmtdFrame::GetRowSpan()
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t rowspan = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-26 08:32:16 -08:00
|
|
|
// Don't look at the content's rowspan if we're not an mtd or a pseudo cell.
|
2013-02-15 21:38:33 -08:00
|
|
|
if ((mContent->Tag() == nsGkAtoms::mtd_) && !StyleContext()->GetPseudo()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAutoString value;
|
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::rowspan, value);
|
|
|
|
if (!value.IsEmpty()) {
|
2012-07-27 06:59:29 -07:00
|
|
|
nsresult error;
|
2007-03-22 10:30:00 -07:00
|
|
|
rowspan = value.ToInteger(&error);
|
2012-08-13 06:49:48 -07:00
|
|
|
if (NS_FAILED(error) || rowspan < 0)
|
2007-03-22 10:30:00 -07:00
|
|
|
rowspan = 1;
|
2013-01-15 04:22:03 -08:00
|
|
|
rowspan = std::min(rowspan, MAX_ROWSPAN);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return rowspan;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
2007-03-22 10:30:00 -07:00
|
|
|
nsMathMLmtdFrame::GetColSpan()
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t colspan = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-26 08:32:16 -08:00
|
|
|
// Don't look at the content's colspan if we're not an mtd or a pseudo cell.
|
2013-02-15 21:38:33 -08:00
|
|
|
if ((mContent->Tag() == nsGkAtoms::mtd_) && !StyleContext()->GetPseudo()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAutoString value;
|
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::columnspan_, value);
|
|
|
|
if (!value.IsEmpty()) {
|
2012-07-27 06:59:29 -07:00
|
|
|
nsresult error;
|
2007-03-22 10:30:00 -07:00
|
|
|
colspan = value.ToInteger(&error);
|
2012-08-13 06:49:48 -07:00
|
|
|
if (NS_FAILED(error) || colspan < 0 || colspan > MAX_COLSPAN)
|
2007-03-22 10:30:00 -07:00
|
|
|
colspan = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return colspan;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsMathMLmtdFrame::AttributeChanged(int32_t aNameSpaceID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Attributes specific to <mtd>:
|
|
|
|
// groupalign : Not yet supported
|
|
|
|
// rowalign : in mathml.css
|
|
|
|
// columnalign : here
|
|
|
|
// rowspan : here
|
|
|
|
// columnspan : here
|
|
|
|
|
|
|
|
if (aAttribute == nsGkAtoms::columnalign_) {
|
2010-03-10 04:49:33 -08:00
|
|
|
// unset any _moz attribute that we may have set earlier, and re-sync
|
|
|
|
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_columnalign_,
|
2011-10-17 07:59:28 -07:00
|
|
|
false);
|
2007-03-22 10:30:00 -07:00
|
|
|
MapColAttributesIntoCSS(nsTableFrame::GetTableFrame(this), mParent, this);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------
|
|
|
|
// implementation of nsMathMLmtdInnerFrame
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_HEAD(nsMathMLmtdInnerFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIMathMLFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
NS_NewMathMLmtdInnerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsMathMLmtdInnerFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtdInnerFrame)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsMathMLmtdInnerFrame::~nsMathMLmtdInnerFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMathMLmtdInnerFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
// Let the base class do the reflow
|
|
|
|
nsresult rv = nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
|
|
|
|
// more about <maligngroup/> and <malignmark/> later
|
|
|
|
// ...
|
|
|
|
return rv;
|
|
|
|
}
|