diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-05-09 14:22:11 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-05-09 15:11:45 +0000 |
commit | 2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c (patch) | |
tree | e75f511546c5fd1a173e87c1f9fb11d7ac8d1af3 /chromium/pdf | |
parent | a4f3d46271c57e8155ba912df46a05559d14726e (diff) | |
download | qtwebengine-chromium-2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c.tar.gz |
BASELINE: Update Chromium to 51.0.2704.41
Also adds in all smaller components by reversing logic for exclusion.
Change-Id: Ibf90b506e7da088ea2f65dcf23f2b0992c504422
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'chromium/pdf')
-rw-r--r-- | chromium/pdf/BUILD.gn | 5 | ||||
-rw-r--r-- | chromium/pdf/pdfium/fuzzers/BUILD.gn | 54 | ||||
-rw-r--r-- | chromium/pdf/pdfium/fuzzers/DEPS | 3 | ||||
-rw-r--r-- | chromium/pdf/pdfium/fuzzers/dicts/pdf.dict | 1466 | ||||
-rw-r--r-- | chromium/pdf/pdfium/fuzzers/dicts/pdf_fm2js.dict | 59 | ||||
-rw-r--r-- | chromium/pdf/pdfium/fuzzers/dicts/pdf_xml.dict | 88 | ||||
-rw-r--r-- | chromium/pdf/pdfium/fuzzers/pdfium_fuzzer.cc | 224 | ||||
-rw-r--r-- | chromium/pdf/pdfium/pdfium_assert_matching_enums.cc | 395 | ||||
-rw-r--r-- | chromium/pdf/pdfium/pdfium_engine.cc | 205 | ||||
-rw-r--r-- | chromium/pdf/pdfium/pdfium_page.cc | 267 | ||||
-rw-r--r-- | chromium/pdf/pdfium/pdfium_page.h | 6 | ||||
-rw-r--r-- | chromium/pdf/preview_mode_client.cc | 3 |
12 files changed, 2317 insertions, 458 deletions
diff --git a/chromium/pdf/BUILD.gn b/chromium/pdf/BUILD.gn index 5582fb01455..d683ab2464e 100644 --- a/chromium/pdf/BUILD.gn +++ b/chromium/pdf/BUILD.gn @@ -42,7 +42,10 @@ static_library("pdf") { configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] if (pdf_engine == 0) { - deps += [ "//third_party/pdfium" ] + deps += [ + "//pdf/pdfium/fuzzers", + "//third_party/pdfium", + ] sources += [ "pdfium/pdfium_api_string_buffer_adapter.cc", diff --git a/chromium/pdf/pdfium/fuzzers/BUILD.gn b/chromium/pdf/pdfium/fuzzers/BUILD.gn new file mode 100644 index 00000000000..fce0b8c4eac --- /dev/null +++ b/chromium/pdf/pdfium/fuzzers/BUILD.gn @@ -0,0 +1,54 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# PDFium fuzzers. + +import("//third_party/pdfium/pdfium.gni") +import("//testing/test.gni") +import("//testing/libfuzzer/fuzzer_test.gni") + +group("fuzzers") { +} + +fuzzer_test("pdfium_fuzzer") { + sources = [ + "pdfium_fuzzer.cc", + ] + deps = [ + "//third_party/pdfium", + "//third_party/pdfium:test_support", + "//v8", + "//v8:v8_libplatform", + ] + additional_configs = [ + "//third_party/pdfium:pdfium_config", + "//v8:external_startup_data", + ] + dict = "dicts/pdf.dict" +} + +fuzzer_test("pdf_jpx_fuzzer") { + sources = [] + deps = [ + "//third_party/pdfium/testing/libfuzzer:pdf_jpx_fuzzer", + ] +} + +if (pdf_enable_xfa) { + fuzzer_test("pdf_fm2js_fuzzer") { + sources = [] + deps = [ + "//third_party/pdfium/testing/libfuzzer:pdf_fm2js_fuzzer", + ] + dict = "dicts/pdf_fm2js.dict" + } + + fuzzer_test("pdf_xml_fuzzer") { + sources = [] + deps = [ + "//third_party/pdfium/testing/libfuzzer:pdf_xml_fuzzer", + ] + dict = "dicts/pdf_xml.dict" + } +} diff --git a/chromium/pdf/pdfium/fuzzers/DEPS b/chromium/pdf/pdfium/fuzzers/DEPS new file mode 100644 index 00000000000..ae5bd5b97c3 --- /dev/null +++ b/chromium/pdf/pdfium/fuzzers/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + "+third_party/pdfium/testing/test_support.h" +] diff --git a/chromium/pdf/pdfium/fuzzers/dicts/pdf.dict b/chromium/pdf/pdfium/fuzzers/dicts/pdf.dict new file mode 100644 index 00000000000..a6c48d59eaa --- /dev/null +++ b/chromium/pdf/pdfium/fuzzers/dicts/pdf.dict @@ -0,0 +1,1466 @@ +# +# AFL dictionary for PDF +# ---------------------- +# +# This is a pretty big PDF dictionary constructed by Ben by manually reviewing +# the spec and combining that with the data pulled out of a corpus of sample +# PDFs. +# +# Contributed by Ben Nagy <ben@iagu.net> +# + +"#" +"%" +"%%" +"%%EOF" +"%FDF-1.7" +"%PDF-1.7" +"(" +"(/xdp:xdp)" +"(\\001)" +"(config)" +"(datasets)" +"(template)" +"(xdp:xdp)" +")" +"-1" +"-1.0" +".." +"/" +"/#23clipboard" +"/.notdef" +"/1" +"/1.0" +"/1.3" +"/3D" +"/3DA" +"/3DAnimationStyle" +"/3DB" +"/3DD" +"/3DI" +"/3DLightingScheme" +"/3DRenderMode" +"/3DV" +"/3DView" +"/90pv-RKSJ-H" +"/A" +"/A0" +"/A85" +"/AA" +"/AAIC" +"/AAPL" +"/ABCDEF+ACaslonPro-Regular" +"/ABCDEF+AJensonPro-LtIt" +"/ABCDEF+AdobeCorpID-MinionRg" +"/ABCDEF+Arial,Bold" +"/ABCDEF+BankGothicMdBT" +"/ABCDEF+Bauhaus-Heavy" +"/ABCDEF+BluesClues" +"/ABCDEF+BodegaSans" +"/ABCDEF+BodoniMTCondensed" +"/ABCDEF+BookAntiqua" +"/ABCDEF+CMBX10" +"/ABCDEF+CaflischScriptPro-Regular" +"/ABCDEF+CityBlueprint" +"/ABCDEF+CourierNewPSMT" +"/ABCDEF+FixedsysExcelsior2.00" +"/ABCDEF+MSTT31854bd45bo188067S00" +"/ABCDEF+MinionPro-BoldCnIt" +"/ABCDEF+MyriadMM-It_400_300_" +"/ABCDEF+Wingdings" +"/ABCDEF+ZapfDingbats" +"/AC" +"/ADBE" +"/ADB_DEVICE_DEFAULT_STYLE" +"/ADB_DefaultStyle" +"/ADB_NO_TRAP_STYLE" +"/AE" +"/AESV2" +"/AGaramond" +"/AH" +"/AI8DstIndex" +"/AI8SrcIndex" +"/AIMetaData" +"/AIPDFPrivateData1" +"/AIS" +"/AL" +"/AN" +"/AP" +"/AS" +"/ASCII85Decode" +"/ASCIIHexDecode" +"/ASomewhatLongerName" +"/AU" +"/Aacute" +"/Acc.#20Prod.#202501#20#2F2#20#20" +"/Accounts#20payable" +"/AccurateScreens" +"/Acircumflex" +"/AcroForm" +"/Action" +"/Actual" +"/Add" +"/Adieresis" +"/Adobe" +"/Adobe#20PDF#20Library" +"/Adobe.PPKLite" +"/AdobeCorpID-Acrobat" +"/AdobeCorpID-MinionRg" +"/AdobePhotoshop" +"/Agrave" +"/All" +"/AllKO" +"/AllOn" +"/Alt" +"/Alternate" +"/AlternatePresentations" +"/Alternates" +"/Amex" +"/And" +"/Angle" +"/Annot" +"/Annots" +"/AntiAlias" +"/AnyOn" +"/Apag_PDFX_Checkup" +"/App" +"/Architecture-Normal" +"/Arial" +"/Aring" +"/Art" +"/ArtBox" +"/Article" +"/Artifact" +"/Artwork" +"/Ascent" +"/Aspect" +"/Assistant" +"/Atilde" +"/AuthEvent" +"/Author" +"/Avenir-Heavy" +"/Avenir-MediumOblique" +"/AvgWidth" +"/BBox" +"/BC" +"/BCL" +"/BDC" +"/BDL" +"/BE" +"/BFSOL" +"/BG" +"/BG2" +"/BM" +"/BMC" +"/BS" +"/BW" +"/Bank" +"/BaseEncoding" +"/BaseFont" +"/BaseState" +"/BaseVersion" +"/Birch" +"/BitsPerComponent" +"/BitsPerCoordinate" +"/BitsPerFlag" +"/BitsPerSample" +"/Bl" +"/BlCDel" +"/BlMiNu" +"/Black" +"/BlackIs1" +"/BlackOP" +"/BlackPoint" +"/BleedBox" +"/Blend" +"/Block" +"/Blue" +"/BluesClues" +"/Bookshelf" +"/Border" +"/Bounds" +"/BoxColorInfo" +"/Btn" +"/BulmerMT-BoldDisplay" +"/ByteRange" +"/C" +"/C0" +"/C0_0" +"/C1" +"/C2W" +"/C3" +"/CALS_AIS" +"/CALS_BM" +"/CALS_HT" +"/CALS_SMASK" +"/CALS_ca" +"/CAM" +"/CB" +"/CC" +"/CCH" +"/CCITTFaxDecode" +"/CD" +"/CDL" +"/CEN" +"/CF" +"/CFM" +"/CI" +"/CIDFontType0" +"/CIDFontType0C" +"/CIDFontType2" +"/CIDInit" +"/CIDSet" +"/CIDSystemInfo" +"/CIDToGIDMap" +"/CMV_LabBar" +"/CMV_LabControl" +"/CMYK" +"/CMYK#20#2880,#208,#2034,#200#29" +"/CMap" +"/CMapName" +"/CMapType" +"/CMapVersion" +"/CO" +"/CP" +"/CS" +"/CS0" +"/CT" +"/CV" +"/CalGray" +"/CalRGB" +"/CapHeight" +"/Caption" +"/Caslon540BT-Roman" +"/CaslonBT-Bold" +"/CaslonBT-BoldItalic" +"/Catalog" +"/Category" +"/Ccedilla" +"/CenturySchoolbookBT-Roman" +"/Ch" +"/Chair" +"/Chap" +"/Chaparral-Display" +"/CharProcs" +"/CharSet" +"/CheckSum" +"/Circle" +"/ClarendonBT-Black" +"/ClassMap" +"/Clearface-Black" +"/Clip" +"/ClippedText" +"/Cn" +"/Collection" +"/CollectionItem" +"/CollectionSchema" +"/CollectionSubitem" +"/Color" +"/ColorBurn" +"/ColorDodge" +"/ColorMatch" +"/ColorSpace" +"/ColorTransform" +"/ColorType" +"/Colorants" +"/Colors" +"/Columns" +"/ComicSansMS,Bold" +"/Comment" +"/Comments" +"/Company" +"/Compatibility" +"/Compatible" +"/Components" +"/CompressArt" +"/Condensed" +"/Configs" +"/Consultant" +"/ContainerVersion" +"/Contents" +"/Coords" +"/Copy" +"/Copy#20center" +"/Cor" +"/Corner#20surface" +"/CosineDot" +"/Count" +"/Cour" +"/Courier" +"/Create" +"/CreationDate" +"/Creator" +"/CreatorInfo" +"/CreatorVersion" +"/CropBox" +"/CropFixed" +"/CropRect" +"/Crypt" +"/CryptFilter" +"/CryptFilterDecodeParms" +"/Cs12" +"/Cs3" +"/Cyan" +"/D" +"/DA" +"/DCTDecode" +"/DIC#202525p*" +"/DIS" +"/DL" +"/DOS" +"/DP" +"/DR" +"/DS" +"/DSz" +"/DV" +"/DW" +"/DamagedRowsBeforeError" +"/Darken" +"/Data" +"/Date" +"/Decode" +"/DecodeParms" +"/DefEmbeddedFile" +"/Default" +"/DefaultCryptFilter" +"/DefaultForPrinting" +"/DefaultRGB" +"/Delete" +"/Delta" +"/DescendantFonts" +"/Descent" +"/Description" +"/Design" +"/Dest" +"/DestOutputProfile" +"/DestOutputProfileRef" +"/Dests" +"/DeviceCMYK" +"/DeviceGray" +"/DeviceN" +"/DeviceRGB" +"/Difference" +"/Differences" +"/DigestLocation" +"/DigestMethod" +"/DigestValue" +"/Dimmed" +"/Direction" +"/DisplayDocTitle" +"/Dissolve" +"/Div" +"/Dm" +"/DocMDP" +"/DocOpen" +"/Document" +"/Documents" +"/Domain" +"/Door" +"/DotGain" +"/Draw" +"/Dt" +"/Dur" +"/Dynamic#20connector" +"/E" +"/EF" +"/EFF" +"/EMC" +"/Eacute" +"/EarlyChange" +"/Ecircumflex" +"/Edieresis" +"/Editable" +"/Egrave" +"/EmbedFonts" +"/EmbedICCProfile" +"/Embedded" +"/EmbeddedFile" +"/EmbeddedFiles" +"/Encode" +"/EncodedByteAlign" +"/Encoding" +"/Encrypt" +"/EncryptMetadata" +"/EndIndent" +"/EndOfBlock" +"/EndOfLine" +"/Euro" +"/Euro.037" +"/Event" +"/ExData" +"/Exchange-Pro" +"/Exclude" +"/Exclusion" +"/Executive" +"/Export" +"/ExportCrispy" +"/ExportState" +"/ExtGState" +"/Extend" +"/Extends" +"/ExtensionLevel" +"/Extensions" +"/F1" +"/F1.0" +"/F12" +"/F13" +"/F3" +"/F5" +"/F6" +"/F7" +"/F8" +"/FB" +"/FD" +"/FDecodeParms" +"/FFilter" +"/FICL" +"/FM" +"/FOV" +"/FRM" +"/FS" +"/FT" +"/Facilities" +"/Fade" +"/False" +"/Feature" +"/FedEx#20Orange" +"/FedEx#20Purple" +"/Field" +"/Fields" +"/Figure" +"/File" +"/Files" +"/Filespec" +"/FillIn" +"/Filter" +"/First" +"/FirstChar" +"/FirstPage" +"/Fit" +"/FitB" +"/FitBH" +"/FitBV" +"/FitH" +"/FitR" +"/FitV" +"/FitWindow" +"/FixedPrint" +"/Flags" +"/FlateDecode" +"/Fm0" +"/Fm4" +"/Fo" +"/Focoltone#201047" +"/Font" +"/FontBBox" +"/FontDescriptor" +"/FontFamily" +"/FontFile" +"/FontFile2" +"/FontMatrix" +"/FontName" +"/FontStretch" +"/FontWeight" +"/Form" +"/FormEx" +"/FormType" +"/FreeText" +"/FreeTextCallout" +"/Frequency" +"/FullSave" +"/FullScreen" +"/Function" +"/FunctionType" +"/Functions" +"/Futura-Bold" +"/Futura-CondensedExtraBold" +"/G" +"/G02" +"/GLGR" +"/GS0" +"/GS1" +"/GS2" +"/GTS" +"/GTS_PDFA1" +"/GTS_PDFX" +"/GTS_PDFXConformance" +"/GTS_PDFXVersion" +"/GWG#20Green" +"/Gamma" +"/Garamond" +"/Georgia,Bold" +"/GoTo" +"/GoTo3DView" +"/GoToE" +"/GoToR" +"/Gold" +"/Goudy" +"/Gray" +"/Green" +"/GreymantleMVB" +"/GrotesqueMT" +"/Group" +"/H" +"/HDAG_Tools" +"/HKana" +"/HT" +"/HT2" +"/Halftone" +"/HalftoneName" +"/HalftoneType" +"/HardLight" +"/HeBo" +"/Head1" +"/Headlamp" +"/Height" +"/HeiseiMin" +"/Helv" +"/Helvetica" +"/Helvetica-Bold" +"/Helvetica-BoldOblique" +"/Helvetica-Condensed" +"/HelveticaNeue-Black" +"/Hide" +"/HonMincho-M" +"/Horizontal" +"/Hue" +"/I" +"/I0" +"/IC" +"/ICCBased" +"/ICCVersion" +"/ID" +"/IDS" +"/IDTree" +"/IEC" +"/IF" +"/IN" +"/ISO32000Registry" +"/ISO_PDFE1" +"/ISO_PDFEVersion" +"/IT" +"/ITO" +"/ITP" +"/IV" +"/IX" +"/Icircumflex" +"/Icon" +"/Identity" +"/Identity-H" +"/IgnEP" +"/Illustrator" +"/Illustrator8.0" +"/Im0" +"/Im1" +"/Im2" +"/Im3" +"/Im4" +"/Image" +"/Image1" +"/ImageB" +"/ImageC" +"/ImageI" +"/ImageMask" +"/ImageResources" +"/ImageType" +"/Import" +"/ImportData" +"/ImpressBT-Regular" +"/Index" +"/Indexed" +"/Info" +"/Information#20services" +"/Ink" +"/InkList" +"/InsertPages" +"/Insignia" +"/IntegerItem" +"/Intent" +"/Interpolate" +"/ItalicAngle" +"/ItcKabel-Ultra" +"/Item1" +"/Item2" +"/JBIG2Decode" +"/JBIG2Globals" +"/JPXDecode" +"/JS" +"/JT" +"/JTC" +"/JTF" +"/JTFile" +"/JTM" +"/JavaScript" +"/JobTicketContents" +"/Justify" +"/Keywords" +"/Kids" +"/L" +"/L1" +"/L1a" +"/L1b" +"/L2R" +"/L50188" +"/LBody" +"/LI" +"/LL" +"/LLE" +"/LLO" +"/LS" +"/LSP" +"/LZW" +"/LZWDecode" +"/Lab" +"/Lang" +"/Last" +"/LastChar" +"/LastItem" +"/LastModified" +"/Lateral#20file" +"/Launch" +"/Layout" +"/Lbl" +"/Leading" +"/Legal" +"/Length" +"/Length1" +"/Length2" +"/Length3" +"/LetterspaceFlags" +"/Lighten" +"/Limits" +"/Line" +"/LineDimension" +"/LineHeight" +"/Linear" +"/Linearized" +"/Link" +"/Locked" +"/LogoGreen" +"/LrTb" +"/Lslash" +"/Luminosity" +"/M" +"/MB" +"/MC" +"/MC0" +"/MCD" +"/MCID" +"/MCR" +"/MD5" +"/MH" +"/MIT" +"/MK" +"/MMType1" +"/MP" +"/MR" +"/MS" +"/MUX#20#2F#20DEMUX" +"/Mac" +"/MacRomanEncoding" +"/Magenta" +"/Manager" +"/MarkInfo" +"/Marked" +"/MarkedPDF" +"/Marker#20board" +"/Markup3D" +"/Mask" +"/Mastercard" +"/Matrix" +"/Max" +"/MaxLen" +"/MaxWidth" +"/Me" +"/Measure" +"/MediaBox" +"/MetaData" +"/Min" +"/MinionMM" +"/MissingWidth" +"/MixedContainer" +"/MixingHints" +"/ModDate" +"/Mode" +"/Modify" +"/Movie" +"/Msg" +"/MurrayHillBT-Bold" +"/MxGeom" +"/MxLaNu" +"/MxPts" +"/MyriadPro-Black" +"/NA" +"/NChannel" +"/ND" +"/NL" +"/NM" +"/NR" +"/Name" +"/Name1" +"/Named" +"/Names" +"/NeedsRendering" +"/NewCenturySchlbk-Italic" +"/NewWindow" +"/Next" +"/NextPage" +"/No" +"/NonEFontNoWarn" +"/NonStruct" +"/None" +"/Normal" +"/Not" +"/NotDefSpecial" +"/NumBlock" +"/Nums" +"/OB" +"/OBJR" +"/OC" +"/OC2" +"/OC3" +"/OC4" +"/OCG" +"/OCGs" +"/OCL" +"/OCMD" +"/OCProperties" +"/OE" +"/OFF" +"/OLN" +"/ON" +"/OOL" +"/OPBG" +"/OPBS" +"/OPI" +"/OPM" +"/OS" +"/OT" +"/Oacute" +"/Obj" +"/ObjStm" +"/Ocircumflex" +"/Odieresis" +"/Ograve" +"/Omega" +"/OneColumn" +"/Online" +"/Open" +"/OpenAction" +"/Operation" +"/Opt" +"/OptionSet" +"/Options" +"/Or" +"/Orange" +"/Order" +"/Ordering" +"/OriginalLayerName" +"/Oslash" +"/Otilde" +"/Outlines" +"/OutputCondition" +"/OutputConditionIdentifier" +"/OutputIntent" +"/OutputIntents" +"/Overlay" +"/P0" +"/P1" +"/P2" +"/P2,#2300ff007900000000,PANTONE#20151#20C" +"/PANTONE" +"/PANTONE#20158-5#20CVS" +"/PANTONE#20221#20CVU" +"/PANTONE#203405#20C" +"/PANTONE#20399#20CVC" +"/PANTONE#20Blue#20072#20C" +"/PANTONE#20Orange#20021#20C" +"/PANTONE#20Orange#20021#20CVC" +"/PANTONE#20Yellow#20C" +"/PC" +"/PDFDocEncoding" +"/PIX" +"/PO" +"/PS" +"/PUBLISHER" +"/PZ" +"/Pa0" +"/Page" +"/PageElement" +"/PageLabels" +"/PageLayout" +"/PageMode" +"/PageRange" +"/Pages" +"/PaintType" +"/Palatino,Bold" +"/Pale#20Brown.c" +"/Panose" +"/Paper#20tray" +"/Para" +"/Params" +"/Parent" +"/ParentTree" +"/ParentTreeNextKey" +"/Part" +"/Pattern" +"/PatternType" +"/PcZ" +"/Perceptual" +"/Perms" +"/Pg" +"/Pgf" +"/PieceInfo" +"/PitStop" +"/Placement" +"/Play" +"/Polygon" +"/PolygonCloud" +"/Popup" +"/Position" +"/PowerUpPDF" +"/PrOut" +"/PrRGBGra" +"/PrRGBIma" +"/Predictor" +"/PresSteps" +"/PreserveRB" +"/Prev" +"/PrevPage" +"/Preview" +"/Print" +"/PrintRecord" +"/PrintScaling" +"/PrintState" +"/PrintStyle" +"/Printed" +"/PrintingOrder" +"/Private" +"/ProcSet" +"/Process" +"/ProcessBlue" +"/ProcessGreen" +"/ProcessRed" +"/Producer" +"/ProfileCS" +"/ProfileName" +"/Prop_Build" +"/Properties" +"/Proportional" +"/PubSec" +"/Q" +"/QuadPoints" +"/R1" +"/RBGroups" +"/RC" +"/RD" +"/REC" +"/REx" +"/RF" +"/RGB" +"/RI" +"/RICMYKGra" +"/RICMYKIma" +"/RICalGra" +"/RICalIma" +"/RIDefault" +"/RIDevNGra" +"/RIDevNIma" +"/RIRGBGra" +"/RIRGBIma" +"/RL" +"/RM" +"/RV" +"/Range" +"/Rect" +"/Red" +"/Redact" +"/Ref" +"/Reference" +"/Registry" +"/RegistryName" +"/RelativeColorimetric" +"/Rendition" +"/Renditions" +"/Requirements" +"/ResetForm" +"/Resolution" +"/Resources" +"/ReversedChars" +"/RoleMap" +"/Root" +"/Rotate" +"/Round" +"/RoundTrip" +"/RoundtripVersion" +"/Router" +"/Rows" +"/RunLengthDecode" +"/Ryumin" +"/SA" +"/SBDraft" +"/SC" +"/SE" +"/SFSSL" +"/SFTWS" +"/SI" +"/SL" +"/SLA" +"/SM" +"/SMask" +"/SMaskInData" +"/SP" +"/SPS" +"/STL" +"/SU" +"/SW" +"/Saturation" +"/SaveAs" +"/SaveContents" +"/SaveResource" +"/SavedBy" +"/Scaron" +"/Schema" +"/Screen" +"/Sect" +"/SemiCondensed" +"/SemiExpanded" +"/Separation" +"/SeparationInfo" +"/SetOCGState" +"/SettingsFileName" +"/Sh0" +"/Sh1" +"/Shading" +"/ShadingType" +"/Shape" +"/Sig" +"/SigFlags" +"/SigRef" +"/Signature" +"/Signed" +"/SinglePage" +"/Size" +"/SlideShow" +"/SoftLight" +"/Solid" +"/Solidities" +"/SomeName" +"/Sort" +"/Sound" +"/Space" +"/SpaceAfter" +"/SpaceBefore" +"/Span" +"/SpawnTemplate" +"/SpdrArt" +"/SpiderInfo" +"/Split" +"/Spot" +"/Spot1" +"/Spot2" +"/SpotFunction" +"/SpotMap" +"/St" +"/Stamp" +"/StandardImageFileData" +"/Star" +"/Start" +"/StartIndent" +"/StartResource" +"/State" +"/StdCF" +"/StemH" +"/StemV" +"/Stm" +"/StmF" +"/Stop" +"/Story" +"/StrF" +"/StrikeOut" +"/StringItem" +"/StructElem" +"/StructParent" +"/StructParents" +"/StructTreeRoot" +"/Style" +"/SubFilter" +"/SubType" +"/Subdictionary" +"/Subform" +"/Subj" +"/Subject" +"/SubmitForm" +"/SubmitStandalone" +"/SubsetFontsBelow" +"/SubsetFontsRatio" +"/Supplement" +"/Swiss721BT-Black" +"/Switch" +"/T" +"/T1" +"/T1_0" +"/TB" +"/TC" +"/TCS" +"/TF" +"/TID" +"/TK" +"/TM" +"/TO" +"/TOC" +"/TOCI" +"/TOYO#200004pc" +"/TP" +"/TR" +"/TR2" +"/TRUMATCH#206-e" +"/TS" +"/TSV" +"/TT" +"/TT0" +"/TTRefMan" +"/TU" +"/TV" +"/TW" +"/TWS" +"/TWY" +"/Tabs" +"/TagSuspect" +"/TargetCS" +"/Technical" +"/Template" +"/TemplateInstantiated" +"/Templates" +"/Text" +"/TextAlign" +"/TextBox" +"/TextIndent" +"/The" +"/This" +"/Thorn" +"/Thread" +"/Threads" +"/Thumb" +"/Thumbnail" +"/Thumbs" +"/Ti" +"/TiBI" +"/TilingType" +"/Times-BoldItalic" +"/Times-Roman" +"/Title" +"/ToUnicode" +"/Toggle" +"/Trans" +"/TransferFunction" +"/TransformMethod" +"/TransformParams" +"/Transparency" +"/TrapInfo" +"/TrapMagicNumber" +"/TrapRegions" +"/TrapSet" +"/Trapped" +"/Trapping" +"/TrappingDetails" +"/TrappingParameters" +"/TrimBox" +"/True" +"/TrueType" +"/TrustedMode" +"/TwoColumnLeft" +"/Tx" +"/Type" +"/Type0" +"/U3D" +"/UA" +"/UCR" +"/UCR2" +"/UIDOffset" +"/UR" +"/UR3" +"/URI" +"/URL" +"/URLs" +"/Uacute" +"/Ucircumflex" +"/Udieresis" +"/Ugrave" +"/Univers-BoldExt" +"/Unix" +"/Unknown" +"/Usage" +"/UseAttachments" +"/UseNone" +"/UseOC" +"/UseOutlines" +"/UseThumbs" +"/UsedCMYK" +"/UserProperties" +"/UserUnit" +"/V2" +"/VA" +"/VE" +"/VP" +"/Verdana,Bold" +"/Version" +"/Vertical" +"/VeryLastItem" +"/View" +"/ViewerPreferences" +"/Visa" +"/Visible" +"/Volume" +"/W2" +"/WAI" +"/WAN" +"/WMode" +"/WP" +"/WarnockPro-BoldIt" +"/Watermark" +"/WebCapture" +"/Which" +"/WhiteBG" +"/WhitePoint" +"/Widget" +"/Width" +"/Widths" +"/Win" +"/WinAnsiEncoding" +"/Window" +"/Windows" +"/Work#20surface" +"/Workbook" +"/Worksheet" +"/WritingMode" +"/X" +"/X1" +"/XFA" +"/XHeight" +"/XML" +"/XN" +"/XObject" +"/XRef" +"/XRefStm" +"/XStep" +"/XUID" +"/XYZ" +"/Y" +"/YStep" +"/Yacute" +"/Ydieresis" +"/Yellow" +"/Z" +"/Z7KNXbN" +"/ZaDb" +"/ZapfDingbats" +"/Zcaron" +"/Zoom" +"/_No_paragraph_style_" +"/a1" +"/acute" +"/adbe.pkcs7.detached" +"/ampersand" +"/apple" +"/approxequal" +"/asciicircum" +"/asciitilde" +"/asterisk" +"/at" +"/audio#2Fmpeg" +"/b" +"/backslash" +"/bar" +"/blank" +"/braceleft" +"/braceright" +"/bracketleft" +"/bracketright" +"/breve" +"/brokenbar" +"/bullet" +"/c108" +"/cCompKind" +"/cCompQuality" +"/cCompression" +"/cRes" +"/cResolution" +"/ca" +"/caron" +"/cedilla" +"/cent" +"/circumflex" +"/colon" +"/comma" +"/copyright" +"/currency" +"/dagger" +"/daggerdbl" +"/degree" +"/deviceNumber" +"/dieresis" +"/divide" +"/dollar" +"/dotaccent" +"/dotlessi" +"/dotlessj" +"/eight" +"/ellipsis" +"/emdash" +"/endash" +"/equal" +"/eth" +"/exclam" +"/exclamdown" +"/f" +"/ff" +"/ffi" +"/ffl" +"/fi" +"/five" +"/fl" +"/florin" +"/four" +"/fraction" +"/gCompKind" +"/gCompQuality" +"/gCompression" +"/gRes" +"/gResolution" +"/germandbls" +"/go1" +"/grave" +"/greater" +"/greaterequal" +"/guillemotleft" +"/guillemotright" +"/guilsinglleft" +"/guilsinglright" +"/hungarumlaut" +"/hyphen" +"/iacute" +"/idieresis" +"/igrave" +"/infinity" +"/integral" +"/j" +"/k" +"/less" +"/lessequal" +"/logicalnot" +"/lozenge" +"/lt#20blue" +"/mCompKind" +"/mCompression" +"/mRes" +"/mResolution" +"/macron" +"/minus" +"/mu" +"/multiply" +"/n" +"/n0" +"/nine" +"/notequal" +"/ntilde" +"/numbersign" +"/o" +"/ogonek" +"/one" +"/onehalf" +"/onequarter" +"/onesuperior" +"/op" +"/ordfeminine" +"/ordmasculine" +"/p" +"/pageH" +"/pageV" +"/paragraph" +"/parenleft" +"/parenright" +"/partialdiff" +"/pdf" +"/pdfx" +"/percent" +"/period" +"/periodcentered" +"/perthousand" +"/pi" +"/plus" +"/plusminus" +"/pms#208400" +"/printX" +"/product" +"/question" +"/questiondown" +"/quotedbl" +"/quotedblbase" +"/quotedblleft" +"/quotedblright" +"/quoteleft" +"/quoteright" +"/quotesinglbase" +"/quotesingle" +"/r" +"/radical" +"/registered" +"/ring" +"/s" +"/s1" +"/sd1" +"/sd2" +"/section" +"/semicolon" +"/seven" +"/six" +"/slash" +"/sterling" +"/summation" +"/thinspace" +"/three" +"/threequarters" +"/threesuperior" +"/tilde" +"/trademark" +"/two" +"/twosuperior" +"/u" +"/underscore" +"/v" +"/w" +"/y1" +"/yen" +"/yes" +"/zero" +"0 R" +"1" +"1.0" +"<" +"<<" +">" +">>" +"Adobe.PPKLite" +"Adobe.PubSec" +"B*" +"BDC" +"BI" +"BMC" +"BT" +"BX" +"CS" +"DP" +"Do" +"EI" +"EMC" +"ET" +"EX" +"Entrust.PPKEF" +"ID" +"MP" +"R" +"T*" +"TJ" +"TL" +"Tc" +"Td" +"Tf" +"Tj" +"Tm" +"Tr" +"Ts" +"Tw" +"W*" +"[" +"[0.0 0.0 0.0 0.0 0.0 0.0]" +"[1 1 1]" +"[1.0 -1.0 1.0 -1.0]" +"[1.0 -1.0]" +"\\" +"]" +"abs" +"adbe.pkcs7.s3" +"adbe.pkcs7.s4" +"adbe.pkcs7.s5" +"add" +"and" +"atan" +"begin" +"beginarrangedfont" +"beginbfchar" +"begincidrange" +"begincmap" +"begincodespacerange" +"beginnotdefchar" +"beginnotdefrange" +"beginusematrix" +"bitshift" +"ceiling" +"cm" +"copy" +"cos" +"cvi" +"cvr" +"d0" +"d1" +"div" +"dup" +"end" +"endarrangedfont" +"endbfchar" +"endcidrange" +"endcmap" +"endcodespacerange" +"endnotdefchar" +"endnotdefrange" +"endobj" +"endstream" +"endusematrix" +"eq" +"exch" +"exp" +"f*" +"false" +"findresource" +"floor" +"ge" +"gs" +"gt" +"idiv" +"if" +"ifelse" +"index" +"le" +"ln" +"log" +"lt" +"mod" +"mul" +"ne" +"neg" +"not" +"null" +"obj" +"or" +"page" +"pop" +"re" +"rg" +"ri" +"roll" +"round" +"sin" +"sqrt" +"startxref" +"stream" +"sub" +"trailer" +"true" +"truncate" +"usecmap" +"usefont" +"xor" +"xref" +"{" +"}" diff --git a/chromium/pdf/pdfium/fuzzers/dicts/pdf_fm2js.dict b/chromium/pdf/pdfium/fuzzers/dicts/pdf_fm2js.dict new file mode 100644 index 00000000000..4ff62ffcfa2 --- /dev/null +++ b/chromium/pdf/pdfium/fuzzers/dicts/pdf_fm2js.dict @@ -0,0 +1,59 @@ +kw0="&" +kw1="(" +kw2=")" +kw3="*" +kw4="+" +kw5="," +kw6="-" +kw7="." +kw8="/" +kw9="<" +kw10="=" +kw11=">" +kw12="[" +kw13="]" +kw14="|" +kw15=".#" +kw16=".*" +kw17=".." +kw18="<=" +kw19="<>" +kw20="==" +kw21=">=" +kw22="do" +kw23="eq" +kw24="ge" +kw25="gt" +kw26="if" +kw27="in" +kw28="le" +kw29="lt" +kw30="ne" +kw31="or" +kw32="null" +kw33="break" +kw34="and" +kw35="end" +kw36="eof" +kw37="for" +kw38="nan" +kw39="not" +kw40="var" +kw41="then" +kw42="else" +kw43="exit" +kw44="downto" +kw45="return" +kw46="infinity" +kw47="endwhile" +kw48="foreach" +kw49="endfunc" +kw50="elseif" +kw51="while" +kw52="endfor" +kw53="throw" +kw54="step" +kw55="upto" +kw56="continue" +kw57="func" +kw58="endif" diff --git a/chromium/pdf/pdfium/fuzzers/dicts/pdf_xml.dict b/chromium/pdf/pdfium/fuzzers/dicts/pdf_xml.dict new file mode 100644 index 00000000000..ff44a2980e5 --- /dev/null +++ b/chromium/pdf/pdfium/fuzzers/dicts/pdf_xml.dict @@ -0,0 +1,88 @@ +# +# AFL dictionary for XML +# ---------------------- +# +# Several basic syntax elements and attributes, modeled on libxml2. +# +# Created by Michal Zalewski <lcamtuf@google.com> +# + +attr_encoding=" encoding=\"1\"" +attr_generic=" a=\"1\"" +attr_href=" href=\"1\"" +attr_standalone=" standalone=\"no\"" +attr_version=" version=\"1\"" +attr_xml_base=" xml:base=\"1\"" +attr_xml_id=" xml:id=\"1\"" +attr_xml_lang=" xml:lang=\"1\"" +attr_xml_space=" xml:space=\"1\"" +attr_xmlns=" xmlns=\"1\"" + +entity_builtin="<" +entity_decimal="" +entity_external="&a;" +entity_hex="" + +string_any="ANY" +string_brackets="[]" +string_cdata="CDATA" +string_col_fallback=":fallback" +string_col_generic=":a" +string_col_include=":include" +string_dashes="--" +string_empty="EMPTY" +string_empty_dblquotes="\"\"" +string_empty_quotes="''" +string_entities="ENTITIES" +string_entity="ENTITY" +string_fixed="#FIXED" +string_id="ID" +string_idref="IDREF" +string_idrefs="IDREFS" +string_implied="#IMPLIED" +string_nmtoken="NMTOKEN" +string_nmtokens="NMTOKENS" +string_notation="NOTATION" +string_parentheses="()" +string_pcdata="#PCDATA" +string_percent="%a" +string_public="PUBLIC" +string_required="#REQUIRED" +string_schema=":schema" +string_system="SYSTEM" +string_ucs4="UCS-4" +string_utf16="UTF-16" +string_utf8="UTF-8" +string_xmlns="xmlns:" + +tag_attlist="<!ATTLIST" +tag_cdata="<![CDATA[" +tag_close="</a>" +tag_doctype="<!DOCTYPE" +tag_element="<!ELEMENT" +tag_entity="<!ENTITY" +tag_ignore="<![IGNORE[" +tag_include="<![INCLUDE[" +tag_notation="<!NOTATION" +tag_open="<a>" +tag_open_close="<a />" +tag_open_exclamation="<!" +tag_open_q="<?" +tag_sq2_close="]]>" +tag_xml_q="<?xml?>" +"http://docboo" +"http://www.w" +"UTF-16LE" +"xmlns" +"he30" +"he2" +"IET" +"FDF-10" +"aDUCS-4OPveb:" +"a>" +"UT" +"xMl" +"/usr/share/sg" +"ha07" +"http://www.oa" +"cle" diff --git a/chromium/pdf/pdfium/fuzzers/pdfium_fuzzer.cc b/chromium/pdf/pdfium/fuzzers/pdfium_fuzzer.cc new file mode 100644 index 00000000000..2bb17c2f470 --- /dev/null +++ b/chromium/pdf/pdfium/fuzzers/pdfium_fuzzer.cc @@ -0,0 +1,224 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This fuzzer is simplified & cleaned up pdfium/samples/pdfium_test.cc + +#include <assert.h> +#include <limits.h> +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#ifdef _MSC_VER +#include <Windows.h> +#else +#include <unistd.h> +#endif + +#include <list> +#include <sstream> +#include <string> +#include <utility> +#include <vector> + +#include "third_party/pdfium/public/fpdf_dataavail.h" +#include "third_party/pdfium/public/fpdf_ext.h" +#include "third_party/pdfium/public/fpdf_formfill.h" +#include "third_party/pdfium/public/fpdf_text.h" +#include "third_party/pdfium/public/fpdfview.h" +#include "third_party/pdfium/testing/test_support.h" + +#include "v8/include/v8.h" + +static int ExampleAppAlert(IPDF_JSPLATFORM*, + FPDF_WIDESTRING, + FPDF_WIDESTRING, + int, + int) { + return 0; +} + +static void ExampleDocGotoPage(IPDF_JSPLATFORM*, int pageNumber) {} + +static void ExampleUnsupportedHandler(UNSUPPORT_INFO*, int type) {} + +FPDF_BOOL Is_Data_Avail(FX_FILEAVAIL* pThis, size_t offset, size_t size) { + return true; +} + +static void Add_Segment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) {} + +static bool RenderPage(const FPDF_DOCUMENT& doc, + const FPDF_FORMHANDLE& form, + const int page_index) { + FPDF_PAGE page = FPDF_LoadPage(doc, page_index); + if (!page) { + return false; + } + FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page); + FORM_OnAfterLoadPage(page, form); + FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN); + + double scale = 1.0; + int width = static_cast<int>(FPDF_GetPageWidth(page) * scale); + int height = static_cast<int>(FPDF_GetPageHeight(page) * scale); + + FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0); + if (!bitmap) { + return false; + } + + FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); + FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); + + FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0); + + FPDFBitmap_Destroy(bitmap); + FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_CLOSE); + FORM_OnBeforeClosePage(page, form); + FPDFText_ClosePage(text_page); + FPDF_ClosePage(page); + return true; +} + +static void RenderPdf(const char* pBuf, size_t len) { + IPDF_JSPLATFORM platform_callbacks; + memset(&platform_callbacks, '\0', sizeof(platform_callbacks)); + platform_callbacks.version = 3; + platform_callbacks.app_alert = ExampleAppAlert; + platform_callbacks.Doc_gotoPage = ExampleDocGotoPage; + + FPDF_FORMFILLINFO form_callbacks; + memset(&form_callbacks, '\0', sizeof(form_callbacks)); + form_callbacks.version = 1; + form_callbacks.m_pJsPlatform = &platform_callbacks; + + TestLoader loader(pBuf, len); + FPDF_FILEACCESS file_access; + memset(&file_access, '\0', sizeof(file_access)); + file_access.m_FileLen = static_cast<unsigned long>(len); + file_access.m_GetBlock = TestLoader::GetBlock; + file_access.m_Param = &loader; + + FX_FILEAVAIL file_avail; + memset(&file_avail, '\0', sizeof(file_avail)); + file_avail.version = 1; + file_avail.IsDataAvail = Is_Data_Avail; + + FX_DOWNLOADHINTS hints; + memset(&hints, '\0', sizeof(hints)); + hints.version = 1; + hints.AddSegment = Add_Segment; + + FPDF_DOCUMENT doc; + int nRet = PDF_DATA_NOTAVAIL; + bool bIsLinearized = false; + FPDF_AVAIL pdf_avail = FPDFAvail_Create(&file_avail, &file_access); + + if (FPDFAvail_IsLinearized(pdf_avail) == PDF_LINEARIZED) { + doc = FPDFAvail_GetDocument(pdf_avail, nullptr); + if (doc) { + while (nRet == PDF_DATA_NOTAVAIL) { + nRet = FPDFAvail_IsDocAvail(pdf_avail, &hints); + } + if (nRet == PDF_DATA_ERROR) { + return; + } + nRet = FPDFAvail_IsFormAvail(pdf_avail, &hints); + if (nRet == PDF_FORM_ERROR || nRet == PDF_FORM_NOTAVAIL) { + return; + } + bIsLinearized = true; + } + } else { + doc = FPDF_LoadCustomDocument(&file_access, nullptr); + } + + if (!doc) { + FPDFAvail_Destroy(pdf_avail); + return; + } + + (void)FPDF_GetDocPermissions(doc); + + FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks); + FPDF_SetFormFieldHighlightColor(form, 0, 0xFFE4DD); + FPDF_SetFormFieldHighlightAlpha(form, 100); + + FORM_DoDocumentJSAction(form); + FORM_DoDocumentOpenAction(form); + + int page_count = FPDF_GetPageCount(doc); + + for (int i = 0; i < page_count; ++i) { + if (bIsLinearized) { + nRet = PDF_DATA_NOTAVAIL; + while (nRet == PDF_DATA_NOTAVAIL) { + nRet = FPDFAvail_IsPageAvail(pdf_avail, i, &hints); + } + if (nRet == PDF_DATA_ERROR) { + return; + } + } + RenderPage(doc, form, i); + } + + FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC); + FPDFDOC_ExitFormFillEnvironment(form); + FPDF_CloseDocument(doc); + FPDFAvail_Destroy(pdf_avail); +} + +std::string ProgramPath() { +#ifdef _MSC_VER + wchar_t wpath[MAX_PATH]; + char path[MAX_PATH]; + DWORD res = GetModuleFileName(NULL, wpath, MAX_PATH); + assert(res != 0); + wcstombs(path, wpath, MAX_PATH); + return std::string(path, res); +#else + char* path = new char[PATH_MAX + 1]; + assert(path); + ssize_t sz = readlink("/proc/self/exe", path, PATH_MAX); + assert(sz > 0); + std::string result(path, sz); + delete[] path; + return result; +#endif +} + +struct TestCase { + TestCase() { + InitializeV8ForPDFium(ProgramPath(), "", &natives_blob, &snapshot_blob, + &platform); + + memset(&config, '\0', sizeof(config)); + config.version = 2; + config.m_pUserFontPaths = nullptr; + config.m_pIsolate = nullptr; + config.m_v8EmbedderSlot = 0; + FPDF_InitLibraryWithConfig(&config); + + memset(&unsupport_info, '\0', sizeof(unsupport_info)); + unsupport_info.version = 1; + unsupport_info.FSDK_UnSupport_Handler = ExampleUnsupportedHandler; + FSDK_SetUnSpObjProcessHandler(&unsupport_info); + } + + v8::Platform* platform; + v8::StartupData natives_blob; + v8::StartupData snapshot_blob; + FPDF_LIBRARY_CONFIG config; + UNSUPPORT_INFO unsupport_info; +}; + +static TestCase* testCase = new TestCase(); + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + RenderPdf(reinterpret_cast<const char*>(data), size); + return 0; +} diff --git a/chromium/pdf/pdfium/pdfium_assert_matching_enums.cc b/chromium/pdf/pdfium/pdfium_assert_matching_enums.cc index 2dcba5418ef..b173a32caba 100644 --- a/chromium/pdf/pdfium/pdfium_assert_matching_enums.cc +++ b/chromium/pdf/pdfium/pdfium_assert_matching_enums.cc @@ -9,205 +9,204 @@ #include "third_party/pdfium/public/fpdf_sysfontinfo.h" #include "ui/events/keycodes/keyboard_codes.h" -#define STATIC_ASSERT_MATCH(np_name, pdfium_name) \ - static_assert(int(np_name) == int(pdfium_name), \ - "mismatching enums: " #np_name) +#define STATIC_ASSERT_ENUM(a, b) \ + static_assert(static_cast<int>(a) == static_cast<int>(b), \ + "mismatching enums: " #a) -STATIC_ASSERT_MATCH(PP_INPUTEVENT_MODIFIER_SHIFTKEY, FWL_EVENTFLAG_ShiftKey); -STATIC_ASSERT_MATCH(PP_INPUTEVENT_MODIFIER_CONTROLKEY, - FWL_EVENTFLAG_ControlKey); -STATIC_ASSERT_MATCH(PP_INPUTEVENT_MODIFIER_ALTKEY, FWL_EVENTFLAG_AltKey); -STATIC_ASSERT_MATCH(PP_INPUTEVENT_MODIFIER_METAKEY, FWL_EVENTFLAG_MetaKey); -STATIC_ASSERT_MATCH(PP_INPUTEVENT_MODIFIER_ISKEYPAD, FWL_EVENTFLAG_KeyPad); -STATIC_ASSERT_MATCH(PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT, - FWL_EVENTFLAG_AutoRepeat); -STATIC_ASSERT_MATCH(PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN, - FWL_EVENTFLAG_LeftButtonDown); -STATIC_ASSERT_MATCH(PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN, - FWL_EVENTFLAG_MiddleButtonDown); -STATIC_ASSERT_MATCH(PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN, - FWL_EVENTFLAG_RightButtonDown); +STATIC_ASSERT_ENUM(PP_INPUTEVENT_MODIFIER_SHIFTKEY, FWL_EVENTFLAG_ShiftKey); +STATIC_ASSERT_ENUM(PP_INPUTEVENT_MODIFIER_CONTROLKEY, FWL_EVENTFLAG_ControlKey); +STATIC_ASSERT_ENUM(PP_INPUTEVENT_MODIFIER_ALTKEY, FWL_EVENTFLAG_AltKey); +STATIC_ASSERT_ENUM(PP_INPUTEVENT_MODIFIER_METAKEY, FWL_EVENTFLAG_MetaKey); +STATIC_ASSERT_ENUM(PP_INPUTEVENT_MODIFIER_ISKEYPAD, FWL_EVENTFLAG_KeyPad); +STATIC_ASSERT_ENUM(PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT, + FWL_EVENTFLAG_AutoRepeat); +STATIC_ASSERT_ENUM(PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN, + FWL_EVENTFLAG_LeftButtonDown); +STATIC_ASSERT_ENUM(PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN, + FWL_EVENTFLAG_MiddleButtonDown); +STATIC_ASSERT_ENUM(PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN, + FWL_EVENTFLAG_RightButtonDown); -STATIC_ASSERT_MATCH(ui::VKEY_BACK, FWL_VKEY_Back); -STATIC_ASSERT_MATCH(ui::VKEY_TAB, FWL_VKEY_Tab); -STATIC_ASSERT_MATCH(ui::VKEY_CLEAR, FWL_VKEY_Clear); -STATIC_ASSERT_MATCH(ui::VKEY_RETURN, FWL_VKEY_Return); -STATIC_ASSERT_MATCH(ui::VKEY_SHIFT, FWL_VKEY_Shift); -STATIC_ASSERT_MATCH(ui::VKEY_CONTROL, FWL_VKEY_Control); -STATIC_ASSERT_MATCH(ui::VKEY_MENU, FWL_VKEY_Menu); -STATIC_ASSERT_MATCH(ui::VKEY_PAUSE, FWL_VKEY_Pause); -STATIC_ASSERT_MATCH(ui::VKEY_CAPITAL, FWL_VKEY_Capital); -STATIC_ASSERT_MATCH(ui::VKEY_KANA, FWL_VKEY_Kana); -STATIC_ASSERT_MATCH(ui::VKEY_HANGUL, FWL_VKEY_Hangul); -STATIC_ASSERT_MATCH(ui::VKEY_JUNJA, FWL_VKEY_Junja); -STATIC_ASSERT_MATCH(ui::VKEY_FINAL, FWL_VKEY_Final); -STATIC_ASSERT_MATCH(ui::VKEY_HANJA, FWL_VKEY_Hanja); -STATIC_ASSERT_MATCH(ui::VKEY_KANJI, FWL_VKEY_Kanji); -STATIC_ASSERT_MATCH(ui::VKEY_ESCAPE, FWL_VKEY_Escape); -STATIC_ASSERT_MATCH(ui::VKEY_CONVERT, FWL_VKEY_Convert); -STATIC_ASSERT_MATCH(ui::VKEY_NONCONVERT, FWL_VKEY_NonConvert); -STATIC_ASSERT_MATCH(ui::VKEY_ACCEPT, FWL_VKEY_Accept); -STATIC_ASSERT_MATCH(ui::VKEY_MODECHANGE, FWL_VKEY_ModeChange); -STATIC_ASSERT_MATCH(ui::VKEY_SPACE, FWL_VKEY_Space); -STATIC_ASSERT_MATCH(ui::VKEY_PRIOR, FWL_VKEY_Prior); -STATIC_ASSERT_MATCH(ui::VKEY_NEXT, FWL_VKEY_Next); -STATIC_ASSERT_MATCH(ui::VKEY_END, FWL_VKEY_End); -STATIC_ASSERT_MATCH(ui::VKEY_HOME, FWL_VKEY_Home); -STATIC_ASSERT_MATCH(ui::VKEY_LEFT, FWL_VKEY_Left); -STATIC_ASSERT_MATCH(ui::VKEY_UP, FWL_VKEY_Up); -STATIC_ASSERT_MATCH(ui::VKEY_RIGHT, FWL_VKEY_Right); -STATIC_ASSERT_MATCH(ui::VKEY_DOWN, FWL_VKEY_Down); -STATIC_ASSERT_MATCH(ui::VKEY_SELECT, FWL_VKEY_Select); -STATIC_ASSERT_MATCH(ui::VKEY_PRINT, FWL_VKEY_Print); -STATIC_ASSERT_MATCH(ui::VKEY_EXECUTE, FWL_VKEY_Execute); -STATIC_ASSERT_MATCH(ui::VKEY_SNAPSHOT, FWL_VKEY_Snapshot); -STATIC_ASSERT_MATCH(ui::VKEY_INSERT, FWL_VKEY_Insert); -STATIC_ASSERT_MATCH(ui::VKEY_DELETE, FWL_VKEY_Delete); -STATIC_ASSERT_MATCH(ui::VKEY_HELP, FWL_VKEY_Help); -STATIC_ASSERT_MATCH(ui::VKEY_0, FWL_VKEY_0); -STATIC_ASSERT_MATCH(ui::VKEY_1, FWL_VKEY_1); -STATIC_ASSERT_MATCH(ui::VKEY_2, FWL_VKEY_2); -STATIC_ASSERT_MATCH(ui::VKEY_3, FWL_VKEY_3); -STATIC_ASSERT_MATCH(ui::VKEY_4, FWL_VKEY_4); -STATIC_ASSERT_MATCH(ui::VKEY_5, FWL_VKEY_5); -STATIC_ASSERT_MATCH(ui::VKEY_6, FWL_VKEY_6); -STATIC_ASSERT_MATCH(ui::VKEY_7, FWL_VKEY_7); -STATIC_ASSERT_MATCH(ui::VKEY_8, FWL_VKEY_8); -STATIC_ASSERT_MATCH(ui::VKEY_9, FWL_VKEY_9); -STATIC_ASSERT_MATCH(ui::VKEY_A, FWL_VKEY_A); -STATIC_ASSERT_MATCH(ui::VKEY_B, FWL_VKEY_B); -STATIC_ASSERT_MATCH(ui::VKEY_C, FWL_VKEY_C); -STATIC_ASSERT_MATCH(ui::VKEY_D, FWL_VKEY_D); -STATIC_ASSERT_MATCH(ui::VKEY_E, FWL_VKEY_E); -STATIC_ASSERT_MATCH(ui::VKEY_F, FWL_VKEY_F); -STATIC_ASSERT_MATCH(ui::VKEY_G, FWL_VKEY_G); -STATIC_ASSERT_MATCH(ui::VKEY_H, FWL_VKEY_H); -STATIC_ASSERT_MATCH(ui::VKEY_I, FWL_VKEY_I); -STATIC_ASSERT_MATCH(ui::VKEY_J, FWL_VKEY_J); -STATIC_ASSERT_MATCH(ui::VKEY_K, FWL_VKEY_K); -STATIC_ASSERT_MATCH(ui::VKEY_L, FWL_VKEY_L); -STATIC_ASSERT_MATCH(ui::VKEY_M, FWL_VKEY_M); -STATIC_ASSERT_MATCH(ui::VKEY_N, FWL_VKEY_N); -STATIC_ASSERT_MATCH(ui::VKEY_O, FWL_VKEY_O); -STATIC_ASSERT_MATCH(ui::VKEY_P, FWL_VKEY_P); -STATIC_ASSERT_MATCH(ui::VKEY_Q, FWL_VKEY_Q); -STATIC_ASSERT_MATCH(ui::VKEY_R, FWL_VKEY_R); -STATIC_ASSERT_MATCH(ui::VKEY_S, FWL_VKEY_S); -STATIC_ASSERT_MATCH(ui::VKEY_T, FWL_VKEY_T); -STATIC_ASSERT_MATCH(ui::VKEY_U, FWL_VKEY_U); -STATIC_ASSERT_MATCH(ui::VKEY_V, FWL_VKEY_V); -STATIC_ASSERT_MATCH(ui::VKEY_W, FWL_VKEY_W); -STATIC_ASSERT_MATCH(ui::VKEY_X, FWL_VKEY_X); -STATIC_ASSERT_MATCH(ui::VKEY_Y, FWL_VKEY_Y); -STATIC_ASSERT_MATCH(ui::VKEY_Z, FWL_VKEY_Z); -STATIC_ASSERT_MATCH(ui::VKEY_LWIN, FWL_VKEY_LWin); -STATIC_ASSERT_MATCH(ui::VKEY_COMMAND, FWL_VKEY_Command); -STATIC_ASSERT_MATCH(ui::VKEY_RWIN, FWL_VKEY_RWin); -STATIC_ASSERT_MATCH(ui::VKEY_APPS, FWL_VKEY_Apps); -STATIC_ASSERT_MATCH(ui::VKEY_SLEEP, FWL_VKEY_Sleep); -STATIC_ASSERT_MATCH(ui::VKEY_NUMPAD0, FWL_VKEY_NumPad0); -STATIC_ASSERT_MATCH(ui::VKEY_NUMPAD1, FWL_VKEY_NumPad1); -STATIC_ASSERT_MATCH(ui::VKEY_NUMPAD2, FWL_VKEY_NumPad2); -STATIC_ASSERT_MATCH(ui::VKEY_NUMPAD3, FWL_VKEY_NumPad3); -STATIC_ASSERT_MATCH(ui::VKEY_NUMPAD4, FWL_VKEY_NumPad4); -STATIC_ASSERT_MATCH(ui::VKEY_NUMPAD5, FWL_VKEY_NumPad5); -STATIC_ASSERT_MATCH(ui::VKEY_NUMPAD6, FWL_VKEY_NumPad6); -STATIC_ASSERT_MATCH(ui::VKEY_NUMPAD7, FWL_VKEY_NumPad7); -STATIC_ASSERT_MATCH(ui::VKEY_NUMPAD8, FWL_VKEY_NumPad8); -STATIC_ASSERT_MATCH(ui::VKEY_NUMPAD9, FWL_VKEY_NumPad9); -STATIC_ASSERT_MATCH(ui::VKEY_MULTIPLY, FWL_VKEY_Multiply); -STATIC_ASSERT_MATCH(ui::VKEY_ADD, FWL_VKEY_Add); -STATIC_ASSERT_MATCH(ui::VKEY_SEPARATOR, FWL_VKEY_Separator); -STATIC_ASSERT_MATCH(ui::VKEY_SUBTRACT, FWL_VKEY_Subtract); -STATIC_ASSERT_MATCH(ui::VKEY_DECIMAL, FWL_VKEY_Decimal); -STATIC_ASSERT_MATCH(ui::VKEY_DIVIDE, FWL_VKEY_Divide); -STATIC_ASSERT_MATCH(ui::VKEY_F1, FWL_VKEY_F1); -STATIC_ASSERT_MATCH(ui::VKEY_F2, FWL_VKEY_F2); -STATIC_ASSERT_MATCH(ui::VKEY_F3, FWL_VKEY_F3); -STATIC_ASSERT_MATCH(ui::VKEY_F4, FWL_VKEY_F4); -STATIC_ASSERT_MATCH(ui::VKEY_F5, FWL_VKEY_F5); -STATIC_ASSERT_MATCH(ui::VKEY_F6, FWL_VKEY_F6); -STATIC_ASSERT_MATCH(ui::VKEY_F7, FWL_VKEY_F7); -STATIC_ASSERT_MATCH(ui::VKEY_F8, FWL_VKEY_F8); -STATIC_ASSERT_MATCH(ui::VKEY_F9, FWL_VKEY_F9); -STATIC_ASSERT_MATCH(ui::VKEY_F10, FWL_VKEY_F10); -STATIC_ASSERT_MATCH(ui::VKEY_F11, FWL_VKEY_F11); -STATIC_ASSERT_MATCH(ui::VKEY_F12, FWL_VKEY_F12); -STATIC_ASSERT_MATCH(ui::VKEY_F13, FWL_VKEY_F13); -STATIC_ASSERT_MATCH(ui::VKEY_F14, FWL_VKEY_F14); -STATIC_ASSERT_MATCH(ui::VKEY_F15, FWL_VKEY_F15); -STATIC_ASSERT_MATCH(ui::VKEY_F16, FWL_VKEY_F16); -STATIC_ASSERT_MATCH(ui::VKEY_F17, FWL_VKEY_F17); -STATIC_ASSERT_MATCH(ui::VKEY_F18, FWL_VKEY_F18); -STATIC_ASSERT_MATCH(ui::VKEY_F19, FWL_VKEY_F19); -STATIC_ASSERT_MATCH(ui::VKEY_F20, FWL_VKEY_F20); -STATIC_ASSERT_MATCH(ui::VKEY_F21, FWL_VKEY_F21); -STATIC_ASSERT_MATCH(ui::VKEY_F22, FWL_VKEY_F22); -STATIC_ASSERT_MATCH(ui::VKEY_F23, FWL_VKEY_F23); -STATIC_ASSERT_MATCH(ui::VKEY_F24, FWL_VKEY_F24); -STATIC_ASSERT_MATCH(ui::VKEY_NUMLOCK, FWL_VKEY_NunLock); -STATIC_ASSERT_MATCH(ui::VKEY_SCROLL, FWL_VKEY_Scroll); -STATIC_ASSERT_MATCH(ui::VKEY_LSHIFT, FWL_VKEY_LShift); -STATIC_ASSERT_MATCH(ui::VKEY_RSHIFT, FWL_VKEY_RShift); -STATIC_ASSERT_MATCH(ui::VKEY_LCONTROL, FWL_VKEY_LControl); -STATIC_ASSERT_MATCH(ui::VKEY_RCONTROL, FWL_VKEY_RControl); -STATIC_ASSERT_MATCH(ui::VKEY_LMENU, FWL_VKEY_LMenu); -STATIC_ASSERT_MATCH(ui::VKEY_RMENU, FWL_VKEY_RMenu); -STATIC_ASSERT_MATCH(ui::VKEY_BROWSER_BACK, FWL_VKEY_BROWSER_Back); -STATIC_ASSERT_MATCH(ui::VKEY_BROWSER_FORWARD, FWL_VKEY_BROWSER_Forward); -STATIC_ASSERT_MATCH(ui::VKEY_BROWSER_REFRESH, FWL_VKEY_BROWSER_Refresh); -STATIC_ASSERT_MATCH(ui::VKEY_BROWSER_STOP, FWL_VKEY_BROWSER_Stop); -STATIC_ASSERT_MATCH(ui::VKEY_BROWSER_SEARCH, FWL_VKEY_BROWSER_Search); -STATIC_ASSERT_MATCH(ui::VKEY_BROWSER_FAVORITES, FWL_VKEY_BROWSER_Favorites); -STATIC_ASSERT_MATCH(ui::VKEY_BROWSER_HOME, FWL_VKEY_BROWSER_Home); -STATIC_ASSERT_MATCH(ui::VKEY_VOLUME_MUTE, FWL_VKEY_VOLUME_Mute); -STATIC_ASSERT_MATCH(ui::VKEY_VOLUME_DOWN, FWL_VKEY_VOLUME_Down); -STATIC_ASSERT_MATCH(ui::VKEY_VOLUME_UP, FWL_VKEY_VOLUME_Up); -STATIC_ASSERT_MATCH(ui::VKEY_MEDIA_NEXT_TRACK, FWL_VKEY_MEDIA_NEXT_Track); -STATIC_ASSERT_MATCH(ui::VKEY_MEDIA_PREV_TRACK, FWL_VKEY_MEDIA_PREV_Track); -STATIC_ASSERT_MATCH(ui::VKEY_MEDIA_STOP, FWL_VKEY_MEDIA_Stop); -STATIC_ASSERT_MATCH(ui::VKEY_MEDIA_PLAY_PAUSE, FWL_VKEY_MEDIA_PLAY_Pause); -STATIC_ASSERT_MATCH(ui::VKEY_MEDIA_LAUNCH_MAIL, FWL_VKEY_MEDIA_LAUNCH_Mail); -STATIC_ASSERT_MATCH(ui::VKEY_MEDIA_LAUNCH_MEDIA_SELECT, - FWL_VKEY_MEDIA_LAUNCH_MEDIA_Select); -STATIC_ASSERT_MATCH(ui::VKEY_MEDIA_LAUNCH_APP1, FWL_VKEY_MEDIA_LAUNCH_APP1); -STATIC_ASSERT_MATCH(ui::VKEY_MEDIA_LAUNCH_APP2, FWL_VKEY_MEDIA_LAUNCH_APP2); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_1, FWL_VKEY_OEM_1); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_PLUS, FWL_VKEY_OEM_Plus); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_COMMA, FWL_VKEY_OEM_Comma); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_MINUS, FWL_VKEY_OEM_Minus); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_PERIOD, FWL_VKEY_OEM_Period); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_2, FWL_VKEY_OEM_2); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_3, FWL_VKEY_OEM_3); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_4, FWL_VKEY_OEM_4); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_5, FWL_VKEY_OEM_5); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_6, FWL_VKEY_OEM_6); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_7, FWL_VKEY_OEM_7); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_8, FWL_VKEY_OEM_8); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_102, FWL_VKEY_OEM_102); -STATIC_ASSERT_MATCH(ui::VKEY_PROCESSKEY, FWL_VKEY_ProcessKey); -STATIC_ASSERT_MATCH(ui::VKEY_PACKET, FWL_VKEY_Packet); -STATIC_ASSERT_MATCH(ui::VKEY_ATTN, FWL_VKEY_Attn); -STATIC_ASSERT_MATCH(ui::VKEY_CRSEL, FWL_VKEY_Crsel); -STATIC_ASSERT_MATCH(ui::VKEY_EXSEL, FWL_VKEY_Exsel); -STATIC_ASSERT_MATCH(ui::VKEY_EREOF, FWL_VKEY_Ereof); -STATIC_ASSERT_MATCH(ui::VKEY_PLAY, FWL_VKEY_Play); -STATIC_ASSERT_MATCH(ui::VKEY_ZOOM, FWL_VKEY_Zoom); -STATIC_ASSERT_MATCH(ui::VKEY_NONAME, FWL_VKEY_NoName); -STATIC_ASSERT_MATCH(ui::VKEY_PA1, FWL_VKEY_PA1); -STATIC_ASSERT_MATCH(ui::VKEY_OEM_CLEAR, FWL_VKEY_OEM_Clear); -STATIC_ASSERT_MATCH(ui::VKEY_UNKNOWN, FWL_VKEY_Unknown); +STATIC_ASSERT_ENUM(ui::VKEY_BACK, FWL_VKEY_Back); +STATIC_ASSERT_ENUM(ui::VKEY_TAB, FWL_VKEY_Tab); +STATIC_ASSERT_ENUM(ui::VKEY_CLEAR, FWL_VKEY_Clear); +STATIC_ASSERT_ENUM(ui::VKEY_RETURN, FWL_VKEY_Return); +STATIC_ASSERT_ENUM(ui::VKEY_SHIFT, FWL_VKEY_Shift); +STATIC_ASSERT_ENUM(ui::VKEY_CONTROL, FWL_VKEY_Control); +STATIC_ASSERT_ENUM(ui::VKEY_MENU, FWL_VKEY_Menu); +STATIC_ASSERT_ENUM(ui::VKEY_PAUSE, FWL_VKEY_Pause); +STATIC_ASSERT_ENUM(ui::VKEY_CAPITAL, FWL_VKEY_Capital); +STATIC_ASSERT_ENUM(ui::VKEY_KANA, FWL_VKEY_Kana); +STATIC_ASSERT_ENUM(ui::VKEY_HANGUL, FWL_VKEY_Hangul); +STATIC_ASSERT_ENUM(ui::VKEY_JUNJA, FWL_VKEY_Junja); +STATIC_ASSERT_ENUM(ui::VKEY_FINAL, FWL_VKEY_Final); +STATIC_ASSERT_ENUM(ui::VKEY_HANJA, FWL_VKEY_Hanja); +STATIC_ASSERT_ENUM(ui::VKEY_KANJI, FWL_VKEY_Kanji); +STATIC_ASSERT_ENUM(ui::VKEY_ESCAPE, FWL_VKEY_Escape); +STATIC_ASSERT_ENUM(ui::VKEY_CONVERT, FWL_VKEY_Convert); +STATIC_ASSERT_ENUM(ui::VKEY_NONCONVERT, FWL_VKEY_NonConvert); +STATIC_ASSERT_ENUM(ui::VKEY_ACCEPT, FWL_VKEY_Accept); +STATIC_ASSERT_ENUM(ui::VKEY_MODECHANGE, FWL_VKEY_ModeChange); +STATIC_ASSERT_ENUM(ui::VKEY_SPACE, FWL_VKEY_Space); +STATIC_ASSERT_ENUM(ui::VKEY_PRIOR, FWL_VKEY_Prior); +STATIC_ASSERT_ENUM(ui::VKEY_NEXT, FWL_VKEY_Next); +STATIC_ASSERT_ENUM(ui::VKEY_END, FWL_VKEY_End); +STATIC_ASSERT_ENUM(ui::VKEY_HOME, FWL_VKEY_Home); +STATIC_ASSERT_ENUM(ui::VKEY_LEFT, FWL_VKEY_Left); +STATIC_ASSERT_ENUM(ui::VKEY_UP, FWL_VKEY_Up); +STATIC_ASSERT_ENUM(ui::VKEY_RIGHT, FWL_VKEY_Right); +STATIC_ASSERT_ENUM(ui::VKEY_DOWN, FWL_VKEY_Down); +STATIC_ASSERT_ENUM(ui::VKEY_SELECT, FWL_VKEY_Select); +STATIC_ASSERT_ENUM(ui::VKEY_PRINT, FWL_VKEY_Print); +STATIC_ASSERT_ENUM(ui::VKEY_EXECUTE, FWL_VKEY_Execute); +STATIC_ASSERT_ENUM(ui::VKEY_SNAPSHOT, FWL_VKEY_Snapshot); +STATIC_ASSERT_ENUM(ui::VKEY_INSERT, FWL_VKEY_Insert); +STATIC_ASSERT_ENUM(ui::VKEY_DELETE, FWL_VKEY_Delete); +STATIC_ASSERT_ENUM(ui::VKEY_HELP, FWL_VKEY_Help); +STATIC_ASSERT_ENUM(ui::VKEY_0, FWL_VKEY_0); +STATIC_ASSERT_ENUM(ui::VKEY_1, FWL_VKEY_1); +STATIC_ASSERT_ENUM(ui::VKEY_2, FWL_VKEY_2); +STATIC_ASSERT_ENUM(ui::VKEY_3, FWL_VKEY_3); +STATIC_ASSERT_ENUM(ui::VKEY_4, FWL_VKEY_4); +STATIC_ASSERT_ENUM(ui::VKEY_5, FWL_VKEY_5); +STATIC_ASSERT_ENUM(ui::VKEY_6, FWL_VKEY_6); +STATIC_ASSERT_ENUM(ui::VKEY_7, FWL_VKEY_7); +STATIC_ASSERT_ENUM(ui::VKEY_8, FWL_VKEY_8); +STATIC_ASSERT_ENUM(ui::VKEY_9, FWL_VKEY_9); +STATIC_ASSERT_ENUM(ui::VKEY_A, FWL_VKEY_A); +STATIC_ASSERT_ENUM(ui::VKEY_B, FWL_VKEY_B); +STATIC_ASSERT_ENUM(ui::VKEY_C, FWL_VKEY_C); +STATIC_ASSERT_ENUM(ui::VKEY_D, FWL_VKEY_D); +STATIC_ASSERT_ENUM(ui::VKEY_E, FWL_VKEY_E); +STATIC_ASSERT_ENUM(ui::VKEY_F, FWL_VKEY_F); +STATIC_ASSERT_ENUM(ui::VKEY_G, FWL_VKEY_G); +STATIC_ASSERT_ENUM(ui::VKEY_H, FWL_VKEY_H); +STATIC_ASSERT_ENUM(ui::VKEY_I, FWL_VKEY_I); +STATIC_ASSERT_ENUM(ui::VKEY_J, FWL_VKEY_J); +STATIC_ASSERT_ENUM(ui::VKEY_K, FWL_VKEY_K); +STATIC_ASSERT_ENUM(ui::VKEY_L, FWL_VKEY_L); +STATIC_ASSERT_ENUM(ui::VKEY_M, FWL_VKEY_M); +STATIC_ASSERT_ENUM(ui::VKEY_N, FWL_VKEY_N); +STATIC_ASSERT_ENUM(ui::VKEY_O, FWL_VKEY_O); +STATIC_ASSERT_ENUM(ui::VKEY_P, FWL_VKEY_P); +STATIC_ASSERT_ENUM(ui::VKEY_Q, FWL_VKEY_Q); +STATIC_ASSERT_ENUM(ui::VKEY_R, FWL_VKEY_R); +STATIC_ASSERT_ENUM(ui::VKEY_S, FWL_VKEY_S); +STATIC_ASSERT_ENUM(ui::VKEY_T, FWL_VKEY_T); +STATIC_ASSERT_ENUM(ui::VKEY_U, FWL_VKEY_U); +STATIC_ASSERT_ENUM(ui::VKEY_V, FWL_VKEY_V); +STATIC_ASSERT_ENUM(ui::VKEY_W, FWL_VKEY_W); +STATIC_ASSERT_ENUM(ui::VKEY_X, FWL_VKEY_X); +STATIC_ASSERT_ENUM(ui::VKEY_Y, FWL_VKEY_Y); +STATIC_ASSERT_ENUM(ui::VKEY_Z, FWL_VKEY_Z); +STATIC_ASSERT_ENUM(ui::VKEY_LWIN, FWL_VKEY_LWin); +STATIC_ASSERT_ENUM(ui::VKEY_COMMAND, FWL_VKEY_Command); +STATIC_ASSERT_ENUM(ui::VKEY_RWIN, FWL_VKEY_RWin); +STATIC_ASSERT_ENUM(ui::VKEY_APPS, FWL_VKEY_Apps); +STATIC_ASSERT_ENUM(ui::VKEY_SLEEP, FWL_VKEY_Sleep); +STATIC_ASSERT_ENUM(ui::VKEY_NUMPAD0, FWL_VKEY_NumPad0); +STATIC_ASSERT_ENUM(ui::VKEY_NUMPAD1, FWL_VKEY_NumPad1); +STATIC_ASSERT_ENUM(ui::VKEY_NUMPAD2, FWL_VKEY_NumPad2); +STATIC_ASSERT_ENUM(ui::VKEY_NUMPAD3, FWL_VKEY_NumPad3); +STATIC_ASSERT_ENUM(ui::VKEY_NUMPAD4, FWL_VKEY_NumPad4); +STATIC_ASSERT_ENUM(ui::VKEY_NUMPAD5, FWL_VKEY_NumPad5); +STATIC_ASSERT_ENUM(ui::VKEY_NUMPAD6, FWL_VKEY_NumPad6); +STATIC_ASSERT_ENUM(ui::VKEY_NUMPAD7, FWL_VKEY_NumPad7); +STATIC_ASSERT_ENUM(ui::VKEY_NUMPAD8, FWL_VKEY_NumPad8); +STATIC_ASSERT_ENUM(ui::VKEY_NUMPAD9, FWL_VKEY_NumPad9); +STATIC_ASSERT_ENUM(ui::VKEY_MULTIPLY, FWL_VKEY_Multiply); +STATIC_ASSERT_ENUM(ui::VKEY_ADD, FWL_VKEY_Add); +STATIC_ASSERT_ENUM(ui::VKEY_SEPARATOR, FWL_VKEY_Separator); +STATIC_ASSERT_ENUM(ui::VKEY_SUBTRACT, FWL_VKEY_Subtract); +STATIC_ASSERT_ENUM(ui::VKEY_DECIMAL, FWL_VKEY_Decimal); +STATIC_ASSERT_ENUM(ui::VKEY_DIVIDE, FWL_VKEY_Divide); +STATIC_ASSERT_ENUM(ui::VKEY_F1, FWL_VKEY_F1); +STATIC_ASSERT_ENUM(ui::VKEY_F2, FWL_VKEY_F2); +STATIC_ASSERT_ENUM(ui::VKEY_F3, FWL_VKEY_F3); +STATIC_ASSERT_ENUM(ui::VKEY_F4, FWL_VKEY_F4); +STATIC_ASSERT_ENUM(ui::VKEY_F5, FWL_VKEY_F5); +STATIC_ASSERT_ENUM(ui::VKEY_F6, FWL_VKEY_F6); +STATIC_ASSERT_ENUM(ui::VKEY_F7, FWL_VKEY_F7); +STATIC_ASSERT_ENUM(ui::VKEY_F8, FWL_VKEY_F8); +STATIC_ASSERT_ENUM(ui::VKEY_F9, FWL_VKEY_F9); +STATIC_ASSERT_ENUM(ui::VKEY_F10, FWL_VKEY_F10); +STATIC_ASSERT_ENUM(ui::VKEY_F11, FWL_VKEY_F11); +STATIC_ASSERT_ENUM(ui::VKEY_F12, FWL_VKEY_F12); +STATIC_ASSERT_ENUM(ui::VKEY_F13, FWL_VKEY_F13); +STATIC_ASSERT_ENUM(ui::VKEY_F14, FWL_VKEY_F14); +STATIC_ASSERT_ENUM(ui::VKEY_F15, FWL_VKEY_F15); +STATIC_ASSERT_ENUM(ui::VKEY_F16, FWL_VKEY_F16); +STATIC_ASSERT_ENUM(ui::VKEY_F17, FWL_VKEY_F17); +STATIC_ASSERT_ENUM(ui::VKEY_F18, FWL_VKEY_F18); +STATIC_ASSERT_ENUM(ui::VKEY_F19, FWL_VKEY_F19); +STATIC_ASSERT_ENUM(ui::VKEY_F20, FWL_VKEY_F20); +STATIC_ASSERT_ENUM(ui::VKEY_F21, FWL_VKEY_F21); +STATIC_ASSERT_ENUM(ui::VKEY_F22, FWL_VKEY_F22); +STATIC_ASSERT_ENUM(ui::VKEY_F23, FWL_VKEY_F23); +STATIC_ASSERT_ENUM(ui::VKEY_F24, FWL_VKEY_F24); +STATIC_ASSERT_ENUM(ui::VKEY_NUMLOCK, FWL_VKEY_NunLock); +STATIC_ASSERT_ENUM(ui::VKEY_SCROLL, FWL_VKEY_Scroll); +STATIC_ASSERT_ENUM(ui::VKEY_LSHIFT, FWL_VKEY_LShift); +STATIC_ASSERT_ENUM(ui::VKEY_RSHIFT, FWL_VKEY_RShift); +STATIC_ASSERT_ENUM(ui::VKEY_LCONTROL, FWL_VKEY_LControl); +STATIC_ASSERT_ENUM(ui::VKEY_RCONTROL, FWL_VKEY_RControl); +STATIC_ASSERT_ENUM(ui::VKEY_LMENU, FWL_VKEY_LMenu); +STATIC_ASSERT_ENUM(ui::VKEY_RMENU, FWL_VKEY_RMenu); +STATIC_ASSERT_ENUM(ui::VKEY_BROWSER_BACK, FWL_VKEY_BROWSER_Back); +STATIC_ASSERT_ENUM(ui::VKEY_BROWSER_FORWARD, FWL_VKEY_BROWSER_Forward); +STATIC_ASSERT_ENUM(ui::VKEY_BROWSER_REFRESH, FWL_VKEY_BROWSER_Refresh); +STATIC_ASSERT_ENUM(ui::VKEY_BROWSER_STOP, FWL_VKEY_BROWSER_Stop); +STATIC_ASSERT_ENUM(ui::VKEY_BROWSER_SEARCH, FWL_VKEY_BROWSER_Search); +STATIC_ASSERT_ENUM(ui::VKEY_BROWSER_FAVORITES, FWL_VKEY_BROWSER_Favorites); +STATIC_ASSERT_ENUM(ui::VKEY_BROWSER_HOME, FWL_VKEY_BROWSER_Home); +STATIC_ASSERT_ENUM(ui::VKEY_VOLUME_MUTE, FWL_VKEY_VOLUME_Mute); +STATIC_ASSERT_ENUM(ui::VKEY_VOLUME_DOWN, FWL_VKEY_VOLUME_Down); +STATIC_ASSERT_ENUM(ui::VKEY_VOLUME_UP, FWL_VKEY_VOLUME_Up); +STATIC_ASSERT_ENUM(ui::VKEY_MEDIA_NEXT_TRACK, FWL_VKEY_MEDIA_NEXT_Track); +STATIC_ASSERT_ENUM(ui::VKEY_MEDIA_PREV_TRACK, FWL_VKEY_MEDIA_PREV_Track); +STATIC_ASSERT_ENUM(ui::VKEY_MEDIA_STOP, FWL_VKEY_MEDIA_Stop); +STATIC_ASSERT_ENUM(ui::VKEY_MEDIA_PLAY_PAUSE, FWL_VKEY_MEDIA_PLAY_Pause); +STATIC_ASSERT_ENUM(ui::VKEY_MEDIA_LAUNCH_MAIL, FWL_VKEY_MEDIA_LAUNCH_Mail); +STATIC_ASSERT_ENUM(ui::VKEY_MEDIA_LAUNCH_MEDIA_SELECT, + FWL_VKEY_MEDIA_LAUNCH_MEDIA_Select); +STATIC_ASSERT_ENUM(ui::VKEY_MEDIA_LAUNCH_APP1, FWL_VKEY_MEDIA_LAUNCH_APP1); +STATIC_ASSERT_ENUM(ui::VKEY_MEDIA_LAUNCH_APP2, FWL_VKEY_MEDIA_LAUNCH_APP2); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_1, FWL_VKEY_OEM_1); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_PLUS, FWL_VKEY_OEM_Plus); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_COMMA, FWL_VKEY_OEM_Comma); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_MINUS, FWL_VKEY_OEM_Minus); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_PERIOD, FWL_VKEY_OEM_Period); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_2, FWL_VKEY_OEM_2); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_3, FWL_VKEY_OEM_3); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_4, FWL_VKEY_OEM_4); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_5, FWL_VKEY_OEM_5); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_6, FWL_VKEY_OEM_6); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_7, FWL_VKEY_OEM_7); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_8, FWL_VKEY_OEM_8); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_102, FWL_VKEY_OEM_102); +STATIC_ASSERT_ENUM(ui::VKEY_PROCESSKEY, FWL_VKEY_ProcessKey); +STATIC_ASSERT_ENUM(ui::VKEY_PACKET, FWL_VKEY_Packet); +STATIC_ASSERT_ENUM(ui::VKEY_ATTN, FWL_VKEY_Attn); +STATIC_ASSERT_ENUM(ui::VKEY_CRSEL, FWL_VKEY_Crsel); +STATIC_ASSERT_ENUM(ui::VKEY_EXSEL, FWL_VKEY_Exsel); +STATIC_ASSERT_ENUM(ui::VKEY_EREOF, FWL_VKEY_Ereof); +STATIC_ASSERT_ENUM(ui::VKEY_PLAY, FWL_VKEY_Play); +STATIC_ASSERT_ENUM(ui::VKEY_ZOOM, FWL_VKEY_Zoom); +STATIC_ASSERT_ENUM(ui::VKEY_NONAME, FWL_VKEY_NoName); +STATIC_ASSERT_ENUM(ui::VKEY_PA1, FWL_VKEY_PA1); +STATIC_ASSERT_ENUM(ui::VKEY_OEM_CLEAR, FWL_VKEY_OEM_Clear); +STATIC_ASSERT_ENUM(ui::VKEY_UNKNOWN, FWL_VKEY_Unknown); -STATIC_ASSERT_MATCH(PP_PRIVATEFONTCHARSET_ANSI, FXFONT_ANSI_CHARSET); -STATIC_ASSERT_MATCH(PP_PRIVATEFONTCHARSET_DEFAULT, FXFONT_DEFAULT_CHARSET); -STATIC_ASSERT_MATCH(PP_PRIVATEFONTCHARSET_SYMBOL, FXFONT_SYMBOL_CHARSET); -STATIC_ASSERT_MATCH(PP_PRIVATEFONTCHARSET_SHIFTJIS, FXFONT_SHIFTJIS_CHARSET); -STATIC_ASSERT_MATCH(PP_PRIVATEFONTCHARSET_HANGUL, FXFONT_HANGEUL_CHARSET); -STATIC_ASSERT_MATCH(PP_PRIVATEFONTCHARSET_GB2312, FXFONT_GB2312_CHARSET); -STATIC_ASSERT_MATCH(PP_PRIVATEFONTCHARSET_CHINESEBIG5, - FXFONT_CHINESEBIG5_CHARSET); +STATIC_ASSERT_ENUM(PP_PRIVATEFONTCHARSET_ANSI, FXFONT_ANSI_CHARSET); +STATIC_ASSERT_ENUM(PP_PRIVATEFONTCHARSET_DEFAULT, FXFONT_DEFAULT_CHARSET); +STATIC_ASSERT_ENUM(PP_PRIVATEFONTCHARSET_SYMBOL, FXFONT_SYMBOL_CHARSET); +STATIC_ASSERT_ENUM(PP_PRIVATEFONTCHARSET_SHIFTJIS, FXFONT_SHIFTJIS_CHARSET); +STATIC_ASSERT_ENUM(PP_PRIVATEFONTCHARSET_HANGUL, FXFONT_HANGEUL_CHARSET); +STATIC_ASSERT_ENUM(PP_PRIVATEFONTCHARSET_GB2312, FXFONT_GB2312_CHARSET); +STATIC_ASSERT_ENUM(PP_PRIVATEFONTCHARSET_CHINESEBIG5, + FXFONT_CHINESEBIG5_CHARSET); -STATIC_ASSERT_MATCH(PP_PRIVATEDUPLEXMODE_NONE, DuplexUndefined); -STATIC_ASSERT_MATCH(PP_PRIVATEDUPLEXMODE_SIMPLEX, Simplex); -STATIC_ASSERT_MATCH(PP_PRIVATEDUPLEXMODE_SHORT_EDGE, DuplexFlipShortEdge); -STATIC_ASSERT_MATCH(PP_PRIVATEDUPLEXMODE_LONG_EDGE, DuplexFlipLongEdge); +STATIC_ASSERT_ENUM(PP_PRIVATEDUPLEXMODE_NONE, DuplexUndefined); +STATIC_ASSERT_ENUM(PP_PRIVATEDUPLEXMODE_SIMPLEX, Simplex); +STATIC_ASSERT_ENUM(PP_PRIVATEDUPLEXMODE_SHORT_EDGE, DuplexFlipShortEdge); +STATIC_ASSERT_ENUM(PP_PRIVATEDUPLEXMODE_LONG_EDGE, DuplexFlipLongEdge); diff --git a/chromium/pdf/pdfium/pdfium_engine.cc b/chromium/pdf/pdfium/pdfium_engine.cc index 10f11d126ba..3899e0ee51e 100644 --- a/chromium/pdf/pdfium/pdfium_engine.cc +++ b/chromium/pdf/pdfium/pdfium_engine.cc @@ -156,14 +156,14 @@ void* MapFont(struct _FPDF_SYSFONTINFO*, int weight, int italic, // printing). // TODO(noamsml): Real font substitution (http://crbug.com/391978) if (!pp::Module::Get()) - return NULL; + return nullptr; pp::BrowserFontDescription description; // Pretend the system does not have the Symbol font to force a fallback to // the built in Symbol font in CFX_FontMapper::FindSubstFont(). if (strcmp(face, "Symbol") == 0) - return NULL; + return nullptr; if (pitch_family & FXFONT_FF_FIXEDPITCH) { description.set_family(PP_BROWSERFONT_TRUSTED_FAMILY_MONOSPACE); @@ -254,7 +254,7 @@ void* MapFont(struct _FPDF_SYSFONTINFO*, int weight, int italic, if (!pp::PDF::IsAvailable()) { NOTREACHED(); - return NULL; + return nullptr; } PP_Resource font_resource = pp::PDF::GetFontFileWithFallback( @@ -406,14 +406,14 @@ void FormatStringForOS(base::string16* text) { // Returns a VarDictionary (representing a bookmark), which in turn contains // child VarDictionaries (representing the child bookmarks). -// If NULL is passed in as the bookmark then we traverse from the "root". +// If nullptr is passed in as the bookmark then we traverse from the "root". // Note that the "root" bookmark contains no useful information. pp::VarDictionary TraverseBookmarks(FPDF_DOCUMENT doc, FPDF_BOOKMARK bookmark, unsigned int depth) { pp::VarDictionary dict; base::string16 title; - unsigned long buffer_size = FPDFBookmark_GetTitle(bookmark, NULL, 0); + unsigned long buffer_size = FPDFBookmark_GetTitle(bookmark, nullptr, 0); if (buffer_size > 0) { PDFiumAPIStringBufferSizeInBytesAdapter<base::string16> api_string_adapter( &title, buffer_size, true); @@ -427,6 +427,18 @@ pp::VarDictionary TraverseBookmarks(FPDF_DOCUMENT doc, if (dest) { int page_index = FPDFDest_GetPageIndex(doc, dest); dict.Set(pp::Var("page"), pp::Var(page_index)); + } else { + // Extract URI for bookmarks linking to an external page. + FPDF_ACTION action = FPDFBookmark_GetAction(bookmark); + buffer_size = FPDFAction_GetURIPath(doc, action, nullptr, 0); + if (buffer_size > 0) { + std::string uri; + PDFiumAPIStringBufferAdapter<std::string> + api_string_adapter(&uri, buffer_size, true); + api_string_adapter.Close(FPDFAction_GetURIPath( + doc, action, api_string_adapter.GetData(), buffer_size)); + dict.Set(pp::Var("uri"), pp::Var(uri)); + } } pp::VarArray children; @@ -506,8 +518,8 @@ bool InitializeSDK() { } void ShutdownSDK() { - TearDownV8(); FPDF_DestroyLibrary(); + TearDownV8(); } PDFEngine* PDFEngine::Create(PDFEngine::Client* client) { @@ -520,8 +532,8 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) current_rotation_(0), doc_loader_(this), password_tries_remaining_(0), - doc_(NULL), - form_(NULL), + doc_(nullptr), + form_(nullptr), defer_page_unload_(false), selecting_(false), mouse_down_state_(PDFiumPage::NONSELECTABLE_AREA, @@ -531,7 +543,7 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) last_character_index_to_search_(-1), permissions_(0), permissions_handler_revision_(-1), - fpdf_availability_(NULL), + fpdf_availability_(nullptr), next_timer_id_(0), last_page_mouse_down_(-1), most_visible_page_(-1), @@ -560,7 +572,7 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) // PDFiumEngine. FPDF_FORMFILLINFO::version = 1; FPDF_FORMFILLINFO::m_pJsPlatform = this; - FPDF_FORMFILLINFO::Release = NULL; + FPDF_FORMFILLINFO::Release = nullptr; FPDF_FORMFILLINFO::FFI_Invalidate = Form_Invalidate; FPDF_FORMFILLINFO::FFI_OutputSelectedRect = Form_OutputSelectedRect; FPDF_FORMFILLINFO::FFI_SetCursor = Form_SetCursor; @@ -583,6 +595,7 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) FPDF_FORMFILLINFO::FFI_GetCurrentPageIndex = Form_GetCurrentPageIndex; FPDF_FORMFILLINFO::FFI_GetPageViewRect = Form_GetPageViewRect; FPDF_FORMFILLINFO::FFI_GetPlatform = Form_GetPlatform; + FPDF_FORMFILLINFO::FFI_PageEvent = nullptr; FPDF_FORMFILLINFO::FFI_PopupMenu = Form_PopupMenu; FPDF_FORMFILLINFO::FFI_PostRequestURL = Form_PostRequestURL; FPDF_FORMFILLINFO::FFI_PutRequestURL = Form_PutRequestURL; @@ -604,8 +617,15 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) IPDF_JSPLATFORM::Field_browse = Form_Browse; IFSDK_PAUSE::version = 1; - IFSDK_PAUSE::user = NULL; + IFSDK_PAUSE::user = nullptr; IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; + +#if defined(OS_LINUX) + // PreviewModeClient does not know its pp::Instance. + pp::Instance* instance = client_->GetPluginInstance(); + if (instance) + g_last_instance_id = instance->pp_instance(); +#endif } PDFiumEngine::~PDFiumEngine() { @@ -632,79 +652,6 @@ PDFiumEngine::~PDFiumEngine() { #ifdef PDF_USE_XFA -// This is just for testing, needs to be removed later -#if defined(WIN32) -#define XFA_TESTFILE(filename) "E:/"#filename -#else -#define XFA_TESTFILE(filename) "/home/"#filename -#endif - -struct FPDF_FILE { - FPDF_FILEHANDLER file_handler; - FILE* file; -}; - -void Sample_Release(FPDF_LPVOID client_data) { - if (!client_data) - return; - FPDF_FILE* file_wrapper = (FPDF_FILE*)client_data; - fclose(file_wrapper->file); - delete file_wrapper; -} - -FPDF_DWORD Sample_GetSize(FPDF_LPVOID client_data) { - if (!client_data) - return 0; - FPDF_FILE* file_wrapper = (FPDF_FILE*)client_data; - long cur_pos = ftell(file_wrapper->file); - if (cur_pos == -1) - return 0; - if (fseek(file_wrapper->file, 0, SEEK_END)) - return 0; - long size = ftell(file_wrapper->file); - fseek(file_wrapper->file, cur_pos, SEEK_SET); - return (FPDF_DWORD)size; -} - -FPDF_RESULT Sample_ReadBlock(FPDF_LPVOID client_data, - FPDF_DWORD offset, - FPDF_LPVOID buffer, - FPDF_DWORD size) { - if (!client_data) - return -1; - FPDF_FILE* file_wrapper = (FPDF_FILE*)client_data; - if (fseek(file_wrapper->file, (long)offset, SEEK_SET)) - return -1; - size_t read_size = fread(buffer, 1, size, file_wrapper->file); - return read_size == size ? 0 : -1; -} - -FPDF_RESULT Sample_WriteBlock(FPDF_LPVOID client_data, - FPDF_DWORD offset, - FPDF_LPCVOID buffer, - FPDF_DWORD size) { - if (!client_data) - return -1; - FPDF_FILE* file_wrapper = (FPDF_FILE*)client_data; - if (fseek(file_wrapper->file, (long)offset, SEEK_SET)) - return -1; - // Write data - size_t write_size = fwrite(buffer, 1, size, file_wrapper->file); - return write_size == size ? 0 : -1; -} - -FPDF_RESULT Sample_Flush(FPDF_LPVOID client_data) { - if (!client_data) - return -1; - // Flush file - fflush(((FPDF_FILE*)client_data)->file); - return 0; -} - -FPDF_RESULT Sample_Truncate(FPDF_LPVOID client_data, FPDF_DWORD size) { - return 0; -} - void PDFiumEngine::Form_EmailTo(FPDF_FORMFILLINFO* param, FPDF_FILEHANDLER* file_handler, FPDF_WIDESTRING to, @@ -857,47 +804,18 @@ void PDFiumEngine::Form_UploadTo(FPDF_FORMFILLINFO* param, FPDF_LPFILEHANDLER PDFiumEngine::Form_DownloadFromURL(FPDF_FORMFILLINFO* param, FPDF_WIDESTRING url) { - std::string url_str = - base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url)); - - // Now should get data from url. - // For testing purpose, use data read from file - // TODO: needs the full implementation here - FILE* file = fopen(XFA_TESTFILE("downloadtest.tem"), "w"); - - FPDF_FILE* file_wrapper = new FPDF_FILE; - file_wrapper->file = file; - file_wrapper->file_handler.clientData = file_wrapper; - file_wrapper->file_handler.Flush = Sample_Flush; - file_wrapper->file_handler.GetSize = Sample_GetSize; - file_wrapper->file_handler.ReadBlock = Sample_ReadBlock; - file_wrapper->file_handler.Release = Sample_Release; - file_wrapper->file_handler.Truncate = Sample_Truncate; - file_wrapper->file_handler.WriteBlock = Sample_WriteBlock; - - return &file_wrapper->file_handler; + // NOTE: Think hard about the security implications before allowing + // a PDF file to perform this action. + return nullptr; } FPDF_FILEHANDLER* PDFiumEngine::Form_OpenFile(FPDF_FORMFILLINFO* param, int file_flag, FPDF_WIDESTRING url, const char* mode) { - std::string url_str = url ? - base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url)) : "NULL"; - - // TODO: need to implement open file from the url - // Use a file path for the ease of testing - FILE* file = fopen(XFA_TESTFILE("tem.txt"), mode); - FPDF_FILE* file_wrapper = new FPDF_FILE; - file_wrapper->file = file; - file_wrapper->file_handler.clientData = file_wrapper; - file_wrapper->file_handler.Flush = Sample_Flush; - file_wrapper->file_handler.GetSize = Sample_GetSize; - file_wrapper->file_handler.ReadBlock = Sample_ReadBlock; - file_wrapper->file_handler.Release = Sample_Release; - file_wrapper->file_handler.Truncate = Sample_Truncate; - file_wrapper->file_handler.WriteBlock = Sample_WriteBlock; - return &file_wrapper->file_handler; + // NOTE: Think hard about the security implications before allowing + // a PDF file to perform this action. + return nullptr; } void PDFiumEngine::Form_GotoURL(FPDF_FORMFILLINFO* param, @@ -1113,8 +1031,10 @@ std::string PDFiumEngine::GetMetadata(const std::string& key) { void PDFiumEngine::OnPartialDocumentLoaded() { file_access_.m_FileLen = doc_loader_.document_size(); - fpdf_availability_ = FPDFAvail_Create(&file_availability_, &file_access_); - DCHECK(fpdf_availability_); + if (!fpdf_availability_) { + fpdf_availability_ = FPDFAvail_Create(&file_availability_, &file_access_); + DCHECK(fpdf_availability_); + } // Currently engine does not deal efficiently with some non-linearized files. // See http://code.google.com/p/chromium/issues/detail?id=59400 @@ -1157,6 +1077,10 @@ void PDFiumEngine::OnNewDataAvailable() { void PDFiumEngine::OnDocumentComplete() { if (!doc_ || !form_) { file_access_.m_FileLen = doc_loader_.document_size(); + if (!fpdf_availability_) { + fpdf_availability_ = FPDFAvail_Create(&file_availability_, &file_access_); + DCHECK(fpdf_availability_); + } LoadDocument(); return; } @@ -1428,7 +1352,7 @@ pp::Buffer_Dev PDFiumEngine::PrintPagesAsRasterPDF( FPDF_CloseDocument(temp_doc); PDFiumMemBufferFileRead file_read(buffer.data(), buffer.size()); - temp_doc = FPDF_LoadCustomDocument(&file_read, NULL); + temp_doc = FPDF_LoadCustomDocument(&file_read, nullptr); FPDF_BOOL imported = FPDF_ImportPages(output_doc, temp_doc, "1", i); FPDF_CloseDocument(temp_doc); @@ -2313,7 +2237,7 @@ int PDFiumEngine::GetNumberOfPages() { } pp::VarArray PDFiumEngine::GetBookmarks() { - pp::VarDictionary dict = TraverseBookmarks(doc_, NULL, 0); + pp::VarDictionary dict = TraverseBookmarks(doc_, nullptr, 0); // The root bookmark contains no useful information. return pp::VarArray(dict.Get(pp::Var("children"))); } @@ -2501,10 +2425,12 @@ bool PDFiumEngine::TryLoadingDoc(bool with_password, password_cstr = password.c_str(); password_tries_remaining_--; } - if (doc_loader_.IsDocumentComplete()) + if (doc_loader_.IsDocumentComplete() && + !FPDFAvail_IsLinearized(fpdf_availability_)) { doc_ = FPDF_LoadCustomDocument(&file_access_, password_cstr); - else + } else { doc_ = FPDFAvail_GetDocument(fpdf_availability_, password_cstr); + } if (!doc_ && FPDF_GetLastError() == FPDF_ERR_PASSWORD) *needs_password = true; @@ -2701,7 +2627,8 @@ bool PDFiumEngine::CheckPageAvailable(int index, std::vector<int>* pending) { if (!doc_ || !form_) return false; - if (static_cast<int>(pages_.size()) > index && pages_[index]->available()) + const int num_pages = static_cast<int>(pages_.size()); + if (index < num_pages && pages_[index]->available()) return true; if (!FPDFAvail_IsPageAvail(fpdf_availability_, index, &download_hints_)) { @@ -2716,7 +2643,7 @@ bool PDFiumEngine::CheckPageAvailable(int index, std::vector<int>* pending) { return false; } - if (static_cast<int>(pages_.size()) > index) + if (index < num_pages) pages_[index]->set_available(true); if (!default_page_size_.GetArea()) default_page_size_ = GetPageSize(index); @@ -2749,7 +2676,7 @@ int PDFiumEngine::StartPaint(int page_index, const pp::Rect& dirty) { ProgressivePaint progressive; progressive.rect = dirty; progressive.page_index = page_index; - progressive.bitmap = NULL; + progressive.bitmap = nullptr; progressive.painted_ = false; progressive_paints_.push_back(progressive); return progressive_paints_.size() - 1; @@ -2915,7 +2842,7 @@ void PDFiumEngine::DrawSelections(int progressive_index, int page_index = progressive_paints_[progressive_index].page_index; pp::Rect dirty_in_screen = progressive_paints_[progressive_index].rect; - void* region = NULL; + void* region = nullptr; int stride; GetRegion(dirty_in_screen.point(), image_data, ®ion, &stride); @@ -2980,7 +2907,7 @@ FPDF_BITMAP PDFiumEngine::CreateBitmap(const pp::Rect& rect, int stride; GetRegion(rect.point(), image_data, ®ion, &stride); if (!region) - return NULL; + return nullptr; return FPDFBitmap_CreateEx( rect.width(), rect.height(), FPDFBitmap_BGRx, region, stride); } @@ -3359,7 +3286,7 @@ void PDFiumEngine::GetRegion(const pp::Point& location, if (image_data->is_null()) { DCHECK(plugin_size_.IsEmpty()); *stride = 0; - *region = NULL; + *region = nullptr; return; } char* buffer = static_cast<char*>(image_data->data()); @@ -3369,7 +3296,7 @@ void PDFiumEngine::GetRegion(const pp::Point& location, // TODO: update this when we support BIDI and scrollbars can be on the left. if (!buffer || !pp::Rect(page_offset_, plugin_size_).Contains(offset_location)) { - *region = NULL; + *region = nullptr; return; } @@ -3491,7 +3418,7 @@ FPDF_PAGE PDFiumEngine::Form_GetPage(FPDF_FORMFILLINFO* param, int page_index) { PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); if (page_index < 0 || page_index >= static_cast<int>(engine->pages_.size())) - return NULL; + return nullptr; return engine->pages_[page_index]->GetPage(); } @@ -3504,7 +3431,7 @@ FPDF_PAGE PDFiumEngine::Form_GetCurrentPage(FPDF_FORMFILLINFO* param, index = engine->GetMostVisiblePage(); if (index == -1) { NOTREACHED(); - return NULL; + return nullptr; } } @@ -3808,7 +3735,7 @@ bool PDFiumEngineExports::RenderPDFPageToDC(const void* pdf_buffer, int page_number, const RenderingSettings& settings, HDC dc) { - FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, buffer_size, NULL); + FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, buffer_size, nullptr); if (!doc) return false; FPDF_PAGE page = FPDF_LoadPage(doc, page_number); @@ -3880,7 +3807,8 @@ bool PDFiumEngineExports::RenderPDFPageToBitmap( int page_number, const RenderingSettings& settings, void* bitmap_buffer) { - FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); + FPDF_DOCUMENT doc = + FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); if (!doc) return false; FPDF_PAGE page = FPDF_LoadPage(doc, page_number); @@ -3914,7 +3842,7 @@ bool PDFiumEngineExports::GetPDFDocInfo(const void* pdf_buffer, int buffer_size, int* page_count, double* max_page_width) { - FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, buffer_size, NULL); + FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, buffer_size, nullptr); if (!doc) return false; int page_count_local = FPDF_GetPageCount(doc); @@ -3942,7 +3870,8 @@ bool PDFiumEngineExports::GetPDFPageSizeByIndex( int page_number, double* width, double* height) { - FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); + FPDF_DOCUMENT doc = + FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); if (!doc) return false; bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; diff --git a/chromium/pdf/pdfium/pdfium_page.cc b/chromium/pdf/pdfium/pdfium_page.cc index 95a8fba3d71..41bcd9c76dd 100644 --- a/chromium/pdf/pdfium/pdfium_page.cc +++ b/chromium/pdf/pdfium/pdfium_page.cc @@ -7,6 +7,8 @@ #include <math.h> #include <stddef.h> +#include <algorithm> + #include "base/logging.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" @@ -32,10 +34,74 @@ const char kTextBoxFontSize[] = "fontSize"; const char kTextBoxNodes[] = "textNodes"; const char kTextNodeType[] = "type"; const char kTextNodeText[] = "text"; -const char kTextNodeURL[] = "url"; const char kTextNodeTypeText[] = "text"; -const char kTextNodeTypeURL[] = "url"; -const char kDocLinkURLPrefix[] = "#page"; + +pp::Rect PageRectToGViewRect(FPDF_PAGE page, const pp::Rect& input) { + int output_width = FPDF_GetPageWidth(page); + int output_height = FPDF_GetPageHeight(page); + + int min_x; + int min_y; + int max_x; + int max_y; + FPDF_PageToDevice(page, 0, 0, output_width, output_height, 0, + input.x(), input.y(), &min_x, &min_y); + FPDF_PageToDevice(page, 0, 0, output_width, output_height, 0, + input.right(), input.bottom(), &max_x, &max_y); + + if (max_x < min_x) + std::swap(min_x, max_x); + if (max_y < min_y) + std::swap(min_y, max_y); + + pp::Rect output_rect(min_x, min_y, max_x - min_x, max_y - min_y); + output_rect.Intersect(pp::Rect(0, 0, output_width, output_height)); + return output_rect; +} + +pp::Rect GetCharRectInGViewCoords(FPDF_PAGE page, FPDF_TEXTPAGE text_page, + int index) { + double left, right, bottom, top; + FPDFText_GetCharBox(text_page, index, &left, &right, &bottom, &top); + if (right < left) + std::swap(left, right); + if (bottom < top) + std::swap(top, bottom); + pp::Rect page_coords(left, top, right - left, bottom - top); + return PageRectToGViewRect(page, page_coords); +} + +// This is the character PDFium inserts where a word is broken across lines. +const unsigned int kSoftHyphen = 0x02; + +// The following characters should all be recognized as Unicode newlines: +// LF: Line Feed, U+000A +// VT: Vertical Tab, U+000B +// FF: Form Feed, U+000C +// CR: Carriage Return, U+000D +// CR+LF: CR (U+000D) followed by LF (U+000A) +// NEL: Next Line, U+0085 +// LS: Line Separator, U+2028 +// PS: Paragraph Separator, U+2029. +// Source: http://en.wikipedia.org/wiki/Newline#Unicode . +const unsigned int kUnicodeNewlines[] = { + 0xA, 0xB, 0xC, 0xD, 0X85, 0x2028, 0x2029 +}; + +bool IsSoftHyphen(unsigned int character) { + return kSoftHyphen == character; +} + +bool OverlapsOnYAxis(const pp::Rect &a, const pp::Rect& b) { + return !(a.IsEmpty() || b.IsEmpty() || + a.bottom() < b.y() || b.bottom() < a.y()); +} + +bool IsEol(unsigned int character) { + const unsigned int* first = kUnicodeNewlines; + const unsigned int* last = kUnicodeNewlines + arraysize(kUnicodeNewlines); + return std::find(first, last, character) != last; +} } // namespace @@ -130,130 +196,105 @@ base::Value* PDFiumPage::GetAccessibleContentAsValue(int rotation) { if (!available_) return node; - double width = FPDF_GetPageWidth(GetPage()); - double height = FPDF_GetPageHeight(GetPage()); + FPDF_PAGE page = GetPage(); + FPDF_TEXTPAGE text_page = GetTextPage(); - base::ListValue* text = new base::ListValue(); - int box_count = FPDFText_CountRects(GetTextPage(), 0, GetCharCount()); - for (int i = 0; i < box_count; i++) { - double left, top, right, bottom; - FPDFText_GetRect(GetTextPage(), i, &left, &top, &right, &bottom); - text->Append( - GetTextBoxAsValue(height, left, top, right, bottom, rotation)); - } + double width = FPDF_GetPageWidth(page); + double height = FPDF_GetPageHeight(page); node->SetDouble(kPageWidth, width); node->SetDouble(kPageHeight, height); - node->Set(kPageTextBox, text); // Takes ownership of |text| - - return node; -} - -base::Value* PDFiumPage::GetTextBoxAsValue(double page_height, - double left, double top, - double right, double bottom, - int rotation) { - base::string16 text_utf16; - int char_count = - FPDFText_GetBoundedText(GetTextPage(), left, top, right, bottom, NULL, 0); - if (char_count > 0) { - unsigned short* data = reinterpret_cast<unsigned short*>( - base::WriteInto(&text_utf16, char_count + 1)); - FPDFText_GetBoundedText(GetTextPage(), - left, top, right, bottom, - data, char_count); - } - std::string text_utf8 = base::UTF16ToUTF8(text_utf16); - - FPDF_LINK link = FPDFLink_GetLinkAtPoint(GetPage(), left, top); - Area area; - std::vector<LinkTarget> targets; - if (link) { - targets.push_back(LinkTarget()); - area = GetLinkTarget(link, &targets[0]); - } else { - pp::Rect rect( - PageToScreen(pp::Point(), 1.0, left, top, right, bottom, rotation)); - GetLinks(rect, &targets); - area = targets.empty() ? TEXT_AREA : WEBLINK_AREA; - } + scoped_ptr<base::ListValue> text(new base::ListValue()); + + int chars_count = FPDFText_CountChars(text_page); + pp::Rect line_rect; + pp::Rect word_rect; + bool seen_literal_text_in_word = false; + + // Iterate over all of the chars on the page. Explicitly run the loop + // with |i == chars_count|, which is one past the last character, and + // pretend it's a newline character in order to ensure we always flush + // the last line. + base::string16 line; + for (int i = 0; i <= chars_count; i++) { + unsigned int character; + pp::Rect char_rect; + + if (i < chars_count) { + character = FPDFText_GetUnicode(text_page, i); + char_rect = GetCharRectInGViewCoords(page, text_page, i); + } else { + // Make the last character a newline so the last line isn't lost. + character = '\n'; + } - int char_index = FPDFText_GetCharIndexAtPos(GetTextPage(), left, top, - kTolerance, kTolerance); - double font_size = FPDFText_GetFontSize(GetTextPage(), char_index); + // There are spurious STX chars appearing in place + // of ligatures. Apply a heuristic to check that some vertical displacement + // is involved before assuming they are line-breaks. + bool is_intraword_linebreak = false; + if (i < chars_count - 1 && IsSoftHyphen(character)) { + // check if the next char and this char are in different lines. + pp::Rect next_char_rect = GetCharRectInGViewCoords( + page, text_page, i + 1); + + // TODO(dmazzoni): this assumes horizontal text. + // https://crbug.com/580311 + is_intraword_linebreak = !OverlapsOnYAxis(char_rect, next_char_rect); + } + if (is_intraword_linebreak || + base::IsUnicodeWhitespace(character) || + IsEol(character)) { + if (!word_rect.IsEmpty() && seen_literal_text_in_word) { + word_rect = pp::Rect(); + seen_literal_text_in_word = false; + } + } - base::DictionaryValue* node = new base::DictionaryValue(); - node->SetDouble(kTextBoxLeft, left); - node->SetDouble(kTextBoxTop, page_height - top); - node->SetDouble(kTextBoxWidth, right - left); - node->SetDouble(kTextBoxHeight, top - bottom); - node->SetDouble(kTextBoxFontSize, font_size); - - base::ListValue* text_nodes = new base::ListValue(); - - if (area == DOCLINK_AREA) { - std::string url = kDocLinkURLPrefix + base::IntToString(targets[0].page); - text_nodes->Append(CreateURLNode(text_utf8, url)); - } else if (area == WEBLINK_AREA && link) { - text_nodes->Append(CreateURLNode(text_utf8, targets[0].url)); - } else if (area == WEBLINK_AREA && !link) { - size_t start = 0; - for (const auto& target : targets) { - // If there is an extra NULL character at end, find() will not return any - // matches. There should not be any though. - if (!target.url.empty()) - DCHECK_NE(target.url.back(), '\0'); - - // PDFium may change the case of generated links. - std::string lowerCaseURL = base::ToLowerASCII(target.url); - std::string lowerCaseText = base::ToLowerASCII(text_utf8); - size_t pos = lowerCaseText.find(lowerCaseURL, start); - size_t length = target.url.size(); - if (pos == std::string::npos) { - // Check if the link is a "mailto:" URL - if (lowerCaseURL.compare(0, 7, "mailto:") == 0) { - pos = lowerCaseText.find(lowerCaseURL.substr(7), start); - length -= 7; + if (is_intraword_linebreak || IsEol(character)) { + if (!line_rect.IsEmpty()) { + if (is_intraword_linebreak) { + // Add a 0-width hyphen. + line.push_back('-'); } - if (pos == std::string::npos) { - // No match has been found. This should never happen. - continue; - } + base::DictionaryValue* text_node = new base::DictionaryValue(); + text_node->SetString(kTextNodeType, kTextNodeTypeText); + text_node->SetString(kTextNodeText, line); + + base::ListValue* text_nodes = new base::ListValue(); + text_nodes->Append(text_node); + + base::DictionaryValue* line_node = new base::DictionaryValue(); + line_node->SetDouble(kTextBoxLeft, line_rect.x()); + line_node->SetDouble(kTextBoxTop, line_rect.y()); + line_node->SetDouble(kTextBoxWidth, line_rect.width()); + line_node->SetDouble(kTextBoxHeight, line_rect.height()); + line_node->SetDouble(kTextBoxFontSize, + FPDFText_GetFontSize(text_page, i)); + line_node->Set(kTextBoxNodes, text_nodes); + text->Append(line_node); + + line.clear(); + line_rect = pp::Rect(); + word_rect = pp::Rect(); + seen_literal_text_in_word = false; } + continue; + } + seen_literal_text_in_word = seen_literal_text_in_word || + !base::IsUnicodeWhitespace(character); + line.push_back(character); - std::string before_text = text_utf8.substr(start, pos - start); - if (!before_text.empty()) - text_nodes->Append(CreateTextNode(before_text)); - std::string link_text = text_utf8.substr(pos, length); - text_nodes->Append(CreateURLNode(link_text, target.url)); + if (!char_rect.IsEmpty()) { + line_rect = line_rect.Union(char_rect); - start = pos + length; + if (!base::IsUnicodeWhitespace(character)) + word_rect = word_rect.Union(char_rect); } - std::string before_text = text_utf8.substr(start); - if (!before_text.empty()) - text_nodes->Append(CreateTextNode(before_text)); - } else { - text_nodes->Append(CreateTextNode(text_utf8)); } - node->Set(kTextBoxNodes, text_nodes); // Takes ownership of |text_nodes|. - return node; -} - -base::Value* PDFiumPage::CreateTextNode(const std::string& text) { - base::DictionaryValue* node = new base::DictionaryValue(); - node->SetString(kTextNodeType, kTextNodeTypeText); - node->SetString(kTextNodeText, text); - return node; -} + node->Set(kPageTextBox, text.release()); // Takes ownership of |text| -base::Value* PDFiumPage::CreateURLNode(const std::string& text, - const std::string& url) { - base::DictionaryValue* node = new base::DictionaryValue(); - node->SetString(kTextNodeType, kTextNodeTypeURL); - node->SetString(kTextNodeText, text); - node->SetString(kTextNodeURL, url); return node; } @@ -276,7 +317,7 @@ PDFiumPage::Area PDFiumPage::GetCharIndex(const pp::Point& point, FPDF_LINK link = FPDFLink_GetLinkAtPoint(GetPage(), new_x, new_y); int control = - FPDPage_HasFormFieldAtPoint(engine_->form(), GetPage(), new_x, new_y); + FPDFPage_HasFormFieldAtPoint(engine_->form(), GetPage(), new_x, new_y); // If there is a control and link at the same point, figure out their z-order // to determine which is on top. diff --git a/chromium/pdf/pdfium/pdfium_page.h b/chromium/pdf/pdfium/pdfium_page.h index da30504b153..802ecb64e55 100644 --- a/chromium/pdf/pdfium/pdfium_page.h +++ b/chromium/pdf/pdfium/pdfium_page.h @@ -106,12 +106,6 @@ class PDFiumPage { Area GetLinkTarget(FPDF_LINK link, LinkTarget* target) const; // Returns target associated with a destination. Area GetDestinationTarget(FPDF_DEST destination, LinkTarget* target) const; - // Returns the text in the supplied box as a Value Node - base::Value* GetTextBoxAsValue(double page_height, double left, double top, - double right, double bottom, int rotation); - // Helper functions for JSON generation - base::Value* CreateTextNode(const std::string& text); - base::Value* CreateURLNode(const std::string& text, const std::string& url); class ScopedLoadCounter { public: diff --git a/chromium/pdf/preview_mode_client.cc b/chromium/pdf/preview_mode_client.cc index 7c74dabb9cd..f1c3e4a4ff0 100644 --- a/chromium/pdf/preview_mode_client.cc +++ b/chromium/pdf/preview_mode_client.cc @@ -138,8 +138,7 @@ void PreviewModeClient::DocumentLoadFailed() { } pp::Instance* PreviewModeClient::GetPluginInstance() { - NOTREACHED(); - return NULL; + return nullptr; } void PreviewModeClient::DocumentHasUnsupportedFeature( |