From cecabe4d0bb4fa08a08b857a6a62b7dc8e75883a Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Sun, 8 Jul 2012 20:45:12 -0400 Subject: [PATCH 01/20] Bug 770814 - Make nsEditor::GetNodeLocation return already_AddRefed instead of having it as an out param; r=ehsan --- editor/libeditor/base/nsEditor.cpp | 25 +-- editor/libeditor/base/nsEditor.h | 9 +- editor/libeditor/base/nsSelectionState.cpp | 7 +- editor/libeditor/html/nsHTMLDataTransfer.cpp | 21 +-- editor/libeditor/html/nsHTMLEditRules.cpp | 158 +++++++----------- editor/libeditor/html/nsHTMLEditor.cpp | 12 +- editor/libeditor/html/nsHTMLEditorStyle.cpp | 12 +- editor/libeditor/html/nsWSRunObject.cpp | 3 +- .../text/nsPlaintextDataTransfer.cpp | 3 +- editor/libeditor/text/nsPlaintextEditor.cpp | 13 +- editor/libeditor/text/nsTextEditRules.cpp | 3 +- 11 files changed, 111 insertions(+), 155 deletions(-) diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index 893780fe58c3..33e10fdaf588 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -1719,9 +1719,8 @@ nsEditor::MoveNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset) NS_ENSURE_TRUE(aNode && aParent, NS_ERROR_NULL_POINTER); nsresult res; - nsCOMPtr oldParent; PRInt32 oldOffset; - GetNodeLocation(aNode, address_of(oldParent), &oldOffset); + nsCOMPtr oldParent = GetNodeLocation(aNode, &oldOffset); if (aOffset == -1) { @@ -2932,9 +2931,8 @@ nsEditor::JoinNodesImpl(nsIDOMNode * aNodeToKeep, PRUint32 firstNodeLength; result = GetLengthOfDOMNode(leftNode, firstNodeLength); NS_ENSURE_SUCCESS(result, result); - nsCOMPtr parent; - GetNodeLocation(aNodeToJoin, address_of(parent), &joinOffset); - GetNodeLocation(aNodeToKeep, address_of(parent), &keepOffset); + nsCOMPtr parent = GetNodeLocation(aNodeToJoin, &joinOffset); + parent = GetNodeLocation(aNodeToKeep, &keepOffset); // if selection endpoint is between the nodes, remember it as being // in the one that is going away instead. This simplifies later selection @@ -3122,18 +3120,21 @@ nsEditor::GetChildOffset(nsIDOMNode* aChild, nsIDOMNode* aParent) } // static -void -nsEditor::GetNodeLocation(nsIDOMNode* aChild, nsCOMPtr* outParent, - PRInt32* outOffset) +already_AddRefed +nsEditor::GetNodeLocation(nsIDOMNode* aChild, PRInt32* outOffset) { - MOZ_ASSERT(aChild && outParent && outOffset); + MOZ_ASSERT(aChild && outOffset); *outOffset = -1; + nsCOMPtr parent; + MOZ_ALWAYS_TRUE(NS_SUCCEEDED( - aChild->GetParentNode(getter_AddRefs(*outParent)))); - if (*outParent) { - *outOffset = GetChildOffset(aChild, *outParent); + aChild->GetParentNode(getter_AddRefs(parent)))); + if (parent) { + *outOffset = GetChildOffset(aChild, parent); } + + return parent.forget(); } // returns the number of things inside aNode. diff --git a/editor/libeditor/base/nsEditor.h b/editor/libeditor/base/nsEditor.h index 125c36a7882f..ddd9fad5b89d 100644 --- a/editor/libeditor/base/nsEditor.h +++ b/editor/libeditor/base/nsEditor.h @@ -443,12 +443,11 @@ public: nsIDOMNode *aParent); /** - * Set outParent to the parent of aChild. - * Set outOffset to the offset of aChild in outParent. + * Set outOffset to the offset of aChild in the parent. + * Returns the parent of aChild. */ - static void GetNodeLocation(nsIDOMNode* aChild, - nsCOMPtr* outParent, - PRInt32* outOffset); + static already_AddRefed GetNodeLocation(nsIDOMNode* aChild, + PRInt32* outOffset); /** returns the number of things inside aNode in the out-param aCount. * @param aNode is the node to get the length of. diff --git a/editor/libeditor/base/nsSelectionState.cpp b/editor/libeditor/base/nsSelectionState.cpp index 63d311ad8555..259a3e8de093 100644 --- a/editor/libeditor/base/nsSelectionState.cpp +++ b/editor/libeditor/base/nsSelectionState.cpp @@ -256,10 +256,8 @@ nsRangeUpdater::SelAdjDeleteNode(nsIDOMNode *aNode) return; } - nsCOMPtr parent; PRInt32 offset = 0; - - nsEditor::GetNodeLocation(aNode, address_of(parent), &offset); + nsCOMPtr parent = nsEditor::GetNodeLocation(aNode, &offset); // check for range endpoints that are after aNode and in the same parent nsRangeStore *item; @@ -314,9 +312,8 @@ nsRangeUpdater::SelAdjSplitNode(nsIDOMNode *aOldRightNode, PRInt32 aOffset, nsID return NS_OK; } - nsCOMPtr parent; PRInt32 offset; - nsEditor::GetNodeLocation(aOldRightNode, address_of(parent), &offset); + nsCOMPtr parent = nsEditor::GetNodeLocation(aOldRightNode, &offset); // first part is same as inserting aNewLeftnode nsresult result = SelAdjInsertNode(parent,offset-1); diff --git a/editor/libeditor/html/nsHTMLDataTransfer.cpp b/editor/libeditor/html/nsHTMLDataTransfer.cpp index e8d3483a1db7..73a0f13cc1ff 100644 --- a/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -541,9 +541,8 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString, rv = IsEmptyNode(parentNode, &isEmpty, true); if (NS_SUCCEEDED(rv) && isEmpty) { - nsCOMPtr listNode; PRInt32 newOffset; - GetNodeLocation(parentNode, address_of(listNode), &newOffset); + nsCOMPtr listNode = GetNodeLocation(parentNode, &newOffset); if (listNode) { DeleteNode(parentNode); @@ -618,7 +617,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString, } if (lastInsertNode) { - GetNodeLocation(lastInsertNode, address_of(parentNode), &offsetOfNewNode); + parentNode = GetNodeLocation(lastInsertNode, &offsetOfNewNode); offsetOfNewNode++; } } @@ -657,7 +656,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString, else // we need to find a container for selection. Look up. { tmp = selNode; - GetNodeLocation(tmp, address_of(selNode), &selOffset); + selNode = GetNodeLocation(tmp, &selOffset); ++selOffset; // want to be *after* last leaf node in paste } @@ -677,8 +676,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString, { // don't leave selection past an invisible break; // reset {selNode,selOffset} to point before break - GetNodeLocation(wsRunObj.mStartReasonNode, address_of(selNode), - &selOffset); + selNode = GetNodeLocation(wsRunObj.mStartReasonNode, &selOffset); // we want to be inside any inline style prior to break nsWSRunObject wsRunObj(this, selNode, selOffset); wsRunObj.PriorVisibleNode(selNode, selOffset, address_of(visNode), @@ -693,8 +691,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString, { // prior visible thing is an image or some other non-text thingy. // We want to be right after it. - GetNodeLocation(wsRunObj.mStartReasonNode, address_of(selNode), - &selOffset); + selNode = GetNodeLocation(wsRunObj.mStartReasonNode, &selOffset); ++selOffset; } } @@ -713,7 +710,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString, PRInt32 linkOffset; rv = SplitNodeDeep(link, selNode, selOffset, &linkOffset, true, address_of(leftLink)); NS_ENSURE_SUCCESS(rv, rv); - GetNodeLocation(leftLink, address_of(selNode), &selOffset); + selNode = GetNodeLocation(leftLink, &selOffset); selection->Collapse(selNode, selOffset+1); } } @@ -2009,9 +2006,8 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsAString & aQuotedText, // Set the selection to just after the inserted node: if (NS_SUCCEEDED(rv) && newNode) { - nsCOMPtr parent; PRInt32 offset; - GetNodeLocation(newNode, address_of(parent), &offset); + nsCOMPtr parent = GetNodeLocation(newNode, &offset); if (parent) { selection->Collapse(parent, offset + 1); } @@ -2094,9 +2090,8 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText, // Set the selection to just after the inserted node: if (NS_SUCCEEDED(rv) && newNode) { - nsCOMPtr parent; PRInt32 offset; - GetNodeLocation(newNode, address_of(parent), &offset); + nsCOMPtr parent = GetNodeLocation(newNode, &offset); if (parent) { selection->Collapse(parent, offset + 1); } diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index e9067c956642..cf6e6e174feb 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -755,12 +755,11 @@ nsHTMLEditRules::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign) NS_ENSURE_SUCCESS(res, res); // get selection location - nsCOMPtr parent; nsCOMPtr rootElem = do_QueryInterface(mHTMLEditor->GetRoot()); NS_ENSURE_TRUE(rootElem, NS_ERROR_FAILURE); PRInt32 offset, rootOffset; - nsEditor::GetNodeLocation(rootElem, address_of(parent), &rootOffset); + nsCOMPtr parent = nsEditor::GetNodeLocation(rootElem, &rootOffset); res = mHTMLEditor->GetStartNodeAndOffset(selection, getter_AddRefs(parent), &offset); NS_ENSURE_SUCCESS(res, res); @@ -1203,7 +1202,7 @@ nsHTMLEditRules::WillInsert(nsISelection *aSelection, bool *aCancel) // if we are here then the selection is right after a mozBR // that is in the same block as the selection. We need to move // the selection start to be before the mozBR. - nsEditor::GetNodeLocation(priorNode, address_of(selNode), &selOffset); + selNode = nsEditor::GetNodeLocation(priorNode, &selOffset); res = aSelection->Collapse(selNode,selOffset); NS_ENSURE_SUCCESS(res, res); } @@ -1608,7 +1607,7 @@ nsHTMLEditRules::StandardBreakImpl(nsIDOMNode* aNode, PRInt32 aOffset, address_of(brNode), nsIEditor::eNone); } NS_ENSURE_SUCCESS(res, res); - nsEditor::GetNodeLocation(brNode, address_of(node), &aOffset); + node = nsEditor::GetNodeLocation(brNode, &aOffset); NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER); if (bAfterBlock && bBeforeBlock) { // we just placed a br between block boundaries. This is the one case @@ -1630,9 +1629,8 @@ nsHTMLEditRules::StandardBreakImpl(nsIDOMNode* aNode, PRInt32 aOffset, // SetInterlinePosition(). It will also assure that if the user clicks // away and then clicks back on their new blank line, they will still // get the style from the line above. - nsCOMPtr brParent; PRInt32 brOffset; - nsEditor::GetNodeLocation(secondBR, address_of(brParent), &brOffset); + nsCOMPtr brParent = nsEditor::GetNodeLocation(secondBR, &brOffset); if (brParent != node || brOffset != aOffset + 1) { res = mHTMLEditor->MoveNode(secondBR, node, aOffset+1); NS_ENSURE_SUCCESS(res, res); @@ -1698,7 +1696,7 @@ nsHTMLEditRules::SplitMailCites(nsISelection *aSelection, bool aPlaintext, bool if (nsEditorUtils::IsDescendantOf(visNode, citeNode, &unused)) { // it is. so lets reset our selection to be just after it. - mHTMLEditor->GetNodeLocation(visNode, address_of(selNode), &selOffset); + selNode = mHTMLEditor->GetNodeLocation(visNode, &selOffset); ++selOffset; } } @@ -1963,7 +1961,7 @@ nsHTMLEditRules::WillDeleteSelection(Selection* aSelection, bool moveOnly = true; - nsEditor::GetNodeLocation(visNode, address_of(selNode), &selOffset); + selNode = nsEditor::GetNodeLocation(visNode, &selOffset); bool interLineIsRight; res = aSelection->GetInterlinePosition(&interLineIsRight); @@ -2509,7 +2507,7 @@ nsHTMLEditRules::GetGoodSelPointForNode(nsIDOMNode *aNode, nsIEditor::EDirection } else { - nsEditor::GetNodeLocation(aNode, outSelNode, outSelOffset); + *outSelNode = nsEditor::GetNodeLocation(aNode, outSelOffset); if (!nsTextEditUtils::IsBreak(aNode) || mHTMLEditor->IsVisBreak(aNode)) { if (aAction == nsIEditor::ePrevious) @@ -2852,9 +2850,9 @@ nsHTMLEditRules::DidDeleteSelection(nsISelection *aSelection, mHTMLEditor->IsEmptyNodeImpl(cite, &isEmpty, true, true, false, &seenBR); if (isEmpty) { - nsCOMPtr parent, brNode; + nsCOMPtr brNode; PRInt32 offset; - nsEditor::GetNodeLocation(citeNode, address_of(parent), &offset); + nsCOMPtr parent = nsEditor::GetNodeLocation(citeNode, &offset); res = mHTMLEditor->DeleteNode(citeNode); NS_ENSURE_SUCCESS(res, res); if (parent && seenBR) @@ -2993,7 +2991,7 @@ nsHTMLEditRules::WillMakeList(nsISelection* aSelection, nsCOMPtr newBlock; nsCOMPtr curNode = arrayOfNodes[i]; PRInt32 offset; - nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset); + curParent = nsEditor::GetNodeLocation(curNode, &offset); // make sure we don't assemble content that is in different table cells // into the same list. respect table cell boundaries when listifying. @@ -3052,9 +3050,8 @@ nsHTMLEditRules::WillMakeList(nsISelection* aSelection, res = mHTMLEditor->SplitNode(curParent, offset, getter_AddRefs(newBlock)); NS_ENSURE_SUCCESS(res, res); - nsCOMPtr parent; PRInt32 offset; - nsEditor::GetNodeLocation(curParent, address_of(parent), &offset); + nsCOMPtr parent = nsEditor::GetNodeLocation(curParent, &offset); res = mHTMLEditor->CreateNode(*aListType, parent, offset, getter_AddRefs(curList)); NS_ENSURE_SUCCESS(res, res); @@ -3207,7 +3204,7 @@ nsHTMLEditRules::WillRemoveList(nsISelection *aSelection, // here's where we actually figure out what to do nsIDOMNode* curNode = arrayOfNodes[i]; PRInt32 offset; - nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset); + curParent = nsEditor::GetNodeLocation(curNode, &offset); if (nsHTMLEditUtils::IsListItem(curNode)) // unlist this listitem { @@ -3511,7 +3508,7 @@ nsHTMLEditRules::WillCSSIndent(nsISelection *aSelection, bool *aCancel, bool * a if (!mHTMLEditor->IsEditable(curNode)) continue; PRInt32 offset; - nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset); + curParent = nsEditor::GetNodeLocation(curNode, &offset); // some logic for putting list items into nested lists... if (nsHTMLEditUtils::IsList(curParent)) @@ -3694,7 +3691,7 @@ nsHTMLEditRules::WillHTMLIndent(nsISelection *aSelection, bool *aCancel, bool * if (!mHTMLEditor->IsEditable(curNode)) continue; PRInt32 offset; - nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset); + curParent = nsEditor::GetNodeLocation(curNode, &offset); // some logic for putting list items into nested lists... if (nsHTMLEditUtils::IsList(curParent)) @@ -3775,7 +3772,7 @@ nsHTMLEditRules::WillHTMLIndent(nsISelection *aSelection, bool *aCancel, bool * if (listitem) { if (indentedLI == listitem) continue; // already indented this list item - nsEditor::GetNodeLocation(listitem, address_of(curParent), &offset); + curParent = nsEditor::GetNodeLocation(listitem, &offset); // check to see if curList is still appropriate. Which it is if // curNode is still right after it in the same list. if (curList) @@ -3883,7 +3880,7 @@ nsHTMLEditRules::WillOutdent(nsISelection *aSelection, bool *aCancel, bool *aHan // here's where we actually figure out what to do nsCOMPtr curNode = arrayOfNodes[i]; PRInt32 offset; - nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset); + curParent = nsEditor::GetNodeLocation(curNode, &offset); // is it a blockquote? if (nsHTMLEditUtils::IsBlockquote(curNode)) @@ -4091,7 +4088,7 @@ nsHTMLEditRules::WillOutdent(nsISelection *aSelection, bool *aCancel, bool *aHan ((sNode == rememberedLeftBQ) || nsEditorUtils::IsDescendantOf(sNode, rememberedLeftBQ))) { // selection is inside rememberedLeftBQ - push it past it. - nsEditor::GetNodeLocation(rememberedLeftBQ, address_of(sNode), &sOffset); + sNode = nsEditor::GetNodeLocation(rememberedLeftBQ, &sOffset); sOffset++; aSelection->Collapse(sNode, sOffset); } @@ -4101,7 +4098,7 @@ nsHTMLEditRules::WillOutdent(nsISelection *aSelection, bool *aCancel, bool *aHan ((sNode == rememberedRightBQ) || nsEditorUtils::IsDescendantOf(sNode, rememberedRightBQ))) { // selection is inside rememberedRightBQ - push it before it. - nsEditor::GetNodeLocation(rememberedRightBQ, address_of(sNode), &sOffset); + sNode = nsEditor::GetNodeLocation(rememberedRightBQ, &sOffset); aSelection->Collapse(sNode, sOffset); } } @@ -4144,12 +4141,12 @@ nsHTMLEditRules::SplitBlock(nsIDOMNode *aBlock, { NS_ENSURE_TRUE(aBlock && aStartChild && aEndChild, NS_ERROR_NULL_POINTER); - nsCOMPtr startParent, endParent, leftNode, rightNode; + nsCOMPtr leftNode, rightNode; PRInt32 startOffset, endOffset, offset; nsresult res; // get split point location - nsEditor::GetNodeLocation(aStartChild, address_of(startParent), &startOffset); + nsCOMPtr startParent = nsEditor::GetNodeLocation(aStartChild, &startOffset); // do the splits! res = mHTMLEditor->SplitNodeDeep(aBlock, startParent, startOffset, &offset, @@ -4162,7 +4159,7 @@ nsHTMLEditRules::SplitBlock(nsIDOMNode *aBlock, *aLeftNode = leftNode; // get split point location - nsEditor::GetNodeLocation(aEndChild, address_of(endParent), &endOffset); + nsCOMPtr endParent = nsEditor::GetNodeLocation(aEndChild, &endOffset); endOffset++; // want to be after lastBQChild // do the splits! @@ -4551,7 +4548,7 @@ nsHTMLEditRules::WillAlign(nsISelection *aSelection, if (!mHTMLEditor->IsEditable(curNode)) continue; PRInt32 offset; - nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset); + curParent = nsEditor::GetNodeLocation(curNode, &offset); // the node is a table element, an horiz rule, a paragraph, a div // or a section header; in HTML 4, it can directly carry the ALIGN @@ -4770,9 +4767,8 @@ nsHTMLEditRules::CheckForEmptyBlock(nsIDOMNode *aStartNode, nsCOMPtr emptyContent = do_QueryInterface(emptyBlock); if (emptyBlock && emptyContent->IsEditable()) { - nsCOMPtr blockParent; PRInt32 offset; - nsEditor::GetNodeLocation(emptyBlock, address_of(blockParent), &offset); + nsCOMPtr blockParent = nsEditor::GetNodeLocation(emptyBlock, &offset); NS_ENSURE_TRUE(blockParent && offset >= 0, NS_ERROR_FAILURE); if (nsHTMLEditUtils::IsListItem(emptyBlock)) @@ -4783,10 +4779,9 @@ nsHTMLEditRules::CheckForEmptyBlock(nsIDOMNode *aStartNode, NS_ENSURE_SUCCESS(res, res); if (bIsFirst) { - nsCOMPtr listParent; PRInt32 listOffset; - nsEditor::GetNodeLocation(blockParent, address_of(listParent), - &listOffset); + nsCOMPtr listParent = nsEditor::GetNodeLocation(blockParent, + &listOffset); NS_ENSURE_TRUE(listParent && listOffset >= 0, NS_ERROR_FAILURE); // if we are a sublist, skip the br creation if (!nsHTMLEditUtils::IsList(listParent)) @@ -4834,11 +4829,9 @@ nsHTMLEditRules::CheckForInvisibleBR(nsIDOMNode *aBlock, if (rightmostNode) { - nsCOMPtr nodeParent; PRInt32 nodeOffset; - - nsEditor::GetNodeLocation(rightmostNode, address_of(nodeParent), - &nodeOffset); + nsCOMPtr nodeParent = nsEditor::GetNodeLocation(rightmostNode, + &nodeOffset); runTest = true; testNode = nodeParent; // use offset + 1, because we want the last node included in our @@ -4979,7 +4972,8 @@ nsHTMLEditRules::ExpandSelectionForDeletion(nsISelection *aSelection) } else { - nsEditor::GetNodeLocation(wsObj.mStartReasonNode, address_of(selStartNode), &selStartOffset); + selStartNode = nsEditor::GetNodeLocation(wsObj.mStartReasonNode, + &selStartOffset); } } else @@ -5011,7 +5005,7 @@ nsHTMLEditRules::ExpandSelectionForDeletion(nsISelection *aSelection) firstBRParent = selEndNode; firstBROffset = selEndOffset; } - nsEditor::GetNodeLocation(wsObj.mEndReasonNode, address_of(selEndNode), &selEndOffset); + selEndNode = nsEditor::GetNodeLocation(wsObj.mEndReasonNode, &selEndOffset); ++selEndOffset; } } @@ -5027,7 +5021,7 @@ nsHTMLEditRules::ExpandSelectionForDeletion(nsISelection *aSelection) } else { - nsEditor::GetNodeLocation(wsObj.mEndReasonNode, address_of(selEndNode), &selEndOffset); + selEndNode = nsEditor::GetNodeLocation(wsObj.mEndReasonNode, &selEndOffset); ++selEndOffset; } } @@ -5150,7 +5144,7 @@ nsHTMLEditRules::NormalizeSelection(nsISelection *inSelection) nsCOMPtr child = mHTMLEditor->GetRightmostChild(wsEndObj.mStartReasonNode, true); if (child) { - nsEditor::GetNodeLocation(child, address_of(newEndNode), &newEndOffset); + newEndNode = nsEditor::GetNodeLocation(child, &newEndOffset); ++newEndOffset; // offset *after* child } // else block is empty - we can leave selection alone here, i think. @@ -5162,8 +5156,7 @@ nsHTMLEditRules::NormalizeSelection(nsISelection *inSelection) res = mHTMLEditor->GetPriorHTMLNode(endNode, endOffset, address_of(child)); if (child) { - nsEditor::GetNodeLocation(child, address_of(newEndNode), - &newEndOffset); + newEndNode = nsEditor::GetNodeLocation(child, &newEndOffset); ++newEndOffset; // offset *after* child } // else block is empty - we can leave selection alone here, i think. @@ -5171,8 +5164,8 @@ nsHTMLEditRules::NormalizeSelection(nsISelection *inSelection) else if (wsEndObj.mStartReason == nsWSRunObject::eBreak) { // endpoint is just after break. lets adjust it to before it. - nsEditor::GetNodeLocation(wsEndObj.mStartReasonNode, - address_of(newEndNode), &newEndOffset); + newEndNode = nsEditor::GetNodeLocation(wsEndObj.mStartReasonNode, + &newEndOffset); } } @@ -5193,8 +5186,7 @@ nsHTMLEditRules::NormalizeSelection(nsISelection *inSelection) nsCOMPtr child = mHTMLEditor->GetLeftmostChild(wsStartObj.mEndReasonNode, true); if (child) { - nsEditor::GetNodeLocation(child, address_of(newStartNode), - &newStartOffset); + newStartNode = nsEditor::GetNodeLocation(child, &newStartOffset); } // else block is empty - we can leave selection alone here, i think. } @@ -5205,16 +5197,15 @@ nsHTMLEditRules::NormalizeSelection(nsISelection *inSelection) res = mHTMLEditor->GetNextHTMLNode(startNode, startOffset, address_of(child)); if (child) { - nsEditor::GetNodeLocation(child, address_of(newStartNode), - &newStartOffset); + newStartNode = nsEditor::GetNodeLocation(child, &newStartOffset); } // else block is empty - we can leave selection alone here, i think. } else if (wsStartObj.mEndReason == nsWSRunObject::eBreak) { // startpoint is just before a break. lets adjust it to after it. - nsEditor::GetNodeLocation(wsStartObj.mEndReasonNode, - address_of(newStartNode), &newStartOffset); + newStartNode = nsEditor::GetNodeLocation(wsStartObj.mEndReasonNode, + &newStartOffset); ++newStartOffset; // offset *after* break } } @@ -6059,8 +6050,7 @@ nsHTMLEditRules::BustUpInlinesAtBRs(nsIDOMNode *inNode, breakNode = arrayOfBreaks[i]; NS_ENSURE_TRUE(breakNode, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(splitDeepNode, NS_ERROR_NULL_POINTER); - nsEditor::GetNodeLocation(breakNode, address_of(splitParentNode), - &splitOffset); + splitParentNode = nsEditor::GetNodeLocation(breakNode, &splitOffset); res = mHTMLEditor->SplitNodeDeep(splitDeepNode, splitParentNode, splitOffset, &resultOffset, false, address_of(leftNode), address_of(rightNode)); NS_ENSURE_SUCCESS(res, res); @@ -6260,9 +6250,8 @@ nsHTMLEditRules::ReturnInHeader(nsISelection *aSelection, NS_ENSURE_TRUE(aSelection && aHeader && aNode, NS_ERROR_NULL_POINTER); // remeber where the header is - nsCOMPtr headerParent; PRInt32 offset; - nsEditor::GetNodeLocation(aHeader, address_of(headerParent), &offset); + nsCOMPtr headerParent = nsEditor::GetNodeLocation(aHeader, &offset); // get ws code to adjust any ws nsCOMPtr selNode = aNode; @@ -6321,7 +6310,7 @@ nsHTMLEditRules::ReturnInHeader(nsISelection *aSelection, } else { - nsEditor::GetNodeLocation(sibling, address_of(headerParent), &offset); + headerParent = nsEditor::GetNodeLocation(sibling, &offset); // put selection after break res = aSelection->Collapse(headerParent,offset+1); } @@ -6352,9 +6341,8 @@ nsHTMLEditRules::ReturnInParagraph(nsISelection* aSelection, *aHandled = false; nsresult res; - nsCOMPtr parent; PRInt32 offset; - nsEditor::GetNodeLocation(aNode, address_of(parent), &offset); + nsCOMPtr parent = nsEditor::GetNodeLocation(aNode, &offset); bool doesCRCreateNewP = mHTMLEditor->GetReturnInParagraphCreatesNewParagraph(); @@ -6481,9 +6469,8 @@ nsHTMLEditRules::SplitParagraph(nsIDOMNode *aPara, } else { - nsCOMPtr parent; PRInt32 offset; - nsEditor::GetNodeLocation(child, address_of(parent), &offset); + nsCOMPtr parent = nsEditor::GetNodeLocation(child, &offset); aSelection->Collapse(parent,offset); } return res; @@ -6513,9 +6500,8 @@ nsHTMLEditRules::ReturnInListItem(nsISelection *aSelection, // get the listitem parent and the active editing host. nsIContent* rootContent = mHTMLEditor->GetActiveEditingHost(); nsCOMPtr rootNode = do_QueryInterface(rootContent); - nsCOMPtr list; PRInt32 itemOffset; - nsEditor::GetNodeLocation(aListItem, address_of(list), &itemOffset); + nsCOMPtr list = nsEditor::GetNodeLocation(aListItem, &itemOffset); // if we are in an empty listitem, then we want to pop up out of the list // but only if prefs says it's ok and if the parent isn't the active editing host. @@ -6525,9 +6511,8 @@ nsHTMLEditRules::ReturnInListItem(nsISelection *aSelection, if (isEmpty && (rootNode != list) && mReturnInEmptyLIKillsList) { // get the list offset now -- before we might eventually split the list - nsCOMPtr listparent; PRInt32 offset; - nsEditor::GetNodeLocation(list, address_of(listparent), &offset); + nsCOMPtr listparent = nsEditor::GetNodeLocation(list, &offset); // are we the last list item in the list? bool bIsLast; @@ -6603,9 +6588,8 @@ nsHTMLEditRules::ReturnInListItem(nsISelection *aSelection, nsCOMPtr nodeAtom = nsEditor::GetTag(aListItem); if (nodeAtom == nsEditProperty::dd || nodeAtom == nsEditProperty::dt) { - nsCOMPtr list; PRInt32 itemOffset; - nsEditor::GetNodeLocation(aListItem, address_of(list), &itemOffset); + nsCOMPtr list = nsEditor::GetNodeLocation(aListItem, &itemOffset); nsAutoString listTag((nodeAtom == nsEditProperty::dt) ? NS_LITERAL_STRING("dd") : NS_LITERAL_STRING("dt")); nsCOMPtr newListItem; @@ -6621,9 +6605,8 @@ nsHTMLEditRules::ReturnInListItem(nsISelection *aSelection, NS_ENSURE_SUCCESS(res, res); if (brNode) { - nsCOMPtr brParent; PRInt32 offset; - nsEditor::GetNodeLocation(brNode, address_of(brParent), &offset); + nsCOMPtr brParent = nsEditor::GetNodeLocation(brNode, &offset); return aSelection->Collapse(brParent, offset); } } @@ -6639,9 +6622,8 @@ nsHTMLEditRules::ReturnInListItem(nsISelection *aSelection, (wsType==nsWSRunObject::eBreak) || nsHTMLEditUtils::IsHR(visNode) ) { - nsCOMPtr parent; PRInt32 offset; - nsEditor::GetNodeLocation(visNode, address_of(parent), &offset); + nsCOMPtr parent = nsEditor::GetNodeLocation(visNode, &offset); return aSelection->Collapse(parent, offset); } else @@ -6680,7 +6662,7 @@ nsHTMLEditRules::MakeBlockquote(nsCOMArray& arrayOfNodes) { // get the node to act on, and its location curNode = arrayOfNodes[i]; - nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset); + curParent = nsEditor::GetNodeLocation(curNode, &offset); // if the node is a table element or list item, dive inside if (nsHTMLEditUtils::IsTableElementButNotTable(curNode) || @@ -6878,7 +6860,7 @@ nsHTMLEditRules::ApplyBlockStyle(nsCOMArray& arrayOfNodes, const nsA { // get the node to act on, and its location curNode = arrayOfNodes[i]; - nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset); + curParent = nsEditor::GetNodeLocation(curNode, &offset); nsAutoString curNodeTag; nsEditor::GetTagString(curNode, curNodeTag); ToLowerCase(curNodeTag); @@ -7070,8 +7052,8 @@ nsHTMLEditRules::JoinNodesSmart( nsIDOMNode *aNodeLeft, // caller responsible for: // left & right node are same type PRInt32 parOffset; - nsCOMPtr parent, rightParent; - nsEditor::GetNodeLocation(aNodeLeft, address_of(parent), &parOffset); + nsCOMPtr rightParent; + nsCOMPtr parent = nsEditor::GetNodeLocation(aNodeLeft, &parOffset); aNodeRight->GetParentNode(getter_AddRefs(rightParent)); // if they don't have the same parent, first move the 'right' node @@ -7342,9 +7324,7 @@ nsHTMLEditRules::PinSelectionToNewBlock(nsISelection *aSelection) } else { - nsCOMPtr tmp2; - nsEditor::GetNodeLocation(tmp, address_of(tmp2), (PRInt32*)&endPoint); - tmp = tmp2; + tmp = nsEditor::GetNodeLocation(tmp, (PRInt32*)&endPoint); endPoint++; // want to be after this node } return aSelection->Collapse(tmp, (PRInt32)endPoint); @@ -7357,9 +7337,7 @@ nsHTMLEditRules::PinSelectionToNewBlock(nsISelection *aSelection) PRInt32 offset; if (!(mHTMLEditor->IsTextNode(tmp) || mHTMLEditor->IsContainer(tmp))) { - nsCOMPtr tmp2; - nsEditor::GetNodeLocation(tmp, address_of(tmp2), &offset); - tmp = tmp2; + tmp = nsEditor::GetNodeLocation(tmp, &offset); } return aSelection->Collapse(tmp, 0); } @@ -7433,7 +7411,7 @@ nsHTMLEditRules::AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection while (!mHTMLEditor->IsEditable(selNode)) { // scan up the tree until we find an editable place to be - nsEditor::GetNodeLocation(temp, address_of(selNode), &selOffset); + selNode = nsEditor::GetNodeLocation(temp, &selOffset); NS_ENSURE_TRUE(selNode, NS_ERROR_FAILURE); temp = selNode; } @@ -7496,7 +7474,7 @@ nsHTMLEditRules::AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection nsCOMPtr brNode; res = CreateMozBR(selNode, selOffset, getter_AddRefs(brNode)); NS_ENSURE_SUCCESS(res, res); - nsEditor::GetNodeLocation(brNode, address_of(selNode), &selOffset); + selNode = nsEditor::GetNodeLocation(brNode, &selOffset); // selection stays *before* moz-br, sticking to it selPriv->SetInterlinePosition(true); res = aSelection->Collapse(selNode,selOffset); @@ -7552,7 +7530,7 @@ nsHTMLEditRules::AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection } else // must be break or image { - nsEditor::GetNodeLocation(nearNode, address_of(selNode), &selOffset); + selNode = nsEditor::GetNodeLocation(nearNode, &selOffset); if (aAction == nsIEditor::ePrevious) selOffset++; // want to be beyond it if we backed up to it res = aSelection->Collapse(selNode, selOffset); } @@ -7783,7 +7761,7 @@ nsHTMLEditRules::RemoveEmptyNodes() // but preserve br. nsCOMPtr parent, brNode; PRInt32 offset; - nsEditor::GetNodeLocation(delNode, address_of(parent), &offset); + parent = nsEditor::GetNodeLocation(delNode, &offset); res = mHTMLEditor->CreateBR(parent, offset, address_of(brNode)); NS_ENSURE_SUCCESS(res, res); } @@ -7909,19 +7887,17 @@ nsHTMLEditRules::PopListItem(nsIDOMNode *aListItem, bool *aOutOfList) // init out params *aOutOfList = false; - nsCOMPtr curParent; nsCOMPtr curNode( do_QueryInterface(aListItem)); PRInt32 offset; - nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset); + nsCOMPtr curParent = nsEditor::GetNodeLocation(curNode, &offset); if (!nsHTMLEditUtils::IsListItem(curNode)) return NS_ERROR_FAILURE; // if it's first or last list item, don't need to split the list // otherwise we do. - nsCOMPtr curParPar; PRInt32 parOffset; - nsEditor::GetNodeLocation(curParent, address_of(curParPar), &parOffset); + nsCOMPtr curParPar = nsEditor::GetNodeLocation(curParent, &parOffset); bool bIsFirstListItem; nsresult res = mHTMLEditor->IsFirstEditableChild(curNode, &bIsFirstListItem); @@ -8702,7 +8678,7 @@ nsHTMLEditRules::WillAbsolutePosition(nsISelection *aSelection, bool *aCancel, b if (!mHTMLEditor->IsEditable(curNode)) continue; PRInt32 offset; - nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset); + curParent = nsEditor::GetNodeLocation(curNode, &offset); // some logic for putting list items into nested lists... if (nsHTMLEditUtils::IsList(curParent)) @@ -8725,9 +8701,7 @@ nsHTMLEditRules::WillAbsolutePosition(nsISelection *aSelection, bool *aCancel, b NS_ENSURE_SUCCESS(res, res); if (!curPositionedDiv) { PRInt32 parentOffset; - nsCOMPtr curParentParent; - nsEditor::GetNodeLocation(curParent, address_of(curParentParent), - &parentOffset); + nsCOMPtr curParentParent = nsEditor::GetNodeLocation(curParent, &parentOffset); res = mHTMLEditor->CreateNode(divType, curParentParent, parentOffset, getter_AddRefs(curPositionedDiv)); mNewBlock = curPositionedDiv; } @@ -8756,7 +8730,7 @@ nsHTMLEditRules::WillAbsolutePosition(nsISelection *aSelection, bool *aCancel, b if (listitem) { if (indentedLI == listitem) continue; // already indented this list item - nsEditor::GetNodeLocation(listitem, address_of(curParent), &offset); + curParent = nsEditor::GetNodeLocation(listitem, &offset); // check to see if curList is still appropriate. Which it is if // curNode is still right after it in the same list. if (curList) @@ -8775,9 +8749,7 @@ nsHTMLEditRules::WillAbsolutePosition(nsISelection *aSelection, bool *aCancel, b NS_ENSURE_SUCCESS(res, res); if (!curPositionedDiv) { PRInt32 parentOffset; - nsCOMPtr curParentParent; - nsEditor::GetNodeLocation(curParent, address_of(curParentParent), - &parentOffset); + nsCOMPtr curParentParent = nsEditor::GetNodeLocation(curParent, &parentOffset); res = mHTMLEditor->CreateNode(divType, curParentParent, parentOffset, getter_AddRefs(curPositionedDiv)); mNewBlock = curPositionedDiv; } diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index 529c67548e41..12bec546d65e 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -526,7 +526,7 @@ nsHTMLEditor::BeginningOfDocument() else if ((visType==nsWSRunObject::eBreak) || (visType==nsWSRunObject::eSpecial)) { - GetNodeLocation(visNode, address_of(selNode), &selOffset); + selNode = GetNodeLocation(visNode, &selOffset); done = true; } else if (visType==nsWSRunObject::eOtherBlock) @@ -546,7 +546,7 @@ nsHTMLEditor::BeginningOfDocument() // like a
// We want to place the caret in front of that block. - GetNodeLocation(visNode, address_of(selNode), &selOffset); + selNode = GetNodeLocation(visNode, &selOffset); done = true; } else @@ -556,7 +556,7 @@ nsHTMLEditor::BeginningOfDocument() isEmptyBlock) { // skip the empty block - GetNodeLocation(visNode, address_of(curNode), &curOffset); + curNode = GetNodeLocation(visNode, &curOffset); ++curOffset; } else @@ -941,7 +941,7 @@ bool nsHTMLEditor::IsVisBreak(nsIDOMNode *aNode) // determine what is going on nsCOMPtr selNode, tmp; PRInt32 selOffset; - GetNodeLocation(aNode, address_of(selNode), &selOffset); + selNode = GetNodeLocation(aNode, &selOffset); selOffset++; // lets look after the break nsWSRunObject wsObj(this, selNode, selOffset); nsCOMPtr visNode; @@ -1468,10 +1468,8 @@ nsHTMLEditor::NormalizeEOLInsertPosition(nsIDOMNode *firstNodeToInsert, if (prevVisType & nsWSRunObject::eThisBlock) return; - nsCOMPtr brNode; PRInt32 brOffset=0; - - GetNodeLocation(nextVisNode, address_of(brNode), &brOffset); + nsCOMPtr brNode = GetNodeLocation(nextVisNode, &brOffset); *insertParentNode = brNode; *insertOffset = brOffset + 1; diff --git a/editor/libeditor/html/nsHTMLEditorStyle.cpp b/editor/libeditor/html/nsHTMLEditorStyle.cpp index 72f1acc5c59c..839fa698e0ad 100644 --- a/editor/libeditor/html/nsHTMLEditorStyle.cpp +++ b/editor/libeditor/html/nsHTMLEditorStyle.cpp @@ -937,13 +937,13 @@ nsresult nsHTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsIDOMRange *inRa !nsTextEditUtils::IsBody(tmp) && !nsHTMLEditUtils::IsNamedAnchor(tmp)) { - GetNodeLocation(tmp, address_of(parent), &tmpOffset); + parent = GetNodeLocation(tmp, &tmpOffset); tmp = parent; } NS_ENSURE_TRUE(tmp, NS_ERROR_NULL_POINTER); if (nsHTMLEditUtils::IsNamedAnchor(tmp)) { - GetNodeLocation(tmp, address_of(parent), &tmpOffset); + parent = GetNodeLocation(tmp, &tmpOffset); startNode = parent; startOffset = tmpOffset; } @@ -953,13 +953,13 @@ nsresult nsHTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsIDOMRange *inRa !nsTextEditUtils::IsBody(tmp) && !nsHTMLEditUtils::IsNamedAnchor(tmp)) { - GetNodeLocation(tmp, address_of(parent), &tmpOffset); + parent = GetNodeLocation(tmp, &tmpOffset); tmp = parent; } NS_ENSURE_TRUE(tmp, NS_ERROR_NULL_POINTER); if (nsHTMLEditUtils::IsNamedAnchor(tmp)) { - GetNodeLocation(tmp, address_of(parent), &tmpOffset); + parent = GetNodeLocation(tmp, &tmpOffset); endNode = parent; endOffset = tmpOffset + 1; } @@ -991,7 +991,7 @@ nsresult nsHTMLEditor::PromoteInlineRange(nsIDOMRange *inRange) IsEditable(startNode) && IsAtFrontOfNode(startNode, startOffset) ) { - GetNodeLocation(startNode, address_of(parent), &startOffset); + parent = GetNodeLocation(startNode, &startOffset); startNode = parent; } NS_ENSURE_TRUE(startNode, NS_ERROR_NULL_POINTER); @@ -1001,7 +1001,7 @@ nsresult nsHTMLEditor::PromoteInlineRange(nsIDOMRange *inRange) IsEditable(endNode) && IsAtEndOfNode(endNode, endOffset) ) { - GetNodeLocation(endNode, address_of(parent), &endOffset); + parent = GetNodeLocation(endNode, &endOffset); endNode = parent; endOffset++; // we are AFTER this node } diff --git a/editor/libeditor/html/nsWSRunObject.cpp b/editor/libeditor/html/nsWSRunObject.cpp index 60efcf259cb8..a384f2a169de 100644 --- a/editor/libeditor/html/nsWSRunObject.cpp +++ b/editor/libeditor/html/nsWSRunObject.cpp @@ -116,9 +116,8 @@ nsWSRunObject::PrepareToDeleteNode(nsHTMLEditor *aHTMLEd, { NS_ENSURE_TRUE(aNode && aHTMLEd, NS_ERROR_NULL_POINTER); - nsCOMPtr parent; PRInt32 offset; - aHTMLEd->GetNodeLocation(aNode, address_of(parent), &offset); + nsCOMPtr parent = aHTMLEd->GetNodeLocation(aNode, &offset); nsWSRunObject leftWSObj(aHTMLEd, parent, offset); nsWSRunObject rightWSObj(aHTMLEd, parent, offset+1); diff --git a/editor/libeditor/text/nsPlaintextDataTransfer.cpp b/editor/libeditor/text/nsPlaintextDataTransfer.cpp index 99408819bd85..b353523ecd3a 100644 --- a/editor/libeditor/text/nsPlaintextDataTransfer.cpp +++ b/editor/libeditor/text/nsPlaintextDataTransfer.cpp @@ -228,8 +228,7 @@ nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent) // The decision for dropping before or after the // subtree should really be done based on coordinates. - GetNodeLocation(userSelectNode, address_of(newSelectionParent), - &newSelectionOffset); + newSelectionParent = GetNodeLocation(userSelectNode, &newSelectionOffset); NS_ENSURE_TRUE(newSelectionParent, NS_ERROR_FAILURE); } diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp index f4702a13abbc..db76b6f60304 100644 --- a/editor/libeditor/text/nsPlaintextEditor.cpp +++ b/editor/libeditor/text/nsPlaintextEditor.cpp @@ -427,11 +427,10 @@ nsPlaintextEditor::CreateBRImpl(nsCOMPtr* aInOutParent, nsCOMPtr brNode; if (nodeAsText) { - nsCOMPtr tmp; PRInt32 offset; PRUint32 len; nodeAsText->GetLength(&len); - GetNodeLocation(node, address_of(tmp), &offset); + nsCOMPtr tmp = GetNodeLocation(node, &offset); NS_ENSURE_TRUE(tmp, NS_ERROR_FAILURE); if (!theOffset) { @@ -447,7 +446,7 @@ nsPlaintextEditor::CreateBRImpl(nsCOMPtr* aInOutParent, // split the text node res = SplitNode(node, theOffset, getter_AddRefs(tmp)); NS_ENSURE_SUCCESS(res, res); - GetNodeLocation(node, address_of(tmp), &offset); + tmp = GetNodeLocation(node, &offset); } // create br res = CreateNode(brType, tmp, offset, getter_AddRefs(brNode)); @@ -465,9 +464,8 @@ nsPlaintextEditor::CreateBRImpl(nsCOMPtr* aInOutParent, *outBRNode = brNode; if (*outBRNode && (aSelect != eNone)) { - nsCOMPtr parent; PRInt32 offset; - GetNodeLocation(*outBRNode, address_of(parent), &offset); + nsCOMPtr parent = GetNodeLocation(*outBRNode, &offset); nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); @@ -524,7 +522,7 @@ nsPlaintextEditor::InsertBR(nsCOMPtr* outBRNode) NS_ENSURE_SUCCESS(res, res); // position selection after br - GetNodeLocation(*outBRNode, address_of(selNode), &selOffset); + selNode = GetNodeLocation(*outBRNode, &selOffset); nsCOMPtr selPriv(do_QueryInterface(selection)); selPriv->SetInterlinePosition(true); return selection->Collapse(selNode, selOffset+1); @@ -1565,9 +1563,8 @@ nsPlaintextEditor::SelectEntireDocument(nsISelection *aSelection) nsCOMPtr childNode = GetChildAt(selNode, selOffset - 1); if (childNode && nsTextEditUtils::IsMozBR(childNode)) { - nsCOMPtr parentNode; PRInt32 parentOffset; - GetNodeLocation(childNode, address_of(parentNode), &parentOffset); + nsCOMPtr parentNode = GetNodeLocation(childNode, &parentOffset); return aSelection->Extend(parentNode, parentOffset); } diff --git a/editor/libeditor/text/nsTextEditRules.cpp b/editor/libeditor/text/nsTextEditRules.cpp index 3d747f240986..eb7bdbd1fce4 100644 --- a/editor/libeditor/text/nsTextEditRules.cpp +++ b/editor/libeditor/text/nsTextEditRules.cpp @@ -417,9 +417,8 @@ nsTextEditRules::CollapseSelectionToTrailingBRIfNeeded(nsISelection* aSelection) if (selOffset != PRInt32(length)) return NS_OK; - nsCOMPtr parentNode; PRInt32 parentOffset; - nsEditor::GetNodeLocation(selNode, address_of(parentNode), &parentOffset); + nsCOMPtr parentNode = nsEditor::GetNodeLocation(selNode, &parentOffset); nsCOMPtr root = do_QueryInterface(mEditor->GetRoot()); NS_ENSURE_TRUE(root, NS_ERROR_NULL_POINTER); From 357cbc427f956df49292b0d4f15eaf39273440fc Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Mon, 9 Jul 2012 01:55:34 +0100 Subject: [PATCH 02/20] Bug 771935 - SVGs that are larger than the browser content area should scroll. r=roc. --- layout/reftests/svg/sizing/reftest.list | 2 ++ .../svg/sizing/scrollbars-01-anti-ref.svg | 11 +++++++++++ layout/reftests/svg/sizing/scrollbars-01.svg | 13 +++++++++++++ layout/reftests/svg/sizing/scrollbars-02.svg | 13 +++++++++++++ layout/svg/base/src/nsSVGOuterSVGFrame.cpp | 16 +++++++--------- layout/svg/base/src/svg.css | 2 +- 6 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 layout/reftests/svg/sizing/scrollbars-01-anti-ref.svg create mode 100644 layout/reftests/svg/sizing/scrollbars-01.svg create mode 100644 layout/reftests/svg/sizing/scrollbars-02.svg diff --git a/layout/reftests/svg/sizing/reftest.list b/layout/reftests/svg/sizing/reftest.list index 0ebf116bc6d8..fe27ba9e74ff 100644 --- a/layout/reftests/svg/sizing/reftest.list +++ b/layout/reftests/svg/sizing/reftest.list @@ -11,6 +11,8 @@ # http://www.w3.org/TR/SVGMobile12/coords.html#IntrinsicSizing # http://www.w3.org/TR/CSS21/visudet.html +!= scrollbars-01.svg scrollbars-01-anti-ref.svg +!= scrollbars-02.svg scrollbars-01-anti-ref.svg # Standalone tests # diff --git a/layout/reftests/svg/sizing/scrollbars-01-anti-ref.svg b/layout/reftests/svg/sizing/scrollbars-01-anti-ref.svg new file mode 100644 index 000000000000..a8d92e0847ac --- /dev/null +++ b/layout/reftests/svg/sizing/scrollbars-01-anti-ref.svg @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/layout/reftests/svg/sizing/scrollbars-01.svg b/layout/reftests/svg/sizing/scrollbars-01.svg new file mode 100644 index 000000000000..4433307db42f --- /dev/null +++ b/layout/reftests/svg/sizing/scrollbars-01.svg @@ -0,0 +1,13 @@ + + + + + + Test that we're given scrollbars if wider than the browser's content area + + + + diff --git a/layout/reftests/svg/sizing/scrollbars-02.svg b/layout/reftests/svg/sizing/scrollbars-02.svg new file mode 100644 index 000000000000..9f9bc4af4ee1 --- /dev/null +++ b/layout/reftests/svg/sizing/scrollbars-02.svg @@ -0,0 +1,13 @@ + + + + + + Test that we're given scrollbars if wider than the browser's content area + + + + diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index cca07baf91ac..8ec30f728a94 100644 --- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -600,15 +600,13 @@ nsSVGOuterSVGFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, new (aBuilder) nsDisplayOuterSVG(aBuilder, this)); NS_ENSURE_SUCCESS(rv, rv); - if (GetStyleDisplay()->IsScrollableOverflow()) { - // Clip to our _content_ box: - nsRect clipRect = - GetContentRectRelativeToSelf() + aBuilder->ToReferenceFrame(this); - nsDisplayClip* item = - new (aBuilder) nsDisplayClip(aBuilder, this, &childItems, clipRect); - rv = childItems.AppendNewToTop(item); - NS_ENSURE_SUCCESS(rv, rv); - } + // Clip to our _content_ box: + nsRect clipRect = + GetContentRectRelativeToSelf() + aBuilder->ToReferenceFrame(this); + nsDisplayClip* item = + new (aBuilder) nsDisplayClip(aBuilder, this, &childItems, clipRect); + rv = childItems.AppendNewToTop(item); + NS_ENSURE_SUCCESS(rv, rv); WrapReplacedContentForBorderRadius(aBuilder, &childItems, aLists); diff --git a/layout/svg/base/src/svg.css b/layout/svg/base/src/svg.css index 19a305f758d5..cb2594df0862 100644 --- a/layout/svg/base/src/svg.css +++ b/layout/svg/base/src/svg.css @@ -14,7 +14,7 @@ switch { -moz-binding: none !important; } -svg, symbol, image, marker, pattern, foreignObject { +svg:not(:root), symbol, image, marker, pattern, foreignObject { overflow: hidden; } From f234ac813a318781e142bfd1212d25cf20e0921d Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Mon, 9 Jul 2012 02:04:56 +0100 Subject: [PATCH 03/20] Bug 769742 - Account for nsSVGOuterSVGFrames' border/padding offset by giving nsSVGOuterSVGFrame an anonymous child to wrap its real children. r=roc. --- content/base/src/nsGkAtomList.h | 1 + layout/base/nsCSSFrameConstructor.cpp | 121 ++++++++++++++--- layout/base/nsCSSFrameConstructor.h | 12 ++ layout/generic/nsFrameIdList.h | 1 + layout/style/nsCSSAnonBoxList.h | 1 + layout/svg/base/src/nsSVGOuterSVGFrame.cpp | 145 +++++++++++++++------ layout/svg/base/src/nsSVGOuterSVGFrame.h | 101 +++++++++++++- layout/svg/base/src/nsSVGUtils.cpp | 1 - 8 files changed, 325 insertions(+), 58 deletions(-) diff --git a/content/base/src/nsGkAtomList.h b/content/base/src/nsGkAtomList.h index 4824a948b598..3205222646ab 100644 --- a/content/base/src/nsGkAtomList.h +++ b/content/base/src/nsGkAtomList.h @@ -1750,6 +1750,7 @@ GK_ATOM(svgLinearGradientFrame, "SVGLinearGradientFrame") GK_ATOM(svgMarkerFrame, "SVGMarkerFrame") GK_ATOM(svgMaskFrame, "SVGMaskFrame") GK_ATOM(svgOuterSVGFrame, "SVGOuterSVGFrame") +GK_ATOM(svgOuterSVGAnonChildFrame, "SVGOuterSVGAnonChildFrame") GK_ATOM(svgPathGeometryFrame, "SVGPathGeometryFrame") GK_ATOM(svgPatternFrame, "SVGPatternFrame") GK_ATOM(svgRadialGradientFrame, "SVGRadialGradientFrame") diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 5afd6d79cb57..cbfb8b356ecf 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -139,6 +139,8 @@ NS_NewHTMLVideoFrame (nsIPresShell* aPresShell, nsStyleContext* aContext); nsIFrame* NS_NewSVGOuterSVGFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); nsIFrame* +NS_NewSVGOuterSVGAnonChildFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); +nsIFrame* NS_NewSVGInnerSVGFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); nsIFrame* NS_NewSVGPathGeometryFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); @@ -2407,25 +2409,30 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle #endif if (aDocElement->IsSVG()) { if (aDocElement->Tag() == nsGkAtoms::svg) { - contentFrame = NS_NewSVGOuterSVGFrame(mPresShell, styleContext); - if (NS_UNLIKELY(!contentFrame)) { - return NS_ERROR_OUT_OF_MEMORY; - } - InitAndRestoreFrame(state, aDocElement, - state.GetGeometricParent(display, - mDocElementContainingBlock), - nsnull, contentFrame); + // We're going to call the right function ourselves, so no need to give a + // function to this FrameConstructionData. + + // XXXbz on the other hand, if we converted this whole function to + // FrameConstructionData/Item, then we'd need the right function + // here... but would probably be able to get away with less code in this + // function in general. + // Use a null PendingBinding, since our binding is not in fact pending. + static const FrameConstructionData rootSVGData = FCDATA_DECL(0, nsnull); + nsRefPtr extraRef(styleContext); + FrameConstructionItem item(&rootSVGData, aDocElement, + aDocElement->Tag(), kNameSpaceID_SVG, + nsnull, extraRef.forget(), true); - // AddChild takes care of transforming the frame tree for fixed-pos - // or abs-pos situations nsFrameItems frameItems; - rv = state.AddChild(contentFrame, frameItems, aDocElement, - styleContext, mDocElementContainingBlock); - if (NS_FAILED(rv) || frameItems.IsEmpty()) { + rv = ConstructOuterSVG(state, item, mDocElementContainingBlock, + styleContext->GetStyleDisplay(), + frameItems, &contentFrame); + if (NS_FAILED(rv)) return rv; - } + if (!contentFrame || frameItems.IsEmpty()) + return NS_ERROR_FAILURE; *aNewFrame = frameItems.FirstChild(); - processChildren = true; + NS_ASSERTION(frameItems.OnlyChild(), "multiple root element frames"); } else { return NS_ERROR_FAILURE; } @@ -2498,8 +2505,9 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle // Still need to process the child content nsFrameItems childItems; - NS_ASSERTION(!nsLayoutUtils::GetAsBlock(contentFrame), - "Only XUL and SVG frames should reach here"); + NS_ASSERTION(!nsLayoutUtils::GetAsBlock(contentFrame) && + !contentFrame->IsFrameOfType(nsIFrame::eSVG), + "Only XUL frames should reach here"); // Use a null PendingBinding, since our binding is not in fact pending. ProcessChildren(state, aDocElement, styleContext, contentFrame, true, childItems, false, nsnull); @@ -4702,6 +4710,82 @@ nsCSSFrameConstructor::FindMathMLData(Element* aElement, ArrayLength(sMathMLData)); } + +// Construct an nsSVGOuterSVGFrame, the anonymous child that wraps its real +// children, and its descendant frames. +nsresult +nsCSSFrameConstructor::ConstructOuterSVG(nsFrameConstructorState& aState, + FrameConstructionItem& aItem, + nsIFrame* aParentFrame, + const nsStyleDisplay* aDisplay, + nsFrameItems& aFrameItems, + nsIFrame** aNewFrame) +{ + nsIContent* const content = aItem.mContent; + nsStyleContext* const styleContext = aItem.mStyleContext; + + nsresult rv = NS_OK; + + // Create the nsSVGOuterSVGFrame: + nsIFrame* newFrame = NS_NewSVGOuterSVGFrame(mPresShell, styleContext); + + nsIFrame* geometricParent = + aState.GetGeometricParent(styleContext->GetStyleDisplay(), + aParentFrame); + + InitAndRestoreFrame(aState, content, geometricParent, nsnull, newFrame); + + // Create the pseudo SC for the anonymous wrapper child as a child of the SC: + nsRefPtr scForAnon; + scForAnon = mPresShell->StyleSet()-> + ResolveAnonymousBoxStyle(nsCSSAnonBoxes::mozSVGOuterSVGAnonChild, + styleContext); + + // Create the anonymous inner wrapper frame + nsIFrame* innerFrame = NS_NewSVGOuterSVGAnonChildFrame(mPresShell, scForAnon); + + if (!innerFrame) { + newFrame->Destroy(); + return NS_ERROR_OUT_OF_MEMORY; + } + + InitAndRestoreFrame(aState, content, newFrame, nsnull, innerFrame); + + // Put the newly created frames into the right child list + SetInitialSingleChild(newFrame, innerFrame); + + rv = aState.AddChild(newFrame, aFrameItems, content, styleContext, + aParentFrame); + if (NS_FAILED(rv)) { + return rv; + } + + if (!mRootElementFrame) { + // The frame we're constructing will be the root element frame. + // Set mRootElementFrame before processing children. + mRootElementFrame = newFrame; + } + + nsFrameItems childItems; + + // Process children + if (aItem.mFCData->mBits & FCDATA_USE_CHILD_ITEMS) { + rv = ConstructFramesFromItemList(aState, aItem.mChildItems, + innerFrame, childItems); + } else { + rv = ProcessChildren(aState, content, styleContext, innerFrame, + true, childItems, false, aItem.mPendingBinding); + } + // XXXbz what about cleaning up? + if (NS_FAILED(rv)) return rv; + + // Set the inner wrapper frame's initial primary list + innerFrame->SetInitialChildList(kPrincipalList, childItems); + + *aNewFrame = newFrame; + return rv; +} + // Only outer elements can be floated or positioned. All other SVG // should be in-flow. #define SIMPLE_SVG_FCDATA(_func) \ @@ -4789,8 +4873,7 @@ nsCSSFrameConstructor::FindSVGData(Element* aElement, // and do the PassesConditionalProcessingTests call in // nsSVGOuterSVGFrame::Init. static const FrameConstructionData sOuterSVGData = - FCDATA_DECL(FCDATA_SKIP_ABSPOS_PUSH | FCDATA_DISALLOW_GENERATED_CONTENT, - NS_NewSVGOuterSVGFrame); + FULL_CTOR_FCDATA(0, &nsCSSFrameConstructor::ConstructOuterSVG); return &sOuterSVGData; } diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index 966fb7506135..75292fce24ec 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -1351,6 +1351,18 @@ private: nsStyleContext* aStyleContext); // SVG - rods + /** + * Construct an nsSVGOuterSVGFrame, the anonymous child that wraps its real + * children, and its descendant frames. This is the FrameConstructionData + * callback used for the job. + */ + nsresult ConstructOuterSVG(nsFrameConstructorState& aState, + FrameConstructionItem& aItem, + nsIFrame* aParentFrame, + const nsStyleDisplay* aDisplay, + nsFrameItems& aFrameItems, + nsIFrame** aNewFrame); + static const FrameConstructionData* FindSVGData(Element* aElement, nsIAtom* aTag, PRInt32 aNameSpaceID, diff --git a/layout/generic/nsFrameIdList.h b/layout/generic/nsFrameIdList.h index f37812b3b1db..11e7658b862f 100644 --- a/layout/generic/nsFrameIdList.h +++ b/layout/generic/nsFrameIdList.h @@ -147,6 +147,7 @@ FRAME_ID(nsSVGLinearGradientFrame) FRAME_ID(nsSVGMarkerFrame) FRAME_ID(nsSVGMaskFrame) FRAME_ID(nsSVGOuterSVGFrame) +FRAME_ID(nsSVGOuterSVGAnonChildFrame) FRAME_ID(nsSVGPaintServerFrame) FRAME_ID(nsSVGPathGeometryFrame) FRAME_ID(nsSVGPatternFrame) diff --git a/layout/style/nsCSSAnonBoxList.h b/layout/style/nsCSSAnonBoxList.h index 8ac6c2014402..e6883edbe011 100644 --- a/layout/style/nsCSSAnonBoxList.h +++ b/layout/style/nsCSSAnonBoxList.h @@ -81,4 +81,5 @@ CSS_ANON_BOX(moztreeprogressmeter, ":-moz-tree-progressmeter") CSS_ANON_BOX(moztreedropfeedback, ":-moz-tree-drop-feedback") #endif +CSS_ANON_BOX(mozSVGOuterSVGAnonChild, ":-moz-svg-outer-svg-anon-child") CSS_ANON_BOX(mozSVGForeignContent, ":-moz-svg-foreign-content") diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index 8ec30f728a94..799b1af8c012 100644 --- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -391,29 +391,32 @@ nsSVGOuterSVGFrame::Reflow(nsPresContext* aPresContext, NotifyViewportOrTransformChanged(changeBits); } - // Now that we've marked the necessary children as dirty, call - // UpdateBounds() on them: + nsSVGOuterSVGAnonChildFrame *anonKid = + static_cast(GetFirstPrincipalChild()); - mCallingUpdateBounds = true; + if (!(GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) { + // Now that we've marked the necessary children as dirty, call + // UpdateBounds() on them: - if (!(mState & NS_STATE_SVG_NONDISPLAY_CHILD)) { - nsIFrame* kid = mFrames.FirstChild(); - while (kid) { - nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); - if (SVGFrame && !(kid->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) { - SVGFrame->UpdateBounds(); - } - kid = kid->GetNextSibling(); - } + mCallingUpdateBounds = true; + + // Update the mRects and visual overflow rects of all our descendants, + // including our anonymous wrapper kid: + anonKid->UpdateBounds(); + NS_ABORT_IF_FALSE(!anonKid->GetNextSibling(), + "We should have one anonymous child frame wrapping our real children"); + + mCallingUpdateBounds = false; } - mCallingUpdateBounds = false; - // Make sure we scroll if we're too big: // XXX Use the bounding box of our descendants? (See bug 353460 comment 14.) aDesiredSize.SetOverflowAreasToDesiredBounds(); FinishAndStoreOverflow(&aDesiredSize); + // Set our anonymous kid's offset from our border box: + anonKid->SetPosition(GetContentRectRelativeToSelf().TopLeft()); + NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS, ("exit nsSVGOuterSVGFrame::Reflow: size=%d,%d", aDesiredSize.width, aDesiredSize.height)); @@ -471,9 +474,12 @@ nsDisplayOuterSVG::HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect, nsPoint rectCenter(rectAtOrigin.x + rectAtOrigin.width / 2, rectAtOrigin.y + rectAtOrigin.height / 2); + nsSVGOuterSVGAnonChildFrame *anonKid = + static_cast( + outerSVGFrame->GetFirstPrincipalChild()); nsIFrame* frame = nsSVGUtils::HitTestChildren( - outerSVGFrame, rectCenter + outerSVGFrame->GetPosition() - - outerSVGFrame->GetContentRect().TopLeft()); + anonKid, rectCenter + outerSVGFrame->GetPosition() - + outerSVGFrame->GetContentRect().TopLeft()); if (frame) { aOutFrames->AppendElement(frame); } @@ -546,8 +552,8 @@ nsSVGOuterSVGFrame::AttributeChanged(PRInt32 aNameSpaceID, // make sure our cached transform matrix gets (lazily) updated mCanvasTM = nsnull; - nsSVGUtils::NotifyChildrenOfSVGChange( - this, aAttribute == nsGkAtoms::viewBox ? + nsSVGUtils::NotifyChildrenOfSVGChange(GetFirstPrincipalChild(), + aAttribute == nsGkAtoms::viewBox ? TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED : TRANSFORM_CHANGED); static_cast(mContent)->ChildrenOnlyTransformChanged(); @@ -676,7 +682,38 @@ nsSVGOuterSVGFrame::NotifyViewportOrTransformChanged(PRUint32 aFlags) } } - nsSVGUtils::NotifyChildrenOfSVGChange(this, aFlags); + nsSVGUtils::NotifyChildrenOfSVGChange(GetFirstPrincipalChild(), aFlags); +} + +//---------------------------------------------------------------------- +// nsISVGChildFrame methods: + +NS_IMETHODIMP +nsSVGOuterSVGFrame::PaintSVG(nsRenderingContext* aContext, + const nsIntRect *aDirtyRect) +{ + NS_ASSERTION(GetFirstPrincipalChild()->GetType() == + nsGkAtoms::svgOuterSVGAnonChildFrame && + !GetFirstPrincipalChild()->GetNextSibling(), + "We should have a single, anonymous, child"); + nsSVGOuterSVGAnonChildFrame *anonKid = + static_cast(GetFirstPrincipalChild()); + return anonKid->PaintSVG(aContext, aDirtyRect); +} + +SVGBBox +nsSVGOuterSVGFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace, + PRUint32 aFlags) +{ + NS_ASSERTION(GetFirstPrincipalChild()->GetType() == + nsGkAtoms::svgOuterSVGAnonChildFrame && + !GetFirstPrincipalChild()->GetNextSibling(), + "We should have a single, anonymous, child"); + // We must defer to our child so that we don't include our + // content->PrependLocalTransformsTo() transforms. + nsSVGOuterSVGAnonChildFrame *anonKid = + static_cast(GetFirstPrincipalChild()); + return anonKid->GetBBoxContribution(aToBBoxUserspace, aFlags); } //---------------------------------------------------------------------- @@ -705,24 +742,6 @@ nsSVGOuterSVGFrame::GetCanvasTM(PRUint32 aFor) return *mCanvasTM; } -bool -nsSVGOuterSVGFrame::HasChildrenOnlyTransform(gfxMatrix *aTransform) const -{ - nsSVGSVGElement *content = static_cast(mContent); - - bool hasTransform = content->HasChildrenOnlyTransform(); - - if (hasTransform && aTransform) { - // Outer- doesn't use x/y, so we can pass eChildToUserSpace here. - gfxMatrix identity; - *aTransform = - content->PrependLocalTransformsTo(identity, - nsSVGElement::eChildToUserSpace); - } - - return hasTransform; -} - //---------------------------------------------------------------------- // Implementation helpers @@ -777,3 +796,55 @@ nsSVGOuterSVGFrame::VerticalScrollbarNotNeeded() const mLengthAttributes[nsSVGSVGElement::HEIGHT]; return height.IsPercentage() && height.GetBaseValInSpecifiedUnits() <= 100; } + + +//---------------------------------------------------------------------- +// Implementation of nsSVGOuterSVGAnonChildFrame + +nsIFrame* +NS_NewSVGOuterSVGAnonChildFrame(nsIPresShell* aPresShell, + nsStyleContext* aContext) +{ + return new (aPresShell) nsSVGOuterSVGAnonChildFrame(aContext); +} + +NS_IMPL_FRAMEARENA_HELPERS(nsSVGOuterSVGAnonChildFrame) + +#ifdef DEBUG +NS_IMETHODIMP +nsSVGOuterSVGAnonChildFrame::Init(nsIContent* aContent, + nsIFrame* aParent, + nsIFrame* aPrevInFlow) +{ + NS_ABORT_IF_FALSE(aParent->GetType() == nsGkAtoms::svgOuterSVGFrame, + "Unexpected parent"); + return nsSVGOuterSVGAnonChildFrameBase::Init(aContent, aParent, aPrevInFlow); +} +#endif + +nsIAtom * +nsSVGOuterSVGAnonChildFrame::GetType() const +{ + return nsGkAtoms::svgOuterSVGAnonChildFrame; +} + +bool +nsSVGOuterSVGAnonChildFrame::HasChildrenOnlyTransform(gfxMatrix *aTransform) const +{ + // We must claim our nsSVGOuterSVGFrame's children-only transforms as our own + // so that the children we are used to wrap are transformed properly. + + nsSVGSVGElement *content = static_cast(mContent); + + bool hasTransform = content->HasChildrenOnlyTransform(); + + if (hasTransform && aTransform) { + // Outer- doesn't use x/y, so we can pass eChildToUserSpace here. + gfxMatrix identity; + *aTransform = + content->PrependLocalTransformsTo(identity, + nsSVGElement::eChildToUserSpace); + } + + return hasTransform; +} diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.h b/layout/svg/base/src/nsSVGOuterSVGFrame.h index 56dce8480c81..55a517710099 100644 --- a/layout/svg/base/src/nsSVGOuterSVGFrame.h +++ b/layout/svg/base/src/nsSVGOuterSVGFrame.h @@ -76,6 +76,15 @@ public: nsIAtom* aAttribute, PRInt32 aModType); + virtual nsIFrame* GetContentInsertionFrame() { + // Any children must be added to our single anonymous inner frame kid. + NS_ABORT_IF_FALSE(GetFirstPrincipalChild() && + GetFirstPrincipalChild()->GetType() == + nsGkAtoms::svgOuterSVGAnonChildFrame, + "Where is our anonymous child?"); + return GetFirstPrincipalChild()->GetContentInsertionFrame(); + } + virtual bool IsSVGTransformed(gfxMatrix *aOwnTransform, gfxMatrix *aFromParentTransform) const { // Outer- can transform its children with viewBox, currentScale and @@ -86,10 +95,23 @@ public: // nsISVGSVGFrame interface: virtual void NotifyViewportOrTransformChanged(PRUint32 aFlags); + // nsISVGChildFrame methods: + NS_IMETHOD PaintSVG(nsRenderingContext* aContext, + const nsIntRect *aDirtyRect); + + virtual SVGBBox GetBBoxContribution(const gfxMatrix &aToBBoxUserspace, + PRUint32 aFlags); + // nsSVGContainerFrame methods: virtual gfxMatrix GetCanvasTM(PRUint32 aFor); - virtual bool HasChildrenOnlyTransform(gfxMatrix *aTransform) const; + virtual bool HasChildrenOnlyTransform(gfxMatrix *aTransform) const { + // Our anonymous wrapper child must claim our children-only transforms as + // its own so that our real children (the frames it wraps) are transformed + // by them, and we must pretend we don't have any children-only transforms + // so that our anonymous child is _not_ transformed by them. + return false; + } /** * Return true only if the height is unspecified (defaulting to 100%) or else @@ -124,4 +146,81 @@ protected: bool mIsRootContent; }; +//////////////////////////////////////////////////////////////////////// +// nsSVGOuterSVGAnonChildFrame class + +typedef nsSVGDisplayContainerFrame nsSVGOuterSVGAnonChildFrameBase; + +/** + * nsSVGOuterSVGFrames have a single direct child that is an instance of this + * class, and which is used to wrap their real child frames. Such anonymous + * wrapper frames created from this class exist because SVG frames need their + * GetPosition() offset to be their offset relative to "user space" (in app + * units) so that they can play nicely with nsDisplayTransform. This is fine + * for all SVG frames except for direct children of an nsSVGOuterSVGFrame, + * since an nsSVGOuterSVGFrame can have CSS border and padding (unlike other + * SVG frames). The direct children can't include the offsets due to any such + * border/padding in their mRects since that would break nsDisplayTransform, + * but not including these offsets would break other parts of the Mozilla code + * that assume a frame's mRect contains its border-box-to-parent-border-box + * offset, in particular nsIFrame::GetOffsetTo and the functions that depend on + * it. Wrapping an nsSVGOuterSVGFrame's children in an instance of this class + * with its GetPosition() set to its nsSVGOuterSVGFrame's border/padding offset + * keeps both nsDisplayTransform and nsIFrame::GetOffsetTo happy. + * + * The reason that this class inherit from nsSVGDisplayContainerFrame rather + * than simply from nsContainerFrame is so that we can avoid having special + * handling for these inner wrappers in multiple parts of the SVG code. For + * example, the implementations of IsSVGTransformed and GetCanvasTM assume + * nsSVGContainerFrame instances all the way up to the nsSVGOuterSVGFrame. + */ +class nsSVGOuterSVGAnonChildFrame + : public nsSVGOuterSVGAnonChildFrameBase +{ + friend nsIFrame* + NS_NewSVGOuterSVGAnonChildFrame(nsIPresShell* aPresShell, + nsStyleContext* aContext); + + nsSVGOuterSVGAnonChildFrame(nsStyleContext* aContext) + : nsSVGOuterSVGAnonChildFrameBase(aContext) + {} + +public: + NS_DECL_FRAMEARENA_HELPERS + +#ifdef DEBUG + NS_IMETHOD Init(nsIContent* aContent, + nsIFrame* aParent, + nsIFrame* aPrevInFlow); + + NS_IMETHOD GetFrameName(nsAString& aResult) const { + return MakeFrameName(NS_LITERAL_STRING("SVGOuterSVGAnonChild"), aResult); + } +#endif + + /** + * Get the "type" of the frame + * + * @see nsGkAtoms::svgOuterSVGAnonChildFrame + */ + virtual nsIAtom* GetType() const; + + virtual bool IsSVGTransformed(gfxMatrix *aOwnTransform, + gfxMatrix *aFromParentTransform) const { + // Outer- can transform its children with viewBox, currentScale and + // currentTranslate, but it itself is not transformed by _SVG_ transforms. + return false; + } + + // nsSVGContainerFrame methods: + virtual gfxMatrix GetCanvasTM(PRUint32 aFor) { + // GetCanvasTM returns the transform from an SVG frame to the frame's + // nsSVGOuterSVGFrame's content box, so we do not include any x/y offset + // set on us for any CSS border or padding on our nsSVGOuterSVGFrame. + return static_cast(mParent)->GetCanvasTM(aFor); + } + + virtual bool HasChildrenOnlyTransform(gfxMatrix *aTransform) const; +}; + #endif diff --git a/layout/svg/base/src/nsSVGUtils.cpp b/layout/svg/base/src/nsSVGUtils.cpp index 6432519c8294..983aad8a7021 100644 --- a/layout/svg/base/src/nsSVGUtils.cpp +++ b/layout/svg/base/src/nsSVGUtils.cpp @@ -703,7 +703,6 @@ nsSVGUtils::InvalidateBounds(nsIFrame *aFrame, bool aDuringUpdate, NS_ASSERTION(aFrame->GetStateBits() & NS_STATE_IS_OUTER_SVG, "SVG frames must always have an nsSVGOuterSVGFrame ancestor!"); - invalidArea.MoveBy(aFrame->GetContentRect().TopLeft() - aFrame->GetPosition()); static_cast(aFrame)->InvalidateWithFlags(invalidArea, aFlags); From 49f20ab5726fae15c7129eb0920ee6c9dd53fcd5 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Mon, 9 Jul 2012 11:09:49 +1000 Subject: [PATCH 04/20] Bug 771900 - Don't have presentation attributes for properties we don't support. r=jwatt --- content/svg/content/src/nsSVGElement.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/content/svg/content/src/nsSVGElement.cpp b/content/svg/content/src/nsSVGElement.cpp index 6901c10cf47b..f0b16f9f4d9e 100644 --- a/content/svg/content/src/nsSVGElement.cpp +++ b/content/svg/content/src/nsSVGElement.cpp @@ -923,13 +923,14 @@ nsSVGElement::sGraphicsMap[] = { // PresentationAttributes-TextContentElements /* static */ const nsGenericElement::MappedAttributeEntry nsSVGElement::sTextContentElementsMap[] = { - { &nsGkAtoms::alignment_baseline }, - { &nsGkAtoms::baseline_shift }, + // Properties that we don't support are commented out. + // { &nsGkAtoms::alignment_baseline }, + // { &nsGkAtoms::baseline_shift }, { &nsGkAtoms::direction }, { &nsGkAtoms::dominant_baseline }, - { &nsGkAtoms::glyph_orientation_horizontal }, - { &nsGkAtoms::glyph_orientation_vertical }, - { &nsGkAtoms::kerning }, + // { &nsGkAtoms::glyph_orientation_horizontal }, + // { &nsGkAtoms::glyph_orientation_vertical }, + // { &nsGkAtoms::kerning }, { &nsGkAtoms::letter_spacing }, { &nsGkAtoms::text_anchor }, { &nsGkAtoms::text_decoration }, From 71c5025969638312d3a1bf48ed45a6cacf675ad1 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Mon, 9 Jul 2012 11:09:50 +1000 Subject: [PATCH 05/20] Bug 771883 - Minor nsTextFrame::GetCaretColorAt refactoring. r=roc --- layout/generic/nsTextFrameThebes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp index b5419263c808..748f6f0a4156 100644 --- a/layout/generic/nsTextFrameThebes.cpp +++ b/layout/generic/nsTextFrameThebes.cpp @@ -5349,6 +5349,7 @@ nsTextFrame::GetCaretColorAt(PRInt32 aOffset) { NS_PRECONDITION(aOffset >= 0, "aOffset must be positive"); + nscolor result = nsFrame::GetCaretColorAt(aOffset); gfxSkipCharsIterator iter = EnsureTextRun(nsTextFrame::eInflated); PropertyProvider provider(this, iter, nsTextFrame::eInflated); PRInt32 contentOffset = provider.GetStart().GetOriginalOffset(); @@ -5358,13 +5359,12 @@ nsTextFrame::GetCaretColorAt(PRInt32 aOffset) "aOffset must be in the frame's range"); PRInt32 offsetInFrame = aOffset - contentOffset; if (offsetInFrame < 0 || offsetInFrame >= contentLength) { - return nsFrame::GetCaretColorAt(aOffset); + return result; } nsTextPaintStyle textPaintStyle(this); SelectionDetails* details = GetSelectionDetails(); SelectionDetails* sdptr = details; - nscolor result = nsFrame::GetCaretColorAt(aOffset); SelectionType type = 0; while (sdptr) { PRInt32 start = NS_MAX(0, sdptr->mStart - contentOffset); From 6f599d230a1db133468f3c27197d1291c188c6e9 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Mon, 9 Jul 2012 11:09:50 +1000 Subject: [PATCH 06/20] Bug 771879 - Minor code formatting tweaks. r=roc --- layout/generic/nsHTMLReflowState.cpp | 4 ++-- layout/generic/nsIFrame.h | 4 ++-- layout/svg/base/src/nsSVGTextPathFrame.cpp | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index dd023d061049..dfc4eaec7b18 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -596,7 +596,6 @@ nsHTMLReflowState::InitFrameType(nsIAtom* aFrameType) // takes precedence over float which takes precedence over display. // XXXldb nsRuleNode::ComputeDisplayData should take care of this, right? // Make sure the frame was actually moved out of the flow, and don't - // just assume what the style says, because we might not have had a // useful float/absolute containing block @@ -1642,6 +1641,7 @@ CalcQuirkContainingBlockHeight(const nsHTMLReflowState* aCBReflowState) // Make sure not to return a negative height here! return NS_MAX(result, 0); } + // Called by InitConstraints() to compute the containing block rectangle for // the element. Handles the special logic for absolutely positioned elements void @@ -1672,7 +1672,7 @@ nsHTMLReflowState::ComputeContainingBlockRectangle(nsPresContext* aPres nsMargin computedBorder = aContainingBlockRS->mComputedBorderPadding - aContainingBlockRS->mComputedPadding; aContainingBlockWidth = aContainingBlockRS->frame->GetRect().width - - computedBorder.LeftRight();; + computedBorder.LeftRight(); NS_ASSERTION(aContainingBlockWidth >= 0, "Negative containing block width!"); aContainingBlockHeight = aContainingBlockRS->frame->GetRect().height - diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index b79d01872aa5..7e0abe2005fc 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -901,7 +901,7 @@ public: // The initial overflow area passed to FinishAndStoreOverflow. This is only set // on frames that Preserve3D(), and when at least one of the overflow areas // differs from the frame bound rect. - NS_DECLARE_FRAME_PROPERTY(InitialOverflowProperty, DestroyOverflowAreas); + NS_DECLARE_FRAME_PROPERTY(InitialOverflowProperty, DestroyOverflowAreas) NS_DECLARE_FRAME_PROPERTY(UsedMarginProperty, DestroyMargin) NS_DECLARE_FRAME_PROPERTY(UsedPaddingProperty, DestroyMargin) @@ -2975,7 +2975,7 @@ protected: * Input: mDirection * Output: mResultContent, mContentOffset */ - nsresult PeekOffsetParagraph(nsPeekOffsetStruct *aPos); + nsresult PeekOffsetParagraph(nsPeekOffsetStruct *aPos); private: nsOverflowAreas* GetOverflowAreasProperty(); diff --git a/layout/svg/base/src/nsSVGTextPathFrame.cpp b/layout/svg/base/src/nsSVGTextPathFrame.cpp index fb4503c41029..73f350e07e13 100644 --- a/layout/svg/base/src/nsSVGTextPathFrame.cpp +++ b/layout/svg/base/src/nsSVGTextPathFrame.cpp @@ -46,7 +46,6 @@ nsSVGTextPathFrame::Init(nsIContent* aContent, nsCOMPtr textPath = do_QueryInterface(aContent); NS_ASSERTION(textPath, "Content is not an SVG textPath"); - return nsSVGTextPathFrameBase::Init(aContent, aParent, aPrevInFlow); } #endif /* DEBUG */ From 6cf6e17a5e3ba5181455f55977700935f617f3c7 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Mon, 9 Jul 2012 11:09:51 +1000 Subject: [PATCH 07/20] Bug 771874 - Make nsTextFrame::TrimmedOffsets::GetEnd const. r=roc --- layout/generic/nsTextFrame.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layout/generic/nsTextFrame.h b/layout/generic/nsTextFrame.h index 1354261736d5..df6030c998af 100644 --- a/layout/generic/nsTextFrame.h +++ b/layout/generic/nsTextFrame.h @@ -396,7 +396,7 @@ public: struct TrimmedOffsets { PRInt32 mStart; PRInt32 mLength; - PRInt32 GetEnd() { return mStart + mLength; } + PRInt32 GetEnd() const { return mStart + mLength; } }; TrimmedOffsets GetTrimmedOffsets(const nsTextFragment* aFrag, bool aTrimAfter); From a04d369a7ddf839a9ab2565f8e43d34975d5ba83 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Mon, 9 Jul 2012 11:09:51 +1000 Subject: [PATCH 08/20] Bug 771903 - Fix member initialization order warning. r=smaug --- content/base/src/nsXMLHttpRequest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index bde334d8755a..c5031037eb8d 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -449,12 +449,12 @@ nsXMLHttpRequest::nsXMLHttpRequest() mWarnAboutMultipartHtml(false), mWarnAboutSyncHtml(false), mLoadLengthComputable(false), mLoadTotal(0), + mIsSystem(false), + mIsAnon(false), mFirstStartRequestSeen(false), mInLoadProgressEvent(false), mResultJSON(JSVAL_VOID), - mResultArrayBuffer(nsnull), - mIsAnon(false), - mIsSystem(false) + mResultArrayBuffer(nsnull) { nsLayoutStatics::AddRef(); From 4b04164545c2e8a46fb49b75e05b2488e427c9bf Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 8 Jul 2012 21:25:10 -0400 Subject: [PATCH 09/20] Bug 762302 - Unprefix CSS Animation properties and @keyframes rule and provide temporary aliases for -moz-animation and exposed subproperties. r=dbaron --- dom/interfaces/css/nsIDOMCSS2Properties.idl | 29 ++- layout/style/nsCSSParser.cpp | 3 +- layout/style/nsCSSPropAliasList.h | 9 + layout/style/nsCSSPropList.h | 36 +-- layout/style/nsCSSRules.cpp | 2 +- layout/style/nsComputedDOMStyle.cpp | 17 +- layout/style/test/property_database.js | 38 +-- layout/style/test/test_animations.html | 232 +++++++++--------- layout/style/test/test_bug716226.html | 2 +- .../test_garbage_at_end_of_declarations.html | 18 +- layout/style/test/test_keyframes_rules.html | 4 +- .../style/test/test_rules_out_of_sheets.html | 2 +- .../test_transitions_computed_values.html | 48 ++-- 13 files changed, 239 insertions(+), 201 deletions(-) diff --git a/dom/interfaces/css/nsIDOMCSS2Properties.idl b/dom/interfaces/css/nsIDOMCSS2Properties.idl index d3e7eaa2ff33..33367ec57f8c 100644 --- a/dom/interfaces/css/nsIDOMCSS2Properties.idl +++ b/dom/interfaces/css/nsIDOMCSS2Properties.idl @@ -14,7 +14,7 @@ * http://www.w3.org/TR/DOM-Level-2-Style */ -[builtinclass, scriptable, uuid(bb40a531-d92b-44d6-a543-cfc25054d5eb)] +[builtinclass, scriptable, uuid(7775d662-0b71-4c9d-92c3-4d0a88a6729d)] interface nsIDOMCSS2Properties : nsISupports { attribute DOMString background; @@ -710,6 +710,33 @@ interface nsIDOMCSS2Properties : nsISupports attribute DOMString resize; // raises(DOMException) on setting + attribute DOMString animationName; + // raises(DOMException) on setting + + attribute DOMString animationDuration; + // raises(DOMException) on setting + + attribute DOMString animationDelay; + // raises(DOMException) on setting + + attribute DOMString animationTimingFunction; + // raises(DOMException) on setting + + attribute DOMString animationDirection; + // raises(DOMException) on setting + + attribute DOMString animationFillMode; + // raises(DOMException) on setting + + attribute DOMString animationIterationCount; + // raises(DOMException) on setting + + attribute DOMString animationPlayState; + // raises(DOMException) on setting + + attribute DOMString animation; + // raises(DOMException) on setting + attribute DOMString MozAnimationName; // raises(DOMException) on setting diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index ac1d1f21e47a..00cbf902d5e0 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -1498,7 +1498,8 @@ CSSParserImpl::ParseAtRule(RuleAppendFunc aAppendFunc, parseFunc = &CSSParserImpl::ParsePageRule; newSection = eCSSSection_General; - } else if (mToken.mIdent.LowerCaseEqualsLiteral("-moz-keyframes")) { + } else if (mToken.mIdent.LowerCaseEqualsLiteral("-moz-keyframes") || + mToken.mIdent.LowerCaseEqualsLiteral("keyframes")) { parseFunc = &CSSParserImpl::ParseKeyframesRule; newSection = eCSSSection_General; diff --git a/layout/style/nsCSSPropAliasList.h b/layout/style/nsCSSPropAliasList.h index 520f402ec0c5..8ca08aafcb6e 100644 --- a/layout/style/nsCSSPropAliasList.h +++ b/layout/style/nsCSSPropAliasList.h @@ -42,3 +42,12 @@ CSS_PROP_ALIAS(-moz-perspective, perspective, MozPerspective, "") CSS_PROP_ALIAS(-moz-transform-style, transform_style, MozTransformStyle, "") CSS_PROP_ALIAS(-moz-backface-visibility, backface_visibility, MozBackfaceVisibility, "") CSS_PROP_ALIAS(-moz-border-image, border_image, MozBorderImage, "") +CSS_PROP_ALIAS(-moz-animation, animation, MozAnimation, "") +CSS_PROP_ALIAS(-moz-animation-delay, animation_delay, MozAnimationDelay, "") +CSS_PROP_ALIAS(-moz-animation-direction, animation_direction, MozAnimationDirection, "") +CSS_PROP_ALIAS(-moz-animation-duration, animation_duration, MozAnimationDuration, "") +CSS_PROP_ALIAS(-moz-animation-fill-mode, animation_fill_mode, MozAnimationFillMode, "") +CSS_PROP_ALIAS(-moz-animation-iteration-count, animation_iteration_count, MozAnimationIterationCount, "") +CSS_PROP_ALIAS(-moz-animation-name, animation_name, MozAnimationName, "") +CSS_PROP_ALIAS(-moz-animation-play-state, animation_play_state, MozAnimationPlayState, "") +CSS_PROP_ALIAS(-moz-animation-timing-function, animation_timing_function, MozAnimationTimingFunction, "") diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index ee2a934497cd..6760eae667c9 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -348,15 +348,15 @@ CSS_PROP_FONT( eStyleAnimType_None) #endif CSS_PROP_SHORTHAND( - -moz-animation, animation, - CSS_PROP_DOMPROP_PREFIXED(Animation), + animation, + Animation, CSS_PROPERTY_PARSE_FUNCTION, "") CSS_PROP_DISPLAY( - -moz-animation-delay, + animation-delay, animation_delay, - CSS_PROP_DOMPROP_PREFIXED(AnimationDelay), + AnimationDelay, CSS_PROPERTY_PARSE_VALUE_LIST | CSS_PROPERTY_VALUE_LIST_USES_COMMAS, "", @@ -365,9 +365,9 @@ CSS_PROP_DISPLAY( CSS_PROP_NO_OFFSET, eStyleAnimType_None) CSS_PROP_DISPLAY( - -moz-animation-direction, + animation-direction, animation_direction, - CSS_PROP_DOMPROP_PREFIXED(AnimationDirection), + AnimationDirection, CSS_PROPERTY_PARSE_VALUE_LIST | CSS_PROPERTY_VALUE_LIST_USES_COMMAS, "", @@ -376,9 +376,9 @@ CSS_PROP_DISPLAY( CSS_PROP_NO_OFFSET, eStyleAnimType_None) CSS_PROP_DISPLAY( - -moz-animation-duration, + animation-duration, animation_duration, - CSS_PROP_DOMPROP_PREFIXED(AnimationDuration), + AnimationDuration, CSS_PROPERTY_PARSE_VALUE_LIST | CSS_PROPERTY_VALUE_LIST_USES_COMMAS, "", @@ -387,9 +387,9 @@ CSS_PROP_DISPLAY( CSS_PROP_NO_OFFSET, eStyleAnimType_None) CSS_PROP_DISPLAY( - -moz-animation-fill-mode, + animation-fill-mode, animation_fill_mode, - CSS_PROP_DOMPROP_PREFIXED(AnimationFillMode), + AnimationFillMode, CSS_PROPERTY_PARSE_VALUE_LIST | CSS_PROPERTY_VALUE_LIST_USES_COMMAS, "", @@ -398,9 +398,9 @@ CSS_PROP_DISPLAY( CSS_PROP_NO_OFFSET, eStyleAnimType_None) CSS_PROP_DISPLAY( - -moz-animation-iteration-count, + animation-iteration-count, animation_iteration_count, - CSS_PROP_DOMPROP_PREFIXED(AnimationIterationCount), + AnimationIterationCount, CSS_PROPERTY_PARSE_VALUE_LIST | // nonnegative per // http://lists.w3.org/Archives/Public/www-style/2011Mar/0355.html @@ -412,9 +412,9 @@ CSS_PROP_DISPLAY( CSS_PROP_NO_OFFSET, eStyleAnimType_None) CSS_PROP_DISPLAY( - -moz-animation-name, + animation-name, animation_name, - CSS_PROP_DOMPROP_PREFIXED(AnimationName), + AnimationName, CSS_PROPERTY_PARSE_VALUE_LIST | CSS_PROPERTY_VALUE_LIST_USES_COMMAS, "", @@ -425,9 +425,9 @@ CSS_PROP_DISPLAY( CSS_PROP_NO_OFFSET, eStyleAnimType_None) CSS_PROP_DISPLAY( - -moz-animation-play-state, + animation-play-state, animation_play_state, - CSS_PROP_DOMPROP_PREFIXED(AnimationPlayState), + AnimationPlayState, CSS_PROPERTY_PARSE_VALUE_LIST | CSS_PROPERTY_VALUE_LIST_USES_COMMAS, "", @@ -436,9 +436,9 @@ CSS_PROP_DISPLAY( CSS_PROP_NO_OFFSET, eStyleAnimType_None) CSS_PROP_DISPLAY( - -moz-animation-timing-function, + animation-timing-function, animation_timing_function, - CSS_PROP_DOMPROP_PREFIXED(AnimationTimingFunction), + AnimationTimingFunction, CSS_PROPERTY_PARSE_VALUE_LIST | CSS_PROPERTY_VALUE_LIST_USES_COMMAS, "", diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index e56202899920..08fbc8c96ebb 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -2017,7 +2017,7 @@ nsCSSKeyframesRule::GetType(PRUint16* aType) NS_IMETHODIMP nsCSSKeyframesRule::GetCssText(nsAString& aCssText) { - aCssText.AssignLiteral("@-moz-keyframes "); + aCssText.AssignLiteral("@keyframes "); aCssText.Append(mName); aCssText.AppendLiteral(" {\n"); nsAutoString tmp; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index faabda346af8..70fd9af14c49 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -4618,6 +4618,15 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength) * Implementations of CSS styles * \* ***************************** */ + //// COMPUTED_STYLE_MAP_ENTRY(animation, Animation), + COMPUTED_STYLE_MAP_ENTRY(animation_delay, AnimationDelay), + COMPUTED_STYLE_MAP_ENTRY(animation_direction, AnimationDirection), + COMPUTED_STYLE_MAP_ENTRY(animation_duration, AnimationDuration), + COMPUTED_STYLE_MAP_ENTRY(animation_fill_mode, AnimationFillMode), + COMPUTED_STYLE_MAP_ENTRY(animation_iteration_count, AnimationIterationCount), + COMPUTED_STYLE_MAP_ENTRY(animation_name, AnimationName), + COMPUTED_STYLE_MAP_ENTRY(animation_play_state, AnimationPlayState), + COMPUTED_STYLE_MAP_ENTRY(animation_timing_function, AnimationTimingFunction), COMPUTED_STYLE_MAP_ENTRY(backface_visibility, BackfaceVisibility), //// COMPUTED_STYLE_MAP_ENTRY(background, Background), COMPUTED_STYLE_MAP_ENTRY(background_attachment, BackgroundAttachment), @@ -4759,14 +4768,6 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength) COMPUTED_STYLE_MAP_ENTRY(align_items, AlignItems), COMPUTED_STYLE_MAP_ENTRY(align_self, AlignSelf), #endif // MOZ_FLEXBOX - COMPUTED_STYLE_MAP_ENTRY(animation_delay, AnimationDelay), - COMPUTED_STYLE_MAP_ENTRY(animation_direction, AnimationDirection), - COMPUTED_STYLE_MAP_ENTRY(animation_duration, AnimationDuration), - COMPUTED_STYLE_MAP_ENTRY(animation_fill_mode, AnimationFillMode), - COMPUTED_STYLE_MAP_ENTRY(animation_iteration_count, AnimationIterationCount), - COMPUTED_STYLE_MAP_ENTRY(animation_name, AnimationName), - COMPUTED_STYLE_MAP_ENTRY(animation_play_state, AnimationPlayState), - COMPUTED_STYLE_MAP_ENTRY(animation_timing_function, AnimationTimingFunction), COMPUTED_STYLE_MAP_ENTRY(appearance, Appearance), COMPUTED_STYLE_MAP_ENTRY(_moz_background_inline_policy, BackgroundInlinePolicy), COMPUTED_STYLE_MAP_ENTRY(binding, Binding), diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index 40fe4566c194..bbe3172f4818 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -43,49 +43,49 @@ function initial_font_family_is_sans_serif() var gInitialFontFamilyIsSansSerif = initial_font_family_is_sans_serif(); var gCSSProperties = { - "-moz-animation": { - domProp: "MozAnimation", + "animation": { + domProp: "animation", inherited: false, type: CSS_TYPE_TRUE_SHORTHAND, - subproperties: [ "-moz-animation-name", "-moz-animation-duration", "-moz-animation-timing-function", "-moz-animation-delay", "-moz-animation-direction", "-moz-animation-fill-mode", "-moz-animation-iteration-count" ], + subproperties: [ "animation-name", "animation-duration", "animation-timing-function", "animation-delay", "animation-direction", "animation-fill-mode", "animation-iteration-count" ], initial_values: [ "none none 0s 0s ease normal 1.0", "none", "0s", "ease", "normal", "1.0" ], other_values: [ "bounce 1s linear 2s", "bounce 1s 2s linear", "bounce linear 1s 2s", "linear bounce 1s 2s", "linear 1s bounce 2s", "linear 1s 2s bounce", "1s bounce linear 2s", "1s bounce 2s linear", "1s 2s bounce linear", "1s linear bounce 2s", "1s linear 2s bounce", "1s 2s linear bounce", "bounce linear 1s", "bounce 1s linear", "linear bounce 1s", "linear 1s bounce", "1s bounce linear", "1s linear bounce", "1s 2s bounce", "1s bounce 2s", "bounce 1s 2s", "1s 2s linear", "1s linear 2s", "linear 1s 2s", "bounce 1s", "1s bounce", "linear 1s", "1s linear", "1s 2s", "2s 1s", "bounce", "linear", "1s", "height", "2s", "ease-in-out", "2s ease-in", "opacity linear", "ease-out 2s", "2s color, 1s bounce, 500ms height linear, 1s opacity 4s cubic-bezier(0.0, 0.1, 1.0, 1.0)", "1s \\32bounce linear 2s", "1s -bounce linear 2s", "1s -\\32bounce linear 2s", "1s \\32 0bounce linear 2s", "1s -\\32 0bounce linear 2s", "1s \\2bounce linear 2s", "1s -\\2bounce linear 2s", "2s, 1s bounce", "1s bounce, 2s", "2s all, 1s bounce", "1s bounce, 2s all", "1s bounce, 2s none", "2s none, 1s bounce", "2s bounce, 1s all", "2s all, 1s bounce" ], invalid_values: [ "2s inherit", "inherit 2s", "2s bounce, 1s inherit", "2s inherit, 1s bounce", "2s initial" ] }, - "-moz-animation-delay": { - domProp: "MozAnimationDelay", + "animation-delay": { + domProp: "animationDelay", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "0s", "0ms" ], other_values: [ "1s", "250ms", "-100ms", "-1s", "1s, 250ms, 2.3s"], invalid_values: [ "0", "0px" ] }, - "-moz-animation-direction": { - domProp: "MozAnimationDirection", + "animation-direction": { + domProp: "animationDirection", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "normal" ], other_values: [ "alternate", "normal, alternate", "alternate, normal", "normal, normal", "normal, normal, normal", "reverse", "alternate-reverse", "normal, reverse, alternate-reverse, alternate" ], invalid_values: [ "normal normal", "inherit, normal", "reverse-alternate" ] }, - "-moz-animation-duration": { - domProp: "MozAnimationDuration", + "animation-duration": { + domProp: "animationDuration", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "0s", "0ms" ], other_values: [ "1s", "250ms", "-1ms", "-2s", "1s, 250ms, 2.3s"], invalid_values: [ "0", "0px" ] }, - "-moz-animation-fill-mode": { - domProp: "MozAnimationFillMode", + "animation-fill-mode": { + domProp: "animationFillMode", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "none" ], other_values: [ "forwards", "backwards", "both", "none, none", "forwards, backwards", "forwards, none", "none, both" ], invalid_values: [ "all"] }, - "-moz-animation-iteration-count": { - domProp: "MozAnimationIterationCount", + "animation-iteration-count": { + domProp: "animationIterationCount", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "1" ], @@ -94,24 +94,24 @@ var gCSSProperties = { // http://lists.w3.org/Archives/Public/www-style/2011Mar/0355.html invalid_values: [ "none", "-1", "-0.5", "-1, infinite", "infinite, -3" ] }, - "-moz-animation-name": { - domProp: "MozAnimationName", + "animation-name": { + domProp: "animationName", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "none" ], other_values: [ "all", "ball", "mall", "color", "bounce, bubble, opacity", "foobar", "auto", "\\32bounce", "-bounce", "-\\32bounce", "\\32 0bounce", "-\\32 0bounce", "\\2bounce", "-\\2bounce" ], invalid_values: [ "bounce, initial", "initial, bounce", "bounce, inherit", "inherit, bounce" ] }, - "-moz-animation-play-state": { - domProp: "MozAnimationPlayState", + "animation-play-state": { + domProp: "animationPlayState", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "running" ], other_values: [ "paused", "running, running", "paused, running", "paused, paused", "running, paused", "paused, running, running, running, paused, running" ], invalid_values: [ "0" ] }, - "-moz-animation-timing-function": { - domProp: "MozAnimationTimingFunction", + "animation-timing-function": { + domProp: "animationTimingFunction", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "ease", "cubic-bezier(0.25, 0.1, 0.25, 1.0)" ], diff --git a/layout/style/test/test_animations.html b/layout/style/test/test_animations.html index a34a89d56069..02e5b5b0359a 100644 --- a/layout/style/test/test_animations.html +++ b/layout/style/test/test_animations.html @@ -9,39 +9,39 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=435442 diff --git a/layout/style/test/test_garbage_at_end_of_declarations.html b/layout/style/test/test_garbage_at_end_of_declarations.html index 467c8532b7e4..34898b2750f7 100644 --- a/layout/style/test/test_garbage_at_end_of_declarations.html +++ b/layout/style/test/test_garbage_at_end_of_declarations.html @@ -62,15 +62,15 @@ var gAllowsExtraUnusual = { "linear": true, "1s": true, "2s": true, "ease-in-out": true, "2s ease-in": true, "ease-out 2s": true }, - "-moz-animation": { "none": true, "0s": true, "ease": true, - "normal": true, "running": true, "1.0": true, - "1s 2s linear": true, "1s linear 2s": true, - "linear 1s 2s": true, "linear 1s": true, - "1s linear": true, "1s 2s": true, "2s 1s": true, - "linear": true, "1s": true, "2s": true, - "ease-in-out": true, "2s ease-in": true, - "ease-out 2s": true, "1s bounce, 2s": true, - "1s bounce, 2s none": true }, + "animation": { "none": true, "0s": true, "ease": true, + "normal": true, "running": true, "1.0": true, + "1s 2s linear": true, "1s linear 2s": true, + "linear 1s 2s": true, "linear 1s": true, + "1s linear": true, "1s 2s": true, "2s 1s": true, + "linear": true, "1s": true, "2s": true, + "ease-in-out": true, "2s ease-in": true, + "ease-out 2s": true, "1s bounce, 2s": true, + "1s bounce, 2s none": true }, }; function test_property(property) diff --git a/layout/style/test/test_keyframes_rules.html b/layout/style/test/test_keyframes_rules.html index f31f057ef2b1..4c01678ad458 100644 --- a/layout/style/test/test_keyframes_rules.html +++ b/layout/style/test/test_keyframes_rules.html @@ -9,7 +9,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=577974 diff --git a/layout/reftests/css-transitions/transitions-inline-already-wrapped-1.html b/layout/reftests/css-transitions/transitions-inline-already-wrapped-1.html index d8c682b97d59..f7533f650668 100644 --- a/layout/reftests/css-transitions/transitions-inline-already-wrapped-1.html +++ b/layout/reftests/css-transitions/transitions-inline-already-wrapped-1.html @@ -1,7 +1,7 @@ Test for CSS transitions and re-wrapping of inlines diff --git a/layout/style/crashtests/729126-1.html b/layout/style/crashtests/729126-1.html index cf61a4a5866f..a5c50abd0b47 100644 --- a/layout/style/crashtests/729126-1.html +++ b/layout/style/crashtests/729126-1.html @@ -1,6 +1,6 @@ - +