OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 { | 236 { |
237 if (!m_imageElement || m_imageElement->document() != this || pageZoomFactor(
this) > 1) | 237 if (!m_imageElement || m_imageElement->document() != this || pageZoomFactor(
this) > 1) |
238 return; | 238 return; |
239 | 239 |
240 LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m
_imageElement->renderer(), pageZoomFactor(this)); | 240 LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m
_imageElement->renderer(), pageZoomFactor(this)); |
241 | 241 |
242 float scale = this->scale(); | 242 float scale = this->scale(); |
243 m_imageElement->setWidth(static_cast<int>(imageSize.width() * scale)); | 243 m_imageElement->setWidth(static_cast<int>(imageSize.width() * scale)); |
244 m_imageElement->setHeight(static_cast<int>(imageSize.height() * scale)); | 244 m_imageElement->setHeight(static_cast<int>(imageSize.height() * scale)); |
245 | 245 |
246 m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueWebkitZoom
In); | 246 m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueZoomIn); |
247 } | 247 } |
248 | 248 |
249 void ImageDocument::imageClicked(int x, int y) | 249 void ImageDocument::imageClicked(int x, int y) |
250 { | 250 { |
251 if (!m_imageSizeIsKnown || imageFitsInWindow()) | 251 if (!m_imageSizeIsKnown || imageFitsInWindow()) |
252 return; | 252 return; |
253 | 253 |
254 m_shouldShrinkImage = !m_shouldShrinkImage; | 254 m_shouldShrinkImage = !m_shouldShrinkImage; |
255 | 255 |
256 if (m_shouldShrinkImage) | 256 if (m_shouldShrinkImage) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 if (!m_imageElement || !m_imageSizeIsKnown || m_imageElement->document() !=
this || pageZoomFactor(this) < 1) | 292 if (!m_imageElement || !m_imageSizeIsKnown || m_imageElement->document() !=
this || pageZoomFactor(this) < 1) |
293 return; | 293 return; |
294 | 294 |
295 LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m
_imageElement->renderer(), 1.0f); | 295 LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m
_imageElement->renderer(), 1.0f); |
296 m_imageElement->setWidth(imageSize.width()); | 296 m_imageElement->setWidth(imageSize.width()); |
297 m_imageElement->setHeight(imageSize.height()); | 297 m_imageElement->setHeight(imageSize.height()); |
298 | 298 |
299 if (imageFitsInWindow()) | 299 if (imageFitsInWindow()) |
300 m_imageElement->removeInlineStyleProperty(CSSPropertyCursor); | 300 m_imageElement->removeInlineStyleProperty(CSSPropertyCursor); |
301 else | 301 else |
302 m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueWebkit
ZoomOut); | 302 m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueZoomOu
t); |
303 | 303 |
304 m_didShrinkImage = false; | 304 m_didShrinkImage = false; |
305 } | 305 } |
306 | 306 |
307 bool ImageDocument::imageFitsInWindow() const | 307 bool ImageDocument::imageFitsInWindow() const |
308 { | 308 { |
309 if (!m_imageElement || m_imageElement->document() != this) | 309 if (!m_imageElement || m_imageElement->document() != this) |
310 return true; | 310 return true; |
311 | 311 |
312 FrameView* view = frame()->view(); | 312 FrameView* view = frame()->view(); |
(...skipping 12 matching lines...) Expand all Loading... |
325 return; | 325 return; |
326 | 326 |
327 bool fitsInWindow = imageFitsInWindow(); | 327 bool fitsInWindow = imageFitsInWindow(); |
328 | 328 |
329 // If the image has been explicitly zoomed in, restore the cursor if the ima
ge fits | 329 // If the image has been explicitly zoomed in, restore the cursor if the ima
ge fits |
330 // and set it to a zoom out cursor if the image doesn't fit | 330 // and set it to a zoom out cursor if the image doesn't fit |
331 if (!m_shouldShrinkImage) { | 331 if (!m_shouldShrinkImage) { |
332 if (fitsInWindow) | 332 if (fitsInWindow) |
333 m_imageElement->removeInlineStyleProperty(CSSPropertyCursor); | 333 m_imageElement->removeInlineStyleProperty(CSSPropertyCursor); |
334 else | 334 else |
335 m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueWe
bkitZoomOut); | 335 m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueZo
omOut); |
336 return; | 336 return; |
337 } | 337 } |
338 | 338 |
339 if (m_didShrinkImage) { | 339 if (m_didShrinkImage) { |
340 // If the window has been resized so that the image fits, restore the im
age size | 340 // If the window has been resized so that the image fits, restore the im
age size |
341 // otherwise update the restored image size. | 341 // otherwise update the restored image size. |
342 if (fitsInWindow) | 342 if (fitsInWindow) |
343 restoreImageSize(); | 343 restoreImageSize(); |
344 else | 344 else |
345 resizeImageToFit(); | 345 resizeImageToFit(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 } | 390 } |
391 | 391 |
392 bool ImageEventListener::operator==(const EventListener& listener) | 392 bool ImageEventListener::operator==(const EventListener& listener) |
393 { | 393 { |
394 if (const ImageEventListener* imageEventListener = ImageEventListener::cast(
&listener)) | 394 if (const ImageEventListener* imageEventListener = ImageEventListener::cast(
&listener)) |
395 return m_doc == imageEventListener->m_doc; | 395 return m_doc == imageEventListener->m_doc; |
396 return false; | 396 return false; |
397 } | 397 } |
398 | 398 |
399 } | 399 } |
OLD | NEW |