From 45ef599c5d2dc69aafea577b8a18ada3e3d3a645 Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Mon, 17 Oct 2011 22:49:34 +0900 Subject: [PATCH 1/5] Bug 692819 - Assertion 'Shutdown the shutdown accessible' when collapse XUL tree, r=tbsaunde --- accessible/src/xul/nsXULTreeAccessible.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/accessible/src/xul/nsXULTreeAccessible.cpp b/accessible/src/xul/nsXULTreeAccessible.cpp index c2baa601a01..92512166543 100644 --- a/accessible/src/xul/nsXULTreeAccessible.cpp +++ b/accessible/src/xul/nsXULTreeAccessible.cpp @@ -883,12 +883,7 @@ nsXULTreeItemAccessibleBase::DoAction(PRUint8 aIndex) bool nsXULTreeItemAccessibleBase::IsDefunct() const { - if (nsAccessibleWrap::IsDefunct() || !mTree || !mTreeView || mRow < 0) - return PR_TRUE; - - PRInt32 rowCount = 0; - nsresult rv = mTreeView->GetRowCount(&rowCount); - return NS_FAILED(rv) || mRow >= rowCount; + return nsAccessibleWrap::IsDefunct() || !mTree || !mTreeView || mRow < 0; } void From 2fe3ac75d0ba908f96b175c5b1d7c60aa5a1aae4 Mon Sep 17 00:00:00 2001 From: Quentin Headen Date: Sun, 16 Oct 2011 22:06:24 -0400 Subject: [PATCH 2/5] Bug 364914 - Do not spell check the contents of a textarea until it's focused for the first time; r=ehsan --- .../base/content/test/test_contextmenu.html | 33 +++++++--- .../html/content/src/nsTextEditorState.cpp | 4 ++ editor/composer/test/test_bug338427.html | 2 +- editor/idl/nsIPlaintextEditor.idl | 2 + editor/libeditor/base/nsEditor.h | 9 ++- .../libeditor/base/nsEditorEventListener.cpp | 11 ++++ .../libeditor/text/tests/test_bug596333.html | 60 +++++++++++-------- .../libeditor/text/tests/test_bug636465.xul | 6 +- layout/reftests/editor/reftest.list | 38 ++++++++---- .../editor/spellcheck-input-nofocus-ref.html | 6 ++ .../editor/spellcheck-textarea-focused.html | 12 ++++ .../spellcheck-textarea-nofocus-ref.html | 6 ++ .../editor/spellcheck-textarea-nofocus.html | 6 ++ .../editor/spellcheck-textarea-ref.html | 4 ++ 14 files changed, 150 insertions(+), 49 deletions(-) create mode 100644 layout/reftests/editor/spellcheck-input-nofocus-ref.html create mode 100644 layout/reftests/editor/spellcheck-textarea-focused.html create mode 100644 layout/reftests/editor/spellcheck-textarea-nofocus-ref.html create mode 100644 layout/reftests/editor/spellcheck-textarea-nofocus.html diff --git a/browser/base/content/test/test_contextmenu.html b/browser/base/content/test/test_contextmenu.html index dfda96b0806..23f986f427b 100644 --- a/browser/base/content/test/test_contextmenu.html +++ b/browser/base/content/test/test_contextmenu.html @@ -23,16 +23,33 @@ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); const Cc = Components.classes; const Ci = Components.interfaces; -function openContextMenuFor(element, shiftkey) { +function openContextMenuFor(element, shiftkey, shouldWaitForFocus) { // Context menu should be closed before we open it again. is(contextMenu.state, "closed", "checking if popup is closed"); - if (lastElement) - lastElement.blur(); - element.focus(); - lastElement = element; - var eventDetails = { type : "contextmenu", button : 2, shiftKey : shiftkey }; - synthesizeMouse(element, 2, 2, eventDetails, element.ownerDocument.defaultView); + //Some elements need time to focus and spellcheck before any tests are + //run on them. + if(shouldWaitForFocus) + { + if (lastElement) + lastElement.blur(); + element.focus(); + + SimpleTest.executeSoon(function() { + lastElement = element; + var eventDetails = { type : "contextmenu", button : 2, shiftKey : shiftkey }; + synthesizeMouse(element, 2, 2, eventDetails, element.ownerDocument.defaultView); + }); + } + else + { + if (lastElement) + lastElement.blur(); + element.focus(); + lastElement = element; + var eventDetails = { type : "contextmenu", button : 2, shiftKey : shiftkey }; + synthesizeMouse(element, 2, 2, eventDetails, element.ownerDocument.defaultView); + } } function closeContextMenu() { @@ -421,7 +438,7 @@ function runTest(testNum) { "---", null, "context-inspect", true]); closeContextMenu(); - openContextMenuFor(textarea); // Invoke context menu for next test. + openContextMenuFor(textarea, false, true); // Invoke context menu for next test, but wait for the spellcheck. break; case 12: diff --git a/content/html/content/src/nsTextEditorState.cpp b/content/html/content/src/nsTextEditorState.cpp index de97f64fafe..f673fff329b 100644 --- a/content/html/content/src/nsTextEditorState.cpp +++ b/content/html/content/src/nsTextEditorState.cpp @@ -1163,6 +1163,10 @@ nsTextEditorState::PrepareEditor(const nsAString *aValue) // Use async reflow and painting for text widgets to improve // performance. editorFlags |= nsIPlaintextEditor::eEditorUseAsyncUpdatesMask; + + // Spell check is diabled at creation time. It is enabled once + // the editor comes into focus. + editorFlags |= nsIPlaintextEditor::eEditorSkipSpellCheck; bool shouldInitializeEditor = false; nsCOMPtr newEditor; // the editor that we might create diff --git a/editor/composer/test/test_bug338427.html b/editor/composer/test/test_bug338427.html index bce1218b3df..ccd647bb0af 100644 --- a/editor/composer/test/test_bug338427.html +++ b/editor/composer/test/test_bug338427.html @@ -12,7 +12,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338427 Mozilla Bug 338427

- +
diff --git a/editor/idl/nsIPlaintextEditor.idl b/editor/idl/nsIPlaintextEditor.idl
index 4ee19bdde26..85fe6b9e9f8 100644
--- a/editor/idl/nsIPlaintextEditor.idl
+++ b/editor/idl/nsIPlaintextEditor.idl
@@ -77,6 +77,8 @@ interface nsIPlaintextEditor : nsISupports
   const long eEditorRightToLeft         = 0x2000;
   // when this flag is set, the internal direction of the editor is LTR.
   const long eEditorLeftToRight         = 0x4000;
+  // when this flag is set, the editor's text content is not spell checked.
+  const long eEditorSkipSpellCheck      = 0x8000;
 
   /*
    * The valid values for newlines handling.
diff --git a/editor/libeditor/base/nsEditor.h b/editor/libeditor/base/nsEditor.h
index f35ff190076..f3755d8c9be 100644
--- a/editor/libeditor/base/nsEditor.h
+++ b/editor/libeditor/base/nsEditor.h
@@ -396,8 +396,8 @@ protected:
   bool CanEnableSpellCheck()
   {
     // Check for password/readonly/disabled, which are not spellchecked
-    // regardless of DOM
-    return !IsPasswordEditor() && !IsReadonly() && !IsDisabled();
+    // regardless of DOM. Also, check to see if spell check should be skipped or not.
+    return !IsPasswordEditor() && !IsReadonly() && !IsDisabled() && !ShouldSkipSpellCheck();
   }
 
 public:
@@ -695,6 +695,11 @@ public:
   {
     return (mFlags & nsIPlaintextEditor::eEditorDontEchoPassword) != 0;
   }
+  
+  PRBool ShouldSkipSpellCheck() const
+  {
+    return (mFlags & nsIPlaintextEditor::eEditorSkipSpellCheck) != 0;
+  }
 
   bool IsTabbable() const
   {
diff --git a/editor/libeditor/base/nsEditorEventListener.cpp b/editor/libeditor/base/nsEditorEventListener.cpp
index 9a78a1a76d0..140d354ff42 100644
--- a/editor/libeditor/base/nsEditorEventListener.cpp
+++ b/editor/libeditor/base/nsEditorEventListener.cpp
@@ -905,6 +905,17 @@ nsEditorEventListener::Focus(nsIDOMEvent* aEvent)
   if (mEditor->IsDisabled()) {
     return NS_OK;
   }
+  
+  // If the spell check skip flag is still enabled from creation time,
+  // disable it because focused editors are allowed to spell check.
+  PRUint32 currentFlags = 0;
+  mEditor->GetFlags(¤tFlags);
+  if(currentFlags & nsIPlaintextEditor::eEditorSkipSpellCheck)
+  {
+    currentFlags ^= nsIPlaintextEditor::eEditorSkipSpellCheck;
+    mEditor->SetFlags(currentFlags);
+  }
+  
 
   nsCOMPtr target;
   aEvent->GetTarget(getter_AddRefs(target));
diff --git a/editor/libeditor/text/tests/test_bug596333.html b/editor/libeditor/text/tests/test_bug596333.html
index beb886964f5..c0b6a5ee9fc 100644
--- a/editor/libeditor/text/tests/test_bug596333.html
+++ b/editor/libeditor/text/tests/test_bug596333.html
@@ -64,47 +64,57 @@ function paste(str) {
   getEditor().pasteTransferable(trans);
 }
 
-function runTest() {
-  gMisspeltWords = ["haz", "cheezburger"];
-  is(isSpellingCheckOk(), true, "All misspellings before editing are accounted for.");
-
+function runOnFocus() {
   var edit = document.getElementById("edit");
-  append(" becaz I'm a lolcat!");
+  edit.removeEventListener("focus", runOnFocus, false);
+  
   SimpleTest.executeSoon(function() {
-    gMisspeltWords.push("becaz");
-    gMisspeltWords.push("lolcat");
-    is(isSpellingCheckOk(), true, "All misspellings after typing are accounted for.");
-
-    // Now, type an invalid word, and instead of hitting "space" at the end, just blur
-    // the textarea and see if the spell check after the blur event catches it.
-    append(" workd");
-    edit.blur();
+    gMisspeltWords = ["haz", "cheezburger"];
+    is(isSpellingCheckOk(), true, "All misspellings before editing are accounted for.");
+    append(" becaz I'm a lolcat!");
     SimpleTest.executeSoon(function() {
-      gMisspeltWords.push("workd");
-      is(isSpellingCheckOk(), true, "All misspellings after blur are accounted for.");
+      gMisspeltWords.push("becaz");
+      gMisspeltWords.push("lolcat");
+      is(isSpellingCheckOk(), true, "All misspellings after typing are accounted for.");
 
-      // Also, test the case when we're entering the first word in a textarea
-      gMisspeltWords = ["workd"];
-      edit.value = "";
-      append("workd ");
+      // Now, type an invalid word, and instead of hitting "space" at the end, just blur
+      // the textarea and see if the spell check after the blur event catches it.
+      append(" workd");
+      edit.blur();
       SimpleTest.executeSoon(function() {
-        is(isSpellingCheckOk(), true, "Misspelling in the first entered word is accounted for.");
+        gMisspeltWords.push("workd");
+        is(isSpellingCheckOk(), true, "All misspellings after blur are accounted for.");
 
-        // Make sure that pasting would also trigger spell checking for the previous word
+        // Also, test the case when we're entering the first word in a textarea
         gMisspeltWords = ["workd"];
         edit.value = "";
-        append("workd");
-        paste("           x");
+        append("workd ");
         SimpleTest.executeSoon(function() {
-          is(isSpellingCheckOk(), true, "Misspelling is accounted for after pasting.");
+          is(isSpellingCheckOk(), true, "Misspelling in the first entered word is accounted for.");
 
-          SimpleTest.finish();
+          // Make sure that pasting would also trigger spell checking for the previous word
+          gMisspeltWords = ["workd"];
+          edit.value = "";
+          append("workd");
+          paste("           x");
+          SimpleTest.executeSoon(function() {
+            is(isSpellingCheckOk(), true, "Misspelling is accounted for after pasting.");
+
+            SimpleTest.finish();
+          });
         });
       });
     });
   });
 }
 
+function runTest()
+{
+  var edit = document.getElementById("edit");
+  edit.addEventListener("focus", runOnFocus, false);
+  edit.focus();
+}
+
 function isSpellingCheckOk() {
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
diff --git a/editor/libeditor/text/tests/test_bug636465.xul b/editor/libeditor/text/tests/test_bug636465.xul
index eb0981422fa..ebb44dd90b7 100644
--- a/editor/libeditor/text/tests/test_bug636465.xul
+++ b/editor/libeditor/text/tests/test_bug636465.xul
@@ -30,16 +30,20 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=636465
   SimpleTest.waitForExplicitFinish();
 
   function runTest() {
+    var x = document.getElementById("x");
+    x.focus();
     setTimeout(function(){
+      x.blur();
       setTimeout(function(){
-        var x = document.getElementById("x");
         var spellCheckTrue = snapshotWindow(window);
         x.setAttribute("spellcheck", "false");
         setTimeout(function(){
           setTimeout(function(){
             var spellCheckFalse = snapshotWindow(window);
             x.setAttribute("spellcheck", "true");
+            x.focus();
             setTimeout(function(){
+              x.blur();
               setTimeout(function(){
                 var spellCheckTrueAgain = snapshotWindow(window);
                 x.removeAttribute("spellcheck");
diff --git a/layout/reftests/editor/reftest.list b/layout/reftests/editor/reftest.list
index 951c1f347dc..e534f46c9c9 100644
--- a/layout/reftests/editor/reftest.list
+++ b/layout/reftests/editor/reftest.list
@@ -18,18 +18,32 @@ needs-focus == passwd-4.html passwd-ref.html
 == emptypasswd-2.html emptypasswd-ref.html
 == caret_on_positioned.html caret_on_positioned-ref.html
 fails-if(Android) != spellcheck-input-disabled.html spellcheck-input-ref.html
-== spellcheck-input-attr-before.html spellcheck-input-ref.html
-== spellcheck-input-attr-after.html spellcheck-input-ref.html
-== spellcheck-input-attr-inherit.html spellcheck-input-ref.html
-== spellcheck-input-attr-dynamic.html spellcheck-input-ref.html
-== spellcheck-input-attr-dynamic-inherit.html spellcheck-input-ref.html
-== spellcheck-input-property-dynamic.html spellcheck-input-ref.html
-== spellcheck-input-property-dynamic-inherit.html spellcheck-input-ref.html
-== spellcheck-input-attr-dynamic-override.html spellcheck-input-ref.html
-== spellcheck-input-attr-dynamic-override-inherit.html spellcheck-input-ref.html
-== spellcheck-input-property-dynamic-override.html spellcheck-input-ref.html
-== spellcheck-input-property-dynamic-override-inherit.html spellcheck-input-ref.html
-== spellcheck-textarea-attr.html spellcheck-textarea-ref.html
+== spellcheck-input-attr-before.html spellcheck-input-nofocus-ref.html
+!= spellcheck-input-attr-before.html spellcheck-input-ref.html
+== spellcheck-input-attr-after.html spellcheck-input-nofocus-ref.html
+!= spellcheck-input-attr-after.html spellcheck-input-ref.html
+== spellcheck-input-attr-inherit.html spellcheck-input-nofocus-ref.html
+!= spellcheck-input-attr-inherit.html spellcheck-input-ref.html
+== spellcheck-input-attr-dynamic.html spellcheck-input-nofocus-ref.html
+!= spellcheck-input-attr-dynamic.html spellcheck-input-ref.html
+== spellcheck-input-attr-dynamic-inherit.html spellcheck-input-nofocus-ref.html
+!= spellcheck-input-attr-dynamic-inherit.html spellcheck-input-ref.html
+== spellcheck-input-property-dynamic.html spellcheck-input-nofocus-ref.html
+!= spellcheck-input-property-dynamic.html spellcheck-input-ref.html
+== spellcheck-input-property-dynamic-inherit.html spellcheck-input-nofocus-ref.html
+!= spellcheck-input-property-dynamic-inherit.html spellcheck-input-ref.html
+== spellcheck-input-attr-dynamic-override.html spellcheck-input-nofocus-ref.html
+!= spellcheck-input-attr-dynamic-override.html spellcheck-input-ref.html
+== spellcheck-input-attr-dynamic-override-inherit.html spellcheck-input-nofocus-ref.html
+!= spellcheck-input-attr-dynamic-override-inherit.html spellcheck-input-ref.html
+== spellcheck-input-property-dynamic-override.html spellcheck-input-nofocus-ref.html
+!= spellcheck-input-property-dynamic-override.html spellcheck-input-ref.html
+== spellcheck-input-property-dynamic-override-inherit.html spellcheck-input-nofocus-ref.html
+!= spellcheck-input-property-dynamic-override-inherit.html spellcheck-input-ref.html
+== spellcheck-textarea-attr.html spellcheck-textarea-nofocus-ref.html
+!= spellcheck-textarea-attr.html spellcheck-textarea-ref.html
+== spellcheck-textarea-focused.html spellcheck-textarea-ref.html
+!= spellcheck-textarea-nofocus.html spellcheck-textarea-ref.html
 fails-if(Android) != spellcheck-textarea-disabled.html spellcheck-textarea-ref.html
 fails-if(Android) != spellcheck-textarea-attr-inherit.html spellcheck-textarea-ref.html
 fails-if(Android) != spellcheck-textarea-attr-dynamic.html spellcheck-textarea-ref.html
diff --git a/layout/reftests/editor/spellcheck-input-nofocus-ref.html b/layout/reftests/editor/spellcheck-input-nofocus-ref.html
new file mode 100644
index 00000000000..1e878b5d151
--- /dev/null
+++ b/layout/reftests/editor/spellcheck-input-nofocus-ref.html
@@ -0,0 +1,6 @@
+
+
+
+    
+
+
diff --git a/layout/reftests/editor/spellcheck-textarea-focused.html b/layout/reftests/editor/spellcheck-textarea-focused.html
new file mode 100644
index 00000000000..ab0741a1289
--- /dev/null
+++ b/layout/reftests/editor/spellcheck-textarea-focused.html
@@ -0,0 +1,12 @@
+
+
+
+
+  
+  
+  
+
+
\ No newline at end of file
diff --git a/layout/reftests/editor/spellcheck-textarea-nofocus-ref.html b/layout/reftests/editor/spellcheck-textarea-nofocus-ref.html
new file mode 100644
index 00000000000..8d993983eba
--- /dev/null
+++ b/layout/reftests/editor/spellcheck-textarea-nofocus-ref.html
@@ -0,0 +1,6 @@
+
+
+
+  
+
+
diff --git a/layout/reftests/editor/spellcheck-textarea-nofocus.html b/layout/reftests/editor/spellcheck-textarea-nofocus.html
new file mode 100644
index 00000000000..a1ce1a0a98a
--- /dev/null
+++ b/layout/reftests/editor/spellcheck-textarea-nofocus.html
@@ -0,0 +1,6 @@
+
+
+
+  
+
+
\ No newline at end of file
diff --git a/layout/reftests/editor/spellcheck-textarea-ref.html b/layout/reftests/editor/spellcheck-textarea-ref.html
index 8d993983eba..5e492c953b1 100644
--- a/layout/reftests/editor/spellcheck-textarea-ref.html
+++ b/layout/reftests/editor/spellcheck-textarea-ref.html
@@ -2,5 +2,9 @@
 
 
   
+  
 
 

From 8c39619ba536d41d3a1e20e29c19af14c71adad2 Mon Sep 17 00:00:00 2001
From: David Bolter 
Date: Mon, 17 Oct 2011 10:30:33 -0400
Subject: [PATCH 3/5] Bug 680085 - Don't traverse dirty text frames when
 computing rendered text. r=roc

We now bail in GetRenderedText when we encounter dirty text frames. This shouldm be okay since dirty text frames should be reflowed at some point and we'll refresh our accessible text cache.
---
 layout/generic/nsTextFrameThebes.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp
index 61cc4d17280..664acfbeecc 100644
--- a/layout/generic/nsTextFrameThebes.cpp
+++ b/layout/generic/nsTextFrameThebes.cpp
@@ -7608,6 +7608,11 @@ nsresult nsTextFrame::GetRenderedText(nsAString* aAppendToString,
        textFrame = static_cast(textFrame->GetNextContinuation())) {
     // For each text frame continuation in this block ...
 
+    if (textFrame->GetStateBits() & NS_FRAME_IS_DIRTY) {
+      // We don't trust dirty frames, expecially when computing rendered text.
+      break;
+    }
+
     // Ensure the text run and grab the gfxSkipCharsIterator for it
     gfxSkipCharsIterator iter = textFrame->EnsureTextRun();
     if (!textFrame->mTextRun)

From 784a7d07fc30be4b907de6fa42cf692b730a5756 Mon Sep 17 00:00:00 2001
From: Benoit Girard 
Date: Fri, 14 Oct 2011 14:00:44 -0400
Subject: [PATCH 4/5] Bug 692759 - Fix Non-InvalidatingCoreAnimation refresh
 timer for async layers plugins. r=smichaud

--HG--
extra : rebase_source : 3017218abbe7897aa34b7a868cc63e49550246ce
---
 dom/plugins/ipc/PluginInstanceChild.cpp  | 23 +++++++++++
 dom/plugins/ipc/PluginInstanceChild.h    |  7 ++++
 dom/plugins/ipc/PluginInstanceParent.cpp | 31 --------------
 dom/plugins/ipc/PluginInstanceParent.h   | 15 -------
 dom/plugins/ipc/PluginModuleParent.cpp   | 52 ------------------------
 dom/plugins/ipc/PluginModuleParent.h     | 12 ------
 6 files changed, 30 insertions(+), 110 deletions(-)

diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp
index 5636892be9f..cf6583e9104 100644
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -201,6 +201,9 @@ PluginInstanceChild::~PluginInstanceChild()
     if (mCGLayer) {
         PluginUtilsOSX::ReleaseCGLayer(mCGLayer);
     }
+    if (mDrawingModel == NPDrawingModelCoreAnimation) {
+        UnscheduleTimer(mCARefreshTimer);
+    }
 #endif
 }
 
@@ -460,6 +463,22 @@ PluginInstanceChild::NPN_GetValue(NPNVariable aVar,
 
 }
 
+#ifdef MOZ_WIDGET_COCOA
+#define DEFAULT_REFRESH_MS 20 // CoreAnimation: 50 FPS
+
+void
+CAUpdate(NPP npp, uint32_t timerID) {
+    static_cast(npp->ndata)->Invalidate();
+}
+
+void
+PluginInstanceChild::Invalidate()
+{
+    NPRect windowRect = {0, 0, mWindow.height, mWindow.width};
+
+    InvalidateRect(&windowRect);
+}
+#endif
 
 NPError
 PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue)
@@ -507,6 +526,10 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue)
             return NPERR_GENERIC_ERROR;
         mDrawingModel = drawingModel;
 
+        if (drawingModel == NPDrawingModelCoreAnimation) {
+            mCARefreshTimer = ScheduleTimer(DEFAULT_REFRESH_MS, true, CAUpdate);
+        }
+
         PLUGIN_LOG_DEBUG(("  Plugin requested drawing model id  #%i\n",
             mDrawingModel));
 
diff --git a/dom/plugins/ipc/PluginInstanceChild.h b/dom/plugins/ipc/PluginInstanceChild.h
index d9fb3fbfec8..53a4a23a15d 100644
--- a/dom/plugins/ipc/PluginInstanceChild.h
+++ b/dom/plugins/ipc/PluginInstanceChild.h
@@ -236,6 +236,10 @@ public:
 
     void InvalidateRect(NPRect* aInvalidRect);
 
+#ifdef MOZ_WIDGET_COCOA
+    void Invalidate();
+#endif // definied(MOZ_WIDGET_COCOA)
+
     uint32_t ScheduleTimer(uint32_t interval, bool repeat, TimerFunc func);
     void UnscheduleTimer(uint32_t id);
 
@@ -426,6 +430,9 @@ private:
     nsCARenderer          mCARenderer;
     void                 *mCGLayer;
 
+    // Core Animation drawing model requires a refresh timer.
+    uint32_t mCARefreshTimer;
+
 public:
     const NPCocoaEvent* getCurrentEvent() {
         return mCurrentEvent;
diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp
index 21ec9584104..22091a2919d 100644
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -96,7 +96,6 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent,
     , mPluginWndProc(NULL)
     , mNestedEventState(false)
 #endif // defined(XP_WIN)
-    , mQuirks(0)
 #if defined(XP_MACOSX)
     , mShWidth(0)
     , mShHeight(0)
@@ -104,20 +103,6 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent,
     , mDrawingModel(NPDrawingModelCoreGraphics)
 #endif
 {
-    InitQuirksModes(aMimeType);
-}
-
-void
-PluginInstanceParent::InitQuirksModes(const nsCString& aMimeType)
-{
-#ifdef MOZ_WIDGET_COCOA
-    NS_NAMED_LITERAL_CSTRING(flash, "application/x-shockwave-flash");
-    // Flash sends us Invalidate events so we will use those
-    // instead of the refresh timer.
-    if (!FindInReadable(flash, aMimeType)) {
-        mQuirks |= COREANIMATION_REFRESH_TIMER;
-    }
-#endif
 }
 
 PluginInstanceParent::~PluginInstanceParent()
@@ -135,9 +120,6 @@ PluginInstanceParent::~PluginInstanceParent()
     }
     if (mShColorSpace)
         ::CGColorSpaceRelease(mShColorSpace);
-    if (mDrawingModel == NPDrawingModelCoreAnimation) {
-        mParent->RemoveFromRefreshTimer(this);
-    }
 #endif
 }
 
@@ -394,10 +376,6 @@ PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginDrawingModel(
         mDrawingModel = drawingModel;
         *result = mNPNIface->setvalue(mNPP, NPPVpluginDrawingModel,
                                   (void*)NPDrawingModelCoreGraphics);
-        if (drawingModel == NPDrawingModelCoreAnimation &&
-            mQuirks & COREANIMATION_REFRESH_TIMER) {
-            mParent->AddToRefreshTimer(this);
-        }
     } else {
         mDrawingModel = drawingModel;
         *result = mNPNIface->setvalue(mNPP, NPPVpluginDrawingModel,
@@ -1863,12 +1841,3 @@ PluginInstanceParent::AnswerPluginFocusChange(const bool& gotFocus)
     return false;
 #endif
 }
-
-#ifdef MOZ_WIDGET_COCOA
-void
-PluginInstanceParent::Invalidate()
-{
-    NPRect windowRect = {0, 0, mShHeight, mShWidth};
-    RecvNPN_InvalidateRect(windowRect);
-}
-#endif
diff --git a/dom/plugins/ipc/PluginInstanceParent.h b/dom/plugins/ipc/PluginInstanceParent.h
index 236b4f8d880..f1238d797e9 100644
--- a/dom/plugins/ipc/PluginInstanceParent.h
+++ b/dom/plugins/ipc/PluginInstanceParent.h
@@ -279,10 +279,6 @@ public:
     virtual bool
     AnswerPluginFocusChange(const bool& gotFocus);
 
-#ifdef MOZ_WIDGET_COCOA
-    void Invalidate();
-#endif // definied(MOZ_WIDGET_COCOA)
-
     nsresult AsyncSetWindow(NPWindow* window);
     nsresult GetImage(mozilla::layers::ImageContainer* aContainer, mozilla::layers::Image** aImage);
     nsresult GetImageSize(nsIntSize* aSize);
@@ -313,16 +309,6 @@ private:
     virtual bool
     DeallocPPluginBackgroundDestroyer(PPluginBackgroundDestroyerParent* aActor);
 
-    // Quirks mode support for various plugin mime types
-    enum PluginQuirks {
-        // OSX: Don't use the refresh timer for plug-ins
-        // using this quirk. These plug-in most have another
-        // way to refresh the window.
-        COREANIMATION_REFRESH_TIMER = 1,
-    };
-
-    void InitQuirksModes(const nsCString& aMimeType);
-
     bool InternalGetValueForNPObject(NPNVariable aVariable,
                                      PPluginScriptableObjectParent** aValue,
                                      NPError* aResult);
@@ -332,7 +318,6 @@ private:
     NPP mNPP;
     const NPNetscapeFuncs* mNPNIface;
     NPWindowType mWindowType;
-    int mQuirks;
 
     nsDataHashtable mScriptableObjects;
 
diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp
index 1fceef5a97e..bb4cdb19960 100644
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -146,12 +146,6 @@ PluginModuleParent::~PluginModuleParent()
 {
     NS_ASSERTION(OkToCleanup(), "unsafe destruction");
 
-#ifdef OS_MACOSX
-    if (mCATimer) {
-        mCATimer->Cancel();
-    }
-#endif
-
     if (!mShutdown) {
         NS_WARNING("Plugin host deleted the module without shutting down.");
         NPError err;
@@ -1171,52 +1165,6 @@ PluginModuleParent::RecvGetNativeCursorsSupported(bool* supported)
 #endif
 }
 
-#ifdef OS_MACOSX
-#define DEFAULT_REFRESH_MS 20 // CoreAnimation: 50 FPS
-
-void
-CAUpdate(nsITimer *aTimer, void *aClosure) {
-    nsTObserverArray *ips =
-        static_cast *>(aClosure);
-    nsTObserverArray::ForwardIterator iter(*ips);
-#ifdef MOZ_WIDGET_COCOA
-    while (iter.HasMore()) {
-        iter.GetNext()->Invalidate();
-    }
-#endif // MOZ_WIDGET_COCOA
-}
-
-void
-PluginModuleParent::AddToRefreshTimer(PluginInstanceParent *aInstance) {
-    if (mCATimerTargets.Contains(aInstance)) {
-        return;
-    }
-
-    mCATimerTargets.AppendElement(aInstance);
-    if (mCATimerTargets.Length() == 1) {
-        if (!mCATimer) {
-            nsresult rv;
-            nsCOMPtr xpcomTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
-            if (NS_FAILED(rv)) {
-                NS_WARNING("Could not create Core Animation timer for plugin.");
-                return;
-            }
-            mCATimer = xpcomTimer;
-        }
-        mCATimer->InitWithFuncCallback(CAUpdate, &mCATimerTargets, DEFAULT_REFRESH_MS,
-                                       nsITimer::TYPE_REPEATING_SLACK);
-    }
-}
-
-void
-PluginModuleParent::RemoveFromRefreshTimer(PluginInstanceParent *aInstance) {
-    bool visibleRemoved = mCATimerTargets.RemoveElement(aInstance);
-    if (visibleRemoved && mCATimerTargets.IsEmpty()) {
-        mCATimer->Cancel();
-    }
-}
-#endif
-
 bool
 PluginModuleParent::RecvNPN_SetException(PPluginScriptableObjectParent* aActor,
                                          const nsCString& aMessage)
diff --git a/dom/plugins/ipc/PluginModuleParent.h b/dom/plugins/ipc/PluginModuleParent.h
index 78b70d7564a..66bb84e515e 100644
--- a/dom/plugins/ipc/PluginModuleParent.h
+++ b/dom/plugins/ipc/PluginModuleParent.h
@@ -61,8 +61,6 @@
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 #include "nsIFileStreams.h"
-#include "nsTObserverArray.h"
-#include "nsITimer.h"
 
 namespace mozilla {
 namespace dom {
@@ -155,11 +153,6 @@ public:
 
     void ProcessRemoteNativeEventsInRPCCall();
 
-#ifdef OS_MACOSX
-    void AddToRefreshTimer(PluginInstanceParent *aInstance);
-    void RemoveFromRefreshTimer(PluginInstanceParent *aInstance);
-#endif
-
 protected:
     NS_OVERRIDE
     virtual mozilla::ipc::RPCChannel::RacyRPCPolicy
@@ -335,11 +328,6 @@ private:
     nsString mBrowserDumpID;
     nsString mHangID;
 
-#ifdef OS_MACOSX
-    nsCOMPtr mCATimer;
-    nsTObserverArray mCATimerTargets;
-#endif
-
 #ifdef MOZ_X11
     // Dup of plugin's X socket, used to scope its resources to this
     // object instead of the plugin process's lifetime

From ba92e80802d839fc6d4953705ea7cbb5d17732b1 Mon Sep 17 00:00:00 2001
From: Ehsan Akhgari 
Date: Mon, 17 Oct 2011 10:42:45 -0400
Subject: [PATCH 5/5] Bug 694797 - Cairo fails to build with VC11 because it
 tries to #define inline, which is a keyword in C++; r=jrmuizel

---
 gfx/cairo/cairo/src/cairo-compiler-private.h |  2 ++
 gfx/cairo/win32-inline-cpp-keyword.patch     | 24 ++++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 gfx/cairo/win32-inline-cpp-keyword.patch

diff --git a/gfx/cairo/cairo/src/cairo-compiler-private.h b/gfx/cairo/cairo/src/cairo-compiler-private.h
index bc6a8802853..ffac9ce1823 100644
--- a/gfx/cairo/cairo/src/cairo-compiler-private.h
+++ b/gfx/cairo/cairo/src/cairo-compiler-private.h
@@ -210,8 +210,10 @@
 #endif
 
 #ifdef _MSC_VER
+#ifndef __cplusplus
 #undef inline
 #define inline __inline
+#endif
 
 /* there are currently linkage problems that arise when trying to include intrin.h in c++:
  * D:\sdks\v7.0\include\winnt.h(3674) : error C2733: second C linkage of overloaded function '_interlockedbittestandset' not allowed
diff --git a/gfx/cairo/win32-inline-cpp-keyword.patch b/gfx/cairo/win32-inline-cpp-keyword.patch
new file mode 100644
index 00000000000..4b6f542d796
--- /dev/null
+++ b/gfx/cairo/win32-inline-cpp-keyword.patch
@@ -0,0 +1,24 @@
+diff --git a/gfx/cairo/cairo/src/cairo-compiler-private.h b/gfx/cairo/cairo/src/cairo-compiler-private.h
+--- a/gfx/cairo/cairo/src/cairo-compiler-private.h
++++ b/gfx/cairo/cairo/src/cairo-compiler-private.h
+@@ -205,18 +205,20 @@
+ #if (defined(__WIN32__) && !defined(__WINE__)) || defined(_MSC_VER)
+ #define snprintf _snprintf
+ #define popen _popen
+ #define pclose _pclose
+ #define hypot _hypot
+ #endif
+ 
+ #ifdef _MSC_VER
++#ifndef __cplusplus
+ #undef inline
+ #define inline __inline
++#endif
+ 
+ /* there are currently linkage problems that arise when trying to include intrin.h in c++:
+  * D:\sdks\v7.0\include\winnt.h(3674) : error C2733: second C linkage of overloaded function '_interlockedbittestandset' not allowed
+  * so avoid defining ffs in c++ code for now */
+ #ifndef  __cplusplus
+ /* Add a definition of ffs */
+ #include 
+ #pragma intrinsic(_BitScanForward)