Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 97983b5

Browse files
committed
Back out fee79a593fd3 and 2c8930343985 (bug 825341) for having probably needed-clobber
1 parent c038cf7 commit 97983b5

40 files changed

Lines changed: 455 additions & 955 deletions

accessible/src/generic/HyperTextAccessible.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,7 @@ HyperTextAccessible::SetSelectionBounds(int32_t aSelectionNum,
18241824

18251825
nsRefPtr<nsRange> range;
18261826
if (aSelectionNum == rangeCount)
1827-
range = new nsRange(mContent);
1827+
range = new nsRange();
18281828
else
18291829
range = domSel->GetRangeAt(aSelectionNum);
18301830

@@ -1886,7 +1886,7 @@ HyperTextAccessible::ScrollSubstringTo(int32_t aStartIndex, int32_t aEndIndex,
18861886
if (IsDefunct())
18871887
return NS_ERROR_FAILURE;
18881888

1889-
nsRefPtr<nsRange> range = new nsRange(mContent);
1889+
nsRefPtr<nsRange> range = new nsRange();
18901890
nsresult rv = HypertextOffsetsToDOMRange(aStartIndex, aEndIndex, range);
18911891
NS_ENSURE_SUCCESS(rv, rv);
18921892

@@ -1910,7 +1910,7 @@ HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartIndex,
19101910
nsIntPoint coords = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordinateType,
19111911
this);
19121912

1913-
nsRefPtr<nsRange> range = new nsRange(mContent);
1913+
nsRefPtr<nsRange> range = new nsRange();
19141914
nsresult rv = HypertextOffsetsToDOMRange(aStartIndex, aEndIndex, range);
19151915
NS_ENSURE_SUCCESS(rv, rv);
19161916

accessible/src/windows/msaa/TextLeafAccessibleWrap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ TextLeafAccessibleWrap::scrollToSubstring(
158158
if (IsDefunct())
159159
return E_FAIL;
160160

161-
nsRefPtr<nsRange> range = new nsRange(mContent);
161+
nsRefPtr<nsRange> range = new nsRange();
162162
if (NS_FAILED(range->SetStart(mContent, aStartIndex)))
163163
return E_FAIL;
164164

content/base/public/nsContentUtils.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ namespace layers {
112112
} // namespace layers
113113

114114
namespace dom {
115-
class DocumentFragment;
116115
class Element;
117116
} // namespace dom
118117

@@ -367,7 +366,6 @@ class nsContentUtils
367366

368367
// Check if the (JS) caller can access aNode.
369368
static bool CanCallerAccess(nsIDOMNode *aNode);
370-
static bool CanCallerAccess(nsINode* aNode);
371369

372370
// Check if the (JS) caller can access aWindow.
373371
// aWindow can be either outer or inner window.
@@ -1086,10 +1084,6 @@ class nsContentUtils
10861084
const nsAString& aFragment,
10871085
bool aPreventScriptExecution,
10881086
nsIDOMDocumentFragment** aReturn);
1089-
static already_AddRefed<mozilla::dom::DocumentFragment>
1090-
CreateContextualFragment(nsINode* aContextNode, const nsAString& aFragment,
1091-
bool aPreventScriptExecution,
1092-
mozilla::ErrorResult& aRv);
10931087

10941088
/**
10951089
* Invoke the fragment parsing algorithm (innerHTML) using the HTML parser.

content/base/public/nsIDocument.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,10 +2472,6 @@ nsresult
24722472
NS_NewVideoDocument(nsIDocument** aInstancePtrResult);
24732473
#endif
24742474

2475-
already_AddRefed<mozilla::dom::DocumentFragment>
2476-
NS_NewDocumentFragment(nsNodeInfoManager* aNodeInfoManager,
2477-
mozilla::ErrorResult& aRv);
2478-
24792475
nsresult
24802476
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
24812477
nsNodeInfoManager *aNodeInfoManager);

content/base/src/DocumentFragment.cpp

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,21 @@
2121
nsresult
2222
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
2323
nsNodeInfoManager *aNodeInfoManager)
24-
{
25-
mozilla::ErrorResult rv;
26-
*aInstancePtrResult = NS_NewDocumentFragment(aNodeInfoManager, rv).get();
27-
return rv.ErrorCode();
28-
}
29-
30-
already_AddRefed<mozilla::dom::DocumentFragment>
31-
NS_NewDocumentFragment(nsNodeInfoManager* aNodeInfoManager,
32-
mozilla::ErrorResult& aRv)
3324
{
3425
using namespace mozilla::dom;
3526

36-
if (!aNodeInfoManager) {
37-
aRv.Throw(NS_ERROR_INVALID_ARG);
38-
return nullptr;
39-
}
27+
NS_ENSURE_ARG(aNodeInfoManager);
4028

41-
nsCOMPtr<nsINodeInfo> nodeInfo =
42-
aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentFragmentNodeName,
43-
nullptr, kNameSpaceID_None,
44-
nsIDOMNode::DOCUMENT_FRAGMENT_NODE);
45-
if (!nodeInfo) {
46-
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
47-
return nullptr;
48-
}
29+
nsCOMPtr<nsINodeInfo> nodeInfo;
30+
nodeInfo = aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentFragmentNodeName,
31+
nullptr, kNameSpaceID_None,
32+
nsIDOMNode::DOCUMENT_FRAGMENT_NODE);
33+
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
34+
35+
DocumentFragment *it = new DocumentFragment(nodeInfo.forget());
36+
NS_ADDREF(*aInstancePtrResult = it);
4937

50-
nsRefPtr<DocumentFragment> it = new DocumentFragment(nodeInfo.forget());
51-
return it.forget();
38+
return NS_OK;
5239
}
5340

5441
namespace mozilla {

content/base/src/nsContentUtils.cpp

Lines changed: 30 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@
168168
#include "nsSVGFeatures.h"
169169
#include "MediaDecoder.h"
170170
#include "DecoderTraits.h"
171-
#include "mozilla/dom/DocumentFragment.h"
172171

173172
#include "nsWrapperCacheInlines.h"
174173
#include "nsViewportInfo.h"
@@ -1589,15 +1588,6 @@ nsContentUtils::CanCallerAccess(nsIPrincipal* aSubjectPrincipal,
15891588
// static
15901589
bool
15911590
nsContentUtils::CanCallerAccess(nsIDOMNode *aNode)
1592-
{
1593-
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
1594-
NS_ENSURE_TRUE(node, false);
1595-
return CanCallerAccess(node);
1596-
}
1597-
1598-
// static
1599-
bool
1600-
nsContentUtils::CanCallerAccess(nsINode* aNode)
16011591
{
16021592
// XXXbz why not check the IsCapabilityEnabled thing up front, and not bother
16031593
// with the system principal games? But really, there should be a simpler
@@ -1612,7 +1602,10 @@ nsContentUtils::CanCallerAccess(nsINode* aNode)
16121602
return true;
16131603
}
16141604

1615-
return CanCallerAccess(subjectPrincipal, aNode->NodePrincipal());
1605+
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
1606+
NS_ENSURE_TRUE(node, false);
1607+
1608+
return CanCallerAccess(subjectPrincipal, node->NodePrincipal());
16161609
}
16171610

16181611
// static
@@ -4052,22 +4045,8 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
40524045
bool aPreventScriptExecution,
40534046
nsIDOMDocumentFragment** aReturn)
40544047
{
4055-
ErrorResult rv;
4056-
*aReturn = CreateContextualFragment(aContextNode, aFragment,
4057-
aPreventScriptExecution, rv).get();
4058-
return rv.ErrorCode();
4059-
}
4060-
4061-
already_AddRefed<DocumentFragment>
4062-
nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
4063-
const nsAString& aFragment,
4064-
bool aPreventScriptExecution,
4065-
ErrorResult& aRv)
4066-
{
4067-
if (!aContextNode) {
4068-
aRv.Throw(NS_ERROR_INVALID_ARG);
4069-
return nullptr;
4070-
}
4048+
*aReturn = nullptr;
4049+
NS_ENSURE_ARG(aContextNode);
40714050

40724051
// If we don't have a document here, we can't get the right security context
40734052
// for compiling event handlers... so just bail out.
@@ -4079,8 +4058,8 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
40794058
#endif
40804059

40814060
if (isHTML) {
4082-
nsRefPtr<DocumentFragment> frag =
4083-
NS_NewDocumentFragment(document->NodeInfoManager(), aRv);
4061+
nsCOMPtr<nsIDOMDocumentFragment> frag;
4062+
NS_NewDocumentFragment(getter_AddRefs(frag), document->NodeInfoManager());
40844063

40854064
nsCOMPtr<nsIContent> contextAsContent = do_QueryInterface(aContextNode);
40864065
if (contextAsContent && !contextAsContent->IsElement()) {
@@ -4091,23 +4070,28 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
40914070
}
40924071
}
40934072

4073+
nsresult rv;
4074+
nsCOMPtr<nsIContent> fragment = do_QueryInterface(frag);
40944075
if (contextAsContent && !contextAsContent->IsHTML(nsGkAtoms::html)) {
4095-
aRv = ParseFragmentHTML(aFragment, frag,
4096-
contextAsContent->Tag(),
4097-
contextAsContent->GetNameSpaceID(),
4098-
(document->GetCompatibilityMode() ==
4076+
rv = ParseFragmentHTML(aFragment,
4077+
fragment,
4078+
contextAsContent->Tag(),
4079+
contextAsContent->GetNameSpaceID(),
4080+
(document->GetCompatibilityMode() ==
40994081
eCompatibility_NavQuirks),
4100-
aPreventScriptExecution);
4082+
aPreventScriptExecution);
41014083
} else {
4102-
aRv = ParseFragmentHTML(aFragment, frag,
4103-
nsGkAtoms::body,
4104-
kNameSpaceID_XHTML,
4105-
(document->GetCompatibilityMode() ==
4084+
rv = ParseFragmentHTML(aFragment,
4085+
fragment,
4086+
nsGkAtoms::body,
4087+
kNameSpaceID_XHTML,
4088+
(document->GetCompatibilityMode() ==
41064089
eCompatibility_NavQuirks),
4107-
aPreventScriptExecution);
4090+
aPreventScriptExecution);
41084091
}
41094092

4110-
return frag.forget();
4093+
frag.forget(aReturn);
4094+
return rv;
41114095
}
41124096

41134097
nsAutoTArray<nsString, 32> tagStack;
@@ -4119,10 +4103,7 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
41194103

41204104
while (content && content->IsElement()) {
41214105
nsString& tagName = *tagStack.AppendElement();
4122-
if (!&tagName) {
4123-
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
4124-
return nullptr;
4125-
}
4106+
NS_ENSURE_TRUE(&tagName, NS_ERROR_OUT_OF_MEMORY);
41264107

41274108
tagName = content->NodeInfo()->QualifiedName();
41284109

@@ -4168,10 +4149,11 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
41684149
content = content->GetParent();
41694150
}
41704151

4171-
nsCOMPtr<nsIDOMDocumentFragment> frag;
4172-
aRv = ParseFragmentXML(aFragment, document, tagStack,
4173-
aPreventScriptExecution, getter_AddRefs(frag));
4174-
return static_cast<DocumentFragment*>(frag.forget().get());
4152+
return ParseFragmentXML(aFragment,
4153+
document,
4154+
tagStack,
4155+
aPreventScriptExecution,
4156+
aReturn);
41754157
}
41764158

41774159
/* static */

content/base/src/nsCopySupport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ nsCopySupport::GetTransferableForNode(nsINode* aNode,
294294
NS_ENSURE_SUCCESS(rv, rv);
295295
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode);
296296
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
297-
nsRefPtr<nsRange> range = new nsRange(aNode);
297+
nsRefPtr<nsRange> range = new nsRange();
298298
rv = range->SelectNode(node);
299299
NS_ENSURE_SUCCESS(rv, rv);
300300
rv = selection->AddRange(range);

content/base/src/nsDocument.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5573,7 +5573,7 @@ nsDocument::CreateRange(nsIDOMRange** aReturn)
55735573
already_AddRefed<nsRange>
55745574
nsIDocument::CreateRange(ErrorResult& rv)
55755575
{
5576-
nsRefPtr<nsRange> range = new nsRange(this);
5576+
nsRefPtr<nsRange> range = new nsRange();
55775577
nsresult res = range->Set(this, 0, this, 0);
55785578
if (NS_FAILED(res)) {
55795579
rv.Throw(res);

0 commit comments

Comments
 (0)