Simplify range walking codes
The new range walker API is about to be ready with #3367, it introduced a completely new simplified way to perform daily range work, it's concise and powerful to support the the following ways when walk along range.
We should try to replace the bells and whistles we've had in v2 for ranges manipulation with this new API after we close #3367.
Now we could:
- Walking along the content inside the range, mostly useful for style system.
outside [->...inside...<-]outside
With
var walker = new CKEDITOR.dom.walker( range ), node;
while ( node = walker.next() )
{
// Node processing...
}
- Walking along the other opposite two sides of the range, mostly useful for enlargement and checking block boundary.
outside <-[ ...inside...]-> outside
With
// E.g. Walking along the left out side
var walkerRange = new CKEDITOR.dom.range();
walkerRange.setStartAt( document.getBody(), CKEDITOR.POSITION_AFTER_START );
walkerRange.setEndAt( range.startContainer, range.startOffset );
walker.guard = function()
{
//// Node processing...
};
do
{
node = walker.next()
}
while ( node )
- Retrieve the boundary nodes of collapsed range:
leftBoundaryNode<-^->rightBoundaryNode
With
// E.g. Get the end boundary node after the range.
var walkerRange = new CKEDITOR.dom.range();
walkerRange.setStartAt( range.endContainer, range.endOffset );
walkerRange.setEndAt( document.getBody(), CKEDITOR.POSITION_BEFORE_END );
var endBoundaryNode = walkerRange.next();
- Even other usages could be expanded...
Sub Tickets
- #3478
- Simplify styles processing
Change History (9)
Owner: |
set to Garry Yao
|
Status: |
new →
assigned
|
Description: |
modified (diff)
|
Keywords: |
Confirmed added
|
Summary: |
Simply range walking codes →
Simplify range walking codes
|
Milestone: |
CKEditor 3.0 →
CKEditor 3.1
|
Owner: |
Garry Yao deleted
|
Priority: |
High →
Normal
|
Status: |
assigned →
new
|
Milestone: |
CKEditor 3.1 →
CKEditor 3.2
|
Milestone: |
CKEditor 3.2 →
CKEditor 3.3
|
Milestone: |
CKEditor 3.3 →
CKEditor 3.x
|
Resolution: |
→ wontfix
|
Status: |
confirmed →
closed
|
Since there's many parts involved, I'll open sub tickets for every single part for it, this one become an umbrella ticket.