From 1bde7f0d37e5f47bb643d75a6b40ffba41680715 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Tue, 8 May 2012 09:49:22 +0700 Subject: [PATCH 001/271] bug 752662 - Fix missing pointer check in Silf reading (cherry-picked from Graphite commit a7cf510b0798). r=jdaggett --- gfx/graphite2/src/Silf.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/gfx/graphite2/src/Silf.cpp b/gfx/graphite2/src/Silf.cpp index e7a20618e711..d837a0211859 100644 --- a/gfx/graphite2/src/Silf.cpp +++ b/gfx/graphite2/src/Silf.cpp @@ -111,6 +111,7 @@ bool Silf::readGraphite(const byte * const silf_start, size_t lSilf, const Face& if (p >= silf_end) { releaseBuffers(); return false; } be::skip(p, be::read(p)); // don't use scriptTag array. be::skip(p); // lbGID + if (p >= silf_end) { releaseBuffers(); return false; } const byte * o_passes = p, * const passes_start = silf_start + be::read(p); From 60b399fdb2ad7d72dfb7ba097c37e96d7323528e Mon Sep 17 00:00:00 2001 From: Marco Zehe Date: Wed, 9 May 2012 15:17:03 +0200 Subject: [PATCH 002/271] Bug 753253 - crash in nsAccessible::ScrollTo, r=tbsaunde --- accessible/src/base/nsAccessible.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 6018a6ad8d6a..a051e989b74c 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -2238,6 +2238,9 @@ nsAccessible::DispatchClickEvent(nsIContent *aContent, PRUint32 aActionIndex) NS_IMETHODIMP nsAccessible::ScrollTo(PRUint32 aHow) { + if (IsDefunct()) + return NS_ERROR_FAILURE; + nsCoreUtils::ScrollTo(mDoc->PresShell(), mContent, aHow); return NS_OK; } From 67b4fa97a889f54d3f62c1766428b613f87f8e1f Mon Sep 17 00:00:00 2001 From: Patrick McManus Date: Wed, 9 May 2012 09:57:04 -0400 Subject: [PATCH 003/271] bug 752648 - identify failed ssl handshakes earlier to improve restart logic r=honzab --- netwerk/protocol/http/nsHttpConnection.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp index d81b9922993b..4ceb5b36e8fe 100644 --- a/netwerk/protocol/http/nsHttpConnection.cpp +++ b/netwerk/protocol/http/nsHttpConnection.cpp @@ -309,8 +309,13 @@ nsHttpConnection::EnsureNPNComplete() PRUint32 count = 0; rv = mSocketOut->Write("", 0, &count); - if (NS_FAILED(rv) && rv != NS_BASE_STREAM_WOULD_BLOCK) + if (NS_FAILED(rv) && rv != NS_BASE_STREAM_WOULD_BLOCK) { + LOG(("nsHttpConnection::EnsureNPNComplete %p socket write failed " + "with result %X\n", this, rv)); + mSocketOutCondition = rv; goto npnComplete; + } + return false; } @@ -1247,7 +1252,14 @@ nsHttpConnection::OnSocketWritable() LOG((" writing transaction request stream\n")); mProxyConnectInProgress = false; - rv = mTransaction->ReadSegments(this, nsIOService::gDefaultSegmentSize, &n); + + if (NS_SUCCEEDED(mSocketOutCondition) || + mSocketOutCondition == NS_BASE_STREAM_WOULD_BLOCK) { + rv = mTransaction->ReadSegments(this, nsIOService::gDefaultSegmentSize, &n); + } + else { + rv = mSocketOutCondition; + } } LOG((" ReadSegments returned [rv=%x read=%u sock-cond=%x]\n", From dd4dbf0fabf0d415174faddc64c60d2498a464a8 Mon Sep 17 00:00:00 2001 From: Mark Capella Date: Wed, 9 May 2012 07:24:24 -0700 Subject: [PATCH 004/271] Bug 749367 - script type=texttemplate content parsed as JavaScript (+E4X), r=jst, f=ms2ger, mbrubeck, jdm --- content/base/src/nsScriptLoader.cpp | 14 +------ content/base/test/Makefile.in | 1 + content/base/test/test_bug749367.html | 29 ++++++++++++++ content/xul/content/test/Makefile.in | 1 + content/xul/content/test/test_bug749367.xul | 39 +++++++++++++++++++ content/xul/document/src/nsXULContentSink.cpp | 10 +---- 6 files changed, 73 insertions(+), 21 deletions(-) create mode 100644 content/base/test/test_bug749367.html create mode 100644 content/xul/content/test/test_bug749367.xul diff --git a/content/base/src/nsScriptLoader.cpp b/content/base/src/nsScriptLoader.cpp index 56fa5d9a1fd4..7e11771ddf24 100644 --- a/content/base/src/nsScriptLoader.cpp +++ b/content/base/src/nsScriptLoader.cpp @@ -465,18 +465,8 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) } } - if (isJavaScript) - typeID = nsIProgrammingLanguage::JAVASCRIPT; - else { - // Use the object factory to locate a matching language. - nsCOMPtr runtime; - rv = NS_GetJSRuntime(getter_AddRefs(runtime)); - if (NS_FAILED(rv) || runtime == nsnull) { - // Failed to get the explicitly specified language - NS_WARNING("Failed to find a scripting language"); - typeID = nsIProgrammingLanguage::UNKNOWN; - } else - typeID = nsIProgrammingLanguage::JAVASCRIPT; + if (!isJavaScript) { + typeID = nsIProgrammingLanguage::UNKNOWN; } if (typeID != nsIProgrammingLanguage::UNKNOWN) { diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index 686c1a6f839c..555dd089c91d 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -578,6 +578,7 @@ _TEST_FILES2 = \ test_bug719533.html \ test_bug737087.html \ test_bug433662.html \ + test_bug749367.html \ $(NULL) _CHROME_FILES = \ diff --git a/content/base/test/test_bug749367.html b/content/base/test/test_bug749367.html new file mode 100644 index 000000000000..565588f411a9 --- /dev/null +++ b/content/base/test/test_bug749367.html @@ -0,0 +1,29 @@ + + + + + + Test for Bug 749367 + + + + + +Mozilla Bug 749367 + +
+
+  
+
+  
+
+  
+ + + diff --git a/content/xul/content/test/Makefile.in b/content/xul/content/test/Makefile.in index 2057ea8c5ffd..2f46aea9f292 100644 --- a/content/xul/content/test/Makefile.in +++ b/content/xul/content/test/Makefile.in @@ -46,6 +46,7 @@ include $(topsrcdir)/config/rules.mk _TEST_FILES = \ test_bug486990.xul \ + test_bug749367.xul \ $(NULL) _CHROME_FILES = \ diff --git a/content/xul/content/test/test_bug749367.xul b/content/xul/content/test/test_bug749367.xul new file mode 100644 index 000000000000..478a119e828a --- /dev/null +++ b/content/xul/content/test/test_bug749367.xul @@ -0,0 +1,39 @@ + + + + + + + + + + diff --git a/content/xul/document/src/nsXULContentSink.cpp b/content/xul/document/src/nsXULContentSink.cpp index 6ea39269796c..592e0f204beb 100644 --- a/content/xul/document/src/nsXULContentSink.cpp +++ b/content/xul/document/src/nsXULContentSink.cpp @@ -928,15 +928,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes, langID = nsIProgrammingLanguage::JAVASCRIPT; version = JSVERSION_LATEST; } else { - // Use the script object factory to locate the language. - nsCOMPtr runtime; - rv = NS_GetJSRuntime(getter_AddRefs(runtime)); - if (NS_FAILED(rv) || runtime == nsnull) { - // Failed to get the explicitly specified language - NS_WARNING("Failed to find a scripting language"); - langID = nsIProgrammingLanguage::UNKNOWN; - } else - langID = nsIProgrammingLanguage::JAVASCRIPT; + langID = nsIProgrammingLanguage::UNKNOWN; } if (langID != nsIProgrammingLanguage::UNKNOWN) { From ae7166da9918b3e2bd3d53b09813bcf503f7f611 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Tue, 8 May 2012 15:38:50 -0400 Subject: [PATCH 005/271] Bug 748914 - Part 1: implement Histogram::Clear; r=taras --- ipc/chromium/src/base/histogram.cc | 6 ++++++ ipc/chromium/src/base/histogram.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/ipc/chromium/src/base/histogram.cc b/ipc/chromium/src/base/histogram.cc index 0b2a1e957429..7f5bf6b9214c 100644 --- a/ipc/chromium/src/base/histogram.cc +++ b/ipc/chromium/src/base/histogram.cc @@ -149,6 +149,12 @@ void Histogram::AddSampleSet(const SampleSet& sample) { sample_.Add(sample); } +void Histogram::Clear() { + SampleSet ss; + ss.Resize(*this); + sample_ = ss; +} + void Histogram::SetRangeDescriptions(const DescriptionPair descriptions[]) { DCHECK(false); } diff --git a/ipc/chromium/src/base/histogram.h b/ipc/chromium/src/base/histogram.h index 621df384f14d..2b1e3c446925 100644 --- a/ipc/chromium/src/base/histogram.h +++ b/ipc/chromium/src/base/histogram.h @@ -395,6 +395,8 @@ class Histogram { virtual void AddSampleSet(const SampleSet& sample); + void Clear(); + // This method is an interface, used only by LinearHistogram. virtual void SetRangeDescriptions(const DescriptionPair descriptions[]); From bbcef6a2d6ad59708856a5fdd1385304b8ea9c5e Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Tue, 8 May 2012 15:39:24 -0400 Subject: [PATCH 006/271] Bug 748914 - Part 2: add a clear() method to JS histograms; r=taras --- toolkit/components/telemetry/Telemetry.cpp | 18 ++++++++++++++++-- toolkit/components/telemetry/nsITelemetry.idl | 1 + .../telemetry/tests/unit/test_nsITelemetry.js | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/toolkit/components/telemetry/Telemetry.cpp b/toolkit/components/telemetry/Telemetry.cpp index 302415451940..9412181aec6e 100644 --- a/toolkit/components/telemetry/Telemetry.cpp +++ b/toolkit/components/telemetry/Telemetry.cpp @@ -461,6 +461,19 @@ JSHistogram_Snapshot(JSContext *cx, unsigned argc, jsval *vp) } } +JSBool +JSHistogram_Clear(JSContext *cx, unsigned argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + if (!obj) { + return JS_FALSE; + } + + Histogram *h = static_cast(JS_GetPrivate(obj)); + h->Clear(); + return JS_TRUE; +} + nsresult WrapAndReturnHistogram(Histogram *h, JSContext *cx, jsval *ret) { @@ -475,8 +488,9 @@ WrapAndReturnHistogram(Histogram *h, JSContext *cx, jsval *ret) if (!obj) return NS_ERROR_FAILURE; JS::AutoObjectRooter root(cx, obj); - if (!(JS_DefineFunction (cx, obj, "add", JSHistogram_Add, 1, 0) - && JS_DefineFunction (cx, obj, "snapshot", JSHistogram_Snapshot, 1, 0))) { + if (!(JS_DefineFunction(cx, obj, "add", JSHistogram_Add, 1, 0) + && JS_DefineFunction(cx, obj, "snapshot", JSHistogram_Snapshot, 0, 0) + && JS_DefineFunction(cx, obj, "clear", JSHistogram_Clear, 0, 0))) { return NS_ERROR_FAILURE; } *ret = OBJECT_TO_JSVAL(obj); diff --git a/toolkit/components/telemetry/nsITelemetry.idl b/toolkit/components/telemetry/nsITelemetry.idl index 61a7e50c91ec..fe7b3d06b6aa 100644 --- a/toolkit/components/telemetry/nsITelemetry.idl +++ b/toolkit/components/telemetry/nsITelemetry.idl @@ -158,6 +158,7 @@ interface nsITelemetry : nsISupports * The returned object has the following functions: * add(int) - Adds an int value to the appropriate bucket * snapshot() - Returns a snapshot of the histogram with the same data fields as in histogramSnapshots() + * clear() - Zeros out the histogram's buckets and sum */ [implicit_jscontext] jsval newHistogram(in ACString name, in PRUint32 min, in PRUint32 max, in PRUint32 bucket_count, in unsigned long histogram_type); diff --git a/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js b/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js index 80cbd2620298..96296726aa5d 100644 --- a/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js +++ b/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js @@ -39,6 +39,20 @@ function test_histogram(histogram_type, name, min, max, bucket_count) { var s = h.snapshot().counts; do_check_eq(s[0], 2) do_check_eq(s[1], 2) + + // Check that clearing works. + h.clear(); + var s = h.snapshot(); + for each(var i in s.counts) { + do_check_eq(i, 0); + } + do_check_eq(s.sum, 0); + + h.add(0); + h.add(1); + var c = h.snapshot().counts; + do_check_eq(c[0], 1); + do_check_eq(c[1], 1); } function expect_fail(f) { From 5db1917152541e965142cd9427ededb79825bf9e Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 7 May 2012 16:09:11 -0400 Subject: [PATCH 007/271] Bug 747508 - Count PresContexts in about:memory; r=njn --- content/base/src/nsDocument.cpp | 3 ++- dom/base/nsWindowMemoryReporter.cpp | 5 +++++ dom/base/nsWindowMemoryReporter.h | 1 + layout/base/nsIPresShell.h | 3 ++- layout/base/nsPresShell.cpp | 5 ++++- layout/base/nsPresShell.h | 3 ++- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 6ad9cde173c4..c36f668339b5 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -9698,7 +9698,8 @@ nsIDocument::DocSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const mPresShell->SizeOfIncludingThis(aWindowSizes->mMallocSizeOf, &aWindowSizes->mLayoutArenas, &aWindowSizes->mLayoutStyleSets, - &aWindowSizes->mLayoutTextRuns); + &aWindowSizes->mLayoutTextRuns, + &aWindowSizes->mLayoutPresContext); } // Measurement of the following members may be added later if DMD finds it diff --git a/dom/base/nsWindowMemoryReporter.cpp b/dom/base/nsWindowMemoryReporter.cpp index c62cf279c0f5..e68d8aef94d1 100644 --- a/dom/base/nsWindowMemoryReporter.cpp +++ b/dom/base/nsWindowMemoryReporter.cpp @@ -210,6 +210,11 @@ CollectWindowReports(nsGlobalWindow *aWindow, "tree, within a window."); aWindowTotalSizes->mLayoutTextRuns += windowSizes.mLayoutTextRuns; + REPORT("/layout/pres-contexts", windowSizes.mLayoutPresContext, + "Memory used for the PresContext in the PresShell's frame " + "within a window."); + aWindowTotalSizes->mLayoutPresContext += windowSizes.mLayoutPresContext; + #undef REPORT return NS_OK; diff --git a/dom/base/nsWindowMemoryReporter.h b/dom/base/nsWindowMemoryReporter.h index b0c7e0b420ee..751e1acec89e 100644 --- a/dom/base/nsWindowMemoryReporter.h +++ b/dom/base/nsWindowMemoryReporter.h @@ -64,6 +64,7 @@ public: size_t mLayoutArenas; size_t mLayoutStyleSets; size_t mLayoutTextRuns; + size_t mLayoutPresContext; }; /** diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index ac31ab042563..eab47ca8f256 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -1221,7 +1221,8 @@ public: virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, size_t *aArenasSize, size_t *aStyleSetsSize, - size_t *aTextRunsSize) const = 0; + size_t *aTextRunsSize, + size_t *aPresContextSize) const = 0; /** * Refresh observer management. diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 02bc8954fdfc..8c322cee7c95 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -8976,7 +8976,8 @@ void PresShell::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, size_t *aArenasSize, size_t *aStyleSetsSize, - size_t *aTextRunsSize) const + size_t *aTextRunsSize, + size_t *aPresContextSize) const { *aArenasSize = aMallocSizeOf(this); *aArenasSize += mFrameArena.SizeOfExcludingThis(aMallocSizeOf); @@ -8984,6 +8985,8 @@ PresShell::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, *aStyleSetsSize = StyleSet()->SizeOfIncludingThis(aMallocSizeOf); *aTextRunsSize = SizeOfTextRuns(aMallocSizeOf); + + *aPresContextSize = mPresContext->SizeOfIncludingThis(aMallocSizeOf); } size_t diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index c7855d750f35..a339d531f5ca 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -822,7 +822,8 @@ public: void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, size_t *aArenasSize, size_t *aStyleSetsSize, - size_t *aTextRunsSize) const; + size_t *aTextRunsSize, + size_t *aPresContextSize) const; size_t SizeOfTextRuns(nsMallocSizeOfFun aMallocSizeOf) const; protected: From 0298f29209497419f9b6e83a690c300a6dc8ecdc Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Wed, 2 May 2012 13:01:39 -0400 Subject: [PATCH 008/271] Bug 589032 - remove mozIStorageStatementWrapper; r=mak --- storage/build/mozStorageCID.h | 6 - storage/build/mozStorageModule.cpp | 5 - storage/public/Makefile.in | 3 +- storage/public/mozIStorageStatementParams.idl | 11 + storage/public/mozIStorageStatementRow.idl | 12 + .../public/mozIStorageStatementWrapper.idl | 88 ------- storage/src/Makefile.in | 1 - storage/src/mozStorageAsyncStatementParams.h | 2 +- storage/src/mozStorageStatementParams.h | 2 +- storage/src/mozStorageStatementRow.h | 2 +- storage/src/mozStorageStatementWrapper.cpp | 227 ----------------- storage/src/mozStorageStatementWrapper.h | 82 ------- storage/test/unit/test_bug-365166.js | 6 - storage/test/unit/test_bug-429521.js | 18 +- storage/test/unit/test_bug-444233.js | 19 +- .../unit/test_storage_statement_wrapper.js | 228 ------------------ storage/test/unit/xpcshell.ini | 1 - 17 files changed, 38 insertions(+), 675 deletions(-) create mode 100644 storage/public/mozIStorageStatementParams.idl create mode 100644 storage/public/mozIStorageStatementRow.idl delete mode 100644 storage/public/mozIStorageStatementWrapper.idl delete mode 100644 storage/src/mozStorageStatementWrapper.cpp delete mode 100644 storage/src/mozStorageStatementWrapper.h delete mode 100644 storage/test/unit/test_storage_statement_wrapper.js diff --git a/storage/build/mozStorageCID.h b/storage/build/mozStorageCID.h index faaa7516a181..4e77184941a3 100644 --- a/storage/build/mozStorageCID.h +++ b/storage/build/mozStorageCID.h @@ -54,12 +54,6 @@ #define MOZ_STORAGE_SERVICE_CONTRACTID MOZ_STORAGE_CONTRACTID_PREFIX "/service;1" -/* dab3a846-3a59-4fc2-9745-c6ff48776f00 */ -#define MOZ_STORAGE_STATEMENT_WRAPPER_CID \ -{ 0xdab3a846, 0x3a59, 0x4fc2, {0x97, 0x45, 0xc6, 0xff, 0x48, 0x77, 0x6f, 0x00} } - -#define MOZ_STORAGE_STATEMENT_WRAPPER_CONTRACTID MOZ_STORAGE_CONTRACTID_PREFIX "/statement-wrapper;1" - /* 3b667ee0-d2da-4ccc-9c3d-95f2ca6a8b4c */ #define VACUUMMANAGER_CID \ { 0x3b667ee0, 0xd2da, 0x4ccc, { 0x9c, 0x3d, 0x95, 0xf2, 0xca, 0x6a, 0x8b, 0x4c } } diff --git a/storage/build/mozStorageModule.cpp b/storage/build/mozStorageModule.cpp index 2d9561636b50..815bbdcc2c4f 100644 --- a/storage/build/mozStorageModule.cpp +++ b/storage/build/mozStorageModule.cpp @@ -42,7 +42,6 @@ #include "mozStorageService.h" #include "mozStorageConnection.h" -#include "mozStorageStatementWrapper.h" #include "VacuumManager.h" #include "mozStorageCID.h" @@ -52,7 +51,6 @@ namespace storage { NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(Service, Service::getSingleton) -NS_GENERIC_FACTORY_CONSTRUCTOR(StatementWrapper) NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(VacuumManager, VacuumManager::getSingleton) @@ -60,19 +58,16 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(VacuumManager, } // namespace mozilla NS_DEFINE_NAMED_CID(MOZ_STORAGE_SERVICE_CID); -NS_DEFINE_NAMED_CID(MOZ_STORAGE_STATEMENT_WRAPPER_CID); NS_DEFINE_NAMED_CID(VACUUMMANAGER_CID); static const mozilla::Module::CIDEntry kStorageCIDs[] = { { &kMOZ_STORAGE_SERVICE_CID, false, NULL, mozilla::storage::ServiceConstructor }, - { &kMOZ_STORAGE_STATEMENT_WRAPPER_CID, false, NULL, mozilla::storage::StatementWrapperConstructor }, { &kVACUUMMANAGER_CID, false, NULL, mozilla::storage::VacuumManagerConstructor }, { NULL } }; static const mozilla::Module::ContractIDEntry kStorageContracts[] = { { MOZ_STORAGE_SERVICE_CONTRACTID, &kMOZ_STORAGE_SERVICE_CID }, - { MOZ_STORAGE_STATEMENT_WRAPPER_CONTRACTID, &kMOZ_STORAGE_STATEMENT_WRAPPER_CID }, { VACUUMMANAGER_CONTRACTID, &kVACUUMMANAGER_CID }, { NULL } }; diff --git a/storage/public/Makefile.in b/storage/public/Makefile.in index 9e4ec35f3c72..3c71f3d8f3ff 100644 --- a/storage/public/Makefile.in +++ b/storage/public/Makefile.in @@ -57,11 +57,12 @@ XPIDLSRCS = \ mozIStorageFunction.idl \ mozIStorageProgressHandler.idl \ mozIStorageStatement.idl \ - mozIStorageStatementWrapper.idl \ mozIStorageValueArray.idl \ mozIStorageResultSet.idl \ mozIStorageRow.idl \ mozIStorageError.idl \ + mozIStorageStatementParams.idl \ + mozIStorageStatementRow.idl \ mozIStorageStatementCallback.idl \ mozIStoragePendingStatement.idl \ mozIStorageBindingParamsArray.idl \ diff --git a/storage/public/mozIStorageStatementParams.idl b/storage/public/mozIStorageStatementParams.idl new file mode 100644 index 000000000000..efeee9772dba --- /dev/null +++ b/storage/public/mozIStorageStatementParams.idl @@ -0,0 +1,11 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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 "nsISupports.idl" + +[scriptable, uuid(e65fe6e2-2643-463c-97e2-27665efe2386)] +interface mozIStorageStatementParams : nsISupports { + // Magic interface for parameter setting that implements nsIXPCScriptable. +}; diff --git a/storage/public/mozIStorageStatementRow.idl b/storage/public/mozIStorageStatementRow.idl new file mode 100644 index 000000000000..8be1da7f169f --- /dev/null +++ b/storage/public/mozIStorageStatementRow.idl @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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 "nsISupports.idl" + +[scriptable, uuid(02eeaf95-c3db-4182-9340-222c29f68f02)] +interface mozIStorageStatementRow : nsISupports { + // Magic interface we return that implements nsIXPCScriptable, to allow + // for by-name access to rows. +}; diff --git a/storage/public/mozIStorageStatementWrapper.idl b/storage/public/mozIStorageStatementWrapper.idl deleted file mode 100644 index 216e300d887c..000000000000 --- a/storage/public/mozIStorageStatementWrapper.idl +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Oracle Corporation code. - * - * The Initial Developer of the Original Code is - * Oracle Corporation - * Portions created by the Initial Developer are Copyright (C) 2004 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "mozIStorageStatement.idl" - -[scriptable, uuid(02eeaf95-c3db-4182-9340-222c29f68f02)] -interface mozIStorageStatementRow : nsISupports { - // magic interface we return that implements nsIXPCScriptable, to allow - // for by-name access to rows -}; - -[scriptable, uuid(e65fe6e2-2643-463c-97e2-27665efe2386)] -interface mozIStorageStatementParams : nsISupports { - // magic interface for parameter setting that implements nsIXPCScriptable. -}; - -/** - * @deprecated As of Mozilla 1.9.2. Methods are already provided on - * mozIStorageStatement. - */ -[scriptable, deprecated, uuid(eee6f7c9-5586-4eaf-b35c-dca987c4ffd1)] -interface mozIStorageStatementWrapper : nsISupports { - /** - * Initialize this wrapper with aStatement. - */ - void initialize(in mozIStorageStatement aStatement); - - /** - * The statement that is wrapped. - */ - readonly attribute mozIStorageStatement statement; - - /** - * Step, reset, and execute the wrapped statement. - */ - void reset(); - [deprecated] boolean step(); - void execute(); - - /** - * The current row. Throws an exception if no row is currently - * available. Useful only from script. The value of this is only - * valid while the statement is still executing, and is still on the - * appropriate row. - */ - readonly attribute mozIStorageStatementRow row; - - /** - * The parameters; these can be set in lieu of using the call - * notation on this. - */ - readonly attribute mozIStorageStatementParams params; -}; diff --git a/storage/src/Makefile.in b/storage/src/Makefile.in index 3ce9543b7ff8..27384812060c 100644 --- a/storage/src/Makefile.in +++ b/storage/src/Makefile.in @@ -78,7 +78,6 @@ CPPSRCS = \ mozStorageService.cpp \ mozStorageConnection.cpp \ mozStorageStatement.cpp \ - mozStorageStatementWrapper.cpp \ mozStorageStatementParams.cpp \ mozStorageStatementRow.cpp \ mozStorageArgValueArray.cpp \ diff --git a/storage/src/mozStorageAsyncStatementParams.h b/storage/src/mozStorageAsyncStatementParams.h index ef04de133154..46b7673c8a2f 100644 --- a/storage/src/mozStorageAsyncStatementParams.h +++ b/storage/src/mozStorageAsyncStatementParams.h @@ -40,7 +40,7 @@ #ifndef mozilla_storage_mozStorageAsyncStatementParams_h_ #define mozilla_storage_mozStorageAsyncStatementParams_h_ -#include "mozIStorageStatementWrapper.h" +#include "mozIStorageStatementParams.h" #include "nsIXPCScriptable.h" class mozIStorageAsyncStatement; diff --git a/storage/src/mozStorageStatementParams.h b/storage/src/mozStorageStatementParams.h index b993158668e7..026ed3b16852 100644 --- a/storage/src/mozStorageStatementParams.h +++ b/storage/src/mozStorageStatementParams.h @@ -40,7 +40,7 @@ #ifndef MOZSTORAGESTATEMENTPARAMS_H #define MOZSTORAGESTATEMENTPARAMS_H -#include "mozIStorageStatementWrapper.h" +#include "mozIStorageStatementParams.h" #include "nsIXPCScriptable.h" class mozIStorageStatement; diff --git a/storage/src/mozStorageStatementRow.h b/storage/src/mozStorageStatementRow.h index 4c13b51e413f..2234d52f214e 100644 --- a/storage/src/mozStorageStatementRow.h +++ b/storage/src/mozStorageStatementRow.h @@ -40,7 +40,7 @@ #ifndef MOZSTORAGESTATEMENTROW_H #define MOZSTORAGESTATEMENTROW_H -#include "mozIStorageStatementWrapper.h" +#include "mozIStorageStatementRow.h" #include "nsIXPCScriptable.h" namespace mozilla { diff --git a/storage/src/mozStorageStatementWrapper.cpp b/storage/src/mozStorageStatementWrapper.cpp deleted file mode 100644 index dbd35e9398dc..000000000000 --- a/storage/src/mozStorageStatementWrapper.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Oracle Corporation code. - * - * The Initial Developer of the Original Code is - * Oracle Corporation - * Portions created by the Initial Developer are Copyright (C) 2004 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * Shawn Wilsher - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsString.h" - -#include "mozStoragePrivateHelpers.h" -#include "mozStorageStatementWrapper.h" -#include "mozStorageStatementParams.h" -#include "mozStorageStatementRow.h" - -#include "sqlite3.h" - -namespace mozilla { -namespace storage { - -//////////////////////////////////////////////////////////////////////////////// -//// StatementWrapper - -StatementWrapper::StatementWrapper() -: mStatement(nsnull) -{ -} - -StatementWrapper::~StatementWrapper() -{ - mStatement = nsnull; -} - -NS_IMPL_ISUPPORTS2( - StatementWrapper, - mozIStorageStatementWrapper, - nsIXPCScriptable -) - -//////////////////////////////////////////////////////////////////////////////// -//// mozIStorageStatementWrapper - -NS_IMETHODIMP -StatementWrapper::Initialize(mozIStorageStatement *aStatement) -{ - NS_ASSERTION(mStatement == nsnull, "StatementWrapper is already initialized"); - NS_ENSURE_ARG_POINTER(aStatement); - - mStatement = static_cast(aStatement); - PRInt32 state; - (void)mStatement->GetState(&state); - NS_ENSURE_TRUE(state != mozIStorageStatement::MOZ_STORAGE_STATEMENT_INVALID, NS_ERROR_FAILURE); - - // fetch various things we care about - (void)mStatement->GetParameterCount(&mParamCount); - (void)mStatement->GetColumnCount(&mResultColumnCount); - - for (unsigned int i = 0; i < mResultColumnCount; i++) { - const void *name = ::sqlite3_column_name16(nativeStatement(), i); - (void)mColumnNames.AppendElement(nsDependentString(static_cast(name))); - } - - return NS_OK; -} - -NS_IMETHODIMP -StatementWrapper::GetStatement(mozIStorageStatement **_statement) -{ - NS_IF_ADDREF(*_statement = mStatement); - return NS_OK; -} - -NS_IMETHODIMP -StatementWrapper::Reset() -{ - if (!mStatement) - return NS_ERROR_FAILURE; - - return mStatement->Reset(); -} - -NS_IMETHODIMP -StatementWrapper::Step(bool *_hasMoreResults) -{ - if (!mStatement) - return NS_ERROR_FAILURE; - - bool hasMore = false; - nsresult rv = mStatement->ExecuteStep(&hasMore); - if (NS_SUCCEEDED(rv) && !hasMore) { - *_hasMoreResults = false; - (void)mStatement->Reset(); - return NS_OK; - } - - *_hasMoreResults = hasMore; - return rv; -} - -NS_IMETHODIMP -StatementWrapper::Execute() -{ - if (!mStatement) - return NS_ERROR_FAILURE; - - return mStatement->Execute(); -} - -NS_IMETHODIMP -StatementWrapper::GetRow(mozIStorageStatementRow **_row) -{ - NS_ENSURE_ARG_POINTER(_row); - - if (!mStatement) - return NS_ERROR_FAILURE; - - PRInt32 state; - mStatement->GetState(&state); - if (state != mozIStorageStatement::MOZ_STORAGE_STATEMENT_EXECUTING) - return NS_ERROR_FAILURE; - - if (!mStatementRow) { - mStatementRow = new StatementRow(mStatement); - NS_ENSURE_TRUE(mStatementRow, NS_ERROR_OUT_OF_MEMORY); - } - - NS_ADDREF(*_row = mStatementRow); - return NS_OK; -} - -NS_IMETHODIMP -StatementWrapper::GetParams(mozIStorageStatementParams **_params) -{ - NS_ENSURE_ARG_POINTER(_params); - - if (!mStatementParams) { - mStatementParams = new StatementParams(mStatement); - NS_ENSURE_TRUE(mStatementParams, NS_ERROR_OUT_OF_MEMORY); - } - - NS_ADDREF(*_params = mStatementParams); - return NS_OK; -} - -//////////////////////////////////////////////////////////////////////////////// -//// nsIXPCScriptable - -#define XPC_MAP_CLASSNAME StatementWrapper -#define XPC_MAP_QUOTED_CLASSNAME "StatementWrapper" -#define XPC_MAP_WANT_CALL -#define XPC_MAP_FLAGS nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE | \ - nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY -#include "xpc_map_end.h" - -NS_IMETHODIMP -StatementWrapper::Call(nsIXPConnectWrappedNative *aWrapper, - JSContext *aCtx, - JSObject *aScopeObj, - PRUint32 aArgc, - jsval *aArgv, - jsval *_vp, - bool *_retval) -{ - if (!mStatement) - return NS_ERROR_FAILURE; - - if (aArgc != mParamCount) { - *_retval = false; - return NS_ERROR_FAILURE; - } - - // reset - (void)mStatement->Reset(); - - // bind parameters - for (int i = 0; i < (int)aArgc; i++) { - nsCOMPtr variant(convertJSValToVariant(aCtx, aArgv[i])); - if (!variant || - NS_FAILED(mStatement->BindByIndex(i, variant))) { - *_retval = false; - return NS_ERROR_INVALID_ARG; - } - } - - // if there are no results, we just execute - if (mResultColumnCount == 0) - (void)mStatement->Execute(); - - *_vp = JSVAL_TRUE; - *_retval = true; - return NS_OK; -} - -} // namespace storage -} // namespace mozilla diff --git a/storage/src/mozStorageStatementWrapper.h b/storage/src/mozStorageStatementWrapper.h deleted file mode 100644 index 4f2d3658b65d..000000000000 --- a/storage/src/mozStorageStatementWrapper.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Oracle Corporation code. - * - * The Initial Developer of the Original Code is - * Oracle Corporation - * Portions created by the Initial Developer are Copyright (C) 2004 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef mozStorageStatementWrapper_h -#define mozStorageStatementWrapper_h - -#include "nsTArray.h" -#include "nsIXPCScriptable.h" - -#include "mozStorageStatement.h" -#include "mozIStorageStatementWrapper.h" - -namespace mozilla { -namespace storage { - -class StatementWrapper : public mozIStorageStatementWrapper - , public nsIXPCScriptable -{ -public: - StatementWrapper(); - - // interfaces - NS_DECL_ISUPPORTS - NS_DECL_MOZISTORAGESTATEMENTWRAPPER - NS_DECL_NSIXPCSCRIPTABLE - -private: - ~StatementWrapper(); - - sqlite3_stmt *nativeStatement() { - return mStatement->nativeStatement(); - } - - nsRefPtr mStatement; - PRUint32 mParamCount; - PRUint32 mResultColumnCount; - nsTArray mColumnNames; - - nsCOMPtr mStatementRow; - nsCOMPtr mStatementParams; -}; - -} // namespace storage -} // namespace mozilla - -#endif // mozStorageStatementWrapper_h diff --git a/storage/test/unit/test_bug-365166.js b/storage/test/unit/test_bug-365166.js index 9779f7775107..d8c3448767a9 100644 --- a/storage/test/unit/test_bug-365166.js +++ b/storage/test/unit/test_bug-365166.js @@ -21,12 +21,6 @@ function run_test() { try { // This shouldn't crash: do_check_eq(statement.getColumnName(0), colName); - - // OK, if the above statement didn't crash, check that initializing a - // wrapper doesn't crash either: - var wrapper = Components.classes["@mozilla.org/storage/statement-wrapper;1"] - .createInstance(Components.interfaces.mozIStorageStatementWrapper); - wrapper.initialize(statement); } finally { statement.reset(); statement.finalize(); diff --git a/storage/test/unit/test_bug-429521.js b/storage/test/unit/test_bug-429521.js index fbb26cf37d78..eed5c7af0dbe 100644 --- a/storage/test/unit/test_bug-429521.js +++ b/storage/test/unit/test_bug-429521.js @@ -37,26 +37,18 @@ * * ***** END LICENSE BLOCK ***** */ -function createStatementWrapper(aSQL) -{ - var stmt = getOpenedDatabase().createStatement(aSQL); - var wrapper = Components.Constructor("@mozilla.org/storage/statement-wrapper;1", Ci.mozIStorageStatementWrapper)(); - wrapper.initialize(stmt); - return wrapper; -} - function setup() { getOpenedDatabase().createTable("t1", "x TEXT"); - var stmt = getOpenedDatabase().createStatement("INSERT INTO t1 (x) VALUES ('/mozilla.org/20070129_1/Europe/Berlin')"); + var stmt = createStatement("INSERT INTO t1 (x) VALUES ('/mozilla.org/20070129_1/Europe/Berlin')"); stmt.execute(); stmt.finalize(); } function test_bug429521() { - var wrapper = createStatementWrapper( + var stmt = createStatement( "SELECT DISTINCT(zone) FROM ("+ "SELECT x AS zone FROM t1 WHERE x LIKE '/mozilla.org%'" + ");"); @@ -64,12 +56,12 @@ function test_bug429521() print("*** test_bug429521: started"); try { - while (wrapper.step()) { + while (stmt.executeStep()) { print("*** test_bug429521: step() Read wrapper.row.zone"); // BUG: the print commands after the following statement // are never executed. Script stops immediately. - var tzId = wrapper.row.zone; + var tzId = stmt.row.zone; print("*** test_bug429521: step() Read wrapper.row.zone finished"); } @@ -79,7 +71,7 @@ function test_bug429521() print("*** test_bug429521: finished"); - wrapper.statement.finalize(); + stmt.finalize(); } function run_test() diff --git a/storage/test/unit/test_bug-444233.js b/storage/test/unit/test_bug-444233.js index 69d6a9dc1060..896b68b626cb 100644 --- a/storage/test/unit/test_bug-444233.js +++ b/storage/test/unit/test_bug-444233.js @@ -37,15 +37,6 @@ * * ***** END LICENSE BLOCK ***** */ -// copy from test_storage_statement_wrapper.js -var wrapper = new Components.Constructor("@mozilla.org/storage/statement-wrapper;1", - Ci.mozIStorageStatementWrapper, - "initialize"); -// we want to override the default function for this file -createStatement = function(aSQL) { - return new wrapper(getOpenedDatabase().createStatement(aSQL)); -} - function setup() { // Create the table getOpenedDatabase().createTable("test_bug444233", @@ -55,12 +46,12 @@ function setup() { var stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)"); stmt.params.value = "value1" stmt.execute(); - stmt.statement.finalize(); + stmt.finalize(); stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)"); stmt.params.value = "value2" stmt.execute(); - stmt.statement.finalize(); + stmt.finalize(); } function test_bug444233() { @@ -68,10 +59,10 @@ function test_bug444233() { // Check that there are 2 results var stmt = createStatement("SELECT COUNT(*) AS number FROM test_bug444233"); - do_check_true(stmt.step()); + do_check_true(stmt.executeStep()); do_check_eq(2, stmt.row.number); stmt.reset(); - stmt.statement.finalize(); + stmt.finalize(); print("*** test_bug444233: doing delete"); @@ -84,7 +75,7 @@ function test_bug444233() { } catch (e) { print("*** test_bug444233: successfully caught exception"); } - stmt.statement.finalize(); + stmt.finalize(); } function run_test() { diff --git a/storage/test/unit/test_storage_statement_wrapper.js b/storage/test/unit/test_storage_statement_wrapper.js deleted file mode 100644 index dfa7f624c7e8..000000000000 --- a/storage/test/unit/test_storage_statement_wrapper.js +++ /dev/null @@ -1,228 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - vim:set ts=2 sw=2 sts=2 et: - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Storage Test Code. - * - * The Initial Developer of the Original Code is - * Mozilla Corporation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shawn Wilsher (Original Author) - * Drew Willcoxon - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// This file tests the functions of mozIStorageStatementWrapper - -function setup() -{ - getOpenedDatabase().createTable("test", "id INTEGER PRIMARY KEY, val NONE," + - "alt_val NONE"); -} - -var wrapper = new Components.Constructor("@mozilla.org/storage/statement-wrapper;1", - Ci.mozIStorageStatementWrapper, - "initialize"); - -// we want to override the default function for this file -createStatement = function(aSQL) { - return new wrapper(getOpenedDatabase().createStatement(aSQL)); -} - -/** - * A convenience wrapper for do_check_eq. Calls do_check_eq on aActualVal - * and aReturnedVal, with one caveat. - * - * Date objects are converted before parameter binding to PRTime's (microsecs - * since epoch). They are not reconverted when retrieved from the database. - * This function abstracts away this reconversion so that you can pass in, - * for example: - * - * checkVal(new Date(), aReturnedVal) // this - * checkVal(new Date().valueOf() * 1000.0, aReturnedVal) // instead of this - * - * Should any other types require conversion in the future, their conversions - * may also be abstracted away here. - * - * @param aActualVal - * the value inserted into the database - * @param aReturnedVal - * the value retrieved from the database - */ -function checkVal(aActualVal, aReturnedVal) -{ - if (aActualVal instanceof Date) aActualVal = aActualVal.valueOf() * 1000.0; - do_check_eq(aActualVal, aReturnedVal); -} - -/** - * Removes all rows from our test table. - */ -function clearTable() -{ - var stmt = createStatement("DELETE FROM test"); - stmt.execute(); - stmt.statement.finalize(); - ensureNumRows(0); -} - -/** - * Ensures that the number of rows in our test table is equal to aNumRows. - * Calls do_check_eq on aNumRows and the value retrieved by SELECT'ing COUNT(*). - * - * @param aNumRows - * the number of rows our test table should contain - */ -function ensureNumRows(aNumRows) -{ - var stmt = createStatement("SELECT COUNT(*) AS number FROM test"); - do_check_true(stmt.step()); - do_check_eq(aNumRows, stmt.row.number); - stmt.reset(); - stmt.statement.finalize(); -} - -/** - * Verifies that the properties exposed by a for-in loop over aObj are - * enumerable. - * - * @param aObj - * the object to check - */ -function checkEnumerableConsistency(aObj) -{ - for (var p in aObj) - do_check_true(Object.prototype.propertyIsEnumerable.call(aObj, p)); -} - -/** - * Inserts aVal into our test table and checks that insertion was successful by - * retrieving the newly inserted value from the database and comparing it - * against aVal. aVal is bound to a single parameter. - * - * @param aVal - * value to insert into our test table and check - */ -function insertAndCheckSingleParam(aVal) -{ - clearTable(); - - var stmt = createStatement("INSERT INTO test (val) VALUES (:val)"); - stmt.params.val = aVal; - checkEnumerableConsistency(stmt.params); - stmt.execute(); - stmt.statement.finalize(); - - ensureNumRows(1); - - stmt = createStatement("SELECT val FROM test WHERE id = 1"); - do_check_true(stmt.step()); - checkVal(aVal, stmt.row.val); - stmt.reset(); - stmt.statement.finalize(); -} - -/** - * Inserts aVal into our test table and checks that insertion was successful by - * retrieving the newly inserted value from the database and comparing it - * against aVal. aVal is bound to two separate parameters, both of which are - * checked against aVal. - * - * @param aVal - * value to insert into our test table and check - */ -function insertAndCheckMultipleParams(aVal) -{ - clearTable(); - - var stmt = createStatement("INSERT INTO test (val, alt_val) " + - "VALUES (:val, :val)"); - stmt.params.val = aVal; - checkEnumerableConsistency(stmt.params); - stmt.execute(); - stmt.statement.finalize(); - - ensureNumRows(1); - - stmt = createStatement("SELECT val, alt_val FROM test WHERE id = 1"); - do_check_true(stmt.step()); - checkVal(aVal, stmt.row.val); - checkVal(aVal, stmt.row.alt_val); - stmt.reset(); - stmt.statement.finalize(); -} - -/** - * A convenience function that prints out a description of aVal using - * aVal.toString and aVal.toSource. Output is useful when the test fails. - * - * @param aVal - * a value inserted or to be inserted into our test table - */ -function printValDesc(aVal) -{ - try - { - var toSource = aVal.toSource(); - } - catch (exc) - { - toSource = ""; - } - print("Testing value: toString=" + aVal + - (toSource ? " toSource=" + toSource : "")); -} - -function run_test() -{ - setup(); - - // function JSValStorageStatementBinder in - // storage/src/mozStorageStatementParams.cpp tells us that the following types - // and only the following types are valid as statement parameters: - var vals = [ - 1337, // int - 3.1337, // double - "foo", // string - true, // boolean - null, // null - new Date(), // Date object - ]; - - vals.forEach(function (val) - { - printValDesc(val); - print("Single parameter"); - insertAndCheckSingleParam(val); - print("Multiple parameters"); - insertAndCheckMultipleParams(val) - }); - - cleanup(); -} diff --git a/storage/test/unit/xpcshell.ini b/storage/test/unit/xpcshell.ini index 4a63fdd7685c..fa996642b22f 100644 --- a/storage/test/unit/xpcshell.ini +++ b/storage/test/unit/xpcshell.ini @@ -28,7 +28,6 @@ fail-if = os == "android" [test_storage_service.js] [test_storage_service_unshared.js] [test_storage_statement.js] -[test_storage_statement_wrapper.js] [test_storage_value_array.js] [test_unicode.js] [test_vacuum.js] From 6760ecf50ef8f582a1814c6aa384a673310e0117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Wed, 9 May 2012 10:32:14 -0400 Subject: [PATCH 009/271] Bug 744294 - Add c++ ConnectionReady. r=mak. --HG-- extra : rebase_source : 3b074030355417564923f69bf48f219f75c3ef6b --- storage/src/mozStorageConnection.cpp | 6 ++---- storage/src/mozStorageConnection.h | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/storage/src/mozStorageConnection.cpp b/storage/src/mozStorageConnection.cpp index 87bf02ae70e0..2cb583f2532b 100644 --- a/storage/src/mozStorageConnection.cpp +++ b/storage/src/mozStorageConnection.cpp @@ -816,10 +816,8 @@ Connection::setClosedState() bool Connection::isAsyncClosing() { MutexAutoLock lockedScope(sharedAsyncExecutionMutex); - bool isReady; - (void)GetConnectionReady(&isReady); return mAsyncExecutionThreadShuttingDown && !!mAsyncExecutionThread && - isReady; + ConnectionReady(); } nsresult @@ -1135,7 +1133,7 @@ Connection::Clone(bool aReadOnly, NS_IMETHODIMP Connection::GetConnectionReady(bool *_ready) { - *_ready = (mDBConn != nsnull); + *_ready = ConnectionReady(); return NS_OK; } diff --git a/storage/src/mozStorageConnection.h b/storage/src/mozStorageConnection.h index 896f5b60e65e..d2b58bdad72d 100644 --- a/storage/src/mozStorageConnection.h +++ b/storage/src/mozStorageConnection.h @@ -175,6 +175,10 @@ public: */ int stepStatement(sqlite3_stmt* aStatement); + bool ConnectionReady() { + return mDBConn != nsnull; + } + /** * True if this is an async connection, it is shutting down and it is not * closed yet. From 8b7988e945dd4fe6bedf609494cbf8429dff57cf Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Tue, 16 Nov 2010 15:45:49 -0500 Subject: [PATCH 010/271] Bug 612128 - Prevent the editor from modifying nodes which are not under an editing host; r=roc,bzbarsky This patch ensures that the NODE_IS_EDITABLE flag is only set on nodes living under an editing host. Things like text controls which used to have that flag previously will not have it any more. The flag would be set on their anonymous div node instead. Note that if text controls actually fall under an editing host, they will get the NODE_IS_EDITABLE flag. This patch also makes nsHTMLEditor::IsEditable return sane results (text nodes are always considered to be editable). --- content/base/src/nsContentAreaDragDrop.cpp | 3 +- .../content/public/nsITextControlElement.h | 4 ++ .../html/content/src/nsGenericHTMLElement.cpp | 43 ++++---------- .../html/content/src/nsGenericHTMLElement.h | 2 - .../html/content/src/nsHTMLInputElement.cpp | 5 -- content/html/content/src/nsHTMLInputElement.h | 5 -- .../content/src/nsHTMLTextAreaElement.cpp | 9 --- .../html/content/src/nsTextEditorState.cpp | 17 ++++++ .../libeditor/base/crashtests/382527-1.html | 4 +- editor/libeditor/base/nsEditor.h | 2 +- editor/libeditor/base/nsEditorCommands.cpp | 8 ++- .../libeditor/html/crashtests/716456-1.html | 1 + editor/libeditor/html/nsHTMLDataTransfer.cpp | 4 +- editor/libeditor/html/nsHTMLEditor.cpp | 20 +++++++ editor/libeditor/html/nsHTMLEditor.h | 2 + editor/libeditor/html/tests/Makefile.in | 1 + .../libeditor/html/tests/test_bug612128.html | 42 ++++++++++++++ editor/reftests/readonly-editable-ref.html | 13 +++++ editor/reftests/readonly-editable.html | 24 ++++++++ .../reftests/readonly-non-editable-ref.html | 21 +++++++ editor/reftests/readonly-non-editable.html | 24 ++++++++ editor/reftests/readwrite-editable-ref.html | 13 +++++ editor/reftests/readwrite-editable.html | 24 ++++++++ .../reftests/readwrite-non-editable-ref.html | 21 +++++++ editor/reftests/readwrite-non-editable.html | 24 ++++++++ editor/reftests/reftest.list | 4 ++ layout/base/nsCSSFrameConstructor.cpp | 58 ++++++++++++------- layout/generic/nsIAnonymousContentCreator.h | 4 ++ 28 files changed, 322 insertions(+), 80 deletions(-) create mode 100644 editor/libeditor/html/tests/test_bug612128.html create mode 100644 editor/reftests/readonly-editable-ref.html create mode 100644 editor/reftests/readonly-editable.html create mode 100644 editor/reftests/readonly-non-editable-ref.html create mode 100644 editor/reftests/readonly-non-editable.html create mode 100644 editor/reftests/readwrite-editable-ref.html create mode 100644 editor/reftests/readwrite-editable.html create mode 100644 editor/reftests/readwrite-non-editable-ref.html create mode 100644 editor/reftests/readwrite-non-editable.html diff --git a/content/base/src/nsContentAreaDragDrop.cpp b/content/base/src/nsContentAreaDragDrop.cpp index 4d3d945bc513..84e23e0f6012 100644 --- a/content/base/src/nsContentAreaDragDrop.cpp +++ b/content/base/src/nsContentAreaDragDrop.cpp @@ -404,7 +404,8 @@ DragDataProducer::Produce(nsDOMDataTransfer* aDataTransfer, nsCOMPtr selection; nsIContent* editingElement = mSelectionTargetNode->IsEditable() ? mSelectionTargetNode->GetEditingHost() : nsnull; - nsCOMPtr textControl(do_QueryInterface(editingElement)); + nsCOMPtr textControl = + nsITextControlElement::GetTextControlElementFromEditingHost(editingElement); if (textControl) { nsISelectionController* selcon = textControl->GetSelectionController(); if (selcon) { diff --git a/content/html/content/public/nsITextControlElement.h b/content/html/content/public/nsITextControlElement.h index b199acba870d..892add07b2e4 100644 --- a/content/html/content/public/nsITextControlElement.h +++ b/content/html/content/public/nsITextControlElement.h @@ -40,6 +40,7 @@ #define nsITextControlElement_h___ #include "nsISupports.h" +#include "nsCOMPtr.h" class nsIContent; class nsAString; class nsIEditor; @@ -226,6 +227,9 @@ public: * elements be initialized eagerly. */ NS_IMETHOD_(bool) HasCachedSelection() = 0; + + static already_AddRefed + GetTextControlElementFromEditingHost(nsIContent* aHost); }; NS_DEFINE_STATIC_IID_ACCESSOR(nsITextControlElement, diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 31f4ee0f6786..ca165c7eb364 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -1876,37 +1876,6 @@ nsGenericHTMLElement::MapCommonAttributesInto(const nsMappedAttributes* aAttribu } } -void -nsGenericHTMLFormElement::UpdateEditableFormControlState(bool aNotify) -{ - // nsCSSFrameConstructor::MaybeConstructLazily is based on the logic of this - // function, so should be kept in sync with that. - - ContentEditableTristate value = GetContentEditableValue(); - if (value != eInherit) { - DoSetEditableFlag(!!value, aNotify); - return; - } - - nsIContent *parent = GetParent(); - - if (parent && parent->HasFlag(NODE_IS_EDITABLE)) { - DoSetEditableFlag(true, aNotify); - return; - } - - if (!IsTextControl(false)) { - DoSetEditableFlag(false, aNotify); - return; - } - - // If not contentEditable we still need to check the readonly attribute. - bool roState; - GetBoolAttr(nsGkAtoms::readonly, &roState); - - DoSetEditableFlag(!roState, aNotify); -} - /* static */ const nsGenericHTMLElement::MappedAttributeEntry nsGenericHTMLElement::sCommonAttributeMap[] = { @@ -2974,6 +2943,18 @@ nsGenericHTMLFormElement::IntrinsicState() const state |= NS_EVENT_STATE_DEFAULT; } + // Make the text controls read-write + if (!state.HasState(NS_EVENT_STATE_MOZ_READWRITE) && + IsTextControl(false)) { + bool roState; + GetBoolAttr(nsGkAtoms::readonly, &roState); + + if (!roState) { + state |= NS_EVENT_STATE_MOZ_READWRITE; + state &= ~NS_EVENT_STATE_MOZ_READONLY; + } + } + return state; } diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 60918bae259b..81633fb8c326 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -910,8 +910,6 @@ protected: virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, bool aNotify); - void UpdateEditableFormControlState(bool aNotify); - /** * This method will update the form owner, using @form or looking to a parent. * diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp index 33b7cceadabb..538021e60cda 100644 --- a/content/html/content/src/nsHTMLInputElement.cpp +++ b/content/html/content/src/nsHTMLInputElement.cpp @@ -860,11 +860,6 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, UpdateTypeMismatchValidityState(); } - UpdateEditableState(aNotify); - nsTextEditorState *state = GetEditorState(); - if (state) { - state->UpdateEditableState(aNotify); - } UpdateState(aNotify); } diff --git a/content/html/content/src/nsHTMLInputElement.h b/content/html/content/src/nsHTMLInputElement.h index 82d1f7f888dd..a2348683c4c7 100644 --- a/content/html/content/src/nsHTMLInputElement.h +++ b/content/html/content/src/nsHTMLInputElement.h @@ -223,11 +223,6 @@ public: NS_IMETHOD FireAsyncClickHandler(); - virtual void UpdateEditableState(bool aNotify) - { - return UpdateEditableFormControlState(aNotify); - } - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLInputElement, nsGenericHTMLFormElement) diff --git a/content/html/content/src/nsHTMLTextAreaElement.cpp b/content/html/content/src/nsHTMLTextAreaElement.cpp index 15dfcfccaf5f..140ef5906b07 100644 --- a/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -219,11 +219,6 @@ public: NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED - virtual void UpdateEditableState(bool aNotify) - { - return UpdateEditableFormControlState(aNotify); - } - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLTextAreaElement, nsGenericHTMLFormElement) @@ -1313,10 +1308,6 @@ nsHTMLTextAreaElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, UpdateTooLongValidityState(); } - if (aName == nsGkAtoms::readonly) { - UpdateEditableState(aNotify); - mState.UpdateEditableState(aNotify); - } UpdateState(aNotify); } diff --git a/content/html/content/src/nsTextEditorState.cpp b/content/html/content/src/nsTextEditorState.cpp index 84fb9cb09310..2e527f6a2a15 100644 --- a/content/html/content/src/nsTextEditorState.cpp +++ b/content/html/content/src/nsTextEditorState.cpp @@ -145,6 +145,20 @@ nsITextControlElement::GetWrapPropertyEnum(nsIContent* aContent, return false; } +/*static*/ +already_AddRefed +nsITextControlElement::GetTextControlElementFromEditingHost(nsIContent* aHost) +{ + if (!aHost) { + return nsnull; + } + + nsCOMPtr parent = + do_QueryInterface(aHost->GetParent()); + + return parent.forget(); +} + static bool SuppressEventHandlers(nsPresContext* aPresContext) { @@ -1566,6 +1580,9 @@ nsTextEditorState::CreateRootNode() nsresult nsTextEditorState::InitializeRootNode() { + // Make our root node editable + mRootNode->SetFlags(NODE_IS_EDITABLE); + // Set the necessary classes on the text control. We use class values // instead of a 'style' attribute so that the style comes from a user-agent // style sheet and is still applied even if author styles are disabled. diff --git a/editor/libeditor/base/crashtests/382527-1.html b/editor/libeditor/base/crashtests/382527-1.html index ff33a141794f..2441dcd87b52 100644 --- a/editor/libeditor/base/crashtests/382527-1.html +++ b/editor/libeditor/base/crashtests/382527-1.html @@ -36,7 +36,9 @@ function init3() rng.setEnd(textNode, 1); targetWindow.getSelection().addRange(rng); - targetDocument.execCommand("inserthtml", false, "

"); + try { + targetDocument.execCommand("inserthtml", false, "

"); + } catch(e) {} document.documentElement.removeAttribute("class"); } diff --git a/editor/libeditor/base/nsEditor.h b/editor/libeditor/base/nsEditor.h index 094fdd6658b8..11140f921267 100644 --- a/editor/libeditor/base/nsEditor.h +++ b/editor/libeditor/base/nsEditor.h @@ -581,7 +581,7 @@ public: /** returns true if aNode is an editable node */ bool IsEditable(nsIDOMNode *aNode); - bool IsEditable(nsIContent *aNode); + virtual bool IsEditable(nsIContent *aNode); /** * aNode must be a non-null text node. diff --git a/editor/libeditor/base/nsEditorCommands.cpp b/editor/libeditor/base/nsEditorCommands.cpp index 63260be5aca7..87698add4d2b 100644 --- a/editor/libeditor/base/nsEditorCommands.cpp +++ b/editor/libeditor/base/nsEditorCommands.cpp @@ -656,16 +656,18 @@ nsSelectAllCommand::IsCommandEnabled(const char * aCommandName, NS_ENSURE_ARG_POINTER(outCmdEnabled); nsresult rv = NS_OK; - *outCmdEnabled = false; + // You can always select all, unless the selection is editable, + // and the editable region is empty! + *outCmdEnabled = true; bool docIsEmpty; - + // you can select all if there is an editor which is non-empty nsCOMPtr editor = do_QueryInterface(aCommandRefCon); if (editor) { rv = editor->GetDocumentIsEmpty(&docIsEmpty); NS_ENSURE_SUCCESS(rv, rv); *outCmdEnabled = !docIsEmpty; - } + } return rv; } diff --git a/editor/libeditor/html/crashtests/716456-1.html b/editor/libeditor/html/crashtests/716456-1.html index 20c2d6a630ad..a5ef5a2cc386 100644 --- a/editor/libeditor/html/crashtests/716456-1.html +++ b/editor/libeditor/html/crashtests/716456-1.html @@ -14,6 +14,7 @@ function boom() document["appendChild"](r); setTimeout(function() { + getSelection().collapse(div, 0); document.execCommand("inserthtml", false, "a"); setTimeout(function() { document.documentElement.removeAttribute("class"); diff --git a/editor/libeditor/html/nsHTMLDataTransfer.cpp b/editor/libeditor/html/nsHTMLDataTransfer.cpp index af0076cd8e0c..51dc79cbc458 100644 --- a/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -314,7 +314,9 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString, // fetch the paste insertion point from our selection rv = GetStartNodeAndOffset(selection, getter_AddRefs(targetNode), &targetOffset); NS_ENSURE_SUCCESS(rv, rv); - NS_ENSURE_TRUE(targetNode, NS_ERROR_FAILURE); + if (!targetNode || !IsEditable(targetNode)) { + return NS_ERROR_FAILURE; + } } else { diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index 78713b58f517..c893eb8b6b86 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -417,6 +417,12 @@ nsHTMLEditor::FindSelectionRoot(nsINode *aNode) } if (!content->HasFlag(NODE_IS_EDITABLE)) { + // If the content is in read-write state but is not editable itself, + // return it as the selection root. + if (content->IsElement() && + content->AsElement()->State().HasState(NS_EVENT_STATE_MOZ_READWRITE)) { + return content.forget(); + } return nsnull; } @@ -5701,6 +5707,20 @@ nsHTMLEditor::GetInputEventTargetContent() return target.forget(); } +bool +nsHTMLEditor::IsEditable(nsIContent* aNode) { + if (!nsPlaintextEditor::IsEditable(aNode)) { + return false; + } + if (aNode->IsElement()) { + // If we're dealing with an element, then ask it whether it's editable. + return aNode->IsEditable(); + } + // We might be dealing with a text node for example, which we always consider + // to be editable. + return true; +} + // virtual MOZ_OVERRIDE dom::Element* nsHTMLEditor::GetEditorRoot() diff --git a/editor/libeditor/html/nsHTMLEditor.h b/editor/libeditor/html/nsHTMLEditor.h index 079087f1db0a..fc3379ceb14a 100644 --- a/editor/libeditor/html/nsHTMLEditor.h +++ b/editor/libeditor/html/nsHTMLEditor.h @@ -140,6 +140,8 @@ public: virtual already_AddRefed FindSelectionRoot(nsINode *aNode); virtual bool IsAcceptableInputEvent(nsIDOMEvent* aEvent); virtual already_AddRefed GetInputEventTargetContent(); + virtual bool IsEditable(nsIContent *aNode); + using nsEditor::IsEditable; /* ------------ nsStubMutationObserver overrides --------- */ NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED diff --git a/editor/libeditor/html/tests/Makefile.in b/editor/libeditor/html/tests/Makefile.in index d0a18a8890d8..b863f65d245f 100644 --- a/editor/libeditor/html/tests/Makefile.in +++ b/editor/libeditor/html/tests/Makefile.in @@ -84,6 +84,7 @@ _TEST_FILES = \ test_bug599322.html \ test_bug607584.html \ test_bug611182.html \ + test_bug612128.html \ test_bug612447.html \ test_bug620906.html \ test_bug622371.html \ diff --git a/editor/libeditor/html/tests/test_bug612128.html b/editor/libeditor/html/tests/test_bug612128.html new file mode 100644 index 000000000000..660bb54904e4 --- /dev/null +++ b/editor/libeditor/html/tests/test_bug612128.html @@ -0,0 +1,42 @@ + + + + + Test for Bug 612128 + + + + + + +Mozilla Bug 612128 +

+
+ +
+
+
+
+
+ + diff --git a/editor/reftests/readonly-editable-ref.html b/editor/reftests/readonly-editable-ref.html new file mode 100644 index 000000000000..99f1e5101739 --- /dev/null +++ b/editor/reftests/readonly-editable-ref.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/editor/reftests/readonly-editable.html b/editor/reftests/readonly-editable.html new file mode 100644 index 000000000000..49210e581472 --- /dev/null +++ b/editor/reftests/readonly-editable.html @@ -0,0 +1,24 @@ + + + + + + + hide me + hide me + hide me + hide me + hide me + hide me + hide me + hide me + + diff --git a/editor/reftests/readonly-non-editable-ref.html b/editor/reftests/readonly-non-editable-ref.html new file mode 100644 index 000000000000..a91071e42c33 --- /dev/null +++ b/editor/reftests/readonly-non-editable-ref.html @@ -0,0 +1,21 @@ + + + + + + + hide me + + hide me + + hide me + + hide me + + + diff --git a/editor/reftests/readonly-non-editable.html b/editor/reftests/readonly-non-editable.html new file mode 100644 index 000000000000..9766045ed73d --- /dev/null +++ b/editor/reftests/readonly-non-editable.html @@ -0,0 +1,24 @@ + + + + + + + hide me + hide me + hide me + hide me + hide me + hide me + hide me + hide me + + diff --git a/editor/reftests/readwrite-editable-ref.html b/editor/reftests/readwrite-editable-ref.html new file mode 100644 index 000000000000..99f1e5101739 --- /dev/null +++ b/editor/reftests/readwrite-editable-ref.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/editor/reftests/readwrite-editable.html b/editor/reftests/readwrite-editable.html new file mode 100644 index 000000000000..49210e581472 --- /dev/null +++ b/editor/reftests/readwrite-editable.html @@ -0,0 +1,24 @@ + + + + + + + hide me + hide me + hide me + hide me + hide me + hide me + hide me + hide me + + diff --git a/editor/reftests/readwrite-non-editable-ref.html b/editor/reftests/readwrite-non-editable-ref.html new file mode 100644 index 000000000000..12e1c46c0aef --- /dev/null +++ b/editor/reftests/readwrite-non-editable-ref.html @@ -0,0 +1,21 @@ + + + + + + + + hide me + + hide me + + hide me + + hide me + + diff --git a/editor/reftests/readwrite-non-editable.html b/editor/reftests/readwrite-non-editable.html new file mode 100644 index 000000000000..535f21f1aa0e --- /dev/null +++ b/editor/reftests/readwrite-non-editable.html @@ -0,0 +1,24 @@ + + + + + + + hide me + hide me + hide me + hide me + hide me + hide me + hide me + hide me + + diff --git a/editor/reftests/reftest.list b/editor/reftests/reftest.list index 827eaa390bef..bc5391f43e82 100644 --- a/editor/reftests/reftest.list +++ b/editor/reftests/reftest.list @@ -85,6 +85,10 @@ skip-if(Android) == 674212-spellcheck.html 674212-spellcheck-ref.html skip-if(Android) == 338427-2.html 338427-2-ref.html skip-if(Android) needs-focus == 338427-3.html 338427-3-ref.html skip-if(Android) == 462758-grabbers-resizers.html 462758-grabbers-resizers-ref.html +== readwrite-non-editable.html readwrite-non-editable-ref.html +== readwrite-editable.html readwrite-editable-ref.html +== readonly-non-editable.html readonly-non-editable-ref.html +== readonly-editable.html readonly-editable-ref.html == dynamic-overflow-change.html dynamic-overflow-change-ref.html == 694880-1.html 694880-ref.html == 694880-2.html 694880-ref.html diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 68adfe1e805a..bb2c3ddb39bd 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -3873,6 +3873,31 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState, return NS_OK; } +static void +SetFlagsOnSubtree(nsIContent *aNode, PtrBits aFlagsToSet) +{ +#ifdef DEBUG + // Make sure that the node passed to us doesn't have any XBL children + { + nsIDocument *doc = aNode->OwnerDoc(); + NS_ASSERTION(doc, "The node must be in a document"); + NS_ASSERTION(!doc->BindingManager()->GetXBLChildNodesFor(aNode), + "The node should not have any XBL children"); + } +#endif + + // Set the flag on the node itself + aNode->SetFlags(aFlagsToSet); + + // Set the flag on all of its children recursively + PRUint32 count; + nsIContent * const *children = aNode->GetChildArray(&count); + + for (PRUint32 index = 0; index < count; ++index) { + SetFlagsOnSubtree(children[index], aFlagsToSet); + } +} + nsresult nsCSSFrameConstructor::GetAnonymousContent(nsIContent* aParent, nsIFrame* aParentFrame, @@ -3900,7 +3925,17 @@ nsCSSFrameConstructor::GetAnonymousContent(nsIContent* aParent, content->SetNativeAnonymous(); } + bool anonContentIsEditable = content->HasFlag(NODE_IS_EDITABLE); rv = content->BindToTree(mDocument, aParent, aParent, true); + // If the anonymous content creator requested that the content should be + // editable, honor its request. + // We need to set the flag on the whole subtree, because existing + // children's flags have already been set as part of the BindToTree operation. + if (anonContentIsEditable) { + NS_ASSERTION(aParentFrame->GetType() == nsGkAtoms::textInputFrame, + "We only expect this for anonymous content under a text control frame"); + SetFlagsOnSubtree(content, NODE_IS_EDITABLE); + } if (NS_FAILED(rv)) { content->UnbindFromTree(); return rv; @@ -6108,25 +6143,6 @@ nsCSSFrameConstructor::ReframeTextIfNeeded(nsIContent* aParentContent, ContentInserted(aParentContent, aContent, nsnull, false); } -// We want to disable lazy frame construction for nodes that are under an -// editor. We use nsINode::IsEditable, but that includes inputs with type text -// and password and textareas, which are common and aren't really editable (the -// native anonymous content under them is what is actually editable) so we want -// to construct frames for those lazily. -// The logic for this check is based on -// nsGenericHTMLFormElement::UpdateEditableFormControlState and so must be kept -// in sync with that. MayHaveContentEditableAttr() being true only indicates -// a contenteditable attribute, it doesn't indicate whether it is true or false, -// so we force eager construction in some cases when the node is not editable, -// but that should be rare. -static inline bool -IsActuallyEditable(nsIContent* aContainer, nsIContent* aChild) -{ - return (aChild->IsEditable() && - (aContainer->IsEditable() || - aChild->MayHaveContentEditableAttr())); -} - // For inserts aChild should be valid, for appends it should be null. // Returns true if this operation can be lazy, false if not. bool @@ -6141,7 +6157,7 @@ nsCSSFrameConstructor::MaybeConstructLazily(Operation aOperation, if (aOperation == CONTENTINSERT) { if (aChild->IsRootOfAnonymousSubtree() || - aChild->IsXUL() || IsActuallyEditable(aContainer, aChild)) { + aChild->IsEditable() || aChild->IsXUL()) { return false; } } else { // CONTENTAPPEND @@ -6150,7 +6166,7 @@ nsCSSFrameConstructor::MaybeConstructLazily(Operation aOperation, for (nsIContent* child = aChild; child; child = child->GetNextSibling()) { NS_ASSERTION(!child->IsRootOfAnonymousSubtree(), "Should be coming through the CONTENTAPPEND case"); - if (child->IsXUL() || IsActuallyEditable(aContainer, child)) { + if (child->IsXUL() || child->IsEditable()) { return false; } } diff --git a/layout/generic/nsIAnonymousContentCreator.h b/layout/generic/nsIAnonymousContentCreator.h index b1e84dc53057..4c351a99b698 100644 --- a/layout/generic/nsIAnonymousContentCreator.h +++ b/layout/generic/nsIAnonymousContentCreator.h @@ -79,6 +79,10 @@ public: * Creates "native" anonymous content and adds the created content to * the aElements array. None of the returned elements can be nsnull. * + * If the anonymous content creator sets the editable flag on some + * of the elements that it creates, the flag will be applied to the node + * upon being bound to the document. + * * @note The returned elements are owned by this object. This object is * responsible for calling UnbindFromTree on the elements it returned * from CreateAnonymousContent when appropriate (i.e. before releasing From 90bc12cbe001c7fe34f3a55209c277ea4e323542 Mon Sep 17 00:00:00 2001 From: Heather Arthur Date: Wed, 9 May 2012 17:23:57 +0100 Subject: [PATCH 011/271] Bug 750556 - crash in mozilla::dom::Element::ClearStyleStateLocks; r=bz --- layout/inspector/src/inDOMUtils.cpp | 28 +++++++++---------- .../inspector/tests/chrome/test_bug708874.xul | 17 +++++++++-- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/layout/inspector/src/inDOMUtils.cpp b/layout/inspector/src/inDOMUtils.cpp index 46028b01c2cd..d0533937bd12 100644 --- a/layout/inspector/src/inDOMUtils.cpp +++ b/layout/inspector/src/inDOMUtils.cpp @@ -138,11 +138,11 @@ inDOMUtils::GetParentForNode(nsIDOMNode* aNode, if (bindingManager) { bparent = bindingManager->GetInsertionParent(content); } - + parent = do_QueryInterface(bparent); } } - + if (!parent) { // Ok, just get the normal DOM parent node aNode->GetParentNode(getter_AddRefs(parent)); @@ -262,7 +262,7 @@ inDOMUtils::IsInheritedProperty(const nsAString &aPropertyName, bool *_retval) return NS_OK; } -NS_IMETHODIMP +NS_IMETHODIMP inDOMUtils::GetBindingURLs(nsIDOMElement *aElement, nsIArray **_retval) { NS_ENSURE_ARG_POINTER(aElement); @@ -292,15 +292,15 @@ NS_IMETHODIMP inDOMUtils::SetContentState(nsIDOMElement *aElement, nsEventStates::InternalType aState) { NS_ENSURE_ARG_POINTER(aElement); - + nsRefPtr esm = inLayoutUtils::GetEventStateManagerFor(aElement); if (esm) { nsCOMPtr content; content = do_QueryInterface(aElement); - + return esm->SetContentState(content, nsEventStates(aState)); } - + return NS_ERROR_FAILURE; } @@ -398,14 +398,14 @@ NS_IMETHODIMP inDOMUtils::AddPseudoClassLock(nsIDOMElement *aElement, const nsAString &aPseudoClass) { - NS_ENSURE_ARG_POINTER(aElement); - nsEventStates state = GetStatesForPseudoClass(aPseudoClass); if (state.IsEmpty()) { return NS_OK; } nsCOMPtr element = do_QueryInterface(aElement); + NS_ENSURE_ARG_POINTER(element); + element->LockStyleStates(state); return NS_OK; @@ -415,14 +415,14 @@ NS_IMETHODIMP inDOMUtils::RemovePseudoClassLock(nsIDOMElement *aElement, const nsAString &aPseudoClass) { - NS_ENSURE_ARG_POINTER(aElement); - nsEventStates state = GetStatesForPseudoClass(aPseudoClass); if (state.IsEmpty()) { return NS_OK; } nsCOMPtr element = do_QueryInterface(aElement); + NS_ENSURE_ARG_POINTER(element); + element->UnlockStyleStates(state); return NS_OK; @@ -433,8 +433,6 @@ inDOMUtils::HasPseudoClassLock(nsIDOMElement *aElement, const nsAString &aPseudoClass, bool *_retval) { - NS_ENSURE_ARG_POINTER(aElement); - nsEventStates state = GetStatesForPseudoClass(aPseudoClass); if (state.IsEmpty()) { *_retval = false; @@ -442,6 +440,8 @@ inDOMUtils::HasPseudoClassLock(nsIDOMElement *aElement, } nsCOMPtr element = do_QueryInterface(aElement); + NS_ENSURE_ARG_POINTER(element); + nsEventStates locks = element->LockedStyleStates(); *_retval = locks.HasAllStates(state); @@ -451,9 +451,9 @@ inDOMUtils::HasPseudoClassLock(nsIDOMElement *aElement, NS_IMETHODIMP inDOMUtils::ClearPseudoClassLocks(nsIDOMElement *aElement) { - NS_ENSURE_ARG_POINTER(aElement); - nsCOMPtr element = do_QueryInterface(aElement); + NS_ENSURE_ARG_POINTER(element); + element->ClearStyleStateLocks(); return NS_OK; diff --git a/layout/inspector/tests/chrome/test_bug708874.xul b/layout/inspector/tests/chrome/test_bug708874.xul index faac9b6d480b..331b8d1872d7 100644 --- a/layout/inspector/tests/chrome/test_bug708874.xul +++ b/layout/inspector/tests/chrome/test_bug708874.xul @@ -28,6 +28,7 @@ function RunTests() { testVisited(); testMultiple(); testInvalid(); + testNotElement(); } function testLockEnabled() { @@ -118,7 +119,7 @@ function testLockDisabled() { /* change state to enabled */ button.removeAttribute("disabled"); - + is(window.getComputedStyle(button).color, disabledColor, ":disabled style applied after enabling"); @@ -256,7 +257,19 @@ function testInvalid() { } } - +function testNotElement() { + var values = [null, undefined, {}]; + try { + for each (value in values); { + DOMUtils.hasPseudoClassLock(value, ":hover"); + DOMUtils.addPseudoClassLock(value, ":hover"); + DOMUtils.removePseudoClassLock(value, ":hover"); + DOMUtils.clearPseudoClassLocks(value); + } + } catch(e) { + // just make sure we don't crash on non-elements + } +} ]]> From f9fade7f61b7095e9d402ec6787248b45cec0fe2 Mon Sep 17 00:00:00 2001 From: Dale Harvey Date: Wed, 9 May 2012 09:34:16 -0700 Subject: [PATCH 012/271] Bug 719461: Added iconchange event to mozbrowser contained frames. r=jlebar --- dom/base/BrowserElementChild.js | 24 ++++ dom/base/BrowserElementParent.js | 1 + dom/tests/mochitest/browser-frame/Makefile.in | 1 + .../browser-frame/test_browserFrame8.html | 130 ++++++++++++++++++ 4 files changed, 156 insertions(+) create mode 100644 dom/tests/mochitest/browser-frame/test_browserFrame8.html diff --git a/dom/base/BrowserElementChild.js b/dom/base/BrowserElementChild.js index beeacae32fbb..77ce4dcfe90e 100644 --- a/dom/base/BrowserElementChild.js +++ b/dom/base/BrowserElementChild.js @@ -45,6 +45,11 @@ BrowserElementChild.prototype = { this._titleChangedHandler.bind(this), /* useCapture = */ true, /* wantsUntrusted = */ false); + + addEventListener('DOMLinkAdded', + this._iconChangedHandler.bind(this), + /* useCapture = */ true, + /* wantsUntrusted = */ false); }, _titleChangedHandler: function(e) { @@ -61,6 +66,25 @@ BrowserElementChild.prototype = { } }, + _iconChangedHandler: function(e) { + debug("Got iconchanged: (" + e.target.href + ")"); + var hasIcon = e.target.rel.split(' ').some(function(x) { + return x.toLowerCase() === 'icon'; + }); + + if (hasIcon) { + var win = e.target.ownerDocument.defaultView; + // Ignore iconchanges which don't come from the top-level + //