Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: third_party/WebKit/Source/core/html/ImageDocument.cpp

Issue 2646663002: [Blink] Don't center images in Android WebViews (Closed)
Patch Set: Update test Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 30 matching lines...) Expand all
41 #include "core/html/HTMLDivElement.h" 41 #include "core/html/HTMLDivElement.h"
42 #include "core/html/HTMLHeadElement.h" 42 #include "core/html/HTMLHeadElement.h"
43 #include "core/html/HTMLHtmlElement.h" 43 #include "core/html/HTMLHtmlElement.h"
44 #include "core/html/HTMLImageElement.h" 44 #include "core/html/HTMLImageElement.h"
45 #include "core/html/HTMLMetaElement.h" 45 #include "core/html/HTMLMetaElement.h"
46 #include "core/layout/LayoutObject.h" 46 #include "core/layout/LayoutObject.h"
47 #include "core/loader/DocumentLoader.h" 47 #include "core/loader/DocumentLoader.h"
48 #include "core/loader/FrameLoader.h" 48 #include "core/loader/FrameLoader.h"
49 #include "core/loader/FrameLoaderClient.h" 49 #include "core/loader/FrameLoaderClient.h"
50 #include "core/loader/resource/ImageResource.h" 50 #include "core/loader/resource/ImageResource.h"
51 #include "core/page/Page.h"
51 #include "platform/HostWindow.h" 52 #include "platform/HostWindow.h"
52 #include "wtf/text/StringBuilder.h" 53 #include "wtf/text/StringBuilder.h"
53 #include <limits> 54 #include <limits>
54 55
55 using namespace std; 56 using namespace std;
56 57
57 namespace { 58 namespace {
58 59
59 // The base square size is set to 10 because it rounds nicely for both the 60 // The base square size is set to 10 because it rounds nicely for both the
60 // minimum scale (0.1) and maximum scale (5.0). 61 // minimum scale (0.1) and maximum scale (5.0).
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 if (isStopped()) { 588 if (isStopped()) {
588 m_imageElement = nullptr; 589 m_imageElement = nullptr;
589 return nullptr; 590 return nullptr;
590 } 591 }
591 } 592 }
592 593
593 return m_imageElement->cachedImageResourceForImageDocument(); 594 return m_imageElement->cachedImageResourceForImageDocument();
594 } 595 }
595 596
596 bool ImageDocument::shouldShrinkToFit() const { 597 bool ImageDocument::shouldShrinkToFit() const {
597 return frame()->isMainFrame(); 598 // WebView automatically resizes to match the contents, causing an infinite
599 // loop as the contents then resize to match the window. To prevent this,
600 // disallow images from shrinking to fit for WebViews.
601 bool isWrapContentWebView =
602 page() ? page()->settings().getForceZeroLayoutHeight() : false;
603 return frame()->isMainFrame() && !isWrapContentWebView;
598 } 604 }
599 605
600 DEFINE_TRACE(ImageDocument) { 606 DEFINE_TRACE(ImageDocument) {
601 visitor->trace(m_divElement); 607 visitor->trace(m_divElement);
602 visitor->trace(m_imageElement); 608 visitor->trace(m_imageElement);
603 HTMLDocument::trace(visitor); 609 HTMLDocument::trace(visitor);
604 } 610 }
605 611
606 // -------- 612 // --------
607 613
(...skipping 11 matching lines...) Expand all
619 } 625 }
620 626
621 bool ImageEventListener::operator==(const EventListener& listener) const { 627 bool ImageEventListener::operator==(const EventListener& listener) const {
622 if (const ImageEventListener* imageEventListener = 628 if (const ImageEventListener* imageEventListener =
623 ImageEventListener::cast(&listener)) 629 ImageEventListener::cast(&listener))
624 return m_doc == imageEventListener->m_doc; 630 return m_doc == imageEventListener->m_doc;
625 return false; 631 return false;
626 } 632 }
627 633
628 } // namespace blink 634 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/ImageDocument.h ('k') | third_party/WebKit/Source/core/html/ImageDocumentTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698