Closed Bug 467071 Opened 16 years ago Closed 8 years ago

new embedding API observer addons/extensions

Categories

(Core Graveyard :: Embedding: APIs, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: tobias.hunger, Unassigned)

References

Details

Attachments

(1 file, 8 obsolete files)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/2008111616 Ubuntu/9.04 (jaunty) Firefox/3.0.4
Build Identifier: incubator/embedding hg repository rev. dabab67820e6

The attached patch adds fixes for lots of build warnings in the new embedding API, adds copyright headers where not present already and extends the existing Listener with a couple of new callbacks:

 * Adds a bool to DocumentLoaded, indicating sucess or failure of the load operation
 * Adds FrameLoaded() callback.
 * Adds AttachAdditionalObservers() which will be used later to attach additional observers to DOM elements.
 * DocumentLoadStarted() to signal (guess what) start of a document load.
 * MoveTo() to notify about (window-) move events.

These extensions are required to build a full featured client based on the new embedding APIs. Please consider this patch for incubator.

Possible issues:

We only tested this patch with the Qt flavor of the embedding APIs.

Reproducible: Always

Steps to Reproduce:
1.
2.
3.
Attached patch The actual patch (obsolete) — Splinter Review
Uh... What's the format of that patch, exactly?  It doesn't seem to be a diff to me.  Please attach a diff if at all possible, so it can just be read in a web browser.
Sorry, it is a gzip'ed diff...

I checked that the mime type was set properly when uploading the patch, I'll fix this.
Attached patch The actual patch (not gzip'ed) (obsolete) — Splinter Review
Tobias, thanks.

The reason I wanted to look at the patch was because I wanted to see what definition of "document load succeeded" was being used here.  As far as I can tell, a 404 HTTP response sounds as a successful load here, right?  And a load that never manages to create a channel doesn't even hit this code?

None of that is clear from the API documentation.

In general, it's worth splitting out substantive changes like that from the whitespace cleanup, bracing changes (some a little suspect, but up to the module owner here), etc, etc...  At least if this code is expected to get code review (which I most certainly hope it is at some point!).
Tobias, thanks for the patches. Some formatting and style feedback after a quick look:

* 4 spaces in c/c++ files for indentation, no tabs
* one space between if/for/switch and (
* no space between function name and (
* no else after return
* return early for failure 

I know that the code you patched against did not follow most of these guidelines, but we just landed a patch that started the fixup process. I figure you could adjust your code we possible. Whitespace is a lower priority (I can fix that up quickly), but more important is:

* no else after return
* return early for failure 

Your code adds some of these patterns:

 NS_IMETHODIMP WebBrowserChrome::SetStatus(PRUint32 statusType, const PRUnichar *status)
 {
-    MozViewListener* pListener = pMozView->GetListener();
-    if (!pListener)
-        return NS_ERROR_NOT_IMPLEMENTED;
-

Keep this (you change this pattern a lot)

+  MozViewListener* pListener = pMozView->GetListener();
+  if(pListener) {

space between "if" and "("


NS_IMETHODIMP WebBrowserChrome::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress)
 {
+  MOZ_UNUSED(aWebProgress);
+  MOZ_UNUSED(aRequest);
+  MOZ_UNUSED(aCurSelfProgress);
+  MOZ_UNUSED(aMaxSelfProgress);
+
+  MozViewListener* pListener = pMozView->GetListener();
+  if(pListener)
+  {
+      PRUint32 percentage = ( 100 * aCurTotalProgress ) / aMaxTotalProgress;
+      if (percentage > 100) { percentage = 100; }
+      pListener->ProgressChanged(percentage);
+      return NS_OK;
+  }
+  else {
     return NS_ERROR_NOT_IMPLEMENTED;
+  }
 }

Don't add an "else" here. Just use the "return" without the "else"
==================================================================

You have a lot of good stuff in this patch (and the other ones you files too). We will be reviewing and landing what we can. Thanks again.
Boris: Yes, I agree that it would have been nice to send in the patches in a more granular fashion. Unfortunately that proved harder to do than expected. In the end I went for this approach since otherwise I'd end up with patches that are even more dependent on the order in which they should be applied than what I send in. And I found it harder to review a series of interdependent patches than to just ignore the whitespace changes.

About the document loaded remarks: You are right, documentation should be improved here (I'll do that ASAP).

Mark: I'll clean up the patch and resubmit it.
Attached patch observer extensions patch v1.1 (obsolete) — Splinter Review
This patch incorparates the suggestions made by reviewers.
Attachment #350449 - Attachment is obsolete: true
Attachment #350455 - Attachment is obsolete: true
I'm not sure I follow the documentation for DocumentLoaded()...

Of course I'm also not sure what use cases aSuccess is expected to address.
Following code should be changed 
+    if (!pListener) { return NS_ERROR_NOT_IMPLEMENTED; }

back to 

-    if (!pListener)
-        return NS_ERROR_NOT_IMPLEMENTED;

as Mark suggested, there are some places (~6) in the v1.1 patch.
(In reply to comment #10)
> Following code should be changed 
> +    if (!pListener) { return NS_ERROR_NOT_IMPLEMENTED; }
> 
> back to 
> 
> -    if (!pListener)
> -        return NS_ERROR_NOT_IMPLEMENTED;

Yes. I fixed 3 of those in the patch for bug 467073 before checking in
Is there anything I should do to make the patch more acceptable?

I do personaly consider if statements without brackets to be a oversight, so I corrected that wherever I ran into it:-)
Blocks: 467076
Rework the patch to avoid introducing { } around single statement if constructs.

Split out removal of unused Embedding.h header, too.
Attachment #350764 - Attachment is obsolete: true
Blocks: 467074
Update copyright year to 2007 instead of 20007.

Otherwise the patch is identical with the previous one.
Attachment #352703 - Attachment is obsolete: true
No longer blocks: 467074
Attached patch observer extensions patch v1.2 (obsolete) — Splinter Review
Shrink the patch by depending on cleanup patches...
Attachment #352722 - Attachment is obsolete: true
Depends on: 469663
OK, the important changes should be more obvious now.

This patch further adds some Qt code to demonstrate the use (this code was part of #467076 before, mixed in with lots of other stuff:-).
Attached patch observer extensions patch v1.3 (obsolete) — Splinter Review
This patch applies to current hg.
Attachment #353049 - Attachment is obsolete: true
Attachment #353429 - Flags: review?(mark.finkle)
Comment on attachment 353429 [details] [diff] [review]
observer extensions patch v1.3

Some changes I'd to see:

I want to change our event names to a more event-like name. Since you touch some in this patch let's start:
* ProgressChanged -> OnProgressChanged
* FrameLoaded -> OnFrameLoaded
* DocumentLoaded -> OnDocumentLoaded
* DocumentLoadStarted -> OnDocumentLoading

Why the need for AttachAdditionallisteners? I'd rather remove it for now.

Overall this looks good. Thanks
Attachment #353429 - Flags: review?(mark.finkle) → review-
Attached patch observer extensions patch v1.4 (obsolete) — Splinter Review
* Rename methods to start with "On" as suggested by Mark.
  Qt Signals were left alone as a signal implies that something
  has happened and it is not usually marked by prefixes as "On".
* Update to current mercurial version.
* Depend on #470201 to shrink the patch a bit and to not
  redo so many changes.
Attachment #353429 - Attachment is obsolete: true
Attachment #353666 - Flags: review?
Depends on: 470201
No longer depends on: 469663
Attachment #353666 - Flags: review? → review?(mark.finkle)
Update patch to new hg revision (plus the two fixes found on bug #470201).
Attachment #353666 - Attachment is obsolete: true
Attachment #355546 - Flags: review?(mark.finkle)
Attachment #353666 - Flags: review?(mark.finkle)
Attachment #355546 - Flags: review?(mark.finkle)
Marking a bunch of bugs in the "Embedding: APIs" component INCOMPLETE in preparation to archive that component. If I have done this incorrectly, please reopen the bugs and move them to a more correct component as we don't have "embedding" APIs any more.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → INCOMPLETE
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: