| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 width = getAttribute(HTMLNames::widthAttr).toInt(&ok); | 238 int width = getAttribute(HTMLNames::widthAttr).toInt(&ok); |
| 239 if (ok) | 239 if (ok) |
| 240 return width; | 240 return width; |
| 241 | 241 |
| 242 // if the image is available, use its width | 242 // if the image is available, use its width |
| 243 if (imageLoader().image()) | 243 if (imageLoader().image()) |
| 244 return imageLoader().image()->imageSizeForRenderer(renderer(), 1.0f)
.width(); | 244 return imageLoader().image()->imageSizeForRenderer(renderer()).width
(); |
| 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 ? box->contentBoxRect().pixelSnappedWidth() : 0; | 253 return box ? box->contentBoxRect().pixelSnappedWidth() : 0; |
| 254 } | 254 } |
| 255 | 255 |
| 256 int HTMLImageElement::height(bool ignorePendingStylesheets) | 256 int HTMLImageElement::height(bool ignorePendingStylesheets) |
| 257 { | 257 { |
| 258 if (!renderer()) { | 258 if (!renderer()) { |
| 259 // check the attribute first for an explicit pixel value | 259 // check the attribute first for an explicit pixel value |
| 260 bool ok; | 260 bool ok; |
| 261 int height = getAttribute(HTMLNames::heightAttr).toInt(&ok); | 261 int height = getAttribute(HTMLNames::heightAttr).toInt(&ok); |
| 262 if (ok) | 262 if (ok) |
| 263 return height; | 263 return height; |
| 264 | 264 |
| 265 // if the image is available, use its height | 265 // if the image is available, use its height |
| 266 if (imageLoader().image()) | 266 if (imageLoader().image()) |
| 267 return imageLoader().image()->imageSizeForRenderer(renderer(), 1.0f)
.height(); | 267 return imageLoader().image()->imageSizeForRenderer(renderer()).heigh
t(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 if (ignorePendingStylesheets) | 270 if (ignorePendingStylesheets) |
| 271 document().updateLayoutIgnorePendingStylesheets(); | 271 document().updateLayoutIgnorePendingStylesheets(); |
| 272 else | 272 else |
| 273 document().updateLayout(); | 273 document().updateLayout(); |
| 274 | 274 |
| 275 RenderBox* box = renderBox(); | 275 RenderBox* box = renderBox(); |
| 276 return box ? box->contentBoxRect().pixelSnappedHeight() : 0; | 276 return box ? box->contentBoxRect().pixelSnappedHeight() : 0; |
| 277 } | 277 } |
| 278 | 278 |
| 279 int HTMLImageElement::naturalWidth() const | 279 int HTMLImageElement::naturalWidth() const |
| 280 { | 280 { |
| 281 if (!imageLoader().image()) | 281 if (!imageLoader().image()) |
| 282 return 0; | 282 return 0; |
| 283 | 283 |
| 284 return imageLoader().image()->imageSizeForRenderer(renderer(), 1.0f, ImageRe
source::IntrinsicSize).width(); | 284 return imageLoader().image()->imageSizeForRenderer(renderer(), ImageResource
::IntrinsicSize).width(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 int HTMLImageElement::naturalHeight() const | 287 int HTMLImageElement::naturalHeight() const |
| 288 { | 288 { |
| 289 if (!imageLoader().image()) | 289 if (!imageLoader().image()) |
| 290 return 0; | 290 return 0; |
| 291 | 291 |
| 292 return imageLoader().image()->imageSizeForRenderer(renderer(), 1.0f, ImageRe
source::IntrinsicSize).height(); | 292 return imageLoader().image()->imageSizeForRenderer(renderer(), ImageResource
::IntrinsicSize).height(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 const String& HTMLImageElement::currentSrc() const | 295 const String& HTMLImageElement::currentSrc() const |
| 296 { | 296 { |
| 297 // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#do
m-img-currentsrc | 297 // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#do
m-img-currentsrc |
| 298 // The currentSrc IDL attribute must return the img element's current reques
t's current URL. | 298 // The currentSrc IDL attribute must return the img element's current reques
t's current URL. |
| 299 // Initially, the pending request turns into current request when it is eith
er available or broken. | 299 // Initially, the pending request turns into current request when it is eith
er available or broken. |
| 300 // We use the image's dimensions as a proxy to it being in any of these stat
es. | 300 // We use the image's dimensions as a proxy to it being in any of these stat
es. |
| 301 if (!imageLoader().image() || !imageLoader().image()->image() || !imageLoade
r().image()->image()->width()) | 301 if (!imageLoader().image() || !imageLoader().image()->image() || !imageLoade
r().image()->image()->width()) |
| 302 return emptyAtom; | 302 return emptyAtom; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 393 |
| 394 *status = NormalSourceImageStatus; | 394 *status = NormalSourceImageStatus; |
| 395 return sourceImage->imageForDefaultFrame(); | 395 return sourceImage->imageForDefaultFrame(); |
| 396 } | 396 } |
| 397 | 397 |
| 398 FloatSize HTMLImageElement::sourceSize() const | 398 FloatSize HTMLImageElement::sourceSize() const |
| 399 { | 399 { |
| 400 ImageResource* image = cachedImage(); | 400 ImageResource* image = cachedImage(); |
| 401 if (!image) | 401 if (!image) |
| 402 return FloatSize(); | 402 return FloatSize(); |
| 403 LayoutSize size; | 403 return image->imageSizeForRenderer(renderer()); // FIXME: Not sure about thi
s. |
| 404 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo
ut this. | |
| 405 | |
| 406 return size; | |
| 407 } | 404 } |
| 408 | 405 |
| 409 FloatSize HTMLImageElement::defaultDestinationSize() const | 406 FloatSize HTMLImageElement::defaultDestinationSize() const |
| 410 { | 407 { |
| 411 ImageResource* image = cachedImage(); | 408 ImageResource* image = cachedImage(); |
| 412 if (!image) | 409 if (!image) |
| 413 return FloatSize(); | 410 return FloatSize(); |
| 414 LayoutSize size; | 411 LayoutSize size; |
| 415 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo
ut this. | 412 size = image->imageSizeForRenderer(renderer()); // FIXME: Not sure about thi
s. |
| 416 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i
mage()->hasRelativeWidth()) | 413 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i
mage()->hasRelativeWidth()) |
| 417 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); | 414 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); |
| 418 return size; | 415 return size; |
| 419 } | 416 } |
| 420 | 417 |
| 421 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be
havior) | 418 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be
havior) |
| 422 { | 419 { |
| 423 unsigned effectiveSize = 0; | 420 unsigned effectiveSize = 0; |
| 424 if (RuntimeEnabledFeatures::pictureSizesEnabled()) { | 421 if (RuntimeEnabledFeatures::pictureSizesEnabled()) { |
| 425 String sizes = getAttribute(HTMLNames::sizesAttr); | 422 String sizes = getAttribute(HTMLNames::sizesAttr); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 439 } | 436 } |
| 440 imageLoader().updateFromElement(behavior); | 437 imageLoader().updateFromElement(behavior); |
| 441 } | 438 } |
| 442 | 439 |
| 443 const KURL& HTMLImageElement::sourceURL() const | 440 const KURL& HTMLImageElement::sourceURL() const |
| 444 { | 441 { |
| 445 return cachedImage()->response().url(); | 442 return cachedImage()->response().url(); |
| 446 } | 443 } |
| 447 | 444 |
| 448 } | 445 } |
| OLD | NEW |