author | Ms2ger <ms2ger@gmail.com> |
Sat, 23 Jun 2012 08:58:04 +0200 | |
changeset 97398 | 0a14c3b24796cf14c3c90fdeb8147b3f11fd543a |
parent 97397 | b93768181dd0c21e22943d8561e262886b1bfa95 |
child 97399 | bb4b37094b9f058b220955d24fb8aad44cbc888b |
push id | 22972 |
push user | Ms2ger@gmail.com |
push date | Sat, 23 Jun 2012 07:10:46 +0000 |
treeherder | mozilla-central@bb4b37094b9f [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bz |
bugs | 767130 |
milestone | 16.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -2041,17 +2041,19 @@ public: * @param aRoot Root <input> or <textarea> element * @param aOutStartOffset Output start offset * @param aOutEndOffset Output end offset */ static void GetSelectionInTextControl(mozilla::Selection* aSelection, Element* aRoot, PRInt32& aOutStartOffset, PRInt32& aOutEndOffset); - + + static nsIEditor* GetHTMLEditor(nsPresContext* aPresContext); + private: static bool InitializeEventTable(); static nsresult EnsureStringBundle(PropertiesFile aFile); static bool CanCallerAccess(nsIPrincipal* aSubjectPrincipal, nsIPrincipal* aPrincipal);
--- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -1165,16 +1165,18 @@ public: /** * Returns true if 'this' is either document or element or * document fragment and aOther is a descendant in the same * anonymous tree. */ bool Contains(const nsINode* aOther) const; nsresult Contains(nsIDOMNode* aOther, bool* aReturn); + bool UnoptimizableCCNode() const; + private: nsIContent* GetNextNodeImpl(const nsINode* aRoot, const bool aSkipChildren) const { // Can't use nsContentUtils::ContentIsDescendantOf here, since we // can't include it here. #ifdef DEBUG
--- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -168,26 +168,27 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_ #include "nsDOMTouchEvent.h" #include "nsIScriptElement.h" #include "nsIContentViewer.h" #include "nsIObjectLoadingContent.h" #include "nsCCUncollectableMarker.h" #include "mozilla/Base64.h" #include "mozilla/Preferences.h" #include "nsDOMMutationObserver.h" - -#include "nsWrapperCacheInlines.h" #include "nsIDOMDocumentType.h" #include "nsCharSeparatedTokenizer.h" - #include "nsICharsetDetector.h" #include "nsICharsetDetectionObserver.h" #include "nsIPlatformCharset.h" +#include "nsIEditor.h" +#include "nsIEditorDocShell.h" #include "mozilla/Attributes.h" +#include "nsWrapperCacheInlines.h" + extern "C" int MOZ_XMLTranslateEntity(const char* ptr, const char* end, const char** next, PRUnichar* result); extern "C" int MOZ_XMLCheckQName(const char* ptr, const char* end, int ns_aware, const char** colon); using namespace mozilla::dom; using namespace mozilla::layers; using namespace mozilla::widget; @@ -6912,8 +6913,23 @@ nsContentUtils::GetSelectionInTextContro focusOffset = firstChild->Length(); } } // Make sure aOutStartOffset <= aOutEndOffset. aOutStartOffset = NS_MIN(anchorOffset, focusOffset); aOutEndOffset = NS_MAX(anchorOffset, focusOffset); } + +nsIEditor* +nsContentUtils::GetHTMLEditor(nsPresContext* aPresContext) +{ + nsCOMPtr<nsISupports> container = aPresContext->GetContainer(); + nsCOMPtr<nsIEditorDocShell> editorDocShell(do_QueryInterface(container)); + bool isEditable; + if (!editorDocShell || + NS_FAILED(editorDocShell->GetEditable(&isEditable)) || !isEditable) + return nsnull; + + nsCOMPtr<nsIEditor> editor; + editorDocShell->GetEditor(getter_AddRefs(editor)); + return editor; +}
--- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -130,47 +130,16 @@ using namespace mozilla; using namespace mozilla::dom; NS_DEFINE_IID(kThisPtrOffsetsSID, NS_THISPTROFFSETS_SID); PRInt32 nsIContent::sTabFocusModel = eTabFocus_any; bool nsIContent::sTabFocusModelAppliesToXUL = false; PRUint32 nsMutationGuard::sMutationCount = 0; -static nsIEditor* GetHTMLEditor(nsPresContext* aPresContext) -{ - nsCOMPtr<nsISupports> container = aPresContext->GetContainer(); - nsCOMPtr<nsIEditorDocShell> editorDocShell(do_QueryInterface(container)); - bool isEditable; - if (!editorDocShell || - NS_FAILED(editorDocShell->GetEditable(&isEditable)) || !isEditable) - return nsnull; - - nsCOMPtr<nsIEditor> editor; - editorDocShell->GetEditor(getter_AddRefs(editor)); - return editor; -} - -static -bool UnoptimizableCCNode(nsINode* aNode) -{ - const PtrBits problematicFlags = (NODE_IS_ANONYMOUS | - NODE_IS_IN_ANONYMOUS_SUBTREE | - NODE_IS_NATIVE_ANONYMOUS_ROOT | - NODE_MAY_BE_IN_BINDING_MNGR | - NODE_IS_INSERTION_PARENT); - return aNode->HasFlag(problematicFlags) || - aNode->NodeType() == nsIDOMNode::ATTRIBUTE_NODE || - // For strange cases like xbl:content/xbl:children - (aNode->IsElement() && - aNode->AsElement()->IsInNamespace(kNameSpaceID_XBL)); -} - -//---------------------------------------------------------------------- - nsEventStates Element::IntrinsicState() const { return IsEditable() ? NS_EVENT_STATE_MOZ_READWRITE : NS_EVENT_STATE_MOZ_READONLY; } void @@ -398,17 +367,17 @@ nsIContent::GetDesiredIMEState() nsIPresShell* ps = doc->GetShell(); if (!ps) { return IMEState(IMEState::DISABLED); } nsPresContext* pc = ps->GetPresContext(); if (!pc) { return IMEState(IMEState::DISABLED); } - nsIEditor* editor = GetHTMLEditor(pc); + nsIEditor* editor = nsContentUtils::GetHTMLEditor(pc); nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(editor); if (!imeEditor) { return IMEState(IMEState::DISABLED); } IMEState state; imeEditor->GetPreferredIMEState(&state); return state; } @@ -2877,17 +2846,17 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns tmp->DeleteProperty(nsGkAtoms::itemprop); } else if (tmp->IsXUL()) { tmp->DeleteProperty(nsGkAtoms::contextmenulistener); tmp->DeleteProperty(nsGkAtoms::popuplistener); } } // Unlink child content (and unbind our subtree). - if (UnoptimizableCCNode(tmp) || !nsCCUncollectableMarker::sGeneration) { + if (tmp->UnoptimizableCCNode() || !nsCCUncollectableMarker::sGeneration) { PRUint32 childCount = tmp->mAttrsAndChildren.ChildCount(); if (childCount) { // Don't allow script to run while we're unbinding everything. nsAutoScriptBlocker scriptBlocker; while (childCount-- > 0) { // Hold a strong ref to the node when we remove it, because we may be // the last reference to it. We need to call TakeChildAt() and // update mFirstChild before calling UnbindFromTree, since this last @@ -2964,23 +2933,23 @@ nsGenericElement::MarkNodeChildren(nsINo } } nsINode* FindOptimizableSubtreeRoot(nsINode* aNode) { nsINode* p; while ((p = aNode->GetNodeParent())) { - if (UnoptimizableCCNode(aNode)) { + if (aNode->UnoptimizableCCNode()) { return nsnull; } aNode = p; } - if (UnoptimizableCCNode(aNode)) { + if (aNode->UnoptimizableCCNode()) { return nsnull; } return aNode; } nsAutoTArray<nsINode*, 1020>* gCCBlackMarkedNodes = nsnull; void @@ -3011,17 +2980,17 @@ nsGenericElement::CanSkipInCC(nsINode* a nsIDocument* currentDoc = aNode->GetCurrentDoc(); if (currentDoc && nsCCUncollectableMarker::InGeneration(currentDoc->GetMarkedCCGeneration())) { return !NeedsScriptTraverse(aNode); } // Bail out early if aNode is somewhere in anonymous content, // or otherwise unusual. - if (UnoptimizableCCNode(aNode)) { + if (aNode->UnoptimizableCCNode()) { return false; } nsINode* root = currentDoc ? static_cast<nsINode*>(currentDoc) : FindOptimizableSubtreeRoot(aNode); if (!root) { return false; @@ -3170,17 +3139,17 @@ OwnedByBindingManager(nsIDocument* aCurr bool nsGenericElement::CanSkip(nsINode* aNode, bool aRemovingAllowed) { // Don't try to optimize anything during shutdown. if (nsCCUncollectableMarker::sGeneration == 0) { return false; } - bool unoptimizable = UnoptimizableCCNode(aNode); + bool unoptimizable = aNode->UnoptimizableCCNode(); nsIDocument* currentDoc = aNode->GetCurrentDoc(); if (currentDoc && nsCCUncollectableMarker::InGeneration(currentDoc->GetMarkedCCGeneration()) && (!unoptimizable || NodeHasActiveFrame(currentDoc, aNode) || OwnedByBindingManager(currentDoc, aNode))) { MarkNodeChildren(aNode); return true; }
--- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -227,30 +227,16 @@ nsINode::GetTextEditorRootContent(nsIEdi nsIContent* rootContent = GetEditorRootContent(editor); if (aEditor) editor.swap(*aEditor); return rootContent; } return nsnull; } -static nsIEditor* GetHTMLEditor(nsPresContext* aPresContext) -{ - nsCOMPtr<nsISupports> container = aPresContext->GetContainer(); - nsCOMPtr<nsIEditorDocShell> editorDocShell(do_QueryInterface(container)); - bool isEditable; - if (!editorDocShell || - NS_FAILED(editorDocShell->GetEditable(&isEditable)) || !isEditable) - return nsnull; - - nsCOMPtr<nsIEditor> editor; - editorDocShell->GetEditor(getter_AddRefs(editor)); - return editor; -} - static nsIContent* GetRootForContentSubtree(nsIContent* aContent) { NS_ENSURE_TRUE(aContent, nsnull); nsIContent* stop = aContent->GetBindingParent(); while (aContent) { nsIContent* parent = aContent->GetParent(); if (parent == stop) { break; @@ -278,17 +264,17 @@ nsINode::GetSelectionRootContent(nsIPres // This node should be a descendant of input/textarea editor. nsIContent* content = GetTextEditorRootContent(); if (content) return content; } nsPresContext* presContext = aPresShell->GetPresContext(); if (presContext) { - nsIEditor* editor = GetHTMLEditor(presContext); + nsIEditor* editor = nsContentUtils::GetHTMLEditor(presContext); if (editor) { // This node is in HTML editor. nsIDocument* doc = GetCurrentDoc(); if (!doc || doc->HasFlag(NODE_IS_EDITABLE) || !HasFlag(NODE_IS_EDITABLE)) { nsIContent* editorRoot = GetEditorRootContent(editor); NS_ENSURE_TRUE(editorRoot, nsnull); return nsContentUtils::IsInSameAnonymousTree(this, editorRoot) ? @@ -1127,29 +1113,29 @@ nsINode::GetContextForEventHandlers(nsre /* static */ void nsINode::Trace(nsINode *tmp, TraceCallback cb, void *closure) { nsContentUtils::TraceWrapper(tmp, cb, closure); } -static -bool UnoptimizableCCNode(nsINode* aNode) +bool +nsINode::UnoptimizableCCNode() const { const PtrBits problematicFlags = (NODE_IS_ANONYMOUS | NODE_IS_IN_ANONYMOUS_SUBTREE | NODE_IS_NATIVE_ANONYMOUS_ROOT | NODE_MAY_BE_IN_BINDING_MNGR | NODE_IS_INSERTION_PARENT); - return aNode->HasFlag(problematicFlags) || - aNode->NodeType() == nsIDOMNode::ATTRIBUTE_NODE || + return HasFlag(problematicFlags) || + NodeType() == nsIDOMNode::ATTRIBUTE_NODE || // For strange cases like xbl:content/xbl:children - (aNode->IsElement() && - aNode->AsElement()->IsInNamespace(kNameSpaceID_XBL)); + (IsElement() && + AsElement()->IsInNamespace(kNameSpaceID_XBL)); } /* static */ bool nsINode::Traverse(nsINode *tmp, nsCycleCollectionTraversalCallback &cb) { if (NS_LIKELY(!cb.WantAllTraces())) { nsIDocument *currentDoc = tmp->GetCurrentDoc(); @@ -1159,25 +1145,25 @@ nsINode::Traverse(nsINode *tmp, nsCycleC } if (nsCCUncollectableMarker::sGeneration) { // If we're black no need to traverse. if (tmp->IsBlack() || tmp->InCCBlackTree()) { return false; } - if (!UnoptimizableCCNode(tmp)) { + if (!tmp->UnoptimizableCCNode()) { // If we're in a black document, return early. if ((currentDoc && currentDoc->IsBlack())) { return false; } // If we're not in anonymous content and we have a black parent, // return early. nsIContent* parent = tmp->GetParent(); - if (parent && !UnoptimizableCCNode(parent) && parent->IsBlack()) { + if (parent && !parent->UnoptimizableCCNode() && parent->IsBlack()) { NS_ABORT_IF_FALSE(parent->IndexOf(tmp) >= 0, "Parent doesn't own us?"); return false; } } } } NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mNodeInfo)