| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Simon Hausmann (hausmann@kde.org) | 4 * (C) 2000 Simon Hausmann (hausmann@kde.org) |
| 5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 6 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 if (name == backgroundAttr || name == marginwidthAttr || name == leftmarginA
ttr || name == marginheightAttr || name == topmarginAttr || name == bgcolorAttr
|| name == textAttr || name == bgpropertiesAttr) | 67 if (name == backgroundAttr || name == marginwidthAttr || name == leftmarginA
ttr || name == marginheightAttr || name == topmarginAttr || name == bgcolorAttr
|| name == textAttr || name == bgpropertiesAttr) |
| 68 return true; | 68 return true; |
| 69 return HTMLElement::isPresentationAttribute(name); | 69 return HTMLElement::isPresentationAttribute(name); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void HTMLBodyElement::collectStyleForPresentationAttribute(const QualifiedName&
name, const AtomicString& value, MutableStylePropertySet* style) | 72 void HTMLBodyElement::collectStyleForPresentationAttribute(const QualifiedName&
name, const AtomicString& value, MutableStylePropertySet* style) |
| 73 { | 73 { |
| 74 if (name == backgroundAttr) { | 74 if (name == backgroundAttr) { |
| 75 String url = stripLeadingAndTrailingHTMLSpaces(value); | 75 String url = stripLeadingAndTrailingHTMLSpaces(value); |
| 76 if (!url.isEmpty()) { | 76 if (!url.isEmpty()) { |
| 77 RefPtr<CSSImageValue> imageValue = CSSImageValue::create(document()-
>completeURL(url).string()); | 77 RefPtr<CSSImageValue> imageValue = CSSImageValue::create(document().
completeURL(url).string()); |
| 78 imageValue->setInitiator(localName()); | 78 imageValue->setInitiator(localName()); |
| 79 style->setProperty(CSSProperty(CSSPropertyBackgroundImage, imageValu
e.release())); | 79 style->setProperty(CSSProperty(CSSPropertyBackgroundImage, imageValu
e.release())); |
| 80 } | 80 } |
| 81 } else if (name == marginwidthAttr || name == leftmarginAttr) { | 81 } else if (name == marginwidthAttr || name == leftmarginAttr) { |
| 82 addHTMLLengthToStyle(style, CSSPropertyMarginRight, value); | 82 addHTMLLengthToStyle(style, CSSPropertyMarginRight, value); |
| 83 addHTMLLengthToStyle(style, CSSPropertyMarginLeft, value); | 83 addHTMLLengthToStyle(style, CSSPropertyMarginLeft, value); |
| 84 } else if (name == marginheightAttr || name == topmarginAttr) { | 84 } else if (name == marginheightAttr || name == topmarginAttr) { |
| 85 addHTMLLengthToStyle(style, CSSPropertyMarginBottom, value); | 85 addHTMLLengthToStyle(style, CSSPropertyMarginBottom, value); |
| 86 addHTMLLengthToStyle(style, CSSPropertyMarginTop, value); | 86 addHTMLLengthToStyle(style, CSSPropertyMarginTop, value); |
| 87 } else if (name == bgcolorAttr) { | 87 } else if (name == bgcolorAttr) { |
| 88 addHTMLColorToStyle(style, CSSPropertyBackgroundColor, value); | 88 addHTMLColorToStyle(style, CSSPropertyBackgroundColor, value); |
| 89 } else if (name == textAttr) { | 89 } else if (name == textAttr) { |
| 90 addHTMLColorToStyle(style, CSSPropertyColor, value); | 90 addHTMLColorToStyle(style, CSSPropertyColor, value); |
| 91 } else if (name == bgpropertiesAttr) { | 91 } else if (name == bgpropertiesAttr) { |
| 92 if (equalIgnoringCase(value, "fixed")) | 92 if (equalIgnoringCase(value, "fixed")) |
| 93 addPropertyToPresentationAttributeStyle(style, CSSPropertyBackgroundA
ttachment, CSSValueFixed); | 93 addPropertyToPresentationAttributeStyle(style, CSSPropertyBackgroundA
ttachment, CSSValueFixed); |
| 94 } else | 94 } else |
| 95 HTMLElement::collectStyleForPresentationAttribute(name, value, style); | 95 HTMLElement::collectStyleForPresentationAttribute(name, value, style); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void HTMLBodyElement::parseAttribute(const QualifiedName& name, const AtomicStri
ng& value) | 98 void HTMLBodyElement::parseAttribute(const QualifiedName& name, const AtomicStri
ng& value) |
| 99 { | 99 { |
| 100 if (name == vlinkAttr || name == alinkAttr || name == linkAttr) { | 100 if (name == vlinkAttr || name == alinkAttr || name == linkAttr) { |
| 101 if (value.isNull()) { | 101 if (value.isNull()) { |
| 102 if (name == linkAttr) | 102 if (name == linkAttr) |
| 103 document()->textLinkColors().resetLinkColor(); | 103 document().textLinkColors().resetLinkColor(); |
| 104 else if (name == vlinkAttr) | 104 else if (name == vlinkAttr) |
| 105 document()->textLinkColors().resetVisitedLinkColor(); | 105 document().textLinkColors().resetVisitedLinkColor(); |
| 106 else | 106 else |
| 107 document()->textLinkColors().resetActiveLinkColor(); | 107 document().textLinkColors().resetActiveLinkColor(); |
| 108 } else { | 108 } else { |
| 109 RGBA32 color; | 109 RGBA32 color; |
| 110 if (CSSParser::parseColor(color, value, !document()->inQuirksMode())
) { | 110 if (CSSParser::parseColor(color, value, !document().inQuirksMode()))
{ |
| 111 if (name == linkAttr) | 111 if (name == linkAttr) |
| 112 document()->textLinkColors().setLinkColor(color); | 112 document().textLinkColors().setLinkColor(color); |
| 113 else if (name == vlinkAttr) | 113 else if (name == vlinkAttr) |
| 114 document()->textLinkColors().setVisitedLinkColor(color); | 114 document().textLinkColors().setVisitedLinkColor(color); |
| 115 else | 115 else |
| 116 document()->textLinkColors().setActiveLinkColor(color); | 116 document().textLinkColors().setActiveLinkColor(color); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 setNeedsStyleRecalc(); | 120 setNeedsStyleRecalc(); |
| 121 } else if (name == onloadAttr) | 121 } else if (name == onloadAttr) |
| 122 document()->setWindowAttributeEventListener(eventNames().loadEvent, crea
teAttributeEventListener(document()->frame(), name, value)); | 122 document().setWindowAttributeEventListener(eventNames().loadEvent, creat
eAttributeEventListener(document().frame(), name, value)); |
| 123 else if (name == onbeforeunloadAttr) | 123 else if (name == onbeforeunloadAttr) |
| 124 document()->setWindowAttributeEventListener(eventNames().beforeunloadEve
nt, createAttributeEventListener(document()->frame(), name, value)); | 124 document().setWindowAttributeEventListener(eventNames().beforeunloadEven
t, createAttributeEventListener(document().frame(), name, value)); |
| 125 else if (name == onunloadAttr) | 125 else if (name == onunloadAttr) |
| 126 document()->setWindowAttributeEventListener(eventNames().unloadEvent, cr
eateAttributeEventListener(document()->frame(), name, value)); | 126 document().setWindowAttributeEventListener(eventNames().unloadEvent, cre
ateAttributeEventListener(document().frame(), name, value)); |
| 127 else if (name == onpagehideAttr) | 127 else if (name == onpagehideAttr) |
| 128 document()->setWindowAttributeEventListener(eventNames().pagehideEvent,
createAttributeEventListener(document()->frame(), name, value)); | 128 document().setWindowAttributeEventListener(eventNames().pagehideEvent, c
reateAttributeEventListener(document().frame(), name, value)); |
| 129 else if (name == onpageshowAttr) | 129 else if (name == onpageshowAttr) |
| 130 document()->setWindowAttributeEventListener(eventNames().pageshowEvent,
createAttributeEventListener(document()->frame(), name, value)); | 130 document().setWindowAttributeEventListener(eventNames().pageshowEvent, c
reateAttributeEventListener(document().frame(), name, value)); |
| 131 else if (name == onpopstateAttr) | 131 else if (name == onpopstateAttr) |
| 132 document()->setWindowAttributeEventListener(eventNames().popstateEvent,
createAttributeEventListener(document()->frame(), name, value)); | 132 document().setWindowAttributeEventListener(eventNames().popstateEvent, c
reateAttributeEventListener(document().frame(), name, value)); |
| 133 else if (name == onblurAttr) | 133 else if (name == onblurAttr) |
| 134 document()->setWindowAttributeEventListener(eventNames().blurEvent, crea
teAttributeEventListener(document()->frame(), name, value)); | 134 document().setWindowAttributeEventListener(eventNames().blurEvent, creat
eAttributeEventListener(document().frame(), name, value)); |
| 135 else if (name == onfocusAttr) | 135 else if (name == onfocusAttr) |
| 136 document()->setWindowAttributeEventListener(eventNames().focusEvent, cre
ateAttributeEventListener(document()->frame(), name, value)); | 136 document().setWindowAttributeEventListener(eventNames().focusEvent, crea
teAttributeEventListener(document().frame(), name, value)); |
| 137 #if ENABLE(ORIENTATION_EVENTS) | 137 #if ENABLE(ORIENTATION_EVENTS) |
| 138 else if (name == onorientationchangeAttr) | 138 else if (name == onorientationchangeAttr) |
| 139 document()->setWindowAttributeEventListener(eventNames().orientationchan
geEvent, createAttributeEventListener(document()->frame(), name, value)); | 139 document().setWindowAttributeEventListener(eventNames().orientationchang
eEvent, createAttributeEventListener(document().frame(), name, value)); |
| 140 #endif | 140 #endif |
| 141 else if (name == onhashchangeAttr) | 141 else if (name == onhashchangeAttr) |
| 142 document()->setWindowAttributeEventListener(eventNames().hashchangeEvent
, createAttributeEventListener(document()->frame(), name, value)); | 142 document().setWindowAttributeEventListener(eventNames().hashchangeEvent,
createAttributeEventListener(document().frame(), name, value)); |
| 143 else if (name == onresizeAttr) | 143 else if (name == onresizeAttr) |
| 144 document()->setWindowAttributeEventListener(eventNames().resizeEvent, cr
eateAttributeEventListener(document()->frame(), name, value)); | 144 document().setWindowAttributeEventListener(eventNames().resizeEvent, cre
ateAttributeEventListener(document().frame(), name, value)); |
| 145 else if (name == onscrollAttr) | 145 else if (name == onscrollAttr) |
| 146 document()->setWindowAttributeEventListener(eventNames().scrollEvent, cr
eateAttributeEventListener(document()->frame(), name, value)); | 146 document().setWindowAttributeEventListener(eventNames().scrollEvent, cre
ateAttributeEventListener(document().frame(), name, value)); |
| 147 else if (name == onselectionchangeAttr) | 147 else if (name == onselectionchangeAttr) |
| 148 document()->setAttributeEventListener(eventNames().selectionchangeEvent,
createAttributeEventListener(document()->frame(), name, value)); | 148 document().setAttributeEventListener(eventNames().selectionchangeEvent,
createAttributeEventListener(document().frame(), name, value)); |
| 149 else if (name == onstorageAttr) | 149 else if (name == onstorageAttr) |
| 150 document()->setWindowAttributeEventListener(eventNames().storageEvent, c
reateAttributeEventListener(document()->frame(), name, value)); | 150 document().setWindowAttributeEventListener(eventNames().storageEvent, cr
eateAttributeEventListener(document().frame(), name, value)); |
| 151 else if (name == ononlineAttr) | 151 else if (name == ononlineAttr) |
| 152 document()->setWindowAttributeEventListener(eventNames().onlineEvent, cr
eateAttributeEventListener(document()->frame(), name, value)); | 152 document().setWindowAttributeEventListener(eventNames().onlineEvent, cre
ateAttributeEventListener(document().frame(), name, value)); |
| 153 else if (name == onofflineAttr) | 153 else if (name == onofflineAttr) |
| 154 document()->setWindowAttributeEventListener(eventNames().offlineEvent, c
reateAttributeEventListener(document()->frame(), name, value)); | 154 document().setWindowAttributeEventListener(eventNames().offlineEvent, cr
eateAttributeEventListener(document().frame(), name, value)); |
| 155 else | 155 else |
| 156 HTMLElement::parseAttribute(name, value); | 156 HTMLElement::parseAttribute(name, value); |
| 157 } | 157 } |
| 158 | 158 |
| 159 Node::InsertionNotificationRequest HTMLBodyElement::insertedInto(ContainerNode*
insertionPoint) | 159 Node::InsertionNotificationRequest HTMLBodyElement::insertedInto(ContainerNode*
insertionPoint) |
| 160 { | 160 { |
| 161 HTMLElement::insertedInto(insertionPoint); | 161 HTMLElement::insertedInto(insertionPoint); |
| 162 if (insertionPoint->inDocument()) { | 162 if (insertionPoint->inDocument()) { |
| 163 // FIXME: It's surprising this is web compatible since it means a margin
width | 163 // FIXME: It's surprising this is web compatible since it means a margin
width |
| 164 // and marginheight attribute can magically appear on the <body> of all
documents | 164 // and marginheight attribute can magically appear on the <body> of all
documents |
| 165 // embedded through <iframe> or <frame>. | 165 // embedded through <iframe> or <frame>. |
| 166 Element* ownerElement = document()->ownerElement(); | 166 Element* ownerElement = document().ownerElement(); |
| 167 if (ownerElement && ownerElement->isFrameElementBase()) { | 167 if (ownerElement && ownerElement->isFrameElementBase()) { |
| 168 HTMLFrameElementBase* ownerFrameElement = toHTMLFrameElementBase(own
erElement); | 168 HTMLFrameElementBase* ownerFrameElement = toHTMLFrameElementBase(own
erElement); |
| 169 int marginWidth = ownerFrameElement->marginWidth(); | 169 int marginWidth = ownerFrameElement->marginWidth(); |
| 170 if (marginWidth != -1) | 170 if (marginWidth != -1) |
| 171 setAttribute(marginwidthAttr, String::number(marginWidth)); | 171 setAttribute(marginwidthAttr, String::number(marginWidth)); |
| 172 int marginHeight = ownerFrameElement->marginHeight(); | 172 int marginHeight = ownerFrameElement->marginHeight(); |
| 173 if (marginHeight != -1) | 173 if (marginHeight != -1) |
| 174 setAttribute(marginheightAttr, String::number(marginHeight)); | 174 setAttribute(marginheightAttr, String::number(marginHeight)); |
| 175 } | 175 } |
| 176 } | 176 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 return value; | 247 return value; |
| 248 // Needed because of truncation (rather than rounding) when scaling up. | 248 // Needed because of truncation (rather than rounding) when scaling up. |
| 249 if (zoomFactor > 1) | 249 if (zoomFactor > 1) |
| 250 value++; | 250 value++; |
| 251 return static_cast<int>(value / zoomFactor); | 251 return static_cast<int>(value / zoomFactor); |
| 252 } | 252 } |
| 253 | 253 |
| 254 int HTMLBodyElement::scrollLeft() | 254 int HTMLBodyElement::scrollLeft() |
| 255 { | 255 { |
| 256 // Update the document's layout. | 256 // Update the document's layout. |
| 257 Document* document = this->document(); | 257 Document& document = this->document(); |
| 258 document->updateLayoutIgnorePendingStylesheets(); | 258 document.updateLayoutIgnorePendingStylesheets(); |
| 259 FrameView* view = document->view(); | 259 FrameView* view = document.view(); |
| 260 return view ? adjustForZoom(view->scrollX(), document) : 0; | 260 return view ? adjustForZoom(view->scrollX(), &document) : 0; |
| 261 } | 261 } |
| 262 | 262 |
| 263 void HTMLBodyElement::setScrollLeft(int scrollLeft) | 263 void HTMLBodyElement::setScrollLeft(int scrollLeft) |
| 264 { | 264 { |
| 265 Document* document = this->document(); | 265 Document& document = this->document(); |
| 266 document->updateLayoutIgnorePendingStylesheets(); | 266 document.updateLayoutIgnorePendingStylesheets(); |
| 267 Frame* frame = document->frame(); | 267 Frame* frame = document.frame(); |
| 268 if (!frame) | 268 if (!frame) |
| 269 return; | 269 return; |
| 270 FrameView* view = frame->view(); | 270 FrameView* view = frame->view(); |
| 271 if (!view) | 271 if (!view) |
| 272 return; | 272 return; |
| 273 view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZo
omFactor()), view->scrollY())); | 273 view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZo
omFactor()), view->scrollY())); |
| 274 } | 274 } |
| 275 | 275 |
| 276 int HTMLBodyElement::scrollTop() | 276 int HTMLBodyElement::scrollTop() |
| 277 { | 277 { |
| 278 // Update the document's layout. | 278 // Update the document's layout. |
| 279 Document* document = this->document(); | 279 Document& document = this->document(); |
| 280 document->updateLayoutIgnorePendingStylesheets(); | 280 document.updateLayoutIgnorePendingStylesheets(); |
| 281 FrameView* view = document->view(); | 281 FrameView* view = document.view(); |
| 282 return view ? adjustForZoom(view->scrollY(), document) : 0; | 282 return view ? adjustForZoom(view->scrollY(), &document) : 0; |
| 283 } | 283 } |
| 284 | 284 |
| 285 void HTMLBodyElement::setScrollTop(int scrollTop) | 285 void HTMLBodyElement::setScrollTop(int scrollTop) |
| 286 { | 286 { |
| 287 Document* document = this->document(); | 287 Document& document = this->document(); |
| 288 document->updateLayoutIgnorePendingStylesheets(); | 288 document.updateLayoutIgnorePendingStylesheets(); |
| 289 Frame* frame = document->frame(); | 289 Frame* frame = document.frame(); |
| 290 if (!frame) | 290 if (!frame) |
| 291 return; | 291 return; |
| 292 FrameView* view = frame->view(); | 292 FrameView* view = frame->view(); |
| 293 if (!view) | 293 if (!view) |
| 294 return; | 294 return; |
| 295 view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop
* frame->pageZoomFactor()))); | 295 view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop
* frame->pageZoomFactor()))); |
| 296 } | 296 } |
| 297 | 297 |
| 298 int HTMLBodyElement::scrollHeight() | 298 int HTMLBodyElement::scrollHeight() |
| 299 { | 299 { |
| 300 // Update the document's layout. | 300 // Update the document's layout. |
| 301 Document* document = this->document(); | 301 Document& document = this->document(); |
| 302 document->updateLayoutIgnorePendingStylesheets(); | 302 document.updateLayoutIgnorePendingStylesheets(); |
| 303 FrameView* view = document->view(); | 303 FrameView* view = document.view(); |
| 304 return view ? adjustForZoom(view->contentsHeight(), document) : 0; | 304 return view ? adjustForZoom(view->contentsHeight(), &document) : 0; |
| 305 } | 305 } |
| 306 | 306 |
| 307 int HTMLBodyElement::scrollWidth() | 307 int HTMLBodyElement::scrollWidth() |
| 308 { | 308 { |
| 309 // Update the document's layout. | 309 // Update the document's layout. |
| 310 Document* document = this->document(); | 310 Document& document = this->document(); |
| 311 document->updateLayoutIgnorePendingStylesheets(); | 311 document.updateLayoutIgnorePendingStylesheets(); |
| 312 FrameView* view = document->view(); | 312 FrameView* view = document.view(); |
| 313 return view ? adjustForZoom(view->contentsWidth(), document) : 0; | 313 return view ? adjustForZoom(view->contentsWidth(), &document) : 0; |
| 314 } | 314 } |
| 315 | 315 |
| 316 void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const | 316 void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const |
| 317 { | 317 { |
| 318 HTMLElement::addSubresourceAttributeURLs(urls); | 318 HTMLElement::addSubresourceAttributeURLs(urls); |
| 319 | 319 |
| 320 addSubresourceURL(urls, document()->completeURL(getAttribute(backgroundAttr)
)); | 320 addSubresourceURL(urls, document().completeURL(getAttribute(backgroundAttr))
); |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace WebCore | 323 } // namespace WebCore |
| OLD | NEW |