Use correct layer default configuration

The default layer configuration is contained in the `OCProperties.D`
dictionary. Under certain circumstances, one of the configurations in
`Configs` should be used.

The code was looking for the first config entry with the `Intent` set
to `View` and also specifying the default value of `View`. This means
the first configuration entry that didn't have an `Intent` set was
used, which is wrong. The `Intent` is optional. By removing the default
value, we get the correct behavior.

The test checks that the correct layer configuration, `D`, is used by
making sure the correct image is rendered.

Bug: pdfium:1283

Change-Id: Icac852605e001151cec9cbefec17d06bf93f6e93
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/53370
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/AUTHORS b/AUTHORS
index bea47b2..8fe2b46 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -54,3 +54,4 @@
 LG Electronics, Inc. <*@lge.com>
 Loongson Technology Corporation Limited. <*@loongson.cn>
 Microsoft <*@microsoft.com>
+PSPDFKit GmbH <*@pspdfkit.com>
diff --git a/core/fpdfdoc/cpdf_occontext.cpp b/core/fpdfdoc/cpdf_occontext.cpp
index e80907c..8613bdd 100644
--- a/core/fpdfdoc/cpdf_occontext.cpp
+++ b/core/fpdfdoc/cpdf_occontext.cpp
@@ -65,7 +65,7 @@
 
   for (size_t i = 0; i < pConfigs->size(); i++) {
     CPDF_Dictionary* pFind = pConfigs->GetDictAt(i);
-    if (pFind && HasIntent(pFind, "View", "View"))
+    if (pFind && HasIntent(pFind, "View", ""))
       return pFind;
   }
   return pConfig;
diff --git a/testing/resources/pixel/bug_1283.in b/testing/resources/pixel/bug_1283.in
new file mode 100644
index 0000000..2120f86
--- /dev/null
+++ b/testing/resources/pixel/bug_1283.in
@@ -0,0 +1,64 @@
+{{header}}
+{{object 1 0}} <<
+  /Type /Catalog
+  /Pages 2 0 R
+  /OCProperties <<
+    /Configs <<
+        /Creator (First Config)
+        /Name (First Config)
+        /OFF [5 0 R]
+    >>
+    /D <<
+        /ON [5 0 R]
+        /Order [5 0 R]
+        /RBGroups []
+    >>
+    /OCGs [5 0 R]
+  >>
+>>
+endobj
+{{object 2 0}} <<
+  /Type /Pages
+  /Count 1
+  /Kids [3 0 R]
+>>
+endobj
+% Page number 0.
+{{object 3 0}} <<
+  /Type /Page
+  /Parent 2 0 R
+  /MediaBox [0 0 400 400]
+  /Contents [4 0 R]
+  /Resources << /XObject << /Fm0 6 0 R >> >>
+>>
+endobj
+% Page 0 contents stream
+{{object 4 0}} <<
+  {{streamlen}}
+>>
+stream
+1 0 0 1 50 50 cm /Fm0 Do
+endstream
+endobj
+{{object 5 0}} <<
+  /Type /OCG
+  /Name (Square)
+>>
+endobj
+% Fm0 XObject
+{{object 6 0}} <<
+  /Type /XObject
+  /Subtype /Form
+  /BBox [0 0 100 100]
+  /OC << /OCGs [5 0 R] /Type /OCMD >>
+>>
+stream
+0 G 0 g
+0 0 100 100 re
+b*
+endstream
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/pixel/bug_1283_expected.pdf.0.png b/testing/resources/pixel/bug_1283_expected.pdf.0.png
new file mode 100644
index 0000000..76369d6
--- /dev/null
+++ b/testing/resources/pixel/bug_1283_expected.pdf.0.png
Binary files differ