From 52ef7d3b1a0e502f4051550e3493d7c2480caeb1 Mon Sep 17 00:00:00 2001 From: "mats.palmgren%bredband.net" Date: Tue, 20 Sep 2005 19:45:10 +0000 Subject: [PATCH] Implement HTML4 align=middle according to spec. Correct the DOM attribute value mapping for some of the other values as well. b=192077 r+sr=dbaron a=mtschrep git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@180661 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/content/src/nsGenericHTMLElement.cpp | 41 ++++++------------- mozilla/layout/base/nsStyleConsts.h | 17 ++++---- mozilla/layout/generic/nsLineLayout.cpp | 12 ++++++ mozilla/layout/style/nsCSSKeywordList.h | 1 + mozilla/layout/style/nsCSSProps.cpp | 1 + 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 9ce7d892418..0938d69af63 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -21,6 +21,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): + * Mats Palmgren * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -2410,37 +2411,21 @@ nsGenericHTMLElement::GetPresContext() return nsnull; } -// XXX check all mappings against ebina's usage static const nsAttrValue::EnumTable kAlignTable[] = { - { "left", NS_STYLE_TEXT_ALIGN_LEFT }, - { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, + { "left", NS_STYLE_TEXT_ALIGN_LEFT }, + { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, - { "texttop", NS_STYLE_VERTICAL_ALIGN_TEXT_TOP },// verified - { "baseline", NS_STYLE_VERTICAL_ALIGN_BASELINE },// verified - { "center", NS_STYLE_VERTICAL_ALIGN_MIDDLE }, - { "bottom", NS_STYLE_VERTICAL_ALIGN_BASELINE },//verified - { "top", NS_STYLE_VERTICAL_ALIGN_TOP },//verified - { "middle", NS_STYLE_VERTICAL_ALIGN_MIDDLE },//verified - { "absbottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM },//verified - { "abscenter", NS_STYLE_VERTICAL_ALIGN_MIDDLE },/* XXX not the same as ebina */ - { "absmiddle", NS_STYLE_VERTICAL_ALIGN_MIDDLE },/* XXX ditto */ - { 0 } -}; + { "top", NS_STYLE_VERTICAL_ALIGN_TOP }, + { "middle", NS_STYLE_VERTICAL_ALIGN_MIDDLE_WITH_BASELINE }, + { "bottom", NS_STYLE_VERTICAL_ALIGN_BASELINE }, -// Elements that should return vertical align values "middle", "bottom", and "top" -// instead of "center", "baseline", and "texttop" from GetAttribute() should use this -static const nsAttrValue::EnumTable kVAlignTable[] = { - { "left", NS_STYLE_TEXT_ALIGN_LEFT }, - { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, - { "top", NS_STYLE_VERTICAL_ALIGN_TOP },//verified - { "texttop", NS_STYLE_VERTICAL_ALIGN_TEXT_TOP },// verified - { "bottom", NS_STYLE_VERTICAL_ALIGN_BASELINE },//verified - { "baseline", NS_STYLE_VERTICAL_ALIGN_BASELINE },// verified - { "middle", NS_STYLE_VERTICAL_ALIGN_MIDDLE },//verified - { "center", NS_STYLE_VERTICAL_ALIGN_MIDDLE }, - { "absbottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM },//verified - { "abscenter", NS_STYLE_VERTICAL_ALIGN_MIDDLE },/* XXX not the same as ebina */ - { "absmiddle", NS_STYLE_VERTICAL_ALIGN_MIDDLE },/* XXX ditto */ + { "center", NS_STYLE_VERTICAL_ALIGN_MIDDLE_WITH_BASELINE }, + { "baseline", NS_STYLE_VERTICAL_ALIGN_BASELINE }, + + { "texttop", NS_STYLE_VERTICAL_ALIGN_TEXT_TOP }, + { "absmiddle", NS_STYLE_VERTICAL_ALIGN_MIDDLE }, + { "abscenter", NS_STYLE_VERTICAL_ALIGN_MIDDLE }, + { "absbottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM }, { 0 } }; diff --git a/mozilla/layout/base/nsStyleConsts.h b/mozilla/layout/base/nsStyleConsts.h index 85cdad6a31a..2a9de3078fb 100644 --- a/mozilla/layout/base/nsStyleConsts.h +++ b/mozilla/layout/base/nsStyleConsts.h @@ -549,14 +549,15 @@ // Note: these values pickup after the text-align values because there // are a few html cases where an object can have both types of // alignment applied with a single attribute -#define NS_STYLE_VERTICAL_ALIGN_BASELINE 10 -#define NS_STYLE_VERTICAL_ALIGN_SUB 11 -#define NS_STYLE_VERTICAL_ALIGN_SUPER 12 -#define NS_STYLE_VERTICAL_ALIGN_TOP 13 -#define NS_STYLE_VERTICAL_ALIGN_TEXT_TOP 14 -#define NS_STYLE_VERTICAL_ALIGN_MIDDLE 15 -#define NS_STYLE_VERTICAL_ALIGN_TEXT_BOTTOM 16 -#define NS_STYLE_VERTICAL_ALIGN_BOTTOM 17 +#define NS_STYLE_VERTICAL_ALIGN_BASELINE 10 +#define NS_STYLE_VERTICAL_ALIGN_SUB 11 +#define NS_STYLE_VERTICAL_ALIGN_SUPER 12 +#define NS_STYLE_VERTICAL_ALIGN_TOP 13 +#define NS_STYLE_VERTICAL_ALIGN_TEXT_TOP 14 +#define NS_STYLE_VERTICAL_ALIGN_MIDDLE 15 +#define NS_STYLE_VERTICAL_ALIGN_TEXT_BOTTOM 16 +#define NS_STYLE_VERTICAL_ALIGN_BOTTOM 17 +#define NS_STYLE_VERTICAL_ALIGN_MIDDLE_WITH_BASELINE 18 // See nsStyleDisplay #define NS_STYLE_VISIBILITY_HIDDEN 0 diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index 4a4ae56c085..23d114c9ef3 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -25,6 +25,7 @@ * L. David Baron * Robert O'Callahan * IBM Corporation + * Mats Palmgren * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -2279,6 +2280,17 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) } pfd->mVerticalAlign = VALIGN_OTHER; break; + + case NS_STYLE_VERTICAL_ALIGN_MIDDLE_WITH_BASELINE: + // Align the midpoint of the frame with the baseline of the parent. + if (frameSpan) { + pfd->mBounds.y = baselineY - pfd->mBounds.height/2; + } + else { + pfd->mBounds.y = baselineY - logicalHeight/2 + pfd->mMargin.top; + } + pfd->mVerticalAlign = VALIGN_OTHER; + break; } break; diff --git a/mozilla/layout/style/nsCSSKeywordList.h b/mozilla/layout/style/nsCSSKeywordList.h index e8f81922e52..fcf6a6f9bee 100644 --- a/mozilla/layout/style/nsCSSKeywordList.h +++ b/mozilla/layout/style/nsCSSKeywordList.h @@ -143,6 +143,7 @@ CSS_KEY(-moz-malayalam, _moz_malayalam) CSS_KEY(-moz-marker, _moz_marker) // Disabled because not supported correctly. CSS_KEY(-moz-menuhover, _moz_menuhover) CSS_KEY(-moz-menuhovertext, _moz_menuhovertext) +CSS_KEY(-moz-middle-with-baseline, _moz_middle_with_baseline) CSS_KEY(-moz-myanmar, _moz_myanmar) CSS_KEY(-moz-none, _moz_none) CSS_KEY(-moz-oriya, _moz_oriya) diff --git a/mozilla/layout/style/nsCSSProps.cpp b/mozilla/layout/style/nsCSSProps.cpp index d0445842df4..24ed33070fc 100644 --- a/mozilla/layout/style/nsCSSProps.cpp +++ b/mozilla/layout/style/nsCSSProps.cpp @@ -898,6 +898,7 @@ const PRInt32 nsCSSProps::kVerticalAlignKTable[] = { eCSSKeyword_top, NS_STYLE_VERTICAL_ALIGN_TOP, eCSSKeyword_text_top, NS_STYLE_VERTICAL_ALIGN_TEXT_TOP, eCSSKeyword_middle, NS_STYLE_VERTICAL_ALIGN_MIDDLE, + eCSSKeyword__moz_middle_with_baseline, NS_STYLE_VERTICAL_ALIGN_MIDDLE_WITH_BASELINE, eCSSKeyword_bottom, NS_STYLE_VERTICAL_ALIGN_BOTTOM, eCSSKeyword_text_bottom, NS_STYLE_VERTICAL_ALIGN_TEXT_BOTTOM, eCSSKeyword_UNKNOWN,-1