зеркало из https://github.com/mozilla/gecko-dev.git
Backout changeset 643bf6006fea (bug 1190172 part 2)
--HG-- extra : rebase_source : c806f63e9cf69bf380e5c3a377de1af3fc35f561
This commit is contained in:
Родитель
65acec6efb
Коммит
db9ddcac79
|
@ -344,7 +344,8 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
|
|||
|
||||
if (aClearStyle) {
|
||||
// pasting does not inherit local inline styles
|
||||
nsCOMPtr<nsINode> tmpNode = selection->GetAnchorNode();
|
||||
nsCOMPtr<nsIDOMNode> tmpNode =
|
||||
do_QueryInterface(selection->GetAnchorNode());
|
||||
int32_t tmpOffset = static_cast<int32_t>(selection->AnchorOffset());
|
||||
rv = ClearStyle(address_of(tmpNode), &tmpOffset, nullptr, nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -4425,11 +4425,14 @@ nsHTMLEditRules::CreateStyleForInsertText(Selection* aSelection,
|
|||
{
|
||||
MOZ_ASSERT(aSelection && aDoc && mHTMLEditor->mTypeInState);
|
||||
|
||||
nsresult res;
|
||||
bool weDidSomething = false;
|
||||
NS_ENSURE_STATE(aSelection->GetRangeAt(0));
|
||||
nsCOMPtr<nsINode> node = aSelection->GetRangeAt(0)->GetStartParent();
|
||||
int32_t offset = aSelection->GetRangeAt(0)->StartOffset();
|
||||
nsCOMPtr<nsIDOMNode> node, tmp;
|
||||
int32_t offset;
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
nsresult res = mHTMLEditor->GetStartNodeAndOffset(aSelection,
|
||||
getter_AddRefs(node),
|
||||
&offset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// next examine our present style and make sure default styles are either
|
||||
// present or explicitly overridden. If neither, add the default style to
|
||||
|
@ -4468,7 +4471,7 @@ nsHTMLEditRules::CreateStyleForInsertText(Selection* aSelection,
|
|||
|
||||
// process clearing any styles first
|
||||
nsAutoPtr<PropItem> item(mHTMLEditor->mTypeInState->TakeClearProperty());
|
||||
while (item && GetAsDOMNode(node) != rootElement) {
|
||||
while (item && node != rootElement) {
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
res = mHTMLEditor->ClearStyle(address_of(node), &offset,
|
||||
item->tag, &item->attr);
|
||||
|
@ -4484,24 +4487,27 @@ nsHTMLEditRules::CreateStyleForInsertText(Selection* aSelection,
|
|||
if (item || relFontSize) {
|
||||
// we have at least one style to add; make a new text node to insert style
|
||||
// nodes above.
|
||||
if (RefPtr<Text> text = node->GetAsText()) {
|
||||
if (mHTMLEditor->IsTextNode(node)) {
|
||||
// if we are in a text node, split it
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
offset = mHTMLEditor->SplitNodeDeep(*text, *text, offset);
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
|
||||
NS_ENSURE_STATE(content || !node);
|
||||
offset = mHTMLEditor->SplitNodeDeep(*content, *content, offset);
|
||||
NS_ENSURE_STATE(offset != -1);
|
||||
node = node->GetParentNode();
|
||||
node->GetParentNode(getter_AddRefs(tmp));
|
||||
node = tmp;
|
||||
}
|
||||
if (!mHTMLEditor->IsContainer(node)) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIContent> newNode;
|
||||
nsCOMPtr<nsIDOMNode> newNode;
|
||||
nsCOMPtr<nsIDOMText> nodeAsText;
|
||||
res = aDoc->CreateTextNode(EmptyString(), getter_AddRefs(nodeAsText));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(nodeAsText, NS_ERROR_NULL_POINTER);
|
||||
newNode = do_QueryInterface(nodeAsText);
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
res = mHTMLEditor->InsertNode(*newNode, *node, offset);
|
||||
res = mHTMLEditor->InsertNode(newNode, node, offset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
node = newNode;
|
||||
offset = 0;
|
||||
|
@ -4520,9 +4526,10 @@ nsHTMLEditRules::CreateStyleForInsertText(Selection* aSelection,
|
|||
|
||||
while (item) {
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
res = mHTMLEditor->SetInlinePropertyOnNode(*node->AsContent(),
|
||||
*item->tag, &item->attr,
|
||||
item->value);
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
|
||||
NS_ENSURE_STATE(content || !node);
|
||||
res = mHTMLEditor->SetInlinePropertyOnNode(*content, *item->tag,
|
||||
&item->attr, item->value);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
item = mHTMLEditor->mTypeInState->TakeSetProperty();
|
||||
}
|
||||
|
|
|
@ -755,7 +755,7 @@ protected:
|
|||
bool aTrustedInput,
|
||||
bool aClearStyle = true);
|
||||
|
||||
nsresult ClearStyle(nsCOMPtr<nsINode>* aNode, int32_t* aOffset,
|
||||
nsresult ClearStyle(nsCOMPtr<nsIDOMNode>* aNode, int32_t* aOffset,
|
||||
nsIAtom* aProperty, const nsAString* aAttribute);
|
||||
|
||||
void SetElementPosition(mozilla::dom::Element& aElement,
|
||||
|
|
|
@ -605,13 +605,15 @@ nsHTMLEditor::SplitStyleAbovePoint(nsCOMPtr<nsINode>* aNode,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLEditor::ClearStyle(nsCOMPtr<nsINode>* aNode, int32_t* aOffset,
|
||||
nsHTMLEditor::ClearStyle(nsCOMPtr<nsIDOMNode>* aNode, int32_t* aOffset,
|
||||
nsIAtom* aProperty, const nsAString* aAttribute)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(*aNode);
|
||||
nsCOMPtr<nsIContent> leftNode, rightNode;
|
||||
nsresult res = SplitStyleAbovePoint(aNode, aOffset, aProperty,
|
||||
nsresult res = SplitStyleAbovePoint(address_of(node), aOffset, aProperty,
|
||||
aAttribute, getter_AddRefs(leftNode),
|
||||
getter_AddRefs(rightNode));
|
||||
*aNode = GetAsDOMNode(node);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
if (leftNode) {
|
||||
|
@ -677,7 +679,7 @@ nsHTMLEditor::ClearStyle(nsCOMPtr<nsINode>* aNode, int32_t* aOffset,
|
|||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
// reset our node offset values to the resulting new sel point
|
||||
*aNode = newSelParent;
|
||||
*aNode = GetAsDOMNode(newSelParent);
|
||||
*aOffset = newSelOffset;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче