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

Side by Side Diff: Source/WebCore/html/ImageInputType.cpp

Issue 12573007: Merge 145423 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 years, 9 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
« no previous file with comments | « Source/WebCore/html/ImageInputType.h ('k') | Source/WebCore/html/InputType.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 4 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 RenderImage* image = toRenderImage(element()->renderer()); 112 RenderImage* image = toRenderImage(element()->renderer());
113 if (!image) 113 if (!image)
114 return; 114 return;
115 image->updateAltText(); 115 image->updateAltText();
116 } 116 }
117 117
118 void ImageInputType::srcAttributeChanged() 118 void ImageInputType::srcAttributeChanged()
119 { 119 {
120 if (!element()->renderer()) 120 if (!element()->renderer())
121 return; 121 return;
122 if (!m_imageLoader) 122 element()->imageLoader()->updateFromElementIgnoringPreviousError();
123 m_imageLoader = adoptPtr(new HTMLImageLoader(element()));
124 m_imageLoader->updateFromElementIgnoringPreviousError();
125 } 123 }
126 124
127 void ImageInputType::attach() 125 void ImageInputType::attach()
128 { 126 {
129 BaseButtonInputType::attach(); 127 BaseButtonInputType::attach();
130 128
131 if (!m_imageLoader) 129 HTMLImageLoader* imageLoader = element()->imageLoader();
132 m_imageLoader = adoptPtr(new HTMLImageLoader(element())); 130 imageLoader->updateFromElement();
133 m_imageLoader->updateFromElement();
134 131
135 RenderImage* renderer = toRenderImage(element()->renderer()); 132 RenderImage* renderer = toRenderImage(element()->renderer());
136 if (!renderer) 133 if (!renderer)
137 return; 134 return;
138 135
139 if (m_imageLoader->hasPendingBeforeLoadEvent()) 136 if (imageLoader->hasPendingBeforeLoadEvent())
140 return; 137 return;
141 138
142 RenderImageResource* imageResource = renderer->imageResource(); 139 RenderImageResource* imageResource = renderer->imageResource();
143 imageResource->setCachedImage(m_imageLoader->image()); 140 imageResource->setCachedImage(imageLoader->image());
144 141
145 // If we have no image at all because we have no src attribute, set 142 // If we have no image at all because we have no src attribute, set
146 // image height and width for the alt text instead. 143 // image height and width for the alt text instead.
147 if (!m_imageLoader->image() && !imageResource->cachedImage()) 144 if (!imageLoader->image() && !imageResource->cachedImage())
148 renderer->setImageSizeForAltText(); 145 renderer->setImageSizeForAltText();
149 } 146 }
150 147
151 void ImageInputType::willMoveToNewOwnerDocument()
152 {
153 BaseButtonInputType::willMoveToNewOwnerDocument();
154 if (m_imageLoader)
155 m_imageLoader->elementDidMoveToNewDocument();
156 }
157
158 bool ImageInputType::shouldRespectAlignAttribute() 148 bool ImageInputType::shouldRespectAlignAttribute()
159 { 149 {
160 return true; 150 return true;
161 } 151 }
162 152
163 bool ImageInputType::canBeSuccessfulSubmitButton() 153 bool ImageInputType::canBeSuccessfulSubmitButton()
164 { 154 {
165 return true; 155 return true;
166 } 156 }
167 157
(...skipping 16 matching lines...) Expand all
184 { 174 {
185 RefPtr<HTMLInputElement> element = this->element(); 175 RefPtr<HTMLInputElement> element = this->element();
186 176
187 if (!element->renderer()) { 177 if (!element->renderer()) {
188 // Check the attribute first for an explicit pixel value. 178 // Check the attribute first for an explicit pixel value.
189 unsigned height; 179 unsigned height;
190 if (parseHTMLNonNegativeInteger(element->fastGetAttribute(heightAttr), h eight)) 180 if (parseHTMLNonNegativeInteger(element->fastGetAttribute(heightAttr), h eight))
191 return height; 181 return height;
192 182
193 // If the image is available, use its height. 183 // If the image is available, use its height.
194 if (m_imageLoader && m_imageLoader->image()) 184 if (element->hasImageLoader()) {
195 return m_imageLoader->image()->imageSizeForRenderer(element->rendere r(), 1).height(); 185 HTMLImageLoader* imageLoader = element->imageLoader();
186 if (imageLoader->image())
187 return imageLoader->image()->imageSizeForRenderer(element->rende rer(), 1).height();
188 }
196 } 189 }
197 190
198 element->document()->updateLayout(); 191 element->document()->updateLayout();
199 192
200 RenderBox* box = element->renderBox(); 193 RenderBox* box = element->renderBox();
201 return box ? adjustForAbsoluteZoom(box->contentHeight(), box) : 0; 194 return box ? adjustForAbsoluteZoom(box->contentHeight(), box) : 0;
202 } 195 }
203 196
204 unsigned ImageInputType::width() const 197 unsigned ImageInputType::width() const
205 { 198 {
206 RefPtr<HTMLInputElement> element = this->element(); 199 RefPtr<HTMLInputElement> element = this->element();
207 200
208 if (!element->renderer()) { 201 if (!element->renderer()) {
209 // Check the attribute first for an explicit pixel value. 202 // Check the attribute first for an explicit pixel value.
210 unsigned width; 203 unsigned width;
211 if (parseHTMLNonNegativeInteger(element->fastGetAttribute(widthAttr), wi dth)) 204 if (parseHTMLNonNegativeInteger(element->fastGetAttribute(widthAttr), wi dth))
212 return width; 205 return width;
213 206
214 // If the image is available, use its width. 207 // If the image is available, use its width.
215 if (m_imageLoader && m_imageLoader->image()) 208 if (element->hasImageLoader()) {
216 return m_imageLoader->image()->imageSizeForRenderer(element->rendere r(), 1).width(); 209 HTMLImageLoader* imageLoader = element->imageLoader();
210 if (imageLoader->image())
211 return imageLoader->image()->imageSizeForRenderer(element->rende rer(), 1).width();
212 }
217 } 213 }
218 214
219 element->document()->updateLayout(); 215 element->document()->updateLayout();
220 216
221 RenderBox* box = element->renderBox(); 217 RenderBox* box = element->renderBox();
222 return box ? adjustForAbsoluteZoom(box->contentWidth(), box) : 0; 218 return box ? adjustForAbsoluteZoom(box->contentWidth(), box) : 0;
223 } 219 }
224 220
225 } // namespace WebCore 221 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/html/ImageInputType.h ('k') | Source/WebCore/html/InputType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698