Bug 1574123 - Use nsLayoutUtils::GetMarkerFrame() more to avoid manual null-checks. r=emilio
authorMats Palmgren <mats@mozilla.com>
Thu, 15 Aug 2019 14:23:37 +0000
changeset 488240 5f30bde4179009fd405f8bd8c924b1f877874d42
parent 488239 04f03c56a77f2f5d2543937bb59d2bd6af136ae7
child 488241 d678d6d2ed75db28a32618b75b06bbb12e369df5
push id113904
push userncsoregi@mozilla.com
push dateThu, 15 Aug 2019 19:41:00 +0000
treeherdermozilla-inbound@b283a7ef186c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1574123, 1105868
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1574123 - Use nsLayoutUtils::GetMarkerFrame() more to avoid manual null-checks. r=emilio (This basically addresses the review comments that I missed in bug 1105868 part 4. My bad.) Differential Revision: https://phabricator.services.mozilla.com/D42134
accessible/html/HTMLListAccessible.cpp
layout/generic/nsContainerFrame.cpp
--- a/accessible/html/HTMLListAccessible.cpp
+++ b/accessible/html/HTMLListAccessible.cpp
@@ -33,18 +33,17 @@ uint64_t HTMLListAccessible::NativeState
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLLIAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 HTMLLIAccessible::HTMLLIAccessible(nsIContent* aContent, DocAccessible* aDoc)
     : HyperTextAccessibleWrap(aContent, aDoc), mBullet(nullptr) {
   mType = eHTMLLiType;
 
-  nsIContent* marker = nsLayoutUtils::GetMarkerPseudo(aContent);
-  if (marker && marker->GetPrimaryFrame()) {
+  if (nsLayoutUtils::GetMarkerFrame(aContent)) {
     mBullet = new HTMLListBulletAccessible(mContent, mDoc);
     Document()->BindToDocument(mBullet, nullptr);
     AppendChild(mBullet);
   }
 }
 
 void HTMLLIAccessible::Shutdown() {
   mBullet = nullptr;
@@ -114,18 +113,17 @@ HTMLListBulletAccessible::HTMLListBullet
   mGenericTypes |= eText;
   mStateFlags |= eSharedNode;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLListBulletAccessible: Accessible
 
 nsIFrame* HTMLListBulletAccessible::GetFrame() const {
-  nsIContent* marker = nsLayoutUtils::GetMarkerPseudo(mContent);
-  return marker ? marker->GetPrimaryFrame() : nullptr;
+  return nsLayoutUtils::GetMarkerFrame(mContent);
 }
 
 ENameValueFlag HTMLListBulletAccessible::Name(nsString& aName) const {
   aName.Truncate();
 
   // Native anonymous content, ARIA can't be used. Get list bullet text.
   if (nsContainerFrame* frame = do_QueryFrame(mContent->GetPrimaryFrame())) {
     frame->GetSpokenMarkerText(aName);
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -1727,35 +1727,29 @@ uint16_t nsContainerFrame::CSSAlignmentF
 
   // In the unexpected/unlikely event that this implementation gets invoked,
   // just use "start" alignment.
   return NS_STYLE_ALIGN_START;
 }
 
 #ifdef ACCESSIBILITY
 void nsContainerFrame::GetSpokenMarkerText(nsAString& aText) const {
+  aText.Truncate();
   const nsStyleList* myList = StyleList();
   if (myList->GetListStyleImage()) {
     char16_t kDiscCharacter = 0x2022;
     aText.Assign(kDiscCharacter);
     aText.Append(' ');
-  } else {
-    nsIContent* markerPseudo = nsLayoutUtils::GetMarkerPseudo(GetContent());
-    if (nsIFrame* marker = markerPseudo->GetPrimaryFrame()) {
-      if (nsBulletFrame* bullet = do_QueryFrame(marker)) {
-        bullet->GetSpokenText(aText);
-      } else {
-        ErrorResult err;
-        markerPseudo->GetTextContent(aText, err);
-        if (err.Failed()) {
-          aText.Truncate();
-        }
-      }
+    return;
+  }
+  if (nsIFrame* marker = nsLayoutUtils::GetMarkerFrame(GetContent())) {
+    if (nsBulletFrame* bullet = do_QueryFrame(marker)) {
+      bullet->GetSpokenText(aText);
     } else {
-      aText.Truncate();
+      marker->GetContent()->GetTextContent(aText, IgnoreErrors());
     }
   }
 }
 #endif
 
 nsOverflowContinuationTracker::nsOverflowContinuationTracker(
     nsContainerFrame* aFrame, bool aWalkOOFFrames,
     bool aSkipOverflowContainerChildren)