/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Use Clone for creating the new node so that the new node is of same class // as this node!
RefPtr<CharacterData> clone = CloneDataNode(mNodeInfo, false);
MOZ_ASSERT(clone && clone->IsText());
RefPtr<Text> newContent = static_cast<Text*>(clone.get());
// nsRange expects the CharacterDataChanged notification is followed // by an insertion of |newContent|. If you change this code, // make sure you make the appropriate changes in nsRange.
newContent->SetText(cutText, true); // XXX should be false?
static Text* FirstLogicallyAdjacentTextNode(Text* aNode) { do {
nsIContent* sibling = aNode->GetPreviousSibling(); if (!sibling || !sibling->IsText()) { return aNode;
}
aNode = static_cast<Text*>(sibling);
} while (1); // Must run out of previous siblings eventually!
}
static Text* LastLogicallyAdjacentTextNode(Text* aNode) { do {
nsIContent* sibling = aNode->GetNextSibling(); if (!sibling || !sibling->IsText()) { return aNode;
}
aNode = static_cast<Text*>(sibling);
} while (1); // Must run out of next siblings eventually!
}
// Handle parent-less nodes if (!parent) {
GetData(aWholeText); return;
}
Text* first = FirstLogicallyAdjacentTextNode(this);
Text* last = LastLogicallyAdjacentTextNode(this);
aWholeText.Truncate();
nsAutoString tmp;
while (true) {
first->GetData(tmp);
aWholeText.Append(tmp);
if (first == last) { break;
}
nsIContent* next = first->GetNextSibling();
MOZ_ASSERT(next && next->IsText(), "How did we run out of text before hitting `last`?");
first = static_cast<Text*>(next);
}
}
bool Text::HasTextForTranslation() { if (mText.Is2b()) { // The fragment contains non-8bit characters which means there // was at least one "interesting" character to trigger non-8bit. returntrue;
}
if (HasFlag(NS_CACHED_TEXT_IS_ONLY_WHITESPACE) &&
HasFlag(NS_TEXT_IS_ONLY_WHITESPACE)) { returnfalse;
}
constchar* cp = mText.Get1b(); constchar* end = cp + mText.GetLength();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.