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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "core/html/HTMLImageElement.h" | 46 #include "core/html/HTMLImageElement.h" |
47 #include "core/html/HTMLMetaElement.h" | 47 #include "core/html/HTMLMetaElement.h" |
48 #include "core/layout/LayoutObject.h" | 48 #include "core/layout/LayoutObject.h" |
49 #include "core/loader/DocumentLoader.h" | 49 #include "core/loader/DocumentLoader.h" |
50 #include "core/loader/FrameLoader.h" | 50 #include "core/loader/FrameLoader.h" |
51 #include "core/loader/resource/ImageResource.h" | 51 #include "core/loader/resource/ImageResource.h" |
52 #include "core/page/Page.h" | 52 #include "core/page/Page.h" |
53 #include "platform/HostWindow.h" | 53 #include "platform/HostWindow.h" |
54 #include "wtf/text/StringBuilder.h" | 54 #include "wtf/text/StringBuilder.h" |
55 | 55 |
56 using namespace std; | |
57 | |
58 namespace { | 56 namespace { |
59 | 57 |
60 // The base square size is set to 10 because it rounds nicely for both the | 58 // The base square size is set to 10 because it rounds nicely for both the |
61 // minimum scale (0.1) and maximum scale (5.0). | 59 // minimum scale (0.1) and maximum scale (5.0). |
62 const int kBaseCheckerSize = 10; | 60 const int kBaseCheckerSize = 10; |
63 | 61 |
64 } // namespace | 62 } // namespace |
65 | 63 |
66 namespace blink { | 64 namespace blink { |
67 | 65 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 zoom); | 308 zoom); |
311 | 309 |
312 // We want to pretend the viewport is larger when the user has zoomed the | 310 // We want to pretend the viewport is larger when the user has zoomed the |
313 // page in (but not when the zoom is coming from device scale). | 311 // page in (but not when the zoom is coming from device scale). |
314 const float manualZoom = | 312 const float manualZoom = |
315 zoom / view->getHostWindow()->windowToViewportScalar(1.f); | 313 zoom / view->getHostWindow()->windowToViewportScalar(1.f); |
316 float widthScale = view->width() * manualZoom / imageSize.width().toFloat(); | 314 float widthScale = view->width() * manualZoom / imageSize.width().toFloat(); |
317 float heightScale = | 315 float heightScale = |
318 view->height() * manualZoom / imageSize.height().toFloat(); | 316 view->height() * manualZoom / imageSize.height().toFloat(); |
319 | 317 |
320 return min(widthScale, heightScale); | 318 return std::min(widthScale, heightScale); |
321 } | 319 } |
322 | 320 |
323 void ImageDocument::resizeImageToFit() { | 321 void ImageDocument::resizeImageToFit() { |
324 DCHECK_EQ(m_shrinkToFitMode, Desktop); | 322 DCHECK_EQ(m_shrinkToFitMode, Desktop); |
325 if (!m_imageElement || m_imageElement->document() != this) | 323 if (!m_imageElement || m_imageElement->document() != this) |
326 return; | 324 return; |
327 | 325 |
328 LayoutSize imageSize = cachedImageSize(m_imageElement); | 326 LayoutSize imageSize = cachedImageSize(m_imageElement); |
329 | 327 |
330 const float scale = this->scale(); | 328 const float scale = this->scale(); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 } | 623 } |
626 | 624 |
627 bool ImageEventListener::operator==(const EventListener& listener) const { | 625 bool ImageEventListener::operator==(const EventListener& listener) const { |
628 if (const ImageEventListener* imageEventListener = | 626 if (const ImageEventListener* imageEventListener = |
629 ImageEventListener::cast(&listener)) | 627 ImageEventListener::cast(&listener)) |
630 return m_doc == imageEventListener->m_doc; | 628 return m_doc == imageEventListener->m_doc; |
631 return false; | 629 return false; |
632 } | 630 } |
633 | 631 |
634 } // namespace blink | 632 } // namespace blink |
OLD | NEW |