283786b7214d36f91637c89db23fa96d3241d734
[framework/web/webkit-efl.git] / Source / WebCore / html / HTMLTableElement.cpp
1 /*
2  * Copyright (C) 1997 Martin Jones (mjones@kde.org)
3  *           (C) 1997 Torben Weis (weis@kde.org)
4  *           (C) 1998 Waldo Bastian (bastian@kde.org)
5  *           (C) 1999 Lars Knoll (knoll@kde.org)
6  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
7  * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010, 2011 Apple Inc. All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public License
20  * along with this library; see the file COPYING.LIB.  If not, write to
21  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  */
24
25 #include "config.h"
26 #include "HTMLTableElement.h"
27
28 #include "Attribute.h"
29 #include "CSSImageValue.h"
30 #include "CSSPropertyNames.h"
31 #include "CSSStyleSheet.h"
32 #include "CSSValueKeywords.h"
33 #include "CSSValuePool.h"
34 #include "ExceptionCode.h"
35 #include "HTMLNames.h"
36 #include "HTMLParserIdioms.h"
37 #include "HTMLTableCaptionElement.h"
38 #include "HTMLTableRowElement.h"
39 #include "HTMLTableRowsCollection.h"
40 #include "HTMLTableSectionElement.h"
41 #include "RenderTable.h"
42 #include "Text.h"
43
44 namespace WebCore {
45
46 using namespace HTMLNames;
47
48 HTMLTableElement::HTMLTableElement(const QualifiedName& tagName, Document* document)
49     : HTMLElement(tagName, document)
50     , m_borderAttr(false)
51     , m_borderColorAttr(false)
52     , m_frameAttr(false)
53     , m_rulesAttr(UnsetRules)
54     , m_padding(1)
55 {
56     ASSERT(hasTagName(tableTag));
57 }
58
59 PassRefPtr<HTMLTableElement> HTMLTableElement::create(Document* document)
60 {
61     return adoptRef(new HTMLTableElement(tableTag, document));
62 }
63
64 PassRefPtr<HTMLTableElement> HTMLTableElement::create(const QualifiedName& tagName, Document* document)
65 {
66     return adoptRef(new HTMLTableElement(tagName, document));
67 }
68
69 HTMLTableCaptionElement* HTMLTableElement::caption() const
70 {
71     for (Node* child = firstChild(); child; child = child->nextSibling()) {
72         if (child->hasTagName(captionTag))
73             return static_cast<HTMLTableCaptionElement*>(child);
74     }
75     return 0;
76 }
77
78 void HTMLTableElement::setCaption(PassRefPtr<HTMLTableCaptionElement> newCaption, ExceptionCode& ec)
79 {
80     deleteCaption();
81     insertBefore(newCaption, firstChild(), ec);
82 }
83
84 HTMLTableSectionElement* HTMLTableElement::tHead() const
85 {
86     for (Node* child = firstChild(); child; child = child->nextSibling()) {
87         if (child->hasTagName(theadTag))
88             return static_cast<HTMLTableSectionElement*>(child);
89     }
90     return 0;
91 }
92
93 void HTMLTableElement::setTHead(PassRefPtr<HTMLTableSectionElement> newHead, ExceptionCode& ec)
94 {
95     deleteTHead();
96
97     Node* child;
98     for (child = firstChild(); child; child = child->nextSibling())
99         if (child->isElementNode() && !child->hasTagName(captionTag) && !child->hasTagName(colgroupTag))
100             break;
101
102     insertBefore(newHead, child, ec);
103 }
104
105 HTMLTableSectionElement* HTMLTableElement::tFoot() const
106 {
107     for (Node* child = firstChild(); child; child = child->nextSibling()) {
108         if (child->hasTagName(tfootTag))
109             return static_cast<HTMLTableSectionElement*>(child);
110     }
111     return 0;
112 }
113
114 void HTMLTableElement::setTFoot(PassRefPtr<HTMLTableSectionElement> newFoot, ExceptionCode& ec)
115 {
116     deleteTFoot();
117
118     Node* child;
119     for (child = firstChild(); child; child = child->nextSibling())
120         if (child->isElementNode() && !child->hasTagName(captionTag) && !child->hasTagName(colgroupTag) && !child->hasTagName(theadTag))
121             break;
122
123     insertBefore(newFoot, child, ec);
124 }
125
126 PassRefPtr<HTMLElement> HTMLTableElement::createTHead()
127 {
128     if (HTMLTableSectionElement* existingHead = tHead())
129         return existingHead;
130     RefPtr<HTMLTableSectionElement> head = HTMLTableSectionElement::create(theadTag, document());
131     ExceptionCode ec;
132     setTHead(head, ec);
133     return head.release();
134 }
135
136 void HTMLTableElement::deleteTHead()
137 {
138     ExceptionCode ec;
139     removeChild(tHead(), ec);
140 }
141
142 PassRefPtr<HTMLElement> HTMLTableElement::createTFoot()
143 {
144     if (HTMLTableSectionElement* existingFoot = tFoot())
145         return existingFoot;
146     RefPtr<HTMLTableSectionElement> foot = HTMLTableSectionElement::create(tfootTag, document());
147     ExceptionCode ec;
148     setTFoot(foot, ec);
149     return foot.release();
150 }
151
152 void HTMLTableElement::deleteTFoot()
153 {
154     ExceptionCode ec;
155     removeChild(tFoot(), ec);
156 }
157
158 PassRefPtr<HTMLElement> HTMLTableElement::createTBody()
159 {
160     RefPtr<HTMLTableSectionElement> body = HTMLTableSectionElement::create(tbodyTag, document());
161     Node* referenceElement = lastBody() ? lastBody()->nextSibling() : 0;
162     insertBefore(body, referenceElement, ASSERT_NO_EXCEPTION);
163     return body.release();
164 }
165
166 PassRefPtr<HTMLElement> HTMLTableElement::createCaption()
167 {
168     if (HTMLTableCaptionElement* existingCaption = caption())
169         return existingCaption;
170     RefPtr<HTMLTableCaptionElement> caption = HTMLTableCaptionElement::create(captionTag, document());
171     ExceptionCode ec;
172     setCaption(caption, ec);
173     return caption.release();
174 }
175
176 void HTMLTableElement::deleteCaption()
177 {
178     ExceptionCode ec;
179     removeChild(caption(), ec);
180 }
181
182 HTMLTableSectionElement* HTMLTableElement::lastBody() const
183 {
184     for (Node* child = lastChild(); child; child = child->previousSibling()) {
185         if (child->hasTagName(tbodyTag))
186             return static_cast<HTMLTableSectionElement*>(child);
187     }
188     return 0;
189 }
190
191 PassRefPtr<HTMLElement> HTMLTableElement::insertRow(int index, ExceptionCode& ec)
192 {
193     if (index < -1) {
194         ec = INDEX_SIZE_ERR;
195         return 0;
196     }
197
198     RefPtr<Node> protectFromMutationEvents(this);
199
200     RefPtr<HTMLTableRowElement> lastRow = 0;
201     RefPtr<HTMLTableRowElement> row = 0;
202     if (index == -1)
203         lastRow = HTMLTableRowsCollection::lastRow(this);
204     else {
205         for (int i = 0; i <= index; ++i) {
206             row = HTMLTableRowsCollection::rowAfter(this, lastRow.get());
207             if (!row) {
208                 if (i != index) {
209                     ec = INDEX_SIZE_ERR;
210                     return 0;
211                 }
212                 break;
213             }
214             lastRow = row;
215         }
216     }
217
218     RefPtr<ContainerNode> parent;
219     if (lastRow)
220         parent = row ? row->parentNode() : lastRow->parentNode();
221     else {
222         parent = lastBody();
223         if (!parent) {
224             RefPtr<HTMLTableSectionElement> newBody = HTMLTableSectionElement::create(tbodyTag, document());
225             RefPtr<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document());
226             newBody->appendChild(newRow, ec);
227             appendChild(newBody.release(), ec);
228             return newRow.release();
229         }
230     }
231
232     RefPtr<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document());
233     parent->insertBefore(newRow, row.get(), ec);
234     return newRow.release();
235 }
236
237 void HTMLTableElement::deleteRow(int index, ExceptionCode& ec)
238 {
239     HTMLTableRowElement* row = 0;
240     if (index == -1)
241         row = HTMLTableRowsCollection::lastRow(this);
242     else {
243         for (int i = 0; i <= index; ++i) {
244             row = HTMLTableRowsCollection::rowAfter(this, row);
245             if (!row)
246                 break;
247         }
248     }
249     if (!row) {
250         ec = INDEX_SIZE_ERR;
251         return;
252     }
253     row->remove(ec);
254 }
255
256 static inline bool isTableCellAncestor(Node* n)
257 {
258     return n->hasTagName(theadTag) || n->hasTagName(tbodyTag) ||
259            n->hasTagName(tfootTag) || n->hasTagName(trTag) ||
260            n->hasTagName(thTag);
261 }
262
263 static bool setTableCellsChanged(Node* n)
264 {
265     ASSERT(n);
266     bool cellChanged = false;
267
268     if (n->hasTagName(tdTag))
269         cellChanged = true;
270     else if (isTableCellAncestor(n)) {
271         for (Node* child = n->firstChild(); child; child = child->nextSibling())
272             cellChanged |= setTableCellsChanged(child);
273     }
274
275     if (cellChanged)
276        n->setNeedsStyleRecalc();
277
278     return cellChanged;
279 }
280
281 static bool getBordersFromFrameAttributeValue(const AtomicString& value, bool& borderTop, bool& borderRight, bool& borderBottom, bool& borderLeft)
282 {
283     borderTop = false;
284     borderRight = false;
285     borderBottom = false;
286     borderLeft = false;
287
288     if (equalIgnoringCase(value, "above"))
289         borderTop = true;
290     else if (equalIgnoringCase(value, "below"))
291         borderBottom = true;
292     else if (equalIgnoringCase(value, "hsides"))
293         borderTop = borderBottom = true;
294     else if (equalIgnoringCase(value, "vsides"))
295         borderLeft = borderRight = true;
296     else if (equalIgnoringCase(value, "lhs"))
297         borderLeft = true;
298     else if (equalIgnoringCase(value, "rhs"))
299         borderRight = true;
300     else if (equalIgnoringCase(value, "box") || equalIgnoringCase(value, "border"))
301         borderTop = borderBottom = borderLeft = borderRight = true;
302     else if (!equalIgnoringCase(value, "void"))
303         return false;
304     return true;
305 }
306
307 void HTMLTableElement::collectStyleForAttribute(const Attribute& attribute, StylePropertySet* style)
308 {
309     if (attribute.name() == widthAttr)
310         addHTMLLengthToStyle(style, CSSPropertyWidth, attribute.value());
311     else if (attribute.name() == heightAttr)
312         addHTMLLengthToStyle(style, CSSPropertyHeight, attribute.value());
313     else if (attribute.name() == borderAttr) {
314         int borderWidth = attribute.isEmpty() ? 1 : attribute.value().toInt();
315         addPropertyToAttributeStyle(style, CSSPropertyBorderWidth, borderWidth, CSSPrimitiveValue::CSS_PX);
316     } else if (attribute.name() == bordercolorAttr) {
317         if (!attribute.isEmpty())
318             addHTMLColorToStyle(style, CSSPropertyBorderColor, attribute.value());
319     } else if (attribute.name() == bgcolorAttr)
320         addHTMLColorToStyle(style, CSSPropertyBackgroundColor, attribute.value());
321     else if (attribute.name() == backgroundAttr) {
322         String url = stripLeadingAndTrailingHTMLSpaces(attribute.value());
323         if (!url.isEmpty())
324             style->setProperty(CSSProperty(CSSPropertyBackgroundImage, CSSImageValue::create(document()->completeURL(url).string())));
325     } else if (attribute.name() == valignAttr) {
326         if (!attribute.isEmpty())
327             addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, attribute.value());
328     } else if (attribute.name() == cellspacingAttr) {
329         if (!attribute.isEmpty())
330             addHTMLLengthToStyle(style, CSSPropertyBorderSpacing, attribute.value());
331     } else if (attribute.name() == vspaceAttr) {
332         addHTMLLengthToStyle(style, CSSPropertyMarginTop, attribute.value());
333         addHTMLLengthToStyle(style, CSSPropertyMarginBottom, attribute.value());
334     } else if (attribute.name() == hspaceAttr) {
335         addHTMLLengthToStyle(style, CSSPropertyMarginLeft, attribute.value());
336         addHTMLLengthToStyle(style, CSSPropertyMarginRight, attribute.value());
337     } else if (attribute.name() == alignAttr) {
338         if (!attribute.value().isEmpty()) {
339             if (equalIgnoringCase(attribute.value(), "center")) {
340                 addPropertyToAttributeStyle(style, CSSPropertyWebkitMarginStart, CSSValueAuto);
341                 addPropertyToAttributeStyle(style, CSSPropertyWebkitMarginEnd, CSSValueAuto);
342             } else
343                 addPropertyToAttributeStyle(style, CSSPropertyFloat, attribute.value());
344         }
345     } else if (attribute.name() == rulesAttr) {
346         // The presence of a valid rules attribute causes border collapsing to be enabled.
347         if (m_rulesAttr != UnsetRules)
348             addPropertyToAttributeStyle(style, CSSPropertyBorderCollapse, CSSValueCollapse);
349     } else if (attribute.name() == frameAttr) {
350         bool borderTop;
351         bool borderRight;
352         bool borderBottom;
353         bool borderLeft;
354         if (getBordersFromFrameAttributeValue(attribute.value(), borderTop, borderRight, borderBottom, borderLeft)) {
355             addPropertyToAttributeStyle(style, CSSPropertyBorderWidth, CSSValueThin);
356             addPropertyToAttributeStyle(style, CSSPropertyBorderTopStyle, borderTop ? CSSValueSolid : CSSValueHidden);
357             addPropertyToAttributeStyle(style, CSSPropertyBorderBottomStyle, borderBottom ? CSSValueSolid : CSSValueHidden);
358             addPropertyToAttributeStyle(style, CSSPropertyBorderLeftStyle, borderLeft ? CSSValueSolid : CSSValueHidden);
359             addPropertyToAttributeStyle(style, CSSPropertyBorderRightStyle, borderRight ? CSSValueSolid : CSSValueHidden);
360         }
361     } else
362         HTMLElement::collectStyleForAttribute(attribute, style);
363 }
364
365 bool HTMLTableElement::isPresentationAttribute(const QualifiedName& name) const
366 {
367     if (name == widthAttr || name == heightAttr || name == bgcolorAttr || name == backgroundAttr || name == valignAttr || name == vspaceAttr || name == hspaceAttr || name == alignAttr || name == cellspacingAttr || name == borderAttr || name == bordercolorAttr || name == frameAttr || name == rulesAttr)
368         return true;
369     return HTMLElement::isPresentationAttribute(name);
370 }
371
372 void HTMLTableElement::parseAttribute(const Attribute& attribute)
373 {
374     CellBorders bordersBefore = cellBorders();
375     unsigned short oldPadding = m_padding;
376
377     if (attribute.name() == borderAttr)  {
378         // FIXME: This attribute is a mess.
379         m_borderAttr = true;
380         if (!attribute.isNull()) {
381             int border = attribute.isEmpty() ? 1 : attribute.value().toInt();
382             m_borderAttr = border;
383         }
384     } else if (attribute.name() == bordercolorAttr) {
385         m_borderColorAttr = !attribute.isEmpty();
386     } else if (attribute.name() == frameAttr) {
387         // FIXME: This attribute is a mess.
388         bool borderTop;
389         bool borderRight;
390         bool borderBottom;
391         bool borderLeft;
392         m_frameAttr = getBordersFromFrameAttributeValue(attribute.value(), borderTop, borderRight, borderBottom, borderLeft);
393     } else if (attribute.name() == rulesAttr) {
394         m_rulesAttr = UnsetRules;
395         if (equalIgnoringCase(attribute.value(), "none"))
396             m_rulesAttr = NoneRules;
397         else if (equalIgnoringCase(attribute.value(), "groups"))
398             m_rulesAttr = GroupsRules;
399         else if (equalIgnoringCase(attribute.value(), "rows"))
400             m_rulesAttr = RowsRules;
401         if (equalIgnoringCase(attribute.value(), "cols"))
402             m_rulesAttr = ColsRules;
403         if (equalIgnoringCase(attribute.value(), "all"))
404             m_rulesAttr = AllRules;
405     } else if (attribute.name() == cellpaddingAttr) {
406         if (!attribute.value().isEmpty())
407             m_padding = max(0, attribute.value().toInt());
408         else
409             m_padding = 1;
410     } else if (attribute.name() == colsAttr) {
411         // ###
412     } else
413         HTMLElement::parseAttribute(attribute);
414
415     if (bordersBefore != cellBorders() || oldPadding != m_padding) {
416         m_sharedCellStyle = 0;
417         bool cellChanged = false;
418         for (Node* child = firstChild(); child; child = child->nextSibling())
419             cellChanged |= setTableCellsChanged(child);
420         if (cellChanged)
421             setNeedsStyleRecalc();
422     }
423 }
424
425 static StylePropertySet* leakBorderStyle(int value)
426 {
427     RefPtr<StylePropertySet> style = StylePropertySet::create();
428     style->setProperty(CSSPropertyBorderTopStyle, value);
429     style->setProperty(CSSPropertyBorderBottomStyle, value);
430     style->setProperty(CSSPropertyBorderLeftStyle, value);
431     style->setProperty(CSSPropertyBorderRightStyle, value);
432     return style.release().leakRef();
433 }
434
435 const StylePropertySet* HTMLTableElement::additionalAttributeStyle()
436 {
437     if (m_frameAttr)
438         return 0;
439     
440     if (!m_borderAttr && !m_borderColorAttr) {
441         // Setting the border to 'hidden' allows it to win over any border
442         // set on the table's cells during border-conflict resolution.
443         if (m_rulesAttr != UnsetRules) {
444             static StylePropertySet* solidBorderStyle = leakBorderStyle(CSSValueHidden);
445             return solidBorderStyle;
446         }
447         return 0;
448     }
449
450     if (m_borderColorAttr) {
451         static StylePropertySet* solidBorderStyle = leakBorderStyle(CSSValueSolid);
452         return solidBorderStyle;
453     }
454     static StylePropertySet* outsetBorderStyle = leakBorderStyle(CSSValueOutset);
455     return outsetBorderStyle;
456 }
457
458 HTMLTableElement::CellBorders HTMLTableElement::cellBorders() const
459 {
460     switch (m_rulesAttr) {
461         case NoneRules:
462         case GroupsRules:
463             return NoBorders;
464         case AllRules:
465             return SolidBorders;
466         case ColsRules:
467             return SolidBordersColsOnly;
468         case RowsRules:
469             return SolidBordersRowsOnly;
470         case UnsetRules:
471             if (!m_borderAttr)
472                 return NoBorders;
473             if (m_borderColorAttr)
474                 return SolidBorders;
475             return InsetBorders;
476     }
477     ASSERT_NOT_REACHED();
478     return NoBorders;
479 }
480
481 PassRefPtr<StylePropertySet> HTMLTableElement::createSharedCellStyle()
482 {
483     RefPtr<StylePropertySet> style = StylePropertySet::create();
484
485     switch (cellBorders()) {
486     case SolidBordersColsOnly:
487         style->setProperty(CSSPropertyBorderLeftWidth, CSSValueThin);
488         style->setProperty(CSSPropertyBorderRightWidth, CSSValueThin);
489         style->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid);
490         style->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid);
491         style->setProperty(CSSPropertyBorderColor, cssValuePool().createInheritedValue());
492         break;
493     case SolidBordersRowsOnly:
494         style->setProperty(CSSPropertyBorderTopWidth, CSSValueThin);
495         style->setProperty(CSSPropertyBorderBottomWidth, CSSValueThin);
496         style->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid);
497         style->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid);
498         style->setProperty(CSSPropertyBorderColor, cssValuePool().createInheritedValue());
499         break;
500     case SolidBorders:
501         style->setProperty(CSSPropertyBorderWidth, cssValuePool().createValue(1, CSSPrimitiveValue::CSS_PX));
502         style->setProperty(CSSPropertyBorderStyle, cssValuePool().createIdentifierValue(CSSValueSolid));
503         style->setProperty(CSSPropertyBorderColor, cssValuePool().createInheritedValue());
504         break;
505     case InsetBorders:
506         style->setProperty(CSSPropertyBorderWidth, cssValuePool().createValue(1, CSSPrimitiveValue::CSS_PX));
507         style->setProperty(CSSPropertyBorderStyle, cssValuePool().createIdentifierValue(CSSValueInset));
508         style->setProperty(CSSPropertyBorderColor, cssValuePool().createInheritedValue());
509         break;
510     case NoBorders:
511         style->setProperty(CSSPropertyBorderWidth, cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX));
512         break;
513     }
514
515     if (m_padding)
516         style->setProperty(CSSPropertyPadding, cssValuePool().createValue(m_padding, CSSPrimitiveValue::CSS_PX));
517
518     return style.release();
519 }
520
521 const StylePropertySet* HTMLTableElement::additionalCellStyle()
522 {
523     if (!m_sharedCellStyle)
524         m_sharedCellStyle = createSharedCellStyle();
525     return m_sharedCellStyle.get();
526 }
527
528 static StylePropertySet* leakGroupBorderStyle(int rows)
529 {
530     RefPtr<StylePropertySet> style = StylePropertySet::create();
531     if (rows) {
532         style->setProperty(CSSPropertyBorderTopWidth, CSSValueThin);
533         style->setProperty(CSSPropertyBorderBottomWidth, CSSValueThin);
534         style->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid);
535         style->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid);
536     } else {
537         style->setProperty(CSSPropertyBorderLeftWidth, CSSValueThin);
538         style->setProperty(CSSPropertyBorderRightWidth, CSSValueThin);
539         style->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid);
540         style->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid);
541     }
542     return style.release().leakRef();
543 }
544
545 const StylePropertySet* HTMLTableElement::additionalGroupStyle(bool rows)
546 {
547     if (m_rulesAttr != GroupsRules)
548         return 0;
549
550     if (rows) {
551         static StylePropertySet* rowBorderStyle = leakGroupBorderStyle(true);
552         return rowBorderStyle;
553     }
554     static StylePropertySet* columnBorderStyle = leakGroupBorderStyle(false);
555     return columnBorderStyle;
556 }
557
558 bool HTMLTableElement::isURLAttribute(const Attribute& attribute) const
559 {
560     return attribute.name() == backgroundAttr || HTMLElement::isURLAttribute(attribute);
561 }
562
563 PassRefPtr<HTMLCollection> HTMLTableElement::rows()
564 {
565     return ensureCachedHTMLCollection(TableRows);
566 }
567
568 PassRefPtr<HTMLCollection> HTMLTableElement::tBodies()
569 {
570     return ensureCachedHTMLCollection(TableTBodies);
571 }
572
573 String HTMLTableElement::rules() const
574 {
575     return getAttribute(rulesAttr);
576 }
577
578 String HTMLTableElement::summary() const
579 {
580     return getAttribute(summaryAttr);
581 }
582
583 void HTMLTableElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
584 {
585     HTMLElement::addSubresourceAttributeURLs(urls);
586
587     addSubresourceURL(urls, document()->completeURL(getAttribute(backgroundAttr)));
588 }
589
590 }