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

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

Issue 136823005: Fix distorted image issue when open some images in a new browser window. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: create renderer to get correct size Created 6 years, 10 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 { 123 {
124 if (!length) 124 if (!length)
125 return; 125 return;
126 126
127 Frame* frame = document()->frame(); 127 Frame* frame = document()->frame();
128 Settings* settings = frame->settings(); 128 Settings* settings = frame->settings();
129 if (!frame->loader().client()->allowImage(!settings || settings->imagesEnabl ed(), document()->url())) 129 if (!frame->loader().client()->allowImage(!settings || settings->imagesEnabl ed(), document()->url()))
130 return; 130 return;
131 131
132 document()->cachedImage()->appendData(data, length); 132 document()->cachedImage()->appendData(data, length);
133 if (!document()->imageElement()->renderer())
134 document()->updateStyleIfNeeded();
esprehn 2014/02/19 02:13:02 Remove the if statement, just call updateStyleIfNe
133 document()->imageUpdated(); 135 document()->imageUpdated();
134 } 136 }
135 137
136 void ImageDocumentParser::finish() 138 void ImageDocumentParser::finish()
137 { 139 {
138 if (!isStopped() && document()->imageElement()) { 140 if (!isStopped() && document()->imageElement()) {
139 ImageResource* cachedImage = document()->cachedImage(); 141 ImageResource* cachedImage = document()->cachedImage();
140 cachedImage->finish(); 142 cachedImage->finish();
141 cachedImage->setResponse(document()->frame()->loader().documentLoader()- >response()); 143 cachedImage->setResponse(document()->frame()->loader().documentLoader()- >response());
142 144
143 // Report the natural image size in the page title, regardless of zoom l evel. 145 // Report the natural image size in the page title, regardless of zoom l evel.
144 // At a zoom level of 1 the image is guaranteed to have an integer size. 146 // At a zoom level of 1 the image is guaranteed to have an integer size.
145 IntSize size = flooredIntSize(cachedImage->imageSizeForRenderer(document ()->imageElement()->renderer(), 1.0f)); 147 IntSize size = flooredIntSize(cachedImage->imageSizeForRenderer(document ()->imageElement()->renderer(), 1.0f));
Noel Gordon 2014/02/19 04:15:57 The renderer() is non-null here with this CL. Tha
146 if (size.width()) { 148 if (size.width()) {
147 // Compute the title, we use the decoded filename of the resource, f alling 149 // Compute the title, we use the decoded filename of the resource, f alling
148 // back on the (decoded) hostname if there is no path. 150 // back on the (decoded) hostname if there is no path.
149 String fileName = decodeURLEscapeSequences(document()->url().lastPat hComponent()); 151 String fileName = decodeURLEscapeSequences(document()->url().lastPat hComponent());
150 if (fileName.isEmpty()) 152 if (fileName.isEmpty())
151 fileName = document()->url().host(); 153 fileName = document()->url().host();
152 document()->setTitle(imageTitle(fileName, size)); 154 document()->setTitle(imageTitle(fileName, size));
153 } 155 }
154 156
155 document()->imageUpdated(); 157 document()->imageUpdated();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 } 384 }
383 385
384 bool ImageEventListener::operator==(const EventListener& listener) 386 bool ImageEventListener::operator==(const EventListener& listener)
385 { 387 {
386 if (const ImageEventListener* imageEventListener = ImageEventListener::cast( &listener)) 388 if (const ImageEventListener* imageEventListener = ImageEventListener::cast( &listener))
387 return m_doc == imageEventListener->m_doc; 389 return m_doc == imageEventListener->m_doc;
388 return false; 390 return false;
389 } 391 }
390 392
391 } 393 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698