Changeset 18755 in webkit
- Timestamp:
- Jan 10, 2007 6:24:30 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 12 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r18753 r18755 1 2007-01-10 Kirby White <KWhiteRight@gmail.com> 2 3 Reviewed by Darin. 4 5 New and adjusted test cases for 6 http://bugs.webkit.org/show_bug.cgi?id=11841 7 8 * fast/dom/HTMLImageElement/image-alt-text-expected.checksum: Added. 9 * fast/dom/HTMLImageElement/image-alt-text-expected.png: Added. 10 * fast/dom/HTMLImageElement/image-alt-text-expected.txt: Added. 11 * fast/dom/HTMLImageElement/image-alt-text.html: Added. 12 * fast/dom/HTMLImageElement/resources/blue_rect.jpg: Added. 13 * fast/dom/HTMLInputElement/input-image-alt-text-expected.checksum: Added. 14 * fast/dom/HTMLInputElement/input-image-alt-text-expected.png: Added. 15 * fast/dom/HTMLInputElement/input-image-alt-text-expected.txt: Added. 16 * fast/dom/HTMLInputElement/input-image-alt-text.html: Added. 17 * fast/dom/HTMLInputElement/resources/blue_rect.jpg: Added. 18 * fast/forms/focus2-expected.txt: 19 * fast/forms/focus2.html: 20 * fast/forms/input-value-expected.checksum: 21 * fast/forms/input-value-expected.png: 22 * fast/forms/input-value-expected.txt: 23 1 24 2007-01-10 Mitz Pettel <mitz@webkit.org> 2 25 -
trunk/LayoutTests/fast/forms/focus2-expected.txt
r18610 r18755 14 14 keypress event: [to] FILE 15 15 blur event: [to] FILE 16 focus event: [to] IMAGE 17 keypress event: [to] IMAGE 18 blur event: [to] IMAGE 16 19 focus event: [to] ISINDEX 17 20 keypress event: [to] ISINDEX … … 56 59 keypress event: [to] FILE 57 60 blur event: [to] FILE 61 focus event: [to] IMAGE 62 keypress event: [to] IMAGE 63 blur event: [to] IMAGE 58 64 focus event: [to] ISINDEX 59 65 keypress event: [to] ISINDEX -
trunk/LayoutTests/fast/forms/focus2.html
r18610 r18755 128 128 log('PARENT DOCUMENT:\n'); 129 129 document.getElementsByTagName('input')[0].focus(); 130 for (var i = 0; i < 1 2; ++i) //>130 for (var i = 0; i < 13; ++i) //> 131 131 dispatchOptionTab(lastFocusedElement, false); 132 132 … … 135 135 log('\nIFRAME DOCUMENT:\n'); 136 136 document.getElementById('testIframe').contentDocument.getElementsByTagName('input')[0].focus(); 137 for (var i = 0; i < 1 2; ++i) //>137 for (var i = 0; i < 13; ++i) //> 138 138 dispatchOptionTab(lastFocusedElement, false); 139 139 </script> -
trunk/LayoutTests/fast/forms/input-value-expected.checksum
r16290 r18755 1 46aacae774651d7db7e097624470e413 1 117a32ed4debd2d2ba5d14641f9004cb -
trunk/LayoutTests/fast/forms/input-value-expected.txt
r18292 r18755 95 95 RenderText {#text} at (1,1) size 222x18 96 96 text run at (1,1) width 222: "image with value property changed" 97 RenderTableCell {TD} at (389,1 35) size 243x2[r=5 c=1 rs=1 cs=1]98 RenderImage {INPUT} at (1,1) size 0x097 RenderTableCell {TD} at (389,128) size 243x15 [r=5 c=1 rs=1 cs=1] 98 RenderImage {INPUT} at (1,1) size 35x13 99 99 RenderTableCell {TD} at (634,126) size 62x20 [r=5 c=2 rs=1 cs=1] 100 100 RenderText {#text} at (1,1) size 28x18 -
trunk/WebCore/ChangeLog
r18754 r18755 1 2007-01-10 Kirby White <KWhiteRight@gmail.com> 2 3 Reviewed by Darin. 4 5 Fixes for http://bugs.webkit.org/show_bug.cgi?id=11841 6 7 Set image size to fit alt text when image or input-image element 8 has no src attribute, so that those images show their alt text instead 9 of showing nothing at all. 10 11 * html/HTMLImageElement.cpp: 12 (WebCore::HTMLImageElement::attach): 13 * html/HTMLInputElement.cpp: 14 (WebCore::HTMLInputElement::attach): 15 * rendering/RenderImage.cpp: 16 (WebCore::RenderImage::setImageSizeForAltText): 17 (WebCore::RenderImage::imageChanged): 18 * rendering/RenderImage.h: 19 1 20 2007-01-11 Mark Rowe <mrowe@apple.com> 2 21 -
trunk/WebCore/html/HTMLImageElement.cpp
r15653 r18755 167 167 HTMLElement::attach(); 168 168 169 if (RenderImage* imageObj = static_cast<RenderImage*>(renderer())) 169 if (renderer()) { 170 RenderImage* imageObj = static_cast<RenderImage*>(renderer()); 170 171 imageObj->setCachedImage(m_imageLoader.image()); 172 173 // If we have no image at all because we have no src attribute, set 174 // image height and width for the alt text instead. 175 if (!m_imageLoader.image() && !imageObj->cachedImage()) 176 imageObj->setImageSizeForAltText(); 177 } 171 178 } 172 179 -
trunk/WebCore/html/HTMLInputElement.cpp
r18523 r18755 850 850 if (renderer()) { 851 851 RenderImage* imageObj = static_cast<RenderImage*>(renderer()); 852 imageObj->setCachedImage(m_imageLoader->image()); 852 imageObj->setCachedImage(m_imageLoader->image()); 853 854 // If we have no image at all because we have no src attribute, set 855 // image height and width for the alt text instead. 856 if (!m_imageLoader->image() && !imageObj->cachedImage()) 857 imageObj->setImageSizeForAltText(); 853 858 } 854 859 } -
trunk/WebCore/rendering/RenderImage.cpp
r18654 r18755 76 76 } 77 77 78 // If we'll be displaying either alt text or an image, add some padding. 79 static const unsigned short paddingWidth = 4; 80 static const unsigned short paddingHeight = 4; 81 82 // Alt text is restricted to this maximum size, in pixels. These are 83 // signed integers because they are compared with other signed values. 84 static const int maxAltTextWidth = 1024; 85 static const int maxAltTextHeight = 256; 86 87 // Sets the image height and width to fit the alt text. Returns true if the 88 // image size changed. 89 bool RenderImage::setImageSizeForAltText(CachedImage* newImage /* = 0 */) 90 { 91 int imageWidth = 0; 92 int imageHeight = 0; 93 94 // If we'll be displaying either text or an image, add a little padding. 95 if (!m_altText.isEmpty() || newImage) { 96 imageWidth = paddingWidth; 97 imageHeight = paddingHeight; 98 } 99 100 if (newImage) { 101 imageWidth += newImage->image()->width(); 102 imageHeight += newImage->image()->height(); 103 } 104 105 // we have an alt and the user meant it (its not a text we invented) 106 if (!m_altText.isEmpty()) { 107 const Font& font = style()->font(); 108 imageWidth = max(imageWidth, min(font.width(TextRun(m_altText.characters(), m_altText.length())), maxAltTextWidth)); 109 imageHeight = max(imageHeight, min(font.height(), maxAltTextHeight)); 110 } 111 112 bool imageSizeChanged = false; 113 114 if (imageWidth != intrinsicWidth()) { 115 setIntrinsicWidth(imageWidth); 116 imageSizeChanged = true; 117 } 118 if (imageHeight != intrinsicHeight()) { 119 setIntrinsicHeight(imageHeight); 120 imageSizeChanged = true; 121 } 122 123 return imageSizeChanged; 124 } 125 78 126 void RenderImage::imageChanged(CachedImage* newImage) 79 127 { … … 88 136 bool imageSizeChanged = false; 89 137 90 if (newImage->isErrorImage()) { 91 int imageWidth = newImage->image()->width() + 4; 92 int imageHeight = newImage->image()->height() + 4; 93 94 // we have an alt and the user meant it (its not a text we invented) 95 if (!m_altText.isEmpty()) { 96 const Font& font = style()->font(); 97 imageWidth = max(imageWidth, min(font.width(TextRun(m_altText.characters(), m_altText.length())), 1024)); 98 imageHeight = max(imageHeight, min(font.height(), 256)); 99 } 100 101 if (imageWidth != intrinsicWidth()) { 102 setIntrinsicWidth(imageWidth); 103 imageSizeChanged = true; 104 } 105 if (imageHeight != intrinsicHeight()) { 106 setIntrinsicHeight(imageHeight); 107 imageSizeChanged = true; 108 } 109 } 110 138 // Set image dimensions, taking into account the size of the alt text. 139 if (newImage->isErrorImage()) 140 imageSizeChanged = setImageSizeForAltText(newImage); 141 111 142 bool ensureLayout = false; 112 143 -
trunk/WebCore/rendering/RenderImage.h
r18724 r18755 47 47 48 48 virtual void imageChanged(CachedImage*); 49 50 bool setImageSizeForAltText(CachedImage* newImage = 0); 49 51 50 52 void updateAltText();
Note: See TracChangeset
for help on using the changeset viewer.