From f12a5d53a7d35bcc88eb7e5d2dda5d06b60f2c98 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Mon, 17 Mar 2014 19:39:40 -0700 Subject: [PATCH 01/88] Bug 975838 - Part 1: add methods to log or throw if called on the wrong thread, pepper GeckoMenu with thread affinities. r=wesj --- mobile/android/base/GeckoEditable.java | 3 +- mobile/android/base/GeckoInputConnection.java | 17 +++--- mobile/android/base/menu/GeckoMenu.java | 21 ++++++- mobile/android/base/util/ThreadUtils.java | 55 ++++++++++++++----- 4 files changed, 72 insertions(+), 24 deletions(-) diff --git a/mobile/android/base/GeckoEditable.java b/mobile/android/base/GeckoEditable.java index 41962694aff..aff8aa08e83 100644 --- a/mobile/android/base/GeckoEditable.java +++ b/mobile/android/base/GeckoEditable.java @@ -8,6 +8,7 @@ package org.mozilla.gecko; import org.mozilla.gecko.gfx.InputConnectionHandler; import org.mozilla.gecko.gfx.LayerView; import org.mozilla.gecko.util.ThreadUtils; +import org.mozilla.gecko.util.ThreadUtils.AssertBehavior; import android.os.Build; import android.os.Handler; @@ -361,7 +362,7 @@ final class GeckoEditable } private void assertOnIcThread() { - ThreadUtils.assertOnThread(mIcRunHandler.getLooper().getThread()); + ThreadUtils.assertOnThread(mIcRunHandler.getLooper().getThread(), AssertBehavior.THROW); } private void geckoPostToIc(Runnable runnable) { diff --git a/mobile/android/base/GeckoInputConnection.java b/mobile/android/base/GeckoInputConnection.java index 706f456e954..aac8e3f8891 100644 --- a/mobile/android/base/GeckoInputConnection.java +++ b/mobile/android/base/GeckoInputConnection.java @@ -5,10 +5,16 @@ package org.mozilla.gecko; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.concurrent.SynchronousQueue; + import org.mozilla.gecko.gfx.InputConnectionHandler; import org.mozilla.gecko.util.Clipboard; import org.mozilla.gecko.util.GamepadUtils; import org.mozilla.gecko.util.ThreadUtils; +import org.mozilla.gecko.util.ThreadUtils.AssertBehavior; import android.R; import android.content.Context; @@ -33,11 +39,6 @@ import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.concurrent.SynchronousQueue; - class GeckoInputConnection extends BaseInputConnection implements InputConnectionHandler, GeckoEditableListener { @@ -115,7 +116,7 @@ class GeckoInputConnection public void waitForUiThread(Handler icHandler) { if (DEBUG) { - ThreadUtils.assertOnThread(icHandler.getLooper().getThread()); + ThreadUtils.assertOnThread(icHandler.getLooper().getThread(), AssertBehavior.THROW); Log.d(LOGTAG, "waitForUiThread() blocking on thread " + icHandler.getLooper().getThread().getName()); } @@ -154,7 +155,7 @@ class GeckoInputConnection public Editable getEditableForUiThread(final Handler uiHandler, final GeckoEditableClient client) { if (DEBUG) { - ThreadUtils.assertOnThread(uiHandler.getLooper().getThread()); + ThreadUtils.assertOnThread(uiHandler.getLooper().getThread(), AssertBehavior.THROW); } final Handler icHandler = client.getInputConnectionHandler(); if (icHandler.getLooper() == uiHandler.getLooper()) { @@ -171,7 +172,7 @@ class GeckoInputConnection final Method method, final Object[] args) throws Throwable { if (DEBUG) { - ThreadUtils.assertOnThread(uiHandler.getLooper().getThread()); + ThreadUtils.assertOnThread(uiHandler.getLooper().getThread(), AssertBehavior.THROW); Log.d(LOGTAG, "UiEditable." + method.getName() + "() blocking"); } synchronized (icHandler) { diff --git a/mobile/android/base/menu/GeckoMenu.java b/mobile/android/base/menu/GeckoMenu.java index ba69b68f1d1..e2aabc816dc 100644 --- a/mobile/android/base/menu/GeckoMenu.java +++ b/mobile/android/base/menu/GeckoMenu.java @@ -4,7 +4,10 @@ package org.mozilla.gecko.menu; +import org.mozilla.gecko.AppConstants; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ThreadUtils; +import org.mozilla.gecko.util.ThreadUtils.AssertBehavior; import android.content.ComponentName; import android.content.Context; @@ -35,6 +38,12 @@ public class GeckoMenu extends ListView GeckoMenuItem.OnShowAsActionChangedListener { private static final String LOGTAG = "GeckoMenu"; + /** + * Controls whether off-UI-thread method calls in this class cause an + * exception or just logging. + */ + private static final AssertBehavior THREAD_ASSERT_BEHAVIOR = AppConstants.RELEASE_BUILD ? AssertBehavior.NONE : AssertBehavior.THROW; + /* * A callback for a menu item selected event. */ @@ -52,7 +61,7 @@ public class GeckoMenu extends ListView // Open the menu. public void openMenu(); - // Show the actual view contaning the menu items. This can either be a parent or sub-menu. + // Show the actual view containing the menu items. This can either be a parent or sub-menu. public void showMenu(View menu); // Close the menu. @@ -130,6 +139,10 @@ public class GeckoMenu extends ListView mSecondaryActionItemBar = (DefaultActionItemBar) LayoutInflater.from(context).inflate(R.layout.menu_secondary_action_bar, null); } + private static void assertOnUiThread() { + ThreadUtils.assertOnUiThread(THREAD_ASSERT_BEHAVIOR); + } + @Override public MenuItem add(CharSequence title) { GeckoMenuItem menuItem = new GeckoMenuItem(this, NO_ID, 0, title); @@ -159,12 +172,14 @@ public class GeckoMenu extends ListView } private void addItem(GeckoMenuItem menuItem) { + assertOnUiThread(); menuItem.setOnShowAsActionChangedListener(this); mAdapter.addMenuItem(menuItem); mItems.add(menuItem); } private boolean addActionItem(final GeckoMenuItem menuItem) { + assertOnUiThread(); menuItem.setOnShowAsActionChangedListener(this); final View actionView = menuItem.getActionView(); @@ -272,6 +287,7 @@ public class GeckoMenu extends ListView @Override public void clear() { + assertOnUiThread(); for (GeckoMenuItem menuItem : mItems) { if (menuItem.hasSubMenu()) { SubMenu sub = menuItem.getSubMenu(); @@ -355,6 +371,7 @@ public class GeckoMenu extends ListView @Override public boolean hasVisibleItems() { + assertOnUiThread(); for (GeckoMenuItem menuItem : mItems) { if (menuItem.isVisible() && !mPrimaryActionItems.containsKey(menuItem) && @@ -386,6 +403,7 @@ public class GeckoMenu extends ListView @Override public void removeItem(int id) { + assertOnUiThread(); GeckoMenuItem item = (GeckoMenuItem) findItem(id); if (item == null) return; @@ -473,6 +491,7 @@ public class GeckoMenu extends ListView } public void onItemChanged(GeckoMenuItem item) { + assertOnUiThread(); if (item.isActionItem()) { final View actionView; if (item.getActionEnum() == GeckoMenuItem.SHOW_AS_ACTION_ALWAYS) { diff --git a/mobile/android/base/util/ThreadUtils.java b/mobile/android/base/util/ThreadUtils.java index a646f1ae4e9..48c8657d0c6 100644 --- a/mobile/android/base/util/ThreadUtils.java +++ b/mobile/android/base/util/ThreadUtils.java @@ -5,15 +5,24 @@ package org.mozilla.gecko.util; +import java.util.Map; + import android.os.Handler; import android.os.MessageQueue; import android.util.Log; -import java.util.Map; - public final class ThreadUtils { private static final String LOGTAG = "ThreadUtils"; + /** + * Controls the action taken when a method like + * {@link ThreadUtils#assertOnUiThread(AssertBehavior)} detects a problem. + */ + public static enum AssertBehavior { + NONE, + THROW, + } + private static Thread sUiThread; private static Thread sBackgroundThread; @@ -101,28 +110,46 @@ public final class ThreadUtils { GeckoBackgroundThread.post(runnable); } + public static void assertOnUiThread(final AssertBehavior assertBehavior) { + assertOnThread(getUiThread(), assertBehavior); + } + public static void assertOnUiThread() { - assertOnThread(getUiThread()); + assertOnThread(getUiThread(), AssertBehavior.THROW); } public static void assertOnGeckoThread() { - assertOnThread(sGeckoThread); + assertOnThread(sGeckoThread, AssertBehavior.THROW); } public static void assertOnBackgroundThread() { - assertOnThread(getBackgroundThread()); + assertOnThread(getBackgroundThread(), AssertBehavior.THROW); } - public static void assertOnThread(Thread expectedThread) { - Thread currentThread = Thread.currentThread(); - long currentThreadId = currentThread.getId(); - long expectedThreadId = expectedThread.getId(); + public static void assertOnThread(final Thread expectedThread) { + assertOnThread(expectedThread, AssertBehavior.THROW); + } - if (currentThreadId != expectedThreadId) { - throw new IllegalThreadStateException("Expected thread " + expectedThreadId + " (\"" - + expectedThread.getName() - + "\"), but running on thread " + currentThreadId - + " (\"" + currentThread.getName() + ")"); + public static void assertOnThread(final Thread expectedThread, AssertBehavior behavior) { + final Thread currentThread = Thread.currentThread(); + final long currentThreadId = currentThread.getId(); + final long expectedThreadId = expectedThread.getId(); + + if (currentThreadId == expectedThreadId) { + return; + } + + final String message = "Expected thread " + + expectedThreadId + " (\"" + expectedThread.getName() + + "\"), but running on thread " + + currentThreadId + " (\"" + currentThread.getName() + ")"; + final IllegalThreadStateException e = new IllegalThreadStateException(message); + + switch (behavior) { + case THROW: + throw e; + default: + Log.e(LOGTAG, "Method called on wrong thread!", e); } } From 30e60c639b6c990596c1d058e63045e5a2d9b20a Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Mon, 17 Mar 2014 19:39:40 -0700 Subject: [PATCH 02/88] Bug 975838 - Part 2: robocop test that a GeckoMenu call will fail on the wrong thread. r=wesj --- mobile/android/base/tests/robocop.ini | 1 + mobile/android/base/tests/testGeckoMenu.java | 68 ++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 mobile/android/base/tests/testGeckoMenu.java diff --git a/mobile/android/base/tests/robocop.ini b/mobile/android/base/tests/robocop.ini index dff29c3d0da..ecb70d6d0e8 100644 --- a/mobile/android/base/tests/robocop.ini +++ b/mobile/android/base/tests/robocop.ini @@ -39,6 +39,7 @@ skip-if = android_version == "10" # disabled on x86 only; bug 927476 skip-if = processor == "x86" [testFormHistory] +[testGeckoMenu] [testGetUserMedia] # disabled on 2.3; bug 979620 skip-if = android_version == "10" diff --git a/mobile/android/base/tests/testGeckoMenu.java b/mobile/android/base/tests/testGeckoMenu.java new file mode 100644 index 00000000000..cae0d96d9b8 --- /dev/null +++ b/mobile/android/base/tests/testGeckoMenu.java @@ -0,0 +1,68 @@ +package org.mozilla.gecko.tests; + +import org.mozilla.gecko.AppConstants; +import org.mozilla.gecko.menu.GeckoMenu; +import org.mozilla.gecko.util.ThreadUtils; + +public class testGeckoMenu extends BaseTest { + + private volatile Exception exception; + private void setException(Exception e) { + this.exception = e; + } + + @Override + protected int getTestType() { + return TEST_MOCHITEST; + } + + public void testMenuThreading() throws InterruptedException { + final GeckoMenu menu = new GeckoMenu(mSolo.getCurrentActivity()); + final Object semaphore = new Object(); + + ThreadUtils.postToUiThread(new Runnable() { + @Override + public void run() { + try { + menu.add("test1"); + } catch (Exception e) { + setException(e); + } + + synchronized (semaphore) { + semaphore.notify(); + } + } + }); + synchronized (semaphore) { + semaphore.wait(); + } + mAsserter.is(exception, null, "No exception thrown if called on UI thread."); + + new Thread(new Runnable() { + @Override + public void run() { + try { + menu.add("test2"); + } catch (Exception e) { + setException(e); + } + + synchronized (semaphore) { + semaphore.notify(); + } + } + }).start(); + synchronized (semaphore) { + semaphore.wait(); + } + + if (AppConstants.RELEASE_BUILD) { + mAsserter.is(exception, null, "No exception was thrown: release build."); + return; + } + + mAsserter.is(exception != null, true, "An exception was thrown."); + mAsserter.is(exception.getClass(), IllegalThreadStateException.class, "An IllegalThreadStateException was thrown."); + } +} From a0aed99bad378b0cc7c2c2dd7ad254fa5918fad9 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Tue, 18 Mar 2014 01:30:21 -0400 Subject: [PATCH 03/88] bug 979470 - clean up garbage file r=cleanup --- mobile/android/base/resources/layout/.#tabs_item_row.xml | 1 - 1 file changed, 1 deletion(-) delete mode 120000 mobile/android/base/resources/layout/.#tabs_item_row.xml diff --git a/mobile/android/base/resources/layout/.#tabs_item_row.xml b/mobile/android/base/resources/layout/.#tabs_item_row.xml deleted file mode 120000 index 4e6f3091923..00000000000 --- a/mobile/android/base/resources/layout/.#tabs_item_row.xml +++ /dev/null @@ -1 +0,0 @@ -blassey@flyingfox.local.319 \ No newline at end of file From 050e04a30da01e0e6cd571f2415ffa163ee2621f Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Mon, 17 Mar 2014 22:42:24 -0700 Subject: [PATCH 04/88] Backed out changeset 02bceb824051 (bug 975838) --- mobile/android/base/tests/robocop.ini | 1 - mobile/android/base/tests/testGeckoMenu.java | 68 -------------------- 2 files changed, 69 deletions(-) delete mode 100644 mobile/android/base/tests/testGeckoMenu.java diff --git a/mobile/android/base/tests/robocop.ini b/mobile/android/base/tests/robocop.ini index ecb70d6d0e8..dff29c3d0da 100644 --- a/mobile/android/base/tests/robocop.ini +++ b/mobile/android/base/tests/robocop.ini @@ -39,7 +39,6 @@ skip-if = android_version == "10" # disabled on x86 only; bug 927476 skip-if = processor == "x86" [testFormHistory] -[testGeckoMenu] [testGetUserMedia] # disabled on 2.3; bug 979620 skip-if = android_version == "10" diff --git a/mobile/android/base/tests/testGeckoMenu.java b/mobile/android/base/tests/testGeckoMenu.java deleted file mode 100644 index cae0d96d9b8..00000000000 --- a/mobile/android/base/tests/testGeckoMenu.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.mozilla.gecko.tests; - -import org.mozilla.gecko.AppConstants; -import org.mozilla.gecko.menu.GeckoMenu; -import org.mozilla.gecko.util.ThreadUtils; - -public class testGeckoMenu extends BaseTest { - - private volatile Exception exception; - private void setException(Exception e) { - this.exception = e; - } - - @Override - protected int getTestType() { - return TEST_MOCHITEST; - } - - public void testMenuThreading() throws InterruptedException { - final GeckoMenu menu = new GeckoMenu(mSolo.getCurrentActivity()); - final Object semaphore = new Object(); - - ThreadUtils.postToUiThread(new Runnable() { - @Override - public void run() { - try { - menu.add("test1"); - } catch (Exception e) { - setException(e); - } - - synchronized (semaphore) { - semaphore.notify(); - } - } - }); - synchronized (semaphore) { - semaphore.wait(); - } - mAsserter.is(exception, null, "No exception thrown if called on UI thread."); - - new Thread(new Runnable() { - @Override - public void run() { - try { - menu.add("test2"); - } catch (Exception e) { - setException(e); - } - - synchronized (semaphore) { - semaphore.notify(); - } - } - }).start(); - synchronized (semaphore) { - semaphore.wait(); - } - - if (AppConstants.RELEASE_BUILD) { - mAsserter.is(exception, null, "No exception was thrown: release build."); - return; - } - - mAsserter.is(exception != null, true, "An exception was thrown."); - mAsserter.is(exception.getClass(), IllegalThreadStateException.class, "An IllegalThreadStateException was thrown."); - } -} From 8910ccd1dbeb16780ccc538b0c6af5762da31831 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Mon, 17 Mar 2014 22:42:34 -0700 Subject: [PATCH 05/88] Backed out changeset 1e8fa32e8abd (bug 975838) --- mobile/android/base/GeckoEditable.java | 3 +- mobile/android/base/GeckoInputConnection.java | 17 +++--- mobile/android/base/menu/GeckoMenu.java | 21 +------ mobile/android/base/util/ThreadUtils.java | 55 +++++-------------- 4 files changed, 24 insertions(+), 72 deletions(-) diff --git a/mobile/android/base/GeckoEditable.java b/mobile/android/base/GeckoEditable.java index aff8aa08e83..41962694aff 100644 --- a/mobile/android/base/GeckoEditable.java +++ b/mobile/android/base/GeckoEditable.java @@ -8,7 +8,6 @@ package org.mozilla.gecko; import org.mozilla.gecko.gfx.InputConnectionHandler; import org.mozilla.gecko.gfx.LayerView; import org.mozilla.gecko.util.ThreadUtils; -import org.mozilla.gecko.util.ThreadUtils.AssertBehavior; import android.os.Build; import android.os.Handler; @@ -362,7 +361,7 @@ final class GeckoEditable } private void assertOnIcThread() { - ThreadUtils.assertOnThread(mIcRunHandler.getLooper().getThread(), AssertBehavior.THROW); + ThreadUtils.assertOnThread(mIcRunHandler.getLooper().getThread()); } private void geckoPostToIc(Runnable runnable) { diff --git a/mobile/android/base/GeckoInputConnection.java b/mobile/android/base/GeckoInputConnection.java index aac8e3f8891..706f456e954 100644 --- a/mobile/android/base/GeckoInputConnection.java +++ b/mobile/android/base/GeckoInputConnection.java @@ -5,16 +5,10 @@ package org.mozilla.gecko; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.concurrent.SynchronousQueue; - import org.mozilla.gecko.gfx.InputConnectionHandler; import org.mozilla.gecko.util.Clipboard; import org.mozilla.gecko.util.GamepadUtils; import org.mozilla.gecko.util.ThreadUtils; -import org.mozilla.gecko.util.ThreadUtils.AssertBehavior; import android.R; import android.content.Context; @@ -39,6 +33,11 @@ import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.concurrent.SynchronousQueue; + class GeckoInputConnection extends BaseInputConnection implements InputConnectionHandler, GeckoEditableListener { @@ -116,7 +115,7 @@ class GeckoInputConnection public void waitForUiThread(Handler icHandler) { if (DEBUG) { - ThreadUtils.assertOnThread(icHandler.getLooper().getThread(), AssertBehavior.THROW); + ThreadUtils.assertOnThread(icHandler.getLooper().getThread()); Log.d(LOGTAG, "waitForUiThread() blocking on thread " + icHandler.getLooper().getThread().getName()); } @@ -155,7 +154,7 @@ class GeckoInputConnection public Editable getEditableForUiThread(final Handler uiHandler, final GeckoEditableClient client) { if (DEBUG) { - ThreadUtils.assertOnThread(uiHandler.getLooper().getThread(), AssertBehavior.THROW); + ThreadUtils.assertOnThread(uiHandler.getLooper().getThread()); } final Handler icHandler = client.getInputConnectionHandler(); if (icHandler.getLooper() == uiHandler.getLooper()) { @@ -172,7 +171,7 @@ class GeckoInputConnection final Method method, final Object[] args) throws Throwable { if (DEBUG) { - ThreadUtils.assertOnThread(uiHandler.getLooper().getThread(), AssertBehavior.THROW); + ThreadUtils.assertOnThread(uiHandler.getLooper().getThread()); Log.d(LOGTAG, "UiEditable." + method.getName() + "() blocking"); } synchronized (icHandler) { diff --git a/mobile/android/base/menu/GeckoMenu.java b/mobile/android/base/menu/GeckoMenu.java index e2aabc816dc..ba69b68f1d1 100644 --- a/mobile/android/base/menu/GeckoMenu.java +++ b/mobile/android/base/menu/GeckoMenu.java @@ -4,10 +4,7 @@ package org.mozilla.gecko.menu; -import org.mozilla.gecko.AppConstants; import org.mozilla.gecko.R; -import org.mozilla.gecko.util.ThreadUtils; -import org.mozilla.gecko.util.ThreadUtils.AssertBehavior; import android.content.ComponentName; import android.content.Context; @@ -38,12 +35,6 @@ public class GeckoMenu extends ListView GeckoMenuItem.OnShowAsActionChangedListener { private static final String LOGTAG = "GeckoMenu"; - /** - * Controls whether off-UI-thread method calls in this class cause an - * exception or just logging. - */ - private static final AssertBehavior THREAD_ASSERT_BEHAVIOR = AppConstants.RELEASE_BUILD ? AssertBehavior.NONE : AssertBehavior.THROW; - /* * A callback for a menu item selected event. */ @@ -61,7 +52,7 @@ public class GeckoMenu extends ListView // Open the menu. public void openMenu(); - // Show the actual view containing the menu items. This can either be a parent or sub-menu. + // Show the actual view contaning the menu items. This can either be a parent or sub-menu. public void showMenu(View menu); // Close the menu. @@ -139,10 +130,6 @@ public class GeckoMenu extends ListView mSecondaryActionItemBar = (DefaultActionItemBar) LayoutInflater.from(context).inflate(R.layout.menu_secondary_action_bar, null); } - private static void assertOnUiThread() { - ThreadUtils.assertOnUiThread(THREAD_ASSERT_BEHAVIOR); - } - @Override public MenuItem add(CharSequence title) { GeckoMenuItem menuItem = new GeckoMenuItem(this, NO_ID, 0, title); @@ -172,14 +159,12 @@ public class GeckoMenu extends ListView } private void addItem(GeckoMenuItem menuItem) { - assertOnUiThread(); menuItem.setOnShowAsActionChangedListener(this); mAdapter.addMenuItem(menuItem); mItems.add(menuItem); } private boolean addActionItem(final GeckoMenuItem menuItem) { - assertOnUiThread(); menuItem.setOnShowAsActionChangedListener(this); final View actionView = menuItem.getActionView(); @@ -287,7 +272,6 @@ public class GeckoMenu extends ListView @Override public void clear() { - assertOnUiThread(); for (GeckoMenuItem menuItem : mItems) { if (menuItem.hasSubMenu()) { SubMenu sub = menuItem.getSubMenu(); @@ -371,7 +355,6 @@ public class GeckoMenu extends ListView @Override public boolean hasVisibleItems() { - assertOnUiThread(); for (GeckoMenuItem menuItem : mItems) { if (menuItem.isVisible() && !mPrimaryActionItems.containsKey(menuItem) && @@ -403,7 +386,6 @@ public class GeckoMenu extends ListView @Override public void removeItem(int id) { - assertOnUiThread(); GeckoMenuItem item = (GeckoMenuItem) findItem(id); if (item == null) return; @@ -491,7 +473,6 @@ public class GeckoMenu extends ListView } public void onItemChanged(GeckoMenuItem item) { - assertOnUiThread(); if (item.isActionItem()) { final View actionView; if (item.getActionEnum() == GeckoMenuItem.SHOW_AS_ACTION_ALWAYS) { diff --git a/mobile/android/base/util/ThreadUtils.java b/mobile/android/base/util/ThreadUtils.java index 48c8657d0c6..a646f1ae4e9 100644 --- a/mobile/android/base/util/ThreadUtils.java +++ b/mobile/android/base/util/ThreadUtils.java @@ -5,24 +5,15 @@ package org.mozilla.gecko.util; -import java.util.Map; - import android.os.Handler; import android.os.MessageQueue; import android.util.Log; +import java.util.Map; + public final class ThreadUtils { private static final String LOGTAG = "ThreadUtils"; - /** - * Controls the action taken when a method like - * {@link ThreadUtils#assertOnUiThread(AssertBehavior)} detects a problem. - */ - public static enum AssertBehavior { - NONE, - THROW, - } - private static Thread sUiThread; private static Thread sBackgroundThread; @@ -110,46 +101,28 @@ public final class ThreadUtils { GeckoBackgroundThread.post(runnable); } - public static void assertOnUiThread(final AssertBehavior assertBehavior) { - assertOnThread(getUiThread(), assertBehavior); - } - public static void assertOnUiThread() { - assertOnThread(getUiThread(), AssertBehavior.THROW); + assertOnThread(getUiThread()); } public static void assertOnGeckoThread() { - assertOnThread(sGeckoThread, AssertBehavior.THROW); + assertOnThread(sGeckoThread); } public static void assertOnBackgroundThread() { - assertOnThread(getBackgroundThread(), AssertBehavior.THROW); + assertOnThread(getBackgroundThread()); } - public static void assertOnThread(final Thread expectedThread) { - assertOnThread(expectedThread, AssertBehavior.THROW); - } + public static void assertOnThread(Thread expectedThread) { + Thread currentThread = Thread.currentThread(); + long currentThreadId = currentThread.getId(); + long expectedThreadId = expectedThread.getId(); - public static void assertOnThread(final Thread expectedThread, AssertBehavior behavior) { - final Thread currentThread = Thread.currentThread(); - final long currentThreadId = currentThread.getId(); - final long expectedThreadId = expectedThread.getId(); - - if (currentThreadId == expectedThreadId) { - return; - } - - final String message = "Expected thread " + - expectedThreadId + " (\"" + expectedThread.getName() + - "\"), but running on thread " + - currentThreadId + " (\"" + currentThread.getName() + ")"; - final IllegalThreadStateException e = new IllegalThreadStateException(message); - - switch (behavior) { - case THROW: - throw e; - default: - Log.e(LOGTAG, "Method called on wrong thread!", e); + if (currentThreadId != expectedThreadId) { + throw new IllegalThreadStateException("Expected thread " + expectedThreadId + " (\"" + + expectedThread.getName() + + "\"), but running on thread " + currentThreadId + + " (\"" + currentThread.getName() + ")"); } } From 77ccea0a1647ca2875c2e39e75c0089cf8441614 Mon Sep 17 00:00:00 2001 From: Brandon Benvie Date: Mon, 17 Mar 2014 11:11:00 -0700 Subject: [PATCH 06/88] Bug 943510 - Convert to Promise.jsm in the devtools framework. r=pbrosset, r=rcampbell --- browser/devtools/framework/gDevTools.jsm | 2 +- browser/devtools/framework/sidebar.js | 2 +- browser/devtools/framework/target.js | 5 ++- browser/devtools/framework/toolbox-hosts.js | 9 ++---- browser/devtools/framework/toolbox-options.js | 8 ++--- browser/devtools/framework/toolbox.js | 22 ++++++------- browser/devtools/inspector/breadcrumbs.js | 6 ++-- browser/devtools/inspector/inspector-panel.js | 16 ++++++---- .../test/browser_inspector_breadcrumbs.js | 9 ++++-- ...nspector_bug_952294_tooltips_dimensions.js | 2 +- .../test/browser_inspector_changes.js | 6 ++-- .../browser_inspector_pseudoclass_lock.js | 3 +- browser/devtools/inspector/test/head.js | 9 ++++++ browser/devtools/markupview/markup-view.js | 10 ++++-- .../test/browser_responsivecomputedview.js | 2 +- .../test/browser_responsiveruleview.js | 2 +- .../devtools/responsivedesign/test/head.js | 28 +++++++---------- ...ug946331_close_tooltip_on_new_selection.js | 7 ++--- .../browser_ruleview_original_source_link.js | 2 +- browser/devtools/styleinspector/test/head.js | 31 +++++++++++-------- 20 files changed, 101 insertions(+), 80 deletions(-) diff --git a/browser/devtools/framework/gDevTools.jsm b/browser/devtools/framework/gDevTools.jsm index 8a593b11c28..8b937881d5b 100644 --- a/browser/devtools/framework/gDevTools.jsm +++ b/browser/devtools/framework/gDevTools.jsm @@ -11,8 +11,8 @@ const { classes: Cc, interfaces: Ci, utils: Cu } = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/devtools/event-emitter.js"); -let promise = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js").Promise; Cu.import("resource://gre/modules/devtools/Loader.jsm"); +const { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {}); var ProfilerController = devtools.require("devtools/profiler/controller"); diff --git a/browser/devtools/framework/sidebar.js b/browser/devtools/framework/sidebar.js index 6d0898911c6..3d7210c8bac 100644 --- a/browser/devtools/framework/sidebar.js +++ b/browser/devtools/framework/sidebar.js @@ -8,7 +8,7 @@ const {Cu} = require("chrome"); Cu.import("resource://gre/modules/Services.jsm"); -var promise = require("sdk/core/promise"); +var {Promise: promise} = require("resource://gre/modules/Promise.jsm"); var EventEmitter = require("devtools/toolkit/event-emitter"); var Telemetry = require("devtools/shared/telemetry"); diff --git a/browser/devtools/framework/target.js b/browser/devtools/framework/target.js index 8aea426bbe1..f78bec359d4 100644 --- a/browser/devtools/framework/target.js +++ b/browser/devtools/framework/target.js @@ -5,9 +5,8 @@ "use strict"; const {Cc, Ci, Cu} = require("chrome"); - -var promise = require("sdk/core/promise"); -var EventEmitter = require("devtools/toolkit/event-emitter"); +const {Promise: promise} = require("resource://gre/modules/Promise.jsm"); +const EventEmitter = require("devtools/toolkit/event-emitter"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "DebuggerServer", diff --git a/browser/devtools/framework/toolbox-hosts.js b/browser/devtools/framework/toolbox-hosts.js index c9173deb0d6..96fa31bb109 100644 --- a/browser/devtools/framework/toolbox-hosts.js +++ b/browser/devtools/framework/toolbox-hosts.js @@ -5,10 +5,8 @@ "use strict"; const {Cu} = require("chrome"); - -let promise = require("sdk/core/promise"); -let EventEmitter = require("devtools/toolkit/event-emitter"); - +const EventEmitter = require("devtools/toolkit/event-emitter"); +const {Promise: promise} = require("resource://gre/modules/Promise.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource:///modules/devtools/DOMHelpers.jsm"); @@ -217,6 +215,7 @@ WindowHost.prototype = { let frameLoad = function(event) { win.removeEventListener("load", frameLoad, true); + win.focus(); this.frame = win.document.getElementById("toolbox-iframe"); this.emit("ready", this.frame); @@ -226,8 +225,6 @@ WindowHost.prototype = { win.addEventListener("load", frameLoad, true); win.addEventListener("unload", this._boundUnload); - win.focus(); - this._window = win; return deferred.promise; diff --git a/browser/devtools/framework/toolbox-options.js b/browser/devtools/framework/toolbox-options.js index 1eb67aadd27..9a16d1e6287 100644 --- a/browser/devtools/framework/toolbox-options.js +++ b/browser/devtools/framework/toolbox-options.js @@ -5,11 +5,9 @@ "use strict"; const {Cu, Cc, Ci} = require("chrome"); - -let promise = require("sdk/core/promise"); -let EventEmitter = require("devtools/toolkit/event-emitter"); - -Cu.import('resource://gre/modules/XPCOMUtils.jsm'); +const EventEmitter = require("devtools/toolkit/event-emitter"); +const {Promise: promise} = require("resource://gre/modules/Promise.jsm"); +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource:///modules/devtools/gDevTools.jsm"); diff --git a/browser/devtools/framework/toolbox.js b/browser/devtools/framework/toolbox.js index e0ef9644138..d166f286ae1 100644 --- a/browser/devtools/framework/toolbox.js +++ b/browser/devtools/framework/toolbox.js @@ -10,7 +10,7 @@ const MIN_ZOOM = 0.5; const MAX_ZOOM = 2; let {Cc, Ci, Cu} = require("chrome"); -let promise = require("sdk/core/promise"); +let {Promise: promise} = require("resource://gre/modules/Promise.jsm"); let EventEmitter = require("devtools/toolkit/event-emitter"); let Telemetry = require("devtools/shared/telemetry"); let HUDService = require("devtools/webconsole/hudservice"); @@ -1433,20 +1433,20 @@ ToolboxHighlighterUtils.prototype = { * @return a promise that resolves when the highlighter is hidden */ unhighlight: function(forceHide=false) { - if (this.isRemoteHighlightable) { - // If the remote highlighter exists on the target, use it - return this.toolbox.initInspector().then(() => { - let autohide = forceHide || !gDevTools.testing; + let unhighlightPromise; + forceHide = forceHide || !gDevTools.testing; - if (autohide) { - return this.toolbox.highlighter.hideBoxModel(); - } - return promise.resolve(); - }); + if (forceHide && this.isRemoteHighlightable && this.toolbox.highlighter) { + // If the remote highlighter exists on the target, use it + unhighlightPromise = this.toolbox.highlighter.hideBoxModel(); } else { // If not, no need to unhighlight as the older highlight method uses a // setTimeout to hide itself - return promise.resolve(); + unhighlightPromise = promise.resolve(); } + + return unhighlightPromise.then(() => { + this.toolbox.emit("node-unhighlight"); + }); } }; diff --git a/browser/devtools/inspector/breadcrumbs.js b/browser/devtools/inspector/breadcrumbs.js index 0ec7fce177d..26c46874591 100644 --- a/browser/devtools/inspector/breadcrumbs.js +++ b/browser/devtools/inspector/breadcrumbs.js @@ -692,8 +692,10 @@ HTMLBreadcrumbs.prototype = { // Make sure the selected node and its neighbours are visible. this.scroll(); - this.inspector.emit("breadcrumbs-updated", this.selection.nodeFront); - doneUpdating(); + return resolveNextTick().then(() => { + this.inspector.emit("breadcrumbs-updated", this.selection.nodeFront); + doneUpdating(); + }); }).then(null, err => { doneUpdating(this.selection.nodeFront); this.selectionGuardEnd(err); diff --git a/browser/devtools/inspector/inspector-panel.js b/browser/devtools/inspector/inspector-panel.js index abbfe7babcf..9c4fe10a78c 100644 --- a/browser/devtools/inspector/inspector-panel.js +++ b/browser/devtools/inspector/inspector-panel.js @@ -470,9 +470,8 @@ InspectorPanel.prototype = { */ destroy: function InspectorPanel__destroy() { if (this._panelDestroyer) { - return this._panelDestroyer.promise; + return this._panelDestroyer; } - this._panelDestroyer = promise.defer(); if (this.walker) { this.walker.off("new-root", this.onNewRoot); @@ -506,7 +505,7 @@ InspectorPanel.prototype = { this.selection.off("before-new-node", this.onBeforeNewSelection); this.selection.off("before-new-node-front", this.onBeforeNewSelection); this.selection.off("detached-front", this.onDetached); - this._destroyMarkup(); + this._panelDestroyer = this._destroyMarkup(); this.panelWin.inspector = null; this.target = null; this.panelDoc = null; @@ -517,8 +516,7 @@ InspectorPanel.prototype = { this.nodemenu = null; this._toolbox = null; - this._panelDestroyer.resolve(null); - return this._panelDestroyer.promise; + return this._panelDestroyer; }, /** @@ -643,14 +641,18 @@ InspectorPanel.prototype = { }, _destroyMarkup: function InspectorPanel__destroyMarkup() { + let destroyPromise; + if (this._boundMarkupFrameLoad) { this._markupFrame.removeEventListener("load", this._boundMarkupFrameLoad, true); this._boundMarkupFrameLoad = null; } if (this.markup) { - this.markup.destroy(); + destroyPromise = this.markup.destroy(); this.markup = null; + } else { + destroyPromise = promise.resolve(); } if (this._markupFrame) { @@ -659,6 +661,8 @@ InspectorPanel.prototype = { } this._markupBox = null; + + return destroyPromise; }, /** diff --git a/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js b/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js index 428d8a2fc4b..47fd0dda94e 100644 --- a/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js +++ b/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js @@ -19,6 +19,9 @@ function test() let nodes; let cursor; let inspector; + let target; + let panel; + let container; gBrowser.selectedTab = gBrowser.addTab(); gBrowser.selectedBrowser.addEventListener("load", function onload() { @@ -43,6 +46,9 @@ function test() function runTests(aInspector) { inspector = aInspector; + target = TargetFactory.forTab(gBrowser.selectedTab); + panel = gDevTools.getToolbox(target).getPanel("inspector"); + container = panel.panelDoc.getElementById("inspector-breadcrumbs"); cursor = 0; inspector.on("breadcrumbs-updated", nodeSelected); executeSoon(function() { @@ -69,9 +75,6 @@ function test() function performTest() { - let target = TargetFactory.forTab(gBrowser.selectedTab); - let panel = gDevTools.getToolbox(target).getPanel("inspector"); - let container = panel.panelDoc.getElementById("inspector-breadcrumbs"); let buttonsLabelIds = nodes[cursor].result.split(" "); // html > body > … diff --git a/browser/devtools/inspector/test/browser_inspector_bug_952294_tooltips_dimensions.js b/browser/devtools/inspector/test/browser_inspector_bug_952294_tooltips_dimensions.js index ffdea9ab0d3..ff6f5070d6c 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_952294_tooltips_dimensions.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_952294_tooltips_dimensions.js @@ -39,7 +39,7 @@ function createDocument() { inspector = aInspector; markupView = inspector.markup; - inspector.sidebar.once("ruleview-ready", function() { + waitForView("ruleview", () => { ruleView = inspector.sidebar.getWindowForTab("ruleview").ruleview.view; inspector.sidebar.select("ruleview"); startTests(); diff --git a/browser/devtools/inspector/test/browser_inspector_changes.js b/browser/devtools/inspector/test/browser_inspector_changes.js index fc76792af6b..57c4fbcda39 100644 --- a/browser/devtools/inspector/test/browser_inspector_changes.js +++ b/browser/devtools/inspector/test/browser_inspector_changes.js @@ -21,7 +21,8 @@ function test() { let ruleview = inspector.sidebar.getWindowForTab("ruleview").ruleview.view; let inlineStyles = ruleview._elementStyle.rules[0]; - for each (let prop in inlineStyles.textProps) { + for (let key in inlineStyles.textProps) { + let prop = inlineStyles.textProps[key]; if (prop.name == aName) { return prop; } @@ -32,7 +33,8 @@ function test() { function runInspectorTests(aInspector) { inspector = aInspector; - inspector.sidebar.once("computedview-ready", () => { + + waitForView("computedview", () => { info("Computed View ready"); inspector.sidebar.select("computedview"); diff --git a/browser/devtools/inspector/test/browser_inspector_pseudoclass_lock.js b/browser/devtools/inspector/test/browser_inspector_pseudoclass_lock.js index 2af4bf0edf0..f439d0755c6 100644 --- a/browser/devtools/inspector/test/browser_inspector_pseudoclass_lock.js +++ b/browser/devtools/inspector/test/browser_inspector_pseudoclass_lock.js @@ -51,7 +51,8 @@ function createDocument() function selectNode(aInspector) { inspector = aInspector; - inspector.sidebar.once("ruleview-ready", function() { + + waitForView("ruleview", () => { ruleview = inspector.sidebar.getWindowForTab("ruleview").ruleview.view; inspector.sidebar.select("ruleview"); inspector.selection.setNode(div, "test"); diff --git a/browser/devtools/inspector/test/head.js b/browser/devtools/inspector/test/head.js index 3076bd94fdd..d1b54323375 100644 --- a/browser/devtools/inspector/test/head.js +++ b/browser/devtools/inspector/test/head.js @@ -202,6 +202,15 @@ function getComputedView() { return inspector.sidebar.getWindowForTab("computedview").computedview.view; } +function waitForView(aName, aCallback) { + let inspector = getActiveInspector(); + if (inspector.sidebar.getTab(aName)) { + aCallback(); + } else { + inspector.sidebar.once(aName + "-ready", aCallback); + } +} + function synthesizeKeyFromKeyTag(aKeyId) { let key = document.getElementById(aKeyId); isnot(key, null, "Successfully retrieved the node"); diff --git a/browser/devtools/markupview/markup-view.js b/browser/devtools/markupview/markup-view.js index a93912df9b3..70ee5a7eb1e 100644 --- a/browser/devtools/markupview/markup-view.js +++ b/browser/devtools/markupview/markup-view.js @@ -177,7 +177,7 @@ MarkupView.prototype = { }, _hideBoxModel: function(forceHide) { - this._inspector.toolbox.highlighterUtils.unhighlight(forceHide); + return this._inspector.toolbox.highlighterUtils.unhighlight(forceHide); }, _briefBoxModelTimer: null, @@ -1044,9 +1044,13 @@ MarkupView.prototype = { * Tear down the markup panel. */ destroy: function() { + if (this._destroyer) { + return this._destroyer; + } + // Note that if the toolbox is closed, this will work fine, but will fail // in case the browser is closed and will trigger a noSuchActor message. - this._hideBoxModel(); + this._destroyer = this._hideBoxModel(); this._hoveredNode = null; this._inspector.toolbox.off("picker-node-hovered", this._onToolboxPickerHover); @@ -1100,6 +1104,8 @@ MarkupView.prototype = { this.tooltip.destroy(); this.tooltip = null; + + return this._destroyer; }, /** diff --git a/browser/devtools/responsivedesign/test/browser_responsivecomputedview.js b/browser/devtools/responsivedesign/test/browser_responsivecomputedview.js index a53d9ae0ac2..b91274a9a8c 100644 --- a/browser/devtools/responsivedesign/test/browser_responsivecomputedview.js +++ b/browser/devtools/responsivedesign/test/browser_responsivecomputedview.js @@ -53,7 +53,7 @@ function test() { instance.setSize(500, 500); - openComputedView(onInspectorUIOpen); + openView("computedview", onInspectorUIOpen); } function onInspectorUIOpen(aInspector, aComputedView) { diff --git a/browser/devtools/responsivedesign/test/browser_responsiveruleview.js b/browser/devtools/responsivedesign/test/browser_responsiveruleview.js index 6abdac3d2f7..a788af3460e 100644 --- a/browser/devtools/responsivedesign/test/browser_responsiveruleview.js +++ b/browser/devtools/responsivedesign/test/browser_responsiveruleview.js @@ -49,7 +49,7 @@ function test() { instance.setSize(500, 500); - openRuleView(onInspectorUIOpen); + openView("ruleview", onInspectorUIOpen); } function onInspectorUIOpen(aInspector, aRuleView) { diff --git a/browser/devtools/responsivedesign/test/head.js b/browser/devtools/responsivedesign/test/head.js index a362137d275..80fe2a594b8 100644 --- a/browser/devtools/responsivedesign/test/head.js +++ b/browser/devtools/responsivedesign/test/head.js @@ -23,23 +23,19 @@ function openInspector(callback) }); } -function openComputedView(callback) +function openView(name, callback) { openInspector(inspector => { - inspector.sidebar.once("computedview-ready", () => { - inspector.sidebar.select("computedview"); - let ruleView = inspector.sidebar.getWindowForTab("computedview").computedview.view; - callback(inspector, ruleView); - }) - }); -} -function openRuleView(callback) -{ - openInspector(inspector => { - inspector.sidebar.once("ruleview-ready", () => { - inspector.sidebar.select("ruleview"); - let ruleView = inspector.sidebar.getWindowForTab("ruleview").ruleview.view; - callback(inspector, ruleView); - }) + function onReady() { + inspector.sidebar.select(name); + let { view } = inspector.sidebar.getWindowForTab(name)[name]; + callback(inspector, view); + } + + if (inspector.sidebar.getTab(name)) { + onReady(); + } else { + inspector.sidebar.once(name + "-ready", onReady); + } }); } diff --git a/browser/devtools/styleinspector/test/browser_bug946331_close_tooltip_on_new_selection.js b/browser/devtools/styleinspector/test/browser_bug946331_close_tooltip_on_new_selection.js index 29d415943f9..bb39bd03724 100644 --- a/browser/devtools/styleinspector/test/browser_bug946331_close_tooltip_on_new_selection.js +++ b/browser/devtools/styleinspector/test/browser_bug946331_close_tooltip_on_new_selection.js @@ -25,11 +25,11 @@ function test() { function createDocument() { contentDoc.body.innerHTML = PAGE_CONTENT; - openRuleView((aInspector, aRuleView) => { + openView("ruleview", (aInspector, aRuleView) => { inspector = aInspector; ruleView = aRuleView; - inspector.sidebar.once("computedview-ready", () => { - computedView = inspector.sidebar.getWindowForTab("computedview").computedview.view; + openView("computedview", (_, aComputedView) => { + computedView = aComputedView; startTests(); }); }); @@ -66,7 +66,6 @@ function testComputedView() { info("Testing computed view tooltip closes on new selection"); inspector.sidebar.select("computedview"); - computedView = inspector.sidebar.getWindowForTab("computedview").computedview.view; // Show the computed view tooltip let tooltip = computedView.tooltip; diff --git a/browser/devtools/styleinspector/test/browser_ruleview_original_source_link.js b/browser/devtools/styleinspector/test/browser_ruleview_original_source_link.js index 025c5121316..278a0a780f2 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_original_source_link.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_original_source_link.js @@ -47,7 +47,7 @@ function highlightNode() // Highlight a node. let div = content.document.getElementsByTagName("div")[0]; - inspector.selection.setNode(div); + inspector.selection.setNode(div, "test"); inspector.once("inspector-updated", () => { is(inspector.selection.node, div, "selection matches the div element"); testRuleViewLink(); diff --git a/browser/devtools/styleinspector/test/head.js b/browser/devtools/styleinspector/test/head.js index 99781f04260..71ec0859628 100644 --- a/browser/devtools/styleinspector/test/head.js +++ b/browser/devtools/styleinspector/test/head.js @@ -65,26 +65,31 @@ function getActiveInspector() return gDevTools.getToolbox(target).getPanel("inspector"); } -function openRuleView(callback) +function openView(name, callback) { openInspector(inspector => { - inspector.sidebar.once("ruleview-ready", () => { - inspector.sidebar.select("ruleview"); - let ruleView = inspector.sidebar.getWindowForTab("ruleview").ruleview.view; - callback(inspector, ruleView); - }) + function onReady() { + inspector.sidebar.select(name); + let { view } = inspector.sidebar.getWindowForTab(name)[name]; + callback(inspector, view); + } + + if (inspector.sidebar.getTab(name)) { + onReady(); + } else { + inspector.sidebar.once(name + "-ready", onReady); + } }); } +function openRuleView(callback) +{ + openView("ruleview", callback); +} + function openComputedView(callback) { - openInspector(inspector => { - inspector.sidebar.once("computedview-ready", () => { - inspector.sidebar.select("computedview"); - let computedView = inspector.sidebar.getWindowForTab("computedview").computedview.view; - callback(inspector, computedView); - }) - }); + openView("computedview", callback); } /** From 90d03f12fb354581833d16fbbc18d3a9f2d57a88 Mon Sep 17 00:00:00 2001 From: Mike de Boer Date: Tue, 18 Mar 2014 12:49:56 +0100 Subject: [PATCH 07/88] [Australis] Bug 983655: fix combined and menu-button buttons styling in the overflow panel. r=Gijs --- browser/themes/linux/customizableui/panelUIOverlay.css | 1 + browser/themes/osx/browser.css | 2 +- browser/themes/shared/customizableui/panelUIOverlay.inc.css | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/browser/themes/linux/customizableui/panelUIOverlay.css b/browser/themes/linux/customizableui/panelUIOverlay.css index ef7ea088368..4a7327b54ce 100644 --- a/browser/themes/linux/customizableui/panelUIOverlay.css +++ b/browser/themes/linux/customizableui/panelUIOverlay.css @@ -30,6 +30,7 @@ .widget-overflow-list .toolbarbutton-1 > .toolbarbutton-menubutton-button { -moz-appearance: none; border: 0; + -moz-margin-start: 3px; } .widget-overflow-list .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker { diff --git a/browser/themes/osx/browser.css b/browser/themes/osx/browser.css index 7b1bc430fcd..18b76577079 100644 --- a/browser/themes/osx/browser.css +++ b/browser/themes/osx/browser.css @@ -506,7 +506,7 @@ toolbar .toolbarbutton-1[checked]:not(:active):hover { transition: background-color 250ms; } -.toolbarbutton-1[type="menu-button"] { +.toolbarbutton-1[type="menu-button"]:not([overflowedItem=true]) { padding: 0; } diff --git a/browser/themes/shared/customizableui/panelUIOverlay.inc.css b/browser/themes/shared/customizableui/panelUIOverlay.inc.css index 16ddc1ca467..7edd627567f 100644 --- a/browser/themes/shared/customizableui/panelUIOverlay.inc.css +++ b/browser/themes/shared/customizableui/panelUIOverlay.inc.css @@ -946,7 +946,7 @@ toolbaritem[overflowedItem=true], -moz-box-orient: horizontal; } -.widget-overflow-list .toolbarbutton-1 > .toolbarbutton-text, +.widget-overflow-list .toolbarbutton-1:not(.toolbarbutton-combined) > .toolbarbutton-text, .widget-overflow-list .toolbarbutton-1 > .toolbarbutton-menubutton-button > .toolbarbutton-text { text-align: start; -moz-padding-start: .5em; From 005984e601c085a2904d41573be3d6ec1239eb82 Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Tue, 18 Feb 2014 15:16:26 -0800 Subject: [PATCH 08/88] Bug 921557 - Use custom EllipsisTextView to handle bug on older devices. r=mleibovic --- mobile/android/base/home/HomeBanner.java | 9 ++- .../base/locales/en-US/android_strings.dtd | 6 ++ mobile/android/base/moz.build | 1 + .../resources/layout/home_banner_content.xml | 28 ++++---- .../android/base/resources/values/attrs.xml | 4 ++ mobile/android/base/strings.xml.in | 3 + .../android/base/widget/EllipsisTextView.java | 65 +++++++++++++++++++ 7 files changed, 99 insertions(+), 17 deletions(-) create mode 100644 mobile/android/base/widget/EllipsisTextView.java diff --git a/mobile/android/base/home/HomeBanner.java b/mobile/android/base/home/HomeBanner.java index d4717e4d629..4fe3e3a70fd 100644 --- a/mobile/android/base/home/HomeBanner.java +++ b/mobile/android/base/home/HomeBanner.java @@ -16,6 +16,7 @@ import org.mozilla.gecko.animation.ViewHelper; import org.mozilla.gecko.gfx.BitmapUtils; import org.mozilla.gecko.util.GeckoEventListener; import org.mozilla.gecko.util.ThreadUtils; +import org.mozilla.gecko.widget.EllipsisTextView; import android.content.Context; import android.graphics.drawable.Drawable; @@ -53,7 +54,9 @@ public class HomeBanner extends LinearLayout // switches back to the default page. private boolean mUserSwipedDown = false; - private final TextView mTextView; + // We must use this custom TextView to address an issue on 2.3 and lower where ellipsized text + // will not wrap more than 2 lines. + private final EllipsisTextView mTextView; private final ImageView mIconView; // Listener that gets called when the banner is dismissed from the close button. @@ -72,7 +75,7 @@ public class HomeBanner extends LinearLayout LayoutInflater.from(context).inflate(R.layout.home_banner_content, this); - mTextView = (TextView) findViewById(R.id.text); + mTextView = (EllipsisTextView) findViewById(R.id.text); mIconView = (ImageView) findViewById(R.id.icon); } @@ -167,7 +170,7 @@ public class HomeBanner extends LinearLayout // Store the current message id to pass back to JS in the view's OnClickListener. setTag(id); - mTextView.setText(Html.fromHtml(text)); + mTextView.setOriginalText(Html.fromHtml(text)); BitmapUtils.getDrawable(getContext(), iconURI, new BitmapUtils.BitmapLoader() { @Override diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index 0baf1da318e..7b467fb66bb 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -418,6 +418,12 @@ just addresses the organization to follow, e.g. "This site is run by " --> + + + + diff --git a/mobile/android/base/moz.build b/mobile/android/base/moz.build index 43cc9bb3fe0..395f63e7446 100644 --- a/mobile/android/base/moz.build +++ b/mobile/android/base/moz.build @@ -381,6 +381,7 @@ gbjar.sources += [ 'widget/DateTimePicker.java', 'widget/Divider.java', 'widget/DoorHanger.java', + 'widget/EllipsisTextView.java', 'widget/FaviconView.java', 'widget/FlowLayout.java', 'widget/GeckoActionProvider.java', diff --git a/mobile/android/base/resources/layout/home_banner_content.xml b/mobile/android/base/resources/layout/home_banner_content.xml index cc2e34b1cd9..cc99a3e8351 100644 --- a/mobile/android/base/resources/layout/home_banner_content.xml +++ b/mobile/android/base/resources/layout/home_banner_content.xml @@ -3,7 +3,8 @@ - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - + - + + + + + diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in index 6a36a3ac3fc..a7b47c4bf02 100644 --- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -397,4 +397,7 @@ &actionbar_menu; &actionbar_done; + + &ellipsis; + diff --git a/mobile/android/base/widget/EllipsisTextView.java b/mobile/android/base/widget/EllipsisTextView.java new file mode 100644 index 00000000000..c46e12e13eb --- /dev/null +++ b/mobile/android/base/widget/EllipsisTextView.java @@ -0,0 +1,65 @@ +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.gecko.widget; + +import org.mozilla.gecko.R; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.widget.TextView; + +/** + * Text view that correctly handles maxLines and ellipsizing for Android < 2.3. + */ +public class EllipsisTextView extends TextView { + private final String ellipsis; + + private int maxLines; + private CharSequence originalText; + + public EllipsisTextView(Context context) { + this(context, null); + } + + public EllipsisTextView(Context context, AttributeSet attrs) { + this(context, attrs, android.R.attr.textViewStyle); + } + + public EllipsisTextView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + + ellipsis = getResources().getString(R.string.ellipsis); + + TypedArray a = context.getTheme() + .obtainStyledAttributes(attrs, R.styleable.EllipsisTextView, 0, 0); + maxLines = a.getInteger(R.styleable.EllipsisTextView_ellipsizeAtLine, 1); + a.recycle(); + } + + public void setOriginalText(CharSequence text) { + originalText = text; + setText(text); + } + + @Override + public void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + + // There is extra space, start over with the original text + if (getLineCount() < maxLines) { + setText(originalText); + } + + // If we are over the max line attribute, ellipsize + if (getLineCount() > maxLines) { + final int endIndex = getLayout().getLineEnd(maxLines - 1) - 1 - ellipsis.length(); + final String text = getText().subSequence(0, endIndex) + ellipsis; + // Make sure that we don't change originalText + setText(text); + } + } +} From db8cc2b92c187e7030aac2f509f92945fffb4d1d Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Tue, 4 Mar 2014 15:14:49 -0800 Subject: [PATCH 09/88] Bug 975055 - Use ViewState to get previous filter for UI. r=lucasr --- mobile/android/base/home/PanelLayout.java | 30 ++++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/mobile/android/base/home/PanelLayout.java b/mobile/android/base/home/PanelLayout.java index f013ef5b793..ce3640d4402 100644 --- a/mobile/android/base/home/PanelLayout.java +++ b/mobile/android/base/home/PanelLayout.java @@ -279,7 +279,7 @@ abstract class PanelLayout extends FrameLayout { } /** - * Used to find the current filter that this view is displaying, or null if none. + * Get the current filter that this view is displaying, or null if none. */ public String getCurrentFilter() { if (mFilterStack == null) { @@ -295,17 +295,31 @@ abstract class PanelLayout extends FrameLayout { public void pushFilter(String filter) { if (mFilterStack == null) { mFilterStack = new LinkedList(); + + // Initialize with a null filter. + // TODO: use initial filter from ViewConfig + mFilterStack.push(null); } mFilterStack.push(filter); } - public String popFilter() { - if (getCurrentFilter() != null) { - mFilterStack.pop(); + /** + * Remove the most recent filter from the stack. + * + * @return whether the filter was popped + */ + public boolean popFilter() { + if (!canPopFilter()) { + return false; } - return getCurrentFilter(); + mFilterStack.pop(); + return true; + } + + public boolean canPopFilter() { + return (mFilterStack != null && mFilterStack.size() > 1); } } @@ -323,10 +337,8 @@ abstract class PanelLayout extends FrameLayout { * @return whether the filter has changed */ private boolean popFilterOnView(ViewState viewState) { - String currentFilter = viewState.getCurrentFilter(); - String filter = viewState.popFilter(); - - if (!TextUtils.equals(currentFilter, filter)) { + if (viewState.popFilter()) { + final String filter = viewState.getCurrentFilter(); mDatasetHandler.requestDataset(new DatasetRequest(viewState.getDatasetId(), filter)); return true; } else { From b3442fc396ca33c80772d7b21e77ae18eb0f8e3e Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Tue, 4 Mar 2014 15:15:44 -0800 Subject: [PATCH 10/88] Bug 975055 - Show previous filter for back row item. r=lucasr --- .../android/base/home/PanelBackItemView.java | 30 +++++++ mobile/android/base/home/PanelGridView.java | 7 ++ mobile/android/base/home/PanelLayout.java | 49 ++++++++++- mobile/android/base/home/PanelListView.java | 7 ++ .../android/base/home/PanelViewAdapter.java | 82 ++++++++++++++++++- .../base/home/PanelViewUrlHandler.java | 20 +++++ mobile/android/base/moz.build | 1 + .../base/resources/layout/panel_back_item.xml | 19 +++++ 8 files changed, 210 insertions(+), 5 deletions(-) create mode 100644 mobile/android/base/home/PanelBackItemView.java create mode 100644 mobile/android/base/resources/layout/panel_back_item.xml diff --git a/mobile/android/base/home/PanelBackItemView.java b/mobile/android/base/home/PanelBackItemView.java new file mode 100644 index 00000000000..52c747e9b47 --- /dev/null +++ b/mobile/android/base/home/PanelBackItemView.java @@ -0,0 +1,30 @@ +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.gecko.home; + +import org.mozilla.gecko.R; + +import android.content.Context; +import android.view.LayoutInflater; +import android.widget.LinearLayout; +import android.widget.TextView; + +class PanelBackItemView extends LinearLayout { + private final TextView title; + + public PanelBackItemView(Context context) { + super(context); + + LayoutInflater.from(context).inflate(R.layout.panel_back_item, this); + setOrientation(HORIZONTAL); + + title = (TextView) findViewById(R.id.title); + } + + public void updateFromFilter(String filter) { + title.setText(filter); + } +} diff --git a/mobile/android/base/home/PanelGridView.java b/mobile/android/base/home/PanelGridView.java index 7b1f89f353d..4f5f03401f4 100644 --- a/mobile/android/base/home/PanelGridView.java +++ b/mobile/android/base/home/PanelGridView.java @@ -13,6 +13,7 @@ import org.mozilla.gecko.home.HomeConfig.ItemHandler; import org.mozilla.gecko.home.HomeConfig.ViewConfig; import org.mozilla.gecko.home.HomePager.OnUrlOpenListener; import org.mozilla.gecko.home.PanelLayout.DatasetBacked; +import org.mozilla.gecko.home.PanelLayout.FilterManager; import org.mozilla.gecko.home.PanelLayout.PanelView; import android.content.Context; @@ -57,6 +58,12 @@ public class PanelGridView extends GridView mUrlHandler.setOnUrlOpenListener(listener); } + @Override + public void setFilterManager(FilterManager filterManager) { + mAdapter.setFilterManager(filterManager); + mUrlHandler.setFilterManager(filterManager); + } + private class PanelGridItemClickListener implements AdapterView.OnItemClickListener { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { diff --git a/mobile/android/base/home/PanelLayout.java b/mobile/android/base/home/PanelLayout.java index ce3640d4402..f79f32e1714 100644 --- a/mobile/android/base/home/PanelLayout.java +++ b/mobile/android/base/home/PanelLayout.java @@ -20,7 +20,6 @@ import android.view.KeyEvent; import android.view.View; import android.widget.FrameLayout; -import java.util.Deque; import java.util.EnumSet; import java.util.LinkedList; import java.util.Map; @@ -74,6 +73,7 @@ abstract class PanelLayout extends FrameLayout { */ public interface DatasetBacked { public void setDataset(Cursor cursor); + public void setFilterManager(FilterManager manager); } /** @@ -143,6 +143,12 @@ abstract class PanelLayout extends FrameLayout { public void setOnUrlOpenListener(OnUrlOpenListener listener); } + public interface FilterManager { + public String getPreviousFilter(); + public boolean canGoBack(); + public void goBack(); + } + public PanelLayout(Context context, PanelConfig panelConfig, DatasetHandler datasetHandler, OnUrlOpenListener urlOpenListener) { super(context); mViewStateMap = new WeakHashMap(); @@ -217,6 +223,11 @@ abstract class PanelLayout extends FrameLayout { ((PanelView) view).setOnUrlOpenListener(new PanelUrlOpenListener(state)); view.setOnKeyListener(new PanelKeyListener(state)); + if (view instanceof DatasetBacked) { + DatasetBacked datasetBacked = (DatasetBacked) view; + datasetBacked.setFilterManager(new PanelFilterManager(state)); + } + return view; } @@ -268,7 +279,7 @@ abstract class PanelLayout extends FrameLayout { */ protected static class ViewState { private final ViewConfig mViewConfig; - private Deque mFilterStack; + private LinkedList mFilterStack; public ViewState(ViewConfig viewConfig) { mViewConfig = viewConfig; @@ -289,6 +300,17 @@ abstract class PanelLayout extends FrameLayout { } } + /** + * Get the previous filter that this view was displaying, or null if none. + */ + public String getPreviousFilter() { + if (!canPopFilter()) { + return null; + } + + return mFilterStack.get(1); + } + /** * Adds a filter to the history stack for this view. */ @@ -383,4 +405,27 @@ abstract class PanelLayout extends FrameLayout { return false; } } + + private class PanelFilterManager implements FilterManager { + private final ViewState mViewState; + + public PanelFilterManager(ViewState viewState) { + mViewState = viewState; + } + + @Override + public String getPreviousFilter() { + return mViewState.getPreviousFilter(); + } + + @Override + public boolean canGoBack() { + return mViewState.canPopFilter(); + } + + @Override + public void goBack() { + popFilterOnView(mViewState); + } + } } diff --git a/mobile/android/base/home/PanelListView.java b/mobile/android/base/home/PanelListView.java index 50c32c98d5b..68f91f26803 100644 --- a/mobile/android/base/home/PanelListView.java +++ b/mobile/android/base/home/PanelListView.java @@ -12,6 +12,7 @@ import org.mozilla.gecko.home.HomeConfig.ItemHandler; import org.mozilla.gecko.home.HomeConfig.ViewConfig; import org.mozilla.gecko.home.HomePager.OnUrlOpenListener; import org.mozilla.gecko.home.PanelLayout.DatasetBacked; +import org.mozilla.gecko.home.PanelLayout.FilterManager; import org.mozilla.gecko.home.PanelLayout.PanelView; import android.content.Context; @@ -53,6 +54,12 @@ public class PanelListView extends HomeListView mUrlHandler.setOnUrlOpenListener(listener); } + @Override + public void setFilterManager(FilterManager filterManager) { + mAdapter.setFilterManager(filterManager); + mUrlHandler.setFilterManager(filterManager); + } + private class PanelListItemClickListener implements AdapterView.OnItemClickListener { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { diff --git a/mobile/android/base/home/PanelViewAdapter.java b/mobile/android/base/home/PanelViewAdapter.java index c513e4a4200..d310de853d0 100644 --- a/mobile/android/base/home/PanelViewAdapter.java +++ b/mobile/android/base/home/PanelViewAdapter.java @@ -6,6 +6,9 @@ package org.mozilla.gecko.home; import org.mozilla.gecko.home.HomeConfig.ItemType; +import org.mozilla.gecko.home.PanelLayout.FilterManager; + +import org.mozilla.gecko.R; import android.content.Context; import android.database.Cursor; @@ -14,8 +17,12 @@ import android.view.View; import android.view.ViewGroup; class PanelViewAdapter extends CursorAdapter { + private static final int VIEW_TYPE_ITEM = 0; + private static final int VIEW_TYPE_BACK = 1; + private final Context mContext; private final ItemType mItemType; + private FilterManager mFilterManager; public PanelViewAdapter(Context context, ItemType itemType) { super(context, null, 0); @@ -23,14 +30,83 @@ class PanelViewAdapter extends CursorAdapter { mItemType = itemType; } + public void setFilterManager(FilterManager manager) { + mFilterManager = manager; + } + @Override - public void bindView(View view, Context context, Cursor cursor) { + public final int getViewTypeCount() { + return 2; + } + + @Override + public int getCount() { + return super.getCount() + (isShowingBack() ? 1 : 0); + } + + @Override + public int getItemViewType(int position) { + if (isShowingBack() && position == 0) { + return VIEW_TYPE_BACK; + } else { + return VIEW_TYPE_ITEM; + } + } + + @Override + public final View getView(int position, View convertView, ViewGroup parent) { + if (convertView == null) { + convertView = newView(parent.getContext(), position, parent); + } + + bindView(convertView, position); + return convertView; + } + + private View newView(Context context, int position, ViewGroup parent) { + if (getItemViewType(position) == VIEW_TYPE_BACK) { + return new PanelBackItemView(context); + } else { + return PanelItemView.create(context, mItemType); + } + } + + private void bindView(View view, int position) { + if (isShowingBack()) { + if (position == 0) { + final PanelBackItemView item = (PanelBackItemView) view; + item.updateFromFilter(mFilterManager.getPreviousFilter()); + return; + } + + position--; + } + + final Cursor cursor = getCursor(position); final PanelItemView item = (PanelItemView) view; item.updateFromCursor(cursor); } + private boolean isShowingBack() { + return (mFilterManager != null ? mFilterManager.canGoBack() : false); + } + + private final Cursor getCursor(int position) { + final Cursor cursor = getCursor(); + if (cursor == null || !cursor.moveToPosition(position)) { + throw new IllegalStateException("Couldn't move cursor to position " + position); + } + + return cursor; + } + @Override - public View newView(Context context, Cursor cursor, ViewGroup parent) { - return PanelItemView.create(mContext, mItemType); + public final void bindView(View view, Context context, Cursor cursor) { + // Do nothing. + } + + @Override + public final View newView(Context context, Cursor cursor, ViewGroup parent) { + return null; } } diff --git a/mobile/android/base/home/PanelViewUrlHandler.java b/mobile/android/base/home/PanelViewUrlHandler.java index a2669de51e3..c7f64383363 100644 --- a/mobile/android/base/home/PanelViewUrlHandler.java +++ b/mobile/android/base/home/PanelViewUrlHandler.java @@ -9,6 +9,7 @@ import org.mozilla.gecko.db.BrowserContract.HomeItems; import org.mozilla.gecko.home.HomeConfig.ItemHandler; import org.mozilla.gecko.home.HomeConfig.ViewConfig; import org.mozilla.gecko.home.HomePager.OnUrlOpenListener; +import org.mozilla.gecko.home.PanelLayout.FilterManager; import android.database.Cursor; @@ -17,6 +18,7 @@ import java.util.EnumSet; class PanelViewUrlHandler { private final ViewConfig mViewConfig; private OnUrlOpenListener mUrlOpenListener; + private FilterManager mFilterManager; public PanelViewUrlHandler(ViewConfig viewConfig) { mViewConfig = viewConfig; @@ -26,7 +28,25 @@ class PanelViewUrlHandler { mUrlOpenListener = listener; } + public void setFilterManager(FilterManager manager) { + mFilterManager = manager; + } + + /** + * If item at this position is a back item, perform the go back action via the + * {@code FilterManager}. Otherwise, prepare the url to be opened by the + * {@code OnUrlOpenListener}. + */ public void openUrlAtPosition(Cursor cursor, int position) { + if (mFilterManager != null && mFilterManager.canGoBack()) { + if (position == 0) { + mFilterManager.goBack(); + return; + } + + position--; + } + if (cursor == null || !cursor.moveToPosition(position)) { throw new IllegalStateException("Couldn't move cursor to position " + position); } diff --git a/mobile/android/base/moz.build b/mobile/android/base/moz.build index 395f63e7446..2191e1f231f 100644 --- a/mobile/android/base/moz.build +++ b/mobile/android/base/moz.build @@ -246,6 +246,7 @@ gbjar.sources += [ 'home/LastTabsPanel.java', 'home/MostRecentPanel.java', 'home/MultiTypeCursorAdapter.java', + 'home/PanelBackItemView.java', 'home/PanelGridView.java', 'home/PanelItemView.java', 'home/PanelLayout.java', diff --git a/mobile/android/base/resources/layout/panel_back_item.xml b/mobile/android/base/resources/layout/panel_back_item.xml new file mode 100644 index 00000000000..0c6d50bfcd5 --- /dev/null +++ b/mobile/android/base/resources/layout/panel_back_item.xml @@ -0,0 +1,19 @@ + + + + + + + + From 0a887c6bf2e7e8931cb4835a132cdf9cb6588fe6 Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Mon, 24 Feb 2014 15:23:29 -0800 Subject: [PATCH 11/88] Bug 975055 - Show filter title in back row. r=lucasr --- .../android/base/home/PanelBackItemView.java | 8 +- mobile/android/base/home/PanelGridView.java | 15 ++-- mobile/android/base/home/PanelLayout.java | 82 +++++++++++++------ mobile/android/base/home/PanelListView.java | 20 +++-- ...Handler.java => PanelViewItemHandler.java} | 24 +++--- .../base/locales/en-US/android_strings.dtd | 4 + mobile/android/base/moz.build | 2 +- mobile/android/base/strings.xml.in | 1 + 8 files changed, 101 insertions(+), 55 deletions(-) rename mobile/android/base/home/{PanelViewUrlHandler.java => PanelViewItemHandler.java} (69%) diff --git a/mobile/android/base/home/PanelBackItemView.java b/mobile/android/base/home/PanelBackItemView.java index 52c747e9b47..c337ab8a334 100644 --- a/mobile/android/base/home/PanelBackItemView.java +++ b/mobile/android/base/home/PanelBackItemView.java @@ -6,8 +6,10 @@ package org.mozilla.gecko.home; import org.mozilla.gecko.R; +import org.mozilla.gecko.home.PanelLayout.FilterDetail; import android.content.Context; +import android.text.TextUtils; import android.view.LayoutInflater; import android.widget.LinearLayout; import android.widget.TextView; @@ -24,7 +26,9 @@ class PanelBackItemView extends LinearLayout { title = (TextView) findViewById(R.id.title); } - public void updateFromFilter(String filter) { - title.setText(filter); + public void updateFromFilter(FilterDetail filter) { + final String backText = getResources() + .getString(R.string.home_move_up_to_filter, filter.title); + title.setText(backText); } } diff --git a/mobile/android/base/home/PanelGridView.java b/mobile/android/base/home/PanelGridView.java index 4f5f03401f4..ffcfa5aaa44 100644 --- a/mobile/android/base/home/PanelGridView.java +++ b/mobile/android/base/home/PanelGridView.java @@ -14,6 +14,7 @@ import org.mozilla.gecko.home.HomeConfig.ViewConfig; import org.mozilla.gecko.home.HomePager.OnUrlOpenListener; import org.mozilla.gecko.home.PanelLayout.DatasetBacked; import org.mozilla.gecko.home.PanelLayout.FilterManager; +import org.mozilla.gecko.home.PanelLayout.OnItemOpenListener; import org.mozilla.gecko.home.PanelLayout.PanelView; import android.content.Context; @@ -28,13 +29,13 @@ public class PanelGridView extends GridView private final ViewConfig mViewConfig; private final PanelViewAdapter mAdapter; - private PanelViewUrlHandler mUrlHandler; + private PanelViewItemHandler mItemHandler; public PanelGridView(Context context, ViewConfig viewConfig) { super(context, null, R.attr.panelGridViewStyle); mViewConfig = viewConfig; - mUrlHandler = new PanelViewUrlHandler(viewConfig); + mItemHandler = new PanelViewItemHandler(viewConfig); mAdapter = new PanelViewAdapter(context, viewConfig.getItemType()); setAdapter(mAdapter); @@ -45,7 +46,7 @@ public class PanelGridView extends GridView @Override public void onDetachedFromWindow() { super.onDetachedFromWindow(); - mUrlHandler.setOnUrlOpenListener(null); + mItemHandler.setOnItemOpenListener(null); } @Override @@ -54,20 +55,20 @@ public class PanelGridView extends GridView } @Override - public void setOnUrlOpenListener(OnUrlOpenListener listener) { - mUrlHandler.setOnUrlOpenListener(listener); + public void setOnItemOpenListener(OnItemOpenListener listener) { + mItemHandler.setOnItemOpenListener(listener); } @Override public void setFilterManager(FilterManager filterManager) { mAdapter.setFilterManager(filterManager); - mUrlHandler.setFilterManager(filterManager); + mItemHandler.setFilterManager(filterManager); } private class PanelGridItemClickListener implements AdapterView.OnItemClickListener { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { - mUrlHandler.openUrlAtPosition(mAdapter.getCursor(), position); + mItemHandler.openItemAtPosition(mAdapter.getCursor(), position); } } } diff --git a/mobile/android/base/home/PanelLayout.java b/mobile/android/base/home/PanelLayout.java index f79f32e1714..66ab91349ea 100644 --- a/mobile/android/base/home/PanelLayout.java +++ b/mobile/android/base/home/PanelLayout.java @@ -5,7 +5,9 @@ package org.mozilla.gecko.home; +import org.mozilla.gecko.R; import org.mozilla.gecko.home.HomePager.OnUrlOpenListener; +import org.mozilla.gecko.home.HomeConfig.ItemHandler; import org.mozilla.gecko.home.HomeConfig.PanelConfig; import org.mozilla.gecko.home.HomeConfig.ViewConfig; import org.mozilla.gecko.util.StringUtils; @@ -64,6 +66,7 @@ abstract class PanelLayout extends FrameLayout { private static final String LOGTAG = "GeckoPanelLayout"; protected final Map mViewStateMap; + private final PanelConfig mPanelConfig; private final DatasetHandler mDatasetHandler; private final OnUrlOpenListener mUrlOpenListener; @@ -140,11 +143,12 @@ abstract class PanelLayout extends FrameLayout { } public interface PanelView { - public void setOnUrlOpenListener(OnUrlOpenListener listener); + public void setOnItemOpenListener(OnItemOpenListener listener); + public void setOnKeyListener(OnKeyListener listener); } public interface FilterManager { - public String getPreviousFilter(); + public FilterDetail getPreviousFilter(); public boolean canGoBack(); public void goBack(); } @@ -152,6 +156,7 @@ abstract class PanelLayout extends FrameLayout { public PanelLayout(Context context, PanelConfig panelConfig, DatasetHandler datasetHandler, OnUrlOpenListener urlOpenListener) { super(context); mViewStateMap = new WeakHashMap(); + mPanelConfig = panelConfig; mDatasetHandler = datasetHandler; mUrlOpenListener = urlOpenListener; } @@ -220,8 +225,9 @@ abstract class PanelLayout extends FrameLayout { // TODO: Push initial filter here onto ViewState mViewStateMap.put(view, state); - ((PanelView) view).setOnUrlOpenListener(new PanelUrlOpenListener(state)); - view.setOnKeyListener(new PanelKeyListener(state)); + PanelView panelView = (PanelView) view; + panelView.setOnItemOpenListener(new PanelOnItemOpenListener(state)); + panelView.setOnKeyListener(new PanelKeyListener(state)); if (view instanceof DatasetBacked) { DatasetBacked datasetBacked = (DatasetBacked) view; @@ -277,9 +283,9 @@ abstract class PanelLayout extends FrameLayout { * Represents a 'live' instance of a panel view associated with * the {@code PanelLayout}. Is responsible for tracking the history stack of filters. */ - protected static class ViewState { + protected class ViewState { private final ViewConfig mViewConfig; - private LinkedList mFilterStack; + private LinkedList mFilterStack; public ViewState(ViewConfig viewConfig) { mViewConfig = viewConfig; @@ -289,10 +295,14 @@ abstract class PanelLayout extends FrameLayout { return mViewConfig.getDatasetId(); } + public ItemHandler getItemHandler() { + return mViewConfig.getItemHandler(); + } + /** * Get the current filter that this view is displaying, or null if none. */ - public String getCurrentFilter() { + public FilterDetail getCurrentFilter() { if (mFilterStack == null) { return null; } else { @@ -303,7 +313,7 @@ abstract class PanelLayout extends FrameLayout { /** * Get the previous filter that this view was displaying, or null if none. */ - public String getPreviousFilter() { + public FilterDetail getPreviousFilter() { if (!canPopFilter()) { return null; } @@ -314,13 +324,13 @@ abstract class PanelLayout extends FrameLayout { /** * Adds a filter to the history stack for this view. */ - public void pushFilter(String filter) { + public void pushFilter(FilterDetail filter) { if (mFilterStack == null) { - mFilterStack = new LinkedList(); + mFilterStack = new LinkedList(); // Initialize with a null filter. // TODO: use initial filter from ViewConfig - mFilterStack.push(null); + mFilterStack.push(new FilterDetail(null, mPanelConfig.getTitle())); } mFilterStack.push(filter); @@ -345,12 +355,25 @@ abstract class PanelLayout extends FrameLayout { } } + static class FilterDetail { + final String filter; + final String title; + + public FilterDetail(String filter, String title) { + this.filter = filter; + this.title = title; + } + } + /** * Pushes filter to {@code ViewState}'s stack and makes request for new filter value. */ - private void pushFilterOnView(ViewState viewState, String filter) { - viewState.pushFilter(filter); - mDatasetHandler.requestDataset(new DatasetRequest(viewState.getDatasetId(), filter)); + private void pushFilterOnView(ViewState viewState, FilterDetail filterDetail) { + viewState.pushFilter(filterDetail); + + final String filter = filterDetail.filter; + final String datasetId = viewState.getDatasetId(); + mDatasetHandler.requestDataset(new DatasetRequest(datasetId, filter)); } /** @@ -360,30 +383,39 @@ abstract class PanelLayout extends FrameLayout { */ private boolean popFilterOnView(ViewState viewState) { if (viewState.popFilter()) { - final String filter = viewState.getCurrentFilter(); - mDatasetHandler.requestDataset(new DatasetRequest(viewState.getDatasetId(), filter)); + final FilterDetail current = viewState.getCurrentFilter(); + + final String filter = (current == null ? null : current.filter); + final String datasetId = viewState.getDatasetId(); + mDatasetHandler.requestDataset(new DatasetRequest(datasetId, filter)); return true; } else { return false; } } - /** - * Custom listener so that we can intercept any filter URLs and make a new dataset request - * rather than forwarding them to the default listener. - */ - private class PanelUrlOpenListener implements OnUrlOpenListener { + public interface OnItemOpenListener { + public void onItemOpen(String url, String title); + } + + private class PanelOnItemOpenListener implements OnItemOpenListener { private ViewState mViewState; - public PanelUrlOpenListener(ViewState viewState) { + public PanelOnItemOpenListener(ViewState viewState) { mViewState = viewState; } @Override - public void onUrlOpen(String url, EnumSet flags) { + public void onItemOpen(String url, String title) { if (StringUtils.isFilterUrl(url)) { - pushFilterOnView(mViewState, StringUtils.getFilterFromUrl(url)); + FilterDetail filterDetail = new FilterDetail(StringUtils.getFilterFromUrl(url), title); + pushFilterOnView(mViewState, filterDetail); } else { + EnumSet flags = EnumSet.noneOf(OnUrlOpenListener.Flags.class); + if (mViewState.getItemHandler() == ItemHandler.INTENT) { + flags.add(OnUrlOpenListener.Flags.OPEN_WITH_INTENT); + } + mUrlOpenListener.onUrlOpen(url, flags); } } @@ -414,7 +446,7 @@ abstract class PanelLayout extends FrameLayout { } @Override - public String getPreviousFilter() { + public FilterDetail getPreviousFilter() { return mViewState.getPreviousFilter(); } diff --git a/mobile/android/base/home/PanelListView.java b/mobile/android/base/home/PanelListView.java index 68f91f26803..22167190e25 100644 --- a/mobile/android/base/home/PanelListView.java +++ b/mobile/android/base/home/PanelListView.java @@ -13,6 +13,7 @@ import org.mozilla.gecko.home.HomeConfig.ViewConfig; import org.mozilla.gecko.home.HomePager.OnUrlOpenListener; import org.mozilla.gecko.home.PanelLayout.DatasetBacked; import org.mozilla.gecko.home.PanelLayout.FilterManager; +import org.mozilla.gecko.home.PanelLayout.OnItemOpenListener; import org.mozilla.gecko.home.PanelLayout.PanelView; import android.content.Context; @@ -28,13 +29,13 @@ public class PanelListView extends HomeListView private final PanelViewAdapter mAdapter; private final ViewConfig mViewConfig; - private final PanelViewUrlHandler mUrlHandler; + private final PanelViewItemHandler mItemHandler; public PanelListView(Context context, ViewConfig viewConfig) { super(context); mViewConfig = viewConfig; - mUrlHandler = new PanelViewUrlHandler(viewConfig); + mItemHandler = new PanelViewItemHandler(viewConfig); mAdapter = new PanelViewAdapter(context, viewConfig.getItemType()); setAdapter(mAdapter); @@ -42,6 +43,12 @@ public class PanelListView extends HomeListView setOnItemClickListener(new PanelListItemClickListener()); } + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + mItemHandler.setOnItemOpenListener(null); + } + @Override public void setDataset(Cursor cursor) { Log.d(LOGTAG, "Setting dataset: " + mViewConfig.getDatasetId()); @@ -49,21 +56,20 @@ public class PanelListView extends HomeListView } @Override - public void setOnUrlOpenListener(OnUrlOpenListener listener) { - super.setOnUrlOpenListener(listener); - mUrlHandler.setOnUrlOpenListener(listener); + public void setOnItemOpenListener(OnItemOpenListener listener) { + mItemHandler.setOnItemOpenListener(listener); } @Override public void setFilterManager(FilterManager filterManager) { mAdapter.setFilterManager(filterManager); - mUrlHandler.setFilterManager(filterManager); + mItemHandler.setFilterManager(filterManager); } private class PanelListItemClickListener implements AdapterView.OnItemClickListener { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { - mUrlHandler.openUrlAtPosition(mAdapter.getCursor(), position); + mItemHandler.openItemAtPosition(mAdapter.getCursor(), position); } } } diff --git a/mobile/android/base/home/PanelViewUrlHandler.java b/mobile/android/base/home/PanelViewItemHandler.java similarity index 69% rename from mobile/android/base/home/PanelViewUrlHandler.java rename to mobile/android/base/home/PanelViewItemHandler.java index c7f64383363..1285a187ae6 100644 --- a/mobile/android/base/home/PanelViewUrlHandler.java +++ b/mobile/android/base/home/PanelViewItemHandler.java @@ -6,26 +6,26 @@ package org.mozilla.gecko.home; import org.mozilla.gecko.db.BrowserContract.HomeItems; -import org.mozilla.gecko.home.HomeConfig.ItemHandler; import org.mozilla.gecko.home.HomeConfig.ViewConfig; import org.mozilla.gecko.home.HomePager.OnUrlOpenListener; import org.mozilla.gecko.home.PanelLayout.FilterManager; +import org.mozilla.gecko.home.PanelLayout.OnItemOpenListener; import android.database.Cursor; import java.util.EnumSet; -class PanelViewUrlHandler { +class PanelViewItemHandler { private final ViewConfig mViewConfig; - private OnUrlOpenListener mUrlOpenListener; + private OnItemOpenListener mItemOpenListener; private FilterManager mFilterManager; - public PanelViewUrlHandler(ViewConfig viewConfig) { + public PanelViewItemHandler(ViewConfig viewConfig) { mViewConfig = viewConfig; } - public void setOnUrlOpenListener(OnUrlOpenListener listener) { - mUrlOpenListener = listener; + public void setOnItemOpenListener(OnItemOpenListener listener) { + mItemOpenListener = listener; } public void setFilterManager(FilterManager manager) { @@ -37,7 +37,7 @@ class PanelViewUrlHandler { * {@code FilterManager}. Otherwise, prepare the url to be opened by the * {@code OnUrlOpenListener}. */ - public void openUrlAtPosition(Cursor cursor, int position) { + public void openItemAtPosition(Cursor cursor, int position) { if (mFilterManager != null && mFilterManager.canGoBack()) { if (position == 0) { mFilterManager.goBack(); @@ -54,13 +54,11 @@ class PanelViewUrlHandler { int urlIndex = cursor.getColumnIndexOrThrow(HomeItems.URL); final String url = cursor.getString(urlIndex); - EnumSet flags = EnumSet.noneOf(OnUrlOpenListener.Flags.class); - if (mViewConfig.getItemHandler() == ItemHandler.INTENT) { - flags.add(OnUrlOpenListener.Flags.OPEN_WITH_INTENT); - } + int titleIndex = cursor.getColumnIndexOrThrow(HomeItems.TITLE); + final String title = cursor.getString(titleIndex); - if (mUrlOpenListener != null) { - mUrlOpenListener.onUrlOpen(url, flags); + if (mItemOpenListener != null) { + mItemOpenListener.onItemOpen(url, title); } } } diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index 7b467fb66bb..037bede9dbe 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -339,6 +339,10 @@ size. --> is no data to show in an about:home panel that was created by an add-on. --> + + + diff --git a/mobile/android/base/moz.build b/mobile/android/base/moz.build index 2191e1f231f..a9f0a6e6459 100644 --- a/mobile/android/base/moz.build +++ b/mobile/android/base/moz.build @@ -253,7 +253,7 @@ gbjar.sources += [ 'home/PanelListView.java', 'home/PanelManager.java', 'home/PanelViewAdapter.java', - 'home/PanelViewUrlHandler.java', + 'home/PanelViewItemHandler.java', 'home/PinSiteDialog.java', 'home/ReadingListPanel.java', 'home/SearchEngine.java', diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in index a7b47c4bf02..c951ceceb4d 100644 --- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -305,6 +305,7 @@ &home_reading_list_hint2; &home_reading_list_hint_accessible; &home_default_empty; + &home_move_up_to_filter; &pin_site_dialog_hint; &filepicker_title; From 18eafb4763162201fe4317604b63ef229594379d Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Thu, 27 Feb 2014 16:42:48 -0800 Subject: [PATCH 12/88] Bug 975055 - Show up arrow for back row. r=lucasr --- mobile/android/base/home/PanelBackItemView.java | 8 ++++++++ .../base/resources/drawable-hdpi/folder_up.png | Bin 0 -> 3442 bytes .../base/resources/drawable-mdpi/folder_up.png | Bin 0 -> 3519 bytes .../base/resources/drawable-xhdpi/folder_up.png | Bin 0 -> 3697 bytes .../base/resources/layout/panel_back_item.xml | 7 +++++++ 5 files changed, 15 insertions(+) create mode 100644 mobile/android/base/resources/drawable-hdpi/folder_up.png create mode 100644 mobile/android/base/resources/drawable-mdpi/folder_up.png create mode 100644 mobile/android/base/resources/drawable-xhdpi/folder_up.png diff --git a/mobile/android/base/home/PanelBackItemView.java b/mobile/android/base/home/PanelBackItemView.java index c337ab8a334..e63fbc26384 100644 --- a/mobile/android/base/home/PanelBackItemView.java +++ b/mobile/android/base/home/PanelBackItemView.java @@ -11,9 +11,12 @@ import org.mozilla.gecko.home.PanelLayout.FilterDetail; import android.content.Context; import android.text.TextUtils; import android.view.LayoutInflater; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import com.squareup.picasso.Picasso; + class PanelBackItemView extends LinearLayout { private final TextView title; @@ -24,6 +27,11 @@ class PanelBackItemView extends LinearLayout { setOrientation(HORIZONTAL); title = (TextView) findViewById(R.id.title); + + final ImageView image = (ImageView) findViewById(R.id.image); + Picasso.with(getContext()) + .load(R.drawable.folder_up) + .into(image); } public void updateFromFilter(FilterDetail filter) { diff --git a/mobile/android/base/resources/drawable-hdpi/folder_up.png b/mobile/android/base/resources/drawable-hdpi/folder_up.png new file mode 100644 index 0000000000000000000000000000000000000000..b7f41aa86dc8ec1986a54ac1a94c742175e25697 GIT binary patch literal 3442 zcmV-&4UO`NP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0007=Nkl8G#+5g`)ruk_lB&cTF(zK3#;Ppb82th+O-TGqF4dJA ztp?G?y%$2f0$wUjCC~^fQ;kVo@JxcFp=a9DX{Wr;hGcl>obwxI=A52}j&ixoYRno| zX$)>~gB#r725*C`tyVBL@!fZy=YcywC-4_20XKmcK07&{>ZuRzITwHoux{D$3~<#q zzEy7ZbHJktXml*2nzn+U5qkX!H39x?yTDHgw9%n7zP@5Av%!m4E z;d72-$?9iA;lWkj=Lkpx-)gwHIpL=r@4l?#BUckV%yX3&`b!<}kT8!(Us${=yi0Fy zmp5qvxCBgjn7*cjFL<6|oZv|{c)+1{M(7ETbN8h1Ga=R#NgwdLz#)gaS)o5RVBzvf z_*utQWjL-ZLFeqq`1QH{0aYdQL%=JV zm)F7vQ{6-08t}{IiBtXaE2J literal 0 HcmV?d00001 diff --git a/mobile/android/base/resources/drawable-mdpi/folder_up.png b/mobile/android/base/resources/drawable-mdpi/folder_up.png new file mode 100644 index 0000000000000000000000000000000000000000..37859e4da34253e6b77c0fa560ea23f185942cad GIT binary patch literal 3519 zcmV;w4M6gVP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0008&NklLt8>Cx^Q8!s9P6;5Gf^yiVMY`iKammu@q9&To=xRXL$F%=X*ECz?S zoSC_E&n+ZL;(eDUV?f5kF4#SLnbuC4fblfYo?`0xpgQ zGco3e;>f$-CFJKgfVF6@pgTGA;5q&tX~-sghJz7vld4?T9QsMbXwTck==d5u*n#gd zjyO#wp)KHkz+WR#%v%Gntp>o-7+n{3TJ!ega_o%_rqo#xrbN+C@INl+;mM_uByE_Q z)0?g(>>UXEHA5D{z<#uc;c`+b0fsU_+e<(TwLmV5I=C^T%v{6O3XoSrFD>ggM2s$b zTgWBYh4mRR*oRJ>ssMQ^^!hSlbUk*b9ep{-MbXi;V@8VMestj^u2+D(9(rA|uAEGd z{q|yUCCG(w#G5Jr{ubVOQpFpmIrKVXT^8uZ*nd&E67&J)hs(ESBuPJxMKKxFmeH9Jpo?*~cod&j06d0Ya66}BejC4r-A5@pA7WliR&@ME!? zFGAkO(|Cd{Q4Y@I_Z(udnixHb|FAMRj^iAj4ex@U;m;^D)8c7*y&Jg|G2auA-55-3 z)dq24lX1#GRP0OA3u&Bss~e0RW~ZrMdLpcD(=q002ovPDHLkV1nW_kGTK< literal 0 HcmV?d00001 diff --git a/mobile/android/base/resources/drawable-xhdpi/folder_up.png b/mobile/android/base/resources/drawable-xhdpi/folder_up.png new file mode 100644 index 0000000000000000000000000000000000000000..580a36c2f7e2d2aeebf68244f877be7115a5545f GIT binary patch literal 3697 zcmV-%4vz7OP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z000A=Nklfv?5VSP!~aU5&Z*Q zL_rq@LS;#`h}o*BWf0MI-F6dL(0!0GZqvniq`?}U^UgVE&dfZ&JMn$yyncM&_q^xK znF)l$VKmNVkrF7Vf-0y+K^0U%H43Vr3aU|11y#^=&JsI~KYbbVvTtp`b)XFR3{(T( zfwRD)pe_|b8$HI1L>-lT04W1nFPM1=I!^=zwJH@rR|;l+g13i- zGW{!)8MIDDMuAVR3X6evKzTBP*7yu_E^28qfmR7-(4h9J&GwxJ$0(8hl_UdbrL0wj z2DR6K%QkDy0bK^iDihRVKZBObbTaAW4d9YNT^Kk6+%~AKkp33=5wtW8%$vZ4IF20# zI)HAEXOwH8@vKRmzfnFfvny#}=_fH(1?nt~R}$TYd~=mt)^fEkH;1n4uUU5#}= zHQ!6npiB>wYvUeS>tz-pf2+QboQ25t--M#$r?B9(N)m|a0qy5P`d`h zyJL1iJ7ul0n_l3UhnSJ52e58x+f6fY%Wcp$gO2sd^z#}s5_K;yWKi4cHt08-?fV6D zD#15JLV`MCv+k?gpcie7v{$l*P2i9G2KLBSFP2OKSKJ1D0kp?}Itc9d5$0^hW!ZWk z!`AC4)^h`{Z<`(fC+9&OlIi6)%t+K-z=s7eO)d_MH}?0UY|clp9+nN^@BESz&d2{? zwgZn7ap`#%I1G$Q2k*-oHBNHmC$LjyTnP999F(7p6R`7*4jw&YZ|9OU;LtG_M_a;D z~OoZ2kpRm z*K~585j-I6e3yWJskNSz6jVVq3aX$As!>n{RZxwBDyV`gs768knm+>o@+qz7=2_3$ P00000NkvXXu0mjf)9%+v literal 0 HcmV?d00001 diff --git a/mobile/android/base/resources/layout/panel_back_item.xml b/mobile/android/base/resources/layout/panel_back_item.xml index 0c6d50bfcd5..60e0c53e51d 100644 --- a/mobile/android/base/resources/layout/panel_back_item.xml +++ b/mobile/android/base/resources/layout/panel_back_item.xml @@ -5,6 +5,13 @@ + + Date: Tue, 18 Mar 2014 09:23:23 +0800 Subject: [PATCH 13/88] Bug 983434 part 2: Store FlexLines and FlexItems in MFBT LinkedLists instead of nsTArrays. r=mats --- layout/generic/nsFlexContainerFrame.cpp | 525 ++++++++++++++---------- layout/generic/nsFlexContainerFrame.h | 21 +- 2 files changed, 315 insertions(+), 231 deletions(-) diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index de8f8bc3305..d088b1d3e2b 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -18,7 +18,9 @@ #include "nsStyleContext.h" #include "prlog.h" #include +#include "mozilla/LinkedList.h" +using namespace mozilla; using namespace mozilla::css; using namespace mozilla::layout; @@ -277,10 +279,13 @@ private: AxisOrientationType mCrossAxis; }; -// Represents a flex item. -// Includes the various pieces of input that the Flexbox Layout Algorithm uses -// to resolve a flexible width. -class nsFlexContainerFrame::FlexItem { +/** + * Represents a flex item. + * Includes the various pieces of input that the Flexbox Layout Algorithm uses + * to resolve a flexible width. + */ +class nsFlexContainerFrame::FlexItem : public LinkedListElement +{ public: // Normal constructor: FlexItem(nsIFrame* aChildFrame, @@ -562,12 +567,16 @@ protected: // in our constructor). }; -// Represents a single flex line in a flex container. -// Manages an array of the FlexItems that are in the line. -class nsFlexContainerFrame::FlexLine { +/** + * Represents a single flex line in a flex container. + * Manages a linked list of the FlexItems that are in the line. + */ +class nsFlexContainerFrame::FlexLine : public LinkedListElement +{ public: FlexLine() - : mTotalInnerHypotheticalMainSize(0), + : mNumItems(0), + mTotalInnerHypotheticalMainSize(0), mTotalOuterHypotheticalMainSize(0), mLineCrossSize(0), mBaselineOffsetFromCrossStart(nscoord_MIN) @@ -579,10 +588,46 @@ public: return mTotalOuterHypotheticalMainSize; } - // Adds a new FlexItem's hypothetical main sizes to our totals. - // (Should only be called when a FlexItem is being appended to this line.) - void AddToMainSizeTotals(nscoord aItemInnerHypotheticalMainSize, - nscoord aItemOuterHypotheticalMainSize) { + // Accessors for our FlexItems & information about them: + FlexItem* GetFirstItem() + { + MOZ_ASSERT(mItems.isEmpty() == (mNumItems == 0), + "mNumItems bookkeeping is off"); + return mItems.getFirst(); + } + + const FlexItem* GetFirstItem() const + { + MOZ_ASSERT(mItems.isEmpty() == (mNumItems == 0), + "mNumItems bookkeeping is off"); + return mItems.getFirst(); + } + + bool IsEmpty() const + { + MOZ_ASSERT(mItems.isEmpty() == (mNumItems == 0), + "mNumItems bookkeeping is off"); + return mItems.isEmpty(); + } + + uint32_t NumItems() const + { + MOZ_ASSERT(mItems.isEmpty() == (mNumItems == 0), + "mNumItems bookkeeping is off"); + return mNumItems; + } + + // Adds the given FlexItem to our list of items, and adds its hypothetical + // outer & inner main sizes to our totals. Use this method instead of + // directly modifying the item list, so that our bookkeeping remains correct. + // XXXdholbert Bug 983427 will extend this to let the caller choose whether + // the new FlexItem goes at the front or the back of the list. + void AddItem(FlexItem* aItem, + nscoord aItemInnerHypotheticalMainSize, + nscoord aItemOuterHypotheticalMainSize) + { + mItems.insertBack(aItem); + mNumItems++; mTotalInnerHypotheticalMainSize += aItemInnerHypotheticalMainSize; mTotalOuterHypotheticalMainSize += aItemOuterHypotheticalMainSize; } @@ -619,12 +664,21 @@ public: void PositionItemsInCrossAxis(nscoord aLineStartPosition, const FlexboxAxisTracker& aAxisTracker); - nsTArray mItems; // Array of the flex items in this flex line. - + friend class AutoFlexLineListClearer; // (needs access to mItems) + private: // Helper for ResolveFlexibleLengths(): void FreezeOrRestoreEachFlexibleSize(const nscoord aTotalViolation, bool aIsFinalIteration); + + LinkedList mItems; // Linked list of this line's flex items. + + uint32_t mNumItems; // Number of FlexItems in this line (in |mItems|). + // (Shouldn't change after GenerateFlexLines finishes + // with this line -- at least, not until we add support + // for splitting lines across continuations. Then we can + // update this count carefully.) + nscoord mTotalInnerHypotheticalMainSize; nscoord mTotalOuterHypotheticalMainSize; nscoord mLineCrossSize; @@ -645,23 +699,23 @@ struct nsFlexContainerFrame::StrutInfo { }; static void -BuildStrutInfoFromCollapsedItems(nsTArray& aLines, +BuildStrutInfoFromCollapsedItems(const FlexLine* aFirstLine, nsTArray& aStruts) { + MOZ_ASSERT(aFirstLine, "null first line pointer"); MOZ_ASSERT(aStruts.IsEmpty(), "We should only build up StrutInfo once per reflow, so " "aStruts should be empty when this is called"); uint32_t itemIdxInContainer = 0; - for (uint32_t lineIdx = 0; lineIdx < aLines.Length(); lineIdx++) { - FlexLine& line = aLines[lineIdx]; - for (uint32_t i = 0; i < line.mItems.Length(); ++i) { - FlexItem& item = line.mItems[i]; + for (const FlexLine* line = aFirstLine; line; line = line->getNext()) { + for (const FlexItem* item = line->GetFirstItem(); item; + item = item->getNext()) { if (NS_STYLE_VISIBILITY_COLLAPSE == - item.Frame()->StyleVisibility()->mVisible) { + item->Frame()->StyleVisibility()->mVisible) { // Note the cross size of the line as the item's strut size. aStruts.AppendElement(StrutInfo(itemIdxInContainer, - line.GetLineCrossSize())); + line->GetLineCrossSize())); } itemIdxInContainer++; } @@ -828,7 +882,7 @@ nsFlexContainerFrame::IsHorizontal() return IsAxisHorizontal(axisTracker.GetMainAxis()); } -FlexItem +FlexItem* nsFlexContainerFrame::GenerateFlexItemForChild( nsPresContext* aPresContext, nsIFrame* aChildFrame, @@ -920,19 +974,19 @@ nsFlexContainerFrame::GenerateFlexItemForChild( } // Construct the flex item! - FlexItem item(aChildFrame, - flexGrow, flexShrink, flexBaseSize, - mainMinSize, mainMaxSize, - crossMinSize, crossMaxSize, - childRS.ComputedPhysicalMargin(), - childRS.ComputedPhysicalBorderPadding(), - aAxisTracker); + FlexItem* item = new FlexItem(aChildFrame, + flexGrow, flexShrink, flexBaseSize, + mainMinSize, mainMaxSize, + crossMinSize, crossMaxSize, + childRS.ComputedPhysicalMargin(), + childRS.ComputedPhysicalBorderPadding(), + aAxisTracker); // If we're inflexible, we can just freeze to our hypothetical main-size // up-front. Similarly, if we're a fixed-size widget, we only have one // valid size, so we freeze to keep ourselves from flexing. if (isFixedSizeWidget || (flexGrow == 0.0f && flexShrink == 0.0f)) { - item.Freeze(); + item->Freeze(); } return item; @@ -1260,7 +1314,7 @@ protected: class MOZ_STACK_CLASS MainAxisPositionTracker : public PositionTracker { public: MainAxisPositionTracker(const FlexboxAxisTracker& aAxisTracker, - const nsTArray& aItems, + const FlexLine* aLine, uint8_t aJustifyContent, nscoord aContentBoxMainSize); @@ -1291,7 +1345,7 @@ private: // content-box. class MOZ_STACK_CLASS CrossAxisPositionTracker : public PositionTracker { public: - CrossAxisPositionTracker(nsTArray& aLines, + CrossAxisPositionTracker(FlexLine* aFirstLine, uint8_t aAlignContent, nscoord aContentBoxCrossSize, bool aIsCrossSizeDefinite, @@ -1497,33 +1551,32 @@ FlexLine::FreezeOrRestoreEachFlexibleSize(const nscoord aTotalViolation, freezeType = eFreezeMaxViolations; } - for (uint32_t i = 0; i < mItems.Length(); i++) { - FlexItem& item = mItems[i]; - MOZ_ASSERT(!item.HadMinViolation() || !item.HadMaxViolation(), + for (FlexItem* item = mItems.getFirst(); item; item = item->getNext()) { + MOZ_ASSERT(!item->HadMinViolation() || !item->HadMaxViolation(), "Can have either min or max violation, but not both"); - if (!item.IsFrozen()) { + if (!item->IsFrozen()) { if (eFreezeEverything == freezeType || - (eFreezeMinViolations == freezeType && item.HadMinViolation()) || - (eFreezeMaxViolations == freezeType && item.HadMaxViolation())) { + (eFreezeMinViolations == freezeType && item->HadMinViolation()) || + (eFreezeMaxViolations == freezeType && item->HadMaxViolation())) { - MOZ_ASSERT(item.GetMainSize() >= item.GetMainMinSize(), + MOZ_ASSERT(item->GetMainSize() >= item->GetMainMinSize(), "Freezing item at a size below its minimum"); - MOZ_ASSERT(item.GetMainSize() <= item.GetMainMaxSize(), + MOZ_ASSERT(item->GetMainSize() <= item->GetMainMaxSize(), "Freezing item at a size above its maximum"); - item.Freeze(); + item->Freeze(); } else if (MOZ_UNLIKELY(aIsFinalIteration)) { // XXXdholbert If & when bug 765861 is fixed, we should upgrade this // assertion to be fatal except in documents with enormous lengths. NS_ERROR("Final iteration still has unfrozen items, this shouldn't" " happen unless there was nscoord under/overflow."); - item.Freeze(); + item->Freeze(); } // else, we'll reset this item's main size to its flex base size on the // next iteration of this algorithm. // Clear this item's violation(s), now that we've dealt with them - item.ClearViolationFlags(); + item->ClearViolationFlags(); } } } @@ -1538,7 +1591,7 @@ void FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize) { PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG, ("ResolveFlexibleLengths\n")); - if (mItems.IsEmpty()) { + if (IsEmpty()) { return; } @@ -1556,24 +1609,23 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize) (mTotalOuterHypotheticalMainSize < aFlexContainerMainSize); // NOTE: I claim that this chunk of the algorithm (the looping part) needs to - // run the loop at MOST aItems.Length() times. This claim should hold up + // run the loop at MOST mNumItems times. This claim should hold up // because we'll freeze at least one item on each loop iteration, and once // we've run out of items to freeze, there's nothing left to do. However, // in most cases, we'll break out of this loop long before we hit that many // iterations. for (uint32_t iterationCounter = 0; - iterationCounter < mItems.Length(); iterationCounter++) { + iterationCounter < mNumItems; iterationCounter++) { // Set every not-yet-frozen item's used main size to its // flex base size, and subtract all the used main sizes from our // total amount of space to determine the 'available free space' // (positive or negative) to be distributed among our flexible items. nscoord availableFreeSpace = spaceAvailableForFlexItemsContentBoxes; - for (uint32_t i = 0; i < mItems.Length(); i++) { - FlexItem& item = mItems[i]; - if (!item.IsFrozen()) { - item.SetMainSize(item.GetFlexBaseSize()); + for (FlexItem* item = mItems.getFirst(); item; item = item->getNext()) { + if (!item->IsFrozen()) { + item->SetMainSize(item->GetFlexBaseSize()); } - availableFreeSpace -= item.GetMainSize(); + availableFreeSpace -= item->GetMainSize(); } PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG, @@ -1601,18 +1653,17 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize) float runningFlexWeightSum = 0.0f; float largestFlexWeight = 0.0f; uint32_t numItemsWithLargestFlexWeight = 0; - for (uint32_t i = 0; i < mItems.Length(); i++) { - FlexItem& item = mItems[i]; - float curFlexWeight = item.GetFlexWeightToUse(isUsingFlexGrow); + for (FlexItem* item = mItems.getFirst(); item; item = item->getNext()) { + float curFlexWeight = item->GetFlexWeightToUse(isUsingFlexGrow); MOZ_ASSERT(curFlexWeight >= 0.0f, "weights are non-negative"); runningFlexWeightSum += curFlexWeight; if (NS_finite(runningFlexWeightSum)) { if (curFlexWeight == 0.0f) { - item.SetShareOfFlexWeightSoFar(0.0f); + item->SetShareOfFlexWeightSoFar(0.0f); } else { - item.SetShareOfFlexWeightSoFar(curFlexWeight / - runningFlexWeightSum); + item->SetShareOfFlexWeightSoFar(curFlexWeight / + runningFlexWeightSum); } } // else, the sum of weights overflows to infinity, in which // case we don't bother with "SetShareOfFlexWeightSoFar" since @@ -1631,16 +1682,19 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize) if (runningFlexWeightSum != 0.0f) { // no distribution if no flexibility PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG, (" Distributing available space:")); - for (uint32_t i = mItems.Length() - 1; i < mItems.Length(); --i) { - FlexItem& item = mItems[i]; + // NOTE: It's important that we traverse our items in *reverse* order + // here, for correct width distribution according to the items' + // "ShareOfFlexWeightSoFar" progressively-calculated values. + for (FlexItem* item = mItems.getLast(); item; + item = item->getPrevious()) { - if (!item.IsFrozen()) { + if (!item->IsFrozen()) { // To avoid rounding issues, we compute the change in size for this // item, and then subtract it from the remaining available space. nscoord sizeDelta = 0; if (NS_finite(runningFlexWeightSum)) { float myShareOfRemainingSpace = - item.GetShareOfFlexWeightSoFar(); + item->GetShareOfFlexWeightSoFar(); MOZ_ASSERT(myShareOfRemainingSpace >= 0.0f && myShareOfRemainingSpace <= 1.0f, @@ -1654,7 +1708,7 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize) sizeDelta = NSToCoordRound(availableFreeSpace * myShareOfRemainingSpace); } - } else if (item.GetFlexWeightToUse(isUsingFlexGrow) == + } else if (item->GetFlexWeightToUse(isUsingFlexGrow) == largestFlexWeight) { // Total flexibility is infinite, so we're just distributing // the available space equally among the items that are tied for @@ -1667,10 +1721,10 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize) availableFreeSpace -= sizeDelta; - item.SetMainSize(item.GetMainSize() + sizeDelta); + item->SetMainSize(item->GetMainSize() + sizeDelta); PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG, - (" child %d receives %d, for a total of %d\n", - i, sizeDelta, item.GetMainSize())); + (" child %p receives %d, for a total of %d\n", + item, sizeDelta, item->GetMainSize())); } } } @@ -1681,25 +1735,24 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize) PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG, (" Checking for violations:")); - for (uint32_t i = 0; i < mItems.Length(); i++) { - FlexItem& item = mItems[i]; - if (!item.IsFrozen()) { - if (item.GetMainSize() < item.GetMainMinSize()) { + for (FlexItem* item = mItems.getFirst(); item; item = item->getNext()) { + if (!item->IsFrozen()) { + if (item->GetMainSize() < item->GetMainMinSize()) { // min violation - totalViolation += item.GetMainMinSize() - item.GetMainSize(); - item.SetMainSize(item.GetMainMinSize()); - item.SetHadMinViolation(); - } else if (item.GetMainSize() > item.GetMainMaxSize()) { + totalViolation += item->GetMainMinSize() - item->GetMainSize(); + item->SetMainSize(item->GetMainMinSize()); + item->SetHadMinViolation(); + } else if (item->GetMainSize() > item->GetMainMaxSize()) { // max violation - totalViolation += item.GetMainMaxSize() - item.GetMainSize(); - item.SetMainSize(item.GetMainMaxSize()); - item.SetHadMaxViolation(); + totalViolation += item->GetMainMaxSize() - item->GetMainSize(); + item->SetMainSize(item->GetMainMaxSize()); + item->SetHadMaxViolation(); } } } FreezeOrRestoreEachFlexibleSize(totalViolation, - iterationCounter + 1 == mItems.Length()); + iterationCounter + 1 == mNumItems); PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG, (" Total violation: %d\n", totalViolation)); @@ -1711,8 +1764,8 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize) // Post-condition: all lengths should've been frozen. #ifdef DEBUG - for (uint32_t i = 0; i < mItems.Length(); ++i) { - MOZ_ASSERT(mItems[i].IsFrozen(), + for (const FlexItem* item = mItems.getFirst(); item; item = item->getNext()) { + MOZ_ASSERT(item->IsFrozen(), "All flexible lengths should've been resolved"); } #endif // DEBUG @@ -1720,7 +1773,7 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize) MainAxisPositionTracker:: MainAxisPositionTracker(const FlexboxAxisTracker& aAxisTracker, - const nsTArray& aItems, + const FlexLine* aLine, uint8_t aJustifyContent, nscoord aContentBoxMainSize) : PositionTracker(aAxisTracker.GetMainAxis()), @@ -1732,13 +1785,13 @@ MainAxisPositionTracker:: // mPackingSpaceRemaining is initialized to the container's main size. Now // we'll subtract out the main sizes of our flex items, so that it ends up // with the *actual* amount of packing space. - for (uint32_t i = 0; i < aItems.Length(); i++) { - const FlexItem& item = aItems[i]; + for (const FlexItem* item = aLine->GetFirstItem(); item; + item = item->getNext()) { nscoord itemMarginBoxMainSize = - item.GetMainSize() + - item.GetMarginBorderPaddingSizeInAxis(aAxisTracker.GetMainAxis()); + item->GetMainSize() + + item->GetMarginBorderPaddingSizeInAxis(aAxisTracker.GetMainAxis()); mPackingSpaceRemaining -= itemMarginBoxMainSize; - mNumAutoMarginsInMainAxis += item.GetNumAutoMarginsInAxis(mAxis); + mNumAutoMarginsInMainAxis += item->GetNumAutoMarginsInAxis(mAxis); } if (mPackingSpaceRemaining <= 0) { @@ -1761,7 +1814,7 @@ MainAxisPositionTracker:: // packing spaces, and advance past any leading packing-space. if (mNumAutoMarginsInMainAxis == 0 && mPackingSpaceRemaining != 0 && - !aItems.IsEmpty()) { + !aLine->IsEmpty()) { switch (mJustifyContent) { case NS_STYLE_JUSTIFY_CONTENT_FLEX_START: // All packing space should go at the end --> nothing to do here. @@ -1779,7 +1832,7 @@ MainAxisPositionTracker:: "negative packing space should make us use 'flex-start' " "instead of 'space-between'"); // 1 packing space between each flex item, no packing space at ends. - mNumPackingSpacesRemaining = aItems.Length() - 1; + mNumPackingSpacesRemaining = aLine->NumItems() - 1; break; case NS_STYLE_JUSTIFY_CONTENT_SPACE_AROUND: MOZ_ASSERT(mPackingSpaceRemaining >= 0, @@ -1788,7 +1841,7 @@ MainAxisPositionTracker:: // 1 packing space between each flex item, plus half a packing space // at beginning & end. So our number of full packing-spaces is equal // to the number of flex items. - mNumPackingSpacesRemaining = aItems.Length(); + mNumPackingSpacesRemaining = aLine->NumItems(); if (mNumPackingSpacesRemaining > 0) { // The edges (start/end) share one full packing space nscoord totalEdgePackingSpace = @@ -1862,7 +1915,7 @@ MainAxisPositionTracker::TraversePackingSpace() } CrossAxisPositionTracker:: - CrossAxisPositionTracker(nsTArray& aLines, + CrossAxisPositionTracker(FlexLine* aFirstLine, uint8_t aAlignContent, nscoord aContentBoxCrossSize, bool aIsCrossSizeDefinite, @@ -1872,9 +1925,9 @@ CrossAxisPositionTracker:: mNumPackingSpacesRemaining(0), mAlignContent(aAlignContent) { - MOZ_ASSERT(!aLines.IsEmpty(), "We should have at least 1 line"); + MOZ_ASSERT(aFirstLine, "null first line pointer"); - if (aIsCrossSizeDefinite && aLines.Length() == 1) { + if (aIsCrossSizeDefinite && !aFirstLine->getNext()) { // "If the flex container has only a single line (even if it's a // multi-line flex container) and has a definite cross size, the cross // size of the flex line is the flex container's inner cross size." @@ -1883,7 +1936,7 @@ CrossAxisPositionTracker:: // means we don't need to be concerned with "align-conent" at all and we // can return early. This is handy, because this is the usual case (for // single-line flexbox). - aLines[0].SetLineCrossSize(aContentBoxCrossSize); + aFirstLine->SetLineCrossSize(aContentBoxCrossSize); return; } @@ -1893,11 +1946,13 @@ CrossAxisPositionTracker:: // cross sizes instead of main sizes.) // Figure out how much packing space we have (container's cross size minus - // all the lines' cross sizes) + // all the lines' cross sizes). Also, share this loop to count how many + // lines we have. (We need that count in some cases below.) mPackingSpaceRemaining = aContentBoxCrossSize; - for (uint32_t i = 0; i < aLines.Length(); i++) { - const FlexLine& line = aLines[i]; - mPackingSpaceRemaining -= line.GetLineCrossSize(); + uint32_t numLines = 0; + for (FlexLine* line = aFirstLine; line; line = line->getNext()) { + mPackingSpaceRemaining -= line->GetLineCrossSize(); + numLines++; } // If packing space is negative, 'space-between' and 'stretch' behave like @@ -1933,7 +1988,7 @@ CrossAxisPositionTracker:: "negative packing space should make us use 'flex-start' " "instead of 'space-between'"); // 1 packing space between each flex line, no packing space at ends. - mNumPackingSpacesRemaining = aLines.Length() - 1; + mNumPackingSpacesRemaining = numLines - 1; break; case NS_STYLE_ALIGN_CONTENT_SPACE_AROUND: { MOZ_ASSERT(mPackingSpaceRemaining >= 0, @@ -1942,7 +1997,7 @@ CrossAxisPositionTracker:: // 1 packing space between each flex line, plus half a packing space // at beginning & end. So our number of full packing-spaces is equal // to the number of flex lines. - mNumPackingSpacesRemaining = aLines.Length(); + mNumPackingSpacesRemaining = numLines; // The edges (start/end) share one full packing space nscoord totalEdgePackingSpace = mPackingSpaceRemaining / mNumPackingSpacesRemaining; @@ -1955,24 +2010,28 @@ CrossAxisPositionTracker:: mNumPackingSpacesRemaining--; break; } - case NS_STYLE_ALIGN_CONTENT_STRETCH: + case NS_STYLE_ALIGN_CONTENT_STRETCH: { // Split space equally between the lines: MOZ_ASSERT(mPackingSpaceRemaining > 0, "negative packing space should make us use 'flex-start' " "instead of 'stretch' (and we shouldn't bother with this " "code if we have 0 packing space)"); - for (uint32_t i = 0; i < aLines.Length(); i++) { - FlexLine& line = aLines[i]; + uint32_t numLinesLeft = numLines; + for (FlexLine* line = aFirstLine; line; line = line->getNext()) { // Our share is the amount of space remaining, divided by the number // of lines remainig. - nscoord shareOfExtraSpace = - mPackingSpaceRemaining / (aLines.Length() - i); - nscoord newSize = line.GetLineCrossSize() + shareOfExtraSpace; - line.SetLineCrossSize(newSize); + MOZ_ASSERT(numLinesLeft > 0, "miscalculated num lines"); + nscoord shareOfExtraSpace = mPackingSpaceRemaining / numLinesLeft; + nscoord newSize = line->GetLineCrossSize() + shareOfExtraSpace; + line->SetLineCrossSize(newSize); + mPackingSpaceRemaining -= shareOfExtraSpace; + numLinesLeft--; } + MOZ_ASSERT(numLinesLeft == 0, "miscalculated num lines"); break; + } default: MOZ_CRASH("Unexpected align-content value"); } @@ -2014,13 +2073,12 @@ FlexLine::ComputeCrossSizeAndBaseline(const FlexboxAxisTracker& aAxisTracker) nscoord crossStartToFurthestBaseline = nscoord_MIN; nscoord crossEndToFurthestBaseline = nscoord_MIN; nscoord largestOuterCrossSize = 0; - for (uint32_t i = 0; i < mItems.Length(); ++i) { - const FlexItem& item = mItems[i]; - nscoord curOuterCrossSize = item.GetCrossSize() + - item.GetMarginBorderPaddingSizeInAxis(aAxisTracker.GetCrossAxis()); + for (const FlexItem* item = mItems.getFirst(); item; item = item->getNext()) { + nscoord curOuterCrossSize = item->GetCrossSize() + + item->GetMarginBorderPaddingSizeInAxis(aAxisTracker.GetCrossAxis()); - if (item.GetAlignSelf() == NS_STYLE_ALIGN_ITEMS_BASELINE && - item.GetNumAutoMarginsInAxis(aAxisTracker.GetCrossAxis()) == 0) { + if (item->GetAlignSelf() == NS_STYLE_ALIGN_ITEMS_BASELINE && + item->GetNumAutoMarginsInAxis(aAxisTracker.GetCrossAxis()) == 0) { // FIXME: Once we support "writing-mode", we'll have to do baseline // alignment in vertical flex containers here (w/ horizontal cross-axes). @@ -2051,7 +2109,7 @@ FlexLine::ComputeCrossSizeAndBaseline(const FlexboxAxisTracker& aAxisTracker) // crossEndToBaseline. nscoord crossStartToBaseline = - item.GetBaselineOffsetFromOuterCrossStart(aAxisTracker.GetCrossAxis()); + item->GetBaselineOffsetFromOuterCrossStart(aAxisTracker.GetCrossAxis()); nscoord crossEndToBaseline = curOuterCrossSize - crossStartToBaseline; // Now, update our "largest" values for these (across all the flex items @@ -2268,6 +2326,18 @@ FlexboxAxisTracker::FlexboxAxisTracker(nsFlexContainerFrame* aFlexContainerFrame "main & cross axes should be in different dimensions"); } +// Allocates a new FlexLine, adds it at the back of the given LinkedList, +// and returs a pointer to it. +// XXXdholbert Bug 983427 will extend this to let the caller choose whether +// the new FlexLine goes at the front or the back of the list. +static FlexLine* +AddNewFlexLineToList(LinkedList& aLines) +{ + FlexLine* newLine = new FlexLine(); + aLines.insertBack(newLine); + return newLine; +} + nsresult nsFlexContainerFrame::GenerateFlexLines( nsPresContext* aPresContext, @@ -2276,25 +2346,21 @@ nsFlexContainerFrame::GenerateFlexLines( nscoord aAvailableHeightForContent, const nsTArray& aStruts, const FlexboxAxisTracker& aAxisTracker, - nsTArray& aLines) + LinkedList& aLines) { - MOZ_ASSERT(aLines.IsEmpty(), "Expecting outparam to start out empty"); + MOZ_ASSERT(aLines.isEmpty(), "Expecting outparam to start out empty"); const bool isSingleLine = NS_STYLE_FLEX_WRAP_NOWRAP == aReflowState.mStylePosition->mFlexWrap; // We have at least one FlexLine. Even an empty flex container has a single // (empty) flex line. - FlexLine* curLine = aLines.AppendElement(); + FlexLine* curLine = AddNewFlexLineToList(aLines); nscoord wrapThreshold; if (isSingleLine) { // Not wrapping. Set threshold to sentinel value that tells us not to wrap. wrapThreshold = NS_UNCONSTRAINEDSIZE; - - // Optimization: We know all items will end up in the first line, so we can - // pre-allocate space for them. - curLine->mItems.SetCapacity(mFrames.GetLength()); } else { // Wrapping! Set wrap threshold to flex container's content-box main-size. wrapThreshold = aContentBoxMainSize; @@ -2331,23 +2397,21 @@ nsFlexContainerFrame::GenerateFlexLines( nsIFrame* childFrame = e.get(); // Honor "page-break-before", if we're multi-line and this line isn't empty: - if (!isSingleLine && !curLine->mItems.IsEmpty() && + if (!isSingleLine && !curLine->IsEmpty() && childFrame->StyleDisplay()->mBreakBefore) { - curLine = aLines.AppendElement(); + curLine = AddNewFlexLineToList(aLines); } - FlexItem* item; + nsAutoPtr item; if (nextStrutIdx < aStruts.Length() && aStruts[nextStrutIdx].mItemIdx == itemIdxInContainer) { // Use the simplified "strut" FlexItem constructor: - item = curLine->mItems.AppendElement( - FlexItem(childFrame, aStruts[nextStrutIdx].mStrutCrossSize)); + item = new FlexItem(childFrame, aStruts[nextStrutIdx].mStrutCrossSize); nextStrutIdx++; } else { - item = curLine->mItems.AppendElement( - GenerateFlexItemForChild(aPresContext, childFrame, - aReflowState, aAxisTracker)); + item = GenerateFlexItemForChild(aPresContext, childFrame, + aReflowState, aAxisTracker); nsresult rv = ResolveFlexItemMaxContentSizing(aPresContext, *item, aReflowState, aAxisTracker); @@ -2362,34 +2426,22 @@ nsFlexContainerFrame::GenerateFlexLines( // (i.e. check if its outer hypothetical main size pushes our line over // the threshold) if (wrapThreshold != NS_UNCONSTRAINEDSIZE && - curLine->mItems.Length() > 1 && // Don't wrap if it'll leave line empty + !curLine->IsEmpty() && // No need to wrap at start of a line. wrapThreshold < (curLine->GetTotalOuterHypotheticalMainSize() + itemOuterHypotheticalMainSize)) { - // Need to wrap to a new line! Create a new line, create a copy of the - // newest FlexItem there, and clear that FlexItem out of the prev. line. - curLine = aLines.AppendElement(); - // NOTE: if that^ AppendElement had to realloc, then |item| may now - // point to bogus memory. Null out our pointer and use a freshly-obtained - // reference ('itemToCopy'), to be on the safe side. - item = nullptr; - - FlexLine& prevLine = aLines[aLines.Length() - 2]; - uint32_t itemIdxInPrevLine = prevLine.mItems.Length() - 1; - FlexItem& itemToCopy = prevLine.mItems[itemIdxInPrevLine]; - - // Copy item into cur line: - curLine->mItems.AppendElement(itemToCopy); - // ...and remove the old copy in prev line: - prevLine.mItems.RemoveElementAt(itemIdxInPrevLine); + curLine = AddNewFlexLineToList(aLines); } - curLine->AddToMainSizeTotals(itemInnerHypotheticalMainSize, - itemOuterHypotheticalMainSize); + // Add item to current flex line (and update the line's bookkeeping about + // how large its items collectively are). + curLine->AddItem(item.forget(), + itemInnerHypotheticalMainSize, + itemOuterHypotheticalMainSize); // Honor "page-break-after", if we're multi-line and have more children: if (!isSingleLine && childFrame->GetNextSibling() && childFrame->StyleDisplay()->mBreakAfter) { - curLine = aLines.AppendElement(); + curLine = AddNewFlexLineToList(aLines); } itemIdxInContainer++; } @@ -2417,13 +2469,12 @@ nsFlexContainerFrame::GetMainSizeFromReflowState( // Returns the largest outer hypothetical main-size of any line in |aLines|. // (i.e. the hypothetical main-size of the largest line) static nscoord -GetLargestLineMainSize(const nsTArray& aLines) +GetLargestLineMainSize(const FlexLine* aFirstLine) { nscoord largestLineOuterSize = 0; - for (uint32_t lineIdx = 0; lineIdx < aLines.Length(); lineIdx++) { - largestLineOuterSize = - std::max(largestLineOuterSize, - aLines[lineIdx].GetTotalOuterHypotheticalMainSize()); + for (const FlexLine* line = aFirstLine; line; line = line->getNext()) { + largestLineOuterSize = std::max(largestLineOuterSize, + line->GetTotalOuterHypotheticalMainSize()); } return largestLineOuterSize; } @@ -2435,9 +2486,11 @@ ClampFlexContainerMainSize(const nsHTMLReflowState& aReflowState, const FlexboxAxisTracker& aAxisTracker, nscoord aUnclampedMainSize, nscoord aAvailableHeightForContent, - const nsTArray& aLines, + const FlexLine* aFirstLine, nsReflowStatus& aStatus) { + MOZ_ASSERT(aFirstLine, "null first line pointer"); + if (IsAxisHorizontal(aAxisTracker.GetMainAxis())) { // Horizontal case is easy -- our main size should already be resolved // before we get a call to Reflow. We don't have to worry about doing @@ -2464,7 +2517,7 @@ ClampFlexContainerMainSize(const nsHTMLReflowState& aReflowState, // continuation or splitting children, so "amount of height required by // our children" is just the main-size (height) of our longest flex line. NS_FRAME_SET_INCOMPLETE(aStatus); - nscoord largestLineOuterSize = GetLargestLineMainSize(aLines); + nscoord largestLineOuterSize = GetLargestLineMainSize(aFirstLine); if (largestLineOuterSize <= aAvailableHeightForContent) { return aAvailableHeightForContent; @@ -2476,7 +2529,7 @@ ClampFlexContainerMainSize(const nsHTMLReflowState& aReflowState, // Resolve auto-height to the largest FlexLine-length, clamped to our // computed min/max main-size properties (min-height & max-height). // XXXdholbert Handle constrained-aAvailableHeightForContent case here. - nscoord largestLineOuterSize = GetLargestLineMainSize(aLines); + nscoord largestLineOuterSize = GetLargestLineMainSize(aFirstLine); return NS_CSS_MINMAX(largestLineOuterSize, aReflowState.ComputedMinHeight(), aReflowState.ComputedMaxHeight()); @@ -2540,28 +2593,26 @@ FlexLine::PositionItemsInMainAxis(uint8_t aJustifyContent, nscoord aContentBoxMainSize, const FlexboxAxisTracker& aAxisTracker) { - MainAxisPositionTracker mainAxisPosnTracker(aAxisTracker, mItems, + MainAxisPositionTracker mainAxisPosnTracker(aAxisTracker, this, aJustifyContent, aContentBoxMainSize); - for (uint32_t i = 0; i < mItems.Length(); ++i) { - FlexItem& item = mItems[i]; - + for (FlexItem* item = mItems.getFirst(); item; item = item->getNext()) { nscoord itemMainBorderBoxSize = - item.GetMainSize() + - item.GetBorderPaddingSizeInAxis(mainAxisPosnTracker.GetAxis()); + item->GetMainSize() + + item->GetBorderPaddingSizeInAxis(mainAxisPosnTracker.GetAxis()); // Resolve any main-axis 'auto' margins on aChild to an actual value. - mainAxisPosnTracker.ResolveAutoMarginsInMainAxis(item); + mainAxisPosnTracker.ResolveAutoMarginsInMainAxis(*item); // Advance our position tracker to child's upper-left content-box corner, // and use that as its position in the main axis. - mainAxisPosnTracker.EnterMargin(item.GetMargin()); + mainAxisPosnTracker.EnterMargin(item->GetMargin()); mainAxisPosnTracker.EnterChildFrame(itemMainBorderBoxSize); - item.SetMainPosition(mainAxisPosnTracker.GetPosition()); + item->SetMainPosition(mainAxisPosnTracker.GetPosition()); mainAxisPosnTracker.ExitChildFrame(itemMainBorderBoxSize); - mainAxisPosnTracker.ExitMargin(item.GetMargin()); + mainAxisPosnTracker.ExitMargin(item->GetMargin()); mainAxisPosnTracker.TraversePackingSpace(); } } @@ -2678,23 +2729,22 @@ FlexLine::PositionItemsInCrossAxis(nscoord aLineStartPosition, { SingleLineCrossAxisPositionTracker lineCrossAxisPosnTracker(aAxisTracker); - for (uint32_t i = 0; i < mItems.Length(); ++i) { - FlexItem& item = mItems[i]; + for (FlexItem* item = mItems.getFirst(); item; item = item->getNext()) { // First, stretch the item's cross size (if appropriate), and resolve any // auto margins in this axis. - item.ResolveStretchedCrossSize(mLineCrossSize, aAxisTracker); - lineCrossAxisPosnTracker.ResolveAutoMarginsInCrossAxis(*this, item); + item->ResolveStretchedCrossSize(mLineCrossSize, aAxisTracker); + lineCrossAxisPosnTracker.ResolveAutoMarginsInCrossAxis(*this, *item); // Compute the cross-axis position of this item nscoord itemCrossBorderBoxSize = - item.GetCrossSize() + - item.GetBorderPaddingSizeInAxis(aAxisTracker.GetCrossAxis()); - lineCrossAxisPosnTracker.EnterAlignPackingSpace(*this, item); - lineCrossAxisPosnTracker.EnterMargin(item.GetMargin()); + item->GetCrossSize() + + item->GetBorderPaddingSizeInAxis(aAxisTracker.GetCrossAxis()); + lineCrossAxisPosnTracker.EnterAlignPackingSpace(*this, *item); + lineCrossAxisPosnTracker.EnterMargin(item->GetMargin()); lineCrossAxisPosnTracker.EnterChildFrame(itemCrossBorderBoxSize); - item.SetCrossPosition(aLineStartPosition + - lineCrossAxisPosnTracker.GetPosition()); + item->SetCrossPosition(aLineStartPosition + + lineCrossAxisPosnTracker.GetPosition()); // Back out to cross-axis edge of the line. lineCrossAxisPosnTracker.ResetPosition(); @@ -2784,6 +2834,33 @@ nsFlexContainerFrame::Reflow(nsPresContext* aPresContext, return rv; } +// RAII class to clean up a list of FlexLines. +// Specifically, this removes each line from the list, deletes all the +// FlexItems in its list, and deletes the FlexLine. +class AutoFlexLineListClearer MOZ_STACK_CLASS { +public: + AutoFlexLineListClearer(LinkedList& aLines + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + : mLines(aLines) + { + MOZ_GUARD_OBJECT_NOTIFIER_INIT; + } + + ~AutoFlexLineListClearer() + { + while (FlexLine* line = mLines.popFirst()) { + while (FlexItem* item = line->mItems.popFirst()) { + delete item; + } + delete line; + } + } + +private: + LinkedList& mLines; + MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER +}; + nsresult nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, @@ -2796,8 +2873,9 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, { aStatus = NS_FRAME_COMPLETE; - // Generate an array of our flex items (already sorted), in a FlexLine. - nsAutoTArray lines; + LinkedList lines; + AutoFlexLineListClearer cleanupLines(lines); + nsresult rv = GenerateFlexLines(aPresContext, aReflowState, aContentBoxMainSize, aAvailableHeightForContent, @@ -2807,43 +2885,40 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, aContentBoxMainSize = ClampFlexContainerMainSize(aReflowState, aAxisTracker, aContentBoxMainSize, aAvailableHeightForContent, - lines, aStatus); + lines.getFirst(), aStatus); - for (uint32_t i = 0; i < lines.Length(); i++) { - lines[i].ResolveFlexibleLengths(aContentBoxMainSize); + for (FlexLine* line = lines.getFirst(); line; line = line->getNext()) { + line->ResolveFlexibleLengths(aContentBoxMainSize); } // Cross Size Determination - Flexbox spec section 9.4 // =================================================== // Calculate the hypothetical cross size of each item: nscoord sumLineCrossSizes = 0; - for (uint32_t lineIdx = 0; lineIdx < lines.Length(); ++lineIdx) { - FlexLine& line = lines[lineIdx]; - for (uint32_t i = 0; i < line.mItems.Length(); ++i) { - FlexItem& item = line.mItems[i]; - + for (FlexLine* line = lines.getFirst(); line; line = line->getNext()) { + for (FlexItem* item = line->GetFirstItem(); item; item = item->getNext()) { // (If the item's already been stretched, or it's a strut, then it // already knows its cross size. Don't bother trying to recalculate it.) - if (!item.IsStretched() && !item.IsStrut()) { + if (!item->IsStretched() && !item->IsStrut()) { nsHTMLReflowState childReflowState(aPresContext, aReflowState, - item.Frame(), + item->Frame(), nsSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE)); // Override computed main-size if (IsAxisHorizontal(aAxisTracker.GetMainAxis())) { - childReflowState.SetComputedWidth(item.GetMainSize()); + childReflowState.SetComputedWidth(item->GetMainSize()); } else { - childReflowState.SetComputedHeight(item.GetMainSize()); + childReflowState.SetComputedHeight(item->GetMainSize()); } nsresult rv = SizeItemInCrossAxis(aPresContext, aAxisTracker, - childReflowState, item); + childReflowState, *item); NS_ENSURE_SUCCESS(rv, rv); } } // Now that we've finished with this line's items, size the line itself: - line.ComputeCrossSizeAndBaseline(aAxisTracker); - sumLineCrossSizes += line.GetLineCrossSize(); + line->ComputeCrossSizeAndBaseline(aAxisTracker); + sumLineCrossSizes += line->GetLineCrossSize(); } bool isCrossSizeDefinite; @@ -2854,7 +2929,8 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, // Set up state for cross-axis alignment, at a high level (outside the // scope of a particular flex line) CrossAxisPositionTracker - crossAxisPosnTracker(lines, aReflowState.mStylePosition->mAlignContent, + crossAxisPosnTracker(lines.getFirst(), + aReflowState.mStylePosition->mAlignContent, contentBoxCrossSize, isCrossSizeDefinite, aAxisTracker); @@ -2863,7 +2939,7 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, // constructor), we can create struts for any flex items with // "visibility: collapse" (and restart flex layout). if (aStruts.IsEmpty()) { // (Don't make struts if we already did) - BuildStrutInfoFromCollapsedItems(lines, aStruts); + BuildStrutInfoFromCollapsedItems(lines.getFirst(), aStruts); if (!aStruts.IsEmpty()) { // Restart flex layout, using our struts. return NS_OK; @@ -2873,7 +2949,8 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, // Set the flex container's baseline, from the baseline-alignment position // of the first line's baseline-aligned items. nscoord flexContainerAscent; - nscoord firstLineBaselineOffset = lines[0].GetBaselineOffsetFromCrossStart(); + nscoord firstLineBaselineOffset = + lines.getFirst()->GetBaselineOffsetFromCrossStart(); if (firstLineBaselineOffset == nscoord_MIN) { // No baseline-aligned flex items in first line --> just use a sentinel // value for now, and we'll update it during final reflow. @@ -2894,20 +2971,19 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, aAxisTracker.GetCrossAxis()); } - for (uint32_t lineIdx = 0; lineIdx < lines.Length(); ++lineIdx) { - FlexLine& line = lines[lineIdx]; + for (FlexLine* line = lines.getFirst(); line; line = line->getNext()) { // Main-Axis Alignment - Flexbox spec section 9.5 // ============================================== - line.PositionItemsInMainAxis(aReflowState.mStylePosition->mJustifyContent, - aContentBoxMainSize, - aAxisTracker); + line->PositionItemsInMainAxis(aReflowState.mStylePosition->mJustifyContent, + aContentBoxMainSize, + aAxisTracker); // Cross-Axis Alignment - Flexbox spec section 9.6 // =============================================== - line.PositionItemsInCrossAxis(crossAxisPosnTracker.GetPosition(), - aAxisTracker); - crossAxisPosnTracker.TraverseLine(line); + line->PositionItemsInCrossAxis(crossAxisPosnTracker.GetPosition(), + aAxisTracker); + crossAxisPosnTracker.TraverseLine(*line); crossAxisPosnTracker.TraversePackingSpace(); } @@ -2921,14 +2997,12 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, // FINAL REFLOW: Give each child frame another chance to reflow, now that // we know its final size and position. - for (uint32_t lineIdx = 0; lineIdx < lines.Length(); ++lineIdx) { - FlexLine& line = lines[lineIdx]; - for (uint32_t i = 0; i < line.mItems.Length(); ++i) { - FlexItem& item = line.mItems[i]; - + for (const FlexLine* line = lines.getFirst(); line; line = line->getNext()) { + for (const FlexItem* item = line->GetFirstItem(); item; + item = item->getNext()) { nsPoint physicalPosn = aAxisTracker.PhysicalPointFromLogicalPoint( - item.GetMainPosition(), - item.GetCrossPosition(), + item->GetMainPosition(), + item->GetCrossPosition(), aContentBoxMainSize, contentBoxCrossSize); // Adjust physicalPosn to be relative to the container's border-box @@ -2936,7 +3010,7 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, physicalPosn += containerContentBoxOrigin; nsHTMLReflowState childReflowState(aPresContext, aReflowState, - item.Frame(), + item->Frame(), nsSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE)); @@ -2947,24 +3021,24 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, // Override computed main-size if (IsAxisHorizontal(aAxisTracker.GetMainAxis())) { - childReflowState.SetComputedWidth(item.GetMainSize()); + childReflowState.SetComputedWidth(item->GetMainSize()); didOverrideComputedWidth = true; } else { - childReflowState.SetComputedHeight(item.GetMainSize()); + childReflowState.SetComputedHeight(item->GetMainSize()); didOverrideComputedHeight = true; } // Override reflow state's computed cross-size, for stretched items. - if (item.IsStretched()) { - MOZ_ASSERT(item.GetAlignSelf() == NS_STYLE_ALIGN_ITEMS_STRETCH, + if (item->IsStretched()) { + MOZ_ASSERT(item->GetAlignSelf() == NS_STYLE_ALIGN_ITEMS_STRETCH, "stretched item w/o 'align-self: stretch'?"); if (IsAxisHorizontal(aAxisTracker.GetCrossAxis())) { - childReflowState.SetComputedWidth(item.GetCrossSize()); + childReflowState.SetComputedWidth(item->GetCrossSize()); didOverrideComputedWidth = true; } else { // If this item's height is stretched, it's a relative height. - item.Frame()->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_HEIGHT); - childReflowState.SetComputedHeight(item.GetCrossSize()); + item->Frame()->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_HEIGHT); + childReflowState.SetComputedHeight(item->GetCrossSize()); didOverrideComputedHeight = true; } } @@ -2976,7 +3050,7 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, // If we're overriding the computed width or height, *and* we had an // earlier "measuring" reflow, then this upcoming reflow needs to be // treated as a resize. - if (item.HadMeasuringReflow()) { + if (item->HadMeasuringReflow()) { if (didOverrideComputedWidth) { // (This is somewhat redundant, since the reflow state already // sets mHResize whenever our computed width has changed since the @@ -2994,7 +3068,7 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, nsHTMLReflowMetrics childDesiredSize(childReflowState); nsReflowStatus childReflowStatus; - nsresult rv = ReflowChild(item.Frame(), aPresContext, + nsresult rv = ReflowChild(item->Frame(), aPresContext, childDesiredSize, childReflowState, physicalPosn.x, physicalPosn.y, 0, childReflowStatus); @@ -3010,7 +3084,7 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, childReflowState.ApplyRelativePositioning(&physicalPosn); - rv = FinishReflowChild(item.Frame(), aPresContext, + rv = FinishReflowChild(item->Frame(), aPresContext, childDesiredSize, &childReflowState, physicalPosn.x, physicalPosn.y, 0); NS_ENSURE_SUCCESS(rv, rv); @@ -3018,13 +3092,14 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, // If this is our first child and we haven't established a baseline for // the container yet (i.e. if we don't have 'align-self: baseline' on any // children), then use this child's baseline as the container's baseline. - if (lineIdx == 0 && i == 0 && flexContainerAscent == nscoord_MIN) { - ResolveReflowedChildAscent(item.Frame(), childDesiredSize); + if (item->Frame() == mFrames.FirstChild() && + flexContainerAscent == nscoord_MIN) { + ResolveReflowedChildAscent(item->Frame(), childDesiredSize); // (We use GetNormalPosition() instead of physicalPosn because we don't // want relative positioning on the child to affect the baseline that we // read from it). - flexContainerAscent = item.Frame()->GetNormalPosition().y + + flexContainerAscent = item->Frame()->GetNormalPosition().y + childDesiredSize.TopAscent(); } } @@ -3045,7 +3120,7 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, // children (or if our children are huge enough that they have nscoord_MIN // as their baseline... in which case, we'll use the wrong baseline, but no // big deal) - NS_WARN_IF_FALSE(lines[0].mItems.IsEmpty(), + NS_WARN_IF_FALSE(lines.getFirst()->IsEmpty(), "Have flex items but didn't get an ascent - that's odd " "(or there are just gigantic sizes involved)"); // Per spec, just use the bottom of content-box. diff --git a/layout/generic/nsFlexContainerFrame.h b/layout/generic/nsFlexContainerFrame.h index 0a606a085fc..242ae549e4d 100644 --- a/layout/generic/nsFlexContainerFrame.h +++ b/layout/generic/nsFlexContainerFrame.h @@ -11,7 +11,10 @@ #define nsFlexContainerFrame_h___ #include "nsContainerFrame.h" -#include "nsTArrayForwardDeclare.h" + +namespace mozilla { +template class LinkedList; +} nsIFrame* NS_NewFlexContainerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); @@ -103,10 +106,12 @@ protected: void SanityCheckAnonymousFlexItems() const; #endif // DEBUG - FlexItem GenerateFlexItemForChild(nsPresContext* aPresContext, - nsIFrame* aChildFrame, - const nsHTMLReflowState& aParentReflowState, - const FlexboxAxisTracker& aAxisTracker); + // Returns a new FlexItem for the given child frame, allocated on the heap. + // Caller is responsible for managing the FlexItem's lifetime. + FlexItem* GenerateFlexItemForChild(nsPresContext* aPresContext, + nsIFrame* aChildFrame, + const nsHTMLReflowState& aParentReflowState, + const FlexboxAxisTracker& aAxisTracker); // Returns nsresult because we might have to reflow aFlexItem.Frame() (to // get its vertical intrinsic size in a vertical flexbox), and if that @@ -116,13 +121,17 @@ protected: const nsHTMLReflowState& aParentReflowState, const FlexboxAxisTracker& aAxisTracker); + // Creates FlexItems for all of our child frames, arranged in a list of + // FlexLines. These are returned by reference in |aLines|. Our actual + // return value has to be |nsresult|, in case we have to reflow a child + // to establish its flex base size and that reflow fails. nsresult GenerateFlexLines(nsPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nscoord aContentBoxMainSize, nscoord aAvailableHeightForContent, const nsTArray& aStruts, const FlexboxAxisTracker& aAxisTracker, - nsTArray& aLines); + mozilla::LinkedList& aLines); nscoord GetMainSizeFromReflowState(const nsHTMLReflowState& aReflowState, const FlexboxAxisTracker& aAxisTracker); From 60476682b59468433588ea38462ef4c24aed11dd Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Tue, 18 Mar 2014 10:27:51 +0800 Subject: [PATCH 14/88] Bug 983434 followup: Fix positioning of MOZ_STACK_CLASS in AutoFlexLineListClearer class definition to fix Linux static-analysis bustage. --- layout/generic/nsFlexContainerFrame.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index d088b1d3e2b..8e0856aac58 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -2837,7 +2837,8 @@ nsFlexContainerFrame::Reflow(nsPresContext* aPresContext, // RAII class to clean up a list of FlexLines. // Specifically, this removes each line from the list, deletes all the // FlexItems in its list, and deletes the FlexLine. -class AutoFlexLineListClearer MOZ_STACK_CLASS { +class MOZ_STACK_CLASS AutoFlexLineListClearer +{ public: AutoFlexLineListClearer(LinkedList& aLines MOZ_GUARD_OBJECT_NOTIFIER_PARAM) From 169b4903a4df2c712d0bf0dca63c36d07c74927b Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Tue, 18 Mar 2014 10:41:33 +0800 Subject: [PATCH 15/88] Bug 984261 - NS_NewSVGRect to Moz2D. r=heycam --- content/svg/content/src/SVGRect.cpp | 8 +++++--- content/svg/content/src/SVGRect.h | 4 ++-- content/svg/content/src/SVGTransformableElement.cpp | 5 ++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/content/svg/content/src/SVGRect.cpp b/content/svg/content/src/SVGRect.cpp index d40833b9fdc..0f0d579137e 100644 --- a/content/svg/content/src/SVGRect.cpp +++ b/content/svg/content/src/SVGRect.cpp @@ -6,6 +6,8 @@ #include "mozilla/dom/SVGRect.h" #include "nsSVGElement.h" +using namespace mozilla::gfx; + namespace mozilla { namespace dom { @@ -47,9 +49,9 @@ NS_NewSVGRect(nsIContent* aParent, float aX, float aY, float aWidth, } already_AddRefed -NS_NewSVGRect(nsIContent* aParent, const gfxRect& aRect) +NS_NewSVGRect(nsIContent* aParent, const Rect& aRect) { - return NS_NewSVGRect(aParent, aRect.X(), aRect.Y(), - aRect.Width(), aRect.Height()); + return NS_NewSVGRect(aParent, aRect.x, aRect.y, + aRect.width, aRect.height); } diff --git a/content/svg/content/src/SVGRect.h b/content/svg/content/src/SVGRect.h index 5ba86b8e2b5..faef6298aa6 100644 --- a/content/svg/content/src/SVGRect.h +++ b/content/svg/content/src/SVGRect.h @@ -6,8 +6,8 @@ #ifndef mozilla_dom_SVGRect_h #define mozilla_dom_SVGRect_h -#include "gfxRect.h" #include "mozilla/dom/SVGIRect.h" +#include "mozilla/gfx/Rect.h" #include "nsSVGElement.h" //////////////////////////////////////////////////////////////////////// @@ -84,6 +84,6 @@ NS_NewSVGRect(nsIContent* aParent, float x=0.0f, float y=0.0f, float width=0.0f, float height=0.0f); already_AddRefed -NS_NewSVGRect(nsIContent* aParent, const gfxRect& rect); +NS_NewSVGRect(nsIContent* aParent, const mozilla::gfx::Rect& rect); #endif //mozilla_dom_SVGRect_h diff --git a/content/svg/content/src/SVGTransformableElement.cpp b/content/svg/content/src/SVGTransformableElement.cpp index 2723cbf3b68..521e2d022d6 100644 --- a/content/svg/content/src/SVGTransformableElement.cpp +++ b/content/svg/content/src/SVGTransformableElement.cpp @@ -3,6 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "gfx2DGlue.h" #include "mozilla/dom/SVGAnimatedTransformList.h" #include "mozilla/dom/SVGTransformableElement.h" #include "mozilla/dom/SVGMatrix.h" @@ -15,6 +16,8 @@ #include "nsSVGUtils.h" #include "SVGContentUtils.h" +using namespace mozilla::gfx; + namespace mozilla { namespace dom { @@ -183,7 +186,7 @@ SVGTransformableElement::GetBBox(ErrorResult& rv) return nullptr; } - return NS_NewSVGRect(this, nsSVGUtils::GetBBox(frame)); + return NS_NewSVGRect(this, ToRect(nsSVGUtils::GetBBox(frame))); } already_AddRefed From 4b2bce8274ab91afa7ff2b2b59b1def6474b634c Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Tue, 18 Mar 2014 10:41:34 +0800 Subject: [PATCH 16/88] Bug 984282 - Remove some unused Thebes includes from content/svg. r=heycam --- content/svg/content/src/SVGContentUtils.h | 4 +++- content/svg/content/src/SVGFECompositeElement.cpp | 1 - content/svg/content/src/SVGFEFloodElement.cpp | 5 +++-- content/svg/content/src/SVGFETileElement.cpp | 1 - content/svg/content/src/SVGPathSegUtils.cpp | 1 + content/svg/content/src/SVGPathSegUtils.h | 1 - content/svg/content/src/nsSVGFilters.cpp | 3 --- content/svg/content/src/nsSVGFilters.h | 1 - content/svg/content/src/nsSVGPathDataParser.h | 1 - 9 files changed, 7 insertions(+), 11 deletions(-) diff --git a/content/svg/content/src/SVGContentUtils.h b/content/svg/content/src/SVGContentUtils.h index b5918d45f29..50adc05bb60 100644 --- a/content/svg/content/src/SVGContentUtils.h +++ b/content/svg/content/src/SVGContentUtils.h @@ -10,8 +10,10 @@ #define _USE_MATH_DEFINES #include -#include "gfxMatrix.h" +#include "mozilla/gfx/Matrix.h" #include "mozilla/RangedPtr.h" +#include "nsError.h" +#include "nsStringFwd.h" class nsIContent; class nsIDocument; diff --git a/content/svg/content/src/SVGFECompositeElement.cpp b/content/svg/content/src/SVGFECompositeElement.cpp index 3e473d62f86..27b095f6aaf 100644 --- a/content/svg/content/src/SVGFECompositeElement.cpp +++ b/content/svg/content/src/SVGFECompositeElement.cpp @@ -5,7 +5,6 @@ #include "mozilla/dom/SVGFECompositeElement.h" #include "mozilla/dom/SVGFECompositeElementBinding.h" -#include "gfxContext.h" NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEComposite) diff --git a/content/svg/content/src/SVGFEFloodElement.cpp b/content/svg/content/src/SVGFEFloodElement.cpp index 83e7cd7769a..44786ba2bc3 100644 --- a/content/svg/content/src/SVGFEFloodElement.cpp +++ b/content/svg/content/src/SVGFEFloodElement.cpp @@ -4,9 +4,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/SVGFEFloodElement.h" + +#include "FilterSupport.h" #include "mozilla/dom/SVGFEFloodElementBinding.h" -#include "gfxContext.h" -#include "gfxColor.h" +#include "nsColor.h" #include "nsIFrame.h" NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFlood) diff --git a/content/svg/content/src/SVGFETileElement.cpp b/content/svg/content/src/SVGFETileElement.cpp index d456ab24387..29420062350 100644 --- a/content/svg/content/src/SVGFETileElement.cpp +++ b/content/svg/content/src/SVGFETileElement.cpp @@ -6,7 +6,6 @@ #include "mozilla/dom/SVGFETileElement.h" #include "mozilla/dom/SVGFETileElementBinding.h" #include "nsSVGFilterInstance.h" -#include "gfxUtils.h" NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FETile) diff --git a/content/svg/content/src/SVGPathSegUtils.cpp b/content/svg/content/src/SVGPathSegUtils.cpp index bcc88682772..709ba0e56b9 100644 --- a/content/svg/content/src/SVGPathSegUtils.cpp +++ b/content/svg/content/src/SVGPathSegUtils.cpp @@ -8,6 +8,7 @@ #include "SVGPathSegUtils.h" #include "gfx2DGlue.h" +#include "gfxPoint.h" #include "nsSVGPathDataParser.h" #include "nsTextFormatter.h" diff --git a/content/svg/content/src/SVGPathSegUtils.h b/content/svg/content/src/SVGPathSegUtils.h index 9a1b5d4c367..dc6c8b4eeca 100644 --- a/content/svg/content/src/SVGPathSegUtils.h +++ b/content/svg/content/src/SVGPathSegUtils.h @@ -6,7 +6,6 @@ #ifndef MOZILLA_SVGPATHSEGUTILS_H__ #define MOZILLA_SVGPATHSEGUTILS_H__ -#include "gfxPoint.h" #include "mozilla/ArrayUtils.h" #include "mozilla/gfx/Point.h" #include "nsDebug.h" diff --git a/content/svg/content/src/nsSVGFilters.cpp b/content/svg/content/src/nsSVGFilters.cpp index 5e301ee20bd..822d633f417 100644 --- a/content/svg/content/src/nsSVGFilters.cpp +++ b/content/svg/content/src/nsSVGFilters.cpp @@ -23,13 +23,10 @@ #include "nsSVGUtils.h" #include "nsStyleContext.h" #include "nsIFrame.h" -#include "gfxContext.h" -#include "gfxMatrix.h" #include "imgIContainer.h" #include "nsNetUtil.h" #include "mozilla/dom/SVGFilterElement.h" #include "nsSVGString.h" -#include "gfxUtils.h" #include "SVGContentUtils.h" #include #include "mozilla/dom/SVGAnimatedLength.h" diff --git a/content/svg/content/src/nsSVGFilters.h b/content/svg/content/src/nsSVGFilters.h index 4e3d8b1985c..a148aa2336f 100644 --- a/content/svg/content/src/nsSVGFilters.h +++ b/content/svg/content/src/nsSVGFilters.h @@ -14,7 +14,6 @@ #include "nsSVGNumber2.h" #include "nsSVGNumberPair.h" #include "FilterSupport.h" -#include "gfxASurface.h" class nsSVGFilterInstance; class nsSVGFilterResource; diff --git a/content/svg/content/src/nsSVGPathDataParser.h b/content/svg/content/src/nsSVGPathDataParser.h index 738fb35f846..f4e842b4adf 100644 --- a/content/svg/content/src/nsSVGPathDataParser.h +++ b/content/svg/content/src/nsSVGPathDataParser.h @@ -8,7 +8,6 @@ #include "mozilla/Attributes.h" #include "mozilla/gfx/Point.h" -#include "gfxPoint.h" #include "nsSVGDataParser.h" namespace mozilla { From 8eae406f1b2f0ee2d3c792446aa47846ab1febc7 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Tue, 18 Mar 2014 10:41:35 +0800 Subject: [PATCH 17/88] Bug 984390 - Stop using gfxPoint in SVGMarkerElement. r=me --- content/svg/content/src/SVGMarkerElement.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/svg/content/src/SVGMarkerElement.cpp b/content/svg/content/src/SVGMarkerElement.cpp index d55ce6ac0ac..fb69b578b15 100644 --- a/content/svg/content/src/SVGMarkerElement.cpp +++ b/content/svg/content/src/SVGMarkerElement.cpp @@ -301,19 +301,19 @@ SVGMarkerElement::GetMarkerTransform(float aStrokeWidth, float aX, float aY, float aAutoAngle, bool aIsStart) { - gfxFloat scale = mEnumAttributes[MARKERUNITS].GetAnimValue() == - SVG_MARKERUNITS_STROKEWIDTH ? aStrokeWidth : 1.0; + float scale = mEnumAttributes[MARKERUNITS].GetAnimValue() == + SVG_MARKERUNITS_STROKEWIDTH ? aStrokeWidth : 1.0f; - gfxFloat angle; + float angle; switch (mOrientType.GetAnimValueInternal()) { case SVG_MARKER_ORIENT_AUTO: angle = aAutoAngle; break; case SVG_MARKER_ORIENT_AUTO_START_REVERSE: - angle = aAutoAngle + (aIsStart ? M_PI : 0.0); + angle = aAutoAngle + (aIsStart ? M_PI : 0.0f); break; default: // SVG_MARKER_ORIENT_ANGLE - angle = mAngleAttributes[ORIENT].GetAnimValue() * M_PI / 180.0; + angle = mAngleAttributes[ORIENT].GetAnimValue() * M_PI / 180.0f; break; } From ffa29f3f6f48012e0729dd236b97eccd125fcfed Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Tue, 18 Mar 2014 10:41:35 +0800 Subject: [PATCH 18/88] Bug 984278, part 1 - Rename SVGMatrix::Matrix and SVGTransform::Matrix to SVGMatrix::GetMatrix and SVGTransform::GetMatrix, respectively. r=dholbert --- content/svg/content/src/DOMSVGPoint.cpp | 2 +- .../svg/content/src/DOMSVGTransformList.cpp | 2 +- content/svg/content/src/SVGMatrix.cpp | 34 +++++++++---------- content/svg/content/src/SVGMatrix.h | 14 ++++---- content/svg/content/src/SVGSVGElement.cpp | 2 +- content/svg/content/src/SVGTransform.cpp | 4 +-- content/svg/content/src/SVGTransform.h | 4 +-- content/svg/content/src/SVGTransformList.cpp | 4 +-- content/svg/content/src/nsSVGTransform.cpp | 6 ++-- content/svg/content/src/nsSVGTransform.h | 2 +- dom/bindings/Bindings.conf | 5 ++- 11 files changed, 41 insertions(+), 38 deletions(-) diff --git a/content/svg/content/src/DOMSVGPoint.cpp b/content/svg/content/src/DOMSVGPoint.cpp index f8999fe07ca..c4236959e6d 100644 --- a/content/svg/content/src/DOMSVGPoint.cpp +++ b/content/svg/content/src/DOMSVGPoint.cpp @@ -112,7 +112,7 @@ DOMSVGPoint::MatrixTransform(dom::SVGMatrix& matrix) float x = HasOwner() ? InternalItem().mX : mPt.mX; float y = HasOwner() ? InternalItem().mY : mPt.mY; - gfxPoint pt = matrix.Matrix().Transform(gfxPoint(x, y)); + gfxPoint pt = matrix.GetMatrix().Transform(gfxPoint(x, y)); nsCOMPtr newPoint = new DOMSVGPoint(pt); return newPoint.forget(); } diff --git a/content/svg/content/src/DOMSVGTransformList.cpp b/content/svg/content/src/DOMSVGTransformList.cpp index 9ecb0b2e715..6e235f03b6d 100644 --- a/content/svg/content/src/DOMSVGTransformList.cpp +++ b/content/svg/content/src/DOMSVGTransformList.cpp @@ -342,7 +342,7 @@ DOMSVGTransformList::RemoveItem(uint32_t index, ErrorResult& error) already_AddRefed DOMSVGTransformList::CreateSVGTransformFromMatrix(dom::SVGMatrix& matrix) { - nsRefPtr result = new SVGTransform(matrix.Matrix()); + nsRefPtr result = new SVGTransform(matrix.GetMatrix()); return result.forget(); } diff --git a/content/svg/content/src/SVGMatrix.cpp b/content/svg/content/src/SVGMatrix.cpp index 4b5b3f2f2fe..9491981837d 100644 --- a/content/svg/content/src/SVGMatrix.cpp +++ b/content/svg/content/src/SVGMatrix.cpp @@ -39,7 +39,7 @@ SVGMatrix::SetA(float aA, ErrorResult& rv) return; } - gfxMatrix mx = Matrix(); + gfxMatrix mx = GetMatrix(); mx.xx = aA; SetMatrix(mx); } @@ -52,7 +52,7 @@ SVGMatrix::SetB(float aB, ErrorResult& rv) return; } - gfxMatrix mx = Matrix(); + gfxMatrix mx = GetMatrix(); mx.yx = aB; SetMatrix(mx); } @@ -65,7 +65,7 @@ SVGMatrix::SetC(float aC, ErrorResult& rv) return; } - gfxMatrix mx = Matrix(); + gfxMatrix mx = GetMatrix(); mx.xy = aC; SetMatrix(mx); } @@ -78,7 +78,7 @@ SVGMatrix::SetD(float aD, ErrorResult& rv) return; } - gfxMatrix mx = Matrix(); + gfxMatrix mx = GetMatrix(); mx.yy = aD; SetMatrix(mx); } @@ -91,7 +91,7 @@ SVGMatrix::SetE(float aE, ErrorResult& rv) return; } - gfxMatrix mx = Matrix(); + gfxMatrix mx = GetMatrix(); mx.x0 = aE; SetMatrix(mx); } @@ -104,7 +104,7 @@ SVGMatrix::SetF(float aF, ErrorResult& rv) return; } - gfxMatrix mx = Matrix(); + gfxMatrix mx = GetMatrix(); mx.y0 = aF; SetMatrix(mx); } @@ -112,18 +112,18 @@ SVGMatrix::SetF(float aF, ErrorResult& rv) already_AddRefed SVGMatrix::Multiply(SVGMatrix& aMatrix) { - nsRefPtr matrix = new SVGMatrix(aMatrix.Matrix() * Matrix()); + nsRefPtr matrix = new SVGMatrix(aMatrix.GetMatrix() * GetMatrix()); return matrix.forget(); } already_AddRefed SVGMatrix::Inverse(ErrorResult& rv) { - if (Matrix().IsSingular()) { + if (GetMatrix().IsSingular()) { rv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return nullptr; } - nsRefPtr matrix = new SVGMatrix(gfxMatrix(Matrix()).Invert()); + nsRefPtr matrix = new SVGMatrix(gfxMatrix(GetMatrix()).Invert()); return matrix.forget(); } @@ -131,7 +131,7 @@ already_AddRefed SVGMatrix::Translate(float x, float y) { nsRefPtr matrix = - new SVGMatrix(gfxMatrix(Matrix()).Translate(gfxPoint(x, y))); + new SVGMatrix(gfxMatrix(GetMatrix()).Translate(gfxPoint(x, y))); return matrix.forget(); } @@ -146,7 +146,7 @@ SVGMatrix::ScaleNonUniform(float scaleFactorX, float scaleFactorY) { nsRefPtr matrix = - new SVGMatrix(gfxMatrix(Matrix()).Scale(scaleFactorX, scaleFactorY)); + new SVGMatrix(gfxMatrix(GetMatrix()).Scale(scaleFactorX, scaleFactorY)); return matrix.forget(); } @@ -154,7 +154,7 @@ already_AddRefed SVGMatrix::Rotate(float angle) { nsRefPtr matrix = - new SVGMatrix(gfxMatrix(Matrix()).Rotate(angle*radPerDegree)); + new SVGMatrix(gfxMatrix(GetMatrix()).Rotate(angle*radPerDegree)); return matrix.forget(); } @@ -167,14 +167,14 @@ SVGMatrix::RotateFromVector(float x, float y, ErrorResult& rv) } nsRefPtr matrix = - new SVGMatrix(gfxMatrix(Matrix()).Rotate(atan2(y, x))); + new SVGMatrix(gfxMatrix(GetMatrix()).Rotate(atan2(y, x))); return matrix.forget(); } already_AddRefed SVGMatrix::FlipX() { - const gfxMatrix& mx = Matrix(); + const gfxMatrix& mx = GetMatrix(); nsRefPtr matrix = new SVGMatrix(gfxMatrix(-mx.xx, -mx.yx, mx.xy, mx.yy, mx.x0, mx.y0)); return matrix.forget(); @@ -183,7 +183,7 @@ SVGMatrix::FlipX() already_AddRefed SVGMatrix::FlipY() { - const gfxMatrix& mx = Matrix(); + const gfxMatrix& mx = GetMatrix(); nsRefPtr matrix = new SVGMatrix(gfxMatrix(mx.xx, mx.yx, -mx.xy, -mx.yy, mx.x0, mx.y0)); return matrix.forget(); @@ -198,7 +198,7 @@ SVGMatrix::SkewX(float angle, ErrorResult& rv) return nullptr; } - const gfxMatrix& mx = Matrix(); + const gfxMatrix& mx = GetMatrix(); gfxMatrix skewMx(mx.xx, mx.yx, (float) (mx.xy + mx.xx*ta), (float) (mx.yy + mx.yx*ta), mx.x0, mx.y0); @@ -215,7 +215,7 @@ SVGMatrix::SkewY(float angle, ErrorResult& rv) return nullptr; } - const gfxMatrix& mx = Matrix(); + const gfxMatrix& mx = GetMatrix(); gfxMatrix skewMx((float) (mx.xx + mx.xy*ta), (float) (mx.yx + mx.yy*ta), mx.xy, mx.yy, mx.x0, mx.y0); diff --git a/content/svg/content/src/SVGMatrix.h b/content/svg/content/src/SVGMatrix.h index 29f4b00c47b..36700ba3216 100644 --- a/content/svg/content/src/SVGMatrix.h +++ b/content/svg/content/src/SVGMatrix.h @@ -75,7 +75,7 @@ public: SetIsDOMBinding(); } - const gfxMatrix& Matrix() const { + const gfxMatrix& GetMatrix() const { return mTransform ? mTransform->Matrixgfx() : mMatrix; } @@ -84,17 +84,17 @@ public: virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aScope) MOZ_OVERRIDE; - float A() const { return static_cast(Matrix().xx); } + float A() const { return static_cast(GetMatrix().xx); } void SetA(float aA, ErrorResult& rv); - float B() const { return static_cast(Matrix().yx); } + float B() const { return static_cast(GetMatrix().yx); } void SetB(float aB, ErrorResult& rv); - float C() const { return static_cast(Matrix().xy); } + float C() const { return static_cast(GetMatrix().xy); } void SetC(float aC, ErrorResult& rv); - float D() const { return static_cast(Matrix().yy); } + float D() const { return static_cast(GetMatrix().yy); } void SetD(float aD, ErrorResult& rv); - float E() const { return static_cast(Matrix().x0); } + float E() const { return static_cast(GetMatrix().x0); } void SetE(float aE, ErrorResult& rv); - float F() const { return static_cast(Matrix().y0); } + float F() const { return static_cast(GetMatrix().y0); } void SetF(float aF, ErrorResult& rv); already_AddRefed Multiply(SVGMatrix& aMatrix); already_AddRefed Inverse(ErrorResult& aRv); diff --git a/content/svg/content/src/SVGSVGElement.cpp b/content/svg/content/src/SVGSVGElement.cpp index 7dbf4e0f681..b371f557b77 100644 --- a/content/svg/content/src/SVGSVGElement.cpp +++ b/content/svg/content/src/SVGSVGElement.cpp @@ -433,7 +433,7 @@ SVGSVGElement::CreateSVGTransform() already_AddRefed SVGSVGElement::CreateSVGTransformFromMatrix(SVGMatrix& matrix) { - nsRefPtr transform = new SVGTransform(matrix.Matrix()); + nsRefPtr transform = new SVGTransform(matrix.GetMatrix()); return transform.forget(); } diff --git a/content/svg/content/src/SVGTransform.cpp b/content/svg/content/src/SVGTransform.cpp index 53ad781372b..61372aaead2 100644 --- a/content/svg/content/src/SVGTransform.cpp +++ b/content/svg/content/src/SVGTransform.cpp @@ -170,7 +170,7 @@ SVGTransform::Type() const } SVGMatrix* -SVGTransform::Matrix() +SVGTransform::GetMatrix() { SVGMatrix* wrapper = SVGMatrixTearoffTable().GetTearoff(this); @@ -194,7 +194,7 @@ SVGTransform::SetMatrix(SVGMatrix& aMatrix, ErrorResult& rv) rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); return; } - SetMatrix(aMatrix.Matrix()); + SetMatrix(aMatrix.GetMatrix()); } void diff --git a/content/svg/content/src/SVGTransform.h b/content/svg/content/src/SVGTransform.h index e71a40c9316..a5ecc44ef9a 100644 --- a/content/svg/content/src/SVGTransform.h +++ b/content/svg/content/src/SVGTransform.h @@ -123,7 +123,7 @@ public: virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aScope) MOZ_OVERRIDE; uint16_t Type() const; - dom::SVGMatrix* Matrix(); + dom::SVGMatrix* GetMatrix(); float Angle() const; void SetMatrix(dom::SVGMatrix& matrix, ErrorResult& rv); void SetTranslate(float tx, float ty, ErrorResult& rv); @@ -139,7 +139,7 @@ protected: return mIsAnimValItem; } const gfxMatrix& Matrixgfx() const { - return Transform().Matrix(); + return Transform().GetMatrix(); } void SetMatrix(const gfxMatrix& aMatrix); diff --git a/content/svg/content/src/SVGTransformList.cpp b/content/svg/content/src/SVGTransformList.cpp index 8b080bc2fa3..b6a95fe42c7 100644 --- a/content/svg/content/src/SVGTransformList.cpp +++ b/content/svg/content/src/SVGTransformList.cpp @@ -22,13 +22,13 @@ SVGTransformList::GetConsolidationMatrix() const if (mItems.IsEmpty()) return result; - result = mItems[0].Matrix(); + result = mItems[0].GetMatrix(); if (mItems.Length() == 1) return result; for (uint32_t i = 1; i < mItems.Length(); ++i) { - result.PreMultiply(mItems[i].Matrix()); + result.PreMultiply(mItems[i].GetMatrix()); } return result; diff --git a/content/svg/content/src/nsSVGTransform.cpp b/content/svg/content/src/nsSVGTransform.cpp index 0af0b726ecc..8d68e6327f7 100644 --- a/content/svg/content/src/nsSVGTransform.cpp +++ b/content/svg/content/src/nsSVGTransform.cpp @@ -166,7 +166,7 @@ SVGTransformSMILData::SVGTransformSMILData(const nsSVGTransform& aTransform) switch (mTransformType) { case SVG_TRANSFORM_MATRIX: { - const gfxMatrix& mx = aTransform.Matrix(); + const gfxMatrix& mx = aTransform.GetMatrix(); mParams[0] = static_cast(mx.xx); mParams[1] = static_cast(mx.yx); mParams[2] = static_cast(mx.xy); @@ -176,13 +176,13 @@ SVGTransformSMILData::SVGTransformSMILData(const nsSVGTransform& aTransform) break; } case SVG_TRANSFORM_TRANSLATE: { - const gfxMatrix& mx = aTransform.Matrix(); + const gfxMatrix& mx = aTransform.GetMatrix(); mParams[0] = static_cast(mx.x0); mParams[1] = static_cast(mx.y0); break; } case SVG_TRANSFORM_SCALE: { - const gfxMatrix& mx = aTransform.Matrix(); + const gfxMatrix& mx = aTransform.GetMatrix(); mParams[0] = static_cast(mx.xx); mParams[1] = static_cast(mx.yy); break; diff --git a/content/svg/content/src/nsSVGTransform.h b/content/svg/content/src/nsSVGTransform.h index f6708a2a678..b27b514c2f4 100644 --- a/content/svg/content/src/nsSVGTransform.h +++ b/content/svg/content/src/nsSVGTransform.h @@ -65,7 +65,7 @@ public: return mType; } - const gfxMatrix& Matrix() const { return mMatrix; } + const gfxMatrix& GetMatrix() const { return mMatrix; } void SetMatrix(const gfxMatrix& aMatrix); void SetTranslate(float aTx, float aTy); void SetScale(float aSx, float aSy); diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 7ed895870a9..ca9656d2a49 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1167,7 +1167,10 @@ DOMInterfaces = { }, 'SVGTransform': { - 'resultNotAddRefed': [ 'matrix' ] + 'resultNotAddRefed': [ 'matrix' ], + 'binaryNames': { + "matrix": "GetMatrix" + } }, 'SVGTransformList': { From 9f74c971052a12a9dcc83305cbf76e6cab345d65 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Fri, 28 Feb 2014 23:16:37 -0800 Subject: [PATCH 19/88] Bug 666656 - Suppress clang and gcc warnings in third-party gfx code: angle, cairo, and pixman. r=BenWa --- gfx/angle/moz.build | 9 +++++++++ gfx/cairo/cairo/src/moz.build | 15 +++++++++++++++ gfx/cairo/libpixman/src/moz.build | 14 +++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/gfx/angle/moz.build b/gfx/angle/moz.build index 6db57d14e0b..8cd7e99c00f 100644 --- a/gfx/angle/moz.build +++ b/gfx/angle/moz.build @@ -131,3 +131,12 @@ FINAL_LIBRARY = 'gkmedias' DEFINES['ANGLE_DISABLE_TRACE'] = True DEFINES['ANGLE_COMPILE_OPTIMIZATION_LEVEL'] = 'D3DCOMPILE_OPTIMIZATION_LEVEL1' DEFINES['COMPILER_IMPLEMENTATION'] = True + +# Suppress warnings in third-party code. +if CONFIG['GNU_CXX']: + CXXFLAGS += [ + '-Wno-sign-compare', + '-Wno-unknown-pragmas', + ] + if CONFIG['CLANG_CXX']: + CXXFLAGS += ['-Wno-unused-private-field'] diff --git a/gfx/cairo/cairo/src/moz.build b/gfx/cairo/cairo/src/moz.build index 3cdf38faa67..8c33cb08ef7 100644 --- a/gfx/cairo/cairo/src/moz.build +++ b/gfx/cairo/cairo/src/moz.build @@ -202,3 +202,18 @@ for var in ('MOZ_TREE_CAIRO', 'MOZ_TREE_PIXMAN'): if CONFIG['MOZ_TREE_FREETYPE']: DEFINES['HAVE_FT_LIBRARY_SETLCDFILTER'] = True DEFINES['FT_LCD_FILTER_H'] = '%s/modules/freetype2/include/freetype/ftlcdfil.h' % TOPSRCDIR + +# Suppress warnings in third-party code. +if CONFIG['GNU_CC']: + CFLAGS += [ + '-Wno-enum-compare', + '-Wno-int-to-pointer-cast', + '-Wno-sign-compare', + '-Wno-type-limits', + ] + if CONFIG['CLANG_CXX']: + CFLAGS += [ + '-Wno-incompatible-pointer-types', + '-Wno-tautological-compare', + '-Wno-tautological-constant-out-of-range-compare', + ] diff --git a/gfx/cairo/libpixman/src/moz.build b/gfx/cairo/libpixman/src/moz.build index 1b40136dd0a..dc5d196ccec 100644 --- a/gfx/cairo/libpixman/src/moz.build +++ b/gfx/cairo/libpixman/src/moz.build @@ -65,7 +65,6 @@ LOCAL_INCLUDES += [ '../../cairo/src', ] - if CONFIG['MOZ_USE_PTHREADS']: DEFINES['HAVE_PTHREAD_SETSPECIFIC'] = True @@ -143,3 +142,16 @@ if use_arm_neon_gcc: DEFINES['USE_ARM_NEON'] = True SOURCES += ['pixman-arm-neon.c'] SOURCES['pixman-arm-neon.c'].flags += ['-mfpu=neon'] + +# Suppress warnings in third-party code. +if CONFIG['GNU_CC']: + CFLAGS += [ + '-Wno-address', + '-Wno-sign-compare' + ] + if CONFIG['CLANG_CXX']: + CFLAGS += [ + '-Wno-incompatible-pointer-types', + '-Wno-tautological-compare', + '-Wno-tautological-constant-out-of-range-compare', + ] From e3f467c3ee31c8bc40af3c4f6b13587251006c8f Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Mon, 17 Mar 2014 09:06:17 -0700 Subject: [PATCH 20/88] Bug 982172 - Encapsulate DatasetRequest fields. r=lucasr --- mobile/android/base/home/DynamicPanel.java | 10 +++++----- mobile/android/base/home/PanelLayout.java | 14 +++++++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/mobile/android/base/home/DynamicPanel.java b/mobile/android/base/home/DynamicPanel.java index 1ebc97b60f8..956afad8619 100644 --- a/mobile/android/base/home/DynamicPanel.java +++ b/mobile/android/base/home/DynamicPanel.java @@ -175,7 +175,7 @@ public class DynamicPanel extends HomeFragment { bundle.putParcelable(DATASET_REQUEST, request); // Ensure one loader per dataset - final int loaderId = generateLoaderId(request.datasetId); + final int loaderId = generateLoaderId(request.getDatasetId()); getLoaderManager().restartLoader(loaderId, bundle, mLoaderCallbacks); } @@ -218,12 +218,12 @@ public class DynamicPanel extends HomeFragment { final String[] selectionArgs; // Null represents the root filter - if (mRequest.filter == null) { + if (mRequest.getFilter() == null) { selection = DBUtils.concatenateWhere(HomeItems.DATASET_ID + " = ?", HomeItems.FILTER + " IS NULL"); - selectionArgs = new String[] { mRequest.datasetId }; + selectionArgs = new String[] { mRequest.getDatasetId() }; } else { selection = DBUtils.concatenateWhere(HomeItems.DATASET_ID + " = ?", HomeItems.FILTER + " = ?"); - selectionArgs = new String[] { mRequest.datasetId, mRequest.filter }; + selectionArgs = new String[] { mRequest.getDatasetId(), mRequest.getFilter() }; } // XXX: You can use CONTENT_FAKE_URI for development to pull items from fake_home_items.json. @@ -256,7 +256,7 @@ public class DynamicPanel extends HomeFragment { final DatasetRequest request = getRequestFromLoader(loader); Log.d(LOGTAG, "Resetting loader for request: " + request); if (mLayout != null) { - mLayout.releaseDataset(request.datasetId); + mLayout.releaseDataset(request.getDatasetId()); } } diff --git a/mobile/android/base/home/PanelLayout.java b/mobile/android/base/home/PanelLayout.java index 66ab91349ea..6d2748b0289 100644 --- a/mobile/android/base/home/PanelLayout.java +++ b/mobile/android/base/home/PanelLayout.java @@ -84,8 +84,8 @@ abstract class PanelLayout extends FrameLayout { * filter for queries on the database. */ public static class DatasetRequest implements Parcelable { - public final String datasetId; - public final String filter; + private final String datasetId; + private final String filter; private DatasetRequest(Parcel in) { this.datasetId = in.readString(); @@ -97,6 +97,14 @@ abstract class PanelLayout extends FrameLayout { this.filter = filter; } + public String getDatasetId() { + return datasetId; + } + + public String getFilter() { + return filter; + } + @Override public int describeContents() { return 0; @@ -168,7 +176,7 @@ abstract class PanelLayout extends FrameLayout { */ public final void deliverDataset(DatasetRequest request, Cursor cursor) { Log.d(LOGTAG, "Delivering request: " + request); - updateViewsWithDataset(request.datasetId, cursor); + updateViewsWithDataset(request.getDatasetId(), cursor); } /** From c38c763203c16e400dd14764e86a021da0d15c72 Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Fri, 14 Mar 2014 13:14:10 -0700 Subject: [PATCH 21/88] Bug 982172 - Add request type to delay filter stack changes until data loads. r=lucasr --- mobile/android/base/home/PanelLayout.java | 144 +++++++++++++++++----- 1 file changed, 116 insertions(+), 28 deletions(-) diff --git a/mobile/android/base/home/PanelLayout.java b/mobile/android/base/home/PanelLayout.java index 6d2748b0289..dd0fceb92cc 100644 --- a/mobile/android/base/home/PanelLayout.java +++ b/mobile/android/base/home/PanelLayout.java @@ -84,25 +84,68 @@ abstract class PanelLayout extends FrameLayout { * filter for queries on the database. */ public static class DatasetRequest implements Parcelable { - private final String datasetId; - private final String filter; + public enum Type implements Parcelable { + DATASET_LOAD, + FILTER_PUSH, + FILTER_POP; - private DatasetRequest(Parcel in) { - this.datasetId = in.readString(); - this.filter = in.readString(); + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(ordinal()); + } + + public static final Creator CREATOR = new Creator() { + @Override + public Type createFromParcel(final Parcel source) { + return Type.values()[source.readInt()]; + } + + @Override + public Type[] newArray(final int size) { + return new Type[size]; + } + }; } - public DatasetRequest(String datasetId, String filter) { - this.datasetId = datasetId; - this.filter = filter; + private final Type mType; + private final String mDatasetId; + private final FilterDetail mFilterDetail; + + private DatasetRequest(Parcel in) { + this.mType = (Type) in.readParcelable(getClass().getClassLoader()); + this.mDatasetId = in.readString(); + this.mFilterDetail = (FilterDetail) in.readParcelable(getClass().getClassLoader()); + } + + public DatasetRequest(String datasetId, FilterDetail filterDetail) { + this(Type.DATASET_LOAD, datasetId, filterDetail); + } + + public DatasetRequest(Type type, String datasetId, FilterDetail filterDetail) { + this.mType = type; + this.mDatasetId = datasetId; + this.mFilterDetail = filterDetail; + } + + public Type getType() { + return mType; } public String getDatasetId() { - return datasetId; + return mDatasetId; } public String getFilter() { - return filter; + return (mFilterDetail != null ? mFilterDetail.filter : null); + } + + public FilterDetail getFilterDetail() { + return mFilterDetail; } @Override @@ -112,12 +155,13 @@ abstract class PanelLayout extends FrameLayout { @Override public void writeToParcel(Parcel dest, int flags) { - dest.writeString(datasetId); - dest.writeString(filter); + dest.writeParcelable(mType, 0); + dest.writeString(mDatasetId); + dest.writeParcelable(mFilterDetail, 0); } public String toString() { - return "{dataset: " + datasetId + ", filter: " + filter + "}"; + return "{type: " + mType + " dataset: " + mDatasetId + ", filter: " + mFilterDetail + "}"; } public static final Creator CREATOR = new Creator() { @@ -176,7 +220,7 @@ abstract class PanelLayout extends FrameLayout { */ public final void deliverDataset(DatasetRequest request, Cursor cursor) { Log.d(LOGTAG, "Delivering request: " + request); - updateViewsWithDataset(request.getDatasetId(), cursor); + updateViewsFromRequest(request, cursor); } /** @@ -184,8 +228,8 @@ abstract class PanelLayout extends FrameLayout { * existing panel views. */ public final void releaseDataset(String datasetId) { - Log.d(LOGTAG, "Resetting dataset: " + datasetId); - updateViewsWithDataset(datasetId, null); + Log.d(LOGTAG, "Releasing dataset: " + datasetId); + releaseViewsWithDataset(datasetId); } /** @@ -261,18 +305,39 @@ abstract class PanelLayout extends FrameLayout { } } - private void updateViewsWithDataset(String datasetId, Cursor cursor) { + private void updateViewsFromRequest(DatasetRequest request, Cursor cursor) { for (Map.Entry entry : mViewStateMap.entrySet()) { final ViewState detail = entry.getValue(); // Update any views associated with the given dataset ID - if (TextUtils.equals(detail.getDatasetId(), datasetId)) { + if (TextUtils.equals(detail.getDatasetId(), request.getDatasetId())) { + switch (request.getType()) { + case FILTER_PUSH: + detail.pushFilter(request.getFilterDetail()); + break; + case FILTER_POP: + detail.popFilter(); + break; + } + final View view = entry.getKey(); maybeSetDataset(view, cursor); } } } + private void releaseViewsWithDataset(String datasetId) { + for (Map.Entry entry : mViewStateMap.entrySet()) { + final ViewState detail = entry.getValue(); + + // Release the cursor on views associated with the given dataset ID + if (TextUtils.equals(detail.getDatasetId(), datasetId)) { + final View view = entry.getKey(); + maybeSetDataset(view, null); + } + } + } + private void maybeSetDataset(View view, Cursor cursor) { if (view instanceof DatasetBacked) { final DatasetBacked dsb = (DatasetBacked) view; @@ -363,25 +428,49 @@ abstract class PanelLayout extends FrameLayout { } } - static class FilterDetail { + static class FilterDetail implements Parcelable { final String filter; final String title; + private FilterDetail(Parcel in) { + this.filter = in.readString(); + this.title = in.readString(); + } + public FilterDetail(String filter, String title) { this.filter = filter; this.title = title; } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(filter); + dest.writeString(title); + } + + public static final Creator CREATOR = new Creator() { + public FilterDetail createFromParcel(Parcel in) { + return new FilterDetail(in); + } + + public FilterDetail[] newArray(int size) { + return new FilterDetail[size]; + } + }; } /** * Pushes filter to {@code ViewState}'s stack and makes request for new filter value. */ private void pushFilterOnView(ViewState viewState, FilterDetail filterDetail) { - viewState.pushFilter(filterDetail); - - final String filter = filterDetail.filter; final String datasetId = viewState.getDatasetId(); - mDatasetHandler.requestDataset(new DatasetRequest(datasetId, filter)); + mDatasetHandler.requestDataset( + new DatasetRequest(DatasetRequest.Type.FILTER_PUSH, datasetId, filterDetail)); } /** @@ -390,12 +479,11 @@ abstract class PanelLayout extends FrameLayout { * @return whether the filter has changed */ private boolean popFilterOnView(ViewState viewState) { - if (viewState.popFilter()) { - final FilterDetail current = viewState.getCurrentFilter(); - - final String filter = (current == null ? null : current.filter); + if (viewState.canPopFilter()) { + final FilterDetail filterDetail = viewState.getPreviousFilter(); final String datasetId = viewState.getDatasetId(); - mDatasetHandler.requestDataset(new DatasetRequest(datasetId, filter)); + mDatasetHandler.requestDataset( + new DatasetRequest(DatasetRequest.Type.FILTER_POP, datasetId, filterDetail)); return true; } else { return false; From 1c206bbb5bd399192169672e54d0dff60f4256e5 Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Mon, 10 Mar 2014 18:45:35 -0700 Subject: [PATCH 22/88] Bug 982190 - Add backImageUrl to allow for view-level custom back icons. r=lucasr --- mobile/android/base/home/HomeConfig.java | 18 +++++++++++++++++- .../android/base/home/PanelBackItemView.java | 5 +++-- mobile/android/base/home/PanelGridView.java | 2 +- mobile/android/base/home/PanelListView.java | 2 +- mobile/android/base/home/PanelViewAdapter.java | 11 ++++++----- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/mobile/android/base/home/HomeConfig.java b/mobile/android/base/home/HomeConfig.java index 7fcc92044fd..375152b4ba3 100644 --- a/mobile/android/base/home/HomeConfig.java +++ b/mobile/android/base/home/HomeConfig.java @@ -583,17 +583,20 @@ public final class HomeConfig { private final String mDatasetId; private final ItemType mItemType; private final ItemHandler mItemHandler; + private final String mBackImageUrl; private static final String JSON_KEY_TYPE = "type"; private static final String JSON_KEY_DATASET = "dataset"; private static final String JSON_KEY_ITEM_TYPE = "itemType"; private static final String JSON_KEY_ITEM_HANDLER = "itemHandler"; + private static final String JSON_KEY_BACK_IMAGE_URL = "backImageUrl"; public ViewConfig(JSONObject json) throws JSONException, IllegalArgumentException { mType = ViewType.fromId(json.getString(JSON_KEY_TYPE)); mDatasetId = json.getString(JSON_KEY_DATASET); mItemType = ItemType.fromId(json.getString(JSON_KEY_ITEM_TYPE)); mItemHandler = ItemHandler.fromId(json.getString(JSON_KEY_ITEM_HANDLER)); + mBackImageUrl = json.optString(JSON_KEY_BACK_IMAGE_URL, null); validate(); } @@ -604,6 +607,7 @@ public final class HomeConfig { mDatasetId = in.readString(); mItemType = (ItemType) in.readParcelable(getClass().getClassLoader()); mItemHandler = (ItemHandler) in.readParcelable(getClass().getClassLoader()); + mBackImageUrl = in.readString(); validate(); } @@ -613,15 +617,18 @@ public final class HomeConfig { mDatasetId = viewConfig.mDatasetId; mItemType = viewConfig.mItemType; mItemHandler = viewConfig.mItemHandler; + mBackImageUrl = viewConfig.mBackImageUrl; validate(); } - public ViewConfig(ViewType type, String datasetId, ItemType itemType, ItemHandler itemHandler) { + public ViewConfig(ViewType type, String datasetId, ItemType itemType, + ItemHandler itemHandler, String backImageUrl) { mType = type; mDatasetId = datasetId; mItemType = itemType; mItemHandler = itemHandler; + mBackImageUrl = backImageUrl; validate(); } @@ -660,6 +667,10 @@ public final class HomeConfig { return mItemHandler; } + public String getBackImageUrl() { + return mBackImageUrl; + } + public JSONObject toJSON() throws JSONException { final JSONObject json = new JSONObject(); @@ -668,6 +679,10 @@ public final class HomeConfig { json.put(JSON_KEY_ITEM_TYPE, mItemType.toString()); json.put(JSON_KEY_ITEM_HANDLER, mItemHandler.toString()); + if (!TextUtils.isEmpty(mBackImageUrl)) { + json.put(JSON_KEY_BACK_IMAGE_URL, mBackImageUrl); + } + return json; } @@ -682,6 +697,7 @@ public final class HomeConfig { dest.writeString(mDatasetId); dest.writeParcelable(mItemType, 0); dest.writeParcelable(mItemHandler, 0); + dest.writeString(mBackImageUrl); } public static final Creator CREATOR = new Creator() { diff --git a/mobile/android/base/home/PanelBackItemView.java b/mobile/android/base/home/PanelBackItemView.java index e63fbc26384..ff0bc745600 100644 --- a/mobile/android/base/home/PanelBackItemView.java +++ b/mobile/android/base/home/PanelBackItemView.java @@ -20,7 +20,7 @@ import com.squareup.picasso.Picasso; class PanelBackItemView extends LinearLayout { private final TextView title; - public PanelBackItemView(Context context) { + public PanelBackItemView(Context context, String backImageUrl) { super(context); LayoutInflater.from(context).inflate(R.layout.panel_back_item, this); @@ -30,7 +30,8 @@ class PanelBackItemView extends LinearLayout { final ImageView image = (ImageView) findViewById(R.id.image); Picasso.with(getContext()) - .load(R.drawable.folder_up) + .load(backImageUrl) + .placeholder(R.drawable.folder_up) .into(image); } diff --git a/mobile/android/base/home/PanelGridView.java b/mobile/android/base/home/PanelGridView.java index ffcfa5aaa44..994c7da5c0c 100644 --- a/mobile/android/base/home/PanelGridView.java +++ b/mobile/android/base/home/PanelGridView.java @@ -37,7 +37,7 @@ public class PanelGridView extends GridView mViewConfig = viewConfig; mItemHandler = new PanelViewItemHandler(viewConfig); - mAdapter = new PanelViewAdapter(context, viewConfig.getItemType()); + mAdapter = new PanelViewAdapter(context, viewConfig); setAdapter(mAdapter); setOnItemClickListener(new PanelGridItemClickListener()); diff --git a/mobile/android/base/home/PanelListView.java b/mobile/android/base/home/PanelListView.java index 22167190e25..ed1bd6a49f2 100644 --- a/mobile/android/base/home/PanelListView.java +++ b/mobile/android/base/home/PanelListView.java @@ -37,7 +37,7 @@ public class PanelListView extends HomeListView mViewConfig = viewConfig; mItemHandler = new PanelViewItemHandler(viewConfig); - mAdapter = new PanelViewAdapter(context, viewConfig.getItemType()); + mAdapter = new PanelViewAdapter(context, viewConfig); setAdapter(mAdapter); setOnItemClickListener(new PanelListItemClickListener()); diff --git a/mobile/android/base/home/PanelViewAdapter.java b/mobile/android/base/home/PanelViewAdapter.java index d310de853d0..d5d9f59e95a 100644 --- a/mobile/android/base/home/PanelViewAdapter.java +++ b/mobile/android/base/home/PanelViewAdapter.java @@ -6,6 +6,7 @@ package org.mozilla.gecko.home; import org.mozilla.gecko.home.HomeConfig.ItemType; +import org.mozilla.gecko.home.HomeConfig.ViewConfig; import org.mozilla.gecko.home.PanelLayout.FilterManager; import org.mozilla.gecko.R; @@ -21,13 +22,13 @@ class PanelViewAdapter extends CursorAdapter { private static final int VIEW_TYPE_BACK = 1; private final Context mContext; - private final ItemType mItemType; + private final ViewConfig mViewConfig; private FilterManager mFilterManager; - public PanelViewAdapter(Context context, ItemType itemType) { + public PanelViewAdapter(Context context, ViewConfig viewConfig) { super(context, null, 0); mContext = context; - mItemType = itemType; + mViewConfig = viewConfig; } public void setFilterManager(FilterManager manager) { @@ -65,9 +66,9 @@ class PanelViewAdapter extends CursorAdapter { private View newView(Context context, int position, ViewGroup parent) { if (getItemViewType(position) == VIEW_TYPE_BACK) { - return new PanelBackItemView(context); + return new PanelBackItemView(context, mViewConfig.getBackImageUrl()); } else { - return PanelItemView.create(context, mItemType); + return PanelItemView.create(context, mViewConfig.getItemType()); } } From bb4fcdf4158b29fa70c7a5679ab5706a7c358f88 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Sat, 15 Mar 2014 23:21:32 -0700 Subject: [PATCH 23/88] Bug 980211 - Suppress clang and gcc warnings in third-party media code: speex, theora, and vpx. r=derf --- media/libspeex_resampler/src/moz.build | 4 ++++ media/libtheora/lib/moz.build | 2 +- media/libvpx/moz.build | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/media/libspeex_resampler/src/moz.build b/media/libspeex_resampler/src/moz.build index d7d0d73b272..4056a6c8e4c 100644 --- a/media/libspeex_resampler/src/moz.build +++ b/media/libspeex_resampler/src/moz.build @@ -41,3 +41,7 @@ if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['OS_TARGET'] != 'Android': DEFINES['_USE_SSE2'] = True if CONFIG['GNU_CC']: SOURCES['resample.c'].flags += ['-msse2'] + +# Suppress warnings in third-party code. +if CONFIG['GNU_CC']: + CFLAGS += ['-Wno-sign-compare'] diff --git a/media/libtheora/lib/moz.build b/media/libtheora/lib/moz.build index d46f7b2d6f0..648b98fae14 100644 --- a/media/libtheora/lib/moz.build +++ b/media/libtheora/lib/moz.build @@ -78,5 +78,5 @@ FINAL_LIBRARY = 'gkmedias' DEFINES['THEORA_DISABLE_ENCODE'] = True # Suppress warnings in third-party code. -if CONFIG['OS_TARGET'] == 'Darwin': +if CONFIG['CLANG_CXX']: CFLAGS += ['-Wno-tautological-compare'] diff --git a/media/libvpx/moz.build b/media/libvpx/moz.build index 54978241803..929bab25fb9 100644 --- a/media/libvpx/moz.build +++ b/media/libvpx/moz.build @@ -87,8 +87,6 @@ if CONFIG['OS_TARGET'] == 'Android': SOURCES += [ '%s/sources/android/cpufeatures/cpu-features.c' % CONFIG['ANDROID_NDK'], ] -elif CONFIG['OS_TARGET'] == 'Darwin': - CFLAGS += ['-Wno-sign-compare'] if not CONFIG['_MSC_VER']: for f in SOURCES: @@ -99,3 +97,7 @@ if not CONFIG['_MSC_VER']: SOURCES[f].flags += ['-mssse3'] if 'avx2' in f: SOURCES[f].flags += ['-mavx2'] + +# Suppress warnings in third-party code. +if CONFIG['GNU_CC']: + CFLAGS += ['-Wno-sign-compare'] From a87bcb5238de823e300cb931f6a13d80d60d6c4f Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Sat, 15 Mar 2014 23:24:47 -0700 Subject: [PATCH 24/88] Bug 984074 - Suppress clang and gcc warnings in third-party code: snappy. r=janv --- other-licenses/snappy/moz.build | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/other-licenses/snappy/moz.build b/other-licenses/snappy/moz.build index b2368b549d2..a28d9aa1d7a 100644 --- a/other-licenses/snappy/moz.build +++ b/other-licenses/snappy/moz.build @@ -18,3 +18,10 @@ UNIFIED_SOURCES += [ ] FINAL_LIBRARY = 'xul' + +# Suppress warnings in third-party code. +if CONFIG['GNU_CXX']: + CXXFLAGS += [ + '-Wno-sign-compare', + '-Wno-unused-function' + ] From fca4f67cbd109541f8c62cc384bfc400e507abc8 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Sat, 15 Mar 2014 23:25:55 -0700 Subject: [PATCH 25/88] Bug 984079 - Suppress clang and gcc warnings in third-party code: protobuf. r=mmc --- toolkit/components/protobuf/moz.build | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/toolkit/components/protobuf/moz.build b/toolkit/components/protobuf/moz.build index 077fe435fdd..79e1b6f3466 100644 --- a/toolkit/components/protobuf/moz.build +++ b/toolkit/components/protobuf/moz.build @@ -46,3 +46,10 @@ UNIFIED_SOURCES += [ FINAL_LIBRARY = 'toolkitcomps' DEFINES['GOOGLE_PROTOBUF_NO_RTTI'] = True + +# Suppress warnings in third-party code. +if CONFIG['GNU_CXX']: + CXXFLAGS += [ + '-Wno-null-conversion', + '-Wno-sign-compare', + ] From 977bc1500be97af86e2d7dd347c11ffc5cbd41b9 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Sat, 15 Mar 2014 23:17:50 -0700 Subject: [PATCH 26/88] Bug 984250 - Suppress clang and gcc warnings in third-party code: hunspell and hyphen. r=ehsan --- extensions/spellcheck/hunspell/src/moz.build | 3 +++ intl/hyphenation/src/moz.build | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/extensions/spellcheck/hunspell/src/moz.build b/extensions/spellcheck/hunspell/src/moz.build index 4da73348ce3..a7e39bf4e8e 100644 --- a/extensions/spellcheck/hunspell/src/moz.build +++ b/extensions/spellcheck/hunspell/src/moz.build @@ -37,3 +37,6 @@ LOCAL_INCLUDES += [ '/editor/libeditor/base', ] +# Suppress warnings in third-party code. +if CONFIG['CLANG_CXX']: + CXXFLAGS += ['-Wno-unused-private-field'] diff --git a/intl/hyphenation/src/moz.build b/intl/hyphenation/src/moz.build index 47d97dcb9c6..83d8c9dc8fb 100644 --- a/intl/hyphenation/src/moz.build +++ b/intl/hyphenation/src/moz.build @@ -17,3 +17,10 @@ SOURCES += [ MSVC_ENABLE_PGO = True FINAL_LIBRARY = 'i18n' + +# Suppress warnings in third-party code. +if CONFIG['GNU_CC']: + CFLAGS += [ + '-Wno-sign-compare', + '-Wno-type-limits', + ] From 76a1f7f455f65b6441279900e2d42ef14628310a Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Fri, 14 Mar 2014 23:24:31 -0700 Subject: [PATCH 27/88] Bug 983959 - Part 1: Fix warnings about unused member variables in js/. r=luke --- js/src/assembler/jit/ExecutableAllocator.h | 9 +-------- js/src/vm/ThreadPool.cpp | 4 ++-- js/src/vm/ThreadPool.h | 6 +++--- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/js/src/assembler/jit/ExecutableAllocator.h b/js/src/assembler/jit/ExecutableAllocator.h index c6842c27b86..89c65024610 100644 --- a/js/src/assembler/jit/ExecutableAllocator.h +++ b/js/src/assembler/jit/ExecutableAllocator.h @@ -115,13 +115,6 @@ private: size_t m_otherCodeBytes; public: - // Flag for downstream use, whether to try to release references to this pool. - bool m_destroy; - - // GC number in which the m_destroy flag was most recently set. Used downstream to - // remember whether m_destroy was computed for the currently active GC. - size_t m_gcNumber; - void release(bool willDestroy = false) { JS_ASSERT(m_refCount != 0); @@ -159,7 +152,7 @@ public: ExecutablePool(ExecutableAllocator* allocator, Allocation a) : m_allocator(allocator), m_freePtr(a.pages), m_end(m_freePtr + a.size), m_allocation(a), m_refCount(1), m_ionCodeBytes(0), m_baselineCodeBytes(0), m_regexpCodeBytes(0), - m_otherCodeBytes(0), m_destroy(false), m_gcNumber(0) + m_otherCodeBytes(0) { } ~ExecutablePool(); diff --git a/js/src/vm/ThreadPool.cpp b/js/src/vm/ThreadPool.cpp index 8fe96ee13ed..52d6fcee987 100644 --- a/js/src/vm/ThreadPool.cpp +++ b/js/src/vm/ThreadPool.cpp @@ -238,11 +238,11 @@ ThreadPoolWorker::terminate(AutoLockMonitor &lock) // them down when requested. ThreadPool::ThreadPool(JSRuntime *rt) - : runtime_(rt), - activeWorkers_(0), + : activeWorkers_(0), joinBarrier_(nullptr), job_(nullptr), #ifdef DEBUG + runtime_(rt), stolenSlices_(0), #endif pendingSlices_(0), diff --git a/js/src/vm/ThreadPool.h b/js/src/vm/ThreadPool.h index 70720a0c0c8..f141bd5647f 100644 --- a/js/src/vm/ThreadPool.h +++ b/js/src/vm/ThreadPool.h @@ -164,9 +164,6 @@ class ThreadPool : public Monitor private: friend class ThreadPoolWorker; - // Initialized at startup only. - JSRuntime *const runtime_; - // Initialized lazily. js::Vector workers_; @@ -178,6 +175,9 @@ class ThreadPool : public Monitor ParallelJob *job_; #ifdef DEBUG + // Initialized at startup only. + JSRuntime *const runtime_; + // Number of stolen slices in the last parallel job. mozilla::Atomic stolenSlices_; #endif From f39ae3e0113a2f49258fb9916263b624b4dced83 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Sun, 16 Mar 2014 22:40:55 -0700 Subject: [PATCH 28/88] Bug 983959 - Part 2: Remove unused DebugOnly #includes in js/. r=luke --- js/src/jit/IonCaches.cpp | 2 -- js/src/jit/mips/MacroAssembler-mips.h | 5 ----- js/src/jsobj.cpp | 3 --- js/src/vm/StringBuffer.h | 2 -- 4 files changed, 12 deletions(-) diff --git a/js/src/jit/IonCaches.cpp b/js/src/jit/IonCaches.cpp index fd5ff3b9190..1712ea0a4a6 100644 --- a/js/src/jit/IonCaches.cpp +++ b/js/src/jit/IonCaches.cpp @@ -6,7 +6,6 @@ #include "jit/IonCaches.h" -#include "mozilla/DebugOnly.h" #include "mozilla/TemplateLib.h" #include "jsproxy.h" @@ -31,7 +30,6 @@ using namespace js; using namespace js::jit; -using mozilla::DebugOnly; using mozilla::tl::FloorLog2; void diff --git a/js/src/jit/mips/MacroAssembler-mips.h b/js/src/jit/mips/MacroAssembler-mips.h index afff3b06847..a6a811bb2b3 100644 --- a/js/src/jit/mips/MacroAssembler-mips.h +++ b/js/src/jit/mips/MacroAssembler-mips.h @@ -7,8 +7,6 @@ #ifndef jit_mips_MacroAssembler_mips_h #define jit_mips_MacroAssembler_mips_h -#include "mozilla/DebugOnly.h" - #include "jsopcode.h" #include "jit/IonCaches.h" @@ -16,12 +14,9 @@ #include "jit/mips/Assembler-mips.h" #include "jit/MoveResolver.h" -using mozilla::DebugOnly; - namespace js { namespace jit { - enum LoadStoreSize { SizeByte = 8, diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index bdb5b5d277d..8eeae57ca9d 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -66,9 +66,6 @@ using namespace js; using namespace js::gc; using namespace js::types; -using js::frontend::IsIdentifier; -using mozilla::ArrayLength; -using mozilla::DebugOnly; using mozilla::Maybe; using mozilla::RoundUpPow2; diff --git a/js/src/vm/StringBuffer.h b/js/src/vm/StringBuffer.h index 7ed5f86725c..5b8b217302a 100644 --- a/js/src/vm/StringBuffer.h +++ b/js/src/vm/StringBuffer.h @@ -7,8 +7,6 @@ #ifndef vm_StringBuffer_h #define vm_StringBuffer_h -#include "mozilla/DebugOnly.h" - #include "jscntxt.h" #include "js/Vector.h" From 33cd68ff0e4fc6897d53b36a29d4e7e191ed4b33 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Mon, 17 Mar 2014 20:11:24 -0700 Subject: [PATCH 29/88] Bug 984071 - Part 1: Fix unused variable warning in content/media/webaudio. r=padenot --- content/media/webaudio/blink/HRTFPanner.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/media/webaudio/blink/HRTFPanner.cpp b/content/media/webaudio/blink/HRTFPanner.cpp index 1c02e0294b7..03cc71faa86 100644 --- a/content/media/webaudio/blink/HRTFPanner.cpp +++ b/content/media/webaudio/blink/HRTFPanner.cpp @@ -112,11 +112,13 @@ int HRTFPanner::calculateDesiredAzimuthIndexAndBlend(double azimuth, double& azi void HRTFPanner::pan(double desiredAzimuth, double elevation, const AudioChunk* inputBus, AudioChunk* outputBus) { +#ifdef DEBUG unsigned numInputChannels = inputBus->IsNull() ? 0 : inputBus->mChannelData.Length(); MOZ_ASSERT(numInputChannels <= 2); MOZ_ASSERT(inputBus->mDuration == WEBAUDIO_BLOCK_SIZE); +#endif bool isOutputGood = outputBus && outputBus->mChannelData.Length() == 2 && outputBus->mDuration == WEBAUDIO_BLOCK_SIZE; MOZ_ASSERT(isOutputGood); From 8d16351a1d7fdcab5d78b65e6bd65d6529e4621a Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Mon, 17 Mar 2014 20:50:45 -0700 Subject: [PATCH 30/88] Bug 973322 followup, set the sticky pref so we don't lose either the expected assertion, or the ability to test for the crash --- layout/mathml/crashtests/crashtests.list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layout/mathml/crashtests/crashtests.list b/layout/mathml/crashtests/crashtests.list index 85700ac68ff..8a22cff6ec8 100644 --- a/layout/mathml/crashtests/crashtests.list +++ b/layout/mathml/crashtests/crashtests.list @@ -58,4 +58,4 @@ load 654928-1.html load 655451-1.xhtml load 713606-1.html load 716349-1.html -asserts(1) load 973322-1.xhtml +test-pref(layout.css.sticky.enabled,true) asserts(1) load 973322-1.xhtml From 686e2f7be423e2401323471c309f8b31ee7198b9 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Tue, 18 Mar 2014 12:06:23 +0800 Subject: [PATCH 31/88] Bug 982318 - Add TransformBounds to Matrix4x4 so that we can stop assuming 2d matrices in TiledContentHost. r=Bas --- gfx/2d/Matrix.cpp | 34 +++++++++++++++++++++++ gfx/2d/Matrix.h | 34 +++++++++++++++++++++++ gfx/2d/Point.h | 22 +++++++++++++++ gfx/layers/composite/TiledContentHost.cpp | 3 +- 4 files changed, 91 insertions(+), 2 deletions(-) diff --git a/gfx/2d/Matrix.cpp b/gfx/2d/Matrix.cpp index 80e2d3d321d..a5be1327aec 100644 --- a/gfx/2d/Matrix.cpp +++ b/gfx/2d/Matrix.cpp @@ -68,5 +68,39 @@ Matrix::NudgeToIntegers() NudgeToInteger(&_32); } +Rect +Matrix4x4::TransformBounds(const Rect& aRect) const +{ + Point quad[4]; + Float min_x, max_x; + Float min_y, max_y; + + quad[0] = *this * aRect.TopLeft(); + quad[1] = *this * aRect.TopRight(); + quad[2] = *this * aRect.BottomLeft(); + quad[3] = *this * aRect.BottomRight(); + + min_x = max_x = quad[0].x; + min_y = max_y = quad[0].y; + + for (int i = 1; i < 4; i++) { + if (quad[i].x < min_x) { + min_x = quad[i].x; + } + if (quad[i].x > max_x) { + max_x = quad[i].x; + } + + if (quad[i].y < min_y) { + min_y = quad[i].y; + } + if (quad[i].y > max_y) { + max_y = quad[i].y; + } + } + + return Rect(min_x, min_y, max_x - min_x, max_y - min_y); +} + } } diff --git a/gfx/2d/Matrix.h b/gfx/2d/Matrix.h index 70b5606e0f1..8107298ce66 100644 --- a/gfx/2d/Matrix.h +++ b/gfx/2d/Matrix.h @@ -338,6 +338,40 @@ public: return Is2D() && As2D().IsIntegerTranslation(); } + Point4D operator *(const Point4D& aPoint) const + { + Point4D retPoint; + + retPoint.x = aPoint.x * _11 + aPoint.y * _21 + aPoint.z * _31 + _41; + retPoint.y = aPoint.x * _12 + aPoint.y * _22 + aPoint.z * _32 + _42; + retPoint.z = aPoint.x * _13 + aPoint.y * _23 + aPoint.z * _33 + _43; + retPoint.w = aPoint.x * _14 + aPoint.y * _24 + aPoint.z * _34 + _44; + + return retPoint; + } + + Point3D operator *(const Point3D& aPoint) const + { + Point4D temp(aPoint.x, aPoint.y, aPoint.z, 1); + + temp = *this * temp; + temp /= temp.w; + + return Point3D(temp.x, temp.y, temp.z); + } + + Point operator *(const Point &aPoint) const + { + Point4D temp(aPoint.x, aPoint.y, 0, 1); + + temp = *this * temp; + temp /= temp.w; + + return Point(temp.x, temp.y); + } + + GFX2D_API Rect TransformBounds(const Rect& rect) const; + // Apply a scale to this matrix. This scale will be applied -before- the // existing transformation of the matrix. Matrix4x4 &Scale(Float aX, Float aY, Float aZ) diff --git a/gfx/2d/Point.h b/gfx/2d/Point.h index d900fbecb2b..704d239ef68 100644 --- a/gfx/2d/Point.h +++ b/gfx/2d/Point.h @@ -10,6 +10,7 @@ #include "Types.h" #include "BasePoint.h" #include "BasePoint3D.h" +#include "BasePoint4D.h" #include "BaseSize.h" #include @@ -92,6 +93,27 @@ struct Point3DTyped : }; typedef Point3DTyped Point3D; +template +struct Point4DTyped : + public BasePoint4D< Float, Point4DTyped > { + typedef BasePoint4D< Float, Point4DTyped > Super; + + Point4DTyped() : Super() {} + Point4DTyped(Float aX, Float aY, Float aZ, Float aW) : Super(aX, aY, aZ, aW) {} + + // XXX When all of the code is ported, the following functions to convert to and from + // unknown types should be removed. + + static Point4DTyped FromUnknownPoint(const Point4DTyped& aPoint) { + return Point4DTyped(aPoint.x, aPoint.y, aPoint.z, aPoint.w); + } + + Point4DTyped ToUnknownPoint() const { + return Point4DTyped(this->x, this->y, this->z, this->w); + } +}; +typedef Point4DTyped Point4D; + template struct IntSizeTyped : public BaseSize< int32_t, IntSizeTyped >, diff --git a/gfx/layers/composite/TiledContentHost.cpp b/gfx/layers/composite/TiledContentHost.cpp index dc0ed2c60a6..a41e0f41973 100644 --- a/gfx/layers/composite/TiledContentHost.cpp +++ b/gfx/layers/composite/TiledContentHost.cpp @@ -318,9 +318,8 @@ TiledContentHost::RenderTile(const TileHost& aTile, } nsIntRect screenBounds = aScreenRegion.GetBounds(); - Matrix mat = aTransform.As2D(); Rect quad(screenBounds.x, screenBounds.y, screenBounds.width, screenBounds.height); - quad = mat.TransformBounds(quad); + quad = aTransform.TransformBounds(quad); if (!quad.Intersects(mCompositor->ClipRectInLayersCoordinates(aClipRect))) { return; From 1cad2f57db541abdb11ec15dc43641f79d379bfd Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Tue, 18 Mar 2014 12:06:25 +0800 Subject: [PATCH 32/88] Bug 982339 - Get rid of TextureClientPoolMember and use nsTArray so that we releases references when we shutdown. r=Bas --- gfx/layers/client/ClientLayerManager.cpp | 30 +++++++----------------- gfx/layers/client/ClientLayerManager.h | 11 +-------- gfx/layers/client/TextureClientPool.cpp | 5 ++++ gfx/layers/client/TextureClientPool.h | 3 +++ 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/gfx/layers/client/ClientLayerManager.cpp b/gfx/layers/client/ClientLayerManager.cpp index cc81f5683ed..fea1e667f2c 100644 --- a/gfx/layers/client/ClientLayerManager.cpp +++ b/gfx/layers/client/ClientLayerManager.cpp @@ -37,11 +37,6 @@ using namespace mozilla::gfx; namespace mozilla { namespace layers { - TextureClientPoolMember::TextureClientPoolMember(SurfaceFormat aFormat, TextureClientPool* aTexturePool) - : mFormat(aFormat) - , mTexturePool(aTexturePool) -{} - ClientLayerManager::ClientLayerManager(nsIWidget* aWidget) : mPhase(PHASE_NONE) , mWidget(aWidget) @@ -61,8 +56,6 @@ ClientLayerManager::~ClientLayerManager() mRoot = nullptr; MOZ_COUNT_DTOR(ClientLayerManager); - - mTexturePools.clear(); } int32_t @@ -233,9 +226,8 @@ ClientLayerManager::EndTransaction(DrawThebesLayerCallback aCallback, MakeSnapshotIfRequired(); } - for (const TextureClientPoolMember* item = mTexturePools.getFirst(); - item; item = item->getNext()) { - item->mTexturePool->ReturnDeferredClients(); + for (size_t i = 0; i < mTexturePools.Length(); i++) { + mTexturePools[i]->ReturnDeferredClients(); } } @@ -458,21 +450,18 @@ ClientLayerManager::SetIsFirstPaint() TextureClientPool* ClientLayerManager::GetTexturePool(SurfaceFormat aFormat) { - for (const TextureClientPoolMember* item = mTexturePools.getFirst(); - item; item = item->getNext()) { - if (item->mFormat == aFormat) { - return item->mTexturePool; + for (size_t i = 0; i < mTexturePools.Length(); i++) { + if (mTexturePools[i]->GetFormat() == aFormat) { + return mTexturePools[i]; } } - TextureClientPoolMember* texturePoolMember = - new TextureClientPoolMember(aFormat, + mTexturePools.AppendElement( new TextureClientPool(aFormat, IntSize(TILEDLAYERBUFFER_TILE_SIZE, TILEDLAYERBUFFER_TILE_SIZE), mForwarder)); - mTexturePools.insertBack(texturePoolMember); - return texturePoolMember->mTexturePool; + return mTexturePools.LastElement(); } SimpleTextureClientPool* @@ -502,9 +491,8 @@ ClientLayerManager::ClearCachedResources(Layer* aSubtree) } else if (mRoot) { ClearLayer(mRoot); } - for (const TextureClientPoolMember* item = mTexturePools.getFirst(); - item; item = item->getNext()) { - item->mTexturePool->Clear(); + for (size_t i = 0; i < mTexturePools.Length(); i++) { + mTexturePools[i]->Clear(); } } diff --git a/gfx/layers/client/ClientLayerManager.h b/gfx/layers/client/ClientLayerManager.h index 3eaa04d97d2..9e5391d46d6 100644 --- a/gfx/layers/client/ClientLayerManager.h +++ b/gfx/layers/client/ClientLayerManager.h @@ -36,15 +36,6 @@ class PLayerChild; class TextureClientPool; class SimpleTextureClientPool; -class TextureClientPoolMember - : public LinkedListElement { -public: - TextureClientPoolMember(gfx::SurfaceFormat aFormat, TextureClientPool* aTexturePool); - - gfx::SurfaceFormat mFormat; - RefPtr mTexturePool; -}; - class ClientLayerManager : public LayerManager { typedef nsTArray > LayerRefArray; @@ -229,7 +220,7 @@ private: bool mNeedsComposite; RefPtr mForwarder; - LinkedList mTexturePools; + nsAutoTArray,2> mTexturePools; // indexed by gfx::SurfaceFormat nsTArray > mSimpleTilePools; diff --git a/gfx/layers/client/TextureClientPool.cpp b/gfx/layers/client/TextureClientPool.cpp index 9d89aa4760b..5a2a0a81ec5 100644 --- a/gfx/layers/client/TextureClientPool.cpp +++ b/gfx/layers/client/TextureClientPool.cpp @@ -30,6 +30,11 @@ TextureClientPool::TextureClientPool(gfx::SurfaceFormat aFormat, gfx::IntSize aS mTimer = do_CreateInstance("@mozilla.org/timer;1"); } +TextureClientPool::~TextureClientPool() +{ + mTimer->Cancel(); +} + TemporaryRef TextureClientPool::GetTextureClient() { diff --git a/gfx/layers/client/TextureClientPool.h b/gfx/layers/client/TextureClientPool.h index ef256a3b7db..a13ebadbae7 100644 --- a/gfx/layers/client/TextureClientPool.h +++ b/gfx/layers/client/TextureClientPool.h @@ -24,6 +24,7 @@ public: MOZ_DECLARE_REFCOUNTED_TYPENAME(TextureClientPool) TextureClientPool(gfx::SurfaceFormat aFormat, gfx::IntSize aSize, ISurfaceAllocator *aAllocator); + ~TextureClientPool(); /** * Gets an allocated TextureClient of size and format that are determined @@ -78,6 +79,8 @@ public: */ void Clear(); + gfx::SurfaceFormat GetFormat() { return mFormat; } + private: // The time in milliseconds before the pool will be shrunk to the minimum // size after returning a client. From a5288ab90989e1ada813c4dc695d03f1257c8a4c Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Tue, 18 Mar 2014 00:36:31 -0400 Subject: [PATCH 33/88] Bug 984346 - Remove the classinfo for SystemMessageManager since the nsIDOMNavigatorSystemMessages API is already implemented in WebIDL; r=bzbarsky --- dom/messages/SystemMessageManager.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/dom/messages/SystemMessageManager.js b/dom/messages/SystemMessageManager.js index b4b4e93654e..67021ea6462 100644 --- a/dom/messages/SystemMessageManager.js +++ b/dom/messages/SystemMessageManager.js @@ -308,14 +308,7 @@ SystemMessageManager.prototype = { QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMNavigatorSystemMessages, Ci.nsIDOMGlobalPropertyInitializer, Ci.nsIObserver, - Ci.nsISupportsWeakReference]), - - classInfo: XPCOMUtils.generateCI({ - classID: Components.ID("{bc076ea0-609b-4d8f-83d7-5af7cbdc3bb2}"), - contractID: "@mozilla.org/system-message-manager;1", - interfaces: [Ci.nsIDOMNavigatorSystemMessages], - flags: Ci.nsIClassInfo.DOM_OBJECT, - classDescription: "System Messages"}) + Ci.nsISupportsWeakReference]) } this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SystemMessageManager]); From dbc1fb8ad81ebb042b818eb6a4ad7825e309b61f Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Tue, 18 Mar 2014 00:38:36 -0400 Subject: [PATCH 34/88] Bug 866528 - Make nsIDOMActivityOptions a dictionary; r=bzbarsky --- b2g/installer/package-manifest.in | 1 - browser/installer/package-manifest.in | 1 - dom/activities/interfaces/moz.build | 1 - .../interfaces/nsIActivityProxy.idl | 3 +- .../interfaces/nsIDOMActivityOptions.idl | 13 ----- .../nsIDOMActivityRequestHandler.idl | 4 +- dom/activities/src/Activities.manifest | 3 - dom/activities/src/Activity.cpp | 12 ++-- dom/activities/src/Activity.h | 9 ++- dom/activities/src/ActivityOptions.js | 56 ------------------- dom/activities/src/ActivityRequestHandler.js | 7 +-- dom/activities/src/ActivityWrapper.js | 2 +- dom/activities/src/moz.build | 1 - dom/bindings/Bindings.conf | 2 - dom/webidl/MozActivity.webidl | 7 ++- 15 files changed, 25 insertions(+), 97 deletions(-) delete mode 100644 dom/activities/interfaces/nsIDOMActivityOptions.idl delete mode 100644 dom/activities/src/ActivityOptions.js diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index 9fa8a099894..84a1b6c9e81 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -543,7 +543,6 @@ @BINPATH@/components/SystemMessageManager.manifest @BINPATH@/components/Activities.manifest -@BINPATH@/components/ActivityOptions.js @BINPATH@/components/ActivityProxy.js @BINPATH@/components/ActivityRequestHandler.js @BINPATH@/components/ActivityWrapper.js diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index d9a53f9c575..97ca8b1334c 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -544,7 +544,6 @@ @BINPATH@/components/SystemMessageManager.manifest @BINPATH@/components/Activities.manifest -@BINPATH@/components/ActivityOptions.js @BINPATH@/components/ActivityProxy.js @BINPATH@/components/ActivityRequestHandler.js @BINPATH@/components/ActivityWrapper.js diff --git a/dom/activities/interfaces/moz.build b/dom/activities/interfaces/moz.build index 0da2d3ffed4..02414add034 100644 --- a/dom/activities/interfaces/moz.build +++ b/dom/activities/interfaces/moz.build @@ -7,7 +7,6 @@ XPIDL_SOURCES += [ 'nsIActivityProxy.idl', 'nsIActivityUIGlue.idl', - 'nsIDOMActivityOptions.idl', 'nsIDOMActivityRequestHandler.idl', ] diff --git a/dom/activities/interfaces/nsIActivityProxy.idl b/dom/activities/interfaces/nsIActivityProxy.idl index 68097107384..a5fa059f1e0 100644 --- a/dom/activities/interfaces/nsIActivityProxy.idl +++ b/dom/activities/interfaces/nsIActivityProxy.idl @@ -4,7 +4,6 @@ #include "nsISupports.idl" -interface nsIDOMMozActivityOptions; interface nsIDOMWindow; /** @@ -14,7 +13,7 @@ interface nsIDOMWindow; interface nsIActivityProxy : nsISupports { void startActivity(in nsISupports /* MozActivity */ activity, - in nsIDOMMozActivityOptions options, + in jsval options, in nsIDOMWindow window); void cleanup(); }; diff --git a/dom/activities/interfaces/nsIDOMActivityOptions.idl b/dom/activities/interfaces/nsIDOMActivityOptions.idl deleted file mode 100644 index 146eb43e3a3..00000000000 --- a/dom/activities/interfaces/nsIDOMActivityOptions.idl +++ /dev/null @@ -1,13 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "domstubs.idl" - -[scriptable, uuid(f5bf5e9b-f53f-470f-b560-0d6f4c1c98ad)] -interface nsIDOMMozActivityOptions : nsISupports -{ - readonly attribute DOMString name; - // The |data| field can be null. - readonly attribute jsval data; -}; diff --git a/dom/activities/interfaces/nsIDOMActivityRequestHandler.idl b/dom/activities/interfaces/nsIDOMActivityRequestHandler.idl index 5cea23688db..4fe0ac0fe4b 100644 --- a/dom/activities/interfaces/nsIDOMActivityRequestHandler.idl +++ b/dom/activities/interfaces/nsIDOMActivityRequestHandler.idl @@ -4,12 +4,10 @@ #include "domstubs.idl" -interface nsIDOMMozActivityOptions; - [scriptable, uuid(e70c4181-ea3f-4aa5-a2f7-af910dc65e45)] interface nsIDOMMozActivityRequestHandler : nsISupports { void postResult(in jsval result); void postError(in DOMString error); - readonly attribute nsIDOMMozActivityOptions source; + readonly attribute jsval source; }; diff --git a/dom/activities/src/Activities.manifest b/dom/activities/src/Activities.manifest index 1802d646327..06b14cdc6a0 100644 --- a/dom/activities/src/Activities.manifest +++ b/dom/activities/src/Activities.manifest @@ -9,6 +9,3 @@ contract @mozilla.org/dom/system-messages/configurator/activity;1 {d2296daa-c406 component {9326952a-dbe3-4d81-a51f-d9c160d96d6b} ActivityRequestHandler.js contract @mozilla.org/dom/activities/request-handler;1 {9326952a-dbe3-4d81-a51f-d9c160d96d6b} - -component {ee983dbb-d5ea-4c5b-be98-10a13cac9f9d} ActivityOptions.js -contract @mozilla.org/dom/activities/options;1 {ee983dbb-d5ea-4c5b-be98-10a13cac9f9d} diff --git a/dom/activities/src/Activity.cpp b/dom/activities/src/Activity.cpp index 532affd9d4c..26344f91760 100644 --- a/dom/activities/src/Activity.cpp +++ b/dom/activities/src/Activity.cpp @@ -4,7 +4,6 @@ #include "Activity.h" -#include "mozilla/dom/MozActivityBinding.h" #include "nsContentUtils.h" #include "nsDOMClassInfo.h" #include "nsIConsoleService.h" @@ -33,9 +32,9 @@ Activity::WrapObject(JSContext* aCx, JS::Handle aScope) nsresult Activity::Initialize(nsPIDOMWindow* aWindow, - nsIDOMMozActivityOptions* aOptions) + JSContext* aCx, + const ActivityOptions& aOptions) { - MOZ_ASSERT(aOptions); MOZ_ASSERT(aWindow); nsCOMPtr document = aWindow->GetExtantDoc(); @@ -67,7 +66,12 @@ Activity::Initialize(nsPIDOMWindow* aWindow, mProxy = do_CreateInstance("@mozilla.org/dom/activities/proxy;1", &rv); NS_ENSURE_SUCCESS(rv, rv); - mProxy->StartActivity(static_cast(this), aOptions, aWindow); + JS::Rooted optionsValue(aCx); + if (!aOptions.ToObject(aCx, JS::NullPtr(), &optionsValue)) { + return NS_ERROR_FAILURE; + } + + mProxy->StartActivity(static_cast(this), optionsValue, aWindow); return NS_OK; } diff --git a/dom/activities/src/Activity.h b/dom/activities/src/Activity.h index 679e6b5752f..30f5fadaa57 100644 --- a/dom/activities/src/Activity.h +++ b/dom/activities/src/Activity.h @@ -7,6 +7,7 @@ #include "DOMRequest.h" #include "mozilla/dom/BindingDeclarations.h" +#include "mozilla/dom/MozActivityBinding.h" #include "nsIActivityProxy.h" #include "mozilla/Preferences.h" #include "nsPIDOMWindow.h" @@ -25,7 +26,8 @@ public: static already_AddRefed Constructor(const GlobalObject& aOwner, - nsIDOMMozActivityOptions* aOptions, + JSContext* aCx, + const ActivityOptions& aOptions, ErrorResult& aRv) { nsCOMPtr window = do_QueryInterface(aOwner.GetAsSupports()); @@ -35,7 +37,7 @@ public: } nsRefPtr activity = new Activity(window); - aRv = activity->Initialize(window, aOptions); + aRv = activity->Initialize(window, aCx, aOptions); return activity.forget(); } @@ -43,7 +45,8 @@ public: protected: nsresult Initialize(nsPIDOMWindow* aWindow, - nsIDOMMozActivityOptions* aOptions); + JSContext* aCx, + const ActivityOptions& aOptions); nsCOMPtr mProxy; diff --git a/dom/activities/src/ActivityOptions.js b/dom/activities/src/ActivityOptions.js deleted file mode 100644 index 6481266cb79..00000000000 --- a/dom/activities/src/ActivityOptions.js +++ /dev/null @@ -1,56 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -const Ci = Components.interfaces; -const Cu = Components.utils; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -function debug(aMsg) { - //dump("-- ActivityOptions.js " + Date.now() + " : " + aMsg + "\n"); -} - -/** - * nsIDOMMozActivityOptions implementation. - */ - -function ActivityOptions() { - debug("ActivityOptions"); - this.wrappedJSObject = this; - - // When a system message of type 'activity' is emitted, it forces the - // creation of an ActivityWrapper which in turns replace the default - // system message callback. The newly created wrapper then create a - // nsIDOMActivityRequestHandler object and fills up the properties of - // this object as well as the properties of the nsIDOMActivityOptions - // object contains by the request handler. - this._name = null; - this._data = null; -} - -ActivityOptions.prototype = { - get name() { - return this._name; - }, - - get data() { - return this._data; - }, - - classID: Components.ID("{ee983dbb-d5ea-4c5b-be98-10a13cac9f9d}"), - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozActivityOptions]), - - classInfo: XPCOMUtils.generateCI({ - classID: Components.ID("{ee983dbb-d5ea-4c5b-be98-10a13cac9f9d}"), - contractID: "@mozilla.org/dom/activities/options;1", - interfaces: [Ci.nsIDOMMozActivityOptions], - flags: Ci.nsIClassInfo.DOM_OBJECT, - classDescription: "Activity Options" - }) -} - -this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ActivityOptions]); diff --git a/dom/activities/src/ActivityRequestHandler.js b/dom/activities/src/ActivityRequestHandler.js index 08d081d314a..5608192a753 100644 --- a/dom/activities/src/ActivityRequestHandler.js +++ b/dom/activities/src/ActivityRequestHandler.js @@ -31,11 +31,10 @@ function ActivityRequestHandler() { // creation of an ActivityWrapper which in turns replace the default // system message callback. The newly created wrapper then create a // nsIDOMActivityRequestHandler object and fills up the properties of - // this object as well as the properties of the nsIDOMActivityOptions - // object contains by the request handler. + // this object as well as the properties of the ActivityOptions + // dictionary contained by the request handler. this._id = null; - this._options = Cc["@mozilla.org/dom/activities/options;1"] - .createInstance(Ci.nsIDOMMozActivityOptions); + this._options = {name: "", data: null}; } ActivityRequestHandler.prototype = { diff --git a/dom/activities/src/ActivityWrapper.js b/dom/activities/src/ActivityWrapper.js index fd4a7754af2..f3cf3101010 100644 --- a/dom/activities/src/ActivityWrapper.js +++ b/dom/activities/src/ActivityWrapper.js @@ -41,7 +41,7 @@ ActivityWrapper.prototype = { .createInstance(Ci.nsIDOMMozActivityRequestHandler); handler.wrappedJSObject._id = aMessage.id; - // options is an nsIDOMActivityOptions object. + // options is an ActivityOptions dictionary. var options = handler.wrappedJSObject._options; options.wrappedJSObject._name = aMessage.payload.name; options.wrappedJSObject._data = Cu.cloneInto(aMessage.payload.data, aWindow); diff --git a/dom/activities/src/moz.build b/dom/activities/src/moz.build index daefa8d379d..8ae35d08c6e 100644 --- a/dom/activities/src/moz.build +++ b/dom/activities/src/moz.build @@ -15,7 +15,6 @@ SOURCES += [ EXTRA_COMPONENTS += [ 'Activities.manifest', 'ActivityMessageConfigurator.js', - 'ActivityOptions.js', 'ActivityProxy.js', 'ActivityRequestHandler.js', 'ActivityWrapper.js', diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index ca9656d2a49..75e38a715f9 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1824,8 +1824,6 @@ def addExternalIface(iface, nativeType=None, headerFile=None, DOMInterfaces[iface] = domInterface addExternalIface('ApplicationCache', nativeType='nsIDOMOfflineResourceList') -addExternalIface('ActivityOptions', nativeType='nsIDOMMozActivityOptions', - headerFile='nsIDOMActivityOptions.h') addExternalIface('Counter') addExternalIface('CSSRule') addExternalIface('mozIDOMApplication', nativeType='mozIDOMApplication', headerFile='nsIDOMApplicationRegistry.h') diff --git a/dom/webidl/MozActivity.webidl b/dom/webidl/MozActivity.webidl index 512628593c5..d98eea40e43 100644 --- a/dom/webidl/MozActivity.webidl +++ b/dom/webidl/MozActivity.webidl @@ -4,9 +4,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -interface ActivityOptions; +dictionary ActivityOptions { + DOMString name = ""; + any data = null; +}; [Pref="dom.sysmsg.enabled", - Constructor(ActivityOptions options)] + Constructor(optional ActivityOptions options)] interface MozActivity : DOMRequest { }; From 6ae1c47e9fc12b8981af84bf7455da1db9c16777 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 18 Mar 2014 13:48:18 +0900 Subject: [PATCH 35/88] Bug 983049 part.1 Rename nsEventChainVisitor to mozilla::EventChainVisitor r=smaug --- content/base/public/Element.h | 5 ++- content/base/src/Element.cpp | 2 +- .../html/content/src/nsGenericHTMLElement.cpp | 3 +- .../html/content/src/nsGenericHTMLElement.h | 4 +- dom/events/nsEventDispatcher.h | 45 +++++++++++-------- 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/content/base/public/Element.h b/content/base/public/Element.h index f8f87563d75..ccca425e677 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -102,6 +102,7 @@ enum { ASSERT_NODE_FLAGS_SPACE(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET); namespace mozilla { +class EventChainVisitor; class EventListenerManager; namespace dom { @@ -1105,8 +1106,8 @@ protected: * @param aURI the uri of the link, set only if the return value is true [OUT] * @return true if we can handle the link event, false otherwise */ - bool CheckHandleEventForLinksPrecondition(nsEventChainVisitor& aVisitor, - nsIURI** aURI) const; + bool CheckHandleEventForLinksPrecondition(EventChainVisitor& aVisitor, + nsIURI** aURI) const; /** * Handle status bar updates before they can be cancelled. diff --git a/content/base/src/Element.cpp b/content/base/src/Element.cpp index fd1629c68fd..719cb13980f 100644 --- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -2317,7 +2317,7 @@ Element::Describe(nsAString& aOutDescription) const } bool -Element::CheckHandleEventForLinksPrecondition(nsEventChainVisitor& aVisitor, +Element::CheckHandleEventForLinksPrecondition(EventChainVisitor& aVisitor, nsIURI** aURI) const { if (aVisitor.mEventStatus == nsEventStatus_eConsumeNoDefault || diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index cf49bfd9740..79c8a01c144 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -695,7 +695,8 @@ nsGenericHTMLElement::FindAncestorForm(HTMLFormElement* aCurrentForm) } bool -nsGenericHTMLElement::CheckHandleEventForAnchorsPreconditions(nsEventChainVisitor& aVisitor) +nsGenericHTMLElement::CheckHandleEventForAnchorsPreconditions( + EventChainVisitor& aVisitor) { NS_PRECONDITION(nsCOMPtr(do_QueryObject(this)), "should be called only when |this| implements |Link|"); diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 78ab6401b89..e088c9a1a72 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -40,6 +40,7 @@ class nsIDOMHTMLCollection; class nsDOMSettableTokenList; namespace mozilla { +class EventChainVisitor; class EventListenerManager; namespace dom { class HTMLFormElement; @@ -588,7 +589,8 @@ public: * Check if an event for an anchor can be handled * @return true if the event can be handled, false otherwise */ - bool CheckHandleEventForAnchorsPreconditions(nsEventChainVisitor& aVisitor); + bool CheckHandleEventForAnchorsPreconditions( + mozilla::EventChainVisitor& aVisitor); nsresult PreHandleEventForAnchors(nsEventChainPreVisitor& aVisitor); nsresult PostHandleEventForAnchors(nsEventChainPostVisitor& aVisitor); bool IsHTMLLink(nsIURI** aURI) const; diff --git a/dom/events/nsEventDispatcher.h b/dom/events/nsEventDispatcher.h index 404769da6e6..6acbba074ac 100644 --- a/dom/events/nsEventDispatcher.h +++ b/dom/events/nsEventDispatcher.h @@ -23,8 +23,7 @@ template class nsCOMArray; namespace mozilla { namespace dom { class EventTarget; -} -} +} // namespace dom /** * About event dispatching: @@ -46,15 +45,20 @@ class EventTarget; * is called right after calling event listener for the current event target. */ -class nsEventChainVisitor { +class EventChainVisitor +{ public: - nsEventChainVisitor(nsPresContext* aPresContext, - mozilla::WidgetEvent* aEvent, - nsIDOMEvent* aDOMEvent, - nsEventStatus aEventStatus = nsEventStatus_eIgnore) - : mPresContext(aPresContext), mEvent(aEvent), mDOMEvent(aDOMEvent), - mEventStatus(aEventStatus), mItemFlags(0) - {} + EventChainVisitor(nsPresContext* aPresContext, + WidgetEvent* aEvent, + nsIDOMEvent* aDOMEvent, + nsEventStatus aEventStatus = nsEventStatus_eIgnore) + : mPresContext(aPresContext) + , mEvent(aEvent) + , mDOMEvent(aDOMEvent) + , mEventStatus(aEventStatus) + , mItemFlags(0) + { + } /** * The prescontext, possibly nullptr. @@ -64,7 +68,7 @@ public: /** * The WidgetEvent which is being dispatched. Never nullptr. */ - mozilla::WidgetEvent* const mEvent; + WidgetEvent* const mEvent; /** * The DOM Event assiciated with the mEvent. Possibly nullptr if a DOM Event @@ -101,14 +105,17 @@ public: nsCOMPtr mItemData; }; -class nsEventChainPreVisitor : public nsEventChainVisitor { +} // namespace mozilla + +class nsEventChainPreVisitor : public mozilla::EventChainVisitor +{ public: nsEventChainPreVisitor(nsPresContext* aPresContext, mozilla::WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent, nsEventStatus aEventStatus, bool aIsInAnon) - : nsEventChainVisitor(aPresContext, aEvent, aDOMEvent, aEventStatus), + : mozilla::EventChainVisitor(aPresContext, aEvent, aDOMEvent, aEventStatus), mCanHandle(true), mAutomaticChromeDispatch(true), mForceContentDispatch(false), mRelatedTargetIsInAnon(false), mOriginalTargetIsInAnon(aIsInAnon), mWantsWillHandleEvent(false), @@ -184,12 +191,14 @@ public: mozilla::dom::EventTarget* mEventTargetAtParent; }; -class nsEventChainPostVisitor : public nsEventChainVisitor { +class nsEventChainPostVisitor : public mozilla::EventChainVisitor +{ public: - nsEventChainPostVisitor(nsEventChainVisitor& aOther) - : nsEventChainVisitor(aOther.mPresContext, aOther.mEvent, aOther.mDOMEvent, - aOther.mEventStatus) - {} + nsEventChainPostVisitor(mozilla::EventChainVisitor& aOther) + : mozilla::EventChainVisitor(aOther.mPresContext, aOther.mEvent, + aOther.mDOMEvent, aOther.mEventStatus) + { + } }; /** From 84f7d80b11801d1854e62dd9f6e9c264c2d254f6 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 18 Mar 2014 13:48:19 +0900 Subject: [PATCH 36/88] Bug 983049 part.2 Rename nsEventChainPreVisitor to mozilla::EventChainPreVisitor r=smaug --- content/base/public/Element.h | 3 +- content/base/public/nsIContent.h | 4 +- content/base/src/Attr.cpp | 2 +- content/base/src/Attr.h | 3 +- content/base/src/Element.cpp | 2 +- content/base/src/FragmentOrElement.cpp | 2 +- content/base/src/nsDocument.cpp | 2 +- content/base/src/nsDocument.h | 4 +- content/base/src/nsGenConImageContent.cpp | 4 +- content/base/src/nsINode.cpp | 2 +- .../base/src/nsInProcessTabChildGlobal.cpp | 7 +-- content/base/src/nsInProcessTabChildGlobal.h | 7 ++- .../html/content/src/HTMLAnchorElement.cpp | 3 +- content/html/content/src/HTMLAnchorElement.h | 3 +- content/html/content/src/HTMLAreaElement.cpp | 3 +- content/html/content/src/HTMLAreaElement.h | 3 +- .../html/content/src/HTMLButtonElement.cpp | 2 +- content/html/content/src/HTMLButtonElement.h | 3 +- .../html/content/src/HTMLFieldSetElement.cpp | 2 +- .../html/content/src/HTMLFieldSetElement.h | 3 +- content/html/content/src/HTMLFormElement.cpp | 2 +- content/html/content/src/HTMLFormElement.h | 3 +- content/html/content/src/HTMLImageElement.cpp | 2 +- content/html/content/src/HTMLImageElement.h | 3 +- content/html/content/src/HTMLInputElement.cpp | 5 ++- content/html/content/src/HTMLInputElement.h | 7 ++- content/html/content/src/HTMLLinkElement.cpp | 3 +- content/html/content/src/HTMLLinkElement.h | 3 +- .../html/content/src/HTMLMenuItemElement.cpp | 2 +- .../html/content/src/HTMLMenuItemElement.h | 5 ++- .../html/content/src/HTMLOptGroupElement.cpp | 2 +- .../html/content/src/HTMLOptGroupElement.h | 3 +- .../html/content/src/HTMLSelectElement.cpp | 2 +- content/html/content/src/HTMLSelectElement.h | 5 ++- .../html/content/src/HTMLTextAreaElement.cpp | 2 +- .../html/content/src/HTMLTextAreaElement.h | 5 ++- .../html/content/src/nsGenericHTMLElement.cpp | 4 +- .../html/content/src/nsGenericHTMLElement.h | 6 ++- .../mathml/content/src/nsMathMLElement.cpp | 3 +- content/mathml/content/src/nsMathMLElement.h | 7 ++- content/svg/content/src/SVGAElement.cpp | 3 +- content/svg/content/src/SVGAElement.h | 5 ++- content/svg/content/src/SVGSVGElement.cpp | 2 +- content/svg/content/src/SVGSVGElement.h | 7 +-- content/xul/content/src/nsXULElement.cpp | 2 +- content/xul/content/src/nsXULElement.h | 4 +- dom/base/nsGlobalWindow.cpp | 2 +- dom/base/nsWindowRoot.cpp | 2 +- dom/base/nsWindowRoot.h | 5 ++- dom/devicestorage/nsDeviceStorage.cpp | 3 +- dom/events/nsDOMEventTargetHelper.cpp | 2 +- dom/events/nsEventDispatcher.cpp | 8 ++-- dom/events/nsEventDispatcher.h | 43 +++++++++++-------- dom/file/ArchiveRequest.cpp | 4 +- dom/file/ArchiveRequest.h | 5 ++- dom/file/FileRequest.cpp | 4 +- dom/file/FileRequest.h | 6 ++- dom/file/LockedFile.cpp | 2 +- dom/file/LockedFile.h | 6 ++- dom/indexedDB/IDBRequest.cpp | 2 +- dom/indexedDB/IDBRequest.h | 3 +- dom/indexedDB/IDBTransaction.cpp | 3 +- dom/indexedDB/IDBTransaction.h | 6 ++- dom/interfaces/events/nsIDOMEventTarget.idl | 10 ++--- dom/ipc/TabChild.h | 2 +- dom/workers/MessagePort.cpp | 3 +- dom/workers/MessagePort.h | 6 ++- dom/workers/SharedWorker.cpp | 3 +- dom/workers/SharedWorker.h | 6 ++- widget/BasicEvents.h | 2 +- 70 files changed, 197 insertions(+), 102 deletions(-) diff --git a/content/base/public/Element.h b/content/base/public/Element.h index ccca425e677..ecb3f209fca 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -102,6 +102,7 @@ enum { ASSERT_NODE_FLAGS_SPACE(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET); namespace mozilla { +class EventChainPreVisitor; class EventChainVisitor; class EventListenerManager; @@ -1112,7 +1113,7 @@ protected: /** * Handle status bar updates before they can be cancelled. */ - nsresult PreHandleEventForLinks(nsEventChainPreVisitor& aVisitor); + nsresult PreHandleEventForLinks(EventChainPreVisitor& aVisitor); /** * Handle default actions for link event if the event isn't consumed yet. diff --git a/content/base/public/nsIContent.h b/content/base/public/nsIContent.h index fd3083352fd..4dafe03cbfe 100644 --- a/content/base/public/nsIContent.h +++ b/content/base/public/nsIContent.h @@ -21,6 +21,7 @@ class nsIFrame; class nsXBLBinding; namespace mozilla { +class EventChainPreVisitor; namespace dom { class ShadowRoot; struct CustomElementData; @@ -913,7 +914,8 @@ public: // Overloaded from nsINode virtual already_AddRefed GetBaseURI() const MOZ_OVERRIDE; - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent( + mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual bool IsPurple() = 0; virtual void RemovePurple() = 0; diff --git a/content/base/src/Attr.cpp b/content/base/src/Attr.cpp index 1ef15e6ae36..66ddee80656 100644 --- a/content/base/src/Attr.cpp +++ b/content/base/src/Attr.cpp @@ -361,7 +361,7 @@ Attr::RemoveChildAt(uint32_t aIndex, bool aNotify) } nsresult -Attr::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +Attr::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = true; return NS_OK; diff --git a/content/base/src/Attr.h b/content/base/src/Attr.h index f5ede10808e..613ed4b2f19 100644 --- a/content/base/src/Attr.h +++ b/content/base/src/Attr.h @@ -23,6 +23,7 @@ #include "nsIDocument.h" namespace mozilla { +class EventChainPreVisitor; namespace dom { // Attribute helper class used to wrap up an attribute with a dom @@ -51,7 +52,7 @@ public: // nsIDOMAttr interface NS_DECL_NSIDOMATTR - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; // nsIAttribute interface void SetMap(nsDOMAttributeMap *aMap) MOZ_OVERRIDE; diff --git a/content/base/src/Element.cpp b/content/base/src/Element.cpp index 719cb13980f..4cae657d60a 100644 --- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -2335,7 +2335,7 @@ Element::CheckHandleEventForLinksPrecondition(EventChainVisitor& aVisitor, } nsresult -Element::PreHandleEventForLinks(nsEventChainPreVisitor& aVisitor) +Element::PreHandleEventForLinks(EventChainPreVisitor& aVisitor) { // Optimisation: return early if this event doesn't interest us. // IMPORTANT: this switch and the switch below it must be kept in sync! diff --git a/content/base/src/FragmentOrElement.cpp b/content/base/src/FragmentOrElement.cpp index 6de3527299a..61f04d70b3d 100644 --- a/content/base/src/FragmentOrElement.cpp +++ b/content/base/src/FragmentOrElement.cpp @@ -703,7 +703,7 @@ FindChromeAccessOnlySubtreeOwner(nsIContent* aContent) } nsresult -nsIContent::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +nsIContent::PreHandleEvent(EventChainPreVisitor& aVisitor) { //FIXME! Document how this event retargeting works, Bug 329124. aVisitor.mCanHandle = true; diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 7790ec078ba..6b21fddae49 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -7636,7 +7636,7 @@ nsDocument::GetExistingListenerManager() const } nsresult -nsDocument::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +nsDocument::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = true; // FIXME! This is a hack to make middle mouse paste working also in Editor. diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 808d325508b..2dcb0624bfd 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -98,6 +98,7 @@ class nsPointerLockPermissionRequest; class nsISecurityConsoleMessage; namespace mozilla { +class EventChainPreVisitor; namespace dom { class UndoManager; class LifecycleCallbacks; @@ -902,7 +903,8 @@ public: NS_DECL_NSIDOMDOCUMENTXBL // nsIDOMEventTarget - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent( + mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual mozilla::EventListenerManager* GetOrCreateListenerManager() MOZ_OVERRIDE; virtual mozilla::EventListenerManager* diff --git a/content/base/src/nsGenConImageContent.cpp b/content/base/src/nsGenConImageContent.cpp index 6ff14f90341..f1ffd92613e 100644 --- a/content/base/src/nsGenConImageContent.cpp +++ b/content/base/src/nsGenConImageContent.cpp @@ -18,6 +18,8 @@ #include "nsEventDispatcher.h" #include "mozilla/BasicEvents.h" +using namespace mozilla; + class nsGenConImageContent MOZ_FINAL : public nsXMLElement, public nsImageLoadingContent { @@ -43,7 +45,7 @@ public: virtual void UnbindFromTree(bool aDeep, bool aNullParent); virtual nsEventStates IntrinsicState() const; - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) { MOZ_ASSERT(IsInNativeAnonymousSubtree()); if (aVisitor.mEvent->message == NS_LOAD || diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index 0bd34c326d7..bdf8055cf91 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -1133,7 +1133,7 @@ nsINode::RemoveEventListener(const nsAString& aType, NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsINode) nsresult -nsINode::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +nsINode::PreHandleEvent(EventChainPreVisitor& aVisitor) { // This is only here so that we can use the NS_DECL_NSIDOMTARGET macro NS_ABORT(); diff --git a/content/base/src/nsInProcessTabChildGlobal.cpp b/content/base/src/nsInProcessTabChildGlobal.cpp index 9abd3e1abd8..05b175531bb 100644 --- a/content/base/src/nsInProcessTabChildGlobal.cpp +++ b/content/base/src/nsInProcessTabChildGlobal.cpp @@ -24,11 +24,12 @@ using mozilla::dom::StructuredCloneData; using mozilla::dom::StructuredCloneClosure; +using namespace mozilla; bool nsInProcessTabChildGlobal::DoSendBlockingMessage(JSContext* aCx, const nsAString& aMessage, - const mozilla::dom::StructuredCloneData& aData, + const dom::StructuredCloneData& aData, JS::Handle aCpows, nsIPrincipal* aPrincipal, InfallibleTArray* aJSONRetVal, @@ -138,7 +139,7 @@ nsInProcessTabChildGlobal::Init() "Couldn't initialize nsInProcessTabChildGlobal"); mMessageManager = new nsFrameMessageManager(this, nullptr, - mozilla::dom::ipc::MM_CHILD); + dom::ipc::MM_CHILD); return NS_OK; } @@ -249,7 +250,7 @@ nsInProcessTabChildGlobal::GetOwnerContent() } nsresult -nsInProcessTabChildGlobal::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +nsInProcessTabChildGlobal::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = true; diff --git a/content/base/src/nsInProcessTabChildGlobal.h b/content/base/src/nsInProcessTabChildGlobal.h index 102168af617..96121b905e3 100644 --- a/content/base/src/nsInProcessTabChildGlobal.h +++ b/content/base/src/nsInProcessTabChildGlobal.h @@ -23,6 +23,10 @@ #include "nsIScriptObjectPrincipal.h" #include "nsWeakReference.h" +namespace mozilla { +class EventChainPreVisitor; +} // namespace mozilla + class nsInProcessTabChildGlobal : public nsDOMEventTargetHelper, public nsFrameScriptExecutor, public nsIInProcessContentFrameMessageManager, @@ -96,7 +100,8 @@ public: JS::Handle aCpows, nsIPrincipal* aPrincipal) MOZ_OVERRIDE; - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent( + mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; NS_IMETHOD AddEventListener(const nsAString& aType, nsIDOMEventListener* aListener, bool aUseCapture) diff --git a/content/html/content/src/HTMLAnchorElement.cpp b/content/html/content/src/HTMLAnchorElement.cpp index e9b9528f5cd..3dd9920ea1d 100644 --- a/content/html/content/src/HTMLAnchorElement.cpp +++ b/content/html/content/src/HTMLAnchorElement.cpp @@ -10,6 +10,7 @@ #include "mozilla/MemoryReporting.h" #include "nsCOMPtr.h" #include "nsContentUtils.h" +#include "nsEventDispatcher.h" #include "nsGkAtoms.h" #include "nsHTMLDNSPrefetch.h" #include "nsIDocument.h" @@ -244,7 +245,7 @@ HTMLAnchorElement::IsHTMLFocusable(bool aWithMouse, } nsresult -HTMLAnchorElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +HTMLAnchorElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { return PreHandleEventForAnchors(aVisitor); } diff --git a/content/html/content/src/HTMLAnchorElement.h b/content/html/content/src/HTMLAnchorElement.h index 8c7e4584977..f0aae4c6435 100644 --- a/content/html/content/src/HTMLAnchorElement.h +++ b/content/html/content/src/HTMLAnchorElement.h @@ -14,6 +14,7 @@ #include "nsDOMTokenList.h" namespace mozilla { +class EventChainPreVisitor; namespace dom { class HTMLAnchorElement MOZ_FINAL : public nsGenericHTMLElement, @@ -54,7 +55,7 @@ public: bool aNullParent = true) MOZ_OVERRIDE; virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) MOZ_OVERRIDE; - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual bool IsLink(nsIURI** aURI) const MOZ_OVERRIDE; virtual void GetLinkTarget(nsAString& aTarget) MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLAreaElement.cpp b/content/html/content/src/HTMLAreaElement.cpp index 38f7d80f600..0e70ffdd55a 100644 --- a/content/html/content/src/HTMLAreaElement.cpp +++ b/content/html/content/src/HTMLAreaElement.cpp @@ -9,6 +9,7 @@ #include "mozilla/Attributes.h" #include "mozilla/dom/HTMLAreaElementBinding.h" #include "mozilla/MemoryReporting.h" +#include "nsEventDispatcher.h" NS_IMPL_NS_NEW_HTML_ELEMENT(Area) @@ -92,7 +93,7 @@ HTMLAreaElement::SetTarget(const nsAString& aValue) } nsresult -HTMLAreaElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +HTMLAreaElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { return PreHandleEventForAnchors(aVisitor); } diff --git a/content/html/content/src/HTMLAreaElement.h b/content/html/content/src/HTMLAreaElement.h index 571645cd7f2..8762e9c075b 100644 --- a/content/html/content/src/HTMLAreaElement.h +++ b/content/html/content/src/HTMLAreaElement.h @@ -18,6 +18,7 @@ class nsIDocument; namespace mozilla { +class EventChainPreVisitor; namespace dom { class HTMLAreaElement MOZ_FINAL : public nsGenericHTMLElement, @@ -43,7 +44,7 @@ public: // nsIDOMHTMLAreaElement NS_DECL_NSIDOMHTMLAREAELEMENT - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual bool IsLink(nsIURI** aURI) const MOZ_OVERRIDE; virtual void GetLinkTarget(nsAString& aTarget) MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLButtonElement.cpp b/content/html/content/src/HTMLButtonElement.cpp index c15a4ed67cd..bd891ffb154 100644 --- a/content/html/content/src/HTMLButtonElement.cpp +++ b/content/html/content/src/HTMLButtonElement.cpp @@ -187,7 +187,7 @@ HTMLButtonElement::IsDisabledForEvents(uint32_t aMessage) } nsresult -HTMLButtonElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +HTMLButtonElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = false; if (IsDisabledForEvents(aVisitor.mEvent->message)) { diff --git a/content/html/content/src/HTMLButtonElement.h b/content/html/content/src/HTMLButtonElement.h index c8b56b82d74..70905d057b7 100644 --- a/content/html/content/src/HTMLButtonElement.h +++ b/content/html/content/src/HTMLButtonElement.h @@ -12,6 +12,7 @@ #include "nsIConstraintValidation.h" namespace mozilla { +class EventChainPreVisitor; namespace dom { class HTMLButtonElement MOZ_FINAL : public nsGenericHTMLFormElementWithState, @@ -47,7 +48,7 @@ public: virtual bool IsDisabledForEvents(uint32_t aMessage) MOZ_OVERRIDE; // nsIDOMEventTarget - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; // nsINode diff --git a/content/html/content/src/HTMLFieldSetElement.cpp b/content/html/content/src/HTMLFieldSetElement.cpp index 65c0235a54f..43d771c3012 100644 --- a/content/html/content/src/HTMLFieldSetElement.cpp +++ b/content/html/content/src/HTMLFieldSetElement.cpp @@ -67,7 +67,7 @@ HTMLFieldSetElement::IsDisabledForEvents(uint32_t aMessage) // nsIContent nsresult -HTMLFieldSetElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +HTMLFieldSetElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { // Do not process any DOM events if the element is disabled. aVisitor.mCanHandle = false; diff --git a/content/html/content/src/HTMLFieldSetElement.h b/content/html/content/src/HTMLFieldSetElement.h index 8e5041fb665..a23d84f297f 100644 --- a/content/html/content/src/HTMLFieldSetElement.h +++ b/content/html/content/src/HTMLFieldSetElement.h @@ -14,6 +14,7 @@ #include "mozilla/dom/ValidityState.h" namespace mozilla { +class EventChainPreVisitor; namespace dom { class HTMLFieldSetElement MOZ_FINAL : public nsGenericHTMLFormElement, @@ -38,7 +39,7 @@ public: NS_DECL_NSIDOMHTMLFIELDSETELEMENT // nsIContent - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, bool aNotify) MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLFormElement.cpp b/content/html/content/src/HTMLFormElement.cpp index f0c29d60a93..aed85324b40 100644 --- a/content/html/content/src/HTMLFormElement.cpp +++ b/content/html/content/src/HTMLFormElement.cpp @@ -482,7 +482,7 @@ HTMLFormElement::UnbindFromTree(bool aDeep, bool aNullParent) } nsresult -HTMLFormElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +HTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mWantsWillHandleEvent = true; if (aVisitor.mEvent->originalTarget == static_cast(this)) { diff --git a/content/html/content/src/HTMLFormElement.h b/content/html/content/src/HTMLFormElement.h index f7bb164832b..32604155cd5 100644 --- a/content/html/content/src/HTMLFormElement.h +++ b/content/html/content/src/HTMLFormElement.h @@ -27,6 +27,7 @@ class nsIMutableArray; class nsIURI; namespace mozilla { +class EventChainPreVisitor; namespace dom { class HTMLFormControlsCollection; class HTMLImageElement; @@ -89,7 +90,7 @@ public: nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult) MOZ_OVERRIDE; - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult WillHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLImageElement.cpp b/content/html/content/src/HTMLImageElement.cpp index 54d272cb50b..2d35cd21bb3 100644 --- a/content/html/content/src/HTMLImageElement.cpp +++ b/content/html/content/src/HTMLImageElement.cpp @@ -341,7 +341,7 @@ HTMLImageElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsresult -HTMLImageElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +HTMLImageElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { // If we are a map and get a mouse click, don't let it be handled by // the Generic Element as this could cause a click event to fire diff --git a/content/html/content/src/HTMLImageElement.h b/content/html/content/src/HTMLImageElement.h index b25c1573fcf..9ee67288c52 100644 --- a/content/html/content/src/HTMLImageElement.h +++ b/content/html/content/src/HTMLImageElement.h @@ -14,6 +14,7 @@ #include "Units.h" namespace mozilla { +class EventChainPreVisitor; namespace dom { class HTMLImageElement MOZ_FINAL : public nsGenericHTMLElement, @@ -51,7 +52,7 @@ public: NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const MOZ_OVERRIDE; - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLInputElement.cpp b/content/html/content/src/HTMLInputElement.cpp index a86d51c9228..e78bc8f7a6d 100644 --- a/content/html/content/src/HTMLInputElement.cpp +++ b/content/html/content/src/HTMLInputElement.cpp @@ -3222,7 +3222,8 @@ HTMLInputElement::SelectAll(nsPresContext* aPresContext) } bool -HTMLInputElement::NeedToInitializeEditorForEvent(nsEventChainPreVisitor& aVisitor) const +HTMLInputElement::NeedToInitializeEditorForEvent( + EventChainPreVisitor& aVisitor) const { // We only need to initialize the editor for single line input controls because they // are lazily initialized. We don't need to initialize the control for @@ -3253,7 +3254,7 @@ HTMLInputElement::IsDisabledForEvents(uint32_t aMessage) } nsresult -HTMLInputElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { // Do not process any DOM events if the element is disabled aVisitor.mCanHandle = false; diff --git a/content/html/content/src/HTMLInputElement.h b/content/html/content/src/HTMLInputElement.h index 39ffc039f5a..d39151a5fa0 100644 --- a/content/html/content/src/HTMLInputElement.h +++ b/content/html/content/src/HTMLInputElement.h @@ -29,6 +29,9 @@ class nsIRadioVisitor; class nsTextEditorState; namespace mozilla { + +class EventChainPreVisitor; + namespace dom { class Date; @@ -148,7 +151,7 @@ public: NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const MOZ_OVERRIDE; - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; void PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor); void StartRangeThumbDrag(WidgetGUIEvent* aEvent); @@ -891,7 +894,7 @@ protected: * Determine whether the editor needs to be initialized explicitly for * a particular event. */ - bool NeedToInitializeEditorForEvent(nsEventChainPreVisitor& aVisitor) const; + bool NeedToInitializeEditorForEvent(EventChainPreVisitor& aVisitor) const; /** * Get the value mode of the element, depending of the type. diff --git a/content/html/content/src/HTMLLinkElement.cpp b/content/html/content/src/HTMLLinkElement.cpp index 335ce3b8166..2208cc6b19f 100644 --- a/content/html/content/src/HTMLLinkElement.cpp +++ b/content/html/content/src/HTMLLinkElement.cpp @@ -11,6 +11,7 @@ #include "mozilla/dom/HTMLLinkElementBinding.h" #include "mozilla/MemoryReporting.h" #include "nsContentUtils.h" +#include "nsEventDispatcher.h" #include "nsGenericHTMLElement.h" #include "nsGkAtoms.h" #include "nsDOMTokenList.h" @@ -302,7 +303,7 @@ HTMLLinkElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, } nsresult -HTMLLinkElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +HTMLLinkElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { return PreHandleEventForAnchors(aVisitor); } diff --git a/content/html/content/src/HTMLLinkElement.h b/content/html/content/src/HTMLLinkElement.h index d17267ef8b9..715f11167e7 100644 --- a/content/html/content/src/HTMLLinkElement.h +++ b/content/html/content/src/HTMLLinkElement.h @@ -13,6 +13,7 @@ #include "nsStyleLinkElement.h" namespace mozilla { +class EventChainPreVisitor; namespace dom { class HTMLLinkElement MOZ_FINAL : public nsGenericHTMLElement, @@ -41,7 +42,7 @@ public: void LinkRemoved(); // nsIDOMEventTarget - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; // nsINode diff --git a/content/html/content/src/HTMLMenuItemElement.cpp b/content/html/content/src/HTMLMenuItemElement.cpp index 5fe3fa2c680..25fd842c9c3 100644 --- a/content/html/content/src/HTMLMenuItemElement.cpp +++ b/content/html/content/src/HTMLMenuItemElement.cpp @@ -251,7 +251,7 @@ HTMLMenuItemElement::SetChecked(bool aChecked) } nsresult -HTMLMenuItemElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +HTMLMenuItemElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { if (aVisitor.mEvent->message == NS_MOUSE_CLICK) { diff --git a/content/html/content/src/HTMLMenuItemElement.h b/content/html/content/src/HTMLMenuItemElement.h index 0dc25b30f14..a583501b283 100644 --- a/content/html/content/src/HTMLMenuItemElement.h +++ b/content/html/content/src/HTMLMenuItemElement.h @@ -11,6 +11,9 @@ #include "nsGenericHTMLElement.h" namespace mozilla { + +class EventChainPreVisitor; + namespace dom { class Visitor; @@ -33,7 +36,7 @@ public: // nsIDOMHTMLMenuItemElement NS_DECL_NSIDOMHTMLMENUITEMELEMENT - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, diff --git a/content/html/content/src/HTMLOptGroupElement.cpp b/content/html/content/src/HTMLOptGroupElement.cpp index 06fff0d9877..0d72445ef09 100644 --- a/content/html/content/src/HTMLOptGroupElement.cpp +++ b/content/html/content/src/HTMLOptGroupElement.cpp @@ -48,7 +48,7 @@ NS_IMPL_STRING_ATTR(HTMLOptGroupElement, Label, label) nsresult -HTMLOptGroupElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +HTMLOptGroupElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = false; // Do not process any DOM events if the element is disabled diff --git a/content/html/content/src/HTMLOptGroupElement.h b/content/html/content/src/HTMLOptGroupElement.h index f0cba097dfc..0d969d1fac5 100644 --- a/content/html/content/src/HTMLOptGroupElement.h +++ b/content/html/content/src/HTMLOptGroupElement.h @@ -11,6 +11,7 @@ #include "nsGenericHTMLElement.h" namespace mozilla { +class EventChainPreVisitor; namespace dom { class HTMLOptGroupElement MOZ_FINAL : public nsGenericHTMLElement, @@ -34,7 +35,7 @@ public: virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE; // nsIContent - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLSelectElement.cpp b/content/html/content/src/HTMLSelectElement.cpp index 4e40c91dc9e..3f14516f9a8 100644 --- a/content/html/content/src/HTMLSelectElement.cpp +++ b/content/html/content/src/HTMLSelectElement.cpp @@ -1478,7 +1478,7 @@ HTMLSelectElement::IsDisabledForEvents(uint32_t aMessage) } nsresult -HTMLSelectElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +HTMLSelectElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = false; if (IsDisabledForEvents(aVisitor.mEvent->message)) { diff --git a/content/html/content/src/HTMLSelectElement.h b/content/html/content/src/HTMLSelectElement.h index 4c1c900aa83..c74facf766b 100644 --- a/content/html/content/src/HTMLSelectElement.h +++ b/content/html/content/src/HTMLSelectElement.h @@ -25,6 +25,9 @@ class nsISelectControlFrame; class nsPresState; namespace mozilla { + +class EventChainPreVisitor; + namespace dom { class HTMLSelectElement; @@ -259,7 +262,7 @@ public: JS::Handle aScope) MOZ_OVERRIDE; // nsIContent - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, int32_t* aTabIndex) MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLTextAreaElement.cpp b/content/html/content/src/HTMLTextAreaElement.cpp index 2c7cd1dad61..2d216331439 100644 --- a/content/html/content/src/HTMLTextAreaElement.cpp +++ b/content/html/content/src/HTMLTextAreaElement.cpp @@ -454,7 +454,7 @@ HTMLTextAreaElement::IsDisabledForEvents(uint32_t aMessage) } nsresult -HTMLTextAreaElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +HTMLTextAreaElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = false; if (IsDisabledForEvents(aVisitor.mEvent->message)) { diff --git a/content/html/content/src/HTMLTextAreaElement.h b/content/html/content/src/HTMLTextAreaElement.h index 4e1cdefaf0b..2c3c9c0c0c8 100644 --- a/content/html/content/src/HTMLTextAreaElement.h +++ b/content/html/content/src/HTMLTextAreaElement.h @@ -29,6 +29,9 @@ class nsPresContext; class nsPresState; namespace mozilla { + +class EventChainPreVisitor; + namespace dom { class HTMLTextAreaElement MOZ_FINAL : public nsGenericHTMLFormElementWithState, @@ -113,7 +116,7 @@ public: int32_t aModType) const MOZ_OVERRIDE; NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE; - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) MOZ_OVERRIDE; diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 79c8a01c144..1b2ec428b54 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -718,7 +718,7 @@ nsGenericHTMLElement::CheckHandleEventForAnchorsPreconditions( } nsresult -nsGenericHTMLElement::PreHandleEventForAnchors(nsEventChainPreVisitor& aVisitor) +nsGenericHTMLElement::PreHandleEventForAnchors(EventChainPreVisitor& aVisitor) { nsresult rv = nsGenericHTMLElementBase::PreHandleEvent(aVisitor); NS_ENSURE_SUCCESS(rv, rv); @@ -2285,7 +2285,7 @@ nsGenericHTMLFormElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, } nsresult -nsGenericHTMLFormElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +nsGenericHTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { if (aVisitor.mEvent->mFlags.mIsTrusted) { switch (aVisitor.mEvent->message) { diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index e088c9a1a72..4ad2459cc95 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -40,6 +40,7 @@ class nsIDOMHTMLCollection; class nsDOMSettableTokenList; namespace mozilla { +class EventChainPreVisitor; class EventChainVisitor; class EventListenerManager; namespace dom { @@ -591,7 +592,7 @@ public: */ bool CheckHandleEventForAnchorsPreconditions( mozilla::EventChainVisitor& aVisitor); - nsresult PreHandleEventForAnchors(nsEventChainPreVisitor& aVisitor); + nsresult PreHandleEventForAnchors(mozilla::EventChainPreVisitor& aVisitor); nsresult PostHandleEventForAnchors(nsEventChainPostVisitor& aVisitor); bool IsHTMLLink(nsIURI** aURI) const; @@ -1328,7 +1329,8 @@ public: virtual IMEState GetDesiredIMEState() MOZ_OVERRIDE; virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE; - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent( + mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual bool IsDisabled() const MOZ_OVERRIDE; diff --git a/content/mathml/content/src/nsMathMLElement.cpp b/content/mathml/content/src/nsMathMLElement.cpp index afeb36dbb8d..15c77cde0d2 100644 --- a/content/mathml/content/src/nsMathMLElement.cpp +++ b/content/mathml/content/src/nsMathMLElement.cpp @@ -21,6 +21,7 @@ #include "nsIScriptError.h" #include "nsContentUtils.h" #include "nsIURI.h" +#include "nsEventDispatcher.h" #include "mozilla/dom/ElementBinding.h" @@ -897,7 +898,7 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes, } nsresult -nsMathMLElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +nsMathMLElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { nsresult rv = Element::PreHandleEvent(aVisitor); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/mathml/content/src/nsMathMLElement.h b/content/mathml/content/src/nsMathMLElement.h index 3cb582944c4..18c0cea54e6 100644 --- a/content/mathml/content/src/nsMathMLElement.h +++ b/content/mathml/content/src/nsMathMLElement.h @@ -17,6 +17,10 @@ class nsCSSValue; typedef nsMappedAttributeElement nsMathMLElementBase; +namespace mozilla { +class EventChainPreVisitor; +} // namespace mozilla + /* * The base class for MathML elements. */ @@ -68,7 +72,8 @@ public: static void MapMathMLAttributesInto(const nsMappedAttributes* aAttributes, nsRuleData* aRuleData); - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent( + mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; nsresult Clone(nsINodeInfo*, nsINode**) const MOZ_OVERRIDE; virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE; diff --git a/content/svg/content/src/SVGAElement.cpp b/content/svg/content/src/SVGAElement.cpp index 69d7a6766d9..153ebb540a0 100644 --- a/content/svg/content/src/SVGAElement.cpp +++ b/content/svg/content/src/SVGAElement.cpp @@ -9,6 +9,7 @@ #include "mozilla/dom/SVGAElementBinding.h" #include "nsCOMPtr.h" #include "nsContentUtils.h" +#include "nsEventDispatcher.h" #include "nsGkAtoms.h" #include "nsSVGString.h" #include "nsIURI.h" @@ -76,7 +77,7 @@ SVGAElement::Href() // nsINode methods nsresult -SVGAElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +SVGAElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { nsresult rv = Element::PreHandleEvent(aVisitor); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/svg/content/src/SVGAElement.h b/content/svg/content/src/SVGAElement.h index 46f10d9c3ad..fbeeffba49a 100644 --- a/content/svg/content/src/SVGAElement.h +++ b/content/svg/content/src/SVGAElement.h @@ -14,6 +14,9 @@ nsresult NS_NewSVGAElement(nsIContent **aResult, already_AddRefed&& aNodeInfo); namespace mozilla { + +class EventChainPreVisitor; + namespace dom { typedef SVGGraphicsElement SVGAElementBase; @@ -33,7 +36,7 @@ public: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGAElement, SVGAElementBase) // nsINode interface methods - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; diff --git a/content/svg/content/src/SVGSVGElement.cpp b/content/svg/content/src/SVGSVGElement.cpp index b371f557b77..8d0d4cec995 100644 --- a/content/svg/content/src/SVGSVGElement.cpp +++ b/content/svg/content/src/SVGSVGElement.cpp @@ -589,7 +589,7 @@ SVGSVGElement::IsAttributeMapped(const nsIAtom* name) const // nsIContent methods: nsresult -SVGSVGElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +SVGSVGElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { if (aVisitor.mEvent->message == NS_SVG_LOAD) { if (mTimedDocumentRoot) { diff --git a/content/svg/content/src/SVGSVGElement.h b/content/svg/content/src/SVGSVGElement.h index 12bb477f46c..a872d540bb9 100644 --- a/content/svg/content/src/SVGSVGElement.h +++ b/content/svg/content/src/SVGSVGElement.h @@ -28,9 +28,10 @@ class nsSVGInnerSVGFrame; class nsSVGImageFrame; namespace mozilla { -class DOMSVGAnimatedPreserveAspectRatio; -class SVGFragmentIdentifier; class AutoSVGRenderingState; +class DOMSVGAnimatedPreserveAspectRatio; +class EventChainPreVisitor; +class SVGFragmentIdentifier; namespace dom { class SVGAngle; @@ -127,7 +128,7 @@ public: // nsIContent interface NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE; - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual bool IsEventAttributeName(nsIAtom* aName) MOZ_OVERRIDE; diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index ffad5e1409d..072a4e42873 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -1139,7 +1139,7 @@ nsXULElement::List(FILE* out, int32_t aIndent) const #endif nsresult -nsXULElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +nsXULElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mForceContentDispatch = true; //FIXME! Bug 329119 nsIAtom* tag = Tag(); diff --git a/content/xul/content/src/nsXULElement.h b/content/xul/content/src/nsXULElement.h index 2b9cffcf3de..49b9aa3de1c 100644 --- a/content/xul/content/src/nsXULElement.h +++ b/content/xul/content/src/nsXULElement.h @@ -49,6 +49,7 @@ class nsXULPrototypeNode; typedef nsTArray > nsPrototypeArray; namespace mozilla { +class EventChainPreVisitor; class EventListenerManager; namespace css { class StyleRule; @@ -374,7 +375,8 @@ public: mozilla::dom::Element) // nsINode - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor); + virtual nsresult PreHandleEvent( + mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; // nsIContent virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 3b815ccd445..bc1819f4648 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -2963,7 +2963,7 @@ nsGlobalWindow::GetJSContextForEventHandlers() } nsresult -nsGlobalWindow::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +nsGlobalWindow::PreHandleEvent(EventChainPreVisitor& aVisitor) { NS_PRECONDITION(IsInnerWindow(), "PreHandleEvent is used on outer window!?"); static uint32_t count = 0; diff --git a/dom/base/nsWindowRoot.cpp b/dom/base/nsWindowRoot.cpp index a9fca71efe5..7cef4567d4f 100644 --- a/dom/base/nsWindowRoot.cpp +++ b/dom/base/nsWindowRoot.cpp @@ -168,7 +168,7 @@ nsWindowRoot::GetContextForEventHandlers(nsresult* aRv) } nsresult -nsWindowRoot::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +nsWindowRoot::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = true; aVisitor.mForceContentDispatch = true; //FIXME! Bug 329119 diff --git a/dom/base/nsWindowRoot.h b/dom/base/nsWindowRoot.h index e65293cbe5d..0cb645005e4 100644 --- a/dom/base/nsWindowRoot.h +++ b/dom/base/nsWindowRoot.h @@ -10,9 +10,12 @@ class nsPIDOMWindow; class nsIDOMEventListener; class nsIDOMEvent; -class nsEventChainPreVisitor; class nsEventChainPostVisitor; +namespace mozilla { +class EventChainPreVisitor; +} // namespace mozilla + #include "mozilla/Attributes.h" #include "mozilla/EventListenerManager.h" #include "nsIDOMEventTarget.h" diff --git a/dom/devicestorage/nsDeviceStorage.cpp b/dom/devicestorage/nsDeviceStorage.cpp index d8f5145aaa0..439becd35cb 100644 --- a/dom/devicestorage/nsDeviceStorage.cpp +++ b/dom/devicestorage/nsDeviceStorage.cpp @@ -57,6 +57,7 @@ #include #include "private/pprio.h" #include "nsContentPermissionHelper.h" +#include "nsEventDispatcher.h" #include "mozilla/dom/DeviceStorageBinding.h" @@ -4275,7 +4276,7 @@ nsDOMDeviceStorage::GetTargetForEventTargetChain() } nsresult -nsDOMDeviceStorage::PreHandleEvent(nsEventChainPreVisitor & aVisitor) +nsDOMDeviceStorage::PreHandleEvent(EventChainPreVisitor& aVisitor) { return nsDOMEventTargetHelper::PreHandleEvent(aVisitor); } diff --git a/dom/events/nsDOMEventTargetHelper.cpp b/dom/events/nsDOMEventTargetHelper.cpp index 2fc55239060..f9eb6ff8b3e 100644 --- a/dom/events/nsDOMEventTargetHelper.cpp +++ b/dom/events/nsDOMEventTargetHelper.cpp @@ -297,7 +297,7 @@ nsDOMEventTargetHelper::GetEventHandler(nsIAtom* aType, } nsresult -nsDOMEventTargetHelper::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +nsDOMEventTargetHelper::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = true; aVisitor.mParentTarget = nullptr; diff --git a/dom/events/nsEventDispatcher.cpp b/dom/events/nsEventDispatcher.cpp index 4cfa7a942fb..376a684d40a 100644 --- a/dom/events/nsEventDispatcher.cpp +++ b/dom/events/nsEventDispatcher.cpp @@ -164,7 +164,7 @@ public: * Resets aVisitor object and calls PreHandleEvent. * Copies mItemFlags and mItemData to the current nsEventTargetChainItem. */ - void PreHandleEvent(nsEventChainPreVisitor& aVisitor); + void PreHandleEvent(EventChainPreVisitor& aVisitor); /** * If the current item in the event target chain has an event listener @@ -219,7 +219,7 @@ nsEventTargetChainItem::nsEventTargetChainItem(EventTarget* aTarget) } void -nsEventTargetChainItem::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +nsEventTargetChainItem::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.Reset(); unused << mTarget->PreHandleEvent(aVisitor); @@ -515,8 +515,8 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget, // Create visitor object and start event dispatching. // PreHandleEvent for the original target. nsEventStatus status = aEventStatus ? *aEventStatus : nsEventStatus_eIgnore; - nsEventChainPreVisitor preVisitor(aPresContext, aEvent, aDOMEvent, status, - isInAnon); + EventChainPreVisitor preVisitor(aPresContext, aEvent, aDOMEvent, status, + isInAnon); targetEtci->PreHandleEvent(preVisitor); if (!preVisitor.mCanHandle && preVisitor.mAutomaticChromeDispatch && content) { diff --git a/dom/events/nsEventDispatcher.h b/dom/events/nsEventDispatcher.h index 6acbba074ac..d1b0ccf1efb 100644 --- a/dom/events/nsEventDispatcher.h +++ b/dom/events/nsEventDispatcher.h @@ -31,7 +31,7 @@ class EventTarget; * nsEventDispatcher::DispatchDOMEvent is called an event target chain is * created. nsEventDispatcher creates the chain by calling PreHandleEvent * on each event target and the creation continues until either the mCanHandle - * member of the nsEventChainPreVisitor object is false or the mParentTarget + * member of the EventChainPreVisitor object is false or the mParentTarget * does not point to a new target. The event target chain is created in the * heap. * @@ -105,24 +105,29 @@ public: nsCOMPtr mItemData; }; -} // namespace mozilla - -class nsEventChainPreVisitor : public mozilla::EventChainVisitor +class EventChainPreVisitor : public EventChainVisitor { public: - nsEventChainPreVisitor(nsPresContext* aPresContext, - mozilla::WidgetEvent* aEvent, - nsIDOMEvent* aDOMEvent, - nsEventStatus aEventStatus, - bool aIsInAnon) - : mozilla::EventChainVisitor(aPresContext, aEvent, aDOMEvent, aEventStatus), - mCanHandle(true), mAutomaticChromeDispatch(true), - mForceContentDispatch(false), mRelatedTargetIsInAnon(false), - mOriginalTargetIsInAnon(aIsInAnon), mWantsWillHandleEvent(false), - mMayHaveListenerManager(true), mParentTarget(nullptr), - mEventTargetAtParent(nullptr) {} + EventChainPreVisitor(nsPresContext* aPresContext, + WidgetEvent* aEvent, + nsIDOMEvent* aDOMEvent, + nsEventStatus aEventStatus, + bool aIsInAnon) + : EventChainVisitor(aPresContext, aEvent, aDOMEvent, aEventStatus) + , mCanHandle(true) + , mAutomaticChromeDispatch(true) + , mForceContentDispatch(false) + , mRelatedTargetIsInAnon(false) + , mOriginalTargetIsInAnon(aIsInAnon) + , mWantsWillHandleEvent(false) + , mMayHaveListenerManager(true) + , mParentTarget(nullptr) + , mEventTargetAtParent(nullptr) + { + } - void Reset() { + void Reset() + { mItemFlags = 0; mItemData = nullptr; mCanHandle = true; @@ -182,15 +187,17 @@ public: /** * Parent item in the event target chain. */ - mozilla::dom::EventTarget* mParentTarget; + dom::EventTarget* mParentTarget; /** * If the event needs to be retargeted, this is the event target, * which should be used when the event is handled at mParentTarget. */ - mozilla::dom::EventTarget* mEventTargetAtParent; + dom::EventTarget* mEventTargetAtParent; }; +} // namespace mozilla + class nsEventChainPostVisitor : public mozilla::EventChainVisitor { public: diff --git a/dom/file/ArchiveRequest.cpp b/dom/file/ArchiveRequest.cpp index 2b77ef4fe43..bb3fab27515 100644 --- a/dom/file/ArchiveRequest.cpp +++ b/dom/file/ArchiveRequest.cpp @@ -11,6 +11,8 @@ #include "nsCxPusher.h" #include "nsEventDispatcher.h" +using namespace mozilla; + USING_FILE_NAMESPACE /** @@ -66,7 +68,7 @@ ArchiveRequest::~ArchiveRequest() } nsresult -ArchiveRequest::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +ArchiveRequest::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = true; aVisitor.mParentTarget = nullptr; diff --git a/dom/file/ArchiveRequest.h b/dom/file/ArchiveRequest.h index 858ae97cac6..78dc1cc1e05 100644 --- a/dom/file/ArchiveRequest.h +++ b/dom/file/ArchiveRequest.h @@ -13,6 +13,9 @@ #include "FileCommon.h" +namespace mozilla { +class EventChainPreVisitor; +} // namespace mozilla BEGIN_FILE_NAMESPACE @@ -36,7 +39,7 @@ public: ArchiveReader* aReader); // nsIDOMEventTarget - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; public: // This is called by the DOMArchiveRequestEvent diff --git a/dom/file/FileRequest.cpp b/dom/file/FileRequest.cpp index 3b3a1e674f0..64a6b040a4e 100644 --- a/dom/file/FileRequest.cpp +++ b/dom/file/FileRequest.cpp @@ -15,6 +15,8 @@ #include "FileHelper.h" #include "LockedFile.h" +using namespace mozilla; + USING_FILE_NAMESPACE FileRequest::FileRequest(nsPIDOMWindow* aWindow) @@ -43,7 +45,7 @@ FileRequest::Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile, } nsresult -FileRequest::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +FileRequest::PreHandleEvent(EventChainPreVisitor& aVisitor) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); diff --git a/dom/file/FileRequest.h b/dom/file/FileRequest.h index d3f727a7dc5..7b2159f3955 100644 --- a/dom/file/FileRequest.h +++ b/dom/file/FileRequest.h @@ -14,6 +14,10 @@ class nsIDOMLockedFile; +namespace mozilla { +class EventChainPreVisitor; +} // namespace mozilla + BEGIN_FILE_NAMESPACE class FileHelper; @@ -31,7 +35,7 @@ public: // nsIDOMEventTarget virtual nsresult - PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; void OnProgress(uint64_t aProgress, uint64_t aProgressMax) diff --git a/dom/file/LockedFile.cpp b/dom/file/LockedFile.cpp index ac9e392d954..bdc9e4faa65 100644 --- a/dom/file/LockedFile.cpp +++ b/dom/file/LockedFile.cpp @@ -341,7 +341,7 @@ NS_IMPL_EVENT_HANDLER(LockedFile, abort) NS_IMPL_EVENT_HANDLER(LockedFile, error) nsresult -LockedFile::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +LockedFile::PreHandleEvent(EventChainPreVisitor& aVisitor) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); diff --git a/dom/file/LockedFile.h b/dom/file/LockedFile.h index 04155daa942..5f00ac125b2 100644 --- a/dom/file/LockedFile.h +++ b/dom/file/LockedFile.h @@ -17,6 +17,10 @@ class nsIInputStream; +namespace mozilla { +class EventChainPreVisitor; +} // namespace mozilla + BEGIN_FILE_NAMESPACE class FileHandle; @@ -60,7 +64,7 @@ public: // nsIDOMEventTarget virtual nsresult - PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; nsresult CreateParallelStream(nsISupports** aStream); diff --git a/dom/indexedDB/IDBRequest.cpp b/dom/indexedDB/IDBRequest.cpp index 95e06c64688..958b5886d0f 100644 --- a/dom/indexedDB/IDBRequest.cpp +++ b/dom/indexedDB/IDBRequest.cpp @@ -386,7 +386,7 @@ NS_IMPL_ADDREF_INHERITED(IDBRequest, IDBWrapperCache) NS_IMPL_RELEASE_INHERITED(IDBRequest, IDBWrapperCache) nsresult -IDBRequest::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +IDBRequest::PreHandleEvent(EventChainPreVisitor& aVisitor) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); diff --git a/dom/indexedDB/IDBRequest.h b/dom/indexedDB/IDBRequest.h index e9dc923c3cb..fb265dbc3d1 100644 --- a/dom/indexedDB/IDBRequest.h +++ b/dom/indexedDB/IDBRequest.h @@ -23,6 +23,7 @@ class nsIScriptContext; class nsPIDOMWindow; namespace mozilla { +class EventChainPreVisitor; namespace dom { class OwningIDBObjectStoreOrIDBIndexOrIDBCursor; class ErrorEventInit; @@ -61,7 +62,7 @@ public: IDBTransaction* aTransaction); // nsIDOMEventTarget - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; void GetSource(Nullable& aSource) const; diff --git a/dom/indexedDB/IDBTransaction.cpp b/dom/indexedDB/IDBTransaction.cpp index f27102f1cff..16504e8366e 100644 --- a/dom/indexedDB/IDBTransaction.cpp +++ b/dom/indexedDB/IDBTransaction.cpp @@ -36,6 +36,7 @@ #define SAVEPOINT_NAME "savepoint" +using namespace mozilla; using namespace mozilla::dom; USING_INDEXEDDB_NAMESPACE using mozilla::dom::quota::QuotaManager; @@ -722,7 +723,7 @@ IDBTransaction::ObjectStore(const nsAString& aName, ErrorResult& aRv) } nsresult -IDBTransaction::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +IDBTransaction::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = true; aVisitor.mParentTarget = mDatabase; diff --git a/dom/indexedDB/IDBTransaction.h b/dom/indexedDB/IDBTransaction.h index 0055c345d6d..577847773fd 100644 --- a/dom/indexedDB/IDBTransaction.h +++ b/dom/indexedDB/IDBTransaction.h @@ -30,6 +30,10 @@ class nsIThread; class nsPIDOMWindow; +namespace mozilla { +class EventChainPreVisitor; +} // namespace mozilla + BEGIN_INDEXEDDB_NAMESPACE class AsyncConnectionHelper; @@ -98,7 +102,7 @@ public: } // nsIDOMEventTarget - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; void OnNewRequest(); void OnRequestFinished(); diff --git a/dom/interfaces/events/nsIDOMEventTarget.idl b/dom/interfaces/events/nsIDOMEventTarget.idl index 1293088cf86..6a11a66ec81 100644 --- a/dom/interfaces/events/nsIDOMEventTarget.idl +++ b/dom/interfaces/events/nsIDOMEventTarget.idl @@ -13,6 +13,7 @@ using mozilla::dom::Nullable; namespace mozilla { +class EventChainPreVisitor; class EventListenerManager; namespace dom { class EventTarget; @@ -20,7 +21,6 @@ class EventTarget; } // namespace mozilla class nsPresContext; -class nsEventChainPreVisitor; class nsEventChainPostVisitor; %} @@ -32,12 +32,12 @@ class nsEventChainPostVisitor; * http://www.w3.org/TR/DOM-Level-2-Events/ */ -[ref] native nsEventChainPreVisitorRef(nsEventChainPreVisitor); [ref] native nsEventChainPostVisitorRef(nsEventChainPostVisitor); [ptr] native WidgetEventPtr(mozilla::WidgetEvent); [ptr] native nsPresContextPtr(nsPresContext); [ptr] native nsEventStatusPtr(nsEventStatus); [ptr] native JSContextPtr(JSContext); +[ref] native EventChainPreVisitorRef(mozilla::EventChainPreVisitor); [ptr] native EventListenerManagerPtr(mozilla::EventListenerManager); [ptr] native EventTargetPtr(mozilla::dom::EventTarget); @@ -211,7 +211,7 @@ interface nsIDOMEventTarget : nsISupports /** * Called before the capture phase of the event flow. * This is used to create the event target chain and implementations - * should set the necessary members of nsEventChainPreVisitor. + * should set the necessary members of EventChainPreVisitor. * At least aVisitor.mCanHandle must be set, * usually also aVisitor.mParentTarget if mCanHandle is PR_TRUE. * First one tells that this object can handle the aVisitor.mEvent event and @@ -224,10 +224,10 @@ interface nsIDOMEventTarget : nsISupports * @note Only nsEventDispatcher should call this method. */ [noscript, nostdcall] - void PreHandleEvent(in nsEventChainPreVisitorRef aVisitor); + void PreHandleEvent(in EventChainPreVisitorRef aVisitor); /** - * If nsEventChainPreVisitor.mWantsWillHandleEvent is set PR_TRUE, + * If EventChainPreVisitor.mWantsWillHandleEvent is set PR_TRUE, * called just before possible event handlers on this object will be called. */ [noscript, nostdcall] diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index c7e6fa1cb50..6aed2433458 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -118,7 +118,7 @@ public: } nsresult - PreHandleEvent(nsEventChainPreVisitor& aVisitor) + PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mForceContentDispatch = true; return NS_OK; diff --git a/dom/workers/MessagePort.cpp b/dom/workers/MessagePort.cpp index 800da33f31f..c87bcba947d 100644 --- a/dom/workers/MessagePort.cpp +++ b/dom/workers/MessagePort.cpp @@ -17,6 +17,7 @@ using mozilla::dom::EventHandlerNonNull; using mozilla::dom::MessagePortBase; using mozilla::dom::Optional; using mozilla::dom::Sequence; +using namespace mozilla; USING_WORKERS_NAMESPACE @@ -244,7 +245,7 @@ MessagePort::WrapObject(JSContext* aCx, JS::Handle aScope) } nsresult -MessagePort::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +MessagePort::PreHandleEvent(EventChainPreVisitor& aVisitor) { AssertCorrectThread(); diff --git a/dom/workers/MessagePort.h b/dom/workers/MessagePort.h index c07cdcf3b4f..ffab0a48652 100644 --- a/dom/workers/MessagePort.h +++ b/dom/workers/MessagePort.h @@ -15,6 +15,10 @@ class nsIDOMEvent; class nsPIDOMWindow; +namespace mozilla { +class EventChainPreVisitor; +} // namespace mozilla + BEGIN_WORKERS_NAMESPACE class SharedWorker; @@ -79,7 +83,7 @@ public: WrapObject(JSContext* aCx, JS::Handle aScope) MOZ_OVERRIDE; virtual nsresult - PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; #ifdef DEBUG void diff --git a/dom/workers/SharedWorker.cpp b/dom/workers/SharedWorker.cpp index 63e691fe228..d7dbed7e769 100644 --- a/dom/workers/SharedWorker.cpp +++ b/dom/workers/SharedWorker.cpp @@ -20,6 +20,7 @@ using mozilla::dom::Optional; using mozilla::dom::Sequence; +using namespace mozilla; USING_WORKERS_NAMESPACE @@ -198,7 +199,7 @@ SharedWorker::WrapObject(JSContext* aCx, JS::Handle aScope) } nsresult -SharedWorker::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +SharedWorker::PreHandleEvent(EventChainPreVisitor& aVisitor) { AssertIsOnMainThread(); diff --git a/dom/workers/SharedWorker.h b/dom/workers/SharedWorker.h index fd579d2af07..ee49d8e3145 100644 --- a/dom/workers/SharedWorker.h +++ b/dom/workers/SharedWorker.h @@ -15,6 +15,10 @@ class nsIDOMEvent; class nsPIDOMWindow; +namespace mozilla { +class EventChainPreVisitor; +} // namespace mozilla + BEGIN_WORKERS_NAMESPACE class MessagePort; @@ -77,7 +81,7 @@ public: WrapObject(JSContext* aCx, JS::Handle aScope) MOZ_OVERRIDE; virtual nsresult - PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; + PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; WorkerPrivate* GetWorkerPrivate() const diff --git a/widget/BasicEvents.h b/widget/BasicEvents.h index 62eaaa653a2..a82c6d7da37 100644 --- a/widget/BasicEvents.h +++ b/widget/BasicEvents.h @@ -546,7 +546,7 @@ public: // If mNoContentDispatch is true, the event is never dispatched to the // event handlers which are added to the contents, onfoo attributes and // properties. Note that this flag is ignored when - // nsEventChainPreVisitor::mForceContentDispatch is set true. For exapmle, + // EventChainPreVisitor::mForceContentDispatch is set true. For exapmle, // window and document object sets it true. Therefore, web applications // can handle the event if they add event listeners to the window or the // document. From 6e0a5b333328d9f36b493ca1743d6166555531d4 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 18 Mar 2014 13:48:20 +0900 Subject: [PATCH 37/88] Bug 983049 part.3 Rename nsEventChainPostVisitor to mozilla::EventChainPostVisitor r=smaug --- content/base/public/Element.h | 3 ++- content/base/src/Element.cpp | 2 +- content/base/src/nsINode.cpp | 2 +- content/html/content/src/HTMLAnchorElement.cpp | 2 +- content/html/content/src/HTMLAnchorElement.h | 4 +++- content/html/content/src/HTMLAreaElement.cpp | 2 +- content/html/content/src/HTMLAreaElement.h | 3 ++- content/html/content/src/HTMLButtonElement.cpp | 2 +- content/html/content/src/HTMLButtonElement.h | 4 +++- content/html/content/src/HTMLFormElement.cpp | 4 ++-- content/html/content/src/HTMLFormElement.h | 7 +++++-- content/html/content/src/HTMLInputElement.cpp | 6 +++--- content/html/content/src/HTMLInputElement.h | 8 +++++--- content/html/content/src/HTMLLabelElement.cpp | 2 +- content/html/content/src/HTMLLabelElement.h | 4 +++- content/html/content/src/HTMLLinkElement.cpp | 2 +- content/html/content/src/HTMLLinkElement.h | 4 +++- content/html/content/src/HTMLMenuItemElement.cpp | 2 +- content/html/content/src/HTMLMenuItemElement.h | 3 ++- content/html/content/src/HTMLSelectElement.cpp | 2 +- content/html/content/src/HTMLSelectElement.h | 4 +++- content/html/content/src/HTMLTextAreaElement.cpp | 2 +- content/html/content/src/HTMLTextAreaElement.h | 4 +++- content/html/content/src/nsGenericHTMLElement.cpp | 2 +- content/html/content/src/nsGenericHTMLElement.h | 3 ++- content/mathml/content/src/nsMathMLElement.cpp | 2 +- content/mathml/content/src/nsMathMLElement.h | 4 +++- content/svg/content/src/SVGAElement.cpp | 2 +- content/svg/content/src/SVGAElement.h | 4 +++- dom/base/nsGlobalWindow.cpp | 4 ++-- dom/base/nsWindowRoot.cpp | 2 +- dom/base/nsWindowRoot.h | 2 +- dom/devicestorage/nsDeviceStorage.cpp | 4 ++-- dom/events/nsDOMEventTargetHelper.cpp | 2 +- dom/events/nsDOMEventTargetHelper.h | 6 ++++-- dom/events/nsEventDispatcher.cpp | 12 ++++++------ dom/events/nsEventDispatcher.h | 14 +++++++------- dom/events/nsEventStateManager.cpp | 2 +- dom/indexedDB/IDBDatabase.cpp | 4 +++- dom/indexedDB/IDBDatabase.h | 4 +++- dom/indexedDB/IDBRequest.cpp | 2 +- dom/indexedDB/IDBRequest.h | 4 +++- dom/indexedDB/IndexedDatabaseManager.cpp | 3 ++- dom/indexedDB/IndexedDatabaseManager.h | 4 ++-- dom/interfaces/events/nsIDOMEventTarget.idl | 10 +++++----- layout/base/nsPresShell.cpp | 2 +- 46 files changed, 105 insertions(+), 71 deletions(-) diff --git a/content/base/public/Element.h b/content/base/public/Element.h index ecb3f209fca..dd5ce491723 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -102,6 +102,7 @@ enum { ASSERT_NODE_FLAGS_SPACE(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET); namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; class EventChainVisitor; class EventListenerManager; @@ -1118,7 +1119,7 @@ protected: /** * Handle default actions for link event if the event isn't consumed yet. */ - nsresult PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor); + nsresult PostHandleEventForLinks(EventChainPostVisitor& aVisitor); /** * Get the target of this link element. Consumers should established that diff --git a/content/base/src/Element.cpp b/content/base/src/Element.cpp index 4cae657d60a..04a59944661 100644 --- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -2396,7 +2396,7 @@ Element::PreHandleEventForLinks(EventChainPreVisitor& aVisitor) } nsresult -Element::PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor) +Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor) { // Optimisation: return early if this event doesn't interest us. // IMPORTANT: this switch and the switch below it must be kept in sync! diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index bdf8055cf91..b880c9cf248 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -1169,7 +1169,7 @@ nsINode::DispatchEvent(nsIDOMEvent *aEvent, bool* aRetVal) } nsresult -nsINode::PostHandleEvent(nsEventChainPostVisitor& /*aVisitor*/) +nsINode::PostHandleEvent(EventChainPostVisitor& /*aVisitor*/) { return NS_OK; } diff --git a/content/html/content/src/HTMLAnchorElement.cpp b/content/html/content/src/HTMLAnchorElement.cpp index 3dd9920ea1d..1ea30e99ce7 100644 --- a/content/html/content/src/HTMLAnchorElement.cpp +++ b/content/html/content/src/HTMLAnchorElement.cpp @@ -251,7 +251,7 @@ HTMLAnchorElement::PreHandleEvent(EventChainPreVisitor& aVisitor) } nsresult -HTMLAnchorElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +HTMLAnchorElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { return PostHandleEventForAnchors(aVisitor); } diff --git a/content/html/content/src/HTMLAnchorElement.h b/content/html/content/src/HTMLAnchorElement.h index f0aae4c6435..129f6733e7a 100644 --- a/content/html/content/src/HTMLAnchorElement.h +++ b/content/html/content/src/HTMLAnchorElement.h @@ -14,6 +14,7 @@ #include "nsDOMTokenList.h" namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; namespace dom { @@ -56,7 +57,8 @@ public: virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) MOZ_OVERRIDE; virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PostHandleEvent( + EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual bool IsLink(nsIURI** aURI) const MOZ_OVERRIDE; virtual void GetLinkTarget(nsAString& aTarget) MOZ_OVERRIDE; virtual already_AddRefed GetHrefURI() const MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLAreaElement.cpp b/content/html/content/src/HTMLAreaElement.cpp index 0e70ffdd55a..0c2bf811e5c 100644 --- a/content/html/content/src/HTMLAreaElement.cpp +++ b/content/html/content/src/HTMLAreaElement.cpp @@ -99,7 +99,7 @@ HTMLAreaElement::PreHandleEvent(EventChainPreVisitor& aVisitor) } nsresult -HTMLAreaElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +HTMLAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { return PostHandleEventForAnchors(aVisitor); } diff --git a/content/html/content/src/HTMLAreaElement.h b/content/html/content/src/HTMLAreaElement.h index 8762e9c075b..6739b64d1be 100644 --- a/content/html/content/src/HTMLAreaElement.h +++ b/content/html/content/src/HTMLAreaElement.h @@ -18,6 +18,7 @@ class nsIDocument; namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; namespace dom { @@ -45,7 +46,7 @@ public: NS_DECL_NSIDOMHTMLAREAELEMENT virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual bool IsLink(nsIURI** aURI) const MOZ_OVERRIDE; virtual void GetLinkTarget(nsAString& aTarget) MOZ_OVERRIDE; virtual already_AddRefed GetHrefURI() const MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLButtonElement.cpp b/content/html/content/src/HTMLButtonElement.cpp index bd891ffb154..b8fb2d3bdcd 100644 --- a/content/html/content/src/HTMLButtonElement.cpp +++ b/content/html/content/src/HTMLButtonElement.cpp @@ -219,7 +219,7 @@ HTMLButtonElement::PreHandleEvent(EventChainPreVisitor& aVisitor) } nsresult -HTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { nsresult rv = NS_OK; if (!aVisitor.mPresContext) { diff --git a/content/html/content/src/HTMLButtonElement.h b/content/html/content/src/HTMLButtonElement.h index 70905d057b7..9d427db8d7a 100644 --- a/content/html/content/src/HTMLButtonElement.h +++ b/content/html/content/src/HTMLButtonElement.h @@ -12,6 +12,7 @@ #include "nsIConstraintValidation.h" namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; namespace dom { @@ -49,7 +50,8 @@ public: // nsIDOMEventTarget virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PostHandleEvent( + EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; // nsINode virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLFormElement.cpp b/content/html/content/src/HTMLFormElement.cpp index aed85324b40..88d0c11f354 100644 --- a/content/html/content/src/HTMLFormElement.cpp +++ b/content/html/content/src/HTMLFormElement.cpp @@ -511,7 +511,7 @@ HTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor) } nsresult -HTMLFormElement::WillHandleEvent(nsEventChainPostVisitor& aVisitor) +HTMLFormElement::WillHandleEvent(EventChainPostVisitor& aVisitor) { // If this is the bubble stage and there is a nested form below us which // received a submit event we do *not* want to handle the submit event @@ -526,7 +526,7 @@ HTMLFormElement::WillHandleEvent(nsEventChainPostVisitor& aVisitor) } nsresult -HTMLFormElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +HTMLFormElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { if (aVisitor.mEvent->originalTarget == static_cast(this)) { uint32_t msg = aVisitor.mEvent->message; diff --git a/content/html/content/src/HTMLFormElement.h b/content/html/content/src/HTMLFormElement.h index 32604155cd5..40882b1a26a 100644 --- a/content/html/content/src/HTMLFormElement.h +++ b/content/html/content/src/HTMLFormElement.h @@ -27,6 +27,7 @@ class nsIMutableArray; class nsIURI; namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; namespace dom { class HTMLFormControlsCollection; @@ -91,8 +92,10 @@ public: const nsAString& aValue, nsAttrValue& aResult) MOZ_OVERRIDE; virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; - virtual nsresult WillHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult WillHandleEvent( + EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PostHandleEvent( + EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, diff --git a/content/html/content/src/HTMLInputElement.cpp b/content/html/content/src/HTMLInputElement.cpp index e78bc8f7a6d..bc3ec73d862 100644 --- a/content/html/content/src/HTMLInputElement.cpp +++ b/content/html/content/src/HTMLInputElement.cpp @@ -3731,7 +3731,7 @@ HTMLInputElement::ShouldPreventDOMActivateDispatch(EventTarget* aOriginalTarget) } nsresult -HTMLInputElement::MaybeInitPickers(nsEventChainPostVisitor& aVisitor) +HTMLInputElement::MaybeInitPickers(EventChainPostVisitor& aVisitor) { // Open a file picker when we receive a click on a , or // open a color picker when we receive a click on a . @@ -3757,7 +3757,7 @@ HTMLInputElement::MaybeInitPickers(nsEventChainPostVisitor& aVisitor) } nsresult -HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { if (!aVisitor.mPresContext) { // Hack alert! In order to open file picker even in case the element isn't @@ -4240,7 +4240,7 @@ HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) } void -HTMLInputElement::PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor) +HTMLInputElement::PostHandleEventForRangeThumb(EventChainPostVisitor& aVisitor) { MOZ_ASSERT(mType == NS_FORM_INPUT_RANGE); diff --git a/content/html/content/src/HTMLInputElement.h b/content/html/content/src/HTMLInputElement.h index d39151a5fa0..cd10000b999 100644 --- a/content/html/content/src/HTMLInputElement.h +++ b/content/html/content/src/HTMLInputElement.h @@ -30,6 +30,7 @@ class nsTextEditorState; namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; namespace dom { @@ -152,8 +153,9 @@ public: virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const MOZ_OVERRIDE; virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; - void PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor); + virtual nsresult PostHandleEvent( + EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + void PostHandleEventForRangeThumb(EventChainPostVisitor& aVisitor); void StartRangeThumbDrag(WidgetGUIEvent* aEvent); void FinishRangeThumbDrag(WidgetGUIEvent* aEvent = nullptr); void CancelRangeThumbDrag(bool aIsForUserEvent = true); @@ -1182,7 +1184,7 @@ protected: * this function checks if it is needed, and if so, open the corresponding * picker (color picker or file picker). */ - nsresult MaybeInitPickers(nsEventChainPostVisitor& aVisitor); + nsresult MaybeInitPickers(EventChainPostVisitor& aVisitor); enum FilePickerType { FILE_PICKER_FILE, diff --git a/content/html/content/src/HTMLLabelElement.cpp b/content/html/content/src/HTMLLabelElement.cpp index 083792832b3..3776eeeb9a7 100644 --- a/content/html/content/src/HTMLLabelElement.cpp +++ b/content/html/content/src/HTMLLabelElement.cpp @@ -112,7 +112,7 @@ DestroyMouseDownPoint(void * /*aObject*/, } nsresult -HTMLLabelElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +HTMLLabelElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent(); if (mHandlingEvent || diff --git a/content/html/content/src/HTMLLabelElement.h b/content/html/content/src/HTMLLabelElement.h index 7b76a3fa21e..97ac01869d2 100644 --- a/content/html/content/src/HTMLLabelElement.h +++ b/content/html/content/src/HTMLLabelElement.h @@ -14,6 +14,7 @@ #include "nsIDOMHTMLLabelElement.h" namespace mozilla { +class EventChainPostVisitor; namespace dom { class HTMLLabelElement MOZ_FINAL : public nsGenericHTMLFormElement, @@ -60,7 +61,8 @@ public: virtual bool IsDisabled() const MOZ_OVERRIDE { return false; } // nsIContent - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PostHandleEvent( + EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual void PerformAccesskey(bool aKeyCausesActivation, bool aIsTrustedEvent) MOZ_OVERRIDE; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLLinkElement.cpp b/content/html/content/src/HTMLLinkElement.cpp index 2208cc6b19f..342501c2fd3 100644 --- a/content/html/content/src/HTMLLinkElement.cpp +++ b/content/html/content/src/HTMLLinkElement.cpp @@ -309,7 +309,7 @@ HTMLLinkElement::PreHandleEvent(EventChainPreVisitor& aVisitor) } nsresult -HTMLLinkElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +HTMLLinkElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { return PostHandleEventForAnchors(aVisitor); } diff --git a/content/html/content/src/HTMLLinkElement.h b/content/html/content/src/HTMLLinkElement.h index 715f11167e7..6a5061e8963 100644 --- a/content/html/content/src/HTMLLinkElement.h +++ b/content/html/content/src/HTMLLinkElement.h @@ -13,6 +13,7 @@ #include "nsStyleLinkElement.h" namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; namespace dom { @@ -43,7 +44,8 @@ public: // nsIDOMEventTarget virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PostHandleEvent( + EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; // nsINode virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLMenuItemElement.cpp b/content/html/content/src/HTMLMenuItemElement.cpp index 25fd842c9c3..5ab7537e81f 100644 --- a/content/html/content/src/HTMLMenuItemElement.cpp +++ b/content/html/content/src/HTMLMenuItemElement.cpp @@ -286,7 +286,7 @@ HTMLMenuItemElement::PreHandleEvent(EventChainPreVisitor& aVisitor) } nsresult -HTMLMenuItemElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +HTMLMenuItemElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { // Check to see if the event was cancelled. if (aVisitor.mEvent->message == NS_MOUSE_CLICK && diff --git a/content/html/content/src/HTMLMenuItemElement.h b/content/html/content/src/HTMLMenuItemElement.h index a583501b283..2f20ff6c973 100644 --- a/content/html/content/src/HTMLMenuItemElement.h +++ b/content/html/content/src/HTMLMenuItemElement.h @@ -37,7 +37,8 @@ public: NS_DECL_NSIDOMHTMLMENUITEMELEMENT virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PostHandleEvent( + EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, diff --git a/content/html/content/src/HTMLSelectElement.cpp b/content/html/content/src/HTMLSelectElement.cpp index 3f14516f9a8..24c9c33b5c0 100644 --- a/content/html/content/src/HTMLSelectElement.cpp +++ b/content/html/content/src/HTMLSelectElement.cpp @@ -1489,7 +1489,7 @@ HTMLSelectElement::PreHandleEvent(EventChainPreVisitor& aVisitor) } nsresult -HTMLSelectElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +HTMLSelectElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { if (aVisitor.mEvent->message == NS_FOCUS_CONTENT) { // If the invalid UI is shown, we should show it while focused and diff --git a/content/html/content/src/HTMLSelectElement.h b/content/html/content/src/HTMLSelectElement.h index c74facf766b..5b41fb3ac15 100644 --- a/content/html/content/src/HTMLSelectElement.h +++ b/content/html/content/src/HTMLSelectElement.h @@ -26,6 +26,7 @@ class nsPresState; namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; namespace dom { @@ -263,7 +264,8 @@ public: // nsIContent virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PostHandleEvent( + EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, int32_t* aTabIndex) MOZ_OVERRIDE; virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex, diff --git a/content/html/content/src/HTMLTextAreaElement.cpp b/content/html/content/src/HTMLTextAreaElement.cpp index 2d216331439..e4ffda5e276 100644 --- a/content/html/content/src/HTMLTextAreaElement.cpp +++ b/content/html/content/src/HTMLTextAreaElement.cpp @@ -509,7 +509,7 @@ HTMLTextAreaElement::FireChangeEventIfNeeded() } nsresult -HTMLTextAreaElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +HTMLTextAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { if (aVisitor.mEvent->message == NS_FORM_SELECTED) { mHandlingSelect = false; diff --git a/content/html/content/src/HTMLTextAreaElement.h b/content/html/content/src/HTMLTextAreaElement.h index 2c3c9c0c0c8..da104526add 100644 --- a/content/html/content/src/HTMLTextAreaElement.h +++ b/content/html/content/src/HTMLTextAreaElement.h @@ -30,6 +30,7 @@ class nsPresState; namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; namespace dom { @@ -117,7 +118,8 @@ public: NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE; virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PostHandleEvent( + EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) MOZ_OVERRIDE; diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 1b2ec428b54..c374dcaae72 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -731,7 +731,7 @@ nsGenericHTMLElement::PreHandleEventForAnchors(EventChainPreVisitor& aVisitor) } nsresult -nsGenericHTMLElement::PostHandleEventForAnchors(nsEventChainPostVisitor& aVisitor) +nsGenericHTMLElement::PostHandleEventForAnchors(EventChainPostVisitor& aVisitor) { if (!CheckHandleEventForAnchorsPreconditions(aVisitor)) { return NS_OK; diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 4ad2459cc95..232ba8c6d92 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -40,6 +40,7 @@ class nsIDOMHTMLCollection; class nsDOMSettableTokenList; namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; class EventChainVisitor; class EventListenerManager; @@ -593,7 +594,7 @@ public: bool CheckHandleEventForAnchorsPreconditions( mozilla::EventChainVisitor& aVisitor); nsresult PreHandleEventForAnchors(mozilla::EventChainPreVisitor& aVisitor); - nsresult PostHandleEventForAnchors(nsEventChainPostVisitor& aVisitor); + nsresult PostHandleEventForAnchors(mozilla::EventChainPostVisitor& aVisitor); bool IsHTMLLink(nsIURI** aURI) const; // HTML element methods diff --git a/content/mathml/content/src/nsMathMLElement.cpp b/content/mathml/content/src/nsMathMLElement.cpp index 15c77cde0d2..532f7a151ca 100644 --- a/content/mathml/content/src/nsMathMLElement.cpp +++ b/content/mathml/content/src/nsMathMLElement.cpp @@ -907,7 +907,7 @@ nsMathMLElement::PreHandleEvent(EventChainPreVisitor& aVisitor) } nsresult -nsMathMLElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +nsMathMLElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { return PostHandleEventForLinks(aVisitor); } diff --git a/content/mathml/content/src/nsMathMLElement.h b/content/mathml/content/src/nsMathMLElement.h index 18c0cea54e6..87535f3b19f 100644 --- a/content/mathml/content/src/nsMathMLElement.h +++ b/content/mathml/content/src/nsMathMLElement.h @@ -18,6 +18,7 @@ class nsCSSValue; typedef nsMappedAttributeElement nsMathMLElementBase; namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; } // namespace mozilla @@ -74,7 +75,8 @@ public: virtual nsresult PreHandleEvent( mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PostHandleEvent( + mozilla::EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; nsresult Clone(nsINodeInfo*, nsINode**) const MOZ_OVERRIDE; virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE; virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE; diff --git a/content/svg/content/src/SVGAElement.cpp b/content/svg/content/src/SVGAElement.cpp index 153ebb540a0..3bd7c2c170f 100644 --- a/content/svg/content/src/SVGAElement.cpp +++ b/content/svg/content/src/SVGAElement.cpp @@ -86,7 +86,7 @@ SVGAElement::PreHandleEvent(EventChainPreVisitor& aVisitor) } nsresult -SVGAElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +SVGAElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { return PostHandleEventForLinks(aVisitor); } diff --git a/content/svg/content/src/SVGAElement.h b/content/svg/content/src/SVGAElement.h index fbeeffba49a..5d3b8dc7c4a 100644 --- a/content/svg/content/src/SVGAElement.h +++ b/content/svg/content/src/SVGAElement.h @@ -15,6 +15,7 @@ nsresult NS_NewSVGAElement(nsIContent **aResult, namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; namespace dom { @@ -37,7 +38,8 @@ public: // nsINode interface methods virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PostHandleEvent( + EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; // nsIContent diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index bc1819f4648..58f09af0e55 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -2951,7 +2951,7 @@ nsGlobalWindow::GetTargetForEventTargetChain() } nsresult -nsGlobalWindow::WillHandleEvent(nsEventChainPostVisitor& aVisitor) +nsGlobalWindow::WillHandleEvent(EventChainPostVisitor& aVisitor) { return NS_OK; } @@ -3162,7 +3162,7 @@ nsGlobalWindow::EnableDialogs() } nsresult -nsGlobalWindow::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor) { NS_PRECONDITION(IsInnerWindow(), "PostHandleEvent is used on outer window!?"); diff --git a/dom/base/nsWindowRoot.cpp b/dom/base/nsWindowRoot.cpp index 7cef4567d4f..69479ce02c6 100644 --- a/dom/base/nsWindowRoot.cpp +++ b/dom/base/nsWindowRoot.cpp @@ -179,7 +179,7 @@ nsWindowRoot::PreHandleEvent(EventChainPreVisitor& aVisitor) } nsresult -nsWindowRoot::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +nsWindowRoot::PostHandleEvent(EventChainPostVisitor& aVisitor) { return NS_OK; } diff --git a/dom/base/nsWindowRoot.h b/dom/base/nsWindowRoot.h index 0cb645005e4..8b14604034e 100644 --- a/dom/base/nsWindowRoot.h +++ b/dom/base/nsWindowRoot.h @@ -10,9 +10,9 @@ class nsPIDOMWindow; class nsIDOMEventListener; class nsIDOMEvent; -class nsEventChainPostVisitor; namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; } // namespace mozilla diff --git a/dom/devicestorage/nsDeviceStorage.cpp b/dom/devicestorage/nsDeviceStorage.cpp index 439becd35cb..a723cd09606 100644 --- a/dom/devicestorage/nsDeviceStorage.cpp +++ b/dom/devicestorage/nsDeviceStorage.cpp @@ -4282,13 +4282,13 @@ nsDOMDeviceStorage::PreHandleEvent(EventChainPreVisitor& aVisitor) } nsresult -nsDOMDeviceStorage::WillHandleEvent(nsEventChainPostVisitor & aVisitor) +nsDOMDeviceStorage::WillHandleEvent(EventChainPostVisitor& aVisitor) { return nsDOMEventTargetHelper::WillHandleEvent(aVisitor); } nsresult -nsDOMDeviceStorage::PostHandleEvent(nsEventChainPostVisitor & aVisitor) +nsDOMDeviceStorage::PostHandleEvent(EventChainPostVisitor& aVisitor) { return nsDOMEventTargetHelper::PostHandleEvent(aVisitor); } diff --git a/dom/events/nsDOMEventTargetHelper.cpp b/dom/events/nsDOMEventTargetHelper.cpp index f9eb6ff8b3e..b0c4d1fe809 100644 --- a/dom/events/nsDOMEventTargetHelper.cpp +++ b/dom/events/nsDOMEventTargetHelper.cpp @@ -305,7 +305,7 @@ nsDOMEventTargetHelper::PreHandleEvent(EventChainPreVisitor& aVisitor) } nsresult -nsDOMEventTargetHelper::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +nsDOMEventTargetHelper::PostHandleEvent(EventChainPostVisitor& aVisitor) { return NS_OK; } diff --git a/dom/events/nsDOMEventTargetHelper.h b/dom/events/nsDOMEventTargetHelper.h index f15f921fed2..9d024116c08 100644 --- a/dom/events/nsDOMEventTargetHelper.h +++ b/dom/events/nsDOMEventTargetHelper.h @@ -241,10 +241,12 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsDOMEventTargetHelper, virtual mozilla::dom::EventTarget* GetTargetForEventTargetChain() { \ return _to GetTargetForEventTargetChain(); \ } \ - virtual nsresult WillHandleEvent(nsEventChainPostVisitor & aVisitor) { \ + virtual nsresult WillHandleEvent( \ + mozilla::EventChainPostVisitor & aVisitor) { \ return _to WillHandleEvent(aVisitor); \ } \ - virtual nsresult PostHandleEvent(nsEventChainPostVisitor & aVisitor) { \ + virtual nsresult PostHandleEvent( \ + mozilla::EventChainPostVisitor & aVisitor) { \ return _to PostHandleEvent(aVisitor); \ } \ virtual nsresult DispatchDOMEvent(mozilla::WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent, nsPresContext* aPresContext, nsEventStatus* aEventStatus) { \ diff --git a/dom/events/nsEventDispatcher.cpp b/dom/events/nsEventDispatcher.cpp index 376a684d40a..1809ae8caf6 100644 --- a/dom/events/nsEventDispatcher.cpp +++ b/dom/events/nsEventDispatcher.cpp @@ -156,7 +156,7 @@ public: * item in the chain. */ static void HandleEventTargetChain(nsTArray& aChain, - nsEventChainPostVisitor& aVisitor, + EventChainPostVisitor& aVisitor, nsDispatchingCallback* aCallback, ELMCreationDetector& aCd); @@ -170,7 +170,7 @@ public: * If the current item in the event target chain has an event listener * manager, this method calls EventListenerManager::HandleEvent(). */ - void HandleEvent(nsEventChainPostVisitor& aVisitor, + void HandleEvent(EventChainPostVisitor& aVisitor, ELMCreationDetector& aCd) { if (WantsWillHandleEvent()) { @@ -200,7 +200,7 @@ public: /** * Copies mItemFlags and mItemData to aVisitor and calls PostHandleEvent. */ - void PostHandleEvent(nsEventChainPostVisitor& aVisitor); + void PostHandleEvent(EventChainPostVisitor& aVisitor); nsCOMPtr mTarget; uint16_t mFlags; @@ -231,7 +231,7 @@ nsEventTargetChainItem::PreHandleEvent(EventChainPreVisitor& aVisitor) } void -nsEventTargetChainItem::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +nsEventTargetChainItem::PostHandleEvent(EventChainPostVisitor& aVisitor) { aVisitor.mItemFlags = mItemFlags; aVisitor.mItemData = mItemData; @@ -241,7 +241,7 @@ nsEventTargetChainItem::PostHandleEvent(nsEventChainPostVisitor& aVisitor) void nsEventTargetChainItem::HandleEventTargetChain( nsTArray& aChain, - nsEventChainPostVisitor& aVisitor, + EventChainPostVisitor& aVisitor, nsDispatchingCallback* aCallback, ELMCreationDetector& aCd) { @@ -588,7 +588,7 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget, } } else { // Event target chain is created. Handle the chain. - nsEventChainPostVisitor postVisitor(preVisitor); + EventChainPostVisitor postVisitor(preVisitor); nsEventTargetChainItem::HandleEventTargetChain(chain, postVisitor, aCallback, diff --git a/dom/events/nsEventDispatcher.h b/dom/events/nsEventDispatcher.h index d1b0ccf1efb..71b36c223ad 100644 --- a/dom/events/nsEventDispatcher.h +++ b/dom/events/nsEventDispatcher.h @@ -196,18 +196,18 @@ public: dom::EventTarget* mEventTargetAtParent; }; -} // namespace mozilla - -class nsEventChainPostVisitor : public mozilla::EventChainVisitor +class EventChainPostVisitor : public mozilla::EventChainVisitor { public: - nsEventChainPostVisitor(mozilla::EventChainVisitor& aOther) - : mozilla::EventChainVisitor(aOther.mPresContext, aOther.mEvent, - aOther.mDOMEvent, aOther.mEventStatus) + EventChainPostVisitor(EventChainVisitor& aOther) + : EventChainVisitor(aOther.mPresContext, aOther.mEvent, + aOther.mDOMEvent, aOther.mEventStatus) { } }; +} // namespace mozilla + /** * If an nsDispatchingCallback object is passed to Dispatch, * its HandleEvent method is called after handling the default event group, @@ -216,7 +216,7 @@ public: */ class MOZ_STACK_CLASS nsDispatchingCallback { public: - virtual void HandleEvent(nsEventChainPostVisitor& aVisitor) = 0; + virtual void HandleEvent(mozilla::EventChainPostVisitor& aVisitor) = 0; }; /** diff --git a/dom/events/nsEventStateManager.cpp b/dom/events/nsEventStateManager.cpp index 7f7285f17c8..7919d63c5a1 100644 --- a/dom/events/nsEventStateManager.cpp +++ b/dom/events/nsEventStateManager.cpp @@ -4038,7 +4038,7 @@ class MOZ_STACK_CLASS nsESMEventCB : public nsDispatchingCallback public: nsESMEventCB(nsIContent* aTarget) : mTarget(aTarget) {} - virtual void HandleEvent(nsEventChainPostVisitor& aVisitor) + virtual void HandleEvent(EventChainPostVisitor& aVisitor) { if (aVisitor.mPresContext) { nsIFrame* frame = aVisitor.mPresContext->GetPrimaryFrameFor(mTarget); diff --git a/dom/indexedDB/IDBDatabase.cpp b/dom/indexedDB/IDBDatabase.cpp index 0ff682c78bc..afd0ba50750 100644 --- a/dom/indexedDB/IDBDatabase.cpp +++ b/dom/indexedDB/IDBDatabase.cpp @@ -15,6 +15,7 @@ #include "mozilla/dom/DOMStringListBinding.h" #include "mozilla/dom/quota/Client.h" #include "mozilla/dom/quota/QuotaManager.h" +#include "nsEventDispatcher.h" #include "nsJSUtils.h" #include "nsProxyRelease.h" #include "nsThreadUtils.h" @@ -43,6 +44,7 @@ using mozilla::dom::quota::AssertIsOnIOThread; using mozilla::dom::quota::Client; using mozilla::dom::quota::QuotaManager; using mozilla::ErrorResult; +using namespace mozilla; using namespace mozilla::dom; namespace { @@ -775,7 +777,7 @@ IDBDatabase::Origin() } nsresult -IDBDatabase::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +IDBDatabase::PostHandleEvent(EventChainPostVisitor& aVisitor) { return IndexedDatabaseManager::FireWindowOnError(GetOwner(), aVisitor); } diff --git a/dom/indexedDB/IDBDatabase.h b/dom/indexedDB/IDBDatabase.h index d7ab0dcaf4f..e4cd22fd275 100644 --- a/dom/indexedDB/IDBDatabase.h +++ b/dom/indexedDB/IDBDatabase.h @@ -27,6 +27,7 @@ class nsIScriptContext; class nsPIDOMWindow; namespace mozilla { +class EventChainPostVisitor; namespace dom { class ContentParent; namespace quota { @@ -81,7 +82,8 @@ public: } // nsIDOMEventTarget - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PostHandleEvent( + EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; DatabaseInfo* Info() const { diff --git a/dom/indexedDB/IDBRequest.cpp b/dom/indexedDB/IDBRequest.cpp index 958b5886d0f..583d28d4fb8 100644 --- a/dom/indexedDB/IDBRequest.cpp +++ b/dom/indexedDB/IDBRequest.cpp @@ -457,7 +457,7 @@ NS_IMPL_ADDREF_INHERITED(IDBOpenDBRequest, IDBRequest) NS_IMPL_RELEASE_INHERITED(IDBOpenDBRequest, IDBRequest) nsresult -IDBOpenDBRequest::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +IDBOpenDBRequest::PostHandleEvent(EventChainPostVisitor& aVisitor) { return IndexedDatabaseManager::FireWindowOnError(GetOwner(), aVisitor); } diff --git a/dom/indexedDB/IDBRequest.h b/dom/indexedDB/IDBRequest.h index fb265dbc3d1..33f6636ca70 100644 --- a/dom/indexedDB/IDBRequest.h +++ b/dom/indexedDB/IDBRequest.h @@ -23,6 +23,7 @@ class nsIScriptContext; class nsPIDOMWindow; namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; namespace dom { class OwningIDBObjectStoreOrIDBIndexOrIDBCursor; @@ -192,7 +193,8 @@ public: void SetTransaction(IDBTransaction* aTransaction); // nsIDOMEventTarget - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; + virtual nsresult PostHandleEvent( + EventChainPostVisitor& aVisitor) MOZ_OVERRIDE; DOMError* GetError(ErrorResult& aRv) { diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp index ee28a55ad7d..8b0f2c6e9cd 100644 --- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -55,6 +55,7 @@ #define LOW_DISK_SPACE_DATA_FREE "free" USING_INDEXEDDB_NAMESPACE +using namespace mozilla; using namespace mozilla::dom; USING_QUOTA_NAMESPACE @@ -306,7 +307,7 @@ IndexedDatabaseManager::Destroy() // static nsresult IndexedDatabaseManager::FireWindowOnError(nsPIDOMWindow* aOwner, - nsEventChainPostVisitor& aVisitor) + EventChainPostVisitor& aVisitor) { NS_ENSURE_TRUE(aVisitor.mDOMEvent, NS_ERROR_UNEXPECTED); if (!aOwner) { diff --git a/dom/indexedDB/IndexedDatabaseManager.h b/dom/indexedDB/IndexedDatabaseManager.h index 1a199047427..111828e6c3d 100644 --- a/dom/indexedDB/IndexedDatabaseManager.h +++ b/dom/indexedDB/IndexedDatabaseManager.h @@ -22,9 +22,9 @@ #define INDEXEDDB_MANAGER_CONTRACTID "@mozilla.org/dom/indexeddb/manager;1" class nsPIDOMWindow; -class nsEventChainPostVisitor; namespace mozilla { +class EventChainPostVisitor; namespace dom { class TabContext; namespace quota { @@ -132,7 +132,7 @@ public: static nsresult FireWindowOnError(nsPIDOMWindow* aOwner, - nsEventChainPostVisitor& aVisitor); + EventChainPostVisitor& aVisitor); static bool TabContextMayAccessOrigin(const mozilla::dom::TabContext& aContext, diff --git a/dom/interfaces/events/nsIDOMEventTarget.idl b/dom/interfaces/events/nsIDOMEventTarget.idl index 6a11a66ec81..bd009bf784b 100644 --- a/dom/interfaces/events/nsIDOMEventTarget.idl +++ b/dom/interfaces/events/nsIDOMEventTarget.idl @@ -13,6 +13,7 @@ using mozilla::dom::Nullable; namespace mozilla { +class EventChainPostVisitor; class EventChainPreVisitor; class EventListenerManager; namespace dom { @@ -21,7 +22,6 @@ class EventTarget; } // namespace mozilla class nsPresContext; -class nsEventChainPostVisitor; %} /** @@ -32,11 +32,11 @@ class nsEventChainPostVisitor; * http://www.w3.org/TR/DOM-Level-2-Events/ */ -[ref] native nsEventChainPostVisitorRef(nsEventChainPostVisitor); [ptr] native WidgetEventPtr(mozilla::WidgetEvent); [ptr] native nsPresContextPtr(nsPresContext); [ptr] native nsEventStatusPtr(nsEventStatus); [ptr] native JSContextPtr(JSContext); +[ref] native EventChainPostVisitorRef(mozilla::EventChainPostVisitor); [ref] native EventChainPreVisitorRef(mozilla::EventChainPreVisitor); [ptr] native EventListenerManagerPtr(mozilla::EventListenerManager); [ptr] native EventTargetPtr(mozilla::dom::EventTarget); @@ -231,7 +231,7 @@ interface nsIDOMEventTarget : nsISupports * called just before possible event handlers on this object will be called. */ [noscript, nostdcall] - void WillHandleEvent(in nsEventChainPostVisitorRef aVisitor); + void WillHandleEvent(in EventChainPostVisitorRef aVisitor); /** * Called after the bubble phase of the system event group. @@ -242,7 +242,7 @@ interface nsIDOMEventTarget : nsISupports * @note Only nsEventDispatcher should call this method. */ [noscript, nostdcall] - void PostHandleEvent(in nsEventChainPostVisitorRef aVisitor); + void PostHandleEvent(in EventChainPostVisitorRef aVisitor); /** * Dispatch an event. @@ -287,7 +287,7 @@ interface nsIDOMEventTarget : nsISupports #define NS_IMPL_DOMTARGET_DEFAULTS(_class) \ mozilla::dom::EventTarget* _class::GetTargetForDOMEvent() { return this; } \ mozilla::dom::EventTarget* _class::GetTargetForEventTargetChain() { return this; } \ -nsresult _class::WillHandleEvent(nsEventChainPostVisitor& aVisitor) { return NS_OK; } \ +nsresult _class::WillHandleEvent(mozilla::EventChainPostVisitor& aVisitor) { return NS_OK; } \ JSContext* _class::GetJSContextForEventHandlers() { return nullptr; } #define NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(aClass) \ diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index fd244e8e07a..52057fd0f70 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -449,7 +449,7 @@ class MOZ_STACK_CLASS nsPresShellEventCB : public nsDispatchingCallback public: nsPresShellEventCB(PresShell* aPresShell) : mPresShell(aPresShell) {} - virtual void HandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE + virtual void HandleEvent(EventChainPostVisitor& aVisitor) MOZ_OVERRIDE { if (aVisitor.mPresContext && aVisitor.mEvent->eventStructType != NS_EVENT) { if (aVisitor.mEvent->message == NS_MOUSE_BUTTON_DOWN || From bdfb32e04946ab097f9f4b6ddac55382d5363977 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 18 Mar 2014 13:48:20 +0900 Subject: [PATCH 38/88] Bug 983049 part.4 Rename nsDispatchingCallback to mozilla::EventDispatchingCallback r=smaug --- dom/events/IMEStateManager.cpp | 3 ++- dom/events/IMEStateManager.h | 4 ++-- dom/events/TextComposition.cpp | 2 +- dom/events/TextComposition.h | 4 ++-- dom/events/nsEventDispatcher.cpp | 6 +++--- dom/events/nsEventDispatcher.h | 13 +++++++------ dom/events/nsEventStateManager.cpp | 2 +- layout/base/nsPresShell.cpp | 2 +- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/dom/events/IMEStateManager.cpp b/dom/events/IMEStateManager.cpp index fea29daa16c..f8d5c4f149a 100644 --- a/dom/events/IMEStateManager.cpp +++ b/dom/events/IMEStateManager.cpp @@ -29,6 +29,7 @@ #include "nsISelection.h" #include "nsISupports.h" #include "nsPresContext.h" +#include "nsEventDispatcher.h" namespace mozilla { @@ -500,7 +501,7 @@ IMEStateManager::DispatchCompositionEvent(nsINode* aEventTargetNode, nsPresContext* aPresContext, WidgetEvent* aEvent, nsEventStatus* aStatus, - nsDispatchingCallback* aCallBack) + EventDispatchingCallback* aCallBack) { MOZ_ASSERT(aEvent->eventStructType == NS_COMPOSITION_EVENT || aEvent->eventStructType == NS_TEXT_EVENT); diff --git a/dom/events/IMEStateManager.h b/dom/events/IMEStateManager.h index 58cd67d2008..86f642dc8ee 100644 --- a/dom/events/IMEStateManager.h +++ b/dom/events/IMEStateManager.h @@ -9,7 +9,6 @@ #include "mozilla/EventForwards.h" #include "nsIWidget.h" -class nsDispatchingCallback; class nsIContent; class nsIDOMMouseEvent; class nsINode; @@ -19,6 +18,7 @@ class nsISelection; namespace mozilla { +class EventDispatchingCallback; class IMEContentObserver; class TextCompositionArray; class TextComposition; @@ -94,7 +94,7 @@ public: nsPresContext* aPresContext, WidgetEvent* aEvent, nsEventStatus* aStatus, - nsDispatchingCallback* aCallBack); + EventDispatchingCallback* aCallBack); /** * Get TextComposition from widget. diff --git a/dom/events/TextComposition.cpp b/dom/events/TextComposition.cpp index f1f7b50d453..d3f3d6f53e5 100644 --- a/dom/events/TextComposition.cpp +++ b/dom/events/TextComposition.cpp @@ -56,7 +56,7 @@ TextComposition::MatchesNativeContext(nsIWidget* aWidget) const void TextComposition::DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus* aStatus, - nsDispatchingCallback* aCallBack) + EventDispatchingCallback* aCallBack) { if (aEvent->message == NS_COMPOSITION_UPDATE) { mLastData = aEvent->AsCompositionEvent()->data; diff --git a/dom/events/TextComposition.h b/dom/events/TextComposition.h index f888739933b..865cdecaf08 100644 --- a/dom/events/TextComposition.h +++ b/dom/events/TextComposition.h @@ -18,11 +18,11 @@ #include "mozilla/EventForwards.h" #include "mozilla/TextRange.h" -class nsDispatchingCallback; class nsIEditor; namespace mozilla { +class EventDispatchingCallback; class IMEStateManager; /** @@ -219,7 +219,7 @@ private: */ void DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus* aStatus, - nsDispatchingCallback* aCallBack); + EventDispatchingCallback* aCallBack); /** * Calculate composition offset then notify composition update to widget diff --git a/dom/events/nsEventDispatcher.cpp b/dom/events/nsEventDispatcher.cpp index 1809ae8caf6..4098bce2304 100644 --- a/dom/events/nsEventDispatcher.cpp +++ b/dom/events/nsEventDispatcher.cpp @@ -157,7 +157,7 @@ public: */ static void HandleEventTargetChain(nsTArray& aChain, EventChainPostVisitor& aVisitor, - nsDispatchingCallback* aCallback, + EventDispatchingCallback* aCallback, ELMCreationDetector& aCd); /** @@ -242,7 +242,7 @@ void nsEventTargetChainItem::HandleEventTargetChain( nsTArray& aChain, EventChainPostVisitor& aVisitor, - nsDispatchingCallback* aCallback, + EventDispatchingCallback* aCallback, ELMCreationDetector& aCd) { // Save the target so that it can be restored later. @@ -379,7 +379,7 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget, WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent, nsEventStatus* aEventStatus, - nsDispatchingCallback* aCallback, + EventDispatchingCallback* aCallback, nsCOMArray* aTargets) { PROFILER_LABEL("nsEventDispatcher", "Dispatch"); diff --git a/dom/events/nsEventDispatcher.h b/dom/events/nsEventDispatcher.h index 71b36c223ad..2fd42224cae 100644 --- a/dom/events/nsEventDispatcher.h +++ b/dom/events/nsEventDispatcher.h @@ -206,19 +206,20 @@ public: } }; -} // namespace mozilla - /** - * If an nsDispatchingCallback object is passed to Dispatch, + * If an EventDispatchingCallback object is passed to Dispatch, * its HandleEvent method is called after handling the default event group, * before handling the system event group. * This is used in nsPresShell. */ -class MOZ_STACK_CLASS nsDispatchingCallback { +class MOZ_STACK_CLASS EventDispatchingCallback +{ public: - virtual void HandleEvent(mozilla::EventChainPostVisitor& aVisitor) = 0; + virtual void HandleEvent(EventChainPostVisitor& aVisitor) = 0; }; +} // namespace mozilla + /** * The generic class for event dispatching. * Must not be used outside Gecko! @@ -247,7 +248,7 @@ public: mozilla::WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent = nullptr, nsEventStatus* aEventStatus = nullptr, - nsDispatchingCallback* aCallback = nullptr, + mozilla::EventDispatchingCallback* aCallback = nullptr, nsCOMArray* aTargets = nullptr); /** diff --git a/dom/events/nsEventStateManager.cpp b/dom/events/nsEventStateManager.cpp index 7919d63c5a1..dca5690b040 100644 --- a/dom/events/nsEventStateManager.cpp +++ b/dom/events/nsEventStateManager.cpp @@ -4033,7 +4033,7 @@ nsEventStateManager::SetCursor(int32_t aCursor, imgIContainer* aContainer, return NS_OK; } -class MOZ_STACK_CLASS nsESMEventCB : public nsDispatchingCallback +class MOZ_STACK_CLASS nsESMEventCB : public EventDispatchingCallback { public: nsESMEventCB(nsIContent* aTarget) : mTarget(aTarget) {} diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 52057fd0f70..03c6d3c9e8e 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -444,7 +444,7 @@ public: PresShell* mShell; }; -class MOZ_STACK_CLASS nsPresShellEventCB : public nsDispatchingCallback +class MOZ_STACK_CLASS nsPresShellEventCB : public EventDispatchingCallback { public: nsPresShellEventCB(PresShell* aPresShell) : mPresShell(aPresShell) {} From b7a8d4a392c13638400119dba88d6bf58c5ead76 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 18 Mar 2014 13:48:21 +0900 Subject: [PATCH 39/88] Bug 983049 part.5 Rename nsEventDispatcher to mozilla::EventDispatcher r=smaug --HG-- rename : dom/events/nsEventDispatcher.cpp => dom/events/EventDispatcher.cpp rename : dom/events/nsEventDispatcher.h => dom/events/EventDispatcher.h --- content/base/src/Attr.cpp | 2 +- content/base/src/Element.cpp | 2 +- content/base/src/FileIOObject.cpp | 2 +- content/base/src/FragmentOrElement.cpp | 2 +- content/base/src/WebSocket.cpp | 1 - content/base/src/nsContentUtils.cpp | 6 +-- content/base/src/nsCopySupport.cpp | 9 ++-- content/base/src/nsDocument.cpp | 19 ++++--- content/base/src/nsFrameLoader.cpp | 1 - content/base/src/nsGenConImageContent.cpp | 2 +- content/base/src/nsGenericDOMDataNode.cpp | 1 - content/base/src/nsINode.cpp | 9 ++-- content/base/src/nsImageLoadingContent.cpp | 1 - .../base/src/nsInProcessTabChildGlobal.cpp | 2 +- content/base/src/nsObjectLoadingContent.cpp | 4 +- content/base/src/nsScriptElement.cpp | 4 +- content/base/src/nsXMLHttpRequest.cpp | 8 +-- .../html/content/src/HTMLAnchorElement.cpp | 2 +- content/html/content/src/HTMLAreaElement.cpp | 2 +- .../html/content/src/HTMLButtonElement.cpp | 8 +-- .../html/content/src/HTMLFieldSetElement.cpp | 2 +- content/html/content/src/HTMLFormElement.cpp | 6 +-- content/html/content/src/HTMLImageElement.cpp | 2 +- content/html/content/src/HTMLInputElement.cpp | 28 ++++++----- content/html/content/src/HTMLLabelElement.cpp | 10 ++-- content/html/content/src/HTMLLinkElement.cpp | 2 +- content/html/content/src/HTMLMediaElement.cpp | 1 - content/html/content/src/HTMLMenuElement.cpp | 6 +-- .../html/content/src/HTMLMenuItemElement.cpp | 2 +- .../html/content/src/HTMLOptGroupElement.cpp | 3 +- .../content/src/HTMLOptionsCollection.cpp | 1 - .../html/content/src/HTMLSelectElement.cpp | 2 +- .../html/content/src/HTMLTextAreaElement.cpp | 6 +-- content/html/content/src/HTMLVideoElement.cpp | 1 - content/html/content/src/UndoManager.cpp | 8 +-- .../html/content/src/nsGenericHTMLElement.cpp | 7 +-- .../mathml/content/src/nsMathMLElement.cpp | 2 +- content/svg/content/src/SVGAElement.cpp | 2 +- content/svg/content/src/SVGSVGElement.cpp | 2 +- content/xml/document/src/XMLDocument.cpp | 5 +- content/xul/content/src/nsXULElement.cpp | 14 +++--- content/xul/document/src/XULDocument.cpp | 6 +-- .../document/src/nsXULCommandDispatcher.cpp | 4 +- dom/base/MessagePort.cpp | 1 - dom/base/nsFocusManager.cpp | 4 +- dom/base/nsGlobalWindow.cpp | 37 +++++++------- dom/base/nsJSEnvironment.cpp | 10 ++-- dom/base/nsWindowRoot.cpp | 10 ++-- dom/browser-element/BrowserElementParent.cpp | 15 +++--- dom/devicestorage/nsDeviceStorage.cpp | 2 +- dom/events/AsyncEventDispatcher.cpp | 10 ++-- ...ventDispatcher.cpp => EventDispatcher.cpp} | 50 ++++++++++--------- ...{nsEventDispatcher.h => EventDispatcher.h} | 32 ++++++------ dom/events/EventListenerManager.cpp | 8 +-- dom/events/EventListenerService.cpp | 6 +-- dom/events/IMEStateManager.cpp | 1 - dom/events/TextComposition.cpp | 6 +-- dom/events/moz.build | 4 +- dom/events/nsDOMEventTargetHelper.cpp | 9 ++-- dom/events/nsEventStateManager.cpp | 33 ++++++------ dom/file/ArchiveRequest.cpp | 2 +- dom/file/FileRequest.cpp | 2 +- dom/file/LockedFile.cpp | 2 +- dom/indexedDB/IDBCursor.cpp | 1 - dom/indexedDB/IDBDatabase.cpp | 2 +- dom/indexedDB/IDBIndex.cpp | 1 - dom/indexedDB/IDBObjectStore.cpp | 1 - dom/indexedDB/IDBRequest.cpp | 2 +- dom/indexedDB/IDBTransaction.cpp | 2 +- dom/indexedDB/IndexedDatabaseManager.cpp | 2 +- dom/interfaces/events/nsIDOMEventTarget.idl | 8 +-- dom/ipc/TabChild.h | 2 +- dom/ipc/TabMessageUtils.cpp | 10 ++-- dom/smil/nsSMILTimedElement.cpp | 4 +- dom/src/offline/nsDOMOfflineResourceList.cpp | 8 +-- dom/workers/MessagePort.cpp | 2 +- dom/workers/SharedWorker.cpp | 2 +- dom/workers/WorkerPrivate.cpp | 8 +-- dom/workers/XMLHttpRequest.cpp | 1 - dom/xbl/nsXBLPrototypeHandler.cpp | 1 - layout/base/nsDocumentViewer.cpp | 11 ++-- layout/base/nsPresContext.cpp | 5 +- layout/base/nsPresShell.cpp | 20 ++++---- layout/generic/nsGfxScrollFrame.cpp | 12 ++--- layout/style/nsAnimationManager.cpp | 4 +- layout/style/nsTransitionManager.cpp | 4 +- layout/xul/nsBoxFrame.cpp | 1 - layout/xul/nsImageBoxFrame.cpp | 4 +- layout/xul/nsMenuFrame.cpp | 12 ++--- layout/xul/nsMenuPopupFrame.cpp | 4 +- layout/xul/nsResizerFrame.cpp | 1 - layout/xul/nsTitleBarFrame.cpp | 1 - layout/xul/nsXULPopupManager.cpp | 10 ++-- layout/xul/nsXULTooltipListener.cpp | 1 - layout/xul/tree/nsTreeBodyFrame.cpp | 8 +-- layout/xul/tree/nsTreeSelection.cpp | 1 - parser/html/nsHtml5SVGLoadDispatcher.cpp | 4 +- parser/html/nsHtml5TreeBuilderCppSupplement.h | 1 - 98 files changed, 295 insertions(+), 319 deletions(-) rename dom/events/{nsEventDispatcher.cpp => EventDispatcher.cpp} (95%) rename dom/events/{nsEventDispatcher.h => EventDispatcher.h} (91%) diff --git a/content/base/src/Attr.cpp b/content/base/src/Attr.cpp index 66ddee80656..268cd44b9b6 100644 --- a/content/base/src/Attr.cpp +++ b/content/base/src/Attr.cpp @@ -10,6 +10,7 @@ #include "mozilla/dom/Attr.h" #include "mozilla/dom/AttrBinding.h" #include "mozilla/dom/Element.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/InternalMutationEvent.h" #include "nsContentCreatorFunctions.h" #include "nsError.h" @@ -18,7 +19,6 @@ #include "nsIContentInlines.h" #include "nsIDocument.h" #include "nsIDOMUserDataHandler.h" -#include "nsEventDispatcher.h" #include "nsGkAtoms.h" #include "nsCOMArray.h" #include "nsNameSpaceManager.h" diff --git a/content/base/src/Element.cpp b/content/base/src/Element.cpp index 04a59944661..89b0be24d2b 100644 --- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -50,6 +50,7 @@ #include "nsIDOMMutationEvent.h" #include "mozilla/AsyncEventDispatcher.h" #include "mozilla/ContentEvents.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/EventListenerManager.h" #include "mozilla/InternalMutationEvent.h" #include "mozilla/MouseEvents.h" @@ -91,7 +92,6 @@ #include "nsGenericHTMLElement.h" #include "nsIEditor.h" #include "nsIEditorIMESupport.h" -#include "nsEventDispatcher.h" #include "nsContentCreatorFunctions.h" #include "nsIControllers.h" #include "nsView.h" diff --git a/content/base/src/FileIOObject.cpp b/content/base/src/FileIOObject.cpp index d72e24c33b3..4ca682a5ac6 100644 --- a/content/base/src/FileIOObject.cpp +++ b/content/base/src/FileIOObject.cpp @@ -4,12 +4,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "FileIOObject.h" +#include "mozilla/EventDispatcher.h" #include "nsDOMFile.h" #include "nsError.h" #include "nsIDOMEvent.h" #include "nsIDOMProgressEvent.h" #include "nsComponentManagerUtils.h" -#include "nsEventDispatcher.h" #define ERROR_STR "error" #define ABORT_STR "abort" diff --git a/content/base/src/FragmentOrElement.cpp b/content/base/src/FragmentOrElement.cpp index 61f04d70b3d..7d573a37efd 100644 --- a/content/base/src/FragmentOrElement.cpp +++ b/content/base/src/FragmentOrElement.cpp @@ -18,6 +18,7 @@ #include "mozilla/dom/FragmentOrElement.h" #include "mozilla/AsyncEventDispatcher.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/EventListenerManager.h" #include "mozilla/dom/Attr.h" #include "nsDOMAttributeMap.h" @@ -91,7 +92,6 @@ #include "nsGenericHTMLElement.h" #include "nsIEditor.h" #include "nsIEditorIMESupport.h" -#include "nsEventDispatcher.h" #include "nsContentCreatorFunctions.h" #include "nsIControllers.h" #include "nsView.h" diff --git a/content/base/src/WebSocket.cpp b/content/base/src/WebSocket.cpp index b54b4888f06..db52277ff1f 100644 --- a/content/base/src/WebSocket.cpp +++ b/content/base/src/WebSocket.cpp @@ -17,7 +17,6 @@ #include "nsIXPConnect.h" #include "nsContentUtils.h" #include "nsCxPusher.h" -#include "nsEventDispatcher.h" #include "nsError.h" #include "nsIScriptObjectPrincipal.h" #include "nsIURL.h" diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 9a047eb5e0a..91c0b212ee2 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -41,6 +41,7 @@ #include "mozilla/dom/TextDecoder.h" #include "mozilla/dom/TouchEvent.h" #include "mozilla/dom/ShadowRoot.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/EventListenerManager.h" #include "mozilla/IMEStateManager.h" #include "mozilla/InternalMutationEvent.h" @@ -74,7 +75,6 @@ #include "nsDOMJSUtils.h" #include "nsDOMMutationObserver.h" #include "nsError.h" -#include "nsEventDispatcher.h" #include "nsEventStateManager.h" #include "nsFocusManager.h" #include "nsGenericHTMLElement.h" @@ -3630,7 +3630,7 @@ nsContentUtils::MaybeFireNodeRemoved(nsINode* aChild, nsINode* aParent, NS_PRECONDITION(aChild->OwnerDoc() == aOwnerDoc, "Wrong owner-doc"); // This checks that IsSafeToRunScript is true since we don't want to fire - // events when that is false. We can't rely on nsEventDispatcher to assert + // events when that is false. We can't rely on EventDispatcher to assert // this in this situation since most of the time there are no mutation // event listeners, in which case we won't even attempt to dispatch events. // However this also allows for two exceptions. First off, we don't assert @@ -3661,7 +3661,7 @@ nsContentUtils::MaybeFireNodeRemoved(nsINode* aChild, nsINode* aParent, mutation.mRelatedNode = do_QueryInterface(aParent); mozAutoSubtreeModified subtree(aOwnerDoc, aParent); - nsEventDispatcher::Dispatch(aChild, nullptr, &mutation); + EventDispatcher::Dispatch(aChild, nullptr, &mutation); } } diff --git a/content/base/src/nsCopySupport.cpp b/content/base/src/nsCopySupport.cpp index 17b1c64ae58..9b43ba4aa63 100644 --- a/content/base/src/nsCopySupport.cpp +++ b/content/base/src/nsCopySupport.cpp @@ -19,7 +19,6 @@ #include "imgIContainer.h" #include "nsIPresShell.h" #include "nsFocusManager.h" -#include "nsEventDispatcher.h" #include "mozilla/dom/DataTransfer.h" #include "nsIDocShell.h" @@ -48,9 +47,9 @@ #include "mozilla/ContentEvents.h" #include "mozilla/dom/Element.h" -#include "mozilla/Selection.h" - +#include "mozilla/EventDispatcher.h" #include "mozilla/Preferences.h" +#include "mozilla/Selection.h" using namespace mozilla; using namespace mozilla::dom; @@ -652,8 +651,8 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres nsEventStatus status = nsEventStatus_eIgnore; InternalClipboardEvent evt(true, aType); evt.clipboardData = clipboardData; - nsEventDispatcher::Dispatch(content, presShell->GetPresContext(), &evt, nullptr, - &status); + EventDispatcher::Dispatch(content, presShell->GetPresContext(), &evt, + nullptr, &status); // If the event was cancelled, don't do the clipboard operation doDefault = (status != nsEventStatus_eConsumeNoDefault); } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 6b21fddae49..40cb67bd4af 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -120,7 +120,7 @@ #include "nsDateTimeFormatCID.h" #include "nsIDateTimeFormat.h" -#include "nsEventDispatcher.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/InternalMutationEvent.h" #include "nsDOMCID.h" @@ -4856,7 +4856,7 @@ nsDocument::DispatchContentLoadedEvents() event->SetTrusted(true); // To dispatch this event we must manually call - // nsEventDispatcher::Dispatch() on the ancestor document since the + // EventDispatcher::Dispatch() on the ancestor document since the // target is not in the same document, so the event would never reach // the ancestor document if we used the normal event // dispatching code. @@ -4870,8 +4870,8 @@ nsDocument::DispatchContentLoadedEvents() nsRefPtr context = shell->GetPresContext(); if (context) { - nsEventDispatcher::Dispatch(parent, context, innerEvent, event, - &status); + EventDispatcher::Dispatch(parent, context, innerEvent, event, + &status); } } } @@ -7675,10 +7675,9 @@ nsIDocument::CreateEvent(const nsAString& aEventType, ErrorResult& rv) const // Create event even without presContext. nsCOMPtr ev; - rv = - nsEventDispatcher::CreateEvent(const_cast(this), - presContext, nullptr, aEventType, - getter_AddRefs(ev)); + rv = EventDispatcher::CreateEvent(const_cast(this), + presContext, nullptr, aEventType, + getter_AddRefs(ev)); return ev ? dont_AddRef(ev.forget().take()->InternalDOMEvent()) : nullptr; } @@ -8669,8 +8668,8 @@ nsDocument::DispatchPageTransition(EventTarget* aDispatchTarget, aPersisted))) { event->SetTrusted(true); event->SetTarget(this); - nsEventDispatcher::DispatchDOMEvent(aDispatchTarget, nullptr, event, - nullptr, nullptr); + EventDispatcher::DispatchDOMEvent(aDispatchTarget, nullptr, event, + nullptr, nullptr); } } } diff --git a/content/base/src/nsFrameLoader.cpp b/content/base/src/nsFrameLoader.cpp index cc9e35ba0a7..a966040fba5 100644 --- a/content/base/src/nsFrameLoader.cpp +++ b/content/base/src/nsFrameLoader.cpp @@ -45,7 +45,6 @@ #include "nsIScrollableFrame.h" #include "nsSubDocumentFrame.h" #include "nsError.h" -#include "nsEventDispatcher.h" #include "nsISHistory.h" #include "nsISHistoryInternal.h" #include "nsIDOMHTMLDocument.h" diff --git a/content/base/src/nsGenConImageContent.cpp b/content/base/src/nsGenConImageContent.cpp index f1ffd92613e..afa74f4ce54 100644 --- a/content/base/src/nsGenConImageContent.cpp +++ b/content/base/src/nsGenConImageContent.cpp @@ -15,8 +15,8 @@ #include "nsImageLoadingContent.h" #include "imgIRequest.h" #include "nsEventStates.h" -#include "nsEventDispatcher.h" #include "mozilla/BasicEvents.h" +#include "mozilla/EventDispatcher.h" using namespace mozilla; diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index e95b4f669b7..36da6450564 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -26,7 +26,6 @@ #include "nsDOMString.h" #include "nsIDOMUserDataHandler.h" #include "nsChangeHint.h" -#include "nsEventDispatcher.h" #include "nsCOMArray.h" #include "nsNodeUtils.h" #include "mozilla/dom/DirectionalityUtils.h" diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index b880c9cf248..fa014abe28e 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -15,6 +15,7 @@ #include "mozAutoDocUpdate.h" #include "mozilla/AsyncEventDispatcher.h" #include "mozilla/CORSMode.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/EventListenerManager.h" #include "mozilla/InternalMutationEvent.h" #include "mozilla/Likely.h" @@ -39,7 +40,6 @@ #include "nsDOMMutationObserver.h" #include "nsDOMString.h" #include "nsDOMTokenList.h" -#include "nsEventDispatcher.h" #include "nsEventStateManager.h" #include "nsFocusManager.h" #include "nsFrameManager.h" @@ -1162,8 +1162,7 @@ nsINode::DispatchEvent(nsIDOMEvent *aEvent, bool* aRetVal) nsEventStatus status = nsEventStatus_eIgnore; nsresult rv = - nsEventDispatcher::DispatchDOMEvent(this, nullptr, aEvent, context, - &status); + EventDispatcher::DispatchDOMEvent(this, nullptr, aEvent, context, &status); *aRetVal = (status != nsEventStatus_eConsumeNoDefault); return rv; } @@ -1180,8 +1179,8 @@ nsINode::DispatchDOMEvent(WidgetEvent* aEvent, nsPresContext* aPresContext, nsEventStatus* aEventStatus) { - return nsEventDispatcher::DispatchDOMEvent(this, aEvent, aDOMEvent, - aPresContext, aEventStatus); + return EventDispatcher::DispatchDOMEvent(this, aEvent, aDOMEvent, + aPresContext, aEventStatus); } EventListenerManager* diff --git a/content/base/src/nsImageLoadingContent.cpp b/content/base/src/nsImageLoadingContent.cpp index 3701efee424..64c7b0c8afd 100644 --- a/content/base/src/nsImageLoadingContent.cpp +++ b/content/base/src/nsImageLoadingContent.cpp @@ -40,7 +40,6 @@ #include "nsContentUtils.h" #include "nsLayoutUtils.h" #include "nsIContentPolicy.h" -#include "nsEventDispatcher.h" #include "nsSVGEffects.h" #include "mozAutoDocUpdate.h" diff --git a/content/base/src/nsInProcessTabChildGlobal.cpp b/content/base/src/nsInProcessTabChildGlobal.cpp index 05b175531bb..7027f522e5d 100644 --- a/content/base/src/nsInProcessTabChildGlobal.cpp +++ b/content/base/src/nsInProcessTabChildGlobal.cpp @@ -8,7 +8,6 @@ #include "nsContentUtils.h" #include "nsIScriptSecurityManager.h" #include "nsIInterfaceRequestorUtils.h" -#include "nsEventDispatcher.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIJSRuntimeService.h" @@ -19,6 +18,7 @@ #include "xpcpublic.h" #include "nsIMozBrowserFrame.h" #include "nsDOMClassInfoID.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/dom/StructuredCloneUtils.h" #include "js/StructuredClone.h" diff --git a/content/base/src/nsObjectLoadingContent.cpp b/content/base/src/nsObjectLoadingContent.cpp index 971c1b67ba9..e83c9cab370 100644 --- a/content/base/src/nsObjectLoadingContent.cpp +++ b/content/base/src/nsObjectLoadingContent.cpp @@ -11,7 +11,6 @@ // Interface headers #include "imgLoader.h" -#include "nsEventDispatcher.h" #include "nsIContent.h" #include "nsIDocShell.h" #include "nsIDocument.h" @@ -81,6 +80,7 @@ #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/Event.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/Telemetry.h" #ifdef XP_WIN @@ -376,7 +376,7 @@ nsPluginCrashedEvent::Run() variant->SetAsBool(mSubmittedCrashReport); containerEvent->SetData(NS_LITERAL_STRING("submittedCrashReport"), variant); - nsEventDispatcher::DispatchDOMEvent(mContent, nullptr, event, nullptr, nullptr); + EventDispatcher::DispatchDOMEvent(mContent, nullptr, event, nullptr, nullptr); return NS_OK; } diff --git a/content/base/src/nsScriptElement.cpp b/content/base/src/nsScriptElement.cpp index 26004d1a862..e90ace95c07 100644 --- a/content/base/src/nsScriptElement.cpp +++ b/content/base/src/nsScriptElement.cpp @@ -5,9 +5,9 @@ #include "nsScriptElement.h" #include "mozilla/BasicEvents.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/dom/Element.h" #include "nsContentUtils.h" -#include "nsEventDispatcher.h" #include "nsPresContext.h" #include "nsScriptLoader.h" #include "nsIParser.h" @@ -63,7 +63,7 @@ nsScriptElement::ScriptEvaluated(nsresult aResult, // Load event doesn't bubble. event.mFlags.mBubbles = (type != NS_LOAD); - nsEventDispatcher::Dispatch(cont, presContext, &event, nullptr, &status); + EventDispatcher::Dispatch(cont, presContext, &event, nullptr, &status); } return rv; diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index b9cc7ffb776..a06b896b932 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -8,6 +8,7 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/dom/XMLHttpRequestUploadBinding.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/EventListenerManager.h" #include "mozilla/MemoryReporting.h" #include "nsDOMBlobBuilder.h" @@ -36,7 +37,6 @@ #include "nsICachingChannel.h" #include "nsContentUtils.h" #include "nsCxPusher.h" -#include "nsEventDispatcher.h" #include "nsCycleCollectionParticipant.h" #include "nsIContentPolicy.h" #include "nsContentPolicyUtils.h" @@ -1393,9 +1393,9 @@ nsXMLHttpRequest::GetLoadGroup() const nsresult nsXMLHttpRequest::CreateReadystatechangeEvent(nsIDOMEvent** aDOMEvent) { - nsresult rv = nsEventDispatcher::CreateEvent(this, nullptr, nullptr, - NS_LITERAL_STRING("Events"), - aDOMEvent); + nsresult rv = EventDispatcher::CreateEvent(this, nullptr, nullptr, + NS_LITERAL_STRING("Events"), + aDOMEvent); if (NS_FAILED(rv)) { return rv; } diff --git a/content/html/content/src/HTMLAnchorElement.cpp b/content/html/content/src/HTMLAnchorElement.cpp index 1ea30e99ce7..82c6754c808 100644 --- a/content/html/content/src/HTMLAnchorElement.cpp +++ b/content/html/content/src/HTMLAnchorElement.cpp @@ -7,10 +7,10 @@ #include "mozilla/dom/HTMLAnchorElement.h" #include "mozilla/dom/HTMLAnchorElementBinding.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/MemoryReporting.h" #include "nsCOMPtr.h" #include "nsContentUtils.h" -#include "nsEventDispatcher.h" #include "nsGkAtoms.h" #include "nsHTMLDNSPrefetch.h" #include "nsIDocument.h" diff --git a/content/html/content/src/HTMLAreaElement.cpp b/content/html/content/src/HTMLAreaElement.cpp index 0c2bf811e5c..947be485f1a 100644 --- a/content/html/content/src/HTMLAreaElement.cpp +++ b/content/html/content/src/HTMLAreaElement.cpp @@ -8,8 +8,8 @@ #include "mozilla/Attributes.h" #include "mozilla/dom/HTMLAreaElementBinding.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/MemoryReporting.h" -#include "nsEventDispatcher.h" NS_IMPL_NS_NEW_HTML_ELEMENT(Area) diff --git a/content/html/content/src/HTMLButtonElement.cpp b/content/html/content/src/HTMLButtonElement.cpp index b8fb2d3bdcd..4a29c67c38e 100644 --- a/content/html/content/src/HTMLButtonElement.cpp +++ b/content/html/content/src/HTMLButtonElement.cpp @@ -23,11 +23,11 @@ #include "nsIDOMEvent.h" #include "nsIDocument.h" #include "mozilla/ContentEvents.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/MouseEvents.h" #include "mozilla/TextEvents.h" #include "nsUnicharUtils.h" #include "nsLayoutUtils.h" -#include "nsEventDispatcher.h" #include "nsPresState.h" #include "nsError.h" #include "nsFocusManager.h" @@ -278,9 +278,9 @@ HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor) NS_MOUSE_CLICK, nullptr, WidgetMouseEvent::eReal); event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD; - nsEventDispatcher::Dispatch(static_cast(this), - aVisitor.mPresContext, &event, nullptr, - &status); + EventDispatcher::Dispatch(static_cast(this), + aVisitor.mPresContext, &event, nullptr, + &status); aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault; } } diff --git a/content/html/content/src/HTMLFieldSetElement.cpp b/content/html/content/src/HTMLFieldSetElement.cpp index 43d771c3012..8e657541356 100644 --- a/content/html/content/src/HTMLFieldSetElement.cpp +++ b/content/html/content/src/HTMLFieldSetElement.cpp @@ -4,10 +4,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/BasicEvents.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/dom/HTMLFieldSetElement.h" #include "mozilla/dom/HTMLFieldSetElementBinding.h" #include "nsContentList.h" -#include "nsEventDispatcher.h" NS_IMPL_NS_NEW_HTML_ELEMENT(FieldSet) diff --git a/content/html/content/src/HTMLFormElement.cpp b/content/html/content/src/HTMLFormElement.cpp index 88d0c11f354..4c74c002135 100644 --- a/content/html/content/src/HTMLFormElement.cpp +++ b/content/html/content/src/HTMLFormElement.cpp @@ -7,6 +7,7 @@ #include "jsapi.h" #include "mozilla/ContentEvents.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/dom/HTMLFormControlsCollection.h" #include "mozilla/dom/HTMLFormElementBinding.h" #include "nsIHTMLDocument.h" @@ -47,8 +48,6 @@ #include "nsLayoutUtils.h" -#include "nsEventDispatcher.h" - #include "mozAutoDocUpdate.h" #include "nsIHTMLCollection.h" @@ -289,8 +288,7 @@ NS_IMETHODIMP HTMLFormElement::Reset() { InternalFormEvent event(true, NS_FORM_RESET); - nsEventDispatcher::Dispatch(static_cast(this), nullptr, - &event); + EventDispatcher::Dispatch(static_cast(this), nullptr, &event); return NS_OK; } diff --git a/content/html/content/src/HTMLImageElement.cpp b/content/html/content/src/HTMLImageElement.cpp index 2d35cd21bb3..2b7b32d3307 100644 --- a/content/html/content/src/HTMLImageElement.cpp +++ b/content/html/content/src/HTMLImageElement.cpp @@ -36,7 +36,7 @@ #include "nsRuleData.h" #include "nsIDOMHTMLMapElement.h" -#include "nsEventDispatcher.h" +#include "mozilla/EventDispatcher.h" #include "nsLayoutUtils.h" diff --git a/content/html/content/src/HTMLInputElement.cpp b/content/html/content/src/HTMLInputElement.cpp index bc3ec73d862..1b49140e3ee 100644 --- a/content/html/content/src/HTMLInputElement.cpp +++ b/content/html/content/src/HTMLInputElement.cpp @@ -57,11 +57,11 @@ #include "nsLinebreakConverter.h" //to strip out carriage returns #include "nsReadableUtils.h" #include "nsUnicharUtils.h" -#include "nsEventDispatcher.h" #include "nsLayoutUtils.h" #include "nsIDOMMutationEvent.h" #include "mozilla/ContentEvents.h" +#include "mozilla/EventDispatcher.h" #include "mozilla/InternalMutationEvent.h" #include "mozilla/TextEvents.h" #include "mozilla/TouchEvents.h" @@ -3201,8 +3201,8 @@ HTMLInputElement::DispatchSelectEvent(nsPresContext* aPresContext) WidgetEvent event(nsContentUtils::IsCallerChrome(), NS_FORM_SELECTED); mHandlingSelectEvent = true; - nsEventDispatcher::Dispatch(static_cast(this), - aPresContext, &event, nullptr, &status); + EventDispatcher::Dispatch(static_cast(this), + aPresContext, &event, nullptr, &status); mHandlingSelectEvent = false; } @@ -3983,9 +3983,9 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD; nsEventStatus status = nsEventStatus_eIgnore; - nsEventDispatcher::Dispatch(static_cast(this), - aVisitor.mPresContext, &event, - nullptr, &status); + EventDispatcher::Dispatch(static_cast(this), + aVisitor.mPresContext, &event, + nullptr, &status); aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault; } // case } // switch @@ -4017,9 +4017,10 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) NS_MOUSE_CLICK, nullptr, WidgetMouseEvent::eReal); event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD; - rv = nsEventDispatcher::Dispatch(ToSupports(selectedRadioButton), - aVisitor.mPresContext, - &event, nullptr, &status); + rv = + EventDispatcher::Dispatch(ToSupports(selectedRadioButton), + aVisitor.mPresContext, + &event, nullptr, &status); if (NS_SUCCEEDED(rv)) { aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault; } @@ -5466,13 +5467,14 @@ FireEventForAccessibility(nsIDOMHTMLInputElement* aTarget, { nsCOMPtr event; nsCOMPtr element = do_QueryInterface(aTarget); - if (NS_SUCCEEDED(nsEventDispatcher::CreateEvent(element, aPresContext, nullptr, - NS_LITERAL_STRING("Events"), - getter_AddRefs(event)))) { + if (NS_SUCCEEDED(EventDispatcher::CreateEvent(element, aPresContext, nullptr, + NS_LITERAL_STRING("Events"), + getter_AddRefs(event)))) { event->InitEvent(aEventType, true, true); event->SetTrusted(true); - nsEventDispatcher::DispatchDOMEvent(aTarget, nullptr, event, aPresContext, nullptr); + EventDispatcher::DispatchDOMEvent(aTarget, nullptr, event, aPresContext, + nullptr); } return NS_OK; diff --git a/content/html/content/src/HTMLLabelElement.cpp b/content/html/content/src/HTMLLabelElement.cpp index 3776eeeb9a7..39fb52afb22 100644 --- a/content/html/content/src/HTMLLabelElement.cpp +++ b/content/html/content/src/HTMLLabelElement.cpp @@ -7,10 +7,10 @@ * Implementation of HTML