Commit bf9fde34 authored by Maks Orlovich's avatar Maks Orlovich

Merge 3.5 changes up to 590814,

There are some regressions, but they seem not too severe 
and I'd rather not hold off on this for too long..

svn path=/trunk/KDE/kdelibs/; revision=591211
parent 52d2aba4
2006-06-28 Germain Garand <germain@ebooksfrance.org>
make updating of addRule/removeRule/insertRule work
cf. http://www.quirksmode.org/dom/w3c_css.html#change
* css/css_stylesheetimpl.cpp
(insertRule/deleteRule): shallow update of styleselector.
* xml/dom_docimpl.{h,cpp}
(updateStyleSelector): new boolean argument for shallow recalculation, when all sheets are known.
(DocumentImpl::recalcStyleSelector): split.
(DocumentImpl::rebuildStyleSelector): new from split. Recreate styleselector with known sheets.
2006-06-27 Germain Garand <germain@ebooksfrance.org>
. Correct drawing of borders on iframes and objects (#118277/#56109)
. Frameborder attribute for iframes (http://www.w3.org/TR/html401/present/frames.html#adef-frameborder)
. Fix widget counter-mask not being updated in time, thus sometimes missing a repaint (e.g: http://lequipe.fr)
* html/html_baseimpl.{h,cpp} (HTMLIFrameElementImpl::parseAttribute): parse frameborder attribute. Defaults to true as per specification.
(HTMLIFrameElementImpl::updateFrame/attach): apply/remove frameborder style at attachment time.
* khtmlview.cpp (drawContents): fix counter-mask problem. Widget geometry is not accurate before painting, so we must
use the RenderObject's.
* rendering/render_frames.h (paddingTop/paddingBottom/paddingLeft/paddingRight): reimplement. Frames have no padding.
(RenderPartObject::canHaveBorder): reimplement. True.
* rendering/render_object.cpp (RenderObject::updateWidgetMasks): clip mask to correct width/height, though it doesn't matter much on X11.
* rendering/render_replaced.h (RenderWidget::borderTop/borderBottom/borderLeft/borderRight): percolated down from RenderForm.
Frames/Iframes also need that reimplementation.
2006-06-22 Germain Garand <germain@ebooksfrance.org>
Implement floating auto-width table quirk
* rendering/render_block.cpp (positionNewFloats): in quirkmode, floated auto-width
tables try to fit within remaining linewidth, so look for minWidth, and relayout if
position found ends up being narrower than current table width.
2006-06-20 Germain Garand <germain@ebooksfrance.org>
Don't let a float serie grow an object's maxwidth beyond the available width
* rendering/render_block.cpp (calcInlineMinMaxWidth/calcBlockMinMaxWidth): lazzily check available width
so floats don't overflow it if they can break line.
* rendering/render_box.{h,cpp} (availableWidth{,Using}): new. Like availableHeight{,Using}
* rendering/render_canvas.cpp (RenderCanvas::layout): set m_viewportWidth before recalculating minmax, as
availableWidth needs it.
2006-06-15 Allan Sandfeld Jensen <kde@carewolf.com>
Merge CSS3 properties background-size, background-origin and background-clip from WebCore
* rendering/render_style.{h,cpp}: New properties
* rendering/render_box.cpp: Handle the values in paintBackgroundExtended.
* dom/css_value.h: Add CSS_PAIR primitive value
* css/css_valueimpl.{h,cpp}: Add PairImpl primitive value
* css/cssstyleselector.cpp: New properties
* css/cssvalues.in: New values
* css/cssproperties.in: New properties
* css/cssparser.{h,cpp}: Clean-up short-hand parsing WC style
2006-06-14 Allan Sandfeld Jensen <kde@carewolf.com>
Implement replaced CSS(3) content, and fix various details in generated pseudo elements for CSS 2.1
* rendering/render_style.{h,cpp}: Add REPLACED and MARKER pseudo styles
* rendering/render_container.{h,cpp}:
(updatePseudoChild) Allow display: block as per CSS 2.1 standard
(updateReplacedContent) Handle changes in Replaced content.
(childrenAllowed) forbid children when generated content is used, this prevents
their render-objects from being attached.
* rendering/render_block.cpp: Postpone updatePseudoChilden to attachment because block
children might need the elements parents.
* rendering/render_inline.cpp: ditto
* rendering/render_generated.{h,cpp}: Add new class RenderGlyph to render list-style glyphs (square, disc, etc.)
* xml/dom_nodeimpl.cpp:
(NodeImpl::diff) detect changes in content and return Detach
* css/css_base.{h,cpp}: Add marker and replaced pseudo-styles
* css/cssstyleselector.cpp:
(checkOneSelector) Allow content on more elements
(precomputeAttributeDependencies) Track attributes inside :not elements as well
2006-06-08 George Staikos <staikos@kde.org>
Fix <a><label><img not in a form not being clickable
......@@ -12,7 +92,7 @@
(RenderBox::calcAbsoluteHorizontal):
(RenderBox::calcAbsoluteHorizontalValues):
(RenderBox::calcAbsoluteVertical):
(RenderBox::calcAbsoluteVerticalValues):
(RenderBox::calcAbsoluteVerticalValues):
(RenderBox::calcAbsoluteHorizontalReplaced): Handle replaced case separately.
(RenderBox::calcAbsoluteVerticalReplaced): ditto.
......
......@@ -82,7 +82,7 @@ void StyleBaseImpl::setParsedValue(int propId, const CSSValueImpl *parsedValue,
propIt.toLast(); // just remove the top one - not sure what should happen if we have multiple instances of the property
while (propIt.current() &&
( propIt.current()->m_id != propId || propIt.current()->nonCSSHint != nonCSSHint ||
propIt.current()->m_bImportant != important) )
propIt.current()->m_important != important) )
--propIt;
if (propIt.current())
propList->removeRef(propIt.current());
......@@ -90,14 +90,14 @@ void StyleBaseImpl::setParsedValue(int propId, const CSSValueImpl *parsedValue,
CSSProperty *prop = new CSSProperty();
prop->m_id = propId;
prop->setValue((CSSValueImpl *) parsedValue);
prop->m_bImportant = important;
prop->m_important = important;
prop->nonCSSHint = nonCSSHint;
propList->append(prop);
#ifdef CSS_DEBUG
kDebug( 6080 ) << "added property: " << getPropertyName(propId).string()
// non implemented yet << ", value: " << parsedValue->cssText().string()
<< " important: " << prop->m_bImportant
<< " important: " << prop->m_important
<< " nonCSS: " << prop->nonCSSHint << endl;
#endif
}
......@@ -171,6 +171,14 @@ void CSSSelector::extractPseudoType() const
if (!value.isEmpty()) {
value = value.lower();
switch (value[0].unicode()) {
case '-':
if (value == "-khtml-replaced")
_pseudoType = PseudoReplaced;
else
if (value == "-khtml-marker")
_pseudoType = PseudoMarker;
element = true;
break;
case 'a':
if (value == "active")
_pseudoType = PseudoActive;
......@@ -316,7 +324,7 @@ DOMString CSSSelector::selectorText() const
str = "*";
else if (tag != anyLocalName)
str = getTagName( cs->tag );
const CSSSelector* op = 0;
while (true) {
if ( cs->attr == ATTR_ID && cs->match == CSSSelector::Id )
......@@ -388,12 +396,12 @@ DOMString CSSSelector::selectorText() const
op=0;
str += ")";
}
if ((cs->relation != CSSSelector::SubSelector && !op) || !cs->tagHistory)
break;
cs = cs->tagHistory;
}
if ( cs->tagHistory ) {
DOMString tagHistoryText = cs->tagHistory->selectorText();
if ( cs->relation == DirectAdjacent )
......
......@@ -141,25 +141,30 @@ namespace DOM {
PseudoNthOfType,
PseudoNthLastOfType,
PseudoOnlyOfType,
PseudoFirstLine,
PseudoFirstLetter,
PseudoLink,
PseudoVisited,
PseudoHover,
PseudoFocus,
PseudoActive,
PseudoTarget,
PseudoBefore,
PseudoAfter,
PseudoLang,
PseudoNot,
PseudoContains,
PseudoRoot,
PseudoSelection,
PseudoEnabled,
PseudoDisabled,
PseudoChecked,
PseudoIndeterminate
PseudoIndeterminate,
// pseudo-elements:
// inherited:
PseudoFirstLine,
PseudoFirstLetter,
PseudoSelection,
// generated:
PseudoBefore,
PseudoAfter,
PseudoMarker,
PseudoReplaced
};
PseudoType pseudoType() const {
......@@ -178,8 +183,8 @@ namespace DOM {
Relation relation : 3;
mutable Match match : 4;
bool nonCSSHint : 1;
unsigned int pseudoId : 3;
mutable PseudoType _pseudoType : 5;
unsigned int pseudoId : 4;
mutable PseudoType _pseudoType : 6;
private:
void extractPseudoType() const;
......
......@@ -265,6 +265,14 @@ DOMString khtml::stringForListStyleType(EListStyleType type)
return "";
}
static CSSPrimitiveValueImpl* valueForColor(QColor color)
{
if (color.isValid())
return new CSSPrimitiveValueImpl(color.rgb());//### KDE4: use rgba!
else
return new CSSPrimitiveValueImpl(khtml::transparentColor);
}
static CSSValueImpl* valueForShadow(const ShadowData *shadow)
{
if (!shadow)
......@@ -274,7 +282,7 @@ static CSSValueImpl* valueForShadow(const ShadowData *shadow)
CSSPrimitiveValueImpl *x = new CSSPrimitiveValueImpl(s->x, CSSPrimitiveValue::CSS_PX);
CSSPrimitiveValueImpl *y = new CSSPrimitiveValueImpl(s->y, CSSPrimitiveValue::CSS_PX);
CSSPrimitiveValueImpl *blur = new CSSPrimitiveValueImpl(s->blur, CSSPrimitiveValue::CSS_PX);
CSSPrimitiveValueImpl *color = new CSSPrimitiveValueImpl(s->color.rgb());
CSSPrimitiveValueImpl *color = valueForColor(s->color);
list->append(new ShadowValueImpl(x, y, blur, color));
}
return list;
......@@ -309,17 +317,16 @@ static CSSValueImpl *getPositionOffsetValue(RenderObject *renderer, int property
if (renderer->isPositioned())
return valueForLength(l, renderer->contentWidth());
if (renderer->isRelPositioned())
// FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
// In other words if left is auto and right is not auto, then left's computed value is negative right.
// So we should get the opposite length unit and see if it is auto.
return valueForLength(l, renderer->contentWidth());
return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
}
RenderStyleDeclarationImpl::RenderStyleDeclarationImpl( DOM::NodeImpl *node )
: CSSStyleDeclarationImpl(0), m_node(node)
{
......@@ -374,7 +381,7 @@ CSSValueImpl *RenderStyleDeclarationImpl::getPropertyCSSValue( int propertyID )
switch(propertyID)
{
case CSS_PROP_BACKGROUND_COLOR:
return new CSSPrimitiveValueImpl(style->backgroundColor().rgb());
return valueForColor(style->backgroundColor());
case CSS_PROP_BACKGROUND_IMAGE:
if (style->backgroundImage())
return new CSSPrimitiveValueImpl(style->backgroundImage()->url(),
......@@ -438,13 +445,13 @@ CSSValueImpl *RenderStyleDeclarationImpl::getPropertyCSSValue( int propertyID )
return new CSSPrimitiveValueImpl(style->borderVerticalSpacing(),
CSSPrimitiveValue::CSS_PX);
case CSS_PROP_BORDER_TOP_COLOR:
return new CSSPrimitiveValueImpl(style->borderTopColor().rgb());
return valueForColor(style->borderTopColor());
case CSS_PROP_BORDER_RIGHT_COLOR:
return new CSSPrimitiveValueImpl(style->borderRightColor().rgb());
return valueForColor(style->borderRightColor());
case CSS_PROP_BORDER_BOTTOM_COLOR:
return new CSSPrimitiveValueImpl(style->borderBottomColor().rgb());
return valueForColor(style->borderBottomColor());
case CSS_PROP_BORDER_LEFT_COLOR:
return new CSSPrimitiveValueImpl(style->borderLeftColor().rgb());
return valueForColor(style->borderLeftColor());
case CSS_PROP_BORDER_TOP_STYLE:
return valueForBorderStyle(style->borderTopStyle());
case CSS_PROP_BORDER_RIGHT_STYLE:
......@@ -492,7 +499,7 @@ CSSValueImpl *RenderStyleDeclarationImpl::getPropertyCSSValue( int propertyID )
case CSS_PROP_CLIP:
break;
case CSS_PROP_COLOR:
return new CSSPrimitiveValueImpl(style->color().rgb());
return valueForColor(style->color());
case CSS_PROP_CONTENT:
break;
case CSS_PROP_COUNTER_INCREMENT:
......@@ -1112,7 +1119,7 @@ CSSProperty RenderStyleDeclarationImpl::property( int id ) const
{
CSSProperty prop;
prop.m_id = id;
prop.m_bImportant = false;
prop.m_important = false;
prop.nonCSSHint = false;
CSSValueImpl* v = getPropertyCSSValue( id );
......
......@@ -194,6 +194,8 @@ unsigned long CSSStyleSheetImpl::insertRule( const DOMString &rule, unsigned lon
// HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at the specified index e.g. if an
//@import rule is inserted after a standard rule set or other at-rule.
m_lstChildren->insert(index, r);
if (m_doc)
m_doc->updateStyleSelector(true /*shallow*/);
return index;
}
......@@ -211,6 +213,8 @@ void CSSStyleSheetImpl::deleteRule( unsigned long index, int &exceptioncode )
return;
}
b->deref();
if (m_doc)
m_doc->updateStyleSelector(true /*shallow*/);
}
void CSSStyleSheetImpl::addNamespace(CSSParser* p, const DOM::DOMString& prefix, const DOM::DOMString& uri)
......
/**
* This file is part of the DOM implementation for KDE.
*
* Copyright 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright 2004 Apple Computer, Inc.
* Copyright 2005 Allan Sandfeld Jensen (kde@carewolf.com)
* Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
* (C) 2004, 2005, 2006 Apple Computer, Inc.
* (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -352,7 +352,7 @@ bool CSSStyleDeclarationImpl::getPropertyPriority( int propertyID ) const
CSSProperty *current;
for ( lstValuesIt.toFirst(); (current = lstValuesIt.current()); ++lstValuesIt ) {
if( propertyID == current->m_id )
return current->m_bImportant;
return current->m_important;
}
}
return false;
......@@ -570,6 +570,15 @@ CSSPrimitiveValueImpl::CSSPrimitiveValueImpl(QRgb color)
m_type = CSSPrimitiveValue::CSS_RGBCOLOR;
}
CSSPrimitiveValueImpl::CSSPrimitiveValueImpl(PairImpl *p)
{
m_value.pair = p;
if (m_value.pair)
m_value.pair->ref();
m_type = CSSPrimitiveValue::CSS_PAIR;
}
CSSPrimitiveValueImpl::~CSSPrimitiveValueImpl()
{
cleanup();
......@@ -588,6 +597,10 @@ void CSSPrimitiveValueImpl::cleanup()
break;
case CSSPrimitiveValue::CSS_RECT:
m_value.rect->deref();
break;
case CSSPrimitiveValue::CSS_PAIR:
m_value.pair->deref();
break;
default:
break;
}
......@@ -793,11 +806,26 @@ DOM::DOMString CSSPrimitiveValueImpl::cssText() const
text += rectVal->right()->cssText() + " ";
text += rectVal->bottom()->cssText() + " ";
text += rectVal->left()->cssText() + ")";
break;
}
break;
case CSSPrimitiveValue::CSS_RGBCOLOR:
text = QColor(m_value.rgbcolor).name();
if (qAlpha(m_value.rgbcolor) != 0xFF) {
if (m_value.rgbcolor == khtml::transparentColor)
text = "transparent";
else
text = "rgba(" + QString::number(qRed (m_value.rgbcolor)) + ","
+ QString::number(qBlue (m_value.rgbcolor)) + ","
+ QString::number(qGreen(m_value.rgbcolor)) + ","
+ QString::number(qAlpha(m_value.rgbcolor)/255.0) + ")";
} else {
text = QColor(m_value.rgbcolor).name();
}
break;
case CSSPrimitiveValue::CSS_PAIR:
text = m_value.pair->first()->cssText();
text += " ";
text += m_value.pair->second()->cssText();
break;
default:
break;
}
......@@ -852,6 +880,29 @@ void RectImpl::setLeft( CSSPrimitiveValueImpl *left )
// -----------------------------------------------------------------
PairImpl::~PairImpl()
{
if (m_first) m_first->deref(); if (m_second) m_second->deref();
}
void PairImpl::setFirst(CSSPrimitiveValueImpl* first)
{
if (first == m_first) return;
if (m_first) m_first->deref();
m_first = first;
if (m_first) m_first->ref();
}
void PairImpl::setSecond(CSSPrimitiveValueImpl* second)
{
if (second == m_second) return;
if (m_second) m_second->deref();
m_second = second;
if (m_second) m_second->ref();
}
// -----------------------------------------------------------------
CSSImageValueImpl::CSSImageValueImpl(const DOMString &url, const StyleBaseImpl* style)
: CSSPrimitiveValueImpl(url, CSSPrimitiveValue::CSS_URI)
{
......@@ -1070,5 +1121,5 @@ DOMString CounterActImpl::cssText() const
DOMString CSSProperty::cssText() const
{
return getPropertyName(m_id) + DOMString(": ") + m_value->cssText() + (m_bImportant ? DOMString(" !important") : DOMString()) + DOMString("; ");
return getPropertyName(m_id) + DOMString(": ") + m_value->cssText() + (m_important ? DOMString(" !important") : DOMString()) + DOMString("; ");
}
/*
* This file is part of the DOM implementation for KDE.
*
* Copyright 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright 2002 Apple Computer, Inc.
* Copyright 2005 Allan Sandfeld Jensen (kde@carewolf.com)
* Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
* (C) 2004, 2005, 2006 Apple Computer, Inc.
* (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -38,12 +38,14 @@ namespace khtml {
class CachedImage;
}
namespace DOM {
class CSSRuleImpl;
class CSSValueImpl;
class NodeImpl;
class CounterImpl;
class PairImpl;
class CSSStyleDeclarationImpl : public StyleBaseImpl
......@@ -170,6 +172,7 @@ public:
CSSPrimitiveValueImpl(CounterImpl *c);
CSSPrimitiveValueImpl( RectImpl *r);
CSSPrimitiveValueImpl(QRgb color);
CSSPrimitiveValueImpl(PairImpl *p);
virtual ~CSSPrimitiveValueImpl();
......@@ -215,6 +218,10 @@ public:
return ( m_type != CSSPrimitiveValue::CSS_RGBCOLOR ? 0 : m_value.rgbcolor );
}
PairImpl* getPairValue() const {
return (m_type != CSSPrimitiveValue::CSS_PAIR ? 0 : m_value.pair);
}
virtual bool isPrimitiveValue() const { return true; }
virtual unsigned short cssValueType() const;
......@@ -234,6 +241,7 @@ protected:
CounterImpl *counter;
RectImpl *rect;
QRgb rgbcolor;
PairImpl* pair;
} m_value;
};
......@@ -285,6 +293,29 @@ protected:
CSSPrimitiveValueImpl *m_left;
};
// A primitive value representing a pair. This is useful for properties like border-radius, background-size/position,
// and border-spacing (all of which are space-separated sets of two values). At the moment we are only using it for
// border-radius and background-size, but (FIXME) border-spacing and background-position could be converted over to use
// it (eliminating some extra -webkit- internal properties).
class PairImpl : public khtml::Shared<PairImpl> {
public:
PairImpl() : m_first(0), m_second(0) { }
PairImpl(CSSPrimitiveValueImpl* first, CSSPrimitiveValueImpl* second)
: m_first(first), m_second(second) { if (first) first->ref(); if (second) second->ref(); }
virtual ~PairImpl();
CSSPrimitiveValueImpl* first() const { return m_first; }
CSSPrimitiveValueImpl* second() const { return m_second; }
void setFirst(CSSPrimitiveValueImpl* first);
void setSecond(CSSPrimitiveValueImpl* second);
protected:
CSSPrimitiveValueImpl* m_first;
CSSPrimitiveValueImpl* m_second;
};
class CSSImageValueImpl : public CSSPrimitiveValueImpl, public khtml::CachedObjectClient
{
public:
......@@ -392,14 +423,14 @@ public:
CSSProperty()
{
m_id = -1;
m_bImportant = false;
m_important = false;
nonCSSHint = false;
m_value = 0;
}
CSSProperty(const CSSProperty& o)
{
m_id = o.m_id;
m_bImportant = o.m_bImportant;
m_important = o.m_important;
nonCSSHint = o.nonCSSHint;
m_value = o.m_value;
if (m_value) m_value->ref();
......@@ -416,14 +447,18 @@ public:
}
}
int id() const { return m_id; }
bool isImportant() const { return m_important; }
CSSValueImpl *value() const { return m_value; }
DOM::DOMString cssText() const;
// make sure the following fits in 4 bytes.
signed int m_id : 29;
bool m_bImportant : 1;
bool nonCSSHint : 1;
signed int m_id : 29;
bool m_important : 1;
bool nonCSSHint : 1;
protected:
CSSValueImpl *m_value;
};
......
This diff is collapsed.
......@@ -2,6 +2,7 @@
* This file is part of the DOM implementation for KDE.
*
* Copyright 2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -23,6 +24,7 @@
#include <qstring.h>
#include <qcolor.h>
#include <QVector>
#include <dom/dom_string.h>
namespace DOM {
......@@ -54,6 +56,7 @@ namespace DOM {
struct Value {
int id;
bool isInt;
union {
double fValue;
int iValue;
......@@ -78,16 +81,15 @@ namespace DOM {
class ValueList {
public:
ValueList();
ValueList() : m_current(0) { }
~ValueList();
void addValue( const Value &val );
Value *current() { return currentValue < numValues ? values + currentValue : 0; }
Value *next() { ++currentValue; return current(); }
bool isLast() const { return currentValue+1 >= numValues; }
Value *values;
int numValues;
int maxValues;
int currentValue;
void addValue(const Value& v) { m_values.append(v); }
unsigned int size() const { return m_values.size(); }
Value* current() { return m_current < m_values.size() ? &m_values[m_current] : 0; }
Value* next() { ++m_current; return current(); }
private:
QVector<Value> m_values;
unsigned int m_current;
};
class CSSParser
......@@ -115,15 +117,16 @@ namespace DOM {
CSSStyleDeclarationImpl *createStyleDeclaration( CSSStyleRuleImpl *rule );
void clearProperties();
bool parseValue( int propId, bool important, int expected=1 );
bool parseShortHand( const int *properties, int numProperties, bool important );
bool parse4Values( const int *properties, bool important );
bool parseValue( int propId, bool important );
bool parseShortHand( int propId, const int *properties, int numProperties, bool important );
bool parse4Values( int propId, const int *properties, bool important );