Open Bug 980317 Opened 10 years ago Updated 2 years ago

Turn nsIContentHandle into a class that asserts its nsIContent* vs. nsIContent** state

Categories

(Core :: DOM: HTML Parser, defect)

defect

Tracking

()

ASSIGNED

People

(Reporter: hsivonen, Assigned: hsivonen)

References

Details

Attachments

(2 files, 2 obsolete files)

Follow-up to bug 959150 per bug 959150 comment 21.
Let's see if this compiles on all our compilers:
https://tbpl.mozilla.org/?tree=Try&rev=41ef892d41f9
Fail:
https://tbpl.mozilla.org/php/getParsedLog.php?id=35725009&tree=Try&full=1#error0

Does b2g emulator have an older compiler than our other targets?
Filed bug 980824.
Attachment #8387535 - Attachment is obsolete: true
Looks like the compiler for B2G ICS emulator is just too broken:
https://tbpl.mozilla.org/php/getParsedLog.php?id=35791355&tree=Try&full=1

smaug, I don't see a way to work around this in nsIContentHandle.h. I think we shouldn't start making changes outside nsIContentHandle.h to cater to broken compilers. Any ideas other than waiting for a build system hacker to deal with bug 980824?
Flags: needinfo?(bugs)
Don't use ?: , but if-else
Flags: needinfo?(bugs)
(In reply to Olli Pettay [:smaug] from comment #9)
> Don't use ?: , but if-else

Well, yeah, but I meant avoiding changes like that when I said "I think we shouldn't start making changes outside nsIContentHandle.h to cater to broken compilers."

I'll try to find out how hard it would be to get the compiler situation fixed, since it's so weird that B2G ICS is worse than B2G JB or Android ICS.
Comment on attachment 8387564 [details] [diff] [review]
Change nsIContentHandle into a class, v3

Review of attachment 8387564 [details] [diff] [review]:
-----------------------------------------------------------------

I have gcc45 on my system -- easy to do a test build with the changes below, might as well, will report back with successfulness of this approach.  I'm fairly confident, this is not unusual compared to the other stuff I encountered when introducing NullptrT (or when using it in not-yet-landed patches), but it's extremely easy to make thinkos here.

True nullptr cannot come soon enough.

::: parser/html/nsIContentHandle.h
@@ +57,5 @@
> +#endif
> +  {
> +  }
> +
> +  nsIContentHandle(mozilla::NullptrT aNull)

You're not going to be able to rely on nullptr having a distinct type here, so long as gcc 4.4/4.5 exist.  You can make this get used if nullptr *does* have a distinct type, like so:

template<typename T>
nsIContentHandle(N,
                 typename mozilla::EnableIf<mozilla::IsNullPointer<N>::value,
                                            int>::Type dummy = 0)
{
  ...
}

Modulo typos above.

@@ +67,5 @@
> +#endif
> +  }
> +
> +  // Alternative to the above constructor to work around bug 980824.
> +  nsIContentHandle(int aNull)

This shouldn't be added.  If you want precise mState checking, have a DEBUG conditional in the nsIContent* overload.

@@ +144,5 @@
> +    return *this;
> +  }
> +
> +  // Alternative to the above operator to work around bug 980824.
> +  nsIContentHandle& operator=(int aNull)

This shouldn't be added, __null will select operator=(mozilla::NullptrT), I believe.
So, I think this largely but not entirely solves the match-nullptr issues.  (The nullptr-or-int-or-long thing should be wrapped up in an mfbt trait, but that's easily done after the fact -- and js/public/RootingAPI.h will want such a thing too.))

The one-ish remaining issue after that is that

  cond ? nullptr : nsIContentHandle()

doesn't compile with emulated nullptr.  I tried to grok the standard language for type conversions, but I suspect it says that if you have a null pointer constant on one arm, and a non-pointer class on the other, the null pointer constant won't convert to the class type, even if the class type has an overload for the null pointer constant type.  I would suggest using nsIContentHandle(nullptr) in all those cases (look to be maybe six or so), but I dunno what you want exactly here, so throwing that aspect into your end of the court.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: