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

Side by Side Diff: sky/engine/core/html/HTMLImageElement.cpp

Issue 1055323002: Remove the x,y,width,height methods from HTMLImageElement. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: remove attrs Created 5 years, 8 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 | « sky/engine/core/html/HTMLImageElement.h ('k') | no next file » | 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed.
5 * Copyright (C) 2010 Google Inc. All rights reserved. 5 * Copyright (C) 2010 Google Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_elementCrea tedByParser ? ImageLoader::ForceLoadImmediately : ImageLoader::LoadNormally); 171 imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_elementCrea tedByParser ? ImageLoader::ForceLoadImmediately : ImageLoader::LoadNormally);
172 } 172 }
173 173
174 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint) 174 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint)
175 { 175 {
176 if (m_listener) 176 if (m_listener)
177 document().mediaQueryMatcher().removeViewportListener(m_listener.get()); 177 document().mediaQueryMatcher().removeViewportListener(m_listener.get());
178 HTMLElement::removedFrom(insertionPoint); 178 HTMLElement::removedFrom(insertionPoint);
179 } 179 }
180 180
181 int HTMLImageElement::width()
182 {
183 if (!renderer()) {
184 // check the attribute first for an explicit pixel value
185 bool ok;
186 int width = getAttribute(HTMLNames::widthAttr).toInt(&ok);
187 if (ok)
188 return width;
189
190 // if the image is available, use its width
191 if (imageLoader().image())
192 return imageLoader().image()->imageSizeForRenderer(renderer()).width ();
193 }
194
195 document().updateLayout();
196
197 RenderBox* box = renderBox();
198 return box ? box->contentBoxRect().pixelSnappedWidth() : 0;
199 }
200
201 int HTMLImageElement::height()
202 {
203 if (!renderer()) {
204 // check the attribute first for an explicit pixel value
205 bool ok;
206 int height = getAttribute(HTMLNames::heightAttr).toInt(&ok);
207 if (ok)
208 return height;
209
210 // if the image is available, use its height
211 if (imageLoader().image())
212 return imageLoader().image()->imageSizeForRenderer(renderer()).heigh t();
213 }
214
215 document().updateLayout();
216
217 RenderBox* box = renderBox();
218 return box ? box->contentBoxRect().pixelSnappedHeight() : 0;
219 }
220
221 int HTMLImageElement::naturalWidth() const 181 int HTMLImageElement::naturalWidth() const
222 { 182 {
223 if (!imageLoader().image()) 183 if (!imageLoader().image())
224 return 0; 184 return 0;
225 185
226 return imageLoader().image()->imageSizeForRenderer(renderer(), ImageResource ::IntrinsicSize).width(); 186 return imageLoader().image()->imageSizeForRenderer(renderer(), ImageResource ::IntrinsicSize).width();
227 } 187 }
228 188
229 int HTMLImageElement::naturalHeight() const 189 int HTMLImageElement::naturalHeight() const
230 { 190 {
(...skipping 14 matching lines...) Expand all
245 205
246 return imageLoader().image()->url().string(); 206 return imageLoader().image()->url().string();
247 } 207 }
248 208
249 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const 209 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const
250 { 210 {
251 return attribute.name() == HTMLNames::srcAttr 211 return attribute.name() == HTMLNames::srcAttr
252 || HTMLElement::isURLAttribute(attribute); 212 || HTMLElement::isURLAttribute(attribute);
253 } 213 }
254 214
255 void HTMLImageElement::setHeight(int value)
256 {
257 setIntegralAttribute(HTMLNames::heightAttr, value);
258 }
259
260 KURL HTMLImageElement::src() const 215 KURL HTMLImageElement::src() const
261 { 216 {
262 return document().completeURL(getAttribute(HTMLNames::srcAttr)); 217 return document().completeURL(getAttribute(HTMLNames::srcAttr));
263 } 218 }
264 219
265 void HTMLImageElement::setSrc(const String& value) 220 void HTMLImageElement::setSrc(const String& value)
266 { 221 {
267 setAttribute(HTMLNames::srcAttr, AtomicString(value)); 222 setAttribute(HTMLNames::srcAttr, AtomicString(value));
268 } 223 }
269 224
270 void HTMLImageElement::setWidth(int value)
271 {
272 setIntegralAttribute(HTMLNames::widthAttr, value);
273 }
274
275 int HTMLImageElement::x() const
276 {
277 document().updateLayout();
278 RenderObject* r = renderer();
279 if (!r)
280 return 0;
281
282 // FIXME: This doesn't work correctly with transforms.
283 FloatPoint absPos = r->localToAbsolute();
284 return absPos.x();
285 }
286
287 int HTMLImageElement::y() const
288 {
289 document().updateLayout();
290 RenderObject* r = renderer();
291 if (!r)
292 return 0;
293
294 // FIXME: This doesn't work correctly with transforms.
295 FloatPoint absPos = r->localToAbsolute();
296 return absPos.y();
297 }
298
299 bool HTMLImageElement::complete() const 225 bool HTMLImageElement::complete() const
300 { 226 {
301 return imageLoader().imageComplete(); 227 return imageLoader().imageComplete();
302 } 228 }
303 229
304 void HTMLImageElement::didMoveToNewDocument(Document& oldDocument) 230 void HTMLImageElement::didMoveToNewDocument(Document& oldDocument)
305 { 231 {
306 imageLoader().elementDidMoveToNewDocument(); 232 imageLoader().elementDidMoveToNewDocument();
307 HTMLElement::didMoveToNewDocument(oldDocument); 233 HTMLElement::didMoveToNewDocument(oldDocument);
308 } 234 }
309 235
310 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior) 236 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior)
311 { 237 {
312 unsigned effectiveSize = 0; 238 unsigned effectiveSize = 0;
313 ImageCandidate candidate = bestFitSourceForImageAttributes( 239 ImageCandidate candidate = bestFitSourceForImageAttributes(
314 document().devicePixelRatio(), effectiveSize, 240 document().devicePixelRatio(), effectiveSize,
315 getAttribute(HTMLNames::srcAttr), AtomicString()); 241 getAttribute(HTMLNames::srcAttr), AtomicString());
316 setBestFitURLAndDPRFromImageCandidate(candidate); 242 setBestFitURLAndDPRFromImageCandidate(candidate);
317 if (m_intrinsicSizingViewportDependant && m_effectiveSizeViewportDependant & & !m_listener.get()) { 243 if (m_intrinsicSizingViewportDependant && m_effectiveSizeViewportDependant & & !m_listener.get()) {
318 m_listener = ViewportChangeListener::create(this); 244 m_listener = ViewportChangeListener::create(this);
319 document().mediaQueryMatcher().addViewportListener(m_listener.get()); 245 document().mediaQueryMatcher().addViewportListener(m_listener.get());
320 } 246 }
321 imageLoader().updateFromElement(behavior); 247 imageLoader().updateFromElement(behavior);
322 } 248 }
323 249
324 } 250 }
OLDNEW
« no previous file with comments | « sky/engine/core/html/HTMLImageElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698