|
|
|
Lines 1266-1289
nsHTMLEditRules::WillInsert(nsISelection
|
Link Here
|
|---|
|
| 1266 |
// we need to get the doc |
1266 |
// we need to get the doc |
| 1267 |
nsCOMPtr<nsIDOMDocument> doc = mHTMLEditor->GetDOMDocument(); |
1267 |
nsCOMPtr<nsIDOMDocument> doc = mHTMLEditor->GetDOMDocument(); |
| 1268 |
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED); |
1268 |
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED); |
| 1269 |
|
1269 |
|
| 1270 |
// for every property that is set, insert a new inline style node |
1270 |
// for every property that is set, insert a new inline style node |
| 1271 |
return CreateStyleForInsertText(aSelection, doc); |
1271 |
return CreateStyleForInsertText(aSelection, doc); |
| 1272 |
} |
1272 |
} |
| 1273 |
|
1273 |
|
| 1274 |
#ifdef XXX_DEAD_CODE |
|
|
| 1275 |
nsresult |
| 1276 |
nsHTMLEditRules::DidInsert(nsISelection *aSelection, nsresult aResult) |
| 1277 |
{ |
| 1278 |
return nsTextEditRules::DidInsert(aSelection, aResult); |
| 1279 |
} |
| 1280 |
#endif |
| 1281 |
|
| 1282 |
nsresult |
1274 |
nsresult |
| 1283 |
nsHTMLEditRules::WillInsertText(nsEditor::OperationID aAction, |
1275 |
nsHTMLEditRules::WillInsertText(nsEditor::OperationID aAction, |
| 1284 |
nsISelection *aSelection, |
1276 |
nsISelection *aSelection, |
| 1285 |
bool *aCancel, |
1277 |
bool *aCancel, |
| 1286 |
bool *aHandled, |
1278 |
bool *aHandled, |
| 1287 |
const nsAString *inString, |
1279 |
const nsAString *inString, |
| 1288 |
nsAString *outString, |
1280 |
nsAString *outString, |
| 1289 |
PRInt32 aMaxLength) |
1281 |
PRInt32 aMaxLength) |
|
Lines 5232-5310
nsHTMLEditRules::ExpandSelectionForDelet
|
Link Here
|
|---|
|
| 5232 |
{ |
5224 |
{ |
| 5233 |
// only expand to just before br |
5225 |
// only expand to just before br |
| 5234 |
res = aSelection->Extend(firstBRParent, firstBROffset); |
5226 |
res = aSelection->Extend(firstBRParent, firstBROffset); |
| 5235 |
} |
5227 |
} |
| 5236 |
|
5228 |
|
| 5237 |
return res; |
5229 |
return res; |
| 5238 |
} |
5230 |
} |
| 5239 |
|
5231 |
|
| 5240 |
#ifdef XXX_DEAD_CODE |
|
|
| 5241 |
/////////////////////////////////////////////////////////////////////////// |
| 5242 |
// AtStartOfBlock: is node/offset at the start of the editable material in this block? |
| 5243 |
// |
| 5244 |
bool |
| 5245 |
nsHTMLEditRules::AtStartOfBlock(nsIDOMNode *aNode, PRInt32 aOffset, nsIDOMNode *aBlock) |
| 5246 |
{ |
| 5247 |
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(aNode); |
| 5248 |
if (nodeAsText && aOffset) return false; // there are chars in front of us |
| 5249 |
|
| 5250 |
nsCOMPtr<nsIDOMNode> priorNode; |
| 5251 |
nsresult res = mHTMLEditor->GetPriorHTMLNode(aNode, aOffset, address_of(priorNode)); |
| 5252 |
NS_ENSURE_SUCCESS(res, true); |
| 5253 |
NS_ENSURE_TRUE(priorNode, true); |
| 5254 |
nsCOMPtr<nsIDOMNode> blockParent = mHTMLEditor->GetBlockNodeParent(priorNode); |
| 5255 |
if (blockParent && (blockParent == aBlock)) return false; |
| 5256 |
return true; |
| 5257 |
} |
| 5258 |
|
| 5259 |
|
| 5260 |
/////////////////////////////////////////////////////////////////////////// |
| 5261 |
// AtEndOfBlock: is node/offset at the end of the editable material in this block? |
| 5262 |
// |
| 5263 |
bool |
| 5264 |
nsHTMLEditRules::AtEndOfBlock(nsIDOMNode *aNode, PRInt32 aOffset, nsIDOMNode *aBlock) |
| 5265 |
{ |
| 5266 |
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(aNode); |
| 5267 |
if (nodeAsText) |
| 5268 |
{ |
| 5269 |
PRUint32 strLength; |
| 5270 |
nodeAsText->GetLength(&strLength); |
| 5271 |
if ((PRInt32)strLength > aOffset) return false; // there are chars in after us |
| 5272 |
} |
| 5273 |
nsCOMPtr<nsIDOMNode> nextNode; |
| 5274 |
nsresult res = mHTMLEditor->GetNextHTMLNode(aNode, aOffset, address_of(nextNode)); |
| 5275 |
NS_ENSURE_SUCCESS(res, true); |
| 5276 |
NS_ENSURE_TRUE(nextNode, true); |
| 5277 |
nsCOMPtr<nsIDOMNode> blockParent = mHTMLEditor->GetBlockNodeParent(nextNode); |
| 5278 |
if (blockParent && (blockParent == aBlock)) return false; |
| 5279 |
return true; |
| 5280 |
} |
| 5281 |
|
| 5282 |
|
| 5283 |
/////////////////////////////////////////////////////////////////////////// |
| 5284 |
// CreateMozDiv: makes a div with type = _moz |
| 5285 |
// |
| 5286 |
nsresult |
| 5287 |
nsHTMLEditRules::CreateMozDiv(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outDiv) |
| 5288 |
{ |
| 5289 |
NS_ENSURE_TRUE(inParent && outDiv, NS_ERROR_NULL_POINTER); |
| 5290 |
nsAutoString divType= "div"; |
| 5291 |
*outDiv = nsnull; |
| 5292 |
nsresult res = mHTMLEditor->CreateNode(divType, inParent, inOffset, getter_AddRefs(*outDiv)); |
| 5293 |
NS_ENSURE_SUCCESS(res, res); |
| 5294 |
// give it special moz attr |
| 5295 |
nsCOMPtr<nsIDOMElement> mozDivElem = do_QueryInterface(*outDiv); |
| 5296 |
res = mHTMLEditor->SetAttribute(mozDivElem, "type", "_moz"); |
| 5297 |
NS_ENSURE_SUCCESS(res, res); |
| 5298 |
res = AddTrailerBR(*outDiv); |
| 5299 |
return res; |
| 5300 |
} |
| 5301 |
#endif |
| 5302 |
|
| 5303 |
|
5232 |
|
| 5304 |
/////////////////////////////////////////////////////////////////////////// |
5233 |
/////////////////////////////////////////////////////////////////////////// |
| 5305 |
// NormalizeSelection: tweak non-collapsed selections to be more "natural". |
5234 |
// NormalizeSelection: tweak non-collapsed selections to be more "natural". |
| 5306 |
// Idea here is to adjust selection endpoint so that they do not cross |
5235 |
// Idea here is to adjust selection endpoint so that they do not cross |
| 5307 |
// breaks or block boundaries unless something editable beyond that boundary |
5236 |
// breaks or block boundaries unless something editable beyond that boundary |
| 5308 |
// is also selected. This adjustment makes it much easier for the various |
5237 |
// is also selected. This adjustment makes it much easier for the various |
| 5309 |
// block operations to determine what nodes to act on. |
5238 |
// block operations to determine what nodes to act on. |
| 5310 |
// |
5239 |
// |