Closed Bug 1323138 Opened 8 years ago Closed 8 years ago

CSSEditUtil should use atom for css property if possible

Categories

(Core :: DOM: Editor, defect)

Unspecified
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla53
Tracking Status
firefox53 --- fixed

People

(Reporter: m_kato, Assigned: m_kato)

References

Details

Attachments

(1 file)

There is a lot of string compare and etc.  We should use nsGkAtom instead.
Comment on attachment 8818184 [details]
Bug 1323138 - CSSEditUtils should use atom for CSS property if possible.

https://reviewboard.mozilla.org/r/98310/#review98534

::: editor/libeditor/CSSEditUtils.cpp:342
(Diff revision 1)
>    if (nsGkAtoms::b == aProperty ||
>        nsGkAtoms::i == aProperty ||
>        nsGkAtoms::tt == aProperty ||
>        nsGkAtoms::u == aProperty ||
>        nsGkAtoms::strike == aProperty ||
>        (nsGkAtoms::font == aProperty && aAttribute &&

(Just random thoughts, though, like a method IsAnyOf(const nsIAtom* aAtom...) might be useful?)

::: editor/libeditor/CSSEditUtils.cpp:390
(Diff revision 1)
>      return true;
>    }
>  
>    // attributes TEXT, BACKGROUND and BGCOLOR on BODY
> -  if (aAttribute && node->IsHTMLElement(nsGkAtoms::body) &&
> -      (aAttribute->EqualsLiteral("text")
> +  if (node->IsHTMLElement(nsGkAtoms::body) &&
> +      (aAttribute == nsGkAtoms::text || aAttribute == nsGkAtoms::background ||

(Then, this could be more readable, but there must be a lot of similar cases, so, not scope of this bug.)

::: editor/libeditor/CSSEditUtils.cpp:946
(Diff revision 1)
> -  *aCount = cssPropertyArray.Length();
> -  for (int32_t index = 0; index < *aCount; index++) {
> +  int32_t count = cssPropertyArray.Length();
> +  for (int32_t index = 0; index < count; index++) {

Perhaps, you should use size_t for count and index here. (Although, not your fault.)

::: editor/libeditor/CSSEditUtils.cpp:979
(Diff revision 1)
>                                               nsIAtom* aHTMLProperty,
> -                                             const nsAString* aAttribute,
> +                                             nsIAtom* aAttribute,
>                                               const nsAString* aValue,
>                                               bool aSuppressTransaction)
>  {
> -  MOZ_ASSERT(aElement);
> +  if (!aElement) {

I wonder, shouldn't you use NS_WARN_IF() here?

::: editor/libeditor/CSSEditUtils.cpp:1160
(Diff revision 1)
>      } else if (nsGkAtoms::strike == aHTMLProperty) {
>        nsAutoString val;
>        val.AssignLiteral("line-through");
> -      aIsSet = ChangeStyleTransaction::ValueIncludes(valueString, val);
> -    } else if (aHTMLAttribute &&
> -               ((nsGkAtoms::font == aHTMLProperty &&
> +      isSet = ChangeStyleTransaction::ValueIncludes(valueString, val);
> +    } else if ((nsGkAtoms::font == aHTMLProperty &&
> +                 aHTMLAttribute == nsGkAtoms::color) ||

Looks like odd indent here.
Attachment #8818184 - Flags: review?(masayuki) → review+
Pushed by m_kato@ga2.so-net.ne.jp:
https://hg.mozilla.org/integration/mozilla-inbound/rev/fd40189cf066
CSSEditUtils should use atom for CSS property if possible. r=masayuki
https://hg.mozilla.org/mozilla-central/rev/fd40189cf066
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: