patch for 'transparent'
David Hyatt
hyatt at apple.com
Mon Nov 3 19:30:45 CET 2003
Index: ChangeLog
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/ChangeLog,v
retrieving revision 1.2182
diff -u -p -r1.2182 ChangeLog
--- ChangeLog 2003/11/03 08:20:05 1.2182
+++ ChangeLog 2003/11/03 18:05:23
@@ -1,3 +1,32 @@
+2003-11-03 David Hyatt <hyatt at apple.com>
+
+ Fix for 3471609, 'transparent' should be an acceptable named color value instead of a special
+ keyword used only by background/border.
+
+ Reviewed by NOBODY (OOPS!).
+
+ * khtml/css/cssparser.cpp:
+ (CSSParser::parseValue):
+ * khtml/css/cssstyleselector.cpp:
+ (khtml::):
+ (khtml::CSSStyleSelector::applyRule):
+ * khtml/css/cssvalues.c:
+ * khtml/css/cssvalues.h:
+ * khtml/css/cssvalues.in:
+ * khtml/rendering/render_box.cpp:
+ (RenderBox::paintBackgroundExtended):
+ * khtml/rendering/render_object.cpp:
+ (RenderObject::setStyle):
+ * khtml/rendering/render_style.h:
+ (khtml::BorderValue::BorderValue):
+ (khtml::BorderValue::isTransparent):
+ (khtml::BorderValue::operator==):
+ (khtml::CollapsedBorderValue::isTransparent):
+ (khtml::RenderStyle::setBorderLeftColor):
+ (khtml::RenderStyle::setBorderRightColor):
+ (khtml::RenderStyle::setBorderTopColor):
+ (khtml::RenderStyle::setBorderBottomColor):
+
2003-11-02 Maciej Stachowiak <mjs at apple.com>
Reviewed by Darin.
Index: khtml/css/cssparser.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/css/cssparser.cpp,v
retrieving revision 1.48
diff -u -p -r1.48 khtml/css/cssparser.cpp
--- khtml/css/cssparser.cpp 2003/11/03 05:53:26 1.48
+++ khtml/css/cssparser.cpp 2003/11/03 18:05:28
@@ -730,20 +730,10 @@ bool CSSParser::parseValue( int propId,
}
/* nobreak */
case CSS_PROP_BACKGROUND_COLOR: // <color> | transparent | inherit
- if ( propId == CSS_PROP_BACKGROUND_COLOR && id == CSS_VAL_TRANSPARENT ) {
- valid_primitive = true;
- break;
- }
- /* nobreak */
case CSS_PROP_BORDER_TOP_COLOR: // <color> | transparent | inherit
case CSS_PROP_BORDER_RIGHT_COLOR: // <color> | transparent | inherit
case CSS_PROP_BORDER_BOTTOM_COLOR: // <color> | transparent | inherit
case CSS_PROP_BORDER_LEFT_COLOR: // <color> | transparent | inherit
- if (id == CSS_VAL_TRANSPARENT) {
- valid_primitive = true;
- break;
- }
- /* fall through */
case CSS_PROP_COLOR: // <color> | inherit
case CSS_PROP_TEXT_DECORATION_COLOR:
if (id == CSS_VAL__KHTML_TEXT)
Index: khtml/css/cssstyleselector.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/css/cssstyleselector.cpp,v
retrieving revision 1.108
diff -u -p -r1.108 khtml/css/cssstyleselector.cpp
--- khtml/css/cssstyleselector.cpp 2003/11/03 05:53:27 1.108
+++ khtml/css/cssstyleselector.cpp 2003/11/03 18:05:33
@@ -1469,6 +1469,7 @@ static const colorMap cmap[] = {
{ CSS_VAL_WHITE, 0xFFFFFFFF },
{ CSS_VAL_YELLOW, 0xFFFFFF00 },
{ CSS_VAL_INVERT, invertedColor },
+ { CSS_VAL_TRANSPARENT, transparentColor },
{ CSS_VAL_GREY, 0xff808080 },
{ 0, 0 }
};
@@ -2321,7 +2322,6 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_SCROLLBAR_ARROW_COLOR:
{
- bool transparentBorder = false;
QColor col;
if(value->cssValueType() == CSSValue::CSS_INHERIT)
{
@@ -2331,19 +2331,15 @@ void CSSStyleSelector::applyRule( int id
col = parentStyle->backgroundColor(); break;
case CSS_PROP_BORDER_TOP_COLOR:
col = parentStyle->borderTopColor();
- transparentBorder = parentStyle->borderTopIsTransparent();
break;
case CSS_PROP_BORDER_RIGHT_COLOR:
col = parentStyle->borderRightColor();
- transparentBorder = parentStyle->borderRightIsTransparent();
break;
case CSS_PROP_BORDER_BOTTOM_COLOR:
col = parentStyle->borderBottomColor();
- transparentBorder = parentStyle->borderBottomIsTransparent();
break;
case CSS_PROP_BORDER_LEFT_COLOR:
col = parentStyle->borderLeftColor();
- transparentBorder = parentStyle->borderLeftIsTransparent();
break;
case CSS_PROP_COLOR:
col = parentStyle->color(); break;
@@ -2359,10 +2355,6 @@ void CSSStyleSelector::applyRule( int id
if ( ident ) {
if ( ident == CSS_VAL__KHTML_TEXT )
col = element->getDocument()->textColor();
- else if ( ident == CSS_VAL_TRANSPARENT ) {
- col = QColor();
- transparentBorder = true;
- }
else
col = colorForCSSValue( ident );
} else if ( primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_RGBCOLOR )
@@ -2377,13 +2369,13 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_BACKGROUND_COLOR:
style->setBackgroundColor(col); break;
case CSS_PROP_BORDER_TOP_COLOR:
- style->setBorderTopColor(col, transparentBorder); break;
+ style->setBorderTopColor(col); break;
case CSS_PROP_BORDER_RIGHT_COLOR:
- style->setBorderRightColor(col, transparentBorder); break;
+ style->setBorderRightColor(col); break;
case CSS_PROP_BORDER_BOTTOM_COLOR:
- style->setBorderBottomColor(col, transparentBorder); break;
+ style->setBorderBottomColor(col); break;
case CSS_PROP_BORDER_LEFT_COLOR:
- style->setBorderLeftColor(col, transparentBorder); break;
+ style->setBorderLeftColor(col); break;
case CSS_PROP_COLOR:
style->setColor(col); break;
case CSS_PROP_OUTLINE_COLOR:
Index: khtml/css/cssvalues.in
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/css/cssvalues.in,v
retrieving revision 1.13
diff -u -p -r1.13 khtml/css/cssvalues.in
--- khtml/css/cssvalues.in 2003/10/30 23:13:08 1.13
+++ khtml/css/cssvalues.in 2003/11/03 18:05:35
@@ -100,11 +100,6 @@ monospace
-khtml-body
#
#
-# CSS_PROP_BACKGROUND_COLOR:
-#
-transparent
-#
-#
# CSS_PROP_*_COLOR
#
aqua
@@ -124,6 +119,7 @@ silver
teal
white
yellow
+transparent
activeborder
activecaption
appworkspace
Index: khtml/rendering/render_box.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_box.cpp,v
retrieving revision 1.92
diff -u -p -r1.92 khtml/rendering/render_box.cpp
--- khtml/rendering/render_box.cpp 2003/11/03 05:53:27 1.92
+++ khtml/rendering/render_box.cpp 2003/11/03 18:05:37
@@ -311,7 +311,7 @@ void RenderBox::paintBackgroundExtended(
int _tx, int _ty, int w, int h,
int bleft, int bright)
{
- if(c.isValid())
+ if (c.isValid() && qAlpha(c.rgb()) > 0)
p->fillRect(_tx, clipy, w, cliph, c);
// no progressive loading of the background image
if(bg && bg->pixmap_size() == bg->valid_rect().size() && !bg->isTransparent() && !bg->isErrorImage()) {
Index: khtml/rendering/render_object.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_object.cpp,v
retrieving revision 1.112
diff -u -p -r1.112 khtml/rendering/render_object.cpp
--- khtml/rendering/render_object.cpp 2003/11/03 05:53:27 1.112
+++ khtml/rendering/render_object.cpp 2003/11/03 18:05:39
@@ -1290,7 +1290,8 @@ void RenderObject::setStyle(RenderStyle
if(nb) nb->ref(this);
}
- setShouldPaintBackgroundOrBorder(m_style->backgroundColor().isValid() ||
+ setShouldPaintBackgroundOrBorder((m_style->backgroundColor().isValid() &&
+ qAlpha(m_style->backgroundColor().rgb()) > 0) ||
m_style->hasBorder() || nb );
if (affectsParentBlock)
Index: khtml/rendering/render_style.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_style.h,v
retrieving revision 1.41
diff -u -p -r1.41 khtml/rendering/render_style.h
--- khtml/rendering/render_style.h 2003/11/03 05:53:27 1.41
+++ khtml/rendering/render_style.h 2003/11/03 18:05:41
@@ -201,13 +201,11 @@ public:
{
width = 3; // medium is default value
style = BNONE;
- transparent = false;
}
QColor color;
- unsigned short width : 11;
+ unsigned short width : 12;
EBorderStyle style : 4;
- bool transparent : 1;
-
+
bool nonZero() const
{
// rikkus: workaround for gcc 2.95.3
@@ -215,12 +213,12 @@ public:
}
bool isTransparent() const {
- return transparent;
+ return color.isValid() && qAlpha(color.rgb()) == 0;
}
bool operator==(const BorderValue& o) const
{
- return width==o.width && style==o.style && color==o.color && transparent==o.transparent;
+ return width==o.width && style==o.style && color==o.color;
}
};
@@ -247,7 +245,7 @@ struct CollapsedBorderValue
EBorderStyle style() const { return border ? border->style : BHIDDEN; }
bool exists() const { return border; }
QColor color() const { return border ? border->color : QColor(); }
- bool isTransparent() const { return border ? border->transparent : true; }
+ bool isTransparent() const { return border ? border->isTransparent() : true; }
bool operator==(const CollapsedBorderValue& o) const
{
@@ -1045,32 +1043,16 @@ public:
void setBorderLeftWidth(unsigned short v) { SET_VAR(surround,border.left.width,v) }
void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround,border.left.style,v) }
- void setBorderLeftColor(const QColor & v, bool t=false)
- {
- SET_VAR(surround,border.left.color,v);
- SET_VAR(surround,border.left.transparent,t)
- }
+ void setBorderLeftColor(const QColor & v) { SET_VAR(surround,border.left.color,v) }
void setBorderRightWidth(unsigned short v) { SET_VAR(surround,border.right.width,v) }
void setBorderRightStyle(EBorderStyle v) { SET_VAR(surround,border.right.style,v) }
- void setBorderRightColor(const QColor & v, bool t=false)
- {
- SET_VAR(surround,border.right.color,v);
- SET_VAR(surround,border.right.transparent,t)
- }
+ void setBorderRightColor(const QColor & v) { SET_VAR(surround,border.right.color,v) }
void setBorderTopWidth(unsigned short v) { SET_VAR(surround,border.top.width,v) }
void setBorderTopStyle(EBorderStyle v) { SET_VAR(surround,border.top.style,v) }
- void setBorderTopColor(const QColor & v, bool t=false)
- {
- SET_VAR(surround,border.top.color,v);
- SET_VAR(surround,border.top.transparent,t)
- }
+ void setBorderTopColor(const QColor & v) { SET_VAR(surround,border.top.color,v) }
void setBorderBottomWidth(unsigned short v) { SET_VAR(surround,border.bottom.width,v) }
void setBorderBottomStyle(EBorderStyle v) { SET_VAR(surround,border.bottom.style,v) }
- void setBorderBottomColor(const QColor & v, bool t=false)
- {
- SET_VAR(surround,border.bottom.color,v);
- SET_VAR(surround,border.bottom.transparent,t)
- }
+ void setBorderBottomColor(const QColor & v) { SET_VAR(surround,border.bottom.color,v) }
void setOutlineWidth(unsigned short v) { SET_VAR(background,outline.width,v) }
void setOutlineStyle(EBorderStyle v) { SET_VAR(background,outline.style,v) }
void setOutlineColor(const QColor & v) { SET_VAR(background,outline.color,v) }
-------------- next part --------------
Just treat it as per CSS3, as one of the valid named colors.
dave
More information about the Khtml-devel
mailing list