I suggest we get rid of the WebNullPluginView class entirely and put the responsibility for this into platform-independent code in WebCore.
One way to do that would be to make a MissingPluginIndicator class in cross-platform code, derived from Widget, to draw the missing plug-in text. This would be a Widget that is not backed by a platform-specific object. Then WebFrameLoaderClient::createPlugin could create this object and not involve an NSView at all.
Another, probably better, way to do it would be to change RenderEmbeddedObject to give it the capability of drawing the missing plug-in text. To do this we would change the argument of FrameLoader::requestObject to be a RenderEmbeddedObject* instead of a RenderPart* and possibly rename it to requestEmbeddedObject. Then do the same thing with the first argument to FrameLoader::loadPlugin. Then inside FrameLoader::loadPlugin we would call RenderEmbeddedObject::setShowsMissingPluginIndicator and add the code to draw the missing plug-in message to the RenderEmbeddedObject class.
The only issue is that our design for missing plug-ins for Safari may not be exactly what other platforms want, so we might want to put #ifdefs or use a theme for the missing plug-in indicator eventually over time, but that’s not needed for the first cut at this.
These are helpful suggestions thanks. The second solution seems like a better fit here, since widgets are responsible for drawing themselves. I'll start working a couple small refactoring patches..
Created attachment 51167[details]
FrameLoader refactoring patch
First step toward eliminating the WebKit WebNullPluginView class. The responsibility for this will soon be in platform-independent code in WebCore. And our plan is to change RenderEmbeddedObject and give it the capability of drawing the missing plug-in text.
Comment on attachment 51167[details]
FrameLoader refactoring patch
Thanks. I think this is a good approach.
> -bool FrameLoader::requestObject(RenderPart* renderer, const String& url, const AtomicString& frameName,
> +bool FrameLoader::requestObject(RenderEmbeddedObject* requestEmbeddedObject, const String& url, const AtomicString& frameName,
The type change here seems good, but I don't understand why the argument is now named "request embedded object". That sounds like a sentence, with "request" being a verb. I think that renderer was actually a fine name for the argument. Or we could use "container" or "object".
The function name "requestObject", is not good, but you didn't change that.
> +class RenderEmbeddedObject;
> class RenderPart;
These functions were the only thing using RenderPart, so I suggest you remove the forward declaration of RenderPart too.
> - bool requestObject(RenderPart* frame, const String& url, const AtomicString& frameName,
> + bool requestObject(RenderEmbeddedObject*, const String& url, const AtomicString& frameName,
> const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues);> - bool loadPlugin(RenderPart*, const KURL&, const String& mimeType,
> + bool loadPlugin(RenderEmbeddedObject*, const KURL&, const String& mimeType,
> const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback);
Indenting is wrong here. You should fix that.
Since the purpose of the patch is primarily renaming and I didn't like the name change, I'll say review-, but lets keep going!
Comment on attachment 51169[details]
Updated FrameLoader refactoring patch per Darin's feedback.
I know I told you to do that loadPlugin indenting on IRC, but I lied - it should match the requestObject indenting just above.
r=me with that change.
Attachment 51249[details] did not pass style-queue:
Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/ChangeLog:5: Line contains tab character. [whitespace/tab] [5]
Total errors found: 1 in 13 files
If any of these errors are false positives, please file a bug against check-webkit-style.
Attachment 51250[details] did not pass style-queue:
Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/ChangeLog:5: Line contains tab character. [whitespace/tab] [5]
Total errors found: 1 in 13 files
If any of these errors are false positives, please file a bug against check-webkit-style.
(In reply to comment #14)
> Created an attachment (id=51250) [details]
> Added "Missing plug-in" localizable string to the following ports: mac, win,
> chromium, and gtk
Can you add this hunk for the Qt port, too? :)
--- a/WebCore/platform/qt/Localizations.cpp
+++ b/WebCore/platform/qt/Localizations.cpp
@@ -524,5 +524,10 @@ String validationMessageStepMismatchText()
return String();
}
+String missingPluginText()
+{
+ return QCoreApplication::translate("QWebPage", "Missing Plugin", "Label text to be used when a plugin is missing");
+}
+
}
// vim: ts=4 sw=4 et
(In reply to comment #16)
> (In reply to comment #14)
> > Created an attachment (id=51250) [details] [details]
> > Added "Missing plug-in" localizable string to the following ports: mac, win,
> > chromium, and gtk
>
> Can you add this hunk for the Qt port, too? :)
>
> --- a/WebCore/platform/qt/Localizations.cpp
> +++ b/WebCore/platform/qt/Localizations.cpp
> @@ -524,5 +524,10 @@ String validationMessageStepMismatchText()
> return String();
> }
>
> +String missingPluginText()
> +{
> + return QCoreApplication::translate("QWebPage", "Missing Plugin", "Label
> text to be used when a plugin is missing");
> +}
> +
> }
> // vim: ts=4 sw=4 et
Thanks a lot, Simon!!
Created attachment 51292[details]
Added "Missing plug-in" localizable string to the following ports: mac, win, chromium, gtk, and qt
Now incorporates Simon's above change.
Attachment 51292[details] did not pass style-queue:
Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/platform/qt/Localizations.cpp:356: Multi-line string ("...") found. This lint script doesn't do well with such strings, and may give bogus warnings. They're ugly and unnecessary, and you should use concatenation instead". [readability/multiline_string] [5]
WebCore/platform/qt/Localizations.cpp:357: Multi-line string ("...") found. This lint script doesn't do well with such strings, and may give bogus warnings. They're ugly and unnecessary, and you should use concatenation instead". [readability/multiline_string] [5]
Total errors found: 2 in 14 files
If any of these errors are false positives, please file a bug against check-webkit-style.
Comment on attachment 51292[details]
Added "Missing plug-in" localizable string to the following ports: mac, win, chromium, gtk, and qt
r+ if you fix the qt build breakage and style warning by not splitting the string across multiple lines, and change "Plug-in" to "Plugin" for the qt build also.
Comment on attachment 51300[details]
Add code to draw a subtle rounded rectangle containing the text "Missing Plug-in"
> Index: rendering/RenderEmbeddedObject.h
> ===================================================================
> --- rendering/RenderEmbeddedObject.h (revision 56339)
> +++ rendering/RenderEmbeddedObject.h (working copy)
> @@ -34,12 +34,15 @@
> virtual ~RenderEmbeddedObject();
>
> void updateWidget(bool onlyCreateNonNetscapePlugins);
> + void setShowsMissingPluginIndicator() { m_showsMissingPluginIndicator = true; }
This needs an associated getter (which should be const).
> + void paint(PaintInfo& paintInfo, int tx, int ty);
I think you should override paintReplaced.
> private:
> + bool m_showsMissingPluginIndicator;
Please put this after the private methods.
r- because it should override paintReplaced().
Created attachment 51323[details]
Add code to draw a subtle rounded rectangle containing the text "Missing Plug-in"
Incorporates above feedback from Simon Fraser.
Comment on attachment 51326[details]
Add code to draw a subtle rounded rectangle containing the text "Missing Plug-in"
> + virtual void paint(PaintInfo& paintInfo, int tx, int ty);
Should omit the argument name paintInfo here.
> + tx += borderLeft() + paddingLeft();
> + ty += borderTop() + paddingTop();
> + FloatRect pluginRect = FloatRect(tx, ty, contentWidth(), contentHeight());
It'd be cleaner not to modify the passed-in tx and ty here. I suggest writing this like this:
FloatRect pluginRect = contentBoxRect();
pluginRect.move(tx, ty);
This accomplishes the same thing and reads a bit cleaner to me.
> + fontDescription.setFontSmoothing(Antialiased);
I don't understand why the setFontSmoothing call is needed here.
> + FloatRect missingPluginRect = FloatRect();
The "= FloatRect()" is not needed. That's the same thing you'd get if you didn't explicitly initialize it.
> + FloatPoint labelPoint = FloatPoint();
Same here.
> + labelPoint.setX(roundf(missingPluginRect.location().x() + (missingPluginRect.size().width() - textWidth) / 2));
> + labelPoint.setY(floorf(missingPluginRect.location().y()+ (missingPluginRect.size().height() - font.height()) / 2 + font.ascent()));
I think this would read better if you just use the constructor:
FloatPoint labelPoint(roundf(missingPluginRect.location().x() + (missingPluginRect.size().width() - textWidth) / 2)),
floorf(missingPluginRect.location().y()+ (missingPluginRect.size().height() - font.height()) / 2 + font.ascent()));
I don't understand the use of floorf instead of roundf for the Y coordinate.
r=me
(In reply to comment #28)
> (From update of attachment 51326[details])
> > + virtual void paint(PaintInfo& paintInfo, int tx, int ty);
>
> Should omit the argument name paintInfo here.
>
> > + tx += borderLeft() + paddingLeft();
> > + ty += borderTop() + paddingTop();
> > + FloatRect pluginRect = FloatRect(tx, ty, contentWidth(), contentHeight());
>
> It'd be cleaner not to modify the passed-in tx and ty here. I suggest writing
> this like this:
>
> FloatRect pluginRect = contentBoxRect();
> pluginRect.move(tx, ty);
I like that much better too, thanks!
>
> This accomplishes the same thing and reads a bit cleaner to me.
>
> > + fontDescription.setFontSmoothing(Antialiased);
>
At the time I wrote this code I thought I needed this. Testing before/after shows no visual difference. Removed.
> > + FloatRect missingPluginRect = FloatRect();
>
> The "= FloatRect()" is not needed. That's the same thing you'd get if you
> didn't explicitly initialize it.
Done.
>
> > + FloatPoint labelPoint = FloatPoint();
>
Same here!
>
> > + labelPoint.setX(roundf(missingPluginRect.location().x() + (missingPluginRect.size().width() - textWidth) / 2));
> > + labelPoint.setY(floorf(missingPluginRect.location().y()+ (missingPluginRect.size().height() - font.height()) / 2 + font.ascent()));
>
> I think this would read better if you just use the constructor:
>
> FloatPoint labelPoint(roundf(missingPluginRect.location().x() +
> (missingPluginRect.size().width() - textWidth) / 2)),
> floorf(missingPluginRect.location().y()+
> (missingPluginRect.size().height() - font.height()) / 2 + font.ascent()));
It wasn't as unwieldy as I thought it would be. Done!
>
> I don't understand the use of floorf instead of roundf for the Y coordinate.
Fixed. They both should be the same.
Thanks for the awesome suggestions!!
2010-03-18 15:40 PDT, Kevin Decker
2010-03-19 10:45 PDT, Kevin Decker
2010-03-19 11:06 PDT, Kevin Decker
2010-03-20 18:24 PDT, Kevin Decker
2010-03-21 10:52 PDT, Kevin Decker
2010-03-21 10:55 PDT, Kevin Decker
2010-03-22 09:18 PDT, Kevin Decker
2010-03-22 10:10 PDT, Kevin Decker
2010-03-22 11:57 PDT, Kevin Decker
2010-03-22 12:09 PDT, Kevin Decker
2010-03-22 14:18 PDT, Kevin Decker
2010-03-22 14:57 PDT, Kevin Decker