зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1313986 - Part 4. Use Element instead of nsIDOMElement for resizer. r=masayuki
Resizer and etc attributes on table editor still use nsIDOMElement. Converting to Element makes both implementation and the callers simpler. MozReview-Commit-ID: TTFSvqn5GE --HG-- extra : rebase_source : 705576c4eb0fe5f8f566f3415a8a72842c919edd
This commit is contained in:
Родитель
3d6d028dd6
Коммит
ef514b53ec
|
@ -270,7 +270,7 @@ HTMLEditor::RefreshGrabber()
|
|||
|
||||
SetAnonymousElementPosition(mPositionedObjectX+12,
|
||||
mPositionedObjectY-14,
|
||||
static_cast<nsIDOMElement*>(GetAsDOMNode(mGrabber)));
|
||||
mGrabber);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -294,9 +294,9 @@ HTMLEditor::HideGrabber()
|
|||
nsCOMPtr<nsIContent> parentContent = mGrabber->GetParent();
|
||||
NS_ENSURE_TRUE(parentContent, NS_ERROR_NULL_POINTER);
|
||||
|
||||
DeleteRefToAnonymousNode(static_cast<nsIDOMElement*>(GetAsDOMNode(mGrabber)), parentContent, ps);
|
||||
DeleteRefToAnonymousNode(mGrabber, parentContent, ps);
|
||||
mGrabber = nullptr;
|
||||
DeleteRefToAnonymousNode(static_cast<nsIDOMElement*>(GetAsDOMNode(mPositioningShadow)), parentContent, ps);
|
||||
DeleteRefToAnonymousNode(mPositioningShadow, parentContent, ps);
|
||||
mPositioningShadow = nullptr;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -399,8 +399,7 @@ HTMLEditor::EndMoving()
|
|||
nsCOMPtr<nsIContent> parentContent = mGrabber->GetParent();
|
||||
NS_ENSURE_TRUE(parentContent, NS_ERROR_FAILURE);
|
||||
|
||||
DeleteRefToAnonymousNode(static_cast<nsIDOMElement*>(GetAsDOMNode(mPositioningShadow)),
|
||||
parentContent, ps);
|
||||
DeleteRefToAnonymousNode(mPositioningShadow, parentContent, ps);
|
||||
|
||||
mPositioningShadow = nullptr;
|
||||
}
|
||||
|
|
|
@ -286,12 +286,12 @@ HTMLEditor::RemoveListenerAndDeleteRef(const nsAString& aEvent,
|
|||
if (evtTarget) {
|
||||
evtTarget->RemoveEventListener(aEvent, aListener, aUseCapture);
|
||||
}
|
||||
DeleteRefToAnonymousNode(static_cast<nsIDOMElement*>(GetAsDOMNode(aElement)), aParentContent, aShell);
|
||||
DeleteRefToAnonymousNode(aElement, aParentContent, aShell);
|
||||
}
|
||||
|
||||
// Deletes all references to an anonymous element
|
||||
void
|
||||
HTMLEditor::DeleteRefToAnonymousNode(nsIDOMElement* aElement,
|
||||
HTMLEditor::DeleteRefToAnonymousNode(nsIContent* aContent,
|
||||
nsIContent* aParentContent,
|
||||
nsIPresShell* aShell)
|
||||
{
|
||||
|
@ -299,38 +299,37 @@ HTMLEditor::DeleteRefToAnonymousNode(nsIDOMElement* aElement,
|
|||
// node so its references get removed from the frame manager's
|
||||
// undisplay map, and its layout frames get destroyed!
|
||||
|
||||
if (aElement) {
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
|
||||
if (content) {
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
// Need to check whether aShell has been destroyed (but not yet deleted).
|
||||
// In that case presContext->GetPresShell() returns nullptr.
|
||||
// See bug 338129.
|
||||
if (content->IsInComposedDoc() && aShell && aShell->GetPresContext() &&
|
||||
aShell->GetPresContext()->GetPresShell() == aShell) {
|
||||
nsCOMPtr<nsIDocumentObserver> docObserver = do_QueryInterface(aShell);
|
||||
if (docObserver) {
|
||||
// Call BeginUpdate() so that the nsCSSFrameConstructor/PresShell
|
||||
// knows we're messing with the frame tree.
|
||||
nsCOMPtr<nsIDocument> document = GetDocument();
|
||||
if (document) {
|
||||
docObserver->BeginUpdate(document, UPDATE_CONTENT_MODEL);
|
||||
}
|
||||
if (NS_WARN_IF(!aContent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// XXX This is wrong (bug 439258). Once it's fixed, the NS_WARNING
|
||||
// in RestyleManager::RestyleForRemove should be changed back
|
||||
// to an assertion.
|
||||
docObserver->ContentRemoved(content->GetComposedDoc(),
|
||||
aParentContent, content, -1,
|
||||
content->GetPreviousSibling());
|
||||
if (document) {
|
||||
docObserver->EndUpdate(document, UPDATE_CONTENT_MODEL);
|
||||
}
|
||||
}
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
// Need to check whether aShell has been destroyed (but not yet deleted).
|
||||
// In that case presContext->GetPresShell() returns nullptr.
|
||||
// See bug 338129.
|
||||
if (aContent->IsInComposedDoc() && aShell && aShell->GetPresContext() &&
|
||||
aShell->GetPresContext()->GetPresShell() == aShell) {
|
||||
nsCOMPtr<nsIDocumentObserver> docObserver = do_QueryInterface(aShell);
|
||||
if (docObserver) {
|
||||
// Call BeginUpdate() so that the nsCSSFrameConstructor/PresShell
|
||||
// knows we're messing with the frame tree.
|
||||
nsCOMPtr<nsIDocument> document = GetDocument();
|
||||
if (document) {
|
||||
docObserver->BeginUpdate(document, UPDATE_CONTENT_MODEL);
|
||||
}
|
||||
|
||||
// XXX This is wrong (bug 439258). Once it's fixed, the NS_WARNING
|
||||
// in RestyleManager::RestyleForRemove should be changed back
|
||||
// to an assertion.
|
||||
docObserver->ContentRemoved(aContent->GetComposedDoc(),
|
||||
aParentContent, aContent, -1,
|
||||
aContent->GetPreviousSibling());
|
||||
if (document) {
|
||||
docObserver->EndUpdate(document, UPDATE_CONTENT_MODEL);
|
||||
}
|
||||
content->UnbindFromTree();
|
||||
}
|
||||
}
|
||||
aContent->UnbindFromTree();
|
||||
}
|
||||
|
||||
// The following method is mostly called by a selection listener. When a
|
||||
|
@ -569,10 +568,10 @@ HTMLEditor::GetPositionAndDimensions(nsIDOMElement* aElement,
|
|||
void
|
||||
HTMLEditor::SetAnonymousElementPosition(int32_t aX,
|
||||
int32_t aY,
|
||||
nsIDOMElement* aElement)
|
||||
Element* aElement)
|
||||
{
|
||||
mCSSEditUtils->SetCSSPropertyPixels(aElement, NS_LITERAL_STRING("left"), aX);
|
||||
mCSSEditUtils->SetCSSPropertyPixels(aElement, NS_LITERAL_STRING("top"), aY);
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*aElement, *nsGkAtoms::left, aX);
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*aElement, *nsGkAtoms::top, aY);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -921,7 +921,7 @@ protected:
|
|||
Element* aElement,
|
||||
nsIContent* aParentContent,
|
||||
nsIPresShell* aShell);
|
||||
void DeleteRefToAnonymousNode(nsIDOMElement* aElement,
|
||||
void DeleteRefToAnonymousNode(nsIContent* aContent,
|
||||
nsIContent* aParentContent,
|
||||
nsIPresShell* aShell);
|
||||
|
||||
|
@ -1007,7 +1007,7 @@ protected:
|
|||
already_AddRefed<Element> CreateResizer(int16_t aLocation,
|
||||
nsIDOMNode* aParentNode);
|
||||
void SetAnonymousElementPosition(int32_t aX, int32_t aY,
|
||||
nsIDOMElement* aResizer);
|
||||
Element* aResizer);
|
||||
|
||||
already_AddRefed<Element> CreateShadow(nsIDOMNode* aParentNode,
|
||||
nsIDOMElement* aOriginalObject);
|
||||
|
@ -1062,16 +1062,16 @@ protected:
|
|||
// inline table editing
|
||||
nsCOMPtr<nsIDOMElement> mInlineEditedCell;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> mAddColumnBeforeButton;
|
||||
nsCOMPtr<nsIDOMElement> mRemoveColumnButton;
|
||||
nsCOMPtr<nsIDOMElement> mAddColumnAfterButton;
|
||||
RefPtr<Element> mAddColumnBeforeButton;
|
||||
RefPtr<Element> mRemoveColumnButton;
|
||||
RefPtr<Element> mAddColumnAfterButton;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> mAddRowBeforeButton;
|
||||
nsCOMPtr<nsIDOMElement> mRemoveRowButton;
|
||||
nsCOMPtr<nsIDOMElement> mAddRowAfterButton;
|
||||
RefPtr<Element> mAddRowBeforeButton;
|
||||
RefPtr<Element> mRemoveRowButton;
|
||||
RefPtr<Element> mAddRowAfterButton;
|
||||
|
||||
void AddMouseClickListener(nsIDOMElement* aElement);
|
||||
void RemoveMouseClickListener(nsIDOMElement* aElement);
|
||||
void AddMouseClickListener(Element* aElement);
|
||||
void RemoveMouseClickListener(Element* aElement);
|
||||
|
||||
nsCOMPtr<nsILinkHandler> mLinkHandler;
|
||||
|
||||
|
|
|
@ -241,16 +241,16 @@ HTMLEditor::SetAllResizersPosition()
|
|||
int32_t rw = (int32_t)((resizerWidth + 1) / 2);
|
||||
int32_t rh = (int32_t)((resizerHeight+ 1) / 2);
|
||||
|
||||
SetAnonymousElementPosition(x-rw, y-rh, static_cast<nsIDOMElement*>(GetAsDOMNode(mTopLeftHandle)));
|
||||
SetAnonymousElementPosition(x+w/2-rw, y-rh, static_cast<nsIDOMElement*>(GetAsDOMNode(mTopHandle)));
|
||||
SetAnonymousElementPosition(x+w-rw-1, y-rh, static_cast<nsIDOMElement*>(GetAsDOMNode(mTopRightHandle)));
|
||||
SetAnonymousElementPosition(x-rw, y-rh, mTopLeftHandle);
|
||||
SetAnonymousElementPosition(x+w/2-rw, y-rh, mTopHandle);
|
||||
SetAnonymousElementPosition(x+w-rw-1, y-rh, mTopRightHandle);
|
||||
|
||||
SetAnonymousElementPosition(x-rw, y+h/2-rh, static_cast<nsIDOMElement*>(GetAsDOMNode(mLeftHandle)));
|
||||
SetAnonymousElementPosition(x+w-rw-1, y+h/2-rh, static_cast<nsIDOMElement*>(GetAsDOMNode(mRightHandle)));
|
||||
SetAnonymousElementPosition(x-rw, y+h/2-rh, mLeftHandle);
|
||||
SetAnonymousElementPosition(x+w-rw-1, y+h/2-rh, mRightHandle);
|
||||
|
||||
SetAnonymousElementPosition(x-rw, y+h-rh-1, static_cast<nsIDOMElement*>(GetAsDOMNode(mBottomLeftHandle)));
|
||||
SetAnonymousElementPosition(x+w/2-rw, y+h-rh-1, static_cast<nsIDOMElement*>(GetAsDOMNode(mBottomHandle)));
|
||||
SetAnonymousElementPosition(x+w-rw-1, y+h-rh-1, static_cast<nsIDOMElement*>(GetAsDOMNode(mBottomRightHandle)));
|
||||
SetAnonymousElementPosition(x-rw, y+h-rh-1, mBottomLeftHandle);
|
||||
SetAnonymousElementPosition(x+w/2-rw, y+h-rh-1, mBottomHandle);
|
||||
SetAnonymousElementPosition(x+w-rw-1, y+h-rh-1, mBottomRightHandle);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -718,7 +718,7 @@ HTMLEditor::SetShadowPosition(Element* aShadow,
|
|||
int32_t aOriginalObjectX,
|
||||
int32_t aOriginalObjectY)
|
||||
{
|
||||
SetAnonymousElementPosition(aOriginalObjectX, aOriginalObjectY, static_cast<nsIDOMElement*>(GetAsDOMNode(aShadow)));
|
||||
SetAnonymousElementPosition(aOriginalObjectX, aOriginalObjectY, aShadow);
|
||||
|
||||
if (HTMLEditUtils::IsImage(aOriginalObject)) {
|
||||
nsAutoString imageSource;
|
||||
|
|
|
@ -61,25 +61,25 @@ HTMLEditor::ShowInlineTableEditingUI(nsIDOMElement* aCell)
|
|||
nsCOMPtr<nsIDOMElement> bodyElement = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(bodyElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
CreateAnonymousElement(NS_LITERAL_STRING("a"), bodyElement,
|
||||
NS_LITERAL_STRING("mozTableAddColumnBefore"),
|
||||
false, getter_AddRefs(mAddColumnBeforeButton));
|
||||
CreateAnonymousElement(NS_LITERAL_STRING("a"), bodyElement,
|
||||
NS_LITERAL_STRING("mozTableRemoveColumn"),
|
||||
false, getter_AddRefs(mRemoveColumnButton));
|
||||
CreateAnonymousElement(NS_LITERAL_STRING("a"), bodyElement,
|
||||
NS_LITERAL_STRING("mozTableAddColumnAfter"),
|
||||
false, getter_AddRefs(mAddColumnAfterButton));
|
||||
mAddColumnBeforeButton =
|
||||
CreateAnonymousElement(nsGkAtoms::a, bodyElement,
|
||||
NS_LITERAL_STRING("mozTableAddColumnBefore"), false);
|
||||
mRemoveColumnButton =
|
||||
CreateAnonymousElement(nsGkAtoms::a, bodyElement,
|
||||
NS_LITERAL_STRING("mozTableRemoveColumn"), false);
|
||||
mAddColumnAfterButton =
|
||||
CreateAnonymousElement(nsGkAtoms::a, bodyElement,
|
||||
NS_LITERAL_STRING("mozTableAddColumnAfter"), false);
|
||||
|
||||
CreateAnonymousElement(NS_LITERAL_STRING("a"), bodyElement,
|
||||
NS_LITERAL_STRING("mozTableAddRowBefore"),
|
||||
false, getter_AddRefs(mAddRowBeforeButton));
|
||||
CreateAnonymousElement(NS_LITERAL_STRING("a"), bodyElement,
|
||||
NS_LITERAL_STRING("mozTableRemoveRow"),
|
||||
false, getter_AddRefs(mRemoveRowButton));
|
||||
CreateAnonymousElement(NS_LITERAL_STRING("a"), bodyElement,
|
||||
NS_LITERAL_STRING("mozTableAddRowAfter"),
|
||||
false, getter_AddRefs(mAddRowAfterButton));
|
||||
mAddRowBeforeButton =
|
||||
CreateAnonymousElement(nsGkAtoms::a, bodyElement,
|
||||
NS_LITERAL_STRING("mozTableAddRowBefore"), false);
|
||||
mRemoveRowButton =
|
||||
CreateAnonymousElement(nsGkAtoms::a, bodyElement,
|
||||
NS_LITERAL_STRING("mozTableRemoveRow"), false);
|
||||
mAddRowAfterButton =
|
||||
CreateAnonymousElement(nsGkAtoms::a, bodyElement,
|
||||
NS_LITERAL_STRING("mozTableAddRowAfter"), false);
|
||||
|
||||
AddMouseClickListener(mAddColumnBeforeButton);
|
||||
AddMouseClickListener(mRemoveColumnButton);
|
||||
|
@ -188,7 +188,7 @@ HTMLEditor::DoInlineTableEditingAction(nsIDOMElement* aElement)
|
|||
}
|
||||
|
||||
void
|
||||
HTMLEditor::AddMouseClickListener(nsIDOMElement* aElement)
|
||||
HTMLEditor::AddMouseClickListener(Element* aElement)
|
||||
{
|
||||
nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(aElement));
|
||||
if (evtTarget) {
|
||||
|
@ -198,7 +198,7 @@ HTMLEditor::AddMouseClickListener(nsIDOMElement* aElement)
|
|||
}
|
||||
|
||||
void
|
||||
HTMLEditor::RemoveMouseClickListener(nsIDOMElement* aElement)
|
||||
HTMLEditor::RemoveMouseClickListener(Element* aElement)
|
||||
{
|
||||
nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(aElement));
|
||||
if (evtTarget) {
|
||||
|
@ -234,17 +234,12 @@ HTMLEditor::RefreshInlineTableEditingUI()
|
|||
|
||||
SetAnonymousElementPosition(xHoriz-10, yCell-7, mAddColumnBeforeButton);
|
||||
#ifdef DISABLE_TABLE_DELETION
|
||||
NS_NAMED_LITERAL_STRING(classStr, "class");
|
||||
|
||||
if (colCount== 1) {
|
||||
mRemoveColumnButton->SetAttribute(classStr,
|
||||
NS_LITERAL_STRING("hidden"));
|
||||
}
|
||||
else {
|
||||
bool hasClass = false;
|
||||
rv = mRemoveColumnButton->HasAttribute(classStr, &hasClass);
|
||||
if (NS_SUCCEEDED(rv) && hasClass) {
|
||||
mRemoveColumnButton->RemoveAttribute(classStr);
|
||||
mRemoveColumnButton->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
|
||||
NS_LITERAL_STRING("hidden"), true);
|
||||
} else {
|
||||
if (mRemoveColumnButton->HasAttr(kNameSpaceID_None, nsGkAtoms::_class)) {
|
||||
mRemoveColumnButton->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_class);
|
||||
}
|
||||
#endif
|
||||
SetAnonymousElementPosition(xHoriz-4, yCell-7, mRemoveColumnButton);
|
||||
|
@ -256,14 +251,11 @@ HTMLEditor::RefreshInlineTableEditingUI()
|
|||
SetAnonymousElementPosition(xCell-7, yVert-10, mAddRowBeforeButton);
|
||||
#ifdef DISABLE_TABLE_DELETION
|
||||
if (rowCount== 1) {
|
||||
mRemoveRowButton->SetAttribute(classStr,
|
||||
NS_LITERAL_STRING("hidden"));
|
||||
}
|
||||
else {
|
||||
bool hasClass = false;
|
||||
rv = mRemoveRowButton->HasAttribute(classStr, &hasClass);
|
||||
if (NS_SUCCEEDED(rv) && hasClass) {
|
||||
mRemoveRowButton->RemoveAttribute(classStr);
|
||||
mRemoveRowButton->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
|
||||
NS_LITERAL_STRING("hidden"), true);
|
||||
} else {
|
||||
if (mRemoveRowButton->HasAttr(kNameSpaceID_None, nsGkAtoms::_class)) {
|
||||
mRemoveRowButton->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_class, true);
|
||||
}
|
||||
#endif
|
||||
SetAnonymousElementPosition(xCell-7, yVert-4, mRemoveRowButton);
|
||||
|
|
Загрузка…
Ссылка в новой задаче