Bug 611103 - Don't depend on the editor in nsDocumentEncoder; r=bzbarsky

This commit is contained in:
Ehsan Akhgari 2015-01-22 10:02:15 -05:00
parent 59d99db61e
commit 12229012ec
3 changed files with 9 additions and 47 deletions

View File

@ -47,9 +47,6 @@
#include "nsStringBuffer.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ShadowRoot.h"
#include "nsIEditor.h"
#include "nsIHTMLEditor.h"
#include "nsIDocShell.h"
#include "mozilla/dom/EncodingUtils.h"
#include "nsComputedDOMStyle.h"
@ -324,34 +321,17 @@ nsDocumentEncoder::IncludeInContext(nsINode *aNode)
static
bool
IsInvisibleBreak(nsINode *aNode) {
// xxxehsan: we should probably figure out a way to determine
// if a BR node is visible without using the editor.
Element* elt = aNode->AsElement();
if (!elt->IsHTML(nsGkAtoms::br) ||
!aNode->IsEditable()) {
if (!aNode->IsElement() || !aNode->IsEditable()) {
return false;
}
nsIFrame* frame = aNode->AsElement()->GetPrimaryFrame();
if (!frame || frame->GetType() != nsGkAtoms::brFrame) {
return false;
}
// Grab the editor associated with the document
nsIDocument *doc = aNode->GetComposedDoc();
if (doc) {
nsPIDOMWindow *window = doc->GetWindow();
if (window) {
nsIDocShell *docShell = window->GetDocShell();
if (docShell) {
nsCOMPtr<nsIEditor> editor;
docShell->GetEditor(getter_AddRefs(editor));
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor);
if (htmlEditor) {
bool isVisible = false;
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(aNode);
htmlEditor->BreakIsVisible(domNode, &isVisible);
return !isVisible;
}
}
}
}
return false;
// If the BRFrame has caused a visible line break, it should have a next
// sibling.
return !frame->GetNextSibling();
}
nsresult

View File

@ -969,7 +969,6 @@ nsHTMLEditor::IsVisBreak(nsINode* aNode)
return true;
}
bool
nsHTMLEditor::IsVisBreak(nsIDOMNode* aNode)
{
@ -978,17 +977,6 @@ nsHTMLEditor::IsVisBreak(nsIDOMNode* aNode)
return IsVisBreak(node);
}
NS_IMETHODIMP
nsHTMLEditor::BreakIsVisible(nsIDOMNode *aNode, bool *aIsVisible)
{
NS_ENSURE_ARG_POINTER(aNode && aIsVisible);
*aIsVisible = IsVisBreak(aNode);
return NS_OK;
}
NS_IMETHODIMP
nsHTMLEditor::GetIsDocumentEditable(bool *aIsDocumentEditable)
{

View File

@ -22,8 +22,7 @@ class Element;
[ptr] native Element (mozilla::dom::Element);
[scriptable, uuid(393a364f-e8e2-48a1-a271-a0067b6bac9b)]
[scriptable, uuid(87ee993e-985f-4a43-a974-0d9512da2fb0)]
interface nsIHTMLEditor : nsISupports
{
%{C++
@ -551,11 +550,6 @@ interface nsIHTMLEditor : nsISupports
*/
attribute boolean returnInParagraphCreatesNewParagraph;
/**
* Checks whether a BR node is visible to the user.
*/
boolean breakIsVisible(in nsIDOMNode aNode);
/**
* Get an active editor's editing host in DOM window. If this editor isn't
* active in the DOM window, this returns NULL.