mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 611103 - Don't depend on the editor in nsDocumentEncoder; r=bzbarsky
This commit is contained in:
parent
59d99db61e
commit
12229012ec
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user