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 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv
ed. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv
ed. |
5 * Copyright (C) 2010 Google Inc. All rights reserved. | 5 * Copyright (C) 2010 Google Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 int width = getAttribute(widthAttr).toInt(&ok); | 215 int width = getAttribute(widthAttr).toInt(&ok); |
216 if (ok) | 216 if (ok) |
217 return width; | 217 return width; |
218 | 218 |
219 // if the image is available, use its width | 219 // if the image is available, use its width |
220 if (m_imageLoader.image()) | 220 if (m_imageLoader.image()) |
221 return m_imageLoader.image()->imageSizeForRenderer(renderer(), 1.0f)
.width(); | 221 return m_imageLoader.image()->imageSizeForRenderer(renderer(), 1.0f)
.width(); |
222 } | 222 } |
223 | 223 |
224 if (ignorePendingStylesheets) | 224 if (ignorePendingStylesheets) |
225 document()->updateLayoutIgnorePendingStylesheets(); | 225 document().updateLayoutIgnorePendingStylesheets(); |
226 else | 226 else |
227 document()->updateLayout(); | 227 document().updateLayout(); |
228 | 228 |
229 RenderBox* box = renderBox(); | 229 RenderBox* box = renderBox(); |
230 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth()
, box) : 0; | 230 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth()
, box) : 0; |
231 } | 231 } |
232 | 232 |
233 int HTMLImageElement::height(bool ignorePendingStylesheets) | 233 int HTMLImageElement::height(bool ignorePendingStylesheets) |
234 { | 234 { |
235 if (!renderer()) { | 235 if (!renderer()) { |
236 // check the attribute first for an explicit pixel value | 236 // check the attribute first for an explicit pixel value |
237 bool ok; | 237 bool ok; |
238 int height = getAttribute(heightAttr).toInt(&ok); | 238 int height = getAttribute(heightAttr).toInt(&ok); |
239 if (ok) | 239 if (ok) |
240 return height; | 240 return height; |
241 | 241 |
242 // if the image is available, use its height | 242 // if the image is available, use its height |
243 if (m_imageLoader.image()) | 243 if (m_imageLoader.image()) |
244 return m_imageLoader.image()->imageSizeForRenderer(renderer(), 1.0f)
.height(); | 244 return m_imageLoader.image()->imageSizeForRenderer(renderer(), 1.0f)
.height(); |
245 } | 245 } |
246 | 246 |
247 if (ignorePendingStylesheets) | 247 if (ignorePendingStylesheets) |
248 document()->updateLayoutIgnorePendingStylesheets(); | 248 document().updateLayoutIgnorePendingStylesheets(); |
249 else | 249 else |
250 document()->updateLayout(); | 250 document().updateLayout(); |
251 | 251 |
252 RenderBox* box = renderBox(); | 252 RenderBox* box = renderBox(); |
253 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight(
), box) : 0; | 253 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight(
), box) : 0; |
254 } | 254 } |
255 | 255 |
256 int HTMLImageElement::naturalWidth() const | 256 int HTMLImageElement::naturalWidth() const |
257 { | 257 { |
258 if (!m_imageLoader.image()) | 258 if (!m_imageLoader.image()) |
259 return 0; | 259 return 0; |
260 | 260 |
(...skipping 28 matching lines...) Expand all Loading... |
289 return !equalIgnoringCase(getAttribute(draggableAttr), "false"); | 289 return !equalIgnoringCase(getAttribute(draggableAttr), "false"); |
290 } | 290 } |
291 | 291 |
292 void HTMLImageElement::setHeight(int value) | 292 void HTMLImageElement::setHeight(int value) |
293 { | 293 { |
294 setAttribute(heightAttr, String::number(value)); | 294 setAttribute(heightAttr, String::number(value)); |
295 } | 295 } |
296 | 296 |
297 KURL HTMLImageElement::src() const | 297 KURL HTMLImageElement::src() const |
298 { | 298 { |
299 return document()->completeURL(getAttribute(srcAttr)); | 299 return document().completeURL(getAttribute(srcAttr)); |
300 } | 300 } |
301 | 301 |
302 void HTMLImageElement::setSrc(const String& value) | 302 void HTMLImageElement::setSrc(const String& value) |
303 { | 303 { |
304 setAttribute(srcAttr, value); | 304 setAttribute(srcAttr, value); |
305 } | 305 } |
306 | 306 |
307 void HTMLImageElement::setWidth(int value) | 307 void HTMLImageElement::setWidth(int value) |
308 { | 308 { |
309 setAttribute(widthAttr, String::number(value)); | 309 setAttribute(widthAttr, String::number(value)); |
(...skipping 25 matching lines...) Expand all Loading... |
335 { | 335 { |
336 return m_imageLoader.imageComplete(); | 336 return m_imageLoader.imageComplete(); |
337 } | 337 } |
338 | 338 |
339 void HTMLImageElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) cons
t | 339 void HTMLImageElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) cons
t |
340 { | 340 { |
341 HTMLElement::addSubresourceAttributeURLs(urls); | 341 HTMLElement::addSubresourceAttributeURLs(urls); |
342 | 342 |
343 addSubresourceURL(urls, src()); | 343 addSubresourceURL(urls, src()); |
344 // FIXME: What about when the usemap attribute begins with "#"? | 344 // FIXME: What about when the usemap attribute begins with "#"? |
345 addSubresourceURL(urls, document()->completeURL(getAttribute(usemapAttr))); | 345 addSubresourceURL(urls, document().completeURL(getAttribute(usemapAttr))); |
346 } | 346 } |
347 | 347 |
348 void HTMLImageElement::didMoveToNewDocument(Document* oldDocument) | 348 void HTMLImageElement::didMoveToNewDocument(Document* oldDocument) |
349 { | 349 { |
350 m_imageLoader.elementDidMoveToNewDocument(); | 350 m_imageLoader.elementDidMoveToNewDocument(); |
351 HTMLElement::didMoveToNewDocument(oldDocument); | 351 HTMLElement::didMoveToNewDocument(oldDocument); |
352 } | 352 } |
353 | 353 |
354 bool HTMLImageElement::isServerMap() const | 354 bool HTMLImageElement::isServerMap() const |
355 { | 355 { |
356 if (!fastHasAttribute(ismapAttr)) | 356 if (!fastHasAttribute(ismapAttr)) |
357 return false; | 357 return false; |
358 | 358 |
359 const AtomicString& usemap = fastGetAttribute(usemapAttr); | 359 const AtomicString& usemap = fastGetAttribute(usemapAttr); |
360 | 360 |
361 // If the usemap attribute starts with '#', it refers to a map element in th
e document. | 361 // If the usemap attribute starts with '#', it refers to a map element in th
e document. |
362 if (usemap.string()[0] == '#') | 362 if (usemap.string()[0] == '#') |
363 return false; | 363 return false; |
364 | 364 |
365 return document()->completeURL(stripLeadingAndTrailingHTMLSpaces(usemap)).is
Empty(); | 365 return document().completeURL(stripLeadingAndTrailingHTMLSpaces(usemap)).isE
mpty(); |
366 } | 366 } |
367 | 367 |
368 Image* HTMLImageElement::imageContents() | 368 Image* HTMLImageElement::imageContents() |
369 { | 369 { |
370 if (!m_imageLoader.imageComplete()) | 370 if (!m_imageLoader.imageComplete()) |
371 return 0; | 371 return 0; |
372 | 372 |
373 return m_imageLoader.image()->image(); | 373 return m_imageLoader.image()->image(); |
374 } | 374 } |
375 | 375 |
376 } | 376 } |
OLD | NEW |