From c8612ff038f7f5badb3bcf846814f967893f4aab Mon Sep 17 00:00:00 2001 From: "caillon%returnzero.com" Date: Wed, 30 Jul 2003 08:13:07 +0000 Subject: [PATCH] Bug 38370. Allow color of an HR element to be changed. Make HR be a block element in quirks mode instead of the hacky inline we were previously using (standards mode already had it as a block). Patch by Ian Hickson with minor modifications by me. r+sr=bzbarsky@mit.edu git-svn-id: svn://10.0.0.236/trunk@145375 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/content/src/nsHTMLHRElement.cpp | 160 +++++-- .../content/shared/public/nsCSSKeywordList.h | 1 + .../content/shared/public/nsLayoutAtomList.h | 1 - mozilla/content/shared/src/nsCSSProps.cpp | 1 + mozilla/dom/public/idl/html/Makefile.in | 1 + .../public/idl/html/nsIDOMNSHTMLHRElement.idl | 50 +++ mozilla/dom/src/base/nsDOMClassInfo.cpp | 2 + mozilla/layout/base/nsCSSFrameConstructor.cpp | 7 - mozilla/layout/base/nsCSSRendering.cpp | 110 +++-- mozilla/layout/base/nsLayoutAtomList.h | 1 - mozilla/layout/base/nsStyleConsts.h | 1 + mozilla/layout/base/public/nsStyleConsts.h | 1 + mozilla/layout/generic/nsFrame.cpp | 1 - mozilla/layout/generic/nsHTMLParts.h | 2 - mozilla/layout/generic/nsLineLayout.cpp | 78 +--- mozilla/layout/html/base/src/Makefile.in | 1 - mozilla/layout/html/base/src/nsFrame.cpp | 1 - mozilla/layout/html/base/src/nsHRFrame.cpp | 404 ------------------ mozilla/layout/html/base/src/nsHTMLParts.h | 2 - mozilla/layout/html/base/src/nsLineLayout.cpp | 78 +--- mozilla/layout/html/document/src/html.css | 24 +- mozilla/layout/html/document/src/quirk.css | 49 +-- .../html/style/src/nsCSSFrameConstructor.cpp | 7 - .../layout/html/style/src/nsCSSRendering.cpp | 110 +++-- .../html/tests/attributes/br-standard.html | 49 +++ mozilla/layout/html/tests/attributes/br.html | 16 +- mozilla/layout/html/tests/attributes/hr.html | 33 +- mozilla/layout/style/html.css | 24 +- mozilla/layout/style/nsCSSKeywordList.h | 1 + mozilla/layout/style/nsCSSProps.cpp | 1 + mozilla/layout/style/quirk.css | 49 +-- 31 files changed, 497 insertions(+), 769 deletions(-) create mode 100644 mozilla/dom/public/idl/html/nsIDOMNSHTMLHRElement.idl delete mode 100644 mozilla/layout/html/base/src/nsHRFrame.cpp create mode 100644 mozilla/layout/html/tests/attributes/br-standard.html diff --git a/mozilla/content/html/content/src/nsHTMLHRElement.cpp b/mozilla/content/html/content/src/nsHTMLHRElement.cpp index 88befa9c390..7312d93e093 100644 --- a/mozilla/content/html/content/src/nsHTMLHRElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLHRElement.cpp @@ -36,6 +36,7 @@ * * ***** END LICENSE BLOCK ***** */ #include "nsIDOMHTMLHRElement.h" +#include "nsIDOMNSHTMLHRElement.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" #include "nsGenericHTMLElement.h" @@ -46,7 +47,8 @@ #include "nsRuleNode.h" class nsHTMLHRElement : public nsGenericHTMLLeafElement, - public nsIDOMHTMLHRElement + public nsIDOMHTMLHRElement, + public nsIDOMNSHTMLHRElement { public: nsHTMLHRElement(); @@ -67,15 +69,15 @@ public: // nsIDOMHTMLHRElement NS_DECL_NSIDOMHTMLHRELEMENT + // nsIDOMNSHTMLHRElement + NS_DECL_NSIDOMNSHTMLHRELEMENT + NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsHTMLValue& aResult); NS_IMETHOD AttributeToString(nsIAtom* aAttribute, const nsHTMLValue& aValue, nsAString& aResult) const; - NS_IMETHOD GetAttributeChangeHint(const nsIAtom* aAttribute, - PRInt32 aModType, - nsChangeHint& aHint) const; NS_IMETHOD_(PRBool) HasAttributeDependentStyle(const nsIAtom* aAttribute) const; NS_IMETHOD GetAttributeMappingFunction(nsMapRuleToAttributesFunc& aMapRuleFunc) const; }; @@ -124,6 +126,7 @@ NS_IMPL_RELEASE_INHERITED(nsHTMLHRElement, nsGenericElement) NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLHRElement, nsGenericHTMLLeafElement) NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLHRElement) + NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLHRElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLHRElement) NS_HTML_CONTENT_INTERFACE_MAP_END @@ -161,6 +164,7 @@ NS_IMPL_STRING_ATTR(nsHTMLHRElement, Align, align) NS_IMPL_BOOL_ATTR(nsHTMLHRElement, NoShade, noshade) NS_IMPL_STRING_ATTR(nsHTMLHRElement, Size, size) NS_IMPL_STRING_ATTR(nsHTMLHRElement, Width, width) +NS_IMPL_STRING_ATTR(nsHTMLHRElement, Color, color) static const nsHTMLValue::EnumTable kAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, @@ -193,6 +197,12 @@ nsHTMLHRElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } + else if (aAttribute == nsHTMLAtoms::color) { + if (aResult.ParseColor(aValue, + nsGenericHTMLLeafElement::GetOwnerDocument())) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + } return NS_CONTENT_ATTR_NOT_THERE; } @@ -220,13 +230,31 @@ MapAttributesIntoRule(const nsIHTMLMappedAttributes* aAttributes, if (!aAttributes || !aData) return; + nsHTMLValue value; + PRBool noshade = PR_FALSE; + + nsHTMLValue color; + aAttributes->GetAttribute(nsHTMLAtoms::color, color); + + PRBool colorIsSet = color.GetUnit() == eHTMLUnit_Color || + color.GetUnit() == eHTMLUnit_ColorName; + + if (aData->mSID == eStyleStruct_Position || + aData->mSID == eStyleStruct_Border) { + if (colorIsSet) { + noshade = PR_TRUE; + } else { + aAttributes->GetAttribute(nsHTMLAtoms::noshade, value); + noshade = value.GetUnit() != eHTMLUnit_Null; + } + } + if (aData->mSID == eStyleStruct_Margin) { - nsCSSRect& margin = aData->mMarginData->mMargin; - nsHTMLValue value; // align: enum aAttributes->GetAttribute(nsHTMLAtoms::align, value); if (eHTMLUnit_Enumerated == value.GetUnit()) { // Map align attribute into auto side margins + nsCSSRect& margin = aData->mMarginData->mMargin; switch (value.GetIntValue()) { case NS_STYLE_TEXT_ALIGN_LEFT: if (margin.mLeft.GetUnit() == eCSSUnit_Null) @@ -250,41 +278,117 @@ MapAttributesIntoRule(const nsIHTMLMappedAttributes* aAttributes, } } else if (aData->mSID == eStyleStruct_Position) { - nsHTMLValue value; // width: pixel, percent if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) { aAttributes->GetAttribute(nsHTMLAtoms::width, value); - if (value.GetUnit() == eHTMLUnit_Pixel) + if (value.GetUnit() == eHTMLUnit_Pixel) { aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel); - else if (value.GetUnit() == eHTMLUnit_Percent) + } else if (value.GetUnit() == eHTMLUnit_Percent) { aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue()); + } } - // size: pixel if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) { - aAttributes->GetAttribute(nsHTMLAtoms::size, value); - if (value.GetUnit() == eHTMLUnit_Pixel) - aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel); + // size: pixel + if (noshade) { + // noshade case: size is set using the border + aData->mPositionData->mHeight.SetAutoValue(); + } else { + // normal case + // the height includes the top and bottom borders that are initially 1px. + // for size=1, html.css has a special case rule that makes this work by + // removing all but the top border. + aAttributes->GetAttribute(nsHTMLAtoms::size, value); + if (value.GetUnit() == eHTMLUnit_Pixel) { + aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel); + } // else use default value from html.css + } + } + } + else if (aData->mSID == eStyleStruct_Border && noshade) { // if not noshade, border styles are dealt with by html.css + // size: pixel + // if a size is set, use half of it per side, otherwise, use 1px per side + float sizePerSide; + PRBool allSides = PR_TRUE; + aAttributes->GetAttribute(nsHTMLAtoms::size, value); + if (value.GetUnit() == eHTMLUnit_Pixel) { + sizePerSide = (float)value.GetPixelValue() / 2.0f; + if (sizePerSide < 1.0f) { + // XXX When the pixel bug is fixed, all the special casing for + // subpixel borders should be removed. + // In the meantime, this makes http://www.microsoft.com/ look right. + sizePerSide = 1.0f; + allSides = PR_FALSE; + } + } else { + sizePerSide = 1.0f; // default to a 2px high line + } + nsCSSRect& borderWidth = aData->mMarginData->mBorderWidth; + if (borderWidth.mTop.GetUnit() == eCSSUnit_Null) { + borderWidth.mTop.SetFloatValue(sizePerSide, eCSSUnit_Pixel); + } + if (allSides) { + if (borderWidth.mRight.GetUnit() == eCSSUnit_Null) { + borderWidth.mRight.SetFloatValue(sizePerSide, eCSSUnit_Pixel); + } + if (borderWidth.mBottom.GetUnit() == eCSSUnit_Null) { + borderWidth.mBottom.SetFloatValue(sizePerSide, eCSSUnit_Pixel); + } + if (borderWidth.mLeft.GetUnit() == eCSSUnit_Null) { + borderWidth.mLeft.SetFloatValue(sizePerSide, eCSSUnit_Pixel); + } + } + + // if a color is set, set the border-style to 'solid' so that the + // 'color' property takes effect, otherwise, use '-moz-bg-solid'. + // (we got the color attribute earlier) + PRInt32 style = colorIsSet ? NS_STYLE_BORDER_STYLE_SOLID : + NS_STYLE_BORDER_STYLE_BG_SOLID; + + nsCSSRect& borderStyle = aData->mMarginData->mBorderStyle; + if (borderStyle.mTop.GetUnit() == eCSSUnit_Null) { + borderStyle.mTop.SetIntValue(style, eCSSUnit_Enumerated); + } + if (allSides) { + if (borderStyle.mRight.GetUnit() == eCSSUnit_Null) { + borderStyle.mRight.SetIntValue(style, eCSSUnit_Enumerated); + } + if (borderStyle.mBottom.GetUnit() == eCSSUnit_Null) { + borderStyle.mBottom.SetIntValue(style, eCSSUnit_Enumerated); + } + if (borderStyle.mLeft.GetUnit() == eCSSUnit_Null) { + borderStyle.mLeft.SetIntValue(style, eCSSUnit_Enumerated); + } + + // If it would be noticeable, set the border radius to + // 100% on all corners + nsCSSRect& borderRadius = aData->mMarginData->mBorderRadius; + if (borderRadius.mTop.GetUnit() == eCSSUnit_Null) { + borderRadius.mTop.SetPercentValue(1.0f); + } + if (borderRadius.mRight.GetUnit() == eCSSUnit_Null) { + borderRadius.mRight.SetPercentValue(1.0f); + } + if (borderRadius.mBottom.GetUnit() == eCSSUnit_Null) { + borderRadius.mBottom.SetPercentValue(1.0f); + } + if (borderRadius.mLeft.GetUnit() == eCSSUnit_Null) { + borderRadius.mLeft.SetPercentValue(1.0f); + } + } + } + else if (aData->mSID == eStyleStruct_Color) { + // color: a color + // (we got the color attribute earlier) + if (colorIsSet && + aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) { + aData->mColorData->mColor.SetColorValue(color.GetColorValue()); } } nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData); } -NS_IMETHODIMP -nsHTMLHRElement::GetAttributeChangeHint(const nsIAtom* aAttribute, - PRInt32 aModType, - nsChangeHint& aHint) const -{ - nsresult rv = - nsGenericHTMLLeafElement::GetAttributeChangeHint(aAttribute, - aModType, aHint); - if (aAttribute == nsHTMLAtoms::noshade) { - NS_UpdateHint(aHint, NS_STYLE_HINT_VISUAL); - } - return rv; -} - NS_IMETHODIMP_(PRBool) nsHTMLHRElement::HasAttributeDependentStyle(const nsIAtom* aAttribute) const { @@ -292,6 +396,8 @@ nsHTMLHRElement::HasAttributeDependentStyle(const nsIAtom* aAttribute) const { &nsHTMLAtoms::align }, { &nsHTMLAtoms::width }, { &nsHTMLAtoms::size }, + { &nsHTMLAtoms::color }, + { &nsHTMLAtoms::noshade }, { nsnull }, }; diff --git a/mozilla/content/shared/public/nsCSSKeywordList.h b/mozilla/content/shared/public/nsCSSKeywordList.h index e7297bc7c90..a968c35ea29 100644 --- a/mozilla/content/shared/public/nsCSSKeywordList.h +++ b/mozilla/content/shared/public/nsCSSKeywordList.h @@ -73,6 +73,7 @@ CSS_KEY(-moz-arabic-indic, _moz_arabic_indic) CSS_KEY(-moz-bengali, _moz_bengali) CSS_KEY(-moz-bg-inset, _moz_bg_inset) CSS_KEY(-moz-bg-outset, _moz_bg_outset) +CSS_KEY(-moz-bg-solid, _moz_bg_solid) CSS_KEY(-moz-box, _moz_box) CSS_KEY(-moz-bulletinboard, _moz_bulletinboard) CSS_KEY(-moz-button, _moz_button) diff --git a/mozilla/content/shared/public/nsLayoutAtomList.h b/mozilla/content/shared/public/nsLayoutAtomList.h index fcbe47738eb..2bb4ca4aef4 100644 --- a/mozilla/content/shared/public/nsLayoutAtomList.h +++ b/mozilla/content/shared/public/nsLayoutAtomList.h @@ -98,7 +98,6 @@ LAYOUT_ATOM(brFrame, "BRFrame") LAYOUT_ATOM(bulletFrame, "BulletFrame") LAYOUT_ATOM(fieldSetFrame, "FieldSetFrame") LAYOUT_ATOM(gfxButtonControlFrame, "gfxButtonControlFrame") -LAYOUT_ATOM(hrFrame, "HRFrame") LAYOUT_ATOM(htmlFrameInnerFrame, "htmlFrameInnerFrame") LAYOUT_ATOM(htmlFrameOuterFrame, "htmlFrameOuterFrame") LAYOUT_ATOM(imageFrame, "ImageFrame") diff --git a/mozilla/content/shared/src/nsCSSProps.cpp b/mozilla/content/shared/src/nsCSSProps.cpp index 7a9eeb5d44d..6f012ef879b 100644 --- a/mozilla/content/shared/src/nsCSSProps.cpp +++ b/mozilla/content/shared/src/nsCSSProps.cpp @@ -290,6 +290,7 @@ const PRInt32 nsCSSProps::kBorderStyleKTable[] = { eCSSKeyword_outset, NS_STYLE_BORDER_STYLE_OUTSET, eCSSKeyword__moz_bg_inset, NS_STYLE_BORDER_STYLE_BG_INSET, eCSSKeyword__moz_bg_outset, NS_STYLE_BORDER_STYLE_BG_OUTSET, + eCSSKeyword__moz_bg_solid, NS_STYLE_BORDER_STYLE_BG_SOLID, -1,-1 }; diff --git a/mozilla/dom/public/idl/html/Makefile.in b/mozilla/dom/public/idl/html/Makefile.in index a42083bc3c5..0114e7711c2 100644 --- a/mozilla/dom/public/idl/html/Makefile.in +++ b/mozilla/dom/public/idl/html/Makefile.in @@ -99,6 +99,7 @@ XPIDLSRCS = \ nsIDOMNSHTMLFormControlList.idl \ nsIDOMNSHTMLFormElement.idl \ nsIDOMNSHTMLFrameElement.idl \ + nsIDOMNSHTMLHRElement.idl \ nsIDOMNSHTMLImageElement.idl \ nsIDOMNSHTMLInputElement.idl \ nsIDOMNSHTMLOptionCollectn.idl \ diff --git a/mozilla/dom/public/idl/html/nsIDOMNSHTMLHRElement.idl b/mozilla/dom/public/idl/html/nsIDOMNSHTMLHRElement.idl new file mode 100644 index 00000000000..5a06ce03fc4 --- /dev/null +++ b/mozilla/dom/public/idl/html/nsIDOMNSHTMLHRElement.idl @@ -0,0 +1,50 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Ian Hickson . + * Portions created by the Initial Developer are Copyright (C) 2003 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" + +/** + * The nsIDOMNSHTMLHRElement interface contains extensions to the + * interface for [X]HTML hr elements, for compatibility with IE. + */ + +[scriptable, uuid(19b5879f-c125-447c-aaaf-719de3ef221a)] +interface nsIDOMNSHTMLHRElement : nsISupports +{ + attribute DOMString color; +}; diff --git a/mozilla/dom/src/base/nsDOMClassInfo.cpp b/mozilla/dom/src/base/nsDOMClassInfo.cpp index 68b53b0e3c2..4deb1e089d0 100644 --- a/mozilla/dom/src/base/nsDOMClassInfo.cpp +++ b/mozilla/dom/src/base/nsDOMClassInfo.cpp @@ -220,6 +220,7 @@ #include "nsIDOMHTMLFrameSetElement.h" #include "nsIDOMNSHTMLFrameElement.h" #include "nsIDOMHTMLHRElement.h" +#include "nsIDOMNSHTMLHRElement.h" #include "nsIDOMHTMLHeadElement.h" #include "nsIDOMHTMLHeadingElement.h" #include "nsIDOMHTMLHtmlElement.h" @@ -1606,6 +1607,7 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_BEGIN(HTMLHRElement, nsIDOMHTMLHRElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLHRElement) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLHRElement) DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES DOM_CLASSINFO_MAP_END diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index cbc141ea87c..3805c460902 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -4582,13 +4582,6 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsIPresShell* aPresShell, // instead... rv = NS_NewImageFrame(aPresShell, &newFrame); } - else if (nsHTMLAtoms::hr == aTag) { - isReplaced = PR_TRUE; - if (!aState.mPseudoFrames.IsEmpty()) { // process pending pseudo frames - ProcessPseudoFrames(aPresContext, aState.mPseudoFrames, aFrameItems); - } - rv = NS_NewHRFrame(aPresShell, &newFrame); - } else if (nsHTMLAtoms::br == aTag) { if (!aState.mPseudoFrames.IsEmpty()) { // process pending pseudo frames ProcessPseudoFrames(aPresContext, aState.mPseudoFrames, aFrameItems); diff --git a/mozilla/layout/base/nsCSSRendering.cpp b/mozilla/layout/base/nsCSSRendering.cpp index d14c99eb1aa..7b4a76b0a64 100644 --- a/mozilla/layout/base/nsCSSRendering.cpp +++ b/mozilla/layout/base/nsCSSRendering.cpp @@ -309,11 +309,10 @@ nscolor nsCSSRendering::MakeBevelColor(PRIntn whichSide, PRUint8 style, else NS_Get3DColors(colors, aBackgroundColor); - if ((style == NS_STYLE_BORDER_STYLE_BG_OUTSET) || - (style == NS_STYLE_BORDER_STYLE_OUTSET) || + (style == NS_STYLE_BORDER_STYLE_OUTSET) || (style == NS_STYLE_BORDER_STYLE_RIDGE)) { - // Flip colors for these two border style + // Flip colors for these three border styles switch (whichSide) { case NS_SIDE_BOTTOM: whichSide = NS_SIDE_TOP; break; case NS_SIDE_RIGHT: whichSide = NS_SIDE_LEFT; break; @@ -533,8 +532,8 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, ((theStyle == NS_STYLE_BORDER_STYLE_RIDGE) ? NS_STYLE_BORDER_STYLE_GROOVE : NS_STYLE_BORDER_STYLE_RIDGE), - aBackgroundColor, theColor, - PR_TRUE)); + aBackgroundColor, theColor, + PR_TRUE)); if (2 == np) { //aContext.DrawLine (theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y); DrawLine (aContext, theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y, aGap); @@ -545,7 +544,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_OUTSIDE, 0.5f, twipsPerPixel); aContext.SetColor ( MakeBevelColor (whichSide, theStyle, aBackgroundColor, - theColor, PR_TRUE)); + theColor, PR_TRUE)); if (2 == np) { //aContext.DrawLine (theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y); DrawLine (aContext, theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y, aGap); @@ -568,6 +567,19 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, } break; + case NS_STYLE_BORDER_STYLE_BG_SOLID: + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, aSkipSides, + BORDER_FULL, 1.0f, twipsPerPixel); + nscolor colors[2]; + NS_Get3DColors(colors, aBackgroundColor); + aContext.SetColor (colors[0]); + if (2 == np) { + DrawLine (aContext, theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y, aGap); + } else { + FillPolygon (aContext, theSide, np, aGap); + } + break; + case NS_STYLE_BORDER_STYLE_DOUBLE: np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_INSIDE, 0.333333f, twipsPerPixel); @@ -595,7 +607,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_FULL, 1.0f, twipsPerPixel); aContext.SetColor ( MakeBevelColor (whichSide, theStyle, aBackgroundColor, - theColor, PR_FALSE)); + theColor, PR_FALSE)); if (2 == np) { //aContext.DrawLine (theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y); DrawLine (aContext, theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y, aGap); @@ -606,10 +618,10 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, break; case NS_STYLE_BORDER_STYLE_OUTSET: case NS_STYLE_BORDER_STYLE_INSET: - np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_FULL, 1.0f, twipsPerPixel); aContext.SetColor ( MakeBevelColor (whichSide, theStyle, aBackgroundColor, - theColor, PR_TRUE)); + theColor, PR_TRUE)); if (2 == np) { //aContext.DrawLine (theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y); DrawLine (aContext, theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y, aGap); @@ -858,7 +870,7 @@ PRBool skippedSide = PR_FALSE; /** --------------------------------------------------- * See documentation in nsCSSRendering.h - * @update 10/22/99 dwc + * @update 10/22/99 dwc */ void nsCSSRendering::DrawDashedSides(PRIntn startSide, nsIRenderingContext& aContext, @@ -1332,7 +1344,7 @@ PRIntn whichSide=0; width = aBounds.width - aBorderEdges->mMaxBorderWidth.right; width += segment->mWidth; } - else + else { width = aBounds.width; } @@ -1357,7 +1369,7 @@ PRIntn whichSide=0; neighborBorderEdges = segment->mInsideNeighbor; neighborEdgeCount=0; } - nsBorderEdge * neighborRight = (nsBorderEdge *)(segment->mInsideNeighbor->mEdges[NS_SIDE_RIGHT].ElementAt(neighborEdgeCount)); + nsBorderEdge * neighborRight = (nsBorderEdge *)(segment->mInsideNeighbor->mEdges[NS_SIDE_RIGHT].ElementAt(neighborEdgeCount)); totalLength = neighborRight->mLength; } dashRect.width = borderOutside.XMost() - borderInside.XMost(); @@ -1366,7 +1378,7 @@ PRIntn whichSide=0; dashRect.y = borderOutside.y + (totalLength/2) - dashRect.height; if ((PR_TRUE==aBorderEdges->mOutsideEdge) && (0!=i)) dashRect.y -= topEdge->mWidth; - currRect = dashRect; + currRect = dashRect; // draw the top half while (currRect.YMost() > borderInside.y) { @@ -1626,7 +1638,8 @@ nsresult GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,nsIFrame *aFra // helper macro to determine if the borderstyle 'a' is a MOZ-BG-XXX style #define MOZ_BG_BORDER(a)\ -((a==NS_STYLE_BORDER_STYLE_BG_INSET) || (a==NS_STYLE_BORDER_STYLE_BG_OUTSET)) +((a==NS_STYLE_BORDER_STYLE_BG_INSET) || (a==NS_STYLE_BORDER_STYLE_BG_OUTSET)\ + || (a==NS_STYLE_BORDER_STYLE_BG_SOLID)) static PRBool GetBorderColor(const nsStyleColor* aColor, const nsStyleBorder& aBorder, PRUint8 aSide, nscolor& aColorVal, @@ -1687,13 +1700,15 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext, const nsStyleBackground* bgColor = nsCSSRendering::FindNonTransparentBackground(aStyleContext, compatMode == eCompatibility_NavQuirks ? PR_TRUE : PR_FALSE); + // mozBGColor is used instead of bgColor when the display type is BG_INSET or BG_OUTSET - // AND, in quirk mode, it is set to the BODY element's background color instead of the nearest - // ancestor's background color. + // or BG_SOLID, and, in quirk mode, it is set to the BODY element's background color + // instead of the nearest ancestor's background color. const nsStyleBackground* mozBGColor = bgColor; // now check if we are in Quirks mode and have a border style of BG_INSET or OUTSET - // - if so we use the bgColor from the HTML element instead of the nearest ancestor + // or BG_SOLID - if so we use the bgColor from the HTML element instead of the + // nearest ancestor if (compatMode == eCompatibility_NavQuirks) { PRBool bNeedBodyBGColor = PR_FALSE; if (aStyleContext) { @@ -3421,7 +3436,7 @@ nsCSSRendering::PaintBackgroundColor(nsIPresContext* aPresContext, /** --------------------------------------------------- * See documentation in nsCSSRendering.h - * @update 3/26/99 dwc + * @update 3/26/99 dwc */ void nsCSSRendering::PaintRoundedBackground(nsIPresContext* aPresContext, @@ -3531,7 +3546,7 @@ nsCSSRendering::PaintRoundedBackground(nsIPresContext* aPresContext, /** --------------------------------------------------- * See documentation in nsCSSRendering.h - * @update 3/26/99 dwc + * @update 3/26/99 dwc */ void nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext, @@ -3676,7 +3691,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext, /** --------------------------------------------------- * See documentation in nsCSSRendering.h - * @update 3/26/99 dwc + * @update 3/26/99 dwc */ void nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderingContext, @@ -3739,13 +3754,23 @@ nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderin switch (border_Style){ case NS_STYLE_BORDER_STYLE_OUTSET: case NS_STYLE_BORDER_STYLE_INSET: + case NS_STYLE_BORDER_STYLE_BG_OUTSET: + case NS_STYLE_BORDER_STYLE_BG_INSET: + case NS_STYLE_BORDER_STYLE_BG_SOLID: { - const nsStyleBackground* bgColor = nsCSSRendering::FindNonTransparentBackground(aStyleContext); - aRenderingContext.SetColor ( MakeBevelColor (aSide, border_Style, bgColor->mBackgroundColor,sideColor, PR_TRUE)); + const nsStyleBackground* bgColor = nsCSSRendering::FindNonTransparentBackground(aStyleContext); + if (border_Style == NS_STYLE_BORDER_STYLE_BG_SOLID) { + nscolor colors[2]; + NS_Get3DColors(colors, bgColor->mBackgroundColor); + aRenderingContext.SetColor(colors[0]); + } else { + aRenderingContext.SetColor(MakeBevelColor(aSide, border_Style, bgColor->mBackgroundColor, sideColor, + !MOZ_BG_BORDER(border_Style)); + } } case NS_STYLE_BORDER_STYLE_DOTTED: case NS_STYLE_BORDER_STYLE_DASHED: - // break; This is here until dotted and dashed are supported. It is ok to have + // break; XXX This is here until dotted and dashed are supported. It is ok to have // dotted and dashed render in solid until this style is supported. This code should // be moved when it is supported so that the above outset and inset will fall into the // solid code below.... @@ -3828,7 +3853,7 @@ nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderin /** --------------------------------------------------- * See documentation in nsCSSRendering.h - * @update 3/26/99 dwc + * @update 3/26/99 dwc */ void RoundedRect::CalcInsetCurves(QBCurve &aULCurve,QBCurve &aURCurve,QBCurve &aLLCurve,QBCurve &aLRCurve,nsMargin &aBorder) @@ -3907,7 +3932,7 @@ PRInt16 adjust=0; /** --------------------------------------------------- * See documentation in nsCSSRendering.h - * @update 4/13/99 dwc + * @update 4/13/99 dwc */ void RoundedRect::Set(nscoord aLeft,nscoord aTop,PRInt32 aWidth,PRInt32 aHeight,PRInt16 aRadius[4],PRInt16 aNumTwipPerPix) @@ -3965,7 +3990,7 @@ RoundedRect::Set(nscoord aLeft,nscoord aTop,PRInt32 aWidth,PRInt32 aHeight,PRIn /** --------------------------------------------------- * See documentation in nsCSSRendering.h - * @update 4/13/99 dwc + * @update 4/13/99 dwc */ void RoundedRect::GetRoundedBorders(QBCurve &aULCurve,QBCurve &aURCurve,QBCurve &aLLCurve,QBCurve &aLRCurve) @@ -3993,7 +4018,7 @@ RoundedRect::GetRoundedBorders(QBCurve &aULCurve,QBCurve &aURCurve,QBCurve &aLLC /** --------------------------------------------------- * Given a qbezier path, convert it into a polygon path - * @update 3/26/99 dwc + * @update 3/26/99 dwc * @param aPoints -- an array of points to use for the path * @param aPolyPath -- an array of points containing the flattened polygon to use * @param aCurIndex -- the index that points to the last element of the array @@ -4056,7 +4081,7 @@ GetPath(nsFloatPoint aPoints[],nsPoint aPolyPath[],PRInt32 *aCurIndex,ePathTypes /** --------------------------------------------------- * See documentation in nsCSSRendering.h - * @update 4/13/99 dwc + * @update 4/13/99 dwc */ void QBCurve::SubDivide(nsIRenderingContext *aRenderingContext,nsPoint aPointArray[],PRInt32 *aCurIndex) @@ -4065,19 +4090,19 @@ QBCurve curve1,curve2; float fx,fy,smag; // divide the curve into 2 pieces - MidPointDivide(&curve1,&curve2); - - fx = (float)fabs(curve1.mAnc2.x - this->mCon.x); - fy = (float)fabs(curve1.mAnc2.y - this->mCon.y); + MidPointDivide(&curve1,&curve2); - //smag = fx+fy-(PR_MIN(fx,fy)>>1); + fx = (float)fabs(curve1.mAnc2.x - this->mCon.x); + fy = (float)fabs(curve1.mAnc2.y - this->mCon.y); + + //smag = fx+fy-(PR_MIN(fx,fy)>>1); smag = fx*fx + fy*fy; - if (smag>1){ - // split the curve again + if (smag>1){ + // split the curve again curve1.SubDivide(aRenderingContext,aPointArray,aCurIndex); curve2.SubDivide(aRenderingContext,aPointArray,aCurIndex); - }else{ + }else{ if(aPointArray ) { // save the points for further processing aPointArray[*aCurIndex].x = (nscoord)curve1.mAnc2.x; @@ -4087,7 +4112,7 @@ float fx,fy,smag; aPointArray[*aCurIndex].y = (nscoord)curve2.mAnc2.y; (*aCurIndex)++; }else{ - // draw the curve + // draw the curve nsTransform2D *aTransform; aRenderingContext->GetCurrentTransform(aTransform); @@ -4095,18 +4120,18 @@ float fx,fy,smag; aRenderingContext->DrawLine((nscoord)curve1.mAnc1.x,(nscoord)curve1.mAnc1.y,(nscoord)curve1.mAnc2.x,(nscoord)curve1.mAnc2.y); aRenderingContext->DrawLine((nscoord)curve1.mAnc2.x,(nscoord)curve1.mAnc2.y,(nscoord)curve2.mAnc2.x,(nscoord)curve2.mAnc2.y); } - } + } } /** --------------------------------------------------- * See documentation in nsCSSRendering.h - * @update 4/13/99 dwc + * @update 4/13/99 dwc */ void QBCurve::MidPointDivide(QBCurve *A,QBCurve *B) { -float c1x,c1y,c2x,c2y; -nsFloatPoint a1; + float c1x,c1y,c2x,c2y; + nsFloatPoint a1; c1x = (mAnc1.x+mCon.x)/2.0f; c1y = (mAnc1.y+mCon.y)/2.0f; @@ -4114,7 +4139,7 @@ nsFloatPoint a1; c2y = (mAnc2.y+mCon.y)/2.0f; a1.x = (c1x + c2x)/2.0f; - a1.y = (c1y + c2y)/2.0f; + a1.y = (c1y + c2y)/2.0f; // put the math into our 2 new curves A->mAnc1 = this->mAnc1; @@ -4486,6 +4511,7 @@ nsCSSRendering::DrawTableBorderSegment(nsIRenderingContext& aContext, break; } // else fall through to solid + case NS_STYLE_BORDER_STYLE_BG_SOLID: case NS_STYLE_BORDER_STYLE_SOLID: DrawSolidBorderSegment(aContext, aBorder, twipsPerPixel, aStartBevelSide, aStartBevelOffset, aEndBevelSide, aEndBevelOffset); diff --git a/mozilla/layout/base/nsLayoutAtomList.h b/mozilla/layout/base/nsLayoutAtomList.h index fcbe47738eb..2bb4ca4aef4 100644 --- a/mozilla/layout/base/nsLayoutAtomList.h +++ b/mozilla/layout/base/nsLayoutAtomList.h @@ -98,7 +98,6 @@ LAYOUT_ATOM(brFrame, "BRFrame") LAYOUT_ATOM(bulletFrame, "BulletFrame") LAYOUT_ATOM(fieldSetFrame, "FieldSetFrame") LAYOUT_ATOM(gfxButtonControlFrame, "gfxButtonControlFrame") -LAYOUT_ATOM(hrFrame, "HRFrame") LAYOUT_ATOM(htmlFrameInnerFrame, "htmlFrameInnerFrame") LAYOUT_ATOM(htmlFrameOuterFrame, "htmlFrameOuterFrame") LAYOUT_ATOM(imageFrame, "ImageFrame") diff --git a/mozilla/layout/base/nsStyleConsts.h b/mozilla/layout/base/nsStyleConsts.h index 674bce8fe20..5f72fc0984b 100644 --- a/mozilla/layout/base/nsStyleConsts.h +++ b/mozilla/layout/base/nsStyleConsts.h @@ -253,6 +253,7 @@ #define NS_STYLE_BORDER_STYLE_HIDDEN 10 #define NS_STYLE_BORDER_STYLE_BG_INSET 11 #define NS_STYLE_BORDER_STYLE_BG_OUTSET 12 +#define NS_STYLE_BORDER_STYLE_BG_SOLID 13 // a bit ORed onto the style for table border collapsing indicating that the style was // derived from a table with its rules attribute set #define NS_STYLE_BORDER_STYLE_RULES_MASK 0x10 diff --git a/mozilla/layout/base/public/nsStyleConsts.h b/mozilla/layout/base/public/nsStyleConsts.h index 674bce8fe20..5f72fc0984b 100644 --- a/mozilla/layout/base/public/nsStyleConsts.h +++ b/mozilla/layout/base/public/nsStyleConsts.h @@ -253,6 +253,7 @@ #define NS_STYLE_BORDER_STYLE_HIDDEN 10 #define NS_STYLE_BORDER_STYLE_BG_INSET 11 #define NS_STYLE_BORDER_STYLE_BG_OUTSET 12 +#define NS_STYLE_BORDER_STYLE_BG_SOLID 13 // a bit ORed onto the style for table border collapsing indicating that the style was // derived from a table with its rules attribute set #define NS_STYLE_BORDER_STYLE_RULES_MASK 0x10 diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 19bafd8ab55..2e523534fd6 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -5213,7 +5213,6 @@ void DR_State::InitFrameTypeTable() AddFrameTypeInfo(nsLayoutAtoms::brFrame, "br", "br"); AddFrameTypeInfo(nsLayoutAtoms::bulletFrame, "bullet", "bullet"); AddFrameTypeInfo(nsLayoutAtoms::gfxButtonControlFrame, "button", "gfxButtonControl"); - AddFrameTypeInfo(nsLayoutAtoms::hrFrame, "hr", "hr"); AddFrameTypeInfo(nsLayoutAtoms::htmlFrameInnerFrame, "frameI", "htmlFrameInner"); AddFrameTypeInfo(nsLayoutAtoms::htmlFrameOuterFrame, "frameO", "htmlFrameOuter"); AddFrameTypeInfo(nsLayoutAtoms::imageFrame, "img", "image"); diff --git a/mozilla/layout/generic/nsHTMLParts.h b/mozilla/layout/generic/nsHTMLParts.h index 341273a1db7..c585b630fc0 100644 --- a/mozilla/layout/generic/nsHTMLParts.h +++ b/mozilla/layout/generic/nsHTMLParts.h @@ -153,8 +153,6 @@ NS_NewBRFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); nsresult NS_NewCommentFrame(nsIPresShell* aPresShell, nsIFrame** aFrameResult); -nsresult -NS_NewHRFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); // and