Tuesday, 10 November 2009

KDE/kdelibs/khtml/imload/decoders

SVN commit 1047308 by cfeck:

Fix loading of CMYK jpeg images

BUG: 135789
BUG: 189414
BUG: 193152


M +13 -0 jpegloader.cpp


--- trunk/KDE/kdelibs/khtml/imload/decoders/jpegloader.cpp #1047307:1047308
@@ -346,6 +346,9 @@
if ( cinfo.jpeg_color_space == JCS_YCbCr )
cinfo.out_color_space = JCS_RGB;

+ if ( cinfo.jpeg_color_space == JCS_YCCK )
+ cinfo.out_color_space = JCS_CMYK;
+
cinfo.do_fancy_upsampling = true;
cinfo.do_block_smoothing = false;
cinfo.quantize_colors = false;
@@ -432,6 +435,16 @@
in-=3;
out[i] = qRgb(in[0], in[1], in[2]);
}
+ } else if ( cinfo.out_color_space == JCS_CMYK ) {
+ uchar *in = scanline + cinfo.output_width * 4;
+ QRgb *out = (QRgb *) scanline;
+
+ for (uint i = cinfo.output_width; i--; )
+ {
+ in -= 4;
+ int k = in[3];
+ out[i] = qRgb(k * in[0] / 255, k * in[1] / 255, k * in[2] / 255);
+ }
}

owner->notifyScanline(passNum + 1, scanline);

Sunday, 8 November 2009

KDE/kdelibs/khtml

SVN commit 1046457 by ggarand:

better design for |style| attribute synchronization : use a specific
class for inline styles (CSSInlineStyleDeclarationImpl) that knows better
when to mark its node.

cleaner that way, and solves the problem that the node used to be marked as
needing sync upon initial |style| attribute parsing.

M +20 -3 css/css_valueimpl.cpp
M +9 -1 css/css_valueimpl.h
M +1 -5 html/html_elementimpl.cpp
M +3 -3 xml/dom_elementimpl.cpp
M +8 -6 xml/dom_elementimpl.h


--- trunk/KDE/kdelibs/khtml/css/css_valueimpl.cpp #1046456:1046457
@@ -684,9 +684,6 @@
void CSSStyleDeclarationImpl::setChanged()
{
if (m_node) {
- if (m_node->nodeType() == Node::ELEMENT_NODE && (static_cast<ElementImpl*>(m_node)->inlineStyleDecls() == this)) {
- m_node->setNeedsStyleAttributeUpdate();
- }
m_node->setChanged();
return;
}
@@ -877,7 +874,27 @@
// ###
}

+// --------------------------------------------------------------------------------------

+void CSSInlineStyleDeclarationImpl::setChanged()
+{
+ if (m_node)
+ m_node->setNeedsStyleAttributeUpdate();
+ CSSStyleDeclarationImpl::setChanged();
+}
+
+void CSSInlineStyleDeclarationImpl::updateFromAttribute(const DOMString &value)
+{
+ if(!m_lstValues) {
+ m_lstValues = new QList<CSSProperty*>;
+ } else {
+ clear();
+ }
+ CSSParser parser( strictParsing );
+ parser.parseDeclaration( this, value );
+ CSSStyleDeclarationImpl::setChanged();
+}
+
// --------------------------------------------------------------------------------------

unsigned short CSSInheritedValueImpl::cssValueType() const
--- trunk/KDE/kdelibs/khtml/css/css_valueimpl.h #1046456:1046457
@@ -91,7 +91,7 @@
QList<CSSProperty*> *values() const { return m_lstValues; }
void setNode(NodeImpl *_node) { m_node = _node; }

- void setChanged();
+ virtual void setChanged();

void removeCSSHints();

@@ -109,6 +109,14 @@
CSSStyleDeclarationImpl(const CSSStyleDeclarationImpl& o);
};

+class CSSInlineStyleDeclarationImpl : public CSSStyleDeclarationImpl
+{
+public:
+ CSSInlineStyleDeclarationImpl(CSSRuleImpl *parentRule): CSSStyleDeclarationImpl(parentRule) {}
+ virtual void setChanged();
+ void updateFromAttribute(const DOMString &value);
+};
+
class CSSValueImpl : public StyleBaseImpl
{
public:
--- trunk/KDE/kdelibs/khtml/html/html_elementimpl.cpp #1046456:1046457
@@ -156,11 +156,7 @@
setContentEditable(attr);
break;
case ATTR_STYLE:
- if (inlineStyleDecls())
- inlineStyleDecls()->clear();
- else
- createInlineDecl();
- inlineStyleDecls()->setProperty(attr->value());
+ getInlineStyleDecls()->updateFromAttribute(attr->value());
setChanged();
break;
case ATTR_TABINDEX:
--- trunk/KDE/kdelibs/khtml/xml/dom_elementimpl.cpp #1046456:1046457
@@ -1098,7 +1098,7 @@
void ElementImpl::createNonCSSDecl()
{
assert(!m_hasCombinedStyle);
- CSSStyleDeclarationImpl *ild = m_style.inlineDecls;
+ CSSInlineStyleDeclarationImpl *ild = m_style.inlineDecls;
m_style.combinedDecls = new CombinedStyleDecl;
m_style.combinedDecls->inlineDecls = ild;
CSSStyleDeclarationImpl *ncd = new CSSStyleDeclarationImpl(0);
@@ -1110,7 +1110,7 @@
m_hasCombinedStyle = true;
}

-CSSStyleDeclarationImpl *ElementImpl::getInlineStyleDecls()
+CSSInlineStyleDeclarationImpl *ElementImpl::getInlineStyleDecls()
{
if (!inlineStyleDecls()) createInlineDecl();
return inlineStyleDecls();
@@ -1120,7 +1120,7 @@
{
assert( !m_style.inlineDecls || (m_hasCombinedStyle && !m_style.combinedDecls->inlineDecls) );

- CSSStyleDeclarationImpl *dcl = new CSSStyleDeclarationImpl(0);
+ CSSInlineStyleDeclarationImpl *dcl = new CSSInlineStyleDeclarationImpl(0);
dcl->ref();
dcl->setParent(document()->elementSheet());
dcl->setNode(this);
--- trunk/KDE/kdelibs/khtml/xml/dom_elementimpl.h #1046456:1046457
@@ -48,6 +48,7 @@
class DocumentImpl;
class NamedAttrMapImpl;
class ElementRareDataImpl;
+class CSSInlineStyleDeclarationImpl;

// Attr can have Text and EntityReference children
// therefore it has to be a fullblown Node. The plan
@@ -160,7 +161,7 @@

struct CombinedStyleDecl
{
- DOM::CSSStyleDeclarationImpl *inlineDecls;
+ DOM::CSSInlineStyleDeclarationImpl *inlineDecls;
DOM::CSSStyleDeclarationImpl *nonCSSDecls;
};

@@ -178,7 +179,7 @@
// stuff for WebCore DOM & SVG api compatibility
virtual bool hasTagName(const QualifiedName& name) const { return qualifiedName() == name;/*should be matches here*/ }
QualifiedName qualifiedName() const { return QualifiedName(id(), m_prefix); }
- CSSStyleDeclarationImpl* style() { return getInlineStyleDecls(); }
+ CSSInlineStyleDeclarationImpl* style() { return getInlineStyleDecls(); }
void setAttribute(const QualifiedName& name, const DOMString& value) {
setAttribute(name.id(), value); /* is it enough for SVG or should the full setAttribute() be called? */
}
@@ -313,9 +314,9 @@

virtual bool childAllowed( NodeImpl *newChild );
virtual bool childTypeAllowed( unsigned short type );
- DOM::CSSStyleDeclarationImpl *inlineStyleDecls() const { return m_hasCombinedStyle ? m_style.combinedDecls->inlineDecls : m_style.inlineDecls; }
+ DOM::CSSInlineStyleDeclarationImpl *inlineStyleDecls() const { return m_hasCombinedStyle ? m_style.combinedDecls->inlineDecls : m_style.inlineDecls; }
DOM::CSSStyleDeclarationImpl *nonCSSStyleDecls() const { return m_hasCombinedStyle ? m_style.combinedDecls->nonCSSDecls : 0; }
- DOM::CSSStyleDeclarationImpl *getInlineStyleDecls();
+ DOM::CSSInlineStyleDeclarationImpl *getInlineStyleDecls();

void dispatchAttrRemovalEvent(NodeImpl::Id id, DOMStringImpl *value);
void dispatchAttrAdditionEvent(NodeImpl::Id id, DOMStringImpl *value);
@@ -371,7 +372,7 @@
mutable NamedAttrMapImpl *namedAttrMap;

union {
- DOM::CSSStyleDeclarationImpl *inlineDecls;
+ DOM::CSSInlineStyleDeclarationImpl *inlineDecls;
CombinedStyleDecl *combinedDecls;
} m_style;
PrefixName m_prefix;
@@ -540,9 +541,10 @@
}
}

-// methods that could be very hot they are need to be inlined
+// methods that could be very hot and therefore need to be inlined
inline DOMStringImpl* ElementImpl::getAttributeImpl(NodeImpl::Id id, const PrefixName& prefix, bool nsAware) const
{
+ if (m_needsStyleAttributeUpdate && (id == ATTR_STYLE)) synchronizeStyleAttribute();
return namedAttrMap ? namedAttrMap->getValue(id, prefix, nsAware) : 0;
}

KDE/kdelibs/khtml

SVN commit 1046451 by ggarand:

make sure the considered style declaration is inline before mirroring it to
the |style| attribute.

we don't want that to apply to non-inline stylesheet rules.


BUG: 207282

M +4 -2 css/css_valueimpl.cpp
M +2 -1 xml/dom_elementimpl.cpp
M +2 -2 xml/dom_elementimpl.h


--- trunk/KDE/kdelibs/khtml/css/css_valueimpl.cpp #1046450:1046451
@@ -684,8 +684,10 @@
void CSSStyleDeclarationImpl::setChanged()
{
if (m_node) {
- if (m_node->nodeType() == Node::ELEMENT_NODE)
- static_cast<ElementImpl*>(m_node)->synchronizeStyleAttribute(cssText());
+ if (m_node->nodeType() == Node::ELEMENT_NODE && (static_cast<ElementImpl*>(m_node)->inlineStyleDecls() == this)) {
+ // FIXME: potentially costly...
+ static_cast<ElementImpl*>(m_node)->synchronizeStyleAttribute();
+ }
m_node->setChanged();
return;
}
--- trunk/KDE/kdelibs/khtml/xml/dom_elementimpl.cpp #1046450:1046451
@@ -1354,8 +1354,9 @@
document()->setFocusNode(this);
}

-void ElementImpl::synchronizeStyleAttribute(const DOMString& value)
+void ElementImpl::synchronizeStyleAttribute()
{
+ DOMString value = getInlineStyleDecls()->cssText();
attributes()->setValueWithoutElementUpdate(ATTR_STYLE, value.implementation());
}

--- trunk/KDE/kdelibs/khtml/xml/dom_elementimpl.h #1046450:1046451
@@ -345,8 +345,8 @@
//Called when mapping from id to this node in document should be added
virtual void addId (const DOMString& id);

- // Synchronize style attribute after it was changed via CSS DOM (html5)
- void synchronizeStyleAttribute(const DOMString& value);
+ // Synchronize style attribute after it was changed via CSSOM
+ void synchronizeStyleAttribute();

protected:
void createAttributeMap() const;

KDE/kdelibs/khtml

SVN commit 1046453 by ggarand:

rework synchronization of the |style| attribute so that is is done
lazzily on attribute retrieval instead.

M +1 -2 css/css_valueimpl.cpp
M +7 -3 xml/dom_elementimpl.cpp
M +2 -1 xml/dom_elementimpl.h
M +3 -2 xml/dom_nodeimpl.cpp
M +5 -2 xml/dom_nodeimpl.h


--- trunk/KDE/kdelibs/khtml/css/css_valueimpl.cpp #1046452:1046453
@@ -685,8 +685,7 @@
{
if (m_node) {
if (m_node->nodeType() == Node::ELEMENT_NODE && (static_cast<ElementImpl*>(m_node)->inlineStyleDecls() == this)) {
- // FIXME: potentially costly...
- static_cast<ElementImpl*>(m_node)->synchronizeStyleAttribute();
+ m_node->setNeedsStyleAttributeUpdate();
}
m_node->setChanged();
return;
--- trunk/KDE/kdelibs/khtml/xml/dom_elementimpl.cpp #1046452:1046453
@@ -587,8 +587,10 @@
{
// clone attributes
if (namedAttrMap)
- clone->attributes()->copyAttributes(namedAttrMap);
+ clone->attributes()->copyAttributes(attributes(true));

+ assert( !m_needsStyleAttributeUpdate ); // ensured by previous line
+
// clone individual style rules
if (m_style.inlineDecls) {
if (m_hasCombinedStyle) {
@@ -1368,9 +1370,11 @@
document()->setFocusNode(this);
}

-void ElementImpl::synchronizeStyleAttribute()
+void ElementImpl::synchronizeStyleAttribute() const
{
- DOMString value = getInlineStyleDecls()->cssText();
+ assert(inlineStyleDecls() && m_needsStyleAttributeUpdate);
+ m_needsStyleAttributeUpdate = false;
+ DOMString value = inlineStyleDecls()->cssText();
attributes()->setValueWithoutElementUpdate(ATTR_STYLE, value.implementation());
}

--- trunk/KDE/kdelibs/khtml/xml/dom_elementimpl.h #1046452:1046453
@@ -260,6 +260,7 @@

NamedAttrMapImpl* attributes(bool readonly = false) const
{
+ if (m_needsStyleAttributeUpdate) synchronizeStyleAttribute();
if (!readonly && !namedAttrMap) createAttributeMap();
return namedAttrMap;
}
@@ -349,7 +350,7 @@
virtual void addId (const DOMString& id);

// Synchronize style attribute after it was changed via CSSOM
- void synchronizeStyleAttribute();
+ void synchronizeStyleAttribute() const;

protected:
void createAttributeMap() const;
--- trunk/KDE/kdelibs/khtml/xml/dom_nodeimpl.cpp #1046452:1046453
@@ -78,7 +78,6 @@
m_changedAscendentAttribute( false ),
m_inDocument( false ),
m_hasAnchor( false ),
- m_elementHasRareData( false ),
m_hovered( false ),
m_focused( false ),
m_active( false ),
@@ -86,7 +85,9 @@
m_htmlCompat( false ),
m_hasClass( false ),
m_hasCombinedStyle( false ),
- m_hasHoverDependency(false)
+ m_hasHoverDependency( false ),
+ m_elementHasRareData( false ),
+ m_needsStyleAttributeUpdate( false )
{
}

--- trunk/KDE/kdelibs/khtml/xml/dom_nodeimpl.h #1046452:1046453
@@ -280,6 +280,7 @@
void setHTMLCompat(bool b) { m_htmlCompat = b; }
bool hasHoverDependency() { return m_hasHoverDependency; }
void setHasHoverDependency(bool b = true) { m_hasHoverDependency = b; }
+ void setNeedsStyleAttributeUpdate(bool b = true) { m_needsStyleAttributeUpdate = b; }
virtual void setFocus(bool b=true) { m_focused = b; }
virtual void setActive(bool b=true) { m_active = b; }
virtual void setHovered(bool b=true) { m_hovered = b; }
@@ -527,7 +528,6 @@
bool m_changedAscendentAttribute : 1;
bool m_inDocument : 1;
bool m_hasAnchor : 1;
- bool m_elementHasRareData : 1;

bool m_hovered : 1;
bool m_focused : 1;
@@ -538,7 +538,10 @@
bool m_hasCombinedStyle : 1; // true if element has inline styles and presentational styles
bool m_hasHoverDependency : 1; // true if element has hover dependency on itself

- // 15 bits left
+ bool m_elementHasRareData : 1;
+ mutable bool m_needsStyleAttributeUpdate : 1; // true if |style| attribute is out of sync (i.e. CSSOM modified our inline styles)
+
+ // 14 bits left
};

// this is the full Node Implementation with parents and children.

KDE/kdelibs/khtml/rendering

SVN commit 1046447 by ggarand:

patch by Andrea IACOVITTI <aiacovitti@libero.it> and Allan Sandfeld Jensen
for honouring "border: none" on native widget borders.

BUG: 200795

M +1 -1 render_replaced.cpp


--- trunk/KDE/kdelibs/khtml/rendering/render_replaced.cpp #1046446:1046447
@@ -480,7 +480,7 @@
}

// Border:
- if (shouldPaintBorder())
+ if (shouldPaintBorder() || (!shouldPaintBackgroundOrBorder() && canHaveBorder()))
{
if (QFrame* frame = qobject_cast<QFrame*>(m_widget))
frame->setFrameShape(QFrame::NoFrame);

KDE/kdelibs/khtml/rendering

SVN commit 1046449 by ggarand:

use correct method for computation of percentage height in relative
positionning:
calcPercentageHeight() properly handles cases where CB recursion
is necessary, and other quirks.

Thanks to Gérard Talbot for accurately spotting the regression.

BUG: 169635

M +14 -2 render_box.cpp


--- trunk/KDE/kdelibs/khtml/rendering/render_box.cpp #1046448:1046449
@@ -1083,11 +1083,23 @@
tx -= style()->right().width(containingBlockWidth());
if(!style()->top().isAuto())
{
- ty += style()->top().width(containingBlockHeight());
+ if (style()->top().isPercent()) {
+ int ph = calcPercentageHeight(style()->top());
+ if (ph != -1)
+ ty += ph;
+ } else {
+ ty += style()->top().width(containingBlockHeight());
+ }
}
else if(!style()->bottom().isAuto())
{
- ty -= style()->bottom().width(containingBlockHeight());
+ if (style()->top().isPercent()) {
+ int ph = calcPercentageHeight(style()->top());
+ if (ph != -1)
+ ty -= ph;
+ } else {
+ ty -= style()->bottom().width(containingBlockHeight());
+ }
}
}

KDE/kdelibs/khtml

SVN commit 1046450 by ggarand:

also hide alt tooltips when the view is scrolled via keyboard shortcuts
(follow up to a previous fix by Martin Koller)

M +3 -0 khtmlview.cpp


--- trunk/KDE/kdelibs/khtml/khtmlview.cpp #1046449:1046450
@@ -3909,6 +3909,9 @@
}
}

+ if ( underMouse() && QToolTip::isVisible() )
+ QToolTip::hideText();
+
if (!d->scrollingSelf) {
d->scrollBarMoved = true;
d->contentsMoving = true;