Add more callback tests to testEventDispatcher,
1) Test for checking that the callback for a Gecko thread event,
dispatched from Gecko, is synchronous. We depend on this behavior in
several places where we require a "function call" style event.
2) Test for checking that callbacks accept a variety of data types as
the response object, including the standard types supported by
GeckoBundle, as well as primitive types that are convertible to standard
types.
Remove GeckoEventListener and NativeEventListener now that we uniformly
use BundleEventListener. Also remove related classes NativeJSContainer,
NativeJSObject, and GeckoRequest, as well as related tests and C++
code.
The "Messaging" object in Messaging.jsm is replaced with a dummy object
that redirect calls to the global and/or window event dispatcher.
Bug 1319660 - 1. Don't take shortcut if old replacement ranges don't match; r=esawin
The block at [1] is a shortcut we take when we reconcile Java text
changes with Gecko text changes. However, we only checked that the new
ranges are the same, i.e. that the new Gecko text is the same as the new
Java text. We should also be checking that the old ranges are the same,
i.e. that the replaced Gecko text is the same as the replaced Java text.
[1] https://dxr.mozilla.org/mozilla-central/rev/bbbd2f7539f224a482cc6d2dd10e6a5f31c8baf3/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoEditable.java#1233
Bug 1319660 - 2. Use previous node instead of sibling when adjusting last node; r=masayuki r=smaug
nsContentIterator in pre mode adjusts its last node if the node is a
childless node like <br>. However, right now it's using GetPrevSibling,
which can lead to error in some edge cases such as:
<p></p><div><br></div>
In this case, if the last node is <br> with offset 0, GetPrevSibling
will return <p> because <p> is <br>'s parent's previous sibling, and the
last node will be set to <p>. However, the correct last node in this
case is <div>, because <br> with offset 0 refers to the position to the
left of <br>, which is <div> with offset 0. In this case, PrevNode
returns the correct <div> value, so we should set the last node to the
result of PrevNode.
For the first node, for a childless node in pre mode, GetNextSibling and
NextNode are the same, so there is no bug in this case. Nevertheless,
this patch changes the call to NextNode to be consistent with calling
PrevNode for the last node.
Bug 1319660 - 3. Add test for correctly adjusting last node in content iterator; r=masayuki
Add a test for the previous patch that makes sure querying selected text
in an edge case works correctly.
Bug 1319660 - 4. Add test for start node regression; r=me
Add a new test case for the NextNode() regression. r=me for trivial
test-only patch.
Bug 1319660 - 5. Restore GetNextSibling call for first node of pre-content-iterator; r=smaug
The last patch changed the `GetNextSibling()` call to `NextNode()`
because I assumed they're equivalent in this case. That turned out to
not be the case because we can reach this line even if the node has
children -- the index just has to be after the last child. So this patch
restores the `GetNextSibling` call to restore the correct behavior.
I also added some comment to clarify that we can reach this line due to
one of two conditions: 1) the node has no children; 2) the node has
children but the index is after the last child.
This patch also replaces the `HasChildren()` check when setting
`cChild`. If the index is after the last child (i.e. index ==
childCount), `GetChildAt()` fails and we erroneously log an assertion
warning, even though the input was valid. The new check handles all
cases whether start node has children or not.
Instead of throwing IME exceptions, try to recover from IME errors by
flushing the entire text unless we already tried that before. This
prevents annoying crashes, and deals with known IME bugs that are too
risky to uplift to older releases.
To deal with the Java side trying to send events to Gecko before Gecko
is ready, make a special exception to queue any undispatched events when
Gecko is not ready, so that the events can be redispatched to Gecko
later.
In addition to the existing fromJSONObject method, add fromBundle,
toBundle, and toJSONObject methods to GeckoBundle, so a GeckoBundle can
be easily converted to/from Bundle and JSONObject.
Don't go through the VsyncSource Java class to test support for vsync.
Because VsyncSource references symbols from API 16+, Dalvik fails to
load it for API 15 and below. Also make several other changes in
VsyncSource, including removing the unnecessary JNIObject superclass,
and refactoring the instance initialization code, which fixes a possible
race when initializing.
Add overrides for Object methods in GeckoBundle, and redirected them to
the corresponding methods in SimpleArrayMap. For equals, a custom
implementation is used because the equals implementation in
SimpleArrayMap had bugs across different support library versions.
Convert "Wifi:Enable" and "Wifi:GetIPAddress" events to GeckoBundle
events. Use the UI thread because we do things like starting activities
and using system services, which are best done on the UI thread.
There's still work to be done here to unify these two processes, but
that can be follow-up. In any case, geckoview.BuildConfig should
change very infrequently, and we're hoping to transition to Gradle
eventually.
MozReview-Commit-ID: D2c6XTYqubj
--HG--
extra : rebase_source : 107febdd97899f29fa493925c70252738fb666b9
This is the first, mostly mechanical, introduction of a GeckoView
specific BuildConfig.
We have a few "debug logging" like checks. I introduced a
MOZILLA_OFFICIAL abstraction and removed some of the checks as I saw
fit. Subsequent patches will remove more of these checks.
With this change applied, Gradle is broken, because there will be
duplicate BuildConfig files included in the build. That will be fixed
in subsequent patches.
MozReview-Commit-ID: KHhV32o5j5A
--HG--
extra : rebase_source : 8b0991fb6ab47bc02ca2b55be8fbaf397740e453
This had some value for Fennec when we shipped split APKs. Since we
don't, there's little value left; and there's definitely no value for
GeckoView, which will only ever ship a single library AAR for all
consumers. (That library AAR will have a minimum SDK, but it'll be
enforced by the Gradle build system, not by runtime checks.)
MozReview-Commit-ID: 3l0jUKdCepS
--HG--
extra : rebase_source : ca7678ac6a96d70ec2da638fe0f8b6132b3c14f1
This patch inlines most uses of Versions in GeckoView.
The Android linter can check that symbols only defined in particular
versions of Android are only accessed behind safe guards. However,
our Versions symbolic constants defeat the Android linter's simplistic
code analysis. The value of the linter is (much!) greater than the
explanatory value of our symbolic constants, especially for GeckoView,
which will only ever ship a single library AAR suitable for all
consumers.
I manually tried to squash a few linter errors; subsequent tickets
will track enabling the linter for GeckoView specifically, and burning
down the remaining linter version errors.
MozReview-Commit-ID: cZmNehx8tR
--HG--
extra : rebase_source : a8fcf08d2edaec504c73c1eb8f399fbb581123e0
This API is vestigial.
Sadly we can't remove GeckoInterface.getActivity entirely since there
are still some Fennec consumers that I don't care to unravel just yet.
MozReview-Commit-ID: HX038okB4sR
--HG--
extra : rebase_source : 4c82e7d186a7b4e93e826f60e7e7ea8af6e851cf
This patch abstracts setting the screen orientation into an interface
(but not into the already overloaded GeckoInterface).
I feel this form obscures the (eventual) connection between the
GeckoView widget and its embedding Activity, but it removes the
explicit getActivity() and it's certainly simpler than previous
iterations.
MozReview-Commit-ID: 8a8bPTlcp3T
--HG--
extra : rebase_source : 4817140c7142abbcb589495ce2d3c169ca0bd9df
As implemented right now, this doesn't make sense for general
GeckoView consumers.
I believe fullscreen will be important to GeckoView consumers -- games
in particular will want it -- but we'll need to think harder about how
to support it, how to support it with multiple GeckoViews, and how to
ensure we persist the fullscreen state across device configuration
changes, etc.
MozReview-Commit-ID: 5sjNx1hovvt
--HG--
extra : rebase_source : 33d28838ec807e7f6bf589245e755eb9c451d94e
This was added for the Android Web App Runtime in Bug 776600. If it
was ever used, it's definitely not now. In addition, fishing the
default orientation from Gecko prefs in a constructor that is
implicitly called from a static singleton initializer is unreliable,
so this probably was never robust. The comments on the ticket say as
much.
MozReview-Commit-ID: E8oz7JsB6oB
--HG--
extra : rebase_source : a77158564f6de73b0673b3720be49d87f89b1377
Bug 1321418 - 1. Use GekcoBundle events in GeckoApp; r=snorp r=sebastian
Switch GeckoApp to using GeckoBundle events everywhere. UI or Gecko
events are used if the event requires the UI or Gecko thread,
respectively, and background events are used for all other events.
There are changes to some other Java classes, such as SnackbarBuilder
and GeckoAccessibility, due to the switch to GeckoBundle.
For "Snackbar:Show", we need the global EventDispatcher because the
event can be sent to both GeckoApp and GeckoPreferences. Howveer, we
only want one listener registered at the same time, so we register and
unregister in GeckoApp's and GeckoPreferences's onPause and onResume
methods.
Bug 1321418 - 2. Use appropriate JS EventDispatcher to send GeckoApp events; r=snorp r=sebastian
Change JS code that sends events to GeckoApp to use either the global
EventDispatcher or the per-window EventDispatcher.
"Session:StatePurged" is not used so it's removed. "Gecko:Ready" in
geckoview.js is not necessary because it's only used for GeckoApp, so
it's removed from geckoview.js.
Bug 1321418 - 3. Use GeckoBundle events in BrowserApp; r=snorp r=sebastian
Switch BrowserApp to using GeckoBundle events, in a similar vein as
GeckoApp. UI or Gecko events are used if the event handlers required UI
or Gecko thread, respectively, and background events are used for all
other events.
Some other Java classes also have to be modified as a result of
switching to GeckoBundle.
Bug 1321418 - 4. Use global EventDispatcher to send BrowserApp events; r=snorp r=sebastian
Change JS code that sends events to BrowserApp to use the global
EventDispatcher instead of "Messaging".
Bug 1321418 - 5. Update usages of events in tests; r=gbrown
Update cases where we use or wait for events in tests.
Fix a crash in GeckoBundle.fromJSONObject due to wrong values array
type. Also, fix a bug where the first element of a converted array is
repeated. r=me for trivial patch.
Convert prompts to use BundleEventListener and GeckoBundle.
DefaultDoorHanger.setOptions accepts a JSONObject argument, but if we
converted it to GeckoBundle, it would involve a lot of extra changes in
the other doorhanger code. So this patch adds GeckoBundle.fromJSONObject
and converts JSONObject to GeckoBundle within
DefaultDoorHanger.setOptions. In the future, another patch would convert
all doorhanger code to use GeckoBundle instead of JSONObject.
Fix several bugs when handling arrays in GeckoBundle.
1. Correctly return null when getting an array that is not in the
bundle, instead of crashing.
2. Convert object arrays to GeckoBundle arrays in EventDispatcher
instead of leaving it as a single GeckoBundle with integer keys, due
to lack of object array support in NativeJSObject.toBundle.
3. Return error when trying to convert a JS array of arrays to
GeckoBundle, instead of crashing.
4. Add convenience methods for setting arrays; for example, setting
boolean arrays from Boolean[] and Collection<Boolean>.
GeckoView's GeckoEventListener and NativeEventListener are not actually
hooked up to events right now, so it's better to just rip them out until
we figure out a better implementation in the future.