You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Mihai Chira <mi...@gmail.com> on 2015/09/21 11:46:48 UTC

Re: git commit: [flex-tlf] [refs/heads/develop] - FLEX-34807

Is this line only confusing for me? var
destinationParagraph:ParagraphElement = destinationLeaf ?
destinationLeaf.getParagraph() : destinationParagraph;

Is this the intention? if (destinationLeaf) destinationParagraph =
destinationLeaf.getParagraph();

On 19 September 2015 at 21:52,  <ha...@apache.org> wrote:
> Repository: flex-tlf
> Updated Branches:
>   refs/heads/develop 2ae535510 -> 96a959d1b
>
>
> FLEX-34807
>
>
> Project: http://git-wip-us.apache.org/repos/asf/flex-tlf/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-tlf/commit/96a959d1
> Tree: http://git-wip-us.apache.org/repos/asf/flex-tlf/tree/96a959d1
> Diff: http://git-wip-us.apache.org/repos/asf/flex-tlf/diff/96a959d1
>
> Branch: refs/heads/develop
> Commit: 96a959d1b943630e68a826a1cf1fc804c73e8b95
> Parents: 2ae5355
> Author: Harbs <ha...@in-tools.com>
> Authored: Sat Sep 19 22:52:35 2015 +0300
> Committer: Harbs <ha...@in-tools.com>
> Committed: Sat Sep 19 22:52:35 2015 +0300
>
> ----------------------------------------------------------------------
>  textLayout/src/flashx/textLayout/edit/TextFlowEdit.as | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/96a959d1/textLayout/src/flashx/textLayout/edit/TextFlowEdit.as
> ----------------------------------------------------------------------
> diff --git a/textLayout/src/flashx/textLayout/edit/TextFlowEdit.as b/textLayout/src/flashx/textLayout/edit/TextFlowEdit.as
> index 235cd08..0fc41fb 100644
> --- a/textLayout/src/flashx/textLayout/edit/TextFlowEdit.as
> +++ b/textLayout/src/flashx/textLayout/edit/TextFlowEdit.as
> @@ -241,7 +241,7 @@ package flashx.textLayout.edit
>                                 var scrapElement:FlowElement = scrapLeaf;               // highest level complete element in the scrap
>
>                                 // On the first paragraph, it always merges in to the destination paragraph if the destination paragraph has content
> -                               var destinationParagraph:ParagraphElement = destinationLeaf.getParagraph();
> +                               var destinationParagraph:ParagraphElement = destinationLeaf ? destinationLeaf.getParagraph() : destinationParagraph;
>                                 if (firstParagraph && (destinationParagraph.textLength > 1 || applyFormat))
>                                 {
>                                         var scrapParagraph:ParagraphElement = scrapLeaf.getParagraph();
> @@ -253,7 +253,7 @@ package flashx.textLayout.edit
>                                 {
>                                         if (applyFormat && firstParagraph)
>                                         {
> -                                               destinationElement = findLowestPossibleParent(destinationLeaf.parent, scrapElement);
> +                                               destinationElement = destinationLeaf ? findLowestPossibleParent(destinationLeaf.parent, scrapElement) : findLowestPossibleParent(destinationElement, scrapElement);
>                                                 var currentIndex:int = destinationElement.findChildIndexAtPosition(insertPosition - destinationElement.getAbsoluteStart());
>                                                 applyFormatToElement(destinationElement, currentIndex, scrapElement);
>                                         }
> @@ -265,7 +265,7 @@ package flashx.textLayout.edit
>
>                                 // Find the lowest level parent in the TextFlow that can accept the scrapElement as a child.
>                                 // If necessary, copy higher up the scrapElement hierarchy to find a match.
> -                               var destinationElement:FlowGroupElement = findLowestPossibleParent(destinationLeaf.parent, scrapElement);
> +                               var destinationElement:FlowGroupElement = destinationLeaf ? findLowestPossibleParent(destinationLeaf.parent, scrapElement) : findLowestPossibleParent(destinationElement, scrapElement);
>                                 while (!destinationElement)
>                                 {
>                                         // Nothing in the TextFlow element hierarchy can accept the incoming scrap element.
>

Re: git commit: [flex-tlf] [refs/heads/develop] - FLEX-34807

Posted by Mihai Chira <mi...@gmail.com>.
Cool, thanks for the explanation.

On 21 September 2015 at 11:57, Harbs <ha...@gmail.com> wrote:
> Yes. It’s a coding style I picked up quite some time ago. It assigns the value to itself if destinationLeaf is null.
>
> It avoids writing an extra “if” (and keeps everything in one line while keeping the declaration at the beginning of the line).
>
> It might be a bit confusing the first time you see it, but I think it’s pretty easy to read once you are familiar with the style.
>
> On Sep 21, 2015, at 12:46 PM, Mihai Chira <mi...@gmail.com> wrote:
>
>> Is this line only confusing for me? var
>> destinationParagraph:ParagraphElement = destinationLeaf ?
>> destinationLeaf.getParagraph() : destinationParagraph;
>>
>> Is this the intention? if (destinationLeaf) destinationParagraph =
>> destinationLeaf.getParagraph();
>

Re: git commit: [flex-tlf] [refs/heads/develop] - FLEX-34807

Posted by Harbs <ha...@gmail.com>.
Yes. It’s a coding style I picked up quite some time ago. It assigns the value to itself if destinationLeaf is null.

It avoids writing an extra “if” (and keeps everything in one line while keeping the declaration at the beginning of the line).

It might be a bit confusing the first time you see it, but I think it’s pretty easy to read once you are familiar with the style.

On Sep 21, 2015, at 12:46 PM, Mihai Chira <mi...@gmail.com> wrote:

> Is this line only confusing for me? var
> destinationParagraph:ParagraphElement = destinationLeaf ?
> destinationLeaf.getParagraph() : destinationParagraph;
> 
> Is this the intention? if (destinationLeaf) destinationParagraph =
> destinationLeaf.getParagraph();