Changeset 100613 in webkit
- Timestamp:
- Nov 17, 2011 6:22:48 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r100612 r100613 1 2011-11-17 Simon Hausmann <simon.hausmann@nokia.com> 2 3 [Qt] Layer violation: Image::loadPlatformResource uses QWebSettings::webGraphic 4 https://bugs.webkit.org/show_bug.cgi?id=72594 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Move the cache for the resource pixmaps into ImageQt.cpp. 9 10 * platform/graphics/Image.h: Add Qt specific setter for resource pixmaps. 11 * platform/graphics/qt/ImageQt.cpp: Moved resource pixmap hash from qwebsettings. 12 (earlyClearGraphics): 13 (graphics): 14 (loadResourcePixmap): 15 (WebCore::Image::setPlatformResource): 16 1 17 2011-11-17 Zeno Albisser <zeno@webkit.org> 2 18 -
trunk/Source/WebCore/platform/graphics/Image.h
r100535 r100613 161 161 #endif 162 162 163 #if PLATFORM(QT) 164 static void setPlatformResource(const char* name, const QPixmap&); 165 #endif 166 163 167 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, 164 168 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect); -
trunk/Source/WebCore/platform/graphics/qt/ImageQt.cpp
r90406 r100613 43 43 #include "qwebsettings.h" 44 44 45 #include <Q Pixmap>46 #include <Q Painter>45 #include <QApplication> 46 #include <QDebug> 47 47 #include <QImage> 48 48 #include <QImageReader> 49 #include <QPainter> 50 #include <QPixmap> 51 #include <QStyle> 49 52 #include <QTransform> 50 53 51 #include <QDebug>52 53 54 #include <math.h> 55 56 typedef QHash<QByteArray, QPixmap> WebGraphicHash; 57 Q_GLOBAL_STATIC(WebGraphicHash, _graphics) 58 59 static void earlyClearGraphics() 60 { 61 _graphics()->clear(); 62 } 63 64 static WebGraphicHash* graphics() 65 { 66 WebGraphicHash* hash = _graphics(); 67 68 if (hash->isEmpty()) { 69 70 // prevent ~QPixmap running after ~QApplication (leaks native pixmaps) 71 qAddPostRoutine(earlyClearGraphics); 72 73 // QWebSettings::MissingImageGraphic 74 hash->insert("missingImage", QPixmap(QLatin1String(":webkit/resources/missingImage.png"))); 75 // QWebSettings::MissingPluginGraphic 76 hash->insert("nullPlugin", QPixmap(QLatin1String(":webkit/resources/nullPlugin.png"))); 77 // QWebSettings::DefaultFrameIconGraphic 78 hash->insert("urlIcon", QPixmap(QLatin1String(":webkit/resources/urlIcon.png"))); 79 // QWebSettings::TextAreaSizeGripCornerGraphic 80 hash->insert("textAreaResizeCorner", QPixmap(QLatin1String(":webkit/resources/textAreaResizeCorner.png"))); 81 // QWebSettings::DeleteButtonGraphic 82 hash->insert("deleteButton", QPixmap(QLatin1String(":webkit/resources/deleteButton.png"))); 83 // QWebSettings::InputSpeechButtonGraphic 84 hash->insert("inputSpeech", QPixmap(QLatin1String(":webkit/resources/inputSpeech.png"))); 85 // QWebSettings::SearchCancelButtonGraphic 86 hash->insert("searchCancelButton", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton)); 87 // QWebSettings::SearchCancelButtonPressedGraphic 88 hash->insert("searchCancelButtonPressed", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton)); 89 } 90 91 return hash; 92 } 54 93 55 94 // This function loads resources into WebKit 56 95 static QPixmap loadResourcePixmap(const char *name) 57 96 { 58 QPixmap pixmap; 59 if (qstrcmp(name, "missingImage") == 0) 60 pixmap = QWebSettings::webGraphic(QWebSettings::MissingImageGraphic); 61 else if (qstrcmp(name, "nullPlugin") == 0) 62 pixmap = QWebSettings::webGraphic(QWebSettings::MissingPluginGraphic); 63 else if (qstrcmp(name, "urlIcon") == 0) 64 pixmap = QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic); 65 else if (qstrcmp(name, "textAreaResizeCorner") == 0) 66 pixmap = QWebSettings::webGraphic(QWebSettings::TextAreaSizeGripCornerGraphic); 67 else if (qstrcmp(name, "deleteButton") == 0) 68 pixmap = QWebSettings::webGraphic(QWebSettings::DeleteButtonGraphic); 69 else if (!qstrcmp(name, "inputSpeech")) 70 pixmap = QWebSettings::webGraphic(QWebSettings::InputSpeechButtonGraphic); 71 else if (!qstrcmp(name, "searchCancelButton")) 72 pixmap = QWebSettings::webGraphic(QWebSettings::SearchCancelButtonGraphic); 73 else if (!qstrcmp(name, "searchCancelButtonPressed")) 74 pixmap = QWebSettings::webGraphic(QWebSettings::SearchCancelButtonPressedGraphic); 75 76 return pixmap; 97 return graphics()->value(name); 77 98 } 78 99 … … 100 121 { 101 122 return StillImage::create(loadResourcePixmap(name)); 123 } 124 125 void Image::setPlatformResource(const char* name, const QPixmap& pixmap) 126 { 127 WebGraphicHash* h = graphics(); 128 if (pixmap.isNull()) 129 h->remove(name); 130 else 131 h->insert(name, pixmap); 102 132 } 103 133 -
trunk/Source/WebKit/qt/Api/qwebsettings.cpp
r98730 r100613 88 88 WebCore::Settings* settings; 89 89 }; 90 91 typedef QHash<int, QPixmap> WebGraphicHash;92 Q_GLOBAL_STATIC(WebGraphicHash, _graphics)93 94 static void earlyClearGraphics()95 {96 _graphics()->clear();97 }98 99 static WebGraphicHash* graphics()100 {101 WebGraphicHash* hash = _graphics();102 103 if (hash->isEmpty()) {104 105 // prevent ~QPixmap running after ~QApplication (leaks native pixmaps)106 qAddPostRoutine(earlyClearGraphics);107 108 hash->insert(QWebSettings::MissingImageGraphic, QPixmap(QLatin1String(":webkit/resources/missingImage.png")));109 hash->insert(QWebSettings::MissingPluginGraphic, QPixmap(QLatin1String(":webkit/resources/nullPlugin.png")));110 hash->insert(QWebSettings::DefaultFrameIconGraphic, QPixmap(QLatin1String(":webkit/resources/urlIcon.png")));111 hash->insert(QWebSettings::TextAreaSizeGripCornerGraphic, QPixmap(QLatin1String(":webkit/resources/textAreaResizeCorner.png")));112 hash->insert(QWebSettings::DeleteButtonGraphic, QPixmap(QLatin1String(":webkit/resources/deleteButton.png")));113 hash->insert(QWebSettings::InputSpeechButtonGraphic, QPixmap(QLatin1String(":webkit/resources/inputSpeech.png")));114 hash->insert(QWebSettings::SearchCancelButtonGraphic, QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));115 hash->insert(QWebSettings::SearchCancelButtonPressedGraphic, QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));116 }117 118 return hash;119 }120 90 121 91 Q_GLOBAL_STATIC(QList<QWebSettingsPrivate*>, allSettings); … … 752 722 */ 753 723 724 static const char* resourceNameForWebGraphic(QWebSettings::WebGraphic type) 725 { 726 switch (type) { 727 case QWebSettings::MissingImageGraphic: return "missingImage"; 728 case QWebSettings::MissingPluginGraphic: return "nullPlugin"; 729 case QWebSettings::DefaultFrameIconGraphic: return "urlIcon"; 730 case QWebSettings::TextAreaSizeGripCornerGraphic: return "textAreaResizeCorner"; 731 case QWebSettings::DeleteButtonGraphic: return "deleteButton"; 732 case QWebSettings::InputSpeechButtonGraphic: return "inputSpeech"; 733 case QWebSettings::SearchCancelButtonGraphic: return "searchCancelButton"; 734 case QWebSettings::SearchCancelButtonPressedGraphic: return "searchCancelButtonPressed"; 735 } 736 return 0; 737 } 738 754 739 /*! 755 740 Sets \a graphic to be drawn when QtWebKit needs to draw an image of the … … 763 748 void QWebSettings::setWebGraphic(WebGraphic type, const QPixmap& graphic) 764 749 { 765 WebGraphicHash* h = graphics(); 766 if (graphic.isNull()) 767 h->remove(type); 768 else 769 h->insert(type, graphic); 750 WebCore::Image::setPlatformResource(resourceNameForWebGraphic(type), graphic); 770 751 } 771 752 … … 778 759 QPixmap QWebSettings::webGraphic(WebGraphic type) 779 760 { 780 return graphics()->value(type); 761 RefPtr<WebCore::Image> img = WebCore::Image::loadPlatformResource(resourceNameForWebGraphic(type)); 762 if (!img) 763 return QPixmap(); 764 QPixmap* pixmap = img->nativeImageForCurrentFrame(); 765 if (!pixmap) 766 return QPixmap(); 767 return *pixmap; 781 768 } 782 769 -
trunk/Source/WebKit/qt/ChangeLog
r100602 r100613 1 2011-11-17 Simon Hausmann <simon.hausmann@nokia.com> 2 3 [Qt] Layer violation: Image::loadPlatformResource uses QWebSettings::webGraphic 4 https://bugs.webkit.org/show_bug.cgi?id=72594 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Move resource pixmap cache into ImageQt.cpp. 9 10 * Api/qwebsettings.cpp: 11 (resourceNameForWebGraphic): Helper function to translate between public API enums and 12 resource names. 13 (QWebSettings::setWebGraphic): Call the new ImageQt::setPlatformResource setter. 14 (QWebSettings::webGraphic): Call Image::loadPlatformResource to read from the cache 15 in WebCore. 16 1 17 2011-11-17 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> 2 18
Note: See TracChangeset
for help on using the changeset viewer.